diff --git a/frontend/assets/course.css b/frontend/assets/course.css index 9b1c4d3c..aa6a1c1b 100644 --- a/frontend/assets/course.css +++ b/frontend/assets/course.css @@ -1,2 +1,2 @@ /* (c) Mathigon, generated by Mathigon Studio */ -@charset "UTF-8";article,aside,audio,canvas,details,figcaption,figure,footer,header,main,nav,section,summary,video{display:block}audio:not([controls]){display:none;height:0}html{-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;font-size:100%}template{display:none}svg{display:block;overflow:hidden}li svg,p svg,td svg{display:inline-block}circle,g,image,line,path,polyline,use{transform-box:fill-box;transform-origin:center}*{-webkit-tap-highlight-color:transparent;color:inherit;cursor:inherit}body,html{margin:0;padding:0}p{hanging-punctuation:first;margin:0 0 1em}h1{font-size:40px;font-weight:400}h2{font-size:28px}h2,h3{font-weight:600}h3{font-size:20px}h1,h2,h3,h4,h5,h6{color:inherit;font-weight:700;line-height:1.1;margin:2em 0 .8em;padding:0;text-rendering:optimizelegibility}a{cursor:pointer}a,a:hover{text-decoration:none}a,button{touch-action:manipulation}button{box-sizing:content-box;-webkit-user-select:none;-moz-user-select:none;user-select:none}.small,small{font-size:80%}.b,b,strong{font-weight:700}.i,dfn,em,i{font-style:italic}sub,sup{font-size:65%;line-height:0;margin:0 .1em;position:relative;vertical-align:baseline}sup{top:-.6em}sub{bottom:-.25em}.text-center{text-align:center}.text-right{text-align:right}.break{-webkit-hyphens:auto;hyphens:auto;word-break:break-all}.nowrap{white-space:nowrap}ol,ul{margin:0 0 1em 1.5em;padding:0;text-align:left}ol ol,ol ul,ul ol,ul ul{margin:.5em 0 0 1.5em}li{margin:0 0 .5em}ol.unstyled,ul.unstyled{list-style:none;margin:0}ol.unstyled li,ul.unstyled li{margin:0}hr{background:#aaa;clear:both;display:block;height:1px;margin:1em 0;padding:0}hr,img{border:0}img{-ms-interpolation-mode:bicubic;height:auto;max-width:100%;vertical-align:middle}figure{margin:0}blockquote{margin:1.5em 0}blockquote,q{font-style:italic}q{quotes:none}blockquote:after,blockquote:before,q:after,q:before{content:none}.hidden,[hidden]{display:none!important;visibility:hidden!important}table{border-collapse:collapse;border-spacing:0}table,td{border:none}td{vertical-align:top}table.fixed{table-layout:fixed}table.grid td{border-bottom:1px solid #c5c2cc;border-right:1px solid #c5c2cc}table.grid tr td:last-child{border-right:none}table.grid tr:last-child td{border-bottom:none}@media print{body,html{background:transparent;color:#000}h2,h3,p{orphans:3;widows:3}h1,h2,h3{page-break-after:avoid}p a,p a:visited{text-decoration:underline}p a[href]:after{content:" (" attr(href) ")"}blockquote,img,pre,tr{page-break-inside:avoid}img{max-width:100%!important}@page{margin:.5cm}}button,form,input,select,textarea{border:none;margin:0;padding:0}input:invalid{box-shadow:none}button,input,select,textarea{background:transparent;display:inline-block;font-family:inherit;font-size:inherit;font-weight:inherit}input[type=date],input[type=email],input[type=password],input[type=text],textarea{cursor:text}button,select{cursor:pointer}form.form-large{margin:0 auto;max-width:600px}.form-row{display:flex;flex-direction:row;flex-wrap:wrap}.form-row .form-field{flex-grow:1;width:180px}.form-large p{margin:0 8px 16px}.form-large .btn,.form-large .icon-btn,.form-large .next-step{margin:12px 8px}.form-field{display:block;padding:8px;position:relative}.form-field input,.form-field select,.form-field textarea,.form-field-style{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:no-repeat top 12px right 10px/24px 24px;background-color:#f6f6f6;border:1px solid rgba(0,0,0,.1);border-radius:4px;box-sizing:border-box;color:#000;display:block;line-height:1.4em;padding:18px 16px 4px;transition:border .2s,background .2s,box-shadow .2s;width:100%}html[theme=dark] .form-field input,html[theme=dark] .form-field select,html[theme=dark] .form-field textarea,html[theme=dark] .form-field-style{background-color:#43424d;border-color:hsla(0,0%,100%,.5);color:#fff}.form-field input:not([disabled]):focus,.form-field input:not([disabled]):hover,.form-field select:not([disabled]):focus,.form-field select:not([disabled]):hover,.form-field textarea:not([disabled]):focus,.form-field textarea:not([disabled]):hover,.form-field-style:not([disabled]):focus,.form-field-style:not([disabled]):hover{background-color:#eee}html[theme=dark] .form-field input:not([disabled]):focus,html[theme=dark] .form-field input:not([disabled]):hover,html[theme=dark] .form-field select:not([disabled]):focus,html[theme=dark] .form-field select:not([disabled]):hover,html[theme=dark] .form-field textarea:not([disabled]):focus,html[theme=dark] .form-field textarea:not([disabled]):hover,html[theme=dark] .form-field-style:not([disabled]):focus,html[theme=dark] .form-field-style:not([disabled]):hover{background-color:#64646d}.form-field input:not([disabled]):focus,.form-field select:not([disabled]):focus,.form-field textarea:not([disabled]):focus,.form-field-style:not([disabled]):focus{border-color:#0f82f2;box-shadow:0 0 0 3px rgba(15,130,242,.5);outline:none}.form-field input:not([disabled]):focus+.placeholder,.form-field select:not([disabled]):focus+.placeholder,.form-field textarea:not([disabled]):focus+.placeholder,.form-field-style:not([disabled]):focus+.placeholder{color:#0f82f2}.form-field input[disabled],.form-field select[disabled],.form-field textarea[disabled],.form-field-style[disabled]{cursor:default!important;opacity:.6}.form-field input.no-label,.form-field select.no-label,.form-field textarea.no-label,.form-field-style.no-label{background-position:top 5px right 10px;padding-top:4px}.form-field input::-moz-placeholder{opacity:0}.form-field input::placeholder{opacity:0}.form-field input:-moz-placeholder-shown{padding:11px 16px}.form-field input:placeholder-shown{padding:11px 16px}.form-field input:-moz-placeholder-shown+.placeholder{transform:none}.form-field input:placeholder-shown+.placeholder{transform:none}.form-field input.dirty:not(:focus){padding-right:36px}.form-field input.dirty:not(:focus).valid,.form-field input.dirty:not(:focus):valid{background-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22%2322ab24%22%20d%3D%22m19.7%206.3-.2-.4-.3-.2c-.1-.1-.3%200-.4%200a36.6%2036.6%200%200%200%20-9.8%208.4%2036.1%2036.1%200%200%200%20-4.8-2.9h-.5l-1%20.9a.4.4%200%200%200%20-.1.3c0%20.2%200%20.3.1.4a72.1%2072.1%200%200%201%206.6%207h.4a.5.5%200%200%200%20.4-.2c3.8-6.8%205.7-9.6%209.4-13%20.2.1.2-.1.2-.3z%22%2F%3E%3C%2Fsvg%3E")}.form-field input.dirty:not(:focus).invalid,.form-field input.dirty:not(:focus):invalid{background-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%3E%3Crect%20x%3D%2210%22%20y%3D%228%22%20width%3D%224%22%20height%3D%2212%22%20fill%3D%22%23fff%22%2F%3E%3Cpath%20fill%3D%22%23cd0e66%22%20d%3D%22M22.1%2C19.5l-9.2-16a1%2C1%2C0%2C0%2C0-1.8%2C0l-9.2%2C16A1%2C1%2C0%2C0%2C0%2C2.7%2C21H21.3A1%2C1%2C0%2C0%2C0%2C22.1%2C19.5Zm-8.7-11v2.4l-.4%2C4.4H11.1l-.4-4.4V8.5ZM12%2C19.4a1.6%2C1.6%2C0%2C0%2C1-1.6-1.6%2C1.6%2C1.6%2C0%2C1%2C1%2C3.2%2C0A1.6%2C1.6%2C0%2C0%2C1%2C12%2C19.4Z%22%2F%3E%3C%2Fsvg%3E");border-color:#cd0e66}.form-field textarea{height:auto;padding:10px 16px;resize:vertical}.form-field textarea::-moz-placeholder{color:#aaa;opacity:1;-moz-transition:color .2s;transition:color .2s}.form-field textarea::placeholder{color:#aaa;opacity:1;transition:color .2s}.form-field textarea:active::-moz-placeholder,.form-field textarea:focus::-moz-placeholder{color:#0f82f2}.form-field textarea:active::placeholder,.form-field textarea:focus::placeholder{color:#0f82f2}.form-field select{background-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22%234d4d4d%22%20d%3D%22m19.9%207.5a1.4%201.4%200%200%200%20-2.1%200l-5.8%205.8-5.8-5.8a1.4%201.4%200%200%200%20-2.1%200%201.5%201.5%200%200%200%200%202.1l6.8%206.9a1.6%201.6%200%200%200%202.2%200l6.8-6.9a1.4%201.4%200%200%200%200-2.1z%22%2F%3E%3C%2Fsvg%3E");padding-right:40px}.form-field .form-error,.form-field .form-hint{font-size:14px;line-height:1.3;margin:4px 17px 0}.form-field .form-error{color:#cd0e66}.form-field .placeholder{color:#aaa;left:24px;line-height:1.4em;pointer-events:none;position:absolute;top:19px;transform:translateY(-7px) scale(.7);transform-origin:top left;transition:transform .2s,color .2s;-webkit-user-select:none;-moz-user-select:none;user-select:none}.form-checkbox{cursor:pointer;display:block;margin:16px 8px;min-height:28px;padding-left:40px;position:relative}.form-checkbox input{left:5px;opacity:0;position:absolute;top:7px}.form-checkbox .control{background:#f6f6f6;border:1px solid rgba(0,0,0,.1);border-radius:4px;height:22px;left:0;position:absolute;top:2px;transition:border .2s,background .2s,box-shadow .2s;width:22px}.form-checkbox .control:after{background:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2221%22%20height%3D%2221%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22m19.7%206.3-.2-.4-.3-.2c-.1-.1-.3%200-.4%200a36.6%2036.6%200%200%200%20-9.8%208.4%2036.1%2036.1%200%200%200%20-4.8-2.9h-.5l-1%20.9a.4.4%200%200%200%20-.1.3c0%20.2%200%20.3.1.4a72.1%2072.1%200%200%201%206.6%207h.4a.5.5%200%200%200%20.4-.2c3.8-6.8%205.7-9.6%209.4-13%20.2.1.2-.1.2-.3z%22%2F%3E%3C%2Fsvg%3E");content:" ";display:block;height:21px;left:1px;position:absolute;top:0;transform:scale(0);transition:transform .4s cubic-bezier(.33,1.9,.52,.7);width:21px}.form-checkbox input:focus+.control,.form-checkbox:hover .control{background:#eee;border-color:#0f82f2}.form-checkbox input:focus+.control{box-shadow:0 0 0 3px rgba(15,130,242,.5);outline:none}.form-checkbox input:checked+.control{background:#0f82f2}.form-checkbox input:checked+.control:after{transform:none}.form-checkbox input:focus:checked+.control,.form-checkbox:hover input:checked+.control{border-color:#053563}.input-field{-webkit-appearance:none;-moz-appearance:textfield;border:1px solid;border-radius:4px;color:inherit;cursor:text;display:block;line-height:1.7em;padding:0;transition:border .2s,background .2s,box-shadow .2s,color .2s}.input-field:focus{border-color:#0f82f2;box-shadow:0 0 0 3px rgba(15,130,242,.5);outline:none}.input-field::-webkit-inner-spin-button,.input-field::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.btn,.icon-btn,.next-step{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:#181824;border:none;border-radius:24px;color:hsla(0,0%,100%,.95);cursor:pointer;display:inline-block;font-weight:600;height:2em;letter-spacing:.2px;line-height:2em;min-width:48px;outline:none;padding:0 1.2em;text-align:center;transition:background .2s,color .2s,box-shadow .2s;transition:transform .3s,background .2s,color .2s,box-shadow .2s,opacity .2s;width:auto}.btn.on,.btn:hover,.icon-btn:hover,.next-step:hover,.on.icon-btn,.on.next-step{box-shadow:0 4px 12px rgba(0,0,0,.25);color:#fff;z-index:10}.btn.disabled,.btn[disabled],.disabled.icon-btn,.disabled.next-step,[disabled].icon-btn,[disabled].next-step{box-shadow:none;cursor:default;pointer-events:none}.btn:hover,.icon-btn:hover,.next-step:hover{transform:scale(1.08)}.btn:active,.icon-btn:active,.next-step:active{transform:scale(.92)}.btn:active,.btn:hover,.icon-btn:active,.icon-btn:hover,.next-step:active,.next-step:hover{background-color:#504b5c}html.is-tabbing .btn:focus,html.is-tabbing .icon-btn:focus,html.is-tabbing .next-step:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #181824}.btn.disabled,.btn[disabled],.disabled.icon-btn,.disabled.next-step,[disabled].icon-btn,[disabled].next-step{background-color:#ddd!important;color:#999!important}.btn x-icon,.icon-btn x-icon,.next-step x-icon{fill:currentColor;margin:0 6px -6px 0;opacity:.95;transition:opacity .2s}.btn:active x-icon,.btn:hover x-icon,.icon-btn:active x-icon,.icon-btn:hover x-icon,.next-step:active x-icon,.next-step:hover x-icon{opacity:1}.btn-small{height:1.6em;line-height:1.6em;padding:0 .8em}.btn-large{font-size:22px;height:44px;line-height:44px;padding:0 20px}.btn-large x-icon{margin:0 10px -6px -2px}.btn-large .arrow{margin:0 -2px -1px 6px}.btn-row{margin:-10px}.btn-row .btn,.btn-row .icon-btn,.btn-row .next-step{margin:10px}.btn-red,.next-step{-webkit-touch-callout:none;background-color:#cd0e66;outline:none}.btn-red:focus,.btn-red:hover,.next-step:focus,.next-step:hover{background-color:#ef1579}html.is-tabbing .btn-red:focus,html.is-tabbing .next-step:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #ef1579}.btn-blue{-webkit-touch-callout:none;background-color:#0f82f2;outline:none}.btn-blue:focus,.btn-blue:hover{background-color:#3696f4}html.is-tabbing .btn-blue:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #3696f4}.btn-green{-webkit-touch-callout:none;background-color:#22ab24;outline:none}.btn-green:focus,.btn-green:hover{background-color:#29cd2b}html.is-tabbing .btn-green:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #29cd2b}.btn-yellow{-webkit-touch-callout:none;background-color:#fd8c00;outline:none}.btn-yellow:focus,.btn-yellow:hover{background-color:#ff9e27}html.is-tabbing .btn-yellow:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #ff9e27}.btn-grey{-webkit-touch-callout:none;background-color:#656073;outline:none}.btn-grey:focus,.btn-grey:hover{background-color:#797389}html.is-tabbing .btn-grey:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #797389}.btn-white{-webkit-touch-callout:none;outline:none}.btn-white,.btn-white:focus,.btn-white:hover{background-color:#fff}html.is-tabbing .btn-white:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #fff}.btn-white,.btn-white:active,.btn-white:hover{color:#3a3645}.btn.facebook,.facebook.icon-btn,.facebook.next-step{-webkit-touch-callout:none;background-color:#1878f2;outline:none}.btn.facebook:focus,.btn.facebook:hover,.facebook.icon-btn:focus,.facebook.icon-btn:hover,.facebook.next-step:focus,.facebook.next-step:hover{background-color:#3f8ff4}html.is-tabbing .btn.facebook:focus,html.is-tabbing .facebook.icon-btn:focus,html.is-tabbing .facebook.next-step:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #3f8ff4}.btn.twitter,.twitter.icon-btn,.twitter.next-step{-webkit-touch-callout:none;background-color:#00b6f1;outline:none}.btn.twitter:focus,.btn.twitter:hover,.twitter.icon-btn:focus,.twitter.icon-btn:hover,.twitter.next-step:focus,.twitter.next-step:hover{background-color:#1bc7ff}html.is-tabbing .btn.twitter:focus,html.is-tabbing .twitter.icon-btn:focus,html.is-tabbing .twitter.next-step:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #1bc7ff}.btn.youtube,.youtube.icon-btn,.youtube.next-step{-webkit-touch-callout:none;background-color:red;outline:none}.btn.youtube:focus,.btn.youtube:hover,.youtube.icon-btn:focus,.youtube.icon-btn:hover,.youtube.next-step:focus,.youtube.next-step:hover{background-color:#ff2929}html.is-tabbing .btn.youtube:focus,html.is-tabbing .youtube.icon-btn:focus,html.is-tabbing .youtube.next-step:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #ff2929}.btn.instagram,.instagram.icon-btn,.instagram.next-step{-webkit-touch-callout:none;background-color:#bc2a8d;outline:none}.btn.instagram:focus,.btn.instagram:hover,.instagram.icon-btn:focus,.instagram.icon-btn:hover,.instagram.next-step:focus,.instagram.next-step:hover{background-color:#d33ba2}html.is-tabbing .btn.instagram:focus,html.is-tabbing .instagram.icon-btn:focus,html.is-tabbing .instagram.next-step:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #d33ba2}.btn.pinterest,.pinterest.icon-btn,.pinterest.next-step{-webkit-touch-callout:none;background-color:#cb2027;outline:none}.btn.pinterest:focus,.btn.pinterest:hover,.pinterest.icon-btn:focus,.pinterest.icon-btn:hover,.pinterest.next-step:focus,.pinterest.next-step:hover{background-color:#df353c}html.is-tabbing .btn.pinterest:focus,html.is-tabbing .pinterest.icon-btn:focus,html.is-tabbing .pinterest.next-step:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #df353c}.btn.tumblr,.tumblr.icon-btn,.tumblr.next-step{-webkit-touch-callout:none;background-color:#35465d;outline:none}.btn.tumblr:focus,.btn.tumblr:hover,.tumblr.icon-btn:focus,.tumblr.icon-btn:hover,.tumblr.next-step:focus,.tumblr.next-step:hover{background-color:#445a77}html.is-tabbing .btn.tumblr:focus,html.is-tabbing .tumblr.icon-btn:focus,html.is-tabbing .tumblr.next-step:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #445a77}.btn.reddit,.reddit.icon-btn,.reddit.next-step{-webkit-touch-callout:none;background-color:#ff5700;outline:none}.btn.reddit:focus,.btn.reddit:hover,.reddit.icon-btn:focus,.reddit.icon-btn:hover,.reddit.next-step:focus,.reddit.next-step:hover{background-color:#ff7229}html.is-tabbing .btn.reddit:focus,html.is-tabbing .reddit.icon-btn:focus,html.is-tabbing .reddit.next-step:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #ff7229}.btn.microsoft,.microsoft.icon-btn,.microsoft.next-step{-webkit-touch-callout:none;background-color:#2f2f2f;outline:none}.btn.microsoft:focus,.btn.microsoft:hover,.microsoft.icon-btn:focus,.microsoft.icon-btn:hover,.microsoft.next-step:focus,.microsoft.next-step:hover{background-color:#434343}html.is-tabbing .btn.microsoft:focus,html.is-tabbing .microsoft.icon-btn:focus,html.is-tabbing .microsoft.next-step:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #434343}.btn.google,.google.icon-btn,.google.next-step{background:#fff;box-shadow:inset 0 0 0 1px #aaa;color:#3a3645}.btn.google:hover,.google.icon-btn:hover,.google.next-step:hover{box-shadow:inset 0 0 0 1px #aaa,0 4px 12px rgba(0,0,0,.25)}html.is-tabbing .btn.google:focus,html.is-tabbing .google.icon-btn:focus,html.is-tabbing .google.next-step:focus{box-shadow:inset 0 0 0 1px #aaa,0 0 0 2px #fff,0 0 0 4px #656073}.icon-btn{border-radius:20px;display:block;height:40px;min-width:40px;padding:0}.icon-btn x-icon{display:block;margin:8px}@font-face{font-family:Mathigon Symbol;font-style:normal;font-weight:400;src:url(/fonts/mathigon-symbol.woff2) format("woff2"),url(/fonts/mathigon-symbol.woff) format("woff")}.math,math{display:inline-block;font-style:normal;font-weight:400;margin:0 .1em}.nowrap .math,.nowrap math{margin-right:0}mfenced,mfrac,mi,mn,mo,mroot,mrow,ms,msqrt,msub,msup,mtext{display:inline-block;font-family:Mathigon Symbol,Source Sans Pro,sans-serif;font-size:inherit;line-height:1;white-space:nowrap}mi[mathvariant=normal]{font-family:Source Sans Pro,sans-serif}mi{line-height:.9}mo{margin:0 .25em}mn+.cursor+mi,mn+mi{margin-left:.1em}mi+mi{margin-left:.05em}mfrac+.coursor+mi,mfrac+.cursor+mtext,mfrac+mi,mfrac+mtext{margin-left:.15em}mo[value=−]:first-child{margin:0 .1em}mo[value="="],mo[value=≈]{margin:0 .4em}mo[value=∡],mo[value=△]{margin:0}.cursor:first-child+mo,mn+mo[value=…],mo+.cursor+mo,mo+.cursor+mo[value],mo+mo,mo+mo[value],mo:first-child,mo[lspace="0"],mo[value=°],mo[value=’]{margin-left:0}mo:last-child,mo[rspace="0"]{margin-right:0}mtext{font-family:Source Sans Pro,Helvetica,sans-serif}mspace{padding:0 .2em}mphantom{visibility:hidden}ms:after,ms:before{content:'"'}ms[lquote]:before{content:attr(lquote)}ms[rquote]:after{content:attr(rquote)}msubsup>:nth-child(3),msup>:last-child{font-size:67%;margin:-.2em .1em 0 .15em;vertical-align:top}msub>:last-child,msubsup>:nth-child(2){font-size:67%;margin:0 .1em -.2em;vertical-align:bottom}mfrac,msub>:last-child mo,msubsup>:nth-child(3) mo,msup>:last-child mo{margin:0 .1em}mfrac{font-size:.6em;vertical-align:-.2em}mfrac>*{display:block;text-align:center}mfrac>:first-child{padding-bottom:.06em}mfrac>:last-child{border-top:1px solid;float:right;padding-top:.06em;width:100%}mfrac:after{content:" ";visibility:hidden;width:0}.display mfrac,.text-center:not(.inline) mfrac,table mfrac{font-size:1em;vertical-align:-.45em}.display mfrac mfrac,.text-center:not(.inline) mfrac mfrac,mfrac mfrac{font-size:75%;vertical-align:-.25em}mroot,msqrt{border-top:1px solid;margin-left:9px;padding:.1em .1em 0 .2em;position:relative}mroot:before,msqrt:before{background:currentColor;bottom:0;content:"";left:-11px;-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2213%22%20height%3D%2222%22%3E%3Cpath%20d%3D%22M3%2C11.72l-1.56.7-.42-1%2C2.93-1.3%2C2.55%2C7.61c.15.46.26.95.37%2C1.41h.09c.09-.46.18-.95.26-1.41L11.12%2C1h1.32L7.67%2C21.13H6.28Z%22%2F%3E%3C%2Fsvg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2213%22%20height%3D%2222%22%3E%3Cpath%20d%3D%22M3%2C11.72l-1.56.7-.42-1%2C2.93-1.3%2C2.55%2C7.61c.15.46.26.95.37%2C1.41h.09c.09-.46.18-.95.26-1.41L11.12%2C1h1.32L7.67%2C21.13H6.28Z%22%2F%3E%3C%2Fsvg%3E");-webkit-mask-size:100% 100%;mask-size:100% 100%;position:absolute;top:-2px;width:13px}mroot>:last-child{font-size:67%;margin-top:-5px;position:absolute;right:calc(100% + 5px)}mfenced{margin:0 calc(5px + .1em);padding:.05em .1em;position:relative}mfenced:after,mfenced:before{bottom:-1px;content:"";top:-1px;width:5px}mfenced:before{left:-4px;-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%225%22%20height%3D%2222%22%3E%3Cpath%20d%3D%22M0%2C11A18.32%2C18.32%2C0%2C0%2C1%2C2.91%2C1L4%2C1.53A18.32%2C18.32%2C0%2C0%2C0%2C1.5%2C11%2C18.33%2C18.33%2C0%2C0%2C0%2C4%2C20.47L2.91%2C21A18.32%2C18.32%2C0%2C0%2C1%2C0%2C11Z%22%2F%3E%3C%2Fsvg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%225%22%20height%3D%2222%22%3E%3Cpath%20d%3D%22M0%2C11A18.32%2C18.32%2C0%2C0%2C1%2C2.91%2C1L4%2C1.53A18.32%2C18.32%2C0%2C0%2C0%2C1.5%2C11%2C18.33%2C18.33%2C0%2C0%2C0%2C4%2C20.47L2.91%2C21A18.32%2C18.32%2C0%2C0%2C1%2C0%2C11Z%22%2F%3E%3C%2Fsvg%3E")}mfenced:after,mfenced:before{background:currentColor;-webkit-mask-size:100% 100%;mask-size:100% 100%;position:absolute}mfenced:after{-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%225%22%20height%3D%2222%22%3E%3Cpath%20d%3D%22M1%2C20.47A18.33%2C18.33%2C0%2C0%2C0%2C3.5%2C11%2C18.32%2C18.32%2C0%2C0%2C0%2C1%2C1.53L2.09%2C1A18.32%2C18.32%2C0%2C0%2C1%2C5%2C11%2C18.32%2C18.32%2C0%2C0%2C1%2C2.09%2C21Z%22%2F%3E%3C%2Fsvg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%225%22%20height%3D%2222%22%3E%3Cpath%20d%3D%22M1%2C20.47A18.33%2C18.33%2C0%2C0%2C0%2C3.5%2C11%2C18.32%2C18.32%2C0%2C0%2C0%2C1%2C1.53L2.09%2C1A18.32%2C18.32%2C0%2C0%2C1%2C5%2C11%2C18.32%2C18.32%2C0%2C0%2C1%2C2.09%2C21Z%22%2F%3E%3C%2Fsvg%3E");right:-4px}mfenced[open="|"]{border-left:1px solid;border-right:1px solid;margin:0 .1em;padding:0 .1em}mfenced[open="|"]:after,mfenced[open="|"]:before{content:none}mfenced[open="["]:before{content:"["}mfenced[close="]"]:after{content:"]"}mfenced[open="{"]:before{content:"{"}mfenced[close="}"]:after{content:"}"}mover,munder{position:relative}mover>:nth-child(2){font-size:0;height:5px;left:0;position:absolute;right:0}mover>[value=‾]:nth-child(2){-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2221%22%20height%3D%225%22%3E%3Cpath%20d%3D%22M0%2C2L21%2C2L21%2C3L0%2C3Z%22%2F%3E%3C%2Fsvg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2221%22%20height%3D%225%22%3E%3Cpath%20d%3D%22M0%2C2L21%2C2L21%2C3L0%2C3Z%22%2F%3E%3C%2Fsvg%3E");top:0}mover>[value=‾]:nth-child(2),mover>[value=→]:nth-child(2){background:currentColor;-webkit-mask-size:100% 100%;mask-size:100% 100%;position:absolute}mover>[value=→]:nth-child(2){-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2221%22%20height%3D%225%22%3E%3Cpath%20d%3D%22M21%2C2.5L15.7%2C0.3L16.5%2C2L0%2C2L0%2C3L16.5%2C3L15.7%2C4.7L21%2C2.5Z%22%2F%3E%3C%2Fsvg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2221%22%20height%3D%225%22%3E%3Cpath%20d%3D%22M21%2C2.5L15.7%2C0.3L16.5%2C2L0%2C2L0%2C3L16.5%2C3L15.7%2C4.7L21%2C2.5Z%22%2F%3E%3C%2Fsvg%3E");top:-2px}mover>[value=↔]:nth-child(2){-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2221%22%20height%3D%225%22%3E%3Cpath%20d%3D%22M21%2C2.5L15.7%2C0.3L16.5%2C2L4.5%2C2L5.3%2C0.3L0%2C2.5L5.3%2C4.7L4.5%2C3L16.5%2C3L15.7%2C4.7L21%2C2.5Z%22%2F%3E%3C%2Fsvg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2221%22%20height%3D%225%22%3E%3Cpath%20d%3D%22M21%2C2.5L15.7%2C0.3L16.5%2C2L4.5%2C2L5.3%2C0.3L0%2C2.5L5.3%2C4.7L4.5%2C3L16.5%2C3L15.7%2C4.7L21%2C2.5Z%22%2F%3E%3C%2Fsvg%3E")}mover>[value=↔]:nth-child(2),mover>[value=⌒]:nth-child(2){background:currentColor;-webkit-mask-size:100% 100%;mask-size:100% 100%;position:absolute;top:-2px}mover>[value=⌒]:nth-child(2){-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2221%22%20height%3D%225%22%3E%3Cpath%20d%3D%22M20.5%2C4.5a.52.52%2C0%2C0%2C1-.29-.09A17.1%2C17.1%2C0%2C0%2C0%2C10.5%2C1.5%2C17.1%2C17.1%2C0%2C0%2C0%2C.79%2C4.41a.5.5%2C0%2C0%2C1-.7-.13.5.5%2C0%2C0%2C1%2C.12-.69A18.22%2C18.22%2C0%2C0%2C1%2C10.5.5%2C18.22%2C18.22%2C0%2C0%2C1%2C20.79%2C3.59a.5.5%2C0%2C0%2C1%2C.12.69A.5.5%2C0%2C0%2C1%2C20.5%2C4.5Z%22%2F%3E%3C%2Fsvg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2221%22%20height%3D%225%22%3E%3Cpath%20d%3D%22M20.5%2C4.5a.52.52%2C0%2C0%2C1-.29-.09A17.1%2C17.1%2C0%2C0%2C0%2C10.5%2C1.5%2C17.1%2C17.1%2C0%2C0%2C0%2C.79%2C4.41a.5.5%2C0%2C0%2C1-.7-.13.5.5%2C0%2C0%2C1%2C.12-.69A18.22%2C18.22%2C0%2C0%2C1%2C10.5.5%2C18.22%2C18.22%2C0%2C0%2C1%2C20.79%2C3.59a.5.5%2C0%2C0%2C1%2C.12.69A.5.5%2C0%2C0%2C1%2C20.5%2C4.5Z%22%2F%3E%3C%2Fsvg%3E")}.snackbar{left:50%;position:fixed;top:52px;transform:translateX(-50%);z-index:500}x-alert{background:#000;border-radius:6px;box-shadow:0 3px 8px rgba(0,0,0,.3);color:#fff;display:none;font-size:16px;line-height:1.4;max-width:300px;padding:8px 20px;width:-moz-max-content;width:max-content}x-alert x-icon{float:left;margin:-2px 6px 20px -4px}x-alert.error{background:#b50c5a}x-alert.warn{background:#e47e00}x-alert.success{background:#1e9620}x-icon{fill:currentColor;display:inline-block;height:24px;width:24px}x-icon svg{display:block}x-icon[name=warning]{fill:#cd0e66}.button x-icon{margin:-10px 3px -10px -8px}.modal-background{-webkit-backdrop-filter:blur(4px);background:rgba(0,0,0,.8);bottom:0;display:none;left:0;position:fixed;right:0;top:44px;transition:background .4s;z-index:400}.modal-background.light{background:hsla(0,0%,100%,.9)}html.webview .modal-background{top:0}x-modal{background:#fff;border-radius:12px;box-shadow:0 6px 32px rgba(0,0,0,.8);box-sizing:border-box;display:none;left:50%;margin-top:22px;max-height:calc(100vh - 84px);max-width:calc(100% - 40px);position:fixed;top:50%;transform:translate(-50%,-50%);width:520px;z-index:401}html[theme=dark] x-modal{background:#2d2c38}x-modal.light{box-shadow:0 4px 20px rgba(0,0,0,.25)}html.webview x-modal{margin-top:0;max-height:calc(100% - 40px)}x-modal .modal-body{-webkit-overflow-scrolling:touch;box-sizing:border-box;height:100%;max-height:calc(100vh - 84px);overflow:auto;overscroll-behavior:contain;padding:24px}@media screen and (max-height:720px){x-modal.interactive{top:42px;transform:translate(-50%)}}.is-safari:not(.is-webview) x-modal,.is-safari:not(.is-webview) x-modal .modal-body{max-height:calc(100vh - 200px)}x-modal h2{margin-top:0}x-modal h2 x-icon{margin:-6px 4px -6px -2px}x-modal h3{margin:1.5em 0 .8em}x-modal h3 x-icon{margin:0 5px -5px 0}x-modal .btn-row{margin:0;text-align:right}x-modal .form-large{margin:0 -8px -10px}x-modal p:last-child:not(.btn-row),x-modal ul:last-child{margin-bottom:0}x-modal .form-checkbox{margin:16px 0}x-modal hr{margin:1.5em 0}x-modal .close{fill:rgba(0,0,0,.4);cursor:pointer;display:block;padding:8px;position:absolute;right:0;top:0;transition:transform .2s,color .2s;z-index:10}html[theme=dark] x-modal .close{fill:hsla(0,0%,100%,.4)}x-modal .close:hover{color:#000;transform:scale(1.4)}html[theme=dark] x-modal .close:hover{color:#fff}x-modal.video{background:#000;border-radius:0;width:1200px}x-modal.video .video-wrap{height:0;padding-bottom:56.25%;position:relative}x-modal.video iframe,x-modal.video video{height:100%;position:absolute;width:100%}x-modal.video .close x-icon{fill:hsla(0,0%,100%,.8);top:-40px}header{background:#181824;box-shadow:0 0 12px rgba(0,0,0,.25);color:#fff;display:flex;height:44px;justify-content:space-between;position:fixed;top:0;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:100%;z-index:450}header #logo,header .nav-link{display:block;font-size:18px;height:44px;line-height:44px}header #logo{box-sizing:border-box;margin-right:-12px;padding:4px 4px 4px 16px}header #logo img,header #logo svg{float:left;height:36px;width:auto}header #logo span{display:inline-block;float:left;line-height:36px;margin:0 8px}header #skip-nav{background:#3a3645;border:2px solid #181824;border-radius:30px;height:32px;left:-9999px;padding:2px 18px;position:absolute;top:2px;z-index:9999}html.is-tabbing header #skip-nav:focus{left:2px}header nav{display:flex}header .nav-link{cursor:pointer;opacity:.8;padding:0 16px;transition:opacity .2s,background .2s}header .nav-link:focus,header .nav-link:hover{background:#4b4757;opacity:1}header .nav-link x-icon{margin:0 8px -6px -2px;vertical-align:baseline}header .nav-link.narrow{padding:0 12px}header .nav-link.narrow x-icon{display:block;margin:0}header .nav-link.popup-target{padding-right:18px}header .nav-item.open .nav-link{background:#4b4757;opacity:1}header .nav-user-icon{border:1px solid hsla(0,0%,100%,.5);border-radius:100%;display:block;height:28px;width:28px}header .popup-body{-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);background:rgba(24,24,36,.91);background-clip:content-box;border-bottom:1px solid hsla(0,0%,100%,.3);border-left:1px solid hsla(0,0%,100%,.3);border-radius:0 0 0 6px;display:none;position:absolute;right:0;top:44px}header .popup-body .nav-link{box-sizing:border-box;color:hsla(0,0%,100%,.8);padding:0 18px;position:relative;text-align:left;transition:background .2s,color .2s;white-space:nowrap;width:100%}header .popup-body .nav-link:before{background:hsla(0,0%,100%,.4);content:" ";display:block;height:1px;position:absolute;top:0;transition:background-color .2s;width:calc(100% - 36px)}header .popup-body .nav-link:first-child:before{display:none}header .popup-body .nav-link.active,header .popup-body .nav-link.on,header .popup-body .nav-link:focus,header .popup-body .nav-link:hover{background:hsla(0,0%,100%,.2);color:#fff}header .popup-body .nav-link.active+:before,header .popup-body .nav-link.active:before,header .popup-body .nav-link.on+:before,header .popup-body .nav-link.on:before,header .popup-body .nav-link:focus+:before,header .popup-body .nav-link:focus:before,header .popup-body .nav-link:hover+:before,header .popup-body .nav-link:hover:before{background:transparent}header .popup-body .nav-link.active,header .popup-body .nav-link.on{background:hsla(0,0%,100%,.32)}header .popup-body .nav-link.logout{max-width:300px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}header .popup-body .nav-link:last-child{border-radius:0 0 0 6px}header .popup-body .nav-link img{float:right;margin:10px 2px 0 12px}header .popup-body .nav-link .form-checkbox{float:right;margin:8px 2px 0 12px;padding-left:24px}@media (max-width:840px){header .nav-link{padding:0 12px}header .nav-link.narrow{padding:0 10px}header .nav-link x-icon{margin-right:6px}}@media (max-width:760px){header .nav-item>.nav-link{height:36px;padding:4px 8px}header .nav-item>.nav-link x-icon{display:block;height:24px;margin:0 auto;width:24px}header .nav-text{display:block;font-size:10px;line-height:12px;text-align:center}}x-modal#language{-webkit-user-select:none;-moz-user-select:none;user-select:none;width:540px}.locale-list{-moz-column-count:3;column-count:3}@media (max-width:560px){.locale-list{-moz-column-count:2;column-count:2}}@media (max-width:420px){.locale-list{-moz-column-count:1;column-count:1}}.locale-link{-webkit-column-break-inside:avoid;border-radius:6px;display:block;margin:2px 0;overflow:hidden;padding:4px 8px;text-overflow:ellipsis;transition:background .2s;white-space:nowrap}.locale-link:hover{background:#e2e1e6}html[theme=dark] .locale-link:hover{background:hsla(0,0%,100%,.2)}.locale-link img{margin-right:8px}#search{width:480px}#search .modal-body{overflow:visible;padding:12px}#search .form-field{padding:0}#search .form-field input{border-radius:40px;font-size:24px;line-height:32px;padding:8px 16px 8px 48px}#search .form-field input::-moz-placeholder{color:inherit;opacity:.5}#search .form-field input::placeholder{color:inherit;opacity:.5}#search .form-field input:focus{box-shadow:0 0 0 3px #87c1f9}#search .form-field x-icon{fill:currentColor;left:13px;position:absolute;top:11px}#search .search-body{max-height:calc(100vh - 160px);min-height:180px;overflow:auto;padding:8px 8px 6px 48px}#search .search-body:after,#search .search-body:before{clear:both;content:" ";display:table}@media screen and (max-width:420px){#search .search-body{padding-left:8px}}#search .search-section{font-size:14px;font-weight:600;text-transform:uppercase}#search .search-result{border-radius:6px;display:block;height:48px;line-height:1.2;margin:0 -6px;padding:6px;transition:background .2s}#search .search-result:focus,#search .search-result:hover{background:#e2e1e6}html[theme=dark] #search .search-result:focus,html[theme=dark] #search .search-result:hover{background:hsla(0,0%,100%,.2)}#search .search-img{background:#000 50%;background-size:cover;border-radius:4px;box-shadow:inset 0 0 0 1px rgba(0,0,0,.2);float:left;height:48px;margin-right:10px;width:48px}#search .search-subtitle{color:#aaa;font-size:14px;margin-top:4px}#search .search-subtitle,#search .search-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#search .search-title{font-size:20px;font-weight:600}#search .search-gloss{background:#fed199;border-radius:6px;font-size:16px;line-height:1.4;margin:6px 0;padding:8px 14px}#search .search-gloss:after,#search .search-gloss:before{clear:both;content:" ";display:table}#search .search-gloss img{border:0;float:right;margin:0 -12px 0 0;width:160px}#search .search-gloss .math,#search .search-gloss x-math{white-space:nowrap}#search .search-gloss li,#search .search-gloss p,#search .search-gloss ul{margin-bottom:.3em}#search .search-gloss li:last-child,#search .search-gloss p:last-child,#search .search-gloss ul:last-child{margin-bottom:0}#search .no-results{color:#aaa;margin-top:32px;padding-right:32px;text-align:center}@media screen and (max-width:420px){#search .no-results{padding:0}}#search .no-results x-icon{fill:#aaa;display:block;margin:0 auto}.global-footer{border-top:1px solid #ccc;color:#aaa;display:flex;font-size:15px;margin:50px 0 40px;padding-top:6px}.global-footer .footer-left{flex-grow:1}.global-footer .footer-right{text-align:right}.global-footer .footer-row{margin:4px 0}.global-footer button{cursor:pointer;line-height:inherit;margin-left:24px;position:relative}.global-footer button img{left:-24px;position:absolute;top:2px}.global-footer .dot{display:inline-block;margin:0 8px}.global-footer .footer-left a,.global-footer button{background-image:linear-gradient(transparent calc(100% - 2px),currentColor calc(100% - 2px),currentColor calc(100% - 1px),transparent calc(100% - 1px));background-repeat:no-repeat;background-size:0 100%;display:inline-block;transition:color .2s,background-size .2s ease-in-out}.global-footer .footer-left a:hover,.global-footer button:hover{background-size:100% 100%;color:#333}html[theme=dark] .global-footer .footer-left a:hover,html[theme=dark] .global-footer button:hover{color:#fff}.global-footer .footer-social{color:#aaa;display:inline-block;margin:-5px 0 -11px;padding:6px 3px;transition:color .2s}.global-footer .footer-social x-icon{display:block}.global-footer .footer-social:hover{color:#333}html[theme=dark] .global-footer .footer-social:hover{color:#fff}@media (max-width:760px){.global-footer{display:block;font-size:16px;margin-bottom:30px}.global-footer .footer-left,.global-footer .footer-right{text-align:center}.global-footer .footer-row{margin-bottom:10px}.global-footer .footer-social{padding:6px}.global-footer .footer-social svg{height:28px;margin:0 4px;width:28px}.global-footer button img{height:20px;left:-26px;top:3px;width:20px}}.course{border-top:1px solid #c5c2cc;-moz-column-count:2;column-count:2;-moz-column-gap:10px;column-gap:10px;min-height:80px;padding:18px 0 18px 90px;position:relative}@media screen and (max-width:660px){.course{-moz-column-count:1;column-count:1}}.course .course-img{background-size:cover;border-radius:6px;height:80px;left:0;position:absolute;top:18px;width:80px}.course h3{-moz-column-span:all;column-span:all;margin:0 0 8px 8px}.course h3 img{margin:-4px 0 0 8px}.course .course-banner{border-radius:20px;color:#fff;float:right;font-size:14px;font-weight:400;margin:0 0 4px 6px;padding:2px 10px}.course .course-section{-moz-column-break-inside:avoid;border-radius:4px;break-inside:avoid;font-size:16px;line-height:1.2;padding:7px 8px 7px 34px;page-break-inside:avoid}.course .course-section.locked{color:#aaa;position:relative}.course .course-section.locked .tooltip{background:#656073;left:auto;padding:1px 10px;right:0;top:7px;transform:none}.course a.course-section{display:block;outline:none;transition:background .2s}.course a.course-section:focus,.course a.course-section:hover{background:#e2e1e6}html[theme=dark] .course a.course-section:focus,html[theme=dark] .course a.course-section:hover{background:hsla(0,0%,100%,.2)}.course .course-section.locked x-icon,.course x-progress{fill:#c5c2cc;display:inline-block;margin:0 6px -4px -26px}html{background-color:#fff;cursor:default;font-family:Source Sans Pro,Helvetica,sans-serif;font-size:18px;line-height:1.6;min-width:320px;touch-action:manipulation}html[theme=dark]{background:#22212e}html:not(.ready) *{animation:none!important;transition:none!important}html:not(.is-tabbing) :focus{outline:none!important}html.grabbing,html.grabbing *{cursor:grabbing!important}body{color:#333}html[theme=dark] body{color:hsla(0,0%,100%,.9)}main{padding-top:44px}html.webview main{padding-top:0}.container{margin:0 auto;max-width:calc(100% - 48px);position:relative;width:1000px}.container.narrow{width:800px}.container.wide{width:1200px}.panel.narrow{margin:0 auto;max-width:800px}svg.mathjax{display:inline-block}svg.mathjax g,svg.mathjax path,svg.mathjax use{transform-box:initial;transform-origin:0 0}.is-mobile .only-desktop,.not-mobile .only-mobile,.not-touch .only-touch{display:none!important}@media screen and (max-width:480px){.xs-hide{display:none!important}}@media screen and (max-width:640px){.s-hide{display:none!important}}@media screen and (min-width:641px){.l-hide{display:none!important}}@media screen and (min-width:801px){.xl-hide{display:none!important}}.invert{filter:none}html[theme=dark] .invert{filter:invert(1)}.r{position:relative}.column,.row{display:flex;flex-wrap:wrap;justify-content:center}.column{flex-direction:column}.row.right{flex-direction:row-reverse}.column.padded,.row.padded{margin:-24px}.column.padded>*,.row.padded>*{margin:24px}.column.padded-thin,.row.padded-thin{margin:-12px}.column.padded-thin>*,.row.padded-thin>*{margin:12px}.column .grow,.row .grow{flex-grow:1}.column .shrink,.row .shrink{flex-shrink:1}.row>*>h2:first-child,.row>*>h3:first-child{margin-top:0}.padded-thin>*>p:last-child,.padded>*>p:last-child{margin-bottom:0}.text-medium{color:#999}button.a,label a,ol a,p a,ul a{background-image:linear-gradient(transparent calc(100% - 3px),currentColor calc(100% - 3px),currentColor calc(100% - 1px),transparent calc(100% - 1px));background-repeat:no-repeat;background-size:0 100%;color:#0f82f2;transition:color .2s,background-size .2s ease-in-out}button.a:hover,label a:hover,ol a:hover,p a:hover,ul a:hover{background-size:100% 100%}.caption{color:#888;font-size:80%;margin:0 0 .6em;text-align:left}.emoji{display:inline-block;font-size:inherit;height:20px;line-height:normal;margin:-4px 2px 0;vertical-align:middle;width:20px}img.emoji{width:auto}.tooltip{-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);background:#181824;border:1px solid #fff;border-radius:16px;color:#fff;font-size:14px;left:50%;line-height:18px;opacity:0;padding:2px 12px;pointer-events:none;position:absolute;top:-22px;transform:translateX(-50%);transition:opacity .1s;white-space:nowrap;z-index:9999}.is-tabbing.not-mobile :focus>.tooltip,.not-mobile :hover>.tooltip{opacity:.8}.alert{background:rgba(253,140,0,.4);border-radius:4px;margin-bottom:2em;padding:12px 44px 12px 20px;position:relative}.alert.fail{background:rgba(205,14,102,.4)}.alert.success{background:rgba(34,171,36,.4)}.alert p:last-child{margin:0}.alert .close{cursor:pointer;font-size:30px;font-weight:700;opacity:.6;padding:0 13px;position:absolute;right:0;top:0}.alert .close:hover{opacity:1}.warning{background:#181824 url(/images/tiles.png);background-size:240px 240px;bottom:0;display:block;left:0;position:fixed;right:0;top:0;z-index:900}.warning-body{left:50%;max-width:calc(100% - 48px);position:absolute;top:50%;transform:translate(-50%,-50%)}.warning-body svg{height:100px;margin:0 auto 20px;width:100px}.warning-body p{background:#cd0e66;border-radius:4px;color:#fff;padding:8px 16px;text-align:center}.warning-body a:hover{color:#3f9bf5}.cookie-warning{background:#b50c5a;border-radius:4px;bottom:10px;box-shadow:0 3px 6px rgba(0,0,0,.3);box-sizing:border-box;color:#fff;left:10px;line-height:1.4;max-width:calc(100vw - 20px);padding:10px 16px 12px;position:fixed;z-index:800}.cookie-warning h2{color:hsla(0,0%,100%,.8);font-size:24px;font-weight:100;margin:0 0 6px}.cookie-warning p{margin-bottom:12px}.cookie-warning .btn,.cookie-warning .icon-btn,.cookie-warning .next-step{color:#b50c5a}.cookie-warning .close{cursor:pointer;opacity:.6;padding:12px;position:absolute;right:2px;top:2px;transition:opacity .2s}.cookie-warning .close:hover{opacity:1}.cookie-warning x-icon{display:block}x-blank,x-blank-mc{display:inline-block;position:relative}x-blank-mc.done,x-blank.done{display:inline;white-space:normal}x-blank .target,x-blank-mc .target{-webkit-touch-callout:none;background:transparent;background:#0f82f2;border-radius:6px;color:#fff;cursor:pointer;display:inline-block;line-height:28px;margin:-3px 2px;padding:0 6px;position:relative;text-align:center;transition:border-radius .2s,background .2s,color .2s,margin .2s,padding .2s,width .2s,min-width .2s,box-shadow .2s}.caption x-blank .target,.caption x-blank-mc .target{height:24px;line-height:24px}x-blank .target:before,x-blank-mc .target:before{background:none;bottom:1px;content:" ";height:3px;left:5px;position:absolute;right:5px}x-blank-mc.on .target,x-blank-mc:hover .target,x-blank.on .target,x-blank:hover .target{box-shadow:0 0 10px rgba(0,0,0,.2)}mfrac x-blank .target,mfrac x-blank-mc .target{margin:0 2px}mfrac x-blank-mc.done .target,mfrac x-blank.done .target{line-height:1}x-blank-mc.invalid .target:before,x-blank.invalid .target:before{background:#cd0e66;border-radius:5px 0 0 5px;bottom:0;color:#fff;content:"×";display:block;font-weight:700;height:auto;left:0;line-height:1;padding:4px 0 3px;position:absolute;text-align:center;top:0;width:20px}x-blank-mc.done .target,x-blank.done .target{background:transparent;background-image:none;box-shadow:none;color:#0f82f2;cursor:default;display:inline;margin:0;min-width:0;padding:1px 0 0}x-blank-mc.done:hover .target,x-blank.done:hover .target{color:#0f82f2}x-blank .target{cursor:text;padding:0}x-blank.invalid .target{padding-left:20px}x-blank input{background:none!important;color:inherit;margin:0;min-width:60px;text-align:center;width:40px}x-blank input:focus{color:#fff}html.is-tabbing x-blank input:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #0f82f2;outline:none}x-blank ::-webkit-input-placeholder{color:inherit!important;opacity:1!important}x-blank :-moz-placeholder,x-blank ::-moz-placeholder{color:inherit!important;opacity:1!important}x-blank-mc .target{line-height:24px;min-width:50px;padding:2px 12px}x-blank-mc.invalid .target{padding-left:30px}html.is-tabbing x-blank-mc .target:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #0f82f2;outline:none}x-blank-mc .popup{background:#0e75da;border-radius:0 6px 6px 6px;box-shadow:0 0 20px rgba(0,0,0,.3);font-style:normal;left:2px;min-width:90px;opacity:0;pointer-events:none;position:absolute;text-align:left;top:100%;transform:scale(.5);transform-origin:left top;transition:opacity .2s,transform .2s;white-space:normal;width:-moz-max-content;width:max-content}.caption x-blank-mc .popup{top:24px}x-blank-mc.left .popup{border-radius:6px 0 6px 6px;left:auto;right:2px;transform-origin:right top}x-blank-mc.top .popup{border-radius:6px 6px 6px 0;bottom:100%;top:auto;transform-origin:left bottom}x-blank-mc.left.top .popup{border-radius:6px 6px 0 6px;transform-origin:right bottom}.caption x-blank-mc.top .popup{bottom:24px}x-blank-mc strong{color:#fff}x-blank-mc.done strong{color:#0f82f2}x-blank-mc.on,x-blank-mc:focus-within{z-index:100}x-blank-mc.on .target,x-blank-mc:focus-within .target{border-radius:5px 5px 0 0}x-blank-mc.on.top .target,x-blank-mc:focus-within.top .target{border-radius:0 0 5px 5px}x-blank-mc.on.invalid .target:before,x-blank-mc:focus-within.invalid .target:before{border-radius:5px 0 0 0}x-blank-mc.on.top.invalid .target:before,x-blank-mc:focus-within.top.invalid .target:before{border-radius:0 0 0 5px}x-blank-mc.on .popup,x-blank-mc:focus-within .popup{opacity:1;pointer-events:all;transform:none}x-blank-mc .choice{box-sizing:border-box;color:hsla(0,0%,100%,.8);cursor:pointer;display:block;font-size:16px;line-height:22px;padding:6px 16px 6px 12px;text-align:left;transition:color .2s,background .2s,box-shadow .2s;width:100%}x-blank-mc .choice:focus,x-blank-mc .choice:hover{background:hsla(0,0%,100%,.2);color:#fff}html.is-tabbing x-blank-mc .choice:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #0f82f2;outline:none}x-blank-mc .choice:first-child{border-top-right-radius:6px}x-blank-mc .choice:last-child{border-radius:0 0 6px 6px}x-blank-mc .choice:before{background:hsla(0,0%,100%,.5);content:" ";display:block;height:1px;left:12px;margin-top:-6px;position:absolute;right:16px;transition:background .2s}x-blank-mc .choice:first-child:before,x-blank-mc .choice:focus+.choice:before,x-blank-mc .choice:focus:before,x-blank-mc .choice:hover+.choice:before,x-blank-mc .choice:hover:before{background:transparent}x-free-text{display:block;margin:1.5em 0;position:relative}x-free-text .text-area{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:#f5f5f6;border:1px solid #ccc;border-radius:6px;color:#333;cursor:text;height:auto;line-height:1.4em;padding:10px 16px 42px;transition:background .2s,border .2s,box-shadow .2s}x-free-text .text-area:empty:after{color:#aaa;content:"What do you notice or wonder?"}x-free-text .text-area:hover,x-free-text:focus-within .text-area{background-color:#eee;border-color:#0f82f2;z-index:2}x-free-text:focus-within .text-area{box-shadow:0 0 0 3px rgba(15,130,242,.5);outline:none}x-free-text .toolbar{background:#dddce1;border-radius:0 0 5px 5px;border-top:1px solid #adabb5;bottom:1px;display:flex;left:1px;opacity:0;pointer-events:none;position:absolute;right:1px;transition:opacity .2s}x-free-text .toolbar .space{flex-grow:1}x-free-text .text-area:focus+.toolbar,x-free-text:focus-within .toolbar{opacity:1;pointer-events:all}x-free-text .toolbar .command{fill:#3a3645;border-right:1px solid #adabb5;cursor:pointer;display:block;height:20px;padding:6px;transition:background .2s,fill .2s}x-free-text .toolbar .command:focus,x-free-text .toolbar .command:hover{fill:#181824;background:#c5c2cc}x-free-text .toolbar .command:first-child{border-bottom-left-radius:5px}x-free-text .toolbar .command x-icon{display:block;margin:0;transition:transform .2s}x-free-text .toolbar .command x-icon:hover{transform:scale(1.08)}x-free-text .toolbar .command x-icon:active{transform:scale(.92)}x-free-text .toolbar .submit{border-radius:0 0 5px 0;font-size:16px;height:33px;line-height:33px;margin-top:-1px;padding:0 12px 0 8px}x-free-text .toolbar .submit.invisible{opacity:0;pointer-events:none;transform:scale(.5)}x-free-text .toolbar .submit x-icon{margin-right:2px}x-free-text .toolbar .submit:focus,x-free-text .toolbar .submit:hover{background:#22ab24}x-gallery{display:block;position:relative}x-gallery .wrapper{cursor:ew-resize;overflow:hidden;position:relative}x-gallery .panel{transform:translateX(0)}x-gallery .panel:after,x-gallery .panel:before{clear:both;content:" ";display:table}x-gallery .panel>*{box-sizing:border-box;float:left;padding:10px}x-gallery .panel>* img,x-gallery .panel>* x-img{display:block;height:auto;margin:0 auto;width:100%}x-gallery .nav{border-top:2px solid #c5c2cc;height:34px;position:relative}x-gallery .back,x-gallery .next{border-radius:0 0 6px 6px;display:block;height:36px;min-width:0;padding:0;position:absolute;top:-2px;transform-origin:center top;width:36px}x-gallery .back.disabled,x-gallery .next.disabled{opacity:0}x-gallery .back x-icon,x-gallery .next x-icon{display:block;margin:6px}x-gallery .next{right:0}x-gallery .dots{left:50%;position:absolute;top:10px;transform:translateX(-50%)}x-gallery .dot{background:rgba(24,24,36,.2);border-radius:4px;float:left;height:8px;margin:4px;transition:opacity .2s;width:8px}x-gallery .dot.on{background:rgba(24,24,36,.8)}x-gesture{fill:rgba(0,0,0,.5);stroke:hsla(0,0%,100%,.5);stroke-width:1px;display:none;pointer-events:none;position:absolute;transform-origin:15px 10px;z-index:9999}html[theme=dark] x-gesture{fill:hsla(0,0%,100%,.5);stroke:rgba(34,33,46,.5)}x-bio,x-bio .target,x-gloss,x-gloss .target{display:inline-block;position:relative}x-bio .target,x-gloss .target{-webkit-touch-callout:none;background:transparent;border-radius:6px;cursor:pointer;line-height:28px;margin:-3px -6px;padding:0 6px;transition:background .2s,color .2s,box-shadow .2s}.caption x-bio .target,.caption x-gloss .target{height:24px;line-height:24px}x-bio .target:before,x-gloss .target:before{background:#feaf4d;bottom:1px;content:" ";height:3px;left:5px;position:absolute;right:5px}x-bio.on .target,x-gloss.on .target{background:#feaf4d;color:rgba(0,0,0,.8)}html.is-tabbing x-bio .target:focus,html.is-tabbing x-gloss .target:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #feaf4d;outline:none}x-bio .popup,x-gloss .popup{font-size:16px;font-weight:400}@media screen and (max-width:600px){x-bio .popup,x-gloss .popup{display:none}}@media screen and (min-width:601px){x-bio .popup,x-gloss .popup{background:#f08500;border-radius:0 6px 6px 6px;box-shadow:0 0 10px rgba(0,0,0,.2);font-style:normal;left:-6px;opacity:0;padding:12px 16px;pointer-events:none;position:absolute;text-align:left;top:100%;transform:scale(.5);transform-origin:left top;transition:opacity .2s,transform .2s;white-space:normal;width:300px}.caption x-bio .popup,.caption x-gloss .popup{top:24px}x-bio.left .popup,x-gloss.left .popup{border-radius:6px 0 6px 6px;left:auto;right:-6px;transform-origin:right top}x-bio.top .popup,x-gloss.top .popup{border-radius:6px 6px 6px 0;bottom:100%;top:auto;transform-origin:left bottom}x-bio.left.top .popup,x-gloss.left.top .popup{border-radius:6px 6px 0 6px;transform-origin:right bottom}.caption x-bio.top .popup,.caption x-gloss.top .popup{bottom:24px}x-bio.on,x-bio:focus-within,x-gloss.on,x-gloss:focus-within{z-index:100}x-bio.on .target,x-bio:focus-within .target,x-gloss.on .target,x-gloss:focus-within .target{border-radius:5px 5px 0 0}x-bio.on.top .target,x-bio:focus-within.top .target,x-gloss.on.top .target,x-gloss:focus-within.top .target{border-radius:0 0 5px 5px}x-bio.on.invalid .target:before,x-bio:focus-within.invalid .target:before,x-gloss.on.invalid .target:before,x-gloss:focus-within.invalid .target:before{border-radius:5px 0 0 0}x-bio.on.top.invalid .target:before,x-bio:focus-within.top.invalid .target:before,x-gloss.on.top.invalid .target:before,x-gloss:focus-within.top.invalid .target:before{border-radius:0 0 0 5px}x-bio.on .popup,x-bio:focus-within .popup,x-gloss.on .popup,x-gloss:focus-within .popup{opacity:1;pointer-events:all;transform:none}}.theorem x-bio .target:before,.theorem x-gloss .target:before{background:#fd8c00}.theorem x-bio.on .target:before,.theorem x-gloss.on .target:before{background:#feaf4d}#glossary-modal,x-bio .popup,x-gloss .popup{color:hsla(0,0%,100%,.9)}#glossary-modal li,#glossary-modal p,x-bio .popup li,x-bio .popup p,x-gloss .popup li,x-gloss .popup p{line-height:1.4;margin:0 0 .7em}#glossary-modal li,x-bio .popup li,x-gloss .popup li{margin-bottom:.3em}#glossary-modal p:last-child,x-bio .popup p:last-child,x-gloss .popup p:last-child{margin-bottom:0}#glossary-modal ol,#glossary-modal ul,x-bio .popup ol,x-bio .popup ul,x-gloss .popup ol,x-gloss .popup ul{margin-left:1.5em}#glossary-modal strong,x-bio .popup strong,x-gloss .popup strong{color:#fff}#glossary-modal a.btn,#glossary-modal a.icon-btn,#glossary-modal a.next-step,x-bio .popup a.btn,x-bio .popup a.icon-btn,x-bio .popup a.next-step,x-gloss .popup a.btn,x-gloss .popup a.icon-btn,x-gloss .popup a.next-step{background:hsla(0,0%,100%,.8);color:#fd8c00;font-weight:400;margin:0}#glossary-modal a.btn:after,#glossary-modal a.btn:before,#glossary-modal a.icon-btn:after,#glossary-modal a.icon-btn:before,#glossary-modal a.next-step:after,#glossary-modal a.next-step:before,x-bio .popup a.btn:after,x-bio .popup a.btn:before,x-bio .popup a.icon-btn:after,x-bio .popup a.icon-btn:before,x-bio .popup a.next-step:after,x-bio .popup a.next-step:before,x-gloss .popup a.btn:after,x-gloss .popup a.btn:before,x-gloss .popup a.icon-btn:after,x-gloss .popup a.icon-btn:before,x-gloss .popup a.next-step:after,x-gloss .popup a.next-step:before{display:none}#glossary-modal a.btn:focus,#glossary-modal a.btn:hover,#glossary-modal a.icon-btn:focus,#glossary-modal a.icon-btn:hover,#glossary-modal a.next-step:focus,#glossary-modal a.next-step:hover,x-bio .popup a.btn:focus,x-bio .popup a.btn:hover,x-bio .popup a.icon-btn:focus,x-bio .popup a.icon-btn:hover,x-bio .popup a.next-step:focus,x-bio .popup a.next-step:hover,x-gloss .popup a.btn:focus,x-gloss .popup a.btn:hover,x-gloss .popup a.icon-btn:focus,x-gloss .popup a.icon-btn:hover,x-gloss .popup a.next-step:focus,x-gloss .popup a.next-step:hover{background:#fff;color:#fd8c00}.bio-img{border-radius:4px;float:right;height:auto;margin:4px 0 5px 10px;width:140px}.gloss-img{display:block;filter:invert(100%)}#glossary-modal{background:#fd8c00;border-radius:8px;width:340px}#glossary-modal .modal-body{padding:12px 18px 14px}#glossary-modal p:first-child{margin-right:18px}#glossary-modal .bio-img{display:block;float:none;margin:0 auto 12px;min-height:160px}#glossary-modal .gloss-img{min-height:120px}#glossary-modal .close{fill:hsla(0,0%,100%,.8)}.lightbox-overlay{background:transparent;bottom:0;cursor:zoom-out;display:none;left:0;position:fixed;right:0;top:0;transition:background .4s;will-change:background;z-index:800}.lightbox-overlay.on{background:rgba(0,0,0,.9)}.lightbox-img{background-position:50%;background-repeat:no-repeat;background-size:contain;bottom:30px;left:30px;position:absolute;right:30px;top:30px;will-change:transition}.lightbox-img.transitions{transition:transform .4s ease-in-out}@media screen and (max-width:540px){.lightbox-img{bottom:0;left:0;right:0;top:0}}x-img{display:block;max-width:100%;position:relative}x-img.interactive{cursor:zoom-in}x-img .wrap{height:0}x-img img{border-radius:4px;display:block;max-width:100%}x-img .credit{background:rgba(0,0,0,.8);border-bottom-right-radius:4px;bottom:0;box-sizing:border-box;color:#fff;font-size:11px;line-height:1.2;max-width:90%;opacity:0;padding:4px 8px;position:absolute;right:0;transition:opacity .2s}x-img:hover .credit{opacity:.9}x-img .zoom{background:rgba(0,0,0,.7);border-top-right-radius:4px;height:36px;opacity:.5;position:absolute;right:0;top:0;transition:opacity .2s,background .2s;width:36px}x-img:hover .zoom{opacity:.9}x-img x-icon{fill:#fff;margin:6px}@media print{.lightbox-img,.lightbox-overlay,x-img .zoom{display:none!important}x-img .credit{opacity:1!important}}x-picker{display:flex;justify-content:space-between;margin:1.5em -4px}x-picker .item{border:4px solid transparent;border-radius:8px;cursor:pointer;margin:4px;position:relative;transition:border .2s,opacity .2s;width:100px}x-picker .item:hover{border-color:#eee}x-picker .item.correct{border-color:#22ab24;cursor:default}x-picker .item.incorrect{border-color:#cd0e66;cursor:default}x-picker .item:after{border:4px solid #fff;border-radius:100%;content:"";height:28px;position:absolute;right:-12px;top:-12px;transform:scale(0);transition:transform .5s cubic-bezier(.33,1.9,.52,.7);width:28px}x-picker .item.correct:after{background:#22ab24 url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22m19.7%206.3-.2-.4-.3-.2c-.1-.1-.3%200-.4%200a36.6%2036.6%200%200%200%20-9.8%208.4%2036.1%2036.1%200%200%200%20-4.8-2.9h-.5l-1%20.9a.4.4%200%200%200%20-.1.3c0%20.2%200%20.3.1.4a72.1%2072.1%200%200%201%206.6%207h.4a.5.5%200%200%200%20.4-.2c3.8-6.8%205.7-9.6%209.4-13%20.2.1.2-.1.2-.3z%22%2F%3E%3C%2Fsvg%3E") 2px 2px no-repeat;transform:scale(1)}x-picker .item.incorrect:after{background:#cd0e66 url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22M19%2C16l-4.7-4.3L18.6%2C7a1.2%2C1.2%2C0%2C0%2C0%2C0-1.5l-.4-.3a1%2C1%2C0%2C0%2C0-1.4%2C0L12%2C9.5%2C7.2%2C5.2a1%2C1%2C0%2C0%2C0-1.4%2C0l-.4.3A1.2%2C1.2%2C0%2C0%2C0%2C5.4%2C7l4.3%2C4.7L5%2C16a1.1%2C1.1%2C0%2C0%2C0-.1%2C1.4l1.5%2C1.4a.9.9%2C0%2C0%2C0%2C1.3%2C0L12%2C14.1l4.3%2C4.7a.9.9%2C0%2C0%2C0%2C1.3%2C0l1.5-1.4A1.1%2C1.1%2C0%2C0%2C0%2C19%2C16Z%22%2F%3E%3C%2Fsvg%3E") 2px 2px no-repeat;transform:scale(1)}x-picker.solved .item{border-color:transparent;cursor:default}x-picker.solved .item:after{background-color:#ccc}x-picker.solved .item[data-error]{opacity:.2}x-picker.list{display:block;margin:1em 24px}x-picker.list .item{border:none;border-radius:5px;margin:8px auto;max-width:480px;padding:4px 12px 4px 42px;transition:background .2s;width:auto}x-picker.list .item:not(.correct):not(.incorrect):hover{background:#eee}x-picker.list .item:after{left:0;top:-1px}x-picker.wrap{flex-wrap:wrap;justify-content:center}x-progress{border:2px solid;border-radius:100%;box-sizing:border-box}x-progress svg{display:block;margin:-14px;max-width:none;pointer-events:none}x-progress path.done,x-progress path.pie{transform:translate(12px,12px)}x-progress path.pie{fill:none;stroke:currentColor;transition:stroke-dasharray .2s}x-progress line{stroke:currentColor;stroke-width:2px}x-course-sidebar{background:#3a3645 linear-gradient(transparent 240px,rgba(0,0,0,.25));bottom:0;box-shadow:0 0 12px rgba(0,0,0,.25);color:#fff;display:flex;flex-direction:column;left:0;position:fixed;top:44px;width:280px;z-index:301}x-course-sidebar .sidebar-hero{background-size:cover;flex-shrink:0.5;height:220px;padding:0 20px;position:relative}x-course-sidebar .sidebar-hero-gradient{background-image:linear-gradient(transparent,rgba(0,0,0,.6) 140px);bottom:0;content:" ";left:0;position:absolute;right:0;top:40px}x-course-sidebar .sidebar-title{bottom:16px;font-size:30px;font-weight:600;line-height:1.1;position:absolute}x-course-sidebar .course-icon{background-size:cover;border:2px solid #fff;border-radius:4px;height:54px;margin-bottom:4px;width:54px}x-course-sidebar .sidebar-author{display:block;font-size:16px;margin-top:6px;opacity:.7;width:-moz-fit-content;width:fit-content}x-course-sidebar .sidebar-body{-webkit-overflow-scrolling:touch;flex-grow:1;overflow:auto;overscroll-behavior:contain}x-course-sidebar .sidebar-row{color:hsla(0,0%,100%,.8);display:block;font-weight:600;line-height:20px;padding:11px 20px 11px 52px;position:relative;transition:background .2s,color .2s}x-course-sidebar .sidebar-row:before{background:hsla(0,0%,100%,.4);content:" ";display:block;height:1px;position:absolute;top:0;transition:background-color .2s;width:calc(100% - 72px)}x-course-sidebar .sidebar-row:first-child:before{display:none}x-course-sidebar .sidebar-row.active,x-course-sidebar .sidebar-row.on,x-course-sidebar .sidebar-row:focus,x-course-sidebar .sidebar-row:hover{background:hsla(0,0%,100%,.2);color:#fff}x-course-sidebar .sidebar-row.active+:before,x-course-sidebar .sidebar-row.active:before,x-course-sidebar .sidebar-row.on+:before,x-course-sidebar .sidebar-row.on:before,x-course-sidebar .sidebar-row:focus+:before,x-course-sidebar .sidebar-row:focus:before,x-course-sidebar .sidebar-row:hover+:before,x-course-sidebar .sidebar-row:hover:before{background:transparent}x-course-sidebar .sidebar-row.active,x-course-sidebar .sidebar-row.on{background:hsla(0,0%,100%,.32)}x-course-sidebar .sidebar-row x-progress{color:#fff;height:20px;left:20px;position:absolute;top:11px;width:20px}x-course-sidebar .sidebar-row .connection{background:#fff;height:calc(100% - 18px);left:29px;pointer-events:none;position:absolute;top:30px;width:2px}x-course-sidebar .sidebar-row x-icon.left{color:#fff;left:18px;position:absolute;top:9px}x-course-sidebar .sidebar-row x-icon.left+.connection{height:calc(100% - 16px);top:28px}x-course-sidebar .sidebar-row x-icon.right{color:hsla(0,0%,100%,.6);float:right;margin:-2px -2px 0 6px}x-course-sidebar .sidebar-row:last-child .connection{display:none}x-course-sidebar .sidebar-row:first-child{margin-top:16px}x-course-sidebar .sidebar-footer{display:flex;flex-shrink:0;justify-content:center}x-course-sidebar .footer-link{cursor:pointer;padding:12px 10px;position:relative}x-course-sidebar .footer-link x-icon{fill:hsla(0,0%,100%,.7);display:block;transition:fill .2s}x-course-sidebar .footer-link:focus x-icon,x-course-sidebar .footer-link:hover x-icon{fill:hsla(0,0%,100%,.9)}x-course-sidebar .sidebar-banner{border-top:1px solid hsla(0,0%,100%,.4);color:hsla(0,0%,100%,.6);flex-shrink:0;font-size:14px;margin:0 18px;padding:4px 0 6px;text-align:center}.sidebar-toggle{background:#cd0e66;border-radius:24px;bottom:8px;box-shadow:0 3px 8px rgba(0,0,0,.3);cursor:pointer;display:none;height:24px;left:8px;padding:10px;position:fixed;width:24px;z-index:300}.sidebar-toggle x-icon{fill:#fff}.sidebar-shadow{bottom:0;display:none;left:0;position:fixed;right:0;top:0;z-index:300}x-modal{-webkit-user-select:text;-moz-user-select:text;user-select:text}#feedback .error{color:#cd0e66;display:none;margin:5px 8px}#feedback button[disabled]:after{content:"ing…"}x-modal#feedback-success{text-align:center;width:320px}x-modal#share{width:400px}.share-row{display:flex;flex-wrap:wrap;justify-content:center;margin:-4px}.share-row .btn,.share-row .icon-btn,.share-row .next-step{border-radius:8px;box-shadow:none;height:36px;margin:4px;min-width:0;padding:8px;width:36px}.share-row .btn x-icon,.share-row .icon-btn x-icon,.share-row .next-step x-icon{margin:0}#glossary-search{background:#feddb3;font-size:16px;height:440px;width:600px}.gloss-sidebar{background:#fd8c00;border-radius:12px 0 0 12px;display:flex;flex-direction:column;width:200px}.gloss-sidebar h2{fill:#fff;color:#fff;margin:20px 24px}.gloss-search{position:relative}.gloss-search x-icon{fill:#fff;left:24px;position:absolute;top:9px}.gloss-search input{background:hsla(0,0%,100%,.24);box-sizing:border-box;color:#fff;padding:10px 12px 10px 54px;transition:background .2s;width:100%}.gloss-search input:focus,.gloss-search input:hover{background:hsla(0,0%,100%,.32)}.gloss-search input::-moz-placeholder{color:hsla(0,0%,100%,.7)}.gloss-search input::placeholder{color:hsla(0,0%,100%,.7)}.gloss-list{-webkit-overflow-scrolling:touch;border-bottom-left-radius:12px;flex:1 1;margin-top:-1px;overflow:auto;overscroll-behavior:contain}.gloss-item{color:hsla(0,0%,100%,.8);cursor:pointer;font-weight:600;line-height:1.3;padding:8px 12px 8px 24px;position:relative;transition:background .2s,color .2s}.gloss-item:before{background:hsla(0,0%,100%,.4);content:" ";display:block;height:1px;position:absolute;top:0;transition:background-color .2s;width:calc(100% - 36px)}.gloss-item:first-child:before{display:none}.gloss-item.active,.gloss-item.on,.gloss-item:focus,.gloss-item:hover{background:hsla(0,0%,100%,.2);color:#fff}.gloss-item.active+:before,.gloss-item.active:before,.gloss-item.on+:before,.gloss-item.on:before,.gloss-item:focus+:before,.gloss-item:focus:before,.gloss-item:hover+:before,.gloss-item:hover:before{background:transparent}.gloss-item.active,.gloss-item.on{background:hsla(0,0%,100%,.32)}.gloss-body{-webkit-overflow-scrolling:touch;flex:1 1;overflow:auto;overscroll-behavior:contain;padding:64px 32px 32px}@media screen and (max-width:840px){x-course-sidebar{box-shadow:none;left:-280px;transition:transform .3s,box-shadow .3s;will-change:transform}.sidebar-toggle{display:block}x-course-sidebar.open{box-shadow:10px 0 60px rgba(0,0,0,.5);transform:translateX(280px)}x-course-sidebar.open+.sidebar-shadow{display:block}}x-slider{box-sizing:border-box;display:block;margin:20px auto 2em;max-width:400px;position:relative;width:calc(100% - 24px)}x-slider .bar{background:#b0afb5;border-radius:2px;height:4px;position:relative}x-slider .play+.bar{margin-left:40px}x-slider .knob{background:#cd0e66;border-radius:12px;cursor:grab;height:20px;left:0;margin:-8px 0 0 -10px;position:absolute;touch-action:pan-y;transition:background .2s,transform .2s,box-shadow .2s;width:20px}x-slider .knob:active,x-slider .knob:hover{background:#f01e7f;box-shadow:0 3px 8px rgba(0,0,0,.25);transform:scale(1.4)}x-slider .play{color:#89868f;cursor:pointer;height:32px;left:-8px;padding:4px;position:absolute;top:-18px;transition:fill .2s,transform .2s;width:32px}x-slider .play:hover{transform:scale(1.08)}x-slider .play:active{transform:scale(.92)}x-slider .play:focus,x-slider .play:hover{color:#3a3645;transform:scale(1.2)}html[theme=dark] x-slider .play:focus,html[theme=dark] x-slider .play:hover{color:#fff}x-slider .play:active{transform:scale(.9)}x-slideshow{display:block}x-slideshow .legend-box{border:solid #ccc;border-width:2px 0}x-slideshow .legend-box>*{display:none;padding:.7em 0}x-slideshow .legend-box p:last-child,x-slideshow .legend-box>p{margin-bottom:0}x-slideshow .nav{height:0;position:relative}x-slideshow .back,x-slideshow .next{border-radius:6px 6px 0 0;bottom:-2px;display:block;height:36px;min-width:0;padding:0;position:absolute;transform-origin:center bottom;width:36px;z-index:1}x-slideshow .back.disabled,x-slideshow .next.disabled{opacity:0}x-slideshow .back x-icon,x-slideshow .next x-icon{margin:6px}[dir=rtl] x-slideshow .back x-icon,[dir=rtl] x-slideshow .next x-icon{transform:scaleX(-1)}x-slideshow .next{right:0}x-slideshow .dots{bottom:8px;left:50%;position:absolute;transform:translateX(-50%)}x-slideshow .dot{background:rgba(24,24,36,.2);border-radius:4px;float:left;height:8px;margin:4px;transition:background .2s;width:8px}html[theme=dark] x-slideshow .dot{background:hsla(0,0%,100%,.4)}x-slideshow .dot.on{background:rgba(0,0,0,.8)}html[theme=dark] x-slideshow .dot.on{background:#fff}x-sortable{display:block;margin:1.5em auto;max-width:600px;position:relative}x-sortable>*{background:#0f82f2;border-radius:4px;color:#fff;cursor:grab;left:0;padding:8px 28px 8px 20px;position:absolute;top:0;transition:opacity .1s,box-shadow .1s;width:calc(100% - 48px)}x-sortable>:active{cursor:grabbing;z-index:100}x-sortable>:after{content:"…";position:absolute;right:0;top:7px;transform:rotate(90deg)}x-sortable:active>*{opacity:.6}x-sortable>:active{box-shadow:0 0 20px rgba(0,0,0,.3);opacity:1}x-sortable.solved:active>*,x-sortable.solved>*,x-sortable.solved>:active{background:none;border:1px solid #0f82f2;box-shadow:none;color:inherit;cursor:default;opacity:1;padding:7px 27px 7px 19px}x-sortable.solved:active>:after,x-sortable.solved>:active:after,x-sortable.solved>:after{display:none}x-step{color:#666;contain:layout style;display:block;height:0;line-height:1.7;opacity:0;overflow:hidden;pointer-events:none;position:relative;transform:translateX(-160px);word-spacing:.05em;z-index:1}html[theme=dark] x-step{color:#dedee0}x-step:after,x-step:before{clear:both;content:" ";display:table}x-course.ready x-step{transition:opacity .8s linear,transform .8s cubic-bezier(.165,.84,.44,1);will-change:opacity,transform}x-step.on{height:auto;opacity:1;overflow:visible;pointer-events:auto;transform:none}x-step:hover{z-index:2}x-step:focus-within{z-index:3}.reveal{visibility:hidden}.next-step{box-sizing:border-box;left:50%;margin-left:-70px;position:absolute;top:calc(100% + 12px);width:140px}x-step.hovering{z-index:1}p.voice{margin-left:-40px;padding-left:40px}.sentence{background-image:linear-gradient(rgba(253,140,0,.3),rgba(253,140,0,.3));background-repeat:no-repeat;background-size:0 100%;-webkit-box-decoration-break:clone;box-decoration-break:clone;transition:background .6s}.sentence.playing{background-size:100% 100%;border-radius:4px;margin:0 -4px;padding:0 4px}.playback-btn{background:#c5c2cc url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2214%22%20height%3D%2214%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22m7.5%206.17v11.66a1.12%201.12%200%200%200%201.73.94l9.16-5.77a1.13%201.13%200%200%200%200-1.91l-9.16-5.86a1.12%201.12%200%200%200%20-1.73.94z%22%2F%3E%3C%2Fsvg%3E") 2px 2px no-repeat;background-clip:content-box;border:10px solid transparent;border-radius:30px;cursor:pointer;height:18px;margin:-4px 0 0 -38px;opacity:0;pointer-events:none;position:absolute;transform:scale(0);transition:opacity .2s,background .2s,transform .2s;width:18px}li.voice .playback-btn{margin-left:-56px}.playback-btn.active,.playback-btn:focus,.voice:hover>.playback-btn{opacity:1;pointer-events:all;transform:scale(1)}.voice:hover>.playback-btn:hover{transform:scale(1.3)}.playback-btn:focus,.playback-btn:hover{background-color:#656073}.playback-btn.active{background:#fd8c00 url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2214%22%20height%3D%2214%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22m8%2019a2%202%200%200%200%202-2v-10a2%202%200%200%200%20-2-2%202%202%200%200%200%20-2%202v10a2%202%200%200%200%202%202zm6-12v10a2%202%200%200%200%202%202%202%202%200%200%200%202-2v-10a2%202%200%200%200%20-2-2%202%202%200%200%200%20-2%202z%22%2F%3E%3C%2Fsvg%3E") 2px 2px no-repeat;background-clip:content-box}x-step h2,x-step h3{color:#333;font-weight:600;line-height:1.15}html[theme=dark] x-step h2,html[theme=dark] x-step h3{color:#fff}x-step h2{border-bottom:2px solid #ddd;font-size:1.6em;margin:2em 0 1em;padding-bottom:6px}x-step .row h2{border:none;padding:0}x-step:first-child h2{margin-top:0}x-step h3{font-size:1.3em;margin:1.2em 0 .8em;text-align:center}x-step .row h3{text-align:left}x-step li strong,x-step p strong,x-step table strong{color:#333;font-weight:700}html[theme=dark] x-step li strong,html[theme=dark] x-step p strong,html[theme=dark] x-step table strong{color:#fff}x-step figure+p,x-step x-geopad+p{margin-top:.5em}x-step ol,x-step ul{margin:0 0 1em;padding:0;text-align:left}x-step ul{list-style-type:disc}x-step li{margin:0 0 .5em 1.5em}x-step .caption{color:#aaa;font-size:.85em;line-height:1.5;margin:.5em 0 0;text-align:center;vertical-align:top}html[theme=dark] x-step .caption{color:hsla(0,0%,100%,.55)}x-step .quote{color:#aaa;font-style:italic;margin:1.5em 2em;text-align:center}html[theme=dark] x-step .quote{color:hsla(0,0%,100%,.55)}x-step hr{background:#ddd;height:2px;margin:2em 0}x-step hr:first-child{margin-top:1em}x-step code{background:#eee;border:1px solid #ccc;border-radius:4px;color:#333;font-family:Courier,monospace;font-size:90%;margin:-.2em .1em;padding:.2em .4em;vertical-align:1px}x-step pre{margin:1em 0}x-step pre code{display:block;padding:.3em .8em}x-step table{border:none;border-collapse:collapse;border-spacing:0;margin:.5em auto 1.5em}x-step td,x-step th{border:none;padding:.6em;text-align:center;vertical-align:middle}x-step table.text-left td,x-step table.text-left th{text-align:left}@media screen and (max-width:540px){x-step td,x-step th{padding:.25em}}x-step td[align=left]{text-align:left}x-step td[align=center]{text-align:center}x-step td[align=right]{text-align:right}x-step .table-fixed{table-layout:fixed;width:95%}x-step .table-small,x-step .table-tiny{margin:0 auto 1em}x-step .table-small td{padding:.3em .6em}x-step .table-tiny td{padding:.2em .3em}x-step table.grid td,x-step table.grid th{border-bottom:1px solid #c5c2cc;border-right:1px solid #c5c2cc}x-step table.grid td:last-child,x-step table.grid th:last-child{border-right:none}x-step table.grid tr:last-child td{border-bottom:none}x-step table h3,x-step table p{margin:0;padding:0;text-align:center!important}x-step table img{height:auto;max-width:95%}x-step table .caption{text-align:center!important}x-step table .td_caption_small{padding-top:0!important}x-step .column,x-step .row{margin:-.5em -.5em .5em}x-step .row>*,x-step article .column>*{margin:.5em;width:260px}x-step .row.padded{margin:-.5em -24px .5em}x-step .row.padded-thin{margin:-.5em -12px .5em}x-step .row>.fit{width:-moz-fit-content;width:fit-content}x-step .row>*>:first-child{margin-top:0}x-step .row>*>:last-child{margin-bottom:0}x-step .row>*>p:first-child{margin-top:-6px}x-step svg{height:auto;max-width:100%}.sticky-wrap{position:relative}.sticky{position:sticky;top:54px}.fixme{background:#fcc}html[theme=dark] .fixme{background:rgba(204,0,0,.5)}.todo{background:#eee;border:2px solid #aaa;border-radius:12px;color:#999;font-size:20px;font-style:italic;margin:2em auto;max-width:580px;padding:22px 24px;text-align:center}html[theme=dark] .todo{background:hsla(0,0%,100%,.15)}@media (min-width:720px){.shifted{margin-top:-70px!important}}figure,x-gallery,x-slideshow{margin:2em auto}figure>img,figure>svg,figure>x-img{display:block;margin:0 auto .3em}x-select.segmented{display:flex;margin:0 auto .5em;width:-moz-fit-content;width:fit-content}x-select.segmented>*{border:1px solid #cd0e66;border-left:none;cursor:pointer;text-align:center;transition:color .2s,background .2s;width:100px}x-select.segmented>:first-child{border-left:1px solid #cd0e66;border-radius:20px 0 0 20px}x-select.segmented>:last-child{border-radius:0 20px 20px 0}x-select.segmented>:hover{background:rgba(205,14,102,.18)}x-select.segmented>.active{background:#cd0e66;color:#fff;cursor:default}html.is-tabbing x-select.segmented>:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #cd0e66;outline:none;z-index:1}.box,.frame,.theorem{background:#f5f5f6;border-radius:6px;box-sizing:border-box;color:rgba(0,0,0,.7);padding:16px}html[theme=dark] .box,html[theme=dark] .frame,html[theme=dark] .theorem{background:#2d2c38;color:inherit}.box>ol:last-child,.box>p:last-child:not(.btn-row),.box>ul:last-child,.frame>ol:last-child,.frame>p:last-child:not(.btn-row),.frame>ul:last-child,.theorem>ol:last-child,.theorem>p:last-child:not(.btn-row),.theorem>ul:last-child{margin-bottom:0}.box .caption,.frame .caption,.theorem .caption{color:rgba(0,0,0,.4)}html[theme=dark] .box .caption,html[theme=dark] .frame .caption,html[theme=dark] .theorem .caption{color:hsla(0,0%,100%,.55)}.box hr,.frame hr,.theorem hr{background:rgba(0,0,0,.2)}html[theme=dark] .box hr,html[theme=dark] .frame hr,html[theme=dark] .theorem hr{background:hsla(0,0%,100%,.25)}.frame.red,.red.box,.red.theorem{background:rgba(205,14,102,.25)}html[theme=dark] .frame.red,html[theme=dark] .red.box,html[theme=dark] .red.theorem{background:rgba(205,14,102,.4)}.blue.box,.blue.theorem,.frame.blue{background:rgba(15,130,242,.25)}html[theme=dark] .blue.box,html[theme=dark] .blue.theorem,html[theme=dark] .frame.blue{background:rgba(15,130,242,.4)}.frame.green,.green.box,.green.theorem{background:rgba(34,171,36,.25)}html[theme=dark] .frame.green,html[theme=dark] .green.box,html[theme=dark] .green.theorem{background:rgba(34,171,36,.4)}.frame.yellow,.yellow.box,.yellow.theorem{background:rgba(253,140,0,.25)}html[theme=dark] .frame.yellow,html[theme=dark] .yellow.box,html[theme=dark] .yellow.theorem{background:rgba(253,140,0,.4)}.frame.orange,.orange.box,.orange.theorem{background:rgba(235,71,38,.25)}html[theme=dark] .frame.orange,html[theme=dark] .orange.box,html[theme=dark] .orange.theorem{background:rgba(235,71,38,.4)}.frame.purple,.purple.box,.purple.theorem{background:rgba(109,59,191,.25)}html[theme=dark] .frame.purple,html[theme=dark] .purple.box,html[theme=dark] .purple.theorem{background:rgba(109,59,191,.4)}.frame.teal,.teal.box,.teal.theorem{background:rgba(0,158,166,.25)}html[theme=dark] .frame.teal,html[theme=dark] .teal.box,html[theme=dark] .teal.theorem{background:rgba(0,158,166,.4)}.frame.lime,.lime.box,.lime.theorem{background:rgba(191,194,18,.25)}html[theme=dark] .frame.lime,html[theme=dark] .lime.box,html[theme=dark] .lime.theorem{background:rgba(191,194,18,.4)}.box{margin:2em 0;padding:20px;position:relative}.box.with-title{border-top-left-radius:0;margin-top:calc(2em + 37px)}.box.no-padding{padding:0}figure .box{margin:0}figure .tabs+.box{padding-top:32px}.box h3{background:#181824;border-radius:12px 12px 0 0;color:#fff;font-size:18px;height:36px;left:0;line-height:36px;margin:0;padding:0 20px;position:absolute;top:-37px}@media screen and (max-width:540px){.box{border-radius:0}.box,.box h3{padding-left:24px}.box h3{border-top-left-radius:0}}.box.red h3{background:#cd0e66}.box.blue h3{background:#0f82f2}.box.green h3{background:#22ab24}.box.yellow h3{background:#fd8c00}.box.orange h3{background:#eb4726}.box.purple h3{background:#6d3bbf}.box.teal h3{background:#009ea6}.box.lime h3{background:#bfc212}.theorem{background:rgba(205,14,102,.25);border-left:6px solid #cd0e66;border-radius:3px 6px 6px 3px;margin:1.5em 0;padding:.6em 1em}html[theme=dark] .theorem{background:rgba(205,14,102,.4)}.theorem.red{border-color:#cd0e66}.theorem.blue{border-color:#0f82f2}.theorem.green{border-color:#22ab24}.theorem.yellow{border-color:#fd8c00}.theorem.orange{border-color:#eb4726}.theorem.purple{border-color:#6d3bbf}.theorem.teal{border-color:#009ea6}.theorem.lime{border-color:#bfc212}x-step p a{-webkit-touch-callout:none;background:transparent;border-radius:6px;color:inherit;cursor:pointer;display:inline-block;line-height:28px;margin:-3px -17px -3px -6px;outline:none;padding:0 17px 0 6px;position:relative;transition:background .2s,color .2s,box-shadow .2s}.caption x-step p a{height:24px;line-height:24px}x-step p a:before{background:#57a8f6;bottom:1px;content:" ";height:3px;left:5px;position:absolute;right:5px}x-step p a:focus,x-step p a:hover{background:#57a8f6;box-shadow:0 0 10px rgba(0,0,0,.2);color:rgba(0,0,0,.8)}x-step p a:before{right:17px}x-step p a:after{background:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%228%22%20height%3D%2214%22%3E%3Cpath%20fill%3D%22none%22%20stroke%3D%22rgba(0%2C0%2C0%2C0.6)%22%20stroke-width%3D%222px%22%20d%3D%22M2%202L6%207L2%2012%22%2F%3E%3C%2Fsvg%3E");content:" ";display:block;height:14px;left:auto;opacity:0;position:absolute;right:5px;top:7px;transition:opacity .1s;width:9px!important}x-step p a:focus:after,x-step p a:hover:after{opacity:1}.circled{background:#3a3645;border-radius:20px;color:#fff;display:inline-block;height:40px;line-height:40px;text-align:center;width:40px}.circled.red{background:#cd0e66}.circled.blue{background:#0f82f2}.circled.green{background:#22ab24}.circled.yellow{background:#fd8c00}.circled.orange{background:#eb4726}.circled.purple{background:#6d3bbf}.circled.teal{background:#009ea6}.circled.lime{background:#bfc212}.pill{background:rgba(101,96,115,.6);border-radius:16px;color:#fff;display:inline-block;line-height:1.5;min-width:10px;padding:0 10px;text-align:center}.pill.red{background:rgba(205,14,102,.6)}.pill.blue{background:rgba(15,130,242,.6)}.pill.green{background:rgba(34,171,36,.6)}.pill.yellow{background:rgba(253,140,0,.6)}.pill.orange{background:rgba(235,71,38,.6)}.pill.purple{background:rgba(109,59,191,.6)}.pill.teal{background:rgba(0,158,166,.6)}.pill.lime{background:rgba(191,194,18,.6)}.pill.step-target{-webkit-touch-callout:none;background-color:rgba(101,96,115,.6);cursor:pointer;outline:none;transition:background .2s,box-shadow .2s}.pill.step-target:focus,.pill.step-target:hover{background-color:#656073}html.is-tabbing .pill.step-target:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #656073}.pill.step-target.red{-webkit-touch-callout:none;background-color:rgba(205,14,102,.6);outline:none}.pill.step-target.red:focus,.pill.step-target.red:hover{background-color:#cd0e66}html.is-tabbing .pill.step-target.red:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #cd0e66}.pill.step-target.blue{-webkit-touch-callout:none;background-color:rgba(15,130,242,.6);outline:none}.pill.step-target.blue:focus,.pill.step-target.blue:hover{background-color:#0f82f2}html.is-tabbing .pill.step-target.blue:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #0f82f2}.pill.step-target.green{-webkit-touch-callout:none;background-color:rgba(34,171,36,.6);outline:none}.pill.step-target.green:focus,.pill.step-target.green:hover{background-color:#22ab24}html.is-tabbing .pill.step-target.green:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #22ab24}.pill.step-target.yellow{-webkit-touch-callout:none;background-color:rgba(253,140,0,.6);outline:none}.pill.step-target.yellow:focus,.pill.step-target.yellow:hover{background-color:#fd8c00}html.is-tabbing .pill.step-target.yellow:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #fd8c00}.pill.step-target.orange{-webkit-touch-callout:none;background-color:rgba(235,71,38,.6);outline:none}.pill.step-target.orange:focus,.pill.step-target.orange:hover{background-color:#eb4726}html.is-tabbing .pill.step-target.orange:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #eb4726}.pill.step-target.purple{-webkit-touch-callout:none;background-color:rgba(109,59,191,.6);outline:none}.pill.step-target.purple:focus,.pill.step-target.purple:hover{background-color:#6d3bbf}html.is-tabbing .pill.step-target.purple:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #6d3bbf}.pill.step-target.teal{-webkit-touch-callout:none;background-color:rgba(0,158,166,.6);outline:none}.pill.step-target.teal:focus,.pill.step-target.teal:hover{background-color:#009ea6}html.is-tabbing .pill.step-target.teal:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #009ea6}.pill.step-target.lime{-webkit-touch-callout:none;background-color:rgba(191,194,18,.6);outline:none}.pill.step-target.lime:focus,.pill.step-target.lime:hover{background-color:#bfc212}html.is-tabbing .pill.step-target.lime:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #bfc212}.var-action{-webkit-touch-callout:none;background:transparent;background:#cd0e66;background-color:#cd0e66;border-radius:6px;color:hsla(0,0%,100%,.8);cursor:pointer;display:inline-block;line-height:28px;margin:-3px 2px;min-width:20px;outline:none;padding:0 8px;position:relative;transition:color .2s,background .2s,box-shadow .2s,transform .3s}.caption .var-action{height:24px;line-height:24px}.var-action:before{background:none;bottom:1px;content:" ";height:3px;left:5px;position:absolute;right:5px}.var-action:focus,.var-action:hover{background-color:#ef1579}html.is-tabbing .var-action:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #ef1579}.var-action:hover{transform:scale(1.08)}.var-action:active{transform:scale(.92)}.var-action:hover{box-shadow:0 0 10px rgba(0,0,0,.2);color:#fff}html.is-tabbing .var-action:focus{outline:none}.check{background:#22ab24 url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22m19.7%206.3-.2-.4-.3-.2c-.1-.1-.3%200-.4%200a36.6%2036.6%200%200%200%20-9.8%208.4%2036.1%2036.1%200%200%200%20-4.8-2.9h-.5l-1%20.9a.4.4%200%200%200%20-.1.3c0%20.2%200%20.3.1.4a72.1%2072.1%200%200%201%206.6%207h.4a.5.5%200%200%200%20.4-.2c3.8-6.8%205.7-9.6%209.4-13%20.2.1.2-.1.2-.3z%22%2F%3E%3C%2Fsvg%3E");border-radius:100%;display:inline-block;height:24px;text-align:center;vertical-align:middle;visibility:hidden;width:24px}.check.incorrect{background:#cd0e66 url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22M19%2C16l-4.7-4.3L18.6%2C7a1.2%2C1.2%2C0%2C0%2C0%2C0-1.5l-.4-.3a1%2C1%2C0%2C0%2C0-1.4%2C0L12%2C9.5%2C7.2%2C5.2a1%2C1%2C0%2C0%2C0-1.4%2C0l-.4.3A1.2%2C1.2%2C0%2C0%2C0%2C5.4%2C7l4.3%2C4.7L5%2C16a1.1%2C1.1%2C0%2C0%2C0-.1%2C1.4l1.5%2C1.4a.9.9%2C0%2C0%2C0%2C1.3%2C0L12%2C14.1l4.3%2C4.7a.9.9%2C0%2C0%2C0%2C1.3%2C0l1.5-1.4A1.1%2C1.1%2C0%2C0%2C0%2C19%2C16Z%22%2F%3E%3C%2Fsvg%3E")}.overflow-wrap{-webkit-overflow-scrolling:touch;margin:0 -40px;overflow:auto;overscroll-behavior:contain;padding:0 40px}.overflow-wrap.overflow-table{margin:1em -40px}.overflow-wrap table{margin:.5em auto}@media screen and (max-width:540px){.box,figure,x-gallery,x-slideshow{margin-left:-24px;margin-right:-24px}x-parallax.full-width{height:320px}figure .caption{padding:0 24px}.fill.box,.fill.theorem,.frame.fill,figure x-img img,figure x-video video{border-radius:0}x-slideshow .legend-box>*{padding-left:24px;padding-right:24px}x-slideshow .back{border-top-left-radius:0}x-slideshow .next{border-top-right-radius:0}x-gallery .back{border-bottom-left-radius:0}x-gallery .next{border-bottom-right-radius:0}}@media print{x-step{height:auto!important;opacity:1!important;transform:none!important}x-step .row,x-step>*{-moz-column-break-inside:avoid;break-inside:avoid}.reveal{visibility:visible!important}.caption,h2,h3,p,strong{color:#000!important}x-bio .popup,x-gloss .popup{display:none!important}}.target-body{display:none;height:100%;left:0;opacity:0;pointer-events:none;position:fixed;top:0;transform:translateZ(0);transition:opacity .3s;width:100%;will-change:opacity;z-index:900}.target-body>rect{fill:#fff}html[theme=dark] .target-body>rect{fill:#22212e}.target-body #arrow path{fill:#000}html[theme=dark] .target-body #arrow path{fill:#fff}.target-body .target-arrow{stroke:#000}html[theme=dark] .target-body .target-arrow{stroke:#fff}@keyframes spin{to{transform:rotate(1turn)}}x-tutor{display:block;font-size:16px}x-tutor .toasts{bottom:8px;max-width:264px;pointer-events:none;position:fixed;right:8px;transition:transform .4s;z-index:300}@media (max-width:400px){x-tutor .toasts{max-width:calc(100% - 80px)}}x-tutor .chat{background:#9fcdfa;border-radius:12px 0 0 0;bottom:0;box-shadow:0 0 12px rgba(0,0,0,.25);display:none;flex-direction:column;height:420px;max-height:calc(100vh - 44px);position:fixed;right:0;width:280px;z-index:301}html.webview x-tutor .chat{max-height:100vh}x-tutor .chat-header{background:#0b62b6;border-radius:12px 0 0 0;color:#fff;font-size:20px;font-weight:600;height:44px;line-height:44px;padding:0 12px}x-tutor .chat-header x-icon[name=fox]{margin:0 8px -9px 0}@media (max-height:450px){x-tutor .chat-header{border-radius:0}}x-tutor .close{fill:hsla(0,0%,100%,.6);cursor:pointer;padding:10px;position:absolute;right:0;top:0;transition:fill .2s,transform .2s}x-tutor .close x-icon{display:block}x-tutor .close:focus,x-tutor .close:hover{fill:#fff;transform:scale(1.4)}x-tutor .chat-body{-webkit-overflow-scrolling:touch;flex:1 1;overflow:auto;overscroll-behavior:contain;padding:2px 8px 44px;position:relative;-webkit-user-select:text;-moz-user-select:text;user-select:text}x-tutor .chat-body.loading:after{animation:spin .7s linear infinite;border:3px solid rgba(15,130,242,.25);border-radius:14px;border-top-color:#0f82f2;content:"";display:block;float:right;height:14px;margin:8px 2px -28px 0;width:14px}x-tutor .chat-footer{background:#fff;display:flex}x-tutor .chat-footer .hint{fill:#656073;cursor:pointer;position:relative;transition:fill .2s}x-tutor .chat-footer .hint:focus,x-tutor .chat-footer .hint:hover{fill:#3a3645}x-tutor .chat-footer .hint x-icon{display:block;padding:8px}x-tutor .chat-footer .input{-webkit-user-modify:read-write-plaintext-only;cursor:text;flex-grow:1;line-height:1.3;max-height:64px;overflow:auto;padding:10px 8px 10px 20px;-webkit-user-select:text;-moz-user-select:text;user-select:text}x-tutor .chat-footer .input:empty:before{color:#aaa;content:"Type a question… (beta)"}x-tutor .msg-wrap{align-items:flex-end;display:flex;flex-direction:column}x-tutor .msg{border-radius:16px 16px 3px 16px;margin-top:6px;width:-moz-fit-content;width:fit-content}x-tutor .toasts .msg{box-shadow:0 2px 6px rgba(0,0,0,.25);cursor:pointer;pointer-events:all}x-tutor .msg.hint,x-tutor .msg.question{line-height:1.4;padding:5px 12px}x-tutor .msg.hint{background:#0f82f2;color:hsla(0,0%,100%,.9)}x-tutor .msg.question{align-self:flex-start;background:#fff;border-radius:16px 16px 16px 3px;color:#0f82f2}x-tutor .msg.archie{background:#0f82f2;border-radius:28px 28px 3px 28px;padding:10px 6px 6px 10px;transition:background .2s}x-tutor .msg.archie x-icon{display:block}x-tutor .msg.correct{background:#1e9620}x-tutor .msg.incorrect{background:#b50c5a}x-tutor .msg.img{background-color:#000;background-size:cover;height:100px;width:150px}x-tutor .msg.video{background:#000;border-radius:3px;overflow:hidden}x-tutor .msg.video iframe{border:none;display:block;height:126px;width:224px}x-tutor .msg p{margin:0}x-tutor .msg .source{color:hsla(0,0%,100%,.5);font-size:10px;margin-top:2px;text-align:right}x-tutor .msg a{transition:color .2s}x-tutor .msg a:hover{color:#fff}html.webview x-tutor .chat-footer:not(.focus){border-bottom:env(safe-area-inset-bottom) solid #d0d3da;transition:border-bottom-width .3s}html.webview x-tutor .msg.archie{border-radius:28px;padding:8px}p .var,p .var strong{color:#cd0e66}.circled .var,.circled.var,.pill .var,.pill.var{color:#fff}x-var{-webkit-touch-callout:none;background:transparent;background:#cd0e66;border-radius:6px;color:hsla(0,0%,100%,.8);cursor:pointer;display:inline-block;line-height:28px;margin:-3px 2px;padding:0 18px;position:relative;touch-action:none;transition:color .2s,box-shadow .2s}.caption x-var{height:24px;line-height:24px}x-var:before{background:none;bottom:1px;content:" ";height:3px;left:5px;position:absolute;right:5px}x-var .left,x-var .right{opacity:.6;padding:7px 1px;position:absolute;top:0;transition:opacity .2s}x-var .left svg,x-var .left x-icon,x-var .right svg,x-var .right x-icon{color:#fff;display:block}x-var .left{left:0;padding-right:4px}x-var .right{padding-left:4px;right:0}x-var .bubble{bottom:28px;left:50%;margin-left:-60px;opacity:0;padding-bottom:6px;pointer-events:none;position:absolute;transform:scale(.5);transform-origin:bottom center;transition:transform .2s,opacity .2s;width:120px;z-index:500}x-var .bubble-box{background:#cd0e66;border-radius:6px;box-shadow:0 0 15px rgba(0,0,0,.15);display:block;height:10px;position:relative}x-var .bubble-arrow{border-left:6px solid transparent;border-right:6px solid transparent;border-top:6px solid #cd0e66;bottom:0;display:block;height:0;left:50%;margin-left:-6px;position:absolute;width:0}x-var .progress{background:#fff;border-radius:6px;bottom:2px;display:block;left:2px;position:absolute;top:2px}x-var.on,x-var:hover{box-shadow:0 0 20px rgba(0,0,0,.3);color:#fff}x-var.on .left,x-var.on .right,x-var:hover .left,x-var:hover .right{opacity:1}x-var.on .bubble,x-var:hover .bubble{opacity:1;transform:none}.var-overlay{display:none;height:100%;left:0;position:absolute;position:fixed;top:0;width:100%;z-index:999}x-play-btn{display:block;left:50%;position:absolute;top:50%}x-play-btn .play-btn-box{background:rgba(0,0,0,.8);border-radius:6px;cursor:pointer;height:44px;margin:-24px;opacity:.9;padding:2px;transition:transform .2s,opacity .2s,background .2s;width:44px}x-play-btn .play-btn-box x-icon{fill:#fff}x-video x-play-btn .play-btn-box{border:1px solid hsla(0,0%,100%,.8);margin:-25px;pointer-events:none}x-play-btn .play-btn-box:focus,x-play-btn .play-btn-box:hover,x-video:hover x-play-btn .play-btn-box{background:rgba(0,0,0,.9);opacity:1;transform:scale(1.2)}x-video.playing x-play-btn .play-btn-box{opacity:0;transform:scale(.2)}x-play-toggle,x-video{display:block}x-video{margin:0 auto;max-width:100%;position:relative}x-video .video-wrap{cursor:pointer;height:0}x-video video{-webkit-touch-callout:none;border-radius:4px;height:100%;position:absolute;width:100%}x-video x-icon{fill:#fff;display:block}x-video .credit{background:rgba(0,0,0,.8);border-top-right-radius:4px;color:#fff;font-size:10px;opacity:0;padding:1px 8px;position:absolute;right:0;top:0;transition:opacity .2s}x-video .credit:empty{display:none}x-video:hover .credit{opacity:.8}x-video .controls{display:none;transition:opacity .2s}x-video.playing:not(:hover) .controls{opacity:0}x-video .shadow{background:linear-gradient(180deg,transparent,#000);bottom:0;height:50px;opacity:.5;position:absolute;width:100%}x-video .play-pause-btn{bottom:0;cursor:pointer;left:0;padding:6px;position:absolute;transition:transform .2s}x-video .play-pause-btn:hover{transform:scale(1.2)}x-video .pause-icon,x-video.playing .play-icon{display:none}x-video.playing .pause-icon{display:block}x-video .timeline{bottom:16px;height:12px;left:50px;position:absolute;right:60px}x-video .bar{cursor:pointer;height:4px;padding:4px 0;position:relative}x-video .bar>*{border-radius:2px;height:4px;position:absolute;top:4px}x-video .background{width:100%}x-video .background,x-video .buffer{background:hsla(0,0%,100%,.5)}x-video .handle,x-video .progress{background:#cd0e66}x-video .handle{border-radius:8px;cursor:pointer;height:14px;margin-left:-7px;position:absolute;top:-1px;transition:transform .2s,background .2s;width:14px}x-video .handle:active,x-video .handle:hover{background:#f01e7f;transform:scale(1.4)}x-video .timecode{bottom:9px;color:#fff;font-size:16px;pointer-events:none;position:absolute;right:16px}x-tabbox{display:block;margin:1.5em 0}x-tabbox .body{background:#f5f5f6;border-radius:6px;padding-top:18px}html[theme=dark] x-tabbox .body{background:#2d2c38}x-tabbox .tab{display:none;padding:1em 24px}x-tabbox .tab p:last-child{margin-bottom:0}x-tabbox.full-width .tab{padding:0;position:relative}x-tabbox.full-width .tab svg{margin:0}x-select.tabs,x-tabbox .titles{-webkit-overflow-scrolling:touch;display:flex;margin:0 auto -18px;max-width:calc(100% - 12px);overflow:auto;overscroll-behavior:contain;width:-moz-fit-content;width:fit-content}x-select.tabs{position:relative;z-index:1}x-tabbox.sticky .titles{position:sticky;top:48px;z-index:2}.webview x-tabbox.sticky .titles{top:4px}x-select.tabs>*,x-tabbox h3{background:#c5c2cc;border:1px solid #fff;color:#333;cursor:pointer;flex-shrink:0;font-size:18px;font-weight:600;height:36px;line-height:36px;margin:0;padding:0 16px;text-align:center;transition:color .2s,background .2s}html[theme=dark] x-select.tabs>*,html[theme=dark] x-tabbox h3{background:#a7a6ab;border-color:#22212e;color:#3a3645}x-select.tabs>:focus,x-select.tabs>:hover,x-tabbox h3:focus,x-tabbox h3:hover{background:#807c89;color:#fff}x-select.tabs>.active,x-tabbox h3.active{background:#3a3645;color:#fff;cursor:default}html[theme=dark] x-select.tabs>.active,html[theme=dark] x-tabbox h3.active{background:#e9e9ea}x-select.tabs>:first-child,x-tabbox h3:first-child{border-radius:20px 0 0 20px}x-select.tabs>:last-child,x-tabbox h3:last-child{border-bottom-right-radius:20px;border-top-right-radius:20px}x-select.tabs>:nth-child(n+2),x-tabbox h3:nth-child(n+2){border-left:none}x-select.tabs>* .check,x-tabbox h3 .check{border:1px solid #fff;margin:0 -6px 3px 6px}@media screen and (max-width:540px){x-tabbox{margin:1.5em -24px}x-tabbox .body{border-radius:0;padding:0}x-select.tabs,x-tabbox .titles{margin:0 0 0 -1px;max-width:100%}x-select.tabs>:first-child,x-tabbox h3:first-child{border-radius:0}x-select.tabs>:last-child,x-tabbox h3:last-child{border-radius:0 8px 0 0}}body,html{-webkit-text-size-adjust:none;-moz-text-size-adjust:none;text-size-adjust:none;touch-action:pan-y;-webkit-user-select:none;-moz-user-select:none;user-select:none}main{padding:44px 40px 0 320px}x-course{display:block}article{margin:0 auto;max-width:760px;-webkit-user-select:text;-moz-user-select:text;user-select:text}h1{color:#000;font-weight:600;margin:112px 0 64px}html[theme=dark] h1{color:#fff}.course-title{display:none;font-size:24px;opacity:.3}.steps{min-height:calc(100vh - 664px)}.page-background{bottom:0;left:280px;position:fixed;right:0;top:44px;z-index:-1}article.dark .page-background{background:#000}.reveal-banner{background:hsla(255,7%,76%,.95);border-radius:0 24px 24px 0;color:#fff;font-size:13px;left:280px;line-height:17px;padding:4px 18px 4px 16px;position:fixed;top:60px;transition:transform .4s,opacity .4s;z-index:100}.reveal-banner svg{display:inline-block;margin:0 0 -2px 3px}.reveal-banner path{stroke:#fff;fill:none;stroke-width:1.5px;stroke-linecap:round}.reveal-banner .complete{cursor:pointer;display:block;width:-moz-fit-content;width:fit-content}.reveal-banner .complete:hover{text-decoration:underline}.reveal-banner.off{opacity:0;transform:translateX(-100%)}.section-dev{color:#999;text-align:center}.section-dev svg{fill:#999;margin:0 auto 6px;width:120px}.section-dev h2{margin:0 0 12px}footer{display:none;height:320px;padding-top:80px;position:relative}.next-section{display:none;margin:0 auto;max-width:100%;transition:transform .2s,filter .2s;width:-moz-max-content;width:max-content}.next-section:focus,.next-section:hover{filter:drop-shadow(0 4px 12px rgba(0,0,0,.25));transform:scale(1.05)}.next-arrow{border-radius:6px;box-sizing:border-box;color:#fff;height:74px;line-height:1.4;-webkit-mask:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22720%22%20height%3D%2274%22%3E%3Cpath%20d%3D%22M718.8%2C34.2%2C705.2%2C2.8A4.9%2C4.9%2C0%2C0%2C0%2C701%2C0H0V74H701a4.9%2C4.9%2C0%2C0%2C0%2C4.2-2.8l13.6-31.4A7.7%2C7.7%2C0%2C0%2C0%2C718.8%2C34.2Z%22%2F%3E%3C%2Fsvg%3E");mask:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22720%22%20height%3D%2274%22%3E%3Cpath%20d%3D%22M718.8%2C34.2%2C705.2%2C2.8A4.9%2C4.9%2C0%2C0%2C0%2C701%2C0H0V74H701a4.9%2C4.9%2C0%2C0%2C0%2C4.2-2.8l13.6-31.4A7.7%2C7.7%2C0%2C0%2C0%2C718.8%2C34.2Z%22%2F%3E%3C%2Fsvg%3E");-webkit-mask-position:right top;mask-position:right top;-webkit-mask-size:720px 74px;mask-size:720px 74px;max-width:100%;padding:8px 36px 0 18px;position:relative;transition:background .2s;-webkit-user-select:none;-moz-user-select:none;user-select:none}.next-arrow .small{color:hsla(0,0%,100%,.6);font-size:16px}.next-arrow .title{font-size:26px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.next-arrow .next-icon{background-position:50%;background-size:cover;border-radius:6px 0 0 6px;border-right:2px solid #fff;height:74px;left:0;position:absolute;top:0;width:74px}.next-arrow .next-icon+.small,.next-arrow .next-icon+.small+.title{padding-left:74px}.skip-step{bottom:0;box-sizing:border-box;color:#888;display:none;font-size:14px;line-height:20px;margin:0;padding:0 40px 24px;position:absolute;text-align:center;width:100%}html[theme=dark] .skip-step{color:#fff}.skip-step a{white-space:nowrap}x-course.ready .skip-step{display:block}@media (max-width:650px){.skip-step br{display:none}}.skip-step svg{display:block;margin:8px auto 0}@media screen and (max-width:840px){main{padding:44px 40px 0}.page-background{left:0}h1{margin:80px 0 54px}.course-title{display:block}.reveal-banner{left:0}}@media screen and (max-width:540px){main{padding:44px 24px 0}.overflow-wrap{margin-left:-24px;margin-right:-24px;padding:0 24px}}@media print{.page-background,footer,header,x-course-sidebar,x-tutor{display:none!important}main{margin:0!important;padding:0 20px!important}article{max-width:none!important}}html.webview main{padding:0 calc(40px + env(safe-area-inset-right)) 0 calc(40px + env(safe-area-inset-left))}html.webview .page-background{left:0;top:0}html.webview .skip-step{padding:0 40px calc(24px + env(safe-area-inset-bottom))}html.webview .steps{min-height:calc(100vh - 620px)}html.webview .reveal-banner{left:0;padding-left:calc(12px + env(safe-area-inset-left));top:16px}@media screen and (max-width:540px){html.webview main{padding:0 calc(24px + env(safe-area-inset-right)) 0 calc(24px + env(safe-area-inset-left))}html.webview .skip-step{background:#eee;margin:0 calc(-24px - env(safe-area-inset-right)) -6px calc(-24px - env(safe-area-inset-left));padding:14px 90px calc(14px + env(safe-area-inset-bottom)) 24px;text-align:left;width:auto}html[theme=dark] html.webview .skip-step{background:#444}}x-algebra-flow,x-math{position:relative}x-algebra-flow svg.equation,x-math svg.equation{fill:currentColor;overflow:visible;width:100%}x-algebra-flow svg.equation *,x-math svg.equation *{transform-origin:0 0}x-algebra-flow .overlay,x-math .overlay{left:0;position:absolute;top:0}x-algebra-flow .overlay>*,x-math .overlay>*{position:absolute;transform-origin:0 0}x-algebra-flow line,x-algebra-flow path,x-math line,x-math path{fill:none;stroke:currentColor;stroke-width:1.45;stroke-linejoin:round;stroke-linecap:round;transform-box:view-box;transform-origin:top left}x-algebra-flow text,x-math text{dominant-baseline:text-before-edge;stroke:currentColor;fill:currentColor;stroke-width:0;font-family:Mathigon Symbol,Source Sans Pro,sans-serif}x-algebra-flow text.font-normal,x-math text.font-normal{font-family:Source Sans Pro,Helvetica,sans-serif}x-math{display:inline-block;font-style:normal}x-math svg.equation{height:100%}x-algebra-flow{display:block;margin:1.5em auto;max-width:440px;position:relative}x-algebra-flow .legend-box{border-top:2px solid #ccc;font-size:16px;line-height:1.5}x-algebra-flow .legend-box p{display:none}x-algebra-flow .legend-box li{display:none;margin:0;padding:8px 48px 0;text-align:center}x-algebra-flow .nav{height:0;position:relative}x-algebra-flow .back,x-algebra-flow .next{border-radius:0 0 6px 6px;display:block;height:36px;min-width:0;padding:0;position:absolute;top:0;transition:opacity .4s,background .2s,color .2s,box-shadow .2s,transform .2s;width:36px;z-index:1}x-algebra-flow .back.hide,x-algebra-flow .next.hide{opacity:0;pointer-events:none}x-algebra-flow .back x-icon,x-algebra-flow .next x-icon{margin:6px}x-algebra-flow .back{transform-origin:left top}x-algebra-flow .next{right:0;transform-origin:right top}.m-red{color:#cd0e66}.m-blue{color:#0f82f2}.m-green{color:#22ab24}.m-yellow{color:#fd8c00}.m-orange{color:#eb4726}.m-purple{color:#6d3bbf}.m-teal{color:#009ea6}.m-lime{color:#bfc212}.lgrey{color:#aaa}.gradient-red{background:#cd0e66 linear-gradient(to bottom right,#cd0e66,#eb4726)}.gradient-orange{background:#eb4726 linear-gradient(to bottom right,#eb4726,#fd8c00)}.gradient-yellow{background:#fd8c00 linear-gradient(to bottom right,#fd8c00,#bfc212)}.gradient-lime{background:#bfc212 linear-gradient(to bottom right,#bfc212,#22ab24)}.gradient-green{background:#22ab24 linear-gradient(to bottom right,#22ab24,#009ea6)}.gradient-teal{background:#009ea6 linear-gradient(to bottom right,#009ea6,#0f82f2)}.gradient-blue{background:#0f82f2 linear-gradient(to bottom right,#0f82f2,#6d3bbf)}.gradient-purple{background:#6d3bbf linear-gradient(to bottom right,#6d3bbf,#cd0e66)}@media (min-width:601px){header .nav-small{display:none!important}}@media (max-width:600px){header .nav-large{display:none!important}header .nav-item>.nav-link{padding:4px 12px}}x-modal#login{width:500px}x-modal#login .modal-body{padding:24px 16px 12px}x-modal#login h2{text-align:center}x-modal#login .btn-row.social{display:flex;flex-wrap:wrap;justify-content:center}x-modal#login .btn-row.social .btn,x-modal#login .btn-row.social .icon-btn,x-modal#login .btn-row.social .next-step{margin:6px;width:140px}x-modal#login .hr{background:#c5c2cc;height:1px;margin:1em 8px;position:relative}x-modal#login .hr span{background:#fff;color:#aaa;display:block;font-size:14px;left:50%;line-height:1;margin-top:-7px;padding:0 12px;position:absolute;text-align:center;text-transform:uppercase;transform:translateX(-50%);white-space:nowrap}.polypad,.tangram{--canvas-bg:#fff;--canvas-fg:#181824}[theme=dark] .polypad,[theme=dark] .tangram{--canvas-bg:#22212e;--canvas-fg:#e2e1e6}x-equation{-webkit-touch-callout:none;background:transparent;background:#0f82f2;border-radius:6px;color:#fff;cursor:pointer;cursor:text;display:inline-block;height:auto;line-height:28px;margin:0;padding:4px 34px 4px 12px;position:relative;text-align:left;transition:background .2s,color .2s,padding .2s,box-shadow .2s}.caption x-equation{height:24px;line-height:24px}x-equation:before{background:none;bottom:1px;content:" ";height:3px;left:5px;position:absolute;right:5px}x-equation.small{font-size:1em;line-height:24px;padding:2px 28px 2px 8px}x-equation.active{z-index:1}x-equation.done{background:none;box-shadow:none;color:#0f82f2;cursor:default;padding:0}html.is-tabbing x-equation.active{box-shadow:0 0 0 2px currentColor,0 0 0 4px #0f82f2}x-equation .input{height:0;overflow:hidden;position:absolute;transform:scale(0);width:0}x-equation.done .input{display:none}x-equation:not(.done) mi+mi{margin-left:0}x-equation>.math{display:inline-block;min-width:80px}x-equation.small .math{min-width:25px}x-equation .math.empty{margin-right:-6px}x-equation .math.empty:after{content:"???"}x-equation.small .math.empty:after{margin-left:10px}x-equation.done .math{min-width:0}x-equation .cursor{animation:cursor 1s step-end infinite;border-right:1px solid;display:none;margin-left:-1px}x-equation.active .cursor{display:inline-block}x-equation mrow.empty{min-width:12px;text-align:center}x-equation mrow.empty:after{content:"◻︎";display:inline-block;margin:0 -.5em;opacity:.5}x-equation .keys{left:0;margin-top:6px;opacity:0;pointer-events:none;position:absolute;top:100%;transform:translateY(-12px);transition:opacity .2s,transform .2s;width:136px}x-equation .btn,x-equation .icon-btn,x-equation .next-step{border-radius:4px;float:left;height:24px;line-height:24px;margin:0 6px 6px 0;min-width:0;padding:2px;width:24px}x-equation .btn rect,x-equation .icon-btn rect,x-equation .next-step rect{fill:#fff;opacity:.45}x-equation .btn line,x-equation .icon-btn line,x-equation .next-step line{stroke:#fff}x-equation .btn path,x-equation .icon-btn path,x-equation .next-step path{fill:#fff}x-equation.active .keys{opacity:1;pointer-events:all;transform:none}x-equation .error{margin-top:-12px;pointer-events:none;position:absolute;right:6px;top:50%}x-equation .error-message{background:#cd0e66;border-radius:6px;bottom:100%;box-shadow:0 2px 4px rgba(0,0,0,.2);color:#fff;cursor:pointer;font-size:14px;left:0;line-height:1.4;margin-bottom:10px;max-width:180px;padding:6px 12px;pointer-events:none;position:absolute;transform-origin:18px bottom -6px;width:-moz-max-content;width:max-content;z-index:10}x-equation .error-message p{margin:0;text-align:left!important}x-equation .error-message:after{border:6px solid transparent;border-top-color:#cd0e66;bottom:-12px;content:" ";left:12px;position:absolute}x-equation .error,x-equation .error-message{opacity:0;transform:scale(.5);transition:opacity .2s,transform .2s}x-equation.has-error:not(.active) .error,x-equation.has-error:not(.active) .error-message{opacity:1;transform:none}x-equation.has-error:not(.active) .error-message{pointer-events:all;transition-delay:.4s}x-equation.done .error,x-equation.done .error-message{display:none}x-equation.small .error{margin-top:-10px;right:4px}x-equation.small .error svg{height:18px;width:18px}x-equation-system{display:block}article x-equation-system table td,table.eqn-system td{padding:.2em .3em;text-align:left}table.eqn-system td{vertical-align:baseline}table.eqn-system td:first-child{text-align:right}.tile{transform-box:view-box;transform-origin:0 0}.tile .handle:not(.persistent),.tile .outline{display:none}.tile.active .handle,.tile.active .link-handle,.tile.active .outline{display:block!important}.tile.no-handles.active .handle{display:none!important}x-polypad:not(.author-mode) .hidden-tile{display:none}x-polypad:not(.author-mode) .locked-tile{pointer-events:none}.geo-path.hidden-tile,.geo-point.hidden-tile,.hidden-tile>:not(.outline,.handle){opacity:.4}.link-handle{fill:#0f82f2;stroke:transparent;stroke-width:10}.link-dot{stroke:var(--canvas-bg);fill:#0f82f2;stroke-width:3}.link-bar{stroke:#0f82f2;stroke-width:5px;fill:none;cursor:move}.link-bar path.dashed{stroke-dasharray:6px 10px;stroke-dashoffset:8px}.group-outline,.rotate-bar,.tile .handle,.tile .outline{stroke-width:6px}.group-outline,.rotate-bar,.tile .outline{stroke:var(--canvas-fg);fill:none}.hidden-tile .outline,.locked-tile .outline{stroke-dasharray:10px 16px}.rotate-circle,.tile .handle{fill:var(--canvas-fg)}.tile path.handle{stroke:var(--canvas-fg)}.group-outline,.rotate-bar{pointer-events:none}.group-shadow{fill:var(--canvas-fg);opacity:15%}.rotate-circle,.tile circle.handle{stroke:transparent;stroke-width:8px}.rotate-circle{cursor:move}.balance,.number-grid-cell circle,.number-tile,.polygon-tile{stroke:var(--canvas-bg);stroke-width:1px}.high-contrast .balance,.high-contrast .number-grid-cell circle,.high-contrast .number-tile,.high-contrast .polygon-tile{stroke:var(--canvas-fg);stroke-width:2px}.prime-move,.prime-segment:hover{stroke:var(--canvas-fg);stroke-width:3px}.grid-axis,.number-line-ticks{stroke-width:3px}.active .grid-axis,.active .number-line-ticks{stroke-width:6px}.axis-gridlines{stroke-width:2px;opacity:.15;pointer-events:none}.penrose-circles{fill:none;stroke-width:2px;stroke:#fff;opacity:.4}.dice-face{stroke-width:4px}.dice-dot{fill:#fff;opacity:.85}.balance-beam{fill:none;stroke-width:8px}.active .balance,.active .balance-beam,.active .bucket{stroke:var(--canvas-fg);stroke-width:6px}.dropzone{fill:none;stroke:var(--canvas-fg);stroke-width:4px;stroke-dasharray:8px 12px;stroke-dashoffset:4px;pointer-events:none}.spinner{fill:var(--canvas-fg);stroke:var(--canvas-bg)}.spinner,pp-tiles .spinner{stroke-width:1px}.utensil .glass{fill:hsla(258,9%,78%,.7)}.utensil .ticks{stroke-width:.6;stroke:var(--canvas-fg);stroke-linecap:butt;pointer-events:none}.utensil .compass-frame,.utensil .compass-legs{fill:#c5c2cc}.utensil .compass-needle,.utensil .compass-top{fill:#656073}.utensil .compass-screw{fill:#c5c2cc}.utensil .compass-pencil{stroke:#656073}.utensil text{fill:var(--canvas-fg);font-size:12px}.polypad.dark .utensil .glass{fill:rgba(101,96,115,.7)}.polypad.dark .utensil .compass-legs{fill:#656073}.polypad.dark .utensil .compass-needle{fill:#c5c2cc}.dot-cell{fill:none;stroke-width:20px;fill-opacity:.3}.bead-gradient{stroke:var(--canvas-bg);fill:url(#sphere-gradient);pointer-events:none}.active .bead-gradient{stroke:var(--canvas-fg);stroke-width:6px}.clock-handle{stroke:transparent;stroke-width:16px;cursor:move;transform-origin:bottom center}.axis-label{font-size:16px;font-weight:700}.axis-label,.geo-label{stroke:var(--canvas-bg);stroke-width:4px;stroke-linejoin:round;paint-order:stroke}.is-safari .axis-label,.is-safari .geo-label{stroke:none}.no-labels text{display:none}.number-line-label,.polygon-label,.polygon-text-label{font-weight:600}.number-line-label,.polygon-label{font-size:18px}.polygon-text-label{pointer-events:none}.number-line-label{transform-box:fill-box;transform-origin:center}.fraction .equation text,.number-line .equation text{font-weight:600}.fraction .equation line{stroke-width:2px}.number-grid-cell.active circle{stroke:var(--canvas-fg);stroke-width:6px}.number-grid-cell text{font-size:24px}.card-label path,.card-label rect{fill:var(--canvas-fg)}.card-label text{stroke:none;fill:var(--canvas-bg);font-size:14px;font-weight:600}.hidden-input{display:none;height:0;overflow:hidden;position:absolute;transform:scale(0);width:0}.problem-box{stroke:#0f82f2;stroke-width:4px;fill:rgba(15,130,242,.25);transition:stroke .3s,fill .3s}.correct .problem-box{stroke:#22ab24;fill:rgba(34,171,36,.25)}.incorrect .problem-box{stroke:#cd0e66;fill:rgba(205,14,102,.25)}.active .problem-box{stroke-width:6px}.problem-text{fill:var(--canvas-fg);color:var(--canvas-fg);cursor:text;font-size:32px;text-align:center}.problem-marker{transform:scale(0);transition:transform .2s cubic-bezier(.33,1.9,.52,.7)}.problem-marker.show{transform:none}.action-card-text{cursor:text;display:none;font-size:20px;text-align:center}@keyframes cursor{0%,to{opacity:1}50%{opacity:0}}.equation{transform-origin:0 0}.equation line,.equation path{fill:none;stroke:currentColor;stroke-width:1.45;transform-box:view-box;transform-origin:top left}.equation text{dominant-baseline:text-before-edge;stroke:currentColor;fill:currentColor;stroke-width:0;font-family:Mathigon Symbol,Source Sans Pro,sans-serif}.equation text.font-normal{font-family:Source Sans Pro,Helvetica,sans-serif}.equation .placeholder{fill:currentColor;opacity:.3}.equation .cursor{stroke:#0f82f2;stroke-width:1.5px;animation:cursor 1s step-end infinite}.equation .range{fill:#87c1f9}.geo-path{fill:none;stroke:currentColor;stroke-width:3px}.geo-path.fill{fill:currentColor;stroke:none;opacity:.5}.geo-path.fill.hover{opacity:.8}.geo-point{fill:currentColor}.geo-point.intersection{stroke:currentColor;stroke-width:3px;fill:var(--canvas-bg)}svg:not(:hover) .geo-point.pending{display:none!important}.geo-shadow{stroke-width:10px;stroke:currentColor;fill:none;display:none}.table-tile{background:var(--canvas-bg);border-left:1px solid var(--border);border-top:1px solid var(--border);display:grid;width:-moz-fit-content;width:fit-content}.table-tile.active{cursor:text}.table-selection{stroke:var(--canvas-fg);fill:var(--canvas-fg);fill-opacity:10%;stroke-width:5px;pointer-events:none}.table-cell{-webkit-user-modify:read-write-plaintext-only;border-bottom:1px solid var(--border);border-right:1px solid var(--border);box-sizing:border-box;color:var(--canvas-fg);font-size:20px;height:50px;line-height:45px;max-width:200px;min-width:100px;padding:2px 8px;text-align:center;-webkit-user-select:text;-moz-user-select:text;user-select:text;white-space:pre}.table-cell.header{background:var(--header);font-weight:700}.table-cell:focus{outline:none}.table-cell:focus:empty{content:"​";display:inline}.table-cell .table-color{border-radius:15px;display:inline-block;height:30px;margin-bottom:-8px;width:30px}.table-hidden{left:0;opacity:0;pointer-events:none;position:fixed;top:0}.chart-line{fill:none;stroke-width:3}.chart-outline{fill:none;stroke-width:6px;stroke:var(--canvas-fg)}.chart-shadow{stroke-width:10px;fill:none;opacity:.4}.donut-hole{fill:var(--canvas-bg)}.chart-focussed{cursor:pointer}@keyframes speaker-move{0%{transform:none}50%{transform:translateX(3px)}to{transform:none}}@keyframes metronome{0%{transform:rotate(-30deg)}50%{transform:rotate(30deg)}to{transform:rotate(-30deg)}}.effects-speaker-move{animation:speaker-move .1s}.polypad svg.overlay,x-polypad{stroke-linecap:round;stroke-linejoin:round;text-anchor:middle}x-polypad{text-anchor:middle;background:var(--canvas-bg);display:block;overflow:hidden;position:relative;touch-action:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}x-polypad .canvas{height:100%;outline:none;width:100%}x-polypad .html-overlay,x-polypad .html-overlay>*{left:0;position:absolute;top:0}x-polypad .selection{stroke:#87c1f9;fill:rgba(135,193,249,.5);display:none}x-polypad .stroke{stroke-width:3px;fill:none}x-polypad .stroke.marker{stroke-width:8px}x-polypad .stroke.highlighter{stroke-width:24px;mix-blend-mode:multiply;opacity:.4}x-polypad .stroke.cut{stroke:var(--canvas-fg);stroke-dasharray:10px}.dark x-polypad .stroke.highlighter{mix-blend-mode:screen}x-polypad[data-tool=text]{cursor:text}x-polypad[data-tool=pan]{cursor:move}x-polypad[data-tool=cutPolygon],x-polypad[data-tool=geoPending],x-polypad[data-tool=geo]{cursor:crosshair}x-polypad .geo-paths,x-polypad .geo-points,x-polypad .geo-shadows,x-polypad .grid,x-polypad .selection,x-polypad .strokes,x-polypad:not([data-tool=move]) .tiles{pointer-events:none}x-polypad .grid{opacity:var(--grid-opacity,.25)}x-polypad.high-contrast .grid{opacity:1}x-polypad .geo-shadows{opacity:.3}x-polypad .grid-pattern line,x-polypad .grid-pattern rect{stroke:var(--canvas-fg);fill:none}x-polypad .grid-pattern .filled,x-polypad .grid-pattern circle{fill:var(--canvas-fg);stroke:none}x-polypad .text-edit{-webkit-user-modify:read-write-plaintext-only;word-wrap:normal;font-size:20px;line-height:1.4em;padding:2px 8px;-webkit-user-select:text;-moz-user-select:text;user-select:text;width:-moz-fit-content;width:fit-content}x-polypad .text-edit[contenteditable]{cursor:text}x-polypad .image-drop{background:rgba(15,130,242,.1);border:6px dashed #0f82f2;box-sizing:border-box;display:none;height:100%;left:0;pointer-events:none;position:absolute;top:0;width:100%}x-polypad .tile-error{background:#fec680;border-radius:6px;bottom:calc(100% + 10px);box-shadow:0 2px 6px rgba(0,0,0,.1);color:#000;font-size:16px;left:-12px;line-height:1.4;padding:5px 10px;position:relative;position:absolute;text-align:left;top:auto;transform-origin:24px bottom -6px;width:260px}x-polypad .tile-error:after{border-left:8px solid transparent;border-right:8px solid transparent;border-top:8px solid #fec680;content:"";display:block;left:50%;left:24px;margin-left:-8px;position:absolute;top:100%}x-polypad .tile-error button{color:#0f82f2;cursor:pointer}x-polypad .tile-error button:focus,x-polypad .tile-error button:hover{text-decoration:underline}x-polypad.handdrawn .canvas{filter:url(#handdrawn)}x-polypad.handdrawn .geo-paths,x-polypad.handdrawn .strokes{filter:url(#pencil)}x-polypad .bg-icon{bottom:-60px;opacity:.1;pointer-events:none;position:absolute;right:-60px}x-polypad .rotate-label{background-color:#181824;border:1px solid;border-color:var(--canvas-bg);border-radius:6px;color:#fff;font-size:14px;font-weight:600;padding:0 7px 1px;pointer-events:none;position:absolute;top:0}.input-field{background:hsla(0,0%,100%,.1);border:1px solid hsla(0,0%,100%,.16);border-radius:5px;line-height:24px;text-align:center}.input-field:focus,.input-field:hover{background-color:hsla(0,0%,100%,.18)}select.input-field{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22rgba(255%2C%20255%2C%20255%2C%200.5)%22%20d%3D%22m19.9%207.5a1.4%201.4%200%200%200%20-2.1%200l-5.8%205.8-5.8-5.8a1.4%201.4%200%200%200%20-2.1%200%201.5%201.5%200%200%200%200%202.1l6.8%206.9a1.6%201.6%200%200%200%202.2%200l6.8-6.9a1.4%201.4%200%200%200%200-2.1z%22%2F%3E%3C%2Fsvg%3E");background-position:top 6px right 5px;background-repeat:no-repeat;background-size:16px 16px;cursor:pointer;padding:0 24px 0 8px;text-align:left;width:auto}select.input-field option{color:initial}input.toggle[type=checkbox]{-webkit-appearance:none;-moz-appearance:none;appearance:none;height:0;position:absolute;width:0}input.toggle+.control{background:hsla(0,0%,100%,.3);border-radius:12px;content:"";cursor:pointer;display:block;height:10px;padding:1px 0;transition:background .2s;width:32px}input.toggle+.control:after{background-color:#9d9ba2;border-radius:12px;content:"";display:block;height:18px;margin:-4px -1px;transition:transform .2s;width:18px}input.toggle:checked+.control{background:#0f82f2}input.toggle:checked+.control:after{background:#ebebec;transform:translateX(16px)}input.toggle:indeterminate+.control:after{background:#c4c3c7;transform:translateX(8px)}.is-tabbing input.toggle:focus+.control{outline:auto}x-factris{background:#083781;border-radius:0 0 12px 12px;color:#fff;display:block;font-family:Comfortaa,sans-serif;line-height:1.15;padding:10px;-webkit-user-select:none;-moz-user-select:none;user-select:none;z-index:1}x-factris .factris-body{background:#0b4bb1;border-radius:8px;box-shadow:0 -4px 0 #06275b;height:500px;margin-top:4px;overflow:hidden;position:relative;width:340px}x-factris .factris-panel-left,x-factris .factris-panel-right,x-factris .factris-panel-top{background:#083781;position:absolute}x-factris .factris-panel-top{border-radius:12px 12px 0 0;bottom:100%;left:50%;margin-left:-90px;padding-top:10px;text-align:center;width:180px}x-factris .factris-panel-top .corner.left{bottom:-1px;left:-12px}x-factris .factris-panel-top .corner.right{bottom:-1px;right:-12px}x-factris .factris-panel-left{border-radius:12px 0 0 12px;left:-120px;padding:10px 0 10px 10px;text-align:right;top:0;width:110px}x-factris .factris-panel-left .corner{bottom:-16px;right:-1px}x-factris .factris-panel-right{border-radius:0 12px 12px 0;padding:10px 10px 10px 0;right:-100px;text-align:center;top:0;width:90px}x-factris .factris-panel-right .corner{bottom:-16px;left:-1px}x-factris,x-factris .factris-panel-left,x-factris .factris-panel-right{box-shadow:0 4px 0 #041e47}x-factris .corner{position:absolute}x-factris .corner path{fill:#083781}x-factris .corner path.dark{fill:#041e47}x-factris .play{fill:#fff;border:10px solid #fff;border-radius:100%;box-shadow:0 4px 0 #06275b,inset 0 4px 0 #06275b;cursor:pointer;display:block;left:50%;margin-left:-50px;position:absolute;top:50%}x-factris .play svg{display:block}x-factris .logo{filter:drop-shadow(0 4px 0 #06275b);height:60px;left:50%;margin:-100px 0 0 -100px;position:absolute;top:50%;width:200px}x-factris .overlay{font-size:48px;font-weight:700;left:0;position:absolute;text-align:center;text-shadow:0 2px 0 #06275b;top:71px;width:100%;z-index:10}x-factris .logo,x-factris .overlay,x-factris .play{opacity:0;pointer-events:none;transform:scale(.5);transition:opacity .2s linear,transform .4s cubic-bezier(.33,1.9,.52,.7)}x-factris .logo.show,x-factris .overlay.show,x-factris .play.show{opacity:1;pointer-events:all;transform:none}x-factris button{background:#cd0e66;border:none;border-radius:4px;box-shadow:0 4px 0 #6e0736;cursor:pointer;transition:transform .08s,box-shadow .08s,background .08s}x-factris button x-icon{fill:#fff}x-factris button .icon{fill:#fff;margin:0 auto}x-factris button:focus,x-factris button:hover{background:#f01e7f}x-factris button.active,x-factris button:active{background:#cd0e66;box-shadow:none;transform:translateY(4px)}x-factris .factris-keys{display:flex;justify-content:center;margin-bottom:4px;margin-top:10px}x-factris .factris-keys>button{width:50px}x-factris .factris-keys>button x-icon{margin-top:6px}x-factris .keys-center{display:flex;flex-direction:column;margin:0 14px;width:100px}x-factris .keys-center button{width:100px}x-factris .keys-center button:first-child{height:42px;margin-bottom:14px}x-factris .keys-center button:first-child x-icon{margin-bottom:-4px}x-factris .keys-center button:last-child x-icon{margin:-5px 0 -7px}x-factris .keys-play{display:flex;margin-bottom:12px}x-factris .keys-play x-icon{margin-top:5px}x-factris .keys-play button{height:48px;width:50px}x-factris .keys-play button:first-child{margin-right:10px}x-factris .discharge{border-radius:100%;height:74px;margin:8px 0 4px;width:74px}x-factris .discharge-count{display:inline-block;margin:8px 0 4px}x-factris .discharge-count circle{fill:none;stroke:#fff;stroke-width:10px;stroke-dasharray:201px;transform:rotate(-90deg);transition:stroke-dashoffset .2s}x-factris .discharge-count text{fill:#fff;text-anchor:middle;font-family:inherit}x-factris .discharge-count text.large{font-size:22px;font-weight:700}x-factris .discharge-count text.small{font-size:9px}x-factris .text-small{font-size:14px;white-space:nowrap}x-factris .text-large{font-size:28px;font-weight:700;white-space:nowrap}x-factris .text-large.margin{margin-top:8px}x-factris .text-large.narrow{letter-spacing:-.07em}x-factris hr{background:hsla(0,0%,100%,.2);height:2px;margin:8px 0 10px}x-factris .highscore-panel{text-align:left}x-factris .highscore-title{font-size:16px;margin-bottom:8px}x-factris .highscore-panel table{font-size:12px;line-height:1.3;opacity:.8;width:100%}x-factris .highscore-panel table td:nth-child(2){text-align:right}x-factris .highscore-panel table a:hover{opacity:1;text-decoration:underline}x-factris .highscore{height:100%;left:0;overflow:auto;position:absolute;top:0;width:100%}x-factris .highscore .text-large{margin:40px;text-align:center}x-factris .highscore x-icon{fill:#fff;margin-bottom:-6px}x-factris .highscore table{margin:0 40px;width:calc(100% - 80px)}x-factris .highscore table td{border-bottom:1px solid hsla(0,0%,100%,.5);padding:6px 0 5px}x-factris .highscore table td:last-child{text-align:right}x-factris .highscore table tr:last-child td{border:none}x-factris .factris-board{height:500px;width:340px}x-factris .grid{opacity:.6}x-factris .grid .faint-grid{opacity:.5}x-factris .grid line{stroke:#fff;stroke-linecap:round}x-factris .grid line.thick{stroke-width:2}x-factris .tiles rect{fill:#22ab24;stroke:#6fc871;stroke-width:1;stroke-linejoin:round;transition:fill .2s}x-factris .tiles rect.fixed{fill:#fd8c00;stroke:#feb459}x-factris .tiles rect.removing{fill:#ffe7ca;stroke:#ffe7ca;opacity:0}x-factris .tiles rect.error{fill:#cd0e66;stroke:#df629c}x-factris .tiles.animated rect{transition:fill .2s,stroke .2s,transform .3s,opacity .2s;transition-delay:0s,0s,.7s,.6s}x-factris .scores text{text-anchor:middle;fill:#cd0e66;stroke:#fff;stroke-width:3px;stroke-linejoin:round;font-size:20px;font-weight:700;opacity:0;paint-order:stroke;transform:scale(.5);transition:opacity .2s linear,transform .4s cubic-bezier(.33,1.9,.52,.7)}.is-safari x-factris .scores text{stroke:none}x-factris .scores .visible text{opacity:1;transform:none}x-factris .highscore-btn{display:none}@media (max-height:740px),(max-width:590px){x-factris{display:flex;flex-direction:column;height:100%;padding:0;white-space:nowrap}x-factris,x-factris .factris-panel-left,x-factris .factris-panel-right,x-factris .factris-panel-top{border-radius:0;box-shadow:none}x-factris .corner,x-factris .highscore-panel,x-factris hr{display:none!important}x-factris .factris-body{flex:1 1;margin:4px 10px 0;width:auto}x-factris .factris-board{height:100%;margin:0 auto;width:100%}x-factris .factris-panel-top{background:none;bottom:auto;top:128px;z-index:2}x-factris .factris-panel-top.hide{display:none}x-factris .factris-panel-left,x-factris .factris-panel-right{display:flex;padding:10px;position:static;width:auto}x-factris .factris-panel-left>:first-child,x-factris .factris-panel-right>:first-child{flex-grow:1}x-factris .factris-panel-left{border-bottom:2px solid hsla(0,0%,100%,.2);border-radius:0}x-factris .keys-play button{height:38px;width:40px}x-factris .keys-play button x-icon{margin-top:3px}x-factris .keys-play button x-icon,x-factris .keys-play button x-icon svg{height:32px!important;width:32px!important}x-factris .factris-panel-left .panel-item{width:100px}x-factris .highscore-btn{display:block;margin-left:10px}x-factris .factris-panel-right{border-radius:0;text-align:left}x-factris .factris-panel-right .text-large{display:inline-block;margin-right:8px}x-factris .factris-panel-right .text-large:after{content:","}x-factris .factris-panel-right .text-large:last-child:after{content:none}x-factris .factris-keys{margin-bottom:14px}html.webview x-factris .factris-keys{margin-bottom:calc(14px + env(safe-area-inset-bottom))}x-factris .discharge{height:39px;margin:-1px 0 0 6px;width:40px}x-factris .discharge x-icon{margin-top:3px}x-factris .discharge x-icon,x-factris .discharge x-icon svg{height:28px!important;width:28px!important}x-factris .discharge-count{height:40px;margin:-1px 0 -1px 6px;width:40px}x-factris .discharge-count text.large{font-size:32px;transform:translateY(11px)}x-factris .discharge-count .small{display:none}x-factris .text-large{font-size:24px}x-factris .text-small{font-size:12px}x-factris .keys-play,x-factris .text-large.margin{margin:0}}marker#axis-arrow{fill:#3a3645}html[theme=dark] marker#axis-arrow{fill:#fff}x-coordinate-sketch,x-coordinate-system,x-geopad{display:block;position:relative}x-coordinate-sketch svg.canvas,x-coordinate-system svg.canvas,x-geopad svg.canvas{display:block;height:100%!important;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:100%}x-coordinate-sketch .grid,x-coordinate-system .grid,x-geopad .grid{opacity:.1}html[theme=dark] x-coordinate-sketch .grid,html[theme=dark] x-coordinate-system .grid,html[theme=dark] x-geopad .grid{opacity:.25}x-coordinate-sketch .grid line,x-coordinate-system .grid line,x-geopad .grid line{stroke:#000;stroke-width:2px}html[theme=dark] x-coordinate-sketch .grid line,html[theme=dark] x-coordinate-system .grid line,html[theme=dark] x-geopad .grid line{stroke:#fff}x-coordinate-sketch .axes line,x-coordinate-system .axes line,x-geopad .axes line{stroke:#3a3645;stroke-width:2px}html[theme=dark] x-coordinate-sketch .axes line,html[theme=dark] x-coordinate-system .axes line,html[theme=dark] x-geopad .axes line{stroke:#fff}x-coordinate-sketch .axes,x-coordinate-sketch .grid,x-coordinate-system .axes,x-coordinate-system .grid,x-geopad .axes,x-geopad .grid{stroke-linecap:round;transition:opacity .2s}x-coordinate-sketch .axes line:not(.tick),x-coordinate-system .axes line:not(.tick),x-geopad .axes line:not(.tick){marker-end:url(#axis-arrow)}x-coordinate-sketch .labels text,x-coordinate-system .labels text,x-geopad .labels text{fill:#3a3645;stroke-width:4px;stroke-linejoin:round;stroke:#fff;font-size:14px;paint-order:stroke}.is-safari x-coordinate-sketch .labels text,.is-safari x-coordinate-system .labels text,.is-safari x-geopad .labels text{stroke:none}html[theme=dark] x-coordinate-sketch .labels text,html[theme=dark] x-coordinate-system .labels text,html[theme=dark] x-geopad .labels text{stroke:#000}x-coordinate-sketch x-gesture,x-coordinate-system x-gesture,x-geopad x-gesture{left:0;position:absolute;top:0}@keyframes pulse{0%{opacity:.6;transform:none}to{opacity:0;transform:scale(3)}}x-coordinate-sketch,x-coordinate-system{color:#cd0e66;margin:2em auto;touch-action:pan-y}x-coordinate-sketch svg,x-coordinate-system svg{stroke-linecap:round;stroke-linejoin:round}x-coordinate-sketch .plot path,x-coordinate-system .plot path{fill:none;stroke:currentColor;stroke-width:3px}x-coordinate-sketch .plot circle,x-coordinate-system .plot circle{fill:currentColor}x-coordinate-sketch .crosshair,x-coordinate-system .crosshair{display:none}x-coordinate-sketch .crosshair circle,x-coordinate-system .crosshair circle{fill:#fff;stroke:currentColor;stroke-width:3px}html[theme=dark] x-coordinate-sketch .crosshair circle,html[theme=dark] x-coordinate-system .crosshair circle{fill:#22212e}x-coordinate-sketch .crosshair path,x-coordinate-system .crosshair path{fill:none;stroke:#3a3645;stroke-width:2px}html[theme=dark] x-coordinate-sketch .crosshair path,html[theme=dark] x-coordinate-system .crosshair path{stroke:#fff}x-coordinate-sketch .crosshair text,x-coordinate-system .crosshair text{fill:currentColor;stroke-width:6px;stroke-linejoin:round;stroke:#fff;font-size:14px;paint-order:stroke}.is-safari x-coordinate-sketch .crosshair text,.is-safari x-coordinate-system .crosshair text{stroke:none}html[theme=dark] x-coordinate-sketch .crosshair text,html[theme=dark] x-coordinate-system .crosshair text{stroke:#000}x-coordinate-sketch g.blue,x-coordinate-sketch.blue,x-coordinate-system g.blue,x-coordinate-system.blue{color:#0f82f2}x-coordinate-sketch g.green,x-coordinate-sketch.green,x-coordinate-system g.green,x-coordinate-system.green{color:#22ab24}x-coordinate-sketch g.yellow,x-coordinate-sketch.yellow,x-coordinate-system g.yellow,x-coordinate-system.yellow{color:#fd8c00}x-coordinate-sketch{cursor:crosshair}x-coordinate-sketch .plot path{stroke-width:8px;opacity:.8}x-geopad{background:#f5f5f6;border-radius:4px;color:inherit;margin:0 auto}html[theme=dark] x-geopad{background:#2d2c38;color:#b2b0b9}x-geopad svg.canvas{position:relative;touch-action:none}x-geopad>canvas,x-geopad>img{height:100%;left:0;max-width:none;position:absolute;top:0;transition:opacity .2s;width:100%}x-geopad .labels text{stroke-width:4px;stroke-linejoin:round;stroke:#f5f5f6;paint-order:stroke}.is-safari x-geopad .labels text{stroke:none}html[theme=dark] x-geopad .labels text{stroke:#2d2c38}x-geopad .labels text.white{stroke:none}.theorem x-geopad{background:transparent}.theorem x-geopad .labels text:not(.white){stroke-width:4px;stroke-linejoin:round;stroke:#f3c3d9;paint-order:stroke}.is-safari .theorem x-geopad .labels text:not(.white){stroke:none}html[theme=dark] .theorem x-geopad .labels text:not(.white){stroke:#000}.tab x-geopad{background:rgba(0,0,0,.03)}.tab x-geopad[grid],x-geopad.no-background,x-geopad[grid]{background:none}.tab x-geopad[grid] .labels text:not(.white),x-geopad.no-background .labels text:not(.white),x-geopad[grid] .labels text:not(.white){stroke-width:4px;stroke-linejoin:round;stroke:#fff;paint-order:stroke}.is-safari .tab x-geopad[grid] .labels text:not(.white),.is-safari x-geopad.no-background .labels text:not(.white),.is-safari x-geopad[grid] .labels text:not(.white){stroke:none}html[theme=dark] .tab x-geopad[grid] .labels text:not(.white),html[theme=dark] x-geopad.no-background .labels text:not(.white),html[theme=dark] x-geopad[grid] .labels text:not(.white){stroke:#22212e}x-geopad .sketch{fill:rgba(101,96,115,.6);display:none;transform-origin:bottom left}x-geopad>.icon-btn{position:absolute;right:8px;top:8px}x-geopad>x-play-toggle{left:8px;position:absolute;top:8px}x-geopad .tools{display:flex;margin:4px 0 0 4px;opacity:0;position:absolute;transition:opacity .3s;transition-delay:1s}x-geopad:hover .tools{opacity:1;transition-delay:0s}x-geopad .tool{background:#c5c2cc;border-radius:3px;box-shadow:none;cursor:pointer;display:none;height:36px;margin:4px;transition:background .2s;width:36px}x-geopad .tool x-icon{fill:#fff;margin:4px}x-geopad .tool:hover{background:#6a637e}x-geopad .tool.active{background:#3a3645}x-geopad[tools*=angleBisector] [data-tool=angleBisector],x-geopad[tools*=circle] [data-tool=circle],x-geopad[tools*=line] [data-tool=line],x-geopad[tools*=move] [data-tool=move],x-geopad[tools*=perpBisector] [data-tool=perpBisector],x-geopad[tools*=point] [data-tool=point],x-geopad[tools*=rectangle] [data-tool=rectangle]{display:block}x-geopad .paths path{fill:none;stroke:currentColor;stroke-width:3px;stroke-linecap:round;stroke-linejoin:round;transition:stroke .2s,stroke-width .2s,fill .2s,opacity .2s,color .2s}x-geopad .paths path.hover,x-geopad .paths path.selected{stroke-width:4px}x-geopad .paths path.thin{stroke-width:2px}x-geopad .paths path.thick{stroke-width:4px}x-geopad .paths path.fill{stroke-width:0;fill:currentColor}x-geopad .paths path[x^="angle("]{stroke-linecap:butt}x-geopad .points circle{fill:#f5f5f6;stroke:currentColor;stroke-width:3px;r:3.5px;transition:r .2s,stroke-width .2s,fill .2s,opacity .2s,color .2s}html[theme=dark] x-geopad .points circle{fill:#2d2c38}x-geopad .points circle.move{r:8px;stroke:transparent;stroke-width:20px;fill:currentColor;touch-action:none}html[theme=dark] x-geopad .points circle.move{fill:currentColor}x-geopad .points circle.hover,x-geopad .points circle.selected{r:6px}x-geopad .points circle.move.hover,x-geopad .points circle.move.selected{r:12px}x-geopad .points circle.pending{transition:none}.focus x-geopad .paths path.focus:not(.fill){stroke-width:5px}.focus x-geopad .points circle.focus{r:8px;stroke-width:5px}.focus x-geopad .points circle.move.focus{r:12px}x-geopad .labels text{fill:currentColor;transition:opacity .2s,color .2s}x-geopad image{transition:opacity .2s}.focus x-geopad image{opacity:.2}x-geopad .transparent,x-geopad .transparent.light{opacity:0}x-geopad .transparent.focus{opacity:1}x-geopad .light,x-geopad .transparent.focus.light{opacity:.5}x-geopad .labels text,x-geopad .paths path,x-geopad .points circle{color:#656073}html[theme=dark] x-geopad .labels text,html[theme=dark] x-geopad .paths path,html[theme=dark] x-geopad .points circle{color:#b2b0b9}x-geopad .labels text.dark,x-geopad .labels text.move,x-geopad .paths path.dark,x-geopad .paths path.move,x-geopad .points circle.dark,x-geopad .points circle.move{color:#3a3645}html[theme=dark] x-geopad .labels text.dark,html[theme=dark] x-geopad .labels text.move,html[theme=dark] x-geopad .paths path.dark,html[theme=dark] x-geopad .paths path.move,html[theme=dark] x-geopad .points circle.dark,html[theme=dark] x-geopad .points circle.move{color:#fff}html[theme=dark] x-geopad .labels text.red,html[theme=dark] x-geopad .paths path.red,html[theme=dark] x-geopad .points circle.red,x-geopad .labels text.red,x-geopad .paths path.red,x-geopad .points circle.red{color:#cd0e66}html[theme=dark] x-geopad .labels text.blue,html[theme=dark] x-geopad .paths path.blue,html[theme=dark] x-geopad .points circle.blue,x-geopad .labels text.blue,x-geopad .paths path.blue,x-geopad .points circle.blue{color:#0f82f2}html[theme=dark] x-geopad .labels text.green,html[theme=dark] x-geopad .paths path.green,html[theme=dark] x-geopad .points circle.green,x-geopad .labels text.green,x-geopad .paths path.green,x-geopad .points circle.green{color:#22ab24}html[theme=dark] x-geopad .labels text.yellow,html[theme=dark] x-geopad .paths path.yellow,html[theme=dark] x-geopad .points circle.yellow,x-geopad .labels text.yellow,x-geopad .paths path.yellow,x-geopad .points circle.yellow{color:#fd8c00}html[theme=dark] x-geopad .labels text.teal,html[theme=dark] x-geopad .paths path.teal,html[theme=dark] x-geopad .points circle.teal,x-geopad .labels text.teal,x-geopad .paths path.teal,x-geopad .points circle.teal{color:#009ea6}html[theme=dark] x-geopad .labels text.orange,html[theme=dark] x-geopad .paths path.orange,html[theme=dark] x-geopad .points circle.orange,x-geopad .labels text.orange,x-geopad .paths path.orange,x-geopad .points circle.orange{color:#eb4726}html[theme=dark] x-geopad .labels text.purple,html[theme=dark] x-geopad .paths path.purple,html[theme=dark] x-geopad .points circle.purple,x-geopad .labels text.purple,x-geopad .paths path.purple,x-geopad .points circle.purple{color:#6d3bbf}html[theme=dark] x-geopad .labels text.lime,html[theme=dark] x-geopad .paths path.lime,html[theme=dark] x-geopad .points circle.lime,x-geopad .labels text.lime,x-geopad .paths path.lime,x-geopad .points circle.lime{color:#bfc212}html[theme=dark] x-geopad .labels text.white,html[theme=dark] x-geopad .paths path.white,html[theme=dark] x-geopad .points circle.white,x-geopad .labels text.white,x-geopad .paths path.white,x-geopad .points circle.white{color:#fff}x-geopad .pulse{fill:#3a3645;animation:pulse 1.8s ease-out infinite}html[theme=dark] x-geopad .pulse{fill:#fff}x-geopad .halo{fill:rgba(58,54,69,.5)}html[theme=dark] x-geopad .halo{fill:hsla(0,0%,100%,.5)}.focus x-geopad .paths path:not(.focus),.focus x-geopad .points circle:not(.focus){color:#e7e6e9}html[theme=dark] .focus x-geopad .paths path:not(.focus),html[theme=dark] .focus x-geopad .points circle:not(.focus){color:#383644}.focus x-geopad .paths path:not(.focus).dark,.focus x-geopad .paths path:not(.focus).move,.focus x-geopad .points circle:not(.focus).dark,.focus x-geopad .points circle:not(.focus).move{color:#e2e2e4}html[theme=dark] .focus x-geopad .paths path:not(.focus).dark,html[theme=dark] .focus x-geopad .paths path:not(.focus).move,html[theme=dark] .focus x-geopad .points circle:not(.focus).dark,html[theme=dark] .focus x-geopad .points circle:not(.focus).move{color:#575660}.focus x-geopad .paths path:not(.focus).red,.focus x-geopad .points circle:not(.focus).red{color:#f1dee8}html[theme=dark] .focus x-geopad .paths path:not(.focus).red,html[theme=dark] .focus x-geopad .points circle:not(.focus).red{color:#4d2641}.focus x-geopad .paths path:not(.focus).blue,.focus x-geopad .points circle:not(.focus).blue{color:#deeaf6}html[theme=dark] .focus x-geopad .paths path:not(.focus).blue,html[theme=dark] .focus x-geopad .points circle:not(.focus).blue{color:#273d5d}.focus x-geopad .paths path:not(.focus).green,.focus x-geopad .points circle:not(.focus).green{color:#e0eee1}html[theme=dark] .focus x-geopad .paths path:not(.focus).green,html[theme=dark] .focus x-geopad .points circle:not(.focus).green{color:#2b4534}.focus x-geopad .paths path:not(.focus).yellow,.focus x-geopad .points circle:not(.focus).yellow{color:#f6ebdd}html[theme=dark] .focus x-geopad .paths path:not(.focus).yellow,html[theme=dark] .focus x-geopad .points circle:not(.focus).yellow{color:#573f2d}.focus x-geopad .paths path:not(.focus).teal,.focus x-geopad .points circle:not(.focus).teal{color:#ddecee}html[theme=dark] .focus x-geopad .paths path:not(.focus).teal,html[theme=dark] .focus x-geopad .points circle:not(.focus).teal{color:#24434e}.focus x-geopad .paths path:not(.focus).orange,.focus x-geopad .points circle:not(.focus).orange{color:#f4e4e1}html[theme=dark] .focus x-geopad .paths path:not(.focus).orange,html[theme=dark] .focus x-geopad .points circle:not(.focus).orange{color:#533134}.focus x-geopad .paths path:not(.focus).purple,.focus x-geopad .points circle:not(.focus).purple{color:#e7e2f1}html[theme=dark] .focus x-geopad .paths path:not(.focus).purple,html[theme=dark] .focus x-geopad .points circle:not(.focus).purple{color:#3a2f53}.focus x-geopad .paths path:not(.focus).lime,.focus x-geopad .points circle:not(.focus).lime{color:#f0f0df}html[theme=dark] .focus x-geopad .paths path:not(.focus).lime,html[theme=dark] .focus x-geopad .points circle:not(.focus).lime{color:#4a4a30}.focus x-geopad .paths path:not(.focus).white,.focus x-geopad .points circle:not(.focus).white{color:#f6f6f7}html[theme=dark] .focus x-geopad .paths path:not(.focus).white,html[theme=dark] .focus x-geopad .points circle:not(.focus).white{color:#575660}.focus x-geopad .pulse{display:none}.focus x-geopad .labels text:not(.focus){opacity:.2}.focus x-geopad .axes,.focus x-geopad canvas{opacity:.1}.focus x-geopad .grid{opacity:.01}x-parallax{display:block;overflow:hidden;position:relative}x-parallax .image{background-position:50%;background-size:cover;bottom:0;left:0;position:absolute;right:0;will-change:transform}x-parallax .content{height:100%;overflow:hidden;position:relative}.other-students{background:#3a3645;border-radius:6px;color:#fff;margin:1.5em 0;padding:12px 20px 2px}.other-students h4{margin:0 0 12px}.other-students img{opacity:.8}.proof{counter-reset:proof-counter;margin:0 0 2em 2em}@media screen and (max-width:660px){.proof{margin-left:0}}.proof li{list-style:none;margin:0 0 1em 3.8em;min-height:2.4em}.proof li .text-center{margin-top:.5em}.proof li:before{border:3px solid #c5c2cc;border-radius:100%;content:counter(proof-counter);counter-increment:proof-counter;display:block;float:left;font-size:1.4em;line-height:1.7em;margin:-4px 0 0 -2.7em;width:1.7em}.proof li:before,.proof-step{color:#666;font-weight:700;text-align:center}.proof-step{border:2px solid #c5c2cc;border-radius:100%;display:inline-block;line-height:1.2em;margin:-5px 0;width:1.2em} \ No newline at end of file +@charset "UTF-8";article,aside,audio,canvas,details,figcaption,figure,footer,header,main,nav,section,summary,video{display:block}audio:not([controls]){display:none;height:0}html{-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;font-size:100%}template{display:none}svg{display:block;overflow:hidden}li svg,p svg,td svg{display:inline-block}circle,g,image,line,path,polyline,use{transform-box:fill-box;transform-origin:center}*{-webkit-tap-highlight-color:transparent;color:inherit;cursor:inherit}body,html{margin:0;padding:0}p{hanging-punctuation:first;margin:0 0 1em}h1{font-size:40px;font-weight:400}h2{font-size:28px}h2,h3{font-weight:600}h3{font-size:20px}h1,h2,h3,h4,h5,h6{color:inherit;font-weight:700;line-height:1.1;margin:2em 0 .8em;padding:0;text-rendering:optimizelegibility}a{cursor:pointer}a,a:hover{text-decoration:none}a,button{touch-action:manipulation}button{box-sizing:content-box;-webkit-user-select:none;-moz-user-select:none;user-select:none}.small,small{font-size:80%}.b,b,strong{font-weight:700}.i,dfn,em,i{font-style:italic}sub,sup{font-size:65%;line-height:0;margin:0 .1em;position:relative;vertical-align:baseline}sup{top:-.6em}sub{bottom:-.25em}.text-center{text-align:center}.text-right{text-align:right}.break{-webkit-hyphens:auto;hyphens:auto;word-break:break-all}.nowrap{white-space:nowrap}ol,ul{margin:0 0 1em 1.5em;padding:0;text-align:left}ol ol,ol ul,ul ol,ul ul{margin:.5em 0 0 1.5em}li{margin:0 0 .5em}ol.unstyled,ul.unstyled{list-style:none;margin:0}ol.unstyled li,ul.unstyled li{margin:0}hr{background:#aaa;clear:both;display:block;height:1px;margin:1em 0;padding:0}hr,img{border:0}img{-ms-interpolation-mode:bicubic;height:auto;max-width:100%;vertical-align:middle}figure{margin:0}blockquote{margin:1.5em 0}blockquote,q{font-style:italic}q{quotes:none}blockquote:after,blockquote:before,q:after,q:before{content:none}.hidden,[hidden]{display:none!important;visibility:hidden!important}table{border-collapse:collapse;border-spacing:0}table,td{border:none}td{vertical-align:top}table.fixed{table-layout:fixed}table.grid td{border-bottom:1px solid #c5c2cc;border-right:1px solid #c5c2cc}table.grid tr td:last-child{border-right:none}table.grid tr:last-child td{border-bottom:none}@media print{body,html{background:transparent;color:#000}h2,h3,p{orphans:3;widows:3}h1,h2,h3{page-break-after:avoid}p a,p a:visited{text-decoration:underline}p a[href]:after{content:" (" attr(href) ")"}blockquote,img,pre,tr{page-break-inside:avoid}img{max-width:100%!important}@page{margin:.5cm}}button,form,input,select,textarea{border:none;margin:0;padding:0}input:invalid{box-shadow:none}button,input,select,textarea{background:transparent;display:inline-block;font-family:inherit;font-size:inherit;font-weight:inherit}input[type=date],input[type=email],input[type=password],input[type=text],textarea{cursor:text}button,select{cursor:pointer}form.form-large{margin:0 auto;max-width:600px}.form-row{display:flex;flex-direction:row;flex-wrap:wrap}.form-row .form-field{flex-grow:1;width:180px}.form-large p{margin:0 8px 16px}.form-large .btn,.form-large .icon-btn,.form-large .next-step{margin:12px 8px}.form-field{display:block;padding:8px;position:relative}.form-field input,.form-field select,.form-field textarea,.form-field-style{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:no-repeat top 12px right 10px/24px 24px;background-color:#f6f6f6;border:1px solid rgba(0,0,0,.1);border-radius:4px;box-sizing:border-box;color:#000;display:block;line-height:1.4em;padding:18px 16px 4px;transition:border .2s,background .2s,box-shadow .2s;width:100%}html[theme=dark] .form-field input,html[theme=dark] .form-field select,html[theme=dark] .form-field textarea,html[theme=dark] .form-field-style{background-color:#43424d;border-color:hsla(0,0%,100%,.5);color:#fff}.form-field input:not([disabled]):focus,.form-field input:not([disabled]):hover,.form-field select:not([disabled]):focus,.form-field select:not([disabled]):hover,.form-field textarea:not([disabled]):focus,.form-field textarea:not([disabled]):hover,.form-field-style:not([disabled]):focus,.form-field-style:not([disabled]):hover{background-color:#eee}html[theme=dark] .form-field input:not([disabled]):focus,html[theme=dark] .form-field input:not([disabled]):hover,html[theme=dark] .form-field select:not([disabled]):focus,html[theme=dark] .form-field select:not([disabled]):hover,html[theme=dark] .form-field textarea:not([disabled]):focus,html[theme=dark] .form-field textarea:not([disabled]):hover,html[theme=dark] .form-field-style:not([disabled]):focus,html[theme=dark] .form-field-style:not([disabled]):hover{background-color:#64646d}.form-field input:not([disabled]):focus,.form-field select:not([disabled]):focus,.form-field textarea:not([disabled]):focus,.form-field-style:not([disabled]):focus{border-color:#0f82f2;box-shadow:0 0 0 3px rgba(15,130,242,.5);outline:none}.form-field input:not([disabled]):focus+.placeholder,.form-field select:not([disabled]):focus+.placeholder,.form-field textarea:not([disabled]):focus+.placeholder,.form-field-style:not([disabled]):focus+.placeholder{color:#0f82f2}.form-field input[disabled],.form-field select[disabled],.form-field textarea[disabled],.form-field-style[disabled]{cursor:default!important;opacity:.6}.form-field input.no-label,.form-field select.no-label,.form-field textarea.no-label,.form-field-style.no-label{background-position:top 5px right 10px;padding-top:4px}.form-field input::-moz-placeholder{opacity:0}.form-field input::placeholder{opacity:0}.form-field input:-moz-placeholder-shown{padding:11px 16px}.form-field input:placeholder-shown{padding:11px 16px}.form-field input:-moz-placeholder-shown+.placeholder{transform:none}.form-field input:placeholder-shown+.placeholder{transform:none}.form-field input.dirty:not(:focus){padding-right:36px}.form-field input.dirty:not(:focus).valid,.form-field input.dirty:not(:focus):valid{background-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22%2322ab24%22%20d%3D%22m19.7%206.3-.2-.4-.3-.2c-.1-.1-.3%200-.4%200a36.6%2036.6%200%200%200%20-9.8%208.4%2036.1%2036.1%200%200%200%20-4.8-2.9h-.5l-1%20.9a.4.4%200%200%200%20-.1.3c0%20.2%200%20.3.1.4a72.1%2072.1%200%200%201%206.6%207h.4a.5.5%200%200%200%20.4-.2c3.8-6.8%205.7-9.6%209.4-13%20.2.1.2-.1.2-.3z%22%2F%3E%3C%2Fsvg%3E")}.form-field input.dirty:not(:focus).invalid,.form-field input.dirty:not(:focus):invalid{background-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%3E%3Crect%20x%3D%2210%22%20y%3D%228%22%20width%3D%224%22%20height%3D%2212%22%20fill%3D%22%23fff%22%2F%3E%3Cpath%20fill%3D%22%23cd0e66%22%20d%3D%22M22.1%2C19.5l-9.2-16a1%2C1%2C0%2C0%2C0-1.8%2C0l-9.2%2C16A1%2C1%2C0%2C0%2C0%2C2.7%2C21H21.3A1%2C1%2C0%2C0%2C0%2C22.1%2C19.5Zm-8.7-11v2.4l-.4%2C4.4H11.1l-.4-4.4V8.5ZM12%2C19.4a1.6%2C1.6%2C0%2C0%2C1-1.6-1.6%2C1.6%2C1.6%2C0%2C1%2C1%2C3.2%2C0A1.6%2C1.6%2C0%2C0%2C1%2C12%2C19.4Z%22%2F%3E%3C%2Fsvg%3E");border-color:#cd0e66}.form-field textarea{height:auto;padding:10px 16px;resize:vertical}.form-field textarea::-moz-placeholder{color:#aaa;opacity:1;-moz-transition:color .2s;transition:color .2s}.form-field textarea::placeholder{color:#aaa;opacity:1;transition:color .2s}.form-field textarea:active::-moz-placeholder,.form-field textarea:focus::-moz-placeholder{color:#0f82f2}.form-field textarea:active::placeholder,.form-field textarea:focus::placeholder{color:#0f82f2}.form-field select{background-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22%234d4d4d%22%20d%3D%22m19.9%207.5a1.4%201.4%200%200%200%20-2.1%200l-5.8%205.8-5.8-5.8a1.4%201.4%200%200%200%20-2.1%200%201.5%201.5%200%200%200%200%202.1l6.8%206.9a1.6%201.6%200%200%200%202.2%200l6.8-6.9a1.4%201.4%200%200%200%200-2.1z%22%2F%3E%3C%2Fsvg%3E");padding-right:40px}.form-field .form-error,.form-field .form-hint{font-size:14px;line-height:1.3;margin:4px 17px 0}.form-field .form-error{color:#cd0e66}.form-field .placeholder{color:#aaa;left:24px;line-height:1.4em;pointer-events:none;position:absolute;top:19px;transform:translateY(-7px) scale(.7);transform-origin:top left;transition:transform .2s,color .2s;-webkit-user-select:none;-moz-user-select:none;user-select:none}.form-checkbox{cursor:pointer;display:block;margin:16px 8px;min-height:28px;padding-left:40px;position:relative}.form-checkbox input{left:5px;opacity:0;position:absolute;top:7px}.form-checkbox .control{background:#f6f6f6;border:1px solid rgba(0,0,0,.1);border-radius:4px;height:22px;left:0;position:absolute;top:2px;transition:border .2s,background .2s,box-shadow .2s;width:22px}.form-checkbox .control:after{background:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2221%22%20height%3D%2221%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22m19.7%206.3-.2-.4-.3-.2c-.1-.1-.3%200-.4%200a36.6%2036.6%200%200%200%20-9.8%208.4%2036.1%2036.1%200%200%200%20-4.8-2.9h-.5l-1%20.9a.4.4%200%200%200%20-.1.3c0%20.2%200%20.3.1.4a72.1%2072.1%200%200%201%206.6%207h.4a.5.5%200%200%200%20.4-.2c3.8-6.8%205.7-9.6%209.4-13%20.2.1.2-.1.2-.3z%22%2F%3E%3C%2Fsvg%3E");content:" ";display:block;height:21px;left:1px;position:absolute;top:0;transform:scale(0);transition:transform .4s cubic-bezier(.33,1.9,.52,.7);width:21px}.form-checkbox input:focus+.control,.form-checkbox:hover .control{background:#eee;border-color:#0f82f2}.form-checkbox input:focus+.control{box-shadow:0 0 0 3px rgba(15,130,242,.5);outline:none}.form-checkbox input:checked+.control{background:#0f82f2}.form-checkbox input:checked+.control:after{transform:none}.form-checkbox input:focus:checked+.control,.form-checkbox:hover input:checked+.control{border-color:#053563}.input-field{-webkit-appearance:none;-moz-appearance:textfield;border:1px solid;border-radius:4px;color:inherit;cursor:text;display:block;line-height:1.7em;padding:0;transition:border .2s,background .2s,box-shadow .2s,color .2s}.input-field:focus{border-color:#0f82f2;box-shadow:0 0 0 3px rgba(15,130,242,.5);outline:none}.input-field::-webkit-inner-spin-button,.input-field::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.btn,.icon-btn,.next-step{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:#181824;border:none;border-radius:24px;color:hsla(0,0%,100%,.95);cursor:pointer;display:inline-block;font-weight:600;height:2em;letter-spacing:.2px;line-height:2em;min-width:48px;outline:none;padding:0 1.2em;text-align:center;transition:background .2s,color .2s,box-shadow .2s;transition:transform .3s,background .2s,color .2s,box-shadow .2s,opacity .2s;width:auto}.btn.on,.btn:hover,.icon-btn:hover,.next-step:hover,.on.icon-btn,.on.next-step{box-shadow:0 4px 12px rgba(0,0,0,.25);color:#fff;z-index:10}.btn.disabled,.btn[disabled],.disabled.icon-btn,.disabled.next-step,[disabled].icon-btn,[disabled].next-step{box-shadow:none;cursor:default;pointer-events:none}.btn:hover,.icon-btn:hover,.next-step:hover{transform:scale(1.08)}.btn:active,.icon-btn:active,.next-step:active{transform:scale(.92)}.btn:active,.btn:hover,.icon-btn:active,.icon-btn:hover,.next-step:active,.next-step:hover{background-color:#504b5c}html.is-tabbing .btn:focus,html.is-tabbing .icon-btn:focus,html.is-tabbing .next-step:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #181824}.btn.disabled,.btn[disabled],.disabled.icon-btn,.disabled.next-step,[disabled].icon-btn,[disabled].next-step{background-color:#ddd!important;color:#999!important}.btn x-icon,.icon-btn x-icon,.next-step x-icon{fill:currentColor;margin:0 6px -6px 0;opacity:.95;transition:opacity .2s}.btn:active x-icon,.btn:hover x-icon,.icon-btn:active x-icon,.icon-btn:hover x-icon,.next-step:active x-icon,.next-step:hover x-icon{opacity:1}.btn-small{height:1.6em;line-height:1.6em;padding:0 .8em}.btn-large{font-size:22px;height:44px;line-height:44px;padding:0 20px}.btn-large x-icon{margin:0 10px -6px -2px}.btn-large .arrow{margin:0 -2px -1px 6px}.btn-row{margin:-10px}.btn-row .btn,.btn-row .icon-btn,.btn-row .next-step{margin:10px}.btn-red,.next-step{-webkit-touch-callout:none;background-color:#cd0e66;outline:none}.btn-red:focus,.btn-red:hover,.next-step:focus,.next-step:hover{background-color:#ef1579}html.is-tabbing .btn-red:focus,html.is-tabbing .next-step:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #ef1579}.btn-blue{-webkit-touch-callout:none;background-color:#0f82f2;outline:none}.btn-blue:focus,.btn-blue:hover{background-color:#3696f4}html.is-tabbing .btn-blue:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #3696f4}.btn-green{-webkit-touch-callout:none;background-color:#22ab24;outline:none}.btn-green:focus,.btn-green:hover{background-color:#29cd2b}html.is-tabbing .btn-green:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #29cd2b}.btn-yellow{-webkit-touch-callout:none;background-color:#fd8c00;outline:none}.btn-yellow:focus,.btn-yellow:hover{background-color:#ff9e27}html.is-tabbing .btn-yellow:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #ff9e27}.btn-grey{-webkit-touch-callout:none;background-color:#656073;outline:none}.btn-grey:focus,.btn-grey:hover{background-color:#797389}html.is-tabbing .btn-grey:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #797389}.btn-white{-webkit-touch-callout:none;outline:none}.btn-white,.btn-white:focus,.btn-white:hover{background-color:#fff}html.is-tabbing .btn-white:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #fff}.btn-white,.btn-white:active,.btn-white:hover{color:#3a3645}.btn.facebook,.facebook.icon-btn,.facebook.next-step{-webkit-touch-callout:none;background-color:#1878f2;outline:none}.btn.facebook:focus,.btn.facebook:hover,.facebook.icon-btn:focus,.facebook.icon-btn:hover,.facebook.next-step:focus,.facebook.next-step:hover{background-color:#3f8ff4}html.is-tabbing .btn.facebook:focus,html.is-tabbing .facebook.icon-btn:focus,html.is-tabbing .facebook.next-step:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #3f8ff4}.btn.twitter,.twitter.icon-btn,.twitter.next-step{-webkit-touch-callout:none;background-color:#00b6f1;outline:none}.btn.twitter:focus,.btn.twitter:hover,.twitter.icon-btn:focus,.twitter.icon-btn:hover,.twitter.next-step:focus,.twitter.next-step:hover{background-color:#1bc7ff}html.is-tabbing .btn.twitter:focus,html.is-tabbing .twitter.icon-btn:focus,html.is-tabbing .twitter.next-step:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #1bc7ff}.btn.youtube,.youtube.icon-btn,.youtube.next-step{-webkit-touch-callout:none;background-color:red;outline:none}.btn.youtube:focus,.btn.youtube:hover,.youtube.icon-btn:focus,.youtube.icon-btn:hover,.youtube.next-step:focus,.youtube.next-step:hover{background-color:#ff2929}html.is-tabbing .btn.youtube:focus,html.is-tabbing .youtube.icon-btn:focus,html.is-tabbing .youtube.next-step:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #ff2929}.btn.instagram,.instagram.icon-btn,.instagram.next-step{-webkit-touch-callout:none;background-color:#bc2a8d;outline:none}.btn.instagram:focus,.btn.instagram:hover,.instagram.icon-btn:focus,.instagram.icon-btn:hover,.instagram.next-step:focus,.instagram.next-step:hover{background-color:#d33ba2}html.is-tabbing .btn.instagram:focus,html.is-tabbing .instagram.icon-btn:focus,html.is-tabbing .instagram.next-step:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #d33ba2}.btn.pinterest,.pinterest.icon-btn,.pinterest.next-step{-webkit-touch-callout:none;background-color:#cb2027;outline:none}.btn.pinterest:focus,.btn.pinterest:hover,.pinterest.icon-btn:focus,.pinterest.icon-btn:hover,.pinterest.next-step:focus,.pinterest.next-step:hover{background-color:#df353c}html.is-tabbing .btn.pinterest:focus,html.is-tabbing .pinterest.icon-btn:focus,html.is-tabbing .pinterest.next-step:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #df353c}.btn.tumblr,.tumblr.icon-btn,.tumblr.next-step{-webkit-touch-callout:none;background-color:#35465d;outline:none}.btn.tumblr:focus,.btn.tumblr:hover,.tumblr.icon-btn:focus,.tumblr.icon-btn:hover,.tumblr.next-step:focus,.tumblr.next-step:hover{background-color:#445a77}html.is-tabbing .btn.tumblr:focus,html.is-tabbing .tumblr.icon-btn:focus,html.is-tabbing .tumblr.next-step:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #445a77}.btn.reddit,.reddit.icon-btn,.reddit.next-step{-webkit-touch-callout:none;background-color:#ff5700;outline:none}.btn.reddit:focus,.btn.reddit:hover,.reddit.icon-btn:focus,.reddit.icon-btn:hover,.reddit.next-step:focus,.reddit.next-step:hover{background-color:#ff7229}html.is-tabbing .btn.reddit:focus,html.is-tabbing .reddit.icon-btn:focus,html.is-tabbing .reddit.next-step:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #ff7229}.btn.microsoft,.microsoft.icon-btn,.microsoft.next-step{-webkit-touch-callout:none;background-color:#2f2f2f;outline:none}.btn.microsoft:focus,.btn.microsoft:hover,.microsoft.icon-btn:focus,.microsoft.icon-btn:hover,.microsoft.next-step:focus,.microsoft.next-step:hover{background-color:#434343}html.is-tabbing .btn.microsoft:focus,html.is-tabbing .microsoft.icon-btn:focus,html.is-tabbing .microsoft.next-step:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #434343}.btn.google,.google.icon-btn,.google.next-step{background:#fff;box-shadow:inset 0 0 0 1px #aaa;color:#3a3645}.btn.google:hover,.google.icon-btn:hover,.google.next-step:hover{box-shadow:inset 0 0 0 1px #aaa,0 4px 12px rgba(0,0,0,.25)}html.is-tabbing .btn.google:focus,html.is-tabbing .google.icon-btn:focus,html.is-tabbing .google.next-step:focus{box-shadow:inset 0 0 0 1px #aaa,0 0 0 2px #fff,0 0 0 4px #656073}.icon-btn{border-radius:20px;display:block;height:40px;min-width:40px;padding:0}.icon-btn x-icon{display:block;margin:8px}@font-face{font-family:Mathigon Symbol;font-style:normal;font-weight:400;src:url(/fonts/mathigon-symbol.woff2) format("woff2"),url(/fonts/mathigon-symbol.woff) format("woff")}.math,math{display:inline-block;font-style:normal;font-weight:400;margin:0 .1em}.nowrap .math,.nowrap math{margin-right:0}mfenced,mfrac,mi,mn,mo,mroot,mrow,ms,msqrt,msub,msup,mtext{display:inline-block;font-family:Mathigon Symbol,Source Sans Pro,sans-serif;font-size:inherit;line-height:1;white-space:nowrap}mi[mathvariant=normal]{font-family:Source Sans Pro,sans-serif}mi{line-height:.9}mo{margin:0 .25em}mn+.cursor+mi,mn+mi{margin-left:.1em}mi+mi{margin-left:.05em}mfrac+.coursor+mi,mfrac+.cursor+mtext,mfrac+mi,mfrac+mtext{margin-left:.15em}mo[value=−]:first-child{margin:0 .1em}mo[value="="],mo[value=≈]{margin:0 .4em}mo[value=∡],mo[value=△]{margin:0}.cursor:first-child+mo,mn+mo[value=…],mo+.cursor+mo,mo+.cursor+mo[value],mo+mo,mo+mo[value],mo:first-child,mo[lspace="0"],mo[value=°],mo[value=’]{margin-left:0}mo:last-child,mo[rspace="0"]{margin-right:0}mtext{font-family:Source Sans Pro,Helvetica,sans-serif}mspace{padding:0 .2em}mphantom{visibility:hidden}ms:after,ms:before{content:'"'}ms[lquote]:before{content:attr(lquote)}ms[rquote]:after{content:attr(rquote)}msubsup>:nth-child(3),msup>:last-child{font-size:67%;margin:-.2em .1em 0 .15em;vertical-align:top}msub>:last-child,msubsup>:nth-child(2){font-size:67%;margin:0 .1em -.2em;vertical-align:bottom}mfrac,msub>:last-child mo,msubsup>:nth-child(3) mo,msup>:last-child mo{margin:0 .1em}mfrac{font-size:.6em;vertical-align:-.2em}mfrac>*{display:block;text-align:center}mfrac>:first-child{padding-bottom:.06em}mfrac>:last-child{border-top:1px solid;float:right;padding-top:.06em;width:100%}mfrac:after{content:" ";visibility:hidden;width:0}.display mfrac,.text-center:not(.inline) mfrac,table mfrac{font-size:1em;vertical-align:-.45em}.display mfrac mfrac,.text-center:not(.inline) mfrac mfrac,mfrac mfrac{font-size:75%;vertical-align:-.25em}mroot,msqrt{border-top:1px solid;margin-left:9px;padding:.1em .1em 0 .2em;position:relative}mroot:before,msqrt:before{background:currentColor;bottom:0;content:"";left:-11px;-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2213%22%20height%3D%2222%22%3E%3Cpath%20d%3D%22M3%2C11.72l-1.56.7-.42-1%2C2.93-1.3%2C2.55%2C7.61c.15.46.26.95.37%2C1.41h.09c.09-.46.18-.95.26-1.41L11.12%2C1h1.32L7.67%2C21.13H6.28Z%22%2F%3E%3C%2Fsvg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2213%22%20height%3D%2222%22%3E%3Cpath%20d%3D%22M3%2C11.72l-1.56.7-.42-1%2C2.93-1.3%2C2.55%2C7.61c.15.46.26.95.37%2C1.41h.09c.09-.46.18-.95.26-1.41L11.12%2C1h1.32L7.67%2C21.13H6.28Z%22%2F%3E%3C%2Fsvg%3E");-webkit-mask-size:100% 100%;mask-size:100% 100%;position:absolute;top:-2px;width:13px}mroot>:last-child{font-size:67%;margin-top:-5px;position:absolute;right:calc(100% + 5px)}mfenced{margin:0 calc(5px + .1em);padding:.05em .1em;position:relative}mfenced:after,mfenced:before{bottom:-1px;content:"";top:-1px;width:5px}mfenced:before{left:-4px;-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%225%22%20height%3D%2222%22%3E%3Cpath%20d%3D%22M0%2C11A18.32%2C18.32%2C0%2C0%2C1%2C2.91%2C1L4%2C1.53A18.32%2C18.32%2C0%2C0%2C0%2C1.5%2C11%2C18.33%2C18.33%2C0%2C0%2C0%2C4%2C20.47L2.91%2C21A18.32%2C18.32%2C0%2C0%2C1%2C0%2C11Z%22%2F%3E%3C%2Fsvg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%225%22%20height%3D%2222%22%3E%3Cpath%20d%3D%22M0%2C11A18.32%2C18.32%2C0%2C0%2C1%2C2.91%2C1L4%2C1.53A18.32%2C18.32%2C0%2C0%2C0%2C1.5%2C11%2C18.33%2C18.33%2C0%2C0%2C0%2C4%2C20.47L2.91%2C21A18.32%2C18.32%2C0%2C0%2C1%2C0%2C11Z%22%2F%3E%3C%2Fsvg%3E")}mfenced:after,mfenced:before{background:currentColor;-webkit-mask-size:100% 100%;mask-size:100% 100%;position:absolute}mfenced:after{-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%225%22%20height%3D%2222%22%3E%3Cpath%20d%3D%22M1%2C20.47A18.33%2C18.33%2C0%2C0%2C0%2C3.5%2C11%2C18.32%2C18.32%2C0%2C0%2C0%2C1%2C1.53L2.09%2C1A18.32%2C18.32%2C0%2C0%2C1%2C5%2C11%2C18.32%2C18.32%2C0%2C0%2C1%2C2.09%2C21Z%22%2F%3E%3C%2Fsvg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%225%22%20height%3D%2222%22%3E%3Cpath%20d%3D%22M1%2C20.47A18.33%2C18.33%2C0%2C0%2C0%2C3.5%2C11%2C18.32%2C18.32%2C0%2C0%2C0%2C1%2C1.53L2.09%2C1A18.32%2C18.32%2C0%2C0%2C1%2C5%2C11%2C18.32%2C18.32%2C0%2C0%2C1%2C2.09%2C21Z%22%2F%3E%3C%2Fsvg%3E");right:-4px}mfenced[open="|"]{border-left:1px solid;border-right:1px solid;margin:0 .1em;padding:0 .1em}mfenced[open="|"]:after,mfenced[open="|"]:before{content:none}mfenced[open="["]:before{content:"["}mfenced[close="]"]:after{content:"]"}mfenced[open="{"]:before{content:"{"}mfenced[close="}"]:after{content:"}"}mover,munder{position:relative}mover>:nth-child(2){font-size:0;height:5px;left:0;position:absolute;right:0}mover>[value=‾]:nth-child(2){-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2221%22%20height%3D%225%22%3E%3Cpath%20d%3D%22M0%2C2L21%2C2L21%2C3L0%2C3Z%22%2F%3E%3C%2Fsvg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2221%22%20height%3D%225%22%3E%3Cpath%20d%3D%22M0%2C2L21%2C2L21%2C3L0%2C3Z%22%2F%3E%3C%2Fsvg%3E");top:0}mover>[value=‾]:nth-child(2),mover>[value=→]:nth-child(2){background:currentColor;-webkit-mask-size:100% 100%;mask-size:100% 100%;position:absolute}mover>[value=→]:nth-child(2){-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2221%22%20height%3D%225%22%3E%3Cpath%20d%3D%22M21%2C2.5L15.7%2C0.3L16.5%2C2L0%2C2L0%2C3L16.5%2C3L15.7%2C4.7L21%2C2.5Z%22%2F%3E%3C%2Fsvg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2221%22%20height%3D%225%22%3E%3Cpath%20d%3D%22M21%2C2.5L15.7%2C0.3L16.5%2C2L0%2C2L0%2C3L16.5%2C3L15.7%2C4.7L21%2C2.5Z%22%2F%3E%3C%2Fsvg%3E");top:-2px}mover>[value=↔]:nth-child(2){-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2221%22%20height%3D%225%22%3E%3Cpath%20d%3D%22M21%2C2.5L15.7%2C0.3L16.5%2C2L4.5%2C2L5.3%2C0.3L0%2C2.5L5.3%2C4.7L4.5%2C3L16.5%2C3L15.7%2C4.7L21%2C2.5Z%22%2F%3E%3C%2Fsvg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2221%22%20height%3D%225%22%3E%3Cpath%20d%3D%22M21%2C2.5L15.7%2C0.3L16.5%2C2L4.5%2C2L5.3%2C0.3L0%2C2.5L5.3%2C4.7L4.5%2C3L16.5%2C3L15.7%2C4.7L21%2C2.5Z%22%2F%3E%3C%2Fsvg%3E")}mover>[value=↔]:nth-child(2),mover>[value=⌒]:nth-child(2){background:currentColor;-webkit-mask-size:100% 100%;mask-size:100% 100%;position:absolute;top:-2px}mover>[value=⌒]:nth-child(2){-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2221%22%20height%3D%225%22%3E%3Cpath%20d%3D%22M20.5%2C4.5a.52.52%2C0%2C0%2C1-.29-.09A17.1%2C17.1%2C0%2C0%2C0%2C10.5%2C1.5%2C17.1%2C17.1%2C0%2C0%2C0%2C.79%2C4.41a.5.5%2C0%2C0%2C1-.7-.13.5.5%2C0%2C0%2C1%2C.12-.69A18.22%2C18.22%2C0%2C0%2C1%2C10.5.5%2C18.22%2C18.22%2C0%2C0%2C1%2C20.79%2C3.59a.5.5%2C0%2C0%2C1%2C.12.69A.5.5%2C0%2C0%2C1%2C20.5%2C4.5Z%22%2F%3E%3C%2Fsvg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2221%22%20height%3D%225%22%3E%3Cpath%20d%3D%22M20.5%2C4.5a.52.52%2C0%2C0%2C1-.29-.09A17.1%2C17.1%2C0%2C0%2C0%2C10.5%2C1.5%2C17.1%2C17.1%2C0%2C0%2C0%2C.79%2C4.41a.5.5%2C0%2C0%2C1-.7-.13.5.5%2C0%2C0%2C1%2C.12-.69A18.22%2C18.22%2C0%2C0%2C1%2C10.5.5%2C18.22%2C18.22%2C0%2C0%2C1%2C20.79%2C3.59a.5.5%2C0%2C0%2C1%2C.12.69A.5.5%2C0%2C0%2C1%2C20.5%2C4.5Z%22%2F%3E%3C%2Fsvg%3E")}.snackbar{left:50%;position:fixed;top:52px;transform:translateX(-50%);z-index:500}x-alert{background:#000;border-radius:6px;box-shadow:0 3px 8px rgba(0,0,0,.3);color:#fff;display:none;font-size:16px;line-height:1.4;max-width:300px;padding:8px 20px;width:-moz-max-content;width:max-content}x-alert x-icon{float:left;margin:-2px 6px 20px -4px}x-alert.error{background:#b50c5a}x-alert.warn{background:#e47e00}x-alert.success{background:#1e9620}x-icon{fill:currentColor;display:inline-block;height:24px;width:24px}x-icon svg{display:block}x-icon[name=warning]{fill:#cd0e66}.button x-icon{margin:-10px 3px -10px -8px}.modal-background{-webkit-backdrop-filter:blur(4px);background:rgba(0,0,0,.8);bottom:0;display:none;left:0;position:fixed;right:0;top:44px;transition:background .4s;z-index:400}.modal-background.light{background:hsla(0,0%,100%,.9)}html.webview .modal-background{top:0}x-modal{background:#fff;border-radius:12px;box-shadow:0 6px 32px rgba(0,0,0,.8);box-sizing:border-box;display:none;left:50%;margin-top:22px;max-height:calc(100vh - 84px);max-width:calc(100% - 40px);position:fixed;top:50%;transform:translate(-50%,-50%);width:520px;z-index:401}html[theme=dark] x-modal{background:#2d2c38}x-modal.light{box-shadow:0 4px 20px rgba(0,0,0,.25)}html.webview x-modal{margin-top:0;max-height:calc(100% - 40px)}x-modal .modal-body{-webkit-overflow-scrolling:touch;box-sizing:border-box;height:100%;max-height:calc(100vh - 84px);overflow:auto;overscroll-behavior:contain;padding:24px}@media screen and (max-height:720px){x-modal.interactive{top:42px;transform:translate(-50%)}}.is-safari:not(.is-webview) x-modal,.is-safari:not(.is-webview) x-modal .modal-body{max-height:calc(100vh - 200px)}x-modal h2{margin-top:0}x-modal h2 x-icon{margin:-6px 4px -6px -2px}x-modal h3{margin:1.5em 0 .8em}x-modal h3 x-icon{margin:0 5px -5px 0}x-modal .btn-row{margin:0;text-align:right}x-modal .form-large{margin:0 -8px -10px}x-modal p:last-child:not(.btn-row),x-modal ul:last-child{margin-bottom:0}x-modal .form-checkbox{margin:16px 0}x-modal hr{margin:1.5em 0}x-modal .close{fill:rgba(0,0,0,.4);cursor:pointer;display:block;padding:8px;position:absolute;right:0;top:0;transition:transform .2s,color .2s;z-index:10}html[theme=dark] x-modal .close{fill:hsla(0,0%,100%,.4)}x-modal .close:hover{color:#000;transform:scale(1.4)}html[theme=dark] x-modal .close:hover{color:#fff}x-modal.video{background:#000;border-radius:0;width:1200px}x-modal.video .video-wrap{height:0;padding-bottom:56.25%;position:relative}x-modal.video iframe,x-modal.video video{height:100%;position:absolute;width:100%}x-modal.video .close x-icon{fill:hsla(0,0%,100%,.8);top:-40px}header{background:#181824;box-shadow:0 0 12px rgba(0,0,0,.25);color:#fff;display:flex;height:44px;justify-content:space-between;position:fixed;top:0;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:100%;z-index:450}header #logo,header .nav-link{display:block;font-size:18px;height:44px;line-height:44px}header #logo{box-sizing:border-box;margin-right:-12px;padding:4px 4px 4px 16px}header #logo img,header #logo svg{float:left;height:36px;width:auto}header #logo span{display:inline-block;float:left;line-height:36px;margin:0 8px}header #skip-nav{background:#3a3645;border:2px solid #181824;border-radius:30px;height:32px;left:-9999px;padding:2px 18px;position:absolute;top:2px;z-index:9999}html.is-tabbing header #skip-nav:focus{left:2px}header nav{display:flex}header .nav-link{cursor:pointer;opacity:.8;padding:0 16px;transition:opacity .2s,background .2s}header .nav-link:focus,header .nav-link:hover{background:#4b4757;opacity:1}header .nav-link x-icon{margin:0 8px -6px -2px;vertical-align:baseline}header .nav-link.narrow{padding:0 12px}header .nav-link.narrow x-icon{display:block;margin:0}header .nav-link.popup-target{padding-right:18px}header .nav-item.open .nav-link{background:#4b4757;opacity:1}header .nav-user-icon{border:1px solid hsla(0,0%,100%,.5);border-radius:100%;display:block;height:28px;width:28px}header .popup-body{-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);background:rgba(24,24,36,.91);background-clip:content-box;border-bottom:1px solid hsla(0,0%,100%,.3);border-left:1px solid hsla(0,0%,100%,.3);border-radius:0 0 0 6px;display:none;position:absolute;right:0;top:44px}header .popup-body .nav-link{box-sizing:border-box;color:hsla(0,0%,100%,.8);padding:0 18px;position:relative;text-align:left;transition:background .2s,color .2s;white-space:nowrap;width:100%}header .popup-body .nav-link:before{background:hsla(0,0%,100%,.4);content:" ";display:block;height:1px;position:absolute;top:0;transition:background-color .2s;width:calc(100% - 36px)}header .popup-body .nav-link:first-child:before{display:none}header .popup-body .nav-link.active,header .popup-body .nav-link.on,header .popup-body .nav-link:focus,header .popup-body .nav-link:hover{background:hsla(0,0%,100%,.2);color:#fff}header .popup-body .nav-link.active+:before,header .popup-body .nav-link.active:before,header .popup-body .nav-link.on+:before,header .popup-body .nav-link.on:before,header .popup-body .nav-link:focus+:before,header .popup-body .nav-link:focus:before,header .popup-body .nav-link:hover+:before,header .popup-body .nav-link:hover:before{background:transparent}header .popup-body .nav-link.active,header .popup-body .nav-link.on{background:hsla(0,0%,100%,.32)}header .popup-body .nav-link.logout{max-width:300px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}header .popup-body .nav-link:last-child{border-radius:0 0 0 6px}header .popup-body .nav-link img{float:right;margin:10px 2px 0 12px}header .popup-body .nav-link .form-checkbox{float:right;margin:8px 2px 0 12px;padding-left:24px}@media (max-width:840px){header .nav-link{padding:0 12px}header .nav-link.narrow{padding:0 10px}header .nav-link x-icon{margin-right:6px}}@media (max-width:760px){header .nav-item>.nav-link{height:36px;padding:4px 8px}header .nav-item>.nav-link x-icon{display:block;height:24px;margin:0 auto;width:24px}header .nav-text{display:block;font-size:10px;line-height:12px;text-align:center}}x-modal#language{-webkit-user-select:none;-moz-user-select:none;user-select:none;width:540px}.locale-list{-moz-column-count:3;column-count:3}@media (max-width:560px){.locale-list{-moz-column-count:2;column-count:2}}@media (max-width:420px){.locale-list{-moz-column-count:1;column-count:1}}.locale-link{-webkit-column-break-inside:avoid;border-radius:6px;display:block;margin:2px 0;overflow:hidden;padding:4px 8px;text-overflow:ellipsis;transition:background .2s;white-space:nowrap}.locale-link:hover{background:#e2e1e6}html[theme=dark] .locale-link:hover{background:hsla(0,0%,100%,.2)}.locale-link img{margin-right:8px}#search{width:480px}#search .modal-body{overflow:visible;padding:12px}#search .form-field{padding:0}#search .form-field input{border-radius:40px;font-size:24px;line-height:32px;padding:8px 16px 8px 48px}#search .form-field input::-moz-placeholder{color:inherit;opacity:.5}#search .form-field input::placeholder{color:inherit;opacity:.5}#search .form-field input:focus{box-shadow:0 0 0 3px #87c1f9}#search .form-field x-icon{fill:currentColor;left:13px;position:absolute;top:11px}#search .search-body{max-height:calc(100vh - 160px);min-height:180px;overflow:auto;padding:8px 8px 6px 48px}#search .search-body:after,#search .search-body:before{clear:both;content:" ";display:table}@media screen and (max-width:420px){#search .search-body{padding-left:8px}}#search .search-section{font-size:14px;font-weight:600;text-transform:uppercase}#search .search-result{border-radius:6px;display:block;height:48px;line-height:1.2;margin:0 -6px;padding:6px;transition:background .2s}#search .search-result:focus,#search .search-result:hover{background:#e2e1e6}html[theme=dark] #search .search-result:focus,html[theme=dark] #search .search-result:hover{background:hsla(0,0%,100%,.2)}#search .search-img{background:#000 50%;background-size:cover;border-radius:4px;box-shadow:inset 0 0 0 1px rgba(0,0,0,.2);float:left;height:48px;margin-right:10px;width:48px}#search .search-subtitle{color:#aaa;font-size:14px;margin-top:4px}#search .search-subtitle,#search .search-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#search .search-title{font-size:20px;font-weight:600}#search .search-gloss{background:#fed199;border-radius:6px;font-size:16px;line-height:1.4;margin:6px 0;padding:8px 14px}#search .search-gloss:after,#search .search-gloss:before{clear:both;content:" ";display:table}#search .search-gloss img{border:0;float:right;margin:0 -12px 0 0;width:160px}#search .search-gloss .math,#search .search-gloss x-math{white-space:nowrap}#search .search-gloss li,#search .search-gloss p,#search .search-gloss ul{margin-bottom:.3em}#search .search-gloss li:last-child,#search .search-gloss p:last-child,#search .search-gloss ul:last-child{margin-bottom:0}#search .no-results{color:#aaa;margin-top:32px;padding-right:32px;text-align:center}@media screen and (max-width:420px){#search .no-results{padding:0}}#search .no-results x-icon{fill:#aaa;display:block;margin:0 auto}.global-footer{border-top:1px solid #ccc;color:#aaa;display:flex;font-size:15px;margin:50px 0 40px;padding-top:6px}.global-footer .footer-left{flex-grow:1}.global-footer .footer-right{text-align:right}.global-footer .footer-row{margin:4px 0}.global-footer button{cursor:pointer;line-height:inherit;margin-left:24px;position:relative}.global-footer button img{left:-24px;position:absolute;top:2px}.global-footer .dot{display:inline-block;margin:0 8px}.global-footer .footer-left a,.global-footer button{background-image:linear-gradient(transparent calc(100% - 2px),currentColor calc(100% - 2px),currentColor calc(100% - 1px),transparent calc(100% - 1px));background-repeat:no-repeat;background-size:0 100%;display:inline-block;transition:color .2s,background-size .2s ease-in-out}.global-footer .footer-left a:hover,.global-footer button:hover{background-size:100% 100%;color:#333}html[theme=dark] .global-footer .footer-left a:hover,html[theme=dark] .global-footer button:hover{color:#fff}.global-footer .footer-social{color:#aaa;display:inline-block;margin:-5px 0 -11px;padding:6px 3px;transition:color .2s}.global-footer .footer-social x-icon{display:block}.global-footer .footer-social:hover{color:#333}html[theme=dark] .global-footer .footer-social:hover{color:#fff}@media (max-width:760px){.global-footer{display:block;font-size:16px;margin-bottom:30px}.global-footer .footer-left,.global-footer .footer-right{text-align:center}.global-footer .footer-row{margin-bottom:10px}.global-footer .footer-social{padding:6px}.global-footer .footer-social svg{height:28px;margin:0 4px;width:28px}.global-footer button img{height:20px;left:-26px;top:3px;width:20px}}.course{border-top:1px solid #c5c2cc;-moz-column-count:2;column-count:2;-moz-column-gap:10px;column-gap:10px;min-height:80px;padding:18px 0 18px 90px;position:relative}@media screen and (max-width:660px){.course{-moz-column-count:1;column-count:1}}.course .course-img{background-size:cover;border-radius:6px;height:80px;left:0;position:absolute;top:18px;width:80px}.course h3{-moz-column-span:all;column-span:all;margin:0 0 8px 8px}.course h3 img{margin:-4px 0 0 8px}.course .course-banner{border-radius:20px;color:#fff;float:right;font-size:14px;font-weight:400;margin:0 0 4px 6px;padding:2px 10px}.course .course-section{-moz-column-break-inside:avoid;border-radius:4px;break-inside:avoid;font-size:16px;line-height:1.2;padding:7px 8px 7px 34px;page-break-inside:avoid}.course .course-section.locked{color:#aaa;position:relative}.course .course-section.locked .tooltip{background:#656073;left:auto;padding:1px 10px;right:0;top:7px;transform:none}.course a.course-section{display:block;outline:none;transition:background .2s}.course a.course-section:focus,.course a.course-section:hover{background:#e2e1e6}html[theme=dark] .course a.course-section:focus,html[theme=dark] .course a.course-section:hover{background:hsla(0,0%,100%,.2)}.course .course-section.locked x-icon,.course x-progress{fill:#c5c2cc;display:inline-block;margin:0 6px -4px -26px}html{background-color:#fff;cursor:default;font-family:Source Sans Pro,Helvetica,sans-serif;font-size:18px;line-height:1.6;min-width:320px;touch-action:manipulation}html[theme=dark]{background:#22212e}html:not(.ready) *{animation:none!important;transition:none!important}html:not(.is-tabbing) :focus{outline:none!important}html.grabbing,html.grabbing *{cursor:grabbing!important}body{color:#333}html[theme=dark] body{color:hsla(0,0%,100%,.9)}main{padding-top:44px}html.webview main{padding-top:0}.container{margin:0 auto;max-width:calc(100% - 48px);position:relative;width:1000px}.container.narrow{width:800px}.container.wide{width:1200px}.panel.narrow{margin:0 auto;max-width:800px}svg.mathjax{display:inline-block}svg.mathjax g,svg.mathjax path,svg.mathjax use{transform-box:initial;transform-origin:0 0}.is-mobile .only-desktop,.not-mobile .only-mobile,.not-touch .only-touch{display:none!important}@media screen and (max-width:480px){.xs-hide{display:none!important}}@media screen and (max-width:640px){.s-hide{display:none!important}}@media screen and (min-width:641px){.l-hide{display:none!important}}@media screen and (min-width:801px){.xl-hide{display:none!important}}.invert{filter:none}html[theme=dark] .invert{filter:invert(1)}.r{position:relative}.column,.row{display:flex;flex-wrap:wrap;justify-content:center}.column{flex-direction:column}.row.right{flex-direction:row-reverse}.column.padded,.row.padded{margin:-24px}.column.padded>*,.row.padded>*{margin:24px}.column.padded-thin,.row.padded-thin{margin:-12px}.column.padded-thin>*,.row.padded-thin>*{margin:12px}.column .grow,.row .grow{flex-grow:1}.column .shrink,.row .shrink{flex-shrink:1}.row>*>h2:first-child,.row>*>h3:first-child{margin-top:0}.padded-thin>*>p:last-child,.padded>*>p:last-child{margin-bottom:0}.text-medium{color:#999}button.a,label a,ol a,p a,ul a{background-image:linear-gradient(transparent calc(100% - 3px),currentColor calc(100% - 3px),currentColor calc(100% - 1px),transparent calc(100% - 1px));background-repeat:no-repeat;background-size:0 100%;color:#0f82f2;transition:color .2s,background-size .2s ease-in-out}button.a:hover,label a:hover,ol a:hover,p a:hover,ul a:hover{background-size:100% 100%}.caption{color:#888;font-size:80%;margin:0 0 .6em;text-align:left}.emoji{display:inline-block;font-size:inherit;height:20px;line-height:normal;margin:-4px 2px 0;vertical-align:middle;width:20px}img.emoji{width:auto}.tooltip{-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);background:#181824;border:1px solid #fff;border-radius:16px;color:#fff;font-size:14px;left:50%;line-height:18px;opacity:0;padding:2px 12px;pointer-events:none;position:absolute;top:-22px;transform:translateX(-50%);transition:opacity .1s;white-space:nowrap;z-index:9999}.is-tabbing.not-mobile :focus>.tooltip,.not-mobile :hover>.tooltip{opacity:.8}.alert{background:rgba(253,140,0,.4);border-radius:4px;margin-bottom:2em;padding:12px 44px 12px 20px;position:relative}.alert.fail{background:rgba(205,14,102,.4)}.alert.success{background:rgba(34,171,36,.4)}.alert p:last-child{margin:0}.alert .close{cursor:pointer;font-size:30px;font-weight:700;opacity:.6;padding:0 13px;position:absolute;right:0;top:0}.alert .close:hover{opacity:1}.warning{background:#181824 url(/images/tiles.png);background-size:240px 240px;bottom:0;display:block;left:0;position:fixed;right:0;top:0;z-index:900}.warning-body{left:50%;max-width:calc(100% - 48px);position:absolute;top:50%;transform:translate(-50%,-50%)}.warning-body svg{height:100px;margin:0 auto 20px;width:100px}.warning-body p{background:#cd0e66;border-radius:4px;color:#fff;padding:8px 16px;text-align:center}.warning-body a:hover{color:#3f9bf5}.cookie-warning{background:#b50c5a;border-radius:4px;bottom:10px;box-shadow:0 3px 6px rgba(0,0,0,.3);box-sizing:border-box;color:#fff;left:10px;line-height:1.4;max-width:calc(100vw - 20px);padding:10px 16px 12px;position:fixed;z-index:800}.cookie-warning h2{color:hsla(0,0%,100%,.8);font-size:24px;font-weight:100;margin:0 0 6px}.cookie-warning p{margin-bottom:12px}.cookie-warning .btn,.cookie-warning .icon-btn,.cookie-warning .next-step{color:#b50c5a}.cookie-warning .close{cursor:pointer;opacity:.6;padding:12px;position:absolute;right:2px;top:2px;transition:opacity .2s}.cookie-warning .close:hover{opacity:1}.cookie-warning x-icon{display:block}x-blank,x-blank-mc{display:inline-block;position:relative}x-blank-mc.done,x-blank.done{display:inline;white-space:normal}x-blank .target,x-blank-mc .target{-webkit-touch-callout:none;background:transparent;background:#0f82f2;border-radius:6px;color:#fff;cursor:pointer;display:inline-block;line-height:28px;margin:-3px 2px;padding:0 6px;position:relative;text-align:center;transition:border-radius .2s,background .2s,color .2s,margin .2s,padding .2s,width .2s,min-width .2s,box-shadow .2s}.caption x-blank .target,.caption x-blank-mc .target{height:24px;line-height:24px}x-blank .target:before,x-blank-mc .target:before{background:none;bottom:1px;content:" ";height:3px;left:5px;position:absolute;right:5px}x-blank-mc.on .target,x-blank-mc:hover .target,x-blank.on .target,x-blank:hover .target{box-shadow:0 0 10px rgba(0,0,0,.2)}mfrac x-blank .target,mfrac x-blank-mc .target{margin:0 2px}mfrac x-blank-mc.done .target,mfrac x-blank.done .target{line-height:1}x-blank-mc.invalid .target:before,x-blank.invalid .target:before{background:#cd0e66;border-radius:5px 0 0 5px;bottom:0;color:#fff;content:"×";display:block;font-weight:700;height:auto;left:0;line-height:1;padding:4px 0 3px;position:absolute;text-align:center;top:0;width:20px}x-blank-mc.done .target,x-blank.done .target{background:transparent;background-image:none;box-shadow:none;color:#0f82f2;cursor:default;display:inline;margin:0;min-width:0;padding:1px 0 0}x-blank-mc.done:hover .target,x-blank.done:hover .target{color:#0f82f2}x-blank .target{cursor:text;padding:0}x-blank.invalid .target{padding-left:20px}x-blank input{background:none!important;color:inherit;margin:0;min-width:60px;text-align:center;width:40px}x-blank input:focus{color:#fff}html.is-tabbing x-blank input:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #0f82f2;outline:none}x-blank ::-webkit-input-placeholder{color:inherit!important;opacity:1!important}x-blank :-moz-placeholder,x-blank ::-moz-placeholder{color:inherit!important;opacity:1!important}x-blank-mc .target{line-height:24px;min-width:50px;padding:2px 12px}x-blank-mc.invalid .target{padding-left:30px}html.is-tabbing x-blank-mc .target:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #0f82f2;outline:none}x-blank-mc .popup{background:#0e75da;border-radius:0 6px 6px 6px;box-shadow:0 0 20px rgba(0,0,0,.3);font-style:normal;left:2px;min-width:90px;opacity:0;pointer-events:none;position:absolute;text-align:left;top:100%;transform:scale(.5);transform-origin:left top;transition:opacity .2s,transform .2s;white-space:normal;width:-moz-max-content;width:max-content}.caption x-blank-mc .popup{top:24px}x-blank-mc.left .popup{border-radius:6px 0 6px 6px;left:auto;right:2px;transform-origin:right top}x-blank-mc.top .popup{border-radius:6px 6px 6px 0;bottom:100%;top:auto;transform-origin:left bottom}x-blank-mc.left.top .popup{border-radius:6px 6px 0 6px;transform-origin:right bottom}.caption x-blank-mc.top .popup{bottom:24px}x-blank-mc strong{color:#fff}x-blank-mc.done strong{color:#0f82f2}x-blank-mc.on,x-blank-mc:focus-within{z-index:100}x-blank-mc.on .target,x-blank-mc:focus-within .target{border-radius:5px 5px 0 0}x-blank-mc.on.top .target,x-blank-mc:focus-within.top .target{border-radius:0 0 5px 5px}x-blank-mc.on.invalid .target:before,x-blank-mc:focus-within.invalid .target:before{border-radius:5px 0 0 0}x-blank-mc.on.top.invalid .target:before,x-blank-mc:focus-within.top.invalid .target:before{border-radius:0 0 0 5px}x-blank-mc.on .popup,x-blank-mc:focus-within .popup{opacity:1;pointer-events:all;transform:none}x-blank-mc .choice{box-sizing:border-box;color:hsla(0,0%,100%,.8);cursor:pointer;display:block;font-size:16px;line-height:22px;padding:6px 16px 6px 12px;text-align:left;transition:color .2s,background .2s,box-shadow .2s;width:100%}x-blank-mc .choice:focus,x-blank-mc .choice:hover{background:hsla(0,0%,100%,.2);color:#fff}html.is-tabbing x-blank-mc .choice:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #0f82f2;outline:none}x-blank-mc .choice:first-child{border-top-right-radius:6px}x-blank-mc .choice:last-child{border-radius:0 0 6px 6px}x-blank-mc .choice:before{background:hsla(0,0%,100%,.5);content:" ";display:block;height:1px;left:12px;margin-top:-6px;position:absolute;right:16px;transition:background .2s}x-blank-mc .choice:first-child:before,x-blank-mc .choice:focus+.choice:before,x-blank-mc .choice:focus:before,x-blank-mc .choice:hover+.choice:before,x-blank-mc .choice:hover:before{background:transparent}x-free-text{display:block;margin:1.5em 0;position:relative}x-free-text .text-area{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:#f5f5f6;border:1px solid #ccc;border-radius:6px;color:#333;cursor:text;height:auto;line-height:1.4em;padding:10px 16px 42px;transition:background .2s,border .2s,box-shadow .2s}x-free-text .text-area:empty:after{color:#aaa;content:"What do you notice or wonder?"}x-free-text .text-area:hover,x-free-text:focus-within .text-area{background-color:#eee;border-color:#0f82f2;z-index:2}x-free-text:focus-within .text-area{box-shadow:0 0 0 3px rgba(15,130,242,.5);outline:none}x-free-text .toolbar{background:#dddce1;border-radius:0 0 5px 5px;border-top:1px solid #adabb5;bottom:1px;display:flex;left:1px;opacity:0;pointer-events:none;position:absolute;right:1px;transition:opacity .2s}x-free-text .toolbar .space{flex-grow:1}x-free-text .text-area:focus+.toolbar,x-free-text:focus-within .toolbar{opacity:1;pointer-events:all}x-free-text .toolbar .command{fill:#3a3645;border-right:1px solid #adabb5;cursor:pointer;display:block;height:20px;padding:6px;transition:background .2s,fill .2s}x-free-text .toolbar .command:focus,x-free-text .toolbar .command:hover{fill:#181824;background:#c5c2cc}x-free-text .toolbar .command:first-child{border-bottom-left-radius:5px}x-free-text .toolbar .command x-icon{display:block;margin:0;transition:transform .2s}x-free-text .toolbar .command x-icon:hover{transform:scale(1.08)}x-free-text .toolbar .command x-icon:active{transform:scale(.92)}x-free-text .toolbar .submit{border-radius:0 0 5px 0;font-size:16px;height:33px;line-height:33px;margin-top:-1px;padding:0 12px 0 8px}x-free-text .toolbar .submit.invisible{opacity:0;pointer-events:none;transform:scale(.5)}x-free-text .toolbar .submit x-icon{margin-right:2px}x-free-text .toolbar .submit:focus,x-free-text .toolbar .submit:hover{background:#22ab24}x-gallery{display:block;position:relative}x-gallery .wrapper{cursor:ew-resize;overflow:hidden;position:relative}x-gallery .panel{transform:translateX(0)}x-gallery .panel:after,x-gallery .panel:before{clear:both;content:" ";display:table}x-gallery .panel>*{box-sizing:border-box;float:left;padding:10px}x-gallery .panel>* img,x-gallery .panel>* x-img{display:block;height:auto;margin:0 auto;width:100%}x-gallery .nav{border-top:2px solid #c5c2cc;height:34px;position:relative}x-gallery .back,x-gallery .next{border-radius:0 0 6px 6px;display:block;height:36px;min-width:0;padding:0;position:absolute;top:-2px;transform-origin:center top;width:36px}x-gallery .back.disabled,x-gallery .next.disabled{opacity:0}x-gallery .back x-icon,x-gallery .next x-icon{display:block;margin:6px}x-gallery .next{right:0}x-gallery .dots{left:50%;position:absolute;top:10px;transform:translateX(-50%)}x-gallery .dot{background:rgba(24,24,36,.2);border-radius:4px;float:left;height:8px;margin:4px;transition:opacity .2s;width:8px}x-gallery .dot.on{background:rgba(24,24,36,.8)}x-gesture{fill:rgba(0,0,0,.5);stroke:hsla(0,0%,100%,.5);stroke-width:1px;display:none;pointer-events:none;position:absolute;transform-origin:15px 10px;z-index:9999}html[theme=dark] x-gesture{fill:hsla(0,0%,100%,.5);stroke:rgba(34,33,46,.5)}x-bio,x-bio .target,x-gloss,x-gloss .target{display:inline-block;position:relative}x-bio .target,x-gloss .target{-webkit-touch-callout:none;background:transparent;border-radius:6px;cursor:pointer;line-height:28px;margin:-3px -6px;padding:0 6px;transition:background .2s,color .2s,box-shadow .2s}.caption x-bio .target,.caption x-gloss .target{height:24px;line-height:24px}x-bio .target:before,x-gloss .target:before{background:#feaf4d;bottom:1px;content:" ";height:3px;left:5px;position:absolute;right:5px}x-bio.on .target,x-gloss.on .target{background:#feaf4d;color:rgba(0,0,0,.8)}html.is-tabbing x-bio .target:focus,html.is-tabbing x-gloss .target:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #feaf4d;outline:none}x-bio .popup,x-gloss .popup{font-size:16px;font-weight:400}@media screen and (max-width:600px){x-bio .popup,x-gloss .popup{display:none}}@media screen and (min-width:601px){x-bio .popup,x-gloss .popup{background:#f08500;border-radius:0 6px 6px 6px;box-shadow:0 0 10px rgba(0,0,0,.2);font-style:normal;left:-6px;opacity:0;padding:12px 16px;pointer-events:none;position:absolute;text-align:left;top:100%;transform:scale(.5);transform-origin:left top;transition:opacity .2s,transform .2s;white-space:normal;width:300px}.caption x-bio .popup,.caption x-gloss .popup{top:24px}x-bio.left .popup,x-gloss.left .popup{border-radius:6px 0 6px 6px;left:auto;right:-6px;transform-origin:right top}x-bio.top .popup,x-gloss.top .popup{border-radius:6px 6px 6px 0;bottom:100%;top:auto;transform-origin:left bottom}x-bio.left.top .popup,x-gloss.left.top .popup{border-radius:6px 6px 0 6px;transform-origin:right bottom}.caption x-bio.top .popup,.caption x-gloss.top .popup{bottom:24px}x-bio.on,x-bio:focus-within,x-gloss.on,x-gloss:focus-within{z-index:100}x-bio.on .target,x-bio:focus-within .target,x-gloss.on .target,x-gloss:focus-within .target{border-radius:5px 5px 0 0}x-bio.on.top .target,x-bio:focus-within.top .target,x-gloss.on.top .target,x-gloss:focus-within.top .target{border-radius:0 0 5px 5px}x-bio.on.invalid .target:before,x-bio:focus-within.invalid .target:before,x-gloss.on.invalid .target:before,x-gloss:focus-within.invalid .target:before{border-radius:5px 0 0 0}x-bio.on.top.invalid .target:before,x-bio:focus-within.top.invalid .target:before,x-gloss.on.top.invalid .target:before,x-gloss:focus-within.top.invalid .target:before{border-radius:0 0 0 5px}x-bio.on .popup,x-bio:focus-within .popup,x-gloss.on .popup,x-gloss:focus-within .popup{opacity:1;pointer-events:all;transform:none}}.theorem x-bio .target:before,.theorem x-gloss .target:before{background:#fd8c00}.theorem x-bio.on .target:before,.theorem x-gloss.on .target:before{background:#feaf4d}#glossary-modal,x-bio .popup,x-gloss .popup{color:hsla(0,0%,100%,.9)}#glossary-modal li,#glossary-modal p,x-bio .popup li,x-bio .popup p,x-gloss .popup li,x-gloss .popup p{line-height:1.4;margin:0 0 .7em}#glossary-modal li,x-bio .popup li,x-gloss .popup li{margin-bottom:.3em}#glossary-modal p:last-child,x-bio .popup p:last-child,x-gloss .popup p:last-child{margin-bottom:0}#glossary-modal ol,#glossary-modal ul,x-bio .popup ol,x-bio .popup ul,x-gloss .popup ol,x-gloss .popup ul{margin-left:1.5em}#glossary-modal strong,x-bio .popup strong,x-gloss .popup strong{color:#fff}#glossary-modal a.btn,#glossary-modal a.icon-btn,#glossary-modal a.next-step,x-bio .popup a.btn,x-bio .popup a.icon-btn,x-bio .popup a.next-step,x-gloss .popup a.btn,x-gloss .popup a.icon-btn,x-gloss .popup a.next-step{background:hsla(0,0%,100%,.8);color:#fd8c00;font-weight:400;margin:0}#glossary-modal a.btn:after,#glossary-modal a.btn:before,#glossary-modal a.icon-btn:after,#glossary-modal a.icon-btn:before,#glossary-modal a.next-step:after,#glossary-modal a.next-step:before,x-bio .popup a.btn:after,x-bio .popup a.btn:before,x-bio .popup a.icon-btn:after,x-bio .popup a.icon-btn:before,x-bio .popup a.next-step:after,x-bio .popup a.next-step:before,x-gloss .popup a.btn:after,x-gloss .popup a.btn:before,x-gloss .popup a.icon-btn:after,x-gloss .popup a.icon-btn:before,x-gloss .popup a.next-step:after,x-gloss .popup a.next-step:before{display:none}#glossary-modal a.btn:focus,#glossary-modal a.btn:hover,#glossary-modal a.icon-btn:focus,#glossary-modal a.icon-btn:hover,#glossary-modal a.next-step:focus,#glossary-modal a.next-step:hover,x-bio .popup a.btn:focus,x-bio .popup a.btn:hover,x-bio .popup a.icon-btn:focus,x-bio .popup a.icon-btn:hover,x-bio .popup a.next-step:focus,x-bio .popup a.next-step:hover,x-gloss .popup a.btn:focus,x-gloss .popup a.btn:hover,x-gloss .popup a.icon-btn:focus,x-gloss .popup a.icon-btn:hover,x-gloss .popup a.next-step:focus,x-gloss .popup a.next-step:hover{background:#fff;color:#fd8c00}.bio-img{border-radius:4px;float:right;height:auto;margin:4px 0 5px 10px;width:140px}.gloss-img{display:block;filter:invert(100%)}#glossary-modal{background:#fd8c00;border-radius:8px;width:340px}#glossary-modal .modal-body{padding:12px 18px 14px}#glossary-modal p:first-child{margin-right:18px}#glossary-modal .bio-img{display:block;float:none;margin:0 auto 12px;min-height:160px}#glossary-modal .gloss-img{min-height:120px}#glossary-modal .close{fill:hsla(0,0%,100%,.8)}.lightbox-overlay{background:transparent;bottom:0;cursor:zoom-out;display:none;left:0;position:fixed;right:0;top:0;transition:background .4s;will-change:background;z-index:800}.lightbox-overlay.on{background:rgba(0,0,0,.9)}.lightbox-img{background-position:50%;background-repeat:no-repeat;background-size:contain;bottom:30px;left:30px;position:absolute;right:30px;top:30px;will-change:transition}.lightbox-img.transitions{transition:transform .4s ease-in-out}@media screen and (max-width:540px){.lightbox-img{bottom:0;left:0;right:0;top:0}}x-img{display:block;max-width:100%;position:relative}x-img.interactive{cursor:zoom-in}x-img .wrap{height:0}x-img img{border-radius:4px;display:block;max-width:100%}x-img .credit{background:rgba(0,0,0,.8);border-bottom-right-radius:4px;bottom:0;box-sizing:border-box;color:#fff;font-size:11px;line-height:1.2;max-width:90%;opacity:0;padding:4px 8px;position:absolute;right:0;transition:opacity .2s}x-img:hover .credit{opacity:.9}x-img .zoom{background:rgba(0,0,0,.7);border-top-right-radius:4px;height:36px;opacity:.5;position:absolute;right:0;top:0;transition:opacity .2s,background .2s;width:36px}x-img:hover .zoom{opacity:.9}x-img x-icon{fill:#fff;margin:6px}@media print{.lightbox-img,.lightbox-overlay,x-img .zoom{display:none!important}x-img .credit{opacity:1!important}}x-picker{display:flex;justify-content:space-between;margin:1.5em -4px}x-picker .item{border:4px solid transparent;border-radius:8px;cursor:pointer;margin:4px;position:relative;transition:border .2s,opacity .2s;width:100px}x-picker .item:hover{border-color:#eee}x-picker .item.correct{border-color:#22ab24;cursor:default}x-picker .item.incorrect{border-color:#cd0e66;cursor:default}x-picker .item:after{border:4px solid #fff;border-radius:100%;content:"";height:28px;position:absolute;right:-12px;top:-12px;transform:scale(0);transition:transform .5s cubic-bezier(.33,1.9,.52,.7);width:28px}x-picker .item.correct:after{background:#22ab24 url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22m19.7%206.3-.2-.4-.3-.2c-.1-.1-.3%200-.4%200a36.6%2036.6%200%200%200%20-9.8%208.4%2036.1%2036.1%200%200%200%20-4.8-2.9h-.5l-1%20.9a.4.4%200%200%200%20-.1.3c0%20.2%200%20.3.1.4a72.1%2072.1%200%200%201%206.6%207h.4a.5.5%200%200%200%20.4-.2c3.8-6.8%205.7-9.6%209.4-13%20.2.1.2-.1.2-.3z%22%2F%3E%3C%2Fsvg%3E") 2px 2px no-repeat;transform:scale(1)}x-picker .item.incorrect:after{background:#cd0e66 url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22M19%2C16l-4.7-4.3L18.6%2C7a1.2%2C1.2%2C0%2C0%2C0%2C0-1.5l-.4-.3a1%2C1%2C0%2C0%2C0-1.4%2C0L12%2C9.5%2C7.2%2C5.2a1%2C1%2C0%2C0%2C0-1.4%2C0l-.4.3A1.2%2C1.2%2C0%2C0%2C0%2C5.4%2C7l4.3%2C4.7L5%2C16a1.1%2C1.1%2C0%2C0%2C0-.1%2C1.4l1.5%2C1.4a.9.9%2C0%2C0%2C0%2C1.3%2C0L12%2C14.1l4.3%2C4.7a.9.9%2C0%2C0%2C0%2C1.3%2C0l1.5-1.4A1.1%2C1.1%2C0%2C0%2C0%2C19%2C16Z%22%2F%3E%3C%2Fsvg%3E") 2px 2px no-repeat;transform:scale(1)}x-picker.solved .item{border-color:transparent;cursor:default}x-picker.solved .item:after{background-color:#ccc}x-picker.solved .item[data-error]{opacity:.2}x-picker.list{display:block;margin:1em 24px}x-picker.list .item{border:none;border-radius:5px;margin:8px auto;max-width:480px;padding:4px 12px 4px 42px;transition:background .2s;width:auto}x-picker.list .item:not(.correct):not(.incorrect):hover{background:#eee}x-picker.list .item:after{left:0;top:-1px}x-picker.wrap{flex-wrap:wrap;justify-content:center}x-progress{border:2px solid;border-radius:100%;box-sizing:border-box}x-progress svg{display:block;margin:-14px;max-width:none;pointer-events:none}x-progress path.done,x-progress path.pie{transform:translate(12px,12px)}x-progress path.pie{fill:none;stroke:currentColor;transition:stroke-dasharray .2s}x-progress line{stroke:currentColor;stroke-width:2px}x-course-sidebar{background:#3a3645 linear-gradient(transparent 240px,rgba(0,0,0,.25));bottom:0;box-shadow:0 0 12px rgba(0,0,0,.25);color:#fff;display:flex;flex-direction:column;left:0;position:fixed;top:44px;width:280px;z-index:301}x-course-sidebar .sidebar-hero{background-size:cover;flex-shrink:0.5;height:220px;padding:0 20px;position:relative}x-course-sidebar .sidebar-hero-gradient{background-image:linear-gradient(transparent,rgba(0,0,0,.6) 140px);bottom:0;content:" ";left:0;position:absolute;right:0;top:40px}x-course-sidebar .sidebar-title{bottom:16px;font-size:30px;font-weight:600;line-height:1.1;position:absolute}x-course-sidebar .course-icon{background-size:cover;border:2px solid #fff;border-radius:4px;height:54px;margin-bottom:4px;width:54px}x-course-sidebar .sidebar-author{display:block;font-size:16px;margin-top:6px;opacity:.7;width:-moz-fit-content;width:fit-content}x-course-sidebar .sidebar-body{-webkit-overflow-scrolling:touch;flex-grow:1;overflow:auto;overscroll-behavior:contain}x-course-sidebar .sidebar-row{color:hsla(0,0%,100%,.8);display:block;font-weight:600;line-height:20px;padding:11px 20px 11px 52px;position:relative;transition:background .2s,color .2s}x-course-sidebar .sidebar-row:before{background:hsla(0,0%,100%,.4);content:" ";display:block;height:1px;position:absolute;top:0;transition:background-color .2s;width:calc(100% - 72px)}x-course-sidebar .sidebar-row:first-child:before{display:none}x-course-sidebar .sidebar-row.active,x-course-sidebar .sidebar-row.on,x-course-sidebar .sidebar-row:focus,x-course-sidebar .sidebar-row:hover{background:hsla(0,0%,100%,.2);color:#fff}x-course-sidebar .sidebar-row.active+:before,x-course-sidebar .sidebar-row.active:before,x-course-sidebar .sidebar-row.on+:before,x-course-sidebar .sidebar-row.on:before,x-course-sidebar .sidebar-row:focus+:before,x-course-sidebar .sidebar-row:focus:before,x-course-sidebar .sidebar-row:hover+:before,x-course-sidebar .sidebar-row:hover:before{background:transparent}x-course-sidebar .sidebar-row.active,x-course-sidebar .sidebar-row.on{background:hsla(0,0%,100%,.32)}x-course-sidebar .sidebar-row x-progress{color:#fff;height:20px;left:20px;position:absolute;top:11px;width:20px}x-course-sidebar .sidebar-row .connection{background:#fff;height:calc(100% - 18px);left:29px;pointer-events:none;position:absolute;top:30px;width:2px}x-course-sidebar .sidebar-row x-icon.left{color:#fff;left:18px;position:absolute;top:9px}x-course-sidebar .sidebar-row x-icon.left+.connection{height:calc(100% - 16px);top:28px}x-course-sidebar .sidebar-row x-icon.right{color:hsla(0,0%,100%,.6);float:right;margin:-2px -2px 0 6px}x-course-sidebar .sidebar-row:last-child .connection{display:none}x-course-sidebar .sidebar-row:first-child{margin-top:16px}x-course-sidebar .sidebar-footer{display:flex;flex-shrink:0;justify-content:center}x-course-sidebar .footer-link{cursor:pointer;padding:12px 10px;position:relative}x-course-sidebar .footer-link x-icon{fill:hsla(0,0%,100%,.7);display:block;transition:fill .2s}x-course-sidebar .footer-link:focus x-icon,x-course-sidebar .footer-link:hover x-icon{fill:hsla(0,0%,100%,.9)}x-course-sidebar .sidebar-banner{border-top:1px solid hsla(0,0%,100%,.4);color:hsla(0,0%,100%,.6);flex-shrink:0;font-size:14px;margin:0 18px;padding:4px 0 6px;text-align:center}.sidebar-toggle{background:#cd0e66;border-radius:24px;bottom:8px;box-shadow:0 3px 8px rgba(0,0,0,.3);cursor:pointer;display:none;height:24px;left:8px;padding:10px;position:fixed;width:24px;z-index:300}.sidebar-toggle x-icon{fill:#fff}.sidebar-shadow{bottom:0;display:none;left:0;position:fixed;right:0;top:0;z-index:300}x-modal{-webkit-user-select:text;-moz-user-select:text;user-select:text}#feedback .error{color:#cd0e66;display:none;margin:5px 8px}#feedback button[disabled]:after{content:"ing…"}x-modal#feedback-success{text-align:center;width:320px}x-modal#share{width:400px}.share-row{display:flex;flex-wrap:wrap;justify-content:center;margin:-4px}.share-row .btn,.share-row .icon-btn,.share-row .next-step{border-radius:8px;box-shadow:none;height:36px;margin:4px;min-width:0;padding:8px;width:36px}.share-row .btn x-icon,.share-row .icon-btn x-icon,.share-row .next-step x-icon{margin:0}#glossary-search{background:#feddb3;font-size:16px;height:440px;width:600px}.gloss-sidebar{background:#fd8c00;border-radius:12px 0 0 12px;display:flex;flex-direction:column;width:200px}.gloss-sidebar h2{fill:#fff;color:#fff;margin:20px 24px}.gloss-search{position:relative}.gloss-search x-icon{fill:#fff;left:24px;position:absolute;top:9px}.gloss-search input{background:hsla(0,0%,100%,.24);box-sizing:border-box;color:#fff;padding:10px 12px 10px 54px;transition:background .2s;width:100%}.gloss-search input:focus,.gloss-search input:hover{background:hsla(0,0%,100%,.32)}.gloss-search input::-moz-placeholder{color:hsla(0,0%,100%,.7)}.gloss-search input::placeholder{color:hsla(0,0%,100%,.7)}.gloss-list{-webkit-overflow-scrolling:touch;border-bottom-left-radius:12px;flex:1 1;margin-top:-1px;overflow:auto;overscroll-behavior:contain}.gloss-item{color:hsla(0,0%,100%,.8);cursor:pointer;font-weight:600;line-height:1.3;padding:8px 12px 8px 24px;position:relative;transition:background .2s,color .2s}.gloss-item:before{background:hsla(0,0%,100%,.4);content:" ";display:block;height:1px;position:absolute;top:0;transition:background-color .2s;width:calc(100% - 36px)}.gloss-item:first-child:before{display:none}.gloss-item.active,.gloss-item.on,.gloss-item:focus,.gloss-item:hover{background:hsla(0,0%,100%,.2);color:#fff}.gloss-item.active+:before,.gloss-item.active:before,.gloss-item.on+:before,.gloss-item.on:before,.gloss-item:focus+:before,.gloss-item:focus:before,.gloss-item:hover+:before,.gloss-item:hover:before{background:transparent}.gloss-item.active,.gloss-item.on{background:hsla(0,0%,100%,.32)}.gloss-body{-webkit-overflow-scrolling:touch;flex:1 1;overflow:auto;overscroll-behavior:contain;padding:64px 32px 32px}@media screen and (max-width:840px){x-course-sidebar{box-shadow:none;left:-280px;transition:transform .3s,box-shadow .3s;will-change:transform}.sidebar-toggle{display:block}x-course-sidebar.open{box-shadow:10px 0 60px rgba(0,0,0,.5);transform:translateX(280px)}x-course-sidebar.open+.sidebar-shadow{display:block}}x-slider{box-sizing:border-box;display:block;margin:20px auto 2em;max-width:400px;position:relative;width:calc(100% - 24px)}x-slider .bar{background:#b0afb5;border-radius:2px;height:4px;position:relative}x-slider .play+.bar{margin-left:40px}x-slider .knob{background:#cd0e66;border-radius:12px;cursor:grab;height:20px;left:0;margin:-8px 0 0 -10px;position:absolute;touch-action:pan-y;transition:background .2s,transform .2s,box-shadow .2s;width:20px}x-slider .knob:active,x-slider .knob:hover{background:#f01e7f;box-shadow:0 3px 8px rgba(0,0,0,.25);transform:scale(1.4)}x-slider .play{color:#89868f;cursor:pointer;height:32px;left:-8px;padding:4px;position:absolute;top:-18px;transition:fill .2s,transform .2s;width:32px}x-slider .play:hover{transform:scale(1.08)}x-slider .play:active{transform:scale(.92)}x-slider .play:focus,x-slider .play:hover{color:#3a3645;transform:scale(1.2)}html[theme=dark] x-slider .play:focus,html[theme=dark] x-slider .play:hover{color:#fff}x-slider .play:active{transform:scale(.9)}x-slideshow{display:block}x-slideshow .legend-box{border:solid #ccc;border-width:2px 0}x-slideshow .legend-box>*{display:none;padding:.7em 0}x-slideshow .legend-box p:last-child,x-slideshow .legend-box>p{margin-bottom:0}x-slideshow .nav{height:0;position:relative}x-slideshow .back,x-slideshow .next{border-radius:6px 6px 0 0;bottom:-2px;display:block;height:36px;min-width:0;padding:0;position:absolute;transform-origin:center bottom;width:36px;z-index:1}x-slideshow .back.disabled,x-slideshow .next.disabled{opacity:0}x-slideshow .back x-icon,x-slideshow .next x-icon{margin:6px}[dir=rtl] x-slideshow .back x-icon,[dir=rtl] x-slideshow .next x-icon{transform:scaleX(-1)}x-slideshow .next{right:0}x-slideshow .dots{bottom:8px;left:50%;position:absolute;transform:translateX(-50%)}x-slideshow .dot{background:rgba(24,24,36,.2);border-radius:4px;float:left;height:8px;margin:4px;transition:background .2s;width:8px}html[theme=dark] x-slideshow .dot{background:hsla(0,0%,100%,.4)}x-slideshow .dot.on{background:rgba(0,0,0,.8)}html[theme=dark] x-slideshow .dot.on{background:#fff}x-sortable{display:block;margin:1.5em auto;max-width:600px;position:relative}x-sortable>*{background:#0f82f2;border-radius:4px;color:#fff;cursor:grab;left:0;padding:8px 28px 8px 20px;position:absolute;top:0;transition:opacity .1s,box-shadow .1s;width:calc(100% - 48px)}x-sortable>:active{cursor:grabbing;z-index:100}x-sortable>:after{content:"…";position:absolute;right:0;top:7px;transform:rotate(90deg)}x-sortable:active>*{opacity:.6}x-sortable>:active{box-shadow:0 0 20px rgba(0,0,0,.3);opacity:1}x-sortable.solved:active>*,x-sortable.solved>*,x-sortable.solved>:active{background:none;border:1px solid #0f82f2;box-shadow:none;color:inherit;cursor:default;opacity:1;padding:7px 27px 7px 19px}x-sortable.solved:active>:after,x-sortable.solved>:active:after,x-sortable.solved>:after{display:none}x-step{color:#666;contain:layout style;display:block;height:0;line-height:1.7;opacity:0;overflow:hidden;pointer-events:none;position:relative;transform:translateX(-160px);word-spacing:.05em;z-index:1}html[theme=dark] x-step{color:#dedee0}x-step:after,x-step:before{clear:both;content:" ";display:table}x-course.ready x-step{transition:opacity .8s linear,transform .8s cubic-bezier(.165,.84,.44,1);will-change:opacity,transform}x-step.on{height:auto;opacity:1;overflow:visible;pointer-events:auto;transform:none}x-step:hover{z-index:2}x-step:focus-within{z-index:3}.reveal{visibility:hidden}.next-step{box-sizing:border-box;left:50%;margin-left:-70px;position:absolute;top:calc(100% + 12px);width:140px}x-step.hovering{z-index:1}p.voice{margin-left:-40px;padding-left:40px}.sentence{background-image:linear-gradient(rgba(253,140,0,.3),rgba(253,140,0,.3));background-repeat:no-repeat;background-size:0 100%;-webkit-box-decoration-break:clone;box-decoration-break:clone;transition:background .6s}.sentence.playing{background-size:100% 100%;border-radius:4px;margin:0 -4px;padding:0 4px}.playback-btn{background:#c5c2cc url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2214%22%20height%3D%2214%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22m7.5%206.17v11.66a1.12%201.12%200%200%200%201.73.94l9.16-5.77a1.13%201.13%200%200%200%200-1.91l-9.16-5.86a1.12%201.12%200%200%200%20-1.73.94z%22%2F%3E%3C%2Fsvg%3E") 2px 2px no-repeat;background-clip:content-box;border:10px solid transparent;border-radius:30px;cursor:pointer;height:18px;margin:-4px 0 0 -38px;opacity:0;pointer-events:none;position:absolute;transform:scale(0);transition:opacity .2s,background .2s,transform .2s;width:18px}li.voice .playback-btn{margin-left:-56px}.playback-btn.active,.playback-btn:focus,.voice:hover>.playback-btn{opacity:1;pointer-events:all;transform:scale(1)}.voice:hover>.playback-btn:hover{transform:scale(1.3)}.playback-btn:focus,.playback-btn:hover{background-color:#656073}.playback-btn.active{background:#fd8c00 url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2214%22%20height%3D%2214%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22m8%2019a2%202%200%200%200%202-2v-10a2%202%200%200%200%20-2-2%202%202%200%200%200%20-2%202v10a2%202%200%200%200%202%202zm6-12v10a2%202%200%200%200%202%202%202%202%200%200%200%202-2v-10a2%202%200%200%200%20-2-2%202%202%200%200%200%20-2%202z%22%2F%3E%3C%2Fsvg%3E") 2px 2px no-repeat;background-clip:content-box}x-step h2,x-step h3{color:#333;font-weight:600;line-height:1.15}html[theme=dark] x-step h2,html[theme=dark] x-step h3{color:#fff}x-step h2{border-bottom:2px solid #ddd;font-size:1.6em;margin:2em 0 1em;padding-bottom:6px}x-step .row h2{border:none;padding:0}x-step:first-child h2{margin-top:0}x-step h3{font-size:1.3em;margin:1.2em 0 .8em;text-align:center}x-step .row h3{text-align:left}x-step li strong,x-step p strong,x-step table strong{color:#333;font-weight:700}html[theme=dark] x-step li strong,html[theme=dark] x-step p strong,html[theme=dark] x-step table strong{color:#fff}x-step figure+p,x-step x-geopad+p{margin-top:.5em}x-step ol,x-step ul{margin:0 0 1em;padding:0;text-align:left}x-step ul{list-style-type:disc}x-step li{margin:0 0 .5em 1.5em}x-step .caption{color:#aaa;font-size:.85em;line-height:1.5;margin:.5em 0 0;text-align:center;vertical-align:top}html[theme=dark] x-step .caption{color:hsla(0,0%,100%,.55)}x-step .quote{color:#aaa;font-style:italic;margin:1.5em 2em;text-align:center}html[theme=dark] x-step .quote{color:hsla(0,0%,100%,.55)}x-step hr{background:#ddd;height:2px;margin:2em 0}x-step hr:first-child{margin-top:1em}x-step code{background:#eee;border:1px solid #ccc;border-radius:4px;color:#333;font-family:Courier,monospace;font-size:90%;margin:-.2em .1em;padding:.2em .4em;vertical-align:1px}x-step pre{margin:1em 0}x-step pre code{display:block;padding:.3em .8em}x-step table{border:none;border-collapse:collapse;border-spacing:0;margin:.5em auto 1.5em}x-step td,x-step th{border:none;padding:.6em;text-align:center;vertical-align:middle}x-step table.text-left td,x-step table.text-left th{text-align:left}@media screen and (max-width:540px){x-step td,x-step th{padding:.25em}}x-step td[align=left]{text-align:left}x-step td[align=center]{text-align:center}x-step td[align=right]{text-align:right}x-step .table-fixed{table-layout:fixed;width:95%}x-step .table-small,x-step .table-tiny{margin:0 auto 1em}x-step .table-small td{padding:.3em .6em}x-step .table-tiny td{padding:.2em .3em}x-step table.grid td,x-step table.grid th{border-bottom:1px solid #c5c2cc;border-right:1px solid #c5c2cc}x-step table.grid td:last-child,x-step table.grid th:last-child{border-right:none}x-step table.grid tr:last-child td{border-bottom:none}x-step table h3,x-step table p{margin:0;padding:0;text-align:center!important}x-step table img{height:auto;max-width:95%}x-step table .caption{text-align:center!important}x-step table .td_caption_small{padding-top:0!important}x-step .column,x-step .row{margin:-.5em -.5em .5em}x-step .row>*,x-step article .column>*{margin:.5em;width:260px}x-step .row.padded{margin:-.5em -24px .5em}x-step .row.padded-thin{margin:-.5em -12px .5em}x-step .row>.fit{width:-moz-fit-content;width:fit-content}x-step .row>*>:first-child{margin-top:0}x-step .row>*>:last-child{margin-bottom:0}x-step .row>*>p:first-child{margin-top:-6px}x-step svg{height:auto;max-width:100%}.sticky-wrap{position:relative}.sticky{position:sticky;top:54px}.fixme{background:#fcc}html[theme=dark] .fixme{background:rgba(204,0,0,.5)}.todo{background:#eee;border:2px solid #aaa;border-radius:12px;color:#999;font-size:20px;font-style:italic;margin:2em auto;max-width:580px;padding:22px 24px;text-align:center}html[theme=dark] .todo{background:hsla(0,0%,100%,.15)}@media (min-width:720px){.shifted{margin-top:-70px!important}}figure,x-gallery,x-slideshow{margin:2em auto}figure>img,figure>svg,figure>x-img{display:block;margin:0 auto .3em}x-select.segmented{display:flex;margin:0 auto .5em;width:-moz-fit-content;width:fit-content}x-select.segmented>*{border:1px solid #cd0e66;border-left:none;cursor:pointer;text-align:center;transition:color .2s,background .2s;width:100px}x-select.segmented>:first-child{border-left:1px solid #cd0e66;border-radius:20px 0 0 20px}x-select.segmented>:last-child{border-radius:0 20px 20px 0}x-select.segmented>:hover{background:rgba(205,14,102,.18)}x-select.segmented>.active{background:#cd0e66;color:#fff;cursor:default}html.is-tabbing x-select.segmented>:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #cd0e66;outline:none;z-index:1}.box,.frame,.theorem{background:#f5f5f6;border-radius:6px;box-sizing:border-box;color:rgba(0,0,0,.7);padding:16px}html[theme=dark] .box,html[theme=dark] .frame,html[theme=dark] .theorem{background:#2d2c38;color:inherit}.box>ol:last-child,.box>p:last-child:not(.btn-row),.box>ul:last-child,.frame>ol:last-child,.frame>p:last-child:not(.btn-row),.frame>ul:last-child,.theorem>ol:last-child,.theorem>p:last-child:not(.btn-row),.theorem>ul:last-child{margin-bottom:0}.box .caption,.frame .caption,.theorem .caption{color:rgba(0,0,0,.4)}html[theme=dark] .box .caption,html[theme=dark] .frame .caption,html[theme=dark] .theorem .caption{color:hsla(0,0%,100%,.55)}.box hr,.frame hr,.theorem hr{background:rgba(0,0,0,.2)}html[theme=dark] .box hr,html[theme=dark] .frame hr,html[theme=dark] .theorem hr{background:hsla(0,0%,100%,.25)}.frame.red,.red.box,.red.theorem{background:rgba(205,14,102,.25)}html[theme=dark] .frame.red,html[theme=dark] .red.box,html[theme=dark] .red.theorem{background:rgba(205,14,102,.4)}.blue.box,.blue.theorem,.frame.blue{background:rgba(15,130,242,.25)}html[theme=dark] .blue.box,html[theme=dark] .blue.theorem,html[theme=dark] .frame.blue{background:rgba(15,130,242,.4)}.frame.green,.green.box,.green.theorem{background:rgba(34,171,36,.25)}html[theme=dark] .frame.green,html[theme=dark] .green.box,html[theme=dark] .green.theorem{background:rgba(34,171,36,.4)}.frame.yellow,.yellow.box,.yellow.theorem{background:rgba(253,140,0,.25)}html[theme=dark] .frame.yellow,html[theme=dark] .yellow.box,html[theme=dark] .yellow.theorem{background:rgba(253,140,0,.4)}.frame.orange,.orange.box,.orange.theorem{background:rgba(235,71,38,.25)}html[theme=dark] .frame.orange,html[theme=dark] .orange.box,html[theme=dark] .orange.theorem{background:rgba(235,71,38,.4)}.frame.purple,.purple.box,.purple.theorem{background:rgba(109,59,191,.25)}html[theme=dark] .frame.purple,html[theme=dark] .purple.box,html[theme=dark] .purple.theorem{background:rgba(109,59,191,.4)}.frame.teal,.teal.box,.teal.theorem{background:rgba(0,158,166,.25)}html[theme=dark] .frame.teal,html[theme=dark] .teal.box,html[theme=dark] .teal.theorem{background:rgba(0,158,166,.4)}.frame.lime,.lime.box,.lime.theorem{background:rgba(191,194,18,.25)}html[theme=dark] .frame.lime,html[theme=dark] .lime.box,html[theme=dark] .lime.theorem{background:rgba(191,194,18,.4)}.box{margin:2em 0;padding:20px;position:relative}.box.with-title{border-top-left-radius:0;margin-top:calc(2em + 37px)}.box.no-padding{padding:0}figure .box{margin:0}figure .tabs+.box{padding-top:32px}.box h3{background:#181824;border-radius:12px 12px 0 0;color:#fff;font-size:18px;height:36px;left:0;line-height:36px;margin:0;padding:0 20px;position:absolute;top:-37px}@media screen and (max-width:540px){.box{border-radius:0}.box,.box h3{padding-left:24px}.box h3{border-top-left-radius:0}}.box.red h3{background:#cd0e66}.box.blue h3{background:#0f82f2}.box.green h3{background:#22ab24}.box.yellow h3{background:#fd8c00}.box.orange h3{background:#eb4726}.box.purple h3{background:#6d3bbf}.box.teal h3{background:#009ea6}.box.lime h3{background:#bfc212}.theorem{background:rgba(205,14,102,.25);border-left:6px solid #cd0e66;border-radius:3px 6px 6px 3px;margin:1.5em 0;padding:.6em 1em}html[theme=dark] .theorem{background:rgba(205,14,102,.4)}.theorem.red{border-color:#cd0e66}.theorem.blue{border-color:#0f82f2}.theorem.green{border-color:#22ab24}.theorem.yellow{border-color:#fd8c00}.theorem.orange{border-color:#eb4726}.theorem.purple{border-color:#6d3bbf}.theorem.teal{border-color:#009ea6}.theorem.lime{border-color:#bfc212}x-step p a{-webkit-touch-callout:none;background:transparent;border-radius:6px;color:inherit;cursor:pointer;display:inline-block;line-height:28px;margin:-3px -17px -3px -6px;outline:none;padding:0 17px 0 6px;position:relative;transition:background .2s,color .2s,box-shadow .2s}.caption x-step p a{height:24px;line-height:24px}x-step p a:before{background:#57a8f6;bottom:1px;content:" ";height:3px;left:5px;position:absolute;right:5px}x-step p a:focus,x-step p a:hover{background:#57a8f6;box-shadow:0 0 10px rgba(0,0,0,.2);color:rgba(0,0,0,.8)}x-step p a:before{right:17px}x-step p a:after{background:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%228%22%20height%3D%2214%22%3E%3Cpath%20fill%3D%22none%22%20stroke%3D%22rgba(0%2C0%2C0%2C0.6)%22%20stroke-width%3D%222px%22%20d%3D%22M2%202L6%207L2%2012%22%2F%3E%3C%2Fsvg%3E");content:" ";display:block;height:14px;left:auto;opacity:0;position:absolute;right:5px;top:7px;transition:opacity .1s;width:9px!important}x-step p a:focus:after,x-step p a:hover:after{opacity:1}.circled{background:#3a3645;border-radius:20px;color:#fff;display:inline-block;height:40px;line-height:40px;text-align:center;width:40px}.circled.red{background:#cd0e66}.circled.blue{background:#0f82f2}.circled.green{background:#22ab24}.circled.yellow{background:#fd8c00}.circled.orange{background:#eb4726}.circled.purple{background:#6d3bbf}.circled.teal{background:#009ea6}.circled.lime{background:#bfc212}.pill{background:rgba(101,96,115,.6);border-radius:16px;color:#fff;display:inline-block;line-height:1.5;min-width:10px;padding:0 10px;text-align:center}.pill.red{background:rgba(205,14,102,.6)}.pill.blue{background:rgba(15,130,242,.6)}.pill.green{background:rgba(34,171,36,.6)}.pill.yellow{background:rgba(253,140,0,.6)}.pill.orange{background:rgba(235,71,38,.6)}.pill.purple{background:rgba(109,59,191,.6)}.pill.teal{background:rgba(0,158,166,.6)}.pill.lime{background:rgba(191,194,18,.6)}.pill.step-target{-webkit-touch-callout:none;background-color:rgba(101,96,115,.6);cursor:pointer;outline:none;transition:background .2s,box-shadow .2s}.pill.step-target:focus,.pill.step-target:hover{background-color:#656073}html.is-tabbing .pill.step-target:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #656073}.pill.step-target.red{-webkit-touch-callout:none;background-color:rgba(205,14,102,.6);outline:none}.pill.step-target.red:focus,.pill.step-target.red:hover{background-color:#cd0e66}html.is-tabbing .pill.step-target.red:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #cd0e66}.pill.step-target.blue{-webkit-touch-callout:none;background-color:rgba(15,130,242,.6);outline:none}.pill.step-target.blue:focus,.pill.step-target.blue:hover{background-color:#0f82f2}html.is-tabbing .pill.step-target.blue:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #0f82f2}.pill.step-target.green{-webkit-touch-callout:none;background-color:rgba(34,171,36,.6);outline:none}.pill.step-target.green:focus,.pill.step-target.green:hover{background-color:#22ab24}html.is-tabbing .pill.step-target.green:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #22ab24}.pill.step-target.yellow{-webkit-touch-callout:none;background-color:rgba(253,140,0,.6);outline:none}.pill.step-target.yellow:focus,.pill.step-target.yellow:hover{background-color:#fd8c00}html.is-tabbing .pill.step-target.yellow:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #fd8c00}.pill.step-target.orange{-webkit-touch-callout:none;background-color:rgba(235,71,38,.6);outline:none}.pill.step-target.orange:focus,.pill.step-target.orange:hover{background-color:#eb4726}html.is-tabbing .pill.step-target.orange:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #eb4726}.pill.step-target.purple{-webkit-touch-callout:none;background-color:rgba(109,59,191,.6);outline:none}.pill.step-target.purple:focus,.pill.step-target.purple:hover{background-color:#6d3bbf}html.is-tabbing .pill.step-target.purple:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #6d3bbf}.pill.step-target.teal{-webkit-touch-callout:none;background-color:rgba(0,158,166,.6);outline:none}.pill.step-target.teal:focus,.pill.step-target.teal:hover{background-color:#009ea6}html.is-tabbing .pill.step-target.teal:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #009ea6}.pill.step-target.lime{-webkit-touch-callout:none;background-color:rgba(191,194,18,.6);outline:none}.pill.step-target.lime:focus,.pill.step-target.lime:hover{background-color:#bfc212}html.is-tabbing .pill.step-target.lime:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #bfc212}.var-action{-webkit-touch-callout:none;background:transparent;background:#cd0e66;background-color:#cd0e66;border-radius:6px;color:hsla(0,0%,100%,.8);cursor:pointer;display:inline-block;line-height:28px;margin:-3px 2px;min-width:20px;outline:none;padding:0 8px;position:relative;transition:color .2s,background .2s,box-shadow .2s,transform .3s}.caption .var-action{height:24px;line-height:24px}.var-action:before{background:none;bottom:1px;content:" ";height:3px;left:5px;position:absolute;right:5px}.var-action:focus,.var-action:hover{background-color:#ef1579}html.is-tabbing .var-action:focus{box-shadow:0 0 0 2px currentColor,0 0 0 4px #ef1579}.var-action:hover{transform:scale(1.08)}.var-action:active{transform:scale(.92)}.var-action:hover{box-shadow:0 0 10px rgba(0,0,0,.2);color:#fff}html.is-tabbing .var-action:focus{outline:none}.check{background:#22ab24 url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22m19.7%206.3-.2-.4-.3-.2c-.1-.1-.3%200-.4%200a36.6%2036.6%200%200%200%20-9.8%208.4%2036.1%2036.1%200%200%200%20-4.8-2.9h-.5l-1%20.9a.4.4%200%200%200%20-.1.3c0%20.2%200%20.3.1.4a72.1%2072.1%200%200%201%206.6%207h.4a.5.5%200%200%200%20.4-.2c3.8-6.8%205.7-9.6%209.4-13%20.2.1.2-.1.2-.3z%22%2F%3E%3C%2Fsvg%3E");border-radius:100%;display:inline-block;height:24px;text-align:center;vertical-align:middle;visibility:hidden;width:24px}.check.incorrect{background:#cd0e66 url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22M19%2C16l-4.7-4.3L18.6%2C7a1.2%2C1.2%2C0%2C0%2C0%2C0-1.5l-.4-.3a1%2C1%2C0%2C0%2C0-1.4%2C0L12%2C9.5%2C7.2%2C5.2a1%2C1%2C0%2C0%2C0-1.4%2C0l-.4.3A1.2%2C1.2%2C0%2C0%2C0%2C5.4%2C7l4.3%2C4.7L5%2C16a1.1%2C1.1%2C0%2C0%2C0-.1%2C1.4l1.5%2C1.4a.9.9%2C0%2C0%2C0%2C1.3%2C0L12%2C14.1l4.3%2C4.7a.9.9%2C0%2C0%2C0%2C1.3%2C0l1.5-1.4A1.1%2C1.1%2C0%2C0%2C0%2C19%2C16Z%22%2F%3E%3C%2Fsvg%3E")}.overflow-wrap{-webkit-overflow-scrolling:touch;margin:0 -40px;overflow:auto;overscroll-behavior:contain;padding:0 40px}.overflow-wrap.overflow-table{margin:1em -40px}.overflow-wrap table{margin:.5em auto}@media screen and (max-width:540px){.box,figure,x-gallery,x-slideshow{margin-left:-24px;margin-right:-24px}x-parallax.full-width{height:320px}figure .caption{padding:0 24px}.fill.box,.fill.theorem,.frame.fill,figure x-img img,figure x-video video{border-radius:0}x-slideshow .legend-box>*{padding-left:24px;padding-right:24px}x-slideshow .back{border-top-left-radius:0}x-slideshow .next{border-top-right-radius:0}x-gallery .back{border-bottom-left-radius:0}x-gallery .next{border-bottom-right-radius:0}}@media print{x-step{height:auto!important;opacity:1!important;transform:none!important}x-step .row,x-step>*{-moz-column-break-inside:avoid;break-inside:avoid}.reveal{visibility:visible!important}.caption,h2,h3,p,strong{color:#000!important}x-bio .popup,x-gloss .popup{display:none!important}}.target-body{display:none;height:100%;left:0;opacity:0;pointer-events:none;position:fixed;top:0;transform:translateZ(0);transition:opacity .3s;width:100%;will-change:opacity;z-index:900}.target-body>rect{fill:#fff}html[theme=dark] .target-body>rect{fill:#22212e}.target-body #arrow path{fill:#000}html[theme=dark] .target-body #arrow path{fill:#fff}.target-body .target-arrow{stroke:#000}html[theme=dark] .target-body .target-arrow{stroke:#fff}@keyframes spin{to{transform:rotate(1turn)}}x-tutor{display:block;font-size:16px}x-tutor .toasts{bottom:8px;max-width:264px;pointer-events:none;position:fixed;right:8px;transition:transform .4s;z-index:300}@media (max-width:400px){x-tutor .toasts{max-width:calc(100% - 80px)}}x-tutor .chat{background:#9fcdfa;border-radius:12px 0 0 0;bottom:0;box-shadow:0 0 12px rgba(0,0,0,.25);display:none;flex-direction:column;height:420px;max-height:calc(100vh - 44px);position:fixed;right:0;width:280px;z-index:301}html.webview x-tutor .chat{max-height:100vh}x-tutor .chat-header{background:#0b62b6;border-radius:12px 0 0 0;color:#fff;font-size:20px;font-weight:600;height:44px;line-height:44px;padding:0 12px}x-tutor .chat-header x-icon[name=fox]{margin:0 8px -9px 0}@media (max-height:450px){x-tutor .chat-header{border-radius:0}}x-tutor .close{fill:hsla(0,0%,100%,.6);cursor:pointer;padding:10px;position:absolute;right:0;top:0;transition:fill .2s,transform .2s}x-tutor .close x-icon{display:block}x-tutor .close:focus,x-tutor .close:hover{fill:#fff;transform:scale(1.4)}x-tutor .chat-body{-webkit-overflow-scrolling:touch;flex:1 1;overflow:auto;overscroll-behavior:contain;padding:2px 8px 44px;position:relative;-webkit-user-select:text;-moz-user-select:text;user-select:text}x-tutor .chat-body.loading:after{animation:spin .7s linear infinite;border:3px solid rgba(15,130,242,.25);border-radius:14px;border-top-color:#0f82f2;content:"";display:block;float:right;height:14px;margin:8px 2px -28px 0;width:14px}x-tutor .chat-footer{background:#fff;display:flex}x-tutor .chat-footer .hint{fill:#656073;cursor:pointer;position:relative;transition:fill .2s}x-tutor .chat-footer .hint:focus,x-tutor .chat-footer .hint:hover{fill:#3a3645}x-tutor .chat-footer .hint x-icon{display:block;padding:8px}x-tutor .chat-footer .input{-webkit-user-modify:read-write-plaintext-only;cursor:text;flex-grow:1;line-height:1.3;max-height:64px;overflow:auto;padding:10px 8px 10px 20px;-webkit-user-select:text;-moz-user-select:text;user-select:text}x-tutor .chat-footer .input:empty:before{color:#aaa;content:"Type a question… (beta)"}x-tutor .msg-wrap{align-items:flex-end;display:flex;flex-direction:column}x-tutor .msg{border-radius:16px 16px 3px 16px;margin-top:6px;width:-moz-fit-content;width:fit-content}x-tutor .toasts .msg{box-shadow:0 2px 6px rgba(0,0,0,.25);cursor:pointer;pointer-events:all}x-tutor .msg.hint,x-tutor .msg.question{line-height:1.4;padding:5px 12px}x-tutor .msg.hint{background:#0f82f2;color:hsla(0,0%,100%,.9)}x-tutor .msg.question{align-self:flex-start;background:#fff;border-radius:16px 16px 16px 3px;color:#0f82f2}x-tutor .msg.archie{background:#0f82f2;border-radius:28px 28px 3px 28px;padding:10px 6px 6px 10px;transition:background .2s}x-tutor .msg.archie x-icon{display:block}x-tutor .msg.correct{background:#1e9620}x-tutor .msg.incorrect{background:#b50c5a}x-tutor .msg.img{background-color:#000;background-size:cover;height:100px;width:150px}x-tutor .msg.video{background:#000;border-radius:3px;overflow:hidden}x-tutor .msg.video iframe{border:none;display:block;height:126px;width:224px}x-tutor .msg p{margin:0}x-tutor .msg .source{color:hsla(0,0%,100%,.5);font-size:10px;margin-top:2px;text-align:right}x-tutor .msg a{transition:color .2s}x-tutor .msg a:hover{color:#fff}html.webview x-tutor .chat-footer:not(.focus){border-bottom:env(safe-area-inset-bottom) solid #d0d3da;transition:border-bottom-width .3s}html.webview x-tutor .msg.archie{border-radius:28px;padding:8px}p .var,p .var strong{color:#cd0e66}.circled .var,.circled.var,.pill .var,.pill.var{color:#fff}x-var{-webkit-touch-callout:none;background:transparent;background:#cd0e66;border-radius:6px;color:hsla(0,0%,100%,.8);cursor:pointer;display:inline-block;line-height:28px;margin:-3px 2px;padding:0 18px;position:relative;touch-action:none;transition:color .2s,box-shadow .2s}.caption x-var{height:24px;line-height:24px}x-var:before{background:none;bottom:1px;content:" ";height:3px;left:5px;position:absolute;right:5px}x-var .left,x-var .right{opacity:.6;padding:7px 1px;position:absolute;top:0;transition:opacity .2s}x-var .left svg,x-var .left x-icon,x-var .right svg,x-var .right x-icon{color:#fff;display:block}x-var .left{left:0;padding-right:4px}x-var .right{padding-left:4px;right:0}x-var .bubble{bottom:28px;left:50%;margin-left:-60px;opacity:0;padding-bottom:6px;pointer-events:none;position:absolute;transform:scale(.5);transform-origin:bottom center;transition:transform .2s,opacity .2s;width:120px;z-index:500}x-var .bubble-box{background:#cd0e66;border-radius:6px;box-shadow:0 0 15px rgba(0,0,0,.15);display:block;height:10px;position:relative}x-var .bubble-arrow{border-left:6px solid transparent;border-right:6px solid transparent;border-top:6px solid #cd0e66;bottom:0;display:block;height:0;left:50%;margin-left:-6px;position:absolute;width:0}x-var .progress{background:#fff;border-radius:6px;bottom:2px;display:block;left:2px;position:absolute;top:2px}x-var.on,x-var:hover{box-shadow:0 0 20px rgba(0,0,0,.3);color:#fff}x-var.on .left,x-var.on .right,x-var:hover .left,x-var:hover .right{opacity:1}x-var.on .bubble,x-var:hover .bubble{opacity:1;transform:none}.var-overlay{display:none;height:100%;left:0;position:absolute;position:fixed;top:0;width:100%;z-index:999}x-play-btn{display:block;left:50%;position:absolute;top:50%}x-play-btn .play-btn-box{background:rgba(0,0,0,.8);border-radius:6px;cursor:pointer;height:44px;margin:-24px;opacity:.9;padding:2px;transition:transform .2s,opacity .2s,background .2s;width:44px}x-play-btn .play-btn-box x-icon{fill:#fff}x-video x-play-btn .play-btn-box{border:1px solid hsla(0,0%,100%,.8);margin:-25px;pointer-events:none}x-play-btn .play-btn-box:focus,x-play-btn .play-btn-box:hover,x-video:hover x-play-btn .play-btn-box{background:rgba(0,0,0,.9);opacity:1;transform:scale(1.2)}x-video.playing x-play-btn .play-btn-box{opacity:0;transform:scale(.2)}x-play-toggle,x-video{display:block}x-video{margin:0 auto;max-width:100%;position:relative}x-video .video-wrap{cursor:pointer;height:0}x-video video{-webkit-touch-callout:none;border-radius:4px;height:100%;position:absolute;width:100%}x-video x-icon{fill:#fff;display:block}x-video .credit{background:rgba(0,0,0,.8);border-top-right-radius:4px;color:#fff;font-size:10px;opacity:0;padding:1px 8px;position:absolute;right:0;top:0;transition:opacity .2s}x-video .credit:empty{display:none}x-video:hover .credit{opacity:.8}x-video .controls{display:none;transition:opacity .2s}x-video.playing:not(:hover) .controls{opacity:0}x-video .shadow{background:linear-gradient(180deg,transparent,#000);bottom:0;height:50px;opacity:.5;position:absolute;width:100%}x-video .play-pause-btn{bottom:0;cursor:pointer;left:0;padding:6px;position:absolute;transition:transform .2s}x-video .play-pause-btn:hover{transform:scale(1.2)}x-video .pause-icon,x-video.playing .play-icon{display:none}x-video.playing .pause-icon{display:block}x-video .timeline{bottom:16px;height:12px;left:50px;position:absolute;right:60px}x-video .bar{cursor:pointer;height:4px;padding:4px 0;position:relative}x-video .bar>*{border-radius:2px;height:4px;position:absolute;top:4px}x-video .background{width:100%}x-video .background,x-video .buffer{background:hsla(0,0%,100%,.5)}x-video .handle,x-video .progress{background:#cd0e66}x-video .handle{border-radius:8px;cursor:pointer;height:14px;margin-left:-7px;position:absolute;top:-1px;transition:transform .2s,background .2s;width:14px}x-video .handle:active,x-video .handle:hover{background:#f01e7f;transform:scale(1.4)}x-video .timecode{bottom:9px;color:#fff;font-size:16px;pointer-events:none;position:absolute;right:16px}x-tabbox{display:block;margin:1.5em 0}x-tabbox .body{background:#f5f5f6;border-radius:6px;padding-top:18px}html[theme=dark] x-tabbox .body{background:#2d2c38}x-tabbox .tab{display:none;padding:1em 24px}x-tabbox .tab p:last-child{margin-bottom:0}x-tabbox.full-width .tab{padding:0;position:relative}x-tabbox.full-width .tab svg{margin:0}x-select.tabs,x-tabbox .titles{-webkit-overflow-scrolling:touch;display:flex;margin:0 auto -18px;max-width:calc(100% - 12px);overflow:auto;overscroll-behavior:contain;width:-moz-fit-content;width:fit-content}x-select.tabs{position:relative;z-index:1}x-tabbox.sticky .titles{position:sticky;top:48px;z-index:2}.webview x-tabbox.sticky .titles{top:4px}x-select.tabs>*,x-tabbox h3{background:#c5c2cc;border:1px solid #fff;color:#333;cursor:pointer;flex-shrink:0;font-size:18px;font-weight:600;height:36px;line-height:36px;margin:0;padding:0 16px;text-align:center;transition:color .2s,background .2s}html[theme=dark] x-select.tabs>*,html[theme=dark] x-tabbox h3{background:#a7a6ab;border-color:#22212e;color:#3a3645}x-select.tabs>:focus,x-select.tabs>:hover,x-tabbox h3:focus,x-tabbox h3:hover{background:#807c89;color:#fff}x-select.tabs>.active,x-tabbox h3.active{background:#3a3645;color:#fff;cursor:default}html[theme=dark] x-select.tabs>.active,html[theme=dark] x-tabbox h3.active{background:#e9e9ea}x-select.tabs>:first-child,x-tabbox h3:first-child{border-radius:20px 0 0 20px}x-select.tabs>:last-child,x-tabbox h3:last-child{border-bottom-right-radius:20px;border-top-right-radius:20px}x-select.tabs>:nth-child(n+2),x-tabbox h3:nth-child(n+2){border-left:none}x-select.tabs>* .check,x-tabbox h3 .check{border:1px solid #fff;margin:0 -6px 3px 6px}@media screen and (max-width:540px){x-tabbox{margin:1.5em -24px}x-tabbox .body{border-radius:0;padding:0}x-select.tabs,x-tabbox .titles{margin:0 0 0 -1px;max-width:100%}x-select.tabs>:first-child,x-tabbox h3:first-child{border-radius:0}x-select.tabs>:last-child,x-tabbox h3:last-child{border-radius:0 8px 0 0}}body,html{-webkit-text-size-adjust:none;-moz-text-size-adjust:none;text-size-adjust:none;touch-action:pan-y;-webkit-user-select:none;-moz-user-select:none;user-select:none}main{padding:44px 40px 0 320px}x-course{display:block}article{margin:0 auto;max-width:760px;-webkit-user-select:text;-moz-user-select:text;user-select:text}h1{color:#000;font-weight:600;margin:112px 0 64px}html[theme=dark] h1{color:#fff}.course-title{display:none;font-size:24px;opacity:.3}.steps{min-height:calc(100vh - 664px)}.page-background{bottom:0;left:280px;position:fixed;right:0;top:44px;z-index:-1}article.dark .page-background{background:#000}.reveal-banner{background:hsla(255,7%,76%,.95);border-radius:0 24px 24px 0;color:#fff;font-size:13px;left:280px;line-height:17px;padding:4px 18px 4px 16px;position:fixed;top:60px;transition:transform .4s,opacity .4s;z-index:100}.reveal-banner svg{display:inline-block;margin:0 0 -2px 3px}.reveal-banner path{stroke:#fff;fill:none;stroke-width:1.5px;stroke-linecap:round}.reveal-banner .complete{cursor:pointer;display:block;width:-moz-fit-content;width:fit-content}.reveal-banner .complete:hover{text-decoration:underline}.reveal-banner.off{opacity:0;transform:translateX(-100%)}.section-dev{color:#999;text-align:center}.section-dev svg{fill:#999;margin:0 auto 6px;width:120px}.section-dev h2{margin:0 0 12px}footer{display:none;height:320px;padding-top:80px;position:relative}.next-section{display:none;margin:0 auto;max-width:100%;transition:transform .2s,filter .2s;width:-moz-max-content;width:max-content}.next-section:focus,.next-section:hover{filter:drop-shadow(0 4px 12px rgba(0,0,0,.25));transform:scale(1.05)}.next-arrow{border-radius:6px;box-sizing:border-box;color:#fff;height:74px;line-height:1.4;-webkit-mask:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22720%22%20height%3D%2274%22%3E%3Cpath%20d%3D%22M718.8%2C34.2%2C705.2%2C2.8A4.9%2C4.9%2C0%2C0%2C0%2C701%2C0H0V74H701a4.9%2C4.9%2C0%2C0%2C0%2C4.2-2.8l13.6-31.4A7.7%2C7.7%2C0%2C0%2C0%2C718.8%2C34.2Z%22%2F%3E%3C%2Fsvg%3E");mask:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22720%22%20height%3D%2274%22%3E%3Cpath%20d%3D%22M718.8%2C34.2%2C705.2%2C2.8A4.9%2C4.9%2C0%2C0%2C0%2C701%2C0H0V74H701a4.9%2C4.9%2C0%2C0%2C0%2C4.2-2.8l13.6-31.4A7.7%2C7.7%2C0%2C0%2C0%2C718.8%2C34.2Z%22%2F%3E%3C%2Fsvg%3E");-webkit-mask-position:right top;mask-position:right top;-webkit-mask-size:720px 74px;mask-size:720px 74px;max-width:100%;padding:8px 36px 0 18px;position:relative;transition:background .2s;-webkit-user-select:none;-moz-user-select:none;user-select:none}.next-arrow .small{color:hsla(0,0%,100%,.6);font-size:16px}.next-arrow .title{font-size:26px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.next-arrow .next-icon{background-position:50%;background-size:cover;border-radius:6px 0 0 6px;border-right:2px solid #fff;height:74px;left:0;position:absolute;top:0;width:74px}.next-arrow .next-icon+.small,.next-arrow .next-icon+.small+.title{padding-left:74px}.skip-step{bottom:0;box-sizing:border-box;color:#888;display:none;font-size:14px;line-height:20px;margin:0;padding:0 40px 24px;position:absolute;text-align:center;width:100%}html[theme=dark] .skip-step{color:#fff}.skip-step a{white-space:nowrap}x-course.ready .skip-step{display:block}@media (max-width:650px){.skip-step br{display:none}}.skip-step svg{display:block;margin:8px auto 0}@media screen and (max-width:840px){main{padding:44px 40px 0}.page-background{left:0}h1{margin:80px 0 54px}.course-title{display:block}.reveal-banner{left:0}}@media screen and (max-width:540px){main{padding:44px 24px 0}.overflow-wrap{margin-left:-24px;margin-right:-24px;padding:0 24px}}@media print{.page-background,footer,header,x-course-sidebar,x-tutor{display:none!important}main{margin:0!important;padding:0 20px!important}article{max-width:none!important}}html.webview main{padding:0 calc(40px + env(safe-area-inset-right)) 0 calc(40px + env(safe-area-inset-left))}html.webview .page-background{left:0;top:0}html.webview .skip-step{padding:0 40px calc(24px + env(safe-area-inset-bottom))}html.webview .steps{min-height:calc(100vh - 620px)}html.webview .reveal-banner{left:0;padding-left:calc(12px + env(safe-area-inset-left));top:16px}@media screen and (max-width:540px){html.webview main{padding:0 calc(24px + env(safe-area-inset-right)) 0 calc(24px + env(safe-area-inset-left))}html.webview .skip-step{background:#eee;margin:0 calc(-24px - env(safe-area-inset-right)) -6px calc(-24px - env(safe-area-inset-left));padding:14px 90px calc(14px + env(safe-area-inset-bottom)) 24px;text-align:left;width:auto}html[theme=dark] html.webview .skip-step{background:#444}}x-algebra-flow,x-math{position:relative}x-algebra-flow svg.equation,x-math svg.equation{fill:currentColor;overflow:visible;width:100%}x-algebra-flow svg.equation *,x-math svg.equation *{transform-origin:0 0}x-algebra-flow .overlay,x-math .overlay{left:0;position:absolute;top:0}x-algebra-flow .overlay>*,x-math .overlay>*{position:absolute;transform-origin:0 0}x-algebra-flow line,x-algebra-flow path,x-math line,x-math path{fill:none;stroke:currentColor;stroke-width:1.45;stroke-linejoin:round;stroke-linecap:round;transform-box:view-box;transform-origin:top left}x-algebra-flow text,x-math text{dominant-baseline:text-before-edge;stroke:currentColor;fill:currentColor;stroke-width:0;font-family:Mathigon Symbol,Source Sans Pro,sans-serif}x-algebra-flow text.font-normal,x-math text.font-normal{font-family:Source Sans Pro,Helvetica,sans-serif}x-math{display:inline-block;font-style:normal}x-math svg.equation{height:100%}x-algebra-flow{display:block;margin:1.5em auto;max-width:440px;position:relative}x-algebra-flow .legend-box{border-top:2px solid #ccc;font-size:16px;line-height:1.5}x-algebra-flow .legend-box p{display:none}x-algebra-flow .legend-box li{display:none;margin:0;padding:8px 48px 0;text-align:center}x-algebra-flow .nav{height:0;position:relative}x-algebra-flow .back,x-algebra-flow .next{border-radius:0 0 6px 6px;display:block;height:36px;min-width:0;padding:0;position:absolute;top:0;transition:opacity .4s,background .2s,color .2s,box-shadow .2s,transform .2s;width:36px;z-index:1}x-algebra-flow .back.hide,x-algebra-flow .next.hide{opacity:0;pointer-events:none}x-algebra-flow .back x-icon,x-algebra-flow .next x-icon{margin:6px}x-algebra-flow .back{transform-origin:left top}x-algebra-flow .next{right:0;transform-origin:right top}.m-red{color:#cd0e66}.m-blue{color:#0f82f2}.m-green{color:#22ab24}.m-yellow{color:#fd8c00}.m-orange{color:#eb4726}.m-purple{color:#6d3bbf}.m-teal{color:#009ea6}.m-lime{color:#bfc212}.lgrey{color:#aaa}.gradient-red{background:#cd0e66 linear-gradient(to bottom right,#cd0e66,#eb4726)}.gradient-orange{background:#eb4726 linear-gradient(to bottom right,#eb4726,#fd8c00)}.gradient-yellow{background:#fd8c00 linear-gradient(to bottom right,#fd8c00,#bfc212)}.gradient-lime{background:#bfc212 linear-gradient(to bottom right,#bfc212,#22ab24)}.gradient-green{background:#22ab24 linear-gradient(to bottom right,#22ab24,#009ea6)}.gradient-teal{background:#009ea6 linear-gradient(to bottom right,#009ea6,#0f82f2)}.gradient-blue{background:#0f82f2 linear-gradient(to bottom right,#0f82f2,#6d3bbf)}.gradient-purple{background:#6d3bbf linear-gradient(to bottom right,#6d3bbf,#cd0e66)}@media (min-width:601px){header .nav-small{display:none!important}}@media (max-width:600px){header .nav-large{display:none!important}header .nav-item>.nav-link{padding:4px 12px}}x-modal#login{width:500px}x-modal#login .modal-body{padding:24px 16px 12px}x-modal#login h2{text-align:center}x-modal#login .btn-row.social{display:flex;flex-wrap:wrap;justify-content:center}x-modal#login .btn-row.social .btn,x-modal#login .btn-row.social .icon-btn,x-modal#login .btn-row.social .next-step{margin:6px;width:140px}x-modal#login .hr{background:#c5c2cc;height:1px;margin:1em 8px;position:relative}x-modal#login .hr span{background:#fff;color:#aaa;display:block;font-size:14px;left:50%;line-height:1;margin-top:-7px;padding:0 12px;position:absolute;text-align:center;text-transform:uppercase;transform:translateX(-50%);white-space:nowrap}.polypad,.tangram{--canvas-bg:#fff;--canvas-fg:#181824}[theme=dark] .polypad,[theme=dark] .tangram{--canvas-bg:#22212e;--canvas-fg:#e2e1e6}x-equation{-webkit-touch-callout:none;background:transparent;background:#0f82f2;border-radius:6px;color:#fff;cursor:pointer;cursor:text;display:inline-block;height:auto;line-height:28px;margin:0;padding:4px 34px 4px 12px;position:relative;text-align:left;transition:background .2s,color .2s,padding .2s,box-shadow .2s}.caption x-equation{height:24px;line-height:24px}x-equation:before{background:none;bottom:1px;content:" ";height:3px;left:5px;position:absolute;right:5px}x-equation.small{font-size:1em;line-height:24px;padding:2px 28px 2px 8px}x-equation.active{z-index:1}x-equation.done{background:none;box-shadow:none;color:#0f82f2;cursor:default;padding:0}html.is-tabbing x-equation.active{box-shadow:0 0 0 2px currentColor,0 0 0 4px #0f82f2}x-equation .input{height:0;overflow:hidden;position:absolute;transform:scale(0);width:0}x-equation.done .input{display:none}x-equation:not(.done) mi+mi{margin-left:0}x-equation>.math{display:inline-block;min-width:80px}x-equation.small .math{min-width:25px}x-equation .math.empty{margin-right:-6px}x-equation .math.empty:after{content:"???"}x-equation.small .math.empty:after{margin-left:10px}x-equation.done .math{min-width:0}x-equation .cursor{animation:cursor 1s step-end infinite;border-right:1px solid;display:none;margin-left:-1px}x-equation.active .cursor{display:inline-block}x-equation mrow.empty{min-width:12px;text-align:center}x-equation mrow.empty:after{content:"◻︎";display:inline-block;margin:0 -.5em;opacity:.5}x-equation .keys{left:0;margin-top:6px;opacity:0;pointer-events:none;position:absolute;top:100%;transform:translateY(-12px);transition:opacity .2s,transform .2s;width:136px}x-equation .btn,x-equation .icon-btn,x-equation .next-step{border-radius:4px;float:left;height:24px;line-height:24px;margin:0 6px 6px 0;min-width:0;padding:2px;width:24px}x-equation .btn rect,x-equation .icon-btn rect,x-equation .next-step rect{fill:#fff;opacity:.45}x-equation .btn line,x-equation .icon-btn line,x-equation .next-step line{stroke:#fff}x-equation .btn path,x-equation .icon-btn path,x-equation .next-step path{fill:#fff}x-equation.active .keys{opacity:1;pointer-events:all;transform:none}x-equation .error{margin-top:-12px;pointer-events:none;position:absolute;right:6px;top:50%}x-equation .error-message{background:#cd0e66;border-radius:6px;bottom:100%;box-shadow:0 2px 4px rgba(0,0,0,.2);color:#fff;cursor:pointer;font-size:14px;left:0;line-height:1.4;margin-bottom:10px;max-width:180px;padding:6px 12px;pointer-events:none;position:absolute;transform-origin:18px bottom -6px;width:-moz-max-content;width:max-content;z-index:10}x-equation .error-message p{margin:0;text-align:left!important}x-equation .error-message:after{border:6px solid transparent;border-top-color:#cd0e66;bottom:-12px;content:" ";left:12px;position:absolute}x-equation .error,x-equation .error-message{opacity:0;transform:scale(.5);transition:opacity .2s,transform .2s}x-equation.has-error:not(.active) .error,x-equation.has-error:not(.active) .error-message{opacity:1;transform:none}x-equation.has-error:not(.active) .error-message{pointer-events:all;transition-delay:.4s}x-equation.done .error,x-equation.done .error-message{display:none}x-equation.small .error{margin-top:-10px;right:4px}x-equation.small .error svg{height:18px;width:18px}x-equation-system{display:block}article x-equation-system table td,table.eqn-system td{padding:.2em .3em;text-align:left}table.eqn-system td{vertical-align:baseline}table.eqn-system td:first-child{text-align:right}.tile{transform-box:view-box;transform-origin:0 0}.tile .handle:not(.persistent),.tile .outline{display:none}.tile.active .handle,.tile.active .link-handle,.tile.active .outline{display:block!important}.tile.no-handles.active .handle{display:none!important}x-polypad:not(.author-mode) .hidden-tile{display:none}x-polypad:not(.author-mode) .locked-tile{pointer-events:none}.geo-path.hidden-tile,.geo-point.hidden-tile,.hidden-tile>:not(.outline,.handle){opacity:.4}.link-handle{fill:#0f82f2;stroke:transparent;stroke-width:10}.link-dot{stroke:var(--canvas-bg);fill:#0f82f2;stroke-width:3}.link-bar{stroke:#0f82f2;stroke-width:5px;fill:none;cursor:move}.link-bar path.dashed{stroke-dasharray:6px 10px;stroke-dashoffset:8px}.group-outline,.rotate-bar,.tile .handle,.tile .outline{stroke-width:6px}.group-outline,.rotate-bar,.tile .outline{stroke:var(--canvas-fg);fill:none}.hidden-tile .outline,.locked-tile .outline{stroke-dasharray:10px 16px}.rotate-circle,.tile .handle{fill:var(--canvas-fg)}.tile path.handle{stroke:var(--canvas-fg)}.group-outline,.rotate-bar{pointer-events:none}.group-shadow{fill:var(--canvas-fg);opacity:15%}.rotate-circle,.tile circle.handle{stroke:transparent;stroke-width:8px}.rotate-circle{cursor:move}.balance,.number-grid-cell circle,.number-tile,.polygon-tile{stroke:var(--canvas-bg);stroke-width:1px}.high-contrast .balance,.high-contrast .number-grid-cell circle,.high-contrast .number-tile,.high-contrast .polygon-tile{stroke:var(--canvas-fg);stroke-width:2px}.prime-move,.prime-segment:hover{stroke:var(--canvas-fg);stroke-width:3px}.grid-axis,.number-line-ticks{stroke-width:3px}.active .grid-axis,.active .number-line-ticks{stroke-width:6px}.axis-gridlines{stroke-width:2px;opacity:.15;pointer-events:none}.penrose-circles{fill:none;stroke-width:2px;stroke:#fff;opacity:.4}.dice-face{stroke-width:4px}.dice-dot{fill:#fff;opacity:.85}.balance-beam{fill:none;stroke-width:8px}.active .balance,.active .balance-beam,.active .bucket{stroke:var(--canvas-fg);stroke-width:6px}.dropzone{fill:none;stroke:var(--canvas-fg);stroke-width:4px;stroke-dasharray:8px 12px;stroke-dashoffset:4px;pointer-events:none}.spinner{fill:var(--canvas-fg);stroke:var(--canvas-bg)}.spinner,pp-tiles .spinner{stroke-width:1px}.utensil .glass{fill:hsla(258,9%,78%,.7)}.utensil .ticks{stroke-width:.6;stroke:var(--canvas-fg);stroke-linecap:butt;pointer-events:none}.utensil .compass-frame,.utensil .compass-legs{fill:#c5c2cc}.utensil .compass-needle,.utensil .compass-top{fill:#656073}.utensil .compass-screw{fill:#c5c2cc}.utensil .compass-pencil{stroke:#656073}.utensil text{fill:var(--canvas-fg);font-size:12px}.polypad.dark .utensil .glass{fill:rgba(101,96,115,.7)}.polypad.dark .utensil .compass-legs{fill:#656073}.polypad.dark .utensil .compass-needle{fill:#c5c2cc}.dot-cell{fill:none;stroke-width:20px;fill-opacity:.3}.bead-gradient{stroke:var(--canvas-bg);fill:url(#sphere-gradient);pointer-events:none}.active .bead-gradient{stroke:var(--canvas-fg);stroke-width:6px}.clock-handle{stroke:transparent;stroke-width:16px;cursor:move;transform-origin:bottom center}.axis-label{font-size:16px;font-weight:700}.axis-label,.geo-label{stroke:var(--canvas-bg);stroke-width:4px;stroke-linejoin:round;paint-order:stroke}.is-safari .axis-label,.is-safari .geo-label{stroke:none}.no-labels text{display:none}.number-line-label,.polygon-label,.polygon-text-label{font-weight:600}.number-line-label,.polygon-label{font-size:18px}.polygon-text-label{pointer-events:none}.number-line-label{transform-box:fill-box;transform-origin:center}.fraction .equation text,.number-line .equation text{font-weight:600}.fraction .equation line{stroke-width:2px}.number-grid-cell.active circle{stroke:var(--canvas-fg);stroke-width:6px}.number-grid-cell text{font-size:24px}.card-label path,.card-label rect{fill:var(--canvas-fg)}.card-label text{stroke:none;fill:var(--canvas-bg);font-size:14px;font-weight:600}.hidden-input{display:none;height:0;overflow:hidden;position:absolute;transform:scale(0);width:0}.problem-box{stroke:#0f82f2;stroke-width:4px;fill:rgba(15,130,242,.25);transition:stroke .3s,fill .3s}.correct .problem-box{stroke:#22ab24;fill:rgba(34,171,36,.25)}.incorrect .problem-box{stroke:#cd0e66;fill:rgba(205,14,102,.25)}.active .problem-box{stroke-width:6px}.problem-text{fill:var(--canvas-fg);color:var(--canvas-fg);cursor:text;font-size:32px;text-align:center}.problem-marker{transform:scale(0);transition:transform .2s cubic-bezier(.33,1.9,.52,.7)}.problem-marker.show{transform:none}.action-card-text{cursor:text;display:none;font-size:20px;text-align:center}@keyframes cursor{0%,to{opacity:1}50%{opacity:0}}.equation{transform-origin:0 0}.equation line,.equation path{fill:none;stroke:currentColor;stroke-width:1.45;transform-box:view-box;transform-origin:top left}.equation text{dominant-baseline:text-before-edge;stroke:currentColor;fill:currentColor;stroke-width:0;font-family:Mathigon Symbol,Source Sans Pro,sans-serif}.equation text.font-normal{font-family:Source Sans Pro,Helvetica,sans-serif}.equation .placeholder{fill:currentColor;opacity:.3}.equation .cursor{stroke:#0f82f2;stroke-width:1.5px;animation:cursor 1s step-end infinite}.equation .range{fill:#87c1f9}.text-edit{-webkit-user-modify:read-write-plaintext-only;word-wrap:normal;font-size:20px;line-height:1.4em;padding:2px 8px;pointer-events:none;-webkit-user-select:text;-moz-user-select:text;user-select:text;width:-moz-fit-content;width:fit-content}.text-edit[contenteditable]{pointer-events:all}.geo-path{fill:none;stroke:currentColor;stroke-width:3px}.geo-path.fill{fill:currentColor;stroke:none;opacity:.5}.geo-path.fill.hover{opacity:.8}.geo-point{fill:currentColor}.geo-point.intersection{stroke:currentColor;stroke-width:3px;fill:var(--canvas-bg)}svg:not(:hover) .geo-point.pending{display:none!important}.geo-shadow{stroke-width:10px;stroke:currentColor;fill:none;display:none}.table-tile{background:var(--canvas-bg);border-left:1px solid var(--border);border-top:1px solid var(--border);display:grid;width:-moz-fit-content;width:fit-content}.table-tile.active{cursor:text}.table-selection{stroke:var(--canvas-fg);fill:var(--canvas-fg);fill-opacity:10%;stroke-width:5px;pointer-events:none}.table-cell{-webkit-user-modify:read-write-plaintext-only;border-bottom:1px solid var(--border);border-right:1px solid var(--border);box-sizing:border-box;color:var(--canvas-fg);font-size:20px;height:50px;line-height:45px;max-width:200px;min-width:100px;padding:2px 8px;text-align:center;-webkit-user-select:text;-moz-user-select:text;user-select:text;white-space:pre}.table-cell.header{background:var(--header);font-weight:700}.table-cell:focus{outline:none}.table-cell:focus:empty{content:"​";display:inline}.table-cell .table-color{border-radius:15px;display:inline-block;height:30px;margin-bottom:-8px;width:30px}.table-hidden{left:0;opacity:0;pointer-events:none;position:fixed;top:0}.chart-line{fill:none;stroke-width:3}.chart-outline{fill:none;stroke-width:6px;stroke:var(--canvas-fg)}.chart-shadow{stroke-width:10px;fill:none;opacity:.4}.donut-hole{fill:var(--canvas-bg)}.chart-focussed{cursor:pointer}@keyframes speaker-move{0%{transform:none}50%{transform:translateX(3px)}to{transform:none}}@keyframes metronome{0%{transform:rotate(-30deg)}50%{transform:rotate(30deg)}to{transform:rotate(-30deg)}}.effects-speaker-move{animation:speaker-move .1s}.polypad svg.overlay,x-polypad{stroke-linecap:round;stroke-linejoin:round;text-anchor:middle}x-polypad{text-anchor:middle;background:var(--canvas-bg);display:block;overflow:hidden;position:relative;touch-action:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}x-polypad .canvas{height:100%;outline:none;width:100%}x-polypad .html-overlay,x-polypad .html-overlay>*{left:0;position:absolute;top:0}x-polypad .selection{stroke:#87c1f9;fill:rgba(135,193,249,.5);display:none}x-polypad .stroke{stroke-width:3px;fill:none}x-polypad .stroke.marker{stroke-width:8px}x-polypad .stroke.highlighter{stroke-width:24px;mix-blend-mode:multiply;opacity:.4}x-polypad .stroke.cut{stroke:var(--canvas-fg);stroke-dasharray:10px}.dark x-polypad .stroke.highlighter{mix-blend-mode:screen}x-polypad[data-tool=text]{cursor:text}x-polypad[data-tool=pan]{cursor:move}x-polypad[data-tool=cutPolygon],x-polypad[data-tool=geoPending],x-polypad[data-tool=geo]{cursor:crosshair}x-polypad .geo-paths,x-polypad .geo-points,x-polypad .geo-shadows,x-polypad .grid,x-polypad .selection,x-polypad .strokes,x-polypad:not([data-tool=move]) .tiles{pointer-events:none}x-polypad .grid{opacity:var(--grid-opacity,.25)}x-polypad.high-contrast .grid{opacity:1}x-polypad .geo-shadows{opacity:.3}x-polypad .grid-pattern line,x-polypad .grid-pattern rect{stroke:var(--canvas-fg);fill:none}x-polypad .grid-pattern .filled,x-polypad .grid-pattern circle{fill:var(--canvas-fg);stroke:none}x-polypad .image-drop{background:rgba(15,130,242,.1);border:6px dashed #0f82f2;box-sizing:border-box;display:none;height:100%;left:0;pointer-events:none;position:absolute;top:0;width:100%}x-polypad .tile-error{background:#fec680;border-radius:6px;bottom:calc(100% + 10px);box-shadow:0 2px 6px rgba(0,0,0,.1);color:#000;font-size:16px;left:-12px;line-height:1.4;padding:5px 10px;position:relative;position:absolute;text-align:left;top:auto;transform-origin:24px bottom -6px;width:260px}x-polypad .tile-error:after{border-left:8px solid transparent;border-right:8px solid transparent;border-top:8px solid #fec680;content:"";display:block;left:50%;left:24px;margin-left:-8px;position:absolute;top:100%}x-polypad .tile-error button{color:#0f82f2;cursor:pointer}x-polypad .tile-error button:focus,x-polypad .tile-error button:hover{text-decoration:underline}x-polypad.handdrawn .canvas{filter:url(#handdrawn)}x-polypad.handdrawn .geo-paths,x-polypad.handdrawn .strokes{filter:url(#pencil)}x-polypad .bg-icon{bottom:-60px;opacity:.1;pointer-events:none;position:absolute;right:-60px}x-polypad .rotate-label{background-color:#181824;border:1px solid;border-color:var(--canvas-bg);border-radius:6px;color:#fff;font-size:14px;font-weight:600;padding:0 7px 1px;pointer-events:none;position:absolute;top:0}.input-field{background:hsla(0,0%,100%,.1);border:1px solid hsla(0,0%,100%,.16);border-radius:5px;line-height:24px;text-align:center}.input-field:focus,.input-field:hover{background-color:hsla(0,0%,100%,.18)}select.input-field{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-image:url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22rgba(255%2C%20255%2C%20255%2C%200.5)%22%20d%3D%22m19.9%207.5a1.4%201.4%200%200%200%20-2.1%200l-5.8%205.8-5.8-5.8a1.4%201.4%200%200%200%20-2.1%200%201.5%201.5%200%200%200%200%202.1l6.8%206.9a1.6%201.6%200%200%200%202.2%200l6.8-6.9a1.4%201.4%200%200%200%200-2.1z%22%2F%3E%3C%2Fsvg%3E");background-position:top 6px right 5px;background-repeat:no-repeat;background-size:16px 16px;cursor:pointer;padding:0 24px 0 8px;text-align:left;width:auto}select.input-field option{color:initial}input.toggle[type=checkbox]{-webkit-appearance:none;-moz-appearance:none;appearance:none;height:0;position:absolute;width:0}input.toggle+.control{background:hsla(0,0%,100%,.3);border-radius:12px;content:"";cursor:pointer;display:block;height:10px;padding:1px 0;transition:background .2s;width:32px}input.toggle+.control:after{background-color:#9d9ba2;border-radius:12px;content:"";display:block;height:18px;margin:-4px -1px;transition:transform .2s;width:18px}input.toggle:checked+.control{background:#0f82f2}input.toggle:checked+.control:after{background:#ebebec;transform:translateX(16px)}input.toggle:indeterminate+.control:after{background:#c4c3c7;transform:translateX(8px)}.is-tabbing input.toggle:focus+.control{outline:auto}x-factris{background:#083781;border-radius:0 0 12px 12px;color:#fff;display:block;font-family:Comfortaa,sans-serif;line-height:1.15;padding:10px;-webkit-user-select:none;-moz-user-select:none;user-select:none;z-index:1}x-factris .factris-body{background:#0b4bb1;border-radius:8px;box-shadow:0 -4px 0 #06275b;height:500px;margin-top:4px;overflow:hidden;position:relative;width:340px}x-factris .factris-panel-left,x-factris .factris-panel-right,x-factris .factris-panel-top{background:#083781;position:absolute}x-factris .factris-panel-top{border-radius:12px 12px 0 0;bottom:100%;left:50%;margin-left:-90px;padding-top:10px;text-align:center;width:180px}x-factris .factris-panel-top .corner.left{bottom:-1px;left:-12px}x-factris .factris-panel-top .corner.right{bottom:-1px;right:-12px}x-factris .factris-panel-left{border-radius:12px 0 0 12px;left:-120px;padding:10px 0 10px 10px;text-align:right;top:0;width:110px}x-factris .factris-panel-left .corner{bottom:-16px;right:-1px}x-factris .factris-panel-right{border-radius:0 12px 12px 0;padding:10px 10px 10px 0;right:-100px;text-align:center;top:0;width:90px}x-factris .factris-panel-right .corner{bottom:-16px;left:-1px}x-factris,x-factris .factris-panel-left,x-factris .factris-panel-right{box-shadow:0 4px 0 #041e47}x-factris .corner{position:absolute}x-factris .corner path{fill:#083781}x-factris .corner path.dark{fill:#041e47}x-factris .play{fill:#fff;border:10px solid #fff;border-radius:100%;box-shadow:0 4px 0 #06275b,inset 0 4px 0 #06275b;cursor:pointer;display:block;left:50%;margin-left:-50px;position:absolute;top:50%}x-factris .play svg{display:block}x-factris .logo{filter:drop-shadow(0 4px 0 #06275b);height:60px;left:50%;margin:-100px 0 0 -100px;position:absolute;top:50%;width:200px}x-factris .overlay{font-size:48px;font-weight:700;left:0;position:absolute;text-align:center;text-shadow:0 2px 0 #06275b;top:71px;width:100%;z-index:10}x-factris .logo,x-factris .overlay,x-factris .play{opacity:0;pointer-events:none;transform:scale(.5);transition:opacity .2s linear,transform .4s cubic-bezier(.33,1.9,.52,.7)}x-factris .logo.show,x-factris .overlay.show,x-factris .play.show{opacity:1;pointer-events:all;transform:none}x-factris button{background:#cd0e66;border:none;border-radius:4px;box-shadow:0 4px 0 #6e0736;cursor:pointer;transition:transform .08s,box-shadow .08s,background .08s}x-factris button x-icon{fill:#fff}x-factris button .icon{fill:#fff;margin:0 auto}x-factris button:focus,x-factris button:hover{background:#f01e7f}x-factris button.active,x-factris button:active{background:#cd0e66;box-shadow:none;transform:translateY(4px)}x-factris .factris-keys{display:flex;justify-content:center;margin-bottom:4px;margin-top:10px}x-factris .factris-keys>button{width:50px}x-factris .factris-keys>button x-icon{margin-top:6px}x-factris .keys-center{display:flex;flex-direction:column;margin:0 14px;width:100px}x-factris .keys-center button{width:100px}x-factris .keys-center button:first-child{height:42px;margin-bottom:14px}x-factris .keys-center button:first-child x-icon{margin-bottom:-4px}x-factris .keys-center button:last-child x-icon{margin:-5px 0 -7px}x-factris .keys-play{display:flex;margin-bottom:12px}x-factris .keys-play x-icon{margin-top:5px}x-factris .keys-play button{height:48px;width:50px}x-factris .keys-play button:first-child{margin-right:10px}x-factris .discharge{border-radius:100%;height:74px;margin:8px 0 4px;width:74px}x-factris .discharge-count{display:inline-block;margin:8px 0 4px}x-factris .discharge-count circle{fill:none;stroke:#fff;stroke-width:10px;stroke-dasharray:201px;transform:rotate(-90deg);transition:stroke-dashoffset .2s}x-factris .discharge-count text{fill:#fff;text-anchor:middle;font-family:inherit}x-factris .discharge-count text.large{font-size:22px;font-weight:700}x-factris .discharge-count text.small{font-size:9px}x-factris .text-small{font-size:14px;white-space:nowrap}x-factris .text-large{font-size:28px;font-weight:700;white-space:nowrap}x-factris .text-large.margin{margin-top:8px}x-factris .text-large.narrow{letter-spacing:-.07em}x-factris hr{background:hsla(0,0%,100%,.2);height:2px;margin:8px 0 10px}x-factris .highscore-panel{text-align:left}x-factris .highscore-title{font-size:16px;margin-bottom:8px}x-factris .highscore-panel table{font-size:12px;line-height:1.3;opacity:.8;width:100%}x-factris .highscore-panel table td:nth-child(2){text-align:right}x-factris .highscore-panel table a:hover{opacity:1;text-decoration:underline}x-factris .highscore{height:100%;left:0;overflow:auto;position:absolute;top:0;width:100%}x-factris .highscore .text-large{margin:40px;text-align:center}x-factris .highscore x-icon{fill:#fff;margin-bottom:-6px}x-factris .highscore table{margin:0 40px;width:calc(100% - 80px)}x-factris .highscore table td{border-bottom:1px solid hsla(0,0%,100%,.5);padding:6px 0 5px}x-factris .highscore table td:last-child{text-align:right}x-factris .highscore table tr:last-child td{border:none}x-factris .factris-board{height:500px;width:340px}x-factris .grid{opacity:.6}x-factris .grid .faint-grid{opacity:.5}x-factris .grid line{stroke:#fff;stroke-linecap:round}x-factris .grid line.thick{stroke-width:2}x-factris .tiles rect{fill:#22ab24;stroke:#6fc871;stroke-width:1;stroke-linejoin:round;transition:fill .2s}x-factris .tiles rect.fixed{fill:#fd8c00;stroke:#feb459}x-factris .tiles rect.removing{fill:#ffe7ca;stroke:#ffe7ca;opacity:0}x-factris .tiles rect.error{fill:#cd0e66;stroke:#df629c}x-factris .tiles.animated rect{transition:fill .2s,stroke .2s,transform .3s,opacity .2s;transition-delay:0s,0s,.7s,.6s}x-factris .scores text{text-anchor:middle;fill:#cd0e66;stroke:#fff;stroke-width:3px;stroke-linejoin:round;font-size:20px;font-weight:700;opacity:0;paint-order:stroke;transform:scale(.5);transition:opacity .2s linear,transform .4s cubic-bezier(.33,1.9,.52,.7)}.is-safari x-factris .scores text{stroke:none}x-factris .scores .visible text{opacity:1;transform:none}x-factris .highscore-btn{display:none}@media (max-height:740px),(max-width:590px){x-factris{display:flex;flex-direction:column;height:100%;padding:0;white-space:nowrap}x-factris,x-factris .factris-panel-left,x-factris .factris-panel-right,x-factris .factris-panel-top{border-radius:0;box-shadow:none}x-factris .corner,x-factris .highscore-panel,x-factris hr{display:none!important}x-factris .factris-body{flex:1 1;margin:4px 10px 0;width:auto}x-factris .factris-board{height:100%;margin:0 auto;width:100%}x-factris .factris-panel-top{background:none;bottom:auto;top:128px;z-index:2}x-factris .factris-panel-top.hide{display:none}x-factris .factris-panel-left,x-factris .factris-panel-right{display:flex;padding:10px;position:static;width:auto}x-factris .factris-panel-left>:first-child,x-factris .factris-panel-right>:first-child{flex-grow:1}x-factris .factris-panel-left{border-bottom:2px solid hsla(0,0%,100%,.2);border-radius:0}x-factris .keys-play button{height:38px;width:40px}x-factris .keys-play button x-icon{margin-top:3px}x-factris .keys-play button x-icon,x-factris .keys-play button x-icon svg{height:32px!important;width:32px!important}x-factris .factris-panel-left .panel-item{width:100px}x-factris .highscore-btn{display:block;margin-left:10px}x-factris .factris-panel-right{border-radius:0;text-align:left}x-factris .factris-panel-right .text-large{display:inline-block;margin-right:8px}x-factris .factris-panel-right .text-large:after{content:","}x-factris .factris-panel-right .text-large:last-child:after{content:none}x-factris .factris-keys{margin-bottom:14px}html.webview x-factris .factris-keys{margin-bottom:calc(14px + env(safe-area-inset-bottom))}x-factris .discharge{height:39px;margin:-1px 0 0 6px;width:40px}x-factris .discharge x-icon{margin-top:3px}x-factris .discharge x-icon,x-factris .discharge x-icon svg{height:28px!important;width:28px!important}x-factris .discharge-count{height:40px;margin:-1px 0 -1px 6px;width:40px}x-factris .discharge-count text.large{font-size:32px;transform:translateY(11px)}x-factris .discharge-count .small{display:none}x-factris .text-large{font-size:24px}x-factris .text-small{font-size:12px}x-factris .keys-play,x-factris .text-large.margin{margin:0}}marker#axis-arrow{fill:#3a3645}html[theme=dark] marker#axis-arrow{fill:#fff}x-coordinate-sketch,x-coordinate-system,x-geopad{display:block;position:relative}x-coordinate-sketch svg.canvas,x-coordinate-system svg.canvas,x-geopad svg.canvas{display:block;height:100%!important;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:100%}x-coordinate-sketch .grid,x-coordinate-system .grid,x-geopad .grid{opacity:.1}html[theme=dark] x-coordinate-sketch .grid,html[theme=dark] x-coordinate-system .grid,html[theme=dark] x-geopad .grid{opacity:.25}x-coordinate-sketch .grid line,x-coordinate-system .grid line,x-geopad .grid line{stroke:#000;stroke-width:2px}html[theme=dark] x-coordinate-sketch .grid line,html[theme=dark] x-coordinate-system .grid line,html[theme=dark] x-geopad .grid line{stroke:#fff}x-coordinate-sketch .axes line,x-coordinate-system .axes line,x-geopad .axes line{stroke:#3a3645;stroke-width:2px}html[theme=dark] x-coordinate-sketch .axes line,html[theme=dark] x-coordinate-system .axes line,html[theme=dark] x-geopad .axes line{stroke:#fff}x-coordinate-sketch .axes,x-coordinate-sketch .grid,x-coordinate-system .axes,x-coordinate-system .grid,x-geopad .axes,x-geopad .grid{stroke-linecap:round;transition:opacity .2s}x-coordinate-sketch .axes line:not(.tick),x-coordinate-system .axes line:not(.tick),x-geopad .axes line:not(.tick){marker-end:url(#axis-arrow)}x-coordinate-sketch .labels text,x-coordinate-system .labels text,x-geopad .labels text{fill:#3a3645;stroke-width:4px;stroke-linejoin:round;stroke:#fff;font-size:14px;paint-order:stroke}.is-safari x-coordinate-sketch .labels text,.is-safari x-coordinate-system .labels text,.is-safari x-geopad .labels text{stroke:none}html[theme=dark] x-coordinate-sketch .labels text,html[theme=dark] x-coordinate-system .labels text,html[theme=dark] x-geopad .labels text{stroke:#000}x-coordinate-sketch x-gesture,x-coordinate-system x-gesture,x-geopad x-gesture{left:0;position:absolute;top:0}@keyframes pulse{0%{opacity:.6;transform:none}to{opacity:0;transform:scale(3)}}x-coordinate-sketch,x-coordinate-system{color:#cd0e66;margin:2em auto;touch-action:pan-y}x-coordinate-sketch svg,x-coordinate-system svg{stroke-linecap:round;stroke-linejoin:round}x-coordinate-sketch .plot path,x-coordinate-system .plot path{fill:none;stroke:currentColor;stroke-width:3px}x-coordinate-sketch .plot circle,x-coordinate-system .plot circle{fill:currentColor}x-coordinate-sketch .crosshair,x-coordinate-system .crosshair{display:none}x-coordinate-sketch .crosshair circle,x-coordinate-system .crosshair circle{fill:#fff;stroke:currentColor;stroke-width:3px}html[theme=dark] x-coordinate-sketch .crosshair circle,html[theme=dark] x-coordinate-system .crosshair circle{fill:#22212e}x-coordinate-sketch .crosshair path,x-coordinate-system .crosshair path{fill:none;stroke:#3a3645;stroke-width:2px}html[theme=dark] x-coordinate-sketch .crosshair path,html[theme=dark] x-coordinate-system .crosshair path{stroke:#fff}x-coordinate-sketch .crosshair text,x-coordinate-system .crosshair text{fill:currentColor;stroke-width:6px;stroke-linejoin:round;stroke:#fff;font-size:14px;paint-order:stroke}.is-safari x-coordinate-sketch .crosshair text,.is-safari x-coordinate-system .crosshair text{stroke:none}html[theme=dark] x-coordinate-sketch .crosshair text,html[theme=dark] x-coordinate-system .crosshair text{stroke:#000}x-coordinate-sketch g.blue,x-coordinate-sketch.blue,x-coordinate-system g.blue,x-coordinate-system.blue{color:#0f82f2}x-coordinate-sketch g.green,x-coordinate-sketch.green,x-coordinate-system g.green,x-coordinate-system.green{color:#22ab24}x-coordinate-sketch g.yellow,x-coordinate-sketch.yellow,x-coordinate-system g.yellow,x-coordinate-system.yellow{color:#fd8c00}x-coordinate-sketch{cursor:crosshair}x-coordinate-sketch .plot path{stroke-width:8px;opacity:.8}x-geopad{background:#f5f5f6;border-radius:4px;color:inherit;margin:0 auto}html[theme=dark] x-geopad{background:#2d2c38;color:#b2b0b9}x-geopad svg.canvas{position:relative;touch-action:none}x-geopad>canvas,x-geopad>img{height:100%;left:0;max-width:none;position:absolute;top:0;transition:opacity .2s;width:100%}x-geopad .labels text{stroke-width:4px;stroke-linejoin:round;stroke:#f5f5f6;paint-order:stroke}.is-safari x-geopad .labels text{stroke:none}html[theme=dark] x-geopad .labels text{stroke:#2d2c38}x-geopad .labels text.white{stroke:none}.theorem x-geopad{background:transparent}.theorem x-geopad .labels text:not(.white){stroke-width:4px;stroke-linejoin:round;stroke:#f3c3d9;paint-order:stroke}.is-safari .theorem x-geopad .labels text:not(.white){stroke:none}html[theme=dark] .theorem x-geopad .labels text:not(.white){stroke:#000}.tab x-geopad{background:rgba(0,0,0,.03)}.tab x-geopad[grid],x-geopad.no-background,x-geopad[grid]{background:none}.tab x-geopad[grid] .labels text:not(.white),x-geopad.no-background .labels text:not(.white),x-geopad[grid] .labels text:not(.white){stroke-width:4px;stroke-linejoin:round;stroke:#fff;paint-order:stroke}.is-safari .tab x-geopad[grid] .labels text:not(.white),.is-safari x-geopad.no-background .labels text:not(.white),.is-safari x-geopad[grid] .labels text:not(.white){stroke:none}html[theme=dark] .tab x-geopad[grid] .labels text:not(.white),html[theme=dark] x-geopad.no-background .labels text:not(.white),html[theme=dark] x-geopad[grid] .labels text:not(.white){stroke:#22212e}x-geopad .sketch{fill:rgba(101,96,115,.6);display:none;transform-origin:bottom left}x-geopad>.icon-btn{position:absolute;right:8px;top:8px}x-geopad>x-play-toggle{left:8px;position:absolute;top:8px}x-geopad .tools{display:flex;margin:4px 0 0 4px;opacity:0;position:absolute;transition:opacity .3s;transition-delay:1s}x-geopad:hover .tools{opacity:1;transition-delay:0s}x-geopad .tool{background:#c5c2cc;border-radius:3px;box-shadow:none;cursor:pointer;display:none;height:36px;margin:4px;transition:background .2s;width:36px}x-geopad .tool x-icon{fill:#fff;margin:4px}x-geopad .tool:hover{background:#6a637e}x-geopad .tool.active{background:#3a3645}x-geopad[tools*=angleBisector] [data-tool=angleBisector],x-geopad[tools*=circle] [data-tool=circle],x-geopad[tools*=line] [data-tool=line],x-geopad[tools*=move] [data-tool=move],x-geopad[tools*=perpBisector] [data-tool=perpBisector],x-geopad[tools*=point] [data-tool=point],x-geopad[tools*=rectangle] [data-tool=rectangle]{display:block}x-geopad .paths path{fill:none;stroke:currentColor;stroke-width:3px;stroke-linecap:round;stroke-linejoin:round;transition:stroke .2s,stroke-width .2s,fill .2s,opacity .2s,color .2s}x-geopad .paths path.hover,x-geopad .paths path.selected{stroke-width:4px}x-geopad .paths path.thin{stroke-width:2px}x-geopad .paths path.thick{stroke-width:4px}x-geopad .paths path.fill{stroke-width:0;fill:currentColor}x-geopad .paths path[x^="angle("]{stroke-linecap:butt}x-geopad .points circle{fill:#f5f5f6;stroke:currentColor;stroke-width:3px;r:3.5px;transition:r .2s,stroke-width .2s,fill .2s,opacity .2s,color .2s}html[theme=dark] x-geopad .points circle{fill:#2d2c38}x-geopad .points circle.move{r:8px;stroke:transparent;stroke-width:20px;fill:currentColor;touch-action:none}html[theme=dark] x-geopad .points circle.move{fill:currentColor}x-geopad .points circle.hover,x-geopad .points circle.selected{r:6px}x-geopad .points circle.move.hover,x-geopad .points circle.move.selected{r:12px}x-geopad .points circle.pending{transition:none}.focus x-geopad .paths path.focus:not(.fill){stroke-width:5px}.focus x-geopad .points circle.focus{r:8px;stroke-width:5px}.focus x-geopad .points circle.move.focus{r:12px}x-geopad .labels text{fill:currentColor;transition:opacity .2s,color .2s}x-geopad image{transition:opacity .2s}.focus x-geopad image{opacity:.2}x-geopad .transparent,x-geopad .transparent.light{opacity:0}x-geopad .transparent.focus{opacity:1}x-geopad .light,x-geopad .transparent.focus.light{opacity:.5}x-geopad .labels text,x-geopad .paths path,x-geopad .points circle{color:#656073}html[theme=dark] x-geopad .labels text,html[theme=dark] x-geopad .paths path,html[theme=dark] x-geopad .points circle{color:#b2b0b9}x-geopad .labels text.dark,x-geopad .labels text.move,x-geopad .paths path.dark,x-geopad .paths path.move,x-geopad .points circle.dark,x-geopad .points circle.move{color:#3a3645}html[theme=dark] x-geopad .labels text.dark,html[theme=dark] x-geopad .labels text.move,html[theme=dark] x-geopad .paths path.dark,html[theme=dark] x-geopad .paths path.move,html[theme=dark] x-geopad .points circle.dark,html[theme=dark] x-geopad .points circle.move{color:#fff}html[theme=dark] x-geopad .labels text.red,html[theme=dark] x-geopad .paths path.red,html[theme=dark] x-geopad .points circle.red,x-geopad .labels text.red,x-geopad .paths path.red,x-geopad .points circle.red{color:#cd0e66}html[theme=dark] x-geopad .labels text.blue,html[theme=dark] x-geopad .paths path.blue,html[theme=dark] x-geopad .points circle.blue,x-geopad .labels text.blue,x-geopad .paths path.blue,x-geopad .points circle.blue{color:#0f82f2}html[theme=dark] x-geopad .labels text.green,html[theme=dark] x-geopad .paths path.green,html[theme=dark] x-geopad .points circle.green,x-geopad .labels text.green,x-geopad .paths path.green,x-geopad .points circle.green{color:#22ab24}html[theme=dark] x-geopad .labels text.yellow,html[theme=dark] x-geopad .paths path.yellow,html[theme=dark] x-geopad .points circle.yellow,x-geopad .labels text.yellow,x-geopad .paths path.yellow,x-geopad .points circle.yellow{color:#fd8c00}html[theme=dark] x-geopad .labels text.teal,html[theme=dark] x-geopad .paths path.teal,html[theme=dark] x-geopad .points circle.teal,x-geopad .labels text.teal,x-geopad .paths path.teal,x-geopad .points circle.teal{color:#009ea6}html[theme=dark] x-geopad .labels text.orange,html[theme=dark] x-geopad .paths path.orange,html[theme=dark] x-geopad .points circle.orange,x-geopad .labels text.orange,x-geopad .paths path.orange,x-geopad .points circle.orange{color:#eb4726}html[theme=dark] x-geopad .labels text.purple,html[theme=dark] x-geopad .paths path.purple,html[theme=dark] x-geopad .points circle.purple,x-geopad .labels text.purple,x-geopad .paths path.purple,x-geopad .points circle.purple{color:#6d3bbf}html[theme=dark] x-geopad .labels text.lime,html[theme=dark] x-geopad .paths path.lime,html[theme=dark] x-geopad .points circle.lime,x-geopad .labels text.lime,x-geopad .paths path.lime,x-geopad .points circle.lime{color:#bfc212}html[theme=dark] x-geopad .labels text.white,html[theme=dark] x-geopad .paths path.white,html[theme=dark] x-geopad .points circle.white,x-geopad .labels text.white,x-geopad .paths path.white,x-geopad .points circle.white{color:#fff}x-geopad .pulse{fill:#3a3645;animation:pulse 1.8s ease-out infinite}html[theme=dark] x-geopad .pulse{fill:#fff}x-geopad .halo{fill:rgba(58,54,69,.5)}html[theme=dark] x-geopad .halo{fill:hsla(0,0%,100%,.5)}.focus x-geopad .paths path:not(.focus),.focus x-geopad .points circle:not(.focus){color:#e7e6e9}html[theme=dark] .focus x-geopad .paths path:not(.focus),html[theme=dark] .focus x-geopad .points circle:not(.focus){color:#383644}.focus x-geopad .paths path:not(.focus).dark,.focus x-geopad .paths path:not(.focus).move,.focus x-geopad .points circle:not(.focus).dark,.focus x-geopad .points circle:not(.focus).move{color:#e2e2e4}html[theme=dark] .focus x-geopad .paths path:not(.focus).dark,html[theme=dark] .focus x-geopad .paths path:not(.focus).move,html[theme=dark] .focus x-geopad .points circle:not(.focus).dark,html[theme=dark] .focus x-geopad .points circle:not(.focus).move{color:#575660}.focus x-geopad .paths path:not(.focus).red,.focus x-geopad .points circle:not(.focus).red{color:#f1dee8}html[theme=dark] .focus x-geopad .paths path:not(.focus).red,html[theme=dark] .focus x-geopad .points circle:not(.focus).red{color:#4d2641}.focus x-geopad .paths path:not(.focus).blue,.focus x-geopad .points circle:not(.focus).blue{color:#deeaf6}html[theme=dark] .focus x-geopad .paths path:not(.focus).blue,html[theme=dark] .focus x-geopad .points circle:not(.focus).blue{color:#273d5d}.focus x-geopad .paths path:not(.focus).green,.focus x-geopad .points circle:not(.focus).green{color:#e0eee1}html[theme=dark] .focus x-geopad .paths path:not(.focus).green,html[theme=dark] .focus x-geopad .points circle:not(.focus).green{color:#2b4534}.focus x-geopad .paths path:not(.focus).yellow,.focus x-geopad .points circle:not(.focus).yellow{color:#f6ebdd}html[theme=dark] .focus x-geopad .paths path:not(.focus).yellow,html[theme=dark] .focus x-geopad .points circle:not(.focus).yellow{color:#573f2d}.focus x-geopad .paths path:not(.focus).teal,.focus x-geopad .points circle:not(.focus).teal{color:#ddecee}html[theme=dark] .focus x-geopad .paths path:not(.focus).teal,html[theme=dark] .focus x-geopad .points circle:not(.focus).teal{color:#24434e}.focus x-geopad .paths path:not(.focus).orange,.focus x-geopad .points circle:not(.focus).orange{color:#f4e4e1}html[theme=dark] .focus x-geopad .paths path:not(.focus).orange,html[theme=dark] .focus x-geopad .points circle:not(.focus).orange{color:#533134}.focus x-geopad .paths path:not(.focus).purple,.focus x-geopad .points circle:not(.focus).purple{color:#e7e2f1}html[theme=dark] .focus x-geopad .paths path:not(.focus).purple,html[theme=dark] .focus x-geopad .points circle:not(.focus).purple{color:#3a2f53}.focus x-geopad .paths path:not(.focus).lime,.focus x-geopad .points circle:not(.focus).lime{color:#f0f0df}html[theme=dark] .focus x-geopad .paths path:not(.focus).lime,html[theme=dark] .focus x-geopad .points circle:not(.focus).lime{color:#4a4a30}.focus x-geopad .paths path:not(.focus).white,.focus x-geopad .points circle:not(.focus).white{color:#f6f6f7}html[theme=dark] .focus x-geopad .paths path:not(.focus).white,html[theme=dark] .focus x-geopad .points circle:not(.focus).white{color:#575660}.focus x-geopad .pulse{display:none}.focus x-geopad .labels text:not(.focus){opacity:.2}.focus x-geopad .axes,.focus x-geopad canvas{opacity:.1}.focus x-geopad .grid{opacity:.01}x-parallax{display:block;overflow:hidden;position:relative}x-parallax .image{background-position:50%;background-size:cover;bottom:0;left:0;position:absolute;right:0;will-change:transform}x-parallax .content{height:100%;overflow:hidden;position:relative}.other-students{background:#3a3645;border-radius:6px;color:#fff;margin:1.5em 0;padding:12px 20px 2px}.other-students h4{margin:0 0 12px}.other-students img{opacity:.8}.proof{counter-reset:proof-counter;margin:0 0 2em 2em}@media screen and (max-width:660px){.proof{margin-left:0}}.proof li{list-style:none;margin:0 0 1em 3.8em;min-height:2.4em}.proof li .text-center{margin-top:.5em}.proof li:before{border:3px solid #c5c2cc;border-radius:100%;content:counter(proof-counter);counter-increment:proof-counter;display:block;float:left;font-size:1.4em;line-height:1.7em;margin:-4px 0 0 -2.7em;width:1.7em}.proof li:before,.proof-step{color:#666;font-weight:700;text-align:center}.proof-step{border:2px solid #c5c2cc;border-radius:100%;display:inline-block;line-height:1.2em;margin:-5px 0;width:1.2em} \ No newline at end of file diff --git a/frontend/assets/course.js b/frontend/assets/course.js index dc5c950a..062fd113 100644 --- a/frontend/assets/course.js +++ b/frontend/assets/course.js @@ -1,9 +1,9 @@ /* (c) Mathigon, generated by Mathigon Studio */ -"use strict";(()=>{var Vh=Object.defineProperty,Fd=Object.defineProperties,Hd=Object.getOwnPropertyDescriptor,jd=Object.getOwnPropertyDescriptors;var Ah=Object.getOwnPropertySymbols;var Ud=Object.prototype.hasOwnProperty,Wd=Object.prototype.propertyIsEnumerable;var To=(s,e)=>{if(e=Symbol[s])return e;throw Error("Symbol."+s+" is not defined")};var kh=(s,e,t)=>e in s?Vh(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,dt=(s,e)=>{for(var t in e||(e={}))Ud.call(e,t)&&kh(s,t,e[t]);if(Ah)for(var t of Ah(e))Wd.call(e,t)&&kh(s,t,e[t]);return s},ut=(s,e)=>Fd(s,jd(e));var T=(s,e,t,i)=>{for(var n=i>1?void 0:i?Hd(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Vh(e,t,n),n};var D=(s,e,t)=>new Promise((i,n)=>{var r=h=>{try{a(t.next(h))}catch(l){n(l)}},o=h=>{try{a(t.throw(h))}catch(l){n(l)}},a=h=>h.done?i(h.value):Promise.resolve(h.value).then(r,o);a((t=t.apply(s,e)).next())}),Kd=function(s,e){this[0]=s,this[1]=e};var As=s=>{var e=s[To("asyncIterator")],t=!1,i,n={};return e==null?(e=s[To("iterator")](),i=r=>n[r]=o=>e[r](o)):(e=e.call(s),i=r=>n[r]=o=>{if(t){if(t=!1,r==="throw")throw o;return o}return t=!0,{done:!1,value:new Kd(new Promise(a=>{var h=e[r](o);if(!(h instanceof Object))throw TypeError("Object expected");a(h)}),1)}}),n[To("iterator")]=()=>n,i("next"),"throw"in e?i("throw"):n.throw=r=>{throw r},"return"in e&&i("return"),n};var So=(s,e)=>{if(e=Symbol[s])return e;throw Error("Symbol."+s+" is not defined")},Xd=function(s,e){this[0]=s,this[1]=e},Yd=s=>{var e=s[So("asyncIterator")],t=!1,i,n={};return e==null?(e=s[So("iterator")](),i=r=>n[r]=o=>e[r](o)):(e=e.call(s),i=r=>n[r]=o=>{if(t){if(t=!1,r==="throw")throw o;return o}return t=!0,{done:!1,value:new Xd(new Promise(a=>{var h=e[r](o);if(!(h instanceof Object))throw TypeError("Object expected");a(h)}),1)}}),n[So("iterator")]=()=>n,i("next"),"throw"in e?i("throw"):n.throw=r=>{throw r},"return"in e&&i("return"),n};function We(s=10){return Math.random().toString(36).substr(2,s)}function _(s,...e){return e.includes(s)}var Zd=(s,e)=>s.concat(e);function Mo(s,e,t=Zd){for(let i of Object.keys(e))i in s&&Array.isArray(s[i])&&Array.isArray(e[i])?s[i]=t(s[i],e[i]):i in s&&s[i]instanceof Object&&e[i]instanceof Object?Mo(s[i],e[i]):s[i]=e[i]}function Zt(s,e=0){return e?+setTimeout(s,e):(s(),0)}function vi(s){return new Promise(e=>setTimeout(e,s))}function Ke(){let s=()=>{},e=()=>{},t=new Promise((i,n)=>{s=i,e=n});return t.catch(i=>i),{promise:t,resolve:s,reject:e}}var Ih=class extends Error{constructor(s){super("[Cache Error]"),this.data=s}};function Le(s){let e=new Map;return function(...t){let i=t.join("--");if(!e.has(i))try{e.set(i,s(...t))}catch(r){e.set(i,new Ih(r))}let n=e.get(i);if(n instanceof Ih)throw n.data;return n}}function ge(s,e=0,t=!1){let i=!1,n=!1;return(...r)=>{i?n=!0:(t?n=!0:s(...r),i=!0,setTimeout(()=>{n&&s(...r),i=n=!1},e))}}function Qd(s){return function(e,t){if(!e||Array.isArray(this)||s.includes(e))return t}}function ve(s,e,t){if(!s)return e;try{return JSON.parse(s,t?Qd(t):void 0)||e}catch(i){return e}}function ne(s,e){return new Array(e).fill(s)}function Co(s,e,t){let i=[];for(let n=0;n=0)for(let n=0;ns;n-=t)i.push(n);else if(s<=e)for(let n=s;n<=e;n+=t)i.push(n);else for(let n=s;n>=e;n-=t)i.push(n);return i}function O(s,e=0){return s[s.length-1-e]}function N(s){return s.reduce((e,t)=>e+t,0)}function wi(s,e,t=!1){return s.slice(0).sort((i,n)=>{let r=e(i),o=e(n);return ro?t?-1:1:0})}function os(s){let e=0;return()=>s[e++%s.length]}function Wt(s){return s.filter((e,t)=>s.indexOf(e)===t)}function we(s){return s.reduce((e,t)=>e.concat(Array.isArray(t)?we(t):t),[])}function as(s){let e=0;return s.map(t=>e+=t)}function Ao(s,e){let t=[];for(let i=0;ie.concat(t),[])}var Nh=class{constructor(s){let e=s.length,t=s.map(i=>({val:i}));for(let[i,n]of t.entries())n.next=t[(i+1)%e],n.prev=t[(i-1+e)%e];this.root=t[0]}*traverse(){let s=this.root;for(;s;)if(yield s,s=s.next,s===this.root)return}get array(){return Array.from(this.traverse())}delete(s){if(s===this.root){if(s.next===s)return this.root=void 0;this.root=s.next}s.prev.next=s.next,s.next.prev=s.prev}},ko=(s=>(s[s.first=0]="first",s[s.firstGreater=1]="firstGreater",s))(ko||{});function Vo(s,e,t){let i=0,n=s.length-1,r=-1;for(;i<=n;){let o=Math.floor((i+n)/2),a=s[o].val;ae?(t===1&&(r=o),n=o-1):t===0?(r=o,n=o-1):t===1&&(i=o+1)}return r}function Io(s,e,t){let i=Vo(s,t,0);if(i<0)return-1;for(;s[i].val===t;){if(s[i].item===e)return i;i+=1}return-1}function K(s,e=/\s+/){return s?s.trim().split(e):[]}function en(s){return s.toLowerCase().replace(/^-/,"").replace(/-(.)/g,(e,t)=>t.toUpperCase())}function Jd(s,e,t=!1){let i=Co(0,s.length+1,e.length+1);for(let n=0;n<=s.length;n++)i[n][0]=n;for(let n=0;n<=e.length;n++)i[0][n]=n;for(let n=1;n<=s.length;n++)for(let r=1;r<=e.length;r++)i[n][r]=Math.min(i[n-1][r-1]+(s.charAt(n-1)===e.charAt(r-1)?0:1),i[n-1][r]+1,i[n][r-1]+1);return t?Math.min(...i[s.length]):i[s.length][e.length]}function Gh(s,e){let t=s.length/2,i=e.map(r=>({w:r,d:Jd(s,r)})).filter(({d:r})=>rr.d)[0];return n?n.w:void 0}var Oe=class{constructor(){this.events=new Map}on(s,e){for(let t of K(s))this.events.has(t)||this.events.set(t,[]),this.events.get(t).push(e)}one(s,e){let t=i=>{this.off(s,t),e(i)};this.on(s,t)}off(s,e){for(let t of K(s))this.events.has(t)&&this.events.set(t,this.events.get(t).filter(i=>i!==e))}trigger(s,e){for(let t of K(s))if(this.events.has(t))for(let i of this.events.get(t))i(e)}},tu=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,eu=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i,su=/rgba?\(([0-9.]+), ?([0-9.]+), ?([0-9.]+)(, ?([0-9.]+))?\)/,iu=["#22ab24","#009ea6","#0f82f2","#6d3bbf","#cd0e66","#eb4726","#fd8c00"];function Lh(s){return s.length===1?`0${s}`:s}function Oh(s,e){if(e<=0)return xt.from(s[0]);if(e>=1)return xt.from(O(s));let t=Math.floor(e*(s.length-1)),i=e*(s.length-1)-t;return xt.mix(s[t+1],s[t],i)}function Eo(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*(2/3-t)*6:s}var xt=class Ct{constructor(e,t,i,n=1){this.r=e,this.g=t,this.b=i,this.a=n}get hex(){let e=[this.r,this.g,this.b].map(i=>Lh(Math.round(i).toString(16))),t=this.a>=1?"":Lh(Math.round(this.a*255).toString(16));return`#${e.join("")}${t}`}get rgb(){return`rgba(${[this.r,this.g,this.b].map(t=>Math.round(t)).join(",")},${this.a})`}get brightness(){return(this.r*299+this.g*587+this.g*114)/1e3}get hsl(){let e=this.r/255,t=this.g/255,i=this.b/255,n=Math.max(e,t,i),r=Math.min(e,t,i),o=(r+n)/2,a=n-r;if(n===r)return[0,0,Math.round(o*100)];let h=e===n?(t-i)/a:t===n?2+(i-e)/a:4+(e-t)/a;h=Math.min(h*60,360),h<0&&(h+=360);let l=o<=.5?a/(n+r):a/(2-n-r);return[Math.round(h),Math.round(l*100),Math.round(o*100)]}get chroma(){return Math.max(this.r,this.g,this.b)-Math.min(this.r,this.g,this.b)}toString(){return this.rgb}copy(){return new Ct(this.r,this.g,this.b,this.a)}static from(e){return typeof e!="string"?e:e.startsWith("#")?Ct.fromHex(e):Ct.fromRgb(e)}static fromRgb(e){let t=e.match(su);if(!t)return new Ct(0,0,0);let i=t[4]?+t[5]||0:1;return new Ct(+t[1],+t[2],+t[3],i)}static fromHex(e){e=e.replace(tu,(i,n,r,o)=>n+n+r+r+o+o);let t=eu.exec(e);return t?new Ct(parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16),t[4]?parseInt(t[4],16)/255:1):new Ct(0,0,0)}static fromHsl(e,t,i){if(e/=360,t/=100,i/=100,t===0){let l=Math.round(i*255);return new Ct(l,l,l)}let n=i<.5?i*(1+t):i+t-i*t,r=2*i-n,o=Eo(r,n,e+1/3),a=Eo(r,n,e),h=Eo(r,n,e-1/3);return new Ct(Math.round(o*255),Math.round(a*255),Math.round(h*255))}static rainbow(e){return z(t=>Oh(iu,t/(e-1)),e)}static gradient(e,t){return z(i=>Oh(e,i/(t-1)),t)}static shades(e,t,i=.5){let n=Ct.mix("#fff",e,i),r=Ct.mix("#000",e,i);return Ct.gradient([n,e,r],t)}static mix(e,t,i=.5){return e=Ct.from(e),t=Ct.from(t),new Ct(i*e.r+(1-i)*t.r,i*e.g+(1-i)*t.g,i*e.b+(1-i)*t.b,i*e.a+(1-i)*t.a)}static mixMany(e,t){t||(t=e.map(()=>1));let i=N(t),n=e.map(v=>v.hsl),r=n.map(v=>v[0]),o=r.map(v=>v<180?v+360:v),a=t.map((v,w)=>v*Math.sqrt(e[w].chroma)),h=N(a),l=N(r.map((v,w)=>v*a[w]))/h,c=N(o.map((v,w)=>v*a[w]))/h,u=N(r.map((v,w)=>Math.abs(v-l)*a[w])),d=N(o.map((v,w)=>Math.abs(v-c)*a[w])),g=u<=d?l:c%360,y=N(n.map((v,w)=>t[w]*v[1]))/i,f=N(n.map((v,w)=>t[w]*v[2]))/i;return Ct.fromHsl(g,y,f)}};function ks(s){return s[Symbol.iterator]().next().value}function*sn(...s){for(let e of s)yield*As(Yd(e))}function Bt(s,e){for(let t of s)if(e(t))return!0;return!1}function*zh(s,e){let t=0;for(let i of s)e(i,t)&&(yield i),t+=1}function*Bh(s,e){for(let t of s)for(let i of e(t))yield i}function*yi(s,e){for(let t of s)for(let i of e)yield[t,i]}function*Lo(s){let e=s.length;for(let t=0;t{for(var t in e)nu(s,t,{get:e[t],enumerable:!0})},an=1e-6;function x(s,e,t=an){return isNaN(s)||isNaN(e)?!1:Math.abs(s-e)t&&([e,t]=[t,e]),s>e+i&&s0?1:-1}var _h=/(\d+)(\d{3})/,ou=["","k","m","b","t","q"];function au(s){let[e,t]=s.split(".");for(;_h.test(e);)e=e.replace(_h,"$1,$2");return e+(t?`.${t}`:"")}function hu(s,e=6){if(!e)return`${s}`;let t=`${Math.abs(Math.floor(s))}`.length,i=t+(s<0?1:0);if(i<=e)return`${Rt(s,e-i)}`;let n=Math.floor(Math.log10(Math.abs(s))/3),r=ou[n],o=e-(t%3||3)-(r?1:0)-(s<0?1:0);return Rt(s/Math.pow(10,3*n),o)+r}function Ot(s,e=0,t=!0){let i=hu(s,e).replace("-","\u2013");return t?au(i):i}var lu=/^-?0,[0-9]+$/,cu=/^-?([0-9]+(,[0-9]{3})*)?\.?[0-9]*$/,pu=/^-?[0-9]+(\.[0-9]{3})*,?[0-9]*$/;function Uh(s){return s=s.replace(/^–/,"-").trim(),!s||s.match(/[^0-9.,-]/)?NaN:lu.test(s)?parseFloat(s.replace(/,/,".")):cu.test(s)?parseFloat(s.replace(/,/g,"")):pu.test(s)?parseFloat(s.replace(/\./g,"").replace(/,/,".")):NaN}var Oo=["","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],qh=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"],du=[""," thousand"," million"," billion"," trillion"," quadrillion"," quintillion"," sextillion"];function uu(s){let[e,t,i]=s.split(""),n=e==="0"?"":` ${Oo[+e]} hundred`;return t+i==="00"?n:+t<2?`${n} ${Oo[+(t+i)]}`:i==="0"?`${n} ${qh[+t]}`:`${n} ${qh[+t]}-${Oo[+i]}`}function No(s){if(s===0)return"zero";let e=Math.round(Math.abs(s)).toString(),t=Math.ceil(e.length/3),i=e.padStart(3*t,"0"),n="";for(let r=0;rn.length===e):i}function Kh(s){if(s.length===1)return[[],s];let e=s.pop(),t=Kh(s),i=[];for(let n of t)i.push(n,[...n,e]);return i}var nn=(s,e)=>{let t=s<0?"\u2013":"";return Math.abs(s)===1&&e?t+e:t+Math.abs(s)+(e||"")},Xh=class ft{constructor(e=0,t=0){this.re=e,this.im=t}get modulus(){return Math.sqrt(this.re*this.re+this.im*this.im)}get argument(){return Math.atan2(this.im,this.re)}get conjugate(){return new ft(this.re,-this.im)}root(e,t=0){let i=Math.pow(this.modulus,1/e),n=(this.argument+t*2*Math.PI)/e;return new ft(i*Math.cos(n),i*Math.sin(n))}toString(e=2){let t=Rt(this.re,e),i=Rt(this.im,e);return i===0?nn(t):t===0?nn(i,"i"):[nn(t),i<0?"\u2013":"+",nn(Math.abs(i),"i")].join(" ")}add(e){return ft.sum(this,e)}subtract(e){return ft.difference(this,e)}multiply(e){return ft.product(this,e)}divide(e){return ft.quotient(this,e)}static sum(e,t){return typeof e=="number"&&(e=new ft(e,0)),typeof t=="number"&&(t=new ft(t,0)),new ft(e.re+t.re,e.im+t.im)}static difference(e,t){return typeof e=="number"&&(e=new ft(e,0)),typeof t=="number"&&(t=new ft(t,0)),new ft(e.re-t.re,e.im-t.im)}static product(e,t){typeof e=="number"&&(e=new ft(e,0)),typeof t=="number"&&(t=new ft(t,0));let i=e.re*t.re-e.im*t.im,n=e.im*t.re+e.re*t.im;return new ft(i,n)}static quotient(e,t){if(typeof e=="number"&&(e=new ft(e,0)),typeof t=="number"&&(t=new ft(t,0)),Math.abs(t.re)1)return be(e,be(...t));let i=Math.abs(e),n=Math.abs(t[0]);for(;n;)[i,n]=[n,i%n];return i}function Is(...s){let[e,...t]=s;return t.length>1?Is(e,Is(...t)):Math.abs(e*t[0])/be(e,t[0])}function zo(s){if(s%1!==0||s<2)return!1;if(s%2===0)return s===2;if(s%3===0)return s===3;let e=Math.sqrt(s);for(let t=5;t<=e;t+=6)if(s%t===0||s%(t+2)===0)return!1;return!0}function Ro(s){if(s===1)return[];if(zo(s))return[s];let e=Math.sqrt(s);for(let t=2;t<=e;++t)if(s%t===0)return Ro(t).concat(Ro(s/t));return[]}function Yh(s){return Wt(Ro(s))}var fu=/^([0-9\-.]*)([%πkmbtq]?)(\/([0-9\-.]+))?([%π]?)$/,Fh=s=>s>=Number.MAX_SAFE_INTEGER,Zh=class X{constructor(e,t,i){this.unit=i,this.num=t!==void 0&&t<0?-e:e,t!==void 0&&Math.abs(t)!==1&&e!==0&&(this.den=Math.abs(t))}valueOf(){return this.value}toMixed(){if(!this.den||this.unit)return this.toString();let e=Math.abs(this.num)%this.den,t=Math.abs(Math.trunc(this.value));return t?`${this.sign<0?"\u2013":""}${t} ${e}/${this.den}`:this.toString()}toExpr(e,t=4){let i=this.value;if(Math.abs(i)>=Number.MAX_VALUE)return"\u221E";if((Fh(this.num)||this.den&&Fh(this.den))&&(e="decimal"),e==="scientific"||Math.abs(i)>=Number.MAX_SAFE_INTEGER){let[n,r]=this.value.toExponential(t-1).split("e");if(Math.abs(+r)>=t){let o=r.startsWith("-"),a=`${o?"(":""}${o?r:r.slice(1)}${o?")":""}`;return`${n.replace(/\.?0+$/,"")} \xD7 10^${a}${this.unit||""}`}}if(!this.unit&&!this.den||e==="decimal"||e==="scientific"){let n=Ot(this.value,t);return n.match(/^[\d.]+$/g)?n:`"${n}"`}else return e==="mixed"?this.toMixed():this.toString()}toString(e=4){let t=!this.den&&!this.unit,i=Ot(this.num,this.den?0:e,t),n=this.unit||"",r=this.den?`/${Ot(this.den,0,t)}`:"";return i==="0"&&(n=""),n==="\u03C0"&&!this.den&&(i==="1"||i==="\u20131")&&(i=i.replace("1","")),`${i}${r}${n}`}toMathML(){let e=`${this.num}`;return this.den!==void 0&&(e=`${e}${this.den}`),this.unit&&(e+=this.unit==="\u03C0"?"\u03C0":"%"),e}get value(){let e=this.unit==="%"?.01:this.unit==="\u03C0"?Math.PI:1;return this.num*e/(this.den||1)}get sign(){return Math.sign(this.num)}get simplified(){if(!this.den)return this;let e=be(Math.abs(this.num),this.den);return new X(this.num/e,this.den/e,this.unit)}get inverse(){return this.den?new X(1/this.num,void 0,this.unit):new X(this.den,this.num)}get negative(){return new X(-this.num,this.den,this.unit)}get fraction(){if(!(this.unit||!ye(this.num)))return[this.num,this.den||1]}static fromString(e){e=e.toLowerCase().replace(/[\s,"]/g,"").replace("\u2013","-").replace("pi","\u03C0");let t=e.match(fu);if(!t)return;let i=t[2]||t[5]||void 0,n=t[1]?+t[1]:void 0,r=t[4]?+t[4]:void 0;if(i==="\u03C0"&&(!t[1]||t[1]==="-")&&(n=t[1]?-1:1),n===void 0||isNaN(n))return;let o=i?"kmbtq".indexOf(i):-1;if(o>=0&&(n*=1e3**(o+1),i=void 0),r===void 0)return new X(n,void 0,i);if(!(isNaN(r)||x(r,0)))return!ye(n)||!ye(r)?new X(n/r,void 0,i):new X(n,r,i)}static fractionFromDecimal(e,t=1e3,i=1e-12){let n=[1,0],r=[0,1],o=Math.abs(e),a=o;for(;Math.abs(n[0]/r[0]-o)>i;){let h=Math.floor(a);if(n=[h*n[0]+n[1],n[0]],r=[h*r[0]+r[1],r[0]],r[0]>t)return new X(e);a=1/(a-h)}return x(n[0]/r[0],o,i)?new X(ru(e)*n[0],r[0]===1?void 0:r[0]):new X(e)}clamp(e,t){let i=this.value;return e!==void 0&&it?new X(t):this}add(e){return X.sum(this,e)}subtract(e){return X.difference(this,e)}multiply(e){return X.product(this,e)}divide(e){return X.quotient(this,e)}static sum(e,t){if(typeof t=="number"&&(t=new X(t)),e.num===0)return t;if(e.unit!==t.unit)return new X(e.value+t.value);if(!e.den&&!t.den)return new X(e.num+t.num,void 0,e.unit);if(e.den||([e,t]=[t,e]),!ye(t.num))return new X(e.value+t.value,void 0,e.unit);let i=Is(e.den,t.den||1),n=i/e.den,r=i/(t.den||1);return new X(e.num*n+t.num*r,i,e.unit)}static difference(e,t){return typeof t=="number"&&(t=new X(t)),X.sum(e,t.negative)}static product(e,t){if(typeof t=="number"&&(t=new X(t)),!e.unit&&!e.den&&ye(e.num))return new X(e.num*t.num,t.den,t.unit);if(!t.unit&&!t.den&&ye(t.num))return new X(e.num*t.num,e.den,e.unit);if(e.unit==="\u03C0"||t.unit==="\u03C0"||!ye(e.num)||!ye(t.num))return new X(e.value*t.value);let i=(e.unit==="%"?100:1)*(t.unit==="%"?100:1);return new X(e.num*t.num,(e.den||1)*(t.den||1)*i)}static quotient(e,t){return typeof t=="number"&&(t=new X(t)),X.product(e,t.inverse)}},At={};Do(At,{determinant:()=>yu,fill:()=>Qh,identity:()=>Jh,inverse:()=>sl,product:()=>on,reflection:()=>vu,rotation:()=>mu,scalarProduct:()=>wu,shear:()=>gu,sum:()=>tl,transpose:()=>el});function Qh(s,e,t){return Co(s,e,t)}function Jh(s=2){let e=Qh(0,s,s);for(let t=0;t1?tl(...t):t[0];if(e.length!==i.length||e[0].length!==i[0].length)throw new Error("Matrix sizes don\u2019t match");let n=[];for(let r=0;rt.map(i=>i*e))}function on(...s){let[e,...t]=s,i=t.length>1?on(...t):t[0];if(e[0].length!==i.length)throw new Error("Matrix sizes don\u2019t match.");let n=[];for(let r=0;rs[n][r],e,e);for(let n=0;nnl,binomial:()=>Tu,cauchy:()=>ku,chiCDF:()=>Iu,exponential:()=>Cu,find:()=>$u,geometric:()=>Au,integer:()=>xu,integrate:()=>ol,normal:()=>Mu,normalPDF:()=>Vu,poisson:()=>Su,shuffle:()=>bu,smart:()=>Pu,uniform:()=>Eu,weighted:()=>il});function bu(s){s=s.slice(0);for(let e=s.length-1;e>0;--e){let t=Math.floor(Math.random()*(e+1));[s[e],s[t]]=[s[t],s[e]]}return s}function xu(s,e){let t=e===void 0?0:s,i=e===void 0?s:e-s+1;return t+Math.floor(i*Math.random())}function il(s){let e=Math.random()*N(s),t=0;return s.findIndex(i=>(t+=i)>=e)}function $u(s){return s[Math.floor(s.length*Math.random())]}var rn=new Map;function Pu(s,e){e||(e=We()),rn.has(e)||rn.set(e,ne(1,s));let t=rn.get(e),i=il(t.map(n=>n*n));return t[i]-=1,t[i]<=0&&rn.set(e,t.map(n=>n+1)),i}function nl(s=.5){return Math.random()e;++i)t*=Math.random();return i-1}function Eu(s=0,e=1){return s+(e-s)*Math.random()}function Mu(s=0,e=1){let t=Math.random(),i=Math.random();return Math.sqrt(-2*Math.log(t))*Math.cos(2*Math.PI*i)*Math.sqrt(e)+s}function Cu(s=1){return s<=0?0:-Math.log(Math.random())/s}function Au(s=.5){if(!(s<=0||s>1))return Math.floor(Math.log(Math.random())/Math.log(1-s))}function ku(){let s,e,t;do e=2*Math.random()-1,t=2*Math.random()-1,s=e*e+t*t;while(s>=1);return e/t}function Vu(s,e=1,t=0){return Math.exp(-((s-e)**2)/(2*t))/Math.sqrt(2*Math.PI*t)}var Hh=7,jh=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23];function rl(s){if(s<.5)return Math.PI/(Math.sin(Math.PI*s)*rl(1-s));s-=1;let e=jh[0];for(let i=1;iMath.pow(i,(e-2)/2)*Math.exp(-i/2),0,s)/Math.pow(2,e/2)/rl(e/2)}var Bo={};Do(Bo,{bestPolynomial:()=>Gu,coefficient:()=>hl,exponential:()=>Ru,linear:()=>Ou,logarithmic:()=>Du,polynomial:()=>al,power:()=>Nu});function Lu(s,e){let t=1,i=s[0];for(let n=1;nre(e+1).map(l=>Math.pow(h[0],l))),i=el(t),n=s.map(h=>[h[1]]),r=on(i,t),o=sl(r);return on(o,i,n).map(h=>h[0])}function hl(s,e){let i=s.reduce((o,a)=>o+a[1],0)/s.length,n=s.reduce((o,a)=>o+(a[1]-i)**2,0);return 1-s.reduce((o,a)=>o+(a[1]-e(a[0]))**2,0)/n}function Gu(s,e=.85,t=8){if(!(s.length<=1))for(let i=1;iLu(n,a);if(hl(s,r)>=e)return{order:i,coefficients:n,fn:r}}}function Ls(s){return s.length?N(s)/s.length:0}var Pt=2*Math.PI;function xi(s,e){let t=Math.atan2(s.y-(e?e.y:0),s.x-(e?e.x:0));return gt(t,Pt)}function ll(s,e){let t,i=1/0,n=-1;for(let[r,o]of e.entries()){let a=o.project(s),h=p.distance(s,a);hn.x))/e.length,i=N(e.map(n=>n.y))/e.length;return new tt(t,i)}static dot(e,t){return e.x*t.x+e.y*t.y}static sum(e,t){return new tt(e.x+t.x,e.y+t.y)}static difference(e,t){return new tt(e.x-t.x,e.y-t.y)}static distance(e,t){return Math.sqrt(Qt(e.x-t.x)+Qt(e.y-t.y))}static manhattan(e,t){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)}static interpolate(e,t,i=.5){return new tt(ht(e.x,t.x,i),ht(e.y,t.y,i))}static interpolateList(e,t=.5){let i=e.length-1,n=Math.floor(B(t,0,1)*i);return tt.interpolate(e[n],e[n+1],i*t-n)}static fromPolar(e,t=1){return new tt(t*Math.cos(e),t*Math.sin(e))}static random(e){let t=_t.uniform(e.xMin,e.xMax),i=_t.uniform(e.yMin,e.yMax);return new tt(t,i)}static equals(e,t,i){return x(e.x,t.x,i)&&x(e.y,t.y,i)}static colinear(e,t,i,n){let r=e.x-t.x,o=e.y-t.y,a=t.x-i.x,h=t.y-i.y;return x(r*h,a*o,n)}transform(e){let t=e[0][0]*this.x+e[0][1]*this.y+e[0][2],i=e[1][0]*this.x+e[1][1]*this.y+e[1][2];return new tt(t,i)}rotate(e,t=R){if(x(e,0))return this;let i=this.x-t.x,n=this.y-t.y,r=Math.cos(e),o=Math.sin(e),a=i*r-n*o+t.x,h=i*o+n*r+t.y;return new tt(a,h)}reflect(e){let t=e.p2.x-e.p1.x,i=e.p2.y-e.p1.y,n=this.x-e.p1.x,r=this.y-e.p1.y,o=(t*r-i*n)/(t*t+i*i),a=this.x+2*o*i,h=this.y-2*o*t;return new tt(a,h)}scale(e,t=e){return new tt(this.x*e,this.y*t)}shift(e,t=e){return new tt(this.x+e,this.y+t)}translate(e){return this.shift(e.x,e.y)}equals(e,t){return tt.equals(this,e,t)}toString(){return`point(${this.x},${this.y})`}},R=new p(0,0);function Tt(s){return["polygon","polyline","rectangle","triangle"].includes(s.type)}function Ye(s){return["polygon","triangle"].includes(s.type)}function pn(s){return s.type==="polyline"}function jo(s){return s.type==="rectangle"}function st(s){return["line","ray","segment"].includes(s.type)}function Uo(s){return s.type==="line"}function dn(s){return s.type==="ray"}function xe(s){return s.type==="segment"}function U(s){return s.type==="circle"}function Ze(s){return s.type==="ellipse"}function Dt(s){return s.type==="arc"}function $e(s){return s.type==="sector"}function qt(s){return s.type==="angle"}function nt(s){return s.type==="point"}var vt=class bi{constructor(e,t){this.p1=e,this.p2=t,this.type="line"}get length(){return p.distance(this.p1,this.p2)}get lengthSquared(){return(this.p1.x-this.p2.x)**2+(this.p1.y-this.p2.y)**2}get midpoint(){return p.average(this.p1,this.p2)}get slope(){return(this.p2.y-this.p1.y)/(this.p2.x-this.p1.x)}get intercept(){return this.p1.y-this.slope*this.p1.x}get angle(){return xi(this.p2,this.p1)}get unitVector(){return this.p2.subtract(this.p1).unitVector}get perpendicularVector(){return new p(this.p2.y-this.p1.y,this.p1.x-this.p2.x).unitVector}parallel(e){return new bi(e,e.add(this.p2).subtract(this.p1))}perpendicular(e){let t=this.line.project(e);return p.equals(e,t)?new bi(t,t.add(this.perpendicularVector.scale(this.length/2))):new bi(t,e)}get perpendicularBisector(){return this.perpendicular(this.midpoint)}distanceSquared(e){let t=this.project(e);return(e.x-t.x)**2+(e.y-t.y)**2}get line(){return this.type==="line"?this:new bi(this.p1,this.p2)}get ray(){return dn(this)?this:new Wo(this.p1,this.p2)}get segment(){return xe(this)?this:new Y(this.p1,this.p2)}offset(e){let t=p.difference(this.p2,this.p1),i=p.difference(e,this.p1);return p.dot(t,i)/this.lengthSquared}project(e){return this.at(this.offset(e))}side(e,t){let i=p.difference(this.p2,this.p1),n=p.difference(e,this.p1),r=n.x*i.y-n.y*i.x;return x(r,0,t)?0:Math.sign(r)}contains(e,t){return this.side(e,t)===0}at(e){return p.interpolate(this.p1,this.p2,e)}transform(e){return new this.constructor(this.p1.transform(e),this.p2.transform(e))}rotate(e,t=R){return x(e,0)?this:new this.constructor(this.p1.rotate(e,t),this.p2.rotate(e,t))}reflect(e){return new this.constructor(this.p1.reflect(e),this.p2.reflect(e))}scale(e,t=e){return new this.constructor(this.p1.scale(e,t),this.p2.scale(e,t))}shift(e,t=e){return new this.constructor(this.p1.shift(e,t),this.p2.shift(e,t))}translate(e){return this.shift(e.x,e.y)}equals(e,t){return this.contains(e.p1,t)&&this.contains(e.p2,t)}toString(){return`line(${this.p1},${this.p2})`}},Wo=class extends vt{constructor(){super(...arguments),this.type="ray"}equals(s,e){return s.type!=="ray"||!this.p1.equals(s.p1,e)?!1:this.p2.equals(s.p2,e)?!0:s.contains(this.p2,e)||this.contains(s.p2,e)}contains(s,e){if(!super.contains(s,e))return!1;let t=this.offset(s);return x(t,0,e)||t>0}toString(){return`ray(${this.p1},${this.p2})`}},Y=class ml extends vt{constructor(){super(...arguments),this.type="segment"}contains(e,t){return super.contains(e,t)?this.p1.equals(e,t)||this.p2.equals(e,t)?!0:x(this.p1.x,this.p2.x,t)?it(e.y,this.p1.y,this.p2.y):it(e.x,this.p1.x,this.p2.x):!1}project(e){let t=p.difference(this.p2,this.p1),i=p.difference(e,this.p1),n=B(p.dot(t,i)/this.lengthSquared,0,1);return this.p1.add(t.scale(n))}contract(e){return new ml(this.at(e),this.at(1-e))}equals(e,t,i=!1){return e.type!=="segment"?!1:this.p1.equals(e.p1,t)&&this.p2.equals(e.p2,t)||!i&&this.p1.equals(e.p2,t)&&this.p2.equals(e.p1,t)}toString(){return`segment(${this.p1},${this.p2})`}},wt=class Os{constructor(e=R,t=1){this.c=e,this.r=t,this.type="circle"}get circumference(){return Pt*this.r}get area(){return Math.PI*this.r**2}get arc(){let e=this.c.shift(this.r,0);return new Ft(this.c,e,Pt)}tangentAt(e){let t=this.at(e),i=this.c.rotate(Math.PI/2,t);return new vt(t,i)}collision(e){let t=this.c.xe.p.x+e.w?e.p.x+e.w:this.c.x,i=this.c.ye.p.y+e.h?e.p.y+e.h:this.c.y;return p.distance(this.c,new p(t,i))<=this.r}project(e){let t=e.subtract(this.c).unitVector.scale(this.r);return p.sum(this.c,t)}at(e){let t=Pt*e;return this.c.shift(this.r*Math.cos(t),this.r*Math.sin(t))}offset(e){return xi(e,this.c)/Pt}contains(e){return p.distance(e,this.c)<=this.r}transform(e){let t=Math.abs(e[0][0])+Math.abs(e[1][1]);return new Os(this.c.transform(e),this.r*t/2)}rotate(e,t=R){return x(e,0)?this:new Os(this.c.rotate(e,t),this.r)}reflect(e){return new Os(this.c.reflect(e),this.r)}scale(e,t=e){return new Os(this.c.scale(e,t),this.r*(e+t)/2)}shift(e,t=e){return new Os(this.c.shift(e,t),this.r)}translate(e){return this.shift(e.x,e.y)}equals(e,t){return x(this.r,e.r,t)&&this.c.equals(e.c,t)}toString(){return`circle(${this.c},${this.r})`}},Ft=class{constructor(s,e,t){this.c=s,this.start=e,this.angle=t,this.type="arc"}get circle(){return new wt(this.c,this.radius)}get radius(){return p.distance(this.c,this.start)}get end(){return this.start.rotate(this.angle,this.c)}get startAngle(){return xi(this.start,this.c)}contract(s){return new this.constructor(this.c,this.at(s/2),this.angle*(1-s))}get minor(){return this.angle<=Math.PI?this:new this.constructor(this.c,this.end,Pt-this.angle)}get major(){return this.angle>=Math.PI?this:new this.constructor(this.c,this.end,Pt-this.angle)}get center(){return this.at(.5)}project(s){let e=this.startAngle,t=e+this.angle,i=xi(s,this.c);return t>Pt&&i=-ls}function cl(s,e,t){let i=s.y-e.y,n=t.x-e.x,r=s.x-e.x,o=t.y-e.y,a=r*n+i*o;if(a(i.prev=e,i.next=t,e.next=i,t&&(t.prev=i),i)}}static node(s){let e=s;return e.remove=()=>{e.prev&&(e.prev.next=e.next),e.next&&(e.next.prev=e.prev),e.prev=e.next=void 0},e}};function Ho(s,e,t){let i={above:t.myFill.above,below:t.myFill.below};return{start:s,end:e,myFill:i}}function Bu(s,e,t,i,n,r){let o=gl(e,n);return o!==0?o:p.equals(t,r)?0:s!==i?s?1:-1:Fo(t,i?n:r,i?r:n)?1:-1}function Xo(s,e,t){s.insertBefore(e,i=>Bu(!!e.isStart,e.pt,t,!!i.isStart,i.pt,i.other.pt)<0)}function _u(s,e,t){let i=Ds.node({isStart:!0,pt:e.start,seg:e,primary:t});return Xo(s,i,e.end),i}function qu(s,e,t,i){let n=Ds.node({pt:t.end,seg:t,primary:i,other:e});e.other=n,Xo(s,n,e.pt)}function ln(s,e,t){let i=_u(s,e,t);return qu(s,i,e,t),i}function Fu(s,e,t){e.other.remove(),e.seg.end=t,e.other.pt=t,Xo(s,e.other,e.pt)}function de(s,e,t){let i=Ho(t,e.seg.end,e.seg);return Fu(s,e,t),ln(s,i,!!e.primary)}function Hu(s,e){let t=s.seg.start,i=s.seg.end,n=e.seg.start,r=e.seg.end;return p.colinear(t,n,r)?p.colinear(i,n,r)||Fo(i,n,r)?1:-1:Fo(t,n,r)?1:-1}function _o(s,e,t){let i=e.seg,n=t.seg,r=i.start,o=i.end,a=n.start,h=n.end,l=zu(r,o,a,h);if(l===!1){if(!p.colinear(r,o,a)||p.equals(r,h)||p.equals(o,a))return!1;let c=p.equals(r,a),u=p.equals(o,h);if(c&&u)return t;let d=!c&&cl(r,a,h),g=!u&&cl(o,a,h);if(c)return g?de(s,t,o):de(s,e,h),t;d&&(u||(g?de(s,t,o):de(s,e,h)),de(s,t,r))}else l.alongA===0&&(l.alongB===-1?de(s,e,a):l.alongB===0?de(s,e,l.pt):l.alongB===1&&de(s,e,h)),l.alongB===0&&(l.alongA===-1?de(s,t,r):l.alongA===0?de(s,t,l.pt):l.alongA===1&&de(s,t,o));return!1}function vl(s,e){var t,i;let n=new Ds,r=[];for(;s.head;){let a=s.head;if(a.isStart){let h=function(){if(c){let g=_o(s,a,c);if(g)return g}return u?_o(s,a,u):!1};var o=h;let l=n.findTransition(g=>Hu(a,g.ev)>0),c=(t=l.before)==null?void 0:t.ev,u=(i=l.after)==null?void 0:i.ev,d=h();if(d&&(e?(!a.seg.myFill.below||a.seg.myFill.above!==a.seg.myFill.below)&&(d.seg.myFill.above=!d.seg.myFill.above):d.seg.otherFill=a.seg.myFill,a.other.remove(),a.remove()),s.head!==a)continue;if(e){let g=a.seg.myFill.below?a.seg.myFill.above!==a.seg.myFill.below:!0;a.seg.myFill.below=u?u.seg.myFill.above:!1,a.seg.myFill.above=g?!a.seg.myFill.below:a.seg.myFill.below}else if(a.seg.otherFill===void 0){let g=u?a.primary===u.primary?u.seg.otherFill.above:u.seg.myFill.above:!1;a.seg.otherFill={above:g,below:g}}a.other.status=l.insert(Ds.node({ev:a}))}else{let h=a.status;if(h===void 0)throw new Error("[Euclid.js] Zero-length segment detected!");if(n.exists(h.prev)&&n.exists(h.next)&&_o(s,h.prev.ev,h.next.ev),h.remove(),!a.primary){let l=a.seg.myFill;a.seg.myFill=a.seg.otherFill,a.seg.otherFill=l}r.push(a.seg)}s.head.remove()}return r}function ju(s){let e=[],t=[];return s.forEach(i=>{let n=i.start,r=i.end;if(p.equals(n,r))return;let o={index:0,matchesHead:!1,matchesPt1:!1},a={index:0,matchesHead:!1,matchesPt1:!1},h=o;function l(f,v,w){h.index=f,h.matchesHead=v,h.matchesPt1=w;let $=h===o;return h=$?a:void 0,!$}for(let f=0;fYo(s,e,Wu),Zu=(s,e)=>Yo(s,e,Ku),Qu=(s,e)=>Yo(s,e,Xu);function Ju(s,e){return x(s.p1.x,s.p2.x)?it(e.y,s.p1.y,s.p2.y):it(e.x,s.p1.x,s.p2.x)}function tf(s,e){return x(s.p1.x,s.p2.x)?(e.y-s.p1.y)/(s.p2.y-s.p1.y)>0:(e.x-s.p1.x)/(s.p2.x-s.p1.x)>0}function ef(s,e){return it(s.offset(e),0,1)}function sf(s,e){let t=s.p1.x-s.p2.x,i=s.p1.y-s.p2.y,n=e.p1.x-e.p2.x,r=e.p1.y-e.p2.y,o=t*r-i*n;if(x(o,0))return[];let a=s.p1.x*s.p2.y-s.p1.y*s.p2.x,h=e.p1.x*e.p2.y-e.p1.y*e.p2.x,l=a*n-t*h,c=a*r-i*h;return[new p(l/o,c/o)]}function nf(s,e){let t=p.distance(s.c,e.c);if(t>s.r+e.r)return[];if(tJu(r,o))),dn(r)&&(t=t.filter(o=>tf(r,o))),Dt(r)&&(t=t.filter(o=>ef(r,o)));return t}function Q(...s){if(s.length<2)return[];if(s.length>2)return we(Wh(s,2).map(i=>Q(...i)));let[e,t]=s;if(qt(e)&&(e=e.shape(!0)),qt(t)&&(t=t.shape(!0)),Tt(t)&&([e,t]=[t,e]),Tt(e)){let i=st(t)?e.points.filter(n=>t.contains(n)):[];for(let n of e.edges)i.push(...Q(n,t));return i}return rf(e,t)}var V=class Xe{constructor(...e){this.type="polygon",this.points=e}get circumference(){if(this.points.length<=1)return 0;let e=p.distance(this.points[0],O(this.points));for(let t=1;tp.distance(i,e));return Math.max(...t)}get oriented(){if(this.signedArea>=0)return this;let e=[...this.points].reverse();return new this.constructor(...e)}cut(e){let t=this.radius/e.length*10,i=e.at(-t),n=e.at(t),r=e.perpendicularVector.scale(e.length*t),o=[i,n,n.add(r),i.add(r)],a=Zu([this.points],[o]),h=Qu([this.points],[o]);return[...a,...h].map(l=>new Xe(...l))}static collision(e,t){if(e.points.some(i=>t.contains(i))||t.points.some(i=>e.contains(i)))return!0;for(let i of e.edges)for(let n of t.edges)if(Q(i,n)[0])return!0;return!1}static union(...e){let[t,...i]=e;if(!i.length)return[t];let n=[t.points],r=i.length>1?Xe.union(...i).map(o=>o.points):[e[1].points];return Yu(n,r).map(o=>new Xe(...o))}static regular(e,t=1){let i=Pt/e,n=Math.PI/2-i/2,r=z(o=>p.fromPolar(n+i*o,t),e);return new Xe(...r)}static interpolate(e,t,i=.5){let n=e.points.map((r,o)=>p.interpolate(r,t.points[o],i));return new Xe(...n)}static convexHull(...e){if(e.length<=3)return new Xe(...e);let t=e.sort((o,a)=>o.x!==a.x?o.x-a.x:o.y-a.y),i=t.slice(0).reverse(),n=[],r=[];for(let[o,a]of[[t,n],[i,r]]){for(let h of o){for(;a.length>=2;){let l=a[a.length-1],c=a[a.length-2];if((l.x-c.x)*(h.y-c.y)>=(h.x-c.x)*(l.y-c.y))a.pop();else break}a.push(h)}a.pop()}return new Xe(...n.concat(r))}contains(e){let t=!1;for(let i of this.edges){if(i.p1.equals(e)||i.contains(e))return!1;if(i.p1.y>e.y==i.p2.y>e.y)continue;let n=(i.p2.x-i.p1.x)/(i.p2.y-i.p1.y);e.xt)return n.at((t-i)/r);i+=r}return this.points[0]}offset(e){let t=this.edges,i=ll(e,this.edges)||[this.points[0],0],n=0;for(let r=0;rt.transform(e)))}rotate(e,t=R){if(x(e,0))return this;let i=this.points.map(n=>n.rotate(e,t));return new this.constructor(...i)}reflect(e){let t=this.points.map(i=>i.reflect(e));return new this.constructor(...t)}scale(e,t=e){let i=this.points.map(n=>n.scale(e,t));return new this.constructor(...i)}shift(e,t=e){let i=this.points.map(n=>n.shift(e,t));return new this.constructor(...i)}translate(e){return this.shift(e.x,e.y)}equals(e,t,i){let n=this.points.length;if(n!==e.points.length)return!1;let r=i?this:this.oriented,o=i?e:e.oriented;for(let a=0;ah.equals(o.points[(l+a)%n],t)))return!0;return!1}toString(){return`polygon(${this.points.join(",")})`}},te=class extends V{constructor(){super(...arguments),this.type="polyline"}get circumference(){return this.length}get length(){let s=0;for(let e=1;eNumber.MAX_SAFE_INTEGER))return new wt(o,a)}get incircle(){let s=this.edges,e=s.map(c=>c.length),t=e[0]+e[1]+e[2],[i,n,r]=this.points,o=e[1]*i.x+e[2]*n.x+e[0]*r.x,a=e[1]*i.y+e[2]*n.y+e[0]*r.y,h=new p(o/t,a/t),l=h.distanceFromLine(s[0]);return isNaN(l)?void 0:new wt(h,l)}get orthocenter(){let[s,e,t]=this.points,i=new vt(s,e).perpendicular(t),n=new vt(s,t).perpendicular(e);return Q(i,n)[0]}},of=180/Math.PI,af=Math.PI/180;function Kt(s){return s*of}function J(s){return s*af}var kt=class ue{constructor(e,t,i){this.a=e,this.b=t,this.c=i,this.type="angle"}static fromDegrees(e){return ue.fromRadians(e*(Math.PI/180))}static fromRadians(e){let t=new p(1,0),i=t.rotate(e);return new ue(t,R,i)}static equals(e,t,i=Math.PI/360){return x(e.rad,t.rad,i)}get rad(){let e=Math.atan2(this.a.y-this.b.y,this.a.x-this.b.x),i=Math.atan2(this.c.y-this.b.y,this.c.x-this.b.x)-e;return i<0&&(i+=Pt),i}get deg(){return this.rad*180/Math.PI}get isRight(){return x(this.rad,Math.PI/2,Math.PI/360)}get bisector(){if(this.b.equals(this.a)||this.b.equals(this.c))return;let e=Math.atan2(this.a.y-this.b.y,this.a.x-this.b.x),t=Math.atan2(this.c.y-this.b.y,this.c.x-this.b.x),i=(e+t)/2;e>t&&(i+=Math.PI);let n=Math.cos(i)+this.b.x,r=Math.sin(i)+this.b.y;return new vt(this.b,new p(n,r))}get sup(){return this.rado.x?i:o.x,n=no.y?r:o.y;return new Rs(new p(t,n),i-t,r-n)}get center(){return new p(this.p.x+this.w/2,this.p.y+this.h/2)}get centroid(){return this.center}get circumference(){return 2*Math.abs(this.w)+2*Math.abs(this.h)}get area(){return Math.abs(this.signedArea)}get signedArea(){return this.w*this.h}get edges(){return this.polygon.edges}get points(){return this.polygon.points}get polygon(){let e=new p(this.p.x+this.w,this.p.y),t=new p(this.p.x+this.w,this.p.y+this.h),i=new p(this.p.x,this.p.y+this.h);return new V(this.p,e,t,i)}get bounds(){return new lt(this.p.x,this.p.x+this.w,this.p.y,this.p.y+this.h)}collision(e){return this.p.xe.p.x&&this.p.ye.p.y}padding(e,t,i,n){return new Rs(this.p.shift(-n,-e),this.w+n+t,this.h+e+i)}get unsigned(){if(this.w>0&&this.h>0)return this;let e=this.p.shift(this.w<0?this.w:0,this.h<0?this.h:0);return new Rs(e,Math.abs(this.w),Math.abs(this.h))}contains(e,t){return it(e.x,this.p.x,this.p.x+this.w,t)&&it(e.y,this.p.y,this.p.y+this.h,t)}project(e){let t;for(let i of this.edges){let n=i.project(e);(!t||p.distance(e,n)0?1:0,r=p.distance(e,s);return[s.x,`${s.y}A${r}`,r,0,n,1,t.x,t.y].join(",")}function Jt(...s){return`M${s.map(e=>`${e.x},${e.y}`).join("L")}`}function qo(s,e){let t=s.perpendicularVector.scale(6),i=s.unitVector.scale(3),n=s.midpoint;switch(e){case"bar":return Jt(n.add(t),n.add(t.inverse));case"bar2":return Jt(n.add(i).add(t),n.add(i).add(t.inverse))+Jt(n.add(i.inverse).add(t),n.add(i.inverse).add(t.inverse));case"arrow":return Jt(n.add(i.inverse).add(t),n.add(i),n.add(i.inverse).add(t.inverse));case"arrow2":return Jt(n.add(i.scale(-2)).add(t),n,n.add(i.scale(-2)).add(t.inverse))+Jt(n.add(t),n.add(i.scale(2)),n.add(t.inverse));default:return""}}function cn(s,e){if(!s||!e)return"";let t=e.perpendicular,i=s.add(e.scale(9)).add(t.scale(9)),n=s.add(e.scale(9)).add(t.scale(-9));return Jt(i,s,n)}function hf(s,e){let t="";return _(e,"start","both")&&(t+=cn(s.p1,s.unitVector)),_(e,"end","both")&&(t+=cn(s.p2,s.unitVector.inverse)),t}function lf(s,e){let t="";if(_(e,"start","both")){let i=new vt(s.c,s.start).perpendicularVector.inverse;t+=cn(s.start,i)}if(_(e,"end","both")){let i=new vt(s.c,s.end).perpendicularVector;t+=cn(s.end,i)}return t}function cf(s,e,t=e,i=e,n=t){let{p:r,w:o,h:a}=s;return`M${r.x} ${r.y+e}a${e} ${e} 0 0 1 ${e} ${-e}h${o-e-t}a${t} ${t} 0 0 1 ${t} ${t}v${a-t-i}a${i} ${i} 0 0 1 ${-i} ${i}h${-o+n+i}a${n} ${n} 0 0 1 ${-n} ${-n}Z`}function Re(s,e={}){if(qt(s)){let t=s.shape(!!e.fill,e.size,e.round);return Re(t,e)}if(xe(s)){if(s.p1.equals(s.p2))return"";let t=Jt(s.p1,s.p2);return e.mark&&(t+=qo(s,e.mark)),e.arrows&&(t+=hf(s,e.arrows)),t}if(dn(s)){if(!e.box)return"";let t=Q(s,e.box)[0];if(!t)return"";let i=Jt(s.p1,t);return e.mark&&(i+=qo(s,e.mark)),i}if(Uo(s)){if(!e.box)return"";let t=Q(s,e.box);if(t.length<2)return"";let i=Jt(t[0],t[1]);return e.mark&&(i+=qo(s,e.mark)),i}if(U(s))return`M${s.c.x-s.r} ${s.c.y}a${s.r},${s.r} 0 1 0 ${2*s.r} 0a${s.r} ${s.r} 0 1 0 ${-2*s.r} 0Z`;if(Ze(s)){let[t,i]=s.majorVertices,n=Kt(s.angle);return`M${t.x} ${t.y}A${s.a} ${s.b} ${n} 0 0 ${i.x} ${i.y}A${s.a} ${s.b} ${n} 0 0 ${t.x} ${t.y}Z`}if(Dt(s)){let t=`M${fl(s.start,s.c,s.end)}`;return e.arrows&&(t+=lf(s,e.arrows)),t}if($e(s))return`M${s.c.x} ${s.c.y} L ${fl(s.start,s.c,s.end)}Z`;if(pn(s))return Jt(...s.points);if(Ye(s))return`${Jt(...s.points)}Z`;if(jo(s)){if(!e.cornerRadius)return`${Jt(...s.polygon.points)}Z`;let t=s.unsigned,i=Math.min(e.cornerRadius,t.w/2,t.h/2);return cf(t,i)}return""}var Qo=(s,e)=>{if(e=Symbol[s])return e;throw Error("Symbol."+s+" is not defined")},ae=(s,e,t)=>new Promise((i,n)=>{var r=h=>{try{a(t.next(h))}catch(l){n(l)}},o=h=>{try{a(t.throw(h))}catch(l){n(l)}},a=h=>h.done?i(h.value):Promise.resolve(h.value).then(r,o);a((t=t.apply(s,e)).next())}),pf=function(s,e){this[0]=s,this[1]=e},df=s=>{var e=s[Qo("asyncIterator")],t=!1,i,n={};return e==null?(e=s[Qo("iterator")](),i=r=>n[r]=o=>e[r](o)):(e=e.call(s),i=r=>n[r]=o=>{if(t){if(t=!1,r==="throw")throw o;return o}return t=!0,{done:!1,value:new pf(new Promise(a=>{var h=e[r](o);if(!(h instanceof Object))throw TypeError("Object expected");a(h)}),1)}}),n[Qo("iterator")]=()=>n,i("next"),"throw"in e?i("throw"):n.throw=r=>{throw r},"return"in e&&i("return"),n},un="_M",Ns=window.navigator.userAgent.toLowerCase(),uf=/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i,wl=/iphone|ipad|ipod/i,ff=/^((?!chrome|android).)*safari/i,yl,mf=class{constructor(){this.isMobile=uf.test(Ns),this.isRetina=(window.devicePixelRatio||1)>1,this.isTouch=!!window.Touch||"ontouchstart"in window,this.isChrome=!!window.chrome,this.isFirefox=Ns.indexOf("firefox")>=0,this.isAndroid=Ns.indexOf("android")>=0,this.isIOS=wl.test(Ns),this.isSafari=wl.test(Ns)||ff.test(Ns),this.loadQueue=[],this.loaded=!1,this.width=window.innerWidth,this.height=window.innerHeight,this.resizeCallbacks=[],this.theme={name:"light",isDark:!1},this.themeChangedCallbacks=[],this.themeOverride="",this.darkQuery=(yl=window.matchMedia)==null?void 0:yl.call(window,"(prefers-color-scheme: dark)");var s,e;window.onload=()=>this.afterLoad(),document.addEventListener("DOMContentLoaded",()=>this.afterLoad());let t=ge(()=>this.applyResize());window.addEventListener("resize",t);try{(s=this.darkQuery)==null||s.addEventListener("change",()=>this.applyThemeChange())}catch(n){(e=this.darkQuery)==null||e.addListener(()=>this.applyThemeChange())}let i=this.getCookie("theme");i&&this.setTheme(i);try{this.localStorage=window.localStorage}catch(n){console.warn("Unable to access Local Storage in this context.")}}afterLoad(){if(!this.loaded){this.loaded=!0;for(let s of this.loadQueue)s();setTimeout(()=>this.resize())}}ready(s){this.loaded?s():this.loadQueue.push(s)}redraw(){document.body.offsetHeight}applyResize(){let s=window.innerWidth,e=window.innerHeight;if(!(this.width===s&&this.height===e)){this.width=s,this.height=e;for(let t of this.resizeCallbacks)t({width:this.width,height:this.height});C.trigger("scroll",{top:C.scrollTop})}}onResize(s){s({width:this.width,height:this.height}),this.resizeCallbacks.push(s)}offResize(s){let e=this.resizeCallbacks.indexOf(s);e>=0&&this.resizeCallbacks.splice(e,1)}resize(){this.applyResize()}applyThemeChange(){let s=this.theme.name,e=s==="dark"||s==="auto"&&this.darkQuery.matches;if(e!==this.theme.isDark){this.theme.isDark=e;for(let t of this.themeChangedCallbacks)t(this.theme);setTimeout(()=>Xt.setAttr("theme",this.themeOverride||(e?"dark":"light")))}}setTheme(s){s!==this.theme.name&&(this.theme.name=s,this.setCookie("theme",s),this.applyThemeChange())}onThemeChange(s){this.themeChangedCallbacks.push(s)}getHash(){return window.location.hash.slice(1)}setHash(s){let e=document.body.scrollTop;window.location.hash=s,document.body.scrollTop=e}setURL(s,e=""){window.history.replaceState({},e,s),e&&(window.document.title=e)}getCookies(){let s=document.cookie.split(";"),e={};for(let t=0,i=s.length;t use")).forEach(function(e){let t=e.getAttribute("xlink:href"),[i,n]=t.split("#");if(!i.length||!n)return;let r=e.parentNode;r.removeChild(e),i in Jo||(Jo[i]=fetch(i).then(a=>a.text())),Jo[i].then(a=>{let h=document.implementation.createHTMLDocument("");h.documentElement.innerHTML=a;let c=h.getElementById(n).cloneNode(!0),u=document.createDocumentFragment();for(;c.childNodes.length;)u.appendChild(c.firstChild);r.appendChild(u)})})}var xf=new Map(Object.entries({" ":"Space",Spacebar:"Space",Del:"Delete",Esc:"Escape",Left:"ArrowLeft",Right:"ArrowRight",Down:"ArrowDown",Up:"ArrowUp"}));function Si(s){return xf.get(s.key)||s.key}function El(s){let e=new Set(["Enter","Space"]),t=!1;document.addEventListener("keyup",i=>{e.has(Si(i))&&(t=!1)}),(s||document).addEventListener("keydown",i=>{if(!t&&e.has(Si(i))){t=!0;let n=b.getActiveInput();n&&n.hasAttr("tabindex")&&n.tagName!=="TEXTAREA"&&(i.preventDefault(),n.trigger("pointerdown",i),n.trigger("pointerstop",i),C.trigger("pointerstop",i),n.trigger("click",i))}})}var bn=!1;setTimeout(()=>bn=!0);var $f="cubic-bezier(0.175, 0.885, 0.32, 1.275)",Pf="cubic-bezier(0.68, -0.275, 0.825, 0.115)",ps={cancel:()=>{},promise:Promise.resolve()};function mt(s,e){if(e===0)return s(1,0,()=>{}),ps;let t=Date.now(),i=Ke(),n=0,r=!0,o=()=>{r=!1,i.reject()};function a(){if(!r)return;(!e||n<=e)&&window.requestAnimationFrame(a);let h=Date.now()-t;s(e?Math.min(1,h/e):h,h-n,o),e&&h>=e&&i.resolve(),n=h}return a(),{cancel:o,promise:i.promise}}function fn(s,e=0,t=0){switch(s){case"quad":return e**2;case"cubic":return e**3;case"quart":return e**4;case"quint":return e**5;case"circ":return 1-Math.sqrt(1-e**2);case"sine":return 1-Math.cos(e*Math.PI/2);case"exp":return e<=0?0:Math.pow(2,10*(e-1));case"back":return t||(t=1.70158),e*e*((t+1)*e-t);case"elastic":return t||(t=.3),-Math.pow(2,10*(e-1))*Math.sin(((e-1)*2/t-.5)*Math.PI);case"swing":return .5-Math.cos(e*Math.PI)/2;case"spring":return 1-Math.cos(e*4.5*Math.PI)*Math.exp(-e*6);case"bounce":return e<1/11?1/64-7.5625*(.5/11-e)*(.5/11-e):e<3/11?1/16-7.5625*(2/11-e)*(2/11-e):e<7/11?1/4-7.5625*(5/11-e)*(5/11-e):1-7.5625*(1-e)*(1-e);default:return e}}function St(s,e=0,t=0){if(e===0)return 0;if(e===1)return 1;let[i,n]=s.split("-");return n==="in"?fn(i,e,t):n==="out"?1-fn(i,1-e,t):e<=.5?fn(i,2*e,t)/2:1-fn(i,2*(1-e),t)/2}function Ht(s,e,t=400,i=0,n="ease-in-out"){if(!bn)return Object.keys(e).forEach(f=>{let v=e[f];s.css(f,Array.isArray(v)?v[1]:v)}),ps;n==="bounce-in"&&(n=$f),n==="bounce-out"&&(n=Pf);let r="";b.isSafari&&(r=s._el.style.transition,s.css("transition","none"),b.redraw());let o=s._data.animation;o&&o.cancel();let a={},h={},l=Ke(),c=window.getComputedStyle(s._el);Object.keys(e).forEach(f=>{let v=e[f],w=en(f);h[w]=Array.isArray(v)?v[0]:c.getPropertyValue(f),a[w]=Array.isArray(v)?v[1]:v,i&&s.css(f,h[w])});let u=a.height;if(a.height==="auto"){let f=s.children.filter(v=>v.css("position")!=="absolute");a.height=`${N(f.map(v=>v.outerHeight))}px`}let d,g=!1;Zt(()=>{g||(d=s._el.animate([h,a],{duration:t,easing:n,fill:"forwards"}),d.onfinish=()=>{s._el&&Object.keys(e).forEach(f=>s.css(f,f==="height"?u:a[f])),b.isSafari&&s.css("transition",r),l.resolve(),d.cancel(),s._data.animation=void 0})},i);let y={cancel(){g||(g=!0,s._el&&Object.keys(e).forEach(f=>s.css(f,s.css(f))),d&&d.cancel(),s._data.animation=void 0)},promise:l.promise};return setTimeout(()=>s._data.animation=y),y}var Tf=/matrix\([0-9.\-\s]+,[0-9.\-\s]+,[0-9.\-\s]+,[0-9.\-\s]+,([0-9.\-\s]+),([0-9.\-\s]+)\)/;function Sf(s,e="fade",t=500,i=0){if(s.show(),!bn)return ps;let n=s._data.animation?1:+s.css("opacity")||1;if(e==="fade")return Ht(s,{opacity:[0,n]},t,i);if(e==="pop"){let r=s.transform.replace(/scale\([0-9.]*\)/,"").replace(Tf,"translate($1px,$2px)");return Ht(s,{opacity:[0,n]},t,i),Ht(s,{transform:[`${r} scale(0.5)`,`${r} scale(1)`]},t,i,"bounce-in")}else{if(e==="descend")return Ht(s,{opacity:[0,1],transform:["translateY(-50%)","none"]},t,i);if(e.startsWith("draw")){let r=s.strokeLength;s.css("stroke-dasharray",`${r}px`),s.css("opacity")||s.css("opacity",1);let o=e==="draw-reverse"?`${2*r}px`:0,a={"stroke-dashoffset":[`${r}px`,o]},h=Ht(s,a,t,i,"linear");return h.promise.then(()=>s.css("stroke-dasharray","")),h}else if(e.startsWith("slide")){let r={opacity:[0,n],transform:["translateY(50px)","none"]};return e.includes("down")&&(r.transform[0]="translateY(-50px)"),e.includes("right")&&(r.transform[0]="translateX(-50px)"),e.includes("left")&&(r.transform[0]="translateX(50px)"),Ht(s,r,t,i)}else if(e.startsWith("reveal")){let r={opacity:[0,n],height:[0,"auto"]};return e.includes("left")&&(r.transform=["translateX(-50%)","none"]),e.includes("right")&&(r.transform=["translateX(50%)","none"]),Ht(s,r,t,i)}}return ps}function Ef(s,e="fade",t=400,i=0,n=!1){if(!s._el)return ps;if(!bn)return s.hide(),ps;if(s.css("display")==="none")return ps;let r;if(e==="fade")r=Ht(s,{opacity:[1,0]},t,i);else if(e==="pop"){let o=s.transform.replace(/scale\([0-9.]*\)/,"");Ht(s,{opacity:[1,0]},t,i),r=Ht(s,{transform:[`${o} scale(1)`,`${o} scale(0.5)`]},t,i,"bounce-out")}else if(e==="ascend")r=Ht(s,{opacity:[1,0],transform:["none","translateY(-50%)"]},t,i);else if(e.startsWith("draw")){let o=s.strokeLength;s.css("stroke-dasharray",o);let h={"stroke-dashoffset":[e==="draw-reverse"?`${2*o}px`:0,`${o}px`]};r=Ht(s,h,t,i,"linear")}else if(e.startsWith("slide")){let o={opacity:0,transform:"translateY(50px)"};e.includes("up")&&(o.transform="translateY(-50px)"),r=Ht(s,o,t,i)}else if(e.startsWith("reveal")){let o={opacity:0,height:0};e.includes("left")&&(o.transform="translateX(-50%)"),e.includes("right")&&(o.transform="translateX(50%)"),r=Ht(s,o,t,i)}return r.promise.then(()=>n?s.remove():s.hide()),r}var Ml={"===":(s,e)=>s===e,"!==":(s,e)=>s!==e,"||":(s,e)=>s||e,"&&":(s,e)=>s&&e,"==":(s,e)=>s==e,"!=":(s,e)=>s!=e,"<=":(s,e)=>s<=e,">=":(s,e)=>s>=e,"**":(s,e)=>s**e,"<":(s,e)=>s":(s,e)=>s>e,"+":(s,e)=>s+e,"-":(s,e)=>s-e,"*":(s,e)=>s*e,"/":(s,e)=>s/e,"%":(s,e)=>s%e},Cl={"-":s=>-s,"+":s=>+s,"!":s=>!s},bl={"||":1,"&&":2,"==":3,"!=":3,"===":3,"!==":3,"<":4,">":4,"<=":4,">=":4,"+":5,"-":5,"*":6,"/":6,"%":6,"**":7},xl={true:!0,false:!1,undefined:void 0},Mf=/\s/,Cf=/[0-9]/,ta=/[a-zA-Zα-ωΑ-Ω$_]/,Af=/[0-9a-zA-Zα-ωΑ-Ω$_]/;function kf(s){let e=s.length,t=0;function i(f){throw new Error(`${f} at character ${t} of "${s}"`)}function n(){for(;Mf.test(s[t]);)t+=1}function r(){var f;let v=((f=s.slice(t).match(/^\d*(\.\d+)?([eE][+-]?\d+)?/))==null?void 0:f[0])||"";t+=v.length;let w=s[t];return w&&(ta.test(w)||w===".")&&i(`Unexpected character (${v+w})`),{type:5,value:parseFloat(v)}}function o(){let f=s[t];t+=1;let v=!1,w="";for(;t2&&M<=bl[L[L.length-2]];)w=L.pop(),v=L.pop(),f=L.pop(),$={type:1,operator:v,left:f,right:w},L.push($);$=u(),$||i(`Expected expression after ${P}`),L.push(P,$)}let k=L.length-1;for($=L[k];k>1;)$={type:1,operator:L[k-1],left:L[k-2],right:$},k-=2;return $}function g(){let f=d();if(n(),f&&s[t]==="?"){t+=1;let v=g();if(v||i("Expected expression"),n(),s[t]===":"){t++;let w=g();return w||i("Expected expression"),{type:3,test:f,consequent:v,alternate:w}}else i("Expected :")}else return f}let y=g();return toe(y,e,t)[0]);return i.some(y=>y===void 0)?mn:[i,void 0];case 1:let n=oe(s.left,e,t)[0],r=oe(s.right,e,t)[0];return"+-**/%".includes(s.operator)&&(n===void 0||r===void 0)?mn:[Ml[s.operator](n,r),void 0];case 2:let[o,a]=oe(s.callee,e,t),h=s.args.map(y=>oe(y,e,t)[0]);return h.some(y=>y===void 0)||typeof o!="function"?mn:[o.apply(a,h),void 0];case 3:let l=oe(s.consequent,e,t),c=oe(s.alternate,e,t);return oe(s.test,e,t)[0]?l:c;case 4:return[t[s.name]||e[s.name],void 0];case 5:return[s.value,void 0];case 6:let u=oe(s.object,e,t)[0],d=s.computed?oe(s.property,e,t)[0]:s.property.name;return u?[u[d],u]:[void 0,void 0];case 7:let g=oe(s.argument,e,t)[0];return g===void 0&&s.operator!=="!"?mn:[Cl[s.operator](g),void 0]}}function ct(s){let e=kf(s);return e?(t={},i={})=>oe(e,t,i)[0]:(t={})=>{}}var Vf=/\${([^}]+)}/g;function vn(s,e=!1){let t=s.split(Vf),i=t.map((n,r)=>r%2?ct(n.replace(/×/g,"*")):void 0);return n=>t.map((r,o)=>{if(!(o%2))return r;let a=i[o](n);return!e&&typeof a=="number"&&a<0?`\u2013${-a}`:a}).join("")}var Pi="ontouchstart"in window,Gs="onpointerdown"in window;function Vt(s){if(s.touches){let e=s.targetTouches.length?s.targetTouches:s.changedTouches;return new p(e[0].clientX,e[0].clientY)}else return new p(s.clientX||0,s.clientY||0)}function If(s){return s.touches||[]}function fe(s,e){return Vt(s).transform(e.inverseTransformMatrix)}function Al(s,e){let t=Vt(s),i=e.bounds,n=(t.x-i.left)*e.canvasWidth/i.width,r=(t.y-i.top)*e.canvasHeight/i.height;return new p(n,r)}function Lf(s){if(s instanceof PointerEvent&&s.pointerType==="mouse")return A(s.target);let e=Vt(s);return A(document.elementFromPoint(e.x,e.y)||void 0)}function Of(s){if(s._data.tapEvent)return;s._data.tapEvent=!0;let e;s.on("pointerdown",t=>e=Vt(t)),s.on("pointerup",t=>{if(!e)return;let i=Vt(t);p.distance(e,i)<6&&s.trigger("tap",t),e=void 0}),s.on("pointercancel",()=>e=void 0)}function Rf(s){s._data.clickOutsideEvent||(s._data.clickOutsideEvent=!0,C.on("pointerdown",e=>{let t=e.composedPath()[0]||e.target;!t||s._el===t||s._el.contains(t)||s.trigger("clickOutside",e)}))}function ds(s,e){let t=e.$box||s,i=Vt;t.type==="svg"?i=d=>fe(d,t.$ownerSVG):t.type==="canvas"&&(i=d=>Al(d,t));let n=e.justInside?s:C,r,o,a=!1,h=0;s.css("touch-action")==="auto"&&s.css("touch-action","none"),s.addClass("noselect");function l(d){d.handled||If(d).length>1||(d.preventDefault(),a=!1,h=d.pointerId||0,n.on("pointermove",c),n.on("pointerstop",u),r=o=i(d),e.down&&e.down(r))}function c(d){if(!r||h&&d.pointerId!==h)return;d.preventDefault();let g=i(d);p.distance(g,o)<.5||(!a&&e.start&&e.start(r),e.move&&e.move(g,r,o),o=g,a=!0)}function u(d,g=!1){r&&(h&&d.pointerId!==h||(d.preventDefault(),n.off("pointermove",c),n.off("pointerstop",u),e.up&&e.up(o,r),a&&e.end&&e.end(o,r),!a&&e.click&&!g&&e.click(r),r=void 0))}C.onKey("Escape",()=>{if(!r)return;a&&e.move&&e.move(r,r,o),o=r;let d=document.createEvent("MouseEvent");d.pointerId=h,u(d,!0)}),s.on("pointerdown",l),e.justInside&&s.on("mouseleave",u),e.accessible&&(s.setAttr("tabindex","0"),document.addEventListener("keydown",d=>{if(![37,38,39,40].includes(d.keyCode)||s!==b.getActiveInput())return;let g=s.boxCenter,y=i({clientX:g.x,clientY:g.y}),f=d.keyCode===37?-25:d.keyCode===39?25:0,v=d.keyCode===38?-25:d.keyCode===40?25:0,w=y.shift(f,v);e.down&&e.down(y),e.start&&e.start(y),e.move&&e.move(w,y,y),e.end&&e.end(w,y)}))}function kl(s,e){let t=Vt;s.type==="svg"?t=n=>fe(n,s.$ownerSVG):s.type==="canvas"&&(t=n=>Al(n,s));let i=!1;s.on("touchstart mouseenter",n=>{!i&&e.enter&&e.enter(),e.move&&e.move(t(n)),i=!0},{passive:!0}),s.on("pointermove",n=>{i&&e.move&&e.move(t(n))}),s.on("touchend mouseleave",()=>{i&&e.exit&&e.exit(),i=!1},{passive:!0})}function Df(s){if(s._data.scrollEvents)return;s._data.scrollEvents=!0;let e=!1,t;function i(){let h=s.scrollTop;if(h===t){e=!1;return}t=h,s.trigger("scroll",{top:t}),window.requestAnimationFrame(i)}function n(){e||window.requestAnimationFrame(i),e=!0}(s.type==="window"?window:s._el).addEventListener("scroll",n);function o(){window.addEventListener("touchmove",n),window.addEventListener("touchend",a)}function a(){window.removeEventListener("touchmove",n),window.removeEventListener("touchend",a)}s._el.addEventListener("touchstart",function(h){h.handled||o()})}function zs(s,e){let t=e.$clickTarget||s,i=0,n=!1,r=!1,o=!1;function a(){n||(e.enter&&e.enter(),n=!0)}function h(){n&&(clearTimeout(i),e.exit&&e.exit(),n=!1)}s.on("mouseover",()=>{e.preventMouseover&&e.preventMouseover()||(clearTimeout(i),i=Zt(()=>{a(),r=!0},e.delay))}),s.on("mouseout",()=>{r&&(clearTimeout(i),i=Zt(h,e.exitDelay||e.delay))}),t.on("focus",()=>{n||e.preventMouseover&&e.preventMouseover()||(clearTimeout(i),a(),o=!0)});let l=()=>{o&&(e.canFocusWithin?setTimeout(()=>{let c=b.getActiveInput();c&&c.hasParent(s)?c.one("blur",l):h()}):h())};t.on("blur",l),t.on("click",()=>{n&&!r?h():n||(a(),r=!1)}),s.on("clickOutside",h)}var ea;function Nf(s){for(let e of s){let t=e.isIntersecting?"enterViewport":"exitViewport";setTimeout(()=>A(e.target).trigger(t))}}function $l(s){if(!s._data.intersectionEvents){if(s._data.intersectionEvents=!0,!window.IntersectionObserver){let e=!1;C.on("scroll",()=>{let t=s.isInViewport;e&&!t?(s.trigger("exitViewport"),e=!1):t&&!e&&(s.trigger("enterViewport"),e=!0)});return}ea||(ea=new IntersectionObserver(Nf)),ea.observe(s._el)}}function Gf(s,e=!1){if(e&&(s._data.resizeObserver&&s._data.resizeObserver.disconnect(),s._data.resizeObserver=void 0),!s._data.resizeObserver){if(window.ResizeObserver){let t=new window.ResizeObserver(()=>s.trigger("resize"));t.observe(s._el),s._data.resizeObserver=t}else if(window.MutationObserver){let t=new MutationObserver(()=>s.trigger("resize"));t.observe(s._el,{attributes:!0,childList:!0,characterData:!0,subtree:!0}),s._data.resizeObserver=t}}}function Pl(s){if(s._data.pointerPositionEvents)return;s._data.pointerPositionEvents=!0;let e=s.parent,t;e.on("pointerend",()=>t=void 0),e.on("pointermove",i=>{let n=t,r=Lf(i);t=r.equals(s)||r.hasParent(s),n!==void 0&&t&&!n&&s.trigger("pointerenter",i),!t&&n&&s.trigger("pointerleave",i)})}function sa(s,e){e._data[`_${s}`]||(e._data[`_${s}`]=!0,Gs?e.on(s.replace("mouse","pointer"),t=>{t.pointerType==="mouse"&&e.trigger(s,t)}):Pi||e._el.addEventListener(s,t=>e.trigger(s,t)))}function zf(s){s.on("keydown",e=>{if(e.metaKey||e.ctrlKey||b.isAndroid&&e.keyCode===229)return;let t=e.key||String.fromCharCode(e.which),i=!!e.shiftKey;s.trigger("key",{code:e.keyCode,key:t,char:t,shift:i})}),b.isAndroid&&s.type==="input"&&s.on("input",e=>{let t=e.key||e.data[e.data.length-1];s.trigger("key",{code:void 0,key:t,char:t}),s.value=""})}var wn={scrollwheel:"DOMMouseScroll mousewheel",pointerdown:Gs?"pointerdown":Pi?"touchstart":"mousedown",pointermove:Gs?"pointermove":Pi?"touchmove":"mousemove",pointerup:Gs?"pointerup":Pi?"touchend":"mouseup",pointercancel:Gs?"pointercancel":"touchcancel",pointerstop:Gs?"pointerup pointercancel":Pi?"touchend touchcancel":"mouseup"},yn={scroll:Df,tap:Of,clickOutside:Rf,key:zf,mousedown:sa.bind(void 0,"mousedown"),mousemove:sa.bind(void 0,"mousemove"),mouseup:sa.bind(void 0,"mouseup"),pointerenter:Pl,pointerleave:Pl,enterViewport:$l,exitViewport:$l,resize:Gf};function Bf(s,e,t,i){if(e in yn)yn[e](s,!1);else if(e in wn){let n=K(wn[e]);for(let r of n)s._el.addEventListener(r,t,i)}else s._el.addEventListener(e,t,i)}function _f(s,e,t){if(e in yn)(!s._events[e]||!s._events[e].length)&&yn[e](s,!0);else if(t&&e in wn){let i=K(wn[e]);for(let n of i)s._el.removeEventListener(n,t)}else t&&s._el.removeEventListener(e,t)}var gn=0,ia=new Map;function Tl(s,e){ia.set(s,e)}function qf(s){if(gn++,s(),gn--,gn===0){for(let[e,t]of ia.entries())e(t);ia.clear()}}function he(s,e){let t=new Map,i=new Map,n=new Set,r,o=0;function a(M){r=M;let P=M(k,!0);return r=void 0,P}function h(M){for(let P of t.values())P.has(M)&&P.delete(M);n.delete(M)}function l(M,P){return n.add(M),P?void 0:M(k,!0)}function c(M,P){i.has(M)&&h(i.get(M));let j=()=>{s[M]=P(k),r===j&&(r=void 0),u(M)};i.set(M,j),a(j)}function u(M){if(gn>0){for(let P of t.get(M)||[])Tl(P,s);for(let P of n)Tl(P,s)}else{for(let P of t.get(M)||[])P(s);for(let P of n)P(s)}}function d(){for(let M of t.values())for(let P of M)P(s);for(let M of n)M(s)}function g(M,P){P&&(s={}),qf(()=>{for(let[j,Ue]of Object.entries(M))j in w||(w[j]=s[j]),k[j]=Ue})}function y(){for(o+=1;`_x${o}`in s;)o+=1;return`_x${o}`}function f(){s={},t.clear(),i.clear(),o=0}function v(){return Object.assign({},s)}let w={};function $(){let M=[{},{}];for(let P of Object.keys(w))w[P]!==s[P]&&(M[0][P]=w[P],M[1][P]=s[P]);return w={},M}function L(M){e&&e.watch(()=>k[M]=e[M])}let k=new Proxy(s,{get(M,P){return P==="watch"?a:P==="unwatch"?h:P==="watchAll"?l:P==="setComputed"?c:P==="forceUpdate"?d:P==="getChanges"?$:P==="assign"?g:P==="getKey"?y:P==="clear"?f:P==="copy"?v:P==="_internal"?[s,t]:(r&&(t.has(P)||t.set(P,new Set),t.get(P).add(r)),P in s||L(P),s[P])},set(M,P,j){return s[P]===j||(P in w||(w[P]=s[P]),s[P]=j,i.has(P)&&(h(i.get(P)),i.delete(P)),u(P)),!0},deleteProperty(M,P){return delete s[P],t.delete(P),i.delete(P),!0}});return k}var Ff={A:7,C:6,H:1,L:2,M:2,Q:4,S:4,T:2,V:1,Z:0},Hf=/[astvzqmhlc]([^astvzqmhlc]*)/ig,jf=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function xn(s){let e=[],t;for(let i of s.match(Hf)||[]){let n=i[0].toUpperCase();if(n==="Z"){e.push({type:"Z",points:[]});continue}let r=(i.slice(1).match(jf)||[]).map(a=>+a),o=n===i[0];for(let[a,h]of Ao(r,Ff[n]).entries()){let l=[],c=n==="M"&&a>0?"L":n,u;n==="H"?(c="L",l=[new p(h[0],o&&(t==null?void 0:t.y)||0)]):n==="V"?(c="L",l=[new p(o&&(t==null?void 0:t.x)||0,h[0])]):n==="A"?(c="A",l=[new p(h[5],h[6])],u=h.slice(0,5)):"MLCSQT".includes(n)&&(l=Ao(h,2).map(d=>new p(d[0],d[1]))),!o&&t&&(l=l.map(d=>d.translate(t))),t=O(l),e.push({type:c,points:l,options:u})}}return e}function na(s){return s?xn(s).map(t=>O(t.points)).filter(t=>!!t):[]}var Uf=["font-family","font-size","font-style","font-weight","letter-spacing","text-decoration","color","display","visibility","alignment-baseline","baseline-shift","opacity","text-anchor","clip","clip-path","clip-rule","mask","filter","transform","transform-origin","white-space","line-height"],Wf=["fill","fill-rule","marker","marker-start","marker-mid","marker-end","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-width","text-rendering","dominant-baseline","transform-box","paint-order"],Kf=["padding","min-width","max-width","height","border-width","border-style","border-color","box-sizing","background","width","grid-template-columns","text-align"],Xf=["class","tabindex","contenteditable"],Yf=new Set(["opacity","transform-box","transform-origin","border-width","border-style","border-color"]),Zf={"font-style":"normal","font-weight":"400","letter-spacing":"normal","text-decoration":"none",display:"block",visibility:"visible","alignment-baseline":"auto","baseline-shift":"0px","text-anchor":"start",clip:"auto","clip-path":"none","clip-rule":"nonzero",mask:"none",opacity:"1",filter:"none",fill:"rgb(0, 0, 0)","fill-rule":"nonzero",marker:"none",stroke:"none","stroke-dasharray":"none","stroke-dashoffset":"0px","stroke-linecap":"butt","stroke-linejoin":"miter","stroke-width":"1px","text-rendering":"auto",transform:"none","dominant-baseline":"auto","transform-origin":"0px 0px","transform-box":"view-box","paint-order":"normal"};function Vl(s){var e,t;if(s.getAttribute("hidden")||s.style.opacity==="0"||s.style.display==="none")(e=s.parentNode)==null||e.removeChild(s);else{for(let i of Array.from(s.children))Vl(i);if(s.tagName==="g"&&s.childElementCount===0)(t=s.parentNode)==null||t.removeChild(s);else for(let i of Xf)s.hasAttribute(i)&&s.removeAttribute(i)}}function Qf(s,e){let t=s.parentElement;for(;t;){let i=t.style.getPropertyValue(e);if(i)return i;t=t.parentElement}}function Il(s,e,t=!1){let i=window.getComputedStyle(s);e.removeAttribute("style");let n=t||s.tagName==="foreignObject",r=[...Uf,...n?Kf:Wf];for(let h of r){let l=i.getPropertyValue(h),c=Qf(e,h);l===Zf[h]&&!c||!Yf.has(h)&&l===c||e.style.setProperty(h,l)}let o=s.children,a=e.children;for(let h=0;hi.textContent=n(s)||"")}}else e&&i.bindModel(s)}}bindVariable(s,e){}toggleDOM(s=!0){s!==!!this._el.parentNode&&(this.$placeholder||(this.$placeholder=A(document.createComment("")),this.insertBefore(this.$placeholder)),s?this.$placeholder.insertBefore(this):this.detach())}makeDynamicAttribute(s,e,t){if(s.startsWith("@")){let i=s.slice(1),n=ct(e);this.on(i,r=>n(t,{$event:r}))}else if(s===":show"){let i=ct(e);t.watch(()=>this.toggle(!!i(t)))}else if(s===":if"){let i=ct(e);t.watch(()=>this.toggleDOM(!!i(t)))}else if(s===":html"){let i=ct(e);t.watch(()=>this.html=i(t)||"")}else if(s===":draw"){let i=ct(e);t.watch(()=>this.draw(i(t)))}else if(s===":class"){let i=ct(e),n=`${this.attr("class")} `;t.watch(()=>this.setAttr("class",n+i(t)))}else if(s===":bind")this.bindVariable(t,e);else if(s.startsWith(":")){let i=ct(e),n=s.slice(1);t.watch(()=>this.setAttr(n,i(t)))}else if(e.includes("${")){let i=vn(e,!0);t.watch(()=>this.setAttr(s,i(t)||""))}(s.startsWith("@")||s.startsWith(":"))&&this.removeAttr(s)}makeDynamicList(s){let[e,t]=this.attr(":for").split(" in ");this.removeAttr(":for");let i=ct(t),n=A(document.createComment(""));this.insertBefore(n),this.detach();let r=[],o=0;s.watch(()=>{let a=i(s);Array.isArray(a)||(a=[]);for(let h=a.length;h{let o=i+n*St(t,r);this.scrollTop=o,this.trigger("scroll",{top:o})},e)}scrollBy(s,e=1e3,t="cubic"){s&&this.scrollTo(this.scrollTop+s,e,t)}css(s,e){if(e===void 0){if(typeof s=="string")return window.getComputedStyle(this._el).getPropertyValue(s);{let t=Object.keys(s);for(let i of t)this._el.style.setProperty(i,`${s[i]}`)}}else typeof s=="string"&&this._el.style.setProperty(s,`${e}`)}get transform(){return this.css("transform").replace("none","")}get transformMatrix(){let s=this.transform;if(!s)return[[1,0,0],[0,1,0]];let e=s.match(/matrix\(([0-9,.\s-]*)\)/);if(!e||!e[1])return[[1,0,0],[0,1,0]];let t=e[1].split(",");return[[+t[0],+t[2],+t[4]],[+t[1],+t[3],+t[5]]]}get scale(){let s=this.transformMatrix;return[s[0][0],s[1][1]]}setTransform(s,e=0,t=1){let i="";s&&(i+=`translate(${$t(s.x,.1)}px,${$t(s.y,.1)}px)`),e&&(i+=` rotate(${e}rad)`),t&&(i+=` scale(${t})`),this._el.style.transform=i}translate(s,e){this.setTransform(new p(s,e))}show(){this.hasAttr("hidden")&&this.removeAttr("hidden"),this.data.display==="visibility"?this._el.style.visibility="visible":this._el.style.display=this.data.display||"block"}hide(){this.data.display==="visibility"?this._el.style.visibility="hidden":this._el.style.display="none"}toggle(s){s?this.show():this.hide()}is(s){return this._el.matches?this._el.matches(s):Array.from(document.querySelectorAll(s)).includes(this._el)}index(){let s=0,e=this._el;for(;(e=e.previousSibling||void 0)!==void 0;)++s;return s}prepend(s){let e=this._el.childNodes;e.length?this._el.insertBefore(s._el,e[0]):this._el.appendChild(s._el)}append(s){this._el.appendChild(s instanceof Text?s:s._el)}insertBefore(s){this.parent._el.insertBefore(s._el,this._el)}insertAfter(s){let e=this._el.nextSibling;e?this.parent._el.insertBefore(s._el,e):this.parent._el.appendChild(s._el)}get next(){return A(this._el.nextSibling)}get prev(){return A(this._el.previousSibling)}$(s){return A(s,this)}$$(s){return Pe(s,this)}get parent(){return A(this._el.parentElement||void 0)}parents(s){let e=[],t=this.parent;for(;t;)(!s||t.is(s))&&e.push(t),t=t.parent;return e}hasParent(...s){let e=s.map(i=>i._el),t=this._el.parentNode;for(;t;){if(_(t,...e))return!0;t=t.parentNode}return!1}get children(){return Array.from(this._el.children||[],s=>A(s))}get childNodes(){return Array.from(this._el.childNodes,s=>{if(!(s instanceof Comment))return s instanceof Text?s:A(s)}).filter(s=>s)}restartAnimation(){let s=this.next,e=this.parent;this.detach(),s?s.insertBefore(this):e.append(this)}detach(){this._el&&this._el.parentNode&&this._el.parentNode.removeChild(this._el)}remove(){this.detach()}removeChildren(){for(;this._el.firstChild;)this._el.removeChild(this._el.firstChild)}copy(s=!0){return A(this._el.cloneNode(s))}on(s,e,t){for(let i of K(s))i in this._events?this._events[i].includes(e)||this._events[i].push(e):this._events[i]=[e],Bf(this,i,e,t)}one(s,e,t){let i=n=>{this.off(s,i),e(n)};this.on(s,i,t)}off(s,e){for(let t of K(s))t in this._events&&(this._events[t]=e?this._events[t].filter(i=>i!==e):[]),_f(this,t,e)}trigger(s,e={}){for(let t of K(s)){if(!this._events[t])return;for(let i of this._events[t])i.call(this,e)}}onKey(s,e,t){s=s.replace("AllArrows","ArrowUp ArrowDown ArrowLeft ArrowRight");let i=new Set(K(s)),n=t!=null&&t.up?"keyup":"keydown";(this._el===document.body?document:this._el).addEventListener(n,o=>{var a,h;let l=Si(o);(t!=null&&t.meta?!o.ctrlKey&&!o.metaKey:o.ctrlKey||o.metaKey)||!l||!i.has(l)||document.activeElement!==this._el&&((h=(a=document.activeElement)==null?void 0:a.shadowRoot)==null?void 0:h.activeElement)!==this._el&&b.formIsActive||e(o,l)})}onAttr(s,e){new MutationObserver(i=>{for(let n of i)n.type==="attributes"&&n.attributeName===s&&e(this.attr(s))}).observe(this._el,{attributes:!0}),e(this.attr(s),!0)}onPromise(s,e=!1){return e?Promise.resolve():new Promise(t=>this.one(s,()=>t()))}animate(s,e=400,t=0,i="ease-in-out"){return Ht(this,s,e,t,i)}enter(s="fade",e=500,t=0){return Sf(this,s,e,t)}exit(s="fade",e=500,t=0,i=!1){return Ef(this,s,e,t,i)}effect(s){this.one("animationend",()=>this.removeClass(`effects-${s}`)),this.addClass(`effects-${s}`)}},us=class extends Ll{get offsetTop(){return this._el.offsetTop}get offsetLeft(){return this._el.offsetLeft}get offsetParent(){return A(this._el.offsetParent||void 0)}get width(){return this._el.offsetWidth}get height(){return this._el.offsetHeight}get innerWidth(){let s=parseFloat(this.css("padding-left")),e=parseFloat(this.css("padding-right"));return this._el.clientWidth-s-e}get innerHeight(){let s=parseFloat(this.css("padding-bottom")),e=parseFloat(this.css("padding-top"));return this._el.clientHeight-s-e}get outerWidth(){let s=parseFloat(this.css("margin-left")),e=parseFloat(this.css("margin-right"));return this.width+s+e||0}get outerHeight(){let s=parseFloat(this.css("margin-bottom")),e=parseFloat(this.css("margin-top"));return this.height+s+e||0}get positionTop(){let s=this._el,e=0;for(;s;)e+=s.offsetTop,s=s.offsetParent;return e}get positionLeft(){let s=this._el,e=0;for(;s;)e+=s.offsetLeft,s=s.offsetParent;return e}offset(s){if(s._el===this._el.offsetParent){let e=this.offsetTop+s._el.clientTop,t=this.offsetLeft+s._el.clientLeft,i=e+this.height,n=t+this.width;return{top:e,left:t,bottom:i,right:n}}else{let e=s._el.getBoundingClientRect(),t=this._el.getBoundingClientRect();return{top:t.top-e.top,left:t.left-e.left,bottom:t.bottom-e.top,right:t.right-e.left}}}},Ol=class extends Ll{constructor(){super(...arguments),this.type="svg"}get $ownerSVG(){return A(this._el.ownerSVGElement||void 0)}get width(){return this.bounds.width}get height(){return this.bounds.height}get positionLeft(){let s=this._el.getBBox().x+this._el.getCTM().e;return this.$ownerSVG.positionLeft+s}get positionTop(){let s=this._el.getBBox().y+this._el.getCTM().f;return this.$ownerSVG.positionTop+s}get inverseTransformMatrix(){let s=this._el.getScreenCTM().inverse(),e=[[s.a,s.c,s.e],[s.b,s.d,s.f]];if(b.isFirefox){let t=this.transformMatrix;e[0][2]-=t[0][2],e[1][2]-=t[1][2]}return e}setTransform(s,e=0,t=1){let i=s?`translate(${$t(s.x,.1)} ${$t(s.y,.1)})`:"",n=x(e,0)?"":`rotate(${e*180/Math.PI})`,r=x(t,1)?"":`scale(${t})`;this.setAttr("transform",[i,n,r].join(" "))}get strokeLength(){if(this._el instanceof SVGGeometryElement)return this._el.getTotalLength();{let s=this.bounds;return 2*s.height+2*s.width}}getPointAtLength(s){if(this._el instanceof SVGGeometryElement){let e=this._el.getPointAtLength(s);return new p(e.x,e.y)}else return new p(0,0)}getPointAt(s){return this.getPointAtLength(s*this.strokeLength)}get points(){return na(this.attr("d"))}set points(s){let e=s.length?`M${s.map(t=>`${t.x},${t.y}`).join("L")}`:"";this.setAttr("d",e)}addPoint(s){let e=`${this.attr("d")} L ${s.x},${s.y}`;this.setAttr("d",e)}get center(){let s=+this.attr(this.tagName==="TEXT"?"x":"cx"),e=+this.attr(this.tagName==="TEXT"?"y":"cy");return new p(s,e)}setCenter(s){this.setAttr(this.tagName==="TEXT"?"x":"cx",s.x),this.setAttr(this.tagName==="TEXT"?"y":"cy",s.y)}setLine(s,e){this.setAttr("x1",s.x),this.setAttr("y1",s.y),this.setAttr("x2",e.x),this.setAttr("y2",e.y)}setRect(s){this.setAttr("x",s.p.x),this.setAttr("y",s.p.y),this.setAttr("width",s.w),this.setAttr("height",s.h)}draw(s,e={}){if(!s)return this.setAttr("d","");let t={};for(let i of["mark","arrows","round"])this.hasAttr(i)&&(t[i]=this.attr(i));this.hasClass("fill")&&(t.fill="fill"),this.hasAttr("size")&&(t.size=+this.attr("size")||void 0),this.setAttr("d",Re(s,Object.assign(e,t)))}},Jf=class extends Ol{get viewBox(){return this._el.viewBox.baseVal||{width:0,height:0}}get $ownerSVG(){return this}get positionLeft(){return parseInt(this.css("margin-left"))+this.parent.positionLeft}get positionTop(){return parseInt(this.css("margin-top"))+this.parent.positionTop}get svgWidth(){return this.viewBox.width||this.width}get svgHeight(){return this.viewBox.height||this.height}drawPath(s,e={},t={}){let i=m("path",e,this);return i.draw(s,t),i}image(s,e,t,i){return ae(this,null,function*(){let n=this.copy(!0);Il(this._el,n._el),s==="svg"&&Vl(n._el),t||(t=e||this.svgHeight),e||(e=this.svgWidth),n.setAttr("width",e),n.setAttr("height",t),n.setAttr("viewBox",i||this.attr("viewBox")||`0 0 ${this.svgWidth} ${this.svgHeight}`),n.setAttr("xmlns","http://www.w3.org/2000/svg");let r=n.$$("image");if(s==="svg")for(let c of r)c.setAttr("href",new URL(c.attr("href"),location.href));else yield Promise.all(r.map(c=>ae(this,null,function*(){c.setAttr("href",yield rm(c.attr("href")))})));let o=new XMLSerializer().serializeToString(n._el),a=`data:image/svg+xml;utf8,${encodeURIComponent(o)}`;if(s==="svg")return a;let h=m("canvas",{width:e,height:t});s==="jpg"&&(h.ctx.fillStyle="white",h.ctx.fillRect(0,0,e,t));let l=yield Gl(a);return h.ctx.drawImage(l,0,0,e,t),h.image(s)})}downloadImage(s,e,t,i){let n=b.isIOS?window.open("","_blank"):void 0,r=b.theme.isDark;r&&b.setTheme("light");let o=s.endsWith(".jpg")?"jpg":s.endsWith(".svg")?"svg":"png",a=this.image(o,e,t,i);r&&b.setTheme("dark"),a.then(h=>{if(n)return n.location.href=h;m("a",{download:s,href:h,target:"_blank"})._el.dispatchEvent(new MouseEvent("click",{view:window,bubbles:!1,cancelable:!0}))})}},Rl=class extends us{constructor(){super(...arguments),this.type="window"}get width(){return window.innerWidth}get height(){return window.innerHeight}get innerWidth(){return window.innerWidth}get innerHeight(){return window.innerHeight}get outerWidth(){return window.outerWidth}get outerHeight(){return window.outerHeight}get scrollWidth(){return document.body.scrollWidth}get scrollHeight(){return document.body.scrollHeight}get scrollTop(){return window.pageYOffset}set scrollTop(s){document.body.scrollTop=document.documentElement.scrollTop=s,this.trigger("scroll",{top:s,left:this.scrollLeft})}get scrollLeft(){return window.pageXOffset}set scrollLeft(s){document.body.scrollLeft=document.documentElement.scrollLeft=s,this.trigger("scroll",{top:this.scrollTop,left:s})}},tm=class extends us{constructor(){super(...arguments),this.type="form"}get action(){return this._el.action}get formData(){let s={};for(let e of Array.from(this._el.elements)){let t=e.name||e.id;t&&(s[t]=e.value)}return s}get isValid(){return this._el.checkValidity()}},em=class extends us{constructor(){super(...arguments),this.type="input"}get checked(){return this._el.checked||!1}set checked(s){this._el.checked=s}get value(){return this._el.value}set value(s){this._el.value=s}bindVariable(s,e){if(this._el.type==="checkbox"){let t=e.startsWith("!"),i=n=>t?!n:n;t&&(e=e.slice(1)),s[e]!==void 0?this.checked=i(s[e]):this.hasAttr("checked")&&(s[e]=i(this.checked)),this.on("change",()=>s[e]=i(this.checked)),s.watch(()=>this.checked=i(s[e]));return}if(this._el.type==="number"){let t=this.hasAttr("min")?+this.attr("min"):-1/0,i=this.hasAttr("max")?+this.attr("max"):1/0;this.change(n=>{n&&(s[e]=B(+n,t,i))})}else this.change(t=>s[e]=t);s[e]!==void 0?this.value=s[e]:this.value&&(s[e]=this.value),this.on("blur",()=>this.value=s[e]),s.watch(()=>{document.activeElement!==this._el&&(this.value=s[e])})}setInputPattern(s){if(isNaN(+s))return;let e=s.match(/^[0-9]+$/);this.setAttr("inputmode",e?"numeric":"decimal"),e&&this.setAttr("pattern","[0-9]*")}change(s){let e=this.value||"";this.on("focus",()=>e=this.value),this.on("change keyup input paste",()=>{this.value!==e&&(e=this.value,s(e))})}validate(s){this.change(e=>this.setValidity(s(e)))}setValidity(s){this._el.setCustomValidity(s)}get isValid(){return this._el.checkValidity()}},sm=class extends us{constructor(){super(...arguments),this.type="canvas"}getContext(s="2d",e={}){return this._el.getContext(s,e)}image(s="png"){return this._el.toDataURL(s==="png"?"image/png":"image/jpeg")}get canvasWidth(){return this._el.width}get canvasHeight(){return this._el.height}get ctx(){return this._ctx||(this._ctx=this.getContext()),this._ctx}draw(s,e={}){this.ctx.save(),Zo(this.ctx,s,e),this.ctx.restore()}clear(){this.ctx.clearRect(0,0,this.canvasWidth,this.canvasHeight)}fill(s){this.ctx.save(),this.ctx.fillStyle=s,this.ctx.fillRect(0,0,this.canvasWidth,this.canvasHeight),this.ctx.restore()}clearCircle(s,e){this.ctx.save(),this.ctx.globalCompositeOperation="destination-out",this.ctx.beginPath(),this.ctx.arc(s.x,s.y,e,0,2*Math.PI,!1),this.ctx.fill(),this.ctx.restore()}downloadImage(s){let e=this.image(s.endsWith(".jpg")?"jpg":"png");m("a",{download:s,href:e,target:"_blank"})._el.dispatchEvent(new MouseEvent("click",{view:window,bubbles:!1,cancelable:!0}))}},im=class extends us{play(){return this._el.play()||Promise.resolve()}pause(){return this._el.pause()}},Dl=["path","rect","circle","ellipse","polygon","polyline","g","defs","marker","line","text","tspan","pattern","mask","svg","foreignObject","image","use","clipPath"];function A(s,e){if(!s)return;let t=e?e._el:document.documentElement,i=typeof s=="string"?t.querySelector(s):s;if(!i)return;if(i._view)return i._view;let n=(i.tagName||"").toLowerCase();return n==="svg"?new Jf(i):n==="canvas"?new sm(i):n==="form"?new tm(i):n==="input"||n==="select"||n==="textarea"?new em(i):n==="video"||n==="audio"?new im(i):Dl.includes(n)?new Ol(i):new us(i)}function Pe(s,e){let t=e?e._el:document.documentElement,i=s?t.querySelectorAll(s):[];return Array.from(i,n=>A(n))}function m(s,e={},t){let i=Dl.includes(s)?document.createElementNS("http://www.w3.org/2000/svg",s):document.createElement(s);for(let[r,o]of Object.entries(e))o!==void 0&&(r==="id"?i.id=o:r==="html"?i.innerHTML=o:r==="text"?i.textContent=o:r==="path"?i.setAttribute("d",Re(o)):i.setAttribute(r,o));let n=A(i);return t&&t.append(n),n}var C=new Rl(document.body),Xt=new Rl(document.documentElement);function nm(s){let e=[];for(let t of Object.keys(s)){let i=s[t];if(t=encodeURIComponent(t),i==null){e.push(t);continue}i=Array.isArray(i)?i.join(","):`${i}`,i=i.replace(/(\r)?\n/g,`\r -`),i=encodeURIComponent(i),i=i.replace(/%20/g,"+"),e.push(`${t}=${i}`)}return e.join("&")}function Nl(s){s=s.replace(/^[?,&]/,"");let e=decodeURIComponent(s).split("&"),t={};return e.forEach(i=>{let n=i.split("=");t[n[0]]=n[1]}),t}function De(s,e){return ae(this,null,function*(){let t=e instanceof FormData,i={method:"POST",body:t?e:e?nm(e):void 0,headers:{"X-CSRF-Token":window.csrfToken||""}};t||(i.headers["Content-Type"]="application/x-www-form-urlencoded");let n=s.includes("?")?"&xhr=1":"?xhr=1",r=yield fetch(s+n,i);if(!r.ok)throw new Error(`Fetch error ${r.status}: ${s}`);return r.text()})}function Gl(s,e=!1){return new Promise(t=>{let i=new Image;e||(i.crossOrigin="Anonymous"),i.onload=()=>t(i),i.src=s})}var rm=Le(s=>ae(void 0,null,function*(){let e=yield Gl(s),t=m("canvas",{width:e.width,height:e.height});return t.ctx.drawImage(e,0,0,e.width,e.height),t.image("png")})),Ti=new Map;function zl(s,e){Ti.has(s)?Mo(Ti.get(s),e,(t,i)=>Wt(t.concat(i))):Ti.set(s,e)}function Bl(){if(window.navigator.onLine)for(let[s,e]of Ti)Ti.delete(s),De(s,{data:JSON.stringify(e)}).catch(t=>{console.error("Failed to send POST request:",t),zl(s,e)})}var _l=ge(Bl,5e3);window.addEventListener("online",_l);window.onbeforeunload=Bl;function ql(s,e){zl(s,e),_l()}var ee=class{constructor(s,e=1,t=!0){this.src=s,this.defaultVolume=e,this.player=new Audio,this.player.src=s,t&&(this.player.preload="auto")}play(s){this.player.currentTime=0,this.player.volume=s||this.defaultVolume,this.player.play()}},om=os(["#cd0e66","#0f82f2","#22ab24","#fd8c00"]),am=class{constructor(s){this.index=s,this.color=om(),this.tilt=Math.floor(Math.random()*10)-10,this.tiltAngleIncrement=Math.random()*.07+.05,this.tiltAngle=0,this.x=Math.random()*b.width,this.y=(Math.random()-1)*b.height,this.r=_t.uniform(10,30)}draw(s){s.beginPath(),s.lineWidth=this.r/2,s.strokeStyle=this.color,s.moveTo(this.x+this.tilt+this.r/4,this.y),s.lineTo(this.x+this.tilt,this.y+this.tilt+this.r/4),s.stroke()}update(s,e){this.tiltAngle+=this.tiltAngleIncrement,this.y+=(Math.cos(s)+3+this.r/2)/2,this.x+=Math.sin(s),this.tilt=Math.sin(this.tiltAngle-this.index/3)*15,this.x<-20?(this.x=-20,this.y=Math.random()*b.height,this.tilt=Math.floor(Math.random()*10)-20):this.x>b.width+20?(this.x=b.width+20,this.y=Math.random()*b.height,this.tilt=Math.floor(Math.random()*10)-20):e&&this.y>b.height&&(this.x=Math.random()*b.width,this.y=-10,this.tilt=Math.floor(Math.random()*10)-20)}},hm="position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 9999",cs=void 0;function Ei(s=2e3,e=150){cs||(cs=m("canvas",{style:hm},C)),cs.setAttr("width",b.width),cs.setAttr("height",b.height),cs.show();let t=cs.ctx,i=z(r=>new am(r),e),n=mt(r=>{t.clearRect(0,0,b.width,b.height);let o=rthis.updateBounds()),ds(s,{start:()=>{this.disabled||(this.startPos=this.position,this.trigger("start"),Xt.addClass("grabbing"))},move:(t,i)=>{this.disabled||(this.setPosition(this.startPos.x+t.x-i.x,this.startPos.y+t.y-i.y),this.trigger("drag",{posn:this.position,pointerPosn:t}),this.checkTarget(t))},end:(t,i)=>{this.disabled||(this.trigger(t.equals(i)?"click":"end",{$target:this.$over}),this.options.$targets&&!this.$over&&this.options.resetOnMiss&&this.resetPosition(),this.$over=void 0,Xt.removeClass("grabbing"))},click:()=>this.trigger("click"),accessible:!0})}addTarget(s){var e;this.options.$targets||(this.options.$targets=[]),(e=this.options.$targets)==null||e.push(s)}removeTarget(s){var e,t;this.options.$targets=(e=this.options.$targets)==null?void 0:e.filter(i=>i!==s),(t=this.options.$targets)!=null&&t.length||(this.options.$targets=void 0)}checkTarget(s){if(!this.options.$targets)return;let e=this.options.$targets.find(t=>t.boundsRect.contains(s));e!==this.$over&&(this.$over&&this.trigger("exit-target",{$target:this.$over}),e&&this.trigger("enter-target",{$target:e}),this.$over=e)}updateBounds(){if(!this.options.withinBounds)return this.bounds=void 0;if(this.options.bounds)return this.bounds=this.options.bounds;let s=this.bounds,e=this.options.$parent||this.$el.parent,t=e.type==="svg"?e.svgWidth:e.width,i=e.type==="svg"?e.svgHeight:e.height;this.bounds=new lt(0,t,0,i),!t&&!i&&setTimeout(()=>this.updateBounds()),s&&this.setPosition(this.position.x*this.bounds.dx/s.dx||0,this.position.y*this.bounds.dy/s.dy||0)}setPosition(s,e){var t;let i=new p(this.options.moveX?s:0,this.options.moveY?e:0);this.bounds&&(i=i.clamp(this.bounds,(t=this.options.margin)!=null?t:0)),i=i.round(this.options.snap||1),this.options.round&&(i=this.options.round(i)),!i.equals(this.position)&&(this.position=i,this.options.useTransform?this.$el.translate(i.x,i.y):(this.options.moveX&&this.$el.css("left",`${i.x}px`),this.options.moveY&&this.$el.css("top",`${i.y}px`)),this.trigger("move",{posn:i}))}resetPosition(s=250){return ae(this,null,function*(){let e=this.position;this.$el.css({"pointer-events":"none"}),yield mt(t=>{let i=p.interpolate(e,this.startPos,t);this.setPosition(i.x,i.y)},s).promise,this.$el.css({"pointer-events":"initial"})})}},lm="position: fixed; top: 0; left: 0; width: 100%; height: 4px; background: #0f82f2; pointer-events: none; z-index: 9999; will-change: transform;";function Sl(s,e){let t=e.regex.exec(s);if(t){t.shift();let i={};for(let[n,r]of e.params.entries())i[r]=t[n];return i}else return}function cm(s,e,t){return ae(this,null,function*(){return s.template?typeof s.template=="string"?s.template:s.template(e):(yield fetch(t+(t.indexOf("?")>=0?"&xhr=1":"?xhr=1"))).text()})}var Fl=document.readyState==="complete";window.addEventListener("load",()=>setTimeout(()=>Fl=!0));"scrollRestoration"in window.history&&(window.history.scrollRestoration="manual");var pm=class extends Oe{constructor(){super(...arguments),this.$viewport=C,this.views=[],this.active={path:"",hash:""},this.preloaded=!1,this.transition=!1,this.noLoad=!1,this.initialise=()=>{}}setup(s={}){s.$viewport&&(this.$viewport=s.$viewport),s.initialise&&(this.initialise=s.initialise),s.preloaded&&(this.preloaded=s.preloaded),s.transition&&(this.transition=s.transition),s.noLoad&&(this.noLoad=s.noLoad),s.click&&C.on("click",e=>this.onLinkClick(e)),s.history&&window.addEventListener("popstate",e=>ae(this,null,function*(){var t;if(!Fl||!((t=e.state)!=null&&t.path))return;(yield this.load(e.state.path,e.state.hash))||window.history.pushState(this.active,"",this.active.path+this.active.hash)}))}view(s,{enter:e,exit:t,template:i}={}){let n=(s.match(/:\w+/g)||[]).map(u=>u.substr(1)),r=`${s.replace(/:\w+/g,"([\\w-]+)").replace("/","\\/")}\\/?`,o=s.includes("?")?"":"(\\?.*)?",h={regex:new RegExp(`^${r}${o}$`,"i"),params:n,enter:e,exit:t,template:i};this.views.push(h);let l=window.location.pathname+window.location.search,c=Sl(l,h);c&&(this.active={path:l,hash:window.location.hash},window.history.replaceState(this.active,"",this.active.path+this.active.hash),b.ready(()=>{setTimeout(()=>{this.preloaded?(this.initialise(this.$viewport,c),h.enter&&h.enter(this.$viewport,c)):this.loadView(h,c)})}))}paths(...s){for(let e of s)this.view(e)}getView(s){for(let e of this.views){let t=Sl(s,e);if(t)return{view:e,params:t}}}load(s,e){return ae(this,null,function*(){if(s===this.active.path&&e!==this.active.hash)return this.trigger("hashChange",e.slice(1)),this.trigger("change",s+e),this.active={path:s,hash:e},!0;let t=this.getView(s);return!t||this.beforeChange&&!(yield this.beforeChange())?!1:(this.active={path:s,hash:e},this.trigger("change",s+e),window.ga&&window.ga("send","pageview",s+e),this.noLoad?t.view.enter&&t.view.enter(this.$viewport,t.params):this.loadView(t.view,t.params),!0)})}loadView(s){return ae(this,arguments,function*(e,t={}){this.showLoadingBar();let i=this.active.path,n=yield cm(e,t,i);if(this.active.path!==i)return;yield this.$viewport.animate({opacity:0},200).promise,this.$viewport.removeChildren(),C.scrollTop=0,this.$viewport.html=n,b.resize(),bf(),this.$viewport.animate({opacity:1},200),this.hideLoadingBar();let r=this.$viewport.$("title");r&&(document.title=r.text),this.initialise(this.$viewport,t),e.enter&&e.enter(this.$viewport,t),this.trigger("afterChange",{$viewport:this.$viewport})})}onLinkClick(s){if(s.metaKey||s.ctrlKey||s.shiftKey||s.defaultPrevented)return;let e=s.target;for(;e&&e.nodeName!=="A";)e=e.parentNode;if(!e||e.nodeName!=="A")return;let t=e;if(t.target||t.origin!==window.location.origin||t.hasAttribute("download")||t.getAttribute("rel")==="external")return;let i=t.getAttribute("href");i&&i.indexOf("mailto:")>-1||this.getView(t.pathname+t.search)&&(s.preventDefault(),this.goTo(t.pathname+t.search,t.hash))}goTo(s,e=""){return ae(this,null,function*(){let t=this.active.path+this.active.hash;(yield this.load(s,e))&&t!==this.active.path+this.active.hash&&window.history.pushState(this.active,"",s+e)})}replace(s,e=""){this.active={path:s,hash:e},window.history.replaceState(this.active,"",s+e)}back(){window.history.back()}forward(){window.history.forward()}showLoadingBar(){this.$loadingBar||(this.$loadingBar=m("div",{style:lm},C)),this.$loadingBar.css({transform:"translateX(-100%)",opacity:1}),this.$loadingBar.show(),this.animation=mt(s=>{this.$loadingBar.css("transform",`translateX(-${10+90*Math.exp(-4*s)}%)`)},3e3)}hideLoadingBar(){return ae(this,null,function*(){var s,e,t;(s=this.animation)==null||s.cancel(),yield(e=this.$loadingBar)==null?void 0:e.animate({transform:"none",opacity:0}).promise,(t=this.$loadingBar)==null||t.hide()})}},Mi=new pm;function dm(s,e){let t=Array.from(s.childNodes);s.innerHTML=e;let i={};for(let n of Array.from(s.querySelectorAll("slot")))i[n.getAttribute("name")||""]=n;for(let n of t){let r=n.getAttribute&&n.getAttribute("slot")||"",o=i[r]||i[""];o&&o.parentNode.insertBefore(n,o)}for(let n of Object.values(i))n.parentNode.removeChild(n)}function*Hl(s){for(let e of Array.from(s.children))e.tagName.includes("-")?yield e:yield*As(df(Hl(e)))}var jl=new Map,um=class extends HTMLElement{constructor(){super(...arguments),this.wasConnected=!1,this.isReady=!1}connectedCallback(){return ae(this,null,function*(){if(this.wasConnected){this._view.trigger("connected");return}this.wasConnected=!0,this.isReady=!1,this._view.created();let s=jl.get(this._view.tagName)||{};s.template&&dm(this,s.template);let e=[...Hl(this)].filter(t=>!t.isReady).map(t=>new Promise(i=>t.addEventListener("ready",i)));setTimeout(()=>{this.isReady||console.error(`Children of custom element ${this.tagName} not ready after 1s.`)},1e3),yield Promise.all(e),this._view.ready(),this.dispatchEvent(new CustomEvent("ready")),this.isReady=!0})}disconnectedCallback(){this._view.trigger("disconnected")}},E=class extends us{created(){}ready(){}},fm=new Map;function S(s,e={}){return function(t){if(window.customElements.get(s)){console.warn(`Trying to declare the custom element ${s} twice!`);return}class i extends um{constructor(){super(),this._view=new t(this)}}fm.set(s,t),jl.set(s.toUpperCase(),e),window.customElements.define(s,i)}}var $n=class{constructor(e){this.clipEndTime=0;this.player=new Audio(e),this.player.preload="true",this.player.addEventListener("timeupdate",()=>{this.player.currentTime>=this.clipEndTime&&this.triggerCallback(!0)}),window.addEventListener("beforeunload",()=>this.player.pause())}playClip(e,t,i){this.triggerCallback(!1),this.player.currentTime=e,this.clipEndTime=t,this.clipCallback=i,this.player.play()}triggerCallback(e){if(!this.clipCallback)return;let t=this.clipCallback;this.clipCallback=void 0,this.player.pause(),t({ended:e})}pause(){this.triggerCallback(!1)}get isPlaying(){return!!this.clipCallback}},oa=!1,ra,Pn=class{constructor(e,t){this.audio=e;this.paragraphs=[];this.paragraphs=t.$$(".voice").map(i=>new aa(i,e));for(let[i,n]of this.paragraphs.entries())n.on("end",()=>{var r;if(this.paragraphs[i+1])this.paragraphs[i+1].play();else{let o=t.nextStep;o&&o.isShown&&((r=o.narration)==null||r.play())}})}play(){var e;this.audio.isPlaying||!oa||(e=this.paragraphs[0])==null||e.play()}},aa=class extends Oe{constructor(t,i){super();this.$p=t;this.audio=i;this.playing=void 0;this.sentences=t.$$(".sentence[data-timings]").map(n=>new ha(n,i)),this.$button=m("button",{class:"playback-btn",title:"Play Narration"}),this.$button.on("click",()=>{this.playing?this.audio.pause():this.play(),oa=!oa,ra=void 0}),t.prepend(this.$button),t.addClass("sentence-wrap");for(let[n,r]of this.sentences.entries())r.on("end",o=>{this.playing=void 0,o&&this.sentences[n+1]?setTimeout(()=>this.play(this.sentences[n+1]),200):(this.$button.removeClass("active"),o&&setTimeout(()=>this.trigger("end"),400))})}play(t){let i=t||this.sentences[0],n=i.$reveal;if(n&&n.css("visibility")==="hidden"){this.$button.removeClass("active"),ra=n,n.one("reveal",()=>{ra===n&&!this.audio.isPlaying&&this.play(i)});return}this.playing=i,this.playing.play(),this.$button.addClass("active");let r=this.$p.parents("x-tabbox .tab")[0];if(r){let h=r.parents("x-tabbox")[0];h.makeActive(r.index());let l=h.active;h.one("change",c=>{this.playing&&c!==l&&this.audio.pause()})}let o=this.$p.bounds,a=o.top+o.height-b.height+20;a>0&&C.scrollBy(a+100),setTimeout(()=>this.$button.focus(),800)}},ha=class extends Oe{constructor(t,i){super();this.$el=t;this.audio=i;let n=t.attr("data-timings").split("-");this.start=+n[0]/1e3,this.end=(+n[1]-200)/1e3}play(){this.$el.addClass("playing"),this.audio.playClip(this.start,this.end,({ended:t})=>{this.$el.removeClass("playing"),this.trigger("end",t)})}get $reveal(){return this.$el.parents(".reveal")[0]}};var mm=Object.defineProperty,gm=Object.getOwnPropertyDescriptor,Ci=(s,e,t,i)=>{for(var n=i>1?void 0:i?gm(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&mm(e,t,n),n},Ul=(s,e,t)=>new Promise((i,n)=>{var r=h=>{try{a(t.next(h))}catch(l){n(l)}},o=h=>{try{a(t.throw(h))}catch(l){n(l)}},a=h=>h.done?i(h.value):Promise.resolve(h.value).then(r,o);a((t=t.apply(s,e)).next())}),Bs,vm=m("div",{class:"snackbar"},C),Wl=class extends E{ready(){var s;vm.append(this),(s=this.$("button"))==null||s.on("click",()=>this.close())}open(s=2e3){return Ul(this,null,function*(){Bs!==this&&(Bs&&(yield Bs.close()),Bs=this,yield this.enter("pop",300).promise,this.setAttr("role","alert"),s&&setTimeout(()=>this.close(),s))})}close(){return Ul(this,null,function*(){Bs===this&&(Bs=void 0,this.removeAttr("role"),yield this.exit("pop",300).promise)})}};Wl=Ci([S("x-alert")],Wl);var Kl=class extends E{ready(){if(this.children.length)return;let s=m("svg",{viewBox:"0 0 24 24",alt:"",role:"presentation"},this),e=m("use",{},s),t=+this.attr("size")||24;for(let i of[this,s])i.css({width:`${t}px`,height:`${t}px`});this.onAttr("name",i=>e.setAttr("href",`/icons.13d4c88a.svg#${i}`))}};Kl=Ci([S("x-icon")],Kl);var ms=m("div",{class:"modal-background"},C),la,Te=void 0,ca=void 0;function pa(){Te&&Te.canClose&&Te.close()}ms.on("click",pa);C.onKey("Escape",pa);Mi.on("change",pa);ms.on("scrollwheel touchmove",s=>{s.preventDefault(),s.stopPropagation()});C.onKey("Space ArrowUp ArrowDown PageDown PageUp",s=>{Te&&(s.preventDefault(),s.stopPropagation())});var Xl=class extends E{constructor(){super(...arguments),this.isOpen=!1,this.canClose=!0}ready(){this.canClose=!this.hasAttr("no-close"),this.$iframe=this.$("iframe[data-src]"),this.$video=this.$("video");let s=Pe(`[data-modal=${this.id}]`);for(let t of s)t.on("click",()=>this.open());Mi.on("afterChange",({$viewport:t})=>{let i=t.$$(`[data-modal=${this.id}]`);for(let n of i)n.on("click",()=>this.open())}),(this.hasClass("open")||b.getHash()===this.id)&&!Te&&this.open(!0),this.$("input")&&this.addClass("interactive");let e=this.$(".close");e&&e.on("click",()=>this.close());for(let t of this.$$(".btn"))t.on("click",()=>this.trigger("btn-click",t))}open(s=!1){var e,t;if(this.isOpen)return;ms.setClass("light",this.hasClass("light")),Te?Te.close(!0):s?ms.show():ms.css("display")==="block"?la==null||la.cancel():ms.enter("fade",250),this.isOpen=!0,Te=this,this.$iframe&&this.$iframe.setAttr("src",this.$iframe.data.src),this.$video&&this.$video.play(),s?this.show():this.enter("pop",250).promise.then(()=>this.css("transform","")),this.setAttr("role","dialog"),this.trigger("open"),ca=document.activeElement;let i=this.$('input, a, button, textarea, [tabindex="0"]');i&&i.focus(),(e=window.ga)==null||e.call(window,"send","event","Modal",this.id),(t=window.gtag)==null||t.call(window,"event","modal",{action:this.id})}close(s=!1,e=!1){this.isOpen&&(this.isOpen=!1,this.removeAttr("role"),Te=void 0,this.$iframe&&this.$iframe.setAttr("src",""),this.$video&&this.$video.pause(),s||(la=ms.exit("fade",250)),this.exit("pop",250).promise.then(()=>this.css("transform","")),e||this.trigger("close"),ca&&ca.focus())}getOpenModal(){return Te}};Xl=Ci([S("x-modal")],Xl);var Yl=class extends E{constructor(){super(...arguments),this.isOpen=!1}ready(){this.animation=this.attr("animation")||"pop",this.$bubble=this.$(".popup-body"),this.$bubble.hide(),this.$(".popup-target").on("click",()=>this.toggleOpen()),this.on("clickOutside",()=>this.close());for(let e of this.$bubble.$$("a"))e.on("click",()=>this.close());C.onKey("Escape",()=>this.close())}toggleOpen(){this.isOpen?this.close():this.open()}open(){this.isOpen||(this.isOpen=!0,this.addClass("active"),this.$bubble.enter(this.animation,150),this.$bubble.setAttr("role","dialog"),this.$bubble.focus(),this.trigger("open"))}close(){this.isOpen&&(this.isOpen=!1,this.removeClass("active"),this.$bubble.exit(this.animation,150),this.$bubble.removeAttr("role"),this.trigger("close"))}};Yl=Ci([S("x-popup")],Yl);var Zl=class extends E{constructor(){super(...arguments),this.$options={}}ready(){let s=this.children;this.$active=this.$(".active")||s[0],this.$active.addClass("active");for(let[e,t]of s.entries())!_(t.tagName,"A","BUTTON")&&!t.hasAttr("tabindex")&&t.setAttr("tabindex",0),t.on("click",()=>this.makeActive(t)),this.$options[t.attr("value")||e]=t;this.trigger("change",this.$active)}makeActive(s){s!==this.$active&&(this.$active.removeClass("active"),this.$active=s,s.addClass("active"),this.trigger("change",s))}bindVariable(s,e){s[e]===void 0&&(s[e]=this.$active.attr("value")),this.on("change",t=>s[e]=t.attr("value")),s.watch(()=>{let t=this.$options[s[e]];t&&this.makeActive(t)})}};Zl=Ci([S("x-select")],Zl);var da=12;function wm(s){return`M${s},${s/2}a${s/2},${s/2},0,0,1,0,${s}A${s/2},${s/2},0,0,1,${s},${s/2}`}function ym(s){return`M ${s},0 C ${s/2},0,0,${s/2},0,${s} s ${s/2},${s},${s},${s} s ${s}-${s/2},${s}-${s} S ${s*1.5},0,${s},0 z M ${s*44.6/50},${s*76.1/50} L ${s*19.2/50},${s*48.8/50} l ${s*4/50}-${s*4.2/50} l ${s*19.8/50},${s*11.9/50} l ${s*34.2/50}-${s*32.6/50} l ${s*3.5/50},${s*3.5/50} L ${s*44.6/50},${s*76.1/50} z`}var Tn=class extends E{constructor(){super(...arguments);this.completed=!1}ready(){this.r=+this.attr("r")||10,this.r1=this.r+da,this.$svg=m("svg",{width:2*this.r1,height:2*this.r1},this),this.$progress=m("path",{class:"pie",d:wm(this.r),"stroke-width":this.r},this.$svg),this.onAttr("p",t=>this.setProgress(+t,!1))}setProgress(t,i=!0){if(t>.99)return this.complete(i);let n=Math.PI*this.r;this.$progress.css("stroke",t?"currentColor":"none"),this.$progress.css("stroke-dasharray",`${t*n} ${n}`)}complete(t=!0){if(this.completed||(this.completed=!0,this.$progress.css("stroke","none"),this.$progress.css("fill","currentColor"),this.$progress.setAttr("d",ym(this.r)),!t))return;let i=`translate(${this.r1} ${this.r1})`,n=m("g",{transform:i},this.$svg),r=z(()=>m("line",{},n),18);mt(o=>{let a=this.r+da*St("quint-out",o),h=this.r+da*o;for(let l=0;l<18;++l){let c=Math.cos(Math.PI*2*l/18),u=Math.sin(Math.PI*2*l/18);r[l].setLine({x:c*a,y:u*a},{x:c*h,y:u*h})}},800).promise.then(()=>n.remove())}};Tn=T([S("x-progress")],Tn);var Ql="2.4.1",ua="i5iSjo",Jl="_av",fa="_au",ma="(not set)";var Sn=[],se=class{static add(e,t,i){tc(e,t).add(i)}static remove(e,t,i){tc(e,t).remove(i)}constructor(e,t){this.context=e,this.methodName=t,this.isTask=/Task$/.test(t),this.originalMethodReference=this.isTask?e.get(t):e[t],this.methodChain=[],this.boundMethodChain=[],this.wrappedMethod=(...i)=>{let n=this.boundMethodChain[this.boundMethodChain.length-1];return n(...i)},this.isTask?e.set(t,this.wrappedMethod):e[t]=this.wrappedMethod}add(e){this.methodChain.push(e),this.rebindMethodChain()}remove(e){let t=this.methodChain.indexOf(e);t>-1&&(this.methodChain.splice(t,1),this.methodChain.length>0?this.rebindMethodChain():this.destroy())}rebindMethodChain(){this.boundMethodChain=[];for(let e,t=0;e=this.methodChain[t];t++){let i=this.boundMethodChain[t-1]||this.originalMethodReference.bind(this.context);this.boundMethodChain.push(e(i))}}destroy(){let e=Sn.indexOf(this);e>-1&&(Sn.splice(e,1),this.isTask?this.context.set(this.methodName,this.originalMethodReference):this.context[this.methodName]=this.originalMethodReference)}};function tc(s,e){let t=Sn.filter(i=>i.context==s&&i.methodName==e)[0];return t||(t=new se(s,e),Sn.push(t)),t}var _s=window.Element.prototype,Bw=_s.matches||_s.matchesSelector||_s.webkitMatchesSelector||_s.mozMatchesSelector||_s.msMatchesSelector||_s.oMatchesSelector;var $m="80",Pm="443",Zw=RegExp(":("+$m+"|"+Pm+")$"),Qw=document.createElement("a");function En(s,e,t=void 0,i=void 0,n=void 0,r=void 0){if(typeof i=="function"){let o=t.get("buildHitTask");return{buildHitTask:a=>{a.set(s,null,!0),a.set(e,null,!0),i(a,n,r),o(a)}}}else return Qe({},s,e)}var ga={};function sc(s,e){let t=s.get("trackingId"),i=ga[t]=ga[t]||{},n=()=>{clearTimeout(i.timeout),i.send&&se.remove(s,"send",i.send),delete ga[t],i.queue.forEach(r=>r())};clearTimeout(i.timeout),i.timeout=setTimeout(n,0),i.queue=i.queue||[],i.queue.push(e),i.send||(i.send=r=>(...o)=>{n(),r(...o)},se.add(s,"send",i.send))}var Qe=Object.assign||function(s,...e){for(let t=0,i=e.length;t>e/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,s)};function va(s,e){let t=window.GoogleAnalyticsObject||"ga";window[t]=window[t]||function(...i){(window[t].q=window[t].q||[]).push(i)},window.gaDevIds=window.gaDevIds||[],window.gaDevIds.indexOf(ua)<0&&window.gaDevIds.push(ua),window[t]("provide",s,e),window.gaplugins=window.gaplugins||{},window.gaplugins[ic(s)]=e}var ki=class{constructor(){this.registry_={}}on(e,t){this.getRegistry_(e).push(t)}off(e=void 0,t=void 0){if(e&&t){let i=this.getRegistry_(e),n=i.indexOf(t);n>-1&&i.splice(n,1)}else this.registry_={}}emit(e,...t){this.getRegistry_(e).forEach(i=>i(...t))}getEventCount(){let e=0;return Object.keys(this.registry_).forEach(t=>{e+=this.getRegistry_(t).length}),e}getRegistry_(e){return this.registry_[e]=this.registry_[e]||[]}};var Mn="autotrack",qs={},ya=!1,Vi,gs=class s extends ki{static getOrCreate(e,t,i){let n=[Mn,e,t].join(":");return qs[n]||(qs[n]=new s(n,i),ya||Sm()),qs[n]}static isSupported_(){if(Vi!=null)return Vi;try{window.localStorage.setItem(Mn,Mn),window.localStorage.removeItem(Mn),Vi=!0}catch(e){Vi=!1}return Vi}static get_(e){return window.localStorage.getItem(e)}static set_(e,t){window.localStorage.setItem(e,t)}static clear_(e){window.localStorage.removeItem(e)}constructor(e,t={}){super(),this.key_=e,this.defaults_=t,this.cache_=null}get(){if(this.cache_)return this.cache_;if(s.isSupported_())try{this.cache_=wa(s.get_(this.key_))}catch(e){}return this.cache_=Qe({},this.defaults_,this.cache_)}set(e){if(this.cache_=Qe({},this.defaults_,this.cache_,e),s.isSupported_())try{s.set_(this.key_,JSON.stringify(this.cache_))}catch(t){}}clear(){if(this.cache_={},s.isSupported_())try{s.clear_(this.key_)}catch(e){}}destroy(){delete qs[this.key_],Object.keys(qs).length||Em()}};function Sm(){window.addEventListener("storage",rc),ya=!0}function Em(){window.removeEventListener("storage",rc),ya=!1}function rc(s){let e=qs[s.key];if(e){let t=Qe({},e.defaults_,wa(s.oldValue)),i=Qe({},e.defaults_,wa(s.newValue));e.cache_=i,e.emit("externalSet",i,t)}}function wa(s){let e={};if(s)try{e=JSON.parse(s)}catch(t){}return e}var Mm=1e3,Cm=60*Mm,Cn={},vs=class s{static getOrCreate(e,t,i){let n=e.get("trackingId");return Cn[n]?Cn[n]:Cn[n]=new s(e,t,i)}constructor(e,t,i){this.tracker=e,this.timeout=t||s.DEFAULT_TIMEOUT,this.timeZone=i,this.sendHitTaskOverride=this.sendHitTaskOverride.bind(this),se.add(e,"sendHitTask",this.sendHitTaskOverride);try{this.dateTimeFormatter=new Intl.DateTimeFormat("en-US",{timeZone:this.timeZone})}catch(r){}let n={hitTime:0,isExpired:!1};this.store=gs.getOrCreate(e.get("trackingId"),"session",n),this.store.get().id||this.store.set({id:Ai()})}getId(){return this.store.get().id}isExpired(e=this.getId()){if(e!=this.getId())return!0;let t=this.store.get();if(t.isExpired)return!0;let i=t.hitTime;if(i){let n=new Date,r=new Date(i);if(n-r>this.timeout*Cm||this.datesAreDifferentInTimezone(n,r))return!0}return!1}datesAreDifferentInTimezone(e,t){return this.dateTimeFormatter?this.dateTimeFormatter.format(e)!=this.dateTimeFormatter.format(t):!1}sendHitTaskOverride(e){return t=>{e(t);let i=t.get("sessionControl"),n=i=="start"||this.isExpired(),r=i=="end",o=this.store.get();o.hitTime=Je(),n&&(o.isExpired=!1,o.id=Ai()),r&&(o.isExpired=!0),this.store.set(o)}}destroy(){se.remove(this.tracker,"sendHitTask",this.sendHitTaskOverride),this.store.destroy(),delete Cn[this.tracker.get("trackingId")]}};vs.DEFAULT_TIMEOUT=30;var ba={CLEAN_URL_TRACKER:1,EVENT_TRACKER:2,IMPRESSION_TRACKER:3,MEDIA_QUERY_TRACKER:4,OUTBOUND_FORM_TRACKER:5,OUTBOUND_LINK_TRACKER:6,PAGE_VISIBILITY_TRACKER:7,SOCIAL_WIDGET_TRACKER:8,URL_CHANGE_TRACKER:9,MAX_SCROLL_TRACKER:10},oc=Object.keys(ba).length;function ac(s,e){Om(s),Lm(s,e)}function Am(s){return parseInt(s||"0",16).toString(2)}function km(s){return parseInt(s||"0",2).toString(16)}function Vm(s,e){if(s.length{document.visibilityState==Se?(this.opts.sendInitialPageview&&(this.sendPageview({isPageLoad:!0}),this.isInitialPageviewSent_=!0),this.store.set({time:Je(),state:Se,pageId:Fs,sessionId:this.session.getId()})):this.opts.sendInitialPageview&&this.opts.pageLoadsMetricIndex&&this.sendPageLoad()})}handleChange(){if(!(document.visibilityState==Se||document.visibilityState==Ii))return;let e=this.getAndValidateChangeData(),t={time:Je(),state:document.visibilityState,pageId:Fs,sessionId:this.session.getId()};document.visibilityState==Se&&this.opts.sendInitialPageview&&!this.isInitialPageviewSent_&&(this.sendPageview(),this.isInitialPageviewSent_=!0),document.visibilityState==Ii&&this.visibleThresholdTimeout_&&clearTimeout(this.visibleThresholdTimeout_),this.session.isExpired(e.sessionId)?(this.store.clear(),this.lastPageState==Ii&&document.visibilityState==Se&&(clearTimeout(this.visibleThresholdTimeout_),this.visibleThresholdTimeout_=setTimeout(()=>{this.store.set(t),this.sendPageview({hitTime:t.time})},this.opts.visibleThreshold))):(e.pageId==Fs&&e.state==Se&&this.sendPageVisibilityEvent(e),this.store.set(t)),this.lastPageState=document.visibilityState}getAndValidateChangeData(){let e=this.store.get();return this.lastPageState==Se&&e.state==Ii&&e.pageId!=Fs&&(e.state=Se,e.pageId=Fs,this.store.set(e)),e}sendPageVisibilityEvent(e,{hitTime:t}={}){let i=this.getTimeSinceLastStoredChange(e,{hitTime:t});if(i&&i>=this.opts.visibleThreshold){let n=Math.round(i/hc),r={transport:"beacon",nonInteraction:!0,eventCategory:"Page Visibility",eventAction:"track",eventValue:n,eventLabel:ma};t&&(r.queueTime=Je()-t),this.opts.visibleMetricIndex&&(r["metric"+this.opts.visibleMetricIndex]=n),this.tracker.send("event",En(r,this.opts.fieldsObj,this.tracker,this.opts.hitFilter))}}sendPageLoad(){let e={transport:"beacon",eventCategory:"Page Visibility",eventAction:"page load",eventLabel:ma,["metric"+this.opts.pageLoadsMetricIndex]:1,nonInteraction:!0};this.tracker.send("event",En(e,this.opts.fieldsObj,this.tracker,this.opts.hitFilter))}sendPageview({hitTime:e,isPageLoad:t}={}){let i={transport:"beacon"};e&&(i.queueTime=Je()-e),t&&this.opts.pageLoadsMetricIndex&&(i["metric"+this.opts.pageLoadsMetricIndex]=1),this.tracker.send("pageview",En(i,this.opts.fieldsObj,this.tracker,this.opts.hitFilter))}trackerSetOverride(e){return(t,i)=>{let n=nc(t)?t:{[t]:i};n.page&&n.page!==this.tracker.get("page")&&this.lastPageState==Se&&this.handleChange(),e(t,i)}}getTimeSinceLastStoredChange(e,{hitTime:t}={}){return e.time?(t||Je())-e.time:0}handleExternalStoreSet(e,t){e.time!=t.time&&t.pageId==Fs&&t.state==Se&&!this.session.isExpired(t.sessionId)&&this.sendPageVisibilityEvent(t,{hitTime:e.time})}handleWindowUnload(){this.lastPageState!=Ii&&this.handleChange()}remove(){this.store.destroy(),this.session.destroy(),se.remove(this.tracker,"set",this.trackerSetOverride),window.removeEventListener("unload",this.handleWindowUnload),document.removeEventListener("visibilitychange",this.handleChange)}};va("pageVisibilityTracker",xa);El();Xt.addClass((b.isMobile?"is":"not")+"-mobile");b.isSafari&&Xt.addClass("is-safari");setTimeout(()=>Xt.addClass("ready"));window.addEventListener("keydown",s=>{s.keyCode===9&&Xt.addClass("is-tabbing")});window.addEventListener("mousedown",()=>{Xt.removeClass("is-tabbing")});var lc=A(".cookie-warning");lc&&A("#yes-to-cookies").on("click",function(){lc.exit("pop",300),b.setCookie("cookie_consent",1)});var $a=A("x-modal#privacy");$a&&$a.$("form").on("submit",s=>{s.preventDefault(),fetch("/profile/accept-policies",{method:"POST"}),$a.close()});var pc;(pc=navigator.serviceWorker)==null||pc.register("/service_worker.js",{scope:"/"}).catch(()=>console.warn("Unable to register Service Worker."));var dc;(dc=A("#skip-nav"))==null||dc.on("click",()=>{var e;(e=(A("article")||A(".panel.active")||A(".body")||C).$("input, button, a, textarea, [contenteditable], [tabindex]"))==null||e.focus()});var Pa=A("nav x-popup");if(Pa){let s=Pa.$$(".popup-body a, .popup-body button");for(let e of s)e.on("click",()=>Pa.close())}var Rm=Pe("#language .locale-link");Mi.on("change",s=>{for(let e of Rm)e.setAttr("href",e.data.host+s)});var An=A("#dark-mode");An&&(An.checked=b.theme.isDark,An.on("change",()=>b.setTheme(An.checked?"dark":"light")));var Li={},ws=A("#search"),ts=ws==null?void 0:ws.$(".form-field input"),kn=ws==null?void 0:ws.$(".search-body");Li[""]=(kn==null?void 0:kn.html)||"";function Dm(s){return s=s.trim().replace(/\s+/," ").toLowerCase().slice(0,50),s==="pi"||s.length>=3?s:""}function Nm(s){return D(this,null,function*(){if(s=encodeURIComponent(Dm(s)),s in Li)return Li[s];let e=yield fetch(`/api/search?q=${s}`);return e.ok?Li[s]=yield e.text():Li[s]=""})}var Gm=0,cc=0;function uc(s){return D(this,null,function*(){let e=Gm+=1,t=yield Nm(s);e<=cc||(cc=e,kn.html=t)})}ts==null||ts.change(s=>{b.setCookie("search",s,60*60*24),setTimeout(()=>{ts.value===s&&uc(s)},300)});ts!=null&&ts.value&&ws.one("open",()=>uc(ts.value));var fc='';function mc(s){if(s.match("^[0-9]+/[0-9]+$")){let e=s.split("/");return+e[0]/+e[1]}else return Uh(s)}var Vn=class extends E{constructor(){super(...arguments);this.solution="";this.solutionNum=NaN;this.solutionDisplay="";this.range=0;this.input="";this.hint="";this.attempts=0;this.placeholder="???";this.done=!1}ready(){if(this.$input=this.$("input"),this.$target=this.$(".target"),this.solution=this.attr("solution"),this.solution.indexOf("\xB1")>=0){let t=this.solution.split("\xB1");this.solution=t[0].trim(),this.range=+t[1]}this.solutionNum=mc(this.solution),this.solutionDisplay=this.solution,this.hint=this.attr("hint"),this.removeAttr("solution"),this.removeAttr("hint"),this.$input.setInputPattern(this.solution),this.hasAttr("placeholder")&&(this.placeholder=this.attr("placeholder")),this.$input.setAttr("placeholder",this.placeholder),this.removeAttr("placeholder"),this.$input.change(t=>{this.input=t,this.isCorrect&&(this.solve(),this.trigger("valid",t),this.moveCursor())}),this.$input.onKey("Enter",()=>this.$input.blur()),this.$input.on("focus",()=>{this.addClass("on"),this.removeClass("invalid"),this.$input.setAttr("placeholder"," ")}),this.$input.on("blur",()=>{if(this.removeClass("on"),this.setClass("invalid",!!this.input&&!this.done),this.$input.setAttr("placeholder",this.placeholder),this.input&&!this.done){this.attempts+=1;let t=this.attempts>=(this.hint?4:3)?`Hmmm\u2026 maybe try ${this.solution}?`:this.attempts>=2?this.hint:void 0;this.trigger("invalid",{hint:t})}})}setup(t,i,n){var r;this.goal=i,this.$step=t,(r=n==null?void 0:n.scores)!=null&&r.includes(i)&&this.solve(!0),this.one("valid",()=>{t.addHint("correct"),t.score(this.solvedBlank?this.solvedBlank.goal:i)}),this.on("invalid",o=>t.addHint(o.hint||"incorrect",{class:"incorrect"}))}get isCorrect(){if(this.done)return!0;if(this.linkedBlanks){let t=this.linkedBlanks.map(i=>i.solvedBlank);return this.solvedBlank=this.linkedBlanks.find(i=>{if(i.done&&!i.solvedBlank||t.includes(i))return!1;if(i.checkAnswer(this.input))return!0}),this.solvedBlank&&(this.solutionDisplay=this.solvedBlank.solution),!!this.solvedBlank}return this.checkAnswer(this.input)}checkAnswer(t){let i=mc(t);return t.toLowerCase()===this.solution.toLowerCase()?!0:this.range&&Math.abs(i-this.solutionNum)<=this.range?(this.solutionDisplay=t,!0):x(i,this.solutionNum)||No(i)===this.solution||t===No(this.solutionNum)}moveCursor(){if(!this.$step)return;let t=this.$step.$blanks[this.$step.$blanks.indexOf(this)+1];!t||t.done||t.tagName==="X-BLANK-MC"||t.css("visibility")==="hidden"||!t.bounds.width||t.focus()}solve(t=!1){this.done=!0,this.$input.remove(),this.$target.html=this.solutionDisplay,this.addClass("done"),this.trigger("solve",{solution:this.solutionDisplay,restore:t})}focus(){this.$input.focus()}blur(){this.$input.blur()}};Vn=T([S("x-blank",{template:fc})],Vn);var gc='???';var In=class extends E{constructor(){super(...arguments);this.done=!1}ready(){this.$target=this.$(".target"),this.$popup=this.$(".popup");let t=this.$popup.$$(".choice");this.solution=t[0].html,_t.shuffle(re(t.length)).forEach(r=>{this.$popup.append(t[r]),t[r].on("click",()=>{this.removeClass("on"),t[r].blur(),r?(this.$target.html=t[r].html,this.addClass("invalid"),this.trigger("invalid")):(this.solve(),this.trigger("valid",this.solution))})});let n=this.$target.bounds.left+this.$popup.width>b.width-15;this.setClass("left",n),zs(this,{enter:()=>{if(this.done)return;this.addClass("on");let r=this.$target.bounds,o=this.$popup.width,a=this.$popup.height,h=b.width-10-r.left,l=o10,u=r.top+r.height+a>b.height-10;this.setClass("left",c&&!l),this.setClass("top",u),this.$popup.css("max-width",!c&&!l?`${h}px`:"none")},exit:()=>{this.removeClass("on")},delay:100,exitDelay:400,$clickTarget:this.$target})}setup(t,i,n){var r;(r=n==null?void 0:n.scores)!=null&&r.includes(i)&&this.solve(!0),this.one("valid",()=>{t.addHint("correct"),t.score(i)}),this.on("invalid",o=>t.addHint(o.hint||"incorrect",{class:"incorrect"}))}solve(t=!1){this.done=!0,this.$target.html=this.solution,this.removeClass("on invalid"),this.addClass("done"),this.trigger("solve",{solution:this.solution,restore:t}),setTimeout(()=>this.$popup.remove(),250),this.$target.removeAttr("tabindex")}};In=T([S("x-blank-mc",{template:gc})],In);var vc='
';var wc=40,yc="free-text",Ln=class extends E{setup(e,t,i){var l,c;let n=this.$(".text-area"),r=this.$(".toolbar .submit"),o=((l=i==null?void 0:i.data)==null?void 0:l[yc])||"";o&&(n.html=o);for(let u of this.$$(".toolbar .command")){let d=u.data.command.split(":");u.on("click",()=>document.execCommand(d[0],!1,d[1]))}let a=o,h=ge(()=>{a!==o&&e.storeData(yc,o),a=o},5e3);n.on("change keyup input paste",()=>{o=n.html.replace(/ /g," ").trim().slice(0,500).trim(),r.setClass("invisible",o.length{h(),e.score(t),r.exit("pop"),this.trigger("submit")}))}};Ln=T([S("x-free-text",{template:vc})],Ln);var bc='
';var On=class extends E{ready(){let e=this.$(".wrapper"),t=this.$(".panel"),i=t.children,n=this.$(".next"),r=this.$(".back"),o=this.$(".dots"),a=i.map(()=>m("div",{class:"dot"},o)),h=i.length,l=+this.attr("slide-width")||void 0,c=this.width,u=1,d=c,g=0,y=0,f=pt=>{y=pt,t.translate(pt,0),this.trigger("move",pt)},v=pt=>{g=pt;for(let[me,gi]of a.entries())gi.setClass("on",me>=pt&&me{c=this.width,u=l?Math.ceil(c/l):1,d=c/u;for(let pt of i)pt.css("width",d+"px");t.css("width",h*d+"px"),f(-g*d),v(g)});let w="quad",$=500,L,k,M,P,j=!1,Ue=()=>{L=Date.now()-P,f(k+M*St(w,L/$)),!j&&L<$?requestAnimationFrame(Ue):this.trigger("slide-end")},xo=pt=>{j=!1,L=0,k=y,M=-pt*d-y,P=Date.now(),v(pt),Ue()};n.on("click",()=>{w="quad",g{w="quad",g>0&&xo(g-1)});let Ch,$o,Po,tn;ds(e,{start:pt=>{j=!0,Ch=y,$o=pt.x,tn=Po=$o},move:pt=>{Po=tn,tn=pt.x;let me=Ch-$o+pt.x,gi=-(h-u)*d,qd=me>0?me/4:me{let pt=tn-Po,me=pt>12?1:pt<-12?-1:0;w="quad-out",xo(B(Math.round(-y/d-me),0,h-u)),setTimeout(()=>this.css("pointer-events","auto"))}})}};On=T([S("x-gallery",{template:bc})],On);var xc='';function Ta(s,e){let t=e.positionLeft-s.positionLeft+e.width/2,i=e.positionTop-s.positionTop+e.height/2;return new p(t,i)}function $c(s){return s?new p(...s.split(",").map(e=>+e)):void 0}var Rn=class extends E{constructor(){super(...arguments);this.doAnimation=!1}created(){this.slide=$c(this.attr("slide")),this.shift=$c(this.attr("offset"))}ready(){this.$target=A(this.attr("target")),this.$target&&(this.$target.on("click pointerdown focus",()=>this.stop()),this.hasAttr("start")&&this.start())}setTarget(t,i,n){this.$target=typeof t=="string"?A(t):t,i&&(this.slide=i),n&&(this.slide=n)}start(t){this.doAnimation||!this.from&&!this.$target||(this.doAnimation=!0,t&&(this.slide=t),this.slide||this.$end?this.runSlideAnimation():this.runClickAnimation())}startSlide(t,i){this.$target=t,this.$end=i,this.start()}stop(){this.doAnimation=!1}runSlideAnimation(){return D(this,null,function*(){this.show();let t=this.from||Ta(this,this.$target);this.shift&&(t=t.add(this.shift));let i=this.slide?t.add(this.slide):Ta(this,this.$end),n=`translate(${t.x-15}px,${t.y-10}px)`,r=`translate(${i.x-15}px,${i.y-10}px)`;yield this.animate({transform:[n+" scale(2)",n],opacity:[0,1]},300).promise,yield this.animate({transform:[n,r]},1e3).promise,yield this.animate({transform:[r,r+" scale(2)"],opacity:[1,0]},300).promise,this.hide(),setTimeout(()=>{this.doAnimation&&this.runSlideAnimation()},1e3)})}runClickAnimation(){return D(this,null,function*(){this.show();let t=this.from||Ta(this,this.$target);this.shift&&(t=t.add(this.shift));let i=`translate(${t.x-15}px,${t.y-10}px)`;yield this.animate({transform:[i+" scale(2)",i],opacity:[0,1]},500).promise,yield this.animate({transform:[i,i+" scale(2)"],opacity:[1,0]},500,200).promise,this.hide(),setTimeout(()=>{this.doAnimation&&this.runClickAnimation()},1e3)})}};Rn=T([S("x-gesture",{template:xc})],Rn);var Sa='';var zm=JSON.parse(A("#glossary").text),Bm=JSON.parse(A("#bios").text),Ea=600,Nn;b.onResize(()=>{Nn&&Nn.hide()});var Oi=class extends E{ready(){this.xid=this.attr("xid"),this.$target=this.$(".target"),this.$popup=this.$(".popup"),this.$popup.html=this.body()||"",this.setClass("left",b.width>Ea&&this.$target.bounds.left+this.$popup.width>b.width-15),zs(this,{enter:()=>this.show(),exit:()=>this.hide(),delay:100,exitDelay:200,$clickTarget:this.$target,canFocusWithin:!0,preventMouseover:()=>b.width<=Ea})}show(){if(Nn=this,this.addClass("on"),b.width<=Ea){let a=A("#glossary-modal");return a.$(".modal-body").html=this.body(),a.open()}let t=this.$target.bounds,i=this.$popup.width,n=this.$popup.height,r=t.top+t.height+n54;this.setClass("top",o&&!r),this.setClass("left",t.left+i>b.width-15)}hide(){Nn=void 0,this.removeClass("on")}body(){let t=zm[this.xid];if(!t)return console.warn("missing gloss:",this.xid);let i=t.text;return t.image&&(i+=``),t.link&&(location.pathname===t.link.split("#")[0]||(i+=`

Learn more\u2026

`)),i}};Oi=T([S("x-gloss",{template:Sa})],Oi);var Dn=class extends Oi{body(){let e=Bm[this.xid];if(!e)return console.warn("missing bio:",this.xid);let t=``,i=e.born?`

Timeline

`:"";return(e.image===!1?"":t)+e.bio+i}};Dn=T([S("x-bio",{template:Sa})],Dn);var Pc='
';var _m=document.createElement("a").relList.supports("ar"),zn=!1,Ma={x:0,y:0,s:1},Tc,ys=m("div",{class:"lightbox-overlay"},C),Ne=m("div",{class:"lightbox-img"},ys);function qm(s,e,t){zn=!0,Tc=s,ys.show(),Ne.show();let i=s.bounds,n=Ne.bounds,r=i.left+i.width/2-n.left-n.width/2,o=i.top+i.height/2-n.top-n.height/2,a=Math.max(i.width/n.width,i.height/n.height);Ma={x:r,y:o,s:a},Ne.css("background-image",`url(${t}), url(${e})`),Ne.css("transform",`translate(${r}px, ${o}px) scale(${a})`),b.redraw(),Ne.addClass("transitions"),b.redraw(),s.css("visibility","hidden"),ys.addClass("on"),Ne.css("transform","scale(1) translate(0,0)")}function Sc(){zn&&(zn=!1,ys.removeClass("on"),Ne.setTransform(Ma,0,Ma.s),setTimeout(()=>{Tc.css("visibility","visible"),ys.css("display","none"),Ne.css("transform","none"),Ne.removeClass("transitions")},400))}ys.on("click touchmove",Sc);C.onKey("Escape",Sc);ys.on("scrollwheel touchmove",s=>{s.preventDefault(),s.stopPropagation()});C.onKey("Space AllArrows PageDown PageUp",s=>{zn&&(s.preventDefault(),s.stopPropagation())});var Gn=class extends E{ready(){let e=this.attr("src"),t=this.$(".wrap"),i=this.attr("width"),n=this.attr("height");this.css("width",i+"px"),t.css("padding-bottom",+n/+i*100+"%");let r=t.$("img");r.setAttr("src",e),r.setAttr("alt",this.attr("alt")||""),r.setAttr("width",i),r.setAttr("height",n),e.endsWith(".gif")&&r.on("click",()=>r.setAttr("src",e));let o=t.$(".credit"),a=this.attr("credit");a?o.text=a:o.remove();let h=t.$(".zoom");if(this.hasAttr("lightbox")){this.addClass("interactive");let l=e.replace(/\.(?=[^.]*$)/,"-large.");this.on("click",()=>qm(this,e,l))}else h.remove();if(_m&&this.hasAttr("ar")){let l=m("a",{href:this.attr("ar"),rel:"ar"});t.prepend(l),l.append(r)}}};Gn=T([S("x-img",{template:Pc})],Gn);var Bn=class extends E{constructor(){super(...arguments);this.correctCount=0;this.solvedCount=0;this.isSolved=!1}setup(t,i,n){var h;let r=this.children,o=r.map(()=>!1);for(let[l,c]of r.entries()){let u=c.data.error,d=u?"incorrect":"correct";u||(this.correctCount+=1),c.one("click",()=>{o[l]||this.isSolved||(t.addHint(u||"correct",{class:d}),c.addClass(d),u||(this.solvedCount+=1,t.score("picker-"+l),this.checkSolved()))})}let a=((h=n==null?void 0:n.scores)==null?void 0:h.filter(l=>l.startsWith("picker-")))||[];for(let l of a){let c=+l.slice(7);o[c]=!0,r[c].addClass("correct")}this.solvedCount=a.length,this.checkSolved()}checkSolved(){this.solvedCountthis.steps=+a),this.speed=+this.attr("speed")||1;let t=this.$(".bar"),i=this.$(".knob"),n=this.$(".play");this.hasAttr("no-play")?n.remove():n.on("click",()=>this.play());let r=this.hasAttr("continuous"),o=this.hasAttr("snap")?t.width/this.steps:.001;this.drag=new fs(i,{moveY:!1,snap:o}),this.drag.on("start",()=>{this.animation&&this.animation.cancel(),this.animation=void 0}),this.drag.on("move",({posn:a})=>{let h=a.x/this.drag.bounds.dx*this.steps;r||(h=Math.round(h)),!x(h,this.current)&&(this.current=h,this.trigger("move",h))}),this.drag.on("end",()=>this.trigger("slide-end"))}setup(t,i){this.bindModel(t.model),this.one("slide-end",()=>t.score(i))}set(t){x(t,this.current)||this.drag.setPosition(t*this.drag.bounds.dx/this.steps,0)}play(){return D(this,null,function*(){this.current>=this.steps&&this.set(0);let t=(1-this.current/this.steps)*3e3/this.speed;this.moveTo(this.steps,t)})}moveTo(t,i=600){return D(this,null,function*(){if(this.animation||t===this.current)return;let n=this.current;this.animation=mt(r=>{this.set(n+(t-n)*St("quad",r))},i),yield this.animation.promise,this.animation=void 0,this.trigger("slide-end")})}bindVariable(t,i){t[i]=0,this.on("move",n=>t[i]=n),t.watch(()=>this.set(t[i]))}};_n=T([S("x-slider",{template:Ec})],_n);var Mc='
';function Fm(s){let e=s.$$("x-blank, x-blank-mc");if(!e.length)return Promise.resolve();let t=0;return new Promise(i=>{for(let n of e)n.on("solve",()=>{t+=1,t>=e.length&&i()})})}var qn=class extends E{constructor(){super(...arguments);this.length=0;this.current=0;this.locked=!1}ready(){this.$legend=this.$(".legend-box"),this.$steps=this.$legend.children,this.$back=this.$(".back"),this.$next=this.$(".next");let t=this.$(".dots");this.$dots=this.$steps.map(()=>m("div",{class:"dot"},t)),this.length=this.$steps.length,this.current=0,this.$back.on("click",()=>this.goBack()),this.$next.on("click",()=>this.goNext()),this.blanks=this.$steps.map(i=>Fm(i)),this.reveals=this.$$("[slide]").map(i=>{let n=i.attr("slide").split("-"),r=n.length>1?[+n[0]||0,+n[1]||this.length]:[+n[0],+n[0]],o=[i.data.animation||"fade",+i.data.duration||400];return i.data.display="visibility",r[0]>=0&&!i.hasClass("reveal")&&i.hide(),[i,r,o]}),this.autoAdvance=this.attr("step")==="auto",this.$steps[0].show(),this.$dots[0].addClass("on"),this.setupSlide(0)}setup(t,i,n){var o;let r=(o=n==null?void 0:n.scores)==null?void 0:o.filter(a=>a.startsWith("slide-")).length;if(r&&rt.score("slide-"+(a-1)))}go(t){if(this.locked||t<0||t>this.length-1||t===this.current)return;this.locked=!0,setTimeout(()=>this.locked=!1,600),this.$back.setClass("disabled",t===0),this.$next.setClass("disabled",t===this.length-1),this.$dots[this.current].removeClass("on"),this.$dots[t].addClass("on"),this.$steps[t].show();let i=this.$steps[t].height+"px";this.$steps[t].hide(),this.$steps[this.current].exit("fade",300).promise.then(()=>this.$steps[t].enter("fade",300)),this.$legend.animate({height:i},600).promise.then(()=>this.$legend.css("height","auto")),this.setupSlide(t),this.current=t,this.trigger("step",t)}setupSlide(t){this.$next.setAttr("disabled","true"),this.blanks[t].then(()=>this.$next.removeAttr("disabled"));for(let[i,n,r]of this.reveals){if(i.hasClass("reveal"))continue;let o=i.css("visibility")!=="hidden",a=t>=n[0]&&t<=n[1];a&&!o&&i.enter(...r,300),!a&&o&&i.exit(...r)}}goNext(){this.locked||(this.go(this.current+1),this.trigger("next",this.current))}goBack(){this.locked||(this.go(this.current-1),this.trigger("back",this.current))}};qn=T([S("x-slideshow",{template:Mc})],qn);var Fn=class extends E{ready(){var g,y;(g=A(".sidebar-toggle"))==null||g.on("click",()=>this.addClass("open")),(y=A(".sidebar-shadow"))==null||y.on("pointerdown",()=>this.removeClass("open"));let e=A("#feedback form"),t=A("#feedback button"),i=A("#feedback .error"),n=A("#feedback-success"),r=A('#feedback textarea[name="message"]'),o=A("x-course").id;e==null||e.on("submit",f=>{f.preventDefault(),t.setAttr("disabled","true"),i.hide(),De(`/course/${o}/feedback`,e.formData).then(()=>{n.open(),r.value=""}).catch(()=>i.show()).then(()=>t.removeAttr("disabled"))});let a=JSON.parse(A("#glossary").text),h=A("#glossary-search"),l=h.$(".gloss-body"),c=h.$(".gloss-list"),u=h.$(".gloss-search input"),d;for(let f of Object.keys(a).sort()){let v=a[f],w=m("div",{class:"gloss-item",html:v.title,tabindex:0},c);w.on("click",()=>{d&&d.removeClass("on"),d=w,w.addClass("on"),l.html=v.text});let $=v.title.toLowerCase();u.change(L=>w.setClass("hidden",!!L&&$.indexOf(L.toLowerCase())<0))}}};Fn=T([S("x-course-sidebar")],Fn);function Ca(s,e){let t=as(s.map(i=>i.h+10));for(let[i,n]of s.entries())n.drag.bounds=new lt(0,0,0,O(t)),n!==e&&n.drag.setPosition(0,t[i-1]||0)}function Hm(s){return s.every((e,t)=>e.index===t)||s.every((e,t)=>e.index===s.length-t-1)}var Hn=class extends E{ready(){this.items=this.children.map(t=>({drag:new fs(t,{moveX:!1,useTransform:!0}),index:+t.data.index,h:0}));for(let t of this.children)t.removeAttr("data-index");for(let t of this.items)t.drag.on("drag",()=>{this.items=wi(this.items,i=>i.drag.position.y-(i===t?10:0)),Ca(this.items,t)}),t.drag.on("end",()=>{Ca(this.items),Hm(this.items)&&this.solve()});b.onResize(()=>{for(let i of this.items)i.h=i.drag.$el.height;let t=N(this.items.map(i=>i.h));this.css("height",t+this.items.length*10-10+"px"),Ca(this.items)})}setup(t,i,n){var r;(r=n==null?void 0:n.scores)!=null&&r.includes(i)&&this.solve(),this.one("solve",()=>{t.addHint("correct"),t.score(i)})}solve(){this.trigger("solve"),this.addClass("solved");for(let t of this.items)t.drag.disabled=!0}};Hn=T([S("x-sortable")],Hn);function Cc(s,e=!1){return D(this,null,function*(){if(s.css("visibility")==="visible")return;s.data.display="visibility";let t=+s.data.duration||400,i=(e?0:600)+(+s.data.delay||0);yield s.enter(s.data.animation||"fade",t,i).promise,s.css({opacity:"",transform:""}),s.trigger("reveal"),s.removeClass("reveal")})}var jn=class extends E{constructor(){super(...arguments);this.model=he({});this.isShown=!1;this.isCompleted=!1;this.scores=new Set}ready(){var i,n,r,o;this.$course=this.parents("x-course")[0],this.$blanks=this.$$("x-blank, x-blank-mc"),this.$components=this.$$("[goal]"),this.userData=(r=(n=(i=this.$course)==null?void 0:i.userData)==null?void 0:n.steps)==null?void 0:r[this.id],this.goals=K(this.attr("goals")),this.$reveals=this.$$(".reveal");let t=this.$$(".check[data-when]");for(let a of[...this.$reveals,...t])this.onScore(a.data.when,()=>Cc(a));this.$nextBtn=this.$$(".next-step");for(let[a,h]of this.$nextBtn.entries())this.onScore("next-"+a,()=>h.exit("pop")),h.one("click",()=>this.score("next-"+a));for(let a of this.$$(".step-target"))a.tagName!=="X-TARGET"&&zs(a,{enter:()=>{let h=this.$$('[target~="'+a.data.to+'"]');for(let l of h)l.addClass("focus");this.addClass("focus"),this.trigger("target-focus",{$targets:h})},exit:()=>{for(let h of this.$$(".focus"))h.removeClass("focus");this.removeClass("focus")}});for(let a of this.$$(".var, .var-action"))a.bindModel(this.model);(o=this.$course)!=null&&o.audio&&(this.narration=new Pn(this.$course.audio,this))}show(){var n,r,o;if(this.isShown)return;this.isShown=!0,(n=StepFunctions==null?void 0:StepFunctions[en(this.id)])==null||n.call(StepFunctions,this);for(let a of this.$components)a.setup(this,a.attr("goal"),this.userData);let t=((r=this.userData)==null?void 0:r.scores)||[];for(let a of t)this.score(a,!1);let i=this.$$("x-gesture[target]");setTimeout(()=>{if(!this.isReady)for(let a of i)a.start()},2e3),(o=this.$course)==null||o.log("Step","show",this.id),this.trigger("show"),this.addClass("on"),this.narration&&setTimeout(()=>this.narration.play(),400)}complete(){if(!this.isCompleted){this.isShown||this.show(),this.isCompleted=!0;for(let t=0;tthis.scores.has(t))}get isPageLoaded(){return this.$course?this.$course.isReady:!0}score(t,i=!0){this.scores.has(t)||(this.scores.add(t),this.trigger("score-"+t),this.trigger("score"),this.$course&&(this.$course.trigger("score"),this.$course.saveProgress({steps:{[this.id]:{scores:[t]}}}),this.$course.log("Step","score",this.id+"/"+t)),i&&this.isReady&&this.$course&&this.$course.isReady&&setTimeout(()=>{this.$course.$activeStep===this&&this.$course.nextStep()},1200))}storeData(t,i){var n;(n=this.$course)==null||n.saveProgress({steps:{[this.id]:{data:{[t]:i}}}})}onScore(t,i){let n=K(t);if(n.every(a=>this.scores.has(a)))return i&&i(),Promise.resolve();let r=Ke(),o=()=>{n.every(a=>this.scores.has(a))&&(i&&i(),r.resolve(),this.off("score",o))};return this.on("score",o),r.promise}addHint(t,i={}){var n,r,o;return this.trigger("hint",t),(n=this.$course)!=null&&n.isReady?this.isInViewport?(r=this.$course.$tutor)==null?void 0:r.showHint(t,i):(this.one("enterViewport",()=>{var a;return(a=this.$course.$tutor)==null?void 0:a.showHint(t,i)}),{text:((o=this.$course.$tutor)==null?void 0:o.hints[t])||t}):{text:t}}delayedHint(t,i=1e4){let n=setTimeout(t,i);this.on("score",()=>{clearTimeout(n),this.isCompleted||(n=setTimeout(t,i))}),this.on("complete",()=>clearTimeout(n))}get nextStep(){if(!this.$course)return;let t=this.$course.$steps.indexOf(this);return this.$course.$steps[t+1]}groupBlanks(...t){let i=t.map(n=>this.$blanks[n]);for(let n of i)n.linkedBlanks=i}};jn=T([S("x-step")],jn);var jm='
',Un=class extends E{constructor(){super(...arguments);this.$titles=[];this.active=0}ready(){let t=this.$(".titles");this.$body=this.$(".body"),this.$tabs=this.$$(".tab");for(let i=0;ithis.makeActive(i))}this.$titles[0].addClass("active"),this.$tabs[0].show()}makeActive(t){if(this.active===t)return;this.$titles[this.active].removeClass("active"),this.$titles[t].addClass("active"),this.$tabs[t].show();let i=this.$tabs[t].outerHeight+"px";this.$tabs[t].hide(),this.$tabs[this.active].exit("fade",300).promise.then(()=>this.$tabs[t].enter("fade",300)),this.$body.animate({height:i},600).promise.then(()=>this.$body.css("height","auto")),this.active=t,this.trigger("change",t)}};Un=T([S("x-tabbox",{template:jm})],Un);var Ac='';function Um(s,e,t,i){let n=new p(s.left-15,s.top+t-15),r=new G(n,s.width+30,s.height+30),o=new p(e.left-15,e.top+i-15),a=new G(o,e.width+30,e.height+30),h=new Y(r.center,a.center);return[Q(h,r)[0],Q(h,a)[0]]}function Wm(s,e){return Math.abs(s[0]-e[0])+Math.abs(s[1]-e[1])}var kc=Pe("header, x-tutor, .sidebar"),js=m("svg",{class:"target-body",html:Ac},C),Km=js.$("mask"),Xm=js.$(".target-arrow"),Hs=!1,Vc=[],Wn=class extends E{ready(){this.setAttr("tabindex",0);let e=this.attr("to").replace(/_/g," "),t=this.hasClass("no-margins"),i,n,r,o,a=()=>{Hs=!0;let u=Pe(e);if(!u.length)return;let d=u[0].hasParent(...kc);i===void 0&&(i=this.hasParent(...kc));let g=this.bounds,y=u.map(f=>f.bounds).filter(f=>f.width||f.height);if(r=0,!d){let f=Math.min(...y.map(L=>L.top)),v=Math.max(...y.map(L=>L.top+L.height)),w=b.height-12-v,$=56-f;r=w<0?w:$>0?$:0}for(let f of Vc)f.remove();Vc=[g,...y].map((f,v)=>{let w=!v||t?4:10;return m("rect",{x:f.left-w,y:f.top-w+(v||!i?r:0),width:f.width+2*w,height:f.height+2*w,rx:v?4:18,ry:v?4:18},Km)}),Xm.points=Um(g,y[0],i?0:r,d?0:r)},h=()=>{r&&C.scrollBy(-r,300),js.css("display","block"),b.redraw(),Zt(function(){js.css("opacity",1)},r?300:0)},l=u=>{Hs&&(u&&_(u.type,"mousemove","pointermove")&&Wm(n,[u.clientX,u.clientY])<40||(clearTimeout(o),Hs=!1,js.css("opacity",0),setTimeout(()=>{Hs||js.css("display","none")},300),C.off("mousewheel mousemove touchend touchmove",l),this.off("mouseleave blur",l)))},c=()=>{r&&!i?C.on("mousemove",l):this.on("mouseleave",l),C.on("mousewheel touchend touchmove",l),this.on("blur",l)};this.on("mouseenter touchstart focus",u=>{n=[u.clientX,u.clientY],a(),o=window.setTimeout(h,r?50:30),c()}),this.on("click",u=>{Hs?(u.handled=!0,l(),setTimeout(()=>A(e).trigger("click mousedown"))):(Hs=!0,r=0,h(),c())})}};Wn=T([S("x-target")],Wn);var rt=class le extends Error{constructor(e,t){super(t),this.name=e}static undefinedVariable(e){return new le("EvalError",`Undefined variable \u201C${e}\u201D.`)}static undefinedFunction(e){return new le("EvalError",`Undefined function \u201C${e}\u201D.`)}static uncallableExpression(e){return new le("EvalError",`Cannot call \u201C${e}\u201D.`)}static evalLoop(e){return new le("EvalError",`Loop in nested evaluation \u201C${e}\u201D.`)}static invalidCharacter(e){return new le("SyntaxError",`Unknown symbol \u201C${e}\u201D.`)}static conflictingBrackets(e){return new le("SyntaxError",`Conflicting brackets \u201C${e}\u201D.`)}static unclosedBracket(e){return new le("SyntaxError",`Unclosed bracket \u201C${e}\u201D.`)}static startOperator(e){return new le("SyntaxError",`A term cannot start with a \u201C${e}\u201D.`)}static endOperator(e){return new le("SyntaxError",`A term cannot end with a \u201C${e}\u201D.`)}static consecutiveOperators(e,t){return new le("SyntaxError",`A \u201C${e}\u201D cannot be followed by a \u201C${t}\u201D.`)}static invalidExpression(){return new le("SyntaxError","This expression is invalid.")}},Na={pi:Math.PI,\u03C0:Math.PI,e:Math.E},Ia={"(":")","[":"]","{":"}"},Ks={"*":"\xB7","**":"\u2217","//":"//","+-":"\xB1","\u2013":"\u2212","-":"\u2212",xx:"\xD7",sum:"\u2211",prod:"\u220F",int:"\u222B",del:"\u2202",grad:"\u2207",aleph:"\u2135",not:"\xAC",AA:"\u2200",EE:"\u2203","'":"\u2019","!=":"\u2260","<=":"\u2264",">=":"\u2265",in:"\u2208","!in":"\u2209","==":"\u2261","~=":"\u2245","~~":"\u2248",sub:"\u2282",sube:"\u2286",prop:"\u221D",oo:"\u221E",cap:"\u2229",cup:"\u222A","<-":"\u2190","->":"\u2192","=>":"\u21D2","<=>":"\u21D4","|->":"\u21A6",uarr:"\u2191",darr:"\u2193",lArr:"\u21D0"},Di={Gamma:"\u0393",Delta:"\u0394",Theta:"\u0398",Lambda:"\u039B",Xi:"\u039E",Pi:"\u03A0",Sigma:"\u03A3",Phi:"\u03A6",Psi:"\u03A8",Omega:"\u03A9",alpha:"\u03B1",beta:"\u03B2",gamma:"\u03B3",delta:"\u03B4",epsilon:"\u025B",zeta:"\u03B6",eta:"\u03B7",theta:"\u03B8",iota:"\u03B9",kappa:"\u03BA",lambda:"\u03BB",mu:"\u03BC",nu:"\u03BD",xi:"\u03BE",pi:"\u03C0",rho:"\u03C1",sigma:"\u03C3",tau:"\u03C4",upsilon:"\u03C5",phi:"\u03C6",chi:"\u03C7",psi:"\u03C8",omega:"\u03C9",CC:"\u2102",NN:"\u2115",QQ:"\u211A",RR:"\u211D",ZZ:"\u2124"},Bc="abcdefghijklmnopqrstuvwxyz",Ym=Bc.split(""),Zm=Bc.toUpperCase().split(""),Qm=Object.values(Di),Jm=[...Ym,...Zm,...Qm,"$"],tg="|()[]{}\xF7,!<>=*/+-\u2013\u2212~^_\u2026\xB0\u2022\u2225\u22A5'\u2220:%\u223C\u25B3",eg=Object.values(Ks),sg=[...tg,...eg],ig={_:"sub","^":"sup","//":"/","\xF7":"/"},Ic={"<":"<",">":">"};function _c(s){return s in Ic?Ic[s]:s}var ng=["abs","round","floor","ceil","max","min","mod","lcm","gcd","gcf","log","exp","ln","sqrt","root","sin","cos","tan","sec","csc","cot","cosec","cotan","arcsin","arccos","arctan","sinh","cosh","tanh","sech","csch","coth","cosech"];function $s(s){return ng.includes(s)}var Xs={"+":"plus","\u2212":"minus","\xB7":"times","\xD7":"times","/":"over","//":"divided by","%":"percent","!":"factorial","\xB1":"plus-minus","=":"equals","\u2260":"does not equal","<":"is less than",">":"is greater than","\u2264":"is less than or equal to","\u2265":"is greater than or equal to",\u03C0:"pi","\u2245":"is congruent to","\u2225":"is parallel to","\u22A5":"is perpendicular to"};for(let s of Object.keys(Di))Xs[Di[s]]=s;var qc=s=>typeof s=="number"?s:s[0],Fc=s=>typeof s=="number"?[s,s]:s,ss=class{evaluate(s={},e){return NaN}interval(s={},e){return Fc(this.evaluate(s))}substitute(s={}){return this}recursiveSubstitute(s){let e=Object.keys(s);return this.unknowns.filter(t=>e.includes(t)).length?this.substitute(s).recursiveSubstitute(s):this}get simplified(){return this}get unknowns(){return this.variables.filter(s=>!Object.prototype.hasOwnProperty.call(Na,s))}get variables(){return[]}get functions(){return[]}collapse(){return this}toString(){return""}toVoice(s={}){return""}toMathML(s={}){return""}},Aa=new Set;function La(s,e,t=!1){var i;let n=(i=e[s])!=null?i:Na[s];if(n===void 0)throw rt.undefinedVariable(s);if(typeof n=="string"||n instanceof ss){if(t||Aa.clear(),Aa.has(s))throw rt.evalLoop(s);return Aa.add(s),typeof n=="string"&&(n=Et.parse(n)),n.evaluate(e,!0)}else return typeof n=="function"?n():n}var Ni=class extends ss{constructor(s){super(),this.n=s}evaluate(){return this.n}toString(){return`${this.n}`}toVoice(){return`${this.n}`}toMathML(){return`${this.n}`}},Ys=class extends ss{constructor(s){super(),this.i=s}evaluate(s={},e){return qc(La(this.i,s,e))}interval(s={},e){return Fc(La(this.i,s,e))}toMathML(){return`${this.i}`}substitute(s={}){return s[this.i]||this}get variables(){return[this.i]}toString(){return this.i}toVoice(){return this.i in Xs?Xs[this.i]:this.i.length===1?`_${this.i}_`:this.i}},rg=class extends ss{constructor(s){super(),this.s=s}evaluate(s={},e){return qc(La(this.s,s,e))}toString(){return`"${this.s}"`}toVoice(){return this.s}toMathML(){return`${this.s}`}},Hc=class extends ss{toString(){return" "}toMathML(){return""}},Me=class extends ss{constructor(s){super(),this.o=s}toString(){return this.o.replace("//","/")}toVoice(){return Xs[this.o]||this.o}get functions(){return[this.o]}toMathML(){let s=_c(this.toString());return`${s}`}},Lc=[-1/0,1/0],Ws=[NaN,NaN],bs=Math.PI/2,Oa=Math.PI*2,at=(s,e)=>[s-Number.EPSILON,e+Number.EPSILON],xs=(...s)=>at(Math.min(...s),Math.max(...s)),og=s=>Math.abs(s[1]-s[0]);var Us=s=>isNaN(s[0])||isNaN(s[1]),Oc=s=>!isFinite(s[0])&&s[0]===s[1],ag=(s,e)=>it(e,s[0]-Number.EPSILON,s[1]+Number.EPSILON),Yn=s=>ag(s,0),Ee={add:(...s)=>s.reduce((e,t)=>e+t,0),sub:(...s)=>s.length>1?s[0]-s[1]:-s[0],mul:(...s)=>s.reduce((e,t)=>e*t,1),div:(s,e)=>s/e,abs:s=>Math.abs(s),round:s=>Math.round(s),floor:s=>Math.floor(s),ceil:s=>Math.ceil(s),max:(...s)=>Math.max(...s),min:(...s)=>Math.min(...s),mod:(s,e)=>s%e,lcm:(...s)=>Is(...s),gcd:(...s)=>be(...s),gcf:(...s)=>be(...s),sup:(s,e)=>Math.pow(s,e),log:(s,e)=>Math.log(s)/(e===void 0?1:Math.log(e)),exp:s=>Math.exp(s),ln:s=>Math.log(s),sqrt:s=>Math.sqrt(s),root:(s,e)=>Math.pow(s,1/e),sin:s=>Math.sin(s),cos:s=>Math.cos(s),tan:s=>Math.tan(s),sec:s=>1/Math.cos(s),csc:s=>1/Math.sin(s),cot:s=>1/Math.tan(s),cosec:s=>Ee.csc(s),cotan:s=>Ee.cot(s),arcsin:s=>Math.asin(s),arccos:s=>Math.acos(s),arctan:s=>Math.atan(s),sinh:s=>Math.sinh(s),cosh:s=>Math.cosh(s),tanh:s=>Math.tanh(s),sech:s=>1/Math.cosh(s),csch:s=>1/Math.sinh(s),coth:s=>1/Math.tanh(s),cosech:s=>Ee.csch(s)};function Kn(s,e){if(s[0]>0)return e[0]>=0?at(s[0]**e[0],s[1]**e[1]):xs(s[0]**e[0],s[0]**e[1],s[1]**e[0],s[1]**e[1]);let t=e[0];return Number.isInteger(t)&&t===e[1]?t===0?[Yn(s)?0:1,1]:t%2?at(s[0]**t,s[1]**t):Yn(s)?[0,Math.max(s[0]**t,s[1]**t)]:xs(s[1]**t,s[0]**t):Ws}function Rc(s,e=Oa){let t=Math.floor(s[0]/e)*e;return[s[0]-t,s[1]-t]}var q={add:(...s)=>at(N(s.map(e=>e[0])),N(s.map(e=>e[1]))),sub:(s,e)=>e!==void 0?at(s[0]-e[1],s[1]-e[0]):at(-s[1],-s[0]),mul:(s,...e)=>(e.length>1&&(e=[q.mul(...e)]),xs(s[0]*e[0][0],s[0]*e[0][1],s[1]*e[0][0],s[1]*e[0][1])),div:(s,e)=>Yn(e)?Lc:xs(s[0]/e[0],s[0]/e[1],s[1]/e[0],s[1]/e[1]),abs:s=>Yn(s)?at(0,Math.max(-s[0],s[1])):xs(Math.abs(s[0]),Math.abs(s[1])),round:s=>at(Math.round(s[0]),Math.round(s[1])),floor:s=>at(Math.floor(s[0]),Math.floor(s[1])),ceil:s=>at(Math.ceil(s[0]),Math.ceil(s[1])),max:(...s)=>at(Math.max(...s.map(e=>e[0])),Math.max(...s.map(e=>e[1]))),min:(...s)=>at(Math.min(...s.map(e=>e[0])),Math.min(...s.map(e=>e[1]))),mod:(s,e)=>{if(Us(s)||Us(e))return Ws;let t=s[0]/(s[0]<0?e[0]:e[1]);return t=t<0?Math.ceil(t):Math.floor(t),q.sub(s,q.mul(e,[t,t]))},lcm:(...s)=>xs(Is(...s.map(e=>e[0]))),gcd:(...s)=>xs(be(...s.map(e=>e[0]))),gcf:(...s)=>q.gcd(...s),sup:(s,e)=>Kn(s,e),log:(s,e)=>(e!==void 0&&q.div(q.log(s),q.log(e)),at(s[0]<=0?-1/0:Math.log(s[0]),Math.log(s[1]))),exp:s=>Kn([Math.E,Math.E],s),ln:s=>q.log(s),sqrt:s=>Kn(s,[.5,.5]),root:(s,e)=>Kn(s,q.div([1,1],e)),sin:s=>q.cos(q.sub(s,[bs,bs])),cos:s=>Us(s)||Oc(s)?Ws:og(s)>=Oa-Number.EPSILON?[-1,1]:(s=Rc(s),s[0]>Math.PI+Number.EPSILON?q.sub(q.cos(q.sub(s,[Math.PI,Math.PI]))):s[1]Us(s)||Oc(s)?Ws:(s=Rc(s,Math.PI),s[0]>bs+Number.EPSILON&&(s=q.sub(s,[Math.PI,Math.PI])),s[0]<-bs+Number.EPSILON||s[1]>bs-Number.EPSILON?Lc:at(Math.tan(s[0]),Math.tan(s[1]))),sec:s=>q.div([1,1],q.cos(s)),csc:s=>q.div([1,1],q.sin(s)),cot:s=>q.div([1,1],q.tan(s)),cosec:s=>q.csc(s),cotan:s=>q.cot(s),arcsin:s=>Us(s)||s[1]<-1||s[0]>1?Ws:at(s[0]<=-1?-bs:Math.asin(s[0]),s[1]>=1?bs:Math.asin(s[1])),arccos:s=>Us(s)||s[1]<-1||s[0]>1?Ws:at(s[1]>=1?0:Math.acos(s[1]),s[0]<=-1?Math.PI:Math.acos(s[0])),arctan:s=>at(Math.atan(s[0]),Math.atan(s[1])),sinh:s=>at(Math.sinh(s[0]),Math.sinh(s[1])),cosh:s=>s[1]<0?at(Math.cosh(s[1]),Math.cosh(s[0])):s[0]>0?at(Math.cosh(s[0]),Math.cosh(s[1])):at(1,Math.cosh(Math.max(-s[0],s[1]))),tanh:s=>at(Math.tanh(s[0]),Math.tanh(s[1])),sech:s=>q.div([1,1],q.cosh(s)),csch:s=>q.div([1,1],q.sinh(s)),coth:s=>q.div([1,1],q.tanh(s)),cosech:s=>q.csch(s)},Xn=K("+ \u2212 * \xD7 \xB7 / \xF7 // sup sub subsup"),Dc=K("sub sup subsup"),ka=',';function jc(s,e){return Xn.includes(e)?s instanceof Zn?!0:!(s instanceof jt)||!Xn.includes(s.fn)?!1:Dc.includes(s.fn)&&Dc.includes(e)?!0:Xn.indexOf(e)>Xn.indexOf(s.fn):!1}function hg(s,e,t){return jc(s,e)?`${t}`:t}function es(s,e){return s instanceof Zn||s instanceof jt?`${e}`:e}function Nc(s){return s==="2"?"squared":s==="3"?"cubed":`to the power of ${s}`}var jt=class Ra extends ss{constructor(e,t=[]){super(),this.fn=e,this.args=t}evaluate(e={}){let t=this.args.map(i=>i.evaluate(e));if(this.fn in e){let i=e[this.fn];if(typeof i=="function")return i(...t);if(typeof i=="number"&&t.length===1)return Ee.mul(i,t[0]);throw rt.uncallableExpression(this.fn)}if(this.fn==="+")return Ee.add(...t);if(this.fn==="\u2212")return Ee.sub(...t);if(["*","\xB7","\xD7"].includes(this.fn))return Ee.mul(...t);if(this.fn==="/")return Ee.div(...t);if(this.fn==="sup")return Ee.sup(...t);if($s(this.fn))return Ee[this.fn](...t);if(this.fn==="(")return t[0];throw rt.undefinedFunction(this.fn)}interval(e={}){let t=this.args.map(i=>i.interval(e));if(this.fn in e){let i=e[this.fn];if(typeof i=="function")return ne(i(...t.map(n=>n[0])),2);if(typeof i=="number"&&t.length===1)return q.mul([i,i],t[0]);if(Array.isArray(i)&&t.length===1)return q.mul(i,t[0]);throw rt.uncallableExpression(this.fn)}if(this.fn==="+")return q.add(...t);if(this.fn==="\u2212")return q.sub(...t);if(["*","\xB7","\xD7"].includes(this.fn))return q.mul(...t);if(this.fn==="/")return q.div(...t);if(this.fn==="sup")return q.sup(...t);if($s(this.fn))return q[this.fn](...t);if(this.fn==="(")return t[0];throw rt.undefinedFunction(this.fn)}substitute(e={}){return new Ra(this.fn,this.args.map(t=>t.substitute(e)))}collapse(){return this.fn==="("?this.args[0].collapse():new Ra(this.fn,this.args.map(e=>e.collapse()))}get simplified(){return this}get variables(){return Wt(we(this.args.map(e=>e.variables)))}get functions(){return Wt([this.fn,...we(this.args.map(e=>e.functions))])}toString(){let e=this.args.map(t=>jc(t,this.fn)?`(${t.toString()})`:t.toString());return this.fn==="\u2212"?e.length>1?e.join(" \u2212 "):`\u2212${e[0]}`:this.fn==="sup"?e.join("^"):this.fn==="sub"?e.join("_"):this.fn==="subsup"?`${e[0]}_${e[1]}^${e[2]}`:K("+ * \xD7 \xB7 / = < > \u2264 \u2265 \u2248").includes(this.fn)?e.join(` ${this.fn} `):_(this.fn,"(","[","{")?this.fn+this.args.join(", ")+Ia[this.fn]:_(this.fn,"!","%")?e[0]+this.fn:`${this.fn}(${e.join(", ")})`}toMathML(e={}){let t=this.args.map(r=>r.toMathML(e)),i=this.args.map((r,o)=>hg(r,this.fn,t[o]));if(this.fn in e){let r=t.map((o,a)=>({toString:()=>o,val:this.args[a]}));return e[this.fn](...r)}if(this.fn==="\u2212")return i.length>1?i.join('\u2212'):`\u2212${i[0]}`;if(_(this.fn,"+","=","<",">","\u2264","\u2265","\u2248")){let r=_c(this.fn);return i.join(`${r}`)}if(_(this.fn,"*","\xD7","\xB7")){let r=i[0];for(let o=1;o\xD7':"")+i[1]}return r}if(this.fn==="//")return i.join('/');if(this.fn==="sqrt")return`${i[0]}`;if(_(this.fn,"/","root")){let r=this.fn==="/"?"mfrac":"mroot",o=this.args.map((a,h)=>es(a,t[h]));return`<${r}>${o.join("")}`}if(_(this.fn,"sup","sub")){let r=[es(this.args[0],i[0]),es(this.args[1],t[1])];return`${r.join("")}`}return this.fn==="subsup"?`${[es(this.args[0],i[0]),es(this.args[1],t[1]),es(this.args[2],t[2])].join("")}`:_(this.fn,"(","[","{")?`${i.join(ka)}`:_(this.fn,"!","%")?`${i[0]}${this.fn}`:this.fn==="abs"?`${i.join(ka)}`:this.fn==="bar"?`${es(this.args[0],i[0])}\u203E`:this.fn==="vec"?`${es(this.args[0],i[0])}\u2192`:`${this.fn}${i.join(ka)}`}toVoice(e={}){let t=this.args.map(n=>n.toVoice(e)),i=t.join(" ");if(this.fn in e){let n=t.map((r,o)=>({toString:()=>r,val:this.args[o]}));return e[this.fn](...n)}return _(this.fn,"(","[","{")?i:this.fn==="sqrt"?`square root of ${i}`:this.fn==="%"?`${i} percent`:this.fn==="!"?`${i} factorial`:this.fn==="/"?`${t[0]} over ${t[1]}`:this.fn==="//"?`${t[0]} divided by ${t[1]}`:this.fn==="sub"?i:this.fn==="subsup"?`${t[0]} ${t[1]} ${Nc(t[2])}`:this.fn==="sup"?`${t[0]} ${Nc(t[1])}`:Xs[this.fn]?t.join(` ${Xs[this.fn]} `):$s(this.fn)?`${this.fn} ${i}`:`${this.fn} of ${i}`}},Zn=class extends ss{constructor(s){super(),this.items=s}evaluate(s={}){return this.collapse().evaluate(s)}interval(s={}){return this.collapse().interval(s)}substitute(s={}){return this.collapse().substitute(s)}get simplified(){return this.collapse().simplified}get variables(){return Wt(Dh(...this.items.map(s=>s.variables)))}get functions(){return this.collapse().functions}toString(){return this.items.map(s=>s.toString()).join(" ")}toMathML(s={}){return this.items.map(e=>e.toMathML(s)).join("")}toVoice(s={}){return this.items.map(e=>e.toVoice(s)).join(" ")}collapse(){return Da(this.items).collapse()}};function Va(s,e){if(e===2)return new rg(s);if(!(!s||!e)){if(e===1&&s.length>1)return new Hc;if(e===3){if(isNaN(+s))throw rt.invalidExpression();return new Ni(+s)}if(e===4)return s in Di?new Ys(Di[s]):s in Ks?new Me(Ks[s]):new Ys(s);if(e===5)return s in Ks?new Me(Ks[s]):new Me(s)}}function lg(s){let e=[],t="",i=0;for(let r of s){if(r==='"'){let a=i===2?0:2,h=Va(t,i);h&&e.push(h),t="",i=a;continue}else if(i===2){t+=r;continue}let o=r.match(/[0-9.]/)?3:Jm.includes(r)?4:sg.includes(r)?5:r.match(/\s/)?1:0;if(!o)throw rt.invalidCharacter(r);if(!i||i===3&&o!==3||i===4&&o!==4&&o!==3||i===5&&!(t+r in Ks)||i===1&&o!==1){let a=Va(t,i);a&&e.push(a),t="",i=o}t+=r}let n=Va(t,i);return n&&e.push(n),e}function cg(s){return s.length>1?new Zn(s):s[0]instanceof Me?new Zn(s):s[0]}function pg(s,e){let t=[[]];for(let i of s)e(i)?t.push([]):O(t).push(i);return t}function Nt(s,e){return s instanceof Me&&K(e).includes(s.o)}function Ri(s){return s instanceof jt&&s.fn==="("?s.args[0]:s}function Qn(s,e){if(Nt(s[0],e))throw rt.startOperator(s[0]);if(Nt(O(s),e))throw rt.endOperator(O(s));for(let t=1;tNt(d,","));a.push(new jt(c,u.map(Gc)))}else Nt(n,"( [ {")?t.push([n]):O(t).push(n)}if(t.length>1)throw rt.unclosedBracket(O(t)[0].o);return Gc(t[0])}function zc(s,e,t=!1){let i=[],n=[],r=!1;function o(){if(r)throw rt.invalidExpression();n.length&&(i.push(n.length>1?new jt(e[0],n):n[0]),n=[])}for(let a of s)if(Nt(a,e)){if(r||!n.length)throw rt.invalidExpression();r=!0}else if(a instanceof Me)o(),i.push(a),r=!1;else{let h=!t||a instanceof Ni;if(n.length&&!r&&h)throw rt.invalidExpression();n.push(a),r=!1}return o(),i}function Da(s){if(s=s.filter(t=>!(t instanceof Hc)),!s.length)throw rt.invalidExpression();let e=s.findIndex(t=>Nt(t,"= < > \u2264 \u2265"));if(e===0)throw rt.startOperator(s[0]);if(e===s.length-1)throw rt.endOperator(s[0]);if(e>0){let t=Da(s.slice(0,e)),i=Da(s.slice(e+1));return new jt(s[e].o,[t,i])}if(Nt(s[0],"%!"))throw rt.startOperator(s[0]);for(let t=0;t1)throw rt.invalidExpression();return s[0]}function ug(s,e=!1,t){let i=dg(lg(s),t);return e?i.collapse():i}function fg(s,e){try{let t=Wt([...s.variables,...e.variables]),i=s.collapse(),n=e.collapse(),r=0;for(let o=0;o<5;++o){let a={};for(let c of t)a[c]=Na[c]||Math.random()*5;let h=i.evaluate(a),l=n.evaluate(a);if(!(isNaN(h)||isNaN(l))){if(!x(h,l))return!1;r+=1}}return!!r}catch(t){return!1}}var Et={numEquals:fg,parse:Le(ug)};var Uc='
';var mg=/[0-9+\-*/()^\s]+/g,gg=os(_t.shuffle(["happy","spongebob","sloth","party","robot","excited","cute","highfive1","applause","highfive2"])),vg=os(_t.shuffle(["minions","panther","dog","snape","what","door","horrible"]));function Ga(s,e,t={}){let i=m("div",{class:"msg-wrap","data-display":"flex"}),n=m("div",{class:"msg "+e},i);return t.class&&n.addClass(t.class),t.visible||i.hide(),_(e,"hint","question")?n.html=s:e==="img"?n.css("background-image",`url(${s})`):e==="video"&&m("iframe",{src:s,allowfullscreen:!0},n),i}var Jn=class extends E{constructor(){super(...arguments);this.recentMessages=[];this.isOpen=!1;this.queuePromise=Promise.resolve()}ready(){var r;this.$course=this.parents("x-course")[0],this.hints=this.$course?JSON.parse(this.$course.$("#hints").text):{};let t=window.user;this.correct=os(_t.shuffle(this.hints.correct||[])),this.incorrect=os(_t.shuffle(this.hints.incorrect||[])),this.$toasts=this.$(".toasts"),this.$chat=this.$(".chat"),this.$chatBody=this.$(".chat-body"),this.$toasts.on("click",o=>{o.handled||this.open()}),this.$(".close").on("click",()=>this.close());let i=this.$(".chat-footer");if(this.$query=i.$(".input"),this.$query.onKey("Enter",o=>{o.preventDefault(),this.askQuestion(this.$query.text.trim()),this.$query.text=""}),this.$query.on("focus",()=>i.addClass("focus")),this.$query.on("blur",()=>i.removeClass("focus")),this.$(".hint").on("click",()=>{this.queue(this.hints.tutorial1),this.queue(t?this.hints.tutorial2:this.hints.account)}),this.$course&&((r=this.$course.userData)!=null&&r.messages))for(let o of this.$course.userData.messages)this.$chatBody.append(Ga(o.content,o.kind||"hint",{visible:!0}));if(!b.getCookie("sessionWelcome")&&this.$course){b.setCookie("sessionWelcome",1,60*60*4);let o=new Date().getHours(),a=o<12?"Morning":o<18?"Afternoon":"Evening";t?setTimeout(()=>this.showHint(`welcome${a}Named`,{variables:{name:t.shortName}}),3e3):b.getCookie("welcome")?(setTimeout(()=>this.showHint(`welcome${a}`),3e3),setTimeout(()=>this.queue(this.hints.account),4500)):(b.setCookie("welcome",1),setTimeout(()=>this.queue(this.hints.welcome),3e3),setTimeout(()=>this.queue(this.hints.tutorial1),4500))}}open(){this.isOpen||(this.isOpen=!0,this.$chat.enter("slide-up",200),this.$chatBody.scrollTop=this.$chatBody.scrollHeight,this.trigger("open"))}close(){this.isOpen&&(this.isOpen=!1,this.$query.blur(),this.trigger("close"),this.$chat.exit("slide-down",200))}queue(t,i="hint",n={}){this.queuePromise=this.queuePromise.then(()=>(this.display(t,i,n),vi(500)))}display(t,i="hint",n={}){let r=n.timeout||8e3;if(b.width<640&&(r*=.7),(n.toast==null?!0:n.toast)&&!this.isOpen){let h=Ga(t,i,n);h.setAttr("role","alert"),this.$toasts.append(h),h.enter("reveal-right"),setTimeout(()=>h.exit("reveal-right",400,0,!0),r),this.on("open",()=>h.exit("reveal",200,0,!0))}let a=Ga(t,i,{class:n.class,visible:!this.isOpen});this.$chatBody.append(a),this.isOpen&&(a.enter("reveal",300),mt(()=>this.$chatBody.scrollTop=this.$chatBody.scrollHeight,200))}showHint(t,i={}){if(_(t,"correct","incorrect")){let r=t==="correct"?this.correct():this.incorrect(),o=t==="correct"?3e3:5e3;if(this.queue(r,"hint",{class:i.class||t,timeout:o}),Math.random()<.2){let a=t==="correct"?gg():vg(),h="";this.queue(`${h}/images/gifs/${a}.gif`,"img",{timeout:o})}return{text:r}}let n=this.hints[t]||t;if(i.variables)for(let[r,o]of Object.entries(i.variables))n=n.replace(new RegExp("\\$"+r,"g"),o);return!i.force&&this.recentMessages.includes(t)?{text:n}:(this.recentMessages.push(t),setTimeout(()=>this.recentMessages.shift(),1e4),i.store!==!1&&this.$course&&this.$course.saveProgress({hints:[{content:n,kind:"hint"}]}),this.queue(n,"hint",{class:i.class}),{text:n})}askQuestion(t){if(!t)return;this.queue(t,"question"),this.$course&&this.$course.log("Tutor","ask",t);let i=(t.match(mg)||[]).filter(n=>n.length>=3&&!n.match(/^[\s0-9]+$/));if(i.length)try{let n=Et.parse(i[0],!0),r=Et.parse("="+n.evaluate());return this.queue(`${n.toMathML()}${r.toMathML()}`)}catch(n){console.log("Parse Error:",i[0])}this.$chatBody.addClass("loading"),De(this.attr("api"),{query:t}).then(n=>{this.$chatBody.removeClass("loading");let r=JSON.parse(n);for(let o of r)this.queue(o.content,o.kind)}).catch(n=>{this.$chatBody.removeClass("loading"),this.queue(this.hints.serverError),console.error("Tutor Error:",n)})}};Jn=T([S("x-tutor",{template:Uc})],Jn);var Wc='
';var Kc=m("div",{class:"var-overlay"},C),tr=class extends E{constructor(){super(...arguments);this.valueChange=!1}ready(){let t=this.attr("bind");if(!t)return;let[i,n,r]=t.split("|");[this.min,this.max,this.step]=r.split(",").map(l=>+l),this.name=i,this.model=this.getParentModel(),this.$(".content").bindModel(this.model),this.$progress=this.$(".progress"),this.setValue(+n);let o=20*(b.isMobile?1.5:1)/B((this.max-this.min)/this.step/12,1,3),a=0,h=0;for(let l of this.$$(".left, .right")){let c=l.hasClass("left")?-this.step:this.step;l.on("click",()=>{this.setValue(this.value+c),this.trigger("slide-end")})}ds(this,{start:l=>{a=l.x,h=this.value,this.addClass("on"),this.valueChange=!1,Kc.show(),Xt.addClass("grabbing")},move:l=>{let c=(l.x-a)/o;this.setValue(h+Rt(c)*this.step)},end:()=>{this.removeClass("on"),this.valueChange&&this.trigger("slide-end"),Kc.hide(),Xt.removeClass("grabbing")}})}setup(t,i){this.one("slide-end",()=>t.score(i))}setValue(t){let i=Rt(B(t,this.min,this.max),2);if(i===this.value)return;this.value=i,this.valueChange=!0,this.model&&(this.model[this.name]=i);let n=this.max-this.min;this.$progress.css("width",116*(i-this.min)/n+"px")}};tr=T([S("x-var",{template:Wc})],tr);var Xc='';var er=class extends E{constructor(){super(...arguments);this.visible=!0}ready(){this.on("click",()=>{this.play(),setTimeout(()=>this.trigger("play"),400)})}play(){this.visible&&(this.visible=!1,this.exit("pop",400))}reset(){this.visible||(this.visible=!0,setTimeout(()=>this.enter("pop"),400))}};er=T([S("x-play-btn",{template:Xc})],er);var sr=class extends E{constructor(){super(...arguments);this.playing=!1}ready(){this.$icon=this.$("x-icon"),this.$("button").on("click",()=>this.toggle())}toggle(){this.playing?this.pause():this.play()}play(){this.playing||(this.playing=!0,this.$icon.setAttr("name","pause"),this.trigger("play"))}pause(){this.playing&&(this.playing=!1,this.$icon.setAttr("name","play"),this.trigger("pause"))}};sr=T([S("x-play-toggle",{template:''})],sr);var Yc='
';function Zc(s){let e=Math.floor(s/60),t=Math.floor(s%60);return e+":"+(t<10?"0":"")+t}var ir=class extends E{ready(){let t=this.attr("src"),i=this.$(".video-wrap"),n=this.$("video"),r=this.attr("width"),o=this.attr("height");this.css("width",r+"px"),i.css("padding-bottom",+o/+r*100+"%"),n.setAttr("poster",this.attr("poster")||t.replace(/mp4$/,"jpg")),this.hasAttr("loop")&&(n._el.loop=!0),this.hasAttr("audio")||(n._el.muted=!0),n._el.preload=this.attr("preload")==="no"?"metadata":"auto",m("source",{src:t,type:"video/mp4"},n),this.hasAttr("credit")&&(this.$(".credit").text=this.attr("credit"));let a=this.$(".bar"),h=this.$(".progress"),l=this.$(".buffer"),c=this.$(".timecode"),u=new fs(this.$(".handle"),{$parent:a,moveY:!1}),d=this.video=n._el,g=this.width-110;b.onResize(()=>g=this.width-110),n.on("canplay",()=>{c.text=Zc(+d.duration)}),n.on("timeupdate",()=>{let v=d.currentTime/d.duration;h.css("width",v*100+"%"),c.text=Zc(+d.currentTime),u.setPosition(v*g,0),this.trigger("timeupdate",d.currentTime)}),n.on("progress",()=>{if(d.buffered.length<=0||d.duration<=0)return;let w=d.buffered.end(d.buffered.length-1)/d.duration*100;l.css("width",w+"%")}),n.on("ended",()=>{d.pause(),this.removeClass("playing"),this.trigger("end")});let y=()=>d.paused?this.play():this.pause(),f=v=>this.setTime(v/g*d.duration);this.hasAttr("hover")?(n.on("mouseover touchstart",()=>this.play()),n.on("mouseout touchend touchcancel",()=>this.pause())):n.on("click",y),this.hasAttr("controls")&&(this.$(".controls").show(),this.$(".play-pause-btn").on("click",y),u.on("start",()=>this.pause()),u.on("drag",({posn:v})=>f(v.x)),a.on("click",v=>f(v.offsetX)))}setTime(t){this.video.currentTime=t}play(){this.video.play(),this.addClass("playing"),this.trigger("play")}pause(){this.video.pause(),this.removeClass("playing")}};ir=T([S("x-video",{template:Yc})],ir);var nr=class extends E{constructor(){super(...arguments);this.isCompleted=!1;this.isReady=!1}created(){this.userData=window.progressData||JSON.parse(this.$("#userdata").text)||{},this.$steps=this.$$("x-step");for(let t of this.$steps)t.on("score",()=>this.trigger("score"));this.data.audio&&(this.audio=new $n(this.data.audio))}ready(){this.$footer=this.$("footer"),this.$skipStep=this.$footer.$(".skip-step"),this.$progress=this.$(".sidebar-row.active x-progress"),this.$tutor=this.$("x-tutor"),this.$stepsWrap=this.$(".steps");let t=this.findStep(b.getHash()),i=this.findStep(this.userData.activeStep);this.$activeStep=i||this.$steps[0];for(let r of this.$steps){if(r.show(),r===this.$activeStep)break;r.complete()}if(this.userData.completed||b.getHash()==="full"||this.data.reveal)this.complete();else for(;this.$activeStep&&this.$activeStep.isReady&&!this.isCompleted;)this.nextStep();(t||i&&!this.userData.completed)&&this.goToStep(t||i,!1),this.$(".section-dev")&&this.complete();let n=this.$(".reveal-banner");setTimeout(()=>{this.isCompleted||(n.removeClass("off"),this.on("score complete",()=>n.addClass("off")))},1500),n.$(".complete").one("click",()=>this.complete()),C.onKey("Space",r=>{r.preventDefault(),this.nextStep(),n.addClass("off")}),this.$footer.$(".skip").on("click",()=>this.nextStep()),this.$footer.$(".show-all").on("click",()=>this.complete()),this.$footer.show(),this.isReady=!0,setTimeout(()=>this.addClass("ready"))}nextStep(){if(this.isCompleted)return;let t=this.$activeStep,i=this.$stepsWrap.height;do{if(t.complete(),t=this.$steps[this.$steps.indexOf(t)+1],!t)return this.complete(!0);t.show()}while(t.isReady);this.$stepsWrap.animate({height:[i+"px","auto"]},800),this.$activeStep=t,this.saveProgress({activeStep:t.id})}goToStep(t,i=!0){let n=this.$stepsWrap.height;for(let a of this.$steps){if(a.isShown||(this.$activeStep=a),a.show(),t.isShown&&!a.isReady)break;a.complete()}let r=t.positionTop-Math.max(50,(b.height-t.height)/2);i?(this.$stepsWrap.animate({height:[n+"px","auto"]},800),C.scrollTo(r)):C.scrollTop=r;let o=O(this.$steps);if(o.isShown&&o.isReady)return this.complete();this.$activeStep&&this.saveProgress({activeStep:this.$activeStep.id})}complete(t=!1){if(this.isCompleted)return;this.isCompleted=!0,this.$steps.forEach(n=>n.complete()),this.$activeStep=void 0;let i=this.$footer.$(".next-section");t?(this.$skipStep.exit("fade",200),i&&i.enter("pop")):(this.$skipStep.hide(),i&&i.show()),this.trigger("complete"),this.saveProgress({completed:!0}),this.log("Course","complete")}findStep(t){for(let i of this.$steps)if(i.id===t)return i}saveProgress(t){if(!this.isReady)return;let n=N(this.$steps.map(r=>r.scores.size))/+this.data.goals||0;this.$progress.setProgress(n),ql(`/course/${this.id}/${this.data.section}`,t)}log(t,i,n){if(window.ga&&this.isReady){let r=i+(n?":"+n:"");window.ga("send","event",t,r,this.id)}}};nr=T([S("x-course")],nr);var rr=class{constructor(){this.callbacks=[]}add(e){this.callbacks.push(e)}start(e=1e3){return mt(i=>{for(let n of this.callbacks)n(i)},e).promise}};function Qc(s,e){return s.every((t,i)=>x(t,e[i]))}function Jc(s,e){s.scale*=e.scale,s.x=s.x*e.scale+e.x,s.y=s.y*e.scale+e.y}function tp(s,e){return x(s.x,e.x)&&x(s.y,e.y)&&x(s.scale,e.scale)}function or(s,e,t){if(t==="adding"){let i=s.strokeLength,n=e<.5?0:St("cubic-in",e*2-1);s.css({"stroke-dasharray":i+"px","stroke-dashoffset":i*(1-n)+"px"})}else if(t==="deleting"){let i=s.strokeLength,n=e<.5?St("cubic-in",2*e):1;s.css({"stroke-dasharray":i+"px","stroke-dashoffset":i*(2-n)+"px"})}}function ep(s,e){let t=[s],i=s.expr;for(;e.startsWith(i);){if(e===i)return t;let n=O(t).next;if(!n)return;t.push(n),i+=n.expr}}function sp(s,e,t=1){let i=t*Math.abs(e.x-s.x)/3,n=p.average(s,e).shift(0,i);return function(r){let o=(1-r)**2*s.x+2*r*(1-r)*n.x+r*r*e.x,a=(1-r)**2*s.y+2*r*(1-r)*n.y+r*r*e.y;return{x:o,y:a}}}function za(s,e){return Math.max(e*s,.4)/s}function Ge(s){return s instanceof Ce&&s.children.length>1||s instanceof Gi?`(${s.expr})`:s.expr}function Zs(s,e){return e.length===1&&e[0].type==="mrow"?e[0]:new Ce(e,s)}var Gt=class s{constructor(e,t,i,n){this.type=e;this.equation=i;this.$element=n;this.children=[];this.status="";this.value="";this.customColor="";this.roundedMotion=!1;this.width=0;this.height=0;this.baseline=0;this.transform={x:0,y:0,scale:1};this.currentDimensions=[0,0,0];this.currentWorldTransform={x:0,y:0,scale:1};this.addChildren(t),n&&i.$row.append(n)}get expr(){return""}get log(){let e=this.children.map(t=>t.log);return`<${this.type}>${e.join("")}`}get color(){return this.customColor||(this.parent?this.parent.color:"")}static create(e,t){let i=e.nodeName.toLowerCase();if(_(i,"mn","mi","mo","mtext")){if(e.textContent==="placeholder")return new qa(t);let r=e.getAttribute("mathvariant")||void 0;return new ar(i,e.textContent||"",t,r)}if(!_(i,"mrow","mfrac","mfenced","msqrt","mroot","msub","msup","msubsup","munder","mover","munderover","mspace"))return new Ua(e,t);if(i==="mfenced"&&e.getAttribute("open")==="["){let r=e.children.length,o=we(Array.from(e.children,h=>Array.from(h.children,l=>s.create(l,t)))),a=new ja(o,t,r);return new hr([a],t)}let n=Array.from(e.children,r=>s.create(r,t));switch(i){case"mrow":return new Ce(n,t);case"mfrac":return n=n.map(r=>Zs(t,[r])),new Fa(n,t);case"mfenced":return n=[Zs(t,n)],new hr(n,t);case"msqrt":return n=[Zs(t,n)],new lr(i,n,t);case"mroot":return n=n.map(r=>Zs(t,[r])),new lr(i,n,t);case"msub":case"msup":case"msubsup":return n=n.map(r=>Zs(t,[r])),new Gi(i,n,t);case"munder":case"mover":case"munderover":return n=n.map(r=>Zs(t,[r])),new Ha(i,n,t);case"mspace":return new _a(t)}throw new Error(`Unknown element type tag ${e.nodeName}`)}get marginLeft(){return .1}get marginRight(){return .1}setTransform(e=0,t=0,i=1){this.transform.x=e,this.transform.y=t,this.transform.scale=i}get worldTransform(){let e=this,t=Object.assign({},this.transform);for(;e=e.parent;)Jc(t,e.transform);return t}get index(){return this.parent?this.parent.children.indexOf(this):-1}get next(){if(!this.parent)return;let e=this.parent.children.indexOf(this);return this.parent.children[e+1]}get prev(){if(!this.parent)return;let e=this.parent.children.indexOf(this);return this.parent.children[e-1]}addChildren(e,t=this.children.length){for(let i of this.children)i.type==="placeholder"&&i.deleteFromDom();for(let i of e)i.detach(),i.parent=this;this.children.splice(t,0,...e)}insertAfter(e){let t=this.parent.children.indexOf(this);this.parent.addChildren(e,t+1)}insertBefore(e){let t=this.parent.children.indexOf(this);this.parent.addChildren(e,t)}detach(){if(this.parent){let e=this.parent.children.indexOf(this);e>=0&&this.parent.children.splice(e,1),this.parent=void 0}}deleteFromDom(){this.parent&&this.detach(),this.$element&&this.$element.remove(),this.$element=void 0;for(let e of this.children.slice(0))e.deleteFromDom()}*parents(e=!1){let t=e?this:this.parent;for(;t;)yield t,t=t.parent}hasParent(e,t=!1){return Bt(this.parents(t),e)}hitTest(e){let{x:t,scale:i}=this.worldTransform,n=this.marginLeft*i*this.equation.fontSize,r=this.marginRight*i*this.equation.fontSize;if(it(e.x,t-n,t+this.width*i+n+r))return this.hitTestChildren(e)||this}hitTestChildren(e){for(let t of this.children){let i=t.hitTest(e);if(i)return i}}measure(e=1){for(let t of this.children)t.measure(e)}clean(){for(let e of this.children)e.clean()}setStatus(e){this.status=e;for(let t of this.children)t.setStatus(e)}render(e){for(let h of this.children)h.render(e);if(!this.$element)return;let t=this.currentWorldTransform,i=this.currentWorldTransform=this.worldTransform,n=this.currentDimensions,r=this.currentDimensions=[this.width,this.height,this.baseline];if(tp(t,i)&&Qc(n,r)&&!this.status)return;if(!e){this.positionElement(i),this.drawElement(1,r[0],r[1],r[2],i.scale);return}this.status==="adding"&&this.positionElement(i);let o=i.y+this.baseline{if(!this.$element)return;let l=St("cubic",h),c=_(this.status,"adding","deleting"),u=c?r[0]:ht(n[0],r[0],l),d=c?r[1]:ht(n[1],r[1],l),g=c?r[2]:ht(n[2],r[2],l),y=c?i.scale:ht(t.scale,i.scale,l);if(this.drawElement(h,u,d,g,y),!this.status){let f=a?a(l):p.interpolate(t,i,l);this.positionElement({x:f.x,y:f.y,scale:y})}})}positionElement(e){this.$element.setTransform(e,0,e.scale)}drawElement(e,t,i,n,r){}},wg="acegmnopqrsuvwxyz",Ps=1.1,Qs=.2,Ba=new Set(["=","\u2248","<",">","\u2264","\u2265"]),yg=document.createElement("canvas"),ip=yg.getContext("2d"),bg=Le((s,e)=>(ip.font=`${e}px "Source Sans Pro", sans-serif`,ip.measureText(s).width)),ar=class extends Gt{constructor(t,i,n,r){super(t,[],n,m("text",{}));this.variant=r;this.setValue(i)}setValue(t){this.$element.text=this.value=t;let i=this.value.split("").every(r=>wg.includes(r));this.width=bg(t,this.equation.fontSize),this.height=(Ps-(i?.1:0))*this.equation.fontSize,this.baseline=this.height-Qs*this.equation.fontSize;let n=this.type==="mtext"||this.variant==="normal";this.$element.setClass("font-normal",n||$s(this.value))}get expr(){return this.value==="xx"?'"xx"':this.type==="mtext"?`"${this.value}"`:this.value}get log(){return`<${this.type}>${this.value}`}get marginLeft(){if(this.type==="mo")return Ba.has(this.value)?this.equation.isDisplay?.5:.35:_(this.value,"\u2221","\u25B3","!","%","\u2019")||_(this.value,"\u2026","\xB0")&&this.prev&&this.prev.type==="mn"?0:.25;if(this.type==="mi"){if(this.prev&&this.prev.type==="mn")return .1;if(this.prev&&this.prev.type==="mi")return .05;if(this.prev&&this.prev.type==="mfrac")return .15}return 0}get marginRight(){return this.type==="mo"?this.equation.isDisplay&&Ba.has(this.value)?.5:_(this.value,"\u2221","\u25B3")?0:this.value==="\u2212"&&(!this.prev||Ba.has(this.prev.value))?.1:.25:0}positionElement(t){if(!this.$element)return;let i=(this.equation.fontSize-this.baseline)*t.scale;this.$element.setTransform({x:t.x,y:t.y-i},0,t.scale)}drawElement(t,i,n,r,o){this.status==="adding"?this.$element.setAttr("opacity",t<.5?0:St("cubic-in",t*2-1)):this.status==="deleting"&&this.$element.setAttr("opacity",t<.5?1-St("cubic-in",2*t):0),this.$element.css("stroke-width",(1-o)*1.5+"px"),this.$element.css("color",this.color||"currentColor")}},_a=class extends Gt{constructor(e){super("mspace",[],e),this.height=(Ps-.1)*e.fontSize,this.baseline=this.height-Qs*this.equation.fontSize,this.width=e.fontSize*.2}get expr(){return" "}},Ce=class extends Gt{constructor(t,i,n,r=0){super("mrow",t,i);this.align=n;this.dx=r}addChildren(t,i=this.children.length){let n=[];for(let r of t)r.type==="mrow"?(n.push(...r.children),r.detach()):n.push(r);super.addChildren(n,i)}get expr(){return this.children.map(t=>t.expr).join(" ").replace(/− /,"\u2212")||"placeholder"}measure(t=1){if(super.measure(t),!this.children.length){this.height=this.width=this.baseline=0;return}this.baseline=Math.max(...this.children.map(n=>n.baseline)),this.height=this.baseline+Math.max(...this.children.map(n=>n.height-n.baseline));let i=0;for(let[n,r]of this.children.entries())r.setTransform(i,this.baseline-r.baseline),i+=r.width,nr.expr===this.align);n&&(this.transform.x=this.dx-n.transform.x-n.width/2)}this.width=i}},qa=class extends Gt{constructor(e){let t=e.fontSize,i=`M${.1*t} ${.3*t}h${t/2}v${t/2}h-${t/2}Z`,n=m("path",{class:"placeholder",d:i});super("placeholder",[],e,n),this.width=.7*t,this.height=Ps*t,this.baseline=this.height-Qs*t}get expr(){return"placeholder"}get marginLeft(){return 0}get marginRight(){return 0}},Fa=class extends Gt{constructor(e,t){super("mfrac",e,t,m("line"))}get expr(){return this.children.map(e=>Ge(e)).join("/")}measure(e){let t=this.hasParent(a=>a.type==="mfrac"||a.type==="matrix"),i=za(e,!this.equation.isDisplay||t?.66:1),n=.1*this.equation.fontSize,[r,o]=this.children;super.measure(e*i),this.width=(Math.max(r.width,o.width)+2*n)*i,this.height=(r.height+o.height)*i,this.baseline=r.height*i+this.equation.fontSize*(Ps/2-Qs),r.setTransform((this.width-r.width*i)/2,0,i),o.setTransform((this.width-o.width*i)/2,r.height*i,i)}drawElement(e,t,i,n){let r=n-this.equation.fontSize*(Ps/2-Qs);this.$element.setLine({x:0,y:r},{x:t,y:r}),this.$element.setAttr("stroke",this.color||"currentColor"),or(this.$element,e,this.status)}hitTestChildren(e){let{scale:t,y:i}=this.worldTransform,n=this.baseline-this.equation.fontSize*(Ps/2-Qs),r=e.y<=i+n*t,o=this.children[r?0:1];return o.hitTestChildren(e)||o}},Gi=class extends Gt{get expr(){let e=Ge(this.children[0]);return this.type!=="msup"&&(e+="_"+Ge(this.children[1])),this.type==="msup"&&(e+="^"+Ge(this.children[1])),this.type==="msubsup"&&(e+="^"+Ge(this.children[2])),e}measure(e){let[t,i,n]=this.children,r=this.type==="msup"?void 0:i,o=this.type==="msubsup"?n:this.type==="msup"?i:void 0,a=.05*this.equation.fontSize,h=za(e,.65);t.measure(e),r&&r.measure(e*h),o&&o.measure(e*h);let l=o?o.height*h-.4*this.equation.fontSize:0,c=r?r.height*h-.5*this.equation.fontSize:0,u=o?o.width:0,d=r?r.width:0;this.width=t.width+a+Math.max(u,d)*h,this.height=t.height+l+c,this.baseline=t.baseline+l,t.setTransform(0,this.baseline-t.baseline),o&&o.setTransform(t.width+a,0,h),r&&r.setTransform(t.width+a,this.height-r.height*h,h)}clean(){if(super.clean(),this.children=this.children.filter(e=>e.type!=="mrow"||e.children.length),this.children.length===0)return this.detach();this.children.length===1&&(this.insertAfter(this.children),this.detach())}},Ha=class extends Gt{get expr(){let e=this.children[0].expr;return this.type!=="munder"&&(e+="_"+Ge(this.children[1])),this.type==="mover"&&(e+="^"+Ge(this.children[1])),this.type==="munderover"&&(e+="^"+Ge(this.children[2])),e}measure(e){super.measure(e)}},hr=class extends Gt{constructor(e,t){super("mfenced",e,t,m("path"))}get expr(){return`(${this.children.map(e=>e.expr).join(",")})`}get marginLeft(){return .2}get marginRight(){return .2}measure(e){super.measure(e);let t=this.children[0];this.height=t.height+2,this.baseline=t.baseline+1;let i=1+this.height/this.equation.fontSize,n=.1*this.equation.fontSize;this.width=t.width+2*(i+n),t.setTransform(i+n,1)}drawElement(e,t,i){let n=Math.min(2+i/this.equation.fontSize,5),r=i-4,o=t-n,a=`M${n},2c${-2*n/3},${.15*r},${-n},${.32*r},${-n},${r/2}s${n/3},${.35*r},${n},${r/2}M${o},2c${2*n/3},${.15*r},${n},${.32*r},${n},${r/2}s${-n/3},${.35*r},${-n},${r/2}`;this.$element.setAttr("d",a),this.$element.css("stroke",this.color||"currentColor"),or(this.$element,e,this.status)}clean(){super.clean(),this.children.length||this.detach()}},lr=class extends Gt{constructor(e,t,i){super(e,t,i,m("path"))}get expr(){return`sqrt(${this.children.map(e=>e.expr).join(", ")})`}get marginLeft(){return .2}get marginRight(){return .2}measure(e){super.measure(e);let t=this.children[0];this.height=t.height+2,this.baseline=t.baseline+2;let i=Math.min(16,3+5*this.height/this.equation.fontSize),n=.05*this.equation.fontSize;this.width=t.width+i+2*n,t.setTransform(i+n,2)}drawElement(e,t,i){let n=Math.min(16,3+5*i/this.equation.fontSize),r=i-2,o=`M0,${.55*r}L${.18*n},${.51*r}L${.45*n},${r}L${n},2L${t},2`;this.$element.setAttr("d",o),this.$element.css("stroke",this.color||"currentColor"),or(this.$element,e,this.status)}clean(){super.clean(),this.children.length||this.detach()}},ja=class extends Gt{constructor(t,i,n){super("matrix",t,i,m("g"));this.rows=n;this.cols=Math.floor(t.length/n)}get expr(){return`${this.children.map(t=>t.expr).join(", ")}`}measure(t){super.measure(t);let i=.6*this.equation.fontSize,n=z(a=>Math.max(...z(h=>this.children[a*this.cols+h].height,this.cols)),this.rows),r=z(a=>Math.max(...z(h=>this.children[h*this.cols+a].width,this.rows)),this.cols);this.height=N(n)+(this.rows-1)*i/2,this.width=N(r)+this.cols*i,this.baseline=(this.height+Ps*this.equation.fontSize)/2;let o=0;for(let a=0;a{this.checkForResize()&&this.equation.resize()}),(n=this.$body.$("x-blank, x-blank-mc"))==null||n.on("solve",r=>{Zt(()=>this.replace(r.solution,"#0f82f2"),r.restore?0:200)})}deleteFromDom(){var t;super.deleteFromDom(),(t=this.$body)==null||t.remove(),this.$body=void 0,this.$measure=void 0}replace(t,i){var o;let n=Number.isNaN(+t)?"mtext":"mn",r=new ar(n,t,this.equation);r.customColor=i,this.insertAfter([r]),(o=this.$body)==null||o.off("resize"),this.deleteFromDom(),this.equation.resize()}checkForResize(){var r,o;let t=this.height,i=this.width,n=this.baseline;return this.height=((r=this.$body)==null?void 0:r.height)||0,this.width=((o=this.$body)==null?void 0:o.width)||0,this.baseline=this.$measure.bounds.top-this.$body.bounds.top,!(x(t,this.height)&&x(i,this.width)&&x(n,this.baseline))}positionElement(t){var i,n;(i=this.$body)==null||i.css({left:t.x+"px",top:t.y+"px"}),x(t.scale,1)||(n=this.$body)==null||n.css("transform",`scale(${t.scale})`)}get expr(){var t;return`"${(t=this.$body)==null?void 0:t.text}"`}get log(){return`${this.expr}`}};var ze=class extends Oe{constructor(t,i,n=0,r="=",o=18,a=!0){super();this.$row=t;this.$overlay=i;this.fontSize=o;this.isDisplay=a;this.isReady=!0;this.deletedNodes=new Set;this.root=new Ce([],this,r,n)}setValue(t){let i=Array.isArray(t)?t.map(n=>Gt.create(n,this)):this.parse(t);for(;this.root.children.length;)this.root.children[0].deleteFromDom();this.root.addChildren(i),this.updateDescription(),this.resize()}updateDescription(){try{let t=Et.parse(this.root.expr).toVoice();this.$row.setAttr("aria-label",t)}catch(t){this.$row.setAttr("aria-label","Invalid expression: "+this.root.expr)}}resize(){this.root.measure(),this.root.render()}parse(t){var a;let i=new DOMParser,n=Et.parse(t).toMathML(),r=i.parseFromString(`${n}`,"text/xml");if(((a=r.firstChild)==null?void 0:a.nodeName)==="parsererror")throw new Error(r.firstChild.textContent);let o=r.firstChild.childNodes;return Array.from(o,h=>Gt.create(h,this))}find(t){let[i,n]=t.split("`");i=i.replace(/[–-]/g,"\u2212");let r=+n||1,o=this.root.children.slice(0),a=0;for(;o.length;){let h=o.shift(),l=h instanceof Ce?void 0:ep(h,i);if(l&&(a+=1,a===r))return l;o.unshift(...h.children)}throw new Error(`Can't find element ${i}.`)}animate(t=1200){return D(this,null,function*(){this.isReady=!1,this.root.clean(),this.root.measure();let i=new rr;this.root.render(i),this.trigger("resize",{height:this.root.height});for(let n of this.deletedNodes)n.render(i);yield i.start(t);for(let n of this.deletedNodes)n.deleteFromDom();this.root.setStatus(""),this.deletedNodes.clear(),this.isReady=!0})}addTermAfter(t,i){let n=O(i?this.find(i):this.root.children),r=this.parse(t);n.insertAfter(r);for(let o of r)o.setStatus("adding");this.updateDescription()}addTermBefore(t,i){let n=i?this.find(i)[0]:this.root.children[0],r=this.parse(t);n.insertBefore(r);for(let o of r)o.setStatus("adding");this.updateDescription()}deleteTerm(t){for(let i of this.find(t))i.setStatus("deleting"),i.detach(),this.deletedNodes.add(i);this.updateDescription()}replaceTerm(t,i){let n=this.find(t),r=this.parse(i);n[0].insertBefore(r);for(let o of r)o.setStatus("adding");for(let o of n)o.setStatus("deleting"),o.detach(),this.deletedNodes.add(o);this.updateDescription()}moveTermAfter(t,i){let n=this.find(t);for(let o of n)o.roundedMotion=!0;O(i?this.find(i):this.root.children).insertAfter(n),this.updateDescription()}moveTermBefore(t,i){let n=this.find(t);for(let o of n)o.roundedMotion=!0;(i?this.find(i)[0]:this.root.children[0]).insertBefore(n),this.updateDescription()}moveTermToStart(t){let i=this.find(t);for(let n of i)n.roundedMotion=!0;this.root.children[0].insertBefore(i),this.updateDescription()}wrapTerms(t,...i){let n=i.map(o=>this.find(o));for(let o of n)for(let a of o)a.roundedMotion=!0;let r=this.parse(t);for(let o of r)o.setStatus("adding");n[0][0].insertBefore(r);for(let[o,a]of n.entries()){let h=this.find("$"+(o+1))[0];h.insertAfter(a),h.deleteFromDom()}this.updateDescription()}unwrapTerm(t,i=1){let n=this.find(t),r=n[0],o=1;for(;o<=i;)r=r.parent,r instanceof Ce&&(r=r.parent),o+=1;r.insertAfter(n),r.setStatus("deleting"),r.detach(),this.deletedNodes.add(r),this.updateDescription()}get leftSide(){let t=this.root.children.findIndex(i=>i.expr==="=");return this.root.children.slice(0,t-1)}get rightSide(){let t=this.root.children.findIndex(i=>i.expr==="=");return this.root.children.slice(t+1)}};var np='
';var rp=1200,xg=400,op=1200,Js=600,zi=16,cr=class extends E{constructor(){super(...arguments);this.rows=[];this.isReady=!0;this.topOffset=4;this.currentHeight=0;this.currentStep=0;this.nextEvents={};this.backEvents={}}ready(){this.$svg=this.$("svg"),this.$lastRow=this.$svg.$("g"),this.$overlay=this.$(".overlay"),this.$legend=this.$(".legend-box"),this.$steps=this.$legend.$$("li"),this.$back=this.$(".back"),this.$next=this.$(".next");let t=+this.attr("dx")||0;this.equation=new ze(this.$lastRow,this.$overlay,t);let i=this.$(".math"),n=i?Array.from(i._el.children):[];this.equation.setValue(this.attr("expr")||n),this.currentHeight=this.topOffset+this.$lastRow.height+16,this.$svg.css("height",this.currentHeight+"px"),this.equation.on("resize",({height:o})=>{let a=this.topOffset+o+zi;Math.abs(a-this.currentHeight)this.goBack()),this.$next.on("click",()=>this.goNext()),this.$steps[0].show(),b.onResize(()=>{let o=this.$svg.width/2;for(let a of[this.$lastRow,this.$overlay])a.css("transform",`translate(${o}px, ${this.topOffset}px)`);for(let a of this.rows)a.$el.css("transform",`translate(${o}px, ${a.top}px)`)});let r=this.$overlay.$$("x-blank, x-blank-mc");r.length&&(this.$next.addClass("hide"),Promise.all(r.map(o=>o.onPromise("solve"))).then(()=>setTimeout(()=>this.goNext(),rp)))}setup(t){this.one("next",({step:i})=>t.score("algebra-flow-"+(i-1)))}newRow(){return D(this,null,function*(){let t=this.$lastRow.copy(!0,!1),i=this.equation.root.height;this.rows.push({$el:t,height:i,top:this.topOffset}),this.$lastRow.insertBefore(t),b.redraw(),this.topOffset+=i+zi,this.currentHeight=this.topOffset+i+zi;for(let n of[this.$lastRow,this.$overlay])n.animate({transform:`translate(${this.$svg.width/2}px, ${this.topOffset}px)`},Js);yield this.$svg.animate({height:this.currentHeight+"px"},Js).promise})}hideLastRow(){return D(this,null,function*(){if(!this.rows.length)return;let t=this.rows.pop();this.topOffset=t.top;for(let i of[this.$lastRow,this.$overlay])i.animate({transform:`translate(${this.$svg.width/2}px, ${t.top}px)`},Js);this.currentHeight=t.top+this.$lastRow.height+zi,this.$svg.animate({height:this.currentHeight+"px"},Js),yield t.$el.exit("fade",Js/2,Js/2).promise,t.$el.remove()})}onNextStep(t){this.nextEvents=t}onBackStep(t){this.backEvents=t}goNext(){return D(this,null,function*(){if(!this.isReady||!this.equation.isReady||this.currentStep>=this.$steps.length-1)return;this.isReady=!1;let t=this.currentStep+1;this.$steps[t].hasClass("new-row")&&(yield this.newRow(),yield vi(xg)),t in this.nextEvents&&(yield this.nextEvents[t](this.equation),yield this.equation.animate(op),yield vi(rp)),yield this.go(t),this.trigger("next",{step:t}),this.isReady=!0})}goBack(){return D(this,null,function*(){if(!this.isReady||!this.equation.isReady||this.currentStep<=0)return;let t=this.currentStep-1;this.isReady=!1,this.currentStep in this.backEvents&&(yield this.backEvents[this.currentStep](this.equation),yield this.equation.animate()),this.$steps[this.currentStep].hasClass("new-row")&&this.hideLastRow(),yield this.go(t),this.trigger("back",{step:t}),this.isReady=!0})}go(t){return D(this,null,function*(){this.$steps[t].show();let i=this.$steps[t].height+"px";this.$steps[t].hide(),this.$legend.animate({height:i},800).promise.then(()=>this.$legend.css("height","auto"));let n=this.currentStep;this.currentStep=t,this.trigger("step",t),yield this.$steps[n].exit("fade",400).promise,this.$back.setClass("hide",t<=0),this.$next.setClass("hide",t>=this.$steps.length-1),yield this.$steps[t].enter("fade",400).promise})}};cr=T([S("x-algebra-flow",{template:np})],cr);var ap='
+
\u2212
\xD7
\xF7
\u03C0
';function cp(s){let e=s.prev;e&&_(e.tagName,"MO","MI","MN")?e.insertBefore(s):e?O(e.children).append(s):s.parent.hasClass("math")||(s.parent.prev?s.parent.prev.append(s):s.parent.parent.insertBefore(s))}function $g(s){let e=s.next;if(e&&_(e.tagName,"MO","MI","MN"))return e.insertAfter(s);e?e.children[0].prepend(s):s.parent.hasClass("math")||(s.parent.next?s.parent.next.prepend(s):s.parent.parent.insertAfter(s))}function Pg(s){let e=s.parent;for(;e.parent.tagName!=="MFRAC"||!e.prev;){if(e.hasClass("math"))return;e=e.parent}e.prev.append(s)}function Tg(s){let e=s.parent;for(;e.parent.tagName!=="MFRAC"||!e.next;){if(e.hasClass("math"))return;e=e.parent}e.next.prepend(s)}function Sg(s){let e=s.prev,t=s.parent;if(e&&_(e.tagName,"MO","MI","MN"))e.remove(),t.children.length<=1&&t.addClass("empty");else if(!e&&!t.prev&&!t.hasClass("math")){let i=t.parent;i.insertBefore(s);for(let n of i.children)for(let r of n.children)i.insertBefore(r);i.remove(),s.parent.children.length<=1&&s.parent.addClass("empty")}else cp(s)}function Ts(s,e){e.insertBefore(s),e.parent.removeClass("empty"),s.children.length&&s.children[0].append(e)}function hp(s,e){"abcdefghijklmnopqrstuvwxyz\u03C0".includes(e)?Ts(m("mi",{text:e}),s):"0123456789.".includes(e)?Ts(m("mn",{text:e}),s):"+\u2212\xB1\xD7\xF7<>\u2264\u2265=%!".includes(e)?Ts(m("mo",{text:e,value:e}),s):e==="frac"?Ts(m("mfrac",{html:''}),s):e==="sqrt"?Ts(m("msqrt",{html:''}),s):_(e,"^","sup")?Ts(m("msup",{html:''}),s):e==="brackets"||"([{|".includes(e)?Ts(m("mfenced",{html:'',type:"("}),s):")]}".includes(e)&&!s.next&&s.parent.parent.tagName==="MFENCED"&&s.parent.parent.insertAfter(s)}function lp(s,e){let t=s.$$(`${e}:first-child, *:not(${e}) + ${e}`);for(let i of t)if(i.parent.tagName!=="MFRAC")for(;i.next&&i.next.tagName===e.toUpperCase();)i.text+=i.next.text,i.next.remove()}var Eg="This is not a valid mathematical expression.",Mg="Fill in all empty placeholders in the expression.",Cg={"+":"addition","\xD7":"multiplication","/":"fractions or division","\u2212":"subtraction",sqrt:"square roots","^":"powers"};function Ss(s,e){if(s instanceof Text)return s.textContent||"";if(s.hasClass("cursor"))return"";let t=s.childNodes;return s.tagName==="MI"?s.text+(e?" ":""):s.tagName==="MFENCED"?"("+Ss(t[0],e)+")":s.tagName==="MSUP"?"^("+Ss(t[0],e)+")":s.tagName==="MFRAC"?`(${Ss(t[0],e)})/(${Ss(t[1],e)})`:s.tagName==="MSQRT"?"sqrt("+Ss(t[0],e)+")":t.map(i=>Ss(i,e)).join("")}function Ag(s,e){try{return{expr:Et.parse(s,!0,{variables:e})}}catch(t){return{error:t instanceof rt?t.message:Eg}}}function kg(s,e,t){let i=s.variables;if(e.length){let n=i.find(o=>!e.includes(o));if(n){let o=Gh(n,t||e);return o?`Did you mean \u201C${o}\u201D instead of \u201C${n}\u201D?`:`There shouldn\u2019t be a variable called \u201C${n}\u201D.`}let r=e.find(o=>!i.includes(o));if(r)return`Your expression should contain \u201C${r}\u201D.`}}function Vg(s,e){if(e.length){let t=s.functions.find(i=>!e.includes(i));if(t)return`This expression should not contain ${Cg[t]||"\u201C"+t+"\u201D"}.`}}function Ig(s,e,t=.001){try{return x(s.evaluate(),e.evaluate(),t)}catch(i){return!1}}var pr=class extends E{constructor(){super(...arguments);this.isDone=!1;this.shortVar=!1;this.lastAttempt="";this.errorCount=0;this.hints=[];this.fns=[];this.vars=[];this.validate=void 0}ready(){if(this.$math=this.$(".math"),this.$textarea=this.$("textarea"),this.$cursor=this.$(".cursor"),this.$error=this.$(".error-message"),this.solution=Et.parse(this.attr("solution")),this.hasAttr("numeric")&&(this.numeric=+this.attr("precision")||.01),this.vars=this.hasAttr("vars")?K(this.attr("vars")):this.solution?this.solution.variables:[],this.hasAttr("fns")&&(this.fns=K(this.attr("fns"))),this.solution&&this.fns.push(...this.solution.functions),this.fns.includes("/")&&!this.fns.includes("\xD7")&&this.fns.push("\xD7"),this.hasAttr("hints")&&(this.hints=K(this.attr("hints"))),this.hasAttr("substitutions")){this.substitutions={},this.autocomplete=this.vars.slice(0);for(let n of this.attr("substitutions").split("|"))if(n.trim()){let[r,o]=n.split(":");this.autocomplete.push(r.trim()),this.substitutions[r.trim()]=Et.parse(o)}}for(let n of["solution","precision","vars","fns","vars-required","substitutions"])this.removeAttr(n);this.shortVar=this.hasAttr("short-var");let t=K(this.attr("keys")||"+ \u2212 \xD7 \xF7 frac sup sqrt brackets"),i=this.$(".keys");for(let n of i.children)t.includes(n.data.type)?(n.on("pointerdown",r=>r.preventDefault()),n.on("pointerup",()=>{hp(this.$cursor,n.data.type),this.check()})):n.remove();this.on("pointerdown",n=>this.onPointerdown(n)),this.$textarea.on("focus",()=>this.onPointerdown()),this.$textarea.on("blur",()=>this.onBlur()),this.$textarea.on("key",n=>this.handleKey(n))}setup(t,i,n){var r;this.$step=t,(r=n==null?void 0:n.scores)!=null&&r.includes(i)&&this.solve(),this.on("solve",()=>{t.addHint("correct"),t.score(i)})}focus(){this.trigger("pointerdown")}onPointerdown(t){if(this.isDone)return;t&&t.preventDefault&&t.preventDefault(),this.addClass("active"),this.$textarea.focus();let i=t&&t.target?A(t.target):this;if(i.tagName==="X-EQUATION"||i.hasClass("math")){let n=this.$math.children,r=N(n.map(a=>a.outerWidth))/2;(t?Vt(t).x=5&&this.$step.addHint(`Hmmm\u2026 maybe try ${this.solution.toMathML()}?`)}check(){if(this.error=void 0,this.value=Ss(this.$math,this.shortVar).trim(),!this.value)return;if(this.$math.$(".empty"))return this.error=Mg;let t=Ag(this.value,this.vars);if(t.error)return this.error=t.error;let i=this.substitutions?t.expr.substitute(this.substitutions):t.expr;if(this.numeric&&Ig(this.solution,i,this.numeric))return this.solve();if(this.validate){let o=this.validate(t.expr)||{};if(o.isCorrect)return this.complete(t.expr);if(o.error)return this.error=o.error}if(this.solution&&Et.numEquals(this.solution,i))return this.complete(t.expr);let n=kg(i,this.vars,this.autocomplete);if(n)return this.error=n;let r=Vg(i,this.fns);if(r)return this.error=r}complete(t){this.isDone||(this.isDone=!0,this.removeClass("has-error active"),this.addClass("done"),this.$textarea.blur(),this.shortVar||lp(this.$math,"mi"),lp(this.$math,"mn"),this.trigger("solve",{expr:t}))}solve(){this.$math.removeClass("empty"),this.$math.html=this.solution.toMathML(),this.complete(this.solution)}};pr=T([S("x-equation",{template:ap})],pr);var Lg={opacity:[0,1],transform:["translateX(-50px)","none"]},Og={error:"You\u2019ve already had this expression before. Try simplifying it."},Rg="You have to fully simplify this expression. The correct solution is $0.",dr=class extends E{constructor(){super(...arguments);this.rowCount=1;this.previousAnswers=[];this.isSolved=!1;this.maxRows=6;this.steps=[];this.hints=[]}created(){this.$table=this.$("table tbody"),this.lastRowContent=this.$table.$("tr:last-child").html}ready(){this.hasAttr("max-rows")&&(this.maxRows=+this.attr("max-rows")),this.hasAttr("steps")&&(this.steps=this.attr("steps").split("|")),this.hasAttr("hints")&&(this.hints=this.attr("hints").split("|")),this.removeAttr("steps"),this.removeAttr("hints"),this.setupEquation(this.$("x-equation"))}setup(t,i,n){var r;this.$step=this.$equation.$step=t,(r=n==null?void 0:n.scores)!=null&&r.includes(i)&&this.solve(),this.on("solve",()=>{t.addHint("correct"),t.score(i)}),this.on("hint",o=>t.addHint(o))}setupEquation(t){this.$equation=t,this.$equation.$step=this.$step,t.one("solve",i=>this.onSolveRow(i.expr)),t.hints=this.hints,t.validate=i=>{let n=this.previousAnswers.includes(i.toString());return(this.validate?this.validate(i,n):void 0)||(n?Og:{})}}onSolveRow(t){if(this.trigger("solve-row",{expr:t,$math:this.$equation.$math}),this.isFinal&&this.isFinal(t))return this.trigger("solve");if(this.isSolved)return;if(this.rowCount+=1,this.previousAnswers.push(t.toString()),this.rowCount>this.maxRows){let n=this.$equation.solution.toMathML();this.trigger("hint",Rg.replace("$0",n)),this.trigger("solve")}let i=m("tr",{html:this.lastRowContent},this.$table);i.animate(Lg,400,500),this.setupEquation(i.$("x-equation")),setTimeout(()=>this.$equation.focus(),1200)}solve(){if(this.isSolved=!0,this.steps.length){let t=this.$table.$("tr:last-child"),i=this.lastRowContent.replace(//,'');for(let n of this.steps){let r=m("tr",{html:i},this.$table),o=r.$(".math.fill"),a=Et.parse(n);o.html=a.toMathML(),t.insertBefore(r),this.trigger("solve-row",{expr:a,$math:o})}}this.$equation.solve()}};dr=T([S("x-equation-system")],dr);var Ka=Math.PI/2;function ur(s){if(nt(s))return[s];if(Tt(s))return s.points;if(st(s))return[s.p1,s.p2];if(qt(s))return ur(s.shape(!0));if(U(s))return[s.c.shift(s.r,0),s.c.shift(-s.r,0),s.c.shift(0,s.r),s.c.shift(0,-s.r)];if(Ze(s))return s.extremes;if($e(s)||Dt(s)){let e=[s.start,s.end];$e(s)&&e.push(s.c);let t=s.radius;for(let[i,n]of[[t,0],[0,t],[-t,0],[0,-t]]){let r=s.c.shift(i,n);Ft.prototype.contains.call(s,r)&&e.push(r)}return e}return[]}function It(...s){return G.aroundPoints(function*(){for(let e of s)for(let t of ur(e))yield t}())}function pp(s,e){let t=It(...Array.from(s,n=>n.transformed.rotate(-e))),i=t.p.shift(t.w/2,t.h/2).rotate(e).shift(-t.w/2,-t.h/2);return new G(i,t.w,t.h)}function mr(s,e){return!s.size&&!e.size?new lt(0,100,0,100):G.aroundPoints(function*(){for(let t of s.values())if(t.transformed&&t.props.status!=="hidden")for(let i of ur(t.transformed))yield i;for(let t of e.values())if(t.path)for(let i of ur(t.path))yield i}()).bounds}function Bi(s,e,t){if(nt(e))return s.contains(e);if(Ye(e))return V.collision(s.polygon,e);if(jo(e))return e.collision(s);if(st(e))return Q(e,s).length>0||s.contains(e.p1);if(qt(e))return Bi(s,e.shape(!0),t);if(U(e))return t==="geo"?Q(e,s).length>0||s.contains(e.at(0)):e.collision(s);if($e(e)||Dt(e)){let i=new V(e.c,e.start,e.at(.25),e.at(.5),e.at(.75),e.end);return V.collision(s.polygon,i)}if(Ze(e)){let i=new V(...re(0,1,.125).map(n=>e.at(n)));return V.collision(s.polygon,i)}return!1}var fr=class{constructor(e){this.$parent=e;this.visible=!1;this.$el=m("div",{class:"tile-error",hidden:!0},e.$html),this.$text=m("span",{},this.$el),this.$button=m("button",{text:"Select Errors"},this.$el),this.$button.on("click",()=>{e.selection.clear(),this.error&&e.selection.select(this.error.locations),this.hide()})}show(e,t){this.visible&&this.error===t||(this.visible=!0,this.$el.setTransform(e),this.$text.html=t.message,this.$button.toggle(!!(t!=null&&t.locations.length)),this.$el.enter("pop",200),this.error=t)}hide(){this.visible&&(this.visible=!1,this.$el.exit("pop",200),this.error=void 0)}},Wa=new Map;function Be(s,e=!0){if(!s||!e||!b.theme.isDark)return s;if(Wa.has(s))return Wa.get(s);let t=xt.fromHex(s),i=t.hsl;it(i[2],30,70)||(i[2]=100-i[2]);let n=xt.fromHsl(...i);n.a=t.a;let r=n.hex;return Wa.set(s,r),r}var gr=Le(s=>{let e=xt.fromHex(s),[t,i,n]=["r","g","b"].map(o=>e[o]<=128?0:2*e[o]-255);return new xt(t,i,n).hex}),vr=Le(s=>xt.from(s).brightness<195?"#fff":"#000");function dp(s){let e=s==null?void 0:s.items;if(e!=null&&e.length)for(let t=0;t+d);let r=n.length>0?+n[0]:t?t[0]:0,o=n.length>1?+n[1]:t?t[1]:e;if(x(r,o))return[r-1,o+1,1];i&&(o+=.01*(o-r));let a=Math.floor(Math.abs(e)/Dg),h=(o-r)/a,l=Math.floor(Math.log10(h)),c=Math.pow(10,l),u=Ng.find(d=>c*d<=h)*c;return o=u*Math.ceil(o/u),r=u*Math.floor(r/u),[r,o,u]}function wr(s,e=4e3){let t=A(`x-alert[key=${s}]`);return t==null?void 0:t.open(e)}function up(s,e){let t=new p(-s/2,-e/2);return new G(t,s,e)}function Ya(s,e,t){if(!s)return;let i={},n=0;for(let r of s){let o=e(r);if(o&&(i[r.id]=o,n+=1),t&&n>t)break}return n?i:void 0}function fp(s,e,t,i,n){return m("use",{href:`/icons.13d4c88a.svg#${s}`,fill:e,width:t,height:t,x:i==null?void 0:i.x,y:i==null?void 0:i.y},n)}function mp(s=0){return 20*1.2**s}function*Ae(s,e=!1){for(let t of s){let i=t.is("group");(!i||e)&&(yield t),i&&(yield*As(Ae(t.children,e)))}}function*gp(s){let e=new Set;for(let t of s)if(t.group){let i=t.group;for(;i.group;)i=i.group;if(e.has(i))continue;e.add(i),yield i}else yield t}function Za(s){let e=Math.min(...s.map(i=>Math.min(...i.map(n=>n.y)))),t=Math.max(...s.map(i=>Math.max(...i.map(n=>n.y))));return[e,t]}function ke(s,e,t){return s.hasAttr(e)?s.attr(e)!=="no":t}function vp(s){let e=K(s).map(t=>+t);return e.length===1?[e[0],e[0],e[0],e[0]]:e.length===2?[e[0],e[1],e[0],e[1]]:e.length===3?[e[0],e[1],e[2],e[1]]:e}function wp(s){let e=s.split(",");return[e[0]!=="no",(e.length>1?e[1]:e[0])!=="no"]}var yp={hasGeoModel:!0,pi:Math.PI,point:(s,e)=>s!==void 0&&e!==void 0?new p(s,e):void 0,angle:(s,e,t)=>s&&e&&t?new kt(s,e,t):void 0,line:(s,e)=>s&&e&&!s.equals(e)?new vt(s,e):void 0,ray:(s,e)=>s&&e&&!s.equals(e)?new Wo(s,e):void 0,segment:(s,e)=>s&&e&&!s.equals(e)?new Y(s,e):void 0,circle:(s,e)=>s&&e?new wt(s,e):void 0,arc:(s,e,t)=>s&&e&&t?new Ft(s,e,t):void 0,sector:(s,e,t)=>s&&e&&t?new Ko(s,e,t):void 0,polygon:(...s)=>s.every(e=>e)?new V(...s):void 0,polyline:(...s)=>s.every(e=>e)?new te(...s):void 0,triangle:(s,e,t)=>s&&e&&t?new $i(s,e,t):void 0,rectangle:(s,e,t)=>s?new G(s,e,t):void 0,distance:p.distance,round:(s,e=0)=>Rt(s,e),sqrt:Math.sqrt,floor:Math.floor,ceil:Math.ceil,intersections:Q};function yr(s,e,t){let i=t,n;for(let r of s){let o=e(r);o!==void 0&&o`,is=class extends E{constructor(){super(...arguments);this.labelSuffix=["",""];this.gridSize=[1,1];this.showGrid=!1;this.showXAxis=!1;this.showYAxis=!1;this.showLabels=!1}setupCoordinates(t,i={}){this.$svg=t,t.addClass("canvas"),this.proportional=!!i.proportional,this.padding=vp(this.attr("padding")||i.padding||"0"),ke(this,"grid",i.showGrid||!1)&&(this.$grid=m("g",{class:"grid"}),t.prepend(this.$grid),this.showGrid=!0);let n=this.attr("axes")||(i.showAxes?"yes":"no");[this.showXAxis,this.showYAxis]=wp(n),(this.showXAxis||this.showYAxis)&&(m("defs",{html:Gg},t),this.$axes=m("g",{class:"axes"}),t.prepend(this.$axes),this.axisNames=(this.attr("axis-names")||",").split(",")),this.$axes&&ke(this,"labels",!0)&&(this.labelSuffix=(this.attr("label-suffix")||",").split(","),this.showLabels=!0),(this.showLabels||this.axisNames)&&(this.$labels=m("g",{class:"labels"},t)),this.resize()}resize(){this.css("max-width","none");let t=+this.attr("width")||this.width,i=+this.attr("height")||(this.hasAttr("width")?t:this.height);this.css("max-width",t+"px"),this.$svg.setAttr("width",t),this.$svg.setAttr("height",i),this.$svg.setAttr("viewBox",`0 0 ${t} ${i}`);let n=this.padding;this.viewportBounds=new lt(n[3],t-n[1],n[0],i-n[2]),this.updatePlotBounds(),this.positionElements(t,i)}updatePlotBounds(t){let[i,n,r]=Xa(this.attr("x-axis"),this.viewportBounds.dx,t==null?void 0:t.xRange),[o,a,h]=Xa(this.attr("y-axis"),this.viewportBounds.dy,t==null?void 0:t.yRange),l=Math.abs(this.viewportBounds.dx/(n-i)),c=Math.abs(this.viewportBounds.dy/(a-o)),u=Math.min(l,c),d=this.proportional?l/u:1,g=this.proportional?c/u:1;this.plotBounds=new lt(d*i,d*n,g*a,g*o),this.plotScale=this.proportional?u:(l+c)/2,this.gridSize=[r,h];let[y,f]=[this.plotBounds,this.viewportBounds];this.plotToViewportMatrix=[[f.dx/y.dx,0,f.xMin-y.xMin/y.dx*f.dx],[0,f.dy/y.dy,f.yMin-y.yMin/y.dy*f.dy]];let v=i>0?d*i:n<0?d*n:0,w=o>0?g*o:a<0?g*a:0;this.plotOrigin=new p(v,w),this.drawAxes()}drawAxes(){let[t,i]=[this.plotBounds,this.viewportBounds],n=this.toViewportCoords(this.plotOrigin),[r,o]=this.gridSize;if(this.$grid&&this.$grid.removeChildren(),this.$axes&&this.$axes.removeChildren(),this.$labels&&this.$labels.removeChildren(),this.showGrid||this.showXAxis){let a=r*Math.trunc(t.xMin/r+.01);for(let h=a;ho=void 0,move:a=>{let h=B(Math.round((a.x-n.xMin)*r),0,this.steps-1);this.points[h]=this.toPlotCoords(new p(n.xMin+h/r,a.y)),o&&this.interpolate(o,h),o=h,this.redraw()},end:()=>this.snap()})}interpolate(t,i){in).map(n=>[n.x,n.y]),i=Bo.bestPolynomial(t);if(i){for(let n=0;nt}ready(){let t=m("svg",{},this);if(this.$plot=m("g",{class:"plot"},t),this.$overlay=m("g",{class:"overlay"},t),this.setupCoordinates(t,{showGrid:!0,showAxes:!0,padding:"20"}),this.hasAttr("fn")){let i=Et.parse(this.attr("fn"),!0);this.setFunctions(n=>i.evaluate({x:n}))}ke(this,"crosshairs",!0)&&(this.crosshairGrid=+this.attr("crosshair-grid")||10,this.setupCrosshairs(t))}setPoints(t,i=1){let n=t.map((r,o)=>new p(o+i,r));this.setSeries(n)}setSeries(...t){let i=Math.max(...t.map(o=>O(o).x)),[n,r]=Za(t);this.updatePlotBounds(new lt(0,i,n,r)),this.$plot.removeChildren();for(let o of t)this.drawLinePlot(o);this.getCrosshairPosn=o=>t[0].reduce((a,h)=>Math.abs(h.x-o.x)<=Math.abs(a.x-o.x)?h:a)}setFunctions(...t){let[i,n]=[this.plotBounds,this.viewportBounds],r=t.map(l=>{let c=[];for(let u=n.xMin;u{let c=$t(B(l.x,i.xMin,i.xMax),h);return new p(c,t[0](c))}}drawLinePlot(t){let i=m("g",{},this.$plot),n=m("path",{},i),r=this.plotBounds;t=t.filter(a=>a.y>=r.yMax&&a.y<=r.yMin);let o=t.map(a=>this.toViewportCoords(a));this.isAnimated?mt(a=>{let h=t.findIndex(l=>l.x>r.xMin+a*r.dx);n.points=o.slice(0,h)},Tp):n.points=o}drawPoints(t){let i=m("g",{},this.$plot),n=this.plotBounds;for(let r of t){let o=this.toViewportCoords(r),a=m("circle",{r:4,cx:o.x,cy:o.y},i);if(this.isAnimated){a.hide();let h=Tp*(r.x-n.xMin)/(n.xMax-n.xMin);setTimeout(()=>a.show(),h)}}}setupCrosshairs(t){let i=m("g",{class:"crosshair"},t),n=m("path",{},i),r=m("circle",{r:4},i),o=m("text",{},i),a=0,h=l=>{let c=this.getCrosshairPosn(this.toPlotCoords(l));if(x(c.x,a))return;a=c.x;let u=this.toViewportCoords(c),d=this.toViewportCoords(this.plotOrigin);r.setCenter(u),n.points=[new p(d.x,u.y),u,new p(u.x,d.y)],o.text=`(${Ot(c.x,5,!1)}, ${Ot(c.y,5,!1)})`;let g=o.width,y=u.x+8+g20?u.y-7:u.y+18)};kl(t,{enter:()=>i.show(),move:l=>h(l),exit:()=>i.hide()})}};xr=T([S("x-coordinate-system")],xr);var ti=class{constructor(e,t){this.$canvas=e;this.defaultCallbacks=t;this.callbacks=new WeakMap;this.global=[];this.isMoving=!1;this.shiftKey=!1;this.altKey=!1;this.cancelled=!1;document.addEventListener("keydown",i=>this.checkKeys(i)),document.addEventListener("keyup",i=>this.checkKeys(i)),document.addEventListener("visibilitychange",()=>{this.shiftKey=this.altKey=!1}),this.$root=Xt,e.css("touch-action","none"),e.on("pointerdown",i=>this.startEvent(i)),C.onKey("Escape",()=>this.cancel()),t.hover&&e.on("pointermove",i=>{this.isMoving||t.hover({posn:fe(i,e),event:i,target:i.target})})}checkKeys(e){this.shiftKey=e.shiftKey,this.altKey=e.altKey}listen(e,t){this.callbacks.set(e._el,t),e.hasParent(this.$canvas)||(e.css("touch-action","none"),e.on("pointerdown",i=>this.startEvent(i)))}listenAll(e){this.global.push(e)}startEvent(e){var d,g,y;if(e.handled||e.button)return;this.isMoving=!0,this.cancelled=!1,e.preventDefault(),this.checkKeys(e);let t=e.pointerId,i=e.target,n=this.getCallbacks(i);"shiftKey"in e&&(this.shiftKey=e.shiftKey),n.blurInput!==!1&&((d=b.getActiveInput())==null||d.blur());let r=fe(e,this.$canvas),o=r,a=!1,h;if(this.constrainInBox){let f=this.$canvas.boundsRect;h=new lt(f.p.x,f.p.x+f.w,f.p.y,f.p.y+f.h)}let l=f=>{var $,L,k,M;if(f.pointerId&&f.pointerId!==t)return;if(f.preventDefault(),this.checkKeys(f),this.cancelled)return c(f);let v=Vt(f);if(h&&(v=v.clamp(h)),v=v.transform(this.$canvas.inverseTransformMatrix),p.distance(v,o)<.5)return;if(!a){let P={posn:r,event:f,target:i};($=n.start)==null||$.call(n,P);for(let j of this.global)(L=j.start)==null||L.call(j,P)}let w={posn:v,startPosn:r,lastPosn:o,event:f,target:i};(k=n.move)==null||k.call(n,w);for(let P of this.global)(M=P.move)==null||M.call(P,w);!a&&n.cursor!==!1&&this.grabbing(),o=v,a=!0},c=f=>{var w,$,L,k,M,P;if(f.pointerId&&f.pointerId!==t)return;f.preventDefault(),this.checkKeys(f),C.off("pointermove",l),C.off("pointerstop",c);let v={posn:r,event:f,target:i};(w=n.up)==null||w.call(n,v);for(let j of this.global)($=j.up)==null||$.call(j,v);if(a){let j={posn:o,lastPosn:o,startPosn:r,event:f,cancelled:this.cancelled,target:i};(L=n.end)==null||L.call(n,j);for(let Ue of this.global)(k=Ue.end)==null||k.call(Ue,j)}else if(!this.cancelled){(M=n.click)==null||M.call(n,v);for(let j of this.global)(P=j.click)==null||P.call(j,v)}this.grabbing(!1),this.isMoving=this.cancelled=!1},u={posn:r,event:e,target:i};(g=n.down)==null||g.call(n,u);for(let f of this.global)(y=f.down)==null||y.call(f,u);C.on("pointermove",l),C.on("pointerstop",c)}grabbing(e=!0){this.$root.setClass("grabbing",e)}getCallbacks(e){for(;e&&e!==this.$canvas._el;){let t=this.callbacks.get(e);if(t&&(!t.checkIfActive||t.checkIfActive()))return t;e=e.parentNode||void 0}return this.defaultCallbacks}cancel(){this.cancelled=!0}};function Bg(s,e){if(typeof s=="string"){let t=ct(s);return i=>{var n;return(n=t(e))==null?void 0:n.equals(i)}}return typeof s=="function"?s:t=>s.equals(t)}function Qa(s,e,t){let i=e.map(g=>Bg(g,s.model)),n=ne(void 0,e.length),r=Ke(),o=[],a=({point:g})=>o.push(g),h=t.maxErrors||4,l=0,c=({path:g})=>{t.onBegin&&t.onBegin(g)},u=()=>{n.every(g=>g)&&(t.onComplete&&t.onComplete(!0),s.off("add:path",d),s.off("begin:path",c),s.off("add:point",a),r.resolve(n))},d=({path:g})=>{let y=g.value;if(y){for(let[f,v]of i.entries())if(!n[f]&&v(y))return n[f]=g,t.onCorrect&&t.onCorrect(g,f),l=0,o=[],u();g.delete();for(let f of o)f.delete();if(o=[],!(st(y)&&y.length<1))if(l+=1,l>=h){let f=n.findIndex(w=>!w),v=e[f];if(typeof v!="function"){let w=s.drawPath(v,{animated:1e3});n[f]=w,t.onHint&&t.onHint(w,f),l=0,u()}}else t.onIncorrect&&t.onIncorrect(g)}};return s.on("begin:path",c),s.on("add:path",d),s.on("add:point",a),r.promise}function Mp(s,e){return m("text",{target:s.attr("target")||void 0,class:s.attr("label-class")||s.attr("class")||void 0,"data-when":s.data.when,style:e?`color: ${e}`:void 0,"text-anchor":"middle"})}function Sp(s,e){let t=[];for(let i of e.paths)i!==s&&i.value&&t.push(i.value.transform(e.plotToViewportMatrix));return t}var _g=new wt(new p(0,-9),12);function Ep(s,e,t){for(let i of t)if(e.every(n=>!Q(_g.translate(i),n).length))return i;return t[0]}function Cp(s,e){let t=s.value.transform(e.plotToViewportMatrix),i=s.$el;if(st(t)){let n=t.perpendicularVector,r=t.angle;n.y>=0&&(n=n.scale(-1),r+=Math.PI);let o=[];for(let l of[.5,.35,.65])for(let c of[-15,5])o.push(t.at(l).add(n.scale(c)));if(!e.labelPositioning)return[o[0],r];let a=Sp(s,e),h=Ep(t,a,o);return i.hasAttr("mark")&&(h=h.add(t.unitVector.scale(12))),[h,r]}if($e(t))return[t.at(.5).subtract(t.c).scale(.6).add(t.c).shift(0,5)];if(Dt(t)){let n=new vt(t.start,t.end),r=n.perpendicularVector.y>=0,o=n.angle+(r?Math.PI:0);return[t.at(.5).add(n.perpendicularVector.scale(r?14:5)),o]}if(qt(t)){let n=(+i.attr("size")||(t.isRight&&!i.hasAttr("round")?20:t.radius))+8;return[t.b.add(t.bisector.unitVector.scale(n+5)).shift(0,3)]}if(nt(t)){let n=i.hasClass("move")?10:8,r=[t.shift(n,-n),t.shift(-n,-n),t.shift(n,10+n),t.shift(-n,10+n)];if(!e.labelPositioning)return[r[0]];let o=Sp(s,e);return[Ep(t,o,r)]}return Tt(t)?[t.centroid.shift(0,5)]:U(t)?[t.c.shift(0,5)]:[]}var $r=class{constructor(e,t,i,n){this.$parent=e;this.$el=i;this.color="";this.label="";this.isPending=!1;this.isLocked=!1;this.components=[];this.dependencies=[];this.fixedLabel=!1;this.name=n||e.model.getKey(),e.shapes.set(this.name,this),e.model.watch(r=>{let o=r[this.name];this.$el.css("display",o?"block":"none"),this.$label&&this.$label.css("display",o?"block":"none"),o&&this.redraw(o),e.queueLabelPositioning()}),this.color=i.css("color")||"",this.setValue(t),i.hasAttr("label")&&this.setLabel(i.attr("label"))}get value(){return this.$parent.model[this.name]}get type(){var e;return(e=this.value)==null?void 0:e.type}get locked(){return this.isLocked}get isHidden(){return this.isPending||this.$el.hasAttr("hidden")||this.$el.hasClass("transparent")}setValue(e){e instanceof Function?this.$parent.model.setComputed(this.name,e):this.$parent.model[this.name]=e}setLabel(e,t,i){this.$label||(this.$label=Mp(this.$el,t),this.$parent.$objLabels.append(this.$label));let n=vn(e);if(this.$parent.model.watch(r=>this.$label.text=n(r)||""),this.fixedLabel=!!i,i){let r=ct(i);this.$parent.model.watch(o=>{this.$label.setTransform(r(o).shift(0,5))})}this.updateLabelPosition()}setColor(e){this.color=e,this.$el.css("color",e);for(let t of this.dependencies)t.setColor(e);this.$label&&this.$label.css("color",e)}updateLabelPosition(){if(!this.$label||!this.value||this.fixedLabel)return;let[e,t]=Cp(this,this.$parent);this.$label.setTransform(e,t)}select(){this.$el.addClass("selected"),this.$el.parent.append(this.$el);for(let e of this.dependencies)e.select()}deselect(){this.$el.removeClass("selected");for(let e of this.dependencies)e.deselect()}hover(e=!1){if(!e){if(this.$parent.hovering===this)return;this.$parent.hovering&&this.$parent.hovering.unhover(),this.$parent.hovering=this}this.$el.addClass("hover");for(let t of this.dependencies)t.hover(!0)}unhover(e=!1){if(!e){if(this.$parent.hovering!==this)return;this.$parent.hovering=void 0}this.$el.removeClass("hover");for(let t of this.dependencies)t.unhover(!0)}delete(e=300){return D(this,null,function*(){this.$parent.shapes.delete(this.name);for(let t of this.components)t.deselect();this.$label&&this.$label.exit("fade",e,0,!0),yield this.removeElement(e),this.$parent.model[this.name]=void 0})}},Ve=class extends $r{constructor(t,i,n,r,o=!1){r||(r=m("circle",{}));super(t,i,r,n);this.$parent.hidePoints||t.$points.append(this.$el),t.points.add(this),this.projectionId=t.model.getKey(),this.projectionOffset=void 0,t.model.watch(a=>{this.projection=a[this.projectionId],this.projection&&(this.projectionOffset===void 0&&(this.projectionOffset=this.projection.offset(this.$parent.model[this.name])),this.$parent.model[this.name]=this.projection.at(this.projectionOffset))}),this.lock(o)}setValue(t){t instanceof Function?(this.project(void 0),this.$parent.model.setComputed(this.name,t)):(t&&this.projection&&(t=this.projection.project(t),this.projectionOffset=this.projection.offset(t)),this.$parent.model[this.name]=t)}redraw(t){let i=t.transform(this.$parent.plotToViewportMatrix);this.$el.setCenter(i),this.$halo&&this.$halo.setCenter(i),this.$pulse&&this.$pulse.setCenter(i)}removeElement(t){return D(this,null,function*(){this.$parent.points.delete(this),yield this.$el.exit("pop",t,0,!0).promise})}distance(t){return this.value?p.distance(t,this.value):1/0}lock(t=!0){this.isLocked=t,this.$el.setClass("move",!t),t?this.$el.removeAttr("tabindex"):this.$el.setAttr("tabindex",0)}project(t){if(this.projectionOffset=void 0,typeof t=="string"){let i=ct(t);this.$parent.model.setComputed(this.projectionId,i)}else t?this.$parent.model.setComputed(this.projectionId,()=>t.value):this.$parent.model[this.projectionId]=void 0}makeIntersection({path1:t,path2:i,index:n}){this.setValue(r=>{if(!r[t.name]||!r[i.name])return;let o=Q(r[t.name],r[i.name]);return o[Math.min(n,o.length-1)]}),this.lock()}addHalo(){this.$halo=m("circle",{class:"halo",r:18},this.$parent.$pulses),this.$halo.setCenter(this.$el.center),this.$halo.enter("pop")}removeHalo(){return D(this,null,function*(){this.$halo&&(this.$halo.exit("pop",500,0,!0),this.$halo=void 0)})}pulsate(){this.$pulse=m("circle",{class:"pulse",r:8},this.$parent.$pulses),this.$pulse.setCenter(this.$el.center),this.$el.one("mouseover pointerdown focus",()=>{this.$pulse&&this.$pulse.remove(),this.$pulse=void 0})}},_e=class extends $r{constructor(e,t,i,n){super(e,t,n||m("path"),i),e.$paths.append(this.$el),e.paths.add(this)}get locked(){return this.isLocked||!this.components.length||this.components.every(e=>e.locked)}redraw(e){let t=e.transform(this.$parent.plotToViewportMatrix);this.$el.draw(t,{box:this.$parent.viewportRect})}distance(e){return this.value?p.distance(e,this.value.project(e)):1/0}removeElement(e){return D(this,null,function*(){this.$parent.paths.delete(this),yield this.$el.exit("draw",e,0,!0).promise})}setComponents(e,t){this.components=this.dependencies=e,this.setValue(()=>{let i=e.map(n=>n.value);if(!i.some(n=>n===void 0))return t(...i)})}};var _i=class{constructor(e){this.$parent=e}enable(){}down(e){}start(e){}move(e,t){}end(e){}hover(e){}click(e){}cancel(){}snapToGrid(e){return this.$parent.snapToGrid?e.round(this.$parent.snapToGrid):e}snapToPoint(e,t){if(this.snapPoint=this.$parent.getPointAt(t),this.snapPoint)return e.$el.setClass("move",!this.snapPoint.locked),e.setValue(this.snapPoint.value);if(this.snapIntersect=this.$parent.getIntersectionAt(t),this.snapIntersect)return e.$el.removeClass("move"),e.setValue(this.snapIntersect.posn);if(!this.$parent.snapToGrid&&(this.snapPath=this.$parent.getPathAt(t),this.snapPath))return e.setValue(this.snapPath.value.project(t));e.$el.addClass("move"),e.setValue(this.snapToGrid(t))}getOrMakePointAt(e){let t=this.$parent.getPointAt(e);if(!t){t=new Ve(this.$parent,this.snapToGrid(e));let i=this.$parent.getIntersectionAt(e);if(i)t.makeIntersection(i);else if(!this.$parent.snapToGrid){let n=this.$parent.getPathAt(e);n&&t.project(n)}this.$parent.trigger("add:point",{point:t})}return t}showPendingPointAt(e){var n,r,o;let t=((n=this.$parent.getIntersectionAt(e))==null?void 0:n.posn)||((o=(r=this.$parent.getPathAt(e))==null?void 0:r.value)==null?void 0:o.project(e)),i=!!t;if(this.$parent.$pendingPoint.toggle(i),i){let a=this.$parent.toViewportCoords(t||e);this.$parent.$pendingPoint.setCenter(a)}}},qi=class extends _i{constructor(){super(...arguments);this.isMoving=!1}enable(){}down(t){this.obj=this.$parent.getPointAt(t)||this.$parent.getPathAt(t),this.obj||this.$parent.deselect();let i=this.$parent.selection;i!==this.obj&&(i&&i.components.includes(this.obj)||this.$parent.select(this.obj))}start(){this.obj&&(this.isMoving=!0,this.obj.isPending=!0,this.$parent.updateIntersections(),this.$parent.trigger("move",{obj:this.obj}))}move(t,i){if(!(!this.obj||this.obj.locked||this.$parent.locked))if(this.obj instanceof _e){let n=t.subtract(i);for(let r of this.obj.components)r.locked||r.setValue(r.value.add(n))}else this.obj instanceof Ve&&this.obj.setValue(this.snapToGrid(t))}end(){this.obj&&(this.isMoving=!1,this.obj.isPending=!1,this.snapPoint||(this.snapIntersect?this.obj.makeIntersection(this.snapIntersect):this.snapPath&&this.obj.project(this.snapPath)),this.$parent.trigger("moveEnd",{path:this.obj}),this.obj=void 0,this.$parent.updateIntersections())}hover(t){if(this.isMoving)return;let i=this.$parent.getPointAt(t)||this.$parent.getPathAt(t),n=i&&!this.$parent.locked&&!i.locked,r=i&&this.$parent.canSelect;this.$parent.setCursor(n?"grab":r?"pointer":"default"),n||r?i.hover():this.$parent.hovering&&this.$parent.hovering.unhover()}},Pr=class extends qi{down(e){this.$parent.deselect(),this.obj=this.getOrMakePointAt(e),this.$parent.select(this.obj)}hover(e){let t=this.$parent.getPointAt(e);if(t)return this.$parent.setCursor(this.$parent.locked||t.locked?"default":"grab"),this.$parent.$pendingPoint.hide(),t.hover();this.$parent.hovering&&this.$parent.hovering.unhover(),this.$parent.setCursor("crosshair"),this.showPendingPointAt(e)}},ei=class extends _i{enable(){this.$parent.setCursor("crosshair")}down(t){this.$parent.deselect(),this.startPoint=this.getOrMakePointAt(t)}start(t){this.startPoint&&(this.$parent.$pendingPoint.hide(),this.endPoint=new Ve(this.$parent,t),this.endPoint.isPending=!0,this.endPoint.$el.addClass("pending"),this.path=new _e(this.$parent,void 0),this.path.setComponents([this.startPoint,this.endPoint],this.expr),this.path.isPending=!0,this.$parent.updateIntersections(),this.$parent.trigger("begin:path",{path:this.path,start:this.startPoint}))}move(t){if(!this.startPoint||!this.path||!this.endPoint)return;if(p.distance(t,this.startPoint.value)<20/this.$parent.plotScale)return this.endPoint.setValue(this.snapToGrid(t));this.snapToPoint(this.endPoint,t)}end(){if(!this.startPoint||!this.path||!this.endPoint)return;this.path.isPending=!1,this.endPoint.isPending=!1,this.startPoint.value.equals(this.endPoint.value)?(this.endPoint.delete(),this.path.delete(),this.path=this.endPoint=void 0):this.snapPoint?(this.path.setComponents([this.startPoint,this.snapPoint],this.expr),this.endPoint.delete(),this.endPoint=void 0):this.snapIntersect?this.endPoint.makeIntersection(this.snapIntersect):this.snapPath&&this.endPoint.project(this.snapPath),this.endPoint&&(this.$parent.trigger("add:point",{point:this.endPoint}),this.endPoint.$el.removeClass("pending"));let t=this.path;this.startPoint=this.endPoint=this.path=void 0,t&&(this.$parent.trigger("add:path",{path:t}),this.$parent.updateIntersections())}hover(t){let i=this.$parent.getPointAt(t);if(i)return this.$parent.$pendingPoint.hide(),i.hover();this.$parent.hovering&&this.$parent.hovering.unhover(),this.showPendingPointAt(t)}cancel(){this.endPoint&&this.endPoint.delete(),this.path&&this.path.delete(),this.$parent.$pendingPoint.hide(),this.startPoint=this.endPoint=this.path=void 0}},Tr=class extends ei{expr(e,t){return new Y(e,t)}},Sr=class extends ei{expr(e,t){return new wt(e,p.distance(e,t))}},Er=class extends ei{expr(e,t){return new G(e,t.x-e.x,t.y-e.y)}},Mr=class extends ei{expr(e,t){return new Y(e,t).perpendicularBisector}},Ap=(s,e,t)=>new kt(s,e,t).bisector,Cr=class extends _i{enable(){}down(t){if(this.$parent.deselect(),!this.firstPoint)this.firstPoint=this.getOrMakePointAt(t),this.firstPoint&&this.firstPoint.addHalo();else if(this.secondPoint){this.path.isPending=this.thirdPoint.isPending=!1,this.thirdPoint.$el.removeClass("pending"),this.firstPoint.removeHalo(),this.secondPoint.removeHalo(),this.snapPoint?(this.path.setComponents([this.firstPoint,this.secondPoint,this.snapPoint],Ap),this.thirdPoint.delete(),this.thirdPoint=void 0):this.snapIntersect?this.thirdPoint.makeIntersection(this.snapIntersect):this.snapPath&&this.thirdPoint.project(this.snapPath);let i=this.path,n=this.thirdPoint;this.firstPoint=this.secondPoint=this.thirdPoint=this.path=void 0,n&&this.$parent.trigger("add:point",{point:n}),this.$parent.trigger("add:path",{path:i}),this.$parent.updateIntersections()}else{if(this.secondPoint=this.getOrMakePointAt(t),!this.secondPoint)return;this.secondPoint.addHalo(),this.thirdPoint=new Ve(this.$parent,this.secondPoint.value),this.thirdPoint.$el.addClass("pending"),this.path=new _e(this.$parent,void 0),this.path.setComponents([this.firstPoint,this.secondPoint,this.thirdPoint],Ap),this.path.isPending=this.thirdPoint.isPending=!0}}hover(t){if(this.$parent.$pendingPoint.hide(),this.thirdPoint){this.snapToPoint(this.thirdPoint,t),this.$parent.setCursor(this.snapPoint?"pointer":"crosshair");return}let i=this.$parent.getPointAt(t);if(i)return this.$parent.setCursor("pointer"),i.hover();this.$parent.hovering&&this.$parent.hovering.unhover(),this.$parent.setCursor("crosshair"),this.showPendingPointAt(t)}cancel(){this.firstPoint&&this.firstPoint.removeHalo(),this.secondPoint&&this.secondPoint.removeHalo(),this.thirdPoint&&this.thirdPoint.delete(),this.path&&this.path.delete(),this.firstPoint=this.secondPoint=this.thirdPoint=this.path=void 0}};var kp='
';var Ar=class extends is{constructor(){super(...arguments);this.shapes=new Map;this.points=new Set;this.paths=new Set;this.intersections=new Set;this.snapToGrid=0;this.locked=!1;this.hidePoints=!1;this.canSelect=!1;this.canIntersect=!1;this.canProject=!0;this.labelPositioning=!1;this.cursor="default"}ready(){let t=this.children.filter(h=>h.tagName==="SVG")[0];if(this.hasAttr("complex")&&(this.setAttr("label-suffix",",i"),this.setAttr("axis-names","Real, Imaginary"),this.setAttr("axes","true"),this.setAttr("grid","true")),!this.hasAttr("x-axis")&&!this.hasAttr("y-axis")){let h=+this.attr("grid"),l=+this.attr("width")||this.width,c=+this.attr("height")||l;this.setAttr("x-axis",h?`-0.5,${l/h-.5},1`:`0,${l},1`),this.setAttr("y-axis",h?`${c/h-.5},-0.5,1`:`${c},0,1`),h&&this.setAttr("snap",1)}this.setupCoordinates(t,{proportional:!0}),this.viewportRect=this.viewportBounds.rect,this.model=this.getParentModel()||he({}),this.model.hasGeoModel||this.model.assign(yp),this.$paths=m("g",{class:"paths"},t),this.$pulses=m("g",{class:"pulses"},t),this.$points=m("g",{class:"points"},t),this.$objLabels=m("g",{class:"labels"},t),this.snapToGrid=this.hasAttr("snap")?+this.attr("snap")||1:0,this.hidePoints=this.hasAttr("no-points"),this.canIntersect=ke(this,"intersections",!1),this.canProject=ke(this,"projections",!0),this.canSelect=ke(this,"selectable",!1),this.labelPositioning=ke(this,"label-positioning",!0),this.hasClass("sticky")&&this.css("top",`calc(50vh - ${this.height/2}px)`),this.queueLabelPositioning=ge(()=>{for(let h of this.shapes.values())h.updateLabelPosition()},0,!0);let i=t.$$("path[x], path[\\:d], circle");for(let h of i){let l=h.hasAttr("x")?ct(h.attr("x")):void 0,c=h.attr("name");if(h.hasAttr(":d"))this.$paths.append(h),h.bindModel(this.model);else if(h.tagName==="PATH")this.$paths.append(h),new _e(this,l,c,h);else{this.$points.append(h);let u=!h.hasClass("move"),d=l||h.center,g=new Ve(this,d,c,h,u);h.hasAttr("project")&&g.project(h.attr("project")),h.hasClass("pulsate")&&g.pulsate()}}this.$pendingPoint=m("circle",{class:"pending"},this.$points),this.$pendingPoint.hide(),this.updateIntersections();let n={move:new qi(this),point:new Pr(this),line:new Tr(this),circle:new Sr(this),perpBisector:new Mr(this),angleBisector:new Cr(this),rectangle:new Er(this)};this.$tools=this.$(".tools");let r=n[this.$tools.$active.data.tool];r.enable();let o=()=>this.toolOverride||r;this.$tools.on("change",h=>{o().cancel(),this.toolOverride=void 0,r=n[h.data.tool],this.hovering&&this.hovering.unhover(),this.$pendingPoint.hide(),this.hovering=void 0,this.deselect(),r.enable()});let a=(h,l=!1)=>this.toPlotCoords(l?h.clamp(this.viewportBounds,8):h);new ti(t,{down:h=>o().down(a(h.posn)),start:h=>o().start(a(h.posn)),move:h=>o().move(a(h.posn,!0),a(h.lastPosn,!0)),end:h=>o().end(a(h.posn,!0)),click:h=>o().click(a(h.posn)),hover:h=>o().hover(a(h.posn))}),C.onKey("Escape",()=>o().cancel()),C.onKey("Backspace Clear Delete",()=>this.delete()),document.addEventListener("keydown",h=>{if([37,38,39,40].indexOf(h.keyCode)<0)return;let c=b.getActiveInput();if(!(!c||!c.hasParent(this))){h.preventDefault();for(let u of this.points){if(u.$el!==c||!u.value)continue;let d=15/this.plotScale,g=this.plotBounds.yMin>this.plotBounds.yMax?-1:1,y=h.keyCode===37?-d:h.keyCode===39?d:0,f=h.keyCode===38?-g*d:h.keyCode===40?g*d:0;u.setValue(u.value.shift(y,f));return}}})}switchTool(t){this.$tools.makeActive(this.$(`.tool[data-tool="${t}"]`))}setCursor(t="default"){t!==this.cursor&&(this.cursor=t,this.$svg.css("cursor",t))}select(t){this.canSelect&&(this.deselect(),t&&(this.selection=t,t.select()),this.trigger("select",{shape:t}))}deselect(){this.selection&&(this.selection.deselect(),this.selection=void 0,this.trigger("select",{shape:void 0}))}delete(){this.hovering&&this.hovering.unhover(),this.selection&&this.selection.delete(),this.trigger("select",{shape:void 0})}redraw(){this.resize(),this.viewportRect=this.viewportBounds.rect,this.model.forceUpdate()}getPointAt(t,i=20){if(this.hidePoints)return;let n=r=>r.isHidden?void 0:r.distance(t);return yr(this.points,n,i/this.plotScale)}getPathAt(t,i=10){if(this.hidePoints||!this.canProject)return;let n=r=>r.isHidden?void 0:r.distance(t);return yr(this.paths,n,i/this.plotScale)}getIntersectionAt(t,i=20){if(!this.canIntersect)return;let n=r=>p.distance(t,r.posn);return yr(this.intersections,n,i/this.plotScale)}updateIntersections(){!this.canIntersect||this.hidePoints||bp(this.paths,this.intersections)}drawPath(t,i={}){typeof t=="string"&&(t=ct(t));let n=new _e(this,t,i.name);i.classes&&n.$el.addClass(i.classes),i.target&&n.$el.setAttr("target",i.target);let r=n.$el.hasClass("fill")?"fade":"draw";return i.animated&&n.$el.enter(r,i.animated),n}drawPoint(t,i={}){typeof t=="string"&&(t=ct(t));let n=new Ve(this,t,i.name,void 0,i.interactive===!1);return i.classes&&n.$el.addClass(i.classes),i.target&&n.$el.setAttr("target",i.target),i.animated!==0&&n.$el.enter("pop",i.animated||500),n}animatePoint(t,i,n=400){let r=this.shapes.get(t),o=new Y(this.model[t],i);return mt(a=>r.setValue(o.at(St("quad",a))),n)}animateConstruction(t,i=2e3){return D(this,null,function*(){let n=this.shapes.get(t),r=n.value;if(U(r)&&(r=r.arc),st(r)){this.$ruler||(this.$ruler=m("path",{d:$p,class:"sketch"},this.$svg));let o=Es(r.at(-.1),12,r.angle-.3,r.length*1.2),a=Es(r.at(-.1),12,r.angle,r.length*1.2);this.$ruler.show(),n.$el.hide(),yield this.$ruler.animate({opacity:[0,1],transform:[o,a]},500).promise,yield n.$el.enter("draw",i).promise,yield this.$ruler.animate({opacity:[1,0],transform:[a,o]},500).promise}else if(Dt(r)){this.$compass||(this.$compass=m("path",{d:xp,class:"sketch"},this.$svg));let o=Es(r.c,50,r.startAngle,r.radius*1.5),a=Es(r.c,50,r.startAngle,r.radius),h=Es(r.c,50,r.startAngle+r.angle,r.radius),l=Es(r.c,50,r.startAngle+r.angle,r.radius*1.5);this.$compass.show(),n.$el.hide(),yield this.$compass.animate({opacity:[0,1],transform:[o,a]},500).promise,n.$el.enter("draw",i),yield this.$compass.animate({transform:[a,h]},i,0,"linear").promise,yield this.$compass.animate({opacity:[1,0],transform:[h,l]},500).promise}})}showGesture(t,i){this.$gesture||(this.$gesture=m("x-gesture",{},this)),this.$gesture.stop();let n=this.toViewportCoords(ct(t)(this.model));if(this.$gesture.from=n,i){let r=this.toViewportCoords(ct(i)(this.model));this.$gesture.start(r.subtract(n))}else this.$gesture.start();this.one("click mouseover pointerdown",()=>this.$gesture.stop())}waitForPoint(){return D(this,null,function*(){return new Promise(t=>{this.one("add:point",({point:i})=>t(i))})})}waitForPath(n){return D(this,arguments,function*(t,i={}){return(yield Qa(this,[t],i))[0]})}waitForPaths(t,i={}){return Qa(this,t,i)}};Ar=T([S("x-geopad",{template:kp})],Ar);var Vp='
';var kr=class extends E{ready(){let e=this.$(".image"),t=this.positionTop<50,i,n;e.css({"background-image":`url("${this.attr("background")}")`,height:t?"100%":"150%"});let r=({height:a})=>{let h=this.positionTop;i=Math.max(0,h-a),n=h+this.height};function o(a){if(a.topn)return;let h=(a.top-i)/(n-i)*(t?50:33);e.css("transform",`translateY(${h}%)`)}b.onResize(r),C.on("scroll",o)}};kr=T([S("x-parallax",{template:Vp})],kr);var et=new AudioContext,Ir,qe,Vr=.05,Rp="/polypad/assets/audio/samples/",Ip=new Map,Dp=new Map,Lp=!1;function qg(){return D(this,null,function*(){if(Lp)return;Lp=!0,qe=et.createDynamicsCompressor(),qe.threshold.setValueAtTime(-15,0),qe.knee.setValueAtTime(1,0),qe.ratio.setValueAtTime(2,0),qe.attack.setValueAtTime(1e-5,0),qe.release.setValueAtTime(1,0),Ir=et.createConvolver();let e=yield(yield fetch(`${Rp}IR13.mp3`)).arrayBuffer();Ir.buffer=yield et.decodeAudioData(e)})}function Np(s){if(!s||s==="synth"||Ip.has(s))return;let e=fetch(`${Rp}${s}.mp3`).then(t=>t.arrayBuffer()).then(t=>et.decodeAudioData(t)).then(t=>Dp.set(s,t)).catch(()=>console.error("Unable to load sample for",s));Ip.set(s,e)}var Ja={piano:{label:"Piano",pitch:-6,vol:-1.5},epiano:{label:"E-Piano",pitch:-1,vol:-2},organ:{label:"Organ",pitch:-1,vol:-1.75},marimba:{label:"Marimba",pitch:1},synth:{label:"Synth"},bass:{label:"Synth Bass",pitch:6.2,vol:-1.75,icon:"synth"},aguitar:{label:"Guitar",pitch:5},eguitar:{label:"E-Guitar",vol:-2},violin:{label:"Violin",vol:-1.75},cello:{label:"Cello",vol:-1.5},banjo:{label:"Banjo",vol:3},trumpet:{label:"Trumpet",vol:-1.75,pitch:-14},clarinet:{label:"Clarinet",pitch:-2,vol:-2},ubass:{label:"Upright Bass",vol:2,icon:"cello"},kick:{label:"Kick",noLoop:!0},snare:{label:"Snare",noLoop:!0},"tom-high":{label:"High Tom",noLoop:!0},"tom-low":{label:"Low Tom",noLoop:!0},"hihat-open":{label:"Open HiHat",noLoop:!0,icon:"hihat"},"hihat-closed":{label:"HiHat",noLoop:!0,icon:"hihat"},ride:{label:"Ride Cymbal",noLoop:!0},crash:{label:"Crash Cymbal",noLoop:!0},cowbell:{label:"Cowbell",noLoop:!0},tambo:{label:"Tambourine",noLoop:!0},bongo:{label:"Bongos",noLoop:!0},shaker:{label:"Shaker",noLoop:!0},woodblock:{label:"Woodblock",noLoop:!0},voice:{label:"Vocal",vol:-1.5},clap:{label:"Clap",noLoop:!0},snap:{label:"Snap",noLoop:!0},ting:{label:"Ting",pitch:5.5},honk:{label:"Honk",pitch:-2,noLoop:!0},scraper:{label:"Scraper",noLoop:!0},boing:{label:"Spring",noLoop:!0,pitch:7},vibraslap:{label:"Vibraslap",noLoop:!0},cow:{label:"Cow",vol:-1.75,noLoop:!0},bark:{label:"Dog",noLoop:!0},duck:{label:"Duck",noLoop:!0},pig:{label:"Pig",noLoop:!0},rooster:{label:"Rooster",pitch:-5,noLoop:!0}},Fg=440*2**(-9/12);var Hg={none:[],percussion:[],major:[0,2,4,5,7,9,11],minor:[0,2,3,5,7,8,10],blues:[0,3,5,6,7,10],pentatonic:[0,2,4,7,9],chromatic:re(12)};function eh(s,e,t=0,i){if(s==="none")return 0;i&&(e=t-e-1);let n=Hg[s],r=gt(e,n.length);return Math.round((e-r)/n.length)*12+n[r]}function Gp(s,e,t){let i=et.createGain();i.connect(qe),i.connect(Ir).connect(qe).connect(et.destination);let n=s+1e-5;return i.gain.setValueAtTime(1e-5,n),i.gain.linearRampToValueAtTime(e,n+=t[0]),i.gain.linearRampToValueAtTime(e*.8,n+=t[1]),i.gain.setValueAtTime(e*.8,n+=t[2]),i.gain.linearRampToValueAtTime(1e-5,n+t[3]),i}function Fi(s,e="piano"){return s===void 0?0:e==="synth"?Fg*2**(s/12):2**((s+(Ja[e].pitch||0))/12)||0}function jg(s,e,t,i,n){let r=Dp.get(s);if(!r)throw new Error(`Missing audio sample: ${s}`);let o=Gp(t,i,n),a=et.createBufferSource(),h=Fi(e,s);a.playbackRate.value=h,a.buffer=r,a.connect(o),a.start(t);let l=[a],c=a.buffer.duration/h,u=c*.5>1.5?1.1:c*.9,d=n[2]/.6,g=d/u;if(d>1.1&&!Ja[s].noLoop)for(let y=1;ythis.stop())}play(e=et.currentTime+Vr,t=1){if(!this.setup)return 0;this.isPlaying&&this.stop(),this.isPlaying=!0,this.tempo=(this.tile.props.tempo||1)*t;let i=this.tile.props.note||0;if(this.currentData=this.setup(i,this.tempo),!this.currentData.beats.length)return this.isPlaying=!1,this.currentData=void 0,0;let n=O(this.currentData.beats);return this.duration=(n.time+n.duration)/this.tempo,this.start=e,this.lastBeat=-1,Op.add(this),this.duration}stop(){var e,t;if(this.isPlaying){Op.remove(this),window.clearInterval(this.timeout),this.isPlaying=!1,(t=(e=this.currentData).end)==null||t.call(e);for(let i of this.stopCont)i.stop();this.stopCont.clear(),this.currentData=void 0,this.tile.$parent.selection.update()}}tick(){var o,a;let e=et.currentTime,t=this.currentData.beats,i=(e-this.start)*this.tempo,n=t.findIndex(h=>h.time>=i);n<0&&(n=t.length-1);for(let h=this.lastBeat+1;h<=n;++h)this.processStep(h);(a=(o=this.currentData).tick)==null||a.call(o,i<0?0:i);let r=this.start+this.duration-e;this.lastBeat>=t.length-1&&r<=0&&this.stop()}processStep(e){var h,l;let t=this.currentData.beats[e],i=this.start+t.time/this.tempo;if(i>et.currentTime+Vr)return;let n=((h=this.tile.props.volume)!=null?h:1)+((l=t.volume)!=null?l:0),r=t.duration/this.tempo,o=t.sound||this.tile.props.sound||"piano";if(t.note instanceof Function)this.playContinuous(t.note,o,i,r,n);else{let c=Array.isArray(t.note)?t.note:[t.note];for(let u of c)this.playNote(u,o,i,r,n)}let a=i-et.currentTime;this.timeout=Zt(()=>{var c,u;return(u=(c=this.currentData).step)==null?void 0:u.call(c,e)},a*1e3),this.lastBeat=e}playNote(e,t=this.tile.props.sound||"piano",i=et.currentTime+Vr,n=.8,r=this.tile.props.volume||1){return Wg(e,t,r,n,i,this.tile.props.modGain,this.tile.props.modFreq)}playContinuous(e,t,i,n,r){let o=this.playNote(Fi(e(0)),t,i,n,r),a=o instanceof OscillatorNode,h=1/60;for(let l=0;l<=n;l+=h){let c=Fi(e(l*this.tempo),t);if(a)o.frequency.setValueAtTime(c,i+l);else for(let u of o)u.playbackRate.setValueAtTime(c,i+l)}if(a)this.stopCont.add(o);else for(let l of o)this.stopCont.add(l)}},th=class{constructor(){this.running=!1;this.tracks=new Set}add(e){this.tracks.add(e),this.running||(et.state!=="running"&&et.resume(),this.running=!0,this.tick(),requestAnimationFrame(()=>this.tick()))}remove(e){this.tracks.delete(e),this.tracks.size||(this.running=!1)}tick(){for(let e of this.tracks)e.tick();this.running&&requestAnimationFrame(()=>this.tick())}},Op=new th;var Kg=new Set(["watch","assign","updateTheme","flushChanges","raw","copy"]);function zp(s,e){let t,i=new Set,n=!0,r=new Map,o=(u,d)=>{for(let g of K(u))r.has(g)||r.set(g,[]),r.get(g).push(d);d(c)},a=u=>{let d=Object.keys(u).filter(y=>u[y]!==s[y]);if(!d.length)return;Object.assign(s,u),e.$parent.pendingChanges.add(e);for(let y of d)i.add(y);let g=Wt(d.flatMap(y=>{var f;return(f=r.get(y))!=null?f:[]}));for(let y of g)y(c)},h=()=>{var u;for(let d of(u=r.get("color"))!=null?u:[])d(c)},l=()=>{if(e.isDeleting)return i.clear(),n?void 0:[t,void 0];let u=t;if(t=Object.assign({},s),n)return i.clear(),n=!1,[void 0,t];let d={},g={},y=!1;for(let f of i)t[f]!==u[f]&&(y=!0,d[f]=t[f],g[f]=u[f]);return i.clear(),y?[g,d]:void 0},c=new Proxy(s,{get(u,d){switch(d){case"watch":return o;case"assign":return a;case"updateTheme":return h;case"flushChanges":return l;case"raw":return s;case"copy":return()=>Object.assign({},s);case"zIndex":return s.zIndex||0;case"layer":return s.layer||"normal";case"color":return Be(s.color,e.$parent.flipTheme);default:return s[d]}},set(u,d,g){var y;if(Kg.has(d))return!1;if(s[d]===g)return!0;s[d]=g;for(let f of(y=r.get(d))!=null?y:[])f(c);return e.$parent.pendingChanges.add(e),i.add(d),!0}});return c}function Bp(s){let e=s.signedArea<0,t=0;for(let[n,r]of s.points.entries())r.ys.points[t].x||(t=n);let i=hs(s.points,t+(e?1:0));return e&&(i=i.reverse()),new V(...i)}function sh(s,e,t=0){let i=s.centroid.x,n=Math.max(...s.points.map(r=>r.y))+42+t;return m("text",{x:i,y:n,style:"font-size:25px"},e)}function Xg(s,e,t,i){e.removeChildren();let n=s.is("polyomino"),r=Bp(s.path),o=r.edges,a=as(o.map(k=>k.length)),h=O(a),l=gr(s.props.color),c=z(k=>{let M=eh(s.props.musicScale||"major",k,o.length,s.props.musicScaleRev),P=(a[k-1]||0)*.01;return{note:t+M,time:P,duration:o[k].length*.01}},o.length),u=m("g",{filter:"url(#outline)"},e),d=m("g",{class:"axis-label",fill:l},e),g=s.props.animation==="vertices"?9:6,y=m("path",{path:r,fill:"none",stroke:l,"stroke-width":5,opacity:1,hidden:!0},u),f=r.points.map(k=>m("circle",{cx:k.x,cy:k.y,r:g,fill:l,hidden:!0},u)),v,w,$;return s.props.animation==="vertices"?$=r.points.map((k,M)=>m("text",{text:M+1,x:k.x,y:k.y+5,fill:"white",hidden:!0},u)):s.props.labels==="number"&&(v=sh(r,d),w=o.map(k=>{let M=k.perpendicularBisector,P=M.at(n?0:15/M.length),j=k.length<45?12:15;return m("text",{text:Rt(k.length/50,1),x:P.x,y:P.y+5,hidden:!0,style:`font-size:${j}px`},d)})),{beats:c,step:k=>{k===0&&(y==null||y.enter("draw",10*h/i)),f==null||f[k].show(),$==null||$[k].show(),w==null||w[k].show(),v&&(v.textStr=Rt(a[k]/50,1))}}}function Yg(s,e,t){e.removeChildren();let i=s.path.area/2500,n=t-12,r=i,o=gr(s.props.color),a=m("clipPath",{id:`clip-${s.id}`},e),h=m("path",{path:G.aroundPoints(s.path.points)},a);s.$path.setAttr("id",`shape-${s.id}`),m("path",{path:s.path,"clip-path":`url(#clip-${s.id})`,fill:o,opacity:1},e);let l=m("g",{class:"axis-label",fill:o},e),c=sh(s.path,l,-15);return{beats:[{note:g=>ht(n-i,n,g/r),duration:r,time:0}],tick:g=>{if(s.props.labels){let f=g/r,v=Rt(ht(0,i,f>.95?1:f),1);c.text=v>0?v+" units\xB2":""}let y=G.aroundPoints(s.path.points).h;h.css("transform",`translateY(${y*(1-g/r)}px)`)}}}function Zg(s,e,t,i){e.removeChildren();let n=Bp(s.path),r=n.points.length,o=n.points.map((v,w)=>new kt(n.points[gt(w+1,r)],v,n.points[gt(w-1,r)])),a=o.map(v=>v.deg),h=[0,...as(a)],l=.42*Math.min(...n.edges.map(v=>v.length)),c=s.is("polyomino"),u=gr(s.props.color),d=m("g",{class:"axis-label",fill:u},e),g=sh(n,d);return{beats:a.map((v,w)=>({note:eh(s.props.musicScale||"major",w,a.length,s.props.musicScaleRev)+t,duration:a[w]/90,time:h[w]/90})),step:v=>{let w=o[v],$=m("path",{fill:u});if(e.prepend($),s.props.labels){let L=w.bisector,k=L.at(-12/L.length),M=`font-size:${c?12:15}px`;m("text",{text:Rt(a[v])+"\xB0",x:k.x,y:k.y+5,style:M},d)}mt(L=>{let k=new kt(w.arc.at(1-L),w.b,w.c);$.draw(k.shape(!0,l,!0)),s.props.labels&&(g.text=Math.round(ht(h[v],h[v+1],L))+"\xB0")},a[v]/90*1e3/i)}}}function _p(s,e){let t=()=>{s.props.labels!=="number"&&e.removeChildren()};return new Lr(s,(i,n)=>{switch(s.props.animation){case"area":return ut(dt({},Yg(s,e,i)),{end:t});case"angles":return ut(dt({},Zg(s,e,i,n)),{end:t});default:return ut(dt({},Xg(s,e,i,n)),{end:t})}})}var qp=6,Qg="M8.1-1.7l-14-8.8c-0.6-0.4-1.4-0.4-2-0.1c-0.6,0.4-1,1-1,1.7V8.8c0,0.7,0.4,1.4,1,1.7c0.3,0.2,0.6,0.3,1,0.3c0.4,0,0.7-0.1,1.1-0.3l14-8.8C8.6,1.3,9,0.7,9,0S8.6-1.3,8.1-1.7z",Hi=!1;function Fp(s){if(!Array.isArray(s))return Fp([s,0]);let[e,t]=s;if(e instanceof p)return[[e,t]];if(U(e)&&(e=new G(e.c.shift(-e.r),2*e.r,2*e.r)),!(e instanceof V)&&!(e instanceof G))return[[R,0]];let i=e.edges.map(n=>[n.midpoint,n.perpendicularBisector.angle]).filter(n=>!x(n[1],1.5*Math.PI));return hs(i,t)}var Or=class{constructor(e,t,i){this.tile=e;this.name=t;this.options={};this.cables=new Set;i&&this.setOptions(i)}get location(){let e=this.options.location;return Array.isArray(e)?e[0]:e}get type(){return(this.location||this.tile.path)instanceof p?"POINT":"REGION"}get points(){let e=this.options.location||this.tile.path||R;return Fp(e).map(t=>[this.tile.worldPosn(t[0]),t[1]])}setOptions(e,t=!0){Object.assign(this.options,e),t&&this.redraw()}redraw(){for(let e of this.cables)e.redraw()}},Rr=class extends Or{sendMessage(e){this.cables.size===0&&this.redraw();for(let t of this.cables.values())t.enqueueMessage(e,!1);Hp()}addCable(e,t=!1){this.cables.add(e),!e.to&&!e.dragging&&this.cables.size>1&&this.removeCable(e,!1),t&&(this.tile.updateCableProps(),this.tile.$parent.flushChanges()),this.redraw()}removeCable(e,t=!0){this.cables.delete(e),e.delete(),t&&this.redraw(),this.tile.updateCableProps()}redraw(){if(Bt(this.cables,e=>e.to))for(let e of this.cables)!e.to&&!e.dragging&&this.removeCable(e);this.cables.size||this.addCable(new ns(this)),super.redraw()}delete(){for(let e of this.cables)e.delete()}},Dr=class extends Or{setOptions(t,i=!0){Object.assign(this.options,t);let n=Array.isArray(t.location)?t.location[0]:t.location;n instanceof p?this.$dot=m("circle",{class:"link-dot persist",r:qp,cx:n.x,cy:n.y},this.tile.$el):this.$dot&&this.$dot.remove(),i&&this.redraw()}addCable(t,i){i&&this.tile.highlight(!0),this.cables.add(t),this.options.connect&&this.options.connect(t)}removeCable(t,i){var n,r;i&&this.tile.highlight(!1),(r=(n=this.options).disconnect)==null||r.call(n,t),this.cables.delete(t)}delete(){for(let t of this.cables)t.from.tile.$parent.pendingChanges.add(t.from.tile),t.from.removeCable(t)}validateConnection(t){return rh(t,this)}},nh=[],ih=!1;function Hp(){var e,t;if(ih)return;ih=!0;let s=0;for(;nh.length;){if(s>=1e4)throw new Error("Queue overflow!");let[i,n]=nh.shift();(e=i.to)!=null&&e.options.message&&((t=i.to)==null||t.options.message(n,i)),s++}ih=!1}function rh(s,e){if(s.tile===e.tile||e.options.max&&[...e.cables].filter(r=>r.from!==s||r.to!==e).length>=e.options.max)return!1;let t=e.options.tileTypes;if(t){let n=s.tile.props.name;if(!t.includes(n))return!1}let i=s.options.tileTypes;if(i){let n=e.tile.props.name;if(!i.includes(n))return!1}return!0}var ns=class s{constructor(e,t){this.from=e;this.dragging=!1;let i=this.from.tile.$parent,n=e.options.persistent?"":"dashed";this.$group=m("g",{class:"link-bar",style:"display:none"},e.tile.$el),this.$line=m("path",{style:"pointer-events: none",class:n},this.$group),this.$originDot=m("circle",{class:"link-dot",r:qp},this.$group),this.$handle=m("path",{class:"link-handle",d:Qg},this.$group),this.connectTo(t),i.events.listen(this.$handle,{start:()=>{i.selection.add(e.tile,!0),Hi=this.dragging=!0},move:({posn:o})=>{this.connectTo(i.getInputAt(o,this.from),o)},end:()=>{Hi=this.dragging=!1,this.to&&this.to.tile.highlight(!1),this.redraw(),e.addCable(this,!0)},click:()=>{this.connectTo(),e.addCable(this,!0)}});let r;i.events.listen(this.$originDot,{start:()=>{i.selection.add(e.tile,!0),r=new s(this.from),Hi=r.dragging=!0,this.from.addCable(r)},move:({posn:o})=>{r.connectTo(i.getInputAt(o,this.from),o)},end:()=>{r.to&&r.to.tile.highlight(!1),r.redraw(),Hi=r.dragging=!1,e.addCable(r,!0),r=void 0}})}connectTo(e,t){this.to&&this.to!==e&&this.to.removeCable(this,!0),e?this.to!==e&&rh(this.from,e)&&(this.to=e,e.addCable(this,t!==void 0),this.from.options.connect&&this.from.options.connect(this)):this.to=void 0,this.redraw(t)}redraw(e){var y;if(!(this.from.options.persistent||this.from.tile.isActive||((y=this.to)==null?void 0:y.tile.isActive)))return this.$group.hide();if(this.from.tile.$el.append(this.$group),this.$group.show(),!this.to&&!e){let[f,v]=this.from.points[0],w=new wt(R,20).at(v/(Math.PI*2));this.$handle.setTransform(this.from.tile.relativePosn(f).add(w),v),this.$line.setAttr("d",""),this.$originDot.hide();return}let i=this.to?this.to.points:[[e,0]],n=yi(this.from.points,i),[r,o]=Vs(n,([f,v])=>p.distance(f[0],v[0])),a=this.from.tile.relativePosn(r[0]),h=o[1]+J((this.to?this.to.tile.rot:180)-this.from.tile.rot),l=this.to?new wt(R,14).at(h/(Math.PI*2)):R,c=this.from.tile.relativePosn(o[0]).add(l),u=p.distance(a,c),d=a.add(p.fromPolar(r[1],u*.7)),g=c.add(p.fromPolar(h,Math.max(u*.7,40)));this.$line.setAttr("d",`M${c.x} ${c.y}C${g.x} ${g.y},${d.x} ${d.y},${a.x} ${a.y}`),this.$handle.setTransform(c,h+Math.PI,this.to?.8:1),this.$originDot.setTransform(a),this.$originDot.show()}delete(){this.connectTo(),this.$group.remove()}enqueueMessage(e,t=!0){if(nh.push([this,e]),t&&Hp(),!this.from.options.highlights)return;let n=e.type==="number"&&e.value===1?F.yellow:F.blue;this.$line.setAttr("style",`stroke: ${n}`),this.$handle.setAttr("style",`fill: ${n}`)}serialize(){return this.to?{fromPort:this.from.name,toTileId:this.to.tile.id,toPort:this.to.name}:void 0}static unSerialize(e,t,i){var o,a;let n=i.tiles.get(e),r=i.tiles.get(t.toTileId);if(n&&r){let h=(o=n.outPorts)==null?void 0:o.get(t.fromPort||"main"),l=(a=r.inPorts)==null?void 0:a.get(t.toPort||"main");h&&l&&rh(h,l)&&h.addCable(new s(h,l))}}static get isMoving(){return Hi}};var Gr=["polygon","custom-polygon","reg-polygon","rectangle","polyomino","circle","arrow"],Nr=class{constructor(e){this.tileContext=e,this.tileContextProps=this.tileContext.props,this.tileContextProps.watch("color",()=>this.setColor()),this.tileContextProps.watch("textLabel",()=>{this.tileContext.value=Number.isNaN(Number(this.tileContextProps.textLabel))?void 0:Number(this.tileContextProps.textLabel),this.renderTextLabel()}),this.tileContextProps.watch("textLabelRotate",()=>this.align()),this.tileContextProps.watch("textLabelFontSize",()=>this.setFontSize())}renderTextLabel(){if(this.$textLabel){this.$textLabel.text=this.tileContextProps.textLabel||"",this.align();return}this.tileContextProps.textLabel&&(this.$textLabel=m("text",{class:"polygon-text-label",text:this.tileContextProps.textLabel,"dominant-baseline":"middle"},this.tileContext.$el),this.setColor(),this.setFontSize(),this.align())}setColor(){this.$textLabel&&this.$textLabel.css("fill",vr(this.tileContextProps.color))}setFontSize(){this.$textLabel&&this.$textLabel.css("font-size",mp(this.tileContextProps.textLabelFontSize))}align(){if(!this.$textLabel)return;let e=this.tileContextProps.textLabelRotate?0:-this.tileContext.rot;this.$textLabel.setTransform(this.tileContext.path&&Ye(this.tileContext.path)?this.tileContext.path.centroid:this.tileContext.center,J(e))}};var F={grey:"#cccccc",darkGrey:"#242436",red:"#cd0e66",orange:"#eb4726",yellow:"#fd8c00",lime:"#bfc212",green:"#22ab24",teal:"#009ea6",blue:"#0f82f2",purple:"#6d3bbf",fg:"var(--canvas-fg)",bg:"var(--canvas-bg)"},Jg="M12.5,0H0V25H12.5a12.5,12.5,0,0,0,0-25Z",t0="M0,0V12.5a12.5,12.5,0,0,0,25,0V0Z",zr=new Map,Br=new Map,e0=[];function Ut(s){zr.set(s.type,s)}function Mt(s){e0.push(...s)}var H=class s{constructor(e,t,i,n){this.$parent=e;this.rot=0;this.snapPoints=[];this.snapLines=[];this.snapAngles=[0,90];this.id=i||We(10),t.name||(t.name=this.constructor.type),this.props=zp(t,this),this.posn=new p(this.props.x||0,this.props.y||0),this.rot=t.rot||0,this.$el=n||m("g",{class:"tile"}),e.tiles.set(this.id,this),Br.set(this.$el._el,this),e.pendingChanges.add(this),this.props.watch("status",({status:r})=>{this.$el.setClass("locked-tile",r==="locked"),this.$el.setClass("hidden-tile",r==="hidden"),this.canSelect||this.$parent.selection.remove(this)}),this.props.watch("sound",r=>Np(r.sound||"piano")),this.props.watch("zIndex layer",()=>this.updateZIndex(!0)),this.props.watch("hideHandles",()=>this.$el.setClass("no-handles",!this.showHandles))}static create(e,t,i){let n=zr.get(t.name);if(!n)throw new Error(`Unknown tile type: ${t.name}`);let r=Object.assign({},n.defaultProps||{},t);r.arpeggio===!1&&!r.musicScale&&(r.musicScale="none",r.arpeggio=void 0);let o=new n(e,r,i);return o.setTransform(),o}static thumbnail(e,t,i){var o,a;let n=zr.get(t);if(!n)throw new Error(`Unknown tile type: ${t}`);let r=ve(i.attr("props"),{});return i.setAttr("aria-label",((o=n.altText)==null?void 0:o.call(n,r))||r.name),(a=n.makeThumbnail)==null?void 0:a.call(n,i,r,e)}delete(){var e,t,i;if(!this.isDeleting){this.isDeleting=!0,(e=this.track)==null||e.stop(),this.collision&&this.collision.setCollision();for(let n of this.optionListeners||[])this.$parent.options.unwatch(n);for(let n of this.stateListeners||[])this.$parent.state.unwatch(n);this.$parent.selection.remove(this);for(let n of((t=this.inPorts)==null?void 0:t.values())||[])n.delete();for(let n of((i=this.outPorts)==null?void 0:i.values())||[])n.delete();this.$parent.tiles.delete(this.id),this.$parent.zIndex.remove(this),this.$parent.mathContext.removeSource(this),Br.delete(this.$el._el),this.$parent.pendingChanges.add(this),this.$el.remove()}}applyChange(e){this.props.assign(e),this.flushChanges(),("x"in e||"y"in e||"rot"in e)&&this.setTransform(new p(this.props.x,this.props.y),this.props.rot)}flushChanges(){return this.props.flushChanges()}setupAudioTrack(){}makeHandle(e,t,i,n,r){let a=m(e==="c"?"circle":"path",{class:"handle"},this.$el);return e==="h"&&a.setAttr("d",Jg),e==="v"&&a.setAttr("d",t0),e==="c"&&a.setAttr("r",10),a.css("cursor",e==="c"?"move":e==="h"?"ew-resize":"ns-resize"),this.$parent.events.listen(a,{down:()=>{var h;return(h=this.track)==null?void 0:h.stop()},start:()=>{this.$parent.selection.add(this.root,!0),n==null||n()},move:h=>t(this.relativePosn(h.posn),h.posn,h.event),click:()=>i==null?void 0:i(),end:()=>{r==null||r(),this.$parent.flushChanges()}}),a}is(e){return this.props.name===e}get $container(){return this.$parent.$tiles[this.props.layer==="back"?0:this.props.layer==="front"?2:1]}updateZIndex(e){e&&this.$parent.zIndex.addOrUpdate(this);let t=this.$parent.zIndex.getTileAbove(this);if(!t)return this.$container.append(this.$el);t.$el.insertBefore(this.$el)}get canSelect(){return this.$parent.state.authorMode?!0:this.props.status!=="hidden"&&this.props.status!=="locked"}get canEdit(){return this.$parent.state.authorMode?!0:!this.authoringOnly&&this.props.status!=="fixed"&&this.props.status!=="generator"}get canRotate(){return this.cannotRotateType?!1:this.$parent.state.authorMode?!0:this.canEdit&&!this.$parent.options.noRotating&&!this.props.cannotRotate}get showHandles(){return this.$parent.state.authorMode?!0:!this.props.hideHandles&&!this.authoringOnly&&this.props.status!=="generator"}get altText(){var t;if(this.props.altText)return this.props.altText;let e=zr.get(this.props.name);return((t=e==null?void 0:e.altText)==null?void 0:t.call(e,this.props))||this.props.name}watchPolypadOptions(e){this.optionListeners||(this.optionListeners=[]),this.optionListeners.push(e),this.$parent.options.watch(e)}watchPolypadState(e){this.stateListeners||(this.stateListeners=[]),this.stateListeners.push(e),this.$parent.state.watch(e)}showErrorIcon(e){var t;if(this.currentError=e,!e)return(t=this.$errorIcon)==null?void 0:t.detach();this.$errorIcon||(this.$errorIcon=m("g",{style:"cursor: pointer"}),m("circle",{cx:12,cy:12,r:12,fill:"transparent"},this.$errorIcon),fp("warning",F.yellow,24,void 0,this.$errorIcon),this.transform(),this.$parent.events.listen(this.$errorIcon,{click:()=>{let i=this.$errorIcon.transformMatrix,n=this.posn.shift(i[0][2],i[1][2]);this.$parent.warningBanner.show(n,this.currentError)}})),this.$el.append(this.$errorIcon)}setCollision(e){var t;!this.canEdit||e&&!e.canEdit||e&&e===this.collision||((t=this.collision)==null||t.highlight(!1),this.collision=e,e==null||e.highlight(!0))}collide(e){}get root(){var e;return((e=this.group)==null?void 0:e.root)||this}flipColor(e){let{color:t,backColor:i}=this.props;this.props.color=i||e,this.props.backColor=t}click(e){}doubleClick(e){}down(e){}up(e){}format(e,t){}focus(){this.$parent.focussedTile=this,this.$parent.selection.clear(),this.isFocussed=!0,this.$parent.trigger("change-focus",{tiles:[this]})}blur(){this.isFocussed=!1,this.$parent.focussedTile=void 0,this.$parent.trigger("change-focus",{tiles:[]})}highlight(e=!0){}onDropzonesChange(){}select(){this.isActive=!0,this.$el.addClass("active"),this.$el.setClass("no-handles",!this.showHandles),this.noAutoLayering||this.updateZIndex(),this.redrawCables()}deselect(){this.isDeleting||(this.isActive=!1,this.$el.removeClass("active"),this.noAutoLayering||this.updateZIndex(),this.redrawCables())}moveStart(e=!1){this.startPosn=this.posn}move(e,t){e&&(this.posn=this.startPosn.add(e),this.transform(!0))}moveEnd(){this.collision&&this.collide(this.collision),this.setTransform()}rotate(e,t=R){this.posn=this.posn.rotate(J(e),t),this.rot=gt(this.rot+e,360),this.transform(!0)}transform(e){var i,n;let t=J(this.rot);this.$el.setTransform(this.posn,t),this.redrawCables(),!e&&this.path&&(this.transformed=this.path.rotate(t).translate(this.posn),this.padding&&(this.transformedPadded=It(this.path).padding(...this.padding).rotate(t).translate(this.posn)),this.snapPoints=this.getSnapPoints().map(r=>r.rotate(t).translate(this.posn)),this.snapLines=this.getSnapLines().map(r=>r.rotate(t).translate(this.posn)),(i=this.$errorIcon)==null||i.setTransform(It(this.path).p.shift(-28,5)),(n=this.group)==null||n.transform())}setTransform(e=this.posn,t=this.rot){this.posn=e,this.props.x=e.x,this.props.y=e.y,this.rot=this.props.rot=gt(t,360),this.transform()}getSnapPoints(){return this.path?nt(this.path)?[this.path]:Tt(this.path)?this.path.points:st(this.path)?[this.path.p1,this.path.p2]:U(this.path)?[this.path.c,this.path.c.shift(0,this.path.r),this.path.c.shift(0,-this.path.r),this.path.c.shift(this.path.r,0),this.path.c.shift(-this.path.r,0)]:Ze(this.path)?[...this.path.majorVertices,...this.path.minorVertices]:$e(this.path)?[this.path.c,this.path.start,this.path.end]:Dt(this.path)?[this.path.start,this.path.end]:qt(this.path)?[]:[]:[]}getSnapLines(){return[]}relativePosn(e){return e.subtract(this.posn).rotate(-J(this.rot))}worldPosn(e){return e.rotate(J(this.rot)).add(this.posn)}get center(){return this.path?U(this.path)||Ze(this.path)?this.path.c:It(this.path).center:R}contains(e){let t=this.transformed;return!t||!Tt(t)&&!U(t)&&!$e(t)?!1:t.contains(e)}findNearby(e,t,i){let n=i||this.worldPosn(this.center);for(let r of this.$parent.getTilesOfType(e))if(r!==this&&p.distance(n,r.worldPosn(r.center))Array.from(Ae([a],!0),c=>{let u=c.posn.add(h).subtract(a.posn);return{tile:c,posn:u,rot:l}}));let n=e.map(a=>a.tile.posn),r=e.map(a=>a.tile.rot);for(let a of e)a.tile.setTransform(a.posn,(o=a.rot)!=null?o:a.tile.rot);return t?mt(a=>{var h,l;a=St("sine",a);for(let[c,u]of e.entries()){let d=J(ht(r[c],(h=u.rot)!=null?h:u.tile.rot,a));if(u.tile.is("group")){let g=p.interpolate(n[c].subtract(u.posn),R,a);u.tile.transformed=u.tile.path.rotate(d,u.tile.path.center).translate(g)}else{let g=p.interpolate(n[c],u.posn,a);u.tile.$el.setTransform(g,d),u.tile.transformed=(l=u.tile.path)==null?void 0:l.rotate(d).translate(g)}}i&&i(a)},t).promise:Promise.resolve()}delayedSetup(){var t;for(let i of((t=this.outPorts)==null?void 0:t.values())||[])for(let n of i.cables)n.delete();let e=this.props.cables||[];for(let i of e)ns.unSerialize(this.id,i,this.$parent)}redrawCables(){var e,t;for(let i of((e=this.inPorts)==null?void 0:e.values())||[])i.redraw();for(let i of((t=this.outPorts)==null?void 0:t.values())||[])i.redraw()}makeInPort(e,t){this.inPorts||(this.inPorts=new Map),this.inPorts.has(e)||this.inPorts.set(e,new Dr(this,e));let i=this.inPorts.get(e);return i.setOptions(t,!1),i}makeOutPort(e,t){this.outPorts||(this.outPorts=new Map),this.outPorts.has(e)||this.outPorts.set(e,new Rr(this,e));let i=this.outPorts.get(e);return i.setOptions(t,!1),i}emitMessage(e,t){var i;typeof e=="string"&&(e=(i=this.outPorts)==null?void 0:i.get(e)),e==null||e.sendMessage(t)}*getCableData(e="out"){let t=e==="in"?this.inPorts:this.outPorts;if(t)for(let i of t.values())for(let n of i.cables)(e==="in"||n.to)&&(yield n.serialize())}updateCableProps(){if(this.$parent.setup)return;let e=Array.from(this.getCableData());this.props.cables=e.length?e:void 0}getClosestPort(e,t,i=10){if(!this.inPorts)return;let n=this.relativePosn(e);for(let a of this.inPorts.values())if(a.location&&nt(a.location)&&p.distance(a.location,n)<=i&&(!t||a.validateConnection(t)))return a;if(!this.contains(e))return;let r=Array.from(this.inPorts.values()).filter(a=>!t||a.validateConnection(t));for(let a of r.filter(h=>h.type==="REGION"))if((a.location||this.path).contains(n))return a;let o=r.filter(a=>a.type==="POINT");return Vs(o,a=>p.distance(n,a.location))}},s0=new vt(R,new p(0,1)),i0=new G(R,50,50).shift(-25,-25).polygon,si=class extends H{constructor(t,i,n){super(t,i,n);this.$path=m("path",{class:"polygon-tile"},this.$el),this.$outline=m("path",{class:"outline"},this.$el),this.props.watch("color",({color:r})=>this.$path.setAttr("fill",r)),this.textLabelInstance=new Nr(this)}transform(t){var i;super.transform(t),(i=this.textLabelInstance)==null||i.align()}setPath(t=i0,i,n){if(i&&!this.symmetric&&(t=t.reflect(s0)),this.path=t,Tt(t)&&(this.snapAngles=Wt(t.edges.map(a=>gt(Math.round(Kt(a.angle)),180)))),this.$path.draw(t,{cornerRadius:n}),this.$outline.draw(t,{cornerRadius:n}),this.transform(),!Tt(t))return;let r=G.aroundPoints(t.points),o=new p(r.center.x,r.p.y);this.showSelectionOutline=p.distance(o,t.project(o))>5}select(){var t,i;(t=this.track)==null||t.stop(),(i=this.$audio)==null||i.removeChildren(),super.select()}setupAudioTrack(){Tt(this.path)&&(this.$audio=m("g",{style:"font-size:15px;font-weight:600",fill:"white"}),this.$outline.insertBefore(this.$audio),this.track=_p(this,this.$audio),this.props.watch("labels",()=>this.track.stop()))}flip(t){this.props.isFlipped=!this.props.isFlipped||void 0;let i=new p(2*t.x-this.posn.x,this.posn.y);this.setTransform(i,-this.rot)}};var _r={point:(s,e)=>s!==void 0&&e!==void 0?new p(s,e):void 0,angle:(s,e,t)=>s&&e&&t?new kt(s,e,t):void 0,line:(s,e)=>s&&e&&!s.equals(e)?new vt(s,e):void 0,segment:(s,e)=>s&&e&&!s.equals(e)?new Y(s,e):void 0,circle:(s,e)=>s&&e?new wt(s,e):void 0,arc:(s,e,t)=>s&&e&&t?new Ft(s,e,t):void 0,polygon:(...s)=>s.every(Boolean)?new V(...s):void 0,polyline:(...s)=>s.every(Boolean)?new te(...s):void 0,triangle:(s,e,t)=>s&&e&&t?new $i(s,e,t):void 0,rectangle:(s,e,t)=>s?new G(s,e,t):void 0,distance:p.distance,intersections:Q},n0=/^_x\d+\.at\([\d.e-]+\)$/,r0=/^intersections\(|\.midpoint$|\.centroid$/,qr=class{constructor(){this.model=he({});this.tiles=new Map;this.dependencies=new Map;this.model.assign(_r),this.queueLabelPositioning=ge(()=>{for(let e of this.tiles.values())Kp(e)},0,!0)}reset(){this.model.clear(),this.model.assign(_r)}redrawLines(e){for(let t of this.tiles.values())t.path&&Uo(t.path)&&(t.$el.draw(t.path,{box:e}),t.$shadow.setAttr("d",t.$el.attr("d")))}},Yt=class extends H{constructor(t,i,n){super(t,i,n,m("path",{class:"geo-path"},t.$geoPaths));this.$parent=t;this.hideSelectionOutline=!0;this.noAutoLayering=!0;this.isProjection=!1;this.parentKeys=[];this.deleted=!1;this.onDraw=()=>this.draw();this.$shadow=m("path",{class:"geo-shadow"},t.$geoShadows),this.props.key||(this.props.key=t.geoData.model.getKey()),t.geoData.tiles.set(this.props.key,this),this.snapPoints=this.snapLines=this.snapAngles=[],this.props.expr&&this.setExpr(this.props.expr),t.geoData.model.watch(this.onDraw),this.props.color||(this.props.color=t.state.penColor),this.props.watch("color",({color:r})=>{var o,a,h;(o=this.$el)==null||o.css("color",r),(a=this.$shadow)==null||a.css("color",r),(h=this.$label)==null||h.setAttr("fill",r)}),this.props.watch("arrows marks",()=>this.draw(!0)),this.props.watch("label",({label:r})=>{if(!r&&this.$label)return this.$label.detach();this.$label||(this.$label=m("text",{fill:this.props.color,class:"geo-label"})),this.$parent.$geoPoints.append(this.$label),Kp(this)})}applyChange(t){super.applyChange(t),"expr"in t&&this.setExpr(this.props.expr)}setExpr(t,i=!1){let n=ct(t);this.$parent.geoData.model.setComputed(this.props.key,n),!i&&(this.props.expr=t,this.setParentKeys(t.match(/_x\d+/g)||[]),this.isProjection=n0.test(t),this.computed=r0.test(t),this.$el.setClass("intersection",this.computed))}draw(t=!1){let i=this.$parent.geoData.model[this.props.key];if(!t&&i===this.path)return;this.path=i,this.$el.setAttr("hidden",i?void 0:!0),this.isActive&&!i&&this.$shadow.hide();let n=i==null?void 0:i.type;if(n!==this.geoType&&(this.$el.setClass("geo-point",n==="point"),this.$el.setClass("geo-path",n!=="point"),this.geoType=n,this.$container.append(this.$el)),!i)return;n==="point"&&(i=new wt(i,this.computed?3.5:6)),this.$el.setClass("fill",this.geoType==="angle");let r=this.$parent.canvasBounds||this.$parent.viewportBounds;this.$el.draw(i,{box:r.rect,arrows:this.props.arrows,mark:this.props.marks}),this.$shadow.setAttr("d",this.$el.attr("d")),this.transform()}setParentKeys(t){var n;let i=this.$parent.geoData.dependencies;for(let r of this.parentKeys)(n=i.get(r))==null||n.delete(this.props.key);this.parentKeys=t;for(let r of t)i.has(r)||i.set(r,new Set),i.get(r).add(this.props.key)}get parents(){let t=this.$parent.geoData.tiles;return this.parentKeys.map(i=>t.get(i)).filter(Boolean)}get children(){let t=this.$parent.geoData.dependencies.get(this.props.key);return t?Array.from(t).map(i=>this.$parent.geoData.tiles.get(i)).filter(Boolean):[]}get ariaDescription(){var t;return`${(t=this.path)==null?void 0:t.type} ${this.props.key}: ${this.props.expr}`}get $container(){return this.geoType==="point"?this.$parent.$geoPoints:this.$parent.$geoPaths}select(){var t;this.isActive=!0,this.path&&(this.geoType==="angle"?this.$el.addClass("hover"):(this.$shadow.show(),(t=this.$el.parent)==null||t.append(this.$el)))}deselect(){this.isActive=!1,this.$shadow.hide(),this.$el.removeClass("hover")}hover(t=!0){this.isActive||!this.path||(this.geoType==="angle"?this.$el.setClass("hover",t):t?this.$shadow.show():this.$shadow.hide())}transform(){this.transformed=this.path,this.snapPoints=this.pending?[]:this.getSnapPoints(),this.snapLines=this.pending||!this.path||nt(this.path)||qt(this.path)?[]:[this.path],this.$parent.geoData.queueLabelPositioning()}setTransform(){this.transform()}shift(t){/^point\([\d.-]+,[\d.-]+\)$/.test(this.props.expr)&&this.setExpr(this.path.translate(t).toString())}delete(){var t;this.deleted=!0,super.delete(),this.$parent.geoData.model.unwatch(this.onDraw),this.$parent.geoData.model[this.props.key]=void 0,this.$parent.geoData.tiles.delete(this.props.key),this.$shadow.remove(),(t=this.$label)==null||t.remove();for(let i of this.children)i.delete()}setPending(t=!0){this.pending=t,t||this.transform();for(let i of this.children)i.setPending(t)}moveStart(){if(!(this.computed||!this.path)){if(this.isProjection){if(this.$parent.selection.size>1)return;this.setParentKeys([])}this.setPending(!0);for(let t of this.parents)t.moveStart();this.moveStartValue=this.transformed}}move(t,i){if(!(!t||!this.path||!this.moveStartValue))if(nt(this.path))this.snapTarget=i,this.$el.setClass("intersection",this.computed||!!(i!=null&&i.intersection)),this.$parent.geoData.model[this.props.key]=this.moveStartValue.translate(t);else for(let n of this.parents)n.move(t)}moveEnd(){var t,i,n,r;if(this.moveStartValue){for(let o of this.parents)o.moveEnd();if(this.setPending(!1),(t=this.snapTarget)!=null&&t.intersection)this.setExpr(this.snapTarget.intersection);else if(((n=(i=this.snapTarget)==null?void 0:i.tile)==null?void 0:n.props.name)==="geo"){let o=(r=this.snapTarget)==null?void 0:r.tile;if(o.path&&nt(o.path)){let a=this.children;for(let h of a)h.setExpr(h.props.expr.replaceAll(this.props.key,o.props.key));this.delete(),this.$parent.flushChanges()}else if(o.path){let a=o.path.offset(this.$parent.geoData.model[this.props.key]);this.setExpr(`${o.props.key}.at(${a})`)}}else this.path&&nt(this.path)&&(this.props.expr=`point(${this.path.x},${this.path.y})`,this.isActive||this.$parent.pendingChanges.add(this))}}static getInferredShape(t){if(t=t.filter(h=>h.path),!t.length)return;if(t.length===1)return{type:t[0].path.type,expr:t[0].props.key,value:t[0].path};t=t.filter(h=>h.geoType!=="angle");let i=t.filter(h=>nt(h.path)),n=t.filter(h=>st(h.path)||U(h.path));if(n.length===1&&i.length===t.length-1){let h=n[0].path;if(i.every(l=>h.contains(l.path)))return{type:h.type,expr:n[0].props.key,value:h}}let r=n.filter(h=>st(h.path));if(i.length+r.length!==t.length)return;for(let h of r)if(xe(h.path)){let l=h.parentKeys.map(c=>h.$parent.geoData.tiles.get(c));for(let c of l)i.includes(c)||i.push(c)}else if(i.filter(l=>h.path.contains(l.path)).length<2)return;let o=i.map(h=>h.props.key).join(","),a=i.map(h=>h.path);if(i.length===2){let h=new Y(a[0],a[1]);return{type:"segment",expr:`segment(${o})`,value:h}}return i.length===3?{type:"triangle",expr:`triangle(${o})`,value:new $i(...a)}:{type:"polygon",expr:`polygon(${o})`,value:new V(...a)}}static copy(t,i,n){let r=h=>{let l=t.get(h)||n.model.getKey();return t.set(h,l),l},o=r(i.key),a=i.expr.replace(/\b_x\d+\b/g,r);return{key:o,expr:a}}};Yt.type="geo",Yt=T([Ut],Yt);var jp=new WeakMap,Up=s=>{let e=jp.get(s);if(e)return e;let t=Yt.getInferredShape(s);return jp.set(s,t),t};Mt([["Midpoint","geo-midpoint","$0.midpoint","segment"],["Perpendicular bisector","geo-perp-bisector","$0.perpendicularBisector","segment"],["Parallel line","geo-parallel","$0.parallel($1)","line","segment"],["Perpendicular line","geo-perpendicular","$0.perpendicular($1)","line","segment"],["Tangent line","geo-tangent","line($0.c,$1).perpendicular($1)","circle"],["Centroid","geo-centroid","$0.centroid","polygon","triangle"],["Circumcircle","geo-circumcircle","$0.circumcircle","triangle"],["Incircle","geo-incircle","$0.incircle","triangle"],["Angle bisector","geo-angle-bisector","$0.bisector","angle"]].map(([s,e,t,...i])=>({id:e,type:"button",tileTypes:["geo"],label:s,icon:e,noFlush:!0,show:n=>{var r;return i.includes(((r=Up(n))==null?void 0:r.type)||"")},click:(n,r)=>{var h;let o=(h=Up(n))==null?void 0:h.expr,a=t.replace(/\$0/g,o||"");if(a.includes("$1"))r.tools.geoPending.enable(a);else{let l=H.create(r,{name:"geo",expr:a});r.selection.add(l,!0);let c=nt(l.path)?"pop":"draw",u=l.$el.enter(c,400);l.$shadow.enter(c,400),r.snapping.updateIntersections(),r.flushChanges(),u.promise.then(()=>l.$el.css("display",""))}}})));Mt([{id:"line-style",type:"select",tileTypes:["geo"],label:"Line Type:",location:"more",show:s=>s.every(e=>e.path&&st(e.path)),options:[{key:"line",label:"Line"},{key:"ray",label:"Ray"},{key:"segment",label:"Segment"}],get:s=>s.geoType,set:(s,e)=>e.setExpr(e.props.expr.replace(/\.(line|ray|segment)$/,"")+`.${s}`)},{id:"arrows",type:"select",tileTypes:["geo"],label:"Arrows:",location:"more",show:s=>s.every(e=>e.geoType==="segment"),options:[{key:"",label:"None"},{key:"start",label:"Start"},{key:"end",label:"End"},{key:"both",label:"Both"}],get:s=>s.props.arrows||"",set:(s,e)=>e.props.arrows=s||void 0},{id:"marks",type:"select",tileTypes:["geo"],label:"Decoration:",location:"more",show:s=>s.every(e=>e.path&&st(e.path)),options:[{key:"",label:"None"},{key:"bar",label:"Bar"},{key:"bar2",label:"Double Bars"},{key:"arrow",label:"Arrow"},{key:"arrow2",label:"Double Arrows"}],get:s=>s.props.marks||"",set:(s,e)=>e.props.marks=s||void 0}]);Mt([{id:"label",type:"input",tileTypes:["geo"],label:"Label:",location:"more",get:s=>s.props.label||"",set:(s,e)=>e.props.label=s}]);var Wp=Math.PI/12;function o0(s){return ye(s/Wp,.03)?new Zh(Math.round(s/Wp),12,"\u03C0").simplified.toString():Ot(s,4)}function a0(s,e){return xe(e)?s.replace(/\$l/g,Ot(e.length/50,4)):Tt(e)||U(e)?s.replace(/\$[cp]/g,Ot(e.circumference/50,4)).replace(/\$a/g,Ot(e.area/2500,4)):qt(e)?s.replace(/\$r/g,o0(e.rad)).replace(/\$d/g,Ot(e.deg,4)+"\xB0"):s}function Kp(s){if(!s.props.label||!s.path)return;s.$label.text=a0(s.props.label,s.path);let[e,t]=h0(s);s.$label.css("transform",`translate(${e.x}px,${e.y}px) rotate(${t}rad)`)}function h0(s){let e,t=s.$label.width,i=12,n=new G(new p(-t/2-3,-i-3),t+6,i+6);for(let r of l0(s.path,s,t,i)){e||(e=r);let o=n.rotate(r[1]).translate(r[0]);if(!Bt(s.$parent.geoData.tiles.values(),a=>{if(!a.path||a.props.status==="hidden"||a===s)return!1;let h=nt(a.path)?new wt(a.path,10):a.path;if(Q(h,o).length)return!0}))return r}return e||[R,0]}function*l0(s,e,t,i){var n;if(nt(s)){let r=e.computed?8:10;yield[s.shift(r+t/2,-r),0],yield[s.shift(-r-t/2,-r),0],yield[s.shift(r+t/2,r+i),0],yield[s.shift(-r-t/2,r+i),0]}else if(st(s)){let r=s.perpendicularVector,o=s.angle;r.y>=0&&(r=r.scale(-1),o+=Math.PI);let a=xe(s)?[.5,.3,.7]:[0,150,-150];for(let h of a)for(let l of[8,-8-i])yield[s.at(h).add(r.scale(l)),o]}else if(Tt(s))for(let r of s.edges){let o=r.perpendicularVector.scale(8),a=r.angle;o.y>=0&&(o=o.scale(1+i/8),a+=Math.PI),yield[r.midpoint.add(o),a]}else if(U(s))yield[s.at(7/8).shift(5+t/2,-5),0],yield[s.at(5/8).shift(-5-t/2,-5),0],yield[s.at(1/8).shift(5+t/2,5+i),0],yield[s.at(3/8).shift(-5-t/2,5+i),0];else if(qt(s)){let r=s.isRight?20*Math.sqrt(2):s.radius,o=((n=s.bisector)==null?void 0:n.unitVector.scale(r+6))||R,a=o.angle();yield[s.b.add(o).shift(t/2*Math.cos(a),i/2*(1+Math.sin(a))),0]}}var Ms=25,Yp=5.4,Zp=4.7;var c0="#ddd",p0={1:F.yellow,x:F.green,x2:F.blue,y:F.teal,y2:"#8d2ca1",xy:"#4e53d0"},oh=s=>s[0]==="-"?F.red:p0[s],Xp=s=>s[0]==="-"?s.slice(1):"-"+s;function ah({splitH:s,splitV:e,expr:t},i=!1){let n=s*e;return t.replace(/2$/,"^2")+(n>1?`${i?"//":"/"}${n}`:"")}function Fr(s,e,t,i){switch(s.startsWith("-")?s.slice(1):s){case"x2":return[t,t];case"y2":return[i,i];case"xy":return[t,i];case"x":return[e,t];case"y":return[e,i];default:return[e,e]}}function Qp(s){let[e,t]=s.reduce(([n,r],{props:o})=>{let a=o.splitH*o.splitV;return[n*a+r,r*a]},[0,1]),i=be(e,t);return[e/i,t/i]}function*d0(s){let e=s,t=[];for(let i=1;ithis.updateFill()),this.props.watch("labels expr",()=>this.updateLabel()),this.resize(),this.move()}applyChange(t){super.applyChange(t),this.resize(),this.move()}get isRotated(){return it(this.rot,45,135)||it(this.rot,225,315)}get denominator(){return this.props.splitV*this.props.splitH}isInverseOf(t){return this.denominator===t.denominator&&Xp(this.props.expr)===t.props.expr}get size(){let{algebraXSize:t,algebraYSize:i}=this.$parent.options,{expr:n,splitV:r,splitH:o}=this.props,[a,h]=Fr(n,1,t,i);return[a*Ms/o,h*Ms/r]}resize(){let[t,i]=this.size;this.setPath(up(t,i).polygon)}updateLabel(){let[t,i]=this.size;this.isRotated&&([t,i]=[i,t]);let n=this.props.labels!=="hidden"&&t>=12&&i>=12;if(this.$label.toggle(n),!n)return;this.labelEqn.setValue(this.collision?"0":ah(this.props,i<25));let r=this.labelEqn.root,o=Math.min((t-2)/r.width*.8,i/r.height*.8,1);this.labelEqn.$row.css("transform",`translate(${-r.width/2}px,${-r.height/2}px)`),this.$label.css("transform",`scale(${o}) rotate(${-this.rot}deg)`)}updateFill(){this.$path.setAttr("fill",this.collision?Be(c0,this.$parent.flipTheme):this.props.color)}transform(t){this.updateLabel(),super.transform(t)}getSideLength(t){this.isRotated&&(t=t==="h"?"v":"h");let{expr:i,splitV:n,splitH:r}=this.props,[o,a]=Fr(i,"1","x","y");return t==="h"?[o,1/r]:[a,1/n]}getEdge(t){let i=gt(t-Math.round(this.rot/90),4);return this.transformed.edges[i]}setCollision(t){this.collision=t,this.updateFill(),this.updateLabel()}move(t){super.move(t);let i=this.collision;if(i){if(p.distance(this.posn,i.posn)<.95*Ms&&this.isInverseOf(i))return;i.setCollision(),this.setCollision()}for(let n of this.$parent.getTilesOfType("algebra"))if(!(n.collision||!this.isInverseOf(n))&&!(p.distance(this.posn,n.posn)>=.95*Ms)){this.setCollision(n),n.setCollision(this);return}}split(t,i=2){this.isRotated&&(t=t==="h"?"v":"h");let[n,r]=this.size,o=t==="h"?new Y(new p(-n/2,0),new p(n/2,0)):new Y(new p(0,-r/2),new p(0,r/2)),a=ut(dt({},this.props.raw),{splitH:t==="h"?this.props.splitH*i:this.props.splitH,splitV:t==="v"?this.props.splitV*i:this.props.splitV});return this.delete(),z(h=>{let l=this.worldPosn(o.at((h+.5)/i));return H.create(this.$parent,Object.assign({},a,{x:l.x,y:l.y}))},i)}static merge(t){let i=It(...t.map(f=>f.transformed)),{x:n,y:r}=i.center,o=t.every(f=>f.isRotated)?90:0,a=t[0].props.expr,{algebraXSize:h,algebraYSize:l}=t[0].$parent.options,c=Fr(a,Ms,h*Ms,l*Ms)[0],u=Qp(t)[1],d=[...d0(u)].find(f=>f>=Math.round(c/(o?i.h:i.w)))||1,g=u/d,y=H.create(t[0].$parent,{name:"algebra",expr:a,splitH:d,splitV:g,x:n,y:r,rot:o});for(let f of t)f.delete();return y}static makeThumbnail(t,i){let n=i.expr,[r,o]=Fr(n,20,78,64),a=n[0]==="-"?n.slice(1):n,h=a==="y2"?112:["x2","xy"].includes(a)?28:2,l=a==="1"?2:["x","x2"].includes(a)?28:112;i.rot&&([h,l,r,o]=[l,h,o,r]),t.setRect(new G(new p(h,l),r,o)),t.setAttr("fill",oh(n));let c=m("g",{style:"font-size:15px;color:white;text-anchor:start",class:"equation"}),u=new ze(c,void 0,0,"",15,!0);u.setValue(ah(i)),u.$row.css("transform",`translate(${h+r/2-u.root.width/2}px, ${l+o/2-u.root.height/2}px)`),t.insertAfter(c)}static altText(t){return ah(t)+" Algebra Tile"}negate(){this.props.expr=Xp(this.props.expr),this.flipColor(oh(this.props.expr)),this.move()}};Cs.type="algebra",Cs.defaultProps={splitH:1,splitV:1},Cs=T([Ut],Cs);Mt([{id:"negate",type:"button",tileTypes:["algebra","dot","number-card"],label:"Negate",click:s=>{for(let e of s)e.negate()}}]);Mt([{id:"merge-algebra",type:"button",tileTypes:["algebra"],label:"Merge",show:s=>s.length<2||!s.every(e=>e.props.expr===s[0].props.expr)?!1:Qp(s)[0]===1,click:(s,e)=>{e.selection.add(Cs.merge(s),!0)}},{id:"splitV",type:"button",tileTypes:["algebra"],label:"Split Vertically",icon:"split-v",show:s=>s.every(e=>e.props.splitV<8),click:(s,e)=>{e.selection.select(s.flatMap(t=>t.split("v",2)))}},{id:"splitH",type:"button",tileTypes:["algebra"],label:"Split Horizontally",icon:"split-h",show:s=>s.every(e=>e.props.splitH<8),click:(s,e)=>{e.selection.select(s.flatMap(t=>t.split("h",2)))}},{id:"split",type:"range",tileTypes:["algebra"],label:"Denominator:",value:"number",icon:"split-h",location:"more",get:s=>[s.props.splitH,s.props.splitV],set:(s,e)=>{e.props.assign({splitH:B(Math.round(s[0]),1,8),splitV:B(Math.round(s[1]),1,8)}),e.resize(),e.updateLabel()}}]);var Jp=1,u0=.2,f0=5;function m0([s,e],t,i){if(!i)return[Math.min(s,t),Math.max(e,t)];let n=eh.length)),n=O(i),r=i.findIndex(h=>h/n>e)+1,o=i.findIndex(h=>h/n>t)+1,a=e<=t?s.points.slice(r,o):[...s.points.slice(r),...s.points.slice(0,o)];return new te(s.at(e),...a,s.at(t))}return s}function hh(s,e,t,i){let n=Jp,r=-1;for(let o=e+1;on&&(r=o,n=a)}n>Jp&&(r-e>1&&hh(s,e,r,i),i.push(s[r]),t-r>1&&hh(s,r,t,i))}function v0(s){if(s.length<=2)return s;let e=[s[0]];return hh(s,0,s.length-1,e),e.push(O(s)),e}function w0(s){if(s.length<=2)return Re(new te(...s));let e=s.map((t,i)=>{let n=s[i-1]||t.subtract(s[i+1].subtract(t).unitVector),r=s[i+1]||t.subtract(s[i-1].subtract(t).unitVector),o=Math.atan2(r.y-n.y,r.x-n.x),a=Math.abs(new kt(n,t,r).sup.rad/Math.PI-.5),h=Math.min(p.distance(n,r),100)*a*u0;return new p(Math.cos(o),Math.sin(o)).scale(h)});return s.map((t,i)=>{if(i===0)return`M${t.x.toFixed(2)} ${t.y.toFixed(2)}`;if(p.distance(s[i-1],t)<4)return`L${t.x.toFixed(2)},${t.y.toFixed(2)}`;let n=s[i-1].add(e[i-1]),r=t.subtract(e[i]);return`C${n.x.toFixed(2)},${n.y.toFixed(2)} ${r.x.toFixed(2)},${r.y.toFixed(2)} ${t.x.toFixed(2)},${t.y.toFixed(2)}`}).join("")}var Fe=class s{constructor(e,t,i,n,r){this.$parent=e;this.brush=n;this.options="";this.$el=m("path",{class:`stroke ${n}`},e.$strokes),this.id=r||We(10),this.setColor(i),t&&this.parse(t),e.strokes.set(this.id,this),this.$parent.pendingStrokes.add(this)}setColor(e){this.color=e,this.$el.setAttr("stroke",Be(e,this.$parent.flipTheme))}parse(e){if(this.options=e,e.startsWith("M")){let t=na(e);this.path=new te(...t),this.$el.setAttr("d",e)}else this.path=ct(e)(_r),this.path&&(this.snap=!0),this.$el.setAttr("d",this.path?Re(this.path):"")}start(e,t){var i;if(this.brush==="ruler"&&(e=((i=this.$parent.snapping.snap([e]))==null?void 0:i.posn)||e),this.startPoint=e,this.path=new te(e,e.shift(.01)),t&&this.brush!=="ruler"){this.utensil=t;let n=t.offset(e);this.utensilRange=[n,n+.01]}this.$el.draw(this.path)}addPoint(e){if(this.brush==="ruler"){let t=this.$parent.snapping.snap([e]),i=(t==null?void 0:t.posn)||e.snap(this.startPoint,f0);this.path=new Y(this.startPoint,i),this.$el.draw(this.path)}else if(this.utensil){let t=B(this.utensil.offset(e),0,1),i=U(this.utensil)||Ye(this.utensil);this.utensilRange=m0(this.utensilRange,t,i),this.path=g0(this.utensil,...this.utensilRange),this.$el.draw(this.path)}else this.path.points.push(e),this.$el.setAttr("d",this.$el.attr("d")+`L${e.x},${e.y}`)}end(){if(this.utensil||this.brush==="ruler")return this.snap=!0,this.options=this.path.toString().replace(/\.(\d{3})\d+/g,(e,t)=>`.${t}`),this.$parent.snapping.addStroke(this);{let e=v0(this.path.points);this.path=new te(...e),this.options=w0(e),this.$el.setAttr("d",this.options)}this.startPoint=this.utensil=this.utensilRange=void 0}flushChanges(){let e=this.serialize();return this.$parent.strokes.has(this.id)?[void 0,e]:[e,void 0]}get snapPoints(){if(this.snap){if(xe(this.path))return[this.path.p1,this.path.p2];if(Dt(this.path))return[this.path.start,this.path.end]}}hitTest(e,t){if(!this.path)return!1;let i=this.path.project(e);return(e.x-i.x)**2+(e.y-i.y)**2t/2?i-t:i}var jr=class{constructor(e){this.$parent=e;this.angle=0;this.startAngle=0;this.hasChanged=!1;this.showTools=!1;this.isMoving=!1;this.tiles=new Set;this.$tools=e.$(".transform-tools"),this.$shadow=e.$(".group-shadow"),this.$rect=this.$tools.$(".group-outline"),this.$rotateBar=this.$tools.$(".rotate-bar"),this.$rotateCircle=this.$tools.$(".rotate-circle");let t=e.$(".rotate-label");t.hide(),e.events.listen(this.$rotateCircle,{start:()=>{this.startAngle=this.angle,this.rotateStart(),t.show()},move:({startPosn:i,posn:n,event:r})=>{this.rotate(this.startAngle-new kt(n,this.center,i).deg);let o=Vt(r).subtract(e.topLeftPosition);t.setTransform(o.shift(b.isMobile?-15:5,b.isMobile?-100:-40)),t.text=gt(Rt(this.angle,1),360)+"\u2009\xB0"},end:()=>{this.rotateEnd(),t.hide()}})}bindKeyboardEvents(e){e.onKey("AllArrows r R",(t,i)=>{if(this.tiles.size){if(i==="r"||i==="R"){if(Array.from(this.tiles).some(n=>!n.canRotate))return;this.rotateStart(),this.rotate(this.angle+(i==="R"?-15:15)),this.rotateEnd()}else{let n=R,r=t.shiftKey?5:25,o=i==="ArrowLeft"?-r:i==="ArrowRight"?r:0,a=i==="ArrowUp"?-r:i==="ArrowDown"?r:0,h=n.shift(o,a);this.moveStart(),this.move({posn:h,startPosn:n}),this.moveEnd()}this.$parent.trigger("shift-selection")}}),e.onKey("Escape",()=>this.clear())}get flatTiles(){return[...Ae(this.tiles,!0)]}get size(){return this.tiles.size}add(e,t=!1,i=!1){t&&this.clear(),!e.isActive&&this.$parent.tiles.has(e.id)&&this.select([e],i)}select(e,t=!1){var i;(i=this.$parent.focussedTile)==null||i.blur(),this.$parent.zIndex.bringToFront(Ae(e),!1,!0);for(let n of e)n.isActive||!this.$parent.tiles.has(n.id)||n.group||(this.tiles.add(n),n.select(),this.hasChanged=!0);t||this.update(!0)}remove(e,t=!1){e.group||!e.isActive||(e.deselect(),this.hasChanged=!0,this.tiles.delete(e),t||this.update(!0))}clear(){if(!this.isMoving){for(let e of this.tiles)e.deselect();this.tiles.size&&(this.hasChanged=!0),this.tiles.clear(),this.update(!0)}}getTileProperty(e){if(!this.size)return;let t=e(ks(this.tiles.values()));for(let i of this.tiles)if(e(i)!==t)return;return t}update(e=!1){if(e&&!this.hasChanged)return;if(this.hasChanged=!1,!this.size){for(let o of[this.$shadow,this.$tools])o.hide();this.$parent.trigger("change-selection",{tiles:[],color:void 0});return}let t=Array.from(this.tiles).filter(o=>o.transformed);this.angle=this.getTileProperty(o=>o.rot)||0,this.rect=pp(t,J(this.angle)),this.center=this.rect.center;let i=t.every(o=>o.canRotate);if(t.length===1&&U(t[0].transformed)&&(i=!1),i&&this.getTileProperty(o=>o.rotateAroundOrigin)){let o=t[0].posn;t.slice(1).every(a=>a.posn.equals(o))&&(this.center=o,this.angle&&t.length===1&&(this.rect=It(t[0].transformed.rotate(-J(this.angle),o))))}this.$rotateBar.toggle(i),this.$rotateCircle.toggle(i);let n=this.size>1||t[0].showSelectionOutline;this.$rect.toggle(n),this.showTools=!this.getTileProperty(o=>o.hideSelectionOutline),this.$tools.toggle(this.showTools),this.$shadow.toggle(n&&this.showTools),(!i||!this.showTools)&&(this.rotateHandle=void 0),(this.size===1?t[0].$container:this.$parent.$svg).append(this.$tools),this.positionTools();let r=this.getTileProperty(o=>o.props.color);this.$parent.trigger("change-selection",{tiles:t,color:r})}positionTools(){if(!this.showTools)return;let e=this.bounds;for(let n of[this.$shadow,this.$rect])n.draw(e);let t=new p(this.center.x,this.rect.p.y),i=new Y(t,t.shift(0,-28)).rotate(J(this.angle),this.center);this.$rotateBar.setLine(i.p1,i.p2),this.$rotateCircle.setCenter(i.p2),this.rotateHandle=i.p2}get bounds(){return this.rect.rotate(J(this.angle),this.center)}getDragBounds(){let{canvas:e,canvasX:t,canvasY:i}=this.$parent.options;if(e==="infinite")return;let n=e==="notebook"?1/0:i!=null?i:0,r=It(...Array.from(this.tiles,o=>o.transformed));if(Number.isFinite(r.w))return new lt(-r.p.x,(t!=null?t:0)-r.p.x-r.w,-r.p.y,n-r.p.y-r.h,"swap")}moveStart(e=!1){if(!Bt(this.tiles,t=>!t.canEdit)){this.isMoving=!0,this.$parent.dropzoneManager.onMoveStart(this.tiles);for(let t of this.tiles)t.moveStart(e);this.startSnapPoints=[];for(let t of this.tiles)for(let i of t.snapPoints)this.startSnapPoints.some(n=>i.equals(n))||this.startSnapPoints.push(i);ed=this.rect,td=this.center,this.dragBounds=this.getDragBounds(),this.$parent.newTileShift=0,this.$parent.trigger("move-start")}}move({posn:e,startPosn:t},i=!1){if(!this.isMoving)return;let n=e.subtract(t);this.dragBounds&&!i&&(n=n.clamp(this.dragBounds));let r=this.startSnapPoints.map(h=>h.add(n)),o=this.$parent.snapping.snap(r);o&&(n=n.add(o.shift));let a=this.tiles.size===1?o:void 0;for(let h of this.tiles)h.move(n,a);this.rect=ed.translate(n),this.center=td.add(n),this.positionTools(),this.$parent.dropzoneManager.onMove(this.tiles),this.$parent.trigger("move-selection")}moveEnd(e,t=!1){if(this.isMoving){t&&this.$parent.options.canvas!=="infinite"&&this.move(e);for(let i of this.tiles)i.moveEnd();this.$parent.dropzoneManager.onMoveEnd(),Bt(this.tiles,i=>i.props.name==="geo")&&this.$parent.snapping.updateIntersections(),this.$parent.trigger("move-end"),this.isMoving=!1,this.$parent.flushChanges()}}rotateStart(){lh.clear();for(let e of this.tiles)for(let t of e.snapAngles)lh.add(gt(t+e.rot,180));Hr.clear(),Hr.add(0);for(let e of this.$parent.tiles.values())if(!e.isActive&&Bt(this.tiles,t=>p.distance(t.posn,e.posn)<140))for(let t of e.snapAngles)Hr.add(gt(t+e.rot,180));this.$parent.newTileShift=0,this.$parent.trigger("rotate-start")}rotate(e){if(e=$t(e,3),e===this.angle)return;let t=1/0;for(let n of lh)for(let r of Hr){let o=y0(r,n+e-this.startAngle,180);Math.abs(o)n.authoringOnly))return{};let t={},i=this.flatTiles;for(let n of i)t[n.id]=n.props.copy();for(let n of i)if(n.is("geo")){for(let r of n.parents)if(!i.includes(r)&&!(r.id in t)&&r.geoType==="point"){let o=`point(${r.path.x},${r.path.y})`;t[r.id]=Object.assign(r.props.copy(),{expr:o})}}return t}delete(){if(this.isMoving||this.$parent.option("noDeleting")||ns.isMoving)return;let e=Ae([...this.tiles].filter(i=>i.canEdit),!0);this.tiles.clear();for(let i of e)i.delete();Bt(e,i=>i.props.name==="geo")&&this.$parent.snapping.updateIntersections(),this.$parent.flushChanges(),this.$parent.newTileShift=0}};var bt=class s{constructor(e=0,t=0,i=0){this.x=e;this.y=t;this.z=i}transform(e){if(e instanceof ji&&(e=e.matrix),e.length!==4||e[0].length!==4)throw new Error("Must use a 4x4 matrix for 3D transforms!");let[[t],[i],[n],[r]]=At.product(e,[[this.x],[this.y],[this.z],[1]]);return new s(t/r,i/r,n/r)}equals(e){return x(this.x,e.x)&&x(this.y,e.y)&&x(this.z,e.z)}fixFloat(){return new s(x(this.x,0)?0:this.x,x(this.y,0)?0:this.y,x(this.z,0)?0:this.z)}add(e){return this.x+=e.x||0,this.y+=e.y||0,this.z+=e.z||0,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}lerp(e,t){return new s(ht(this.x,e.x||0,t),ht(this.y,e.y||0,t),ht(this.z,e.z||0,t))}scale(e){return new s(this.x*e,this.y*e,this.z*e)}get magnitude(){return Math.hypot(this.x,this.y,this.z)}get normalize(){return this.scale(1/this.magnitude)}get asArray(){return[this.x,this.y,this.z]}get inverse(){return new s(-this.x,-this.y,-this.z)}get xy(){return new p(this.x,this.y)}[Symbol.iterator](){return this.asArray.values()}static get zero(){return new s(0,0,0)}static get oneZ(){return new s(0,0,1)}static get one(){return new s(1,1,1)}static all(e){return new s(e,e,e)}static from2D(e){return new s(e.x,e.y,0)}static average(e){return new s(Ls(e.map(t=>t.x)),Ls(e.map(t=>t.y)),Ls(e.map(t=>t.z)))}static dot(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}static cross(e,t){let i=e.y*t.z-e.z*t.y,n=e.z*t.x-e.x*t.z,r=e.x*t.y-e.y*t.x;return new s(i,n,r)}};var ie={translate({x:s,y:e,z:t}){return[[1,0,0,s],[0,1,0,e],[0,0,1,t],[0,0,0,1]]},rotateX(s){let e=Math.cos(s),t=Math.sin(s);return[[1,0,0,0],[0,e,-t,0],[0,t,e,0],[0,0,0,1]]},rotateY(s){let e=Math.cos(s),t=Math.sin(s);return[[e,0,t,0],[0,1,0,0],[-t,0,e,0],[0,0,0,1]]},rotateZ(s){let e=Math.cos(s),t=Math.sin(s);return[[e,-t,0,0],[t,e,0,0],[0,0,1,0],[0,0,0,1]]},rotateAxis({x:s,y:e,z:t},i){let n=Math.hypot(s,e,t);n=1/n,s*=n,e*=n,t*=n;let r=Math.sin(i),o=Math.cos(i),a=1-o;return[[s*s*a+o,s*e*a-t*r,s*t*a+e*r,0],[e*s*a+t*r,e*e*a+o,e*t*a-s*r,0],[t*s*a-e*r,t*e*a+s*r,t*t*a+o,0],[0,0,0,1]]},fromEulerAngles(s,e,t){return At.product(ie.rotateX(s),ie.rotateY(e),ie.rotateZ(t))},scale({x:s,y:e,z:t}){return[[s,0,0,0],[0,e,0,0],[0,0,t,0],[0,0,0,1]]},scaleAll(s){return[[s,0,0,0],[0,s,0,0],[0,0,s,0],[0,0,0,1]]},perspective(s,e,t,i){let n=t*Math.tan(J(s)/2),r=-n,o=n*e,a=-o;return[[2*t/(o-a),0,(o+a)/(o-a),0],[0,2*t/(n-r),(n+r)/(n-r),0],[0,0,-((i+t)/(i-t)),-(2*i*t/(i-t))],[0,0,-1,0]]},transformPoint(s,e){return e instanceof bt?e.transform(s):new bt(e.x,e.y).transform(s)}},ji=class{constructor(){this.matrix=At.identity(4)}clear(){return this.matrix=At.identity(4),this}translate(e=0,t=0,i=0){return this.matrix=At.product(this.matrix,ie.translate({x:e,y:t,z:i})),this}rotate(e=0,t=0,i=0){return this.matrix=At.product(this.matrix,ie.rotateZ(i),ie.rotateY(t),ie.rotateX(e)),this}scale(e){return this.matrix=At.product(this.matrix,ie.scale(e)),this}dragToRotate(e,t,i=100){let n=new bt(e.x,e.y,i**3/(i**2+e.length**2)).normalize,r=new bt(t.x,t.y,i**3/(i**2+t.length**2)).normalize,o=B(bt.dot(n,r),-1,1),a=bt.cross(n,r),h=ie.rotateAxis(a,2*Math.acos(o));return this.matrix=At.product(h,this.matrix),this}isRotationMatrix(){if(!x(At.determinant(this.matrix),1))return!1;let e=At.transpose(this.matrix);return At.product(this.matrix,e).every((i,n)=>i.every((r,o)=>x(r,n===o?1:0)))}toEulerAngles(){let e=this.matrix,t=Math.hypot(e[0][0],e[1][0]);if(x(t,0)){let a=Math.atan2(-e[1][2],e[1][1]),h=Math.atan2(-e[2][0],t);return[a,h,0]}let n=Math.atan2(e[2][1],e[2][2]),r=Math.atan2(-e[2][0],t),o=Math.atan2(e[1][0],e[0][0]);return[n,r,o]}};var b0=new xt(0,0,0);function x0(s){let e=s.r,t=s.c.x,i=s.c.y,n=.5523*e;return`M${t} ${i-e}C${t+n} ${i-e} ${t+e} ${i-n} ${t+e} ${i}C${t+e} ${i+n} ${t+n} ${i+e} ${t} ${i+e}C${t-n} ${i+e} ${t-e} ${i+n} ${t-e} ${i}C${t-e} ${i-n} ${t-n} ${i-e} ${t} ${i-e}`}var Ur=class{constructor(){this.transform=new ji;this.visible=!0}getTransformed(e){let t=this;do e=e.transform(t.transform);while(t=t.parent);return e}get normal(){return this.getTransformed(bt.oneZ).add(this.getTransformed(bt.zero).inverse).normalize}project(e,t={fov:120}){if(t.fov===!1)return new p(e.x,e.y);let i=Math.exp(e.z/t.fov);return new p(e.x*i,e.y*i)}*getProjectedVertices(e){for(let t of this.getVertices())yield this.project(t,e)}},Ui=class extends Ur{constructor(t,i={},n){super();this.children=[];this.sorting=!1;this.$el=m("g",i,n);for(let r of t)this.addChild(r)}addChild(t){return t.parent&&t.parent.removeChild(t),this.children.push(t),this.$el&&t.$el&&this.$el.append(t.$el),t.parent=this,t}removeChild(t){let i=this.children.indexOf(t);i>=0&&this.children.splice(i,1),t.$el&&t.$el.remove(),t.parent=void 0}render(t){if(this.visible){if(this.sorting)for(let i of wi(this.children,n=>n.zIndex))this.$el.append(i.$el);for(let i of this.children)i.render(t)}}*getFaces(){for(let t of this.children)for(let i of t.getFaces())yield i}*getVertices(){for(let t of this.children)for(let i of t.getVertices())yield i}get zIndex(){return Ls(this.children.map(t=>t.zIndex))}},Wi=class extends Ur{constructor(t,i={},n){super();this.shape=t;if(!t)this.commands=[];else if(typeof t=="string")this.commands=xn(t);else{let o=U(t)?x0(t):Re(t);this.commands=xn(o)}let r=p.average(...this.commands.filter(o=>o.points.length).map(o=>p.average(...o.points)));this.centroid=new bt(r.x,r.y,0),n&&(this.color=n),this.$el=m("path",i)}render(t){if(!this.visible)return;let i=this.normal.z;if(t!=null&&t.hideBackface){let r=i>-.01;if(this.$el.toggle(r),!r)return}if(this.color){let r=xt.mix(this.color,b0,(Math.abs(i)+1)/2);this.$el.setAttr("fill",r),this.$el.setAttr("stroke",r)}let n=this.commands.map(r=>{let o=r.points.map(a=>{let h=this.project(this.getTransformed(new bt(a.x,a.y)),t);return`${h.x},${h.y}`});return r.type+o.join(",")}).join("");this.$el.setAttr("d",n)}get zIndex(){return this.getTransformed(this.centroid).z}*getFaces(){yield this}*getVertices(){if(!(!this.shape||typeof this.shape=="string"||!Tt(this.shape)))for(let t of this.commands)for(let i of t.points)yield this.getTransformed(new bt(i.x,i.y))}};var W=V.regular(3),ii=V.regular(4),ce=V.regular(5),sd={shape:W,children:[{shape:W,dihedral:70.53,rot:180},{shape:W,dihedral:70.53,parentEdge:1,rot:300},{shape:W,dihedral:70.53,parentEdge:2,rot:60}]},id={shape:ii,children:[{shape:ii,dihedral:90,myEdge:2,children:[{shape:ii,dihedral:90,myEdge:2}]},{shape:ii,dihedral:90,parentEdge:1,rot:270},{shape:ii,dihedral:90,parentEdge:2},{shape:ii,dihedral:90,parentEdge:3,rot:90}]},nd={shape:W,children:[{shape:W,dihedral:109.47,rot:180},{shape:W,dihedral:109.47,parentEdge:1,rot:300,children:[{shape:W,dihedral:109.47,parentEdge:1,rot:300}]},{shape:W,dihedral:109.47,parentEdge:2,rot:60,children:[{shape:W,dihedral:109.47,parentEdge:1,rot:300},{shape:W,dihedral:109.47,parentEdge:2,rot:60,children:[{shape:W,dihedral:109.47,parentEdge:1,rot:300}]}]}]},rd={shape:ce,children:[{shape:ce,dihedral:116.57,rot:180},{shape:ce,dihedral:116.57,parentEdge:1,rot:252},{shape:ce,dihedral:116.57,parentEdge:2,rot:324},{shape:ce,dihedral:116.57,parentEdge:3,rot:36},{shape:ce,dihedral:116.57,parentEdge:4,rot:108,children:[{shape:ce,dihedral:116.57,parentEdge:2,rot:324,children:[{shape:ce,dihedral:116.57,parentEdge:3,rot:36,children:[{shape:ce,dihedral:116.57,parentEdge:1,rot:252},{shape:ce,dihedral:116.57,parentEdge:2,rot:324},{shape:ce,dihedral:116.57,parentEdge:3,rot:36},{shape:ce,dihedral:116.57,parentEdge:4,rot:108}]}]}]}]},od={shape:W,children:[{shape:W,dihedral:138.19,rot:180},{shape:W,dihedral:138.19,parentEdge:1,rot:300,children:[{shape:W,dihedral:138.19,parentEdge:1,rot:300,children:[{shape:W,dihedral:138.19,parentEdge:2,rot:60,children:[{shape:W,dihedral:138.19,parentEdge:1,rot:300,children:[{shape:W,dihedral:138.19,parentEdge:1,rot:300}]},{shape:W,dihedral:138.19,parentEdge:2,rot:60}]},{shape:W,dihedral:138.19,parentEdge:1,rot:300}]},{shape:W,dihedral:138.19,parentEdge:2,rot:60}]},{shape:W,dihedral:138.19,parentEdge:2,rot:60,children:[{shape:W,dihedral:138.19,parentEdge:2,rot:60,children:[{shape:W,dihedral:138.19,parentEdge:1,rot:300,children:[{shape:W,dihedral:138.19,parentEdge:2,rot:60,children:[{shape:W,dihedral:138.19,parentEdge:1,rot:300,children:[{shape:W,dihedral:138.19,parentEdge:1,rot:300}]},{shape:W,dihedral:138.19,parentEdge:2,rot:60}]},{shape:W,dihedral:138.19,parentEdge:1,rot:300}]},{shape:W,dihedral:138.19,parentEdge:2,rot:60}]},{shape:W,dihedral:138.19,parentEdge:1,rot:300}]}]},ad=new V(new p(.587785,.466639),new p(0,.750495),new p(-.587785,.466639),new p(0,-.73981)),He={shape:ad,dihedral:89.7451,rot:180},sE={shape:ad,children:[ut(dt({},He),{parentEdge:1,myEdge:1,children:[ut(dt({},He),{children:[ut(dt({},He),{parentEdge:1,myEdge:1,children:[ut(dt({},He),{children:[ut(dt({},He),{parentEdge:1,myEdge:1,children:[ut(dt({},He),{children:[ut(dt({},He),{parentEdge:1,myEdge:1,children:[ut(dt({},He),{children:[ut(dt({},He),{parentEdge:1,myEdge:1})]})]})]})]})]})]})]})]})]};function hd(s,e,t){let i=V.regular(s).scale(e*zt(s)),n=new G(R,e,t).polygon,r=[{shape:i,rot:180,parentEdge:2}],o=z(a=>({shape:n,parentEdge:a,rot:360/s*a,children:a?void 0:r}),s);return{shape:i,children:o}}function ld(s,e,t){let i=V.regular(s).scale(e*zt(s)),n=new V(new p(-e/2,0),new p(e/2,0),new p(0,-t)),r=Kt(Math.acos(e/t/2/Math.tan(Math.PI/s))),o=z(a=>({shape:n,dihedral:r,parentEdge:a,rot:180+360/s*a}),s);return{shape:i,children:o}}var $0=At.identity(4);function cd(s,e,t,i){var g;let n=e.shape.edges[s.parentEdge||0],r=s.shape.edges[s.myEdge||0],o=J(s.dihedral||90),a=i(s);t.addChild(a);let h=bt.from2D(n.midpoint),l=bt.from2D(r.midpoint),c=bt.from2D(n.unitVector),u=s.rot?J(s.rot):0,d=((g=s.children)==null?void 0:g.map(y=>cd(y,s,t,i)))||[];return[a,h,l,c,u,o,d]}function ch(s,e,t=1){var o;let i=e(s),n=new Ui([i]);n.sorting=!0;let r=((o=s.children)==null?void 0:o.map(a=>cd(a,s,n,e)))||[];return ph(r,n,t),{group:new Ui([n]),foldTree:r}}function pd(s,e,t=$0){let[i,n,r,o,a,h,l]=s,c=ht(Math.PI,h,e),u=ie.rotateAxis(o,Math.PI-c);a&&(u=At.product(u,ie.rotateZ(a)));let d=r.transform(u),g=ie.translate(d.inverse.add(n));i.transform.matrix=At.product(t,g,u);for(let y of l||[])pd(y,e,i.transform.matrix)}function ph(s,e,t){e.transform.clear();for(let r of s)pd(r,t);let i=Array.from(e.getFaces()).map(r=>r.getTransformed(r.centroid)),n=bt.average(i).inverse;e.transform.translate(n.x,n.y,n.z)}function P0(s,e,t){let i=Math.cos(s),n=Math.cos(e),r=Math.cos(t),o=Math.sin(e),a=Math.acos((r-i*n)/(Math.sin(s)*o)),h=Math.acos((i-n*r)/(o*Math.sin(t)));return[a,h]}function dd(s,e){return Math.asin(Math.cos(s*e)/Math.cos(s/2))}var T0=new Set([60,90,108]),S0=[{internal:[60,90,90,90],dihedral:[144.74,135,135,135]},{internal:[60,60,60,60,90],dihedral:[153.23,153.23,153.23,142.98,142.98]},{internal:[60,90,108,90],dihedral:[159.09,148.28,148.28,159.09]},{internal:[60,60,60,60,108],dihedral:[164.18,164.18,152.93,152.93,152.93]}];function E0(...s){let e=s.length;if(e===3)return P0(s[0],s[1],s[2]);let t=s.map(n=>Math.round(Kt(n)));if((e===4||e===5)&&t.includes(60)&&t.every(n=>T0.has(n))){for(let n of S0)if(n.internal.length===e){for(let r=0;ro===n.internal[(a+r)%e]))return hs(n.dihedral,r).slice(0,e-1).map(o=>J(o))}}if(e===4&&t.filter(n=>n===60).length===3){let n=t.findIndex(l=>l!==60),r=(Math.PI-s[n])/4,o=Math.acos(-1/Math.sqrt(3)*Math.tan(r)),a=Math.acos(1-2/3*((3-Math.tan(r)**2)/4+(Math.sin(3*r)/Math.sin(2*r))**2));return hs([o,a,a,o],4-n).slice(0,e-1)}let i=Math.PI/N(s);return z(n=>{let r=dd(s[n],i),o=dd(s[n+1],i);return r+o},s.length-1)}var dh=(s,e)=>gt(s+1,e.size),uh=(s,e)=>gt(s-1,e.size);function M0(s,e){let t=s.polygon.points[uh(e,s)],i=s.polygon.points[e],n=s.polygon.points[dh(e,s)];return new kt(n,i,t).sup.rad}function C0(s){let e=s.find(a=>a.neighbours.filter(Boolean).length===1),t=uh(e.neighbours.findIndex(Boolean),e),i=[],n=e,r=t;do{let a=[];for(;a.push({face:n,vertex:r}),!!n.neighbours[r];){let h=n;n=n.neighbours[r],r=dh(n.neighbours.indexOf(h),n)}r=dh(r,n),i.push(a)}while(n!==e||r!==t);let o=new Nh(i);for(;;){let a=Math.max(3,...o.array.map(c=>c.val.length)),h=o.array.filter(c=>c.val.length>=a);if(!h.length)break;let l=new Set;for(let c of h){if(l.has(c))continue;let u=c.val.map(g=>M0(g.face,g.vertex)),d=E0(...u);for(let[g,y]of d.entries()){let f=c.val[g],v=c.val[g+1],w=f.vertex,$=uh(v.vertex,v.face);f.face.dihedral[w]=v.face.dihedral[$]=Math.max(y,f.face.dihedral[w]||0,v.face.dihedral[$]||0)}c.prev.val.push(...c.next.val),l.add(c.next),o.delete(c.next),o.delete(c)}}}function ud(s,e){return Math.max(...s.neighbours.map(t=>!t||t===e?0:ud(t,s)))+1}function fd(s,e){return s.visited?!0:(s.visited=!0,s.neighbours.filter(t=>t&&t!==e).some(t=>fd(t,s)))}function md(s,e,t,i){let n=s.neighbours.map((r,o)=>{if(!(!r||r===t))return md(r,e,s,s.dihedral[o])}).filter(Boolean);return{shape:s.polygon.translate(e.inverse),color:s.tile.props.color,children:n.length?n:void 0,dihedral:i?+Kt(i).toFixed(2):void 0,parentEdge:t?t.neighbours.indexOf(s):void 0,myEdge:t?s.neighbours.indexOf(t):void 0}}function A0(s){let e=s.map(t=>{let i=t.transformed.oriented,n=i.points.length;return{tile:t,polygon:i,size:n,neighbours:ne(void 0,n),dihedral:ne(void 0,n),edges:i.edges,center:i.centroid,radius:i.radius}});if(!e.some(t=>t.size<3)){for(let[t,i]of e.entries())for(let[n,r]of e.entries())if(!(t>=n)&&!(i.radius+r.radius!t.joined)&&!fd(e[0]))return e}}function gd(s){let e=A0(s);if(!e)return;C0(e);let t=Vs(e,n=>ud(n)),i=t.polygon.centroid;return[i,md(t,i)]}var fh=s=>Ki[s%Ki.length]||F.yellow;function yd(s){var t;let e=((t=s.c||s.children)==null?void 0:t.map(i=>yd(i)))||[];return{shape:Wr(s.shape||s.s),color:s.color||s.a,children:e,dihedral:s.dihedral||s.d,parentEdge:s.parentEdge||s.p,myEdge:s.myEdge||s.m,rot:s.rot||s.r}}function bd(s){var t;let e=(t=s.children)==null?void 0:t.map(i=>bd(i));return e!=null&&e.length||(e=void 0),{s:ri(s.shape),a:s.color,c:e,d:s.dihedral,p:s.parentEdge,m:s.myEdge,r:s.rot}}function k0(s){return yd(ve(s.replace(/([a-z]):/g,'"$1":'),{}))}function V0(s){return JSON.stringify(bd(s)).replace(/"([a-z])":/g,"$1:")}function ni(s,e=1){var i;let t=(i=s.children)==null?void 0:i.map(n=>ni(n,e));return Object.assign({},s,{children:t,shape:s.shape.scale(e)})}var vd=s=>s.split(",").map(e=>+e),mh=s=>s.map(e=>e.toFixed(4)).join(","),gh={Tetrahedron:{net:ni(sd,zt(3)*50),scale:1.1,name:"Tetrahedron"},Cube:{net:ni(id,zt(4)*50),scale:.8,name:"Cube"},Octahedron:{net:ni(nd,zt(3)*50),scale:.95,name:"Octahedron"},Dodecahedron:{net:ni(rd,zt(5)*50),scale:.42,name:"Dodecahedron"},Icosahedron:{net:ni(od,zt(3)*50),scale:.67,name:"Icosahedron"},Pyramid:{net:ld(6,50,100),scale:.57,name:"Pyramid"},Prism:{net:hd(6,50,100),scale:.45,name:"Prism"}},vh={fov:400},wd=[1.066,.243,-.088],rs=class extends H{constructor(t,i,n){var o;super(t,i,n);this.cannotRotateType=!0;this.net=((o=gh[this.props.net])==null?void 0:o.net)||k0(this.props.net),this.rotation=vd(this.props.rotation);let r=ch(this.net,a=>new Wi(a.shape,{class:"polygon-tile"},a.color||fh(a.shape.points.length)));this.solid=r.group,this.foldTree=r.foldTree,this.$el.append(this.solid.$el),this.$outline=m("path",{class:"outline"},this.$el),this.$moveBar=m("path",{d:"M0 0h30",class:"handle"},this.$el),this.$moveHandle=m("path",{d:"M0 0h14v14h-14Z",class:"handle",style:"cursor: grab"},this.$el),this.solid.$el.css("cursor","move"),this.props.watch("color",({color:a})=>{if(a){for(let h of this.solid.getFaces())h.color=a;this.render(!1)}}),this.render(),this.updateOutline(),t.events.listen(this.solid.$el,{start:()=>{t.selection.add(this,!0),this.$el.removeClass("active")},move:({posn:a,lastPosn:h})=>{this.solid.transform.dragToRotate(h.subtract(this.posn),a.subtract(this.posn),100),this.render(!1)},end:()=>{this.rotation=this.solid.transform.toEulerAngles(),this.props.rotation=mh(this.rotation),this.updateOutline(),t.flushChanges(),this.$el.addClass("active")},click:a=>t.tools.move.down(a),checkIfActive:()=>this.props.hinge>0})}applyChange(t){super.applyChange(t),this.rotation=vd(this.props.rotation),this.render(),this.updateOutline()}render(t=!0){t&&(this.solid.transform.clear(),ph(this.foldTree,this.solid.children[0],-this.props.hinge),this.solid.transform.rotate(...this.rotation)),this.solid.render(vh)}updateOutline(){let t=this.solid.getProjectedVertices(vh);this.path=V.convexHull(...t),this.$outline.draw(this.path),this.transform(),this.$moveBar.translate(this.path.points[0].x-30,this.path.points[0].y),this.$moveHandle.translate(this.path.points[0].x-45,this.path.points[0].y-7)}animateHinges(t,i=!1,n=800){return D(this,null,function*(){let r=i?this.rotation:[0,0,0],o=this.props.hinge;yield mt(a=>{this.props.hinge=ht(o,t,a),i&&(this.rotation=r.map(h=>h*(1-a))),this.render()},n).promise,this.props.rotation=mh(this.rotation),this.updateOutline()})}hingeStart(){this.startRotation=this.rotation,this.startAngle=this.props.hinge,this.$el.removeClass("active")}hingeMove(t){if(!x(t,this.props.hinge)){if(this.props.hinge=B(t,0,1),this.startRotation&&this.startAngle){let i=B(t/this.startAngle,0,1);this.rotation=this.startRotation.map(n=>i*n)}this.render()}}hingeEnd(){this.updateOutline(),this.props.rotation=mh(this.rotation),this.$el.addClass("active")}static fold(t){let i=gd(t);if(!i){wr("polyhedron-error");return}let n={name:"polyhedron",net:V0(i[1]),hinge:0,rotation:"0,0,0"},r=H.create(t[0].$parent,n),o=r.solid.children[0].transform.matrix;r.setTransform(i[0].shift(-o[0][3],-o[1][3])),r.props.hinge=1,setTimeout(()=>{r.props.hinge=0,r.animateHinges(1)},10);for(let a of t)a.delete();return r}unfold(){return D(this,null,function*(){this.$parent.selection.remove(this),this.props.hinge>0&&(yield this.animateHinges(0,!0));let t=Array.from(this.solid.getFaces()).map(i=>{let n=new V(...Array.from(i.getProjectedVertices())),r=this.props.color||i.color||fh(n.points.length);return H.create(this.$parent,{name:"polygon",shape:ri(n),color:r,x:this.posn.x,y:this.posn.y})});return this.delete(),t})}static makeThumbnail(t,i){let n=m("svg",{width:70,height:70},t),r=m("g",{transform:"translate(35, 35)"},n),{net:o,scale:a}=gh[i.net],h=ch(o,l=>new Wi(l.shape,{class:"polygon-tile"},fh(l.shape.points.length)),-1).group;h.transform.clear().rotate(...wd).scale({x:a,y:a,z:a}),r.append(h.$el),h.render(vh)}static altText(t){var i;return((i=gh[t.net])==null?void 0:i.name)||"Polyhedron"}};rs.type="polyhedron",rs.defaultProps={hinge:1,rotation:wd.join(",")},rs=T([Ut],rs);Mt([{id:"unfold",type:"button",tileTypes:["polyhedron"],label:"Unfold",click:s=>Promise.all(s.map(e=>e.unfold()))},{id:"hinges",type:"slider",tileTypes:["polyhedron"],label:"Hinges",start:s=>s.hingeStart(),move:(s,e)=>s.hingeMove(e),end:s=>s.hingeEnd(),get:s=>s.props.hinge}]);var I=50,ot=Math.sqrt(3)/4*I;function zt(s){let e=Math.cos(Pt/s);return 1/Math.sqrt(2-2*e)}var xd={"equ-triangle":new V(new p(-I/2,ot),new p(I/2,ot),new p(0,-ot)),square:V.regular(4,I*zt(4)),"reg-pentagon":V.regular(5,I*zt(5)),"reg-hexagon":V.regular(6,I*zt(6)),"reg-heptagon":V.regular(7,I*zt(7)),"reg-octagon":V.regular(8,I*zt(8)),"reg-decagon":V.regular(10,I*zt(10)),"reg-dodecagon":V.regular(12,I*zt(12)),rectangle:new G(new p(-I,-I/2),2*I,I).polygon,trapezium:new V(new p(-I,ot),new p(I,ot),new p(I/2,-ot),new p(-I/2,-ot)),rhombus:new V(new p(-I*3/4,ot),new p(I/4,ot),new p(I*3/4,-ot),new p(-I/4,-ot)),"right-triangle":new V(new p(-I/2,-I/2),new p(I/2,-I/2),new p(-I/2,I/2)),"rhombus-2":new V(new p(I/2-ot,I/4),new p(-ot-I/2,I/4),new p(ot-I/2,-I/4),new p(ot+I/2,-I/4)),chevron:new V(new p(-.75*I,2*ot),new p(.25*I,2*ot),new p(.75*I,0),new p(.25*I,-2*ot),new p(-.75*I,-2*ot),new p(-.25*I,0)),"right-triangle-2":new V(new p(-2*ot,-I/2),new p(-2*ot,I/2),new p(2*ot,-I/2)),kite:new V(new p(0,-I),new p(2*ot,-I/2),new p(0,I),new p(-2*ot,-I/2)),dart:new V(new p(2*ot,.75*I),new p(0,-.75*I),new p(-2*ot,.75*I),new p(0,.25*I))},I0={"equ-triangle":"Equilateral Triangle",square:"Square","reg-pentagon":"Regular Pentagon","reg-hexagon":"Regular Hexagon","reg-heptagon":"Regular Heptagon","reg-octagon":"Regular Octagon","reg-decagon":"Regular Decagon","reg-dodecagon":"Regular Dodecagon",rectangle:"Rectangle",trapezium:"Trapezium",rhombus:"Rhombus","right-triangle":"Right Triangle","rhombus-2":"Rhombus",chevron:"Chevron","right-triangle-2":"Right Triangle",kite:"Kite",dart:"Dart"},L0=[[[-15.7728,63.1105],[-65.2725,56.0545],[-61.7426,-21.037],[-34.7275,-63.1105],[65.2725,-63.1105]],[[60.6056,14.8729],[-53.4909,57.394],[-80.668,-12.5086],[-20.582,-57.394],[80.668,-57.394]],[[0,-73.612],[50,12.9905],[15,73.612],[-50,12.9905],[-30,-73.612]],[[67.056,-58.248],[67.056,1.752],[-10.5597,58.248],[-67.056,-19.3675],[7.056,-58.248]],[[-74.4415,-47.6314],[35.5585,-47.6314],[74.4415,-8.733],[60.1965,44.3902],[-19.4415,47.6314]],[[47.6215,-81.108],[43.731,-26.2458],[-24.012,81.108],[-47.6215,-43.6179],[-7.3786,-81.108]],[[94.9659,43.7299],[-5.0343,43.7299],[-94.9659,0],[-5.0343,-43.7299],[42.1151,-41.1631]],[[-13.1927,57.1955],[76.8074,57.1955],[76.8257,-32.8045],[-9.8062,-57.1955],[-76.8257,-6.4506]],[[-3.2764,58.8874],[86.2804,29.1016],[26.2804,-43.7514],[-26.2804,-58.8874],[-86.2804,13.9666]],[[51.5265,-55],[58.4735,-14.7198],[9.6458,43.251],[-58.4735,55],[-58.4735,-55]],[[-95.733,-40.991],[53.87,-40.991],[95.733,-15.7718],[1.5099,40.991],[-95.733,-10.4271]],[[-85.642,-51.4515],[12.4961,-51.4515],[85.642,-13.2965],[-38.4855,51.4515],[-85.642,18.5485]],[[-69.99,67.0025],[84.488,2.9975],[84.488,-67.0025],[14.488,-67.0025],[-84.488,32.0117]],[[-15.6401,96.696],[46.9202,6.219],[8.0799,-96.696],[-46.9202,-96.696],[-46.9202,51.458]],[[-46.6683,85],[-46.6683,22.7758],[15.5561,-85],[46.6683,-31.1122],[15.5561,85]],[[0,-46.65],[-43.301,-21.65],[-43.301,46.65],[43.301,46.65],[43.301,-21.65]],[[-25,46.65],[25,46.65],[59.15,-12.5],[0,-46.65],[-59.15,-12.5]],[[0,-64.951],[-50,21.65],[-25,64.951],[25,64.951],[50,21.65]]].map(s=>new V(...s.map(e=>new p(...e)))),Ki=["","","",F.yellow,F.blue,F.green,F.red,F.teal,F.purple],O0={trapezium:F.orange,"right-triangle":F.green,"rhombus-2":F.lime,chevron:F.orange,kite:F.purple,dart:F.teal},R0={"equ-triangle":F.green,square:F.yellow,"reg-pentagon":F.blue,"reg-hexagon":"#ffd615",rectangle:F.yellow,trapezium:"#cc1030",rhombus:F.blue,"rhombus-2":"#e6e2c6",chevron:"#cc1030","right-triangle-2":"#ffd615",kite:"#134791",dart:F.purple},D0=[...xt.rainbow(15).map(s=>s.hex),F.red,F.blue,F.yellow],N0=new Set(["trapezium","rhombus","rhombus-2","rectangle","right-triangle","right-triangle-2"]),G0=new Set(["equ-triangle","square","reg-pentagon","reg-hexagon","reg-heptagon","reg-octagon","reg-decagon","reg-dodecagon","rectangle","trapezium","kite","dart"]),ri=s=>s.points.map(e=>`${e.x.toFixed(2)} ${e.y.toFixed(2)}`).join(","),z0=s=>new V(...s.split(",").map(e=>{let[t,i]=e.split(" ");return new p(+t||0,+i||0)}));function Wr(s){return s.startsWith("pentagon-")?L0[+s.slice(9)-1]:/^[\d.-]/.test(s)?z0(s):xd[s]||xd.square}function $d(s,e,t=!1){return s.startsWith("pentagon-")?D0[+s.slice(9)-1]:(t?R0:O0)[s]||Ki[e%Ki.length]||F.yellow}var Xi=class extends si{constructor(e,t,i){super(e,t,i);let n=Wr(this.props.shape);this.props.watch("scale isFlipped",({isFlipped:r,scale:o})=>this.setPath(n.scale(o||1),r)),this.symmetric=G0.has(this.props.shape),this.props.color||(this.props.color=$d(this.props.shape,this.path.points.length,e.options.altColors))}static makeThumbnail(e,t,i){let n=N0.has(t.shape)?60:80,r=Wr(t.shape);r=r.scale((t.shape.startsWith("pentagon-")?41:36)/r.radius).shift(40,n/2);let o=m("svg",{width:80,height:n},e),a=m("path",{class:"polygon-tile",path:r},o);i.options.watch(h=>a.setAttr("fill",$d(t.shape,r.points.length,h.altColors)))}static altText(e){if(e.shape.startsWith("pentagon-")){let t=+e.shape.slice(9);return t<16?`Pentagon ${t}`:t===16?"Prismatic Pentagon":t===17?"Cairo Pentagon":"Floret Pentagon"}return I0[e.shape]||"Polygon"}};Xi.type="polygon",Xi=T([Ut],Xi);var oi=["polygon","tangram","polyomino","custom-polygon","rectangle","reg-polygon","fractal","penrose","aperiodic-hat"];Mt([{id:"flip",type:"button",label:"Flip",tileTypes:[...oi,"arrow","egg","garden","number-frame"],show:s=>s.length>1||!!s[0].rot||!s[0].symmetric,click:(s,e)=>{let t=e.selection.center;for(let i of s)i.flip(t)}},{id:"cut",type:"button",tileTypes:oi,label:"Cut",noFlush:!0,show:s=>s.every(e=>!(e.is("rectangle")&&e.props.cornerRadius>0)),click:(s,e)=>e.tools.cutPolygon.enable()},{id:"join",type:"button",label:"Join",tileTypes:oi,location:"more",show:s=>s.length>1&&s.every(e=>!(e.is("rectangle")&&e.props.cornerRadius>0)),click:(s,e)=>{let t=s.map(o=>o.transformed),i=V.union(...t),n=s[0].props.color,r=i.map(o=>H.create(e,{name:"polygon",shape:ri(o),color:n}));for(let o of s)o.delete();e.selection.select(r,!0)}},{id:"fold-net",type:"button",label:"Fold Net",tileTypes:oi,show:s=>s.length>2,click:s=>rs.fold(s)},{id:"animation",type:"select",tileTypes:oi,label:"Animation:",location:"music",flattenGroups:!0,feature:"noMusic",options:[{key:"vertices",label:"Vertices"},{key:"perimeter",label:"Perimeter"},{key:"area",label:"Area"},{key:"angles",label:"Angles"}],get:s=>{var e;return((e=s.props.animation)==null?void 0:e.replace("hidden","perimeter"))||"perimeter"},set:(s,e)=>e.props.animation=s},{id:"audio-labels",type:"checkbox",tileTypes:oi,label:"Show labels:",location:"music",flattenGroups:!0,feature:"noMusic",show:s=>s.every(e=>!["vertices"].includes(e.props.animation)),get:s=>s.props.labels==="number",set:(s,e)=>e.props.labels=s?"number":void 0}]);Mt([{id:"label",type:"input",label:"Label:",tileTypes:Gr,icon:"text",authorOnly:!0,get:s=>s.props.textLabel||"",set:(s,e)=>e.props.textLabel=`${s}`},{id:"labelFontSize",type:"input",label:"Font size:",tileTypes:Gr,icon:" ",value:"number",range:[1,15],increment:1,authorOnly:!0,show:s=>s.some(e=>e.props.textLabel),get:s=>5+(s.props.textLabelFontSize||0),set:(s,e)=>e.props.textLabelFontSize=+s-5},{id:"textLabelRotate",type:"checkbox",label:"Rotate label:",tileTypes:Gr,icon:" ",authorOnly:!0,show:s=>s.some(e=>e.props.textLabel),get:s=>!!s.props.textLabelRotate,set:(s,e)=>e.props.textLabelRotate=s}]);Mt([{id:"scale",type:"input",label:"Scale:",location:"more",value:"number",range:[.1,10],icon:"geo-scale",increment:.1,tileTypes:["polygon","reg-polygon","rectangle","custom-polygon"],get:s=>s.props.scale||1,set:(s,e)=>{let t=e.path.centroid.scale(1-+s/(e.props.scale||1));e.setTransform(e.posn.add(t)),e.props.scale=+s,e.$parent.selection.update()}}]);var Pd='';var yt=50,B0=100,di=class extends H{constructor(t,i,n){super(t,i,n);this.cannotRotateType=!0;this.cannotDragToSelect=!0;this.$el.addClass("utensil"),this.setup(),this.$handles=[0,1].map(r=>this.makeHandle("c",(o,a)=>{let h=r?this.posn:this.absoluteEnd;a=this.$parent.snapping.orthogonal(a,h),r&&(this.absoluteEnd=a);let l=r?this.posn:a;this.props.isFixed||(this.props.width=Math.max(p.distance(l,this.absoluteEnd),B0)),this.setTransform(l,Kt(this.absoluteEnd.angle(l))),this.update()})),this.update()}applyChange(t){super.applyChange(t),this.update()}flip(){this.props.isFlipped=!this.props.isFlipped,this.update()}transform(t){super.transform(t),this.absoluteEnd=this.worldPosn(new p(this.props.width,0))}update(){this.$handles[1].setCenter({x:this.props.width,y:0}),this.transform()}getDrawingPath(t){var n;let i=(n=this.transformed)==null?void 0:n.project(t);if(i&&p.distance(t,i)<30)return this.transformed}},_0=new Set(["ruler","protractor","set-triangle","compass"]);function Sd(s){return _0.has(s.props.name)}var q0=2.54,Kr=60,ai=yt*q0;function*Td(s,e,t,i){let n=(e+.1)/s;for(let r=0;r<=n;r+=1){let o=i?i.findIndex(h=>!(r%h)):-1,a=r*s;yield[t?e-a:a,o]}}var hi=class extends di{constructor(t,i,n){super(t,i,n);this.padding=[0,20,0,20];this.props.watch("units fixed",()=>this.update())}setup(){this.$glass=m("rect",{x:-20,height:Kr,class:"glass",rx:5},this.$el),this.$ticks=m("path",{class:"ticks"},this.$el),this.$labelsTop=z(t=>m("text",{text:t},this.$el),31),this.$labelsBottom=z(t=>m("text",{text:t,y:42},this.$el),12),this.$labelsBottom[0].text="0 in"}update(){let{units:t,width:i,isFlipped:n}=this.props,r=t==="both",o=t==="hidden";this.$glass.setAttr("width",i+40),this.path=new G(R,i,Kr);let a="";if(!o&&t!=="in")for(let[l,c]of Td(yt/10,i,n,[10,5]))a+=`M${l} 0v${([20,15][c]||10)*(r?.8:1)}`;if(!o&&t!=="cm"){let l=r?Kr:0;for(let[c,u]of Td(ai/16,i,n,[16,8,4]))a+=`M${c} ${l}v${([20,16,12][u]||8)*(r?-.8:1)}`}this.$ticks.setAttr("d",a),this.$labelsTop[0].text=t==="in"?"0 in":"0 cm";let h=t==="in"?ai:yt;for(let[l,c]of this.$labelsTop.entries())c.toggle(!o&&l*h<=i+.1),c.setAttr("y",r?26:32),c.setAttr("x",n?i-h*l:h*l);for(let[l,c]of this.$labelsBottom.entries())c.toggle(!o&&r&&l*ai<=i+.1),c.setAttr("x",n?i-ai*l:ai*l);super.update()}getSnapPoints(){if(this.props.units==="hidden")return[];let t=this.props.units==="both",i=ai/2,n=z(o=>new p(this.props.isFlipped?this.props.width-o*yt:o*yt,0),this.props.width/yt),r=z(o=>new p(this.props.isFlipped?this.props.width-o*i:o*i,t?Kr:0),this.props.width/i);return this.props.units==="cm"?n:t?[...n,...r]:r}getSnapLines(){let[t,i,n]=this.path.edges;return this.props.units==="both"?[t,n]:[t]}getDrawingPath(t){if(!this.transformed)return;let[i,n,r]=this.transformed.edges,o=p.distance(t,i.project(t)),a=p.distance(t,r.project(t));return o<30?i:this.props.units==="both"&&a<30?r:void 0}static altText(){return"Ruler"}};hi.type="ruler",hi.defaultProps={width:400,layer:"front",units:"cm"},hi=T([Ut],hi);function F0(s){return`M0-${s}A${s},${s},0,0,0-${s},0V3a5,5,0,0,0,5,5H${s-5}a5,5,0,0,0,5-5V0A${s},${s},0,0,0,0-${s}Z`}var li=class extends di{constructor(){super(...arguments);this.padding=[0,0,10,0]}setup(){this.$glass=m("path",{d:"",class:"glass"},this.$el),this.$ticks=m("path",{class:"ticks"},this.$el),this.$labels=z(t=>[m("text",{text:t*10},this.$el),m("text",{text:t*10,style:"font-size:9px"},this.$el)],19),this.$labels[9][0].css("font-size","20px"),this.$labels[9][1].hide()}update(){let t=this.props.width;this.path=new Ft(R,new p(-this.props.width,0),Math.PI),this.$glass.setAttr("d",F0(t));let i="",n=this.props.width<120?5:1;for(let r=0;r<=180;r+=n){let o=!(r%10),a=!o&&!(r%5),h=p.fromPolar(J(-r)),l=t-(o?30:a?23:15);i+=`M${h.x*t} ${h.y*t}L${h.x*l} ${h.y*l}`,o&&(i+=`M${h.x*8} ${h.y*8}L${h.x*(t-60)} ${h.y*(t-60)}`)}this.$ticks.setAttr("d",i);for(let[r,[o,a]]of this.$labels.entries()){if(r===9){o.setAttr("y",52-t);continue}o.toggle(t>160||!(r%3)),a.toggle(t>160),o.setAttr("y",44-t),a.setAttr("y",55-t),o.setAttr("transform",`rotate(${(this.props.isFlipped?-1:1)*(90-10*r)})`),a.setAttr("transform",`rotate(${(this.props.isFlipped?1:-1)*(90-10*r)})`)}super.update()}getSnapPoints(){return[R,this.path.start,this.path.at(.5),this.path.end]}getSnapLines(){return[]}static altText(){return"Protractor"}};li.type="protractor",li.defaultProps={width:200,layer:"front"},li=T([Ut],li);var wh=234,Zr=150;function H0(s){let e=sm("text",{text:t,y:-23},this.$el),31),this.$hLabels[0].hide(),this.$vLabels=z(t=>m("text",{text:t,x:25,"dominant-baseline":"central"},this.$el),31),this.$vLabels[0].hide()}update(){this.path=new V(R,new p(this.props.width,0),new p(0,-this.props.width)),this.$glass.setAttr("d",H0(this.props.width));let t=this.props.width-50,i="",n=2,r=1;for(let o=0;o<=t;o+=yt/10){let a=o%yt?o%(yt/2)?0:r:n,h=o<10?-10*(o/10):[-10,-15,-20][a];i+=`M${o} 0V${h}`}for(let o=0;o<=t;o+=yt/10){let a=o%yt?o%(yt/2)?0:r:n,h=o<10?10*(o/10):[10,15,20][a];i+=`M0,${-o} H${h}`}this.$ticks.setAttr("d",i);for(let[o,a]of this.$hLabels.entries())o>0&&a.toggle(this.props.width>=Zr&&o0&&a.toggle(this.props.width>=Zr&&oi.at(a*yt/t),t/yt),o=z(a=>n.at(a*yt/t),t/yt);return r.concat(o)}getSnapLines(){return[this.path]}static altText(){return"Set Triangle"}};ci.type="set-triangle",ci.defaultProps={width:280,layer:"front"},ci=T([Ut],ci);var Xr=375,Yr=new p(54,68),pi=class extends di{setup(){this.$el.html=Pd,this.$pencil=this.$el.$(".pencil"),this.$top=this.$el.$(".top"),this.$legPin=this.$el.$(".leg-pin"),this.$legPencil=this.$el.$(".leg-pencil"),this.props.watch("color",({color:n})=>this.$pencil.css("fill",n));let t,i=0;this.$parent.events.listen(this.$pencil.$("g"),{start:n=>{let r=new p(this.props.width,0).rotate(J(this.rot)).add(this.posn);t=new Fe(this.$parent,"",this.props.color,"pen"),t.start(r,new wt(this.posn,this.props.width)),i=Kt(n.posn.angle(this.posn))-this.rot;for(let o of this.$handles)o.setAttr("hidden",!0)},move:n=>{this.rot=Kt(n.posn.angle(this.posn))-i,this.transform();let r=p.fromPolar(J(this.rot),this.props.width).add(this.posn);t.addPoint(r)},end:()=>{t.end(),this.$parent.flushChanges(),t=void 0;for(let n of this.$handles)n.removeAttr("hidden")}}),this.$parent.events.listen(this.$top,{start:n=>{i=Kt(n.posn.angle(this.posn))-this.rot;for(let r of this.$handles)r.setAttr("hidden",!0)},move:n=>{this.rot=Kt(n.posn.angle(this.posn))-i,this.transform()},end:()=>{this.$parent.flushChanges();for(let n of this.$handles)n.removeAttr("hidden")}})}update(){this.props.width>730&&(this.props.width=730);let t=this.props.width-Yr.x,i=Xr-Yr.y,n=new wt(R,Xr),r=new wt(new p(t,-Yr.y),i),o=Q(n,r)[0],a=Math.acos(o.x/Xr),h=Math.acos((t-o.x)/i);this.$legPin.css("transform",`rotate(${-a+Ka}rad`),this.$legPencil.css("transform",`rotate(${h-Ka}rad`),this.$pencil.setTransform({x:this.props.width-Yr.x,y:0}),this.$top.setTransform({x:o.x,y:Xr+o.y}),this.path=new Y(R,new p(this.props.width,0)),super.update()}getSnapPoints(){return[R,new p(this.props.width,0)]}getDrawingPath(){}static altText(){return"Compass"}};pi.type="compass",pi.defaultProps={width:300,layer:"front",color:F.red},pi=T([Ut],pi);Mt([{id:"flip",type:"button",tileTypes:["ruler","protractor"],label:"Flip",click:s=>{for(let e of s)e.flip()}}]);Mt([{id:"labels",type:"select",tileTypes:["ruler"],label:"Labels:",options:[{label:"Centimeters",key:"cm"},{label:"Inches",key:"in"},{label:"Both",key:"both"},{label:"None",key:"hidden"}],location:"more",get:s=>s.props.units,set:(s,e)=>e.props.units=s},{id:"fixed-length",type:"checkbox",tileTypes:["ruler"],label:"Fixed Length",location:"more",get:s=>!!s.props.isFixed,set:(s,e)=>e.props.isFixed=s}]);var je=class{constructor(e){this.$parent=e}getTileAt(e){let t=this.$parent.snapping.snapGeo(e.posn);if(t!=null&&t.tile&&t.tile.canSelect)return t.tile;let i=e.target;for(;i;){let n=Br.get(i);if(n!=null&&n.canSelect&&n.props.name!=="geo")return n;if(i=i.parentNode||void 0,i===this.$parent._el)return}}hoverGeoTile(e){var t;this.hoveringTile!==e&&((t=this.hoveringTile)==null||t.hover(!1)),e==null||e.hover(),this.hoveringTile=e}down(e){}start(e){}move(e){}up(e){}end(e){}click(e){}hover(e){}cancel(){}},Qr=class extends je{constructor(){super(...arguments);this.clickTimeout=0}down(t){var n,r;let i=this.activeTile=(n=this.getTileAt(t))==null?void 0:n.root;this.previousSelection=void 0,(r=this.$parent.focussedTile)==null||r.blur(),this.$parent.warningBanner.hide(),i?(i.isActive&&this.$parent.events.shiftKey?this.$parent.selection.remove(i):(this.$parent.events.shiftKey||!i.isActive)&&this.$parent.selection.add(i,!this.$parent.events.shiftKey),i.down(t),this.$parent.events.grabbing()):this.$parent.events.shiftKey?this.previousSelection=new Set(this.$parent.selection.tiles):this.$parent.selection.clear()}up(t){var i;(i=this.activeTile)==null||i.up(t)}start(){if(this.activeTile){let t=!this.$parent.state.authorMode&&this.activeTile.props.status==="generator";(this.$parent.events.altKey||t)&&(t&&this.$parent.selection.add(this.activeTile,!0),this.$parent.paste(this.$parent.selection.copy(!0),R)),this.$parent.selection.moveStart()}else this.$parent.$selection.show()}move(t){var n;if(this.activeTile){this.$parent.selection.move(t);return}let i=G.aroundPoints([t.startPosn,t.posn]);this.$parent.$selection.setRect(i);for(let r of this.$parent.tiles.values()){if(!r.canSelect||r.cannotDragToSelect||!r.transformed||r.group)continue;let o=Bi(i,r.transformed,r.props.name);(this.$parent.events.shiftKey&&((n=this.previousSelection)==null?void 0:n.has(r))?!o:o)?this.$parent.selection.add(r,!1,!0):this.$parent.selection.remove(r,!0)}this.$parent.selection.update(!0)}end(){this.activeTile?this.$parent.selection.moveEnd():this.$parent.$selection.hide(),this.$parent.events.grabbing(!1)}click(t){if(this.activeTile){this.activeTile.click(t);let i=Date.now();i-this.clickTimeout<500&&this.activeTile.doubleClick(t),this.clickTimeout=i}}hover(t){let i=this.getTileAt(t);this.hoverGeoTile(i!=null&&i.is("geo")?i:void 0),this.$parent.$svg.css("cursor",i?"grab":"")}},Jr=class extends je{down({posn:e}){this.erase(e)}move({posn:e,lastPosn:t}){let i=p.distance(e,t)/4;for(let n=0;nn.distanceSquared(e)<100):U(t)&&i==="geo"?Math.abs(p.distance(e,t.c)-t.r)<10:t.contains(e)}erase(e){let t=this.$parent.option("noDeleting")?[]:this.$parent.tiles.values();for(let i of t)if(!(!i.transformed||i.cannotDragToSelect||!i.canSelect||!i.canEdit)&&this.shouldErase(e,i.transformed,i.props.name)){i.delete();return}for(let i of this.$parent.strokes.values())if(i.hitTest(e,10)){i.delete();return}}end(){this.$parent.flushChanges(),this.$parent.snapping.updateIntersections()}click(){this.end()}},to=class extends je{constructor(){super(...arguments);this.options="text"}down({posn:t}){let i=H.create(this.$parent,{name:this.options,x:t.x-10,y:t.y-15});this.$parent.trigger("add-tile",{tile:i}),this.$parent.setActiveTool("move"),i.focus(!0)}},eo=class extends je{enable(){this.previousTool=this.$parent.state.tool,this.$parent.setActiveTool("pan")}down(t){this.initialOrigin=this.$parent.origin,this.startPosn=Vt(t.event)}move(t){let i=Vt(t.event).subtract(this.startPosn),n=this.initialOrigin.subtract(i.scale(1/this.$parent.zoom));this.$parent.setViewport(n,this.$parent.zoom)}disable(){this.$parent.setActiveTool(this.previousTool)}},so=class extends je{constructor(){super(...arguments);this.options="pen"}getUtensil(t){for(let i of this.$parent.tiles.values()){let n=Sd(i)?i.getDrawingPath(t):void 0;if(n)return n}}down({posn:t}){this.stroke=new Fe(this.$parent,"",this.$parent.state.penColor,this.options),this.stroke.start(t,this.getUtensil(t))}move({posn:t}){this.stroke.addPoint(t)}click(){this.$parent.flushChanges(),this.stroke=void 0}end(t){this.stroke.end(),this.click()}},Yi=class extends je{constructor(){super(...arguments);this.options="line";this.angleIndex=0}expr(t,i){var n;switch(this.options){case"line":return`segment(${t},${i})`;case"circle":return`circle(${t},distance(${t},${i}))`;case"rect":return`rectangle(${t},${i}.x-${t}.x,${i}.y-${t}.y)`;case"angle":return`angle(${i},${(n=this.midPoint)==null?void 0:n.props.key},${t})`}}snapPoint(t){var o;this.$parent.options.canvas!=="infinite"&&(t=t.clamp(this.$parent.canvasBounds));let i=this.$parent.snapping.snap([t]);i&&(t=t.add(i.shift));let n="",r=((o=i==null?void 0:i.tile)==null?void 0:o.props.name)==="geo"?i==null?void 0:i.tile:void 0;return r!=null&&r.path&&nt(r.path)&&(n=r.props.key),i!=null&&i.intersection&&(n=i.intersection),{point:t,tile:r,expr:n||`point(${t.x},${t.y})`}}getOrMakePointTile(t){var n,r;if((n=t==null?void 0:t.tile)!=null&&n.path&&nt(t.tile.path))return t.tile;if((r=t==null?void 0:t.tile)!=null&&r.path){let o=t.tile.path.offset(t.point),a=new Yt(this.$parent,{expr:`${t.tile.props.key}.at(${o})`});return this.$parent.trigger("add-tile",{tile:a}),a}let i=new Yt(this.$parent,{expr:t.expr});return this.$parent.trigger("add-tile",{tile:i}),i}drawPendingPoint(t){var r,o;let i=((o=(r=t.tile)==null?void 0:r.path)==null?void 0:o.type)==="point",n=t.expr.startsWith("intersection");this.$parent.$pendingPoint.toggle(!i),i||(this.$parent.$pendingPoint.setCenter(t.point),this.$parent.$pendingPoint.setClass("intersection",n),this.$parent.$pendingPoint.setAttr("r",n?3.5:6))}down({posn:t}){let i=this.snapPoint(t),n=this.getOrMakePointTile(i);this.options==="angle"?(this.angleIndex===0?(this.startPoint=n,this.angleIndex=1):this.angleIndex===1?(this.midPoint=n,this.angleIndex=2,this.path=new Yt(this.$parent,{expr:this.expr(this.startPoint.props.key,n.props.key)})):(this.path.setExpr(this.expr(this.startPoint.props.key,n.props.key)),this.angleIndex=0,this.path=this.startPoint=this.midPoint=void 0),this.$parent.flushChanges()):this.startPoint=n}start(){var t;this.options!=="angle"&&(this.path=new Yt(this.$parent,{}),this.startPoint.pending=this.path.pending=!0,(t=this.$parent.$pendingPoint)==null||t.show(),this.hoverGeoTile())}move({posn:t}){var i;this.options!=="angle"&&(this.endSnap=this.snapPoint(t),this.path.setExpr(this.expr(this.startPoint.props.key,this.endSnap.expr),!0),this.drawPendingPoint(this.endSnap),this.hoverGeoTile((i=this.endSnap)==null?void 0:i.tile))}end(){var n;if(this.options==="angle")return;let t=p.distance(this.startPoint.path,this.endSnap.point)<8,i;t?this.path.delete():(i=this.getOrMakePointTile(this.endSnap),this.path.setExpr(this.expr(this.startPoint.props.key,i.props.key)),this.path.setPending(!1),this.$parent.trigger("add-tile",{tile:this.path})),this.startPoint.setPending(!1),(n=this.$parent.$pendingPoint)==null||n.hide(),this.hoverGeoTile(),this.$parent.snapping.updateIntersections(),this.$parent.flushChanges(),this.startPoint=this.path=this.endSnap=void 0}click(){this.options!=="angle"&&this.$parent.flushChanges()}hover(t){var n;let i=this.snapPoint(t.posn);this.drawPendingPoint(i),this.hoverGeoTile(((n=i==null?void 0:i.tile)==null?void 0:n.props.name)==="geo"?i.tile:void 0),this.options==="angle"&&this.angleIndex===2&&this.path.setExpr(this.expr(this.startPoint.props.key,i.expr))}cancel(){this.$parent.$pendingPoint.hide(),this.path&&this.path.delete(),this.startPoint=this.path=this.endSnap=void 0,this.angleIndex=0}},io=class extends Yi{constructor(){super(...arguments);this.expression=""}enable(t){var i;this.expression=t,this.$parent.selection.clear(),this.$parent.setActiveTool("geoPending"),(i=window.event)!=null&&i.clientX&&this.hover({posn:fe(window.event,this.$parent.$svg)})}makePath(){return this.path=new Yt(this.$parent,{}),this.path.$el.css("opacity",.5),this.path.pending=!0,this.path}down(t){if(!this.expression)return;super.down(t);let i=this.path||this.makePath();i.$el.css("opacity",1),i.setExpr(this.expression.replace(/\$1/g,this.startPoint.props.key)),i.pending=!1,this.path=void 0,this.$parent.selection.add(i,!0),this.$parent.flushChanges(),this.$parent.snapping.updateIntersections(),this.$parent.trigger("add-tile",{tile:i}),this.$parent.setActiveTool("move")}hover({posn:t}){var n;if(!this.expression)return;let i=this.snapPoint(t);this.drawPendingPoint(i),this.hoverGeoTile(((n=i==null?void 0:i.tile)==null?void 0:n.props.name)==="geo"?i.tile:void 0),this.path||this.makePath(),this.path.setExpr(this.expression.replace(/\$1/g,i.expr))}cancel(){super.cancel(),this.expression=""}},no=class extends je{enable(){if(this.tiles=Array.from(this.$parent.selection.tiles),!this.tiles.length)return this.cancel();this.$parent.selection.clear(),this.$parent.setActiveTool("cutPolygon");for(let t of this.tiles)t.$el.addClass("active")}down(){}start({posn:t}){var i;this.tiles&&(this.startPoint=((i=this.$parent.snapping.snap([t]))==null?void 0:i.posn)||t,this.$stroke=m("line",{class:"stroke cut"},this.$parent.$strokes))}move({posn:t}){var i,n;this.tiles&&(this.endPoint=((i=this.$parent.snapping.snap([t]))==null?void 0:i.posn)||t.snap(this.startPoint,5),(n=this.$stroke)==null||n.setLine(this.startPoint,this.endPoint))}end(t){var n;if(!this.tiles)return;if(t.cancelled)return this.cancel();let i=new vt(this.startPoint,this.endPoint);for(let r of this.tiles||[]){let a=r.transformed.cut(i);if(a.length>1){for(let h of a)H.create(this.$parent,ut(dt({},r.props.raw),{name:"polygon",shape:ri(h),scale:void 0,index:void 0,isFlipped:void 0,width:void 0,height:void 0,sides:void 0,x:0,y:0,rot:0}));r.delete()}else r.$el.removeClass("active")}this.$parent.flushChanges(),(n=this.$stroke)==null||n.remove(),this.$stroke=this.tiles=this.startPoint=this.endPoint=void 0,this.$parent.setActiveTool("move")}click(){this.cancel()}cancel(){var t;for(let i of this.tiles||[])i.$el.removeClass("active");(t=this.$stroke)==null||t.remove(),this.$stroke=this.tiles=this.startPoint=this.endPoint=void 0,setTimeout(()=>this.$parent.setActiveTool("move"))}};var Ed='
';var j0=new Set(["x","y","\u03B8","r"]);function Md(s){if(s instanceof jt&&s.fn==="="){let[e,t]=s.args;if(e instanceof Ys&&!j0.has(e.i))return{variable:e.i,expression:t}}return{expression:s}}var ro=class{constructor(){this.assignments=new Map;this.callbackDeps=new Map;this.updatedNames=new Set}findFirstAssigner(e){var t;return(t=this.assignments.get(e))==null?void 0:t.keys().next().value}findDependants(e,t=[]){let i=[];for(let[r,o]of this.assignments.entries())o.size===1&&r!==e&&!t.includes(r)&&ks(o.values()).unknowns.filter(h=>!t.includes(h)).includes(e)&&i.push(r);let n=Bh(i,r=>this.findDependants(r,i.filter(o=>o!==r)));return[...i,...n]}validate(e){let t=new Set,i=(n,r=[])=>{if(!this.assignments.has(n)){t.add(n);return}if(r.includes(n))return{message:`The variable ${n} is defined recursively.`,locations:r.splice(r.indexOf(n)).map(a=>this.findFirstAssigner(a))};let o=this.assignments.get(n);if(o.size===1){let a=ks(o.values());for(let h of a.unknowns){let l=i(h,[...r,n]);if(l)return l}}else return{message:`You have defined ${n} in multiple places.`,locations:Array.from(o.keys())}};for(let n of e.unknowns){let r=i(n);if(r)return{error:r,dependsOn:[],unknowns:[]}}return{dependsOn:[],unknowns:Array.from(t)}}evaluate(e){let{error:t,unknowns:i}=this.validate(e);if(t||i.length)return{error:t,value:Number.NaN};try{return{value:e.evaluate(this.evalContext)}}catch(n){return{value:Number.NaN}}}get evalContext(){let e={};for(let[t,i]of this.assignments.entries())i.size===1&&(e[t]=ks(i.values()));return e}get serializedEvalContext(){let e={};for(let[t,i]of Object.entries(this.evalContext))e[t]=i.toString();return e}substituteAssignments(e){let t=Md(e);return t.variable?new jt("=",[new Ys(t.variable),t.expression.recursiveSubstitute(this.evalContext)]):e.recursiveSubstitute(this.evalContext)}markUpdated(e){this.updatedNames.add(e);for(let t of this.findDependants(e))this.updatedNames.add(t)}flushChanges(){for(let[t,i]of this.callbackDeps.entries())i.some(n=>this.updatedNames.has(n))&&t();let e=Array.from(this.updatedNames);return this.updatedNames.clear(),e}updateSource(e,t,i,n=!0){this.removeSource(e,!1),this.assignments.has(t)||this.assignments.set(t,new Map),this.assignments.get(t).set(e,i),this.markUpdated(t),n&&this.flushChanges()}attemptUpdateSource(e,t,i=!0){if(typeof t=="string")try{t=Et.parse(t).collapse()}catch(r){return}let n=Md(t);return n.variable?this.updateSource(e,n.variable,n.expression,i):this.removeSource(e),n.expression}removeSource(e,t=!0){for(let[i,n]of this.assignments.entries())n.has(e)&&this.markUpdated(i),n.delete(e),n.size===0&&this.assignments.delete(i);t&&this.flushChanges()}watch(e,t,i=!1){this.callbackDeps.set(t,e),i&&t()}unwatch(e){e&&this.callbackDeps.delete(e)}};var pe="/polypad/assets/audio",Cd={roll:new ee(`${pe}/roll.mp3`,.6,!1),spin:new ee(`${pe}/spin.mp3`,.5,!1),coinToss:new ee(`${pe}/coin-toss.mp3`,.3,!1),shuffle:new ee(`${pe}/shuffle.mp3`,.3,!1),rng:new ee(`${pe}/rng-roll.mp3`,.3,!1),draw:new ee(`${pe}/card-draw.mp3`,.2,!1),click:new ee(`${pe}/click.mp3`,.3,!1),woosh:new ee(`${pe}/woosh.mp3`,.2,!1),rise:new ee(`${pe}/rise.mp3`,.3,!1),fall:new ee(`${pe}/fall.mp3`,.3,!1),splitCoins:new ee(`${pe}/split-coins.mp3`,.175,!1),mergeCoins:new ee(`${pe}/merge-coins.mp3`,.3,!1)};var Ie=25,yh=Ie*Math.sqrt(3)/2,U0=Math.sqrt(2*Ie**2)/2;function ui(s,e,t){let i,n,r;t:for(let o of t)for(let a of e){let h=o.posn||o.path.project(a),l=h.subtract(a),c=l.length;if(c{let[y,f,v,w,$]=xh(s,d);n+=g*w,y&&(i[y]||(i[y]=[0,0,0]),i[y][0]+=g*f,i[y][1]+=g*v,i[y][2]=$)};for(let d of e)r(d,1);for(let d of t)r(d,-1);if(x(n,0))return;let o=Object.keys(i).filter(d=>i[d][0]||i[d][1]),a=o.find(d=>!s.tileWeights.has(d))||O(o);if(!a)return!0;let[h,l,c]=i[a],u=x(l,0)?c-n/h:Math.max(...Go(l,h,n-h*c-l*c*c));s.tileWeights.set(a,u),s.options.tileWeights=Array.from(s.tileWeights.entries()).map(d=>d.join("=")).join(",")}function $h(s,e){s.tileWeights.clear();for(let t of e.split(",")){let[i,n]=t.split("=");i&&s.tileWeights.set(i,+n||0)}}var Ad="M0,26A18.1,18.1,0,0,0-18,44V72H18V44A18.1,18.1,0,0,0,0,26Z",K0=new Set(["text","number-line","spinner","decimal-grid","axes","custom-spinner","ruler","protractor","compass","geo","dot-machine","abacus","balance","chess-board","multi-jump","set-triangle","bucket","table","number-grid","ten-frame","chart","pie-chart","box-whisker","clock","polyhedron","rectangle","question-blank","logic-switch","logic-gate","logic-speaker","chess-piece"]),Zi=15,Lt=40,kd=180;function ao(s){let e=s/2;return`M${e},0C${e},16,66.3,20,0,20S${-e},16${-e},0Z`}var fi=class extends H{constructor(t,i,n){super(t,i,n);this.cannotRotateType=!0;this.isAnimating=!1;this.$beam=m("path",{class:"balance-beam"},this.$el),this.$left=m("path",{class:"balance"},this.$el),this.$right=m("path",{class:"balance"},this.$el),this.$base=m("path",{d:Ad,class:"balance"},this.$el),this.dropzones=this.targetAreas().map(r=>this.$parent.dropzoneManager.createDropzone(this,{path:r,ignored:K0})),this.$handle=this.makeHandle("c",r=>{this.props.size=B($t(r.x-Lt,20),120,800),this.resize(),this.draw(),this.transform()}),this.$handle.css("cursor","ew-resize"),this.props.watch("color",({color:r})=>{this.$beam.css("stroke",r);for(let o of[this.$base,this.$left,this.$right])o.css("fill",r)}),this.customTransform(),this.resize(),this.draw()}onDropzonesChange(){this.rebalance(400)}applyChange(t){super.applyChange(t),"level"in t&&this.draw()}targetAreas(){let t=new G(new p(0,-kd),this.props.size,kd),i=t.shift(-this.props.size-Lt,this.props.level*Zi),n=t.shift(Lt,-this.props.level*Zi);return[i,n]}resize(){this.$left.setAttr("d",ao(this.props.size)),this.$right.setAttr("d",ao(this.props.size)),this.customTransform()}draw(t=this.props.level){let i=this.props.size/2+Lt,n=new p(-i,t*15),r=new p(i,-t*15);this.$beam.draw(new te(n.shift(0,10),n.shift(0,44),r.shift(0,44),r.shift(0,10))),this.$left.setTransform(n),this.$right.setTransform(r),this.$handle.setCenter({x:this.props.size+Lt,y:-t*15});let[o,a]=this.targetAreas();this.dropzones[0].updateTarget(o),this.dropzones[1].updateTarget(a)}rebalance(t=400){return D(this,null,function*(){let[i,n]=this.dropzones.map(d=>d.containedTiles),r=N(Array.from(Ae(i),d=>xh(this.$parent,d)[3])),o=N(Array.from(Ae(n),d=>xh(this.$parent,d)[3])),a=x(r,o)?0:r({tile:d,posn:d.posn.shift(0,l)})),u=Array.from(n,d=>({tile:d,posn:d.posn.shift(0,-l)}));yield H.animate([...c,...u],t,d=>{this.draw(ht(h,a,d)),this.$parent.selection.update()}),this.isAnimating=!1,this.transform(),this.$parent.selection.update()})}customTransform(){let t=this.props.level*Zi,i=this.props.size+Lt;this.path=new V(new p(-i,t),new p(-Lt,t),new p(-Lt,25),new p(Lt,25),new p(Lt,-t),new p(i,-t),new p(i,-t+48),new p(Lt,-t+48),new p(Lt,72),new p(-Lt,72),new p(-Lt,t+48),new p(-i,t+48))}getSnapPoints(){let t=this.props.level*Zi,i=this.props.size+Lt;return[new p(-i,t),new p(-Lt,t),new p(Lt,-t),new p(i,-t)]}getSnapLines(){let[t,i,n,r]=this.getSnapPoints();return[new Y(t,i),new Y(n,r)]}balance(){let[t,i]=this.dropzones.map(r=>r.containedTiles);if(W0(this.$parent,t,i))return wr("balance-error");for(let r of this.$parent.getTilesOfType("balance"))r.rebalance()}static makeThumbnail(t){let i=m("svg",{width:250,height:50,viewBox:"-290 -10 580 82",class:"scale"},t);m("path",{d:"M-160 10v34h320v-34",fill:"transparent",stroke:"#bbb","stroke-width":10},i),m("path",{d:ao(240),transform:"translate(-160 0)",fill:"#bbb"},i),m("path",{d:ao(240),transform:"translate(160 0)",fill:"#bbb"},i),m("path",{d:Ad,fill:"#bbb"},i)}static altText(){return"Balance Scale"}};fi.type="balance",fi.defaultProps={level:0,size:240,color:"#bbb"},fi=T([Ut],fi);Mt([{id:"balance",type:"button",tileTypes:["balance"],label:"Balance",show:s=>s.length===1&&!!s[0].props.level,click:s=>{s[0].balance()}}]);function Vd(s){return[...s].sort((e,t)=>e.props.zIndex-t.props.zIndex)}function Id(s,e,t){let i=Io(s,e,t);i>=0&&s.splice(i,1)}function X0(s,e){if(!s.length)return s.push({item:e,val:e.props.zIndex});let t=Vo(s,e.props.zIndex,ko.firstGreater);s.splice(t<0?s.length:t,0,{item:e,val:e.props.zIndex})}var ho=class{constructor(e){this.$parent=e;this.sorted={front:[],normal:[],back:[]};this.layers=new WeakMap}clear(){this.sorted={front:[],normal:[],back:[]},this.layers=new WeakMap}addOrUpdate(e){let t=this.layers.get(e);t&&Id(this.sorted[t.layer],e,t.z);let i=t&&t.layer!==e.props.layer,n=this.sorted[e.props.layer];(e.props.raw.zIndex===void 0||i)&&(e.props.raw.zIndex=n.length?O(n).val+1:0),this.layers.set(e,{layer:e.props.layer,z:e.props.zIndex}),X0(n,e)}remove(e){let t=this.sorted[e.props.layer];Id(t,e,e.props.zIndex),this.layers.delete(e)}bringToFront(e,t,i){for(let n of Vd(e)){if(n.noAutoLayering&&!t)continue;let r=O(this.sorted[n.props.layer]);r.item!==n&&(n.props.zIndex=r?r.val+1:0,i&&this.$parent.pendingChanges.add(n))}}bringToBack(e,t){for(let i of Vd(e)){if(i.noAutoLayering&&!t)continue;let n=this.sorted[i.props.layer][0];if(n.item===i)return;i.props.zIndex=n?n.val-1:0}}getTileAbove(e){let t=this.sorted[e.props.layer],i=Io(t,e,e.props.zIndex);for(let n=i+1;n

This colour is adjusted in dark mode.

Customise the Polypad features and UI, or use advanced tile properties and authoring tools. Learn more

\u2022 \u2022 Learn more

Polypad UI and features

Tile actions and properties

Display and audio options

`;function Ph(s=!0){let e=s?"":"hidden";return{mergeTiles:s,sidebar:e,toolbar:e,actionbar:e,settings:e,noCopyPaste:!s,noUndoRedo:!s,noPinchPan:!s,noDeleting:!s,noAudio:!s,noMusic:!s,noRotating:!s,noSnapping:!s,altColors:!1}}var lo=class extends E{bindPolypad(e){var u;this.bindModel(e.options);let t=this.$('input[type="color"]');t.change(d=>e.options.background=d),t.on("blur",()=>e.flushChanges());let i=this.$(".bg-warn"),n=()=>{let d=e.options.background||"#ffffff";t.value=d,t.next.css("background",d),i==null||i.toggle(b.theme.isDark&&e.flipTheme)};e.options.watch(n),b.onThemeChange(n),this.$("select").on("change",()=>{let d=e.options.canvas;e.options.canvasX=d==="infinite"?void 0:750,e.options.canvasY=d==="fixed"?750:void 0,e.resetViewport(),e.flushChanges()});for(let[d,g]of this.$$(".size").entries()){let y=d===1?"canvasY":"canvasX";g.onKey("Enter",()=>g.blur()),g.change(f=>{f&&(e.options[y]=(Math.round(+f)||15)*50,e.resetViewport())}),g.on("blur",()=>e.flushChanges()),e.options.watch(f=>g.value=`${(f[y]||0)/50}`)}for(let d of this.$$("input.toggle"))d.on("change",()=>e.selection.update());let o=this.$(".sidebar");e.options.watch(d=>o.checked=d.sidebar!=="hidden"),o.on("click",()=>e.options.sidebar=o.checked?"":"hidden");let a=this.$$(".setting");e.options.watch(({settings:d})=>{let g=(d==null?void 0:d.split(","))||[];for(let y of a)y.checked=!d||g.includes(y.data.key)});for(let d of a)d.on("change",()=>{e.options.settings=a.every(g=>g.checked)?void 0:a.filter(g=>g.checked).map(g=>g.data.key).join(",")||"other"});for(let d of this.$$(".advanced input, .authoring, .advanced select"))d.on("change",()=>setTimeout(()=>e.flushChanges()));Th||(u=this.$(".handdrawn"))==null||u.parent.remove(),this.$(".authoring").bindVariable(e.state,"authorMode");let l=this.$$(".caption, .advanced");e.state.watch(d=>l.map((g,y)=>g.toggle(d.authorMode?!!y:!y)));let c=this.$$(".preset");for(let[d,g]of c.entries())g.on("click",()=>e.options.assign(Ph(!d)))}};lo=T([S("pp-customise",{template:Ld})],lo);var Od=12,Rd=s=>s.path.rotate(J(s.rot),s.is("group")?s.path.center:void 0),co=class{constructor(e,t){this.tile=e;this.options=t;this.containedTiles=new Set;this.$path=m("path",{class:"dropzone",path:t.path,hidden:!0},e.$el)}canInsert(e){var n,r,o,a;let t=(r=(n=this.options.allowed)==null?void 0:n.has(e.props.name))!=null?r:!0,i=(a=(o=this.options.ignored)==null?void 0:o.has(e.props.name))!=null?a:!1;return t&&!i}hasReachedTileLimit(){return this.options.maxTiles?this.containedTiles.size>=this.options.maxTiles:!1}overlaps(e){if(!e.path)return!1;let t=Rd(e).translate(e.posn.subtract(this.tile.posn)).rotate(-J(this.tile.rot));return Bi(this.options.path,t)}addTile(e){this.containedTiles.add(e),e.inDropZone=this}delete(){for(let e of this.containedTiles)e.inDropZone=void 0;this.containedTiles.clear(),this.$path.remove()}updateTarget(e,t){var n;this.options.path=e;let i=-((n=this.options.boxOffset)!=null?n:0);this.$path.draw(e.padding(i,i,i,i)),this.reflowLayout(t)}reflowLayout(e){if(!this.containedTiles.size||!this.options.layout||this.options.layout==="none")return;let t=this.getSortedTiles(),i=this.options.layout==="flow"?this.flowLayout(t):this.centerLayout(t),n=e?0:240;H.animate(i,n,()=>this.tile.$parent.selection.update())}getSortedTiles(){return Array.from(this.containedTiles).sort((e,t)=>Math.abs(e.posn.y-t.posn.y)<25?e.posn.x-t.posn.x:e.posn.y-t.posn.y)}flowLayout(e){var l;let t=Math.min(this.options.path.h,this.options.path.w),i=B(0,(t-50)/2,(l=this.options.padding)!=null?l:Od),n=i,r=i,o=0,a=0,h=this.tile.posn.add(this.options.path.p);return e.map(c=>{let u=It(c.transformed);n+u.w+i>this.options.path.w+.001&&(r+=o+i,r>this.options.path.h-25+.001&&(a++,r=i+5*a),n=i+5*a,o=0);let d=h.add(c.posn).subtract(u.p).shift(n,r);return n+=u.w+i,o=Math.max(o,u.h),{tile:c,posn:d}})}centerLayout(e){var v;let t=e.map(w=>It(Rd(w))),i=Math.ceil(Math.sqrt(e.length)),n=Math.ceil(e.length/i),r=z(w=>re(w*i,Math.min((w+1)*i,e.length)-1),n),o=z(w=>N(r[w].map($=>t[$].w)),n),a=Math.max(...o),h=z(w=>Math.max(...r[w].map($=>t[$].h)),n),l=N(h),c=(v=this.options.padding)!=null?v:Od,u=o.map(w=>i>1?Math.min((this.options.path.w-w)/(i-1),c):0),d=n>1?Math.min((this.options.path.h-l)/(n-1),c):0,g=this.tile.posn.add(this.options.path.center).shift(-(a+(i-1)*Math.min(...u))/2,-(l+(n-1)*d)/2),y=0,f=0;return e.map((w,$)=>{let L=$%i,k=Math.floor($/i),M=g.shift(y,f).subtract(t[$].p);return(L+1)%i?y+=t[$].w+u[k]:(y=0,f+=h[k]+d),{tile:w,posn:M}})}};var Dd=s=>s.props.status!=="locked"&&s.props.status!=="hidden",po=class{constructor(e){this.polypad=e;this.dropzones=new Map;this.lockedTiles=new Set;this.tilesMoved=!1}createDropzone(e,t){this.dropzones.has(e)||this.dropzones.set(e,new Set);let i=new co(e,t);return this.dropzones.get(e).add(i),i}deleteDropzone(e){var t;e.delete(),(t=this.dropzones.get(e.tile))==null||t.delete(e)}clear(){for(let e of this.dropzones.values())for(let t of e)t.delete();this.dropzones.clear()}lockToZone(e,t){var i;(i=e.inDropZone)==null||i.containedTiles.delete(e),t.containedTiles.add(e),this.lockedTiles.add(e)}update(e){if(!this.dropzones.size)return;if(!e||Bt(e,n=>this.dropzones.has(n))){let n=zh(e||[],r=>r.isDeleting);e=sn(this.polypad.tiles.values(),n)}let t=new Set,i=!1;t:for(let n of gp(e)){if(n.isDeleting&&(i=!0),n.isDeleting&&this.dropzones.has(n)){for(let r of this.dropzones.get(n))r.delete();this.dropzones.delete(n);continue}if(n.inDropZone){if(t.add(n.inDropZone.tile),!n.isDeleting&&this.lockedTiles.has(n))continue;n.inDropZone.containedTiles.delete(n),n.inDropZone=void 0}if(Dd(n)&&!(this.dropzones.has(n)||n.isDeleting)){for(let r of this.dropzones.values())for(let o of r)if(o.overlaps(n)){if(!o.canInsert(n)){o.options.ejectInvalid&&this.ejectFromZone(n,o);continue}if(o.hasReachedTileLimit()&&o.containedTiles.size){let a=O([...o.containedTiles]);this.ejectFromZone(a,o)}o.addTile(n),t.add(o.tile);continue t}}}for(let n of t){if(this.tilesMoved||i)for(let r of this.dropzones.get(n)||[])r.reflowLayout();n.isDeleting||n.onDropzonesChange()}this.polypad.trigger("dropzone-change",{tiles:t}),this.lockedTiles.clear(),this.tilesMoved=!1}ejectFromZone(e,t,i=20){let n=It(e.transformed),r=t.tile.posn.add(t.options.path.p),o=[{y:r.y-n.p.y-n.h-i},{x:r.x+t.options.path.w-n.p.x+i},{y:r.y+t.options.path.h-n.p.y+i},{x:r.x-n.p.x-n.w-i}];for(let[a,h]of o.entries()){let l=e.posn.shift(h.x||0,h.y||0);if(!(a<3&&this.polypad.getTileAt(l,["categorizer"])))return t.containedTiles.delete(e),e.inDropZone=void 0,H.animate([{tile:e,posn:l}],200,()=>e.$parent.selection.update())}}onMoveStart(e){if(!this.dropzones.size)return;let t=new Set;for(let i of e)for(let n of this.dropzones.get(i)||[])if(n.$path.show(),n.options.sticky)for(let r of n.containedTiles)t.add(r);this.polypad.selection.select(t)}onMove(e){if(!this.dropzones.size)return;let t=new Set;for(let[i,n]of this.dropzones.entries())if(!i.isActive)for(let r of n)r.$path.toggle(Bt(e,o=>{if(!Dd(o))return;let a=!t.has(o)&&(r.containedTiles.has(o)||r.canInsert(o))&&r.overlaps(o);return a&&t.add(o),a}))}onMoveEnd(){if(this.dropzones.size){this.tilesMoved=!0;for(let e of this.dropzones.values())for(let t of e)t.$path.hide()}}};var uo=4,fo=s=>`${s.xMin} ${s.yMin} ${s.dx} ${s.dy}`,Nd=s=>!!s.name,Th=b.isChrome&&!b.isMobile,mo=class extends E{constructor(){super(...arguments);this.tiles=new Map;this.strokes=new Map;this.options=he({});this.state=he({tool:"move",changeCount:0,penColor:"#242436",audioPlaying:0});this.mathContext=new ro;this.snapping=new oo(this);this.zIndex=new ho(this);this.dropzoneManager=new po(this);this.geoData=new qr;this.tools={move:new Qr(this),pen:new so(this),geo:new Yi(this),geoPending:new io(this),eraser:new Jr(this),text:new to(this),pan:new eo(this),cutPolygon:new no(this)};this.origin=R;this.zoom=1;this.margins=[40,40,40,40];this.initial={};this.newTileShift=0;this.tileWeights=new Map;this.setup=!1;this.undoStack=[];this.redoStack=[];this.pendingChanges=new Set;this.pendingStrokes=new Set}ready(){this.$svg=this.$("svg.canvas"),this.$tiles=this.$svg.$$(".tiles"),this.$selection=this.$svg.$(".selection"),this.$strokes=this.$svg.$(".strokes"),this.$grid=this.$svg.$(".grid"),this.$html=this.$(".html-overlay"),this.$mask=this.$(".mask"),this.$geoShadows=this.$svg.$(".geo-shadows"),this.$geoPaths=this.$svg.$(".geo-paths"),this.$geoPoints=this.$svg.$(".geo-points"),this.$pendingPoint=m("circle",{class:"geo-point pending",hidden:!0},this.$geoPoints),this.setAttr("data-tool","move"),this.events=new ti(this.$svg,{down:i=>this.tools[this.state.tool].down(i),up:i=>this.tools[this.state.tool].up(i),start:i=>this.tools[this.state.tool].start(i),move:i=>this.tools[this.state.tool].move(i),end:i=>this.tools[this.state.tool].end(i),click:i=>this.tools[this.state.tool].click(i),hover:i=>this.tools[this.state.tool].hover(i),cursor:!1}),this.selection=new jr(this),this.warningBanner=new fr(this),this.setViewport(R,1),this.options.watch(i=>{this.$grid.setAttr("fill",i.grid&&i.grid!=="none"?`url(#${i.grid})`:"none"),this.$grid.setRect(this.viewportBounds.rect)}),this.$svg.on("contextmenu",i=>{this.focussedTile||i.preventDefault()}),this.enablePinchPan(),this.enableAccessibility(),b.onThemeChange(()=>{this.setBackground(this.options.background);for(let i of this.tiles.values())i.props.updateTheme();for(let i of this.strokes.values())i.setColor(i.color);this.updateCursor()}),this.options.watch(i=>this.setBackground(i.background)),this.options.watch(i=>this.setClass("high-contrast",!!i.highContrast)),Th&&this.options.watch(i=>this.setClass("handdrawn",!!i.handdrawn)),this.state.watch(()=>this.updateCursor());let t=this.$(".bg-icon");this.state.watch(i=>{t.toggle(i.authorMode),this.setClass("author-mode",!!i.authorMode),this.selection.clear()}),this.options.watch(()=>{let{canvas:i,canvasX:n=750,canvasY:r=750}=this.options,o=2e4;this.$mask.toggle(i!=="infinite"),i==="notebook"?this.$mask.setAttr("d",`M-1 -1h${n+2}V${o}H${o}V${-o}H${-o}V${o}H-1z`):i==="fixed"&&this.$mask.setAttr("d",`M-1 -1h${n+2}v${r+2}h${-n-2}zM${-o}${-o}V${o}H${o}V${-o}z`),this.canvasBounds=i==="infinite"?void 0:new lt(0,n,0,i==="notebook"?1e10:r)})}playSound(t){this.options.noAudio||Cd[t].play()}setBackground(t="#fff"){let i=xt.fromHex(t).hsl[2],n=t;this.flipTheme=i>=70,b.theme.isDark&&this.flipTheme&&(n=i>99?"#22212e":Be(t),i=100-i);let r=i<50?"#e2e1e6":"#181824";this.parent.css("--canvas-bg",n),this.parent.css("--canvas-fg",r),this.parent.css("--grid-opacity",.5-Math.abs(i/50-1)/4),this.parent.setClass("dark",i<50),this.$mask.css("fill",xt.mix("#000",n,.25).hex);let o=this.margins.some(a=>a>0);this.$mask.css("stroke",o?xt.mix(r,n,.4).hex:"transparent")}updateCursor(){let{tool:t,toolOptions:i,penColor:n}=this.state;if(t!=="pen"&&t!=="eraser")return this.css("cursor","");let r=t==="eraser"?10:i==="highlighter"?12:5,o=t==="eraser"?"#fff":Be(n||"#000",this.flipTheme);this.css("cursor",`url('data:image/svg+xml;utf8,') ${r+1} ${r+1}, auto`.replaceAll("#","%23"))}getTileAt(t,i){for(let n of this.tiles.values())if(!(i&&!i.includes(n.props.name))&&n.contains(t))return n}getInputAt(t,i){for(let n of this.tiles.values()){let r=n.getClosestPort(t,i);if(r)return r}}*getTilesOfType(t){for(let i of this.tiles.values())i.is(t)&&(yield i)}getBounds(t=0){let{canvas:i,canvasX:n,canvasY:r}=this.options;if(i==="infinite")return this.contentBounds.extend(t);let o=i==="notebook"?this.contentBounds.yMax+t:r;return new lt(0,n!=null?n:0,0,o!=null?o:0)}option(t){return this.state.authorMode?!1:!!this.options[t]}hasAction(t){let i=this.options.actionbar;return i?i.split(",").includes(t):!0}enablePinchPan(){this.on("wheel",n=>{if(!this.options.noPinchPan)if(n.preventDefault(),n.ctrlKey){let r=this.zoom*(1-n.deltaY/100);this.setViewport(this.origin,r,fe(n,this.$svg))}else{let r=this.origin.shift(n.deltaX/this.zoom,n.deltaY/this.zoom);this.setViewport(r,this.zoom)}});let t=0,i=this.origin;this.on("gesturestart",n=>{this.options.noPinchPan||(n.preventDefault(),i=new p(n.pageX,n.pageY).subtract(this.origin),t=this.zoom,this.events.cancel())}),this.on("gesturechange",n=>{if(this.options.noPinchPan)return;n.preventDefault();let r=t*n.scale,o=new p(n.pageX,n.pageY).subtract(i);this.setViewport(o,r,fe(n,this.$svg))}),this.on("gestureend",n=>{this.options.noPinchPan||n.preventDefault()})}enableImageDrop(t,i){let n=m("div",{class:"image-drop"},this);this.imageUploadCallback=t,this.on("dragenter dragover dragleave drop",o=>o.preventDefault()),this.on("dragenter dragover",()=>n.show()),this.on("dragleave drop",()=>n.hide());let r=(o,a)=>D(this,null,function*(){let l=Array.from((o==null?void 0:o.files)||[]).slice(0,10).map((c,u)=>this.newImage(c,a.shift(u*25),t));yield Promise.all(l),this.flushChanges(),this.trigger("paste")});this.on("drop",o=>r(o.dataTransfer,fe(o,this.$svg))),i==null||i.on("change",()=>D(this,null,function*(){yield r(i._el,this.viewportBounds.center),i.value=""}))}bindKeyboardEvents(t=C,i){this.selection.bindKeyboardEvents(t),t.onKey("Backspace Clear Delete",()=>this.selection.delete()),t.onKey("z",n=>{n.preventDefault(),this[n.shiftKey?"redo":"undo"]()},{meta:!0}),t.onKey("y",n=>{n.preventDefault(),this.redo()},{meta:!0}),t.onKey("c",()=>{if(this.option("noCopyPaste"))return;let n=this.selection.copy();this.paste(n,new p(25,25)),this.flushChanges()}),t.onKey("a",n=>{var o;if((o=A("x-modal"))!=null&&o.getOpenModal())return;n.preventDefault();let r=Array.from(this.tiles.values());this.state.authorMode||(r=r.filter(a=>a.canSelect)),this.selection.select(r)},{meta:!0}),C.on("cut copy",n=>{var o;if(i!=null&&i()||!this.selection.tiles.size||this.option("noCopyPaste")||b.formIsActive)return;let r=this.selection.copy();(o=window.navigator.clipboard)==null||o.writeText(JSON.stringify(r)),n.type==="cut"&&this.selection.delete()}),C.on("paste",n=>D(this,null,function*(){var a;if(i!=null&&i()||this.option("noCopyPaste")||b.formIsActive)return;let r=dp(n.clipboardData);if(r&&this.imageUploadCallback)return yield this.newImage(r,this.center.shift(-50),this.imageUploadCallback),this.flushChanges(),this.trigger("paste");let o=yield(a=window.navigator.clipboard)==null?void 0:a.readText();if(o){try{let h=JSON.parse(o);if(!Object.keys(h).length)return;this.paste(h)}catch(h){let l=H.create(this,{name:"text",html:o});l.setTransform(this.viewportBounds.center.subtract(l.center)),this.selection.add(l,!0),this.flushChanges(),this.trigger("paste"),this.selection.select([l])}this.flushChanges()}})),t.onKey("Space",n=>{this.options.noPinchPan||this.state.tool==="pan"||(n.preventDefault(),this.tools.pan.enable())}),t.onKey("Space",n=>{this.options.noPinchPan||this.state.tool!=="pan"||(n.preventDefault(),this.tools.pan.disable())},{up:!0})}enableAccessibility(){let t,i=!1,n=r=>{this.focussedTile||(t=r,this.$svg.setAttr("aria-description",r?r.altText:"Empty Canvas"),r&&this.selection.add(r,!0))};this.$svg.on("focusin",()=>{if(!i)return;let r=Array.from(this.tiles.values()).filter(o=>!o.props.status);n(this.events.shiftKey?O(r):r[0])}),this.$svg.on("focusout",()=>t=void 0),C.on("keydown",r=>{if(i=!0,r.keyCode!==9||!t)return;let o=Array.from(this.tiles.values()).filter(a=>!a.group&&!a.props.status);n(o[o.indexOf(t)+(r.shiftKey?-1:1)]),t&&r.preventDefault()}),C.on("pointerdown",()=>i=!1),this.$svg.on("pointerdown",()=>{i=!1,this.focussedTile||this.$svg.focus()})}newImage(t,i,n){return D(this,null,function*(){let r=new FileReader;r.readAsDataURL(t),yield new Promise(a=>r.onloadend=a);let o=H.create(this,{name:"image",href:(r.result||"").toString(),x:i.x,y:i.y});return this.selection.add(o,!0),yield n==null?void 0:n(t,o),o})}setViewport(t,i=1,n){var v;if(i=B(i,1/uo,uo),n){let w=this.zoom/i;t=n.subtract(n.subtract(this.origin).scale(w))}let r=this.width/i,o=this.height/i,{canvas:a,canvasX:h=0,canvasY:l=0,grid:c}=this.options,[u,d,g,y]=this.margins;if(a==="infinite")this.origin=t.clamp(this.contentBounds.extend(o,0,0,r),50/i);else{let w=a==="notebook"?this.contentBounds.yMax+o-u/i:l,$=new lt(-y/i,h-r+d/i,-u/i,w-o+g/i,"center");this.origin=t.clamp($)}this.zoom=i,this.viewportBounds=new lt(this.origin.x,this.origin.x+r,this.origin.y,this.origin.y+o),this.$svg.setAttr("viewBox",this.attr("viewBox")||fo(this.viewportBounds)),this.$html.setTransform(this.origin.inverse.scale(this.zoom),0,this.zoom);let f=this.viewportBounds.rect;c!=="none"&&this.$grid.setRect(f),this.geoData.redrawLines(((v=this.canvasBounds)==null?void 0:v.rect)||f),this.newTileShift=0,this.trigger("viewport")}resetViewport(){let t=this.options.canvas;if(t==="infinite"&&!this.tiles.size&&!this.strokes.size)return this.setViewport(R,1);let i=this.getBounds(),{width:n,height:r,margins:o}=this,[a,h,l,c]=o,u=(n-c-h)/i.dx,d=t==="notebook"?1:(r-a-l)/i.dy,g=B(Math.min(u,d),1/uo,t==="infinite"?1:uo);if(t==="notebook")return this.setViewport(new p(0,-a),g);let y=new p(n+c-h,r+a-l),f=i.center.subtract(y.scale(1/2/g));this.setViewport(f,g)}setZoom(t){let i=this.viewportBounds.center;this.setViewport(this.origin,this.zoom*t,i)}bindSource(t,i){let n=t.attr("tile");t.setAttr("tabindex",0),H.thumbnail(this,n,t);let r,o=i==null?void 0:i.$(".tiles");this.events.listen(t,{down:()=>this.trigger("add-tile-start"),start:({posn:a})=>{r=H.create(this,Object.assign({name:n},ve(t.attr("props"),{}))),r.setTransform(a.subtract(r.center)),this.selection.add(r,!0),this.selection.moveStart(!0),i&&i.setAttr("viewBox",fo(this.viewportBounds)),(o||r.$container).append(r.$el),this.trigger("add-tile",{tile:r})},move:a=>this.selection.move(a,!0),end:a=>{r.$container.append(r.$el),this.selection.moveEnd(a,!0)},click:()=>{r=H.create(this,Object.assign({name:n},ve(t.attr("props"),{}))),r.setTransform(this.center.subtract(r.center).shift(this.newTileShift*25)),this.selection.add(r,!0),r.moveEnd(),this.trigger("add-tile",{tile:r}),this.flushChanges(),this.newTileShift+=1}})}get center(){let[t,i,n,r]=this.margins;return this.viewportBounds.center.shift((r-i)/this.zoom/2,(t-n)/this.zoom/2)}setActiveTool(t,i){this.tools[this.state.tool].cancel(),this.warningBanner.hide(),this.selection.clear(),this.state.assign({tool:t,toolOptions:i}),i&&(this.tools[this.state.tool].options=i),this.setAttr("data-tool",t)}clear(t=!0){this.selection.clear();for(let i of this.tiles.values())i.delete();for(let i of this.strokes.values())i.delete();t&&this.setViewport(R,1),this.flushChanges()}thumbnail(t,i,n="jpg"){return D(this,null,function*(){return this.state.authorMode&&(this.state.authorMode=!1),yield this.$svg.image(n,t,i,fo(this.getBounds(50)))})}downloadImage(t="png",i){var o;this.selection.clear();let n=i||((o=this.state.title)==null?void 0:o.replace(/\s+/g,"-").replace(/[^\w-]/g,"").toLowerCase())||"polypad",r=this.getBounds(50);this.$svg.downloadImage(`${n}.${t}`,r.dx,r.dy,fo(r))}paste(t,i){this.selection.clear();let n=new Map;for(let h of Object.keys(t))n.set(h,We(10));let r=new Map,o=Object.entries(t).sort((h,l)=>(h[1].zIndex||0)-(l[1].zIndex||0)).map(([h,l])=>{var c,u,d;return l.name==="geo"&&Object.assign(l,Yt.copy(r,l,this.geoData)),l.name==="group"&&(l.children=(c=l.children)==null?void 0:c.split(",").map(g=>n.get(g)).join(",")),l.status=void 0,l.zIndex=void 0,l.cables=(u=l.cables)==null?void 0:u.map(g=>ut(dt({},g),{toTileId:n.get(g.toTileId)})),(l.name==="table"||l.name==="action-card")&&(l.links=(d=l.links)==null?void 0:d.split(",").map(g=>n.get(g)||g).join(",")),H.create(this,l,n.get(h))}).filter(Boolean);for(let h of o)h.delayedSetup();let a=It(...o.map(h=>h.transformed)).center;i===void 0&&(i=this.center.subtract(a).shift(this.newTileShift*25));for(let h of o)h.is("geo")?h.shift(i):h.setTransform(h.posn.add(i));this.newTileShift+=1,this.dropzoneManager.onMoveEnd(),this.flushChanges(),this.trigger("paste"),this.selection.select(o)}check(t){let i=!1;return new Promise(n=>{this.on("change",()=>{!i&&t(Array.from(this.tiles.values()))&&(i=!0,n())})})}flushChanges(){if(this.setup)return;this.trigger("change",{action:"change"});let t=new Map,i=this.options.getChanges();Object.keys(i[0]).length&&t.set("options",i),this.dropzoneManager.update(this.pendingChanges);for(let n of sn(this.pendingChanges,this.pendingStrokes)){let r=n.flushChanges();r&&t.set(n.id,r)}this.pendingChanges.clear(),this.pendingStrokes.clear(),t.size&&(this.contentBounds=mr(this.tiles,this.strokes),!this.options.noUndoRedo&&(this.undoStack.push(t),this.undoStack.length>50&&this.undoStack.shift(),this.redoStack=[],this.state.canUndo=!0,this.state.canRedo=!1,this.state.changeCount+=1))}undo(){this.undoStack.length&&(this.applyChange(O(this.undoStack),!0),this.redoStack.push(this.undoStack.pop()),this.state.canUndo=!!this.undoStack.length,this.state.canRedo=!0,this.state.changeCount-=1,this.selection.update(),this.trigger("change",{action:"undo"}))}redo(){this.redoStack.length&&(this.applyChange(O(this.redoStack)),this.undoStack.push(this.redoStack.pop()),this.state.canUndo=!0,this.state.canRedo=!!this.redoStack.length,this.state.changeCount+=1,this.selection.update(),this.trigger("change",{action:"redo"}))}applyChange(t,i=!1){var r,o;let n=new Set;for(let[a,[h,l]]of t.entries()){if(i&&([h,l]=[l,h]),a==="options")this.options.assign(l),("canvas"in l||"canvasX"in l||"canvasY"in l)&&this.resetViewport(),"tileWeights"in l&&$h(this,l.tileWeights||"");else if(h)if(l){let c=this.tiles.get(a);c==null||c.applyChange(l),c&&n.add(c)}else if(Nd(h)){let c=this.tiles.get(a);c==null||c.delete(),c&&n.add(c)}else(r=this.strokes.get(a))==null||r.delete();else if(Nd(l)){let c=H.create(this,l,a);c.flushChanges(),n.add(c)}else Fe.create(this,l,a);this.contentBounds=mr(this.tiles,this.strokes)}for(let a of t.keys())(o=this.tiles.get(a))==null||o.delayedSetup();this.dropzoneManager.update(n),this.pendingChanges.clear(),this.pendingStrokes.clear(),this.options.getChanges()}serialize(t=5e3,i=2e3,n=16e3){var r;return{title:(r=this.state.title)==null?void 0:r.slice(0,30),version:2,tiles:Ya(this.tiles.values(),o=>o.props.copy(),t),strokes:Ya(this.strokes.values(),o=>o.serialize(n),i),options:this.options.copy()}}load(t){this.setup=!0,this.clear(!1),this.geoData.reset(),this.zIndex.clear(),this.dropzoneManager.clear(),this.initial=t,this.state.assign({title:t.title,canUndo:!1,canRedo:!1,changeCount:0,audioPlaying:0,authorMode:!1}),this.undoStack=this.redoStack=[],t.options||(t.options=Ph(!0)),t.options.grid||(t.options.grid="none"),t.options.canvas||(t.options.canvas="infinite"),t.options.algebraXSize||(t.options.algebraXSize=Yp),t.options.algebraYSize||(t.options.algebraYSize=Zp),t.options.pinActions||(t.options.pinActions="custom"),this.options.assign(t.options,!0),this.options.forceUpdate(),$h(this,t.options.tileWeights||"");for(let[i,n]of Object.entries(t.tiles||{}))H.create(this,n,i).flushChanges();for(let[i,n]of Object.entries(t.strokes||{}))Fe.create(this,n,i);for(let i of this.tiles.values())i.delayedSetup();this.snapping.updateIntersections(),this.contentBounds=mr(this.tiles,this.strokes),this.dropzoneManager.update(),this.resetViewport(),this.setActiveTool("move"),this.pendingChanges.clear(),this.pendingStrokes.clear(),this.options.getChanges(),this.setup=!1}};mo=T([S("x-polypad",{template:Ed})],mo);var Gd=`
\${numberFormat(points)}
Points
\${min(time)}m \${time % 60}s
Time

Highscore
\${highscore[0].name.slice(0, 4)}\${numberFormat(highscore[0].score)}
\${highscore[1].name.slice(0, 4)}\${numberFormat(highscore[1].score)}
\${highscore[2].name.slice(0, 4)}\${numberFormat(highscore[2].score)}
\${highscore[3].name.slice(0, 4)}\${numberFormat(highscore[3].score)}
View more\u2026
Next blocks:
\${next[0]}
\${next[1]}
\${next[2]}
\${next[3]}
\${next[4]}

Discharge:
\${discardCounter}needed
Game over!
Paused
Highscore
\${highscore[0].name}\${numberFormat(highscore[0].score)}
\${highscore[1].name}\${numberFormat(highscore[1].score)}
\${highscore[2].name}\${numberFormat(highscore[2].score)}
\${highscore[3].name}\${numberFormat(highscore[3].score)}
\${highscore[4].name}\${numberFormat(highscore[4].score)}
\${highscore[5].name}\${numberFormat(highscore[5].score)}
\${highscore[6].name}\${numberFormat(highscore[6].score)}
\${highscore[7].name}\${numberFormat(highscore[7].score)}
\${highscore[8].name}\${numberFormat(highscore[8].score)}
\${highscore[9].name}\${numberFormat(highscore[9].score)}
\${highscore[10].name}\${numberFormat(highscore[10].score)}
Block size:
\${active[0] || '?' } = \${active[2]|| '?'} \xD7 \${active[1]|| '?'}
`;var Y0=1e3,Z=B(+Nl(location.search).size||16,8,24),Z0=5,mi=Math.ceil(Z/2),vo=Z+mi,wo=[];for(let s=2;s<=Z*1.5;s+=1){let e=zo(s);e&&s>.75*Z||s>Z&&Yh(s)[0]>Z/2||(e&&s>Z/2||s>1.25*Z?wo.push(s):wo.push(s,s))}var Qi=()=>wo[_t.integer(wo.length)],Q0=re(1,Z),J0=Z*10,zd=z(s=>J0*2**s,Z),Sh=class{constructor(e,t,i){this.$el=m("rect",{width:20,height:20},i),this.setPosition(e,t)}setPosition(e,t){this.x=e,this.y=t,this.$el.setTransform({x:10+20*this.x,y:10+20*this.y})}go(e,t,i){this.setPosition(this.x+i-t,this.y+e)}canSet(e,t,i){return!i.find(n=>n.x===e&&n.y===t)}canGo(e,t,i,n){let r=this.x+i-t,o=this.y+e;return o>=vo||r<0||r>=Z?!1:this.canSet(r,o,n)}canGoDown(e){return this.canGo(1,0,0,e)}goDown(e=1){if(e!==0)return this.go(e,0,0)}},go=class extends E{constructor(){super(...arguments);this.interval=void 0;this.tiles=[];this.activeTiles=[];this.activeSize=[0,0,0];this.activeFactors=[];this.isDown=!1;this.keyLock=!1;this.requestQueue=Promise.resolve("");this.highscore=!0}ready(){this.$svg=this.$(".factris-board"),this.$tiles=this.$svg.$(".tiles"),this.$shadow=this.$svg.$(".shadow"),this.attr("highscore")==="no"&&(this.highscore=!1);let t=this.$svg.$(".scores");this.$scores=zd.map((i,n)=>{let r=m("g",{},t);return m("text",{text:"+"+i,class:`s${n+1}`},r),r}),this.bindModel(he({time:0,points:0,playing:!1,lost:!1,initial:!0,key:void 0,discardCounter:0,next:[],active:[],highscore:[],showHighscore:!1,min:i=>Math.floor(i/60),numberFormat:Ot,app:this}));for(let i of this.$$("button, .play"))i.on("contextmenu",n=>n.preventDefault());C.onKey("AllArrows",(i,n)=>{this.model.playing&&(i.preventDefault(),this.isDown=!0,this.model.key=n,this.keyPress(n))}),C.onKey("AllArrows",()=>{this.model.playing&&(this.isDown=this.keyLock=!1,this.model.key=void 0)},{up:!0}),this.setupSVG(),this.updateHighscore()}setupSVG(){this.$svg.setAttr("viewBox",`0 0 ${(Z+1)*20} ${(vo+1)*20}`);let t=this.$svg.$(".grid"),i=t.$(".faint-grid");for(let n=0;n<=Z;n+=1){let r=10+n*20,o=10+(mi+n)*20,a=!(n%4)||n===Z?t:i,h=!(n%2)||n===Z?"thick":"";m("line",{x1:10,y1:o,x2:10+Z*20,y2:o,class:h},a),m("line",{x1:r,y1:10+mi*20,x2:r,y2:vo*20+10,class:h},a)}}drawShadow(){this.activeTiles.length&&(this.$shadow.setAttr("x",10+20*this.activeSize[0]),this.$shadow.setAttr("y",10+20*this.activeSize[1]),this.$shadow.setAttr("width",20*this.activeSize[2]),this.$shadow.setAttr("height",20*(vo-this.activeSize[1])))}newRect(){let t=this.getNewTileSize();this.activeFactors=Q0.filter(r=>t%r===0);let i=this.activeFactors.pop(),n=Math.floor((Z-i)/2);this.activeTiles=z(r=>new Sh(n+r%i,Math.floor(r/i),this.$tiles),t),this.model.active=[t,i,t/i],this.activeSize=[n,t/i,i],this.drawShadow(),this.isDown&&(this.keyLock=!0)}reset(){this.pause(),this.model.time=0,this.model.points=0,this.model.discardCounter=0,this.model.showHighscore=!1,this.model.lost=!1,this.model.next=[Qi(),Qi(),Qi(),Qi()];for(let t of this.tiles)t.$el.remove();for(let t of this.activeTiles)t.$el.remove();this.tiles=[],this.newRect(),this.play(),this.requestQueue=Promise.resolve("")}toggle(){this.model.lost?this.reset():this.model.playing?this.pause():this.play()}pause(){this.model.playing=!1,clearInterval(this.interval)}play(){var t,i;if(this.model.showHighscore=!1,(t=window.ga)==null||t.call(window,"send","event","Factris","play"),(i=window.gtag)==null||i.call(window,"event","factris",{action:"play"}),this.model.initial||this.model.lost)return this.model.initial=!1,this.reset();this.model.playing=!0,this.interval=window.setInterval(()=>this.tick(),Y0)}getNewTileSize(){let t=Z*Z-this.tiles.length;if(this.model.next[0]>t)return t>Z?t-Z:Z;this.model.discardCounter>0&&(this.model.discardCounter-=1);let i=this.model.next[0];return this.model.next=[...this.model.next.slice(1),Qi()],i}tick(){if(this.model.time+=1,this.activeTiles.every(o=>o.canGoDown(this.tiles))){for(let o of this.activeTiles)o.goDown();this.activeSize[1]+=1,this.drawShadow();return}this.tiles.push(...this.activeTiles);for(let o of this.activeTiles)o.$el.addClass("fixed");if(this.tiles.some(o=>o.y=6&&Ei(10,150*i.length/Z),this.removeRows(i);let n=this.model.points,r=(n+Z)%13+(n-Z)%87;this.requestQueue=this.requestQueue.then(o=>De("/factris-verify",{token:o,size:Z,score:n,check:r})),this.trigger("score",{points:n})}getFullRows(){return z(t=>this.tiles.filter(i=>i.y===t+mi),Z).filter(t=>t.length===Z)}removeRows(t){let i=we(t);this.tiles=this.tiles.filter(o=>!i.includes(o)),this.$tiles.addClass("animated"),b.redraw();for(let o of i)o.$el.addClass("removing");let n=t.map(o=>o[0].y);for(let o of this.tiles)o.goDown(n.filter(a=>a>o.y).length);let r=400/t.length;for(let[o,a]of n.reverse().entries())this.$scores[o].setTransform({x:10+mi*20,y:27+a*20}),Zt(()=>this.$scores[o].addClass("visible"),o*r);return setTimeout(()=>{for(let o of this.$scores)o.removeClass("visible")},600),setTimeout(()=>{for(let o of i)o.$el.remove();this.$tiles.removeClass("animated"),this.newRect()},1e3),!1}gameOver(){this.model.lost=!0;for(let t of this.activeTiles)t.$el.addClass("error");this.pause(),this.requestQueue.then(t=>{t&&this.trigger("game-over",{token:t,points:this.model.points})})}discharge(){if(this.model.playing){for(let t of this.activeTiles)t.$el.remove();this.newRect(),this.model.discardCounter=Z0}}keyPress(t,i=!0){if(this.model.playing&&!this.keyLock){if(t==="ArrowUp"){if(!this.activeFactors.length)return;let n=this.activeFactors.pop(),r=this.activeSize[0]+Math.floor((this.activeSize[2]-n)/2),o=this.activeSize[1];if(this.activeTiles.some((l,c)=>!l.canSet(r+c%n,o-1-Math.floor(c/n),this.tiles)))return;for(let[l,c]of this.activeTiles.entries())c.setPosition(r+l%n,o-1-Math.floor(l/n));let h=this.model.active[0];this.model.active=[h,n,h/n],this.activeSize=[r,o,n]}else{let n=t==="ArrowDown"?1:0,r=t==="ArrowLeft"?1:0,o=t==="ArrowRight"?1:0;if(this.activeTiles.every(a=>a.canGo(n,r,o,this.tiles))){for(let a of this.activeTiles)a.go(n,r,o);this.activeSize[0]+=o-r,this.activeSize[1]+=n}i&&t==="ArrowDown"&&setTimeout(()=>this.keyPress("ArrowDown",!1),100)}this.drawShadow()}}showHighscore(){this.highscore&&(this.pause(),this.model.showHighscore=!0)}updateHighscore(){return D(this,null,function*(){if(!this.highscore)return;let t=yield fetch(`/factris-highscore?size=${Z}`);this.model.highscore=yield t.json()})}};go=T([S("x-factris",{template:Gd})],go);var yo=class extends E{ready(){let e=Array.from(this._el.children);this.removeChildren();let t=m("svg",{class:"equation"},this),i=m("g",{transform:"translate(2 0)"},t),n=m("div",{class:"overlay"},this),r=parseFloat(this.css("font-size")),o=this.parents(".text-center").length||this.hasClass("display"),a=new ze(i,n,0,"",r,!!o);a.setValue(this.attr("expr")||e),this.css({width:a.root.width+4+"px",height:a.root.height+"px","vertical-align":`-${a.root.height-a.root.baseline}px`})}};yo=T([S("x-math")],yo);window.$=A;window.$$=Pe;window.Browser=b;var bo=A("x-modal#privacy");bo&&bo.$("form").on("submit",s=>{s.preventDefault();let e=bo.$('input[name="newsletter"]');De("/settings/privacy",{policies:"on",newsletter:e.checked?"on":"off"}),bo.close()});var Bd="";function Mh(){return fetch("/joke").then(s=>s.text()).then(s=>Bd=s),Bd}var Eh=A(".error-box");Eh&&Eh.on("click",()=>Eh.html=Mh());Mh();window.tellMeAJoke=function(){return Mh().replace(/

/g,"").replace(/<\/p>/g,` +"use strict";(()=>{var Ih=Object.defineProperty,Hd=Object.defineProperties,jd=Object.getOwnPropertyDescriptor,Ud=Object.getOwnPropertyDescriptors;var kh=Object.getOwnPropertySymbols;var Wd=Object.prototype.hasOwnProperty,Kd=Object.prototype.propertyIsEnumerable;var Eo=(s,e)=>(e=Symbol[s])?e:Symbol.for("Symbol."+s);var Vh=(s,e,t)=>e in s?Ih(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,ut=(s,e)=>{for(var t in e||(e={}))Wd.call(e,t)&&Vh(s,t,e[t]);if(kh)for(var t of kh(e))Kd.call(e,t)&&Vh(s,t,e[t]);return s},ft=(s,e)=>Hd(s,Ud(e));var T=(s,e,t,i)=>{for(var n=i>1?void 0:i?jd(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Ih(e,t,n),n};var D=(s,e,t)=>new Promise((i,n)=>{var r=h=>{try{a(t.next(h))}catch(l){n(l)}},o=h=>{try{a(t.throw(h))}catch(l){n(l)}},a=h=>h.done?i(h.value):Promise.resolve(h.value).then(r,o);a((t=t.apply(s,e)).next())}),Xd=function(s,e){this[0]=s,this[1]=e};var ks=s=>{var e=s[Eo("asyncIterator")],t=!1,i,n={};return e==null?(e=s[Eo("iterator")](),i=r=>n[r]=o=>e[r](o)):(e=e.call(s),i=r=>n[r]=o=>{if(t){if(t=!1,r==="throw")throw o;return o}return t=!0,{done:!1,value:new Xd(new Promise(a=>{var h=e[r](o);if(!(h instanceof Object))throw TypeError("Object expected");a(h)}),1)}}),n[Eo("iterator")]=()=>n,i("next"),"throw"in e?i("throw"):n.throw=r=>{throw r},"return"in e&&i("return"),n};var Mo=(s,e)=>(e=Symbol[s])?e:Symbol.for("Symbol."+s),Yd=function(s,e){this[0]=s,this[1]=e},Zd=s=>{var e=s[Mo("asyncIterator")],t=!1,i,n={};return e==null?(e=s[Mo("iterator")](),i=r=>n[r]=o=>e[r](o)):(e=e.call(s),i=r=>n[r]=o=>{if(t){if(t=!1,r==="throw")throw o;return o}return t=!0,{done:!1,value:new Yd(new Promise(a=>{var h=e[r](o);if(!(h instanceof Object))throw TypeError("Object expected");a(h)}),1)}}),n[Mo("iterator")]=()=>n,i("next"),"throw"in e?i("throw"):n.throw=r=>{throw r},"return"in e&&i("return"),n};function We(s=10){return Math.random().toString(36).substr(2,s)}function _(s,...e){return e.includes(s)}var Qd=(s,e)=>s.concat(e);function Ao(s,e,t=Qd){for(let i of Object.keys(e))i in s&&Array.isArray(s[i])&&Array.isArray(e[i])?s[i]=t(s[i],e[i]):i in s&&s[i]instanceof Object&&e[i]instanceof Object?Ao(s[i],e[i]):s[i]=e[i]}function Zt(s,e=0){return e?+setTimeout(s,e):(s(),0)}function wi(s){return new Promise(e=>setTimeout(e,s))}function Ke(){let s=()=>{},e=()=>{},t=new Promise((i,n)=>{s=i,e=n});return t.catch(i=>i),{promise:t,resolve:s,reject:e}}var Lh=class extends Error{constructor(s){super("[Cache Error]"),this.data=s}};function Oe(s){let e=new Map;return function(...t){let i=t.join("--");if(!e.has(i))try{e.set(i,s(...t))}catch(r){e.set(i,new Lh(r))}let n=e.get(i);if(n instanceof Lh)throw n.data;return n}}function ve(s,e=0,t=!1){let i=!1,n=!1;return(...r)=>{i?n=!0:(t?n=!0:s(...r),i=!0,setTimeout(()=>{n&&s(...r),i=n=!1},e))}}function Jd(s){return function(e,t){if(!e||Array.isArray(this)||s.includes(e))return t}}function we(s,e,t){if(!s)return e;try{return JSON.parse(s,t?Jd(t):void 0)||e}catch(i){return e}}function re(s,e){return new Array(e).fill(s)}function ko(s,e,t){let i=[];for(let n=0;n=0)for(let n=0;ns;n-=t)i.push(n);else if(s<=e)for(let n=s;n<=e;n+=t)i.push(n);else for(let n=s;n>=e;n-=t)i.push(n);return i}function O(s,e=0){return s[s.length-1-e]}function N(s){return s.reduce((e,t)=>e+t,0)}function yi(s,e,t=!1){return s.slice(0).sort((i,n)=>{let r=e(i),o=e(n);return ro?t?-1:1:0})}function os(s){let e=0;return()=>s[e++%s.length]}function Wt(s){return s.filter((e,t)=>s.indexOf(e)===t)}function ye(s){return s.reduce((e,t)=>e.concat(Array.isArray(t)?ye(t):t),[])}function as(s){let e=0;return s.map(t=>e+=t)}function Vo(s,e){let t=[];for(let i=0;ie.concat(t),[])}var Gh=class{constructor(s){let e=s.length,t=s.map(i=>({val:i}));for(let[i,n]of t.entries())n.next=t[(i+1)%e],n.prev=t[(i-1+e)%e];this.root=t[0]}*traverse(){let s=this.root;for(;s;)if(yield s,s=s.next,s===this.root)return}get array(){return Array.from(this.traverse())}delete(s){if(s===this.root){if(s.next===s)return this.root=void 0;this.root=s.next}s.prev.next=s.next,s.next.prev=s.prev}},Io=(s=>(s[s.first=0]="first",s[s.firstGreater=1]="firstGreater",s))(Io||{});function Lo(s,e,t){let i=0,n=s.length-1,r=-1;for(;i<=n;){let o=Math.floor((i+n)/2),a=s[o].val;ae?(t===1&&(r=o),n=o-1):t===0?(r=o,n=o-1):t===1&&(i=o+1)}return r}function Oo(s,e,t){let i=Lo(s,t,0);if(i<0)return-1;for(;s[i].val===t;){if(s[i].item===e)return i;i+=1}return-1}function K(s,e=/\s+/){return s?s.trim().split(e):[]}function nn(s){return s.toLowerCase().replace(/^-/,"").replace(/-(.)/g,(e,t)=>t.toUpperCase())}function tu(s,e,t=!1){let i=ko(0,s.length+1,e.length+1);for(let n=0;n<=s.length;n++)i[n][0]=n;for(let n=0;n<=e.length;n++)i[0][n]=n;for(let n=1;n<=s.length;n++)for(let r=1;r<=e.length;r++)i[n][r]=Math.min(i[n-1][r-1]+(s.charAt(n-1)===e.charAt(r-1)?0:1),i[n-1][r]+1,i[n][r-1]+1);return t?Math.min(...i[s.length]):i[s.length][e.length]}function zh(s,e){let t=s.length/2,i=e.map(r=>({w:r,d:tu(s,r)})).filter(({d:r})=>rr.d)[0];return n?n.w:void 0}var Re=class{constructor(){this.events=new Map}on(s,e){for(let t of K(s))this.events.has(t)||this.events.set(t,[]),this.events.get(t).push(e)}one(s,e){let t=i=>{this.off(s,t),e(i)};this.on(s,t)}off(s,e){for(let t of K(s))this.events.has(t)&&this.events.set(t,this.events.get(t).filter(i=>i!==e))}trigger(s,e){for(let t of K(s))if(this.events.has(t))for(let i of this.events.get(t))i(e)}},eu=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,su=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i,iu=/rgba?\(([0-9.]+), ?([0-9.]+), ?([0-9.]+)(, ?([0-9.]+))?\)/,nu=["#22ab24","#009ea6","#0f82f2","#6d3bbf","#cd0e66","#eb4726","#fd8c00"];function Oh(s){return s.length===1?`0${s}`:s}function Rh(s,e){if(e<=0)return $t.from(s[0]);if(e>=1)return $t.from(O(s));let t=Math.floor(e*(s.length-1)),i=e*(s.length-1)-t;return $t.mix(s[t+1],s[t],i)}function Co(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*(2/3-t)*6:s}var $t=class Ct{constructor(e,t,i,n=1){this.r=e,this.g=t,this.b=i,this.a=n}get hex(){let e=[this.r,this.g,this.b].map(i=>Oh(Math.round(i).toString(16))),t=this.a>=1?"":Oh(Math.round(this.a*255).toString(16));return`#${e.join("")}${t}`}get rgb(){return`rgba(${[this.r,this.g,this.b].map(t=>Math.round(t)).join(",")},${this.a})`}get brightness(){return(this.r*299+this.g*587+this.g*114)/1e3}get hsl(){let e=this.r/255,t=this.g/255,i=this.b/255,n=Math.max(e,t,i),r=Math.min(e,t,i),o=(r+n)/2,a=n-r;if(n===r)return[0,0,Math.round(o*100)];let h=e===n?(t-i)/a:t===n?2+(i-e)/a:4+(e-t)/a;h=Math.min(h*60,360),h<0&&(h+=360);let l=o<=.5?a/(n+r):a/(2-n-r);return[Math.round(h),Math.round(l*100),Math.round(o*100)]}get chroma(){return Math.max(this.r,this.g,this.b)-Math.min(this.r,this.g,this.b)}toString(){return this.rgb}copy(){return new Ct(this.r,this.g,this.b,this.a)}static from(e){return typeof e!="string"?e:e.startsWith("#")?Ct.fromHex(e):Ct.fromRgb(e)}static fromRgb(e){let t=e.match(iu);if(!t)return new Ct(0,0,0);let i=t[4]?+t[5]||0:1;return new Ct(+t[1],+t[2],+t[3],i)}static fromHex(e){e=e.replace(eu,(i,n,r,o)=>n+n+r+r+o+o);let t=su.exec(e);return t?new Ct(parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16),t[4]?parseInt(t[4],16)/255:1):new Ct(0,0,0)}static fromHsl(e,t,i){if(e/=360,t/=100,i/=100,t===0){let l=Math.round(i*255);return new Ct(l,l,l)}let n=i<.5?i*(1+t):i+t-i*t,r=2*i-n,o=Co(r,n,e+1/3),a=Co(r,n,e),h=Co(r,n,e-1/3);return new Ct(Math.round(o*255),Math.round(a*255),Math.round(h*255))}static rainbow(e){return z(t=>Rh(nu,t/(e-1)),e)}static gradient(e,t){return z(i=>Rh(e,i/(t-1)),t)}static shades(e,t,i=.5){let n=Ct.mix("#fff",e,i),r=Ct.mix("#000",e,i);return Ct.gradient([n,e,r],t)}static mix(e,t,i=.5){return e=Ct.from(e),t=Ct.from(t),new Ct(i*e.r+(1-i)*t.r,i*e.g+(1-i)*t.g,i*e.b+(1-i)*t.b,i*e.a+(1-i)*t.a)}static mixMany(e,t){t||(t=e.map(()=>1));let i=N(t),n=e.map(v=>v.hsl),r=n.map(v=>v[0]),o=r.map(v=>v<180?v+360:v),a=t.map((v,w)=>v*Math.sqrt(e[w].chroma)),h=N(a),l=N(r.map((v,w)=>v*a[w]))/h,c=N(o.map((v,w)=>v*a[w]))/h,u=N(r.map((v,w)=>Math.abs(v-l)*a[w])),d=N(o.map((v,w)=>Math.abs(v-c)*a[w])),g=u<=d?l:c%360,y=N(n.map((v,w)=>t[w]*v[1]))/i,f=N(n.map((v,w)=>t[w]*v[2]))/i;return Ct.fromHsl(g,y,f)}};function Vs(s){return s[Symbol.iterator]().next().value}function*rn(...s){for(let e of s)yield*ks(Zd(e))}function Bt(s,e){for(let t of s)if(e(t))return!0;return!1}function*Bh(s,e){let t=0;for(let i of s)e(i,t)&&(yield i),t+=1}function*_h(s,e){for(let t of s)for(let i of e(t))yield i}function*bi(s,e){for(let t of s)for(let i of e)yield[t,i]}function*Ro(s){let e=s.length;for(let t=0;t{for(var t in e)ru(s,t,{get:e[t],enumerable:!0})},ln=1e-6;function x(s,e,t=ln){return isNaN(s)||isNaN(e)?!1:Math.abs(s-e)t&&([e,t]=[t,e]),s>e+i&&s0?1:-1}var qh=/(\d+)(\d{3})/,au=["","k","m","b","t","q"];function hu(s){let[e,t]=s.split(".");for(;qh.test(e);)e=e.replace(qh,"$1,$2");return e+(t?`.${t}`:"")}function lu(s,e=6){if(!e)return`${s}`;let t=`${Math.abs(Math.floor(s))}`.length,i=t+(s<0?1:0);if(i<=e)return`${Rt(s,e-i)}`;let n=Math.floor(Math.log10(Math.abs(s))/3),r=au[n],o=e-(t%3||3)-(r?1:0)-(s<0?1:0);return Rt(s/Math.pow(10,3*n),o)+r}function Ot(s,e=0,t=!0){let i=lu(s,e).replace("-","\u2013");return t?hu(i):i}var cu=/^-?0,[0-9]+$/,pu=/^-?([0-9]+(,[0-9]{3})*)?\.?[0-9]*$/,du=/^-?[0-9]+(\.[0-9]{3})*,?[0-9]*$/;function Wh(s){return s=s.replace(/^–/,"-").trim(),!s||s.match(/[^0-9.,-]/)?NaN:cu.test(s)?parseFloat(s.replace(/,/,".")):pu.test(s)?parseFloat(s.replace(/,/g,"")):du.test(s)?parseFloat(s.replace(/\./g,"").replace(/,/,".")):NaN}var Do=["","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],Fh=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"],uu=[""," thousand"," million"," billion"," trillion"," quadrillion"," quintillion"," sextillion"];function fu(s){let[e,t,i]=s.split(""),n=e==="0"?"":` ${Do[+e]} hundred`;return t+i==="00"?n:+t<2?`${n} ${Do[+(t+i)]}`:i==="0"?`${n} ${Fh[+t]}`:`${n} ${Fh[+t]}-${Do[+i]}`}function zo(s){if(s===0)return"zero";let e=Math.round(Math.abs(s)).toString(),t=Math.ceil(e.length/3),i=e.padStart(3*t,"0"),n="";for(let r=0;rn.length===e):i}function Xh(s){if(s.length===1)return[[],s];let e=s.pop(),t=Xh(s),i=[];for(let n of t)i.push(n,[...n,e]);return i}var on=(s,e)=>{let t=s<0?"\u2013":"";return Math.abs(s)===1&&e?t+e:t+Math.abs(s)+(e||"")},Yh=class mt{constructor(e=0,t=0){this.re=e,this.im=t}get modulus(){return Math.sqrt(this.re*this.re+this.im*this.im)}get argument(){return Math.atan2(this.im,this.re)}get conjugate(){return new mt(this.re,-this.im)}root(e,t=0){let i=Math.pow(this.modulus,1/e),n=(this.argument+t*2*Math.PI)/e;return new mt(i*Math.cos(n),i*Math.sin(n))}toString(e=2){let t=Rt(this.re,e),i=Rt(this.im,e);return i===0?on(t):t===0?on(i,"i"):[on(t),i<0?"\u2013":"+",on(Math.abs(i),"i")].join(" ")}add(e){return mt.sum(this,e)}subtract(e){return mt.difference(this,e)}multiply(e){return mt.product(this,e)}divide(e){return mt.quotient(this,e)}static sum(e,t){return typeof e=="number"&&(e=new mt(e,0)),typeof t=="number"&&(t=new mt(t,0)),new mt(e.re+t.re,e.im+t.im)}static difference(e,t){return typeof e=="number"&&(e=new mt(e,0)),typeof t=="number"&&(t=new mt(t,0)),new mt(e.re-t.re,e.im-t.im)}static product(e,t){typeof e=="number"&&(e=new mt(e,0)),typeof t=="number"&&(t=new mt(t,0));let i=e.re*t.re-e.im*t.im,n=e.im*t.re+e.re*t.im;return new mt(i,n)}static quotient(e,t){if(typeof e=="number"&&(e=new mt(e,0)),typeof t=="number"&&(t=new mt(t,0)),Math.abs(t.re)1)return xe(e,xe(...t));let i=Math.abs(e),n=Math.abs(t[0]);for(;n;)[i,n]=[n,i%n];return i}function Ls(...s){let[e,...t]=s;return t.length>1?Ls(e,Ls(...t)):Math.abs(e*t[0])/xe(e,t[0])}function _o(s){if(s%1!==0||s<2)return!1;if(s%2===0)return s===2;if(s%3===0)return s===3;let e=Math.sqrt(s);for(let t=5;t<=e;t+=6)if(s%t===0||s%(t+2)===0)return!1;return!0}function No(s){if(s===1)return[];if(_o(s))return[s];let e=Math.sqrt(s);for(let t=2;t<=e;++t)if(s%t===0)return No(t).concat(No(s/t));return[]}function Zh(s){return Wt(No(s))}var mu=/^([0-9\-.]*)([%πkmbtq]?)(\/([0-9\-.]+))?([%π]?)$/,Hh=s=>s>=Number.MAX_SAFE_INTEGER,cn=class X{constructor(e,t,i){this.unit=i,this.num=t!==void 0&&t<0?-e:e,t!==void 0&&Math.abs(t)!==1&&e!==0&&(this.den=Math.abs(t))}valueOf(){return this.value}toMixed(){if(!this.den||this.unit)return this.toString();let e=Math.abs(this.num)%this.den,t=Math.abs(Math.trunc(this.value));return t?`${this.sign<0?"\u2013":""}${t} ${e}/${this.den}`:this.toString()}toExpr(e,t=4){let i=this.value;if(Math.abs(i)>=Number.MAX_VALUE)return"\u221E";if((Hh(this.num)||this.den&&Hh(this.den))&&(e="decimal"),e==="scientific"||Math.abs(i)>=Number.MAX_SAFE_INTEGER){let[n,r]=this.value.toExponential(t-1).split("e");if(Math.abs(+r)>=t){let o=r.startsWith("-"),a=`${o?"(":""}${o?r:r.slice(1)}${o?")":""}`;return`${n.replace(/\.?0+$/,"")} \xD7 10^${a}${this.unit||""}`}}if(!this.unit&&!this.den||e==="decimal"||e==="scientific"){let n=Ot(this.value,t);return n.match(/^[\d.]+$/g)?n:`"${n}"`}else return e==="mixed"?this.toMixed():this.toString()}toString(e=4){let t=!this.den&&!this.unit,i=Ot(this.num,this.den?0:e,t),n=this.unit||"",r=this.den?`/${Ot(this.den,0,t)}`:"";return i==="0"&&(n=""),n==="\u03C0"&&!this.den&&(i==="1"||i==="\u20131")&&(i=i.replace("1","")),`${i}${r}${n}`}toMathML(){let e=`${this.num}`;return this.den!==void 0&&(e=`${e}${this.den}`),this.unit&&(e+=this.unit==="\u03C0"?"\u03C0":"%"),e}get value(){let e=this.unit==="%"?.01:this.unit==="\u03C0"?Math.PI:1;return this.num*e/(this.den||1)}get sign(){return Math.sign(this.num)}get simplified(){if(!this.den)return this;let e=xe(Math.abs(this.num),this.den);return new X(this.num/e,this.den/e,this.unit)}get inverse(){return this.den?new X(1/this.num,void 0,this.unit):new X(this.den,this.num)}get negative(){return new X(-this.num,this.den,this.unit)}get fraction(){if(!(this.unit||!be(this.num)))return[this.num,this.den||1]}static fromString(e){e=e.toLowerCase().replace(/[\s,"]/g,"").replace("\u2013","-").replace("pi","\u03C0");let t=e.match(mu);if(!t)return;let i=t[2]||t[5]||void 0,n=t[1]?+t[1]:void 0,r=t[4]?+t[4]:void 0;if(i==="\u03C0"&&(!t[1]||t[1]==="-")&&(n=t[1]?-1:1),n===void 0||isNaN(n))return;let o=i?"kmbtq".indexOf(i):-1;if(o>=0&&(n*=1e3**(o+1),i=void 0),r===void 0)return new X(n,void 0,i);if(!(isNaN(r)||x(r,0)))return!be(n)||!be(r)?new X(n/r,void 0,i):new X(n,r,i)}static fractionFromDecimal(e,t=1e3,i=1e-12){let n=[1,0],r=[0,1],o=Math.abs(e),a=o;for(;Math.abs(n[0]/r[0]-o)>i;){let h=Math.floor(a);if(n=[h*n[0]+n[1],n[0]],r=[h*r[0]+r[1],r[0]],r[0]>t)return new X(e);a=1/(a-h)}return x(n[0]/r[0],o,i)?new X(ou(e)*n[0],r[0]===1?void 0:r[0]):new X(e)}clamp(e,t){let i=this.value;return e!==void 0&&it?new X(t):this}add(e){return X.sum(this,e)}subtract(e){return X.difference(this,e)}multiply(e){return X.product(this,e)}divide(e){return X.quotient(this,e)}static sum(e,t){if(typeof t=="number"&&(t=new X(t)),e.num===0)return t;if(e.unit!==t.unit)return new X(e.value+t.value);if(!e.den&&!t.den)return new X(e.num+t.num,void 0,e.unit);if(e.den||([e,t]=[t,e]),!be(t.num))return new X(e.value+t.value,void 0,e.unit);let i=Ls(e.den,t.den||1),n=i/e.den,r=i/(t.den||1);return new X(e.num*n+t.num*r,i,e.unit)}static difference(e,t){return typeof t=="number"&&(t=new X(t)),X.sum(e,t.negative)}static product(e,t){if(typeof t=="number"&&(t=new X(t)),!e.unit&&!e.den&&be(e.num))return new X(e.num*t.num,t.den,t.unit);if(!t.unit&&!t.den&&be(t.num))return new X(e.num*t.num,e.den,e.unit);if(e.unit==="\u03C0"||t.unit==="\u03C0"||!be(e.num)||!be(t.num))return new X(e.value*t.value);let i=(e.unit==="%"?100:1)*(t.unit==="%"?100:1);return new X(e.num*t.num,(e.den||1)*(t.den||1)*i)}static quotient(e,t){return typeof t=="number"&&(t=new X(t)),X.product(e,t.inverse)}},At={};Go(At,{determinant:()=>bu,fill:()=>Qh,identity:()=>Jh,inverse:()=>sl,product:()=>hn,reflection:()=>wu,rotation:()=>gu,scalarProduct:()=>yu,shear:()=>vu,sum:()=>tl,transpose:()=>el});function Qh(s,e,t){return ko(s,e,t)}function Jh(s=2){let e=Qh(0,s,s);for(let t=0;t1?tl(...t):t[0];if(e.length!==i.length||e[0].length!==i[0].length)throw new Error("Matrix sizes don\u2019t match");let n=[];for(let r=0;rt.map(i=>i*e))}function hn(...s){let[e,...t]=s,i=t.length>1?hn(...t):t[0];if(e[0].length!==i.length)throw new Error("Matrix sizes don\u2019t match.");let n=[];for(let r=0;rs[n][r],e,e);for(let n=0;nnl,binomial:()=>Su,cauchy:()=>Vu,chiCDF:()=>Lu,exponential:()=>Au,find:()=>Pu,geometric:()=>ku,integer:()=>$u,integrate:()=>ol,normal:()=>Cu,normalPDF:()=>Iu,poisson:()=>Eu,shuffle:()=>xu,smart:()=>Tu,uniform:()=>Mu,weighted:()=>il});function xu(s){s=s.slice(0);for(let e=s.length-1;e>0;--e){let t=Math.floor(Math.random()*(e+1));[s[e],s[t]]=[s[t],s[e]]}return s}function $u(s,e){let t=e===void 0?0:s,i=e===void 0?s:e-s+1;return t+Math.floor(i*Math.random())}function il(s){let e=Math.random()*N(s),t=0;return s.findIndex(i=>(t+=i)>=e)}function Pu(s){return s[Math.floor(s.length*Math.random())]}var an=new Map;function Tu(s,e){e||(e=We()),an.has(e)||an.set(e,re(1,s));let t=an.get(e),i=il(t.map(n=>n*n));return t[i]-=1,t[i]<=0&&an.set(e,t.map(n=>n+1)),i}function nl(s=.5){return Math.random()e;++i)t*=Math.random();return i-1}function Mu(s=0,e=1){return s+(e-s)*Math.random()}function Cu(s=0,e=1){let t=Math.random(),i=Math.random();return Math.sqrt(-2*Math.log(t))*Math.cos(2*Math.PI*i)*Math.sqrt(e)+s}function Au(s=1){return s<=0?0:-Math.log(Math.random())/s}function ku(s=.5){if(!(s<=0||s>1))return Math.floor(Math.log(Math.random())/Math.log(1-s))}function Vu(){let s,e,t;do e=2*Math.random()-1,t=2*Math.random()-1,s=e*e+t*t;while(s>=1);return e/t}function Iu(s,e=1,t=0){return Math.exp(-((s-e)**2)/(2*t))/Math.sqrt(2*Math.PI*t)}var jh=7,Uh=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23];function rl(s){if(s<.5)return Math.PI/(Math.sin(Math.PI*s)*rl(1-s));s-=1;let e=Uh[0];for(let i=1;iMath.pow(i,(e-2)/2)*Math.exp(-i/2),0,s)/Math.pow(2,e/2)/rl(e/2)}var qo={};Go(qo,{bestPolynomial:()=>zu,coefficient:()=>hl,exponential:()=>Du,linear:()=>Ru,logarithmic:()=>Nu,polynomial:()=>al,power:()=>Gu});function Ou(s,e){let t=1,i=s[0];for(let n=1;noe(e+1).map(l=>Math.pow(h[0],l))),i=el(t),n=s.map(h=>[h[1]]),r=hn(i,t),o=sl(r);return hn(o,i,n).map(h=>h[0])}function hl(s,e){let i=s.reduce((o,a)=>o+a[1],0)/s.length,n=s.reduce((o,a)=>o+(a[1]-i)**2,0);return 1-s.reduce((o,a)=>o+(a[1]-e(a[0]))**2,0)/n}function zu(s,e=.85,t=8){if(!(s.length<=1))for(let i=1;iOu(n,a);if(hl(s,r)>=e)return{order:i,coefficients:n,fn:r}}}function Os(s){return s.length?N(s)/s.length:0}var Tt=2*Math.PI;function $i(s,e){let t=Math.atan2(s.y-(e?e.y:0),s.x-(e?e.x:0));return gt(t,Tt)}function ll(s,e){let t,i=1/0,n=-1;for(let[r,o]of e.entries()){let a=o.project(s),h=p.distance(s,a);hn.x))/e.length,i=N(e.map(n=>n.y))/e.length;return new et(t,i)}static dot(e,t){return e.x*t.x+e.y*t.y}static sum(e,t){return new et(e.x+t.x,e.y+t.y)}static difference(e,t){return new et(e.x-t.x,e.y-t.y)}static distance(e,t){return Math.sqrt(Qt(e.x-t.x)+Qt(e.y-t.y))}static manhattan(e,t){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)}static interpolate(e,t,i=.5){return new et(tt(e.x,t.x,i),tt(e.y,t.y,i))}static interpolateList(e,t=.5){let i=e.length-1,n=Math.floor(B(t,0,1)*i);return et.interpolate(e[n],e[n+1],i*t-n)}static fromPolar(e,t=1){return new et(t*Math.cos(e),t*Math.sin(e))}static random(e){let t=_t.uniform(e.xMin,e.xMax),i=_t.uniform(e.yMin,e.yMax);return new et(t,i)}static equals(e,t,i){return x(e.x,t.x,i)&&x(e.y,t.y,i)}static colinear(e,t,i,n){let r=e.x-t.x,o=e.y-t.y,a=t.x-i.x,h=t.y-i.y;return x(r*h,a*o,n)}transform(e){let t=e[0][0]*this.x+e[0][1]*this.y+e[0][2],i=e[1][0]*this.x+e[1][1]*this.y+e[1][2];return new et(t,i)}rotate(e,t=R){if(x(e,0))return this;let i=this.x-t.x,n=this.y-t.y,r=Math.cos(e),o=Math.sin(e),a=i*r-n*o+t.x,h=i*o+n*r+t.y;return new et(a,h)}reflect(e){let t=e.p2.x-e.p1.x,i=e.p2.y-e.p1.y,n=this.x-e.p1.x,r=this.y-e.p1.y,o=(t*r-i*n)/(t*t+i*i),a=this.x+2*o*i,h=this.y-2*o*t;return new et(a,h)}scale(e,t=e){return new et(this.x*e,this.y*t)}shift(e,t=e){return new et(this.x+e,this.y+t)}translate(e){return this.shift(e.x,e.y)}equals(e,t){return et.equals(this,e,t)}toString(){return`point(${this.x},${this.y})`}},R=new p(0,0);function St(s){return["polygon","polyline","rectangle","triangle"].includes(s.type)}function Ye(s){return["polygon","triangle"].includes(s.type)}function fn(s){return s.type==="polyline"}function Wo(s){return s.type==="rectangle"}function it(s){return["line","ray","segment"].includes(s.type)}function Ko(s){return s.type==="line"}function mn(s){return s.type==="ray"}function $e(s){return s.type==="segment"}function U(s){return s.type==="circle"}function Ze(s){return s.type==="ellipse"}function Dt(s){return s.type==="arc"}function Pe(s){return s.type==="sector"}function qt(s){return s.type==="angle"}function rt(s){return s.type==="point"}var vt=class xi{constructor(e,t){this.p1=e,this.p2=t,this.type="line"}get length(){return p.distance(this.p1,this.p2)}get lengthSquared(){return(this.p1.x-this.p2.x)**2+(this.p1.y-this.p2.y)**2}get midpoint(){return p.average(this.p1,this.p2)}get slope(){return(this.p2.y-this.p1.y)/(this.p2.x-this.p1.x)}get intercept(){return this.p1.y-this.slope*this.p1.x}get angle(){return $i(this.p2,this.p1)}get unitVector(){return this.p2.subtract(this.p1).unitVector}get perpendicularVector(){return new p(this.p2.y-this.p1.y,this.p1.x-this.p2.x).unitVector}parallel(e){return new xi(e,e.add(this.p2).subtract(this.p1))}perpendicular(e){let t=this.line.project(e);return p.equals(e,t)?new xi(t,t.add(this.perpendicularVector.scale(this.length/2))):new xi(t,e)}get perpendicularBisector(){return this.perpendicular(this.midpoint)}distanceSquared(e){let t=this.project(e);return(e.x-t.x)**2+(e.y-t.y)**2}get line(){return this.type==="line"?this:new xi(this.p1,this.p2)}get ray(){return mn(this)?this:new Xo(this.p1,this.p2)}get segment(){return $e(this)?this:new Y(this.p1,this.p2)}offset(e){let t=p.difference(this.p2,this.p1),i=p.difference(e,this.p1);return p.dot(t,i)/this.lengthSquared}project(e){return this.at(this.offset(e))}side(e,t){let i=p.difference(this.p2,this.p1),n=p.difference(e,this.p1),r=n.x*i.y-n.y*i.x;return x(r,0,t)?0:Math.sign(r)}contains(e,t){return this.side(e,t)===0}at(e){return p.interpolate(this.p1,this.p2,e)}transform(e){return new this.constructor(this.p1.transform(e),this.p2.transform(e))}rotate(e,t=R){return x(e,0)?this:new this.constructor(this.p1.rotate(e,t),this.p2.rotate(e,t))}reflect(e){return new this.constructor(this.p1.reflect(e),this.p2.reflect(e))}scale(e,t=e){return new this.constructor(this.p1.scale(e,t),this.p2.scale(e,t))}shift(e,t=e){return new this.constructor(this.p1.shift(e,t),this.p2.shift(e,t))}translate(e){return this.shift(e.x,e.y)}equals(e,t){return this.contains(e.p1,t)&&this.contains(e.p2,t)}toString(){return`line(${this.p1},${this.p2})`}},Xo=class extends vt{constructor(){super(...arguments),this.type="ray"}equals(s,e){return s.type!=="ray"||!this.p1.equals(s.p1,e)?!1:this.p2.equals(s.p2,e)?!0:s.contains(this.p2,e)||this.contains(s.p2,e)}contains(s,e){if(!super.contains(s,e))return!1;let t=this.offset(s);return x(t,0,e)||t>0}toString(){return`ray(${this.p1},${this.p2})`}},Y=class ml extends vt{constructor(){super(...arguments),this.type="segment"}contains(e,t){return super.contains(e,t)?this.p1.equals(e,t)||this.p2.equals(e,t)?!0:x(this.p1.x,this.p2.x,t)?nt(e.y,this.p1.y,this.p2.y):nt(e.x,this.p1.x,this.p2.x):!1}project(e){let t=p.difference(this.p2,this.p1),i=p.difference(e,this.p1),n=B(p.dot(t,i)/this.lengthSquared,0,1);return this.p1.add(t.scale(n))}contract(e){return new ml(this.at(e),this.at(1-e))}equals(e,t,i=!1){return e.type!=="segment"?!1:this.p1.equals(e.p1,t)&&this.p2.equals(e.p2,t)||!i&&this.p1.equals(e.p2,t)&&this.p2.equals(e.p1,t)}toString(){return`segment(${this.p1},${this.p2})`}},wt=class Rs{constructor(e=R,t=1){this.c=e,this.r=t,this.type="circle"}get circumference(){return Tt*this.r}get area(){return Math.PI*this.r**2}get arc(){let e=this.c.shift(this.r,0);return new Ft(this.c,e,Tt)}tangentAt(e){let t=this.at(e),i=this.c.rotate(Math.PI/2,t);return new vt(t,i)}collision(e){let t=this.c.xe.p.x+e.w?e.p.x+e.w:this.c.x,i=this.c.ye.p.y+e.h?e.p.y+e.h:this.c.y;return p.distance(this.c,new p(t,i))<=this.r}project(e){let t=e.subtract(this.c).unitVector.scale(this.r);return p.sum(this.c,t)}at(e){let t=Tt*e;return this.c.shift(this.r*Math.cos(t),this.r*Math.sin(t))}offset(e){return $i(e,this.c)/Tt}contains(e){return p.distance(e,this.c)<=this.r}transform(e){let t=Math.abs(e[0][0])+Math.abs(e[1][1]);return new Rs(this.c.transform(e),this.r*t/2)}rotate(e,t=R){return x(e,0)?this:new Rs(this.c.rotate(e,t),this.r)}reflect(e){return new Rs(this.c.reflect(e),this.r)}scale(e,t=e){return new Rs(this.c.scale(e,t),this.r*(e+t)/2)}shift(e,t=e){return new Rs(this.c.shift(e,t),this.r)}translate(e){return this.shift(e.x,e.y)}equals(e,t){return x(this.r,e.r,t)&&this.c.equals(e.c,t)}toString(){return`circle(${this.c},${this.r})`}},Ft=class{constructor(s,e,t){this.c=s,this.start=e,this.angle=t,this.type="arc"}get circle(){return new wt(this.c,this.radius)}get radius(){return p.distance(this.c,this.start)}get end(){return this.start.rotate(this.angle,this.c)}get startAngle(){return $i(this.start,this.c)}contract(s){return new this.constructor(this.c,this.at(s/2),this.angle*(1-s))}get minor(){return this.angle<=Math.PI?this:new this.constructor(this.c,this.end,Tt-this.angle)}get major(){return this.angle>=Math.PI?this:new this.constructor(this.c,this.end,Tt-this.angle)}get center(){return this.at(.5)}project(s){let e=this.startAngle,t=e+this.angle,i=$i(s,this.c);return t>Tt&&i=-ls}function cl(s,e,t){let i=s.y-e.y,n=t.x-e.x,r=s.x-e.x,o=t.y-e.y,a=r*n+i*o;if(a(i.prev=e,i.next=t,e.next=i,t&&(t.prev=i),i)}}static node(s){let e=s;return e.remove=()=>{e.prev&&(e.prev.next=e.next),e.next&&(e.next.prev=e.prev),e.prev=e.next=void 0},e}};function Uo(s,e,t){let i={above:t.myFill.above,below:t.myFill.below};return{start:s,end:e,myFill:i}}function _u(s,e,t,i,n,r){let o=gl(e,n);return o!==0?o:p.equals(t,r)?0:s!==i?s?1:-1:jo(t,i?n:r,i?r:n)?1:-1}function Zo(s,e,t){s.insertBefore(e,i=>_u(!!e.isStart,e.pt,t,!!i.isStart,i.pt,i.other.pt)<0)}function qu(s,e,t){let i=Ns.node({isStart:!0,pt:e.start,seg:e,primary:t});return Zo(s,i,e.end),i}function Fu(s,e,t,i){let n=Ns.node({pt:t.end,seg:t,primary:i,other:e});e.other=n,Zo(s,n,e.pt)}function dn(s,e,t){let i=qu(s,e,t);return Fu(s,i,e,t),i}function Hu(s,e,t){e.other.remove(),e.seg.end=t,e.other.pt=t,Zo(s,e.other,e.pt)}function ue(s,e,t){let i=Uo(t,e.seg.end,e.seg);return Hu(s,e,t),dn(s,i,!!e.primary)}function ju(s,e){let t=s.seg.start,i=s.seg.end,n=e.seg.start,r=e.seg.end;return p.colinear(t,n,r)?p.colinear(i,n,r)||jo(i,n,r)?1:-1:jo(t,n,r)?1:-1}function Fo(s,e,t){let i=e.seg,n=t.seg,r=i.start,o=i.end,a=n.start,h=n.end,l=Bu(r,o,a,h);if(l===!1){if(!p.colinear(r,o,a)||p.equals(r,h)||p.equals(o,a))return!1;let c=p.equals(r,a),u=p.equals(o,h);if(c&&u)return t;let d=!c&&cl(r,a,h),g=!u&&cl(o,a,h);if(c)return g?ue(s,t,o):ue(s,e,h),t;d&&(u||(g?ue(s,t,o):ue(s,e,h)),ue(s,t,r))}else l.alongA===0&&(l.alongB===-1?ue(s,e,a):l.alongB===0?ue(s,e,l.pt):l.alongB===1&&ue(s,e,h)),l.alongB===0&&(l.alongA===-1?ue(s,t,r):l.alongA===0?ue(s,t,l.pt):l.alongA===1&&ue(s,t,o));return!1}function vl(s,e){var t,i;let n=new Ns,r=[];for(;s.head;){let a=s.head;if(a.isStart){let h=function(){if(c){let g=Fo(s,a,c);if(g)return g}return u?Fo(s,a,u):!1};var o=h;let l=n.findTransition(g=>ju(a,g.ev)>0),c=(t=l.before)==null?void 0:t.ev,u=(i=l.after)==null?void 0:i.ev,d=h();if(d&&(e?(!a.seg.myFill.below||a.seg.myFill.above!==a.seg.myFill.below)&&(d.seg.myFill.above=!d.seg.myFill.above):d.seg.otherFill=a.seg.myFill,a.other.remove(),a.remove()),s.head!==a)continue;if(e){let g=a.seg.myFill.below?a.seg.myFill.above!==a.seg.myFill.below:!0;a.seg.myFill.below=u?u.seg.myFill.above:!1,a.seg.myFill.above=g?!a.seg.myFill.below:a.seg.myFill.below}else if(a.seg.otherFill===void 0){let g=u?a.primary===u.primary?u.seg.otherFill.above:u.seg.myFill.above:!1;a.seg.otherFill={above:g,below:g}}a.other.status=l.insert(Ns.node({ev:a}))}else{let h=a.status;if(h===void 0)throw new Error("[Euclid.js] Zero-length segment detected!");if(n.exists(h.prev)&&n.exists(h.next)&&Fo(s,h.prev.ev,h.next.ev),h.remove(),!a.primary){let l=a.seg.myFill;a.seg.myFill=a.seg.otherFill,a.seg.otherFill=l}r.push(a.seg)}s.head.remove()}return r}function Uu(s){let e=[],t=[];return s.forEach(i=>{let n=i.start,r=i.end;if(p.equals(n,r))return;let o={index:0,matchesHead:!1,matchesPt1:!1},a={index:0,matchesHead:!1,matchesPt1:!1},h=o;function l(f,v,w){h.index=f,h.matchesHead=v,h.matchesPt1=w;let $=h===o;return h=$?a:void 0,!$}for(let f=0;fQo(s,e,Ku),Qu=(s,e)=>Qo(s,e,Xu),Ju=(s,e)=>Qo(s,e,Yu);function tf(s,e){return x(s.p1.x,s.p2.x)?nt(e.y,s.p1.y,s.p2.y):nt(e.x,s.p1.x,s.p2.x)}function ef(s,e){return x(s.p1.x,s.p2.x)?(e.y-s.p1.y)/(s.p2.y-s.p1.y)>0:(e.x-s.p1.x)/(s.p2.x-s.p1.x)>0}function sf(s,e){return nt(s.offset(e),0,1)}function nf(s,e){let t=s.p1.x-s.p2.x,i=s.p1.y-s.p2.y,n=e.p1.x-e.p2.x,r=e.p1.y-e.p2.y,o=t*r-i*n;if(x(o,0))return[];let a=s.p1.x*s.p2.y-s.p1.y*s.p2.x,h=e.p1.x*e.p2.y-e.p1.y*e.p2.x,l=a*n-t*h,c=a*r-i*h;return[new p(l/o,c/o)]}function rf(s,e){let t=p.distance(s.c,e.c);if(t>s.r+e.r)return[];if(ttf(r,o))),mn(r)&&(t=t.filter(o=>ef(r,o))),Dt(r)&&(t=t.filter(o=>sf(r,o)));return t}function Q(...s){if(s.length<2)return[];if(s.length>2)return ye(Kh(s,2).map(i=>Q(...i)));let[e,t]=s;if(qt(e)&&(e=e.shape(!0)),qt(t)&&(t=t.shape(!0)),St(t)&&([e,t]=[t,e]),St(e)){let i=it(t)?e.points.filter(n=>t.contains(n)):[];for(let n of e.edges)i.push(...Q(n,t));return i}return of(e,t)}var V=class Xe{constructor(...e){this.type="polygon",this.points=e}get circumference(){if(this.points.length<=1)return 0;let e=p.distance(this.points[0],O(this.points));for(let t=1;tp.distance(i,e));return Math.max(...t)}get oriented(){if(this.signedArea>=0)return this;let e=[...this.points].reverse();return new this.constructor(...e)}cut(e){let t=this.radius/e.length*10,i=e.at(-t),n=e.at(t),r=e.perpendicularVector.scale(e.length*t),o=[i,n,n.add(r),i.add(r)],a=Qu([this.points],[o]),h=Ju([this.points],[o]);return[...a,...h].map(l=>new Xe(...l))}static collision(e,t){if(e.points.some(i=>t.contains(i))||t.points.some(i=>e.contains(i)))return!0;for(let i of e.edges)for(let n of t.edges)if(Q(i,n)[0])return!0;return!1}static union(...e){let[t,...i]=e;if(!i.length)return[t];let n=[t.points],r=i.length>1?Xe.union(...i).map(o=>o.points):[e[1].points];return Zu(n,r).map(o=>new Xe(...o))}static regular(e,t=1){let i=Tt/e,n=Math.PI/2-i/2,r=z(o=>p.fromPolar(n+i*o,t),e);return new Xe(...r)}static interpolate(e,t,i=.5){let n=e.points.map((r,o)=>p.interpolate(r,t.points[o],i));return new Xe(...n)}static convexHull(...e){if(e.length<=3)return new Xe(...e);let t=e.sort((o,a)=>o.x!==a.x?o.x-a.x:o.y-a.y),i=t.slice(0).reverse(),n=[],r=[];for(let[o,a]of[[t,n],[i,r]]){for(let h of o){for(;a.length>=2;){let l=a[a.length-1],c=a[a.length-2];if((l.x-c.x)*(h.y-c.y)>=(h.x-c.x)*(l.y-c.y))a.pop();else break}a.push(h)}a.pop()}return new Xe(...n.concat(r))}contains(e){let t=!1;for(let i of this.edges){if(i.p1.equals(e)||i.contains(e))return!1;if(i.p1.y>e.y==i.p2.y>e.y)continue;let n=(i.p2.x-i.p1.x)/(i.p2.y-i.p1.y);e.xt)return n.at((t-i)/r);i+=r}return this.points[0]}offset(e){let t=this.edges,i=ll(e,this.edges)||[this.points[0],0],n=0;for(let r=0;rt.transform(e)))}rotate(e,t=R){if(x(e,0))return this;let i=this.points.map(n=>n.rotate(e,t));return new this.constructor(...i)}reflect(e){let t=this.points.map(i=>i.reflect(e));return new this.constructor(...t)}scale(e,t=e){let i=this.points.map(n=>n.scale(e,t));return new this.constructor(...i)}shift(e,t=e){let i=this.points.map(n=>n.shift(e,t));return new this.constructor(...i)}translate(e){return this.shift(e.x,e.y)}equals(e,t,i){let n=this.points.length;if(n!==e.points.length)return!1;let r=i?this:this.oriented,o=i?e:e.oriented;for(let a=0;ah.equals(o.points[(l+a)%n],t)))return!0;return!1}toString(){return`polygon(${this.points.join(",")})`}},te=class extends V{constructor(){super(...arguments),this.type="polyline"}get circumference(){return this.length}get length(){let s=0;for(let e=1;eNumber.MAX_SAFE_INTEGER))return new wt(o,a)}get incircle(){let s=this.edges,e=s.map(c=>c.length),t=e[0]+e[1]+e[2],[i,n,r]=this.points,o=e[1]*i.x+e[2]*n.x+e[0]*r.x,a=e[1]*i.y+e[2]*n.y+e[0]*r.y,h=new p(o/t,a/t),l=h.distanceFromLine(s[0]);return isNaN(l)?void 0:new wt(h,l)}get orthocenter(){let[s,e,t]=this.points,i=new vt(s,e).perpendicular(t),n=new vt(s,t).perpendicular(e);return Q(i,n)[0]}},af=180/Math.PI,hf=Math.PI/180;function Kt(s){return s*af}function J(s){return s*hf}var kt=class fe{constructor(e,t,i){this.a=e,this.b=t,this.c=i,this.type="angle"}static fromDegrees(e){return fe.fromRadians(e*(Math.PI/180))}static fromRadians(e){let t=new p(1,0),i=t.rotate(e);return new fe(t,R,i)}static equals(e,t,i=Math.PI/360){return x(e.rad,t.rad,i)}get rad(){let e=Math.atan2(this.a.y-this.b.y,this.a.x-this.b.x),i=Math.atan2(this.c.y-this.b.y,this.c.x-this.b.x)-e;return i<0&&(i+=Tt),i}get deg(){return this.rad*180/Math.PI}get isRight(){return x(this.rad,Math.PI/2,Math.PI/360)}get bisector(){if(this.b.equals(this.a)||this.b.equals(this.c))return;let e=Math.atan2(this.a.y-this.b.y,this.a.x-this.b.x),t=Math.atan2(this.c.y-this.b.y,this.c.x-this.b.x),i=(e+t)/2;e>t&&(i+=Math.PI);let n=Math.cos(i)+this.b.x,r=Math.sin(i)+this.b.y;return new vt(this.b,new p(n,r))}get sup(){return this.rado.x?i:o.x,n=no.y?r:o.y;return new Ds(new p(t,n),i-t,r-n)}get center(){return new p(this.p.x+this.w/2,this.p.y+this.h/2)}get centroid(){return this.center}get circumference(){return 2*Math.abs(this.w)+2*Math.abs(this.h)}get area(){return Math.abs(this.signedArea)}get signedArea(){return this.w*this.h}get edges(){return this.polygon.edges}get points(){return this.polygon.points}get polygon(){let e=new p(this.p.x+this.w,this.p.y),t=new p(this.p.x+this.w,this.p.y+this.h),i=new p(this.p.x,this.p.y+this.h);return new V(this.p,e,t,i)}get bounds(){return new lt(this.p.x,this.p.x+this.w,this.p.y,this.p.y+this.h)}collision(e){return this.p.xe.p.x&&this.p.ye.p.y}padding(e,t,i,n){return new Ds(this.p.shift(-n,-e),this.w+n+t,this.h+e+i)}get unsigned(){if(this.w>0&&this.h>0)return this;let e=this.p.shift(this.w<0?this.w:0,this.h<0?this.h:0);return new Ds(e,Math.abs(this.w),Math.abs(this.h))}contains(e,t){return nt(e.x,this.p.x,this.p.x+this.w,t)&&nt(e.y,this.p.y,this.p.y+this.h,t)}project(e){let t;for(let i of this.edges){let n=i.project(e);(!t||p.distance(e,n)0?1:0,r=p.distance(e,s);return[s.x,`${s.y}A${r}`,r,0,n,1,t.x,t.y].join(",")}function Jt(...s){return`M${s.map(e=>`${e.x},${e.y}`).join("L")}`}function Ho(s,e){let t=s.perpendicularVector.scale(6),i=s.unitVector.scale(3),n=s.midpoint;switch(e){case"bar":return Jt(n.add(t),n.add(t.inverse));case"bar2":return Jt(n.add(i).add(t),n.add(i).add(t.inverse))+Jt(n.add(i.inverse).add(t),n.add(i.inverse).add(t.inverse));case"arrow":return Jt(n.add(i.inverse).add(t),n.add(i),n.add(i.inverse).add(t.inverse));case"arrow2":return Jt(n.add(i.scale(-2)).add(t),n,n.add(i.scale(-2)).add(t.inverse))+Jt(n.add(t),n.add(i.scale(2)),n.add(t.inverse));default:return""}}function un(s,e){if(!s||!e)return"";let t=e.perpendicular,i=s.add(e.scale(9)).add(t.scale(9)),n=s.add(e.scale(9)).add(t.scale(-9));return Jt(i,s,n)}function lf(s,e){let t="";return _(e,"start","both")&&(t+=un(s.p1,s.unitVector)),_(e,"end","both")&&(t+=un(s.p2,s.unitVector.inverse)),t}function cf(s,e){let t="";if(_(e,"start","both")){let i=new vt(s.c,s.start).perpendicularVector.inverse;t+=un(s.start,i)}if(_(e,"end","both")){let i=new vt(s.c,s.end).perpendicularVector;t+=un(s.end,i)}return t}function pf(s,e,t=e,i=e,n=t){let{p:r,w:o,h:a}=s;return`M${r.x} ${r.y+e}a${e} ${e} 0 0 1 ${e} ${-e}h${o-e-t}a${t} ${t} 0 0 1 ${t} ${t}v${a-t-i}a${i} ${i} 0 0 1 ${-i} ${i}h${-o+n+i}a${n} ${n} 0 0 1 ${-n} ${-n}Z`}function De(s,e={}){if(qt(s)){let t=s.shape(!!e.fill,e.size,e.round);return De(t,e)}if($e(s)){if(s.p1.equals(s.p2))return"";let t=Jt(s.p1,s.p2);return e.mark&&(t+=Ho(s,e.mark)),e.arrows&&(t+=lf(s,e.arrows)),t}if(mn(s)){if(!e.box)return"";let t=Q(s,e.box)[0];if(!t)return"";let i=Jt(s.p1,t);return e.mark&&(i+=Ho(s,e.mark)),i}if(Ko(s)){if(!e.box)return"";let t=Q(s,e.box);if(t.length<2)return"";let i=Jt(t[0],t[1]);return e.mark&&(i+=Ho(s,e.mark)),i}if(U(s))return`M${s.c.x-s.r} ${s.c.y}a${s.r},${s.r} 0 1 0 ${2*s.r} 0a${s.r} ${s.r} 0 1 0 ${-2*s.r} 0Z`;if(Ze(s)){let[t,i]=s.majorVertices,n=Kt(s.angle);return`M${t.x} ${t.y}A${s.a} ${s.b} ${n} 0 0 ${i.x} ${i.y}A${s.a} ${s.b} ${n} 0 0 ${t.x} ${t.y}Z`}if(Dt(s)){let t=`M${fl(s.start,s.c,s.end)}`;return e.arrows&&(t+=cf(s,e.arrows)),t}if(Pe(s))return`M${s.c.x} ${s.c.y} L ${fl(s.start,s.c,s.end)}Z`;if(fn(s))return Jt(...s.points);if(Ye(s))return`${Jt(...s.points)}Z`;if(Wo(s)){if(!e.cornerRadius)return`${Jt(...s.polygon.points)}Z`;let t=s.unsigned,i=Math.min(e.cornerRadius,t.w/2,t.h/2);return pf(t,i)}return""}var ta=(s,e)=>(e=Symbol[s])?e:Symbol.for("Symbol."+s),he=(s,e,t)=>new Promise((i,n)=>{var r=h=>{try{a(t.next(h))}catch(l){n(l)}},o=h=>{try{a(t.throw(h))}catch(l){n(l)}},a=h=>h.done?i(h.value):Promise.resolve(h.value).then(r,o);a((t=t.apply(s,e)).next())}),df=function(s,e){this[0]=s,this[1]=e},uf=s=>{var e=s[ta("asyncIterator")],t=!1,i,n={};return e==null?(e=s[ta("iterator")](),i=r=>n[r]=o=>e[r](o)):(e=e.call(s),i=r=>n[r]=o=>{if(t){if(t=!1,r==="throw")throw o;return o}return t=!0,{done:!1,value:new df(new Promise(a=>{var h=e[r](o);if(!(h instanceof Object))throw TypeError("Object expected");a(h)}),1)}}),n[ta("iterator")]=()=>n,i("next"),"throw"in e?i("throw"):n.throw=r=>{throw r},"return"in e&&i("return"),n},gn="_M",Gs=window.navigator.userAgent.toLowerCase(),ff=/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i,wl=/iphone|ipad|ipod/i,mf=/^((?!chrome|android).)*safari/i,yl,gf=class{constructor(){this.isMobile=ff.test(Gs),this.isRetina=(window.devicePixelRatio||1)>1,this.isTouch=!!window.Touch||"ontouchstart"in window,this.isChrome=!!window.chrome,this.isFirefox=Gs.indexOf("firefox")>=0,this.isAndroid=Gs.indexOf("android")>=0,this.isIOS=wl.test(Gs),this.isSafari=wl.test(Gs)||mf.test(Gs),this.loadQueue=[],this.loaded=!1,this.width=window.innerWidth,this.height=window.innerHeight,this.resizeCallbacks=[],this.theme={name:"light",isDark:!1},this.themeChangedCallbacks=[],this.themeOverride="",this.darkQuery=(yl=window.matchMedia)==null?void 0:yl.call(window,"(prefers-color-scheme: dark)");var s,e;window.onload=()=>this.afterLoad(),document.addEventListener("DOMContentLoaded",()=>this.afterLoad());let t=ve(()=>this.applyResize());window.addEventListener("resize",t);try{(s=this.darkQuery)==null||s.addEventListener("change",()=>this.applyThemeChange())}catch(n){(e=this.darkQuery)==null||e.addListener(()=>this.applyThemeChange())}let i=this.getCookie("theme");i&&this.setTheme(i);try{this.localStorage=window.localStorage}catch(n){console.warn("Unable to access Local Storage in this context.")}}afterLoad(){if(!this.loaded){this.loaded=!0;for(let s of this.loadQueue)s();setTimeout(()=>this.resize())}}ready(s){this.loaded?s():this.loadQueue.push(s)}redraw(){document.body.offsetHeight}applyResize(){let s=window.innerWidth,e=window.innerHeight;if(!(this.width===s&&this.height===e)){this.width=s,this.height=e;for(let t of this.resizeCallbacks)t({width:this.width,height:this.height});C.trigger("scroll",{top:C.scrollTop})}}onResize(s){s({width:this.width,height:this.height}),this.resizeCallbacks.push(s)}offResize(s){let e=this.resizeCallbacks.indexOf(s);e>=0&&this.resizeCallbacks.splice(e,1)}resize(){this.applyResize()}applyThemeChange(){let s=this.theme.name,e=s==="dark"||s==="auto"&&this.darkQuery.matches;if(e!==this.theme.isDark){this.theme.isDark=e;for(let t of this.themeChangedCallbacks)t(this.theme);setTimeout(()=>Xt.setAttr("theme",this.themeOverride||(e?"dark":"light")))}}setTheme(s){s!==this.theme.name&&(this.theme.name=s,this.setCookie("theme",s),this.applyThemeChange())}onThemeChange(s){this.themeChangedCallbacks.push(s)}getHash(){return window.location.hash.slice(1)}setHash(s){let e=document.body.scrollTop;window.location.hash=s,document.body.scrollTop=e}setURL(s,e=""){window.history.replaceState({},e,s),e&&(window.document.title=e)}getCookies(){let s=document.cookie.split(";"),e={};for(let t=0,i=s.length;t use")).forEach(function(e){let t=e.getAttribute("xlink:href"),[i,n]=t.split("#");if(!i.length||!n)return;let r=e.parentNode;r.removeChild(e),i in ea||(ea[i]=fetch(i).then(a=>a.text())),ea[i].then(a=>{let h=document.implementation.createHTMLDocument("");h.documentElement.innerHTML=a;let c=h.getElementById(n).cloneNode(!0),u=document.createDocumentFragment();for(;c.childNodes.length;)u.appendChild(c.firstChild);r.appendChild(u)})})}var $f=new Map(Object.entries({" ":"Space",Spacebar:"Space",Del:"Delete",Esc:"Escape",Left:"ArrowLeft",Right:"ArrowRight",Down:"ArrowDown",Up:"ArrowUp"}));function Ei(s){return $f.get(s.key)||s.key}function El(s){let e=new Set(["Enter","Space"]),t=!1;document.addEventListener("keyup",i=>{e.has(Ei(i))&&(t=!1)}),(s||document).addEventListener("keydown",i=>{if(!t&&e.has(Ei(i))){t=!0;let n=b.getActiveInput();n&&n.hasAttr("tabindex")&&n.tagName!=="TEXTAREA"&&(i.preventDefault(),n.trigger("pointerdown",i),n.trigger("pointerstop",i),C.trigger("pointerstop",i),n.trigger("click",i))}})}var Pn=!1;setTimeout(()=>Pn=!0);var Pf="cubic-bezier(0.175, 0.885, 0.32, 1.275)",Tf="cubic-bezier(0.68, -0.275, 0.825, 0.115)",ps={cancel:()=>{},promise:Promise.resolve()};function pt(s,e){if(e===0)return s(1,0,()=>{}),ps;let t=Date.now(),i=Ke(),n=0,r=!0,o=()=>{r=!1,i.reject()};function a(){if(!r)return;(!e||n<=e)&&window.requestAnimationFrame(a);let h=Date.now()-t;s(e?Math.min(1,h/e):h,h-n,o),e&&h>=e&&i.resolve(),n=h}return a(),{cancel:o,promise:i.promise}}function vn(s,e=0,t=0){switch(s){case"quad":return e**2;case"cubic":return e**3;case"quart":return e**4;case"quint":return e**5;case"circ":return 1-Math.sqrt(1-e**2);case"sine":return 1-Math.cos(e*Math.PI/2);case"exp":return e<=0?0:Math.pow(2,10*(e-1));case"back":return t||(t=1.70158),e*e*((t+1)*e-t);case"elastic":return t||(t=.3),-Math.pow(2,10*(e-1))*Math.sin(((e-1)*2/t-.5)*Math.PI);case"swing":return .5-Math.cos(e*Math.PI)/2;case"spring":return 1-Math.cos(e*4.5*Math.PI)*Math.exp(-e*6);case"bounce":return e<1/11?1/64-7.5625*(.5/11-e)*(.5/11-e):e<3/11?1/16-7.5625*(2/11-e)*(2/11-e):e<7/11?1/4-7.5625*(5/11-e)*(5/11-e):1-7.5625*(1-e)*(1-e);default:return e}}function yt(s,e=0,t=0){if(e===0)return 0;if(e===1)return 1;let[i,n]=s.split("-");return n==="in"?vn(i,e,t):n==="out"?1-vn(i,1-e,t):e<=.5?vn(i,2*e,t)/2:1-vn(i,2*(1-e),t)/2}function Ht(s,e,t=400,i=0,n="ease-in-out"){if(!Pn)return Object.keys(e).forEach(f=>{let v=e[f];s.css(f,Array.isArray(v)?v[1]:v)}),ps;n==="bounce-in"&&(n=Pf),n==="bounce-out"&&(n=Tf);let r="";b.isSafari&&(r=s._el.style.transition,s.css("transition","none"),b.redraw());let o=s._data.animation;o&&o.cancel();let a={},h={},l=Ke(),c=window.getComputedStyle(s._el);Object.keys(e).forEach(f=>{let v=e[f],w=nn(f);h[w]=Array.isArray(v)?v[0]:c.getPropertyValue(f),a[w]=Array.isArray(v)?v[1]:v,i&&s.css(f,h[w])});let u=a.height;if(a.height==="auto"){let f=s.children.filter(v=>v.css("position")!=="absolute");a.height=`${N(f.map(v=>v.outerHeight))}px`}let d,g=!1;Zt(()=>{g||(d=s._el.animate([h,a],{duration:t,easing:n,fill:"forwards"}),d.onfinish=()=>{s._el&&Object.keys(e).forEach(f=>s.css(f,f==="height"?u:a[f])),b.isSafari&&s.css("transition",r),l.resolve(),d.cancel(),s._data.animation=void 0})},i);let y={cancel(){g||(g=!0,s._el&&Object.keys(e).forEach(f=>s.css(f,s.css(f))),d&&d.cancel(),s._data.animation=void 0)},promise:l.promise};return setTimeout(()=>s._data.animation=y),y}var Sf=/matrix\([0-9.\-\s]+,[0-9.\-\s]+,[0-9.\-\s]+,[0-9.\-\s]+,([0-9.\-\s]+),([0-9.\-\s]+)\)/;function Ef(s,e="fade",t=500,i=0){if(s.show(),!Pn)return ps;let n=s._data.animation?1:+s.css("opacity")||1;if(e==="fade")return Ht(s,{opacity:[0,n]},t,i);if(e==="pop"){let r=s.transform.replace(/scale\([0-9.]*\)/,"").replace(Sf,"translate($1px,$2px)");return Ht(s,{opacity:[0,n]},t,i),Ht(s,{transform:[`${r} scale(0.5)`,`${r} scale(1)`]},t,i,"bounce-in")}else{if(e==="descend")return Ht(s,{opacity:[0,1],transform:["translateY(-50%)","none"]},t,i);if(e.startsWith("draw")){let r=s.strokeLength;s.css("stroke-dasharray",`${r}px`),s.css("opacity")||s.css("opacity",1);let o=e==="draw-reverse"?`${2*r}px`:0,a={"stroke-dashoffset":[`${r}px`,o]},h=Ht(s,a,t,i,"linear");return h.promise.then(()=>s.css("stroke-dasharray","")),h}else if(e.startsWith("slide")){let r={opacity:[0,n],transform:["translateY(50px)","none"]};return e.includes("down")&&(r.transform[0]="translateY(-50px)"),e.includes("right")&&(r.transform[0]="translateX(-50px)"),e.includes("left")&&(r.transform[0]="translateX(50px)"),Ht(s,r,t,i)}else if(e.startsWith("reveal")){let r={opacity:[0,n],height:[0,"auto"]};return e.includes("left")&&(r.transform=["translateX(-50%)","none"]),e.includes("right")&&(r.transform=["translateX(50%)","none"]),Ht(s,r,t,i)}}return ps}function Mf(s,e="fade",t=400,i=0,n=!1){if(!s._el)return ps;if(!Pn)return s.hide(),ps;if(s.css("display")==="none")return ps;let r;if(e==="fade")r=Ht(s,{opacity:[1,0]},t,i);else if(e==="pop"){let o=s.transform.replace(/scale\([0-9.]*\)/,"");Ht(s,{opacity:[1,0]},t,i),r=Ht(s,{transform:[`${o} scale(1)`,`${o} scale(0.5)`]},t,i,"bounce-out")}else if(e==="ascend")r=Ht(s,{opacity:[1,0],transform:["none","translateY(-50%)"]},t,i);else if(e.startsWith("draw")){let o=s.strokeLength;s.css("stroke-dasharray",o);let h={"stroke-dashoffset":[e==="draw-reverse"?`${2*o}px`:0,`${o}px`]};r=Ht(s,h,t,i,"linear")}else if(e.startsWith("slide")){let o={opacity:0,transform:"translateY(50px)"};e.includes("up")&&(o.transform="translateY(-50px)"),r=Ht(s,o,t,i)}else if(e.startsWith("reveal")){let o={opacity:0,height:0};e.includes("left")&&(o.transform="translateX(-50%)"),e.includes("right")&&(o.transform="translateX(50%)"),r=Ht(s,o,t,i)}return r.promise.then(()=>n?s.remove():s.hide()),r}var Ml={"===":(s,e)=>s===e,"!==":(s,e)=>s!==e,"||":(s,e)=>s||e,"&&":(s,e)=>s&&e,"==":(s,e)=>s==e,"!=":(s,e)=>s!=e,"<=":(s,e)=>s<=e,">=":(s,e)=>s>=e,"**":(s,e)=>s**e,"<":(s,e)=>s":(s,e)=>s>e,"+":(s,e)=>s+e,"-":(s,e)=>s-e,"*":(s,e)=>s*e,"/":(s,e)=>s/e,"%":(s,e)=>s%e},Cl={"-":s=>-s,"+":s=>+s,"!":s=>!s},bl={"||":1,"&&":2,"==":3,"!=":3,"===":3,"!==":3,"<":4,">":4,"<=":4,">=":4,"+":5,"-":5,"*":6,"/":6,"%":6,"**":7},xl={true:!0,false:!1,undefined:void 0},Cf=/\s/,Af=/[0-9]/,sa=/[a-zA-Zα-ωΑ-Ω$_]/,kf=/[0-9a-zA-Zα-ωΑ-Ω$_]/;function Vf(s){let e=s.length,t=0;function i(f){throw new Error(`${f} at character ${t} of "${s}"`)}function n(){for(;Cf.test(s[t]);)t+=1}function r(){var f;let v=((f=s.slice(t).match(/^\d*(\.\d+)?([eE][+-]?\d+)?/))==null?void 0:f[0])||"";t+=v.length;let w=s[t];return w&&(sa.test(w)||w===".")&&i(`Unexpected character (${v+w})`),{type:5,value:parseFloat(v)}}function o(){let f=s[t];t+=1;let v=!1,w="";for(;t2&&M<=bl[I[I.length-2]];)w=I.pop(),v=I.pop(),f=I.pop(),$={type:1,operator:v,left:f,right:w},I.push($);$=u(),$||i(`Expected expression after ${P}`),I.push(P,$)}let A=I.length-1;for($=I[A];A>1;)$={type:1,operator:I[A-1],left:I[A-2],right:$},A-=2;return $}function g(){let f=d();if(n(),f&&s[t]==="?"){t+=1;let v=g();if(v||i("Expected expression"),n(),s[t]===":"){t++;let w=g();return w||i("Expected expression"),{type:3,test:f,consequent:v,alternate:w}}else i("Expected :")}else return f}let y=g();return tae(y,e,t)[0]);return i.some(y=>y===void 0)?wn:[i,void 0];case 1:let n=ae(s.left,e,t)[0],r=ae(s.right,e,t)[0];return"+-**/%".includes(s.operator)&&(n===void 0||r===void 0)?wn:[Ml[s.operator](n,r),void 0];case 2:let[o,a]=ae(s.callee,e,t),h=s.args.map(y=>ae(y,e,t)[0]);return h.some(y=>y===void 0)||typeof o!="function"?wn:[o.apply(a,h),void 0];case 3:let l=ae(s.consequent,e,t),c=ae(s.alternate,e,t);return ae(s.test,e,t)[0]?l:c;case 4:return[t[s.name]||e[s.name],void 0];case 5:return[s.value,void 0];case 6:let u=ae(s.object,e,t)[0],d=s.computed?ae(s.property,e,t)[0]:s.property.name;return u?[u[d],u]:[void 0,void 0];case 7:let g=ae(s.argument,e,t)[0];return g===void 0&&s.operator!=="!"?wn:[Cl[s.operator](g),void 0]}}function ct(s){let e=Vf(s);return e?(t={},i={})=>ae(e,t,i)[0]:(t={})=>{}}var If=/\${([^}]+)}/g;function bn(s,e=!1){let t=s.split(If),i=t.map((n,r)=>r%2?ct(n.replace(/×/g,"*")):void 0);return n=>t.map((r,o)=>{if(!(o%2))return r;let a=i[o](n);return!e&&typeof a=="number"&&a<0?`\u2013${-a}`:a}).join("")}var Ti="ontouchstart"in window,zs="onpointerdown"in window;function Vt(s){if(s.touches){let e=s.targetTouches.length?s.targetTouches:s.changedTouches;return new p(e[0].clientX,e[0].clientY)}else return new p(s.clientX||0,s.clientY||0)}function Lf(s){return s.touches||[]}function me(s,e){return Vt(s).transform(e.inverseTransformMatrix)}function Al(s,e){let t=Vt(s),i=e.bounds,n=(t.x-i.left)*e.canvasWidth/i.width,r=(t.y-i.top)*e.canvasHeight/i.height;return new p(n,r)}function Of(s){if(s instanceof PointerEvent&&s.pointerType==="mouse")return k(s.target);let e=Vt(s);return k(document.elementFromPoint(e.x,e.y)||void 0)}function Rf(s){if(s._data.tapEvent)return;s._data.tapEvent=!0;let e;s.on("pointerdown",t=>e=Vt(t)),s.on("pointerup",t=>{if(!e)return;let i=Vt(t);p.distance(e,i)<6&&s.trigger("tap",t),e=void 0}),s.on("pointercancel",()=>e=void 0)}function Df(s){s._data.clickOutsideEvent||(s._data.clickOutsideEvent=!0,C.on("pointerdown",e=>{let t=e.composedPath()[0]||e.target;!t||s._el===t||s._el.contains(t)||s.trigger("clickOutside",e)}))}function ds(s,e){let t=e.$box||s,i=Vt;t.type==="svg"?i=d=>me(d,t.$ownerSVG):t.type==="canvas"&&(i=d=>Al(d,t));let n=e.justInside?s:C,r,o,a=!1,h=0;s.css("touch-action")==="auto"&&s.css("touch-action","none"),s.addClass("noselect");function l(d){d.handled||Lf(d).length>1||(d.preventDefault(),a=!1,h=d.pointerId||0,n.on("pointermove",c),n.on("pointerstop",u),r=o=i(d),e.down&&e.down(r))}function c(d){if(!r||h&&d.pointerId!==h)return;d.preventDefault();let g=i(d);p.distance(g,o)<.5||(!a&&e.start&&e.start(r),e.move&&e.move(g,r,o),o=g,a=!0)}function u(d,g=!1){r&&(h&&d.pointerId!==h||(d.preventDefault(),n.off("pointermove",c),n.off("pointerstop",u),e.up&&e.up(o,r),a&&e.end&&e.end(o,r),!a&&e.click&&!g&&e.click(r),r=void 0))}C.onKey("Escape",()=>{if(!r)return;a&&e.move&&e.move(r,r,o),o=r;let d=document.createEvent("MouseEvent");d.pointerId=h,u(d,!0)}),s.on("pointerdown",l),e.justInside&&s.on("mouseleave",u),e.accessible&&(s.setAttr("tabindex","0"),document.addEventListener("keydown",d=>{if(![37,38,39,40].includes(d.keyCode)||s!==b.getActiveInput())return;let g=s.boxCenter,y=i({clientX:g.x,clientY:g.y}),f=d.keyCode===37?-25:d.keyCode===39?25:0,v=d.keyCode===38?-25:d.keyCode===40?25:0,w=y.shift(f,v);e.down&&e.down(y),e.start&&e.start(y),e.move&&e.move(w,y,y),e.end&&e.end(w,y)}))}function kl(s,e){let t=Vt;s.type==="svg"?t=n=>me(n,s.$ownerSVG):s.type==="canvas"&&(t=n=>Al(n,s));let i=!1;s.on("touchstart mouseenter",n=>{!i&&e.enter&&e.enter(),e.move&&e.move(t(n)),i=!0},{passive:!0}),s.on("pointermove",n=>{i&&e.move&&e.move(t(n))}),s.on("touchend mouseleave",()=>{i&&e.exit&&e.exit(),i=!1},{passive:!0})}function Nf(s){if(s._data.scrollEvents)return;s._data.scrollEvents=!0;let e=!1,t;function i(){let h=s.scrollTop;if(h===t){e=!1;return}t=h,s.trigger("scroll",{top:t}),window.requestAnimationFrame(i)}function n(){e||window.requestAnimationFrame(i),e=!0}(s.type==="window"?window:s._el).addEventListener("scroll",n);function o(){window.addEventListener("touchmove",n),window.addEventListener("touchend",a)}function a(){window.removeEventListener("touchmove",n),window.removeEventListener("touchend",a)}s._el.addEventListener("touchstart",function(h){h.handled||o()})}function Bs(s,e){let t=e.$clickTarget||s,i=0,n=!1,r=!1,o=!1;function a(){n||(e.enter&&e.enter(),n=!0)}function h(){n&&(clearTimeout(i),e.exit&&e.exit(),n=!1)}s.on("mouseover",()=>{e.preventMouseover&&e.preventMouseover()||(clearTimeout(i),i=Zt(()=>{a(),r=!0},e.delay))}),s.on("mouseout",()=>{r&&(clearTimeout(i),i=Zt(h,e.exitDelay||e.delay))}),t.on("focus",()=>{n||e.preventMouseover&&e.preventMouseover()||(clearTimeout(i),a(),o=!0)});let l=()=>{o&&(e.canFocusWithin?setTimeout(()=>{let c=b.getActiveInput();c&&c.hasParent(s)?c.one("blur",l):h()}):h())};t.on("blur",l),t.on("click",()=>{n&&!r?h():n||(a(),r=!1)}),s.on("clickOutside",h)}var ia;function Gf(s){for(let e of s){let t=e.isIntersecting?"enterViewport":"exitViewport";setTimeout(()=>k(e.target).trigger(t))}}function $l(s){if(!s._data.intersectionEvents){if(s._data.intersectionEvents=!0,!window.IntersectionObserver){let e=!1;C.on("scroll",()=>{let t=s.isInViewport;e&&!t?(s.trigger("exitViewport"),e=!1):t&&!e&&(s.trigger("enterViewport"),e=!0)});return}ia||(ia=new IntersectionObserver(Gf)),ia.observe(s._el)}}function zf(s,e=!1){if(e&&(s._data.resizeObserver&&s._data.resizeObserver.disconnect(),s._data.resizeObserver=void 0),!s._data.resizeObserver){if(window.ResizeObserver){let t=new window.ResizeObserver(()=>s.trigger("resize"));t.observe(s._el),s._data.resizeObserver=t}else if(window.MutationObserver){let t=new MutationObserver(()=>s.trigger("resize"));t.observe(s._el,{attributes:!0,childList:!0,characterData:!0,subtree:!0}),s._data.resizeObserver=t}}}function Pl(s){if(s._data.pointerPositionEvents)return;s._data.pointerPositionEvents=!0;let e=s.parent,t;e.on("pointerend",()=>t=void 0),e.on("pointermove",i=>{let n=t,r=Of(i);t=r.equals(s)||r.hasParent(s),n!==void 0&&t&&!n&&s.trigger("pointerenter",i),!t&&n&&s.trigger("pointerleave",i)})}function na(s,e){e._data[`_${s}`]||(e._data[`_${s}`]=!0,zs?e.on(s.replace("mouse","pointer"),t=>{t.pointerType==="mouse"&&e.trigger(s,t)}):Ti||e._el.addEventListener(s,t=>e.trigger(s,t)))}function Bf(s){s.on("keydown",e=>{if(e.metaKey||e.ctrlKey||b.isAndroid&&e.keyCode===229)return;let t=e.key||String.fromCharCode(e.which),i=!!e.shiftKey;s.trigger("key",{code:e.keyCode,key:t,char:t,shift:i})}),b.isAndroid&&s.type==="input"&&s.on("input",e=>{let t=e.key||e.data[e.data.length-1];s.trigger("key",{code:void 0,key:t,char:t}),s.value=""})}var xn={scrollwheel:"DOMMouseScroll mousewheel",pointerdown:zs?"pointerdown":Ti?"touchstart":"mousedown",pointermove:zs?"pointermove":Ti?"touchmove":"mousemove",pointerup:zs?"pointerup":Ti?"touchend":"mouseup",pointercancel:zs?"pointercancel":"touchcancel",pointerstop:zs?"pointerup pointercancel":Ti?"touchend touchcancel":"mouseup"},$n={scroll:Nf,tap:Rf,clickOutside:Df,key:Bf,mousedown:na.bind(void 0,"mousedown"),mousemove:na.bind(void 0,"mousemove"),mouseup:na.bind(void 0,"mouseup"),pointerenter:Pl,pointerleave:Pl,enterViewport:$l,exitViewport:$l,resize:zf};function _f(s,e,t,i){if(e in $n)$n[e](s,!1);else if(e in xn){let n=K(xn[e]);for(let r of n)s._el.addEventListener(r,t,i)}else s._el.addEventListener(e,t,i)}function qf(s,e,t){if(e in $n)(!s._events[e]||!s._events[e].length)&&$n[e](s,!0);else if(t&&e in xn){let i=K(xn[e]);for(let n of i)s._el.removeEventListener(n,t)}else t&&s._el.removeEventListener(e,t)}var yn=0,ra=new Map;function Tl(s,e){ra.set(s,e)}function Ff(s){if(yn++,s(),yn--,yn===0){for(let[e,t]of ra.entries())e(t);ra.clear()}}function le(s,e){let t=new Map,i=new Map,n=new Set,r,o=0;function a(M){r=M;let P=M(A,!0);return r=void 0,P}function h(M){for(let P of t.values())P.has(M)&&P.delete(M);n.delete(M)}function l(M,P){return n.add(M),P?void 0:M(A,!0)}function c(M,P){i.has(M)&&h(i.get(M));let j=()=>{s[M]=P(A),r===j&&(r=void 0),u(M)};i.set(M,j),a(j)}function u(M){if(yn>0){for(let P of t.get(M)||[])Tl(P,s);for(let P of n)Tl(P,s)}else{for(let P of t.get(M)||[])P(s);for(let P of n)P(s)}}function d(){for(let M of t.values())for(let P of M)P(s);for(let M of n)M(s)}function g(M,P){P&&(s={}),Ff(()=>{for(let[j,ne]of Object.entries(M))j in w||(w[j]=s[j]),A[j]=ne})}function y(){for(o+=1;`_x${o}`in s;)o+=1;return`_x${o}`}function f(){s={},t.clear(),i.clear(),o=0}function v(){return Object.assign({},s)}let w={};function $(){let M=[{},{}];for(let P of Object.keys(w))w[P]!==s[P]&&(M[0][P]=w[P],M[1][P]=s[P]);return w={},M}function I(M){e&&e.watch(()=>A[M]=e[M])}let A=new Proxy(s,{get(M,P){return P==="watch"?a:P==="unwatch"?h:P==="watchAll"?l:P==="setComputed"?c:P==="forceUpdate"?d:P==="getChanges"?$:P==="assign"?g:P==="getKey"?y:P==="clear"?f:P==="copy"?v:P==="_internal"?[s,t]:(r&&(t.has(P)||t.set(P,new Set),t.get(P).add(r)),P in s||I(P),s[P])},set(M,P,j){return s[P]===j||(P in w||(w[P]=s[P]),s[P]=j,i.has(P)&&(h(i.get(P)),i.delete(P)),u(P)),!0},deleteProperty(M,P){return delete s[P],t.delete(P),i.delete(P),!0}});return A}var Hf={A:7,C:6,H:1,L:2,M:2,Q:4,S:4,T:2,V:1,Z:0},jf=/[astvzqmhlc]([^astvzqmhlc]*)/ig,Uf=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function Tn(s){let e=[],t;for(let i of s.match(jf)||[]){let n=i[0].toUpperCase();if(n==="Z"){e.push({type:"Z",points:[]});continue}let r=(i.slice(1).match(Uf)||[]).map(a=>+a),o=n===i[0];for(let[a,h]of Vo(r,Hf[n]).entries()){let l=[],c=n==="M"&&a>0?"L":n,u;n==="H"?(c="L",l=[new p(h[0],o&&(t==null?void 0:t.y)||0)]):n==="V"?(c="L",l=[new p(o&&(t==null?void 0:t.x)||0,h[0])]):n==="A"?(c="A",l=[new p(h[5],h[6])],u=h.slice(0,5)):"MLCSQT".includes(n)&&(l=Vo(h,2).map(d=>new p(d[0],d[1]))),!o&&t&&(l=l.map(d=>d.translate(t))),t=O(l),e.push({type:c,points:l,options:u})}}return e}function oa(s){return s?Tn(s).map(t=>O(t.points)).filter(t=>!!t):[]}var Wf=["font-family","font-size","font-style","font-weight","letter-spacing","text-decoration","color","display","visibility","alignment-baseline","baseline-shift","opacity","text-anchor","clip","clip-path","clip-rule","mask","filter","transform","transform-origin","white-space","line-height"],Kf=["fill","fill-rule","marker","marker-start","marker-mid","marker-end","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-width","text-rendering","dominant-baseline","transform-box","paint-order"],Xf=["padding","min-width","max-width","height","border-width","border-style","border-color","box-sizing","background","width","grid-template-columns","text-align"],Yf=["class","tabindex","contenteditable"],Zf=new Set(["opacity","transform-box","transform-origin","border-width","border-style","border-color"]),Qf={"font-style":"normal","font-weight":"400","letter-spacing":"normal","text-decoration":"none",display:"block",visibility:"visible","alignment-baseline":"auto","baseline-shift":"0px","text-anchor":"start",clip:"auto","clip-path":"none","clip-rule":"nonzero",mask:"none",opacity:"1",filter:"none",fill:"rgb(0, 0, 0)","fill-rule":"nonzero",marker:"none",stroke:"none","stroke-dasharray":"none","stroke-dashoffset":"0px","stroke-linecap":"butt","stroke-linejoin":"miter","stroke-width":"1px","text-rendering":"auto",transform:"none","dominant-baseline":"auto","transform-origin":"0px 0px","transform-box":"view-box","paint-order":"normal"};function Vl(s){var e,t;if(s.getAttribute("hidden")||s.style.opacity==="0"||s.style.display==="none")(e=s.parentNode)==null||e.removeChild(s);else{for(let i of Array.from(s.children))Vl(i);if(s.tagName==="g"&&s.childElementCount===0)(t=s.parentNode)==null||t.removeChild(s);else for(let i of Yf)s.hasAttribute(i)&&s.removeAttribute(i)}}function Jf(s,e){let t=s.parentElement;for(;t;){let i=t.style.getPropertyValue(e);if(i)return i;t=t.parentElement}}function Il(s,e,t=!1){let i=window.getComputedStyle(s);e.removeAttribute("style");let n=t||s.tagName==="foreignObject",r=[...Wf,...n?Xf:Kf];for(let h of r){let l=i.getPropertyValue(h),c=Jf(e,h);l===Qf[h]&&!c||!Zf.has(h)&&l===c||e.style.setProperty(h,l)}let o=s.children,a=e.children;for(let h=0;hi.textContent=n(s)||"")}}else e&&i.bindModel(s)}}bindVariable(s,e){}toggleDOM(s=!0){s!==!!this._el.parentNode&&(this.$placeholder||(this.$placeholder=k(document.createComment("")),this.insertBefore(this.$placeholder)),s?this.$placeholder.insertBefore(this):this.detach())}makeDynamicAttribute(s,e,t){if(s.startsWith("@")){let i=s.slice(1),n=ct(e);this.on(i,r=>n(t,{$event:r}))}else if(s===":show"){let i=ct(e);t.watch(()=>this.toggle(!!i(t)))}else if(s===":if"){let i=ct(e);t.watch(()=>this.toggleDOM(!!i(t)))}else if(s===":html"){let i=ct(e);t.watch(()=>this.html=i(t)||"")}else if(s===":draw"){let i=ct(e);t.watch(()=>this.draw(i(t)))}else if(s===":class"){let i=ct(e),n=`${this.attr("class")} `;t.watch(()=>this.setAttr("class",n+i(t)))}else if(s===":bind")this.bindVariable(t,e);else if(s.startsWith(":")){let i=ct(e),n=s.slice(1);t.watch(()=>this.setAttr(n,i(t)))}else if(e.includes("${")){let i=bn(e,!0);t.watch(()=>this.setAttr(s,i(t)||""))}(s.startsWith("@")||s.startsWith(":"))&&this.removeAttr(s)}makeDynamicList(s){let[e,t]=this.attr(":for").split(" in ");this.removeAttr(":for");let i=ct(t),n=k(document.createComment(""));this.insertBefore(n),this.detach();let r=[],o=0;s.watch(()=>{let a=i(s);Array.isArray(a)||(a=[]);for(let h=a.length;h{let o=i+n*yt(t,r);this.scrollTop=o,this.trigger("scroll",{top:o})},e)}scrollBy(s,e=1e3,t="cubic"){s&&this.scrollTo(this.scrollTop+s,e,t)}css(s,e){if(e===void 0){if(typeof s=="string")return window.getComputedStyle(this._el).getPropertyValue(s);{let t=Object.keys(s);for(let i of t)this._el.style.setProperty(i,`${s[i]}`)}}else typeof s=="string"&&this._el.style.setProperty(s,`${e}`)}get transform(){return this.css("transform").replace("none","")}get transformMatrix(){let s=this.transform;if(!s)return[[1,0,0],[0,1,0]];let e=s.match(/matrix\(([0-9,.\s-]*)\)/);if(!e||!e[1])return[[1,0,0],[0,1,0]];let t=e[1].split(",");return[[+t[0],+t[2],+t[4]],[+t[1],+t[3],+t[5]]]}get scale(){let s=this.transformMatrix;return[s[0][0],s[1][1]]}setTransform(s,e=0,t=1){let i="";s&&(i+=`translate(${Pt(s.x,.1)}px,${Pt(s.y,.1)}px)`),e&&(i+=` rotate(${e}rad)`),t&&(i+=` scale(${t})`),this._el.style.transform=i}translate(s,e){this.setTransform(new p(s,e))}show(){this.hasAttr("hidden")&&this.removeAttr("hidden"),this.data.display==="visibility"?this._el.style.visibility="visible":this._el.style.display=this.data.display||"block"}hide(){this.data.display==="visibility"?this._el.style.visibility="hidden":this._el.style.display="none"}toggle(s){s?this.show():this.hide()}is(s){return this._el.matches?this._el.matches(s):Array.from(document.querySelectorAll(s)).includes(this._el)}index(){let s=0,e=this._el;for(;(e=e.previousSibling||void 0)!==void 0;)++s;return s}prepend(s){let e=this._el.childNodes;e.length?this._el.insertBefore(s._el,e[0]):this._el.appendChild(s._el)}append(s){this._el.appendChild(s instanceof Text?s:s._el)}insertBefore(s){this.parent._el.insertBefore(s._el,this._el)}insertAfter(s){let e=this._el.nextSibling;e?this.parent._el.insertBefore(s._el,e):this.parent._el.appendChild(s._el)}get next(){return k(this._el.nextSibling)}get prev(){return k(this._el.previousSibling)}$(s){return k(s,this)}$$(s){return Te(s,this)}get parent(){return k(this._el.parentElement||void 0)}parents(s){let e=[],t=this.parent;for(;t;)(!s||t.is(s))&&e.push(t),t=t.parent;return e}hasParent(...s){let e=s.map(i=>i._el),t=this._el.parentNode;for(;t;){if(_(t,...e))return!0;t=t.parentNode}return!1}get children(){return Array.from(this._el.children||[],s=>k(s))}get childNodes(){return Array.from(this._el.childNodes,s=>{if(!(s instanceof Comment))return s instanceof Text?s:k(s)}).filter(s=>s)}restartAnimation(){let s=this.next,e=this.parent;this.detach(),s?s.insertBefore(this):e.append(this)}detach(){this._el&&this._el.parentNode&&this._el.parentNode.removeChild(this._el)}remove(){this.detach()}removeChildren(){for(;this._el.firstChild;)this._el.removeChild(this._el.firstChild)}copy(s=!0){return k(this._el.cloneNode(s))}on(s,e,t){for(let i of K(s))i in this._events?this._events[i].includes(e)||this._events[i].push(e):this._events[i]=[e],_f(this,i,e,t)}one(s,e,t){let i=n=>{this.off(s,i),e(n)};this.on(s,i,t)}off(s,e){for(let t of K(s))t in this._events&&(this._events[t]=e?this._events[t].filter(i=>i!==e):[]),qf(this,t,e)}trigger(s,e={}){for(let t of K(s)){if(!this._events[t])return;for(let i of this._events[t])i.call(this,e)}}onKey(s,e,t){s=s.replace("AllArrows","ArrowUp ArrowDown ArrowLeft ArrowRight");let i=new Set(K(s)),n=t!=null&&t.up?"keyup":"keydown";(this._el===document.body?document:this._el).addEventListener(n,o=>{var a,h;let l=Ei(o);(t!=null&&t.meta?!o.ctrlKey&&!o.metaKey:o.ctrlKey||o.metaKey)||!l||!i.has(l)||document.activeElement!==this._el&&((h=(a=document.activeElement)==null?void 0:a.shadowRoot)==null?void 0:h.activeElement)!==this._el&&b.formIsActive||e(o,l)})}onAttr(s,e){new MutationObserver(i=>{for(let n of i)n.type==="attributes"&&n.attributeName===s&&e(this.attr(s))}).observe(this._el,{attributes:!0}),e(this.attr(s),!0)}onPromise(s,e=!1){return e?Promise.resolve():new Promise(t=>this.one(s,()=>t()))}animate(s,e=400,t=0,i="ease-in-out"){return Ht(this,s,e,t,i)}enter(s="fade",e=500,t=0){return Ef(this,s,e,t)}exit(s="fade",e=500,t=0,i=!1){return Mf(this,s,e,t,i)}effect(s){this.one("animationend",()=>this.removeClass(`effects-${s}`)),this.addClass(`effects-${s}`)}},us=class extends Ll{get offsetTop(){return this._el.offsetTop}get offsetLeft(){return this._el.offsetLeft}get offsetParent(){return k(this._el.offsetParent||void 0)}get width(){return this._el.offsetWidth}get height(){return this._el.offsetHeight}get innerWidth(){let s=parseFloat(this.css("padding-left")),e=parseFloat(this.css("padding-right"));return this._el.clientWidth-s-e}get innerHeight(){let s=parseFloat(this.css("padding-bottom")),e=parseFloat(this.css("padding-top"));return this._el.clientHeight-s-e}get outerWidth(){let s=parseFloat(this.css("margin-left")),e=parseFloat(this.css("margin-right"));return this.width+s+e||0}get outerHeight(){let s=parseFloat(this.css("margin-bottom")),e=parseFloat(this.css("margin-top"));return this.height+s+e||0}get positionTop(){let s=this._el,e=0;for(;s;)e+=s.offsetTop,s=s.offsetParent;return e}get positionLeft(){let s=this._el,e=0;for(;s;)e+=s.offsetLeft,s=s.offsetParent;return e}offset(s){if(s._el===this._el.offsetParent){let e=this.offsetTop+s._el.clientTop,t=this.offsetLeft+s._el.clientLeft,i=e+this.height,n=t+this.width;return{top:e,left:t,bottom:i,right:n}}else{let e=s._el.getBoundingClientRect(),t=this._el.getBoundingClientRect();return{top:t.top-e.top,left:t.left-e.left,bottom:t.bottom-e.top,right:t.right-e.left}}}},Ol=class extends Ll{constructor(){super(...arguments),this.type="svg"}get $ownerSVG(){return k(this._el.ownerSVGElement||void 0)}get width(){return this.bounds.width}get height(){return this.bounds.height}get positionLeft(){let s=this._el.getBBox().x+this._el.getCTM().e;return this.$ownerSVG.positionLeft+s}get positionTop(){let s=this._el.getBBox().y+this._el.getCTM().f;return this.$ownerSVG.positionTop+s}get inverseTransformMatrix(){let s=this._el.getScreenCTM().inverse(),e=[[s.a,s.c,s.e],[s.b,s.d,s.f]];if(b.isFirefox){let t=this.transformMatrix;e[0][2]-=t[0][2],e[1][2]-=t[1][2]}return e}setTransform(s,e=0,t=1){let i=s?`translate(${Pt(s.x,.1)} ${Pt(s.y,.1)})`:"",n=x(e,0)?"":`rotate(${e*180/Math.PI})`,r=x(t,1)?"":`scale(${t})`;this.setAttr("transform",[i,n,r].join(" "))}get strokeLength(){if(this._el instanceof SVGGeometryElement)return this._el.getTotalLength();{let s=this.bounds;return 2*s.height+2*s.width}}getPointAtLength(s){if(this._el instanceof SVGGeometryElement){let e=this._el.getPointAtLength(s);return new p(e.x,e.y)}else return new p(0,0)}getPointAt(s){return this.getPointAtLength(s*this.strokeLength)}get points(){return oa(this.attr("d"))}set points(s){let e=s.length?`M${s.map(t=>`${t.x},${t.y}`).join("L")}`:"";this.setAttr("d",e)}addPoint(s){let e=`${this.attr("d")} L ${s.x},${s.y}`;this.setAttr("d",e)}get center(){let s=+this.attr(this.tagName==="TEXT"?"x":"cx"),e=+this.attr(this.tagName==="TEXT"?"y":"cy");return new p(s,e)}setCenter(s){this.setAttr(this.tagName==="TEXT"?"x":"cx",s.x),this.setAttr(this.tagName==="TEXT"?"y":"cy",s.y)}setLine(s,e){this.setAttr("x1",s.x),this.setAttr("y1",s.y),this.setAttr("x2",e.x),this.setAttr("y2",e.y)}setRect(s){this.setAttr("x",s.p.x),this.setAttr("y",s.p.y),this.setAttr("width",s.w),this.setAttr("height",s.h)}draw(s,e={}){if(!s)return this.setAttr("d","");let t={};for(let i of["mark","arrows","round"])this.hasAttr(i)&&(t[i]=this.attr(i));this.hasClass("fill")&&(t.fill="fill"),this.hasAttr("size")&&(t.size=+this.attr("size")||void 0),this.setAttr("d",De(s,Object.assign(e,t)))}},tm=class extends Ol{get viewBox(){return this._el.viewBox.baseVal||{width:0,height:0}}get $ownerSVG(){return this}get positionLeft(){return parseInt(this.css("margin-left"))+this.parent.positionLeft}get positionTop(){return parseInt(this.css("margin-top"))+this.parent.positionTop}get svgWidth(){return this.viewBox.width||this.width}get svgHeight(){return this.viewBox.height||this.height}drawPath(s,e={},t={}){let i=m("path",e,this);return i.draw(s,t),i}image(s,e,t,i){return he(this,null,function*(){let n=this.copy(!0);Il(this._el,n._el),s==="svg"&&Vl(n._el),t||(t=e||this.svgHeight),e||(e=this.svgWidth),n.setAttr("width",e),n.setAttr("height",t),n.setAttr("viewBox",i||this.attr("viewBox")||`0 0 ${this.svgWidth} ${this.svgHeight}`),n.setAttr("xmlns","http://www.w3.org/2000/svg");let r=n.$$("image");if(s==="svg")for(let c of r)c.setAttr("href",new URL(c.attr("href"),location.href));else yield Promise.all(r.map(c=>he(this,null,function*(){c.setAttr("href",yield om(c.attr("href")))})));let o=new XMLSerializer().serializeToString(n._el),a=`data:image/svg+xml;utf8,${encodeURIComponent(o)}`;if(s==="svg")return a;let h=m("canvas",{width:e,height:t});s==="jpg"&&(h.ctx.fillStyle="white",h.ctx.fillRect(0,0,e,t));let l=yield Gl(a);return h.ctx.drawImage(l,0,0,e,t),h.image(s)})}downloadImage(s,e,t,i){let n=b.isIOS?window.open("","_blank"):void 0,r=b.theme.isDark;r&&b.setTheme("light");let o=s.endsWith(".jpg")?"jpg":s.endsWith(".svg")?"svg":"png",a=this.image(o,e,t,i);r&&b.setTheme("dark"),a.then(h=>{if(n)return n.location.href=h;m("a",{download:s,href:h,target:"_blank"})._el.dispatchEvent(new MouseEvent("click",{view:window,bubbles:!1,cancelable:!0}))})}},Rl=class extends us{constructor(){super(...arguments),this.type="window"}get width(){return window.innerWidth}get height(){return window.innerHeight}get innerWidth(){return window.innerWidth}get innerHeight(){return window.innerHeight}get outerWidth(){return window.outerWidth}get outerHeight(){return window.outerHeight}get scrollWidth(){return document.body.scrollWidth}get scrollHeight(){return document.body.scrollHeight}get scrollTop(){return window.pageYOffset}set scrollTop(s){document.body.scrollTop=document.documentElement.scrollTop=s,this.trigger("scroll",{top:s,left:this.scrollLeft})}get scrollLeft(){return window.pageXOffset}set scrollLeft(s){document.body.scrollLeft=document.documentElement.scrollLeft=s,this.trigger("scroll",{top:this.scrollTop,left:s})}},em=class extends us{constructor(){super(...arguments),this.type="form"}get action(){return this._el.action}get formData(){let s={};for(let e of Array.from(this._el.elements)){let t=e.name||e.id;t&&(s[t]=e.value)}return s}get isValid(){return this._el.checkValidity()}},sm=class extends us{constructor(){super(...arguments),this.type="input"}get checked(){return this._el.checked||!1}set checked(s){this._el.checked=s}get value(){return this._el.value}set value(s){this._el.value=s}bindVariable(s,e){if(this._el.type==="checkbox"){let t=e.startsWith("!"),i=n=>t?!n:n;t&&(e=e.slice(1)),s[e]!==void 0?this.checked=i(s[e]):this.hasAttr("checked")&&(s[e]=i(this.checked)),this.on("change",()=>s[e]=i(this.checked)),s.watch(()=>this.checked=i(s[e]));return}if(this._el.type==="number"){let t=this.hasAttr("min")?+this.attr("min"):-1/0,i=this.hasAttr("max")?+this.attr("max"):1/0;this.change(n=>{n&&(s[e]=B(+n,t,i))})}else this.change(t=>s[e]=t);s[e]!==void 0?this.value=s[e]:this.value&&(s[e]=this.value),this.on("blur",()=>this.value=s[e]),s.watch(()=>{document.activeElement!==this._el&&(this.value=s[e])})}setInputPattern(s){if(isNaN(+s))return;let e=s.match(/^[0-9]+$/);this.setAttr("inputmode",e?"numeric":"decimal"),e&&this.setAttr("pattern","[0-9]*")}change(s){let e=this.value||"";this.on("focus",()=>e=this.value),this.on("change keyup input paste",()=>{this.value!==e&&(e=this.value,s(e))})}validate(s){this.change(e=>this.setValidity(s(e)))}setValidity(s){this._el.setCustomValidity(s)}get isValid(){return this._el.checkValidity()}},im=class extends us{constructor(){super(...arguments),this.type="canvas"}getContext(s="2d",e={}){return this._el.getContext(s,e)}image(s="png"){return this._el.toDataURL(s==="png"?"image/png":"image/jpeg")}get canvasWidth(){return this._el.width}get canvasHeight(){return this._el.height}get ctx(){return this._ctx||(this._ctx=this.getContext()),this._ctx}draw(s,e={}){this.ctx.save(),Jo(this.ctx,s,e),this.ctx.restore()}clear(){this.ctx.clearRect(0,0,this.canvasWidth,this.canvasHeight)}fill(s){this.ctx.save(),this.ctx.fillStyle=s,this.ctx.fillRect(0,0,this.canvasWidth,this.canvasHeight),this.ctx.restore()}clearCircle(s,e){this.ctx.save(),this.ctx.globalCompositeOperation="destination-out",this.ctx.beginPath(),this.ctx.arc(s.x,s.y,e,0,2*Math.PI,!1),this.ctx.fill(),this.ctx.restore()}downloadImage(s){let e=this.image(s.endsWith(".jpg")?"jpg":"png");m("a",{download:s,href:e,target:"_blank"})._el.dispatchEvent(new MouseEvent("click",{view:window,bubbles:!1,cancelable:!0}))}},nm=class extends us{play(){return this._el.play()||Promise.resolve()}pause(){return this._el.pause()}},Dl=["path","rect","circle","ellipse","polygon","polyline","g","defs","marker","line","text","tspan","pattern","mask","svg","foreignObject","image","use","clipPath"];function k(s,e){if(!s)return;let t=e?e._el:document.documentElement,i=typeof s=="string"?t.querySelector(s):s;if(!i)return;if(i._view)return i._view;let n=(i.tagName||"").toLowerCase();return n==="svg"?new tm(i):n==="canvas"?new im(i):n==="form"?new em(i):n==="input"||n==="select"||n==="textarea"?new sm(i):n==="video"||n==="audio"?new nm(i):Dl.includes(n)?new Ol(i):new us(i)}function Te(s,e){let t=e?e._el:document.documentElement,i=s?t.querySelectorAll(s):[];return Array.from(i,n=>k(n))}function m(s,e={},t){let i=Dl.includes(s)?document.createElementNS("http://www.w3.org/2000/svg",s):document.createElement(s);for(let[r,o]of Object.entries(e))o!==void 0&&(r==="id"?i.id=o:r==="html"?i.innerHTML=o:r==="text"?i.textContent=o:r==="path"?i.setAttribute("d",De(o)):i.setAttribute(r,o));let n=k(i);return t&&t.append(n),n}var C=new Rl(document.body),Xt=new Rl(document.documentElement);function rm(s){let e=[];for(let t of Object.keys(s)){let i=s[t];if(t=encodeURIComponent(t),i==null){e.push(t);continue}i=Array.isArray(i)?i.join(","):`${i}`,i=i.replace(/(\r)?\n/g,`\r +`),i=encodeURIComponent(i),i=i.replace(/%20/g,"+"),e.push(`${t}=${i}`)}return e.join("&")}function Nl(s){s=s.replace(/^[?,&]/,"");let e=decodeURIComponent(s).split("&"),t={};return e.forEach(i=>{let n=i.split("=");t[n[0]]=n[1]}),t}function Ne(s,e){return he(this,null,function*(){let t=e instanceof FormData,i={method:"POST",body:t?e:e?rm(e):void 0,headers:{"X-CSRF-Token":window.csrfToken||""}};t||(i.headers["Content-Type"]="application/x-www-form-urlencoded");let n=s.includes("?")?"&xhr=1":"?xhr=1",r=yield fetch(s+n,i);if(!r.ok)throw new Error(`Fetch error ${r.status}: ${s}`);return r.text()})}function Gl(s,e=!1){return new Promise(t=>{let i=new Image;e||(i.crossOrigin="Anonymous"),i.onload=()=>t(i),i.src=s})}var om=Oe(s=>he(void 0,null,function*(){let e=yield Gl(s),t=m("canvas",{width:e.width,height:e.height});return t.ctx.drawImage(e,0,0,e.width,e.height),t.image("png")})),Si=new Map;function zl(s,e){Si.has(s)?Ao(Si.get(s),e,(t,i)=>Wt(t.concat(i))):Si.set(s,e)}function Bl(){if(window.navigator.onLine)for(let[s,e]of Si)Si.delete(s),Ne(s,{data:JSON.stringify(e)}).catch(t=>{console.error("Failed to send POST request:",t),zl(s,e)})}var _l=ve(Bl,5e3);window.addEventListener("online",_l);window.onbeforeunload=Bl;function ql(s,e){zl(s,e),_l()}var ee=class{constructor(s,e=1,t=!0){this.src=s,this.defaultVolume=e,this.player=new Audio,this.player.src=s,t&&(this.player.preload="auto")}play(s){this.player.currentTime=0,this.player.volume=s||this.defaultVolume,this.player.play()}},am=os(["#cd0e66","#0f82f2","#22ab24","#fd8c00"]),hm=class{constructor(s){this.index=s,this.color=am(),this.tilt=Math.floor(Math.random()*10)-10,this.tiltAngleIncrement=Math.random()*.07+.05,this.tiltAngle=0,this.x=Math.random()*b.width,this.y=(Math.random()-1)*b.height,this.r=_t.uniform(10,30)}draw(s){s.beginPath(),s.lineWidth=this.r/2,s.strokeStyle=this.color,s.moveTo(this.x+this.tilt+this.r/4,this.y),s.lineTo(this.x+this.tilt,this.y+this.tilt+this.r/4),s.stroke()}update(s,e){this.tiltAngle+=this.tiltAngleIncrement,this.y+=(Math.cos(s)+3+this.r/2)/2,this.x+=Math.sin(s),this.tilt=Math.sin(this.tiltAngle-this.index/3)*15,this.x<-20?(this.x=-20,this.y=Math.random()*b.height,this.tilt=Math.floor(Math.random()*10)-20):this.x>b.width+20?(this.x=b.width+20,this.y=Math.random()*b.height,this.tilt=Math.floor(Math.random()*10)-20):e&&this.y>b.height&&(this.x=Math.random()*b.width,this.y=-10,this.tilt=Math.floor(Math.random()*10)-20)}},lm="position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 9999",cs=void 0;function Mi(s=2e3,e=150){cs||(cs=m("canvas",{style:lm},C)),cs.setAttr("width",b.width),cs.setAttr("height",b.height),cs.show();let t=cs.ctx,i=z(r=>new hm(r),e),n=pt(r=>{t.clearRect(0,0,b.width,b.height);let o=rthis.updateBounds()),ds(s,{start:()=>{this.disabled||(this.startPos=this.position,this.trigger("start"),Xt.addClass("grabbing"))},move:(t,i)=>{this.disabled||(this.setPosition(this.startPos.x+t.x-i.x,this.startPos.y+t.y-i.y),this.trigger("drag",{posn:this.position,pointerPosn:t}),this.checkTarget(t))},end:(t,i)=>{this.disabled||(this.trigger(t.equals(i)?"click":"end",{$target:this.$over}),this.options.$targets&&!this.$over&&this.options.resetOnMiss&&this.resetPosition(),this.$over=void 0,Xt.removeClass("grabbing"))},click:()=>this.trigger("click"),accessible:!0})}addTarget(s){var e;this.options.$targets||(this.options.$targets=[]),(e=this.options.$targets)==null||e.push(s)}removeTarget(s){var e,t;this.options.$targets=(e=this.options.$targets)==null?void 0:e.filter(i=>i!==s),(t=this.options.$targets)!=null&&t.length||(this.options.$targets=void 0)}checkTarget(s){if(!this.options.$targets)return;let e=this.options.$targets.find(t=>t.boundsRect.contains(s));e!==this.$over&&(this.$over&&this.trigger("exit-target",{$target:this.$over}),e&&this.trigger("enter-target",{$target:e}),this.$over=e)}updateBounds(){if(!this.options.withinBounds)return this.bounds=void 0;if(this.options.bounds)return this.bounds=this.options.bounds;let s=this.bounds,e=this.options.$parent||this.$el.parent,t=e.type==="svg"?e.svgWidth:e.width,i=e.type==="svg"?e.svgHeight:e.height;this.bounds=new lt(0,t,0,i),!t&&!i&&setTimeout(()=>this.updateBounds()),s&&this.setPosition(this.position.x*this.bounds.dx/s.dx||0,this.position.y*this.bounds.dy/s.dy||0)}setPosition(s,e){var t;let i=new p(this.options.moveX?s:0,this.options.moveY?e:0);this.bounds&&(i=i.clamp(this.bounds,(t=this.options.margin)!=null?t:0)),i=i.round(this.options.snap||1),this.options.round&&(i=this.options.round(i)),!i.equals(this.position)&&(this.position=i,this.options.useTransform?this.$el.translate(i.x,i.y):(this.options.moveX&&this.$el.css("left",`${i.x}px`),this.options.moveY&&this.$el.css("top",`${i.y}px`)),this.trigger("move",{posn:i}))}resetPosition(s=250){return he(this,null,function*(){let e=this.position;this.$el.css({"pointer-events":"none"}),yield pt(t=>{let i=p.interpolate(e,this.startPos,t);this.setPosition(i.x,i.y)},s).promise,this.$el.css({"pointer-events":"initial"})})}},cm="position: fixed; top: 0; left: 0; width: 100%; height: 4px; background: #0f82f2; pointer-events: none; z-index: 9999; will-change: transform;";function Sl(s,e){let t=e.regex.exec(s);if(t){t.shift();let i={};for(let[n,r]of e.params.entries())i[r]=t[n];return i}else return}function pm(s,e,t){return he(this,null,function*(){return s.template?typeof s.template=="string"?s.template:s.template(e):(yield fetch(t+(t.indexOf("?")>=0?"&xhr=1":"?xhr=1"))).text()})}var Fl=document.readyState==="complete";window.addEventListener("load",()=>setTimeout(()=>Fl=!0));"scrollRestoration"in window.history&&(window.history.scrollRestoration="manual");var dm=class extends Re{constructor(){super(...arguments),this.$viewport=C,this.views=[],this.active={path:"",hash:""},this.preloaded=!1,this.transition=!1,this.noLoad=!1,this.initialise=()=>{}}setup(s={}){s.$viewport&&(this.$viewport=s.$viewport),s.initialise&&(this.initialise=s.initialise),s.preloaded&&(this.preloaded=s.preloaded),s.transition&&(this.transition=s.transition),s.noLoad&&(this.noLoad=s.noLoad),s.click&&C.on("click",e=>this.onLinkClick(e)),s.history&&window.addEventListener("popstate",e=>he(this,null,function*(){var t;if(!Fl||!((t=e.state)!=null&&t.path))return;(yield this.load(e.state.path,e.state.hash))||window.history.pushState(this.active,"",this.active.path+this.active.hash)}))}view(s,{enter:e,exit:t,template:i}={}){let n=(s.match(/:\w+/g)||[]).map(u=>u.substr(1)),r=`${s.replace(/:\w+/g,"([\\w-]+)").replace("/","\\/")}\\/?`,o=s.includes("?")?"":"(\\?.*)?",h={regex:new RegExp(`^${r}${o}$`,"i"),params:n,enter:e,exit:t,template:i};this.views.push(h);let l=window.location.pathname+window.location.search,c=Sl(l,h);c&&(this.active={path:l,hash:window.location.hash},window.history.replaceState(this.active,"",this.active.path+this.active.hash),b.ready(()=>{setTimeout(()=>{this.preloaded?(this.initialise(this.$viewport,c),h.enter&&h.enter(this.$viewport,c)):this.loadView(h,c)})}))}paths(...s){for(let e of s)this.view(e)}getView(s){for(let e of this.views){let t=Sl(s,e);if(t)return{view:e,params:t}}}load(s,e){return he(this,null,function*(){if(s===this.active.path&&e!==this.active.hash)return this.trigger("hashChange",e.slice(1)),this.trigger("change",s+e),this.active={path:s,hash:e},!0;let t=this.getView(s);return!t||this.beforeChange&&!(yield this.beforeChange())?!1:(this.active={path:s,hash:e},this.trigger("change",s+e),window.ga&&window.ga("send","pageview",s+e),this.noLoad?t.view.enter&&t.view.enter(this.$viewport,t.params):this.loadView(t.view,t.params),!0)})}loadView(s){return he(this,arguments,function*(e,t={}){this.showLoadingBar();let i=this.active.path,n=yield pm(e,t,i);if(this.active.path!==i)return;yield this.$viewport.animate({opacity:0},200).promise,this.$viewport.removeChildren(),C.scrollTop=0,this.$viewport.html=n,b.resize(),xf(),this.$viewport.animate({opacity:1},200),this.hideLoadingBar();let r=this.$viewport.$("title");r&&(document.title=r.text),this.initialise(this.$viewport,t),e.enter&&e.enter(this.$viewport,t),this.trigger("afterChange",{$viewport:this.$viewport})})}onLinkClick(s){if(s.metaKey||s.ctrlKey||s.shiftKey||s.defaultPrevented)return;let e=s.target;for(;e&&e.nodeName!=="A";)e=e.parentNode;if(!e||e.nodeName!=="A")return;let t=e;if(t.target||t.origin!==window.location.origin||t.hasAttribute("download")||t.getAttribute("rel")==="external")return;let i=t.getAttribute("href");i&&i.indexOf("mailto:")>-1||this.getView(t.pathname+t.search)&&(s.preventDefault(),this.goTo(t.pathname+t.search,t.hash))}goTo(s,e=""){return he(this,null,function*(){let t=this.active.path+this.active.hash;(yield this.load(s,e))&&t!==this.active.path+this.active.hash&&window.history.pushState(this.active,"",s+e)})}replace(s,e=""){this.active={path:s,hash:e},window.history.replaceState(this.active,"",s+e)}back(){window.history.back()}forward(){window.history.forward()}showLoadingBar(){this.$loadingBar||(this.$loadingBar=m("div",{style:cm},C)),this.$loadingBar.css({transform:"translateX(-100%)",opacity:1}),this.$loadingBar.show(),this.animation=pt(s=>{this.$loadingBar.css("transform",`translateX(-${10+90*Math.exp(-4*s)}%)`)},3e3)}hideLoadingBar(){return he(this,null,function*(){var s,e,t;(s=this.animation)==null||s.cancel(),yield(e=this.$loadingBar)==null?void 0:e.animate({transform:"none",opacity:0}).promise,(t=this.$loadingBar)==null||t.hide()})}},Ci=new dm;function um(s,e){let t=Array.from(s.childNodes);s.innerHTML=e;let i={};for(let n of Array.from(s.querySelectorAll("slot")))i[n.getAttribute("name")||""]=n;for(let n of t){let r=n.getAttribute&&n.getAttribute("slot")||"",o=i[r]||i[""];o&&o.parentNode.insertBefore(n,o)}for(let n of Object.values(i))n.parentNode.removeChild(n)}function*Hl(s){for(let e of Array.from(s.children))e.tagName.includes("-")?yield e:yield*ks(uf(Hl(e)))}var jl=new Map,fm=class extends HTMLElement{constructor(){super(...arguments),this.wasConnected=!1,this.isReady=!1}connectedCallback(){return he(this,null,function*(){if(this.wasConnected){this._view.trigger("connected");return}this.wasConnected=!0,this.isReady=!1,this._view.created();let s=jl.get(this._view.tagName)||{};s.template&&um(this,s.template);let e=[...Hl(this)].filter(t=>!t.isReady).map(t=>new Promise(i=>t.addEventListener("ready",i)));setTimeout(()=>{this.isReady||console.error(`Children of custom element ${this.tagName} not ready after 1s.`)},1e3),yield Promise.all(e),this._view.ready(),this.dispatchEvent(new CustomEvent("ready")),this.isReady=!0})}disconnectedCallback(){this._view.trigger("disconnected")}},E=class extends us{created(){}ready(){}},mm=new Map;function S(s,e={}){return function(t){if(window.customElements.get(s)){console.warn(`Trying to declare the custom element ${s} twice!`);return}class i extends fm{constructor(){super(),this._view=new t(this)}}mm.set(s,t),jl.set(s.toUpperCase(),e),window.customElements.define(s,i)}}var Sn=class{constructor(e){this.clipEndTime=0;this.player=new Audio(e),this.player.preload="true",this.player.addEventListener("timeupdate",()=>{this.player.currentTime>=this.clipEndTime&&this.triggerCallback(!0)}),window.addEventListener("beforeunload",()=>this.player.pause())}playClip(e,t,i){this.triggerCallback(!1),this.player.currentTime=e,this.clipEndTime=t,this.clipCallback=i,this.player.play()}triggerCallback(e){if(!this.clipCallback)return;let t=this.clipCallback;this.clipCallback=void 0,this.player.pause(),t({ended:e})}pause(){this.triggerCallback(!1)}get isPlaying(){return!!this.clipCallback}},ha=!1,aa,En=class{constructor(e,t){this.audio=e;this.paragraphs=[];this.paragraphs=t.$$(".voice").map(i=>new la(i,e));for(let[i,n]of this.paragraphs.entries())n.on("end",()=>{var r;if(this.paragraphs[i+1])this.paragraphs[i+1].play();else{let o=t.nextStep;o&&o.isShown&&((r=o.narration)==null||r.play())}})}play(){var e;this.audio.isPlaying||!ha||(e=this.paragraphs[0])==null||e.play()}},la=class extends Re{constructor(t,i){super();this.$p=t;this.audio=i;this.playing=void 0;this.sentences=t.$$(".sentence[data-timings]").map(n=>new ca(n,i)),this.$button=m("button",{class:"playback-btn",title:"Play Narration"}),this.$button.on("click",()=>{this.playing?this.audio.pause():this.play(),ha=!ha,aa=void 0}),t.prepend(this.$button),t.addClass("sentence-wrap");for(let[n,r]of this.sentences.entries())r.on("end",o=>{this.playing=void 0,o&&this.sentences[n+1]?setTimeout(()=>this.play(this.sentences[n+1]),200):(this.$button.removeClass("active"),o&&setTimeout(()=>this.trigger("end"),400))})}play(t){let i=t||this.sentences[0],n=i.$reveal;if(n&&n.css("visibility")==="hidden"){this.$button.removeClass("active"),aa=n,n.one("reveal",()=>{aa===n&&!this.audio.isPlaying&&this.play(i)});return}this.playing=i,this.playing.play(),this.$button.addClass("active");let r=this.$p.parents("x-tabbox .tab")[0];if(r){let h=r.parents("x-tabbox")[0];h.makeActive(r.index());let l=h.active;h.one("change",c=>{this.playing&&c!==l&&this.audio.pause()})}let o=this.$p.bounds,a=o.top+o.height-b.height+20;a>0&&C.scrollBy(a+100),setTimeout(()=>this.$button.focus(),800)}},ca=class extends Re{constructor(t,i){super();this.$el=t;this.audio=i;let n=t.attr("data-timings").split("-");this.start=+n[0]/1e3,this.end=(+n[1]-200)/1e3}play(){this.$el.addClass("playing"),this.audio.playClip(this.start,this.end,({ended:t})=>{this.$el.removeClass("playing"),this.trigger("end",t)})}get $reveal(){return this.$el.parents(".reveal")[0]}};var gm=Object.defineProperty,vm=Object.getOwnPropertyDescriptor,Ai=(s,e,t,i)=>{for(var n=i>1?void 0:i?vm(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&gm(e,t,n),n},Ul=(s,e,t)=>new Promise((i,n)=>{var r=h=>{try{a(t.next(h))}catch(l){n(l)}},o=h=>{try{a(t.throw(h))}catch(l){n(l)}},a=h=>h.done?i(h.value):Promise.resolve(h.value).then(r,o);a((t=t.apply(s,e)).next())}),_s,wm=m("div",{class:"snackbar"},C),Wl=class extends E{ready(){var s;wm.append(this),(s=this.$("button"))==null||s.on("click",()=>this.close())}open(s=2e3){return Ul(this,null,function*(){_s!==this&&(_s&&(yield _s.close()),_s=this,yield this.enter("pop",300).promise,this.setAttr("role","alert"),s&&setTimeout(()=>this.close(),s))})}close(){return Ul(this,null,function*(){_s===this&&(_s=void 0,this.removeAttr("role"),yield this.exit("pop",300).promise)})}};Wl=Ai([S("x-alert")],Wl);var Kl=class extends E{ready(){if(this.children.length)return;let s=m("svg",{viewBox:"0 0 24 24",alt:"",role:"presentation"},this),e=m("use",{},s),t=+this.attr("size")||24;for(let i of[this,s])i.css({width:`${t}px`,height:`${t}px`});this.onAttr("name",i=>e.setAttr("href",`/icons.13d4c88a.svg#${i}`))}};Kl=Ai([S("x-icon")],Kl);var ms=m("div",{class:"modal-background"},C),pa,Se=void 0,da=void 0;function ua(){Se&&Se.canClose&&Se.close()}ms.on("click",ua);C.onKey("Escape",ua);Ci.on("change",ua);ms.on("scrollwheel touchmove",s=>{s.preventDefault(),s.stopPropagation()});C.onKey("Space ArrowUp ArrowDown PageDown PageUp",s=>{Se&&(s.preventDefault(),s.stopPropagation())});var Xl=class extends E{constructor(){super(...arguments),this.isOpen=!1,this.canClose=!0}ready(){this.canClose=!this.hasAttr("no-close"),this.$iframe=this.$("iframe[data-src]"),this.$video=this.$("video");let s=Te(`[data-modal=${this.id}]`);for(let t of s)t.on("click",()=>this.open());Ci.on("afterChange",({$viewport:t})=>{let i=t.$$(`[data-modal=${this.id}]`);for(let n of i)n.on("click",()=>this.open())}),(this.hasClass("open")||b.getHash()===this.id)&&!Se&&this.open(!0),this.$("input")&&this.addClass("interactive");let e=this.$(".close");e&&e.on("click",()=>this.close());for(let t of this.$$(".btn"))t.on("click",()=>this.trigger("btn-click",t))}open(s=!1){var e,t;if(this.isOpen)return;ms.setClass("light",this.hasClass("light")),Se?Se.close(!0):s?ms.show():ms.css("display")==="block"?pa==null||pa.cancel():ms.enter("fade",250),this.isOpen=!0,Se=this,this.$iframe&&this.$iframe.setAttr("src",this.$iframe.data.src),this.$video&&this.$video.play(),s?this.show():this.enter("pop",250).promise.then(()=>this.css("transform","")),this.setAttr("role","dialog"),this.trigger("open"),da=document.activeElement;let i=this.$('input, a, button, textarea, [tabindex="0"]');i&&i.focus(),(e=window.ga)==null||e.call(window,"send","event","Modal",this.id),(t=window.gtag)==null||t.call(window,"event","modal",{action:this.id})}close(s=!1,e=!1){this.isOpen&&(this.isOpen=!1,this.removeAttr("role"),Se=void 0,this.$iframe&&this.$iframe.setAttr("src",""),this.$video&&this.$video.pause(),s||(pa=ms.exit("fade",250)),this.exit("pop",250).promise.then(()=>this.css("transform","")),e||this.trigger("close"),da&&da.focus())}getOpenModal(){return Se}};Xl=Ai([S("x-modal")],Xl);var Yl=class extends E{constructor(){super(...arguments),this.isOpen=!1}ready(){this.animation=this.attr("animation")||"pop",this.$bubble=this.$(".popup-body"),this.$bubble.hide(),this.$(".popup-target").on("click",()=>this.toggleOpen()),this.on("clickOutside",()=>this.close());for(let e of this.$bubble.$$("a"))e.on("click",()=>this.close());C.onKey("Escape",()=>this.close())}toggleOpen(){this.isOpen?this.close():this.open()}open(){this.isOpen||(this.isOpen=!0,this.addClass("active"),this.$bubble.enter(this.animation,150),this.$bubble.setAttr("role","dialog"),this.$bubble.focus(),this.trigger("open"))}close(){this.isOpen&&(this.isOpen=!1,this.removeClass("active"),this.$bubble.exit(this.animation,150),this.$bubble.removeAttr("role"),this.trigger("close"))}};Yl=Ai([S("x-popup")],Yl);var Zl=class extends E{constructor(){super(...arguments),this.$options={}}ready(){let s=this.children;this.$active=this.$(".active")||s[0],this.$active.addClass("active");for(let[e,t]of s.entries())!_(t.tagName,"A","BUTTON")&&!t.hasAttr("tabindex")&&t.setAttr("tabindex",0),t.on("click",()=>this.makeActive(t)),this.$options[t.attr("value")||e]=t;this.trigger("change",this.$active)}makeActive(s){s!==this.$active&&(this.$active.removeClass("active"),this.$active=s,s.addClass("active"),this.trigger("change",s))}bindVariable(s,e){s[e]===void 0&&(s[e]=this.$active.attr("value")),this.on("change",t=>s[e]=t.attr("value")),s.watch(()=>{let t=this.$options[s[e]];t&&this.makeActive(t)})}};Zl=Ai([S("x-select")],Zl);var fa=12;function ym(s){return`M${s},${s/2}a${s/2},${s/2},0,0,1,0,${s}A${s/2},${s/2},0,0,1,${s},${s/2}`}function bm(s){return`M ${s},0 C ${s/2},0,0,${s/2},0,${s} s ${s/2},${s},${s},${s} s ${s}-${s/2},${s}-${s} S ${s*1.5},0,${s},0 z M ${s*44.6/50},${s*76.1/50} L ${s*19.2/50},${s*48.8/50} l ${s*4/50}-${s*4.2/50} l ${s*19.8/50},${s*11.9/50} l ${s*34.2/50}-${s*32.6/50} l ${s*3.5/50},${s*3.5/50} L ${s*44.6/50},${s*76.1/50} z`}var Mn=class extends E{constructor(){super(...arguments);this.completed=!1}ready(){this.r=+this.attr("r")||10,this.r1=this.r+fa,this.$svg=m("svg",{width:2*this.r1,height:2*this.r1},this),this.$progress=m("path",{class:"pie",d:ym(this.r),"stroke-width":this.r},this.$svg),this.onAttr("p",t=>this.setProgress(+t,!1))}setProgress(t,i=!0){if(t>.99)return this.complete(i);let n=Math.PI*this.r;this.$progress.css("stroke",t?"currentColor":"none"),this.$progress.css("stroke-dasharray",`${t*n} ${n}`)}complete(t=!0){if(this.completed||(this.completed=!0,this.$progress.css("stroke","none"),this.$progress.css("fill","currentColor"),this.$progress.setAttr("d",bm(this.r)),!t))return;let i=`translate(${this.r1} ${this.r1})`,n=m("g",{transform:i},this.$svg),r=z(()=>m("line",{},n),18);pt(o=>{let a=this.r+fa*yt("quint-out",o),h=this.r+fa*o;for(let l=0;l<18;++l){let c=Math.cos(Math.PI*2*l/18),u=Math.sin(Math.PI*2*l/18);r[l].setLine({x:c*a,y:u*a},{x:c*h,y:u*h})}},800).promise.then(()=>n.remove())}};Mn=T([S("x-progress")],Mn);var Ql="2.4.1",ma="i5iSjo",Jl="_av",ga="_au",va="(not set)";var Cn=[],se=class{static add(e,t,i){tc(e,t).add(i)}static remove(e,t,i){tc(e,t).remove(i)}constructor(e,t){this.context=e,this.methodName=t,this.isTask=/Task$/.test(t),this.originalMethodReference=this.isTask?e.get(t):e[t],this.methodChain=[],this.boundMethodChain=[],this.wrappedMethod=(...i)=>{let n=this.boundMethodChain[this.boundMethodChain.length-1];return n(...i)},this.isTask?e.set(t,this.wrappedMethod):e[t]=this.wrappedMethod}add(e){this.methodChain.push(e),this.rebindMethodChain()}remove(e){let t=this.methodChain.indexOf(e);t>-1&&(this.methodChain.splice(t,1),this.methodChain.length>0?this.rebindMethodChain():this.destroy())}rebindMethodChain(){this.boundMethodChain=[];for(let e,t=0;e=this.methodChain[t];t++){let i=this.boundMethodChain[t-1]||this.originalMethodReference.bind(this.context);this.boundMethodChain.push(e(i))}}destroy(){let e=Cn.indexOf(this);e>-1&&(Cn.splice(e,1),this.isTask?this.context.set(this.methodName,this.originalMethodReference):this.context[this.methodName]=this.originalMethodReference)}};function tc(s,e){let t=Cn.filter(i=>i.context==s&&i.methodName==e)[0];return t||(t=new se(s,e),Cn.push(t)),t}var qs=window.Element.prototype,Bw=qs.matches||qs.matchesSelector||qs.webkitMatchesSelector||qs.mozMatchesSelector||qs.msMatchesSelector||qs.oMatchesSelector;var Pm="80",Tm="443",Zw=RegExp(":("+Pm+"|"+Tm+")$"),Qw=document.createElement("a");function An(s,e,t=void 0,i=void 0,n=void 0,r=void 0){if(typeof i=="function"){let o=t.get("buildHitTask");return{buildHitTask:a=>{a.set(s,null,!0),a.set(e,null,!0),i(a,n,r),o(a)}}}else return Qe({},s,e)}var wa={};function sc(s,e){let t=s.get("trackingId"),i=wa[t]=wa[t]||{},n=()=>{clearTimeout(i.timeout),i.send&&se.remove(s,"send",i.send),delete wa[t],i.queue.forEach(r=>r())};clearTimeout(i.timeout),i.timeout=setTimeout(n,0),i.queue=i.queue||[],i.queue.push(e),i.send||(i.send=r=>(...o)=>{n(),r(...o)},se.add(s,"send",i.send))}var Qe=Object.assign||function(s,...e){for(let t=0,i=e.length;t>e/4).toString(16):("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,s)};function ya(s,e){let t=window.GoogleAnalyticsObject||"ga";window[t]=window[t]||function(...i){(window[t].q=window[t].q||[]).push(i)},window.gaDevIds=window.gaDevIds||[],window.gaDevIds.indexOf(ma)<0&&window.gaDevIds.push(ma),window[t]("provide",s,e),window.gaplugins=window.gaplugins||{},window.gaplugins[ic(s)]=e}var Vi=class{constructor(){this.registry_={}}on(e,t){this.getRegistry_(e).push(t)}off(e=void 0,t=void 0){if(e&&t){let i=this.getRegistry_(e),n=i.indexOf(t);n>-1&&i.splice(n,1)}else this.registry_={}}emit(e,...t){this.getRegistry_(e).forEach(i=>i(...t))}getEventCount(){let e=0;return Object.keys(this.registry_).forEach(t=>{e+=this.getRegistry_(t).length}),e}getRegistry_(e){return this.registry_[e]=this.registry_[e]||[]}};var kn="autotrack",Fs={},xa=!1,Ii,gs=class s extends Vi{static getOrCreate(e,t,i){let n=[kn,e,t].join(":");return Fs[n]||(Fs[n]=new s(n,i),xa||Em()),Fs[n]}static isSupported_(){if(Ii!=null)return Ii;try{window.localStorage.setItem(kn,kn),window.localStorage.removeItem(kn),Ii=!0}catch(e){Ii=!1}return Ii}static get_(e){return window.localStorage.getItem(e)}static set_(e,t){window.localStorage.setItem(e,t)}static clear_(e){window.localStorage.removeItem(e)}constructor(e,t={}){super(),this.key_=e,this.defaults_=t,this.cache_=null}get(){if(this.cache_)return this.cache_;if(s.isSupported_())try{this.cache_=ba(s.get_(this.key_))}catch(e){}return this.cache_=Qe({},this.defaults_,this.cache_)}set(e){if(this.cache_=Qe({},this.defaults_,this.cache_,e),s.isSupported_())try{s.set_(this.key_,JSON.stringify(this.cache_))}catch(t){}}clear(){if(this.cache_={},s.isSupported_())try{s.clear_(this.key_)}catch(e){}}destroy(){delete Fs[this.key_],Object.keys(Fs).length||Mm()}};function Em(){window.addEventListener("storage",rc),xa=!0}function Mm(){window.removeEventListener("storage",rc),xa=!1}function rc(s){let e=Fs[s.key];if(e){let t=Qe({},e.defaults_,ba(s.oldValue)),i=Qe({},e.defaults_,ba(s.newValue));e.cache_=i,e.emit("externalSet",i,t)}}function ba(s){let e={};if(s)try{e=JSON.parse(s)}catch(t){}return e}var Cm=1e3,Am=60*Cm,Vn={},vs=class s{static getOrCreate(e,t,i){let n=e.get("trackingId");return Vn[n]?Vn[n]:Vn[n]=new s(e,t,i)}constructor(e,t,i){this.tracker=e,this.timeout=t||s.DEFAULT_TIMEOUT,this.timeZone=i,this.sendHitTaskOverride=this.sendHitTaskOverride.bind(this),se.add(e,"sendHitTask",this.sendHitTaskOverride);try{this.dateTimeFormatter=new Intl.DateTimeFormat("en-US",{timeZone:this.timeZone})}catch(r){}let n={hitTime:0,isExpired:!1};this.store=gs.getOrCreate(e.get("trackingId"),"session",n),this.store.get().id||this.store.set({id:ki()})}getId(){return this.store.get().id}isExpired(e=this.getId()){if(e!=this.getId())return!0;let t=this.store.get();if(t.isExpired)return!0;let i=t.hitTime;if(i){let n=new Date,r=new Date(i);if(n-r>this.timeout*Am||this.datesAreDifferentInTimezone(n,r))return!0}return!1}datesAreDifferentInTimezone(e,t){return this.dateTimeFormatter?this.dateTimeFormatter.format(e)!=this.dateTimeFormatter.format(t):!1}sendHitTaskOverride(e){return t=>{e(t);let i=t.get("sessionControl"),n=i=="start"||this.isExpired(),r=i=="end",o=this.store.get();o.hitTime=Je(),n&&(o.isExpired=!1,o.id=ki()),r&&(o.isExpired=!0),this.store.set(o)}}destroy(){se.remove(this.tracker,"sendHitTask",this.sendHitTaskOverride),this.store.destroy(),delete Vn[this.tracker.get("trackingId")]}};vs.DEFAULT_TIMEOUT=30;var $a={CLEAN_URL_TRACKER:1,EVENT_TRACKER:2,IMPRESSION_TRACKER:3,MEDIA_QUERY_TRACKER:4,OUTBOUND_FORM_TRACKER:5,OUTBOUND_LINK_TRACKER:6,PAGE_VISIBILITY_TRACKER:7,SOCIAL_WIDGET_TRACKER:8,URL_CHANGE_TRACKER:9,MAX_SCROLL_TRACKER:10},oc=Object.keys($a).length;function ac(s,e){Rm(s),Om(s,e)}function km(s){return parseInt(s||"0",16).toString(2)}function Vm(s){return parseInt(s||"0",2).toString(16)}function Im(s,e){if(s.length{document.visibilityState==Ee?(this.opts.sendInitialPageview&&(this.sendPageview({isPageLoad:!0}),this.isInitialPageviewSent_=!0),this.store.set({time:Je(),state:Ee,pageId:Hs,sessionId:this.session.getId()})):this.opts.sendInitialPageview&&this.opts.pageLoadsMetricIndex&&this.sendPageLoad()})}handleChange(){if(!(document.visibilityState==Ee||document.visibilityState==Li))return;let e=this.getAndValidateChangeData(),t={time:Je(),state:document.visibilityState,pageId:Hs,sessionId:this.session.getId()};document.visibilityState==Ee&&this.opts.sendInitialPageview&&!this.isInitialPageviewSent_&&(this.sendPageview(),this.isInitialPageviewSent_=!0),document.visibilityState==Li&&this.visibleThresholdTimeout_&&clearTimeout(this.visibleThresholdTimeout_),this.session.isExpired(e.sessionId)?(this.store.clear(),this.lastPageState==Li&&document.visibilityState==Ee&&(clearTimeout(this.visibleThresholdTimeout_),this.visibleThresholdTimeout_=setTimeout(()=>{this.store.set(t),this.sendPageview({hitTime:t.time})},this.opts.visibleThreshold))):(e.pageId==Hs&&e.state==Ee&&this.sendPageVisibilityEvent(e),this.store.set(t)),this.lastPageState=document.visibilityState}getAndValidateChangeData(){let e=this.store.get();return this.lastPageState==Ee&&e.state==Li&&e.pageId!=Hs&&(e.state=Ee,e.pageId=Hs,this.store.set(e)),e}sendPageVisibilityEvent(e,{hitTime:t}={}){let i=this.getTimeSinceLastStoredChange(e,{hitTime:t});if(i&&i>=this.opts.visibleThreshold){let n=Math.round(i/hc),r={transport:"beacon",nonInteraction:!0,eventCategory:"Page Visibility",eventAction:"track",eventValue:n,eventLabel:va};t&&(r.queueTime=Je()-t),this.opts.visibleMetricIndex&&(r["metric"+this.opts.visibleMetricIndex]=n),this.tracker.send("event",An(r,this.opts.fieldsObj,this.tracker,this.opts.hitFilter))}}sendPageLoad(){let e={transport:"beacon",eventCategory:"Page Visibility",eventAction:"page load",eventLabel:va,["metric"+this.opts.pageLoadsMetricIndex]:1,nonInteraction:!0};this.tracker.send("event",An(e,this.opts.fieldsObj,this.tracker,this.opts.hitFilter))}sendPageview({hitTime:e,isPageLoad:t}={}){let i={transport:"beacon"};e&&(i.queueTime=Je()-e),t&&this.opts.pageLoadsMetricIndex&&(i["metric"+this.opts.pageLoadsMetricIndex]=1),this.tracker.send("pageview",An(i,this.opts.fieldsObj,this.tracker,this.opts.hitFilter))}trackerSetOverride(e){return(t,i)=>{let n=nc(t)?t:{[t]:i};n.page&&n.page!==this.tracker.get("page")&&this.lastPageState==Ee&&this.handleChange(),e(t,i)}}getTimeSinceLastStoredChange(e,{hitTime:t}={}){return e.time?(t||Je())-e.time:0}handleExternalStoreSet(e,t){e.time!=t.time&&t.pageId==Hs&&t.state==Ee&&!this.session.isExpired(t.sessionId)&&this.sendPageVisibilityEvent(t,{hitTime:e.time})}handleWindowUnload(){this.lastPageState!=Li&&this.handleChange()}remove(){this.store.destroy(),this.session.destroy(),se.remove(this.tracker,"set",this.trackerSetOverride),window.removeEventListener("unload",this.handleWindowUnload),document.removeEventListener("visibilitychange",this.handleChange)}};ya("pageVisibilityTracker",Pa);El();Xt.addClass((b.isMobile?"is":"not")+"-mobile");b.isSafari&&Xt.addClass("is-safari");setTimeout(()=>Xt.addClass("ready"));window.addEventListener("keydown",s=>{s.keyCode===9&&Xt.addClass("is-tabbing")});window.addEventListener("mousedown",()=>{Xt.removeClass("is-tabbing")});var lc=k(".cookie-warning");lc&&k("#yes-to-cookies").on("click",function(){lc.exit("pop",300),b.setCookie("cookie_consent",1)});var Ta=k("x-modal#privacy");Ta&&Ta.$("form").on("submit",s=>{s.preventDefault(),fetch("/profile/accept-policies",{method:"POST"}),Ta.close()});var pc;(pc=navigator.serviceWorker)==null||pc.register("/service_worker.js",{scope:"/"}).catch(()=>console.warn("Unable to register Service Worker."));var dc;(dc=k("#skip-nav"))==null||dc.on("click",()=>{var e;(e=(k("article")||k(".panel.active")||k(".body")||C).$("input, button, a, textarea, [contenteditable], [tabindex]"))==null||e.focus()});var Sa=k("nav x-popup");if(Sa){let s=Sa.$$(".popup-body a, .popup-body button");for(let e of s)e.on("click",()=>Sa.close())}var Dm=Te("#language .locale-link");Ci.on("change",s=>{for(let e of Dm)e.setAttr("href",e.data.host+s)});var In=k("#dark-mode");In&&(In.checked=b.theme.isDark,In.on("change",()=>b.setTheme(In.checked?"dark":"light")));var Oi={},ws=k("#search"),ts=ws==null?void 0:ws.$(".form-field input"),Ln=ws==null?void 0:ws.$(".search-body");Oi[""]=(Ln==null?void 0:Ln.html)||"";function Nm(s){return s=s.trim().replace(/\s+/," ").toLowerCase().slice(0,50),s==="pi"||s.length>=3?s:""}function Gm(s){return D(this,null,function*(){if(s=encodeURIComponent(Nm(s)),s in Oi)return Oi[s];let e=yield fetch(`/api/search?q=${s}`);return e.ok?Oi[s]=yield e.text():Oi[s]=""})}var zm=0,cc=0;function uc(s){return D(this,null,function*(){let e=zm+=1,t=yield Gm(s);e<=cc||(cc=e,Ln.html=t)})}ts==null||ts.change(s=>{b.setCookie("search",s,60*60*24),setTimeout(()=>{ts.value===s&&uc(s)},300)});ts!=null&&ts.value&&ws.one("open",()=>uc(ts.value));var fc='';function mc(s){if(s.match("^[0-9]+/[0-9]+$")){let e=s.split("/");return+e[0]/+e[1]}else return Wh(s)}var On=class extends E{constructor(){super(...arguments);this.solution="";this.solutionNum=NaN;this.solutionDisplay="";this.range=0;this.input="";this.hint="";this.attempts=0;this.placeholder="???";this.done=!1}ready(){if(this.$input=this.$("input"),this.$target=this.$(".target"),this.solution=this.attr("solution"),this.solution.indexOf("\xB1")>=0){let t=this.solution.split("\xB1");this.solution=t[0].trim(),this.range=+t[1]}this.solutionNum=mc(this.solution),this.solutionDisplay=this.solution,this.hint=this.attr("hint"),this.removeAttr("solution"),this.removeAttr("hint"),this.$input.setInputPattern(this.solution),this.hasAttr("placeholder")&&(this.placeholder=this.attr("placeholder")),this.$input.setAttr("placeholder",this.placeholder),this.removeAttr("placeholder"),this.$input.change(t=>{this.input=t,this.isCorrect&&(this.solve(),this.trigger("valid",t),this.moveCursor())}),this.$input.onKey("Enter",()=>this.$input.blur()),this.$input.on("focus",()=>{this.addClass("on"),this.removeClass("invalid"),this.$input.setAttr("placeholder"," ")}),this.$input.on("blur",()=>{if(this.removeClass("on"),this.setClass("invalid",!!this.input&&!this.done),this.$input.setAttr("placeholder",this.placeholder),this.input&&!this.done){this.attempts+=1;let t=this.attempts>=(this.hint?4:3)?`Hmmm\u2026 maybe try ${this.solution}?`:this.attempts>=2?this.hint:void 0;this.trigger("invalid",{hint:t})}})}setup(t,i,n){var r;this.goal=i,this.$step=t,(r=n==null?void 0:n.scores)!=null&&r.includes(i)&&this.solve(!0),this.one("valid",()=>{t.addHint("correct"),t.score(this.solvedBlank?this.solvedBlank.goal:i)}),this.on("invalid",o=>t.addHint(o.hint||"incorrect",{class:"incorrect"}))}get isCorrect(){if(this.done)return!0;if(this.linkedBlanks){let t=this.linkedBlanks.map(i=>i.solvedBlank);return this.solvedBlank=this.linkedBlanks.find(i=>{if(i.done&&!i.solvedBlank||t.includes(i))return!1;if(i.checkAnswer(this.input))return!0}),this.solvedBlank&&(this.solutionDisplay=this.solvedBlank.solution),!!this.solvedBlank}return this.checkAnswer(this.input)}checkAnswer(t){let i=mc(t);return t.toLowerCase()===this.solution.toLowerCase()?!0:this.range&&Math.abs(i-this.solutionNum)<=this.range?(this.solutionDisplay=t,!0):x(i,this.solutionNum)||zo(i)===this.solution||t===zo(this.solutionNum)}moveCursor(){if(!this.$step)return;let t=this.$step.$blanks[this.$step.$blanks.indexOf(this)+1];!t||t.done||t.tagName==="X-BLANK-MC"||t.css("visibility")==="hidden"||!t.bounds.width||t.focus()}solve(t=!1){this.done=!0,this.$input.remove(),this.$target.html=this.solutionDisplay,this.addClass("done"),this.trigger("solve",{solution:this.solutionDisplay,restore:t})}focus(){this.$input.focus()}blur(){this.$input.blur()}};On=T([S("x-blank",{template:fc})],On);var gc='???

';var Rn=class extends E{constructor(){super(...arguments);this.done=!1}ready(){this.$target=this.$(".target"),this.$popup=this.$(".popup");let t=this.$popup.$$(".choice");this.solution=t[0].html,_t.shuffle(oe(t.length)).forEach(r=>{this.$popup.append(t[r]),t[r].on("click",()=>{this.removeClass("on"),t[r].blur(),r?(this.$target.html=t[r].html,this.addClass("invalid"),this.trigger("invalid")):(this.solve(),this.trigger("valid",this.solution))})});let n=this.$target.bounds.left+this.$popup.width>b.width-15;this.setClass("left",n),Bs(this,{enter:()=>{if(this.done)return;this.addClass("on");let r=this.$target.bounds,o=this.$popup.width,a=this.$popup.height,h=b.width-10-r.left,l=o10,u=r.top+r.height+a>b.height-10;this.setClass("left",c&&!l),this.setClass("top",u),this.$popup.css("max-width",!c&&!l?`${h}px`:"none")},exit:()=>{this.removeClass("on")},delay:100,exitDelay:400,$clickTarget:this.$target})}setup(t,i,n){var r;(r=n==null?void 0:n.scores)!=null&&r.includes(i)&&this.solve(!0),this.one("valid",()=>{t.addHint("correct"),t.score(i)}),this.on("invalid",o=>t.addHint(o.hint||"incorrect",{class:"incorrect"}))}solve(t=!1){this.done=!0,this.$target.html=this.solution,this.removeClass("on invalid"),this.addClass("done"),this.trigger("solve",{solution:this.solution,restore:t}),setTimeout(()=>this.$popup.remove(),250),this.$target.removeAttr("tabindex")}};Rn=T([S("x-blank-mc",{template:gc})],Rn);var vc='
';var wc=40,yc="free-text",Dn=class extends E{setup(e,t,i){var l,c;let n=this.$(".text-area"),r=this.$(".toolbar .submit"),o=((l=i==null?void 0:i.data)==null?void 0:l[yc])||"";o&&(n.html=o);for(let u of this.$$(".toolbar .command")){let d=u.data.command.split(":");u.on("click",()=>document.execCommand(d[0],!1,d[1]))}let a=o,h=ve(()=>{a!==o&&e.storeData(yc,o),a=o},5e3);n.on("change keyup input paste",()=>{o=n.html.replace(/ /g," ").trim().slice(0,500).trim(),r.setClass("invisible",o.length{h(),e.score(t),r.exit("pop"),this.trigger("submit")}))}};Dn=T([S("x-free-text",{template:vc})],Dn);var bc='
';var Nn=class extends E{ready(){let e=this.$(".wrapper"),t=this.$(".panel"),i=t.children,n=this.$(".next"),r=this.$(".back"),o=this.$(".dots"),a=i.map(()=>m("div",{class:"dot"},o)),h=i.length,l=+this.attr("slide-width")||void 0,c=this.width,u=1,d=c,g=0,y=0,f=dt=>{y=dt,t.translate(dt,0),this.trigger("move",dt)},v=dt=>{g=dt;for(let[ge,vi]of a.entries())vi.setClass("on",ge>=dt&&ge{c=this.width,u=l?Math.ceil(c/l):1,d=c/u;for(let dt of i)dt.css("width",d+"px");t.css("width",h*d+"px"),f(-g*d),v(g)});let w="quad",$=500,I,A,M,P,j=!1,ne=()=>{I=Date.now()-P,f(A+M*yt(w,I/$)),!j&&I<$?requestAnimationFrame(ne):this.trigger("slide-end")},As=dt=>{j=!1,I=0,A=y,M=-dt*d-y,P=Date.now(),v(dt),ne()};n.on("click",()=>{w="quad",g{w="quad",g>0&&As(g-1)});let en,To,So,sn;ds(e,{start:dt=>{j=!0,en=y,To=dt.x,sn=So=To},move:dt=>{So=sn,sn=dt.x;let ge=en-To+dt.x,vi=-(h-u)*d,Fd=ge>0?ge/4:ge{let dt=sn-So,ge=dt>12?1:dt<-12?-1:0;w="quad-out",As(B(Math.round(-y/d-ge),0,h-u)),setTimeout(()=>this.css("pointer-events","auto"))}})}};Nn=T([S("x-gallery",{template:bc})],Nn);var xc='';function Ea(s,e){let t=e.positionLeft-s.positionLeft+e.width/2,i=e.positionTop-s.positionTop+e.height/2;return new p(t,i)}function $c(s){return s?new p(...s.split(",").map(e=>+e)):void 0}var Gn=class extends E{constructor(){super(...arguments);this.doAnimation=!1}created(){this.slide=$c(this.attr("slide")),this.shift=$c(this.attr("offset"))}ready(){this.$target=k(this.attr("target")),this.$target&&(this.$target.on("click pointerdown focus",()=>this.stop()),this.hasAttr("start")&&this.start())}setTarget(t,i,n){this.$target=typeof t=="string"?k(t):t,i&&(this.slide=i),n&&(this.slide=n)}start(t){this.doAnimation||!this.from&&!this.$target||(this.doAnimation=!0,t&&(this.slide=t),this.slide||this.$end?this.runSlideAnimation():this.runClickAnimation())}startSlide(t,i){this.$target=t,this.$end=i,this.start()}stop(){this.doAnimation=!1}runSlideAnimation(){return D(this,null,function*(){this.show();let t=this.from||Ea(this,this.$target);this.shift&&(t=t.add(this.shift));let i=this.slide?t.add(this.slide):Ea(this,this.$end),n=`translate(${t.x-15}px,${t.y-10}px)`,r=`translate(${i.x-15}px,${i.y-10}px)`;yield this.animate({transform:[n+" scale(2)",n],opacity:[0,1]},300).promise,yield this.animate({transform:[n,r]},1e3).promise,yield this.animate({transform:[r,r+" scale(2)"],opacity:[1,0]},300).promise,this.hide(),setTimeout(()=>{this.doAnimation&&this.runSlideAnimation()},1e3)})}runClickAnimation(){return D(this,null,function*(){this.show();let t=this.from||Ea(this,this.$target);this.shift&&(t=t.add(this.shift));let i=`translate(${t.x-15}px,${t.y-10}px)`;yield this.animate({transform:[i+" scale(2)",i],opacity:[0,1]},500).promise,yield this.animate({transform:[i,i+" scale(2)"],opacity:[1,0]},500,200).promise,this.hide(),setTimeout(()=>{this.doAnimation&&this.runClickAnimation()},1e3)})}};Gn=T([S("x-gesture",{template:xc})],Gn);var Ma='';var Bm=JSON.parse(k("#glossary").text),_m=JSON.parse(k("#bios").text),Ca=600,Bn;b.onResize(()=>{Bn&&Bn.hide()});var Ri=class extends E{ready(){this.xid=this.attr("xid"),this.$target=this.$(".target"),this.$popup=this.$(".popup"),this.$popup.html=this.body()||"",this.setClass("left",b.width>Ca&&this.$target.bounds.left+this.$popup.width>b.width-15),Bs(this,{enter:()=>this.show(),exit:()=>this.hide(),delay:100,exitDelay:200,$clickTarget:this.$target,canFocusWithin:!0,preventMouseover:()=>b.width<=Ca})}show(){if(Bn=this,this.addClass("on"),b.width<=Ca){let a=k("#glossary-modal");return a.$(".modal-body").html=this.body(),a.open()}let t=this.$target.bounds,i=this.$popup.width,n=this.$popup.height,r=t.top+t.height+n54;this.setClass("top",o&&!r),this.setClass("left",t.left+i>b.width-15)}hide(){Bn=void 0,this.removeClass("on")}body(){let t=Bm[this.xid];if(!t)return console.warn("missing gloss:",this.xid);let i=t.text;return t.image&&(i+=``),t.link&&(location.pathname===t.link.split("#")[0]||(i+=`

Learn more\u2026

`)),i}};Ri=T([S("x-gloss",{template:Ma})],Ri);var zn=class extends Ri{body(){let e=_m[this.xid];if(!e)return console.warn("missing bio:",this.xid);let t=``,i=e.born?`

Timeline

`:"";return(e.image===!1?"":t)+e.bio+i}};zn=T([S("x-bio",{template:Ma})],zn);var Pc='
';var qm=document.createElement("a").relList.supports("ar"),qn=!1,Aa={x:0,y:0,s:1},Tc,ys=m("div",{class:"lightbox-overlay"},C),Ge=m("div",{class:"lightbox-img"},ys);function Fm(s,e,t){qn=!0,Tc=s,ys.show(),Ge.show();let i=s.bounds,n=Ge.bounds,r=i.left+i.width/2-n.left-n.width/2,o=i.top+i.height/2-n.top-n.height/2,a=Math.max(i.width/n.width,i.height/n.height);Aa={x:r,y:o,s:a},Ge.css("background-image",`url(${t}), url(${e})`),Ge.css("transform",`translate(${r}px, ${o}px) scale(${a})`),b.redraw(),Ge.addClass("transitions"),b.redraw(),s.css("visibility","hidden"),ys.addClass("on"),Ge.css("transform","scale(1) translate(0,0)")}function Sc(){qn&&(qn=!1,ys.removeClass("on"),Ge.setTransform(Aa,0,Aa.s),setTimeout(()=>{Tc.css("visibility","visible"),ys.css("display","none"),Ge.css("transform","none"),Ge.removeClass("transitions")},400))}ys.on("click touchmove",Sc);C.onKey("Escape",Sc);ys.on("scrollwheel touchmove",s=>{s.preventDefault(),s.stopPropagation()});C.onKey("Space AllArrows PageDown PageUp",s=>{qn&&(s.preventDefault(),s.stopPropagation())});var _n=class extends E{ready(){let e=this.attr("src"),t=this.$(".wrap"),i=this.attr("width"),n=this.attr("height");this.css("width",i+"px"),t.css("padding-bottom",+n/+i*100+"%");let r=t.$("img");r.setAttr("src",e),r.setAttr("alt",this.attr("alt")||""),r.setAttr("width",i),r.setAttr("height",n),e.endsWith(".gif")&&r.on("click",()=>r.setAttr("src",e));let o=t.$(".credit"),a=this.attr("credit");a?o.text=a:o.remove();let h=t.$(".zoom");if(this.hasAttr("lightbox")){this.addClass("interactive");let l=e.replace(/\.(?=[^.]*$)/,"-large.");this.on("click",()=>Fm(this,e,l))}else h.remove();if(qm&&this.hasAttr("ar")){let l=m("a",{href:this.attr("ar"),rel:"ar"});t.prepend(l),l.append(r)}}};_n=T([S("x-img",{template:Pc})],_n);var Fn=class extends E{constructor(){super(...arguments);this.correctCount=0;this.solvedCount=0;this.isSolved=!1}setup(t,i,n){var h;let r=this.children,o=r.map(()=>!1);for(let[l,c]of r.entries()){let u=c.data.error,d=u?"incorrect":"correct";u||(this.correctCount+=1),c.one("click",()=>{o[l]||this.isSolved||(t.addHint(u||"correct",{class:d}),c.addClass(d),u||(this.solvedCount+=1,t.score("picker-"+l),this.checkSolved()))})}let a=((h=n==null?void 0:n.scores)==null?void 0:h.filter(l=>l.startsWith("picker-")))||[];for(let l of a){let c=+l.slice(7);o[c]=!0,r[c].addClass("correct")}this.solvedCount=a.length,this.checkSolved()}checkSolved(){this.solvedCountthis.steps=+a),this.speed=+this.attr("speed")||1;let t=this.$(".bar"),i=this.$(".knob"),n=this.$(".play");this.hasAttr("no-play")?n.remove():n.on("click",()=>this.play());let r=this.hasAttr("continuous"),o=this.hasAttr("snap")?t.width/this.steps:.001;this.drag=new fs(i,{moveY:!1,snap:o}),this.drag.on("start",()=>{this.animation&&this.animation.cancel(),this.animation=void 0}),this.drag.on("move",({posn:a})=>{let h=a.x/this.drag.bounds.dx*this.steps;r||(h=Math.round(h)),!x(h,this.current)&&(this.current=h,this.trigger("move",h))}),this.drag.on("end",()=>this.trigger("slide-end"))}setup(t,i){this.bindModel(t.model),this.one("slide-end",()=>t.score(i))}set(t){x(t,this.current)||this.drag.setPosition(t*this.drag.bounds.dx/this.steps,0)}play(){return D(this,null,function*(){this.current>=this.steps&&this.set(0);let t=(1-this.current/this.steps)*3e3/this.speed;this.moveTo(this.steps,t)})}moveTo(t,i=600){return D(this,null,function*(){if(this.animation||t===this.current)return;let n=this.current;this.animation=pt(r=>{this.set(n+(t-n)*yt("quad",r))},i),yield this.animation.promise,this.animation=void 0,this.trigger("slide-end")})}bindVariable(t,i){t[i]=0,this.on("move",n=>t[i]=n),t.watch(()=>this.set(t[i]))}};Hn=T([S("x-slider",{template:Ec})],Hn);var Mc='
';function Hm(s){let e=s.$$("x-blank, x-blank-mc");if(!e.length)return Promise.resolve();let t=0;return new Promise(i=>{for(let n of e)n.on("solve",()=>{t+=1,t>=e.length&&i()})})}var jn=class extends E{constructor(){super(...arguments);this.length=0;this.current=0;this.locked=!1}ready(){this.$legend=this.$(".legend-box"),this.$steps=this.$legend.children,this.$back=this.$(".back"),this.$next=this.$(".next");let t=this.$(".dots");this.$dots=this.$steps.map(()=>m("div",{class:"dot"},t)),this.length=this.$steps.length,this.current=0,this.$back.on("click",()=>this.goBack()),this.$next.on("click",()=>this.goNext()),this.blanks=this.$steps.map(i=>Hm(i)),this.reveals=this.$$("[slide]").map(i=>{let n=i.attr("slide").split("-"),r=n.length>1?[+n[0]||0,+n[1]||this.length]:[+n[0],+n[0]],o=[i.data.animation||"fade",+i.data.duration||400];return i.data.display="visibility",r[0]>=0&&!i.hasClass("reveal")&&i.hide(),[i,r,o]}),this.autoAdvance=this.attr("step")==="auto",this.$steps[0].show(),this.$dots[0].addClass("on"),this.setupSlide(0)}setup(t,i,n){var o;let r=(o=n==null?void 0:n.scores)==null?void 0:o.filter(a=>a.startsWith("slide-")).length;if(r&&rt.score("slide-"+(a-1)))}go(t){if(this.locked||t<0||t>this.length-1||t===this.current)return;this.locked=!0,setTimeout(()=>this.locked=!1,600),this.$back.setClass("disabled",t===0),this.$next.setClass("disabled",t===this.length-1),this.$dots[this.current].removeClass("on"),this.$dots[t].addClass("on"),this.$steps[t].show();let i=this.$steps[t].height+"px";this.$steps[t].hide(),this.$steps[this.current].exit("fade",300).promise.then(()=>this.$steps[t].enter("fade",300)),this.$legend.animate({height:i},600).promise.then(()=>this.$legend.css("height","auto")),this.setupSlide(t),this.current=t,this.trigger("step",t)}setupSlide(t){this.$next.setAttr("disabled","true"),this.blanks[t].then(()=>this.$next.removeAttr("disabled"));for(let[i,n,r]of this.reveals){if(i.hasClass("reveal"))continue;let o=i.css("visibility")!=="hidden",a=t>=n[0]&&t<=n[1];a&&!o&&i.enter(...r,300),!a&&o&&i.exit(...r)}}goNext(){this.locked||(this.go(this.current+1),this.trigger("next",this.current))}goBack(){this.locked||(this.go(this.current-1),this.trigger("back",this.current))}};jn=T([S("x-slideshow",{template:Mc})],jn);var Un=class extends E{ready(){var g,y;(g=k(".sidebar-toggle"))==null||g.on("click",()=>this.addClass("open")),(y=k(".sidebar-shadow"))==null||y.on("pointerdown",()=>this.removeClass("open"));let e=k("#feedback form"),t=k("#feedback button"),i=k("#feedback .error"),n=k("#feedback-success"),r=k('#feedback textarea[name="message"]'),o=k("x-course").id;e==null||e.on("submit",f=>{f.preventDefault(),t.setAttr("disabled","true"),i.hide(),Ne(`/course/${o}/feedback`,e.formData).then(()=>{n.open(),r.value=""}).catch(()=>i.show()).then(()=>t.removeAttr("disabled"))});let a=JSON.parse(k("#glossary").text),h=k("#glossary-search"),l=h.$(".gloss-body"),c=h.$(".gloss-list"),u=h.$(".gloss-search input"),d;for(let f of Object.keys(a).sort()){let v=a[f],w=m("div",{class:"gloss-item",html:v.title,tabindex:0},c);w.on("click",()=>{d&&d.removeClass("on"),d=w,w.addClass("on"),l.html=v.text});let $=v.title.toLowerCase();u.change(I=>w.setClass("hidden",!!I&&$.indexOf(I.toLowerCase())<0))}}};Un=T([S("x-course-sidebar")],Un);function ka(s,e){let t=as(s.map(i=>i.h+10));for(let[i,n]of s.entries())n.drag.bounds=new lt(0,0,0,O(t)),n!==e&&n.drag.setPosition(0,t[i-1]||0)}function jm(s){return s.every((e,t)=>e.index===t)||s.every((e,t)=>e.index===s.length-t-1)}var Wn=class extends E{ready(){this.items=this.children.map(t=>({drag:new fs(t,{moveX:!1,useTransform:!0}),index:+t.data.index,h:0}));for(let t of this.children)t.removeAttr("data-index");for(let t of this.items)t.drag.on("drag",()=>{this.items=yi(this.items,i=>i.drag.position.y-(i===t?10:0)),ka(this.items,t)}),t.drag.on("end",()=>{ka(this.items),jm(this.items)&&this.solve()});b.onResize(()=>{for(let i of this.items)i.h=i.drag.$el.height;let t=N(this.items.map(i=>i.h));this.css("height",t+this.items.length*10-10+"px"),ka(this.items)})}setup(t,i,n){var r;(r=n==null?void 0:n.scores)!=null&&r.includes(i)&&this.solve(),this.one("solve",()=>{t.addHint("correct"),t.score(i)})}solve(){this.trigger("solve"),this.addClass("solved");for(let t of this.items)t.drag.disabled=!0}};Wn=T([S("x-sortable")],Wn);function Cc(s,e=!1){return D(this,null,function*(){if(s.css("visibility")==="visible")return;s.data.display="visibility";let t=+s.data.duration||400,i=(e?0:600)+(+s.data.delay||0);yield s.enter(s.data.animation||"fade",t,i).promise,s.css({opacity:"",transform:""}),s.trigger("reveal"),s.removeClass("reveal")})}var Kn=class extends E{constructor(){super(...arguments);this.model=le({});this.isShown=!1;this.isCompleted=!1;this.scores=new Set}ready(){var i,n,r,o;this.$course=this.parents("x-course")[0],this.$blanks=this.$$("x-blank, x-blank-mc"),this.$components=this.$$("[goal]"),this.userData=(r=(n=(i=this.$course)==null?void 0:i.userData)==null?void 0:n.steps)==null?void 0:r[this.id],this.goals=K(this.attr("goals")),this.$reveals=this.$$(".reveal");let t=this.$$(".check[data-when]");for(let a of[...this.$reveals,...t])this.onScore(a.data.when,()=>Cc(a));this.$nextBtn=this.$$(".next-step");for(let[a,h]of this.$nextBtn.entries())this.onScore("next-"+a,()=>h.exit("pop")),h.one("click",()=>this.score("next-"+a));for(let a of this.$$(".step-target"))a.tagName!=="X-TARGET"&&Bs(a,{enter:()=>{let h=this.$$('[target~="'+a.data.to+'"]');for(let l of h)l.addClass("focus");this.addClass("focus"),this.trigger("target-focus",{$targets:h})},exit:()=>{for(let h of this.$$(".focus"))h.removeClass("focus");this.removeClass("focus")}});for(let a of this.$$(".var, .var-action"))a.bindModel(this.model);(o=this.$course)!=null&&o.audio&&(this.narration=new En(this.$course.audio,this))}show(){var n,r,o;if(this.isShown)return;this.isShown=!0,(n=StepFunctions==null?void 0:StepFunctions[nn(this.id)])==null||n.call(StepFunctions,this);for(let a of this.$components)a.setup(this,a.attr("goal"),this.userData);let t=((r=this.userData)==null?void 0:r.scores)||[];for(let a of t)this.score(a,!1);let i=this.$$("x-gesture[target]");setTimeout(()=>{if(!this.isReady)for(let a of i)a.start()},2e3),(o=this.$course)==null||o.log("Step","show",this.id),this.trigger("show"),this.addClass("on"),this.narration&&setTimeout(()=>this.narration.play(),400)}complete(){if(!this.isCompleted){this.isShown||this.show(),this.isCompleted=!0;for(let t=0;tthis.scores.has(t))}get isPageLoaded(){return this.$course?this.$course.isReady:!0}score(t,i=!0){this.scores.has(t)||(this.scores.add(t),this.trigger("score-"+t),this.trigger("score"),this.$course&&(this.$course.trigger("score"),this.$course.saveProgress({steps:{[this.id]:{scores:[t]}}}),this.$course.log("Step","score",this.id+"/"+t)),i&&this.isReady&&this.$course&&this.$course.isReady&&setTimeout(()=>{this.$course.$activeStep===this&&this.$course.nextStep()},1200))}storeData(t,i){var n;(n=this.$course)==null||n.saveProgress({steps:{[this.id]:{data:{[t]:i}}}})}onScore(t,i){let n=K(t);if(n.every(a=>this.scores.has(a)))return i&&i(),Promise.resolve();let r=Ke(),o=()=>{n.every(a=>this.scores.has(a))&&(i&&i(),r.resolve(),this.off("score",o))};return this.on("score",o),r.promise}addHint(t,i={}){var n,r,o;return this.trigger("hint",t),(n=this.$course)!=null&&n.isReady?this.isInViewport?(r=this.$course.$tutor)==null?void 0:r.showHint(t,i):(this.one("enterViewport",()=>{var a;return(a=this.$course.$tutor)==null?void 0:a.showHint(t,i)}),{text:((o=this.$course.$tutor)==null?void 0:o.hints[t])||t}):{text:t}}delayedHint(t,i=1e4){let n=setTimeout(t,i);this.on("score",()=>{clearTimeout(n),this.isCompleted||(n=setTimeout(t,i))}),this.on("complete",()=>clearTimeout(n))}get nextStep(){if(!this.$course)return;let t=this.$course.$steps.indexOf(this);return this.$course.$steps[t+1]}groupBlanks(...t){let i=t.map(n=>this.$blanks[n]);for(let n of i)n.linkedBlanks=i}};Kn=T([S("x-step")],Kn);var Um='
',Xn=class extends E{constructor(){super(...arguments);this.$titles=[];this.active=0}ready(){let t=this.$(".titles");this.$body=this.$(".body"),this.$tabs=this.$$(".tab");for(let i=0;ithis.makeActive(i))}this.$titles[0].addClass("active"),this.$tabs[0].show()}makeActive(t){if(this.active===t)return;this.$titles[this.active].removeClass("active"),this.$titles[t].addClass("active"),this.$tabs[t].show();let i=this.$tabs[t].outerHeight+"px";this.$tabs[t].hide(),this.$tabs[this.active].exit("fade",300).promise.then(()=>this.$tabs[t].enter("fade",300)),this.$body.animate({height:i},600).promise.then(()=>this.$body.css("height","auto")),this.active=t,this.trigger("change",t)}};Xn=T([S("x-tabbox",{template:Um})],Xn);var Ac='';function Wm(s,e,t,i){let n=new p(s.left-15,s.top+t-15),r=new G(n,s.width+30,s.height+30),o=new p(e.left-15,e.top+i-15),a=new G(o,e.width+30,e.height+30),h=new Y(r.center,a.center);return[Q(h,r)[0],Q(h,a)[0]]}function Km(s,e){return Math.abs(s[0]-e[0])+Math.abs(s[1]-e[1])}var kc=Te("header, x-tutor, .sidebar"),Us=m("svg",{class:"target-body",html:Ac},C),Xm=Us.$("mask"),Ym=Us.$(".target-arrow"),js=!1,Vc=[],Yn=class extends E{ready(){this.setAttr("tabindex",0);let e=this.attr("to").replace(/_/g," "),t=this.hasClass("no-margins"),i,n,r,o,a=()=>{js=!0;let u=Te(e);if(!u.length)return;let d=u[0].hasParent(...kc);i===void 0&&(i=this.hasParent(...kc));let g=this.bounds,y=u.map(f=>f.bounds).filter(f=>f.width||f.height);if(r=0,!d){let f=Math.min(...y.map(I=>I.top)),v=Math.max(...y.map(I=>I.top+I.height)),w=b.height-12-v,$=56-f;r=w<0?w:$>0?$:0}for(let f of Vc)f.remove();Vc=[g,...y].map((f,v)=>{let w=!v||t?4:10;return m("rect",{x:f.left-w,y:f.top-w+(v||!i?r:0),width:f.width+2*w,height:f.height+2*w,rx:v?4:18,ry:v?4:18},Xm)}),Ym.points=Wm(g,y[0],i?0:r,d?0:r)},h=()=>{r&&C.scrollBy(-r,300),Us.css("display","block"),b.redraw(),Zt(function(){Us.css("opacity",1)},r?300:0)},l=u=>{js&&(u&&_(u.type,"mousemove","pointermove")&&Km(n,[u.clientX,u.clientY])<40||(clearTimeout(o),js=!1,Us.css("opacity",0),setTimeout(()=>{js||Us.css("display","none")},300),C.off("mousewheel mousemove touchend touchmove",l),this.off("mouseleave blur",l)))},c=()=>{r&&!i?C.on("mousemove",l):this.on("mouseleave",l),C.on("mousewheel touchend touchmove",l),this.on("blur",l)};this.on("mouseenter touchstart focus",u=>{n=[u.clientX,u.clientY],a(),o=window.setTimeout(h,r?50:30),c()}),this.on("click",u=>{js?(u.handled=!0,l(),setTimeout(()=>k(e).trigger("click mousedown"))):(js=!0,r=0,h(),c())})}};Yn=T([S("x-target")],Yn);var ot=class ce extends Error{constructor(e,t){super(t),this.name=e}static undefinedVariable(e){return new ce("EvalError",`Undefined variable \u201C${e}\u201D.`)}static undefinedFunction(e){return new ce("EvalError",`Undefined function \u201C${e}\u201D.`)}static uncallableExpression(e){return new ce("EvalError",`Cannot call \u201C${e}\u201D.`)}static evalLoop(e){return new ce("EvalError",`Loop in nested evaluation \u201C${e}\u201D.`)}static invalidCharacter(e){return new ce("SyntaxError",`Unknown symbol \u201C${e}\u201D.`)}static conflictingBrackets(e){return new ce("SyntaxError",`Conflicting brackets \u201C${e}\u201D.`)}static unclosedBracket(e){return new ce("SyntaxError",`Unclosed bracket \u201C${e}\u201D.`)}static startOperator(e){return new ce("SyntaxError",`A term cannot start with a \u201C${e}\u201D.`)}static endOperator(e){return new ce("SyntaxError",`A term cannot end with a \u201C${e}\u201D.`)}static consecutiveOperators(e,t){return new ce("SyntaxError",`A \u201C${e}\u201D cannot be followed by a \u201C${t}\u201D.`)}static invalidExpression(){return new ce("SyntaxError","This expression is invalid.")}},za={pi:Math.PI,\u03C0:Math.PI,e:Math.E},Oa={"(":")","[":"]","{":"}"},Xs={"*":"\xB7","**":"\u2217","//":"//","+-":"\xB1","\u2013":"\u2212","-":"\u2212",xx:"\xD7",sum:"\u2211",prod:"\u220F",int:"\u222B",del:"\u2202",grad:"\u2207",aleph:"\u2135",not:"\xAC",AA:"\u2200",EE:"\u2203","'":"\u2019","!=":"\u2260","<=":"\u2264",">=":"\u2265",in:"\u2208","!in":"\u2209","==":"\u2261","~=":"\u2245","~~":"\u2248",sub:"\u2282",sube:"\u2286",prop:"\u221D",oo:"\u221E",cap:"\u2229",cup:"\u222A","<-":"\u2190","->":"\u2192","=>":"\u21D2","<=>":"\u21D4","|->":"\u21A6",uarr:"\u2191",darr:"\u2193",lArr:"\u21D0"},Ni={Gamma:"\u0393",Delta:"\u0394",Theta:"\u0398",Lambda:"\u039B",Xi:"\u039E",Pi:"\u03A0",Sigma:"\u03A3",Phi:"\u03A6",Psi:"\u03A8",Omega:"\u03A9",alpha:"\u03B1",beta:"\u03B2",gamma:"\u03B3",delta:"\u03B4",epsilon:"\u025B",zeta:"\u03B6",eta:"\u03B7",theta:"\u03B8",iota:"\u03B9",kappa:"\u03BA",lambda:"\u03BB",mu:"\u03BC",nu:"\u03BD",xi:"\u03BE",pi:"\u03C0",rho:"\u03C1",sigma:"\u03C3",tau:"\u03C4",upsilon:"\u03C5",phi:"\u03C6",chi:"\u03C7",psi:"\u03C8",omega:"\u03C9",CC:"\u2102",NN:"\u2115",QQ:"\u211A",RR:"\u211D",ZZ:"\u2124"},Bc="abcdefghijklmnopqrstuvwxyz",Zm=Bc.split(""),Qm=Bc.toUpperCase().split(""),Jm=Object.values(Ni),tg=[...Zm,...Qm,...Jm,"$"],eg="|()[]{}\xF7,!<>=*/+-\u2013\u2212~^_\u2026\xB0\u2022\u2225\u22A5'\u2220:%\u223C\u25B3",sg=Object.values(Xs),ig=[...eg,...sg],ng={_:"sub","^":"sup","//":"/","\xF7":"/"},Ic={"<":"<",">":">"};function _c(s){return s in Ic?Ic[s]:s}var rg=["abs","round","floor","ceil","max","min","mod","lcm","gcd","gcf","log","exp","ln","sqrt","root","sin","cos","tan","sec","csc","cot","cosec","cotan","arcsin","arccos","arctan","sinh","cosh","tanh","sech","csch","coth","cosech"];function $s(s){return rg.includes(s)}var Ys={"+":"plus","\u2212":"minus","\xB7":"times","\xD7":"times","/":"over","//":"divided by","%":"percent","!":"factorial","\xB1":"plus-minus","=":"equals","\u2260":"does not equal","<":"is less than",">":"is greater than","\u2264":"is less than or equal to","\u2265":"is greater than or equal to",\u03C0:"pi","\u2245":"is congruent to","\u2225":"is parallel to","\u22A5":"is perpendicular to"};for(let s of Object.keys(Ni))Ys[Ni[s]]=s;var qc=s=>typeof s=="number"?s:s[0],Fc=s=>typeof s=="number"?[s,s]:s,ss=class{evaluate(s={},e){return NaN}interval(s={},e){return Fc(this.evaluate(s))}substitute(s={}){return this}recursiveSubstitute(s){let e=Object.keys(s);return this.unknowns.filter(t=>e.includes(t)).length?this.substitute(s).recursiveSubstitute(s):this}get simplified(){return this}get unknowns(){return this.variables.filter(s=>!Object.prototype.hasOwnProperty.call(za,s))}get variables(){return[]}get functions(){return[]}collapse(){return this}toString(){return""}toVoice(s={}){return""}toMathML(s={}){return""}},Va=new Set;function Ra(s,e,t=!1){var i;let n=(i=e[s])!=null?i:za[s];if(n===void 0)throw ot.undefinedVariable(s);if(typeof n=="string"||n instanceof ss){if(t||Va.clear(),Va.has(s))throw ot.evalLoop(s);return Va.add(s),typeof n=="string"&&(n=Et.parse(n)),n.evaluate(e,!0)}else return typeof n=="function"?n():n}var Gi=class extends ss{constructor(s){super(),this.n=s}evaluate(){return this.n}toString(){return`${this.n}`}toVoice(){return`${this.n}`}toMathML(){return`${this.n}`}},Zs=class extends ss{constructor(s){super(),this.i=s}evaluate(s={},e){return qc(Ra(this.i,s,e))}interval(s={},e){return Fc(Ra(this.i,s,e))}toMathML(){return`${this.i}`}substitute(s={}){return s[this.i]||this}get variables(){return[this.i]}toString(){return this.i}toVoice(){return this.i in Ys?Ys[this.i]:this.i.length===1?`_${this.i}_`:this.i}},og=class extends ss{constructor(s){super(),this.s=s}evaluate(s={},e){return qc(Ra(this.s,s,e))}toString(){return`"${this.s}"`}toVoice(){return this.s}toMathML(){return`${this.s}`}},Hc=class extends ss{toString(){return" "}toMathML(){return""}},Ce=class extends ss{constructor(s){super(),this.o=s}toString(){return this.o.replace("//","/")}toVoice(){return Ys[this.o]||this.o}get functions(){return[this.o]}toMathML(){let s=_c(this.toString());return`${s}`}},Lc=[-1/0,1/0],Ks=[NaN,NaN],bs=Math.PI/2,Da=Math.PI*2,ht=(s,e)=>[s-Number.EPSILON,e+Number.EPSILON],xs=(...s)=>ht(Math.min(...s),Math.max(...s)),ag=s=>Math.abs(s[1]-s[0]);var Ws=s=>isNaN(s[0])||isNaN(s[1]),Oc=s=>!isFinite(s[0])&&s[0]===s[1],hg=(s,e)=>nt(e,s[0]-Number.EPSILON,s[1]+Number.EPSILON),Jn=s=>hg(s,0),Me={add:(...s)=>s.reduce((e,t)=>e+t,0),sub:(...s)=>s.length>1?s[0]-s[1]:-s[0],mul:(...s)=>s.reduce((e,t)=>e*t,1),div:(s,e)=>s/e,abs:s=>Math.abs(s),round:s=>Math.round(s),floor:s=>Math.floor(s),ceil:s=>Math.ceil(s),max:(...s)=>Math.max(...s),min:(...s)=>Math.min(...s),mod:(s,e)=>s%e,lcm:(...s)=>Ls(...s),gcd:(...s)=>xe(...s),gcf:(...s)=>xe(...s),sup:(s,e)=>Math.pow(s,e),log:(s,e)=>Math.log(s)/(e===void 0?1:Math.log(e)),exp:s=>Math.exp(s),ln:s=>Math.log(s),sqrt:s=>Math.sqrt(s),root:(s,e)=>Math.pow(s,1/e),sin:s=>Math.sin(s),cos:s=>Math.cos(s),tan:s=>Math.tan(s),sec:s=>1/Math.cos(s),csc:s=>1/Math.sin(s),cot:s=>1/Math.tan(s),cosec:s=>Me.csc(s),cotan:s=>Me.cot(s),arcsin:s=>Math.asin(s),arccos:s=>Math.acos(s),arctan:s=>Math.atan(s),sinh:s=>Math.sinh(s),cosh:s=>Math.cosh(s),tanh:s=>Math.tanh(s),sech:s=>1/Math.cosh(s),csch:s=>1/Math.sinh(s),coth:s=>1/Math.tanh(s),cosech:s=>Me.csch(s)};function Zn(s,e){if(s[0]>0)return e[0]>=0?ht(s[0]**e[0],s[1]**e[1]):xs(s[0]**e[0],s[0]**e[1],s[1]**e[0],s[1]**e[1]);let t=e[0];return Number.isInteger(t)&&t===e[1]?t===0?[Jn(s)?0:1,1]:t%2?ht(s[0]**t,s[1]**t):Jn(s)?[0,Math.max(s[0]**t,s[1]**t)]:xs(s[1]**t,s[0]**t):Ks}function Rc(s,e=Da){let t=Math.floor(s[0]/e)*e;return[s[0]-t,s[1]-t]}var q={add:(...s)=>ht(N(s.map(e=>e[0])),N(s.map(e=>e[1]))),sub:(s,e)=>e!==void 0?ht(s[0]-e[1],s[1]-e[0]):ht(-s[1],-s[0]),mul:(s,...e)=>(e.length>1&&(e=[q.mul(...e)]),xs(s[0]*e[0][0],s[0]*e[0][1],s[1]*e[0][0],s[1]*e[0][1])),div:(s,e)=>Jn(e)?Lc:xs(s[0]/e[0],s[0]/e[1],s[1]/e[0],s[1]/e[1]),abs:s=>Jn(s)?ht(0,Math.max(-s[0],s[1])):xs(Math.abs(s[0]),Math.abs(s[1])),round:s=>ht(Math.round(s[0]),Math.round(s[1])),floor:s=>ht(Math.floor(s[0]),Math.floor(s[1])),ceil:s=>ht(Math.ceil(s[0]),Math.ceil(s[1])),max:(...s)=>ht(Math.max(...s.map(e=>e[0])),Math.max(...s.map(e=>e[1]))),min:(...s)=>ht(Math.min(...s.map(e=>e[0])),Math.min(...s.map(e=>e[1]))),mod:(s,e)=>{if(Ws(s)||Ws(e))return Ks;let t=s[0]/(s[0]<0?e[0]:e[1]);return t=t<0?Math.ceil(t):Math.floor(t),q.sub(s,q.mul(e,[t,t]))},lcm:(...s)=>xs(Ls(...s.map(e=>e[0]))),gcd:(...s)=>xs(xe(...s.map(e=>e[0]))),gcf:(...s)=>q.gcd(...s),sup:(s,e)=>Zn(s,e),log:(s,e)=>(e!==void 0&&q.div(q.log(s),q.log(e)),ht(s[0]<=0?-1/0:Math.log(s[0]),Math.log(s[1]))),exp:s=>Zn([Math.E,Math.E],s),ln:s=>q.log(s),sqrt:s=>Zn(s,[.5,.5]),root:(s,e)=>Zn(s,q.div([1,1],e)),sin:s=>q.cos(q.sub(s,[bs,bs])),cos:s=>Ws(s)||Oc(s)?Ks:ag(s)>=Da-Number.EPSILON?[-1,1]:(s=Rc(s),s[0]>Math.PI+Number.EPSILON?q.sub(q.cos(q.sub(s,[Math.PI,Math.PI]))):s[1]Ws(s)||Oc(s)?Ks:(s=Rc(s,Math.PI),s[0]>bs+Number.EPSILON&&(s=q.sub(s,[Math.PI,Math.PI])),s[0]<-bs+Number.EPSILON||s[1]>bs-Number.EPSILON?Lc:ht(Math.tan(s[0]),Math.tan(s[1]))),sec:s=>q.div([1,1],q.cos(s)),csc:s=>q.div([1,1],q.sin(s)),cot:s=>q.div([1,1],q.tan(s)),cosec:s=>q.csc(s),cotan:s=>q.cot(s),arcsin:s=>Ws(s)||s[1]<-1||s[0]>1?Ks:ht(s[0]<=-1?-bs:Math.asin(s[0]),s[1]>=1?bs:Math.asin(s[1])),arccos:s=>Ws(s)||s[1]<-1||s[0]>1?Ks:ht(s[1]>=1?0:Math.acos(s[1]),s[0]<=-1?Math.PI:Math.acos(s[0])),arctan:s=>ht(Math.atan(s[0]),Math.atan(s[1])),sinh:s=>ht(Math.sinh(s[0]),Math.sinh(s[1])),cosh:s=>s[1]<0?ht(Math.cosh(s[1]),Math.cosh(s[0])):s[0]>0?ht(Math.cosh(s[0]),Math.cosh(s[1])):ht(1,Math.cosh(Math.max(-s[0],s[1]))),tanh:s=>ht(Math.tanh(s[0]),Math.tanh(s[1])),sech:s=>q.div([1,1],q.cosh(s)),csch:s=>q.div([1,1],q.sinh(s)),coth:s=>q.div([1,1],q.tanh(s)),cosech:s=>q.csch(s)},Qn=K("+ \u2212 * \xD7 \xB7 / \xF7 // sup sub subsup"),Dc=K("sub sup subsup"),Ia=',';function jc(s,e){return Qn.includes(e)?s instanceof tr?!0:!(s instanceof jt)||!Qn.includes(s.fn)?!1:Dc.includes(s.fn)&&Dc.includes(e)?!0:Qn.indexOf(e)>Qn.indexOf(s.fn):!1}function lg(s,e,t){return jc(s,e)?`${t}`:t}function es(s,e){return s instanceof tr||s instanceof jt?`${e}`:e}function Nc(s){return s==="2"?"squared":s==="3"?"cubed":`to the power of ${s}`}var jt=class Na extends ss{constructor(e,t=[]){super(),this.fn=e,this.args=t}evaluate(e={}){let t=this.args.map(i=>i.evaluate(e));if(this.fn in e){let i=e[this.fn];if(typeof i=="function")return i(...t);if(typeof i=="number"&&t.length===1)return Me.mul(i,t[0]);throw ot.uncallableExpression(this.fn)}if(this.fn==="+")return Me.add(...t);if(this.fn==="\u2212")return Me.sub(...t);if(["*","\xB7","\xD7"].includes(this.fn))return Me.mul(...t);if(this.fn==="/")return Me.div(...t);if(this.fn==="sup")return Me.sup(...t);if($s(this.fn))return Me[this.fn](...t);if(this.fn==="(")return t[0];throw ot.undefinedFunction(this.fn)}interval(e={}){let t=this.args.map(i=>i.interval(e));if(this.fn in e){let i=e[this.fn];if(typeof i=="function")return re(i(...t.map(n=>n[0])),2);if(typeof i=="number"&&t.length===1)return q.mul([i,i],t[0]);if(Array.isArray(i)&&t.length===1)return q.mul(i,t[0]);throw ot.uncallableExpression(this.fn)}if(this.fn==="+")return q.add(...t);if(this.fn==="\u2212")return q.sub(...t);if(["*","\xB7","\xD7"].includes(this.fn))return q.mul(...t);if(this.fn==="/")return q.div(...t);if(this.fn==="sup")return q.sup(...t);if($s(this.fn))return q[this.fn](...t);if(this.fn==="(")return t[0];throw ot.undefinedFunction(this.fn)}substitute(e={}){return new Na(this.fn,this.args.map(t=>t.substitute(e)))}collapse(){return this.fn==="("?this.args[0].collapse():new Na(this.fn,this.args.map(e=>e.collapse()))}get simplified(){return this}get variables(){return Wt(ye(this.args.map(e=>e.variables)))}get functions(){return Wt([this.fn,...ye(this.args.map(e=>e.functions))])}toString(){let e=this.args.map(t=>jc(t,this.fn)?`(${t.toString()})`:t.toString());return this.fn==="\u2212"?e.length>1?e.join(" \u2212 "):`\u2212${e[0]}`:this.fn==="sup"?e.join("^"):this.fn==="sub"?e.join("_"):this.fn==="subsup"?`${e[0]}_${e[1]}^${e[2]}`:K("+ * \xD7 \xB7 / = < > \u2264 \u2265 \u2248").includes(this.fn)?e.join(` ${this.fn} `):_(this.fn,"(","[","{")?this.fn+this.args.join(", ")+Oa[this.fn]:_(this.fn,"!","%")?e[0]+this.fn:`${this.fn}(${e.join(", ")})`}toMathML(e={}){let t=this.args.map(r=>r.toMathML(e)),i=this.args.map((r,o)=>lg(r,this.fn,t[o]));if(this.fn in e){let r=t.map((o,a)=>({toString:()=>o,val:this.args[a]}));return e[this.fn](...r)}if(this.fn==="\u2212")return i.length>1?i.join('\u2212'):`\u2212${i[0]}`;if(_(this.fn,"+","=","<",">","\u2264","\u2265","\u2248")){let r=_c(this.fn);return i.join(`${r}`)}if(_(this.fn,"*","\xD7","\xB7")){let r=i[0];for(let o=1;o\xD7':"")+i[1]}return r}if(this.fn==="//")return i.join('/');if(this.fn==="sqrt")return`${i[0]}`;if(_(this.fn,"/","root")){let r=this.fn==="/"?"mfrac":"mroot",o=this.args.map((a,h)=>es(a,t[h]));return`<${r}>${o.join("")}`}if(_(this.fn,"sup","sub")){let r=[es(this.args[0],i[0]),es(this.args[1],t[1])];return`${r.join("")}`}return this.fn==="subsup"?`${[es(this.args[0],i[0]),es(this.args[1],t[1]),es(this.args[2],t[2])].join("")}`:_(this.fn,"(","[","{")?`${i.join(Ia)}`:_(this.fn,"!","%")?`${i[0]}${this.fn}`:this.fn==="abs"?`${i.join(Ia)}`:this.fn==="bar"?`${es(this.args[0],i[0])}\u203E`:this.fn==="vec"?`${es(this.args[0],i[0])}\u2192`:`${this.fn}${i.join(Ia)}`}toVoice(e={}){let t=this.args.map(n=>n.toVoice(e)),i=t.join(" ");if(this.fn in e){let n=t.map((r,o)=>({toString:()=>r,val:this.args[o]}));return e[this.fn](...n)}return _(this.fn,"(","[","{")?i:this.fn==="sqrt"?`square root of ${i}`:this.fn==="%"?`${i} percent`:this.fn==="!"?`${i} factorial`:this.fn==="/"?`${t[0]} over ${t[1]}`:this.fn==="//"?`${t[0]} divided by ${t[1]}`:this.fn==="sub"?i:this.fn==="subsup"?`${t[0]} ${t[1]} ${Nc(t[2])}`:this.fn==="sup"?`${t[0]} ${Nc(t[1])}`:Ys[this.fn]?t.join(` ${Ys[this.fn]} `):$s(this.fn)?`${this.fn} ${i}`:`${this.fn} of ${i}`}},tr=class extends ss{constructor(s){super(),this.items=s}evaluate(s={}){return this.collapse().evaluate(s)}interval(s={}){return this.collapse().interval(s)}substitute(s={}){return this.collapse().substitute(s)}get simplified(){return this.collapse().simplified}get variables(){return Wt(Nh(...this.items.map(s=>s.variables)))}get functions(){return this.collapse().functions}toString(){return this.items.map(s=>s.toString()).join(" ")}toMathML(s={}){return this.items.map(e=>e.toMathML(s)).join("")}toVoice(s={}){return this.items.map(e=>e.toVoice(s)).join(" ")}collapse(){return Ga(this.items).collapse()}};function La(s,e){if(e===2)return new og(s);if(!(!s||!e)){if(e===1&&s.length>1)return new Hc;if(e===3){if(isNaN(+s))throw ot.invalidExpression();return new Gi(+s)}if(e===4)return s in Ni?new Zs(Ni[s]):s in Xs?new Ce(Xs[s]):new Zs(s);if(e===5)return s in Xs?new Ce(Xs[s]):new Ce(s)}}function cg(s){let e=[],t="",i=0;for(let r of s){if(r==='"'){let a=i===2?0:2,h=La(t,i);h&&e.push(h),t="",i=a;continue}else if(i===2){t+=r;continue}let o=r.match(/[0-9.]/)?3:tg.includes(r)?4:ig.includes(r)?5:r.match(/\s/)?1:0;if(!o)throw ot.invalidCharacter(r);if(!i||i===3&&o!==3||i===4&&o!==4&&o!==3||i===5&&!(t+r in Xs)||i===1&&o!==1){let a=La(t,i);a&&e.push(a),t="",i=o}t+=r}let n=La(t,i);return n&&e.push(n),e}function pg(s){return s.length>1?new tr(s):s[0]instanceof Ce?new tr(s):s[0]}function dg(s,e){let t=[[]];for(let i of s)e(i)?t.push([]):O(t).push(i);return t}function Nt(s,e){return s instanceof Ce&&K(e).includes(s.o)}function Di(s){return s instanceof jt&&s.fn==="("?s.args[0]:s}function er(s,e){if(Nt(s[0],e))throw ot.startOperator(s[0]);if(Nt(O(s),e))throw ot.endOperator(O(s));for(let t=1;tNt(d,","));a.push(new jt(c,u.map(Gc)))}else Nt(n,"( [ {")?t.push([n]):O(t).push(n)}if(t.length>1)throw ot.unclosedBracket(O(t)[0].o);return Gc(t[0])}function zc(s,e,t=!1){let i=[],n=[],r=!1;function o(){if(r)throw ot.invalidExpression();n.length&&(i.push(n.length>1?new jt(e[0],n):n[0]),n=[])}for(let a of s)if(Nt(a,e)){if(r||!n.length)throw ot.invalidExpression();r=!0}else if(a instanceof Ce)o(),i.push(a),r=!1;else{let h=!t||a instanceof Gi;if(n.length&&!r&&h)throw ot.invalidExpression();n.push(a),r=!1}return o(),i}function Ga(s){if(s=s.filter(t=>!(t instanceof Hc)),!s.length)throw ot.invalidExpression();let e=s.findIndex(t=>Nt(t,"= < > \u2264 \u2265"));if(e===0)throw ot.startOperator(s[0]);if(e===s.length-1)throw ot.endOperator(s[0]);if(e>0){let t=Ga(s.slice(0,e)),i=Ga(s.slice(e+1));return new jt(s[e].o,[t,i])}if(Nt(s[0],"%!"))throw ot.startOperator(s[0]);for(let t=0;t1)throw ot.invalidExpression();return s[0]}function fg(s,e=!1,t){let i=ug(cg(s),t);return e?i.collapse():i}function mg(s,e){try{let t=Wt([...s.variables,...e.variables]),i=s.collapse(),n=e.collapse(),r=0;for(let o=0;o<5;++o){let a={};for(let c of t)a[c]=za[c]||Math.random()*5;let h=i.evaluate(a),l=n.evaluate(a);if(!(isNaN(h)||isNaN(l))){if(!x(h,l))return!1;r+=1}}return!!r}catch(t){return!1}}var Et={numEquals:mg,parse:Oe(fg)};var Uc='
';var gg=/[0-9+\-*/()^\s]+/g,vg=os(_t.shuffle(["happy","spongebob","sloth","party","robot","excited","cute","highfive1","applause","highfive2"])),wg=os(_t.shuffle(["minions","panther","dog","snape","what","door","horrible"]));function Ba(s,e,t={}){let i=m("div",{class:"msg-wrap","data-display":"flex"}),n=m("div",{class:"msg "+e},i);return t.class&&n.addClass(t.class),t.visible||i.hide(),_(e,"hint","question")?n.html=s:e==="img"?n.css("background-image",`url(${s})`):e==="video"&&m("iframe",{src:s,allowfullscreen:!0},n),i}var sr=class extends E{constructor(){super(...arguments);this.recentMessages=[];this.isOpen=!1;this.queuePromise=Promise.resolve()}ready(){var r;this.$course=this.parents("x-course")[0],this.hints=this.$course?JSON.parse(this.$course.$("#hints").text):{};let t=window.user;this.correct=os(_t.shuffle(this.hints.correct||[])),this.incorrect=os(_t.shuffle(this.hints.incorrect||[])),this.$toasts=this.$(".toasts"),this.$chat=this.$(".chat"),this.$chatBody=this.$(".chat-body"),this.$toasts.on("click",o=>{o.handled||this.open()}),this.$(".close").on("click",()=>this.close());let i=this.$(".chat-footer");if(this.$query=i.$(".input"),this.$query.onKey("Enter",o=>{o.preventDefault(),this.askQuestion(this.$query.text.trim()),this.$query.text=""}),this.$query.on("focus",()=>i.addClass("focus")),this.$query.on("blur",()=>i.removeClass("focus")),this.$(".hint").on("click",()=>{this.queue(this.hints.tutorial1),this.queue(t?this.hints.tutorial2:this.hints.account)}),this.$course&&((r=this.$course.userData)!=null&&r.messages))for(let o of this.$course.userData.messages)this.$chatBody.append(Ba(o.content,o.kind||"hint",{visible:!0}));if(!b.getCookie("sessionWelcome")&&this.$course){b.setCookie("sessionWelcome",1,60*60*4);let o=new Date().getHours(),a=o<12?"Morning":o<18?"Afternoon":"Evening";t?setTimeout(()=>this.showHint(`welcome${a}Named`,{variables:{name:t.shortName}}),3e3):b.getCookie("welcome")?(setTimeout(()=>this.showHint(`welcome${a}`),3e3),setTimeout(()=>this.queue(this.hints.account),4500)):(b.setCookie("welcome",1),setTimeout(()=>this.queue(this.hints.welcome),3e3),setTimeout(()=>this.queue(this.hints.tutorial1),4500))}}open(){this.isOpen||(this.isOpen=!0,this.$chat.enter("slide-up",200),this.$chatBody.scrollTop=this.$chatBody.scrollHeight,this.trigger("open"))}close(){this.isOpen&&(this.isOpen=!1,this.$query.blur(),this.trigger("close"),this.$chat.exit("slide-down",200))}queue(t,i="hint",n={}){this.queuePromise=this.queuePromise.then(()=>(this.display(t,i,n),wi(500)))}display(t,i="hint",n={}){let r=n.timeout||8e3;if(b.width<640&&(r*=.7),(n.toast==null?!0:n.toast)&&!this.isOpen){let h=Ba(t,i,n);h.setAttr("role","alert"),this.$toasts.append(h),h.enter("reveal-right"),setTimeout(()=>h.exit("reveal-right",400,0,!0),r),this.on("open",()=>h.exit("reveal",200,0,!0))}let a=Ba(t,i,{class:n.class,visible:!this.isOpen});this.$chatBody.append(a),this.isOpen&&(a.enter("reveal",300),pt(()=>this.$chatBody.scrollTop=this.$chatBody.scrollHeight,200))}showHint(t,i={}){if(_(t,"correct","incorrect")){let r=t==="correct"?this.correct():this.incorrect(),o=t==="correct"?3e3:5e3;if(this.queue(r,"hint",{class:i.class||t,timeout:o}),Math.random()<.2){let a=t==="correct"?vg():wg(),h="";this.queue(`${h}/images/gifs/${a}.gif`,"img",{timeout:o})}return{text:r}}let n=this.hints[t]||t;if(i.variables)for(let[r,o]of Object.entries(i.variables))n=n.replace(new RegExp("\\$"+r,"g"),o);return!i.force&&this.recentMessages.includes(t)?{text:n}:(this.recentMessages.push(t),setTimeout(()=>this.recentMessages.shift(),1e4),i.store!==!1&&this.$course&&this.$course.saveProgress({hints:[{content:n,kind:"hint"}]}),this.queue(n,"hint",{class:i.class}),{text:n})}askQuestion(t){if(!t)return;this.queue(t,"question"),this.$course&&this.$course.log("Tutor","ask",t);let i=(t.match(gg)||[]).filter(n=>n.length>=3&&!n.match(/^[\s0-9]+$/));if(i.length)try{let n=Et.parse(i[0],!0),r=Et.parse("="+n.evaluate());return this.queue(`${n.toMathML()}${r.toMathML()}`)}catch(n){console.log("Parse Error:",i[0])}this.$chatBody.addClass("loading"),Ne(this.attr("api"),{query:t}).then(n=>{this.$chatBody.removeClass("loading");let r=JSON.parse(n);for(let o of r)this.queue(o.content,o.kind)}).catch(n=>{this.$chatBody.removeClass("loading"),this.queue(this.hints.serverError),console.error("Tutor Error:",n)})}};sr=T([S("x-tutor",{template:Uc})],sr);var Wc='
';var Kc=m("div",{class:"var-overlay"},C),ir=class extends E{constructor(){super(...arguments);this.valueChange=!1}ready(){let t=this.attr("bind");if(!t)return;let[i,n,r]=t.split("|");[this.min,this.max,this.step]=r.split(",").map(l=>+l),this.name=i,this.model=this.getParentModel(),this.$(".content").bindModel(this.model),this.$progress=this.$(".progress"),this.setValue(+n);let o=20*(b.isMobile?1.5:1)/B((this.max-this.min)/this.step/12,1,3),a=0,h=0;for(let l of this.$$(".left, .right")){let c=l.hasClass("left")?-this.step:this.step;l.on("click",()=>{this.setValue(this.value+c),this.trigger("slide-end")})}ds(this,{start:l=>{a=l.x,h=this.value,this.addClass("on"),this.valueChange=!1,Kc.show(),Xt.addClass("grabbing")},move:l=>{let c=(l.x-a)/o;this.setValue(h+Rt(c)*this.step)},end:()=>{this.removeClass("on"),this.valueChange&&this.trigger("slide-end"),Kc.hide(),Xt.removeClass("grabbing")}})}setup(t,i){this.one("slide-end",()=>t.score(i))}setValue(t){let i=Rt(B(t,this.min,this.max),2);if(i===this.value)return;this.value=i,this.valueChange=!0,this.model&&(this.model[this.name]=i);let n=this.max-this.min;this.$progress.css("width",116*(i-this.min)/n+"px")}};ir=T([S("x-var",{template:Wc})],ir);var Xc='';var nr=class extends E{constructor(){super(...arguments);this.visible=!0}ready(){this.on("click",()=>{this.play(),setTimeout(()=>this.trigger("play"),400)})}play(){this.visible&&(this.visible=!1,this.exit("pop",400))}reset(){this.visible||(this.visible=!0,setTimeout(()=>this.enter("pop"),400))}};nr=T([S("x-play-btn",{template:Xc})],nr);var rr=class extends E{constructor(){super(...arguments);this.playing=!1}ready(){this.$icon=this.$("x-icon"),this.$("button").on("click",()=>this.toggle())}toggle(){this.playing?this.pause():this.play()}play(){this.playing||(this.playing=!0,this.$icon.setAttr("name","pause"),this.trigger("play"))}pause(){this.playing&&(this.playing=!1,this.$icon.setAttr("name","play"),this.trigger("pause"))}};rr=T([S("x-play-toggle",{template:''})],rr);var Yc='
';function Zc(s){let e=Math.floor(s/60),t=Math.floor(s%60);return e+":"+(t<10?"0":"")+t}var or=class extends E{ready(){let t=this.attr("src"),i=this.$(".video-wrap"),n=this.$("video"),r=this.attr("width"),o=this.attr("height");this.css("width",r+"px"),i.css("padding-bottom",+o/+r*100+"%"),n.setAttr("poster",this.attr("poster")||t.replace(/mp4$/,"jpg")),this.hasAttr("loop")&&(n._el.loop=!0),this.hasAttr("audio")||(n._el.muted=!0),n._el.preload=this.attr("preload")==="no"?"metadata":"auto",m("source",{src:t,type:"video/mp4"},n),this.hasAttr("credit")&&(this.$(".credit").text=this.attr("credit"));let a=this.$(".bar"),h=this.$(".progress"),l=this.$(".buffer"),c=this.$(".timecode"),u=new fs(this.$(".handle"),{$parent:a,moveY:!1}),d=this.video=n._el,g=this.width-110;b.onResize(()=>g=this.width-110),n.on("canplay",()=>{c.text=Zc(+d.duration)}),n.on("timeupdate",()=>{let v=d.currentTime/d.duration;h.css("width",v*100+"%"),c.text=Zc(+d.currentTime),u.setPosition(v*g,0),this.trigger("timeupdate",d.currentTime)}),n.on("progress",()=>{if(d.buffered.length<=0||d.duration<=0)return;let w=d.buffered.end(d.buffered.length-1)/d.duration*100;l.css("width",w+"%")}),n.on("ended",()=>{d.pause(),this.removeClass("playing"),this.trigger("end")});let y=()=>d.paused?this.play():this.pause(),f=v=>this.setTime(v/g*d.duration);this.hasAttr("hover")?(n.on("mouseover touchstart",()=>this.play()),n.on("mouseout touchend touchcancel",()=>this.pause())):n.on("click",y),this.hasAttr("controls")&&(this.$(".controls").show(),this.$(".play-pause-btn").on("click",y),u.on("start",()=>this.pause()),u.on("drag",({posn:v})=>f(v.x)),a.on("click",v=>f(v.offsetX)))}setTime(t){this.video.currentTime=t}play(){this.video.play(),this.addClass("playing"),this.trigger("play")}pause(){this.video.pause(),this.removeClass("playing")}};or=T([S("x-video",{template:Yc})],or);var ar=class extends E{constructor(){super(...arguments);this.isCompleted=!1;this.isReady=!1}created(){this.userData=window.progressData||JSON.parse(this.$("#userdata").text)||{},this.$steps=this.$$("x-step");for(let t of this.$steps)t.on("score",()=>this.trigger("score"));this.data.audio&&(this.audio=new Sn(this.data.audio))}ready(){this.$footer=this.$("footer"),this.$skipStep=this.$footer.$(".skip-step"),this.$progress=this.$(".sidebar-row.active x-progress"),this.$tutor=this.$("x-tutor"),this.$stepsWrap=this.$(".steps");let t=this.findStep(b.getHash()),i=this.findStep(this.userData.activeStep);this.$activeStep=i||this.$steps[0];for(let r of this.$steps){if(r.show(),r===this.$activeStep)break;r.complete()}if(this.userData.completed||b.getHash()==="full"||this.data.reveal)this.complete();else for(;this.$activeStep&&this.$activeStep.isReady&&!this.isCompleted;)this.nextStep();(t||i&&!this.userData.completed)&&this.goToStep(t||i,!1),this.$(".section-dev")&&this.complete();let n=this.$(".reveal-banner");setTimeout(()=>{this.isCompleted||(n.removeClass("off"),this.on("score complete",()=>n.addClass("off")))},1500),n.$(".complete").one("click",()=>this.complete()),C.onKey("Space",r=>{r.preventDefault(),this.nextStep(),n.addClass("off")}),this.$footer.$(".skip").on("click",()=>this.nextStep()),this.$footer.$(".show-all").on("click",()=>this.complete()),this.$footer.show(),this.isReady=!0,setTimeout(()=>this.addClass("ready"))}nextStep(){if(this.isCompleted)return;let t=this.$activeStep,i=this.$stepsWrap.height;do{if(t.complete(),t=this.$steps[this.$steps.indexOf(t)+1],!t)return this.complete(!0);t.show()}while(t.isReady);this.$stepsWrap.animate({height:[i+"px","auto"]},800),this.$activeStep=t,this.saveProgress({activeStep:t.id})}goToStep(t,i=!0){let n=this.$stepsWrap.height;for(let a of this.$steps){if(a.isShown||(this.$activeStep=a),a.show(),t.isShown&&!a.isReady)break;a.complete()}let r=t.positionTop-Math.max(50,(b.height-t.height)/2);i?(this.$stepsWrap.animate({height:[n+"px","auto"]},800),C.scrollTo(r)):C.scrollTop=r;let o=O(this.$steps);if(o.isShown&&o.isReady)return this.complete();this.$activeStep&&this.saveProgress({activeStep:this.$activeStep.id})}complete(t=!1){if(this.isCompleted)return;this.isCompleted=!0,this.$steps.forEach(n=>n.complete()),this.$activeStep=void 0;let i=this.$footer.$(".next-section");t?(this.$skipStep.exit("fade",200),i&&i.enter("pop")):(this.$skipStep.hide(),i&&i.show()),this.trigger("complete"),this.saveProgress({completed:!0}),this.log("Course","complete")}findStep(t){for(let i of this.$steps)if(i.id===t)return i}saveProgress(t){if(!this.isReady)return;let n=N(this.$steps.map(r=>r.scores.size))/+this.data.goals||0;this.$progress.setProgress(n),ql(`/course/${this.id}/${this.data.section}`,t)}log(t,i,n){if(window.ga&&this.isReady){let r=i+(n?":"+n:"");window.ga("send","event",t,r,this.id)}}};ar=T([S("x-course")],ar);var hr=class{constructor(){this.callbacks=[]}add(e){this.callbacks.push(e)}start(e=1e3){return pt(i=>{for(let n of this.callbacks)n(i)},e).promise}};function Qc(s,e){return s.every((t,i)=>x(t,e[i]))}function Jc(s,e){s.scale*=e.scale,s.x=s.x*e.scale+e.x,s.y=s.y*e.scale+e.y}function tp(s,e){return x(s.x,e.x)&&x(s.y,e.y)&&x(s.scale,e.scale)}function lr(s,e,t){if(t==="adding"){let i=s.strokeLength,n=e<.5?0:yt("cubic-in",e*2-1);s.css({"stroke-dasharray":i+"px","stroke-dashoffset":i*(1-n)+"px"})}else if(t==="deleting"){let i=s.strokeLength,n=e<.5?yt("cubic-in",2*e):1;s.css({"stroke-dasharray":i+"px","stroke-dashoffset":i*(2-n)+"px"})}}function ep(s,e){let t=[s],i=s.expr;for(;e.startsWith(i);){if(e===i)return t;let n=O(t).next;if(!n)return;t.push(n),i+=n.expr}}function sp(s,e,t=1){let i=t*Math.abs(e.x-s.x)/3,n=p.average(s,e).shift(0,i);return function(r){let o=(1-r)**2*s.x+2*r*(1-r)*n.x+r*r*e.x,a=(1-r)**2*s.y+2*r*(1-r)*n.y+r*r*e.y;return{x:o,y:a}}}function _a(s,e){return Math.max(e*s,.4)/s}function ze(s){return s instanceof Ae&&s.children.length>1||s instanceof zi?`(${s.expr})`:s.expr}function Qs(s,e){return e.length===1&&e[0].type==="mrow"?e[0]:new Ae(e,s)}var Gt=class s{constructor(e,t,i,n){this.type=e;this.equation=i;this.$element=n;this.children=[];this.status="";this.value="";this.customColor="";this.roundedMotion=!1;this.width=0;this.height=0;this.baseline=0;this.transform={x:0,y:0,scale:1};this.currentDimensions=[0,0,0];this.currentWorldTransform={x:0,y:0,scale:1};this.addChildren(t),n&&i.$row.append(n)}get expr(){return""}get log(){let e=this.children.map(t=>t.log);return`<${this.type}>${e.join("")}`}get color(){return this.customColor||(this.parent?this.parent.color:"")}static create(e,t){let i=e.nodeName.toLowerCase();if(_(i,"mn","mi","mo","mtext")){if(e.textContent==="placeholder")return new Ha(t);let r=e.getAttribute("mathvariant")||void 0;return new cr(i,e.textContent||"",t,r)}if(!_(i,"mrow","mfrac","mfenced","msqrt","mroot","msub","msup","msubsup","munder","mover","munderover","mspace"))return new Ka(e,t);if(i==="mfenced"&&e.getAttribute("open")==="["){let r=e.children.length,o=ye(Array.from(e.children,h=>Array.from(h.children,l=>s.create(l,t)))),a=new Wa(o,t,r);return new pr([a],t)}let n=Array.from(e.children,r=>s.create(r,t));switch(i){case"mrow":return new Ae(n,t);case"mfrac":return n=n.map(r=>Qs(t,[r])),new ja(n,t);case"mfenced":return n=[Qs(t,n)],new pr(n,t);case"msqrt":return n=[Qs(t,n)],new dr(i,n,t);case"mroot":return n=n.map(r=>Qs(t,[r])),new dr(i,n,t);case"msub":case"msup":case"msubsup":return n=n.map(r=>Qs(t,[r])),new zi(i,n,t);case"munder":case"mover":case"munderover":return n=n.map(r=>Qs(t,[r])),new Ua(i,n,t);case"mspace":return new Fa(t)}throw new Error(`Unknown element type tag ${e.nodeName}`)}get marginLeft(){return .1}get marginRight(){return .1}setTransform(e=0,t=0,i=1){this.transform.x=e,this.transform.y=t,this.transform.scale=i}get worldTransform(){let e=this,t=Object.assign({},this.transform);for(;e=e.parent;)Jc(t,e.transform);return t}get index(){return this.parent?this.parent.children.indexOf(this):-1}get next(){if(!this.parent)return;let e=this.parent.children.indexOf(this);return this.parent.children[e+1]}get prev(){if(!this.parent)return;let e=this.parent.children.indexOf(this);return this.parent.children[e-1]}addChildren(e,t=this.children.length){for(let i of this.children)i.type==="placeholder"&&i.deleteFromDom();for(let i of e)i.detach(),i.parent=this;this.children.splice(t,0,...e)}insertAfter(e){let t=this.parent.children.indexOf(this);this.parent.addChildren(e,t+1)}insertBefore(e){let t=this.parent.children.indexOf(this);this.parent.addChildren(e,t)}detach(){if(this.parent){let e=this.parent.children.indexOf(this);e>=0&&this.parent.children.splice(e,1),this.parent=void 0}}deleteFromDom(){this.parent&&this.detach(),this.$element&&this.$element.remove(),this.$element=void 0;for(let e of this.children.slice(0))e.deleteFromDom()}*parents(e=!1){let t=e?this:this.parent;for(;t;)yield t,t=t.parent}hasParent(e,t=!1){return Bt(this.parents(t),e)}hitTest(e){let{x:t,scale:i}=this.worldTransform,n=this.marginLeft*i*this.equation.fontSize,r=this.marginRight*i*this.equation.fontSize;if(nt(e.x,t-n,t+this.width*i+n+r))return this.hitTestChildren(e)||this}hitTestChildren(e){for(let t of this.children){let i=t.hitTest(e);if(i)return i}}measure(e=1){for(let t of this.children)t.measure(e)}clean(){for(let e of this.children)e.clean()}setStatus(e){this.status=e;for(let t of this.children)t.setStatus(e)}render(e){for(let h of this.children)h.render(e);if(!this.$element)return;let t=this.currentWorldTransform,i=this.currentWorldTransform=this.worldTransform,n=this.currentDimensions,r=this.currentDimensions=[this.width,this.height,this.baseline];if(tp(t,i)&&Qc(n,r)&&!this.status)return;if(!e){this.positionElement(i),this.drawElement(1,r[0],r[1],r[2],i.scale);return}this.status==="adding"&&this.positionElement(i);let o=i.y+this.baseline{if(!this.$element)return;let l=yt("cubic",h),c=_(this.status,"adding","deleting"),u=c?r[0]:tt(n[0],r[0],l),d=c?r[1]:tt(n[1],r[1],l),g=c?r[2]:tt(n[2],r[2],l),y=c?i.scale:tt(t.scale,i.scale,l);if(this.drawElement(h,u,d,g,y),!this.status){let f=a?a(l):p.interpolate(t,i,l);this.positionElement({x:f.x,y:f.y,scale:y})}})}positionElement(e){this.$element.setTransform(e,0,e.scale)}drawElement(e,t,i,n,r){}},yg="acegmnopqrsuvwxyz",Ps=1.1,Js=.2,qa=new Set(["=","\u2248","<",">","\u2264","\u2265"]),bg=document.createElement("canvas"),ip=bg.getContext("2d"),xg=Oe((s,e)=>(ip.font=`${e}px "Source Sans Pro", sans-serif`,ip.measureText(s).width)),cr=class extends Gt{constructor(t,i,n,r){super(t,[],n,m("text",{}));this.variant=r;this.setValue(i)}setValue(t){this.$element.text=this.value=t;let i=this.value.split("").every(r=>yg.includes(r));this.width=xg(t,this.equation.fontSize),this.height=(Ps-(i?.1:0))*this.equation.fontSize,this.baseline=this.height-Js*this.equation.fontSize;let n=this.type==="mtext"||this.variant==="normal";this.$element.setClass("font-normal",n||$s(this.value))}get expr(){return this.value==="xx"?'"xx"':this.type==="mtext"?`"${this.value}"`:this.value}get log(){return`<${this.type}>${this.value}`}get marginLeft(){if(this.type==="mo")return qa.has(this.value)?this.equation.isDisplay?.5:.35:_(this.value,"\u2221","\u25B3","!","%","\u2019")||_(this.value,"\u2026","\xB0")&&this.prev&&this.prev.type==="mn"?0:.25;if(this.type==="mi"){if(this.prev&&this.prev.type==="mn")return .1;if(this.prev&&this.prev.type==="mi")return .05;if(this.prev&&this.prev.type==="mfrac")return .15}return 0}get marginRight(){return this.type==="mo"?this.equation.isDisplay&&qa.has(this.value)?.5:_(this.value,"\u2221","\u25B3")?0:this.value==="\u2212"&&(!this.prev||qa.has(this.prev.value))?.1:.25:0}positionElement(t){if(!this.$element)return;let i=(this.equation.fontSize-this.baseline)*t.scale;this.$element.setTransform({x:t.x,y:t.y-i},0,t.scale)}drawElement(t,i,n,r,o){this.status==="adding"?this.$element.setAttr("opacity",t<.5?0:yt("cubic-in",t*2-1)):this.status==="deleting"&&this.$element.setAttr("opacity",t<.5?1-yt("cubic-in",2*t):0),this.$element.css("stroke-width",(1-o)*1.5+"px"),this.$element.css("color",this.color||"currentColor")}},Fa=class extends Gt{constructor(e){super("mspace",[],e),this.height=(Ps-.1)*e.fontSize,this.baseline=this.height-Js*this.equation.fontSize,this.width=e.fontSize*.2}get expr(){return" "}},Ae=class extends Gt{constructor(t,i,n,r=0){super("mrow",t,i);this.align=n;this.dx=r}addChildren(t,i=this.children.length){let n=[];for(let r of t)r.type==="mrow"?(n.push(...r.children),r.detach()):n.push(r);super.addChildren(n,i)}get expr(){return this.children.map(t=>t.expr).join(" ").replace(/− /,"\u2212")||"placeholder"}measure(t=1){if(super.measure(t),!this.children.length){this.height=this.width=this.baseline=0;return}this.baseline=Math.max(...this.children.map(n=>n.baseline)),this.height=this.baseline+Math.max(...this.children.map(n=>n.height-n.baseline));let i=0;for(let[n,r]of this.children.entries())r.setTransform(i,this.baseline-r.baseline),i+=r.width,nr.expr===this.align);n&&(this.transform.x=this.dx-n.transform.x-n.width/2)}this.width=i}},Ha=class extends Gt{constructor(e){let t=e.fontSize,i=`M${.1*t} ${.3*t}h${t/2}v${t/2}h-${t/2}Z`,n=m("path",{class:"placeholder",d:i});super("placeholder",[],e,n),this.width=.7*t,this.height=Ps*t,this.baseline=this.height-Js*t}get expr(){return"placeholder"}get marginLeft(){return 0}get marginRight(){return 0}},ja=class extends Gt{constructor(e,t){super("mfrac",e,t,m("line"))}get expr(){return this.children.map(e=>ze(e)).join("/")}measure(e){let t=this.hasParent(a=>a.type==="mfrac"||a.type==="matrix"),i=_a(e,!this.equation.isDisplay||t?.66:1),n=.1*this.equation.fontSize,[r,o]=this.children;super.measure(e*i),this.width=(Math.max(r.width,o.width)+2*n)*i,this.height=(r.height+o.height)*i,this.baseline=r.height*i+this.equation.fontSize*(Ps/2-Js),r.setTransform((this.width-r.width*i)/2,0,i),o.setTransform((this.width-o.width*i)/2,r.height*i,i)}drawElement(e,t,i,n){let r=n-this.equation.fontSize*(Ps/2-Js);this.$element.setLine({x:0,y:r},{x:t,y:r}),this.$element.setAttr("stroke",this.color||"currentColor"),lr(this.$element,e,this.status)}hitTestChildren(e){let{scale:t,y:i}=this.worldTransform,n=this.baseline-this.equation.fontSize*(Ps/2-Js),r=e.y<=i+n*t,o=this.children[r?0:1];return o.hitTestChildren(e)||o}},zi=class extends Gt{get expr(){let e=ze(this.children[0]);return this.type!=="msup"&&(e+="_"+ze(this.children[1])),this.type==="msup"&&(e+="^"+ze(this.children[1])),this.type==="msubsup"&&(e+="^"+ze(this.children[2])),e}measure(e){let[t,i,n]=this.children,r=this.type==="msup"?void 0:i,o=this.type==="msubsup"?n:this.type==="msup"?i:void 0,a=.05*this.equation.fontSize,h=_a(e,.65);t.measure(e),r&&r.measure(e*h),o&&o.measure(e*h);let l=o?o.height*h-.4*this.equation.fontSize:0,c=r?r.height*h-.5*this.equation.fontSize:0,u=o?o.width:0,d=r?r.width:0;this.width=t.width+a+Math.max(u,d)*h,this.height=t.height+l+c,this.baseline=t.baseline+l,t.setTransform(0,this.baseline-t.baseline),o&&o.setTransform(t.width+a,0,h),r&&r.setTransform(t.width+a,this.height-r.height*h,h)}clean(){if(super.clean(),this.children=this.children.filter(e=>e.type!=="mrow"||e.children.length),this.children.length===0)return this.detach();this.children.length===1&&(this.insertAfter(this.children),this.detach())}},Ua=class extends Gt{get expr(){let e=this.children[0].expr;return this.type!=="munder"&&(e+="_"+ze(this.children[1])),this.type==="mover"&&(e+="^"+ze(this.children[1])),this.type==="munderover"&&(e+="^"+ze(this.children[2])),e}measure(e){super.measure(e)}},pr=class extends Gt{constructor(e,t){super("mfenced",e,t,m("path"))}get expr(){return`(${this.children.map(e=>e.expr).join(",")})`}get marginLeft(){return .2}get marginRight(){return .2}measure(e){super.measure(e);let t=this.children[0];this.height=t.height+2,this.baseline=t.baseline+1;let i=1+this.height/this.equation.fontSize,n=.1*this.equation.fontSize;this.width=t.width+2*(i+n),t.setTransform(i+n,1)}drawElement(e,t,i){let n=Math.min(2+i/this.equation.fontSize,5),r=i-4,o=t-n,a=`M${n},2c${-2*n/3},${.15*r},${-n},${.32*r},${-n},${r/2}s${n/3},${.35*r},${n},${r/2}M${o},2c${2*n/3},${.15*r},${n},${.32*r},${n},${r/2}s${-n/3},${.35*r},${-n},${r/2}`;this.$element.setAttr("d",a),this.$element.css("stroke",this.color||"currentColor"),lr(this.$element,e,this.status)}clean(){super.clean(),this.children.length||this.detach()}},dr=class extends Gt{constructor(e,t,i){super(e,t,i,m("path"))}get expr(){return`sqrt(${this.children.map(e=>e.expr).join(", ")})`}get marginLeft(){return .2}get marginRight(){return .2}measure(e){super.measure(e);let t=this.children[0];this.height=t.height+2,this.baseline=t.baseline+2;let i=Math.min(16,3+5*this.height/this.equation.fontSize),n=.05*this.equation.fontSize;this.width=t.width+i+2*n,t.setTransform(i+n,2)}drawElement(e,t,i){let n=Math.min(16,3+5*i/this.equation.fontSize),r=i-2,o=`M0,${.55*r}L${.18*n},${.51*r}L${.45*n},${r}L${n},2L${t},2`;this.$element.setAttr("d",o),this.$element.css("stroke",this.color||"currentColor"),lr(this.$element,e,this.status)}clean(){super.clean(),this.children.length||this.detach()}},Wa=class extends Gt{constructor(t,i,n){super("matrix",t,i,m("g"));this.rows=n;this.cols=Math.floor(t.length/n)}get expr(){return`${this.children.map(t=>t.expr).join(", ")}`}measure(t){super.measure(t);let i=.6*this.equation.fontSize,n=z(a=>Math.max(...z(h=>this.children[a*this.cols+h].height,this.cols)),this.rows),r=z(a=>Math.max(...z(h=>this.children[h*this.cols+a].width,this.rows)),this.cols);this.height=N(n)+(this.rows-1)*i/2,this.width=N(r)+this.cols*i,this.baseline=(this.height+Ps*this.equation.fontSize)/2;let o=0;for(let a=0;a{this.checkForResize()&&this.equation.resize()}),(n=this.$body.$("x-blank, x-blank-mc"))==null||n.on("solve",r=>{Zt(()=>this.replace(r.solution,"#0f82f2"),r.restore?0:200)})}deleteFromDom(){var t;super.deleteFromDom(),(t=this.$body)==null||t.remove(),this.$body=void 0,this.$measure=void 0}replace(t,i){var o;let n=Number.isNaN(+t)?"mtext":"mn",r=new cr(n,t,this.equation);r.customColor=i,this.insertAfter([r]),(o=this.$body)==null||o.off("resize"),this.deleteFromDom(),this.equation.resize()}checkForResize(){var r,o;let t=this.height,i=this.width,n=this.baseline;return this.height=((r=this.$body)==null?void 0:r.height)||0,this.width=((o=this.$body)==null?void 0:o.width)||0,this.baseline=this.$measure.bounds.top-this.$body.bounds.top,!(x(t,this.height)&&x(i,this.width)&&x(n,this.baseline))}positionElement(t){var i,n;(i=this.$body)==null||i.css({left:t.x+"px",top:t.y+"px"}),x(t.scale,1)||(n=this.$body)==null||n.css("transform",`scale(${t.scale})`)}get expr(){var t;return`"${(t=this.$body)==null?void 0:t.text}"`}get log(){return`${this.expr}`}};var Be=class extends Re{constructor(t,i,n=0,r="=",o=18,a=!0){super();this.$row=t;this.$overlay=i;this.fontSize=o;this.isDisplay=a;this.isReady=!0;this.deletedNodes=new Set;this.root=new Ae([],this,r,n)}setValue(t){let i=Array.isArray(t)?t.map(n=>Gt.create(n,this)):this.parse(t);for(;this.root.children.length;)this.root.children[0].deleteFromDom();this.root.addChildren(i),this.updateDescription(),this.resize()}updateDescription(){try{let t=Et.parse(this.root.expr).toVoice();this.$row.setAttr("aria-label",t)}catch(t){this.$row.setAttr("aria-label","Invalid expression: "+this.root.expr)}}resize(){this.root.measure(),this.root.render()}parse(t){var a;let i=new DOMParser,n=Et.parse(t).toMathML(),r=i.parseFromString(`${n}`,"text/xml");if(((a=r.firstChild)==null?void 0:a.nodeName)==="parsererror")throw new Error(r.firstChild.textContent);let o=r.firstChild.childNodes;return Array.from(o,h=>Gt.create(h,this))}find(t){let[i,n]=t.split("`");i=i.replace(/[–-]/g,"\u2212");let r=+n||1,o=this.root.children.slice(0),a=0;for(;o.length;){let h=o.shift(),l=h instanceof Ae?void 0:ep(h,i);if(l&&(a+=1,a===r))return l;o.unshift(...h.children)}throw new Error(`Can't find element ${i}.`)}animate(t=1200){return D(this,null,function*(){this.isReady=!1,this.root.clean(),this.root.measure();let i=new hr;this.root.render(i),this.trigger("resize",{height:this.root.height});for(let n of this.deletedNodes)n.render(i);yield i.start(t);for(let n of this.deletedNodes)n.deleteFromDom();this.root.setStatus(""),this.deletedNodes.clear(),this.isReady=!0})}addTermAfter(t,i){let n=O(i?this.find(i):this.root.children),r=this.parse(t);n.insertAfter(r);for(let o of r)o.setStatus("adding");this.updateDescription()}addTermBefore(t,i){let n=i?this.find(i)[0]:this.root.children[0],r=this.parse(t);n.insertBefore(r);for(let o of r)o.setStatus("adding");this.updateDescription()}deleteTerm(t){for(let i of this.find(t))i.setStatus("deleting"),i.detach(),this.deletedNodes.add(i);this.updateDescription()}replaceTerm(t,i){let n=this.find(t),r=this.parse(i);n[0].insertBefore(r);for(let o of r)o.setStatus("adding");for(let o of n)o.setStatus("deleting"),o.detach(),this.deletedNodes.add(o);this.updateDescription()}moveTermAfter(t,i){let n=this.find(t);for(let o of n)o.roundedMotion=!0;O(i?this.find(i):this.root.children).insertAfter(n),this.updateDescription()}moveTermBefore(t,i){let n=this.find(t);for(let o of n)o.roundedMotion=!0;(i?this.find(i)[0]:this.root.children[0]).insertBefore(n),this.updateDescription()}moveTermToStart(t){let i=this.find(t);for(let n of i)n.roundedMotion=!0;this.root.children[0].insertBefore(i),this.updateDescription()}wrapTerms(t,...i){let n=i.map(o=>this.find(o));for(let o of n)for(let a of o)a.roundedMotion=!0;let r=this.parse(t);for(let o of r)o.setStatus("adding");n[0][0].insertBefore(r);for(let[o,a]of n.entries()){let h=this.find("$"+(o+1))[0];h.insertAfter(a),h.deleteFromDom()}this.updateDescription()}unwrapTerm(t,i=1){let n=this.find(t),r=n[0],o=1;for(;o<=i;)r=r.parent,r instanceof Ae&&(r=r.parent),o+=1;r.insertAfter(n),r.setStatus("deleting"),r.detach(),this.deletedNodes.add(r),this.updateDescription()}get leftSide(){let t=this.root.children.findIndex(i=>i.expr==="=");return this.root.children.slice(0,t-1)}get rightSide(){let t=this.root.children.findIndex(i=>i.expr==="=");return this.root.children.slice(t+1)}};var np='
';var rp=1200,$g=400,op=1200,ti=600,Bi=16,ur=class extends E{constructor(){super(...arguments);this.rows=[];this.isReady=!0;this.topOffset=4;this.currentHeight=0;this.currentStep=0;this.nextEvents={};this.backEvents={}}ready(){this.$svg=this.$("svg"),this.$lastRow=this.$svg.$("g"),this.$overlay=this.$(".overlay"),this.$legend=this.$(".legend-box"),this.$steps=this.$legend.$$("li"),this.$back=this.$(".back"),this.$next=this.$(".next");let t=+this.attr("dx")||0;this.equation=new Be(this.$lastRow,this.$overlay,t);let i=this.$(".math"),n=i?Array.from(i._el.children):[];this.equation.setValue(this.attr("expr")||n),this.currentHeight=this.topOffset+this.$lastRow.height+16,this.$svg.css("height",this.currentHeight+"px"),this.equation.on("resize",({height:o})=>{let a=this.topOffset+o+Bi;Math.abs(a-this.currentHeight)this.goBack()),this.$next.on("click",()=>this.goNext()),this.$steps[0].show(),b.onResize(()=>{let o=this.$svg.width/2;for(let a of[this.$lastRow,this.$overlay])a.css("transform",`translate(${o}px, ${this.topOffset}px)`);for(let a of this.rows)a.$el.css("transform",`translate(${o}px, ${a.top}px)`)});let r=this.$overlay.$$("x-blank, x-blank-mc");r.length&&(this.$next.addClass("hide"),Promise.all(r.map(o=>o.onPromise("solve"))).then(()=>setTimeout(()=>this.goNext(),rp)))}setup(t){this.one("next",({step:i})=>t.score("algebra-flow-"+(i-1)))}newRow(){return D(this,null,function*(){let t=this.$lastRow.copy(!0,!1),i=this.equation.root.height;this.rows.push({$el:t,height:i,top:this.topOffset}),this.$lastRow.insertBefore(t),b.redraw(),this.topOffset+=i+Bi,this.currentHeight=this.topOffset+i+Bi;for(let n of[this.$lastRow,this.$overlay])n.animate({transform:`translate(${this.$svg.width/2}px, ${this.topOffset}px)`},ti);yield this.$svg.animate({height:this.currentHeight+"px"},ti).promise})}hideLastRow(){return D(this,null,function*(){if(!this.rows.length)return;let t=this.rows.pop();this.topOffset=t.top;for(let i of[this.$lastRow,this.$overlay])i.animate({transform:`translate(${this.$svg.width/2}px, ${t.top}px)`},ti);this.currentHeight=t.top+this.$lastRow.height+Bi,this.$svg.animate({height:this.currentHeight+"px"},ti),yield t.$el.exit("fade",ti/2,ti/2).promise,t.$el.remove()})}onNextStep(t){this.nextEvents=t}onBackStep(t){this.backEvents=t}goNext(){return D(this,null,function*(){if(!this.isReady||!this.equation.isReady||this.currentStep>=this.$steps.length-1)return;this.isReady=!1;let t=this.currentStep+1;this.$steps[t].hasClass("new-row")&&(yield this.newRow(),yield wi($g)),t in this.nextEvents&&(yield this.nextEvents[t](this.equation),yield this.equation.animate(op),yield wi(rp)),yield this.go(t),this.trigger("next",{step:t}),this.isReady=!0})}goBack(){return D(this,null,function*(){if(!this.isReady||!this.equation.isReady||this.currentStep<=0)return;let t=this.currentStep-1;this.isReady=!1,this.currentStep in this.backEvents&&(yield this.backEvents[this.currentStep](this.equation),yield this.equation.animate()),this.$steps[this.currentStep].hasClass("new-row")&&this.hideLastRow(),yield this.go(t),this.trigger("back",{step:t}),this.isReady=!0})}go(t){return D(this,null,function*(){this.$steps[t].show();let i=this.$steps[t].height+"px";this.$steps[t].hide(),this.$legend.animate({height:i},800).promise.then(()=>this.$legend.css("height","auto"));let n=this.currentStep;this.currentStep=t,this.trigger("step",t),yield this.$steps[n].exit("fade",400).promise,this.$back.setClass("hide",t<=0),this.$next.setClass("hide",t>=this.$steps.length-1),yield this.$steps[t].enter("fade",400).promise})}};ur=T([S("x-algebra-flow",{template:np})],ur);var ap='
+
\u2212
\xD7
\xF7
\u03C0
';function cp(s){let e=s.prev;e&&_(e.tagName,"MO","MI","MN")?e.insertBefore(s):e?O(e.children).append(s):s.parent.hasClass("math")||(s.parent.prev?s.parent.prev.append(s):s.parent.parent.insertBefore(s))}function Pg(s){let e=s.next;if(e&&_(e.tagName,"MO","MI","MN"))return e.insertAfter(s);e?e.children[0].prepend(s):s.parent.hasClass("math")||(s.parent.next?s.parent.next.prepend(s):s.parent.parent.insertAfter(s))}function Tg(s){let e=s.parent;for(;e.parent.tagName!=="MFRAC"||!e.prev;){if(e.hasClass("math"))return;e=e.parent}e.prev.append(s)}function Sg(s){let e=s.parent;for(;e.parent.tagName!=="MFRAC"||!e.next;){if(e.hasClass("math"))return;e=e.parent}e.next.prepend(s)}function Eg(s){let e=s.prev,t=s.parent;if(e&&_(e.tagName,"MO","MI","MN"))e.remove(),t.children.length<=1&&t.addClass("empty");else if(!e&&!t.prev&&!t.hasClass("math")){let i=t.parent;i.insertBefore(s);for(let n of i.children)for(let r of n.children)i.insertBefore(r);i.remove(),s.parent.children.length<=1&&s.parent.addClass("empty")}else cp(s)}function Ts(s,e){e.insertBefore(s),e.parent.removeClass("empty"),s.children.length&&s.children[0].append(e)}function hp(s,e){"abcdefghijklmnopqrstuvwxyz\u03C0".includes(e)?Ts(m("mi",{text:e}),s):"0123456789.".includes(e)?Ts(m("mn",{text:e}),s):"+\u2212\xB1\xD7\xF7<>\u2264\u2265=%!".includes(e)?Ts(m("mo",{text:e,value:e}),s):e==="frac"?Ts(m("mfrac",{html:''}),s):e==="sqrt"?Ts(m("msqrt",{html:''}),s):_(e,"^","sup")?Ts(m("msup",{html:''}),s):e==="brackets"||"([{|".includes(e)?Ts(m("mfenced",{html:'',type:"("}),s):")]}".includes(e)&&!s.next&&s.parent.parent.tagName==="MFENCED"&&s.parent.parent.insertAfter(s)}function lp(s,e){let t=s.$$(`${e}:first-child, *:not(${e}) + ${e}`);for(let i of t)if(i.parent.tagName!=="MFRAC")for(;i.next&&i.next.tagName===e.toUpperCase();)i.text+=i.next.text,i.next.remove()}var Mg="This is not a valid mathematical expression.",Cg="Fill in all empty placeholders in the expression.",Ag={"+":"addition","\xD7":"multiplication","/":"fractions or division","\u2212":"subtraction",sqrt:"square roots","^":"powers"};function Ss(s,e){if(s instanceof Text)return s.textContent||"";if(s.hasClass("cursor"))return"";let t=s.childNodes;return s.tagName==="MI"?s.text+(e?" ":""):s.tagName==="MFENCED"?"("+Ss(t[0],e)+")":s.tagName==="MSUP"?"^("+Ss(t[0],e)+")":s.tagName==="MFRAC"?`(${Ss(t[0],e)})/(${Ss(t[1],e)})`:s.tagName==="MSQRT"?"sqrt("+Ss(t[0],e)+")":t.map(i=>Ss(i,e)).join("")}function kg(s,e){try{return{expr:Et.parse(s,!0,{variables:e})}}catch(t){return{error:t instanceof ot?t.message:Mg}}}function Vg(s,e,t){let i=s.variables;if(e.length){let n=i.find(o=>!e.includes(o));if(n){let o=zh(n,t||e);return o?`Did you mean \u201C${o}\u201D instead of \u201C${n}\u201D?`:`There shouldn\u2019t be a variable called \u201C${n}\u201D.`}let r=e.find(o=>!i.includes(o));if(r)return`Your expression should contain \u201C${r}\u201D.`}}function Ig(s,e){if(e.length){let t=s.functions.find(i=>!e.includes(i));if(t)return`This expression should not contain ${Ag[t]||"\u201C"+t+"\u201D"}.`}}function Lg(s,e,t=.001){try{return x(s.evaluate(),e.evaluate(),t)}catch(i){return!1}}var fr=class extends E{constructor(){super(...arguments);this.isDone=!1;this.shortVar=!1;this.lastAttempt="";this.errorCount=0;this.hints=[];this.fns=[];this.vars=[];this.validate=void 0}ready(){if(this.$math=this.$(".math"),this.$textarea=this.$("textarea"),this.$cursor=this.$(".cursor"),this.$error=this.$(".error-message"),this.solution=Et.parse(this.attr("solution")),this.hasAttr("numeric")&&(this.numeric=+this.attr("precision")||.01),this.vars=this.hasAttr("vars")?K(this.attr("vars")):this.solution?this.solution.variables:[],this.hasAttr("fns")&&(this.fns=K(this.attr("fns"))),this.solution&&this.fns.push(...this.solution.functions),this.fns.includes("/")&&!this.fns.includes("\xD7")&&this.fns.push("\xD7"),this.hasAttr("hints")&&(this.hints=K(this.attr("hints"))),this.hasAttr("substitutions")){this.substitutions={},this.autocomplete=this.vars.slice(0);for(let n of this.attr("substitutions").split("|"))if(n.trim()){let[r,o]=n.split(":");this.autocomplete.push(r.trim()),this.substitutions[r.trim()]=Et.parse(o)}}for(let n of["solution","precision","vars","fns","vars-required","substitutions"])this.removeAttr(n);this.shortVar=this.hasAttr("short-var");let t=K(this.attr("keys")||"+ \u2212 \xD7 \xF7 frac sup sqrt brackets"),i=this.$(".keys");for(let n of i.children)t.includes(n.data.type)?(n.on("pointerdown",r=>r.preventDefault()),n.on("pointerup",()=>{hp(this.$cursor,n.data.type),this.check()})):n.remove();this.on("pointerdown",n=>this.onPointerdown(n)),this.$textarea.on("focus",()=>this.onPointerdown()),this.$textarea.on("blur",()=>this.onBlur()),this.$textarea.on("key",n=>this.handleKey(n))}setup(t,i,n){var r;this.$step=t,(r=n==null?void 0:n.scores)!=null&&r.includes(i)&&this.solve(),this.on("solve",()=>{t.addHint("correct"),t.score(i)})}focus(){this.trigger("pointerdown")}onPointerdown(t){if(this.isDone)return;t&&t.preventDefault&&t.preventDefault(),this.addClass("active"),this.$textarea.focus();let i=t&&t.target?k(t.target):this;if(i.tagName==="X-EQUATION"||i.hasClass("math")){let n=this.$math.children,r=N(n.map(a=>a.outerWidth))/2;(t?Vt(t).x=5&&this.$step.addHint(`Hmmm\u2026 maybe try ${this.solution.toMathML()}?`)}check(){if(this.error=void 0,this.value=Ss(this.$math,this.shortVar).trim(),!this.value)return;if(this.$math.$(".empty"))return this.error=Cg;let t=kg(this.value,this.vars);if(t.error)return this.error=t.error;let i=this.substitutions?t.expr.substitute(this.substitutions):t.expr;if(this.numeric&&Lg(this.solution,i,this.numeric))return this.solve();if(this.validate){let o=this.validate(t.expr)||{};if(o.isCorrect)return this.complete(t.expr);if(o.error)return this.error=o.error}if(this.solution&&Et.numEquals(this.solution,i))return this.complete(t.expr);let n=Vg(i,this.vars,this.autocomplete);if(n)return this.error=n;let r=Ig(i,this.fns);if(r)return this.error=r}complete(t){this.isDone||(this.isDone=!0,this.removeClass("has-error active"),this.addClass("done"),this.$textarea.blur(),this.shortVar||lp(this.$math,"mi"),lp(this.$math,"mn"),this.trigger("solve",{expr:t}))}solve(){this.$math.removeClass("empty"),this.$math.html=this.solution.toMathML(),this.complete(this.solution)}};fr=T([S("x-equation",{template:ap})],fr);var Og={opacity:[0,1],transform:["translateX(-50px)","none"]},Rg={error:"You\u2019ve already had this expression before. Try simplifying it."},Dg="You have to fully simplify this expression. The correct solution is $0.",mr=class extends E{constructor(){super(...arguments);this.rowCount=1;this.previousAnswers=[];this.isSolved=!1;this.maxRows=6;this.steps=[];this.hints=[]}created(){this.$table=this.$("table tbody"),this.lastRowContent=this.$table.$("tr:last-child").html}ready(){this.hasAttr("max-rows")&&(this.maxRows=+this.attr("max-rows")),this.hasAttr("steps")&&(this.steps=this.attr("steps").split("|")),this.hasAttr("hints")&&(this.hints=this.attr("hints").split("|")),this.removeAttr("steps"),this.removeAttr("hints"),this.setupEquation(this.$("x-equation"))}setup(t,i,n){var r;this.$step=this.$equation.$step=t,(r=n==null?void 0:n.scores)!=null&&r.includes(i)&&this.solve(),this.on("solve",()=>{t.addHint("correct"),t.score(i)}),this.on("hint",o=>t.addHint(o))}setupEquation(t){this.$equation=t,this.$equation.$step=this.$step,t.one("solve",i=>this.onSolveRow(i.expr)),t.hints=this.hints,t.validate=i=>{let n=this.previousAnswers.includes(i.toString());return(this.validate?this.validate(i,n):void 0)||(n?Rg:{})}}onSolveRow(t){if(this.trigger("solve-row",{expr:t,$math:this.$equation.$math}),this.isFinal&&this.isFinal(t))return this.trigger("solve");if(this.isSolved)return;if(this.rowCount+=1,this.previousAnswers.push(t.toString()),this.rowCount>this.maxRows){let n=this.$equation.solution.toMathML();this.trigger("hint",Dg.replace("$0",n)),this.trigger("solve")}let i=m("tr",{html:this.lastRowContent},this.$table);i.animate(Og,400,500),this.setupEquation(i.$("x-equation")),setTimeout(()=>this.$equation.focus(),1200)}solve(){if(this.isSolved=!0,this.steps.length){let t=this.$table.$("tr:last-child"),i=this.lastRowContent.replace(//,'');for(let n of this.steps){let r=m("tr",{html:i},this.$table),o=r.$(".math.fill"),a=Et.parse(n);o.html=a.toMathML(),t.insertBefore(r),this.trigger("solve-row",{expr:a,$math:o})}}this.$equation.solve()}};mr=T([S("x-equation-system")],mr);var Ya=Math.PI/2;function gr(s){if(rt(s))return[s];if(St(s))return s.points;if(it(s))return[s.p1,s.p2];if(qt(s))return gr(s.shape(!0));if(U(s))return[s.c.shift(s.r,0),s.c.shift(-s.r,0),s.c.shift(0,s.r),s.c.shift(0,-s.r)];if(Ze(s))return s.extremes;if(Pe(s)||Dt(s)){let e=[s.start,s.end];Pe(s)&&e.push(s.c);let t=s.radius;for(let[i,n]of[[t,0],[0,t],[-t,0],[0,-t]]){let r=s.c.shift(i,n);Ft.prototype.contains.call(s,r)&&e.push(r)}return e}return[]}function It(...s){return G.aroundPoints(function*(){for(let e of s)for(let t of gr(e))yield t}())}function pp(s,e){let t=It(...Array.from(s,n=>n.transformed.rotate(-e))),i=t.p.shift(t.w/2,t.h/2).rotate(e).shift(-t.w/2,-t.h/2);return new G(i,t.w,t.h)}function wr(s,e,t){return!s.size&&!e.size?new lt(0,100,0,100):G.aroundPoints(function*(){for(let i of s.values())if(i.transformed&&(i.props.status!=="hidden"||t))for(let n of gr(i.transformed))yield n;for(let i of e.values())if(i.path)for(let n of gr(i.path))yield n}()).bounds}function _i(s,e,t){if(rt(e))return s.contains(e);if(Ye(e))return V.collision(s.polygon,e);if(Wo(e))return e.collision(s);if(it(e))return Q(e,s).length>0||s.contains(e.p1);if(qt(e))return _i(s,e.shape(!0),t);if(U(e))return t==="geo"?Q(e,s).length>0||s.contains(e.at(0)):e.collision(s);if(Pe(e)||Dt(e)){let i=new V(e.c,e.start,e.at(.25),e.at(.5),e.at(.75),e.end);return V.collision(s.polygon,i)}if(Ze(e)){let i=new V(...oe(0,1,.125).map(n=>e.at(n)));return V.collision(s.polygon,i)}return!1}var vr=class{constructor(e){this.$parent=e;this.visible=!1;this.$el=m("div",{class:"tile-error",hidden:!0},e.$html),this.$text=m("span",{},this.$el),this.$button=m("button",{text:"Select Errors"},this.$el),this.$button.on("click",()=>{e.selection.clear(),this.error&&e.selection.select(this.error.locations||[]),this.hide()})}show(e,t){var i;this.visible&&this.error===t||(this.visible=!0,this.$el.setTransform(e),this.$text.html=t.message,this.$button.toggle(!!((i=t==null?void 0:t.locations)!=null&&i.length)),this.$el.enter("pop",200),this.error=t)}hide(){this.visible&&(this.visible=!1,this.$el.exit("pop",200),this.error=void 0)}},Xa=new Map;function _e(s,e=!0){if(!s||!e||!b.theme.isDark)return s;if(Xa.has(s))return Xa.get(s);let t=$t.fromHex(s),i=t.hsl;nt(i[2],30,70)||(i[2]=100-i[2]);let n=$t.fromHsl(...i);n.a=t.a;let r=n.hex;return Xa.set(s,r),r}var yr=Oe(s=>{let e=$t.fromHex(s),[t,i,n]=["r","g","b"].map(o=>e[o]<=128?0:2*e[o]-255);return new $t(t,i,n).hex}),br=Oe(s=>$t.from(s).brightness<195?"#fff":"#000");function dp(s){let e=s==null?void 0:s.items;if(e!=null&&e.length)for(let t=0;t+d);let r=n.length>0?+n[0]:t?t[0]:0,o=n.length>1?+n[1]:t?t[1]:e;if(x(r,o))return[r-1,o+1,1];i&&(o+=.01*(o-r));let a=Math.floor(Math.abs(e)/Ng),h=(o-r)/a,l=Math.floor(Math.log10(h)),c=Math.pow(10,l),u=Gg.find(d=>c*d<=h)*c;return o=u*Math.ceil(o/u),r=u*Math.floor(r/u),[r,o,u]}function xr(s,e=4e3){let t=k(`x-alert[key=${s}]`);return t==null?void 0:t.open(e)}function up(s,e){let t=new p(-s/2,-e/2);return new G(t,s,e)}function Qa(s,e,t){if(!s)return;let i={},n=0;for(let r of s){let o=e(r);if(o&&(i[r.id]=o,n+=1),t&&n>t)break}return n?i:void 0}function fp(s,e,t,i,n){return m("use",{href:`/icons.13d4c88a.svg#${s}`,fill:e,width:t,height:t,x:i==null?void 0:i.x,y:i==null?void 0:i.y},n)}function mp(s=0){return 20*1.2**s}function*ke(s,e=!1){for(let t of s){let i=t.is("group");(!i||e)&&(yield t),i&&(yield*ks(ke(t.children,e)))}}function*gp(s){let e=new Set;for(let t of s)if(t.group){let i=t.group;for(;i.group;)i=i.group;if(e.has(i))continue;e.add(i),yield i}else yield t}function Ja(s){let e=Math.min(...s.map(i=>Math.min(...i.map(n=>n.y)))),t=Math.max(...s.map(i=>Math.max(...i.map(n=>n.y))));return[e,t]}function Ve(s,e,t){return s.hasAttr(e)?s.attr(e)!=="no":t}function vp(s){let e=K(s).map(t=>+t);return e.length===1?[e[0],e[0],e[0],e[0]]:e.length===2?[e[0],e[1],e[0],e[1]]:e.length===3?[e[0],e[1],e[2],e[1]]:e}function wp(s){let e=s.split(",");return[e[0]!=="no",(e.length>1?e[1]:e[0])!=="no"]}var yp={hasGeoModel:!0,pi:Math.PI,point:(s,e)=>s!==void 0&&e!==void 0?new p(s,e):void 0,angle:(s,e,t)=>s&&e&&t?new kt(s,e,t):void 0,line:(s,e)=>s&&e&&!s.equals(e)?new vt(s,e):void 0,ray:(s,e)=>s&&e&&!s.equals(e)?new Xo(s,e):void 0,segment:(s,e)=>s&&e&&!s.equals(e)?new Y(s,e):void 0,circle:(s,e)=>s&&e?new wt(s,e):void 0,arc:(s,e,t)=>s&&e&&t?new Ft(s,e,t):void 0,sector:(s,e,t)=>s&&e&&t?new Yo(s,e,t):void 0,polygon:(...s)=>s.every(e=>e)?new V(...s):void 0,polyline:(...s)=>s.every(e=>e)?new te(...s):void 0,triangle:(s,e,t)=>s&&e&&t?new Pi(s,e,t):void 0,rectangle:(s,e,t)=>s?new G(s,e,t):void 0,distance:p.distance,round:(s,e=0)=>Rt(s,e),sqrt:Math.sqrt,floor:Math.floor,ceil:Math.ceil,intersections:Q};function $r(s,e,t){let i=t,n;for(let r of s){let o=e(r);o!==void 0&&o`,is=class extends E{constructor(){super(...arguments);this.labelSuffix=["",""];this.gridSize=[1,1];this.showGrid=!1;this.showXAxis=!1;this.showYAxis=!1;this.showLabels=!1}setupCoordinates(t,i={}){this.$svg=t,t.addClass("canvas"),this.proportional=!!i.proportional,this.padding=vp(this.attr("padding")||i.padding||"0"),Ve(this,"grid",i.showGrid||!1)&&(this.$grid=m("g",{class:"grid"}),t.prepend(this.$grid),this.showGrid=!0);let n=this.attr("axes")||(i.showAxes?"yes":"no");[this.showXAxis,this.showYAxis]=wp(n),(this.showXAxis||this.showYAxis)&&(m("defs",{html:zg},t),this.$axes=m("g",{class:"axes"}),t.prepend(this.$axes),this.axisNames=(this.attr("axis-names")||",").split(",")),this.$axes&&Ve(this,"labels",!0)&&(this.labelSuffix=(this.attr("label-suffix")||",").split(","),this.showLabels=!0),(this.showLabels||this.axisNames)&&(this.$labels=m("g",{class:"labels"},t)),this.resize()}resize(){this.css("max-width","none");let t=+this.attr("width")||this.width,i=+this.attr("height")||(this.hasAttr("width")?t:this.height);this.css("max-width",t+"px"),this.$svg.setAttr("width",t),this.$svg.setAttr("height",i),this.$svg.setAttr("viewBox",`0 0 ${t} ${i}`);let n=this.padding;this.viewportBounds=new lt(n[3],t-n[1],n[0],i-n[2]),this.updatePlotBounds(),this.positionElements(t,i)}updatePlotBounds(t){let[i,n,r]=Za(this.attr("x-axis"),this.viewportBounds.dx,t==null?void 0:t.xRange),[o,a,h]=Za(this.attr("y-axis"),this.viewportBounds.dy,t==null?void 0:t.yRange),l=Math.abs(this.viewportBounds.dx/(n-i)),c=Math.abs(this.viewportBounds.dy/(a-o)),u=Math.min(l,c),d=this.proportional?l/u:1,g=this.proportional?c/u:1;this.plotBounds=new lt(d*i,d*n,g*a,g*o),this.plotScale=this.proportional?u:(l+c)/2,this.gridSize=[r,h];let[y,f]=[this.plotBounds,this.viewportBounds];this.plotToViewportMatrix=[[f.dx/y.dx,0,f.xMin-y.xMin/y.dx*f.dx],[0,f.dy/y.dy,f.yMin-y.yMin/y.dy*f.dy]];let v=i>0?d*i:n<0?d*n:0,w=o>0?g*o:a<0?g*a:0;this.plotOrigin=new p(v,w),this.drawAxes()}drawAxes(){let[t,i]=[this.plotBounds,this.viewportBounds],n=this.toViewportCoords(this.plotOrigin),[r,o]=this.gridSize;if(this.$grid&&this.$grid.removeChildren(),this.$axes&&this.$axes.removeChildren(),this.$labels&&this.$labels.removeChildren(),this.showGrid||this.showXAxis){let a=r*Math.trunc(t.xMin/r+.01);for(let h=a;ho=void 0,move:a=>{let h=B(Math.round((a.x-n.xMin)*r),0,this.steps-1);this.points[h]=this.toPlotCoords(new p(n.xMin+h/r,a.y)),o&&this.interpolate(o,h),o=h,this.redraw()},end:()=>this.snap()})}interpolate(t,i){in).map(n=>[n.x,n.y]),i=qo.bestPolynomial(t);if(i){for(let n=0;nt}ready(){let t=m("svg",{},this);if(this.$plot=m("g",{class:"plot"},t),this.$overlay=m("g",{class:"overlay"},t),this.setupCoordinates(t,{showGrid:!0,showAxes:!0,padding:"20"}),this.hasAttr("fn")){let i=Et.parse(this.attr("fn"),!0);this.setFunctions(n=>i.evaluate({x:n}))}Ve(this,"crosshairs",!0)&&(this.crosshairGrid=+this.attr("crosshair-grid")||10,this.setupCrosshairs(t))}setPoints(t,i=1){let n=t.map((r,o)=>new p(o+i,r));this.setSeries(n)}setSeries(...t){let i=Math.max(...t.map(o=>O(o).x)),[n,r]=Ja(t);this.updatePlotBounds(new lt(0,i,n,r)),this.$plot.removeChildren();for(let o of t)this.drawLinePlot(o);this.getCrosshairPosn=o=>t[0].reduce((a,h)=>Math.abs(h.x-o.x)<=Math.abs(a.x-o.x)?h:a)}setFunctions(...t){let[i,n]=[this.plotBounds,this.viewportBounds],r=t.map(l=>{let c=[];for(let u=n.xMin;u{let c=Pt(B(l.x,i.xMin,i.xMax),h);return new p(c,t[0](c))}}drawLinePlot(t){let i=m("g",{},this.$plot),n=m("path",{},i),r=this.plotBounds;t=t.filter(a=>a.y>=r.yMax&&a.y<=r.yMin);let o=t.map(a=>this.toViewportCoords(a));this.isAnimated?pt(a=>{let h=t.findIndex(l=>l.x>r.xMin+a*r.dx);n.points=o.slice(0,h)},Tp):n.points=o}drawPoints(t){let i=m("g",{},this.$plot),n=this.plotBounds;for(let r of t){let o=this.toViewportCoords(r),a=m("circle",{r:4,cx:o.x,cy:o.y},i);if(this.isAnimated){a.hide();let h=Tp*(r.x-n.xMin)/(n.xMax-n.xMin);setTimeout(()=>a.show(),h)}}}setupCrosshairs(t){let i=m("g",{class:"crosshair"},t),n=m("path",{},i),r=m("circle",{r:4},i),o=m("text",{},i),a=0,h=l=>{let c=this.getCrosshairPosn(this.toPlotCoords(l));if(x(c.x,a))return;a=c.x;let u=this.toViewportCoords(c),d=this.toViewportCoords(this.plotOrigin);r.setCenter(u),n.points=[new p(d.x,u.y),u,new p(u.x,d.y)],o.text=`(${Ot(c.x,5,!1)}, ${Ot(c.y,5,!1)})`;let g=o.width,y=u.x+8+g20?u.y-7:u.y+18)};kl(t,{enter:()=>i.show(),move:l=>h(l),exit:()=>i.hide()})}};Tr=T([S("x-coordinate-system")],Tr);var ei=class{constructor(e,t){this.$canvas=e;this.defaultCallbacks=t;this.callbacks=new WeakMap;this.global=[];this.isMoving=!1;this.shiftKey=!1;this.altKey=!1;this.cancelled=!1;document.addEventListener("keydown",i=>this.checkKeys(i)),document.addEventListener("keyup",i=>this.checkKeys(i)),document.addEventListener("visibilitychange",()=>{this.shiftKey=this.altKey=!1}),this.$root=Xt,e.css("touch-action","none"),e.on("pointerdown",i=>this.startEvent(i)),C.onKey("Escape",()=>this.cancel()),t.hover&&e.on("pointermove",i=>{this.isMoving||t.hover({posn:me(i,e),event:i,target:i.target})})}checkKeys(e){this.shiftKey=e.shiftKey,this.altKey=e.altKey}listen(e,t){this.callbacks.set(e._el,t),e.hasParent(this.$canvas)||(e.css("touch-action","none"),e.on("pointerdown",i=>this.startEvent(i)))}listenAll(e){this.global.push(e)}startEvent(e){var d,g,y;if(e.handled||e.button)return;this.isMoving=!0,this.cancelled=!1,e.preventDefault(),this.checkKeys(e);let t=e.pointerId,i=e.target,n=this.getCallbacks(i);"shiftKey"in e&&(this.shiftKey=e.shiftKey),n.blurInput!==!1&&((d=b.getActiveInput())==null||d.blur());let r=me(e,this.$canvas),o=r,a=!1,h;if(this.constrainInBox){let f=this.$canvas.boundsRect;h=new lt(f.p.x,f.p.x+f.w,f.p.y,f.p.y+f.h)}let l=f=>{var $,I,A,M;if(f.pointerId&&f.pointerId!==t)return;if(f.preventDefault(),this.checkKeys(f),this.cancelled)return c(f);let v=Vt(f);if(h&&(v=v.clamp(h)),v=v.transform(this.$canvas.inverseTransformMatrix),p.distance(v,o)<.5)return;if(!a){let P={posn:r,event:f,target:i};($=n.start)==null||$.call(n,P);for(let j of this.global)(I=j.start)==null||I.call(j,P)}let w={posn:v,startPosn:r,lastPosn:o,event:f,target:i};(A=n.move)==null||A.call(n,w);for(let P of this.global)(M=P.move)==null||M.call(P,w);!a&&n.cursor!==!1&&this.grabbing(),o=v,a=!0},c=f=>{var w,$,I,A,M,P;if(f.pointerId&&f.pointerId!==t)return;f.preventDefault(),this.checkKeys(f),C.off("pointermove",l),C.off("pointerstop",c);let v={posn:r,event:f,target:i};(w=n.up)==null||w.call(n,v);for(let j of this.global)($=j.up)==null||$.call(j,v);if(a){let j={posn:o,lastPosn:o,startPosn:r,event:f,cancelled:this.cancelled,target:i};(I=n.end)==null||I.call(n,j);for(let ne of this.global)(A=ne.end)==null||A.call(ne,j)}else if(!this.cancelled){(M=n.click)==null||M.call(n,v);for(let j of this.global)(P=j.click)==null||P.call(j,v)}this.grabbing(!1),this.isMoving=this.cancelled=!1},u={posn:r,event:e,target:i};(g=n.down)==null||g.call(n,u);for(let f of this.global)(y=f.down)==null||y.call(f,u);C.on("pointermove",l),C.on("pointerstop",c)}grabbing(e=!0){this.$root.setClass("grabbing",e)}getCallbacks(e){for(;e&&e!==this.$canvas._el;){let t=this.callbacks.get(e);if(t&&(!t.checkIfActive||t.checkIfActive()))return t;e=e.parentNode||void 0}return this.defaultCallbacks}cancel(){this.cancelled=!0}};function _g(s,e){if(typeof s=="string"){let t=ct(s);return i=>{var n;return(n=t(e))==null?void 0:n.equals(i)}}return typeof s=="function"?s:t=>s.equals(t)}function th(s,e,t){let i=e.map(g=>_g(g,s.model)),n=re(void 0,e.length),r=Ke(),o=[],a=({point:g})=>o.push(g),h=t.maxErrors||4,l=0,c=({path:g})=>{t.onBegin&&t.onBegin(g)},u=()=>{n.every(g=>g)&&(t.onComplete&&t.onComplete(!0),s.off("add:path",d),s.off("begin:path",c),s.off("add:point",a),r.resolve(n))},d=({path:g})=>{let y=g.value;if(y){for(let[f,v]of i.entries())if(!n[f]&&v(y))return n[f]=g,t.onCorrect&&t.onCorrect(g,f),l=0,o=[],u();g.delete();for(let f of o)f.delete();if(o=[],!(it(y)&&y.length<1))if(l+=1,l>=h){let f=n.findIndex(w=>!w),v=e[f];if(typeof v!="function"){let w=s.drawPath(v,{animated:1e3});n[f]=w,t.onHint&&t.onHint(w,f),l=0,u()}}else t.onIncorrect&&t.onIncorrect(g)}};return s.on("begin:path",c),s.on("add:path",d),s.on("add:point",a),r.promise}function Mp(s,e){return m("text",{target:s.attr("target")||void 0,class:s.attr("label-class")||s.attr("class")||void 0,"data-when":s.data.when,style:e?`color: ${e}`:void 0,"text-anchor":"middle"})}function Sp(s,e){let t=[];for(let i of e.paths)i!==s&&i.value&&t.push(i.value.transform(e.plotToViewportMatrix));return t}var qg=new wt(new p(0,-9),12);function Ep(s,e,t){for(let i of t)if(e.every(n=>!Q(qg.translate(i),n).length))return i;return t[0]}function Cp(s,e){let t=s.value.transform(e.plotToViewportMatrix),i=s.$el;if(it(t)){let n=t.perpendicularVector,r=t.angle;n.y>=0&&(n=n.scale(-1),r+=Math.PI);let o=[];for(let l of[.5,.35,.65])for(let c of[-15,5])o.push(t.at(l).add(n.scale(c)));if(!e.labelPositioning)return[o[0],r];let a=Sp(s,e),h=Ep(t,a,o);return i.hasAttr("mark")&&(h=h.add(t.unitVector.scale(12))),[h,r]}if(Pe(t))return[t.at(.5).subtract(t.c).scale(.6).add(t.c).shift(0,5)];if(Dt(t)){let n=new vt(t.start,t.end),r=n.perpendicularVector.y>=0,o=n.angle+(r?Math.PI:0);return[t.at(.5).add(n.perpendicularVector.scale(r?14:5)),o]}if(qt(t)){let n=(+i.attr("size")||(t.isRight&&!i.hasAttr("round")?20:t.radius))+8;return[t.b.add(t.bisector.unitVector.scale(n+5)).shift(0,3)]}if(rt(t)){let n=i.hasClass("move")?10:8,r=[t.shift(n,-n),t.shift(-n,-n),t.shift(n,10+n),t.shift(-n,10+n)];if(!e.labelPositioning)return[r[0]];let o=Sp(s,e);return[Ep(t,o,r)]}return St(t)?[t.centroid.shift(0,5)]:U(t)?[t.c.shift(0,5)]:[]}var Sr=class{constructor(e,t,i,n){this.$parent=e;this.$el=i;this.color="";this.label="";this.isPending=!1;this.isLocked=!1;this.components=[];this.dependencies=[];this.fixedLabel=!1;this.name=n||e.model.getKey(),e.shapes.set(this.name,this),e.model.watch(r=>{let o=r[this.name];this.$el.css("display",o?"block":"none"),this.$label&&this.$label.css("display",o?"block":"none"),o&&this.redraw(o),e.queueLabelPositioning()}),this.color=i.css("color")||"",this.setValue(t),i.hasAttr("label")&&this.setLabel(i.attr("label"))}get value(){return this.$parent.model[this.name]}get type(){var e;return(e=this.value)==null?void 0:e.type}get locked(){return this.isLocked}get isHidden(){return this.isPending||this.$el.hasAttr("hidden")||this.$el.hasClass("transparent")}setValue(e){e instanceof Function?this.$parent.model.setComputed(this.name,e):this.$parent.model[this.name]=e}setLabel(e,t,i){this.$label||(this.$label=Mp(this.$el,t),this.$parent.$objLabels.append(this.$label));let n=bn(e);if(this.$parent.model.watch(r=>this.$label.text=n(r)||""),this.fixedLabel=!!i,i){let r=ct(i);this.$parent.model.watch(o=>{this.$label.setTransform(r(o).shift(0,5))})}this.updateLabelPosition()}setColor(e){this.color=e,this.$el.css("color",e);for(let t of this.dependencies)t.setColor(e);this.$label&&this.$label.css("color",e)}updateLabelPosition(){if(!this.$label||!this.value||this.fixedLabel)return;let[e,t]=Cp(this,this.$parent);this.$label.setTransform(e,t)}select(){this.$el.addClass("selected"),this.$el.parent.append(this.$el);for(let e of this.dependencies)e.select()}deselect(){this.$el.removeClass("selected");for(let e of this.dependencies)e.deselect()}hover(e=!1){if(!e){if(this.$parent.hovering===this)return;this.$parent.hovering&&this.$parent.hovering.unhover(),this.$parent.hovering=this}this.$el.addClass("hover");for(let t of this.dependencies)t.hover(!0)}unhover(e=!1){if(!e){if(this.$parent.hovering!==this)return;this.$parent.hovering=void 0}this.$el.removeClass("hover");for(let t of this.dependencies)t.unhover(!0)}delete(e=300){return D(this,null,function*(){this.$parent.shapes.delete(this.name);for(let t of this.components)t.deselect();this.$label&&this.$label.exit("fade",e,0,!0),yield this.removeElement(e),this.$parent.model[this.name]=void 0})}},Ie=class extends Sr{constructor(t,i,n,r,o=!1){r||(r=m("circle",{}));super(t,i,r,n);this.$parent.hidePoints||t.$points.append(this.$el),t.points.add(this),this.projectionId=t.model.getKey(),this.projectionOffset=void 0,t.model.watch(a=>{this.projection=a[this.projectionId],this.projection&&(this.projectionOffset===void 0&&(this.projectionOffset=this.projection.offset(this.$parent.model[this.name])),this.$parent.model[this.name]=this.projection.at(this.projectionOffset))}),this.lock(o)}setValue(t){t instanceof Function?(this.project(void 0),this.$parent.model.setComputed(this.name,t)):(t&&this.projection&&(t=this.projection.project(t),this.projectionOffset=this.projection.offset(t)),this.$parent.model[this.name]=t)}redraw(t){let i=t.transform(this.$parent.plotToViewportMatrix);this.$el.setCenter(i),this.$halo&&this.$halo.setCenter(i),this.$pulse&&this.$pulse.setCenter(i)}removeElement(t){return D(this,null,function*(){this.$parent.points.delete(this),yield this.$el.exit("pop",t,0,!0).promise})}distance(t){return this.value?p.distance(t,this.value):1/0}lock(t=!0){this.isLocked=t,this.$el.setClass("move",!t),t?this.$el.removeAttr("tabindex"):this.$el.setAttr("tabindex",0)}project(t){if(this.projectionOffset=void 0,typeof t=="string"){let i=ct(t);this.$parent.model.setComputed(this.projectionId,i)}else t?this.$parent.model.setComputed(this.projectionId,()=>t.value):this.$parent.model[this.projectionId]=void 0}makeIntersection({path1:t,path2:i,index:n}){this.setValue(r=>{if(!r[t.name]||!r[i.name])return;let o=Q(r[t.name],r[i.name]);return o[Math.min(n,o.length-1)]}),this.lock()}addHalo(){this.$halo=m("circle",{class:"halo",r:18},this.$parent.$pulses),this.$halo.setCenter(this.$el.center),this.$halo.enter("pop")}removeHalo(){return D(this,null,function*(){this.$halo&&(this.$halo.exit("pop",500,0,!0),this.$halo=void 0)})}pulsate(){this.$pulse=m("circle",{class:"pulse",r:8},this.$parent.$pulses),this.$pulse.setCenter(this.$el.center),this.$el.one("mouseover pointerdown focus",()=>{this.$pulse&&this.$pulse.remove(),this.$pulse=void 0})}},qe=class extends Sr{constructor(e,t,i,n){super(e,t,n||m("path"),i),e.$paths.append(this.$el),e.paths.add(this)}get locked(){return this.isLocked||!this.components.length||this.components.every(e=>e.locked)}redraw(e){let t=e.transform(this.$parent.plotToViewportMatrix);this.$el.draw(t,{box:this.$parent.viewportRect})}distance(e){return this.value?p.distance(e,this.value.project(e)):1/0}removeElement(e){return D(this,null,function*(){this.$parent.paths.delete(this),yield this.$el.exit("draw",e,0,!0).promise})}setComponents(e,t){this.components=this.dependencies=e,this.setValue(()=>{let i=e.map(n=>n.value);if(!i.some(n=>n===void 0))return t(...i)})}};var qi=class{constructor(e){this.$parent=e}enable(){}down(e){}start(e){}move(e,t){}end(e){}hover(e){}click(e){}cancel(){}snapToGrid(e){return this.$parent.snapToGrid?e.round(this.$parent.snapToGrid):e}snapToPoint(e,t){if(this.snapPoint=this.$parent.getPointAt(t),this.snapPoint)return e.$el.setClass("move",!this.snapPoint.locked),e.setValue(this.snapPoint.value);if(this.snapIntersect=this.$parent.getIntersectionAt(t),this.snapIntersect)return e.$el.removeClass("move"),e.setValue(this.snapIntersect.posn);if(!this.$parent.snapToGrid&&(this.snapPath=this.$parent.getPathAt(t),this.snapPath))return e.setValue(this.snapPath.value.project(t));e.$el.addClass("move"),e.setValue(this.snapToGrid(t))}getOrMakePointAt(e){let t=this.$parent.getPointAt(e);if(!t){t=new Ie(this.$parent,this.snapToGrid(e));let i=this.$parent.getIntersectionAt(e);if(i)t.makeIntersection(i);else if(!this.$parent.snapToGrid){let n=this.$parent.getPathAt(e);n&&t.project(n)}this.$parent.trigger("add:point",{point:t})}return t}showPendingPointAt(e){var n,r,o;let t=((n=this.$parent.getIntersectionAt(e))==null?void 0:n.posn)||((o=(r=this.$parent.getPathAt(e))==null?void 0:r.value)==null?void 0:o.project(e)),i=!!t;if(this.$parent.$pendingPoint.toggle(i),i){let a=this.$parent.toViewportCoords(t||e);this.$parent.$pendingPoint.setCenter(a)}}},Fi=class extends qi{constructor(){super(...arguments);this.isMoving=!1}enable(){}down(t){this.obj=this.$parent.getPointAt(t)||this.$parent.getPathAt(t),this.obj||this.$parent.deselect();let i=this.$parent.selection;i!==this.obj&&(i&&i.components.includes(this.obj)||this.$parent.select(this.obj))}start(){this.obj&&(this.isMoving=!0,this.obj.isPending=!0,this.$parent.updateIntersections(),this.$parent.trigger("move",{obj:this.obj}))}move(t,i){if(!(!this.obj||this.obj.locked||this.$parent.locked))if(this.obj instanceof qe){let n=t.subtract(i);for(let r of this.obj.components)r.locked||r.setValue(r.value.add(n))}else this.obj instanceof Ie&&this.obj.setValue(this.snapToGrid(t))}end(){this.obj&&(this.isMoving=!1,this.obj.isPending=!1,this.snapPoint||(this.snapIntersect?this.obj.makeIntersection(this.snapIntersect):this.snapPath&&this.obj.project(this.snapPath)),this.$parent.trigger("moveEnd",{path:this.obj}),this.obj=void 0,this.$parent.updateIntersections())}hover(t){if(this.isMoving)return;let i=this.$parent.getPointAt(t)||this.$parent.getPathAt(t),n=i&&!this.$parent.locked&&!i.locked,r=i&&this.$parent.canSelect;this.$parent.setCursor(n?"grab":r?"pointer":"default"),n||r?i.hover():this.$parent.hovering&&this.$parent.hovering.unhover()}},Er=class extends Fi{down(e){this.$parent.deselect(),this.obj=this.getOrMakePointAt(e),this.$parent.select(this.obj)}hover(e){let t=this.$parent.getPointAt(e);if(t)return this.$parent.setCursor(this.$parent.locked||t.locked?"default":"grab"),this.$parent.$pendingPoint.hide(),t.hover();this.$parent.hovering&&this.$parent.hovering.unhover(),this.$parent.setCursor("crosshair"),this.showPendingPointAt(e)}},si=class extends qi{enable(){this.$parent.setCursor("crosshair")}down(t){this.$parent.deselect(),this.startPoint=this.getOrMakePointAt(t)}start(t){this.startPoint&&(this.$parent.$pendingPoint.hide(),this.endPoint=new Ie(this.$parent,t),this.endPoint.isPending=!0,this.endPoint.$el.addClass("pending"),this.path=new qe(this.$parent,void 0),this.path.setComponents([this.startPoint,this.endPoint],this.expr),this.path.isPending=!0,this.$parent.updateIntersections(),this.$parent.trigger("begin:path",{path:this.path,start:this.startPoint}))}move(t){if(!this.startPoint||!this.path||!this.endPoint)return;if(p.distance(t,this.startPoint.value)<20/this.$parent.plotScale)return this.endPoint.setValue(this.snapToGrid(t));this.snapToPoint(this.endPoint,t)}end(){if(!this.startPoint||!this.path||!this.endPoint)return;this.path.isPending=!1,this.endPoint.isPending=!1,this.startPoint.value.equals(this.endPoint.value)?(this.endPoint.delete(),this.path.delete(),this.path=this.endPoint=void 0):this.snapPoint?(this.path.setComponents([this.startPoint,this.snapPoint],this.expr),this.endPoint.delete(),this.endPoint=void 0):this.snapIntersect?this.endPoint.makeIntersection(this.snapIntersect):this.snapPath&&this.endPoint.project(this.snapPath),this.endPoint&&(this.$parent.trigger("add:point",{point:this.endPoint}),this.endPoint.$el.removeClass("pending"));let t=this.path;this.startPoint=this.endPoint=this.path=void 0,t&&(this.$parent.trigger("add:path",{path:t}),this.$parent.updateIntersections())}hover(t){let i=this.$parent.getPointAt(t);if(i)return this.$parent.$pendingPoint.hide(),i.hover();this.$parent.hovering&&this.$parent.hovering.unhover(),this.showPendingPointAt(t)}cancel(){this.endPoint&&this.endPoint.delete(),this.path&&this.path.delete(),this.$parent.$pendingPoint.hide(),this.startPoint=this.endPoint=this.path=void 0}},Mr=class extends si{expr(e,t){return new Y(e,t)}},Cr=class extends si{expr(e,t){return new wt(e,p.distance(e,t))}},Ar=class extends si{expr(e,t){return new G(e,t.x-e.x,t.y-e.y)}},kr=class extends si{expr(e,t){return new Y(e,t).perpendicularBisector}},Ap=(s,e,t)=>new kt(s,e,t).bisector,Vr=class extends qi{enable(){}down(t){if(this.$parent.deselect(),!this.firstPoint)this.firstPoint=this.getOrMakePointAt(t),this.firstPoint&&this.firstPoint.addHalo();else if(this.secondPoint){this.path.isPending=this.thirdPoint.isPending=!1,this.thirdPoint.$el.removeClass("pending"),this.firstPoint.removeHalo(),this.secondPoint.removeHalo(),this.snapPoint?(this.path.setComponents([this.firstPoint,this.secondPoint,this.snapPoint],Ap),this.thirdPoint.delete(),this.thirdPoint=void 0):this.snapIntersect?this.thirdPoint.makeIntersection(this.snapIntersect):this.snapPath&&this.thirdPoint.project(this.snapPath);let i=this.path,n=this.thirdPoint;this.firstPoint=this.secondPoint=this.thirdPoint=this.path=void 0,n&&this.$parent.trigger("add:point",{point:n}),this.$parent.trigger("add:path",{path:i}),this.$parent.updateIntersections()}else{if(this.secondPoint=this.getOrMakePointAt(t),!this.secondPoint)return;this.secondPoint.addHalo(),this.thirdPoint=new Ie(this.$parent,this.secondPoint.value),this.thirdPoint.$el.addClass("pending"),this.path=new qe(this.$parent,void 0),this.path.setComponents([this.firstPoint,this.secondPoint,this.thirdPoint],Ap),this.path.isPending=this.thirdPoint.isPending=!0}}hover(t){if(this.$parent.$pendingPoint.hide(),this.thirdPoint){this.snapToPoint(this.thirdPoint,t),this.$parent.setCursor(this.snapPoint?"pointer":"crosshair");return}let i=this.$parent.getPointAt(t);if(i)return this.$parent.setCursor("pointer"),i.hover();this.$parent.hovering&&this.$parent.hovering.unhover(),this.$parent.setCursor("crosshair"),this.showPendingPointAt(t)}cancel(){this.firstPoint&&this.firstPoint.removeHalo(),this.secondPoint&&this.secondPoint.removeHalo(),this.thirdPoint&&this.thirdPoint.delete(),this.path&&this.path.delete(),this.firstPoint=this.secondPoint=this.thirdPoint=this.path=void 0}};var kp='
';var Ir=class extends is{constructor(){super(...arguments);this.shapes=new Map;this.points=new Set;this.paths=new Set;this.intersections=new Set;this.snapToGrid=0;this.locked=!1;this.hidePoints=!1;this.canSelect=!1;this.canIntersect=!1;this.canProject=!0;this.labelPositioning=!1;this.cursor="default"}ready(){let t=this.children.filter(h=>h.tagName==="SVG")[0];if(this.hasAttr("complex")&&(this.setAttr("label-suffix",",i"),this.setAttr("axis-names","Real, Imaginary"),this.setAttr("axes","true"),this.setAttr("grid","true")),!this.hasAttr("x-axis")&&!this.hasAttr("y-axis")){let h=+this.attr("grid"),l=+this.attr("width")||this.width,c=+this.attr("height")||l;this.setAttr("x-axis",h?`-0.5,${l/h-.5},1`:`0,${l},1`),this.setAttr("y-axis",h?`${c/h-.5},-0.5,1`:`${c},0,1`),h&&this.setAttr("snap",1)}this.setupCoordinates(t,{proportional:!0}),this.viewportRect=this.viewportBounds.rect,this.model=this.getParentModel()||le({}),this.model.hasGeoModel||this.model.assign(yp),this.$paths=m("g",{class:"paths"},t),this.$pulses=m("g",{class:"pulses"},t),this.$points=m("g",{class:"points"},t),this.$objLabels=m("g",{class:"labels"},t),this.snapToGrid=this.hasAttr("snap")?+this.attr("snap")||1:0,this.hidePoints=this.hasAttr("no-points"),this.canIntersect=Ve(this,"intersections",!1),this.canProject=Ve(this,"projections",!0),this.canSelect=Ve(this,"selectable",!1),this.labelPositioning=Ve(this,"label-positioning",!0),this.hasClass("sticky")&&this.css("top",`calc(50vh - ${this.height/2}px)`),this.queueLabelPositioning=ve(()=>{for(let h of this.shapes.values())h.updateLabelPosition()},0,!0);let i=t.$$("path[x], path[\\:d], circle");for(let h of i){let l=h.hasAttr("x")?ct(h.attr("x")):void 0,c=h.attr("name");if(h.hasAttr(":d"))this.$paths.append(h),h.bindModel(this.model);else if(h.tagName==="PATH")this.$paths.append(h),new qe(this,l,c,h);else{this.$points.append(h);let u=!h.hasClass("move"),d=l||h.center,g=new Ie(this,d,c,h,u);h.hasAttr("project")&&g.project(h.attr("project")),h.hasClass("pulsate")&&g.pulsate()}}this.$pendingPoint=m("circle",{class:"pending"},this.$points),this.$pendingPoint.hide(),this.updateIntersections();let n={move:new Fi(this),point:new Er(this),line:new Mr(this),circle:new Cr(this),perpBisector:new kr(this),angleBisector:new Vr(this),rectangle:new Ar(this)};this.$tools=this.$(".tools");let r=n[this.$tools.$active.data.tool];r.enable();let o=()=>this.toolOverride||r;this.$tools.on("change",h=>{o().cancel(),this.toolOverride=void 0,r=n[h.data.tool],this.hovering&&this.hovering.unhover(),this.$pendingPoint.hide(),this.hovering=void 0,this.deselect(),r.enable()});let a=(h,l=!1)=>this.toPlotCoords(l?h.clamp(this.viewportBounds,8):h);new ei(t,{down:h=>o().down(a(h.posn)),start:h=>o().start(a(h.posn)),move:h=>o().move(a(h.posn,!0),a(h.lastPosn,!0)),end:h=>o().end(a(h.posn,!0)),click:h=>o().click(a(h.posn)),hover:h=>o().hover(a(h.posn))}),C.onKey("Escape",()=>o().cancel()),C.onKey("Backspace Clear Delete",()=>this.delete()),document.addEventListener("keydown",h=>{if([37,38,39,40].indexOf(h.keyCode)<0)return;let c=b.getActiveInput();if(!(!c||!c.hasParent(this))){h.preventDefault();for(let u of this.points){if(u.$el!==c||!u.value)continue;let d=15/this.plotScale,g=this.plotBounds.yMin>this.plotBounds.yMax?-1:1,y=h.keyCode===37?-d:h.keyCode===39?d:0,f=h.keyCode===38?-g*d:h.keyCode===40?g*d:0;u.setValue(u.value.shift(y,f));return}}})}switchTool(t){this.$tools.makeActive(this.$(`.tool[data-tool="${t}"]`))}setCursor(t="default"){t!==this.cursor&&(this.cursor=t,this.$svg.css("cursor",t))}select(t){this.canSelect&&(this.deselect(),t&&(this.selection=t,t.select()),this.trigger("select",{shape:t}))}deselect(){this.selection&&(this.selection.deselect(),this.selection=void 0,this.trigger("select",{shape:void 0}))}delete(){this.hovering&&this.hovering.unhover(),this.selection&&this.selection.delete(),this.trigger("select",{shape:void 0})}redraw(){this.resize(),this.viewportRect=this.viewportBounds.rect,this.model.forceUpdate()}getPointAt(t,i=20){if(this.hidePoints)return;let n=r=>r.isHidden?void 0:r.distance(t);return $r(this.points,n,i/this.plotScale)}getPathAt(t,i=10){if(this.hidePoints||!this.canProject)return;let n=r=>r.isHidden?void 0:r.distance(t);return $r(this.paths,n,i/this.plotScale)}getIntersectionAt(t,i=20){if(!this.canIntersect)return;let n=r=>p.distance(t,r.posn);return $r(this.intersections,n,i/this.plotScale)}updateIntersections(){!this.canIntersect||this.hidePoints||bp(this.paths,this.intersections)}drawPath(t,i={}){typeof t=="string"&&(t=ct(t));let n=new qe(this,t,i.name);i.classes&&n.$el.addClass(i.classes),i.target&&n.$el.setAttr("target",i.target);let r=n.$el.hasClass("fill")?"fade":"draw";return i.animated&&n.$el.enter(r,i.animated),n}drawPoint(t,i={}){typeof t=="string"&&(t=ct(t));let n=new Ie(this,t,i.name,void 0,i.interactive===!1);return i.classes&&n.$el.addClass(i.classes),i.target&&n.$el.setAttr("target",i.target),i.animated!==0&&n.$el.enter("pop",i.animated||500),n}animatePoint(t,i,n=400){let r=this.shapes.get(t),o=new Y(this.model[t],i);return pt(a=>r.setValue(o.at(yt("quad",a))),n)}animateConstruction(t,i=2e3){return D(this,null,function*(){let n=this.shapes.get(t),r=n.value;if(U(r)&&(r=r.arc),it(r)){this.$ruler||(this.$ruler=m("path",{d:$p,class:"sketch"},this.$svg));let o=Es(r.at(-.1),12,r.angle-.3,r.length*1.2),a=Es(r.at(-.1),12,r.angle,r.length*1.2);this.$ruler.show(),n.$el.hide(),yield this.$ruler.animate({opacity:[0,1],transform:[o,a]},500).promise,yield n.$el.enter("draw",i).promise,yield this.$ruler.animate({opacity:[1,0],transform:[a,o]},500).promise}else if(Dt(r)){this.$compass||(this.$compass=m("path",{d:xp,class:"sketch"},this.$svg));let o=Es(r.c,50,r.startAngle,r.radius*1.5),a=Es(r.c,50,r.startAngle,r.radius),h=Es(r.c,50,r.startAngle+r.angle,r.radius),l=Es(r.c,50,r.startAngle+r.angle,r.radius*1.5);this.$compass.show(),n.$el.hide(),yield this.$compass.animate({opacity:[0,1],transform:[o,a]},500).promise,n.$el.enter("draw",i),yield this.$compass.animate({transform:[a,h]},i,0,"linear").promise,yield this.$compass.animate({opacity:[1,0],transform:[h,l]},500).promise}})}showGesture(t,i){this.$gesture||(this.$gesture=m("x-gesture",{},this)),this.$gesture.stop();let n=this.toViewportCoords(ct(t)(this.model));if(this.$gesture.from=n,i){let r=this.toViewportCoords(ct(i)(this.model));this.$gesture.start(r.subtract(n))}else this.$gesture.start();this.one("click mouseover pointerdown",()=>this.$gesture.stop())}waitForPoint(){return D(this,null,function*(){return new Promise(t=>{this.one("add:point",({point:i})=>t(i))})})}waitForPath(n){return D(this,arguments,function*(t,i={}){return(yield th(this,[t],i))[0]})}waitForPaths(t,i={}){return th(this,t,i)}};Ir=T([S("x-geopad",{template:kp})],Ir);var Vp='
';var Lr=class extends E{ready(){let e=this.$(".image"),t=this.positionTop<50,i,n;e.css({"background-image":`url("${this.attr("background")}")`,height:t?"100%":"150%"});let r=({height:a})=>{let h=this.positionTop;i=Math.max(0,h-a),n=h+this.height};function o(a){if(a.topn)return;let h=(a.top-i)/(n-i)*(t?50:33);e.css("transform",`translateY(${h}%)`)}b.onResize(r),C.on("scroll",o)}};Lr=T([S("x-parallax",{template:Vp})],Lr);var st=new AudioContext,Rr,Fe,Or=.05,Rp="/polypad/assets/audio/samples/",Ip=new Map,Dp=new Map,Lp=!1;function Fg(){return D(this,null,function*(){if(Lp)return;Lp=!0,Fe=st.createDynamicsCompressor(),Fe.threshold.setValueAtTime(-15,0),Fe.knee.setValueAtTime(1,0),Fe.ratio.setValueAtTime(2,0),Fe.attack.setValueAtTime(1e-5,0),Fe.release.setValueAtTime(1,0),Rr=st.createConvolver();let e=yield(yield fetch(`${Rp}IR13.mp3`)).arrayBuffer();Rr.buffer=yield st.decodeAudioData(e)})}function Np(s){if(!s||s==="synth"||Ip.has(s))return;let e=fetch(`${Rp}${s}.mp3`).then(t=>t.arrayBuffer()).then(t=>st.decodeAudioData(t)).then(t=>Dp.set(s,t)).catch(()=>console.error("Unable to load sample for",s));Ip.set(s,e)}var eh={piano:{label:"Piano",pitch:-6,vol:-1.5},epiano:{label:"E-Piano",pitch:-1,vol:-2},organ:{label:"Organ",pitch:-1,vol:-1.75},marimba:{label:"Marimba",pitch:1},synth:{label:"Synth"},bass:{label:"Synth Bass",pitch:6.2,vol:-1.75,icon:"synth"},aguitar:{label:"Guitar",pitch:5},eguitar:{label:"E-Guitar",vol:-2},violin:{label:"Violin",vol:-1.75},cello:{label:"Cello",vol:-1.5},banjo:{label:"Banjo",vol:3},trumpet:{label:"Trumpet",vol:-1.75,pitch:-14},clarinet:{label:"Clarinet",pitch:-2,vol:-2},ubass:{label:"Upright Bass",vol:2,icon:"cello"},kick:{label:"Kick",noLoop:!0},snare:{label:"Snare",noLoop:!0},"tom-high":{label:"High Tom",noLoop:!0},"tom-low":{label:"Low Tom",noLoop:!0},"hihat-open":{label:"Open HiHat",noLoop:!0,icon:"hihat"},"hihat-closed":{label:"HiHat",noLoop:!0,icon:"hihat"},ride:{label:"Ride Cymbal",noLoop:!0},crash:{label:"Crash Cymbal",noLoop:!0},cowbell:{label:"Cowbell",noLoop:!0},tambo:{label:"Tambourine",noLoop:!0},bongo:{label:"Bongos",noLoop:!0},shaker:{label:"Shaker",noLoop:!0},woodblock:{label:"Woodblock",noLoop:!0},voice:{label:"Vocal",vol:-1.5},clap:{label:"Clap",noLoop:!0},snap:{label:"Snap",noLoop:!0},ting:{label:"Ting",pitch:5.5},honk:{label:"Honk",pitch:-2,noLoop:!0},scraper:{label:"Scraper",noLoop:!0},boing:{label:"Spring",noLoop:!0,pitch:7},vibraslap:{label:"Vibraslap",noLoop:!0},cow:{label:"Cow",vol:-1.75,noLoop:!0},bark:{label:"Dog",noLoop:!0},duck:{label:"Duck",noLoop:!0},pig:{label:"Pig",noLoop:!0},rooster:{label:"Rooster",pitch:-5,noLoop:!0}},Hg=440*2**(-9/12);var jg={none:[],percussion:[],major:[0,2,4,5,7,9,11],minor:[0,2,3,5,7,8,10],blues:[0,3,5,6,7,10],pentatonic:[0,2,4,7,9],chromatic:oe(12)};function ih(s,e,t=0,i){if(s==="none")return 0;i&&(e=t-e-1);let n=jg[s],r=gt(e,n.length);return Math.round((e-r)/n.length)*12+n[r]}function Gp(s,e,t){let i=st.createGain();i.connect(Fe),i.connect(Rr).connect(Fe).connect(st.destination);let n=s+1e-5;return i.gain.setValueAtTime(1e-5,n),i.gain.linearRampToValueAtTime(e,n+=t[0]),i.gain.linearRampToValueAtTime(e*.8,n+=t[1]),i.gain.setValueAtTime(e*.8,n+=t[2]),i.gain.linearRampToValueAtTime(1e-5,n+t[3]),i}function Hi(s,e="piano"){return s===void 0?0:e==="synth"?Hg*2**(s/12):2**((s+(eh[e].pitch||0))/12)||0}function Ug(s,e,t,i,n){let r=Dp.get(s);if(!r)throw new Error(`Missing audio sample: ${s}`);let o=Gp(t,i,n),a=st.createBufferSource(),h=Hi(e,s);a.playbackRate.value=h,a.buffer=r,a.connect(o),a.start(t);let l=[a],c=a.buffer.duration/h,u=c*.5>1.5?1.1:c*.9,d=n[2]/.6,g=d/u;if(d>1.1&&!eh[s].noLoop)for(let y=1;ythis.stop())}play(e=st.currentTime+Or,t=1){if(!this.setup)return 0;this.isPlaying&&this.stop(),this.isPlaying=!0,this.tempo=(this.tile.props.tempo||1)*t;let i=this.tile.props.note||0;if(this.currentData=this.setup(i,this.tempo),!this.currentData.beats.length)return this.isPlaying=!1,this.currentData=void 0,0;let n=O(this.currentData.beats);return this.duration=(n.time+n.duration)/this.tempo,this.start=e,this.lastBeat=-1,Op.add(this),this.duration}stop(){var e,t;if(this.isPlaying){Op.remove(this),window.clearInterval(this.timeout),this.isPlaying=!1,(t=(e=this.currentData).end)==null||t.call(e);for(let i of this.stopCont)i.stop();this.stopCont.clear(),this.currentData=void 0,this.tile.$parent.selection.update()}}tick(){var o,a;let e=st.currentTime,t=this.currentData.beats,i=(e-this.start)*this.tempo,n=t.findIndex(h=>h.time>=i);n<0&&(n=t.length-1);for(let h=this.lastBeat+1;h<=n;++h)this.processStep(h);(a=(o=this.currentData).tick)==null||a.call(o,i<0?0:i);let r=this.start+this.duration-e;this.lastBeat>=t.length-1&&r<=0&&this.stop()}processStep(e){var h,l;let t=this.currentData.beats[e],i=this.start+t.time/this.tempo;if(i>st.currentTime+Or)return;let n=((h=this.tile.props.volume)!=null?h:1)+((l=t.volume)!=null?l:0),r=t.duration/this.tempo,o=t.sound||this.tile.props.sound||"piano";if(t.note instanceof Function)this.playContinuous(t.note,o,i,r,n);else{let c=Array.isArray(t.note)?t.note:[t.note];for(let u of c)this.playNote(u,o,i,r,n)}let a=i-st.currentTime;this.timeout=Zt(()=>{var c,u;return(u=(c=this.currentData).step)==null?void 0:u.call(c,e)},a*1e3),this.lastBeat=e}playNote(e,t=this.tile.props.sound||"piano",i=st.currentTime+Or,n=.8,r=this.tile.props.volume||1){return Kg(e,t,r,n,i,this.tile.props.modGain,this.tile.props.modFreq)}playContinuous(e,t,i,n,r){let o=this.playNote(Hi(e(0)),t,i,n,r),a=o instanceof OscillatorNode,h=1/60;for(let l=0;l<=n;l+=h){let c=Hi(e(l*this.tempo),t);if(a)o.frequency.setValueAtTime(c,i+l);else for(let u of o)u.playbackRate.setValueAtTime(c,i+l)}if(a)this.stopCont.add(o);else for(let l of o)this.stopCont.add(l)}},sh=class{constructor(){this.running=!1;this.tracks=new Set}add(e){this.tracks.add(e),this.running||(st.state!=="running"&&st.resume(),this.running=!0,this.tick(),requestAnimationFrame(()=>this.tick()))}remove(e){this.tracks.delete(e),this.tracks.size||(this.running=!1)}tick(){for(let e of this.tracks)e.tick();this.running&&requestAnimationFrame(()=>this.tick())}},Op=new sh;var Xg=new Set(["watch","assign","updateTheme","flushChanges","raw","copy"]);function zp(s,e){let t,i=new Set,n=!0,r=new Map,o=(u,d)=>{for(let g of K(u))r.has(g)||r.set(g,[]),r.get(g).push(d);d(c)},a=u=>{let d=Object.keys(u).filter(y=>u[y]!==s[y]);if(!d.length)return;Object.assign(s,u),e.$parent.pendingChanges.add(e);for(let y of d)i.add(y);let g=Wt(d.flatMap(y=>{var f;return(f=r.get(y))!=null?f:[]}));for(let y of g)y(c)},h=()=>{var u;for(let d of(u=r.get("color"))!=null?u:[])d(c)},l=()=>{if(e.isDeleting)return i.clear(),n?void 0:[t,void 0];let u=t;if(t=Object.assign({},s),n)return i.clear(),n=!1,[void 0,t];let d={},g={},y=!1;for(let f of i)t[f]!==u[f]&&(y=!0,d[f]=t[f],g[f]=u[f]);return i.clear(),y?[g,d]:void 0},c=new Proxy(s,{get(u,d){switch(d){case"watch":return o;case"assign":return a;case"updateTheme":return h;case"flushChanges":return l;case"raw":return s;case"copy":return()=>Object.assign({},s);case"zIndex":return s.zIndex||0;case"layer":return s.layer||"normal";case"color":return _e(s.color,e.$parent.flipTheme);default:return s[d]}},set(u,d,g){var y;if(Xg.has(d))return!1;if(s[d]===g)return!0;s[d]=g;for(let f of(y=r.get(d))!=null?y:[])f(c);return e.$parent.pendingChanges.add(e),i.add(d),!0}});return c}function Bp(s){let e=s.signedArea<0,t=0;for(let[n,r]of s.points.entries())r.ys.points[t].x||(t=n);let i=hs(s.points,t+(e?1:0));return e&&(i=i.reverse()),new V(...i)}function nh(s,e,t=0){let i=s.centroid.x,n=Math.max(...s.points.map(r=>r.y))+42+t;return m("text",{x:i,y:n,style:"font-size:25px"},e)}function Yg(s,e,t,i){e.removeChildren();let n=s.is("polyomino"),r=Bp(s.path),o=r.edges,a=as(o.map(A=>A.length)),h=O(a),l=yr(s.props.color),c=z(A=>{let M=ih(s.props.musicScale||"major",A,o.length,s.props.musicScaleRev),P=(a[A-1]||0)*.01;return{note:t+M,time:P,duration:o[A].length*.01}},o.length),u=m("g",{filter:"url(#outline)"},e),d=m("g",{class:"axis-label",fill:l},e),g=s.props.animation==="vertices"?9:6,y=m("path",{path:r,fill:"none",stroke:l,"stroke-width":5,opacity:1,hidden:!0},u),f=r.points.map(A=>m("circle",{cx:A.x,cy:A.y,r:g,fill:l,hidden:!0},u)),v,w,$;return s.props.animation==="vertices"?$=r.points.map((A,M)=>m("text",{text:M+1,x:A.x,y:A.y+5,fill:"white",hidden:!0},u)):s.props.labels==="number"&&(v=nh(r,d),w=o.map(A=>{let M=A.perpendicularBisector,P=M.at(n?0:15/M.length),j=A.length<45?12:15;return m("text",{text:Rt(A.length/50,1),x:P.x,y:P.y+5,hidden:!0,style:`font-size:${j}px`},d)})),{beats:c,step:A=>{A===0&&(y==null||y.enter("draw",10*h/i)),f==null||f[A].show(),$==null||$[A].show(),w==null||w[A].show(),v&&(v.textStr=Rt(a[A]/50,1))}}}function Zg(s,e,t){e.removeChildren();let i=s.path.area/2500,n=t-12,r=i,o=yr(s.props.color),a=m("clipPath",{id:`clip-${s.id}`},e),h=m("path",{path:G.aroundPoints(s.path.points)},a);s.$path.setAttr("id",`shape-${s.id}`),m("path",{path:s.path,"clip-path":`url(#clip-${s.id})`,fill:o,opacity:1},e);let l=m("g",{class:"axis-label",fill:o},e),c=nh(s.path,l,-15);return{beats:[{note:g=>tt(n-i,n,g/r),duration:r,time:0}],tick:g=>{if(s.props.labels){let f=g/r,v=Rt(tt(0,i,f>.95?1:f),1);c.text=v>0?v+" units\xB2":""}let y=G.aroundPoints(s.path.points).h;h.css("transform",`translateY(${y*(1-g/r)}px)`)}}}function Qg(s,e,t,i){e.removeChildren();let n=Bp(s.path),r=n.points.length,o=n.points.map((v,w)=>new kt(n.points[gt(w+1,r)],v,n.points[gt(w-1,r)])),a=o.map(v=>v.deg),h=[0,...as(a)],l=.42*Math.min(...n.edges.map(v=>v.length)),c=s.is("polyomino"),u=yr(s.props.color),d=m("g",{class:"axis-label",fill:u},e),g=nh(n,d);return{beats:a.map((v,w)=>({note:ih(s.props.musicScale||"major",w,a.length,s.props.musicScaleRev)+t,duration:a[w]/90,time:h[w]/90})),step:v=>{let w=o[v],$=m("path",{fill:u});if(e.prepend($),s.props.labels){let I=w.bisector,A=I.at(-12/I.length),M=`font-size:${c?12:15}px`;m("text",{text:Rt(a[v])+"\xB0",x:A.x,y:A.y+5,style:M},d)}pt(I=>{let A=new kt(w.arc.at(1-I),w.b,w.c);$.draw(A.shape(!0,l,!0)),s.props.labels&&(g.text=Math.round(tt(h[v],h[v+1],I))+"\xB0")},a[v]/90*1e3/i)}}}function _p(s,e){let t=()=>{s.props.labels!=="number"&&e.removeChildren()};return new Dr(s,(i,n)=>{switch(s.props.animation){case"area":return ft(ut({},Zg(s,e,i)),{end:t});case"angles":return ft(ut({},Qg(s,e,i,n)),{end:t});default:return ft(ut({},Yg(s,e,i,n)),{end:t})}})}var qp=6,Jg="M8.1-1.7l-14-8.8c-0.6-0.4-1.4-0.4-2-0.1c-0.6,0.4-1,1-1,1.7V8.8c0,0.7,0.4,1.4,1,1.7c0.3,0.2,0.6,0.3,1,0.3c0.4,0,0.7-0.1,1.1-0.3l14-8.8C8.6,1.3,9,0.7,9,0S8.6-1.3,8.1-1.7z",ji=!1;function Fp(s){if(!Array.isArray(s))return Fp([s,0]);let[e,t]=s;if(e instanceof p)return[[e,t]];if(U(e)&&(e=new G(e.c.shift(-e.r),2*e.r,2*e.r)),!(e instanceof V)&&!(e instanceof G))return[[R,0]];let i=e.edges.map(n=>[n.midpoint,n.perpendicularBisector.angle]).filter(n=>!x(n[1],1.5*Math.PI));return hs(i,t)}var Nr=class{constructor(e,t,i){this.tile=e;this.name=t;this.options={};this.cables=new Set;i&&this.setOptions(i)}get location(){let e=this.options.location;return Array.isArray(e)?e[0]:e}get type(){return(this.location||this.tile.path)instanceof p?"POINT":"REGION"}get points(){let e=this.options.location||this.tile.path||R;return Fp(e).map(t=>[this.tile.worldPosn(t[0]),t[1]])}setOptions(e,t=!0){Object.assign(this.options,e),t&&this.redraw()}redraw(){for(let e of this.cables)e.redraw()}},Gr=class extends Nr{sendMessage(e){this.cables.size===0&&this.redraw();for(let t of this.cables.values())t.enqueueMessage(e,!1);Hp()}addCable(e,t=!1){this.cables.add(e),!e.to&&!e.dragging&&this.cables.size>1&&this.removeCable(e,!1),t&&(this.tile.updateCableProps(),this.tile.$parent.flushChanges()),this.redraw()}removeCable(e,t=!0){this.cables.delete(e),e.delete(),t&&this.redraw(),this.tile.updateCableProps()}redraw(){if(Bt(this.cables,e=>e.to))for(let e of this.cables)!e.to&&!e.dragging&&this.removeCable(e);this.cables.size||this.addCable(new ns(this)),super.redraw()}delete(){for(let e of this.cables)e.delete()}},zr=class extends Nr{setOptions(t,i=!0){Object.assign(this.options,t);let n=Array.isArray(t.location)?t.location[0]:t.location;n instanceof p?this.$dot=m("circle",{class:"link-dot persist",r:qp,cx:n.x,cy:n.y},this.tile.$el):this.$dot&&this.$dot.remove(),i&&this.redraw()}addCable(t,i){i&&this.tile.highlight(!0),this.cables.add(t),this.options.connect&&this.options.connect(t)}removeCable(t,i){var n,r;i&&this.tile.highlight(!1),(r=(n=this.options).disconnect)==null||r.call(n,t),this.cables.delete(t)}delete(){for(let t of this.cables)t.from.tile.$parent.pendingChanges.add(t.from.tile),t.from.removeCable(t)}validateConnection(t){return ah(t,this)}},oh=[],rh=!1;function Hp(){var e,t;if(rh)return;rh=!0;let s=0;for(;oh.length;){if(s>=1e4)throw new Error("Queue overflow!");let[i,n]=oh.shift();(e=i.to)!=null&&e.options.message&&((t=i.to)==null||t.options.message(n,i)),s++}rh=!1}function ah(s,e){if(s.tile===e.tile||e.options.max&&[...e.cables].filter(r=>r.from!==s||r.to!==e).length>=e.options.max)return!1;let t=e.options.tileTypes;if(t){let n=s.tile.props.name;if(!t.includes(n))return!1}let i=s.options.tileTypes;if(i){let n=e.tile.props.name;if(!i.includes(n))return!1}return!0}var ns=class s{constructor(e,t){this.from=e;this.dragging=!1;let i=this.from.tile.$parent,n=e.options.persistent?"":"dashed";this.$group=m("g",{class:"link-bar",style:"display:none"},e.tile.$el),this.$line=m("path",{style:"pointer-events: none",class:n},this.$group),this.$originDot=m("circle",{class:"link-dot",r:qp},this.$group),this.$handle=m("path",{class:"link-handle",d:Jg},this.$group),this.connectTo(t),i.events.listen(this.$handle,{start:()=>{i.selection.add(e.tile,!0),ji=this.dragging=!0},move:({posn:o})=>{this.connectTo(i.getInputAt(o,this.from),o)},end:()=>{ji=this.dragging=!1,this.to&&this.to.tile.highlight(!1),this.redraw(),e.addCable(this,!0)},click:()=>{this.connectTo(),e.addCable(this,!0)}});let r;i.events.listen(this.$originDot,{start:()=>{i.selection.add(e.tile,!0),r=new s(this.from),ji=r.dragging=!0,this.from.addCable(r)},move:({posn:o})=>{r.connectTo(i.getInputAt(o,this.from),o)},end:()=>{r.to&&r.to.tile.highlight(!1),r.redraw(),ji=r.dragging=!1,e.addCable(r,!0),r=void 0}})}connectTo(e,t){this.to&&this.to!==e&&this.to.removeCable(this,!0),e?this.to!==e&&ah(this.from,e)&&(this.to=e,e.addCable(this,t!==void 0),this.from.options.connect&&this.from.options.connect(this)):this.to=void 0,this.redraw(t)}redraw(e){var y;if(!(this.from.options.persistent||this.from.tile.isActive||((y=this.to)==null?void 0:y.tile.isActive)))return this.$group.hide();if(this.from.tile.$el.append(this.$group),this.$group.show(),!this.to&&!e){let[f,v]=this.from.points[0],w=new wt(R,20).at(v/(Math.PI*2));this.$handle.setTransform(this.from.tile.relativePosn(f).add(w),v),this.$line.setAttr("d",""),this.$originDot.hide();return}let i=this.to?this.to.points:[[e,0]],n=bi(this.from.points,i),[r,o]=Is(n,([f,v])=>p.distance(f[0],v[0])),a=this.from.tile.relativePosn(r[0]),h=o[1]+J((this.to?this.to.tile.rot:180)-this.from.tile.rot),l=this.to?new wt(R,14).at(h/(Math.PI*2)):R,c=this.from.tile.relativePosn(o[0]).add(l),u=p.distance(a,c),d=a.add(p.fromPolar(r[1],u*.7)),g=c.add(p.fromPolar(h,Math.max(u*.7,40)));this.$line.setAttr("d",`M${c.x} ${c.y}C${g.x} ${g.y},${d.x} ${d.y},${a.x} ${a.y}`),this.$handle.setTransform(c,h+Math.PI,this.to?.8:1),this.$originDot.setTransform(a),this.$originDot.show()}delete(){this.connectTo(),this.$group.remove()}enqueueMessage(e,t=!0){if(oh.push([this,e]),t&&Hp(),!this.from.options.highlights)return;let n=e.type==="number"&&e.value===1?F.yellow:F.blue;this.$line.setAttr("style",`stroke: ${n}`),this.$handle.setAttr("style",`fill: ${n}`)}serialize(){return this.to?{fromPort:this.from.name,toTileId:this.to.tile.id,toPort:this.to.name}:void 0}static unSerialize(e,t,i){var o,a;let n=i.tiles.get(e),r=i.tiles.get(t.toTileId);if(n&&r){let h=(o=n.outPorts)==null?void 0:o.get(t.fromPort||"main"),l=(a=r.inPorts)==null?void 0:a.get(t.toPort||"main");h&&l&&ah(h,l)&&h.addCable(new s(h,l))}}static get isMoving(){return ji}};var _r=["polygon","custom-polygon","reg-polygon","rectangle","polyomino","circle","arrow"],Br=class{constructor(e){this.tileContext=e,this.tileContextProps=this.tileContext.props,this.tileContextProps.watch("color",()=>this.setColor()),this.tileContextProps.watch("textLabel",()=>{var t;this.tileContext.value=(t=cn.fromString(this.tileContextProps.textLabel||""))==null?void 0:t.value,this.renderTextLabel()}),this.tileContextProps.watch("textLabelRotate",()=>this.align()),this.tileContextProps.watch("textLabelFontSize",()=>this.setFontSize())}renderTextLabel(){if(this.$textLabel){this.$textLabel.text=this.tileContextProps.textLabel||"",this.align();return}this.tileContextProps.textLabel&&(this.$textLabel=m("text",{class:"polygon-text-label",text:this.tileContextProps.textLabel,"dominant-baseline":"middle"},this.tileContext.$el),this.setColor(),this.setFontSize(),this.align())}setColor(){this.$textLabel&&this.$textLabel.css("fill",br(this.tileContextProps.color))}setFontSize(){if(!this.$textLabel)return;let e=this.tileContextProps.textLabelFontSize||0;this.$textLabel.css("font-size",mp(e)),this.$textLabel.setAttr("dy",e)}align(){if(!this.$textLabel)return;let e=this.tileContextProps.textLabelRotate?0:-this.tileContext.rot;this.$textLabel.setTransform(this.tileContext.path&&Ye(this.tileContext.path)?this.tileContext.path.centroid:this.tileContext.center,J(e))}};var F={grey:"#cccccc",darkGrey:"#242436",red:"#cd0e66",orange:"#eb4726",yellow:"#fd8c00",lime:"#bfc212",green:"#22ab24",teal:"#009ea6",blue:"#0f82f2",purple:"#6d3bbf",fg:"var(--canvas-fg)",bg:"var(--canvas-bg)"},t0="M12.5,0H0V25H12.5a12.5,12.5,0,0,0,0-25Z",e0="M0,0V12.5a12.5,12.5,0,0,0,25,0V0Z",qr=new Map,Fr=new Map,s0=[];function Ut(s){qr.set(s.type,s)}function Mt(s){s0.push(...s)}var H=class s{constructor(e,t,i,n){this.$parent=e;this.rot=0;this.snapPoints=[];this.snapLines=[];this.snapAngles=[0,90];this.id=i||We(10),t.name||(t.name=this.constructor.type),this.props=zp(t,this),this.posn=new p(this.props.x||0,this.props.y||0),this.rot=t.rot||0,this.$el=n||m("g",{class:"tile"}),e.tiles.set(this.id,this),Fr.set(this.$el._el,this),e.pendingChanges.add(this),this.props.watch("status",({status:r})=>{this.$el.setClass("locked-tile",r==="locked"),this.$el.setClass("hidden-tile",r==="hidden"),this.canSelect||this.$parent.selection.remove(this)}),this.props.watch("sound",r=>Np(r.sound||"piano")),this.props.watch("zIndex layer",()=>this.updateZIndex(!0)),this.props.watch("hideHandles",()=>this.$el.setClass("no-handles",!this.showHandles))}static create(e,t,i){let n=qr.get(t.name);if(!n)throw new Error(`Unknown tile type: ${t.name}`);let r=Object.assign({},n.defaultProps||{},t);r.arpeggio===!1&&!r.musicScale&&(r.musicScale="none",r.arpeggio=void 0);let o=new n(e,r,i);return o.setTransform(),o}static thumbnail(e,t,i){var o,a;let n=qr.get(t);if(!n)throw new Error(`Unknown tile type: ${t}`);let r=we(i.attr("props"),{});return i.setAttr("aria-label",((o=n.altText)==null?void 0:o.call(n,r))||r.name),(a=n.makeThumbnail)==null?void 0:a.call(n,i,r,e)}delete(){var e,t,i;if(!this.isDeleting){this.isDeleting=!0,(e=this.track)==null||e.stop(),this.collision&&this.collision.setCollision();for(let n of this.optionListeners||[])this.$parent.options.unwatch(n);for(let n of this.stateListeners||[])this.$parent.state.unwatch(n);this.$parent.selection.remove(this);for(let n of((t=this.inPorts)==null?void 0:t.values())||[])n.delete();for(let n of((i=this.outPorts)==null?void 0:i.values())||[])n.delete();this.$parent.tiles.delete(this.id),this.$parent.zIndex.remove(this),this.$parent.mathContext.removeSource(this),Fr.delete(this.$el._el),this.$parent.pendingChanges.add(this),this.$el.remove()}}applyChange(e){this.props.assign(e),this.flushChanges(),("x"in e||"y"in e||"rot"in e)&&this.setTransform(new p(this.props.x,this.props.y),this.props.rot)}flushChanges(){return this.props.flushChanges()}setupAudioTrack(){}makeHandle(e,t,i,n,r){let a=m(e==="c"?"circle":"path",{class:"handle"},this.$el);return e==="h"&&a.setAttr("d",t0),e==="v"&&a.setAttr("d",e0),e==="c"&&a.setAttr("r",10),a.css("cursor",e==="c"?"move":e==="h"?"ew-resize":"ns-resize"),this.$parent.events.listen(a,{down:()=>{var h;return(h=this.track)==null?void 0:h.stop()},start:()=>{this.$parent.selection.add(this.root,!0),n==null||n()},move:h=>t(this.relativePosn(h.posn),h.posn,h.event),click:()=>i==null?void 0:i(),end:()=>{r==null||r(),this.$parent.flushChanges()}}),a}is(e){return this.props.name===e}get $container(){return this.$parent.$tiles[this.props.layer==="back"?0:this.props.layer==="front"?2:1]}updateZIndex(e){e&&this.$parent.zIndex.addOrUpdate(this);let t=this.$parent.zIndex.getTileAbove(this);if(!t)return this.$container.append(this.$el);t.$el.insertBefore(this.$el)}get canSelect(){return this.$parent.state.authorMode?!0:this.props.status!=="hidden"&&this.props.status!=="locked"}get canEdit(){return this.$parent.state.authorMode?!0:!this.authoringOnly&&this.props.status!=="fixed"&&this.props.status!=="generator"}get canRotate(){return this.cannotRotateType?!1:this.$parent.state.authorMode?!0:this.canEdit&&!this.$parent.options.noRotating&&!this.props.cannotRotate}get showHandles(){return this.$parent.state.authorMode?!0:!this.props.hideHandles&&!this.authoringOnly&&this.props.status!=="generator"}get altText(){var t;if(this.props.altText)return this.props.altText;let e=qr.get(this.props.name);return((t=e==null?void 0:e.altText)==null?void 0:t.call(e,this.props))||this.props.name}watchPolypadOptions(e){this.optionListeners||(this.optionListeners=[]),this.optionListeners.push(e),this.$parent.options.watch(e)}watchPolypadState(e){this.stateListeners||(this.stateListeners=[]),this.stateListeners.push(e),this.$parent.state.watch(e)}showErrorIcon(e){var t;if(this.currentError=e,!e)return(t=this.$errorIcon)==null?void 0:t.detach();this.$errorIcon||(this.$errorIcon=m("g",{style:"cursor: pointer"}),m("circle",{cx:12,cy:12,r:12,fill:"transparent"},this.$errorIcon),fp("warning",F.yellow,24,void 0,this.$errorIcon),this.transform(),this.$parent.events.listen(this.$errorIcon,{click:()=>{let i=this.$errorIcon.transformMatrix,n=this.posn.shift(i[0][2],i[1][2]);this.$parent.warningBanner.show(n,this.currentError)}})),this.$el.append(this.$errorIcon)}setCollision(e){var t;!this.canEdit||e&&!e.canEdit||e&&e===this.collision||((t=this.collision)==null||t.highlight(!1),this.collision=e,e==null||e.highlight(!0))}collide(e){}get root(){var e;return((e=this.group)==null?void 0:e.root)||this}flipColor(e){let{color:t,backColor:i}=this.props;this.props.color=i||e,this.props.backColor=t}click(e,t){}doubleClick(e){}down(e){}up(e){}format(e,t){}focus(){this.$parent.focussedTile=this,this.$parent.selection.clear(),this.isFocussed=!0,this.$parent.trigger("change-focus",{tiles:[this]})}blur(){this.isFocussed=!1,this.$parent.focussedTile=void 0,this.$parent.trigger("change-focus",{tiles:[]})}highlight(e=!0){}onDropzonesChange(){}select(){this.isActive=!0,this.$el.addClass("active"),this.$el.setClass("no-handles",!this.showHandles),this.noAutoLayering||this.updateZIndex(),this.redrawCables()}deselect(){this.isDeleting||(this.isActive=!1,this.$el.removeClass("active"),this.noAutoLayering||this.updateZIndex(),this.redrawCables())}moveStart(e=!1){this.startPosn=this.posn}move(e,t){var i;if(e){let n=(i=this.startPosn)==null?void 0:i.add(e);n&&(this.posn=n),this.transform(!0)}}moveEnd(){this.collision&&this.collide(this.collision),this.setTransform()}rotate(e,t=R){this.posn=this.posn.rotate(J(e),t),this.rot=gt(this.rot+e,360),this.transform(!0)}transform(e){var i,n;let t=J(this.rot);this.$el.setTransform(this.posn,t),this.redrawCables(),!e&&this.path&&(this.transformed=this.path.rotate(t).translate(this.posn),this.padding&&(this.transformedPadded=It(this.path).padding(...this.padding).rotate(t).translate(this.posn)),this.snapPoints=this.getSnapPoints().map(r=>r.rotate(t).translate(this.posn)),this.snapLines=this.getSnapLines().map(r=>r.rotate(t).translate(this.posn)),(i=this.$errorIcon)==null||i.setTransform(It(this.path).p.shift(-28,5)),(n=this.group)==null||n.transform())}setTransform(e=this.posn,t=this.rot){this.posn=e,this.props.x=e.x,this.props.y=e.y,this.rot=this.props.rot=gt(t,360),this.transform()}getSnapPoints(){return this.path?rt(this.path)?[this.path]:St(this.path)?this.path.points:it(this.path)?[this.path.p1,this.path.p2]:U(this.path)?[this.path.c,this.path.c.shift(0,this.path.r),this.path.c.shift(0,-this.path.r),this.path.c.shift(this.path.r,0),this.path.c.shift(-this.path.r,0)]:Ze(this.path)?[...this.path.majorVertices,...this.path.minorVertices]:Pe(this.path)?[this.path.c,this.path.start,this.path.end]:Dt(this.path)?[this.path.start,this.path.end]:qt(this.path)?[]:[]:[]}getSnapLines(){return[]}relativePosn(e){return e.subtract(this.posn).rotate(-J(this.rot))}worldPosn(e){return e.rotate(J(this.rot)).add(this.posn)}get center(){return this.path?U(this.path)||Ze(this.path)?this.path.c:It(this.path).center:R}contains(e){let t=this.transformed;return!t||!St(t)&&!U(t)&&!Pe(t)?!1:t.contains(e)}findNearby(e,t,i){let n=i||this.worldPosn(this.center);for(let r of this.$parent.getTilesOfType(e))if(r!==this&&p.distance(n,r.worldPosn(r.center))Array.from(ke([h],!0),d=>{let g=d.posn.add(l).subtract(h.posn);return{tile:d,posn:g,rot:c,scale:u}}));let r=e.map(h=>h.tile.posn),o=e.map(h=>h.tile.rot);for(let h of e)h.tile.setTransform(h.posn,(a=h.rot)!=null?a:h.tile.rot),h.tile.isAnimating=!0;if(!t)return Promise.resolve();yield pt(h=>{var l,c;h=yt(n,h);for(let[u,d]of e.entries()){let g=J(tt(o[u],(l=d.rot)!=null?l:d.tile.rot,h));if(d.tile.is("group")){let y=p.interpolate(r[u].subtract(d.posn),R,h);d.tile.transformed=d.tile.path.rotate(g,d.tile.path.center).translate(y)}else{let y=p.interpolate(r[u],d.posn,h),f=d.scale?tt(d.scale[0],d.scale[1],h):void 0;d.tile.$el.setTransform(y,g,f),d.tile.transformed=(c=d.tile.path)==null?void 0:c.rotate(g).translate(y)}}i&&i(h)},t).promise;for(let h of e)h.tile.isAnimating=!1})}delayedSetup(){var t;for(let i of((t=this.outPorts)==null?void 0:t.values())||[])for(let n of i.cables)n.delete();let e=this.props.cables||[];for(let i of e)ns.unSerialize(this.id,i,this.$parent)}redrawCables(){var e,t;for(let i of((e=this.inPorts)==null?void 0:e.values())||[])i.redraw();for(let i of((t=this.outPorts)==null?void 0:t.values())||[])i.redraw()}makeInPort(e,t){this.inPorts||(this.inPorts=new Map),this.inPorts.has(e)||this.inPorts.set(e,new zr(this,e));let i=this.inPorts.get(e);return i.setOptions(t,!1),i}makeOutPort(e,t){this.outPorts||(this.outPorts=new Map),this.outPorts.has(e)||this.outPorts.set(e,new Gr(this,e));let i=this.outPorts.get(e);return i.setOptions(t,!1),i}emitMessage(e,t){var i;typeof e=="string"&&(e=(i=this.outPorts)==null?void 0:i.get(e)),e==null||e.sendMessage(t)}*getCableData(e="out"){let t=e==="in"?this.inPorts:this.outPorts;if(t)for(let i of t.values())for(let n of i.cables)(e==="in"||n.to)&&(yield n.serialize())}updateCableProps(){if(this.$parent.setup)return;let e=Array.from(this.getCableData());this.props.cables=e.length?e:void 0}getClosestPort(e,t,i=10){if(!this.inPorts)return;let n=this.relativePosn(e);for(let a of this.inPorts.values())if(a.location&&rt(a.location)&&p.distance(a.location,n)<=i&&(!t||a.validateConnection(t)))return a;if(!this.contains(e))return;let r=Array.from(this.inPorts.values()).filter(a=>!t||a.validateConnection(t));for(let a of r.filter(h=>h.type==="REGION"))if((a.location||this.path).contains(n))return a;let o=r.filter(a=>a.type==="POINT");return Is(o,a=>p.distance(n,a.location))}},i0=new vt(R,new p(0,1)),n0=new G(R,50,50).shift(-25,-25).polygon,ii=class extends H{constructor(t,i,n){super(t,i,n);this.$path=m("path",{class:"polygon-tile"},this.$el),this.$outline=m("path",{class:"outline"},this.$el),this.props.watch("color",({color:r})=>this.$path.setAttr("fill",r)),this.textLabelInstance=new Br(this)}transform(t){var i;super.transform(t),(i=this.textLabelInstance)==null||i.align()}setPath(t=n0,i,n){if(i&&!this.symmetric&&(t=t.reflect(i0)),this.path=t,St(t)&&(this.snapAngles=Wt(t.edges.map(a=>gt(Math.round(Kt(a.angle)),180)))),this.$path.draw(t,{cornerRadius:n}),this.$outline.draw(t,{cornerRadius:n}),this.transform(),!St(t))return;let r=G.aroundPoints(t.points),o=new p(r.center.x,r.p.y);this.showSelectionOutline=p.distance(o,t.project(o))>5}select(){var t,i;(t=this.track)==null||t.stop(),(i=this.$audio)==null||i.removeChildren(),super.select()}setupAudioTrack(){St(this.path)&&(this.$audio=m("g",{style:"font-size:15px;font-weight:600",fill:"white"}),this.$outline.insertBefore(this.$audio),this.track=_p(this,this.$audio),this.props.watch("labels",()=>this.track.stop()))}flip(t){this.props.isFlipped=!this.props.isFlipped||void 0;let i=new p(2*t.x-this.posn.x,this.posn.y);this.setTransform(i,-this.rot)}};var Hr={point:(s,e)=>s!==void 0&&e!==void 0?new p(s,e):void 0,angle:(s,e,t)=>s&&e&&t?new kt(s,e,t):void 0,line:(s,e)=>s&&e&&!s.equals(e)?new vt(s,e):void 0,segment:(s,e)=>s&&e&&!s.equals(e)?new Y(s,e):void 0,circle:(s,e)=>s&&e?new wt(s,e):void 0,arc:(s,e,t)=>s&&e&&t?new Ft(s,e,t):void 0,polygon:(...s)=>s.every(Boolean)?new V(...s):void 0,polyline:(...s)=>s.every(Boolean)?new te(...s):void 0,triangle:(s,e,t)=>s&&e&&t?new Pi(s,e,t):void 0,rectangle:(s,e,t)=>s?new G(s,e,t):void 0,distance:p.distance,intersections:Q},r0=/^_x\d+\.at\([\d.e-]+\)$/,o0=/^intersections\(|\.midpoint$|\.centroid$/,jr=class{constructor(){this.model=le({});this.tiles=new Map;this.dependencies=new Map;this.model.assign(Hr),this.queueLabelPositioning=ve(()=>{for(let e of this.tiles.values())Kp(e)},0,!0)}reset(){this.model.clear(),this.model.assign(Hr)}redrawLines(e){for(let t of this.tiles.values())t.path&&Ko(t.path)&&(t.$el.draw(t.path,{box:e}),t.$shadow.setAttr("d",t.$el.attr("d")))}},Yt=class extends H{constructor(t,i,n){super(t,i,n,m("path",{class:"geo-path"},t.$geoPaths));this.$parent=t;this.hideSelectionOutline=!0;this.noAutoLayering=!0;this.isProjection=!1;this.parentKeys=[];this.deleted=!1;this.onDraw=()=>this.draw();this.$shadow=m("path",{class:"geo-shadow"},t.$geoShadows),this.props.key||(this.props.key=t.geoData.model.getKey()),t.geoData.tiles.set(this.props.key,this),this.snapPoints=this.snapLines=this.snapAngles=[],this.props.expr&&this.setExpr(this.props.expr),t.geoData.model.watch(this.onDraw),this.props.color||(this.props.color=t.state.penColor),this.props.watch("color",({color:r})=>{var o,a,h;(o=this.$el)==null||o.css("color",r),(a=this.$shadow)==null||a.css("color",r),(h=this.$label)==null||h.setAttr("fill",r)}),this.props.watch("arrows marks",()=>this.draw(!0)),this.props.watch("label",({label:r})=>{if(!r&&this.$label)return this.$label.detach();this.$label||(this.$label=m("text",{fill:this.props.color,class:"geo-label"})),this.$parent.$geoPoints.append(this.$label),Kp(this)})}applyChange(t){super.applyChange(t),"expr"in t&&this.setExpr(this.props.expr)}setExpr(t,i=!1){let n=ct(t);this.$parent.geoData.model.setComputed(this.props.key,n),!i&&(this.props.expr=t,this.setParentKeys(t.match(/_x\d+/g)||[]),this.isProjection=r0.test(t),this.computed=o0.test(t),this.$el.setClass("intersection",this.computed))}draw(t=!1){let i=this.$parent.geoData.model[this.props.key];if(!t&&i===this.path)return;this.path=i,this.$el.setAttr("hidden",i?void 0:!0),this.isActive&&!i&&this.$shadow.hide();let n=i==null?void 0:i.type;if(n!==this.geoType&&(this.$el.setClass("geo-point",n==="point"),this.$el.setClass("geo-path",n!=="point"),this.geoType=n,this.$container.append(this.$el)),!i)return;n==="point"&&(i=new wt(i,this.computed?3.5:6)),this.$el.setClass("fill",this.geoType==="angle");let r=this.$parent.canvasBounds||this.$parent.viewportBounds;this.$el.draw(i,{box:r.rect,arrows:this.props.arrows,mark:this.props.marks}),this.$shadow.setAttr("d",this.$el.attr("d")),this.transform()}setParentKeys(t){var n;let i=this.$parent.geoData.dependencies;for(let r of this.parentKeys)(n=i.get(r))==null||n.delete(this.props.key);this.parentKeys=t;for(let r of t)i.has(r)||i.set(r,new Set),i.get(r).add(this.props.key)}get parents(){let t=this.$parent.geoData.tiles;return this.parentKeys.map(i=>t.get(i)).filter(Boolean)}get children(){let t=this.$parent.geoData.dependencies.get(this.props.key);return t?Array.from(t).map(i=>this.$parent.geoData.tiles.get(i)).filter(Boolean):[]}get ariaDescription(){var t;return`${(t=this.path)==null?void 0:t.type} ${this.props.key}: ${this.props.expr}`}get $container(){return this.geoType==="point"?this.$parent.$geoPoints:this.$parent.$geoPaths}select(){var t;this.isActive=!0,this.path&&(this.geoType==="angle"?this.$el.addClass("hover"):(this.$shadow.show(),(t=this.$el.parent)==null||t.append(this.$el)))}deselect(){this.isActive=!1,this.$shadow.hide(),this.$el.removeClass("hover")}hover(t=!0){this.isActive||!this.path||(this.geoType==="angle"?this.$el.setClass("hover",t):t?this.$shadow.show():this.$shadow.hide())}transform(){this.transformed=this.path,this.snapPoints=this.pending?[]:this.getSnapPoints(),this.snapLines=this.pending||!this.path||rt(this.path)||qt(this.path)?[]:[this.path],this.$parent.geoData.queueLabelPositioning()}setTransform(){this.transform()}shift(t){/^point\([\d.-]+,[\d.-]+\)$/.test(this.props.expr)&&this.setExpr(this.path.translate(t).toString())}delete(){var t;this.deleted=!0,super.delete(),this.$parent.geoData.model.unwatch(this.onDraw),this.$parent.geoData.model[this.props.key]=void 0,this.$parent.geoData.tiles.delete(this.props.key),this.$shadow.remove(),(t=this.$label)==null||t.remove();for(let i of this.children)i.delete()}setPending(t=!0){this.pending=t,t||this.transform();for(let i of this.children)i.setPending(t)}moveStart(){if(!(this.computed||!this.path)){if(this.isProjection){if(this.$parent.selection.size>1)return;this.setParentKeys([])}this.setPending(!0);for(let t of this.parents)t.moveStart();this.moveStartValue=this.transformed}}move(t,i){if(!(!t||!this.path||!this.moveStartValue))if(rt(this.path))this.snapTarget=i,this.$el.setClass("intersection",this.computed||!!(i!=null&&i.intersection)),this.$parent.geoData.model[this.props.key]=this.moveStartValue.translate(t);else for(let n of this.parents)n.move(t)}moveEnd(){var t,i,n,r;if(this.moveStartValue){for(let o of this.parents)o.moveEnd();if(this.setPending(!1),(t=this.snapTarget)!=null&&t.intersection)this.setExpr(this.snapTarget.intersection);else if(((n=(i=this.snapTarget)==null?void 0:i.tile)==null?void 0:n.props.name)==="geo"){let o=(r=this.snapTarget)==null?void 0:r.tile;if(o.path&&rt(o.path)){let a=this.children;for(let h of a)h.setExpr(h.props.expr.replaceAll(this.props.key,o.props.key));this.delete(),this.$parent.flushChanges()}else if(o.path){let a=o.path.offset(this.$parent.geoData.model[this.props.key]);this.setExpr(`${o.props.key}.at(${a})`)}}else this.path&&rt(this.path)&&(this.props.expr=`point(${this.path.x},${this.path.y})`,this.isActive||this.$parent.pendingChanges.add(this))}}static getInferredShape(t){if(t=t.filter(h=>h.path),!t.length)return;if(t.length===1)return{type:t[0].path.type,expr:t[0].props.key,value:t[0].path};t=t.filter(h=>h.geoType!=="angle");let i=t.filter(h=>rt(h.path)),n=t.filter(h=>it(h.path)||U(h.path));if(n.length===1&&i.length===t.length-1){let h=n[0].path;if(i.every(l=>h.contains(l.path)))return{type:h.type,expr:n[0].props.key,value:h}}let r=n.filter(h=>it(h.path));if(i.length+r.length!==t.length)return;for(let h of r)if($e(h.path)){let l=h.parentKeys.map(c=>h.$parent.geoData.tiles.get(c));for(let c of l)i.includes(c)||i.push(c)}else if(i.filter(l=>h.path.contains(l.path)).length<2)return;let o=i.map(h=>h.props.key).join(","),a=i.map(h=>h.path);if(i.length===2){let h=new Y(a[0],a[1]);return{type:"segment",expr:`segment(${o})`,value:h}}return i.length===3?{type:"triangle",expr:`triangle(${o})`,value:new Pi(...a)}:{type:"polygon",expr:`polygon(${o})`,value:new V(...a)}}static copy(t,i,n){let r=h=>{let l=t.get(h)||n.model.getKey();return t.set(h,l),l},o=r(i.key),a=i.expr.replace(/\b_x\d+\b/g,r);return{key:o,expr:a}}};Yt.type="geo",Yt=T([Ut],Yt);var jp=new WeakMap,Up=s=>{let e=jp.get(s);if(e)return e;let t=Yt.getInferredShape(s);return jp.set(s,t),t};Mt([["Midpoint","geo-midpoint","$0.midpoint","segment"],["Perpendicular bisector","geo-perp-bisector","$0.perpendicularBisector","segment"],["Parallel line","geo-parallel","$0.parallel($1)","line","segment"],["Perpendicular line","geo-perpendicular","$0.perpendicular($1)","line","segment"],["Tangent line","geo-tangent","line($0.c,$1).perpendicular($1)","circle"],["Centroid","geo-centroid","$0.centroid","polygon","triangle"],["Circumcircle","geo-circumcircle","$0.circumcircle","triangle"],["Incircle","geo-incircle","$0.incircle","triangle"],["Angle bisector","geo-angle-bisector","$0.bisector","angle"]].map(([s,e,t,...i])=>({id:e,type:"button",tileTypes:["geo"],label:s,icon:e,noFlush:!0,show:n=>{var r;return i.includes(((r=Up(n))==null?void 0:r.type)||"")},click:(n,r)=>{var h;let o=(h=Up(n))==null?void 0:h.expr,a=t.replace(/\$0/g,o||"");if(a.includes("$1"))r.tools.geoPending.enable(a);else{let l=H.create(r,{name:"geo",expr:a});r.selection.add(l,!0);let c=rt(l.path)?"pop":"draw",u=l.$el.enter(c,400);l.$shadow.enter(c,400),r.snapping.updateIntersections(),r.flushChanges(),u.promise.then(()=>l.$el.css("display",""))}}})));Mt([{id:"line-style",type:"select",tileTypes:["geo"],label:"Line Type:",location:"more",show:s=>s.every(e=>e.path&&it(e.path)),options:[{key:"line",label:"Line"},{key:"ray",label:"Ray"},{key:"segment",label:"Segment"}],get:s=>s.geoType,set:(s,e)=>e.setExpr(e.props.expr.replace(/\.(line|ray|segment)$/,"")+`.${s}`)},{id:"arrows",type:"select",tileTypes:["geo"],label:"Arrows:",location:"more",show:s=>s.every(e=>e.geoType==="segment"),options:[{key:"",label:"None"},{key:"start",label:"Start"},{key:"end",label:"End"},{key:"both",label:"Both"}],get:s=>s.props.arrows||"",set:(s,e)=>e.props.arrows=s||void 0},{id:"marks",type:"select",tileTypes:["geo"],label:"Decoration:",location:"more",show:s=>s.every(e=>e.path&&it(e.path)),options:[{key:"",label:"None"},{key:"bar",label:"Bar"},{key:"bar2",label:"Double Bars"},{key:"arrow",label:"Arrow"},{key:"arrow2",label:"Double Arrows"}],get:s=>s.props.marks||"",set:(s,e)=>e.props.marks=s||void 0}]);Mt([{id:"label",type:"input",tileTypes:["geo"],label:"Label:",location:"more",get:s=>s.props.label||"",set:(s,e)=>e.props.label=s}]);var Wp=Math.PI/12;function a0(s){return be(s/Wp,.03)?new cn(Math.round(s/Wp),12,"\u03C0").simplified.toString():Ot(s,4)}function h0(s,e){return $e(e)?s.replace(/\$l/g,Ot(e.length/50,4)):St(e)||U(e)?s.replace(/\$[cp]/g,Ot(e.circumference/50,4)).replace(/\$a/g,Ot(e.area/2500,4)):qt(e)?s.replace(/\$r/g,a0(e.rad)).replace(/\$d/g,Ot(e.deg,4)+"\xB0"):s}function Kp(s){if(!s.props.label||!s.path)return;s.$label.text=h0(s.props.label,s.path);let[e,t]=l0(s);s.$label.css("transform",`translate(${e.x}px,${e.y}px) rotate(${t}rad)`)}function l0(s){let e,t=s.$label.width,i=12,n=new G(new p(-t/2-3,-i-3),t+6,i+6);for(let r of c0(s.path,s,t,i)){e||(e=r);let o=n.rotate(r[1]).translate(r[0]);if(!Bt(s.$parent.geoData.tiles.values(),a=>{if(!a.path||a.props.status==="hidden"||a===s)return!1;let h=rt(a.path)?new wt(a.path,10):a.path;if(Q(h,o).length)return!0}))return r}return e||[R,0]}function*c0(s,e,t,i){var n;if(rt(s)){let r=e.computed?8:10;yield[s.shift(r+t/2,-r),0],yield[s.shift(-r-t/2,-r),0],yield[s.shift(r+t/2,r+i),0],yield[s.shift(-r-t/2,r+i),0]}else if(it(s)){let r=s.perpendicularVector,o=s.angle;r.y>=0&&(r=r.scale(-1),o+=Math.PI);let a=$e(s)?[.5,.3,.7]:[0,150,-150];for(let h of a)for(let l of[8,-8-i])yield[s.at(h).add(r.scale(l)),o]}else if(St(s))for(let r of s.edges){let o=r.perpendicularVector.scale(8),a=r.angle;o.y>=0&&(o=o.scale(1+i/8),a+=Math.PI),yield[r.midpoint.add(o),a]}else if(U(s))yield[s.at(7/8).shift(5+t/2,-5),0],yield[s.at(5/8).shift(-5-t/2,-5),0],yield[s.at(1/8).shift(5+t/2,5+i),0],yield[s.at(3/8).shift(-5-t/2,5+i),0];else if(qt(s)){let r=s.isRight?20*Math.sqrt(2):s.radius,o=((n=s.bisector)==null?void 0:n.unitVector.scale(r+6))||R,a=o.angle();yield[s.b.add(o).shift(t/2*Math.cos(a),i/2*(1+Math.sin(a))),0]}}var Ms=25,Yp=5.4,Zp=4.7;var p0="#ddd",d0={1:F.yellow,x:F.green,x2:F.blue,y:F.teal,y2:"#8d2ca1",xy:"#4e53d0"},hh=s=>s[0]==="-"?F.red:d0[s],Xp=s=>s[0]==="-"?s.slice(1):"-"+s;function lh({splitH:s,splitV:e,expr:t},i=!1){let n=s*e;return t.replace(/2$/,"^2")+(n>1?`${i?"//":"/"}${n}`:"")}function Ur(s,e,t,i){switch(s.startsWith("-")?s.slice(1):s){case"x2":return[t,t];case"y2":return[i,i];case"xy":return[t,i];case"x":return[e,t];case"y":return[e,i];default:return[e,e]}}function Qp(s){let[e,t]=s.reduce(([n,r],{props:o})=>{let a=o.splitH*o.splitV;return[n*a+r,r*a]},[0,1]),i=xe(e,t);return[e/i,t/i]}function*u0(s){let e=s,t=[];for(let i=1;ithis.updateFill()),this.props.watch("labels expr",()=>this.updateLabel()),this.resize(),this.move()}applyChange(t){super.applyChange(t),this.resize(),this.move()}get isRotated(){return nt(this.rot,45,135)||nt(this.rot,225,315)}get denominator(){return this.props.splitV*this.props.splitH}isInverseOf(t){return this.denominator===t.denominator&&Xp(this.props.expr)===t.props.expr}get size(){let{algebraXSize:t,algebraYSize:i}=this.$parent.options,{expr:n,splitV:r,splitH:o}=this.props,[a,h]=Ur(n,1,t,i);return[a*Ms/o,h*Ms/r]}resize(){let[t,i]=this.size;this.setPath(up(t,i).polygon)}updateLabel(){let[t,i]=this.size;this.isRotated&&([t,i]=[i,t]);let n=this.props.labels!=="hidden"&&t>=12&&i>=12;if(this.$label.toggle(n),!n)return;this.labelEqn.setValue(this.collision?"0":lh(this.props,i<25));let r=this.labelEqn.root,o=Math.min((t-2)/r.width*.8,i/r.height*.8,1);this.labelEqn.$row.css("transform",`translate(${-r.width/2}px,${-r.height/2}px)`),this.$label.css("transform",`scale(${o}) rotate(${-this.rot}deg)`)}updateFill(){this.$path.setAttr("fill",this.collision?_e(p0,this.$parent.flipTheme):this.props.color)}transform(t){this.updateLabel(),super.transform(t)}getSideLength(t){this.isRotated&&(t=t==="h"?"v":"h");let{expr:i,splitV:n,splitH:r}=this.props,[o,a]=Ur(i,"1","x","y");return t==="h"?[o,1/r]:[a,1/n]}getEdge(t){let i=gt(t-Math.round(this.rot/90),4);return this.transformed.edges[i]}setCollision(t){this.collision=t,this.updateFill(),this.updateLabel()}move(t){super.move(t);let i=this.collision;if(i){if(p.distance(this.posn,i.posn)<.95*Ms&&this.isInverseOf(i))return;i.setCollision(),this.setCollision()}for(let n of this.$parent.getTilesOfType("algebra"))if(!(n.collision||!this.isInverseOf(n))&&!(p.distance(this.posn,n.posn)>=.95*Ms)){this.setCollision(n),n.setCollision(this);return}}split(t,i=2){this.isRotated&&(t=t==="h"?"v":"h");let[n,r]=this.size,o=t==="h"?new Y(new p(-n/2,0),new p(n/2,0)):new Y(new p(0,-r/2),new p(0,r/2)),a=ft(ut({},this.props.raw),{splitH:t==="h"?this.props.splitH*i:this.props.splitH,splitV:t==="v"?this.props.splitV*i:this.props.splitV});return this.delete(),z(h=>{let l=this.worldPosn(o.at((h+.5)/i));return H.create(this.$parent,Object.assign({},a,{x:l.x,y:l.y}))},i)}static merge(t){let i=It(...t.map(f=>f.transformed)),{x:n,y:r}=i.center,o=t.every(f=>f.isRotated)?90:0,a=t[0].props.expr,{algebraXSize:h,algebraYSize:l}=t[0].$parent.options,c=Ur(a,Ms,h*Ms,l*Ms)[0],u=Qp(t)[1],d=[...u0(u)].find(f=>f>=Math.round(c/(o?i.h:i.w)))||1,g=u/d,y=H.create(t[0].$parent,{name:"algebra",expr:a,splitH:d,splitV:g,x:n,y:r,rot:o});for(let f of t)f.delete();return y}static makeThumbnail(t,i){let n=i.expr,[r,o]=Ur(n,20,78,64),a=n[0]==="-"?n.slice(1):n,h=a==="y2"?112:["x2","xy"].includes(a)?28:2,l=a==="1"?2:["x","x2"].includes(a)?28:112;i.rot&&([h,l,r,o]=[l,h,o,r]),t.setRect(new G(new p(h,l),r,o)),t.setAttr("fill",hh(n));let c=m("g",{style:"font-size:15px;color:white;text-anchor:start",class:"equation"}),u=new Be(c,void 0,0,"",15,!0);u.setValue(lh(i)),u.$row.css("transform",`translate(${h+r/2-u.root.width/2}px, ${l+o/2-u.root.height/2}px)`),t.insertAfter(c)}static altText(t){return lh(t)+" Algebra Tile"}negate(){this.props.expr=Xp(this.props.expr),this.flipColor(hh(this.props.expr)),this.move()}};Cs.type="algebra",Cs.defaultProps={splitH:1,splitV:1},Cs=T([Ut],Cs);Mt([{id:"negate",type:"button",tileTypes:["algebra","dot","number-card"],label:"Negate",icon:"turn",useTextLabel:!0,click:s=>{for(let e of s)e.negate()}}]);Mt([{id:"merge-algebra",type:"button",tileTypes:["algebra"],label:"Merge",icon:"merge",useTextLabel:!0,show:s=>s.length<2||!s.every(e=>e.props.expr===s[0].props.expr)?!1:Qp(s)[0]===1,click:(s,e)=>{e.selection.add(Cs.merge(s),!0)}},{id:"splitV",type:"button",tileTypes:["algebra"],label:"Split Vertically",icon:"split-v",show:s=>s.every(e=>e.props.splitV<8),click:(s,e)=>{e.selection.select(s.flatMap(t=>t.split("v",2)))}},{id:"splitH",type:"button",tileTypes:["algebra"],label:"Split Horizontally",icon:"split-h",show:s=>s.every(e=>e.props.splitH<8),click:(s,e)=>{e.selection.select(s.flatMap(t=>t.split("h",2)))}},{id:"split",type:"range",tileTypes:["algebra"],label:"Denominator:",value:"number",icon:"split-h",location:"more",get:s=>[s.props.splitH,s.props.splitV],set:(s,e)=>{e.props.assign({splitH:B(Math.round(s[0]),1,8),splitV:B(Math.round(s[1]),1,8)}),e.resize(),e.updateLabel()}}]);var Jp=1,f0=.2,m0=5;function g0([s,e],t,i){if(!i)return[Math.min(s,t),Math.max(e,t)];let n=eh.length)),n=O(i),r=i.findIndex(h=>h/n>e)+1,o=i.findIndex(h=>h/n>t)+1,a=e<=t?s.points.slice(r,o):[...s.points.slice(r),...s.points.slice(0,o)];return new te(s.at(e),...a,s.at(t))}return s}function ch(s,e,t,i){let n=Jp,r=-1;for(let o=e+1;on&&(r=o,n=a)}n>Jp&&(r-e>1&&ch(s,e,r,i),i.push(s[r]),t-r>1&&ch(s,r,t,i))}function w0(s){if(s.length<=2)return s;let e=[s[0]];return ch(s,0,s.length-1,e),e.push(O(s)),e}function y0(s){if(s.length<=2)return De(new te(...s));let e=s.map((t,i)=>{let n=s[i-1]||t.subtract(s[i+1].subtract(t).unitVector),r=s[i+1]||t.subtract(s[i-1].subtract(t).unitVector),o=Math.atan2(r.y-n.y,r.x-n.x),a=Math.abs(new kt(n,t,r).sup.rad/Math.PI-.5),h=Math.min(p.distance(n,r),100)*a*f0;return new p(Math.cos(o),Math.sin(o)).scale(h)});return s.map((t,i)=>{if(i===0)return`M${t.x.toFixed(2)} ${t.y.toFixed(2)}`;if(p.distance(s[i-1],t)<4)return`L${t.x.toFixed(2)},${t.y.toFixed(2)}`;let n=s[i-1].add(e[i-1]),r=t.subtract(e[i]);return`C${n.x.toFixed(2)},${n.y.toFixed(2)} ${r.x.toFixed(2)},${r.y.toFixed(2)} ${t.x.toFixed(2)},${t.y.toFixed(2)}`}).join("")}var He=class s{constructor(e,t,i,n,r){this.$parent=e;this.brush=n;this.options="";this.$el=m("path",{class:`stroke ${n}`},e.$strokes),this.id=r||We(10),this.setColor(i),t&&this.parse(t),e.strokes.set(this.id,this),this.$parent.pendingStrokes.add(this)}setColor(e){this.color=e,this.$el.setAttr("stroke",_e(e,this.$parent.flipTheme))}parse(e){if(this.options=e,e.startsWith("M")){let t=oa(e);this.path=new te(...t),this.$el.setAttr("d",e)}else this.path=ct(e)(Hr),this.path&&(this.snap=!0),this.$el.setAttr("d",this.path?De(this.path):"")}start(e,t){var i;if(this.brush==="ruler"&&(e=((i=this.$parent.snapping.snap([e]))==null?void 0:i.posn)||e),this.startPoint=e,this.path=new te(e,e.shift(.01)),t&&this.brush!=="ruler"){this.utensil=t;let n=t.offset(e);this.utensilRange=[n,n+.01]}this.$el.draw(this.path)}addPoint(e){if(this.brush==="ruler"){let t=this.$parent.snapping.snap([e]),i=(t==null?void 0:t.posn)||e.snap(this.startPoint,m0);this.path=new Y(this.startPoint,i),this.$el.draw(this.path)}else if(this.utensil){let t=B(this.utensil.offset(e),0,1),i=U(this.utensil)||Ye(this.utensil);this.utensilRange=g0(this.utensilRange,t,i),this.path=v0(this.utensil,...this.utensilRange),this.$el.draw(this.path)}else this.path.points.push(e),this.$el.setAttr("d",this.$el.attr("d")+`L${e.x},${e.y}`)}end(){if(this.utensil||this.brush==="ruler")return this.snap=!0,this.options=this.path.toString().replace(/\.(\d{3})\d+/g,(e,t)=>`.${t}`),this.$parent.snapping.addStroke(this);{let e=w0(this.path.points);this.path=new te(...e),this.options=y0(e),this.$el.setAttr("d",this.options)}this.startPoint=this.utensil=this.utensilRange=void 0}flushChanges(){let e=this.serialize();return this.$parent.strokes.has(this.id)?[void 0,e]:[e,void 0]}get snapPoints(){if(this.snap){if($e(this.path))return[this.path.p1,this.path.p2];if(Dt(this.path))return[this.path.start,this.path.end]}}hitTest(e,t){if(!this.path)return!1;let i=this.path.project(e);return(e.x-i.x)**2+(e.y-i.y)**2t/2?i-t:i}var Kr=class{constructor(e){this.$parent=e;this.angle=0;this.startAngle=0;this.hasChanged=!1;this.showTools=!1;this.isMoving=!1;this.tiles=new Set;this.$tools=e.$(".transform-tools"),this.$shadow=e.$(".group-shadow"),this.$rect=this.$tools.$(".group-outline"),this.$rotateBar=this.$tools.$(".rotate-bar"),this.$rotateCircle=this.$tools.$(".rotate-circle");let t=e.$(".rotate-label");t.hide(),e.events.listen(this.$rotateCircle,{start:()=>{this.startAngle=this.angle,this.rotateStart(),t.show()},move:({startPosn:i,posn:n,event:r})=>{this.rotate(this.startAngle-new kt(n,this.center,i).deg);let o=Vt(r).subtract(e.topLeftPosition);t.setTransform(o.shift(b.isMobile?-15:5,b.isMobile?-100:-40)),t.text=gt(Rt(this.angle,1),360)+"\u2009\xB0"},end:()=>{this.rotateEnd(),t.hide()}})}bindKeyboardEvents(e){e.onKey("AllArrows r R",(t,i)=>{if(this.tiles.size){if(i==="r"||i==="R"){if(Array.from(this.tiles).some(r=>!r.canRotate))return;this.rotateStart();let n=i==="r"||i==="R"&&t.shiftKey&&t.getModifierState("CapsLock")?15:-15;this.rotate(this.angle+n),this.rotateEnd()}else{let n=R,r=t.shiftKey?5:25,o=i==="ArrowLeft"?-r:i==="ArrowRight"?r:0,a=i==="ArrowUp"?-r:i==="ArrowDown"?r:0,h=n.shift(o,a);this.moveStart(),this.move({posn:h,startPosn:n}),this.moveEnd()}this.$parent.trigger("shift-selection")}}),e.onKey("Escape",()=>this.clear())}get flatTiles(){return[...ke(this.tiles,!0)]}get size(){return this.tiles.size}add(e,t=!1,i=!1){t&&this.clear(),!e.isActive&&this.$parent.tiles.has(e.id)&&this.select([e],i)}select(e,t=!1){var i;(i=this.$parent.focussedTile)==null||i.blur(),this.$parent.zIndex.bringToFront(ke(e),!1,!0);for(let n of e)n.isActive||!this.$parent.tiles.has(n.id)||n.group||(this.tiles.add(n),n.select(),this.hasChanged=!0);t||this.update(!0)}remove(e,t=!1){e.group||!e.isActive||(e.deselect(),this.hasChanged=!0,this.tiles.delete(e),t||this.update(!0))}clear(){if(!this.isMoving){for(let e of this.tiles)e.deselect();this.tiles.size&&(this.hasChanged=!0),this.tiles.clear(),this.update(!0)}}getTileProperty(e){if(!this.size)return;let t=e(Vs(this.tiles.values()));for(let i of this.tiles)if(e(i)!==t)return;return t}update(e=!1){if(e&&!this.hasChanged)return;if(this.hasChanged=!1,!this.size){for(let o of[this.$shadow,this.$tools])o.hide();this.$parent.trigger("change-selection",{tiles:[],color:void 0});return}let t=Array.from(this.tiles).filter(o=>o.transformed);this.angle=this.getTileProperty(o=>o.rot)||0,this.rect=pp(t,J(this.angle)),this.center=this.rect.center;let i=t.every(o=>o.canRotate);if(t.length===1&&U(t[0].transformed)&&(i=!1),i&&this.getTileProperty(o=>o.rotateAroundOrigin)){let o=t[0].posn;t.slice(1).every(a=>a.posn.equals(o))&&(this.center=o,this.angle&&t.length===1&&(this.rect=It(t[0].transformed.rotate(-J(this.angle),o))))}this.$rotateBar.toggle(i),this.$rotateCircle.toggle(i);let n=this.size>1||t[0].showSelectionOutline;this.$rect.toggle(n),this.showTools=!this.getTileProperty(o=>o.hideSelectionOutline),this.$tools.toggle(this.showTools),this.$shadow.toggle(n&&this.showTools),(!i||!this.showTools)&&(this.rotateHandle=void 0),(this.size===1?t[0].$container:this.$parent.$svg).append(this.$tools),this.positionTools();let r=this.getTileProperty(o=>o.props.color);this.$parent.trigger("change-selection",{tiles:t,color:r})}positionTools(){if(!this.showTools)return;let e=this.bounds;for(let n of[this.$shadow,this.$rect])n.draw(e);let t=new p(this.center.x,this.rect.p.y),i=new Y(t,t.shift(0,-28)).rotate(J(this.angle),this.center);this.$rotateBar.setLine(i.p1,i.p2),this.$rotateCircle.setCenter(i.p2),this.rotateHandle=i.p2}get bounds(){return this.rect.rotate(J(this.angle),this.center)}getDragBounds(){let{canvas:e,canvasX:t,canvasY:i}=this.$parent.options;if(e==="infinite")return;let n=e==="notebook"?1/0:i!=null?i:0,r=It(...Array.from(this.tiles,o=>o.transformed));if(Number.isFinite(r.w))return new lt(-r.p.x,(t!=null?t:0)-r.p.x-r.w,-r.p.y,n-r.p.y-r.h,"swap")}moveStart(e=!1){if(!Bt(this.tiles,t=>!t.canEdit||t.isAnimating)){this.isMoving=!0,this.$parent.dropzoneManager.onMoveStart(this.tiles);for(let t of this.tiles)t.moveStart(e);this.startSnapPoints=[];for(let t of this.tiles)for(let i of t.snapPoints)this.startSnapPoints.some(n=>i.equals(n))||this.startSnapPoints.push(i);ed=this.rect,td=this.center,this.dragBounds=this.getDragBounds(),this.$parent.newTileShift=0,this.$parent.trigger("move-start")}}move({posn:e,startPosn:t},i=!1){if(!this.isMoving)return;let n=e.subtract(t);this.dragBounds&&!i&&(n=n.clamp(this.dragBounds));let r=this.startSnapPoints.map(h=>h.add(n)),o=this.$parent.snapping.snap(r);o&&(n=n.add(o.shift));let a=this.tiles.size===1?o:void 0;for(let h of this.tiles)h.move(n,a);this.rect=ed.translate(n),this.center=td.add(n),this.positionTools(),this.$parent.dropzoneManager.onMove(this.tiles),this.$parent.trigger("move-selection")}moveEnd(e,t=!1){if(this.isMoving){t&&this.$parent.options.canvas!=="infinite"&&this.move(e);for(let i of this.tiles)i.moveEnd();this.$parent.dropzoneManager.onMoveEnd(),Bt(this.tiles,i=>i.props.name==="geo")&&this.$parent.snapping.updateIntersections(),this.$parent.trigger("move-end"),this.isMoving=!1,this.$parent.flushChanges()}}rotateStart(){ph.clear();for(let e of this.tiles)for(let t of e.snapAngles)ph.add(gt(t+e.rot,180));Wr.clear(),Wr.add(0);for(let e of this.$parent.tiles.values())if(!e.isActive&&Bt(this.tiles,t=>p.distance(t.posn,e.posn)<140))for(let t of e.snapAngles)Wr.add(gt(t+e.rot,180));this.$parent.dropzoneManager.onMoveStart(this.tiles),this.$parent.newTileShift=0,this.$parent.trigger("rotate-start")}rotate(e){if(e=Pt(e,3),e===this.angle)return;let t=1/0;for(let n of ph)for(let r of Wr){let o=b0(r,n+e-this.startAngle,180);Math.abs(o)n.authoringOnly))return{};let t={},i=this.flatTiles;for(let n of i)t[n.id]=n.props.copy();for(let n of i)if(n.is("geo")){for(let r of n.parents)if(!i.includes(r)&&!(r.id in t)&&r.geoType==="point"){let o=`point(${r.path.x},${r.path.y})`;t[r.id]=Object.assign(r.props.copy(),{expr:o})}}return t}delete(){if(this.isMoving||this.$parent.option("noDeleting")||ns.isMoving)return;let e=ke([...this.tiles].filter(i=>i.canEdit),!0);this.tiles.clear();for(let i of e)i.delete();Bt(e,i=>i.props.name==="geo")&&this.$parent.snapping.updateIntersections(),this.$parent.flushChanges(),this.$parent.newTileShift=0}};var xt=class s{constructor(e=0,t=0,i=0){this.x=e;this.y=t;this.z=i}transform(e){if(e instanceof Ui&&(e=e.matrix),e.length!==4||e[0].length!==4)throw new Error("Must use a 4x4 matrix for 3D transforms!");let[[t],[i],[n],[r]]=At.product(e,[[this.x],[this.y],[this.z],[1]]);return new s(t/r,i/r,n/r)}equals(e){return x(this.x,e.x)&&x(this.y,e.y)&&x(this.z,e.z)}fixFloat(){return new s(x(this.x,0)?0:this.x,x(this.y,0)?0:this.y,x(this.z,0)?0:this.z)}add(e){return this.x+=e.x||0,this.y+=e.y||0,this.z+=e.z||0,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}lerp(e,t){return new s(tt(this.x,e.x||0,t),tt(this.y,e.y||0,t),tt(this.z,e.z||0,t))}scale(e){return new s(this.x*e,this.y*e,this.z*e)}get magnitude(){return Math.hypot(this.x,this.y,this.z)}get normalize(){return this.scale(1/this.magnitude)}get asArray(){return[this.x,this.y,this.z]}get inverse(){return new s(-this.x,-this.y,-this.z)}get xy(){return new p(this.x,this.y)}[Symbol.iterator](){return this.asArray.values()}static get zero(){return new s(0,0,0)}static get oneZ(){return new s(0,0,1)}static get one(){return new s(1,1,1)}static all(e){return new s(e,e,e)}static from2D(e){return new s(e.x,e.y,0)}static average(e){return new s(Os(e.map(t=>t.x)),Os(e.map(t=>t.y)),Os(e.map(t=>t.z)))}static dot(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}static cross(e,t){let i=e.y*t.z-e.z*t.y,n=e.z*t.x-e.x*t.z,r=e.x*t.y-e.y*t.x;return new s(i,n,r)}};var ie={translate({x:s,y:e,z:t}){return[[1,0,0,s],[0,1,0,e],[0,0,1,t],[0,0,0,1]]},rotateX(s){let e=Math.cos(s),t=Math.sin(s);return[[1,0,0,0],[0,e,-t,0],[0,t,e,0],[0,0,0,1]]},rotateY(s){let e=Math.cos(s),t=Math.sin(s);return[[e,0,t,0],[0,1,0,0],[-t,0,e,0],[0,0,0,1]]},rotateZ(s){let e=Math.cos(s),t=Math.sin(s);return[[e,-t,0,0],[t,e,0,0],[0,0,1,0],[0,0,0,1]]},rotateAxis({x:s,y:e,z:t},i){let n=Math.hypot(s,e,t);n=1/n,s*=n,e*=n,t*=n;let r=Math.sin(i),o=Math.cos(i),a=1-o;return[[s*s*a+o,s*e*a-t*r,s*t*a+e*r,0],[e*s*a+t*r,e*e*a+o,e*t*a-s*r,0],[t*s*a-e*r,t*e*a+s*r,t*t*a+o,0],[0,0,0,1]]},fromEulerAngles(s,e,t){return At.product(ie.rotateX(s),ie.rotateY(e),ie.rotateZ(t))},scale({x:s,y:e,z:t}){return[[s,0,0,0],[0,e,0,0],[0,0,t,0],[0,0,0,1]]},scaleAll(s){return[[s,0,0,0],[0,s,0,0],[0,0,s,0],[0,0,0,1]]},perspective(s,e,t,i){let n=t*Math.tan(J(s)/2),r=-n,o=n*e,a=-o;return[[2*t/(o-a),0,(o+a)/(o-a),0],[0,2*t/(n-r),(n+r)/(n-r),0],[0,0,-((i+t)/(i-t)),-(2*i*t/(i-t))],[0,0,-1,0]]},transformPoint(s,e){return e instanceof xt?e.transform(s):new xt(e.x,e.y).transform(s)}},Ui=class{constructor(){this.matrix=At.identity(4)}clear(){return this.matrix=At.identity(4),this}translate(e=0,t=0,i=0){return this.matrix=At.product(this.matrix,ie.translate({x:e,y:t,z:i})),this}rotate(e=0,t=0,i=0){return this.matrix=At.product(this.matrix,ie.rotateZ(i),ie.rotateY(t),ie.rotateX(e)),this}scale(e){return this.matrix=At.product(this.matrix,ie.scale(e)),this}dragToRotate(e,t,i=100){let n=new xt(e.x,e.y,i**3/(i**2+e.length**2)).normalize,r=new xt(t.x,t.y,i**3/(i**2+t.length**2)).normalize,o=B(xt.dot(n,r),-1,1),a=xt.cross(n,r),h=ie.rotateAxis(a,2*Math.acos(o));return this.matrix=At.product(h,this.matrix),this}isRotationMatrix(){if(!x(At.determinant(this.matrix),1))return!1;let e=At.transpose(this.matrix);return At.product(this.matrix,e).every((i,n)=>i.every((r,o)=>x(r,n===o?1:0)))}toEulerAngles(){let e=this.matrix,t=Math.hypot(e[0][0],e[1][0]);if(x(t,0)){let a=Math.atan2(-e[1][2],e[1][1]),h=Math.atan2(-e[2][0],t);return[a,h,0]}let n=Math.atan2(e[2][1],e[2][2]),r=Math.atan2(-e[2][0],t),o=Math.atan2(e[1][0],e[0][0]);return[n,r,o]}};var x0=new $t(0,0,0);function $0(s){let e=s.r,t=s.c.x,i=s.c.y,n=.5523*e;return`M${t} ${i-e}C${t+n} ${i-e} ${t+e} ${i-n} ${t+e} ${i}C${t+e} ${i+n} ${t+n} ${i+e} ${t} ${i+e}C${t-n} ${i+e} ${t-e} ${i+n} ${t-e} ${i}C${t-e} ${i-n} ${t-n} ${i-e} ${t} ${i-e}`}var Xr=class{constructor(){this.transform=new Ui;this.visible=!0}getTransformed(e){let t=this;do e=e.transform(t.transform);while(t=t.parent);return e}get normal(){return this.getTransformed(xt.oneZ).add(this.getTransformed(xt.zero).inverse).normalize}project(e,t={fov:120}){if(t.fov===!1)return new p(e.x,e.y);let i=Math.exp(e.z/t.fov);return new p(e.x*i,e.y*i)}*getProjectedVertices(e){for(let t of this.getVertices())yield this.project(t,e)}},Wi=class extends Xr{constructor(t,i={},n){super();this.children=[];this.sorting=!1;this.$el=m("g",i,n);for(let r of t)this.addChild(r)}addChild(t){return t.parent&&t.parent.removeChild(t),this.children.push(t),this.$el&&t.$el&&this.$el.append(t.$el),t.parent=this,t}removeChild(t){let i=this.children.indexOf(t);i>=0&&this.children.splice(i,1),t.$el&&t.$el.remove(),t.parent=void 0}render(t){if(this.visible){if(this.sorting)for(let i of yi(this.children,n=>n.zIndex))this.$el.append(i.$el);for(let i of this.children)i.render(t)}}*getFaces(){for(let t of this.children)for(let i of t.getFaces())yield i}*getVertices(){for(let t of this.children)for(let i of t.getVertices())yield i}get zIndex(){return Os(this.children.map(t=>t.zIndex))}},Ki=class extends Xr{constructor(t,i={},n){super();this.shape=t;if(!t)this.commands=[];else if(typeof t=="string")this.commands=Tn(t);else{let o=U(t)?$0(t):De(t);this.commands=Tn(o)}let r=p.average(...this.commands.filter(o=>o.points.length).map(o=>p.average(...o.points)));this.centroid=new xt(r.x,r.y,0),n&&(this.color=n),this.$el=m("path",i)}render(t){if(!this.visible)return;let i=this.normal.z;if(t!=null&&t.hideBackface){let r=i>-.01;if(this.$el.toggle(r),!r)return}if(this.color){let r=$t.mix(this.color,x0,(Math.abs(i)+1)/2);this.$el.setAttr("fill",r),this.$el.setAttr("stroke",r)}let n=this.commands.map(r=>{let o=r.points.map(a=>{let h=this.project(this.getTransformed(new xt(a.x,a.y)),t);return`${h.x},${h.y}`});return r.type+o.join(",")}).join("");this.$el.setAttr("d",n)}get zIndex(){return this.getTransformed(this.centroid).z}*getFaces(){yield this}*getVertices(){if(!(!this.shape||typeof this.shape=="string"||!St(this.shape)))for(let t of this.commands)for(let i of t.points)yield this.getTransformed(new xt(i.x,i.y))}};var W=V.regular(3),ni=V.regular(4),pe=V.regular(5),sd={shape:W,children:[{shape:W,dihedral:70.53,rot:180},{shape:W,dihedral:70.53,parentEdge:1,rot:300},{shape:W,dihedral:70.53,parentEdge:2,rot:60}]},id={shape:ni,children:[{shape:ni,dihedral:90,myEdge:2,children:[{shape:ni,dihedral:90,myEdge:2}]},{shape:ni,dihedral:90,parentEdge:1,rot:270},{shape:ni,dihedral:90,parentEdge:2},{shape:ni,dihedral:90,parentEdge:3,rot:90}]},nd={shape:W,children:[{shape:W,dihedral:109.47,rot:180},{shape:W,dihedral:109.47,parentEdge:1,rot:300,children:[{shape:W,dihedral:109.47,parentEdge:1,rot:300}]},{shape:W,dihedral:109.47,parentEdge:2,rot:60,children:[{shape:W,dihedral:109.47,parentEdge:1,rot:300},{shape:W,dihedral:109.47,parentEdge:2,rot:60,children:[{shape:W,dihedral:109.47,parentEdge:1,rot:300}]}]}]},rd={shape:pe,children:[{shape:pe,dihedral:116.57,rot:180},{shape:pe,dihedral:116.57,parentEdge:1,rot:252},{shape:pe,dihedral:116.57,parentEdge:2,rot:324},{shape:pe,dihedral:116.57,parentEdge:3,rot:36},{shape:pe,dihedral:116.57,parentEdge:4,rot:108,children:[{shape:pe,dihedral:116.57,parentEdge:2,rot:324,children:[{shape:pe,dihedral:116.57,parentEdge:3,rot:36,children:[{shape:pe,dihedral:116.57,parentEdge:1,rot:252},{shape:pe,dihedral:116.57,parentEdge:2,rot:324},{shape:pe,dihedral:116.57,parentEdge:3,rot:36},{shape:pe,dihedral:116.57,parentEdge:4,rot:108}]}]}]}]},od={shape:W,children:[{shape:W,dihedral:138.19,rot:180},{shape:W,dihedral:138.19,parentEdge:1,rot:300,children:[{shape:W,dihedral:138.19,parentEdge:1,rot:300,children:[{shape:W,dihedral:138.19,parentEdge:2,rot:60,children:[{shape:W,dihedral:138.19,parentEdge:1,rot:300,children:[{shape:W,dihedral:138.19,parentEdge:1,rot:300}]},{shape:W,dihedral:138.19,parentEdge:2,rot:60}]},{shape:W,dihedral:138.19,parentEdge:1,rot:300}]},{shape:W,dihedral:138.19,parentEdge:2,rot:60}]},{shape:W,dihedral:138.19,parentEdge:2,rot:60,children:[{shape:W,dihedral:138.19,parentEdge:2,rot:60,children:[{shape:W,dihedral:138.19,parentEdge:1,rot:300,children:[{shape:W,dihedral:138.19,parentEdge:2,rot:60,children:[{shape:W,dihedral:138.19,parentEdge:1,rot:300,children:[{shape:W,dihedral:138.19,parentEdge:1,rot:300}]},{shape:W,dihedral:138.19,parentEdge:2,rot:60}]},{shape:W,dihedral:138.19,parentEdge:1,rot:300}]},{shape:W,dihedral:138.19,parentEdge:2,rot:60}]},{shape:W,dihedral:138.19,parentEdge:1,rot:300}]}]},ad=new V(new p(.587785,.466639),new p(0,.750495),new p(-.587785,.466639),new p(0,-.73981)),je={shape:ad,dihedral:89.7451,rot:180},nE={shape:ad,children:[ft(ut({},je),{parentEdge:1,myEdge:1,children:[ft(ut({},je),{children:[ft(ut({},je),{parentEdge:1,myEdge:1,children:[ft(ut({},je),{children:[ft(ut({},je),{parentEdge:1,myEdge:1,children:[ft(ut({},je),{children:[ft(ut({},je),{parentEdge:1,myEdge:1,children:[ft(ut({},je),{children:[ft(ut({},je),{parentEdge:1,myEdge:1})]})]})]})]})]})]})]})]})]};function hd(s,e,t){let i=V.regular(s).scale(e*zt(s)),n=new G(R,e,t).polygon,r=[{shape:i,rot:180,parentEdge:2}],o=z(a=>({shape:n,parentEdge:a,rot:360/s*a,children:a?void 0:r}),s);return{shape:i,children:o}}function ld(s,e,t){let i=V.regular(s).scale(e*zt(s)),n=new V(new p(-e/2,0),new p(e/2,0),new p(0,-t)),r=Kt(Math.acos(e/t/2/Math.tan(Math.PI/s))),o=z(a=>({shape:n,dihedral:r,parentEdge:a,rot:180+360/s*a}),s);return{shape:i,children:o}}var P0=At.identity(4);function cd(s,e,t,i){var g;let n=e.shape.edges[s.parentEdge||0],r=s.shape.edges[s.myEdge||0],o=J(s.dihedral||90),a=i(s);t.addChild(a);let h=xt.from2D(n.midpoint),l=xt.from2D(r.midpoint),c=xt.from2D(n.unitVector),u=s.rot?J(s.rot):0,d=((g=s.children)==null?void 0:g.map(y=>cd(y,s,t,i)))||[];return[a,h,l,c,u,o,d]}function dh(s,e,t=1){var o;let i=e(s),n=new Wi([i]);n.sorting=!0;let r=((o=s.children)==null?void 0:o.map(a=>cd(a,s,n,e)))||[];return uh(r,n,t),{group:new Wi([n]),foldTree:r}}function pd(s,e,t=P0){let[i,n,r,o,a,h,l]=s,c=tt(Math.PI,h,e),u=ie.rotateAxis(o,Math.PI-c);a&&(u=At.product(u,ie.rotateZ(a)));let d=r.transform(u),g=ie.translate(d.inverse.add(n));i.transform.matrix=At.product(t,g,u);for(let y of l||[])pd(y,e,i.transform.matrix)}function uh(s,e,t){e.transform.clear();for(let r of s)pd(r,t);let i=Array.from(e.getFaces()).map(r=>r.getTransformed(r.centroid)),n=xt.average(i).inverse;e.transform.translate(n.x,n.y,n.z)}function T0(s,e,t){let i=Math.cos(s),n=Math.cos(e),r=Math.cos(t),o=Math.sin(e),a=Math.acos((r-i*n)/(Math.sin(s)*o)),h=Math.acos((i-n*r)/(o*Math.sin(t)));return[a,h]}function dd(s,e){return Math.asin(Math.cos(s*e)/Math.cos(s/2))}var S0=new Set([60,90,108]),E0=[{internal:[60,90,90,90],dihedral:[144.74,135,135,135]},{internal:[60,60,60,60,90],dihedral:[153.23,153.23,153.23,142.98,142.98]},{internal:[60,90,108,90],dihedral:[159.09,148.28,148.28,159.09]},{internal:[60,60,60,60,108],dihedral:[164.18,164.18,152.93,152.93,152.93]}];function M0(...s){let e=s.length;if(e===3)return T0(s[0],s[1],s[2]);let t=s.map(n=>Math.round(Kt(n)));if((e===4||e===5)&&t.includes(60)&&t.every(n=>S0.has(n))){for(let n of E0)if(n.internal.length===e){for(let r=0;ro===n.internal[(a+r)%e]))return hs(n.dihedral,r).slice(0,e-1).map(o=>J(o))}}if(e===4&&t.filter(n=>n===60).length===3){let n=t.findIndex(l=>l!==60),r=(Math.PI-s[n])/4,o=Math.acos(-1/Math.sqrt(3)*Math.tan(r)),a=Math.acos(1-2/3*((3-Math.tan(r)**2)/4+(Math.sin(3*r)/Math.sin(2*r))**2));return hs([o,a,a,o],4-n).slice(0,e-1)}let i=Math.PI/N(s);return z(n=>{let r=dd(s[n],i),o=dd(s[n+1],i);return r+o},s.length-1)}var fh=(s,e)=>gt(s+1,e.size),mh=(s,e)=>gt(s-1,e.size);function C0(s,e){let t=s.polygon.points[mh(e,s)],i=s.polygon.points[e],n=s.polygon.points[fh(e,s)];return new kt(n,i,t).sup.rad}function A0(s){let e=s.find(a=>a.neighbours.filter(Boolean).length===1),t=mh(e.neighbours.findIndex(Boolean),e),i=[],n=e,r=t;do{let a=[];for(;a.push({face:n,vertex:r}),!!n.neighbours[r];){let h=n;n=n.neighbours[r],r=fh(n.neighbours.indexOf(h),n)}r=fh(r,n),i.push(a)}while(n!==e||r!==t);let o=new Gh(i);for(;;){let a=Math.max(3,...o.array.map(c=>c.val.length)),h=o.array.filter(c=>c.val.length>=a);if(!h.length)break;let l=new Set;for(let c of h){if(l.has(c))continue;let u=c.val.map(g=>C0(g.face,g.vertex)),d=M0(...u);for(let[g,y]of d.entries()){let f=c.val[g],v=c.val[g+1],w=f.vertex,$=mh(v.vertex,v.face);f.face.dihedral[w]=v.face.dihedral[$]=Math.max(y,f.face.dihedral[w]||0,v.face.dihedral[$]||0)}c.prev.val.push(...c.next.val),l.add(c.next),o.delete(c.next),o.delete(c)}}}function ud(s,e){return Math.max(...s.neighbours.map(t=>!t||t===e?0:ud(t,s)))+1}function fd(s,e){return s.visited?!0:(s.visited=!0,s.neighbours.filter(t=>t&&t!==e).some(t=>fd(t,s)))}function md(s,e,t,i){let n=s.neighbours.map((r,o)=>{if(!(!r||r===t))return md(r,e,s,s.dihedral[o])}).filter(Boolean);return{shape:s.polygon.translate(e.inverse),color:s.tile.props.color,children:n.length?n:void 0,dihedral:i?+Kt(i).toFixed(2):void 0,parentEdge:t?t.neighbours.indexOf(s):void 0,myEdge:t?s.neighbours.indexOf(t):void 0}}function k0(s){let e=s.map(t=>{let i=t.transformed.oriented,n=i.points.length;return{tile:t,polygon:i,size:n,neighbours:re(void 0,n),dihedral:re(void 0,n),edges:i.edges,center:i.centroid,radius:i.radius}});if(!e.some(t=>t.size<3)){for(let[t,i]of e.entries())for(let[n,r]of e.entries())if(!(t>=n)&&!(i.radius+r.radius!t.joined)&&!fd(e[0]))return e}}function gd(s){let e=k0(s);if(!e)return;A0(e);let t=Is(e,n=>ud(n)),i=t.polygon.centroid;return[i,md(t,i)]}var gh=s=>Xi[s%Xi.length]||F.yellow;function yd(s){var t;let e=((t=s.c||s.children)==null?void 0:t.map(i=>yd(i)))||[];return{shape:Yr(s.shape||s.s),color:s.color||s.a,children:e,dihedral:s.dihedral||s.d,parentEdge:s.parentEdge||s.p,myEdge:s.myEdge||s.m,rot:s.rot||s.r}}function bd(s){var t;let e=(t=s.children)==null?void 0:t.map(i=>bd(i));return e!=null&&e.length||(e=void 0),{s:oi(s.shape),a:s.color,c:e,d:s.dihedral,p:s.parentEdge,m:s.myEdge,r:s.rot}}function V0(s){return yd(we(s.replace(/([a-z]):/g,'"$1":'),{}))}function I0(s){return JSON.stringify(bd(s)).replace(/"([a-z])":/g,"$1:")}function ri(s,e=1){var i;let t=(i=s.children)==null?void 0:i.map(n=>ri(n,e));return Object.assign({},s,{children:t,shape:s.shape.scale(e)})}var vd=s=>s.split(",").map(e=>+e),vh=s=>s.map(e=>e.toFixed(4)).join(","),wh={Tetrahedron:{net:ri(sd,zt(3)*50),scale:1.1,name:"Tetrahedron"},Cube:{net:ri(id,zt(4)*50),scale:.8,name:"Cube"},Octahedron:{net:ri(nd,zt(3)*50),scale:.95,name:"Octahedron"},Dodecahedron:{net:ri(rd,zt(5)*50),scale:.42,name:"Dodecahedron"},Icosahedron:{net:ri(od,zt(3)*50),scale:.67,name:"Icosahedron"},Pyramid:{net:ld(6,50,100),scale:.57,name:"Pyramid"},Prism:{net:hd(6,50,100),scale:.45,name:"Prism"}},yh={fov:400},wd=[1.066,.243,-.088],rs=class extends H{constructor(t,i,n){var o;super(t,i,n);this.cannotRotateType=!0;this.net=((o=wh[this.props.net])==null?void 0:o.net)||V0(this.props.net),this.rotation=vd(this.props.rotation);let r=dh(this.net,a=>new Ki(a.shape,{class:"polygon-tile"},a.color||gh(a.shape.points.length)));this.solid=r.group,this.foldTree=r.foldTree,this.$el.append(this.solid.$el),this.$outline=m("path",{class:"outline"},this.$el),this.$moveBar=m("path",{d:"M0 0h30",class:"handle"},this.$el),this.$moveHandle=m("path",{d:"M0 0h14v14h-14Z",class:"handle",style:"cursor: grab"},this.$el),this.solid.$el.css("cursor","move"),this.props.watch("color",({color:a})=>{if(a){for(let h of this.solid.getFaces())h.color=a;this.render(!1)}}),this.render(),this.updateOutline(),t.events.listen(this.solid.$el,{start:()=>{t.selection.add(this,!0),this.$el.removeClass("active")},move:({posn:a,lastPosn:h})=>{this.solid.transform.dragToRotate(h.subtract(this.posn),a.subtract(this.posn),100),this.render(!1)},end:()=>{this.rotation=this.solid.transform.toEulerAngles(),this.props.rotation=vh(this.rotation),this.updateOutline(),t.flushChanges(),this.$el.addClass("active")},click:a=>t.tools.move.down(a),checkIfActive:()=>this.props.hinge>0})}applyChange(t){super.applyChange(t),this.rotation=vd(this.props.rotation),this.render(),this.updateOutline()}render(t=!0){t&&(this.solid.transform.clear(),uh(this.foldTree,this.solid.children[0],-this.props.hinge),this.solid.transform.rotate(...this.rotation)),this.solid.render(yh)}updateOutline(){let t=this.solid.getProjectedVertices(yh);this.path=V.convexHull(...t),this.$outline.draw(this.path),this.transform(),this.$moveBar.translate(this.path.points[0].x-30,this.path.points[0].y),this.$moveHandle.translate(this.path.points[0].x-45,this.path.points[0].y-7)}animateHinges(t,i=!1,n=800){return D(this,null,function*(){let r=i?this.rotation:[0,0,0],o=this.props.hinge;yield pt(a=>{this.props.hinge=tt(o,t,a),i&&(this.rotation=r.map(h=>h*(1-a))),this.render()},n).promise,this.props.rotation=vh(this.rotation),this.updateOutline()})}hingeStart(){this.startRotation=this.rotation,this.startAngle=this.props.hinge,this.$el.removeClass("active")}hingeMove(t){if(!x(t,this.props.hinge)){if(this.props.hinge=B(t,0,1),this.startRotation&&this.startAngle){let i=B(t/this.startAngle,0,1);this.rotation=this.startRotation.map(n=>i*n)}this.render()}}hingeEnd(){this.updateOutline(),this.props.rotation=vh(this.rotation),this.$el.addClass("active")}static fold(t){let i=gd(t);if(!i){xr("polyhedron-error");return}let n={name:"polyhedron",net:I0(i[1]),hinge:0,rotation:"0,0,0"},r=H.create(t[0].$parent,n),o=r.solid.children[0].transform.matrix;r.setTransform(i[0].shift(-o[0][3],-o[1][3])),r.props.hinge=1,setTimeout(()=>{r.props.hinge=0,r.animateHinges(1)},10);for(let a of t)a.delete();return r}unfold(){return D(this,null,function*(){this.$parent.selection.remove(this),this.props.hinge>0&&(yield this.animateHinges(0,!0));let t=Array.from(this.solid.getFaces()).map(i=>{let n=new V(...Array.from(i.getProjectedVertices())),r=this.props.color||i.color||gh(n.points.length);return H.create(this.$parent,{name:"polygon",shape:oi(n),color:r,x:this.posn.x,y:this.posn.y})});return this.delete(),t})}static makeThumbnail(t,i){let n=m("svg",{width:70,height:70},t),r=m("g",{transform:"translate(35, 35)"},n),{net:o,scale:a}=wh[i.net],h=dh(o,l=>new Ki(l.shape,{class:"polygon-tile"},gh(l.shape.points.length)),-1).group;h.transform.clear().rotate(...wd).scale({x:a,y:a,z:a}),r.append(h.$el),h.render(yh)}static altText(t){var i;return((i=wh[t.net])==null?void 0:i.name)||"Polyhedron"}};rs.type="polyhedron",rs.defaultProps={hinge:1,rotation:wd.join(",")},rs=T([Ut],rs);Mt([{id:"unfold",type:"button",tileTypes:["polyhedron"],label:"Unfold",click:s=>Promise.all(s.map(e=>e.unfold()))},{id:"hinges",type:"slider",tileTypes:["polyhedron"],label:"Hinges",start:s=>s.hingeStart(),move:(s,e)=>s.hingeMove(e),end:s=>s.hingeEnd(),get:s=>s.props.hinge}]);var L=50,at=Math.sqrt(3)/4*L;function zt(s){let e=Math.cos(Tt/s);return 1/Math.sqrt(2-2*e)}var xd={"equ-triangle":new V(new p(-L/2,at),new p(L/2,at),new p(0,-at)),square:V.regular(4,L*zt(4)),"reg-pentagon":V.regular(5,L*zt(5)),"reg-hexagon":V.regular(6,L*zt(6)),"reg-heptagon":V.regular(7,L*zt(7)),"reg-octagon":V.regular(8,L*zt(8)),"reg-decagon":V.regular(10,L*zt(10)),"reg-dodecagon":V.regular(12,L*zt(12)),rectangle:new G(new p(-L,-L/2),2*L,L).polygon,trapezium:new V(new p(-L,at),new p(L,at),new p(L/2,-at),new p(-L/2,-at)),rhombus:new V(new p(-L*3/4,at),new p(L/4,at),new p(L*3/4,-at),new p(-L/4,-at)),"right-triangle":new V(new p(-L/2,-L/2),new p(L/2,-L/2),new p(-L/2,L/2)),"rhombus-2":new V(new p(L/2-at,L/4),new p(-at-L/2,L/4),new p(at-L/2,-L/4),new p(at+L/2,-L/4)),chevron:new V(new p(-.75*L,2*at),new p(.25*L,2*at),new p(.75*L,0),new p(.25*L,-2*at),new p(-.75*L,-2*at),new p(-.25*L,0)),"right-triangle-2":new V(new p(-2*at,-L/2),new p(-2*at,L/2),new p(2*at,-L/2)),kite:new V(new p(0,-L),new p(2*at,-L/2),new p(0,L),new p(-2*at,-L/2)),dart:new V(new p(2*at,.75*L),new p(0,-.75*L),new p(-2*at,.75*L),new p(0,.25*L))},L0={"equ-triangle":"Equilateral Triangle",square:"Square","reg-pentagon":"Regular Pentagon","reg-hexagon":"Regular Hexagon","reg-heptagon":"Regular Heptagon","reg-octagon":"Regular Octagon","reg-decagon":"Regular Decagon","reg-dodecagon":"Regular Dodecagon",rectangle:"Rectangle",trapezium:"Trapezium",rhombus:"Rhombus","right-triangle":"Right Triangle","rhombus-2":"Rhombus",chevron:"Chevron","right-triangle-2":"Right Triangle",kite:"Kite",dart:"Dart"},O0=[[[-15.7728,63.1105],[-65.2725,56.0545],[-61.7426,-21.037],[-34.7275,-63.1105],[65.2725,-63.1105]],[[60.6056,14.8729],[-53.4909,57.394],[-80.668,-12.5086],[-20.582,-57.394],[80.668,-57.394]],[[0,-73.612],[50,12.9905],[15,73.612],[-50,12.9905],[-30,-73.612]],[[67.056,-58.248],[67.056,1.752],[-10.5597,58.248],[-67.056,-19.3675],[7.056,-58.248]],[[-74.4415,-47.6314],[35.5585,-47.6314],[74.4415,-8.733],[60.1965,44.3902],[-19.4415,47.6314]],[[47.6215,-81.108],[43.731,-26.2458],[-24.012,81.108],[-47.6215,-43.6179],[-7.3786,-81.108]],[[94.9659,43.7299],[-5.0343,43.7299],[-94.9659,0],[-5.0343,-43.7299],[42.1151,-41.1631]],[[-13.1927,57.1955],[76.8074,57.1955],[76.8257,-32.8045],[-9.8062,-57.1955],[-76.8257,-6.4506]],[[-3.2764,58.8874],[86.2804,29.1016],[26.2804,-43.7514],[-26.2804,-58.8874],[-86.2804,13.9666]],[[51.5265,-55],[58.4735,-14.7198],[9.6458,43.251],[-58.4735,55],[-58.4735,-55]],[[-95.733,-40.991],[53.87,-40.991],[95.733,-15.7718],[1.5099,40.991],[-95.733,-10.4271]],[[-85.642,-51.4515],[12.4961,-51.4515],[85.642,-13.2965],[-38.4855,51.4515],[-85.642,18.5485]],[[-69.99,67.0025],[84.488,2.9975],[84.488,-67.0025],[14.488,-67.0025],[-84.488,32.0117]],[[-15.6401,96.696],[46.9202,6.219],[8.0799,-96.696],[-46.9202,-96.696],[-46.9202,51.458]],[[-46.6683,85],[-46.6683,22.7758],[15.5561,-85],[46.6683,-31.1122],[15.5561,85]],[[0,-46.65],[-43.301,-21.65],[-43.301,46.65],[43.301,46.65],[43.301,-21.65]],[[-25,46.65],[25,46.65],[59.15,-12.5],[0,-46.65],[-59.15,-12.5]],[[0,-64.951],[-50,21.65],[-25,64.951],[25,64.951],[50,21.65]]].map(s=>new V(...s.map(e=>new p(...e)))),Xi=["","","",F.yellow,F.blue,F.green,F.red,F.teal,F.purple],R0={trapezium:F.orange,"right-triangle":F.green,"rhombus-2":F.lime,chevron:F.orange,kite:F.purple,dart:F.teal},D0={"equ-triangle":F.green,square:F.yellow,"reg-pentagon":F.blue,"reg-hexagon":"#ffd615",rectangle:F.yellow,trapezium:"#cc1030",rhombus:F.blue,"rhombus-2":"#e6e2c6",chevron:"#cc1030","right-triangle-2":"#ffd615",kite:"#134791",dart:F.purple},N0=[...$t.rainbow(15).map(s=>s.hex),F.red,F.blue,F.yellow],G0=new Set(["trapezium","rhombus","rhombus-2","rectangle","right-triangle","right-triangle-2"]),z0=new Set(["equ-triangle","square","reg-pentagon","reg-hexagon","reg-heptagon","reg-octagon","reg-decagon","reg-dodecagon","rectangle","trapezium","kite","dart"]),oi=s=>s.points.map(e=>`${e.x.toFixed(2)} ${e.y.toFixed(2)}`).join(","),B0=s=>new V(...s.split(",").map(e=>{let[t,i]=e.split(" ");return new p(+t||0,+i||0)}));function Yr(s){return s.startsWith("pentagon-")?O0[+s.slice(9)-1]:/^[\d.-]/.test(s)?B0(s):xd[s]||xd.square}function $d(s,e,t=!1){return s.startsWith("pentagon-")?N0[+s.slice(9)-1]:(t?D0:R0)[s]||Xi[e%Xi.length]||F.yellow}var Yi=class extends ii{constructor(e,t,i){super(e,t,i);let n=Yr(this.props.shape);this.props.watch("scale isFlipped",({isFlipped:r,scale:o})=>this.setPath(n.scale(o||1),r)),this.symmetric=z0.has(this.props.shape),this.props.color||(this.props.color=$d(this.props.shape,this.path.points.length,e.options.altColors))}static makeThumbnail(e,t,i){let n=G0.has(t.shape)?60:80,r=Yr(t.shape);r=r.scale((t.shape.startsWith("pentagon-")?41:36)/r.radius).shift(40,n/2);let o=m("svg",{width:80,height:n},e),a=m("path",{class:"polygon-tile",path:r},o);i.options.watch(h=>a.setAttr("fill",$d(t.shape,r.points.length,h.altColors)))}static altText(e){if(e.shape.startsWith("pentagon-")){let t=+e.shape.slice(9);return t<16?`Pentagon ${t}`:t===16?"Prismatic Pentagon":t===17?"Cairo Pentagon":"Floret Pentagon"}return L0[e.shape]||"Polygon"}};Yi.type="polygon",Yi=T([Ut],Yi);var ai=["polygon","tangram","polyomino","custom-polygon","rectangle","reg-polygon","fractal","penrose","aperiodic-hat"];Mt([{id:"flip",type:"button",label:"Flip",icon:"flip",useTextLabel:!0,tileTypes:[...ai,"arrow","egg","garden","number-frame"],show:s=>s.length>1||!!s[0].rot||!s[0].symmetric,click:(s,e)=>{let t=e.selection.center;for(let i of s)i.flip(t)}},{id:"cut",type:"button",tileTypes:ai,label:"Cut",icon:"cut",useTextLabel:!0,noFlush:!0,show:s=>s.every(e=>!(e.is("rectangle")&&e.props.cornerRadius>0)),click:(s,e)=>e.tools.cutPolygon.enable()},{id:"join",type:"button",label:"Join",icon:"merge",useTextLabel:!0,tileTypes:ai,location:"more",show:s=>s.length>1&&s.every(e=>!(e.is("rectangle")&&e.props.cornerRadius>0)),click:(s,e)=>{let t=s.map(o=>o.transformed),i=V.union(...t),n=s[0].props.color,r=i.map(o=>H.create(e,{name:"polygon",shape:oi(o),color:n}));for(let o of s)o.delete();e.selection.select(r,!0)}},{id:"fold-net",type:"button",label:"Fold Net",icon:"cube",useTextLabel:!0,tileTypes:ai,show:s=>s.length>2,click:s=>rs.fold(s)},{id:"animation",type:"select",tileTypes:ai,label:"Animation:",location:"music",flattenGroups:!0,feature:"noMusic",options:[{key:"vertices",label:"Vertices"},{key:"perimeter",label:"Perimeter"},{key:"area",label:"Area"},{key:"angles",label:"Angles"}],get:s=>{var e;return((e=s.props.animation)==null?void 0:e.replace("hidden","perimeter"))||"perimeter"},set:(s,e)=>e.props.animation=s},{id:"audio-labels",type:"checkbox",tileTypes:ai,label:"Show labels:",location:"music",flattenGroups:!0,feature:"noMusic",show:s=>s.every(e=>!["vertices"].includes(e.props.animation)),get:s=>s.props.labels==="number",set:(s,e)=>e.props.labels=s?"number":void 0}]);Mt([{id:"label",type:"input",label:"Label:",tileTypes:_r,icon:"text",authorOnly:!0,get:s=>s.props.textLabel||"",set:(s,e)=>e.props.textLabel=`${s}`},{id:"labelFontSize",type:"input",label:"Font size:",tileTypes:_r,icon:" ",value:"number",range:[1,15],increment:1,authorOnly:!0,show:s=>s.some(e=>e.props.textLabel),get:s=>5+(s.props.textLabelFontSize||0),set:(s,e)=>e.props.textLabelFontSize=+s-5},{id:"textLabelRotate",type:"checkbox",label:"Rotate label:",tileTypes:_r,icon:" ",authorOnly:!0,show:s=>s.some(e=>e.props.textLabel),get:s=>!!s.props.textLabelRotate,set:(s,e)=>e.props.textLabelRotate=s}]);Mt([{id:"scale",type:"input",label:"Scale:",location:"more",value:"number",range:[.1,10],icon:"geo-scale",increment:.1,tileTypes:["polygon","reg-polygon","rectangle","custom-polygon"],get:s=>s.props.scale||1,set:(s,e)=>{let t=e.path.centroid.scale(1-+s/(e.props.scale||1));e.setTransform(e.posn.add(t)),e.props.scale=+s,e.$parent.selection.update()}}]);var Pd='';var bt=50,_0=100,ui=class extends H{constructor(t,i,n){super(t,i,n);this.cannotRotateType=!0;this.cannotDragToSelect=!0;this.$el.addClass("utensil"),this.setup(),this.$handles=[0,1].map(r=>this.makeHandle("c",(o,a)=>{let h=r?this.posn:this.absoluteEnd;a=this.$parent.snapping.orthogonal(a,h),r&&(this.absoluteEnd=a);let l=r?this.posn:a;this.props.isFixed||(this.props.width=Math.max(p.distance(l,this.absoluteEnd),_0)),this.setTransform(l,Kt(this.absoluteEnd.angle(l))),this.update()})),this.update()}applyChange(t){super.applyChange(t),this.update()}flip(){this.props.isFlipped=!this.props.isFlipped,this.update()}transform(t){super.transform(t),this.absoluteEnd=this.worldPosn(new p(this.props.width,0))}update(){this.$handles[1].setCenter({x:this.props.width,y:0}),this.transform()}getDrawingPath(t){var n;let i=(n=this.transformed)==null?void 0:n.project(t);if(i&&p.distance(t,i)<30)return this.transformed}},q0=new Set(["ruler","protractor","set-triangle","compass"]);function Sd(s){return q0.has(s.props.name)}var F0=2.54,Zr=60,hi=bt*F0;function*Td(s,e,t,i){let n=(e+.1)/s;for(let r=0;r<=n;r+=1){let o=i?i.findIndex(h=>!(r%h)):-1,a=r*s;yield[t?e-a:a,o]}}var li=class extends ui{constructor(t,i,n){super(t,i,n);this.padding=[0,20,0,20];this.props.watch("units fixed",()=>this.update())}setup(){this.$glass=m("rect",{x:-20,height:Zr,class:"glass",rx:5},this.$el),this.$ticks=m("path",{class:"ticks"},this.$el),this.$labelsTop=z(t=>m("text",{text:t},this.$el),31),this.$labelsBottom=z(t=>m("text",{text:t,y:42},this.$el),12),this.$labelsBottom[0].text="0 in"}update(){let{units:t,width:i,isFlipped:n}=this.props,r=t==="both",o=t==="hidden";this.$glass.setAttr("width",i+40),this.path=new G(R,i,Zr);let a="";if(!o&&t!=="in")for(let[l,c]of Td(bt/10,i,n,[10,5]))a+=`M${l} 0v${([20,15][c]||10)*(r?.8:1)}`;if(!o&&t!=="cm"){let l=r?Zr:0;for(let[c,u]of Td(hi/16,i,n,[16,8,4]))a+=`M${c} ${l}v${([20,16,12][u]||8)*(r?-.8:1)}`}this.$ticks.setAttr("d",a),this.$labelsTop[0].text=t==="in"?"0 in":"0 cm";let h=t==="in"?hi:bt;for(let[l,c]of this.$labelsTop.entries())c.toggle(!o&&l*h<=i+.1),c.setAttr("y",r?26:32),c.setAttr("x",n?i-h*l:h*l);for(let[l,c]of this.$labelsBottom.entries())c.toggle(!o&&r&&l*hi<=i+.1),c.setAttr("x",n?i-hi*l:hi*l);super.update()}getSnapPoints(){if(this.props.units==="hidden")return[];let t=this.props.units==="both",i=hi/2,n=z(o=>new p(this.props.isFlipped?this.props.width-o*bt:o*bt,0),this.props.width/bt),r=z(o=>new p(this.props.isFlipped?this.props.width-o*i:o*i,t?Zr:0),this.props.width/i);return this.props.units==="cm"?n:t?[...n,...r]:r}getSnapLines(){let[t,i,n]=this.path.edges;return this.props.units==="both"?[t,n]:[t]}getDrawingPath(t){if(!this.transformed)return;let[i,n,r]=this.transformed.edges,o=p.distance(t,i.project(t)),a=p.distance(t,r.project(t));return o<30?i:this.props.units==="both"&&a<30?r:void 0}static altText(){return"Ruler"}};li.type="ruler",li.defaultProps={width:400,layer:"front",units:"cm"},li=T([Ut],li);function H0(s){return`M0-${s}A${s},${s},0,0,0-${s},0V3a5,5,0,0,0,5,5H${s-5}a5,5,0,0,0,5-5V0A${s},${s},0,0,0,0-${s}Z`}var ci=class extends ui{constructor(){super(...arguments);this.padding=[0,0,10,0]}setup(){this.$glass=m("path",{d:"",class:"glass"},this.$el),this.$ticks=m("path",{class:"ticks"},this.$el),this.$labels=z(t=>[m("text",{text:t*10},this.$el),m("text",{text:t*10,style:"font-size:9px"},this.$el)],19),this.$labels[9][0].css("font-size","20px"),this.$labels[9][1].hide()}update(){let t=this.props.width;this.path=new Ft(R,new p(-this.props.width,0),Math.PI),this.$glass.setAttr("d",H0(t));let i="",n=this.props.width<120?5:1;for(let r=0;r<=180;r+=n){let o=!(r%10),a=!o&&!(r%5),h=p.fromPolar(J(-r)),l=t-(o?30:a?23:15);i+=`M${h.x*t} ${h.y*t}L${h.x*l} ${h.y*l}`,o&&(i+=`M${h.x*8} ${h.y*8}L${h.x*(t-60)} ${h.y*(t-60)}`)}this.$ticks.setAttr("d",i);for(let[r,[o,a]]of this.$labels.entries()){if(r===9){o.setAttr("y",52-t);continue}o.toggle(t>160||!(r%3)),a.toggle(t>160),o.setAttr("y",44-t),a.setAttr("y",55-t),o.setAttr("transform",`rotate(${(this.props.isFlipped?-1:1)*(90-10*r)})`),a.setAttr("transform",`rotate(${(this.props.isFlipped?1:-1)*(90-10*r)})`)}super.update()}getSnapPoints(){return[R,this.path.start,this.path.at(.5),this.path.end]}getSnapLines(){return[]}static altText(){return"Protractor"}};ci.type="protractor",ci.defaultProps={width:200,layer:"front"},ci=T([Ut],ci);var bh=234,to=150;function j0(s){let e=sm("text",{text:t,y:-23},this.$el),31),this.$hLabels[0].hide(),this.$vLabels=z(t=>m("text",{text:t,x:25,"dominant-baseline":"central"},this.$el),31),this.$vLabels[0].hide()}update(){this.path=new V(R,new p(this.props.width,0),new p(0,-this.props.width)),this.$glass.setAttr("d",j0(this.props.width));let t=this.props.width-50,i="",n=2,r=1;for(let o=0;o<=t;o+=bt/10){let a=o%bt?o%(bt/2)?0:r:n,h=o<10?-10*(o/10):[-10,-15,-20][a];i+=`M${o} 0V${h}`}for(let o=0;o<=t;o+=bt/10){let a=o%bt?o%(bt/2)?0:r:n,h=o<10?10*(o/10):[10,15,20][a];i+=`M0,${-o} H${h}`}this.$ticks.setAttr("d",i);for(let[o,a]of this.$hLabels.entries())o>0&&a.toggle(this.props.width>=to&&o0&&a.toggle(this.props.width>=to&&oi.at(a*bt/t),t/bt),o=z(a=>n.at(a*bt/t),t/bt);return r.concat(o)}getSnapLines(){return[this.path]}static altText(){return"Set Triangle"}};pi.type="set-triangle",pi.defaultProps={width:280,layer:"front"},pi=T([Ut],pi);var Qr=375,Jr=new p(54,68),di=class extends ui{setup(){this.$el.html=Pd,this.$pencil=this.$el.$(".pencil"),this.$top=this.$el.$(".top"),this.$legPin=this.$el.$(".leg-pin"),this.$legPencil=this.$el.$(".leg-pencil"),this.props.watch("color",({color:n})=>this.$pencil.css("fill",n));let t,i=0;this.$parent.events.listen(this.$pencil.$("g"),{start:n=>{let r=new p(this.props.width,0).rotate(J(this.rot)).add(this.posn);t=new He(this.$parent,"",this.props.color,"pen"),t.start(r,new wt(this.posn,this.props.width)),i=Kt(n.posn.angle(this.posn))-this.rot;for(let o of this.$handles)o.setAttr("hidden",!0)},move:n=>{this.rot=Kt(n.posn.angle(this.posn))-i,this.transform();let r=p.fromPolar(J(this.rot),this.props.width).add(this.posn);t.addPoint(r)},end:()=>{t.end(),this.$parent.flushChanges(),t=void 0;for(let n of this.$handles)n.removeAttr("hidden")}}),this.$parent.events.listen(this.$top,{start:n=>{i=Kt(n.posn.angle(this.posn))-this.rot;for(let r of this.$handles)r.setAttr("hidden",!0)},move:n=>{this.rot=Kt(n.posn.angle(this.posn))-i,this.transform()},end:()=>{this.$parent.flushChanges();for(let n of this.$handles)n.removeAttr("hidden")}})}update(){this.props.width>730&&(this.props.width=730);let t=this.props.width-Jr.x,i=Qr-Jr.y,n=new wt(R,Qr),r=new wt(new p(t,-Jr.y),i),o=Q(n,r)[0],a=Math.acos(o.x/Qr),h=Math.acos((t-o.x)/i);this.$legPin.css("transform",`rotate(${-a+Ya}rad`),this.$legPencil.css("transform",`rotate(${h-Ya}rad`),this.$pencil.setTransform({x:this.props.width-Jr.x,y:0}),this.$top.setTransform({x:o.x,y:Qr+o.y}),this.path=new Y(R,new p(this.props.width,0)),super.update()}getSnapPoints(){return[R,new p(this.props.width,0)]}getDrawingPath(){}static altText(){return"Compass"}};di.type="compass",di.defaultProps={width:300,layer:"front",color:F.red},di=T([Ut],di);Mt([{id:"flip",type:"button",tileTypes:["ruler","protractor"],label:"Flip",icon:"flip",useTextLabel:!0,click:s=>{for(let e of s)e.flip()}}]);Mt([{id:"labels",type:"select",tileTypes:["ruler"],label:"Labels:",options:[{label:"Centimeters",key:"cm"},{label:"Inches",key:"in"},{label:"Both",key:"both"},{label:"None",key:"hidden"}],location:"more",get:s=>s.props.units,set:(s,e)=>e.props.units=s},{id:"fixed-length",type:"checkbox",tileTypes:["ruler"],label:"Fixed Length",location:"more",get:s=>!!s.props.isFixed,set:(s,e)=>e.props.isFixed=s}]);var Ue=class{constructor(e){this.$parent=e}getTileAt(e){let t=this.$parent.snapping.snapGeo(e.posn);if(t!=null&&t.tile&&t.tile.canSelect)return t.tile;let i=e.target;for(;i;){let n=Fr.get(i);if(n!=null&&n.canSelect&&n.props.name!=="geo")return n;if(i=i.parentNode||void 0,i===this.$parent._el)return}}hoverGeoTile(e){var t;this.hoveringTile!==e&&((t=this.hoveringTile)==null||t.hover(!1)),e==null||e.hover(),this.hoveringTile=e}down(e){}start(e){}move(e){}up(e){}end(e){}click(e){}hover(e){}cancel(){}},eo=class extends Ue{constructor(){super(...arguments);this.clickTimeout=0}down(t){var n,r;let i=this.activeTile=(n=this.getTileAt(t))==null?void 0:n.root;this.activeTileWasSelected=i==null?void 0:i.isActive,this.previousSelection=void 0,(r=this.$parent.focussedTile)==null||r.blur(),this.$parent.warningBanner.hide(),i?(i.isActive&&this.$parent.events.shiftKey?this.$parent.selection.remove(i):(this.$parent.events.shiftKey||!i.isActive)&&this.$parent.selection.add(i,!this.$parent.events.shiftKey),i.down(t),this.$parent.events.grabbing()):this.$parent.events.shiftKey?this.previousSelection=new Set(this.$parent.selection.tiles):this.$parent.selection.clear()}up(t){var i;(i=this.activeTile)==null||i.up(t)}start(){if(this.activeTile){let t=!this.$parent.state.authorMode&&this.activeTile.props.status==="generator";(this.$parent.events.altKey||t)&&(t&&this.$parent.selection.add(this.activeTile,!0),this.$parent.paste(this.$parent.selection.copy(!0),R)),this.$parent.selection.moveStart()}else this.$parent.$selection.show()}move(t){var n;if(this.activeTile){this.$parent.selection.move(t);return}let i=G.aroundPoints([t.startPosn,t.posn]);this.$parent.$selection.setRect(i);for(let r of this.$parent.tiles.values()){if(!r.canSelect||r.cannotDragToSelect||!r.transformed||r.group)continue;let o=_i(i,r.transformed,r.props.name);(this.$parent.events.shiftKey&&((n=this.previousSelection)==null?void 0:n.has(r))?!o:o)?this.$parent.selection.add(r,!1,!0):this.$parent.selection.remove(r,!0)}this.$parent.selection.update(!0)}end(){this.activeTile?this.$parent.selection.moveEnd():this.$parent.$selection.hide(),this.$parent.events.grabbing(!1)}click(t){if(this.activeTile){this.activeTile.click(t,!this.activeTileWasSelected);let i=Date.now();i-this.clickTimeout<500&&this.activeTile.doubleClick(t),this.clickTimeout=i}}hover(t){let i=this.getTileAt(t);this.hoverGeoTile(i!=null&&i.is("geo")?i:void 0),this.$parent.$svg.css("cursor",i?"grab":"")}},so=class extends Ue{down({posn:e}){this.erase(e)}move({posn:e,lastPosn:t}){let i=p.distance(e,t)/4;for(let n=0;nn.distanceSquared(e)<100):U(t)&&i==="geo"?Math.abs(p.distance(e,t.c)-t.r)<10:t.contains(e)}erase(e){let t=this.$parent.option("noDeleting")?[]:this.$parent.tiles.values();for(let i of t)if(!(!i.transformed||i.cannotDragToSelect||!i.canSelect||!i.canEdit)&&this.shouldErase(e,i.transformed,i.props.name)){i.delete();return}for(let i of this.$parent.strokes.values())if(i.hitTest(e,10)){i.delete();return}}end(){this.$parent.flushChanges(),this.$parent.snapping.updateIntersections()}click(){this.end()}},io=class extends Ue{constructor(){super(...arguments);this.options="text"}down({posn:t}){let i=H.create(this.$parent,{name:this.options,x:t.x-10,y:t.y-15});this.$parent.trigger("add-tile",{tile:i}),this.$parent.setActiveTool("move"),i.focus(!0)}},no=class extends Ue{enable(){this.previousTool=this.$parent.state.tool,this.$parent.setActiveTool("pan")}down(t){this.initialOrigin=this.$parent.origin,this.startPosn=Vt(t.event)}move(t){let i=Vt(t.event).subtract(this.startPosn),n=this.initialOrigin.subtract(i.scale(1/this.$parent.zoom));this.$parent.setViewport(n,this.$parent.zoom)}disable(){this.$parent.setActiveTool(this.previousTool)}},ro=class extends Ue{constructor(){super(...arguments);this.options="pen"}getUtensil(t){for(let i of this.$parent.tiles.values()){let n=Sd(i)?i.getDrawingPath(t):void 0;if(n)return n}}down({posn:t}){this.stroke=new He(this.$parent,"",this.$parent.state.penColor,this.options),this.stroke.start(t,this.getUtensil(t))}move({posn:t}){this.stroke.addPoint(t)}click(){this.$parent.flushChanges(),this.stroke=void 0}end(t){this.stroke.end(),this.click()}},Zi=class extends Ue{constructor(){super(...arguments);this.options="line";this.angleIndex=0}expr(t,i){var n;switch(this.options){case"line":return`segment(${t},${i})`;case"circle":return`circle(${t},distance(${t},${i}))`;case"rect":return`rectangle(${t},${i}.x-${t}.x,${i}.y-${t}.y)`;case"angle":return`angle(${i},${(n=this.midPoint)==null?void 0:n.props.key},${t})`}}snapPoint(t){var o;this.$parent.options.canvas!=="infinite"&&(t=t.clamp(this.$parent.canvasBounds));let i=this.$parent.snapping.snap([t]);i&&(t=t.add(i.shift));let n="",r=((o=i==null?void 0:i.tile)==null?void 0:o.props.name)==="geo"?i==null?void 0:i.tile:void 0;return r!=null&&r.path&&rt(r.path)&&(n=r.props.key),i!=null&&i.intersection&&(n=i.intersection),{point:t,tile:r,expr:n||`point(${t.x},${t.y})`}}getOrMakePointTile(t){var n,r;if((n=t==null?void 0:t.tile)!=null&&n.path&&rt(t.tile.path))return t.tile;if((r=t==null?void 0:t.tile)!=null&&r.path){let o=t.tile.path.offset(t.point),a=new Yt(this.$parent,{expr:`${t.tile.props.key}.at(${o})`});return this.$parent.trigger("add-tile",{tile:a}),a}let i=new Yt(this.$parent,{expr:t.expr});return this.$parent.trigger("add-tile",{tile:i}),i}drawPendingPoint(t){var r,o;let i=((o=(r=t.tile)==null?void 0:r.path)==null?void 0:o.type)==="point",n=t.expr.startsWith("intersection");this.$parent.$pendingPoint.toggle(!i),i||(this.$parent.$pendingPoint.setCenter(t.point),this.$parent.$pendingPoint.setClass("intersection",n),this.$parent.$pendingPoint.setAttr("r",n?3.5:6))}down({posn:t}){let i=this.snapPoint(t),n=this.getOrMakePointTile(i);this.options==="angle"?(this.angleIndex===0?(this.startPoint=n,this.angleIndex=1):this.angleIndex===1?(this.midPoint=n,this.angleIndex=2,this.path=new Yt(this.$parent,{expr:this.expr(this.startPoint.props.key,n.props.key)})):(this.path.setExpr(this.expr(this.startPoint.props.key,n.props.key)),this.angleIndex=0,this.path=this.startPoint=this.midPoint=void 0),this.$parent.flushChanges()):this.startPoint=n}start(){var t;this.options!=="angle"&&(this.path=new Yt(this.$parent,{}),this.startPoint.pending=this.path.pending=!0,(t=this.$parent.$pendingPoint)==null||t.show(),this.hoverGeoTile())}move({posn:t}){var i;this.options!=="angle"&&(this.endSnap=this.snapPoint(t),this.path.setExpr(this.expr(this.startPoint.props.key,this.endSnap.expr),!0),this.drawPendingPoint(this.endSnap),this.hoverGeoTile((i=this.endSnap)==null?void 0:i.tile))}end(){var n;if(this.options==="angle")return;let t=p.distance(this.startPoint.path,this.endSnap.point)<8,i;t?this.path.delete():(i=this.getOrMakePointTile(this.endSnap),this.path.setExpr(this.expr(this.startPoint.props.key,i.props.key)),this.path.setPending(!1),this.$parent.trigger("add-tile",{tile:this.path})),this.startPoint.setPending(!1),(n=this.$parent.$pendingPoint)==null||n.hide(),this.hoverGeoTile(),this.$parent.snapping.updateIntersections(),this.$parent.flushChanges(),this.startPoint=this.path=this.endSnap=void 0}click(){this.options!=="angle"&&this.$parent.flushChanges()}hover(t){var n;let i=this.snapPoint(t.posn);this.drawPendingPoint(i),this.hoverGeoTile(((n=i==null?void 0:i.tile)==null?void 0:n.props.name)==="geo"?i.tile:void 0),this.options==="angle"&&this.angleIndex===2&&this.path.setExpr(this.expr(this.startPoint.props.key,i.expr))}cancel(){this.$parent.$pendingPoint.hide(),this.path&&this.path.delete(),this.startPoint=this.path=this.endSnap=void 0,this.angleIndex=0}},oo=class extends Zi{constructor(){super(...arguments);this.expression=""}enable(t){var i;this.expression=t,this.$parent.selection.clear(),this.$parent.setActiveTool("geoPending"),(i=window.event)!=null&&i.clientX&&this.hover({posn:me(window.event,this.$parent.$svg)})}makePath(){return this.path=new Yt(this.$parent,{}),this.path.$el.css("opacity",.5),this.path.pending=!0,this.path}down(t){if(!this.expression)return;super.down(t);let i=this.path||this.makePath();i.$el.css("opacity",1),i.setExpr(this.expression.replace(/\$1/g,this.startPoint.props.key)),i.pending=!1,this.path=void 0,this.$parent.selection.add(i,!0),this.$parent.flushChanges(),this.$parent.snapping.updateIntersections(),this.$parent.trigger("add-tile",{tile:i}),this.$parent.setActiveTool("move")}hover({posn:t}){var n;if(!this.expression)return;let i=this.snapPoint(t);this.drawPendingPoint(i),this.hoverGeoTile(((n=i==null?void 0:i.tile)==null?void 0:n.props.name)==="geo"?i.tile:void 0),this.path||this.makePath(),this.path.setExpr(this.expression.replace(/\$1/g,i.expr))}cancel(){super.cancel(),this.expression=""}},ao=class extends Ue{enable(){if(this.tiles=Array.from(this.$parent.selection.tiles),!this.tiles.length)return this.cancel();this.$parent.selection.clear(),this.$parent.setActiveTool("cutPolygon");for(let t of this.tiles)t.$el.addClass("active")}down(){}start({posn:t}){var i;this.tiles&&(this.startPoint=((i=this.$parent.snapping.snap([t]))==null?void 0:i.posn)||t,this.$stroke=m("line",{class:"stroke cut"},this.$parent.$strokes))}move({posn:t}){var i,n;this.tiles&&(this.endPoint=((i=this.$parent.snapping.snap([t]))==null?void 0:i.posn)||t.snap(this.startPoint,5),(n=this.$stroke)==null||n.setLine(this.startPoint,this.endPoint))}end(t){var n;if(!this.tiles)return;if(t.cancelled)return this.cancel();let i=new vt(this.startPoint,this.endPoint);for(let r of this.tiles||[]){let a=r.transformed.cut(i);if(a.length>1){for(let h of a)H.create(this.$parent,ft(ut({},r.props.raw),{name:"polygon",shape:oi(h),scale:void 0,index:void 0,isFlipped:void 0,width:void 0,height:void 0,sides:void 0,x:0,y:0,rot:0}));r.delete()}else r.$el.removeClass("active")}this.$parent.flushChanges(),(n=this.$stroke)==null||n.remove(),this.$stroke=this.tiles=this.startPoint=this.endPoint=void 0,this.$parent.setActiveTool("move")}click(){this.cancel()}cancel(){var t;for(let i of this.tiles||[])i.$el.removeClass("active");(t=this.$stroke)==null||t.remove(),this.$stroke=this.tiles=this.startPoint=this.endPoint=void 0,setTimeout(()=>this.$parent.setActiveTool("move"))}};var Ed='
';var Cd=new Set(["x","y","\u03B8","r"]);function Md(s,e){if(s instanceof jt&&s.fn==="="){let[t,i]=s.args;if(t instanceof Zs&&!(e==="graphing"&&Cd.has(t.i)))return{variable:t.i,expression:i}}return{expression:s}}var ho=class{constructor(){this.assignments=new Map;this.callbackDeps=new Map;this.updatedNames=new Set}get defined(){return[...this.assignments.keys()]}findFirstAssigner(e){var t;return(t=this.assignments.get(e))==null?void 0:t.keys().next().value}findDependants(e,t=[]){let i=[];for(let[r,o]of this.assignments.entries())o.size===1&&r!==e&&!t.includes(r)&&Vs(o.values()).unknowns.filter(h=>!t.includes(h)).includes(e)&&i.push(r);let n=_h(i,r=>this.findDependants(r,i.filter(o=>o!==r)));return[...i,...n]}validate(e){let t=new Set,i=(n,r=[])=>{if(!this.assignments.has(n)){t.add(n);return}if(r.includes(n))return{message:`The variable ${n} is defined recursively.`,locations:r.splice(r.indexOf(n)).map(a=>this.findFirstAssigner(a))};let o=this.assignments.get(n);if(o.size===1){let a=Vs(o.values());for(let h of a.unknowns){let l=i(h,[...r,n]);if(l)return l}}else return{message:`You have defined ${n} in multiple places.`,locations:Array.from(o.keys())}};for(let n of e.unknowns){let r=i(n);if(r)return{error:r,dependsOn:[],unknowns:[]}}return{dependsOn:[],unknowns:Array.from(t)}}evaluate(e){try{let{error:t,unknowns:i}=this.validate(e);return t||i.length?{error:t,value:Number.NaN}:{value:e.evaluate(this.evalContext)}}catch(t){return{value:Number.NaN}}}get evalContext(){let e={};for(let[t,i]of this.assignments.entries())i.size===1&&(e[t]=Vs(i.values()));return e}serializeEvalContext(e){let t={};for(let[i,n]of Object.entries(this.evalContext))e==="graphing"&&Cd.has(i)||(t[i]=n.toString());return t}substituteAssignments(e,t){let i=Md(e,t);return i.variable?new jt("=",[new Zs(i.variable),i.expression.recursiveSubstitute(this.evalContext)]):e.recursiveSubstitute(this.evalContext)}markUpdated(e){this.updatedNames.add(e);for(let t of this.findDependants(e))this.updatedNames.add(t)}flushChanges(){for(let[t,i]of this.callbackDeps.entries())i.some(n=>this.updatedNames.has(n))&&t();let e=Array.from(this.updatedNames);return this.updatedNames.clear(),e}updateSource(e,t,i,n=!0){this.removeSource(e,!1),this.assignments.has(t)||this.assignments.set(t,new Map),this.assignments.get(t).set(e,i),this.markUpdated(t),n&&this.flushChanges()}attemptUpdateSource(e,t,i,n=!0){if(typeof t=="string")try{t=Et.parse(t).collapse()}catch(o){return}let r=Md(t,i);return r.variable?this.updateSource(e,r.variable,r.expression,n):this.removeSource(e),r}removeSource(e,t=!0){for(let[i,n]of this.assignments.entries())n.has(e)&&this.markUpdated(i),n.delete(e),n.size===0&&this.assignments.delete(i);t&&this.flushChanges()}watch(e,t,i=!1){this.callbackDeps.set(t,e),i&&t()}unwatch(e){e&&this.callbackDeps.delete(e)}};var de="/polypad/assets/audio",Ad={roll:new ee(`${de}/roll.mp3`,.6,!1),spin:new ee(`${de}/spin.mp3`,.5,!1),coinToss:new ee(`${de}/coin-toss.mp3`,.3,!1),shuffle:new ee(`${de}/shuffle.mp3`,.3,!1),rng:new ee(`${de}/rng-roll.mp3`,.3,!1),draw:new ee(`${de}/card-draw.mp3`,.2,!1),click:new ee(`${de}/click.mp3`,.3,!1),woosh:new ee(`${de}/woosh.mp3`,.2,!1),rise:new ee(`${de}/rise.mp3`,.3,!1),fall:new ee(`${de}/fall.mp3`,.3,!1),splitCoins:new ee(`${de}/split-coins.mp3`,.175,!1),mergeCoins:new ee(`${de}/merge-coins.mp3`,.3,!1)};var Le=25,xh=Le*Math.sqrt(3)/2,U0=Math.sqrt(2*Le**2)/2;function fi(s,e,t){let i,n,r;t:for(let o of t)for(let a of e){let h=o.posn||o.path.project(a),l=h.subtract(a),c=l.length;if(c^-]/g,""),n=btoa(e.props.name+i+e.props.raw.color).replace(/=/g,""),r=(g=s.tileWeights.get(n))!=null?g:1;return[n,1,0,r,r]}function W0(s,e,t){let i={},n=0,r=(d,g=1)=>{let[y,f,v,w,$]=Ph(s,d);n+=g*w,y&&(i[y]||(i[y]=[0,0,0]),i[y][0]+=g*f,i[y][1]+=g*v,i[y][2]=$)};for(let d of e)r(d,1);for(let d of t)r(d,-1);if(x(n,0))return;let o=Object.keys(i).filter(d=>i[d][0]||i[d][1]),a=o.find(d=>!s.tileWeights.has(d))||O(o);if(!a)return!0;let[h,l,c]=i[a],u=x(l,0)?c-n/h:Math.max(...Bo(l,h,n-h*c-l*c*c));s.tileWeights.set(a,u),s.options.tileWeights=Array.from(s.tileWeights.entries()).map(d=>d.join("=")).join(",")}function Th(s,e){s.tileWeights.clear();for(let t of e.split(",")){let[i,n]=t.split("=");i&&s.tileWeights.set(i,+n||0)}}var kd="M0,26A18.1,18.1,0,0,0-18,44V72H18V44A18.1,18.1,0,0,0,0,26Z",K0=new Set(["text","number-line","spinner","decimal-grid","axes","custom-spinner","ruler","protractor","compass","geo","dot-machine","abacus","balance","chess-board","multi-jump","set-triangle","bucket","table","number-grid","chart","pie-chart","box-whisker","clock","polyhedron","rectangle","question-blank","logic-switch","logic-gate","logic-speaker","chess-piece","function-machine"]),Qi=15,Lt=40,Vd=180;function co(s){let e=s/2;return`M${e},0C${e},16,66.3,20,0,20S${-e},16${-e},0Z`}var mi=class extends H{constructor(t,i,n){super(t,i,n);this.cannotRotateType=!0;this.$beam=m("path",{class:"balance-beam"},this.$el),this.$left=m("path",{class:"balance"},this.$el),this.$right=m("path",{class:"balance"},this.$el),this.$base=m("path",{d:kd,class:"balance"},this.$el),this.dropzones=this.targetAreas().map(r=>this.$parent.dropzoneManager.createDropzone(this,{path:r,ignored:K0})),this.$handle=this.makeHandle("c",r=>{this.props.size=B(Pt(r.x-Lt,20),120,800),this.resize(),this.draw(),this.transform()}),this.$handle.css("cursor","ew-resize"),this.props.watch("color",({color:r})=>{this.$beam.css("stroke",r);for(let o of[this.$base,this.$left,this.$right])o.css("fill",r)}),this.customTransform(),this.resize(),this.draw()}onDropzonesChange(){this.rebalance(400)}applyChange(t){super.applyChange(t),"level"in t&&this.draw()}targetAreas(){let t=new G(new p(0,-Vd),this.props.size,Vd),i=t.shift(-this.props.size-Lt,this.props.level*Qi),n=t.shift(Lt,-this.props.level*Qi);return[i,n]}resize(){this.$left.setAttr("d",co(this.props.size)),this.$right.setAttr("d",co(this.props.size)),this.customTransform()}draw(t=this.props.level){let i=this.props.size/2+Lt,n=new p(-i,t*15),r=new p(i,-t*15);this.$beam.draw(new te(n.shift(0,10),n.shift(0,44),r.shift(0,44),r.shift(0,10))),this.$left.setTransform(n),this.$right.setTransform(r),this.$handle.setCenter({x:this.props.size+Lt,y:-t*15});let[o,a]=this.targetAreas();this.dropzones[0].updateTarget(o),this.dropzones[1].updateTarget(a)}rebalance(t=400){return D(this,null,function*(){let[i,n]=this.dropzones.map(d=>d.containedTiles),r=N(Array.from(ke(i),d=>Ph(this.$parent,d)[3])),o=N(Array.from(ke(n),d=>Ph(this.$parent,d)[3])),a=x(r,o)?0:r({tile:d,posn:d.posn.shift(0,l)})),u=Array.from(n,d=>({tile:d,posn:d.posn.shift(0,-l)}));yield H.animate([...c,...u],t,d=>{this.draw(tt(h,a,d)),this.$parent.selection.update()}),this.isAnimating=!1,this.transform(),this.$parent.selection.update()})}customTransform(){let t=this.props.level*Qi,i=this.props.size+Lt;this.path=new V(new p(-i,t),new p(-Lt,t),new p(-Lt,25),new p(Lt,25),new p(Lt,-t),new p(i,-t),new p(i,-t+48),new p(Lt,-t+48),new p(Lt,72),new p(-Lt,72),new p(-Lt,t+48),new p(-i,t+48))}getSnapPoints(){let t=this.props.level*Qi,i=this.props.size+Lt;return[new p(-i,t),new p(-Lt,t),new p(Lt,-t),new p(i,-t)]}getSnapLines(){let[t,i,n,r]=this.getSnapPoints();return[new Y(t,i),new Y(n,r)]}balance(){let[t,i]=this.dropzones.map(r=>r.containedTiles);if(W0(this.$parent,t,i))return xr("balance-error");for(let r of this.$parent.getTilesOfType("balance"))r.rebalance()}static makeThumbnail(t){let i=m("svg",{width:250,height:50,viewBox:"-290 -10 580 82",class:"scale"},t);m("path",{d:"M-160 10v34h320v-34",fill:"transparent",stroke:"#bbb","stroke-width":10},i),m("path",{d:co(240),transform:"translate(-160 0)",fill:"#bbb"},i),m("path",{d:co(240),transform:"translate(160 0)",fill:"#bbb"},i),m("path",{d:kd,fill:"#bbb"},i)}static altText(){return"Balance Scale"}};mi.type="balance",mi.defaultProps={level:0,size:240,color:"#bbb"},mi=T([Ut],mi);Mt([{id:"balance",type:"button",tileTypes:["balance"],label:"Balance",show:s=>s.length===1&&!!s[0].props.level,click:s=>{s[0].balance()}}]);function Id(s){return[...s].sort((e,t)=>e.props.zIndex-t.props.zIndex)}function Ld(s,e,t){let i=Oo(s,e,t);i>=0&&s.splice(i,1)}function X0(s,e){if(!s.length)return s.push({item:e,val:e.props.zIndex});let t=Lo(s,e.props.zIndex,Io.firstGreater);s.splice(t<0?s.length:t,0,{item:e,val:e.props.zIndex})}var po=class{constructor(e){this.$parent=e;this.sorted={front:[],normal:[],back:[]};this.layers=new WeakMap}clear(){this.sorted={front:[],normal:[],back:[]},this.layers=new WeakMap}addOrUpdate(e){let t=this.layers.get(e);t&&Ld(this.sorted[t.layer],e,t.z);let i=t&&t.layer!==e.props.layer,n=this.sorted[e.props.layer];(e.props.raw.zIndex===void 0||i)&&(e.props.raw.zIndex=n.length?O(n).val+1:0),this.layers.set(e,{layer:e.props.layer,z:e.props.zIndex}),X0(n,e)}remove(e){let t=this.sorted[e.props.layer];Ld(t,e,e.props.zIndex),this.layers.delete(e)}bringToFront(e,t,i){for(let n of Id(e)){if(n.noAutoLayering&&!t)continue;let r=O(this.sorted[n.props.layer]);r.item!==n&&(n.props.zIndex=r?r.val+1:0,i&&this.$parent.pendingChanges.add(n))}}bringToBack(e,t){for(let i of Id(e)){if(i.noAutoLayering&&!t)continue;let n=this.sorted[i.props.layer][0];if(n.item===i)return;i.props.zIndex=n?n.val-1:0}}getTileAbove(e){let t=this.sorted[e.props.layer],i=Oo(t,e,e.props.zIndex);for(let n=i+1;n

This colour is adjusted in dark mode.

Customise the Polypad features and UI, or use advanced tile properties and authoring tools. Learn more

\u2022 \u2022 Learn more

Polypad UI and features

Tile actions and properties

Display and audio options

`;function Sh(s=!0){let e=s?"":"hidden";return{mergeTiles:s,sidebar:e,toolbar:e,actionbar:e,settings:e,noCopyPaste:!s,noUndoRedo:!s,noPinchPan:!s,noDeleting:!s,noAudio:!s,noMusic:!s,noRotating:!s,noSnapping:!s,altColors:!1}}var uo=class extends E{bindPolypad(e){var u;this.bindModel(e.options);let t=this.$('input[type="color"]');t.change(d=>e.options.background=d),t.on("blur",()=>e.flushChanges());let i=this.$(".bg-warn"),n=()=>{let d=e.options.background||"#ffffff";t.value=d,t.next.css("background",d),i==null||i.toggle(b.theme.isDark&&e.flipTheme)};e.options.watch(n),b.onThemeChange(n),this.$("select").on("change",()=>{let d=e.options.canvas;e.options.canvasX=d==="infinite"?void 0:750,e.options.canvasY=d==="fixed"?750:void 0,e.resetViewport(),e.flushChanges()});for(let[d,g]of this.$$(".size").entries()){let y=d===1?"canvasY":"canvasX";g.onKey("Enter",()=>g.blur()),g.change(f=>{f&&(e.options[y]=(Math.round(+f)||15)*50,e.resetViewport())}),g.on("blur",()=>e.flushChanges()),e.options.watch(f=>g.value=`${(f[y]||0)/50}`)}for(let d of this.$$("input.toggle"))d.on("change",()=>e.selection.update());let o=this.$(".sidebar");e.options.watch(d=>o.checked=d.sidebar!=="hidden"),o.on("click",()=>e.options.sidebar=o.checked?"":"hidden");let a=this.$$(".setting");e.options.watch(({settings:d})=>{let g=(d==null?void 0:d.split(","))||[];for(let y of a)y.checked=!d||g.includes(y.data.key)});for(let d of a)d.on("change",()=>{e.options.settings=a.every(g=>g.checked)?void 0:a.filter(g=>g.checked).map(g=>g.data.key).join(",")||"other"});for(let d of this.$$(".advanced input, .authoring, .advanced select"))d.on("change",()=>setTimeout(()=>e.flushChanges()));Eh||(u=this.$(".handdrawn"))==null||u.parent.remove(),this.$(".authoring").bindVariable(e.state,"authorMode");let l=this.$$(".caption, .advanced");e.state.watch(d=>l.map((g,y)=>g.toggle(d.authorMode?!!y:!y)));let c=this.$$(".preset");for(let[d,g]of c.entries())g.on("click",()=>e.options.assign(Sh(!d)))}};uo=T([S("pp-customise",{template:Od})],uo);var Rd=12,Dd=s=>s.path.rotate(J(s.rot),s.is("group")?s.path.center:void 0),fo=class{constructor(e,t){this.tile=e;this.options=t;this.containedTiles=new Set;this.$path=m("path",{class:"dropzone",path:t.path,hidden:!0},e.$el)}canInsert(e){var n,r,o,a;let t=(r=(n=this.options.allowed)==null?void 0:n.has(e.props.name))!=null?r:!0,i=(a=(o=this.options.ignored)==null?void 0:o.has(e.props.name))!=null?a:!1;return t&&!i&&(!this.options.canAdd||this.options.canAdd(e))}hasReachedTileLimit(){return this.options.maxTiles?this.containedTiles.size>=this.options.maxTiles:!1}overlaps(e){if(!e.path)return!1;let t=Dd(e).translate(e.posn.subtract(this.tile.posn)).rotate(-J(this.tile.rot));return _i(this.options.path,t)}addTile(e){this.containedTiles.add(e),e.inDropZone=this}delete(){for(let e of this.containedTiles)e.inDropZone=void 0;this.containedTiles.clear(),this.$path.remove()}updateTarget(e,t){var n;this.options.path=e;let i=-((n=this.options.boxOffset)!=null?n:0);this.$path.draw(e.padding(i,i,i,i)),this.reflowLayout(t)}reflowLayout(e){if(!this.containedTiles.size||!this.options.layout||this.options.layout==="none")return;let t=this.getSortedTiles(),i=this.options.layout==="flow"?this.flowLayout(t):this.centerLayout(t),n=e?0:240;H.animate(i,n,()=>this.tile.$parent.selection.update())}getSortedTiles(){return Array.from(this.containedTiles).sort((e,t)=>Math.abs(e.posn.y-t.posn.y)<25?e.posn.x-t.posn.x:e.posn.y-t.posn.y)}flowLayout(e){var l;let t=Math.min(this.options.path.h,this.options.path.w),i=B(0,(t-50)/2,(l=this.options.padding)!=null?l:Rd),n=i,r=i,o=0,a=0,h=this.tile.posn.add(this.options.path.p);return e.map(c=>{let u=It(c.transformed);n+u.w+i>this.options.path.w+.001&&(r+=o+i,r>this.options.path.h-25+.001&&(a++,r=i+5*a),n=i+5*a,o=0);let d=h.add(c.posn).subtract(u.p).shift(n,r);return n+=u.w+i,o=Math.max(o,u.h),{tile:c,posn:d}})}centerLayout(e){var v;let t=e.map(w=>It(Dd(w))),i=Math.ceil(Math.sqrt(e.length)),n=Math.ceil(e.length/i),r=z(w=>oe(w*i,Math.min((w+1)*i,e.length)-1),n),o=z(w=>N(r[w].map($=>t[$].w)),n),a=Math.max(...o),h=z(w=>Math.max(...r[w].map($=>t[$].h)),n),l=N(h),c=(v=this.options.padding)!=null?v:Rd,u=o.map(w=>i>1?Math.min((this.options.path.w-w)/(i-1),c):0),d=n>1?Math.min((this.options.path.h-l)/(n-1),c):0,g=this.tile.posn.add(this.options.path.center).shift(-(a+(i-1)*Math.min(...u))/2,-(l+(n-1)*d)/2),y=0,f=0;return e.map((w,$)=>{let I=$%i,A=Math.floor($/i),M=g.shift(y,f).subtract(t[$].p);return(I+1)%i?y+=t[$].w+u[A]:(y=0,f+=h[A]+d),{tile:w,posn:M}})}};var Nd=s=>s.props.status!=="locked"&&s.props.status!=="hidden",mo=class{constructor(e){this.polypad=e;this.dropzones=new Map;this.lockedTiles=new Set;this.tilesMoved=!1}createDropzone(e,t){this.dropzones.has(e)||this.dropzones.set(e,new Set);let i=new fo(e,t);return this.dropzones.get(e).add(i),i}deleteDropzone(e){var t;e.delete(),(t=this.dropzones.get(e.tile))==null||t.delete(e)}clear(){for(let e of this.dropzones.values())for(let t of e)t.delete();this.dropzones.clear()}lockToZone(e,t){var i;(i=e.inDropZone)==null||i.containedTiles.delete(e),t.containedTiles.add(e),this.lockedTiles.add(e)}update(e){if(!this.dropzones.size)return;if(!e||Bt(e,n=>this.dropzones.has(n))){let n=Bh(e||[],r=>r.isDeleting);e=rn(this.polypad.tiles.values(),n)}let t=new Set,i=!1;t:for(let n of gp(e)){if(n.isDeleting&&(i=!0),n.isDeleting&&this.dropzones.has(n)){for(let r of this.dropzones.get(n))r.delete();this.dropzones.delete(n);continue}if(n.inDropZone){if(t.add(n.inDropZone.tile),!n.isDeleting&&this.lockedTiles.has(n))continue;n.inDropZone.containedTiles.delete(n),n.inDropZone=void 0}if(Nd(n)&&!(this.dropzones.has(n)||n.isDeleting)){for(let r of this.dropzones.values())for(let o of r)if(o.overlaps(n)){if(!o.canInsert(n)){o.options.ejectInvalid&&this.ejectFromZone(n,o);continue}if(o.hasReachedTileLimit()&&o.containedTiles.size){let a=O([...o.containedTiles]);this.ejectFromZone(a,o)}o.addTile(n),t.add(o.tile);continue t}}}for(let n of t){if(this.tilesMoved||i)for(let r of this.dropzones.get(n)||[])r.reflowLayout();n.isDeleting||n.onDropzonesChange()}this.polypad.trigger("dropzone-change",{tiles:t}),this.lockedTiles.clear(),this.tilesMoved=!1}ejectFromZone(e,t,i=20){let n=It(e.transformed),r=t.tile.posn.add(t.options.path.p),o=[{y:r.y-n.p.y-n.h-i},{x:r.x+t.options.path.w-n.p.x+i},{y:r.y+t.options.path.h-n.p.y+i},{x:r.x-n.p.x-n.w-i}];for(let[a,h]of o.entries()){let l=e.posn.shift(h.x||0,h.y||0);if(!(a<3&&this.polypad.getTileAt(l,["categorizer"])))return t.containedTiles.delete(e),e.inDropZone=void 0,H.animate([{tile:e,posn:l}],200,()=>e.$parent.selection.update())}}onMoveStart(e){if(!this.dropzones.size)return;let t=new Set;for(let i of e)for(let n of this.dropzones.get(i)||[])if(n.$path.show(),n.options.sticky)for(let r of n.containedTiles)t.add(r);this.polypad.selection.select(t)}onMove(e){if(!this.dropzones.size)return;let t=new Set;for(let[i,n]of this.dropzones.entries())if(!i.isActive)for(let r of n)r.$path.toggle(Bt(e,o=>{if(!Nd(o))return;let a=!t.has(o)&&(r.containedTiles.has(o)||r.canInsert(o))&&r.overlaps(o);return a&&t.add(o),a}))}onMoveEnd(){if(this.dropzones.size){this.tilesMoved=!0;for(let e of this.dropzones.values())for(let t of e)t.$path.hide()}}};var go=4,vo=s=>`${s.xMin} ${s.yMin} ${s.dx} ${s.dy}`,Gd=s=>!!s.name,Eh=b.isChrome&&!b.isMobile,wo=class extends E{constructor(){super(...arguments);this.tiles=new Map;this.strokes=new Map;this.options=le({});this.state=le({tool:"move",changeCount:0,penColor:"#242436",audioPlaying:0});this.mathContext=new ho;this.snapping=new lo(this);this.zIndex=new po(this);this.dropzoneManager=new mo(this);this.geoData=new jr;this.tools={move:new eo(this),pen:new ro(this),geo:new Zi(this),geoPending:new oo(this),eraser:new so(this),text:new io(this),pan:new no(this),cutPolygon:new ao(this)};this.origin=R;this.zoom=1;this.margins=[40,40,40,40];this.initial={};this.newTileShift=0;this.tileWeights=new Map;this.setup=!1;this.undoStack=[];this.redoStack=[];this.pendingChanges=new Set;this.pendingStrokes=new Set}ready(){this.$svg=this.$("svg.canvas"),this.$tiles=this.$svg.$$(".tiles"),this.$selection=this.$svg.$(".selection"),this.$strokes=this.$svg.$(".strokes"),this.$grid=this.$svg.$(".grid"),this.$html=this.$(".html-overlay"),this.$mask=this.$(".mask"),this.$geoShadows=this.$svg.$(".geo-shadows"),this.$geoPaths=this.$svg.$(".geo-paths"),this.$geoPoints=this.$svg.$(".geo-points"),this.$pendingPoint=m("circle",{class:"geo-point pending",hidden:!0},this.$geoPoints),this.setAttr("data-tool","move"),this.events=new ei(this.$svg,{down:i=>this.tools[this.state.tool].down(i),up:i=>this.tools[this.state.tool].up(i),start:i=>this.tools[this.state.tool].start(i),move:i=>this.tools[this.state.tool].move(i),end:i=>this.tools[this.state.tool].end(i),click:i=>this.tools[this.state.tool].click(i),hover:i=>this.tools[this.state.tool].hover(i),cursor:!1}),this.selection=new Kr(this),this.warningBanner=new vr(this),this.setViewport(R,1),this.options.watch(i=>{this.$grid.setAttr("fill",i.grid&&i.grid!=="none"?`url(#${i.grid})`:"none"),this.$grid.setRect(this.viewportBounds.rect)}),this.$svg.on("contextmenu",i=>{this.focussedTile||i.preventDefault()}),this.enablePinchPan(),this.enableAccessibility(),b.onThemeChange(()=>{this.setBackground(this.options.background);for(let i of this.tiles.values())i.props.updateTheme();for(let i of this.strokes.values())i.setColor(i.color);this.updateCursor()}),this.options.watch(i=>this.setBackground(i.background)),this.options.watch(i=>this.setClass("high-contrast",!!i.highContrast)),Eh&&this.options.watch(i=>this.setClass("handdrawn",!!i.handdrawn)),this.state.watch(()=>this.updateCursor());let t=this.$(".bg-icon");this.state.watch(i=>{t.toggle(i.authorMode),this.setClass("author-mode",!!i.authorMode),this.selection.clear()}),this.options.watch(()=>{let{canvas:i,canvasX:n=750,canvasY:r=750}=this.options,o=2e4;this.$mask.toggle(i!=="infinite"),i==="notebook"?this.$mask.setAttr("d",`M-1 -1h${n+2}V${o}H${o}V${-o}H${-o}V${o}H-1z`):i==="fixed"&&this.$mask.setAttr("d",`M-1 -1h${n+2}v${r+2}h${-n-2}zM${-o}${-o}V${o}H${o}V${-o}z`),this.canvasBounds=i==="infinite"?void 0:new lt(0,n,0,i==="notebook"?1e10:r)})}playSound(t){this.options.noAudio||Ad[t].play()}setBackground(t="#fff"){let i=$t.fromHex(t).hsl[2],n=t;this.flipTheme=i>=70,b.theme.isDark&&this.flipTheme&&(n=i>99?"#22212e":_e(t),i=100-i);let r=i<50?"#e2e1e6":"#181824";this.parent.css("--canvas-bg",n),this.parent.css("--canvas-fg",r),this.parent.css("--grid-opacity",.5-Math.abs(i/50-1)/4),this.parent.setClass("dark",i<50),this.$mask.css("fill",$t.mix("#000",n,.25).hex);let o=this.margins.some(a=>a>0);this.$mask.css("stroke",o?$t.mix(r,n,.4).hex:"transparent")}updateCursor(){let{tool:t,toolOptions:i,penColor:n}=this.state;if(t!=="pen"&&t!=="eraser")return this.css("cursor","");let r=t==="eraser"?10:i==="highlighter"?12:5,o=t==="eraser"?"#fff":_e(n||"#000",this.flipTheme);this.css("cursor",`url('data:image/svg+xml;utf8,') ${r+1} ${r+1}, auto`.replaceAll("#","%23"))}getTileAt(t,i){for(let n of this.tiles.values())if(!(i&&!i.includes(n.props.name))&&n.contains(t))return n}getInputAt(t,i){for(let n of this.tiles.values()){let r=n.getClosestPort(t,i);if(r)return r}}*getTilesOfType(t){for(let i of this.tiles.values())i.is(t)&&(yield i)}getBounds(t=0){let{canvas:i,canvasX:n,canvasY:r}=this.options;if(i==="infinite")return this.contentBounds.extend(t);let o=i==="notebook"?this.contentBounds.yMax+t:r;return new lt(0,n!=null?n:0,0,o!=null?o:0)}option(t){return this.state.authorMode?!1:!!this.options[t]}hasAction(t){let i=this.options.actionbar;return i?i.split(",").includes(t):!0}enablePinchPan(){this.on("wheel",n=>{if(!this.options.noPinchPan)if(n.preventDefault(),n.ctrlKey){let r=this.zoom*(1-n.deltaY/100);this.setViewport(this.origin,r,me(n,this.$svg))}else{let r=this.origin.shift(n.deltaX/this.zoom,n.deltaY/this.zoom);this.setViewport(r,this.zoom)}});let t=0,i=this.origin;this.on("gesturestart",n=>{this.options.noPinchPan||(n.preventDefault(),i=new p(n.pageX,n.pageY).subtract(this.origin),t=this.zoom,this.events.cancel())}),this.on("gesturechange",n=>{if(this.options.noPinchPan)return;n.preventDefault();let r=t*n.scale,o=new p(n.pageX,n.pageY).subtract(i);this.setViewport(o,r,me(n,this.$svg))}),this.on("gestureend",n=>{this.options.noPinchPan||n.preventDefault()})}enableImageDrop(t,i){let n=m("div",{class:"image-drop"},this);this.imageUploadCallback=t,this.on("dragenter dragover dragleave drop",o=>o.preventDefault()),this.on("dragenter dragover",()=>n.show()),this.on("dragleave drop",()=>n.hide());let r=(o,a)=>D(this,null,function*(){let l=Array.from((o==null?void 0:o.files)||[]).slice(0,10).map((c,u)=>this.newImage(c,a.shift(u*25),t));yield Promise.all(l),this.flushChanges(),this.trigger("paste")});this.on("drop",o=>r(o.dataTransfer,me(o,this.$svg))),i==null||i.on("change",()=>D(this,null,function*(){yield r(i._el,this.viewportBounds.center),i.value=""}))}bindKeyboardEvents(t=C,i){this.selection.bindKeyboardEvents(t),t.onKey("Backspace Clear Delete",()=>this.selection.delete()),t.onKey("z",n=>{n.preventDefault(),this[n.shiftKey?"redo":"undo"]()},{meta:!0}),t.onKey("y",n=>{n.preventDefault(),this.redo()},{meta:!0}),t.onKey("c C",()=>{if(this.option("noCopyPaste"))return;let n=this.selection.copy();this.paste(n,new p(25,25)),this.flushChanges()}),t.onKey("a",n=>{var o;if((o=k("x-modal"))!=null&&o.getOpenModal())return;n.preventDefault();let r=Array.from(this.tiles.values());this.state.authorMode||(r=r.filter(a=>a.canSelect)),this.selection.select(r)},{meta:!0}),C.on("cut copy",n=>{var o;if(i!=null&&i()||!this.selection.tiles.size||this.option("noCopyPaste")||b.formIsActive)return;let r=this.selection.copy();(o=window.navigator.clipboard)==null||o.writeText(JSON.stringify(r)),n.type==="cut"&&this.selection.delete()}),C.on("paste",n=>D(this,null,function*(){var a;if(i!=null&&i()||this.option("noCopyPaste")||b.formIsActive)return;let r=dp(n.clipboardData);if(r&&this.imageUploadCallback)return yield this.newImage(r,this.center.shift(-50),this.imageUploadCallback),this.flushChanges(),this.trigger("paste");let o=yield(a=window.navigator.clipboard)==null?void 0:a.readText();if(o){try{let h=JSON.parse(o);if(!Object.keys(h).length)return;this.paste(h)}catch(h){let l=H.create(this,{name:"text",html:o});l.setTransform(this.viewportBounds.center.subtract(l.center)),this.selection.add(l,!0),this.flushChanges(),this.trigger("paste"),this.selection.select([l])}this.flushChanges()}})),t.onKey("Space",n=>{this.options.noPinchPan||this.state.tool==="pan"||(n.preventDefault(),this.tools.pan.enable())}),t.onKey("Space",n=>{this.options.noPinchPan||this.state.tool!=="pan"||(n.preventDefault(),this.tools.pan.disable())},{up:!0})}enableAccessibility(){let t,i=!1,n=r=>{this.focussedTile||(t=r,this.$svg.setAttr("aria-description",r?r.altText:"Empty Canvas"),r&&this.selection.add(r,!0))};this.$svg.on("focusin",()=>{if(!i)return;let r=Array.from(this.tiles.values()).filter(o=>!o.props.status);n(this.events.shiftKey?O(r):r[0])}),this.$svg.on("focusout",()=>t=void 0),C.on("keydown",r=>{var a;if(i=!0,r.key==="Escape")return(a=this.focussedTile)==null?void 0:a.blur();if(r.key!=="Tab"||!t)return;let o=Array.from(this.tiles.values()).filter(h=>!h.group&&!h.props.status);n(o[o.indexOf(t)+(r.shiftKey?-1:1)]),t&&r.preventDefault()}),C.on("pointerdown",()=>i=!1),this.$svg.on("pointerdown",()=>{i=!1,this.focussedTile||this.$svg.focus()})}newImage(t,i,n){return D(this,null,function*(){let r=new FileReader;r.readAsDataURL(t),yield new Promise(a=>r.onloadend=a);let o=H.create(this,{name:"image",href:(r.result||"").toString(),x:i.x,y:i.y});return this.selection.add(o,!0),yield n==null?void 0:n(t,o),o})}setViewport(t,i=1,n){var v;if(i=B(i,1/go,go),n){let w=this.zoom/i;t=n.subtract(n.subtract(this.origin).scale(w))}let r=this.width/i,o=this.height/i,{canvas:a,canvasX:h=0,canvasY:l=0,grid:c}=this.options,[u,d,g,y]=this.margins;if(a==="infinite")this.origin=t.clamp(this.contentBounds.extend(o,0,0,r),50/i);else{let w=a==="notebook"?this.contentBounds.yMax+o-u/i:l,$=new lt(-y/i,h-r+d/i,-u/i,w-o+g/i,"center");this.origin=t.clamp($)}this.zoom=i,this.viewportBounds=new lt(this.origin.x,this.origin.x+r,this.origin.y,this.origin.y+o),this.$svg.setAttr("viewBox",this.attr("viewBox")||vo(this.viewportBounds)),this.$html.setTransform(this.origin.inverse.scale(this.zoom),0,this.zoom);let f=this.viewportBounds.rect;c!=="none"&&this.$grid.setRect(f),this.geoData.redrawLines(((v=this.canvasBounds)==null?void 0:v.rect)||f),this.newTileShift=0,this.trigger("viewport")}resetViewport(){if(this.options.canvas==="infinite"&&!this.tiles.size&&!this.strokes.size)return this.setViewport(R,1);this.panToBounds()}panToBounds(t,i=0){let{width:n,height:r,margins:o,origin:a,zoom:h,options:l}=this,[c,u,d,g]=o,y=!t&&l.canvas==="notebook",f=!t&&l.canvas==="infinite",v=t||this.getBounds(),w=(n-g-u)/v.dx,$=y?1:(r-c-d)/v.dy,I=B(Math.min(w,$),1/go,f?1:go),A=new p(n+g-u,r+c-d),M=y?new p(0,-c):v.center.subtract(A.scale(1/2/I)),P=new p(n/2,r/2);pt(j=>{let ne=yt("cubic",j),As=Math.exp(tt(Math.log(h),Math.log(I),ne)),en=p.interpolate(a,M,ne).add(P.scale(tt(1/h,1/I,ne)-1/As));this.setViewport(en,As)},i)}setZoom(t){let i=this.viewportBounds.center;this.setViewport(this.origin,this.zoom*t,i)}bindSource(t,i){let n=t.attr("tile");t.setAttr("tabindex",0),H.thumbnail(this,n,t);let r,o=i==null?void 0:i.$(".tiles");this.events.listen(t,{down:()=>this.trigger("add-tile-start"),start:({posn:a})=>{r=H.create(this,Object.assign({name:n},we(t.attr("props"),{}))),r.setTransform(a.subtract(r.center)),this.selection.add(r,!0),this.selection.moveStart(!0),i&&i.setAttr("viewBox",vo(this.viewportBounds)),(o||r.$container).append(r.$el),this.trigger("add-tile",{tile:r})},move:a=>this.selection.move(a,!0),end:a=>{r.$container.append(r.$el),this.selection.moveEnd(a,!0)},click:()=>{r=H.create(this,Object.assign({name:n},we(t.attr("props"),{}))),r.setTransform(this.center.subtract(r.center).shift(this.newTileShift*25)),this.selection.add(r,!0),r.moveEnd(),this.trigger("add-tile",{tile:r}),this.flushChanges(),this.newTileShift+=1}})}get center(){let[t,i,n,r]=this.margins;return this.viewportBounds.center.shift((r-i)/this.zoom/2,(t-n)/this.zoom/2)}setActiveTool(t,i){this.tools[this.state.tool].cancel(),this.warningBanner.hide(),this.selection.clear(),this.state.assign({tool:t,toolOptions:i}),i&&(this.tools[this.state.tool].options=i),this.setAttr("data-tool",t)}clear(t=!0){this.selection.clear();for(let i of this.tiles.values())i.delete();for(let i of this.strokes.values())i.delete();t&&this.setViewport(R,1),this.flushChanges()}thumbnail(t,i,n="jpg"){return D(this,null,function*(){return this.state.authorMode&&(this.state.authorMode=!1),yield this.$svg.image(n,t,i,vo(this.getBounds(50)))})}downloadImage(t="png",i){var o;this.selection.clear();let n=i||((o=this.state.title)==null?void 0:o.replace(/\s+/g,"-").replace(/[^\w-]/g,"").toLowerCase())||"polypad",r=this.getBounds(50);this.$svg.downloadImage(`${n}.${t}`,r.dx,r.dy,vo(r))}paste(t,i){this.selection.clear();let n=new Map;for(let h of Object.keys(t))n.set(h,We(10));let r=new Map,o=Object.entries(t).sort((h,l)=>(h[1].zIndex||0)-(l[1].zIndex||0)).map(([h,l])=>{var c,u,d;return l.name==="geo"&&Object.assign(l,Yt.copy(r,l,this.geoData)),l.name==="group"&&(l.children=(c=l.children)==null?void 0:c.split(",").map(g=>n.get(g)).join(",")),l.status=void 0,l.zIndex=void 0,l.cables=(u=l.cables)==null?void 0:u.map(g=>ft(ut({},g),{toTileId:n.get(g.toTileId)})),(l.name==="table"||l.name==="action-card")&&(l.links=(d=l.links)==null?void 0:d.split(",").map(g=>n.get(g)||g).join(",")),H.create(this,l,n.get(h))}).filter(Boolean);for(let h of o)h.delayedSetup();let a=It(...o.map(h=>h.transformed)).center;i===void 0&&(i=this.center.subtract(a).shift(this.newTileShift*25));for(let h of o)h.is("geo")?h.shift(i):h.setTransform(h.posn.add(i));this.newTileShift+=1,this.dropzoneManager.onMoveEnd(),this.flushChanges(),this.trigger("paste"),this.selection.select(o)}check(t){let i=!1;return new Promise(n=>{this.on("change",()=>{!i&&t(Array.from(this.tiles.values()))&&(i=!0,n())})})}flushChanges(){if(this.setup)return;this.trigger("change",{action:"change"});let t=new Map,i=this.options.getChanges();Object.keys(i[0]).length&&t.set("options",i),this.dropzoneManager.update(this.pendingChanges);for(let n of rn(this.pendingChanges,this.pendingStrokes)){let r=n.flushChanges();r&&t.set(n.id,r)}this.pendingChanges.clear(),this.pendingStrokes.clear(),t.size&&(this.contentBounds=wr(this.tiles,this.strokes),!this.options.noUndoRedo&&(this.undoStack.push(t),this.undoStack.length>50&&this.undoStack.shift(),this.redoStack=[],this.state.canUndo=!0,this.state.canRedo=!1,this.state.changeCount+=1))}undo(){this.undoStack.length&&(this.applyChange(O(this.undoStack),!0),this.redoStack.push(this.undoStack.pop()),this.state.canUndo=!!this.undoStack.length,this.state.canRedo=!0,this.state.changeCount-=1,this.selection.update(),this.trigger("change",{action:"undo"}))}redo(){this.redoStack.length&&(this.applyChange(O(this.redoStack)),this.undoStack.push(this.redoStack.pop()),this.state.canUndo=!0,this.state.canRedo=!!this.redoStack.length,this.state.changeCount+=1,this.selection.update(),this.trigger("change",{action:"redo"}))}applyChange(t,i=!1){var r,o;let n=new Set;for(let[a,[h,l]]of t.entries()){if(i&&([h,l]=[l,h]),a==="options")this.options.assign(l),("canvas"in l||"canvasX"in l||"canvasY"in l)&&this.resetViewport(),"tileWeights"in l&&Th(this,l.tileWeights||"");else if(h)if(l){let c=this.tiles.get(a);c==null||c.applyChange(l),c&&n.add(c)}else if(Gd(h)){let c=this.tiles.get(a);c==null||c.delete(),c&&n.add(c)}else(r=this.strokes.get(a))==null||r.delete();else if(Gd(l)){let c=H.create(this,l,a);c.flushChanges(),n.add(c)}else He.create(this,l,a);this.contentBounds=wr(this.tiles,this.strokes)}for(let a of t.keys())(o=this.tiles.get(a))==null||o.delayedSetup();this.dropzoneManager.update(n),this.pendingChanges.clear(),this.pendingStrokes.clear(),this.options.getChanges()}serialize(t=5e3,i=2e3,n=16e3){var r;return{title:(r=this.state.title)==null?void 0:r.slice(0,30),version:2,tiles:Qa(this.tiles.values(),o=>o.props.copy(),t),strokes:Qa(this.strokes.values(),o=>o.serialize(n),i),options:this.options.copy()}}load(t){this.setup=!0,this.clear(!1),this.geoData.reset(),this.zIndex.clear(),this.dropzoneManager.clear(),this.initial=t,this.state.assign({title:t.title,canUndo:!1,canRedo:!1,changeCount:0,audioPlaying:0,authorMode:!1}),this.undoStack=this.redoStack=[],t.options||(t.options=Sh(!0)),t.options.grid||(t.options.grid="none"),t.options.canvas||(t.options.canvas="infinite"),t.options.algebraXSize||(t.options.algebraXSize=Yp),t.options.algebraYSize||(t.options.algebraYSize=Zp),t.options.pinActions||(t.options.pinActions="custom"),this.options.assign(t.options,!0),this.options.forceUpdate(),Th(this,t.options.tileWeights||"");for(let[i,n]of Object.entries(t.tiles||{}))H.create(this,n,i).flushChanges();for(let[i,n]of Object.entries(t.strokes||{}))He.create(this,n,i);for(let i of this.tiles.values())i.delayedSetup();this.snapping.updateIntersections(),this.contentBounds=wr(this.tiles,this.strokes),this.dropzoneManager.update(),this.resetViewport(),this.setActiveTool("move"),this.pendingChanges.clear(),this.pendingStrokes.clear(),this.options.getChanges(),this.setup=!1}};wo=T([S("x-polypad",{template:Ed})],wo);var zd=`
\${numberFormat(points)}
Points
\${min(time)}m \${time % 60}s
Time

Highscore
\${highscore[0].name.slice(0, 4)}\${numberFormat(highscore[0].score)}
\${highscore[1].name.slice(0, 4)}\${numberFormat(highscore[1].score)}
\${highscore[2].name.slice(0, 4)}\${numberFormat(highscore[2].score)}
\${highscore[3].name.slice(0, 4)}\${numberFormat(highscore[3].score)}
View more\u2026
Next blocks:
\${next[0]}
\${next[1]}
\${next[2]}
\${next[3]}
\${next[4]}

Discharge:
\${discardCounter}needed
Game over!
Paused
Highscore
\${highscore[0].name}\${numberFormat(highscore[0].score)}
\${highscore[1].name}\${numberFormat(highscore[1].score)}
\${highscore[2].name}\${numberFormat(highscore[2].score)}
\${highscore[3].name}\${numberFormat(highscore[3].score)}
\${highscore[4].name}\${numberFormat(highscore[4].score)}
\${highscore[5].name}\${numberFormat(highscore[5].score)}
\${highscore[6].name}\${numberFormat(highscore[6].score)}
\${highscore[7].name}\${numberFormat(highscore[7].score)}
\${highscore[8].name}\${numberFormat(highscore[8].score)}
\${highscore[9].name}\${numberFormat(highscore[9].score)}
\${highscore[10].name}\${numberFormat(highscore[10].score)}
Block size:
\${active[0] || '?' } = \${active[2]|| '?'} \xD7 \${active[1]|| '?'}
`;var Y0=1e3,Z=B(+Nl(location.search).size||16,8,24),Z0=5,gi=Math.ceil(Z/2),bo=Z+gi,xo=[];for(let s=2;s<=Z*1.5;s+=1){let e=_o(s);e&&s>.75*Z||s>Z&&Zh(s)[0]>Z/2||(e&&s>Z/2||s>1.25*Z?xo.push(s):xo.push(s,s))}var Ji=()=>xo[_t.integer(xo.length)],Q0=oe(1,Z),J0=Z*10,Bd=z(s=>J0*2**s,Z),Mh=class{constructor(e,t,i){this.$el=m("rect",{width:20,height:20},i),this.setPosition(e,t)}setPosition(e,t){this.x=e,this.y=t,this.$el.setTransform({x:10+20*this.x,y:10+20*this.y})}go(e,t,i){this.setPosition(this.x+i-t,this.y+e)}canSet(e,t,i){return!i.find(n=>n.x===e&&n.y===t)}canGo(e,t,i,n){let r=this.x+i-t,o=this.y+e;return o>=bo||r<0||r>=Z?!1:this.canSet(r,o,n)}canGoDown(e){return this.canGo(1,0,0,e)}goDown(e=1){if(e!==0)return this.go(e,0,0)}},yo=class extends E{constructor(){super(...arguments);this.interval=void 0;this.tiles=[];this.activeTiles=[];this.activeSize=[0,0,0];this.activeFactors=[];this.isDown=!1;this.keyLock=!1;this.requestQueue=Promise.resolve("");this.highscore=!0}ready(){this.$svg=this.$(".factris-board"),this.$tiles=this.$svg.$(".tiles"),this.$shadow=this.$svg.$(".shadow"),this.attr("highscore")==="no"&&(this.highscore=!1);let t=this.$svg.$(".scores");this.$scores=Bd.map((i,n)=>{let r=m("g",{},t);return m("text",{text:"+"+i,class:`s${n+1}`},r),r}),this.bindModel(le({time:0,points:0,playing:!1,lost:!1,initial:!0,key:void 0,discardCounter:0,next:[],active:[],highscore:[],showHighscore:!1,min:i=>Math.floor(i/60),numberFormat:Ot,app:this}));for(let i of this.$$("button, .play"))i.on("contextmenu",n=>n.preventDefault());C.onKey("AllArrows",(i,n)=>{this.model.playing&&(i.preventDefault(),this.isDown=!0,this.model.key=n,this.keyPress(n))}),C.onKey("AllArrows",()=>{this.model.playing&&(this.isDown=this.keyLock=!1,this.model.key=void 0)},{up:!0}),this.setupSVG(),this.updateHighscore()}setupSVG(){this.$svg.setAttr("viewBox",`0 0 ${(Z+1)*20} ${(bo+1)*20}`);let t=this.$svg.$(".grid"),i=t.$(".faint-grid");for(let n=0;n<=Z;n+=1){let r=10+n*20,o=10+(gi+n)*20,a=!(n%4)||n===Z?t:i,h=!(n%2)||n===Z?"thick":"";m("line",{x1:10,y1:o,x2:10+Z*20,y2:o,class:h},a),m("line",{x1:r,y1:10+gi*20,x2:r,y2:bo*20+10,class:h},a)}}drawShadow(){this.activeTiles.length&&(this.$shadow.setAttr("x",10+20*this.activeSize[0]),this.$shadow.setAttr("y",10+20*this.activeSize[1]),this.$shadow.setAttr("width",20*this.activeSize[2]),this.$shadow.setAttr("height",20*(bo-this.activeSize[1])))}newRect(){let t=this.getNewTileSize();this.activeFactors=Q0.filter(r=>t%r===0);let i=this.activeFactors.pop(),n=Math.floor((Z-i)/2);this.activeTiles=z(r=>new Mh(n+r%i,Math.floor(r/i),this.$tiles),t),this.model.active=[t,i,t/i],this.activeSize=[n,t/i,i],this.drawShadow(),this.isDown&&(this.keyLock=!0)}reset(){this.pause(),this.model.time=0,this.model.points=0,this.model.discardCounter=0,this.model.showHighscore=!1,this.model.lost=!1,this.model.next=[Ji(),Ji(),Ji(),Ji()];for(let t of this.tiles)t.$el.remove();for(let t of this.activeTiles)t.$el.remove();this.tiles=[],this.newRect(),this.play(),this.requestQueue=Promise.resolve("")}toggle(){this.model.lost?this.reset():this.model.playing?this.pause():this.play()}pause(){this.model.playing=!1,clearInterval(this.interval)}play(){var t,i;if(this.model.showHighscore=!1,(t=window.ga)==null||t.call(window,"send","event","Factris","play"),(i=window.gtag)==null||i.call(window,"event","factris",{action:"play"}),this.model.initial||this.model.lost)return this.model.initial=!1,this.reset();this.model.playing=!0,this.interval=window.setInterval(()=>this.tick(),Y0)}getNewTileSize(){let t=Z*Z-this.tiles.length;if(this.model.next[0]>t)return t>Z?t-Z:Z;this.model.discardCounter>0&&(this.model.discardCounter-=1);let i=this.model.next[0];return this.model.next=[...this.model.next.slice(1),Ji()],i}tick(){if(this.model.time+=1,this.activeTiles.every(o=>o.canGoDown(this.tiles))){for(let o of this.activeTiles)o.goDown();this.activeSize[1]+=1,this.drawShadow();return}this.tiles.push(...this.activeTiles);for(let o of this.activeTiles)o.$el.addClass("fixed");if(this.tiles.some(o=>o.y=6&&Mi(10,150*i.length/Z),this.removeRows(i);let n=this.model.points,r=(n+Z)%13+(n-Z)%87;this.requestQueue=this.requestQueue.then(o=>Ne("/factris-verify",{token:o,size:Z,score:n,check:r})),this.trigger("score",{points:n})}getFullRows(){return z(t=>this.tiles.filter(i=>i.y===t+gi),Z).filter(t=>t.length===Z)}removeRows(t){let i=ye(t);this.tiles=this.tiles.filter(o=>!i.includes(o)),this.$tiles.addClass("animated"),b.redraw();for(let o of i)o.$el.addClass("removing");let n=t.map(o=>o[0].y);for(let o of this.tiles)o.goDown(n.filter(a=>a>o.y).length);let r=400/t.length;for(let[o,a]of n.reverse().entries())this.$scores[o].setTransform({x:10+gi*20,y:27+a*20}),Zt(()=>this.$scores[o].addClass("visible"),o*r);return setTimeout(()=>{for(let o of this.$scores)o.removeClass("visible")},600),setTimeout(()=>{for(let o of i)o.$el.remove();this.$tiles.removeClass("animated"),this.newRect()},1e3),!1}gameOver(){this.model.lost=!0;for(let t of this.activeTiles)t.$el.addClass("error");this.pause(),this.requestQueue.then(t=>{t&&this.trigger("game-over",{token:t,points:this.model.points})})}discharge(){if(this.model.playing){for(let t of this.activeTiles)t.$el.remove();this.newRect(),this.model.discardCounter=Z0}}keyPress(t,i=!0){if(this.model.playing&&!this.keyLock){if(t==="ArrowUp"){if(!this.activeFactors.length)return;let n=this.activeFactors.pop(),r=this.activeSize[0]+Math.floor((this.activeSize[2]-n)/2),o=this.activeSize[1];if(this.activeTiles.some((l,c)=>!l.canSet(r+c%n,o-1-Math.floor(c/n),this.tiles)))return;for(let[l,c]of this.activeTiles.entries())c.setPosition(r+l%n,o-1-Math.floor(l/n));let h=this.model.active[0];this.model.active=[h,n,h/n],this.activeSize=[r,o,n]}else{let n=t==="ArrowDown"?1:0,r=t==="ArrowLeft"?1:0,o=t==="ArrowRight"?1:0;if(this.activeTiles.every(a=>a.canGo(n,r,o,this.tiles))){for(let a of this.activeTiles)a.go(n,r,o);this.activeSize[0]+=o-r,this.activeSize[1]+=n}i&&t==="ArrowDown"&&setTimeout(()=>this.keyPress("ArrowDown",!1),100)}this.drawShadow()}}showHighscore(){this.highscore&&(this.pause(),this.model.showHighscore=!0)}updateHighscore(){return D(this,null,function*(){if(!this.highscore)return;let t=yield fetch(`/factris-highscore?size=${Z}`);this.model.highscore=yield t.json()})}};yo=T([S("x-factris",{template:zd})],yo);var $o=class extends E{ready(){let e=Array.from(this._el.children);this.removeChildren();let t=m("svg",{class:"equation"},this),i=m("g",{transform:"translate(2 0)"},t),n=m("div",{class:"overlay"},this),r=parseFloat(this.css("font-size")),o=this.parents(".text-center").length||this.hasClass("display"),a=new Be(i,n,0,"",r,!!o);a.setValue(this.attr("expr")||e),this.css({width:a.root.width+4+"px",height:a.root.height+"px","vertical-align":`-${a.root.height-a.root.baseline}px`})}};$o=T([S("x-math")],$o);window.$=k;window.$$=Te;window.Browser=b;var Po=k("x-modal#privacy");Po&&Po.$("form").on("submit",s=>{s.preventDefault();let e=Po.$('input[name="newsletter"]');Ne("/settings/privacy",{policies:"on",newsletter:e.checked?"on":"off"}),Po.close()});var _d="";function Ah(){return fetch("/joke").then(s=>s.text()).then(s=>_d=s),_d}var Ch=k(".error-box");Ch&&Ch.on("click",()=>Ch.html=Ah());Ah();window.tellMeAJoke=function(){return Ah().replace(/

/g,"").replace(/<\/p>/g,` `).trim()};console.log(`%cWelcome to Mathigon! %cYou can see our source code at https://github.com/mathigon %cIf you want to contribute, visit https://mathigon.io -%cJust here for fun? Run tellMeAJoke()`,"color: #cd0e66; font-weight: bold; font-size: 18px;","color: #0f82f2; font-weight: bold;","color: #22ab24; font-weight: bold;","color: #fd8c00; font-weight: bold;");var _d=[38,38,40,40,37,39,37,39,66,65],Ji=0;document.addEventListener("keydown",s=>{s.keyCode===_d[Ji]?(Ji+=1,Ji===_d.length&&(Ei(),Ji=0)):Ji=0});})(); \ No newline at end of file +%cJust here for fun? Run tellMeAJoke()`,"color: #cd0e66; font-weight: bold; font-size: 18px;","color: #0f82f2; font-weight: bold;","color: #22ab24; font-weight: bold;","color: #fd8c00; font-weight: bold;");var qd=[38,38,40,40,37,39,37,39,66,65],tn=0;document.addEventListener("keydown",s=>{s.keyCode===qd[tn]?(tn+=1,tn===qd.length&&(Mi(),tn=0)):tn=0});})(); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 3df5e970..c1250318 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,12 +9,12 @@ "version": "0.7.4", "license": "UNLICENSED", "dependencies": { - "@mathigon/boost": "1.2.18", - "@mathigon/core": "1.1.13", - "@mathigon/euclid": "1.1.15", - "@mathigon/fermat": "1.1.12", - "@mathigon/hilbert": "1.1.12", - "@mathigon/studio": "0.1.39", + "@mathigon/boost": "1.2.19", + "@mathigon/core": "1.1.14", + "@mathigon/euclid": "1.1.16", + "@mathigon/fermat": "1.1.13", + "@mathigon/hilbert": "1.1.13", + "@mathigon/studio": "0.1.40", "@types/d3": "6.3.0", "@types/three": "0.91.14", "@types/topojson": "3.2.3", @@ -1181,9 +1181,9 @@ } }, "node_modules/@esbuild/android-arm": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.4.tgz", - "integrity": "sha512-uBIbiYMeSsy2U0XQoOGVVcpIktjLMEKa7ryz2RLr7L/vTnANNEsPVAh4xOv7ondGz6ac1zVb0F8Jx20rQikffQ==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.8.tgz", + "integrity": "sha512-31E2lxlGM1KEfivQl8Yf5aYU/mflz9g06H6S15ITUFQueMFtFjESRMoDSkvMo8thYvLBax+VKTPlpnx+sPicOA==", "cpu": [ "arm" ], @@ -1196,9 +1196,9 @@ } }, "node_modules/@esbuild/android-arm64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.19.4.tgz", - "integrity": "sha512-mRsi2vJsk4Bx/AFsNBqOH2fqedxn5L/moT58xgg51DjX1la64Z3Npicut2VbhvDFO26qjWtPMsVxCd80YTFVeg==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.19.8.tgz", + "integrity": "sha512-B8JbS61bEunhfx8kasogFENgQfr/dIp+ggYXwTqdbMAgGDhRa3AaPpQMuQU0rNxDLECj6FhDzk1cF9WHMVwrtA==", "cpu": [ "arm64" ], @@ -1211,9 +1211,9 @@ } }, "node_modules/@esbuild/android-x64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.19.4.tgz", - "integrity": "sha512-4iPufZ1TMOD3oBlGFqHXBpa3KFT46aLl6Vy7gwed0ZSYgHaZ/mihbYb4t7Z9etjkC9Al3ZYIoOaHrU60gcMy7g==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.19.8.tgz", + "integrity": "sha512-rdqqYfRIn4jWOp+lzQttYMa2Xar3OK9Yt2fhOhzFXqg0rVWEfSclJvZq5fZslnz6ypHvVf3CT7qyf0A5pM682A==", "cpu": [ "x64" ], @@ -1226,9 +1226,9 @@ } }, "node_modules/@esbuild/darwin-arm64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.4.tgz", - "integrity": "sha512-Lviw8EzxsVQKpbS+rSt6/6zjn9ashUZ7Tbuvc2YENgRl0yZTktGlachZ9KMJUsVjZEGFVu336kl5lBgDN6PmpA==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.8.tgz", + "integrity": "sha512-RQw9DemMbIq35Bprbboyf8SmOr4UXsRVxJ97LgB55VKKeJOOdvsIPy0nFyF2l8U+h4PtBx/1kRf0BelOYCiQcw==", "cpu": [ "arm64" ], @@ -1241,9 +1241,9 @@ } }, "node_modules/@esbuild/darwin-x64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.19.4.tgz", - "integrity": "sha512-YHbSFlLgDwglFn0lAO3Zsdrife9jcQXQhgRp77YiTDja23FrC2uwnhXMNkAucthsf+Psr7sTwYEryxz6FPAVqw==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.19.8.tgz", + "integrity": "sha512-3sur80OT9YdeZwIVgERAysAbwncom7b4bCI2XKLjMfPymTud7e/oY4y+ci1XVp5TfQp/bppn7xLw1n/oSQY3/Q==", "cpu": [ "x64" ], @@ -1256,9 +1256,9 @@ } }, "node_modules/@esbuild/freebsd-arm64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.4.tgz", - "integrity": "sha512-vz59ijyrTG22Hshaj620e5yhs2dU1WJy723ofc+KUgxVCM6zxQESmWdMuVmUzxtGqtj5heHyB44PjV/HKsEmuQ==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.8.tgz", + "integrity": "sha512-WAnPJSDattvS/XtPCTj1tPoTxERjcTpH6HsMr6ujTT+X6rylVe8ggxk8pVxzf5U1wh5sPODpawNicF5ta/9Tmw==", "cpu": [ "arm64" ], @@ -1271,9 +1271,9 @@ } }, "node_modules/@esbuild/freebsd-x64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.19.4.tgz", - "integrity": "sha512-3sRbQ6W5kAiVQRBWREGJNd1YE7OgzS0AmOGjDmX/qZZecq8NFlQsQH0IfXjjmD0XtUYqr64e0EKNFjMUlPL3Cw==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.19.8.tgz", + "integrity": "sha512-ICvZyOplIjmmhjd6mxi+zxSdpPTKFfyPPQMQTK/w+8eNK6WV01AjIztJALDtwNNfFhfZLux0tZLC+U9nSyA5Zg==", "cpu": [ "x64" ], @@ -1286,9 +1286,9 @@ } }, "node_modules/@esbuild/linux-arm": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.19.4.tgz", - "integrity": "sha512-z/4ArqOo9EImzTi4b6Vq+pthLnepFzJ92BnofU1jgNlcVb+UqynVFdoXMCFreTK7FdhqAzH0vmdwW5373Hm9pg==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.19.8.tgz", + "integrity": "sha512-H4vmI5PYqSvosPaTJuEppU9oz1dq2A7Mr2vyg5TF9Ga+3+MGgBdGzcyBP7qK9MrwFQZlvNyJrvz6GuCaj3OukQ==", "cpu": [ "arm" ], @@ -1301,9 +1301,9 @@ } }, "node_modules/@esbuild/linux-arm64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.19.4.tgz", - "integrity": "sha512-ZWmWORaPbsPwmyu7eIEATFlaqm0QGt+joRE9sKcnVUG3oBbr/KYdNE2TnkzdQwX6EDRdg/x8Q4EZQTXoClUqqA==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.19.8.tgz", + "integrity": "sha512-z1zMZivxDLHWnyGOctT9JP70h0beY54xDDDJt4VpTX+iwA77IFsE1vCXWmprajJGa+ZYSqkSbRQ4eyLCpCmiCQ==", "cpu": [ "arm64" ], @@ -1316,9 +1316,9 @@ } }, "node_modules/@esbuild/linux-ia32": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.19.4.tgz", - "integrity": "sha512-EGc4vYM7i1GRUIMqRZNCTzJh25MHePYsnQfKDexD8uPTCm9mK56NIL04LUfX2aaJ+C9vyEp2fJ7jbqFEYgO9lQ==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.19.8.tgz", + "integrity": "sha512-1a8suQiFJmZz1khm/rDglOc8lavtzEMRo0v6WhPgxkrjcU0LkHj+TwBrALwoz/OtMExvsqbbMI0ChyelKabSvQ==", "cpu": [ "ia32" ], @@ -1331,9 +1331,9 @@ } }, "node_modules/@esbuild/linux-loong64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.19.4.tgz", - "integrity": "sha512-WVhIKO26kmm8lPmNrUikxSpXcgd6HDog0cx12BUfA2PkmURHSgx9G6vA19lrlQOMw+UjMZ+l3PpbtzffCxFDRg==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.19.8.tgz", + "integrity": "sha512-fHZWS2JJxnXt1uYJsDv9+b60WCc2RlvVAy1F76qOLtXRO+H4mjt3Tr6MJ5l7Q78X8KgCFudnTuiQRBhULUyBKQ==", "cpu": [ "loong64" ], @@ -1346,9 +1346,9 @@ } }, "node_modules/@esbuild/linux-mips64el": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.19.4.tgz", - "integrity": "sha512-keYY+Hlj5w86hNp5JJPuZNbvW4jql7c1eXdBUHIJGTeN/+0QFutU3GrS+c27L+NTmzi73yhtojHk+lr2+502Mw==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.19.8.tgz", + "integrity": "sha512-Wy/z0EL5qZYLX66dVnEg9riiwls5IYnziwuju2oUiuxVc+/edvqXa04qNtbrs0Ukatg5HEzqT94Zs7J207dN5Q==", "cpu": [ "mips64el" ], @@ -1361,9 +1361,9 @@ } }, "node_modules/@esbuild/linux-ppc64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.19.4.tgz", - "integrity": "sha512-tQ92n0WMXyEsCH4m32S21fND8VxNiVazUbU4IUGVXQpWiaAxOBvtOtbEt3cXIV3GEBydYsY8pyeRMJx9kn3rvw==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.19.8.tgz", + "integrity": "sha512-ETaW6245wK23YIEufhMQ3HSeHO7NgsLx8gygBVldRHKhOlD1oNeNy/P67mIh1zPn2Hr2HLieQrt6tWrVwuqrxg==", "cpu": [ "ppc64" ], @@ -1376,9 +1376,9 @@ } }, "node_modules/@esbuild/linux-riscv64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.19.4.tgz", - "integrity": "sha512-tRRBey6fG9tqGH6V75xH3lFPpj9E8BH+N+zjSUCnFOX93kEzqS0WdyJHkta/mmJHn7MBaa++9P4ARiU4ykjhig==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.19.8.tgz", + "integrity": "sha512-T2DRQk55SgoleTP+DtPlMrxi/5r9AeFgkhkZ/B0ap99zmxtxdOixOMI570VjdRCs9pE4Wdkz7JYrsPvsl7eESg==", "cpu": [ "riscv64" ], @@ -1391,9 +1391,9 @@ } }, "node_modules/@esbuild/linux-s390x": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.19.4.tgz", - "integrity": "sha512-152aLpQqKZYhThiJ+uAM4PcuLCAOxDsCekIbnGzPKVBRUDlgaaAfaUl5NYkB1hgY6WN4sPkejxKlANgVcGl9Qg==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.19.8.tgz", + "integrity": "sha512-NPxbdmmo3Bk7mbNeHmcCd7R7fptJaczPYBaELk6NcXxy7HLNyWwCyDJ/Xx+/YcNH7Im5dHdx9gZ5xIwyliQCbg==", "cpu": [ "s390x" ], @@ -1406,9 +1406,9 @@ } }, "node_modules/@esbuild/linux-x64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.19.4.tgz", - "integrity": "sha512-Mi4aNA3rz1BNFtB7aGadMD0MavmzuuXNTaYL6/uiYIs08U7YMPETpgNn5oue3ICr+inKwItOwSsJDYkrE9ekVg==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.19.8.tgz", + "integrity": "sha512-lytMAVOM3b1gPypL2TRmZ5rnXl7+6IIk8uB3eLsV1JwcizuolblXRrc5ShPrO9ls/b+RTp+E6gbsuLWHWi2zGg==", "cpu": [ "x64" ], @@ -1421,9 +1421,9 @@ } }, "node_modules/@esbuild/netbsd-x64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.19.4.tgz", - "integrity": "sha512-9+Wxx1i5N/CYo505CTT7T+ix4lVzEdz0uCoYGxM5JDVlP2YdDC1Bdz+Khv6IbqmisT0Si928eAxbmGkcbiuM/A==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.19.8.tgz", + "integrity": "sha512-hvWVo2VsXz/8NVt1UhLzxwAfo5sioj92uo0bCfLibB0xlOmimU/DeAEsQILlBQvkhrGjamP0/el5HU76HAitGw==", "cpu": [ "x64" ], @@ -1436,9 +1436,9 @@ } }, "node_modules/@esbuild/openbsd-x64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.19.4.tgz", - "integrity": "sha512-MFsHleM5/rWRW9EivFssop+OulYVUoVcqkyOkjiynKBCGBj9Lihl7kh9IzrreDyXa4sNkquei5/DTP4uCk25xw==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.19.8.tgz", + "integrity": "sha512-/7Y7u77rdvmGTxR83PgaSvSBJCC2L3Kb1M/+dmSIvRvQPXXCuC97QAwMugBNG0yGcbEGfFBH7ojPzAOxfGNkwQ==", "cpu": [ "x64" ], @@ -1451,9 +1451,9 @@ } }, "node_modules/@esbuild/sunos-x64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.19.4.tgz", - "integrity": "sha512-6Xq8SpK46yLvrGxjp6HftkDwPP49puU4OF0hEL4dTxqCbfx09LyrbUj/D7tmIRMj5D5FCUPksBbxyQhp8tmHzw==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.19.8.tgz", + "integrity": "sha512-9Lc4s7Oi98GqFA4HzA/W2JHIYfnXbUYgekUP/Sm4BG9sfLjyv6GKKHKKVs83SMicBF2JwAX6A1PuOLMqpD001w==", "cpu": [ "x64" ], @@ -1466,9 +1466,9 @@ } }, "node_modules/@esbuild/win32-arm64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.19.4.tgz", - "integrity": "sha512-PkIl7Jq4mP6ke7QKwyg4fD4Xvn8PXisagV/+HntWoDEdmerB2LTukRZg728Yd1Fj+LuEX75t/hKXE2Ppk8Hh1w==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.19.8.tgz", + "integrity": "sha512-rq6WzBGjSzihI9deW3fC2Gqiak68+b7qo5/3kmB6Gvbh/NYPA0sJhrnp7wgV4bNwjqM+R2AApXGxMO7ZoGhIJg==", "cpu": [ "arm64" ], @@ -1481,9 +1481,9 @@ } }, "node_modules/@esbuild/win32-ia32": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.19.4.tgz", - "integrity": "sha512-ga676Hnvw7/ycdKB53qPusvsKdwrWzEyJ+AtItHGoARszIqvjffTwaaW3b2L6l90i7MO9i+dlAW415INuRhSGg==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.19.8.tgz", + "integrity": "sha512-AIAbverbg5jMvJznYiGhrd3sumfwWs8572mIJL5NQjJa06P8KfCPWZQ0NwZbPQnbQi9OWSZhFVSUWjjIrn4hSw==", "cpu": [ "ia32" ], @@ -1496,9 +1496,9 @@ } }, "node_modules/@esbuild/win32-x64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.19.4.tgz", - "integrity": "sha512-HP0GDNla1T3ZL8Ko/SHAS2GgtjOg+VmWnnYLhuTksr++EnduYB0f3Y2LzHsUwb2iQ13JGoY6G3R8h6Du/WG6uA==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.19.8.tgz", + "integrity": "sha512-bfZ0cQ1uZs2PqpulNL5j/3w+GDhP36k1K5c38QdQg+Swy51jFZWWeIkteNsufkQxp986wnqRRsb/bHbY1WQ7TA==", "cpu": [ "x64" ], @@ -1834,83 +1834,83 @@ } }, "node_modules/@mathigon/boost": { - "version": "1.2.18", - "resolved": "https://registry.npmjs.org/@mathigon/boost/-/boost-1.2.18.tgz", - "integrity": "sha512-x3V5ucSszBjiJDdtKWW6ohNh/IdL8azb0qMJ6cEcA5DI1Wgc6F0ANlzyBkT+ixXbWxJrsbBmiEd2rBsQR8dNcw==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@mathigon/boost/-/boost-1.2.19.tgz", + "integrity": "sha512-IzlXgaTJT2CUoAjGndGqI8ULkuUIDc4Q6MBbn7aEmQTk+TjZPHyLdHjRfOhgxEKuLNkbPyHBSvrPaeZ7Eh0MXw==", "dependencies": { - "@mathigon/core": "1.1.13", - "@mathigon/euclid": "1.1.15", - "@mathigon/fermat": "1.1.12" + "@mathigon/core": "1.1.14", + "@mathigon/euclid": "1.1.16", + "@mathigon/fermat": "1.1.13" }, "engines": { "node": ">=16" } }, "node_modules/@mathigon/core": { - "version": "1.1.13", - "resolved": "https://registry.npmjs.org/@mathigon/core/-/core-1.1.13.tgz", - "integrity": "sha512-5flk0MbajXeIQx9yjEHgMcJP5PTewT7tQhnUf3pmogg4EqZnDfHCMxmI4g0EP2b4LXHbZQFFS4qarDI3E3pLSg==", + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/@mathigon/core/-/core-1.1.14.tgz", + "integrity": "sha512-x5y8TlR48xi9jMiceoWLEIdH9yCpJRs4MgabRdaDY6F+UY7rrNihyITsdoCsQYF/pQaIkYFtbTeTsnnRX9m3hQ==", "engines": { "node": ">=16" } }, "node_modules/@mathigon/euclid": { - "version": "1.1.15", - "resolved": "https://registry.npmjs.org/@mathigon/euclid/-/euclid-1.1.15.tgz", - "integrity": "sha512-wJomO8Y9Aj5vtkLqR4WoYP9tNHtG8+dYvumO6XZzVVUaTLk1WZ18zRl1V9HdcnLwa29pRWERACkwNtBN35I0vA==", + "version": "1.1.16", + "resolved": "https://registry.npmjs.org/@mathigon/euclid/-/euclid-1.1.16.tgz", + "integrity": "sha512-UqhLsR3n+RLhVmETtaScd5tP86BflhVHmnc132DHtDW5dX+03OTGoL5HlVaE9i+kS3iL5L5IXcALq0pOsF2y/A==", "dependencies": { - "@mathigon/core": "1.1.13", - "@mathigon/fermat": "1.1.12" + "@mathigon/core": "1.1.14", + "@mathigon/fermat": "1.1.13" }, "engines": { "node": ">=16" } }, "node_modules/@mathigon/fermat": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/@mathigon/fermat/-/fermat-1.1.12.tgz", - "integrity": "sha512-XmxqmQHQM5liOu5HzU/4jLeDEAckM9ZGvl2X0AZYq11DkAgR+F0G6FFgt5vU4z85SCCVpbq44pdnbBn60MSexA==", + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/@mathigon/fermat/-/fermat-1.1.13.tgz", + "integrity": "sha512-YjQBI+3cgrgD7OaRqOnqk3tffK4zIwHRj1f8oyuYU0rf07UbVa1h6ZFlimqI2FV1N7fDqMkOyx3osQUhPSBYEQ==", "dependencies": { - "@mathigon/core": "1.1.13" + "@mathigon/core": "1.1.14" }, "engines": { "node": ">=16" } }, "node_modules/@mathigon/hilbert": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/@mathigon/hilbert/-/hilbert-1.1.12.tgz", - "integrity": "sha512-21zTArkacdS6AYmtlf3pL2+hJLguwAdcDkwbADcnuqaKLu+oQ3hnWxPrH0IPJ2bOlLekrRPqKf1uQ/ujInFwHw==", + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/@mathigon/hilbert/-/hilbert-1.1.13.tgz", + "integrity": "sha512-iEpWUNmYC+MGeqxINwT+BB8pd2VdDmkTRGYzG5MnlfvkrH3w9eamJIvxCAgmF9BprZEazYPqenWcXSAVKCeekg==", "dependencies": { - "@mathigon/core": "1.1.13", - "@mathigon/fermat": "1.1.12" + "@mathigon/core": "1.1.14", + "@mathigon/fermat": "1.1.13" }, "engines": { "node": ">=16" } }, "node_modules/@mathigon/studio": { - "version": "0.1.39", - "resolved": "https://registry.npmjs.org/@mathigon/studio/-/studio-0.1.39.tgz", - "integrity": "sha512-vJ0Q8YPpgPYwolUnyRPrKU8zIAwsKBxjG2Smi9UrSjiHVVpNkafl2wLiWZUH/WaafGpN3DBar1E8Uf4Xgc0FLA==", - "dependencies": { - "@mathigon/boost": "1.2.18", - "@mathigon/core": "1.1.13", - "@mathigon/euclid": "1.1.15", - "@mathigon/fermat": "1.1.12", - "@mathigon/hilbert": "1.1.12", + "version": "0.1.40", + "resolved": "https://registry.npmjs.org/@mathigon/studio/-/studio-0.1.40.tgz", + "integrity": "sha512-xGJxJLr7XinS1cdY3HxGEpLwn8vET4vT4LtVV0Wmrs6rf4pMJwm2osmMlIrIEK3Jno2zDIk0niGHKHpJj3W1bQ==", + "dependencies": { + "@mathigon/boost": "1.2.19", + "@mathigon/core": "1.1.14", + "@mathigon/euclid": "1.1.16", + "@mathigon/fermat": "1.1.13", + "@mathigon/hilbert": "1.1.13", "@sendgrid/mail": "7.7.0", - "@types/bcryptjs": "2.4.4", - "@types/compression": "1.7.3", - "@types/cookie-parser": "1.4.4", - "@types/express": "4.17.18", - "@types/express-flash": "0.0.3", - "@types/express-session": "1.17.8", + "@types/bcryptjs": "2.4.6", + "@types/compression": "1.7.5", + "@types/cookie-parser": "1.4.6", + "@types/express": "4.17.21", + "@types/express-flash": "0.0.5", + "@types/express-session": "1.17.10", "@types/js-yaml": "4.0.5", - "@types/lusca": "1.7.2", + "@types/lusca": "1.7.4", "@types/node-fetch": "2.6.4", - "@types/pug": "2.0.7", - "@types/validator": "13.11.2", + "@types/pug": "2.0.10", + "@types/validator": "13.11.7", "@webcomponents/custom-elements": "1.6.0", "autoprefixer": "10.4.16", "autotrack": "2.4.1", @@ -1922,7 +1922,7 @@ "cookie-parser": "1.4.6", "cssnano": "6.0.1", "date-fns": "2.30.0", - "esbuild": "0.19.4", + "esbuild": "0.19.8", "express": "4.18.2", "express-flash": "0.0.2", "express-session": "1.17.3", @@ -1941,7 +1941,7 @@ "postcss-inline-svg": "6.0.0", "pug": "3.0.2", "rtlcss": "4.1.1", - "sass": "1.68.0", + "sass": "1.69.5", "tslib": "2.6.2", "typescript": "5.1.6", "validator": "13.11.0", @@ -2302,39 +2302,39 @@ "integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==" }, "node_modules/@types/bcryptjs": { - "version": "2.4.4", - "resolved": "https://registry.npmjs.org/@types/bcryptjs/-/bcryptjs-2.4.4.tgz", - "integrity": "sha512-9wlJI7k5gRyJEC4yrV7DubzNQFTPiykYxUA6lBtsk5NlOfW9oWLJ1HdIA4YtE+6C3i3mTpDQQEosJ2rVZfBWnw==" + "version": "2.4.6", + "resolved": "https://registry.npmjs.org/@types/bcryptjs/-/bcryptjs-2.4.6.tgz", + "integrity": "sha512-9xlo6R2qDs5uixm0bcIqCeMCE6HiQsIyel9KQySStiyqNl2tnj2mP3DX1Nf56MD6KMenNNlBBsy3LJ7gUEQPXQ==" }, "node_modules/@types/body-parser": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.0.tgz", - "integrity": "sha512-W98JrE0j2K78swW4ukqMleo8R7h/pFETjM2DQ90MF6XK2i4LO4W3gQ71Lt4w3bfm2EvVSyWHplECvB5sK22yFQ==", + "version": "1.19.5", + "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.5.tgz", + "integrity": "sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg==", "dependencies": { "@types/connect": "*", "@types/node": "*" } }, "node_modules/@types/compression": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/@types/compression/-/compression-1.7.3.tgz", - "integrity": "sha512-rKquEGjebqizyHNMOpaE/4FdYR5VQiWFeesqYfvJU0seSEyB4625UGhNOO/qIkH10S3wftiV7oefc8WdLZ/gCQ==", + "version": "1.7.5", + "resolved": "https://registry.npmjs.org/@types/compression/-/compression-1.7.5.tgz", + "integrity": "sha512-AAQvK5pxMpaT+nDvhHrsBhLSYG5yQdtkaJE1WYieSNY2mVFKAgmU4ks65rkZD5oqnGCFLyQpUr1CqI4DmUMyDg==", "dependencies": { "@types/express": "*" } }, "node_modules/@types/connect": { - "version": "3.4.34", - "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.34.tgz", - "integrity": "sha512-ePPA/JuI+X0vb+gSWlPKOY0NdNAie/rPUqX2GUPpbZwiKTkSPhjXWuee47E4MtE54QVzGCQMQkAL6JhV2E1+cQ==", + "version": "3.4.38", + "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz", + "integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==", "dependencies": { "@types/node": "*" } }, "node_modules/@types/cookie-parser": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/@types/cookie-parser/-/cookie-parser-1.4.4.tgz", - "integrity": "sha512-Var+aj5I6ZgIqsQ05N2V8q5OBrFfZXtIGWWDSrEYLIbMw758obagSwdGcLCjwh1Ga7M7+wj0SDIAaAC/WT7aaA==", + "version": "1.4.6", + "resolved": "https://registry.npmjs.org/@types/cookie-parser/-/cookie-parser-1.4.6.tgz", + "integrity": "sha512-KoooCrD56qlLskXPLGUiJxOMnv5l/8m7cQD2OxJ73NPMhuSz9PmvwRD6EpjDyKBVrdJDdQ4bQK7JFNHnNmax0w==", "dependencies": { "@types/express": "*" } @@ -2567,9 +2567,9 @@ } }, "node_modules/@types/express": { - "version": "4.17.18", - "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.18.tgz", - "integrity": "sha512-Sxv8BSLLgsBYmcnGdGjjEjqET2U+AKAdCRODmMiq02FgjwuV75Ut85DRpvFjyw/Mk0vgUOliGRU0UUmuuZHByQ==", + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.21.tgz", + "integrity": "sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ==", "dependencies": { "@types/body-parser": "*", "@types/express-serve-static-core": "^4.17.33", @@ -2578,27 +2578,28 @@ } }, "node_modules/@types/express-flash": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/@types/express-flash/-/express-flash-0.0.3.tgz", - "integrity": "sha512-a48dRK2dtstVAmNqiRfv2Wx/5r4JuD1uh1sRNuSc3LttCx0QUgp2UwYd1BFsAt769guIgXQhQk3hC4xCs8PMxw==", + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/@types/express-flash/-/express-flash-0.0.5.tgz", + "integrity": "sha512-lz8xxkEev6JHEyHeDNb45tUkhUnPERim9td+Ov7kBDCq6+dFHlu+BvTKYz7DcLh02a3ZK+tg2mze4tZ8DgJyLw==", "dependencies": { "@types/express": "*" } }, "node_modules/@types/express-serve-static-core": { - "version": "4.17.33", - "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.33.tgz", - "integrity": "sha512-TPBqmR/HRYI3eC2E5hmiivIzv+bidAfXofM+sbonAGvyDhySGw9/PQZFt2BLOrjUUR++4eJVpx6KnLQK1Fk9tA==", + "version": "4.17.41", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.41.tgz", + "integrity": "sha512-OaJ7XLaelTgrvlZD8/aa0vvvxZdUmlCn6MtWeB7TkiKW70BQLc9XEPpDLPdbo52ZhXUCrznlWdCHWxJWtdyajA==", "dependencies": { "@types/node": "*", "@types/qs": "*", - "@types/range-parser": "*" + "@types/range-parser": "*", + "@types/send": "*" } }, "node_modules/@types/express-session": { - "version": "1.17.8", - "resolved": "https://registry.npmjs.org/@types/express-session/-/express-session-1.17.8.tgz", - "integrity": "sha512-bFF7/3wOldMn+56XyFRGY9ZzCr3JWhNSP2ajMPgTlbZR6BQOCHdAbNA9W5dMBPgMywpIP4zkmhxP6Opm/NRYMQ==", + "version": "1.17.10", + "resolved": "https://registry.npmjs.org/@types/express-session/-/express-session-1.17.10.tgz", + "integrity": "sha512-U32bC/s0ejXijw5MAzyaV4tuZopCh/K7fPoUDyNbsRXHvPSeymygYD1RFL99YOLhF5PNOkzswvOTRaVHdL1zMw==", "dependencies": { "@types/express": "*" } @@ -2618,6 +2619,11 @@ "@types/node": "*" } }, + "node_modules/@types/http-errors": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.4.tgz", + "integrity": "sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA==" + }, "node_modules/@types/js-yaml": { "version": "4.0.5", "resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.5.tgz", @@ -2648,9 +2654,9 @@ "optional": true }, "node_modules/@types/lusca": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/@types/lusca/-/lusca-1.7.2.tgz", - "integrity": "sha512-bZbEVR7h2bJd1TBLl5JNypaCCiGD59EY56DTOkInYtCxk1ZYZeM+giIrdc0H/T+o7KRuz26ydbN5ws/zcNUflA==", + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/@types/lusca/-/lusca-1.7.4.tgz", + "integrity": "sha512-fdLI0mxG5RFy/OegqGc82v+/Bqbu9Qr1MemWv4JjhaBhtrSdVeM6LX9+J1WSMR8BJF7kb+MALDCuh4fsIOA6zg==", "dependencies": { "@types/express": "*" } @@ -2672,9 +2678,9 @@ "optional": true }, "node_modules/@types/mime": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz", - "integrity": "sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw==" + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz", + "integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==" }, "node_modules/@types/minimatch": { "version": "5.1.2", @@ -2697,19 +2703,19 @@ } }, "node_modules/@types/pug": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/@types/pug/-/pug-2.0.7.tgz", - "integrity": "sha512-I469DU0UXNC1aHepwirWhu9YKg5fkxohZD95Ey/5A7lovC+Siu+MCLffva87lnfThaOrw9Vb1DUN5t55oULAAw==" + "version": "2.0.10", + "resolved": "https://registry.npmjs.org/@types/pug/-/pug-2.0.10.tgz", + "integrity": "sha512-Sk/uYFOBAB7mb74XcpizmH0KOR2Pv3D2Hmrh1Dmy5BmK3MpdSa5kqZcg6EKBdklU0bFXX9gCfzvpnyUehrPIuA==" }, "node_modules/@types/qs": { - "version": "6.9.7", - "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz", - "integrity": "sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==" + "version": "6.9.10", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.10.tgz", + "integrity": "sha512-3Gnx08Ns1sEoCrWssEgTSJs/rsT2vhGP+Ja9cnnk9k4ALxinORlQneLXFeFKOTJMOeZUFD1s7w+w2AphTpvzZw==" }, "node_modules/@types/range-parser": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz", - "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==" + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.7.tgz", + "integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==" }, "node_modules/@types/rimraf": { "version": "3.0.2", @@ -2727,15 +2733,25 @@ "integrity": "sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A==", "dev": true }, - "node_modules/@types/serve-static": { - "version": "1.13.9", - "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.13.9.tgz", - "integrity": "sha512-ZFqF6qa48XsPdjXV5Gsz0Zqmux2PerNd3a/ktL45mHpa19cuMi/cL8tcxdAx497yRh+QtYPuofjT9oWw9P7nkA==", + "node_modules/@types/send": { + "version": "0.17.4", + "resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.4.tgz", + "integrity": "sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA==", "dependencies": { "@types/mime": "^1", "@types/node": "*" } }, + "node_modules/@types/serve-static": { + "version": "1.15.5", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.5.tgz", + "integrity": "sha512-PDRk21MnK70hja/YF8AHfC7yIsiQHn1rcXx7ijCFBX/k+XQJhQT/gw3xekXKJvx+5SXaMMS8oqQy09Mzvz2TuQ==", + "dependencies": { + "@types/http-errors": "*", + "@types/mime": "*", + "@types/node": "*" + } + }, "node_modules/@types/three": { "version": "0.91.14", "resolved": "https://registry.npmjs.org/@types/three/-/three-0.91.14.tgz", @@ -2792,9 +2808,9 @@ } }, "node_modules/@types/validator": { - "version": "13.11.2", - "resolved": "https://registry.npmjs.org/@types/validator/-/validator-13.11.2.tgz", - "integrity": "sha512-nIKVVQKT6kGKysnNt+xLobr+pFJNssJRi2s034wgWeFBUx01fI8BeHTW2TcRp7VcFu9QCYG8IlChTuovcm0oKQ==" + "version": "13.11.7", + "resolved": "https://registry.npmjs.org/@types/validator/-/validator-13.11.7.tgz", + "integrity": "sha512-q0JomTsJ2I5Mv7dhHhQLGjMvX0JJm5dyZ1DXQySIUzU1UlwzB8bt+R6+LODUbz0UDIOvEzGc28tk27gBJw2N8Q==" }, "node_modules/@types/webidl-conversions": { "version": "7.0.0", @@ -4946,9 +4962,9 @@ } }, "node_modules/esbuild": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.4.tgz", - "integrity": "sha512-x7jL0tbRRpv4QUyuDMjONtWFciygUxWaUM1kMX2zWxI0X2YWOt7MSA0g4UdeSiHM8fcYVzpQhKYOycZwxTdZkA==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.8.tgz", + "integrity": "sha512-l7iffQpT2OrZfH2rXIp7/FkmaeZM0vxbxN9KfiCwGYuZqzMg/JdvX26R31Zxn/Pxvsrg3Y9N6XTcnknqDyyv4w==", "hasInstallScript": true, "bin": { "esbuild": "bin/esbuild" @@ -4957,28 +4973,28 @@ "node": ">=12" }, "optionalDependencies": { - "@esbuild/android-arm": "0.19.4", - "@esbuild/android-arm64": "0.19.4", - "@esbuild/android-x64": "0.19.4", - "@esbuild/darwin-arm64": "0.19.4", - "@esbuild/darwin-x64": "0.19.4", - "@esbuild/freebsd-arm64": "0.19.4", - "@esbuild/freebsd-x64": "0.19.4", - "@esbuild/linux-arm": "0.19.4", - "@esbuild/linux-arm64": "0.19.4", - "@esbuild/linux-ia32": "0.19.4", - "@esbuild/linux-loong64": "0.19.4", - "@esbuild/linux-mips64el": "0.19.4", - "@esbuild/linux-ppc64": "0.19.4", - "@esbuild/linux-riscv64": "0.19.4", - "@esbuild/linux-s390x": "0.19.4", - "@esbuild/linux-x64": "0.19.4", - "@esbuild/netbsd-x64": "0.19.4", - "@esbuild/openbsd-x64": "0.19.4", - "@esbuild/sunos-x64": "0.19.4", - "@esbuild/win32-arm64": "0.19.4", - "@esbuild/win32-ia32": "0.19.4", - "@esbuild/win32-x64": "0.19.4" + "@esbuild/android-arm": "0.19.8", + "@esbuild/android-arm64": "0.19.8", + "@esbuild/android-x64": "0.19.8", + "@esbuild/darwin-arm64": "0.19.8", + "@esbuild/darwin-x64": "0.19.8", + "@esbuild/freebsd-arm64": "0.19.8", + "@esbuild/freebsd-x64": "0.19.8", + "@esbuild/linux-arm": "0.19.8", + "@esbuild/linux-arm64": "0.19.8", + "@esbuild/linux-ia32": "0.19.8", + "@esbuild/linux-loong64": "0.19.8", + "@esbuild/linux-mips64el": "0.19.8", + "@esbuild/linux-ppc64": "0.19.8", + "@esbuild/linux-riscv64": "0.19.8", + "@esbuild/linux-s390x": "0.19.8", + "@esbuild/linux-x64": "0.19.8", + "@esbuild/netbsd-x64": "0.19.8", + "@esbuild/openbsd-x64": "0.19.8", + "@esbuild/sunos-x64": "0.19.8", + "@esbuild/win32-arm64": "0.19.8", + "@esbuild/win32-ia32": "0.19.8", + "@esbuild/win32-x64": "0.19.8" } }, "node_modules/escalade": { @@ -9996,9 +10012,9 @@ } }, "node_modules/sass": { - "version": "1.68.0", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.68.0.tgz", - "integrity": "sha512-Lmj9lM/fef0nQswm1J2HJcEsBUba4wgNx2fea6yJHODREoMFnwRpZydBnX/RjyXw2REIwdkbqE4hrTo4qfDBUA==", + "version": "1.69.5", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.69.5.tgz", + "integrity": "sha512-qg2+UCJibLr2LCVOt3OlPhr/dqVHWOa9XtZf2OjbLs/T4VPSJ00udtgJxH3neXZm+QqX8B+3cU7RaLqp1iVfcQ==", "dependencies": { "chokidar": ">=3.0.0 <4.0.0", "immutable": "^4.0.0", @@ -12474,135 +12490,135 @@ } }, "@esbuild/android-arm": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.4.tgz", - "integrity": "sha512-uBIbiYMeSsy2U0XQoOGVVcpIktjLMEKa7ryz2RLr7L/vTnANNEsPVAh4xOv7ondGz6ac1zVb0F8Jx20rQikffQ==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.8.tgz", + "integrity": "sha512-31E2lxlGM1KEfivQl8Yf5aYU/mflz9g06H6S15ITUFQueMFtFjESRMoDSkvMo8thYvLBax+VKTPlpnx+sPicOA==", "optional": true }, "@esbuild/android-arm64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.19.4.tgz", - "integrity": "sha512-mRsi2vJsk4Bx/AFsNBqOH2fqedxn5L/moT58xgg51DjX1la64Z3Npicut2VbhvDFO26qjWtPMsVxCd80YTFVeg==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.19.8.tgz", + "integrity": "sha512-B8JbS61bEunhfx8kasogFENgQfr/dIp+ggYXwTqdbMAgGDhRa3AaPpQMuQU0rNxDLECj6FhDzk1cF9WHMVwrtA==", "optional": true }, "@esbuild/android-x64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.19.4.tgz", - "integrity": "sha512-4iPufZ1TMOD3oBlGFqHXBpa3KFT46aLl6Vy7gwed0ZSYgHaZ/mihbYb4t7Z9etjkC9Al3ZYIoOaHrU60gcMy7g==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.19.8.tgz", + "integrity": "sha512-rdqqYfRIn4jWOp+lzQttYMa2Xar3OK9Yt2fhOhzFXqg0rVWEfSclJvZq5fZslnz6ypHvVf3CT7qyf0A5pM682A==", "optional": true }, "@esbuild/darwin-arm64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.4.tgz", - "integrity": "sha512-Lviw8EzxsVQKpbS+rSt6/6zjn9ashUZ7Tbuvc2YENgRl0yZTktGlachZ9KMJUsVjZEGFVu336kl5lBgDN6PmpA==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.8.tgz", + "integrity": "sha512-RQw9DemMbIq35Bprbboyf8SmOr4UXsRVxJ97LgB55VKKeJOOdvsIPy0nFyF2l8U+h4PtBx/1kRf0BelOYCiQcw==", "optional": true }, "@esbuild/darwin-x64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.19.4.tgz", - "integrity": "sha512-YHbSFlLgDwglFn0lAO3Zsdrife9jcQXQhgRp77YiTDja23FrC2uwnhXMNkAucthsf+Psr7sTwYEryxz6FPAVqw==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.19.8.tgz", + "integrity": "sha512-3sur80OT9YdeZwIVgERAysAbwncom7b4bCI2XKLjMfPymTud7e/oY4y+ci1XVp5TfQp/bppn7xLw1n/oSQY3/Q==", "optional": true }, "@esbuild/freebsd-arm64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.4.tgz", - "integrity": "sha512-vz59ijyrTG22Hshaj620e5yhs2dU1WJy723ofc+KUgxVCM6zxQESmWdMuVmUzxtGqtj5heHyB44PjV/HKsEmuQ==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.8.tgz", + "integrity": "sha512-WAnPJSDattvS/XtPCTj1tPoTxERjcTpH6HsMr6ujTT+X6rylVe8ggxk8pVxzf5U1wh5sPODpawNicF5ta/9Tmw==", "optional": true }, "@esbuild/freebsd-x64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.19.4.tgz", - "integrity": "sha512-3sRbQ6W5kAiVQRBWREGJNd1YE7OgzS0AmOGjDmX/qZZecq8NFlQsQH0IfXjjmD0XtUYqr64e0EKNFjMUlPL3Cw==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.19.8.tgz", + "integrity": "sha512-ICvZyOplIjmmhjd6mxi+zxSdpPTKFfyPPQMQTK/w+8eNK6WV01AjIztJALDtwNNfFhfZLux0tZLC+U9nSyA5Zg==", "optional": true }, "@esbuild/linux-arm": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.19.4.tgz", - "integrity": "sha512-z/4ArqOo9EImzTi4b6Vq+pthLnepFzJ92BnofU1jgNlcVb+UqynVFdoXMCFreTK7FdhqAzH0vmdwW5373Hm9pg==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.19.8.tgz", + "integrity": "sha512-H4vmI5PYqSvosPaTJuEppU9oz1dq2A7Mr2vyg5TF9Ga+3+MGgBdGzcyBP7qK9MrwFQZlvNyJrvz6GuCaj3OukQ==", "optional": true }, "@esbuild/linux-arm64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.19.4.tgz", - "integrity": "sha512-ZWmWORaPbsPwmyu7eIEATFlaqm0QGt+joRE9sKcnVUG3oBbr/KYdNE2TnkzdQwX6EDRdg/x8Q4EZQTXoClUqqA==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.19.8.tgz", + "integrity": "sha512-z1zMZivxDLHWnyGOctT9JP70h0beY54xDDDJt4VpTX+iwA77IFsE1vCXWmprajJGa+ZYSqkSbRQ4eyLCpCmiCQ==", "optional": true }, "@esbuild/linux-ia32": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.19.4.tgz", - "integrity": "sha512-EGc4vYM7i1GRUIMqRZNCTzJh25MHePYsnQfKDexD8uPTCm9mK56NIL04LUfX2aaJ+C9vyEp2fJ7jbqFEYgO9lQ==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.19.8.tgz", + "integrity": "sha512-1a8suQiFJmZz1khm/rDglOc8lavtzEMRo0v6WhPgxkrjcU0LkHj+TwBrALwoz/OtMExvsqbbMI0ChyelKabSvQ==", "optional": true }, "@esbuild/linux-loong64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.19.4.tgz", - "integrity": "sha512-WVhIKO26kmm8lPmNrUikxSpXcgd6HDog0cx12BUfA2PkmURHSgx9G6vA19lrlQOMw+UjMZ+l3PpbtzffCxFDRg==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.19.8.tgz", + "integrity": "sha512-fHZWS2JJxnXt1uYJsDv9+b60WCc2RlvVAy1F76qOLtXRO+H4mjt3Tr6MJ5l7Q78X8KgCFudnTuiQRBhULUyBKQ==", "optional": true }, "@esbuild/linux-mips64el": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.19.4.tgz", - "integrity": "sha512-keYY+Hlj5w86hNp5JJPuZNbvW4jql7c1eXdBUHIJGTeN/+0QFutU3GrS+c27L+NTmzi73yhtojHk+lr2+502Mw==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.19.8.tgz", + "integrity": "sha512-Wy/z0EL5qZYLX66dVnEg9riiwls5IYnziwuju2oUiuxVc+/edvqXa04qNtbrs0Ukatg5HEzqT94Zs7J207dN5Q==", "optional": true }, "@esbuild/linux-ppc64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.19.4.tgz", - "integrity": "sha512-tQ92n0WMXyEsCH4m32S21fND8VxNiVazUbU4IUGVXQpWiaAxOBvtOtbEt3cXIV3GEBydYsY8pyeRMJx9kn3rvw==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.19.8.tgz", + "integrity": "sha512-ETaW6245wK23YIEufhMQ3HSeHO7NgsLx8gygBVldRHKhOlD1oNeNy/P67mIh1zPn2Hr2HLieQrt6tWrVwuqrxg==", "optional": true }, "@esbuild/linux-riscv64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.19.4.tgz", - "integrity": "sha512-tRRBey6fG9tqGH6V75xH3lFPpj9E8BH+N+zjSUCnFOX93kEzqS0WdyJHkta/mmJHn7MBaa++9P4ARiU4ykjhig==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.19.8.tgz", + "integrity": "sha512-T2DRQk55SgoleTP+DtPlMrxi/5r9AeFgkhkZ/B0ap99zmxtxdOixOMI570VjdRCs9pE4Wdkz7JYrsPvsl7eESg==", "optional": true }, "@esbuild/linux-s390x": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.19.4.tgz", - "integrity": "sha512-152aLpQqKZYhThiJ+uAM4PcuLCAOxDsCekIbnGzPKVBRUDlgaaAfaUl5NYkB1hgY6WN4sPkejxKlANgVcGl9Qg==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.19.8.tgz", + "integrity": "sha512-NPxbdmmo3Bk7mbNeHmcCd7R7fptJaczPYBaELk6NcXxy7HLNyWwCyDJ/Xx+/YcNH7Im5dHdx9gZ5xIwyliQCbg==", "optional": true }, "@esbuild/linux-x64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.19.4.tgz", - "integrity": "sha512-Mi4aNA3rz1BNFtB7aGadMD0MavmzuuXNTaYL6/uiYIs08U7YMPETpgNn5oue3ICr+inKwItOwSsJDYkrE9ekVg==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.19.8.tgz", + "integrity": "sha512-lytMAVOM3b1gPypL2TRmZ5rnXl7+6IIk8uB3eLsV1JwcizuolblXRrc5ShPrO9ls/b+RTp+E6gbsuLWHWi2zGg==", "optional": true }, "@esbuild/netbsd-x64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.19.4.tgz", - "integrity": "sha512-9+Wxx1i5N/CYo505CTT7T+ix4lVzEdz0uCoYGxM5JDVlP2YdDC1Bdz+Khv6IbqmisT0Si928eAxbmGkcbiuM/A==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.19.8.tgz", + "integrity": "sha512-hvWVo2VsXz/8NVt1UhLzxwAfo5sioj92uo0bCfLibB0xlOmimU/DeAEsQILlBQvkhrGjamP0/el5HU76HAitGw==", "optional": true }, "@esbuild/openbsd-x64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.19.4.tgz", - "integrity": "sha512-MFsHleM5/rWRW9EivFssop+OulYVUoVcqkyOkjiynKBCGBj9Lihl7kh9IzrreDyXa4sNkquei5/DTP4uCk25xw==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.19.8.tgz", + "integrity": "sha512-/7Y7u77rdvmGTxR83PgaSvSBJCC2L3Kb1M/+dmSIvRvQPXXCuC97QAwMugBNG0yGcbEGfFBH7ojPzAOxfGNkwQ==", "optional": true }, "@esbuild/sunos-x64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.19.4.tgz", - "integrity": "sha512-6Xq8SpK46yLvrGxjp6HftkDwPP49puU4OF0hEL4dTxqCbfx09LyrbUj/D7tmIRMj5D5FCUPksBbxyQhp8tmHzw==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.19.8.tgz", + "integrity": "sha512-9Lc4s7Oi98GqFA4HzA/W2JHIYfnXbUYgekUP/Sm4BG9sfLjyv6GKKHKKVs83SMicBF2JwAX6A1PuOLMqpD001w==", "optional": true }, "@esbuild/win32-arm64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.19.4.tgz", - "integrity": "sha512-PkIl7Jq4mP6ke7QKwyg4fD4Xvn8PXisagV/+HntWoDEdmerB2LTukRZg728Yd1Fj+LuEX75t/hKXE2Ppk8Hh1w==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.19.8.tgz", + "integrity": "sha512-rq6WzBGjSzihI9deW3fC2Gqiak68+b7qo5/3kmB6Gvbh/NYPA0sJhrnp7wgV4bNwjqM+R2AApXGxMO7ZoGhIJg==", "optional": true }, "@esbuild/win32-ia32": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.19.4.tgz", - "integrity": "sha512-ga676Hnvw7/ycdKB53qPusvsKdwrWzEyJ+AtItHGoARszIqvjffTwaaW3b2L6l90i7MO9i+dlAW415INuRhSGg==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.19.8.tgz", + "integrity": "sha512-AIAbverbg5jMvJznYiGhrd3sumfwWs8572mIJL5NQjJa06P8KfCPWZQ0NwZbPQnbQi9OWSZhFVSUWjjIrn4hSw==", "optional": true }, "@esbuild/win32-x64": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.19.4.tgz", - "integrity": "sha512-HP0GDNla1T3ZL8Ko/SHAS2GgtjOg+VmWnnYLhuTksr++EnduYB0f3Y2LzHsUwb2iQ13JGoY6G3R8h6Du/WG6uA==", + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.19.8.tgz", + "integrity": "sha512-bfZ0cQ1uZs2PqpulNL5j/3w+GDhP36k1K5c38QdQg+Swy51jFZWWeIkteNsufkQxp986wnqRRsb/bHbY1WQ7TA==", "optional": true }, "@eslint-community/eslint-utils": { @@ -12837,71 +12853,71 @@ } }, "@mathigon/boost": { - "version": "1.2.18", - "resolved": "https://registry.npmjs.org/@mathigon/boost/-/boost-1.2.18.tgz", - "integrity": "sha512-x3V5ucSszBjiJDdtKWW6ohNh/IdL8azb0qMJ6cEcA5DI1Wgc6F0ANlzyBkT+ixXbWxJrsbBmiEd2rBsQR8dNcw==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@mathigon/boost/-/boost-1.2.19.tgz", + "integrity": "sha512-IzlXgaTJT2CUoAjGndGqI8ULkuUIDc4Q6MBbn7aEmQTk+TjZPHyLdHjRfOhgxEKuLNkbPyHBSvrPaeZ7Eh0MXw==", "requires": { - "@mathigon/core": "1.1.13", - "@mathigon/euclid": "1.1.15", - "@mathigon/fermat": "1.1.12" + "@mathigon/core": "1.1.14", + "@mathigon/euclid": "1.1.16", + "@mathigon/fermat": "1.1.13" } }, "@mathigon/core": { - "version": "1.1.13", - "resolved": "https://registry.npmjs.org/@mathigon/core/-/core-1.1.13.tgz", - "integrity": "sha512-5flk0MbajXeIQx9yjEHgMcJP5PTewT7tQhnUf3pmogg4EqZnDfHCMxmI4g0EP2b4LXHbZQFFS4qarDI3E3pLSg==" + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/@mathigon/core/-/core-1.1.14.tgz", + "integrity": "sha512-x5y8TlR48xi9jMiceoWLEIdH9yCpJRs4MgabRdaDY6F+UY7rrNihyITsdoCsQYF/pQaIkYFtbTeTsnnRX9m3hQ==" }, "@mathigon/euclid": { - "version": "1.1.15", - "resolved": "https://registry.npmjs.org/@mathigon/euclid/-/euclid-1.1.15.tgz", - "integrity": "sha512-wJomO8Y9Aj5vtkLqR4WoYP9tNHtG8+dYvumO6XZzVVUaTLk1WZ18zRl1V9HdcnLwa29pRWERACkwNtBN35I0vA==", + "version": "1.1.16", + "resolved": "https://registry.npmjs.org/@mathigon/euclid/-/euclid-1.1.16.tgz", + "integrity": "sha512-UqhLsR3n+RLhVmETtaScd5tP86BflhVHmnc132DHtDW5dX+03OTGoL5HlVaE9i+kS3iL5L5IXcALq0pOsF2y/A==", "requires": { - "@mathigon/core": "1.1.13", - "@mathigon/fermat": "1.1.12" + "@mathigon/core": "1.1.14", + "@mathigon/fermat": "1.1.13" } }, "@mathigon/fermat": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/@mathigon/fermat/-/fermat-1.1.12.tgz", - "integrity": "sha512-XmxqmQHQM5liOu5HzU/4jLeDEAckM9ZGvl2X0AZYq11DkAgR+F0G6FFgt5vU4z85SCCVpbq44pdnbBn60MSexA==", + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/@mathigon/fermat/-/fermat-1.1.13.tgz", + "integrity": "sha512-YjQBI+3cgrgD7OaRqOnqk3tffK4zIwHRj1f8oyuYU0rf07UbVa1h6ZFlimqI2FV1N7fDqMkOyx3osQUhPSBYEQ==", "requires": { - "@mathigon/core": "1.1.13" + "@mathigon/core": "1.1.14" } }, "@mathigon/hilbert": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/@mathigon/hilbert/-/hilbert-1.1.12.tgz", - "integrity": "sha512-21zTArkacdS6AYmtlf3pL2+hJLguwAdcDkwbADcnuqaKLu+oQ3hnWxPrH0IPJ2bOlLekrRPqKf1uQ/ujInFwHw==", + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/@mathigon/hilbert/-/hilbert-1.1.13.tgz", + "integrity": "sha512-iEpWUNmYC+MGeqxINwT+BB8pd2VdDmkTRGYzG5MnlfvkrH3w9eamJIvxCAgmF9BprZEazYPqenWcXSAVKCeekg==", "requires": { - "@mathigon/core": "1.1.13", - "@mathigon/fermat": "1.1.12" + "@mathigon/core": "1.1.14", + "@mathigon/fermat": "1.1.13" } }, "@mathigon/studio": { - "version": "0.1.39", - "resolved": "https://registry.npmjs.org/@mathigon/studio/-/studio-0.1.39.tgz", - "integrity": "sha512-vJ0Q8YPpgPYwolUnyRPrKU8zIAwsKBxjG2Smi9UrSjiHVVpNkafl2wLiWZUH/WaafGpN3DBar1E8Uf4Xgc0FLA==", + "version": "0.1.40", + "resolved": "https://registry.npmjs.org/@mathigon/studio/-/studio-0.1.40.tgz", + "integrity": "sha512-xGJxJLr7XinS1cdY3HxGEpLwn8vET4vT4LtVV0Wmrs6rf4pMJwm2osmMlIrIEK3Jno2zDIk0niGHKHpJj3W1bQ==", "requires": { "@google-cloud/secret-manager": "4.2.2", "@google-cloud/text-to-speech": "4.2.3", "@google-cloud/translate": "7.2.2", - "@mathigon/boost": "1.2.18", - "@mathigon/core": "1.1.13", - "@mathigon/euclid": "1.1.15", - "@mathigon/fermat": "1.1.12", - "@mathigon/hilbert": "1.1.12", + "@mathigon/boost": "1.2.19", + "@mathigon/core": "1.1.14", + "@mathigon/euclid": "1.1.16", + "@mathigon/fermat": "1.1.13", + "@mathigon/hilbert": "1.1.13", "@sendgrid/mail": "7.7.0", - "@types/bcryptjs": "2.4.4", - "@types/compression": "1.7.3", - "@types/cookie-parser": "1.4.4", - "@types/express": "4.17.18", - "@types/express-flash": "0.0.3", - "@types/express-session": "1.17.8", + "@types/bcryptjs": "2.4.6", + "@types/compression": "1.7.5", + "@types/cookie-parser": "1.4.6", + "@types/express": "4.17.21", + "@types/express-flash": "0.0.5", + "@types/express-session": "1.17.10", "@types/js-yaml": "4.0.5", - "@types/lusca": "1.7.2", + "@types/lusca": "1.7.4", "@types/node-fetch": "2.6.4", - "@types/pug": "2.0.7", - "@types/validator": "13.11.2", + "@types/pug": "2.0.10", + "@types/validator": "13.11.7", "@webcomponents/custom-elements": "1.6.0", "autoprefixer": "10.4.16", "autotrack": "2.4.1", @@ -12913,7 +12929,7 @@ "cookie-parser": "1.4.6", "cssnano": "6.0.1", "date-fns": "2.30.0", - "esbuild": "0.19.4", + "esbuild": "0.19.8", "express": "4.18.2", "express-flash": "0.0.2", "express-session": "1.17.3", @@ -12935,7 +12951,7 @@ "pug": "3.0.2", "puppeteer": "20.9.0", "rtlcss": "4.1.1", - "sass": "1.68.0", + "sass": "1.69.5", "tslib": "2.6.2", "typescript": "5.1.6", "validator": "13.11.0", @@ -13217,39 +13233,39 @@ "integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==" }, "@types/bcryptjs": { - "version": "2.4.4", - "resolved": "https://registry.npmjs.org/@types/bcryptjs/-/bcryptjs-2.4.4.tgz", - "integrity": "sha512-9wlJI7k5gRyJEC4yrV7DubzNQFTPiykYxUA6lBtsk5NlOfW9oWLJ1HdIA4YtE+6C3i3mTpDQQEosJ2rVZfBWnw==" + "version": "2.4.6", + "resolved": "https://registry.npmjs.org/@types/bcryptjs/-/bcryptjs-2.4.6.tgz", + "integrity": "sha512-9xlo6R2qDs5uixm0bcIqCeMCE6HiQsIyel9KQySStiyqNl2tnj2mP3DX1Nf56MD6KMenNNlBBsy3LJ7gUEQPXQ==" }, "@types/body-parser": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.0.tgz", - "integrity": "sha512-W98JrE0j2K78swW4ukqMleo8R7h/pFETjM2DQ90MF6XK2i4LO4W3gQ71Lt4w3bfm2EvVSyWHplECvB5sK22yFQ==", + "version": "1.19.5", + "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.5.tgz", + "integrity": "sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg==", "requires": { "@types/connect": "*", "@types/node": "*" } }, "@types/compression": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/@types/compression/-/compression-1.7.3.tgz", - "integrity": "sha512-rKquEGjebqizyHNMOpaE/4FdYR5VQiWFeesqYfvJU0seSEyB4625UGhNOO/qIkH10S3wftiV7oefc8WdLZ/gCQ==", + "version": "1.7.5", + "resolved": "https://registry.npmjs.org/@types/compression/-/compression-1.7.5.tgz", + "integrity": "sha512-AAQvK5pxMpaT+nDvhHrsBhLSYG5yQdtkaJE1WYieSNY2mVFKAgmU4ks65rkZD5oqnGCFLyQpUr1CqI4DmUMyDg==", "requires": { "@types/express": "*" } }, "@types/connect": { - "version": "3.4.34", - "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.34.tgz", - "integrity": "sha512-ePPA/JuI+X0vb+gSWlPKOY0NdNAie/rPUqX2GUPpbZwiKTkSPhjXWuee47E4MtE54QVzGCQMQkAL6JhV2E1+cQ==", + "version": "3.4.38", + "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz", + "integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==", "requires": { "@types/node": "*" } }, "@types/cookie-parser": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/@types/cookie-parser/-/cookie-parser-1.4.4.tgz", - "integrity": "sha512-Var+aj5I6ZgIqsQ05N2V8q5OBrFfZXtIGWWDSrEYLIbMw758obagSwdGcLCjwh1Ga7M7+wj0SDIAaAC/WT7aaA==", + "version": "1.4.6", + "resolved": "https://registry.npmjs.org/@types/cookie-parser/-/cookie-parser-1.4.6.tgz", + "integrity": "sha512-KoooCrD56qlLskXPLGUiJxOMnv5l/8m7cQD2OxJ73NPMhuSz9PmvwRD6EpjDyKBVrdJDdQ4bQK7JFNHnNmax0w==", "requires": { "@types/express": "*" } @@ -13484,9 +13500,9 @@ } }, "@types/express": { - "version": "4.17.18", - "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.18.tgz", - "integrity": "sha512-Sxv8BSLLgsBYmcnGdGjjEjqET2U+AKAdCRODmMiq02FgjwuV75Ut85DRpvFjyw/Mk0vgUOliGRU0UUmuuZHByQ==", + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.21.tgz", + "integrity": "sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ==", "requires": { "@types/body-parser": "*", "@types/express-serve-static-core": "^4.17.33", @@ -13495,27 +13511,28 @@ } }, "@types/express-flash": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/@types/express-flash/-/express-flash-0.0.3.tgz", - "integrity": "sha512-a48dRK2dtstVAmNqiRfv2Wx/5r4JuD1uh1sRNuSc3LttCx0QUgp2UwYd1BFsAt769guIgXQhQk3hC4xCs8PMxw==", + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/@types/express-flash/-/express-flash-0.0.5.tgz", + "integrity": "sha512-lz8xxkEev6JHEyHeDNb45tUkhUnPERim9td+Ov7kBDCq6+dFHlu+BvTKYz7DcLh02a3ZK+tg2mze4tZ8DgJyLw==", "requires": { "@types/express": "*" } }, "@types/express-serve-static-core": { - "version": "4.17.33", - "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.33.tgz", - "integrity": "sha512-TPBqmR/HRYI3eC2E5hmiivIzv+bidAfXofM+sbonAGvyDhySGw9/PQZFt2BLOrjUUR++4eJVpx6KnLQK1Fk9tA==", + "version": "4.17.41", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.41.tgz", + "integrity": "sha512-OaJ7XLaelTgrvlZD8/aa0vvvxZdUmlCn6MtWeB7TkiKW70BQLc9XEPpDLPdbo52ZhXUCrznlWdCHWxJWtdyajA==", "requires": { "@types/node": "*", "@types/qs": "*", - "@types/range-parser": "*" + "@types/range-parser": "*", + "@types/send": "*" } }, "@types/express-session": { - "version": "1.17.8", - "resolved": "https://registry.npmjs.org/@types/express-session/-/express-session-1.17.8.tgz", - "integrity": "sha512-bFF7/3wOldMn+56XyFRGY9ZzCr3JWhNSP2ajMPgTlbZR6BQOCHdAbNA9W5dMBPgMywpIP4zkmhxP6Opm/NRYMQ==", + "version": "1.17.10", + "resolved": "https://registry.npmjs.org/@types/express-session/-/express-session-1.17.10.tgz", + "integrity": "sha512-U32bC/s0ejXijw5MAzyaV4tuZopCh/K7fPoUDyNbsRXHvPSeymygYD1RFL99YOLhF5PNOkzswvOTRaVHdL1zMw==", "requires": { "@types/express": "*" } @@ -13535,6 +13552,11 @@ "@types/node": "*" } }, + "@types/http-errors": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.4.tgz", + "integrity": "sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA==" + }, "@types/js-yaml": { "version": "4.0.5", "resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.5.tgz", @@ -13565,9 +13587,9 @@ "optional": true }, "@types/lusca": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/@types/lusca/-/lusca-1.7.2.tgz", - "integrity": "sha512-bZbEVR7h2bJd1TBLl5JNypaCCiGD59EY56DTOkInYtCxk1ZYZeM+giIrdc0H/T+o7KRuz26ydbN5ws/zcNUflA==", + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/@types/lusca/-/lusca-1.7.4.tgz", + "integrity": "sha512-fdLI0mxG5RFy/OegqGc82v+/Bqbu9Qr1MemWv4JjhaBhtrSdVeM6LX9+J1WSMR8BJF7kb+MALDCuh4fsIOA6zg==", "requires": { "@types/express": "*" } @@ -13589,9 +13611,9 @@ "optional": true }, "@types/mime": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz", - "integrity": "sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw==" + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz", + "integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==" }, "@types/minimatch": { "version": "5.1.2", @@ -13614,19 +13636,19 @@ } }, "@types/pug": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/@types/pug/-/pug-2.0.7.tgz", - "integrity": "sha512-I469DU0UXNC1aHepwirWhu9YKg5fkxohZD95Ey/5A7lovC+Siu+MCLffva87lnfThaOrw9Vb1DUN5t55oULAAw==" + "version": "2.0.10", + "resolved": "https://registry.npmjs.org/@types/pug/-/pug-2.0.10.tgz", + "integrity": "sha512-Sk/uYFOBAB7mb74XcpizmH0KOR2Pv3D2Hmrh1Dmy5BmK3MpdSa5kqZcg6EKBdklU0bFXX9gCfzvpnyUehrPIuA==" }, "@types/qs": { - "version": "6.9.7", - "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz", - "integrity": "sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==" + "version": "6.9.10", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.10.tgz", + "integrity": "sha512-3Gnx08Ns1sEoCrWssEgTSJs/rsT2vhGP+Ja9cnnk9k4ALxinORlQneLXFeFKOTJMOeZUFD1s7w+w2AphTpvzZw==" }, "@types/range-parser": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz", - "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==" + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.7.tgz", + "integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==" }, "@types/rimraf": { "version": "3.0.2", @@ -13644,15 +13666,25 @@ "integrity": "sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A==", "dev": true }, - "@types/serve-static": { - "version": "1.13.9", - "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.13.9.tgz", - "integrity": "sha512-ZFqF6qa48XsPdjXV5Gsz0Zqmux2PerNd3a/ktL45mHpa19cuMi/cL8tcxdAx497yRh+QtYPuofjT9oWw9P7nkA==", + "@types/send": { + "version": "0.17.4", + "resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.4.tgz", + "integrity": "sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA==", "requires": { "@types/mime": "^1", "@types/node": "*" } }, + "@types/serve-static": { + "version": "1.15.5", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.5.tgz", + "integrity": "sha512-PDRk21MnK70hja/YF8AHfC7yIsiQHn1rcXx7ijCFBX/k+XQJhQT/gw3xekXKJvx+5SXaMMS8oqQy09Mzvz2TuQ==", + "requires": { + "@types/http-errors": "*", + "@types/mime": "*", + "@types/node": "*" + } + }, "@types/three": { "version": "0.91.14", "resolved": "https://registry.npmjs.org/@types/three/-/three-0.91.14.tgz", @@ -13709,9 +13741,9 @@ } }, "@types/validator": { - "version": "13.11.2", - "resolved": "https://registry.npmjs.org/@types/validator/-/validator-13.11.2.tgz", - "integrity": "sha512-nIKVVQKT6kGKysnNt+xLobr+pFJNssJRi2s034wgWeFBUx01fI8BeHTW2TcRp7VcFu9QCYG8IlChTuovcm0oKQ==" + "version": "13.11.7", + "resolved": "https://registry.npmjs.org/@types/validator/-/validator-13.11.7.tgz", + "integrity": "sha512-q0JomTsJ2I5Mv7dhHhQLGjMvX0JJm5dyZ1DXQySIUzU1UlwzB8bt+R6+LODUbz0UDIOvEzGc28tk27gBJw2N8Q==" }, "@types/webidl-conversions": { "version": "7.0.0", @@ -15283,32 +15315,32 @@ } }, "esbuild": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.4.tgz", - "integrity": "sha512-x7jL0tbRRpv4QUyuDMjONtWFciygUxWaUM1kMX2zWxI0X2YWOt7MSA0g4UdeSiHM8fcYVzpQhKYOycZwxTdZkA==", - "requires": { - "@esbuild/android-arm": "0.19.4", - "@esbuild/android-arm64": "0.19.4", - "@esbuild/android-x64": "0.19.4", - "@esbuild/darwin-arm64": "0.19.4", - "@esbuild/darwin-x64": "0.19.4", - "@esbuild/freebsd-arm64": "0.19.4", - "@esbuild/freebsd-x64": "0.19.4", - "@esbuild/linux-arm": "0.19.4", - "@esbuild/linux-arm64": "0.19.4", - "@esbuild/linux-ia32": "0.19.4", - "@esbuild/linux-loong64": "0.19.4", - "@esbuild/linux-mips64el": "0.19.4", - "@esbuild/linux-ppc64": "0.19.4", - "@esbuild/linux-riscv64": "0.19.4", - "@esbuild/linux-s390x": "0.19.4", - "@esbuild/linux-x64": "0.19.4", - "@esbuild/netbsd-x64": "0.19.4", - "@esbuild/openbsd-x64": "0.19.4", - "@esbuild/sunos-x64": "0.19.4", - "@esbuild/win32-arm64": "0.19.4", - "@esbuild/win32-ia32": "0.19.4", - "@esbuild/win32-x64": "0.19.4" + "version": "0.19.8", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.8.tgz", + "integrity": "sha512-l7iffQpT2OrZfH2rXIp7/FkmaeZM0vxbxN9KfiCwGYuZqzMg/JdvX26R31Zxn/Pxvsrg3Y9N6XTcnknqDyyv4w==", + "requires": { + "@esbuild/android-arm": "0.19.8", + "@esbuild/android-arm64": "0.19.8", + "@esbuild/android-x64": "0.19.8", + "@esbuild/darwin-arm64": "0.19.8", + "@esbuild/darwin-x64": "0.19.8", + "@esbuild/freebsd-arm64": "0.19.8", + "@esbuild/freebsd-x64": "0.19.8", + "@esbuild/linux-arm": "0.19.8", + "@esbuild/linux-arm64": "0.19.8", + "@esbuild/linux-ia32": "0.19.8", + "@esbuild/linux-loong64": "0.19.8", + "@esbuild/linux-mips64el": "0.19.8", + "@esbuild/linux-ppc64": "0.19.8", + "@esbuild/linux-riscv64": "0.19.8", + "@esbuild/linux-s390x": "0.19.8", + "@esbuild/linux-x64": "0.19.8", + "@esbuild/netbsd-x64": "0.19.8", + "@esbuild/openbsd-x64": "0.19.8", + "@esbuild/sunos-x64": "0.19.8", + "@esbuild/win32-arm64": "0.19.8", + "@esbuild/win32-ia32": "0.19.8", + "@esbuild/win32-x64": "0.19.8" } }, "escalade": { @@ -18976,9 +19008,9 @@ } }, "sass": { - "version": "1.68.0", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.68.0.tgz", - "integrity": "sha512-Lmj9lM/fef0nQswm1J2HJcEsBUba4wgNx2fea6yJHODREoMFnwRpZydBnX/RjyXw2REIwdkbqE4hrTo4qfDBUA==", + "version": "1.69.5", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.69.5.tgz", + "integrity": "sha512-qg2+UCJibLr2LCVOt3OlPhr/dqVHWOa9XtZf2OjbLs/T4VPSJ00udtgJxH3neXZm+QqX8B+3cU7RaLqp1iVfcQ==", "requires": { "chokidar": ">=3.0.0 <4.0.0", "immutable": "^4.0.0", diff --git a/package.json b/package.json index eb080b42..1ab54709 100644 --- a/package.json +++ b/package.json @@ -19,12 +19,12 @@ "node": ">=16" }, "dependencies": { - "@mathigon/boost": "1.2.18", - "@mathigon/core": "1.1.13", - "@mathigon/euclid": "1.1.15", - "@mathigon/fermat": "1.1.12", - "@mathigon/hilbert": "1.1.12", - "@mathigon/studio": "0.1.39", + "@mathigon/boost": "1.2.19", + "@mathigon/core": "1.1.14", + "@mathigon/euclid": "1.1.16", + "@mathigon/fermat": "1.1.13", + "@mathigon/hilbert": "1.1.13", + "@mathigon/studio": "0.1.40", "@types/d3": "6.3.0", "@types/three": "0.91.14", "@types/topojson": "3.2.3",