/*
 Joel Espinosa Longi
 jlongi@im.unam.mx
 https://github.com/jlongi/DescartesJS
 LGPL - http://www.gnu.org/licenses/lgpl.html
 2016-05-05
*/
var babel=function(a){if(a.loadLib)return a;a.loadLib=!0;a.falso=a["false"]=a.fals=a.gezurra=a.faux=a.fals="false";a.verdadero=a["true"]=a.veritable=a.egia=a.vrai=a.verdadeiro=a.veritable="true";a.no=a.ez=a.non=a["n\u00e3o"]="false";a["s\u00ed"]=a.yes=a.bai=a.oui=a.si=a["sim "]="true";a.negro=a.black=a.negre=a.beltza=a.noir=a.preto=a["#000000"]="#000000";a.maxenta=a.magenta=a["#ff00ff"]="#ff00ff";a.azul=a.blue=a.blau=a.urdina=a.bleu=a["#0000ff"]="#0000ff";a.turquesa=a.cyan=a.turkesa=a.turquoise=a["#00ffff"]=
"#00ffff";a.verde=a.green=a.verd=a.berdea=a.vert=a["#00ff00"]="#00ff00";a.amarillo=a.yellow=a.groc=a.horia=a.jaune=a.amarelo=a["#ffff00"]="#ffff00";a.naranja=a.orange=a.taronja=a.laranja=a.laranxa=a["#ffc800"]="#ffc800";a.rojo=a.red=a.vermell=a.gorria=a.rouge=a.vermello=a.vermelho=a["#ff0000"]="#ff0000";a.pink=a.rosa=a.arrosa=a.rose=a["#ffafaf"]="#ffafaf";a.grisObscuro=a.darkGray=a.grisFosc=a["gris iluna"]=a.grisObscur=a.grisEscuro=a.cinzaEscuro=a["#404040"]="#404040";a.gris=a.gray=a.grisa=a.cinza=
a["#808080"]="#808080";a.grisClaro=a.lightGray=a.grisClar=a["gris argia"]=a.grisClair=a.cinzaClaro=a["#c0c0c0"]="#c0c0c0";a.blanco=a.white=a.blanc=a.zuria=a.branco=a["#ffffff"]="#ffffff";a.escala=a.scale=a.eskala=a["\u00e9chelle"]="scale";a.nombre=a.name=a.nom=a.izena=a.nome="name";a.ikusgai=a["vis\u00edvel"]=a.visible="visible";a.rastro=a.trace=a.rastre=a.arrastoa="trace";a.fondo=a.background=a.fons=a.hondoa=a.fond=a.fundo="background";a["par\u00e1metro"]=a.parameter=a.parametroa=a["par\u00e2metro"]=
a["par\u00e0metre"]="parameter";a["sucesi\u00f3n"]=a.sequence=a["successi\u00f3"]=a.segida=a.succession=a["seq\u00fc\u00eancia"]="sequence";a["tama\u00f1o"]=a.size=a.neurria=a.taille=a.tamanho=a["grand\u00e0ria"]="size";a.decimales=a.decimals=a.hamartarra=a["d\u00e9cimales"]=a.decimais="decimals";a.red=a.net=a.xarxa=a.sarea=a["r\u00e9seau"]=a.rede=a.malha="net";a.red10=a.net10=a.xarxa10=a.sarea10=a["r\u00e9seau10"]=a.rede10=a.malha10="net10";a.ejes=a.axes=a.eixos=a.ardatzak=a.eixes="axes";a.texto=
a.text=a.testua=a.texte="text";a["cr\u00e9ditos"]=a.about=a["cr\u00e8dits"]=a.kreditoak=a["cr\u00e9dits"]=a.sobre="about";a.config=a.konfig=a["configura\u00e7\u00e3o"]="config";a.limpiar=a.clear=a.neteja=a.ezabatu=a.nettoye=a.limpar="clear";a.incr=a.gehi=a.incremento="incr";a.min=a.inf="min";a.max=a.sup=a["m\u00e1x"]="max";a.relleno=a.fill=a.ple=a.betea=a.plein=a.recheo=a.preencher="fill";a["relleno+"]=a["fill+"]=a["ple+"]=a["betea+"]=a["plein+"]=a["recheo+"]=a["preencher+"]=a.fillP="fillP";a["relleno-"]=
a["fill-"]=a["ple-"]=a["betea-"]=a["plein-"]=a["recheo-"]=a["preencher-"]=a.fillM="fillM";a.flecha=a.arrow=a.fletxa=a.gezia=a["fl\u00e8che"]=a.frecha=a.seta="arrow";a.ancho=a.width=a.ample=a.zabalera=a.large=a.largura="width";a.punta=a.spear=a.muturra=a.pointe=a.ponta="spear";a["regi\u00f3n"]=a.region=a["regi\u00f3"]=a.eskualde=a["r\u00e9gion"]=a["rexi\u00f3n"]=a["regi\u00e3o"]="region";a.norte=a.north=a.nord=a.ipar="north";a.sur=a.south=a.sud=a.hego=a.sul="south";a.este=a.east=a.est=a.ekialde=a.leste=
"east";a.oeste=a.west=a.oest=a.hegoalde=a.ouest="west";a.exterior=a.external=a.kanpoalde=a.externo="external";a["expresi\u00f3n"]=a.expresion=a["expresi\u00f3"]=a.adierazpen=a["express\u00e3o"]="expresion";a.tipo=a.type=a.tipus=a.mota="type";a["posici\u00f3n"]=a.position=a["posici\u00f3"]=a.posizio=a["posi\u00e7\u00e3o"]="position";a["constricci\u00f3n"]=a.constraint=a["constricci\u00f3"]=a.beharte=a.constriction=a["constrici\u00f3n"]=a["restri\u00e7\u00e3o"]="constraint";a.valor=a.value=a.balio=
a.valeur="value";a["ecuaci\u00f3n"]=a.equation=a["equaci\u00f3"]=a.ekuazio=a["\u00e9quation"]=a["equa\u00e7\u00e3o"]="equation";a.curva=a.curve=a.corba=a.kurba=a.courbe="curve";a.texto=a.text=a.testu=a.texte="text";a.punto=a.point=a.punt=a.puntu=a.ponto="point";a.segmento=a.segment=a.zuzenki="segment";a.arco=a.arc=a.arku="arc";a["pol\u00edgono"]=a.polygon=a["pol\u00edgon"]=a.poligono=a.polygone="polygon";a.imagen=a.image=a.imatge=a.irudi=a.imaxe=a.imagem="image";a["Versi\u00f3n"]=a.Version=a["Versi\u00f3"]=
a["Vers\u00e3o"]=a.version="version";a.Idioma=a.Language=a.Hizkuntza=a.Langue=a.language="language";a["O.x"]="O.x";a["O.y"]="O.y";a.Botones=a.Buttons=a.Botons=a.Botoiak=a.Boutons=a["Bot\u00f3ns"]=a["Bot\u00f5es"]=a.Botons="Buttons";a["Animaci\u00f3n"]=a.Animation=a["Animaci\u00f3"]=a.Animazio=a["Anima\u00e7\u00e3o"]="Animation";a.constante=a.constant=a.Konstante="constant";a.fuente=a.font=a.iturri=a.source=a.fonte="font";a["num\u00e9rico"]=a.numeric=a["num\u00e8ric"]=a.zenbakizko=a["num\u00e9rique"]=
"numeric";a["gr\u00e1fico"]=a.graphic=a["gr\u00e0fic"]=a.grafiko=a.graphique="graphic";a.inicio=a.init=a.inici=a.hasiera=a.commencement=a["in\u00edcio"]="init";a.hacer=a["do"]=a.fer=a.egin=a.faire=a.facer=a.fazer=a.doExpr="doExpr";a.mientras=a["while"]=a.mentre=a.bitartean=a["tandis que"]=a.mentres=a.enquanto=a.whileExpr="whileExpr";a.evaluar=a.evaluate=a.avalua=a.ebaluatu=a["\u00e9valuer"]=a.avaliar="evaluate";a.variable=a.aldagaia=a["vari\u00e1vel"]="variable";a["funci\u00f3n"]=a["function"]=a["funci\u00f3"]=
a.funtzio=a.fonction=a["fun\u00e7\u00e3o"]="function";a.algoritmo=a.algorithm=a.algorisme=a.algorithme="algorithm";a.vector=a.array=a.bektore=a.vecteur=a.matriz="array";a["dibujar-si"]=a["draw-if"]=a["marraztu-baldin"]=a["dessiner-si"]=a["debuxar-se"]=a["desenhar-se"]=a["dibuixa-si"]=a.drawif="drawif";a.dominio=a.range=a.domini=a["izate-eremua"]=a.domain=a["dom\u00ednio"]="range";a.pausa=a.delay=a.eten="delay";a["eje-x"]=a["x-axis"]=a["eix-x"]=a["x-ardatza"]=a["axe-x"]=a["eixe-x"]=a["eixo-x"]=a.x_axis=
"x_axis";a["eje-y"]=a["y-axis"]=a["eix-y"]=a["y-ardatza"]=a["axe-y"]=a["eixe-y"]=a["eixo-y"]=a.y_axis="y_axis";a["n\u00fameros"]=a.numbers=a.nombres=a.zenbakiak="numbers";a["exponencial-si"]=a["exponential-if"]=a["esponentzial-baldin"]=a["exponentiel-si"]=a["exponencial-se"]=a.exponentialif="exponentialif";a.familia=a.family=a["fam\u00edlia"]=a.famille="family";a.intervalo=a.interval=a.tarte=a.intervalle="interval";a.pasos=a.steps=a.passos=a.pausoak=a.pas="steps";a.centro=a.center=a.centre=a.zentro=
"center";a.radio=a.radius=a.radi=a.erradio=a.rayon=a.raio="radius";a.fin=a.end=a.fi=a.bukaera=a.fim="end";a["una-sola-vez"]=a["only-once"]=a["una-sola-vegada"]=a["behin-bakarrik"]=a["une-seule-fois"]=a["unha-soa-vez"]=a["apenas-uma-vez"]=a.onlyOnce="onlyOnce";a.siempre=a.always=a.sempre=a.beti=a.toujours="always";a["color-int"]=a["int-colour"]=a["barruko-kolore"]=a["couleur-int"]=a["cor-int"]=a.colorInt="colorInt";a.repetir=a.loop=a.repeteix=a.errepikatu=a["r\u00e9p\u00e9ter"]="loop";a.controles=
a.controls=a.kontrolak=a["contr\u00f4les"]=a.controis="controls";a.animar=a.animate=a.anima=a.animatu=a.animer="animate";a.auto="auto";a.alto=a.height=a.alt=a.altu=a.haut=a.altura="height";a.x=a.left="x";a.y=a.top="y";a.espacio=a.space=a.espai=a.espazio=a.espace=a.espazo=a["espa\u00e7o"]="space";a.Nu="Nu";a.Nv="Nv";a.ancho=a.depth=a.amplada=a.zabalera=a.largeur=a.ancho=a.profundidade=a.amplada=a.width="width";a.largo=a.length=a.llargada=a.luzera=a.longueur=a.longo=a.comprimento=a.llargada="length";
a.alto=a.height=a["al\u00e7ada"]=a.altu=a.hauteur=a.alto=a.altura=a["al\u00e7ada"]="height";a.color_reverso=a.backcolor=a.color_revers=a["atzealde kolorea"]=a.couleur_revers=a.cor_reverso=a.cor_de_fundo="backcolor";a.aristas=a.edges=a.arestes=a.ertzak=a["ar\u00eates"]=a.arestas="edges";a.rotini=a.inirot="inirot";a.posini=a.inipos="inipos";a["tri\u00e1ngulo"]=a.triangle=a.hirukia=a["tri\u00e2ngulo"]="triangle";a.cara=a.face=a.aurpegi="face";a.polireg=a.regpoly=a["pol\u00edgonoRegular"]="polireg";a.superficie=
a.surface=a["superf\u00edcie"]=a.azalera="surface";a.cubo=a.cube=a.cub=a.kubo="cube";a["paralelep\u00edpedo"]=a.box=a["paral\u00b7lelep\u00edpede"]=a.paralelepipedo=a["parall\u00e9l\u00e9pip\u00e8de"]="box";a.cono=a.cone=a.con=a.kono=a["c\u00f4ne"]="cone";a.cilindro=a.cylinder=a.cilindre=a.zilindro=a.cylindre="cylinder";a.esfera=a.sphere=a["sph\u00e8re"]="sphere";a.tetraedro=a.tetrahedron=a.tetraedre=a["t\u00e9tra\u00e8dre"]="tetrahedron";a.octaedro=a["octahedron="]=a.octaedre=a.oktaedro=a["octa\u00e8dre"]=
"octahedron";a.dodecaedro=a.dodecahedron=a.dodecaedre=a.dodekaedro=a["dod\u00e9ca\u00e8dre"]="dodecahedron";a.icosaedro=a.icosahedron=a.icosaedre=a.ikosaedro=a["icosa\u00e8dre"]="icosahedron";a.elipsoide=a.ellipsoid=a["el\u00b7lipsoide"]=a["ellipso\u00efde"]=a["elips\u00f3ide"]="ellipsoid";a.macro=a.makro="macro";a.id="id";a.modelo=a.model=a.eredu=a["mod\u00e8le"]="model";a.color=a.kolore=a.couleur=a.cor=a.colour=a.kolorea="color";a.luz=a.light=a.llum=a.argia=a["lumi\u00e8re"]="light";a.metal=a.metall=
a["m\u00e9tal"]="metal";a.alambre=a.wire=a.filferro=a.alanbre=a["fil de fer"]=a.arame="wire";a.cortar=a.split=a.talla=a.moztu=a.couper=a.dividir="split";a.despliegue=a.render=a.desplegament=a.zabaltze=a["d\u00e8ploiement"]=a.despregamento=a.processar="render";a.orden=a.sort=a.ordre=a.ordena=a.orde=a.ordenar="sort";a.pintor=a.painter=a.margolari=a.peintre="painter";a["trazado de rayos"]=a["ray trace"]=a["tra\u00e7at de raigs"]=a["izpi trazadura"]=a["trace de rayons"]=a["trazado de raios"]=a["tra\u00e7ado de raios"]=
a.raytrace="raytrace";a.imagen=a.bg_image=a.imatge=a.irudia=a.imaxe=a.imagem_de_fundo=a.image="image";a.despl_imagen=a.bg_display=a.despl_imatge=a["irudi desplazamendu"]=a.despl_image=a.despr_imaxe=a["apresenta\u00e7\u00e3o_de_imagem"]="bg_display";a["arr-izq"]=a.topleft=a["dalt-esq"]=a["goi-ezk"]=a["au-dessus-gau"]=a["arr-esq"]=a["acima-esquerda"]="topleft";a["expand."]=a.stretch=a.hedatu=a["expandir "]="stretch";a.mosaico=a.patch=a.mosaic=a.mosaiko=a["mosa\u00efque"]="patch";a.centrada=a.center=
a.zentratu=a["centr\u00e9e"]=a.centrado="imgcenter";a.archivo=a.file=a.fitxer=a.artxibo=a.fichier=a.arquivo="file";a.tipo_de_macro=a.macro_type=a.tipus_de_macro=a.makro_mota=a.type_de_macro=a.tipo_de_macro=a.tipo_de_macro=a.tipus_de_macro="macro_type";a.filas_norte=a.rows_north=a.files_nord=a["HTML kodea"]=a.files_nord=a.filas_norte=a.linhas_norte=a.files_nord=a.rowsNorth="rowsNorth";a.filas_sur=a.rows_south=a.files_sud=a.ipar_lerro=a.files_sud=a.filas_sur=a.linhas_sul=a.files_sud=a.rowsSouth="rowsSouth";
a.ancho_este=a.width_east=a.ample_est=a.hego_lerro=a.ample_est=a.ancho_leste=a.largura_leste=a.ample_est=a.widthEast="widthEast";a.ancho_oeste=a.width_west=a.ample_oest=a.ekialde_zabalera=a.ample_ouest=a.ancho_oeste=a.largura_oeste=a.ample_oest=a.widthWest="widthWest";a.fijo=a.fixed=a.fix=a.hegoalde_zabalera=a.fixe=a.fixo="fixed";a["Reiniciar Animaci\u00f3n"]=a["Init Animation"]=a["Reinicia Animaci\u00f3"]=a.finko=a["Recommencer l'Animation"]=a["Reiniciar Anima\u00e7\u00e3o"]=a.initAnimation="initAnimation";
a["Explicaci\u00f3n"]=a.Explanation=a.Azalpena=a.Explication=a["Explica\u00e7\u00e3o"]=a["Explicaci\u00f3"]="Explanation";a.tooltip=a.dica="tooltip";a.discreto=a.discrete=a.discret=a.diskretu="discrete";a.interfaz=a.gui=a["interf\u00edcie"]=a.interfaze=a["interface"]="gui";a.pulsador=a.spinner=a.polsador=a.pultsadore=a.bouton="spinner";a["campo de texto"]=a.textfield=a["camp de text"]=a["testu esarrua"]=a["champ de texte"]="textfield";a["men\u00fa"]=a.choice=a.menu=a.escolha="menu";a.barra=a.scrollbar=
a.barre="scrollbar";a.opciones=a.options=a.opcions=a.aukerak=a["opci\u00f3ns"]=a["op\u00e7\u00f5es"]="options";a.interior=a.barruko=a["int\u00e9rieur"]="interior";a["condici\u00f3n"]=a.condition=a["condici\u00f3"]=a.baldintza=a["condi\u00e7\u00e3o"]="condition";a["acci\u00f3n"]=a.action=a["acci\u00f3"]=a.ekintza=a["a\u00e7\u00e3o"]="action";a.evento=a.event=a.esdeveniment=a.gertaera=a["\u00e9v\u00e9nement"]="event";a["abrir URL"]=a["open URL"]=a["obre URL"]=a["URL zabaldu"]=a["ouvrir URL"]=a.openURL=
"openURL";a["abrir Escena"]=a["open Scene"]=a["obre Escena"]=a["eszena zabaldu"]=a["ouvrir Escena"]=a["abrir Cena"]=a.openScene="openScene";a["bot\u00f3n"]=a.button=a["bot\u00f3"]=a.botoi=a.bouton=a["bot\u00e3o"]="button";a.mensaje=a.message=a.mezua=a.mensaxe=a.mensagem=a.missatge="message";a.alternar=a.alternate=a.alterna=a.txandakatu=a.alterner="alternate";a["ejecuci\u00f3n"]=a.execution=a["execuci\u00f3"]=a.gauzatze=a["ex\u00e9cution"]=a["execuci\u00f3n"]=a["execu\u00e7\u00e3o"]="execution";a.calcular=
a.calculate=a.calcula=a.kalkulatu=a.calculer="calculate";a.coord_abs=a.abs_coord=a.koor_abs="abs_coord";a.negrita=a.bold=a.negreta=a.lodi=a["caract\u00e8re gras"]=a.negra=a.negrito="bold";a.cursiva=a.italics=a.etzana=a.italique=a["it\u00e1lico"]="italics";a.subrayada=a.underlined=a.subratllat=a.azpimarratua=a.soulignement=a["subli\u00f1ada"]=a.sublinhado="underlined";a.imagen=a.image=a.imatge=a.irundia=a.imaxe=a.imagem="image";a.pos_mensajes=a.msg_pos=a.pos_missatges=a.mezuen_pos=a.pos_messages=a.pos_mensaxes=
"msg_pos";a.izquierda=a.left=a.esquerra=a.eskerrean=a.gauche=a.esquerda=a.esquerda=a.esquerra=a.x="x";a.derecha=a.right=a.dreta=a.eskuinan=a.droite=a.dereita=a.direita=a.dreta="right";a["sensible_a_los_movimientos_del_rat\u00f3n"]=a.sensitive_to_mouse_movements=a["sensible_als_moviments_del_ratol\u00ed"]=a["xagu mugimenduarekiko sentikorra"]=a.sensible_aux_mouvements_du_souris=a.sensible_aos_movementos_do_rato=a["sens\u00edvel_aos_movimentos_do_mouse"]="sensitive_to_mouse_movements";a.reproducir=
a.play=a.reprodueix=a.erreproduzitu=a.reproduire=a.reproduzir=a.playAudio="playAudio";a["activo-si"]=a["active-if"]=a["actiu-si"]=a["altiboa-baldin"]=a["actif-si"]=a["activo-se"]=a["ativo-se"]=a.activeif="activeif";a.rotfin=a.finrot=a.bukrot=a.endrot="endrot";a.posfin=a.finpos=a.bukpos=a.endpos="endpos";a.editable=a.editagarria=a["edit\u00e1vel"]="editable";a.tipo=a.type=a.tipus=a.mota="type";a.R2="R2";a.R3="R3";a.vectores=a.bektoreak=a.vecteurs=a.vetores=a.vectors="vectors";a["fuente puntos"]=a["font size"]=
a["font punts"]=a["puntu iturria"]=a["source points"]=a["fonte puntos"]=a["fonte pontos"]=a.font_size="font_size";a["ecuaci\u00f3n"]=a.equation=a["equaci\u00f3"]=a.ekuazio=a["\u00e9quation"]=a["equa\u00e7\u00e3o"]="equation";a.punto=a.dot=a.punt=a.puntu=a.point=a.ponto="point";a.escenario=a.scenario=a.escenari=a.agertoki=a["sc\u00e8ne"]=a["cen\u00e1rio"]="scenario";a.cID="cID";a.matriz=a.matrix=a.matriu=a.matrice="matrix";a.filas=a.rows=a.files="rows";a.columnas=a.columns=a.colonnes="columns";a.solo_texto=
a.only_text=a.seulement_texte=a["s\u00f3_texto"]=a.tan_sols_texte=a.onlyText="onlyText";a.respuesta=a.answer="answer";a.peso=a.weight=a.pes="weight";a.decimal_symbol=a["signo decimal"]=a["decimal symbol"]="decimal_symbol";a.info="info";a.color_contorn_text=a.color_text_border=a.color_borde_texto=a.muga_testuaren_kolorea=a.couleur_contour_texte=a.cor_borde_texto=a.colore_bordo_testo=a.cor_borda_texto=a.color_contorn_text=a.border="border";a.video=a["vid\u00e9o"]="video";a.audio=a["\u00e0udio"]="audio";
a.autoplay="autoplay";a.loop="loop";a.poster="poster";a.opacidad=a.opacity=a["opacit\u00e9"]=a.opacitat=a.opacidade="opacity";a.alinear=a.align=a["ali\u00f1ar"]=a.aligner="align";a.malla=a.mesh="mesh";a.local=a.Local="local";return a}(babel||{}),descartesJS=function(a){if(a.loadLib)return a;var k,d;a.convertFont=function(a){if(""==a)return a;k=a.split(",");d="";"bold"==k[1].toLowerCase()?d+="Bold ":"italic"==k[1].toLowerCase()||"italics"==k[1].toLowerCase()?d+="Italic ":"bold+italic"==k[1].toLowerCase()&&
(d+="Italic Bold ");fontName=k[0].split(" ")[0].toLowerCase();d+=k[2]+"px ";return d="serif"===fontName||"times new roman"===fontName||"timesroman"===fontName||"times"===fontName?d+"descartesJS_serif,Times,'Times New Roman', serif":"sansserif"===fontName||"arial"===fontName||"helvetica"===fontName?d+"descartesJS_sansserif,Arial,Helvetica,Sans-serif":d+"descartesJS_monospace,Courier,'Courier New',Monospace"};a.getTextWidth=function(c,g){a.ctx.font=g;return Math.round(a.ctx.measureText(c).width)};a.getFieldFontSize=
function(a){a=Math.min(50,a);return a=24<=a?Math.floor(a/2+2-a/16):20<=a?12:17<=a?11:15<=a?10:9};var f={ss_5:{a:5,d:3},ss_6:{a:5,d:3},ss_7:{a:6,d:3},ss_8:{a:7,d:3},ss_9:{a:9,d:4},ss_10:{a:10,d:4},ss_11:{a:11,d:4},ss_12:{a:12,d:4},ss_13:{a:13,d:4},ss_14:{a:13,d:4},ss_15:{a:14,d:4},ss_16:{a:15,d:4},ss_17:{a:15,d:5},ss_18:{a:16,d:5},ss_19:{a:18,d:5},ss_20:{a:19,d:5},ss_21:{a:19,d:6},ss_22:{a:20,d:6},ss_23:{a:21,d:6},ss_24:{a:21,d:7},ss_25:{a:23,d:6},ss_26:{a:25,d:7},ss_27:{a:26,d:7},ss_28:{a:26,d:7},
ss_29:{a:27,d:7},ss_30:{a:28,d:8},ss_31:{a:28,d:8},ss_32:{a:29,d:8},ss_33:{a:31,d:8},ss_34:{a:32,d:8},ss_35:{a:32,d:9},ss_36:{a:33,d:9},ss_37:{a:34,d:10},ss_38:{a:34,d:10},ss_39:{a:35,d:10},ss_40:{a:36,d:10},ss_41:{a:38,d:11},ss_42:{a:38,d:11},ss_43:{a:39,d:11},ss_44:{a:40,d:11},ss_45:{a:40,d:11},ss_46:{a:42,d:11},ss_47:{a:43,d:11},ss_48:{a:45,d:11},ss_49:{a:45,d:13},ss_50:{a:46,d:13},ss_51:{a:47,d:13},ss_52:{a:48,d:13},ss_53:{a:48,d:14},ss_54:{a:49,d:14},ss_55:{a:51,d:14},ss_56:{a:52,d:14},ss_57:{a:52,
d:14},ss_58:{a:53,d:14},ss_59:{a:53,d:14},ss_60:{a:54,d:14},ss_61:{a:55,d:15},ss_62:{a:56,d:15},ss_63:{a:57,d:15},ss_64:{a:58,d:15},ss_65:{a:59,d:16},ss_66:{a:60,d:16},ss_67:{a:60,d:16},ss_68:{a:61,d:16},ss_69:{a:62,d:17},ss_70:{a:63,d:17},ss_71:{a:64,d:17},ss_72:{a:65,d:17},ss_73:{a:66,d:17},ss_74:{a:66,d:17},ss_75:{a:67,d:17},ss_76:{a:68,d:17},ss_77:{a:70,d:18},ss_78:{a:70,d:18},ss_79:{a:71,d:18},ss_80:{a:72,d:18},ss_81:{a:73,d:20},ss_82:{a:73,d:20},ss_83:{a:74,d:20},ss_84:{a:75,d:20},ss_85:{a:77,
d:20},ss_86:{a:77,d:20},ss_87:{a:78,d:20},ss_88:{a:79,d:20},ss_89:{a:80,d:20},ss_90:{a:80,d:20},ss_91:{a:81,d:20},ss_92:{a:83,d:20},ss_93:{a:84,d:20},ss_94:{a:84,d:20},ss_95:{a:85,d:20},ss_96:{a:86,d:20},ss_97:{a:87,d:20},ss_98:{a:87,d:20},ss_99:{a:89,d:20},s_5:{a:4,d:4},s_6:{a:5,d:4},s_7:{a:6,d:4},s_8:{a:7,d:4},s_9:{a:9,d:4},s_10:{a:10,d:3},s_11:{a:11,d:4},s_12:{a:12,d:4},s_13:{a:12,d:4},s_14:{a:13,d:4},s_15:{a:13,d:5},s_16:{a:15,d:5},s_17:{a:15,d:5},s_18:{a:16,d:5},s_19:{a:16,d:6},s_20:{a:17,d:6},
s_21:{a:18,d:6},s_22:{a:20,d:6},s_23:{a:20,d:7},s_24:{a:21,d:7},s_25:{a:23,d:7},s_26:{a:23,d:7},s_27:{a:24,d:8},s_28:{a:26,d:8},s_29:{a:26,d:8},s_30:{a:27,d:8},s_31:{a:28,d:9},s_32:{a:28,d:9},s_33:{a:29,d:9},s_34:{a:31,d:9},s_35:{a:32,d:10},s_36:{a:32,d:10},s_37:{a:33,d:10},s_38:{a:34,d:10},s_39:{a:34,d:12},s_40:{a:35,d:12},s_41:{a:37,d:12},s_42:{a:38,d:12},s_43:{a:39,d:12},s_44:{a:40,d:12},s_45:{a:41,d:13},s_46:{a:41,d:13},s_47:{a:42,d:13},s_48:{a:43,d:13},s_49:{a:44,d:15},s_50:{a:45,d:15},s_51:{a:45,
d:15},s_52:{a:46,d:15},s_53:{a:48,d:15},s_54:{a:48,d:15},s_55:{a:49,d:15},s_56:{a:50,d:15},s_57:{a:51,d:15},s_58:{a:52,d:15},s_59:{a:53,d:15},s_60:{a:54,d:15},s_61:{a:54,d:17},s_62:{a:55,d:17},s_63:{a:56,d:17},s_64:{a:57,d:17},s_65:{a:58,d:17},s_66:{a:59,d:17},s_67:{a:60,d:17},s_68:{a:61,d:17},s_69:{a:61,d:18},s_70:{a:62,d:18},s_71:{a:63,d:18},s_72:{a:64,d:18},s_73:{a:65,d:19},s_74:{a:66,d:19},s_75:{a:67,d:19},s_76:{a:67,d:19},s_77:{a:68,d:20},s_78:{a:70,d:20},s_79:{a:71,d:20},s_80:{a:71,d:20},s_81:{a:72,
d:21},s_82:{a:73,d:21},s_83:{a:73,d:21},s_84:{a:75,d:21},s_85:{a:76,d:21},s_86:{a:77,d:21},s_87:{a:77,d:21},s_88:{a:78,d:21},s_89:{a:79,d:21},s_90:{a:81,d:21},s_91:{a:81,d:21},s_92:{a:82,d:21},s_93:{a:83,d:21},s_94:{a:83,d:21},s_95:{a:84,d:21},s_96:{a:86,d:21},s_97:{a:87,d:21},s_98:{a:87,d:21},s_99:{a:88,d:21},m_5:{a:4,d:3},m_6:{a:5,d:3},m_7:{a:6,d:3},m_8:{a:6,d:3},m_9:{a:9,d:4},m_10:{a:9,d:4},m_11:{a:10,d:5},m_12:{a:11,d:5},m_13:{a:11,d:6},m_14:{a:11,d:7},m_15:{a:12,d:6},m_16:{a:13,d:6},m_17:{a:14,
d:7},m_18:{a:14,d:7},m_19:{a:15,d:7},m_20:{a:16,d:7},m_21:{a:16,d:8},m_22:{a:17,d:8},m_23:{a:17,d:9},m_24:{a:19,d:9},m_25:{a:21,d:9},m_26:{a:21,d:9},m_27:{a:22,d:9},m_28:{a:22,d:10},m_29:{a:23,d:10},m_30:{a:24,d:10},m_31:{a:25,d:11},m_32:{a:26,d:11},m_33:{a:26,d:11},m_34:{a:27,d:11},m_35:{a:28,d:11},m_36:{a:28,d:12},m_37:{a:28,d:11},m_38:{a:30,d:11},m_39:{a:31,d:12},m_40:{a:31,d:12},m_41:{a:32,d:14},m_42:{a:32,d:14},m_43:{a:33,d:14},m_44:{a:34,d:14},m_45:{a:35,d:14},m_46:{a:36,d:14},m_47:{a:37,d:14},
m_48:{a:37,d:14},m_49:{a:38,d:17},m_50:{a:38,d:17},m_51:{a:39,d:17},m_52:{a:41,d:17},m_53:{a:41,d:18},m_54:{a:42,d:18},m_55:{a:43,d:18},m_56:{a:43,d:18},m_57:{a:44,d:19},m_58:{a:46,d:19},m_59:{a:46,d:19},m_60:{a:47,d:19},m_61:{a:47,d:21},m_62:{a:48,d:21},m_63:{a:49,d:21},m_64:{a:49,d:22},m_65:{a:51,d:21},m_66:{a:52,d:21},m_67:{a:52,d:21},m_68:{a:53,d:21},m_69:{a:53,d:22},m_70:{a:54,d:22},m_71:{a:55,d:22},m_72:{a:56,d:22},m_73:{a:57,d:23},m_74:{a:58,d:23},m_75:{a:58,d:23},m_76:{a:59,d:23},m_77:{a:59,
d:24},m_78:{a:60,d:24},m_79:{a:62,d:24},m_80:{a:62,d:24},m_81:{a:63,d:25},m_82:{a:64,d:25},m_83:{a:64,d:25},m_84:{a:65,d:25},m_85:{a:65,d:25},m_86:{a:67,d:25},m_87:{a:68,d:25},m_88:{a:68,d:25},m_89:{a:69,d:25},m_90:{a:70,d:25},m_91:{a:70,d:25},m_92:{a:71,d:25},m_93:{a:72,d:25},m_94:{a:73,d:25},m_95:{a:74,d:25},m_96:{a:74,d:25},m_97:{a:75,d:25},m_98:{a:76,d:25},m_99:{a:77,d:25}},p={};document.createElement("canvas");var c;a.getFontMetrics=function(a){if(p[a])return p[a];c=parseInt(a.match(/(\d+\.*)+px/)[0]);
var g;a.match("sansserif")?g="ss_":a.match("serif")?g="s_":a.match("monospace")&&(g="m_");g=f[g+c];g={ascent:g.a,descent:g.d,h:g.a+g.d,baseline:g.a};return p[a]=g};return a}(descartesJS||{}),descartesJS=function(a){function k(){var a,b,e,c,g,n,d,q,f;Number.prototype.oToFixed=Number.prototype.toFixed;Number.prototype.toFixed=function(h){try{return this.oToFixed(h)}catch(m){h=h?h:0;h=0>h?0:parseInt(h);a=this.toString();g=a.indexOf("e");-1!==g&&(n=a.split("e"),q="-"===n[0][0]?"-":"",d="-"===q?parseFloat(n[0].substring(1)).oToFixed(11):
parseFloat(n[0]).oToFixed(11),f=parseInt(n[1]),b=d.indexOf("."),0>b+f?(b=0>b?1:b,a=q+"0."+Array(Math.abs(b+f)+1).join("0")+d.replace(".","")):(d=d.replace(".",""),a=q+d+Array(f-d.length+2).join("0")));b=a.indexOf(".");e="";if(-1===b)0<h&&(e="."),e+=Array(h+1).join("0"),a+=e;else if(c=a.length-b-1,c>=h)11>=h&&(a=parseFloat(a).oToFixed(h)),a=0<h?a.substring(0,b+1+h):a.substring(0,b);else{var r=0;for(h-=c;r<h;r++)e+="0";a+=e}return a}}}function d(a,b,e){a.fillStyle="#c0c0c0";a.fillRect(b.offsetLeft,
b.offsetTop,b.offsetWidth,b.offsetHeight);f(a,b,e.controls)}function f(a,b,e){for(var c,n=e.length-1;0<=n;n--)c=e[n],c.drawIfValue&&a.drawImage(c.getScreenshot(),b.offsetLeft+c.x,b.offsetTop+c.y)}if(a.loadLib)return a;var p=2*Math.PI,c=360/p,h=p/360,g=Math.floor,b,u,n,r,q,t,v,e,m,w;a.rangeOK=1;a.cssScale=1;a.extend=function(a,b){if("function"==typeof Object.create)a.prototype=Object.create(b.prototype);else if(a.prototype.__proto__)a.prototype.__proto__=b.prototype;else for(var e in b.prototype)b.prototype.hasOwnProperty(e)&&
(a.prototype[e]=b.prototype[e]);a.prototype.uber=b.prototype};a.radToDeg=function(a){return a*c};a.degToRad=function(a){return a*h};a.drawLine=function(a,b,e,c,n,d,q){a.lineWidth=q||1;a.strokeStyle=d||"black";w=a.lineWidth%2?.5:0;a.beginPath();a.moveTo(g(b)+w,g(e)+w);a.lineTo(g(c)+w,g(n)+w);a.stroke()};a.getColor=function(a,e){if("string"==typeof e)return e;b=a.eval(e);u=g(255*b[0][0]);n=g(255*b[0][1]);r=g(255*b[0][2]);q=1-b[0][3];return"rgba("+u+","+n+","+r+","+q+")"};a.getFeatures=function(){var b=
navigator.appVersion.toLowerCase();a.hasTouchSupport=window.hasOwnProperty&&window.hasOwnProperty("ontouchstart")||"ontouchstart"in window||/android/i.test(b);a.isIOS=/iPad|iPhone/i.test(navigator.userAgent);b=document.createElement("canvas");a.hasCanvas=b.getContext&&b.getContext("2d");a.hasCanvas&&(a.ctx=document.createElement("canvas").getContext("2d"),a._ratio=1.5);k()};a.removeNeedlessDecimals=function(a){var b,e;if("string"==typeof a&&(b=a.indexOf("."),-1!=b)){e=a.substring(b);if(0==parseFloat(e))return a.substring(0,
b);for(var c=e.length;0<c;c--)if(0!=e.charAt(c))return a.substring(0,b+c+1)}return a};a.returnValue=function(a){return"number"===typeof a?parseFloat(a.toFixed(11)):a};a.whichBtn=function(a){return null!==a.which?2>a.which?"L":2===a.which?"M":"R":2>a.button?"L":4===a.button?"M":"R"};a.getCursorPosition=function(b,c){b.touches?(t=b.touches[0],v=t.pageX,e=t.pageY):(v=b.pageX,e=b.pageY);m=c.getBoundingClientRect();return{x:(v-window.pageXOffset-m.left)/a.cssScale,y:(e-window.pageYOffset-m.top)/a.cssScale}};
a.getScreenshot=function(){var b=a.apps[0],e,c=document.createElement("canvas"),n=new Image;if(b){c.setAttribute("width",b.width);c.setAttribute("height",b.height);for(var g=c.getContext("2d"),q=0,h=b.spaces.length;q<h;q++)e=b.spaces[q],e.drawIfValue&&"R2"===e.type&&(g.drawImage(e.backCanvas,e.x,e.y),g.drawImage(e.canvas,e.x,e.y),f(g,e.container,e.ctrs));0<b.northSpace.controls.length&&d(g,b.northSpace.container,b.northSpace);0<b.southSpace.controls.length&&d(g,b.southSpace.container,b.southSpace);
0<b.eastSpace.controls.length&&d(g,b.eastSpace.container,b.eastSpace);0<b.westSpace.controls.length&&d(g,b.westSpace.container,b.westSpace);n.src=c.toDataURL("image/png")}return n};window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame;window.cancelAnimationFrame=window.cancelAnimationFrame||window.mozCancelAnimationFrame;a.setInterval=function(a,b){function e(){(new Date).getTime()-c>=b&&(a.call(),
c=(new Date).getTime());n.value=requestAnimationFrame(e)}if(!requestAnimationFrame)return setInterval(a,b);var c=(new Date).getTime(),n={};n.value=requestAnimationFrame(e);return n};a.clearInterval=function(a){a&&(cancelAnimationFrame?cancelAnimationFrame(a.value):clearInterval(a))};a.setTimeout=function(a,b){function e(){(new Date).getTime()-c>=b?a.call():n.value=requestAnimationFrame(e)}if(!requestAnimationFrame)return setTimeout(a,b);var c=(new Date).getTime(),n={};n.value=requestAnimationFrame(e);
return n};a.clearTimeout=function(a){a&&(cancelAnimationFrame?cancelAnimationFrame(a.value):clearTimeout(a))};a.showAbout=function(){var b="<html>\n<head>\n<style>\nbody{ text-align:center; }\niframe{ width:650px; height:73px; overflow:hidden; border:1px solid black; }\ndt{ font-weight:bold; margin-top:10px; }\n</style>\n</head>\n<body>\n<iframe src='http://arquimedes.matem.unam.mx/Descartes5/creditos/bannerPatrocinadores.html'></iframe>\n<h2> <a href='http://proyectodescartes.org/' target='_blank'>ProyectoDescartes.org</a> <br> <a href='http://descartesjs.org' target='_blank'>DescartesJS.org</a> </h2>\n<dl>\n<dt> Dise&ntilde;o funcional:</dt>\n<dd>\n<nobr>Jos&eacute; Luis Abreu Leon,</nobr>\n<nobr>Jos&eacute; R. Galo Sanchez,</nobr>\n<nobr>Juan Madrigal Muga</nobr>\n</dd>\n<dt>Autores del software:</dt>\n<dd>\n<nobr>Jos&eacute; Luis Abreu Leon,</nobr>\n<nobr>Marta Oliver&oacute; Serrat,</nobr>\n<nobr>Oscar Escamilla Gonz&aacute;lez,</nobr>\n<nobr>Joel Espinosa Longi</nobr>\n</dd>\n</dl>\n<p>\nEl software en Java est&aacute; bajo la licencia\n<a href='https://joinup.ec.europa.eu/software/page/eupl/licence-eupl'>EUPL v.1.1 </a>\n<br>\nEl software en JavaScript est&aacute; bajo licencia\n<a href='http://www.gnu.org/licenses/lgpl.html'>LGPL</a>\n</p>\n<p>\nLa documentaci&oacute;n y el c&oacute;digo fuente se encuentran en :\n<br>\n<a href='http://arquimedes.matem.unam.mx/Descartes5/'>http://arquimedes.matem.unam.mx/Descartes5/</a>\n</p>\n";
a.ccLicense&&(b+="<p>\nEste objeto, creado con Descartes, est&aacute; licenciado\npor sus autores como\n<a href='http://creativecommons.org/licenses/by-nc-sa/4.0/'><nobr>Creative Commons</nobr></a>\n<br>\n<a href='http://creativecommons.org/licenses/by-nc-sa/4.0/'><img src='https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png'></a>\n</p>");var b=b+"</body> </html>",e=window.open("","creditos","width=700,height=500,titlebar=0,toolbar=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0");e.document.write(b);
e.document.close()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k,d;a.cacheFiles={};a.openExternalFile=function(f){if(a.cacheFiles[f])return a.cacheFiles[f];k=null;var p=!1;if(window.XMLHttpRequest)try{p=new XMLHttpRequest}catch(c){p=!1}else if(window.ActiveXObject)try{p=new ActiveXObject("Msxml2.XMLHTTP")}catch(c){try{p=new ActiveXObject("Microsoft.XMLHTTP")}catch(h){p=!1}}d=p;d.open("GET",f,!1);try{d.send(null),k=d.responseText,k.match(String.fromCharCode(65533))&&
(d.open("GET",f,!1),d.overrideMimeType("text/plain; charset=ISO-8859-1"),d.send(null),k=d.responseText)}catch(c){console.log("Error to load the file :",f),k=null}return k};a.addExternalFileContent=function(d,k){a.cacheFiles[d]=k};return a}(descartesJS||{}),descartesJS=function(a){function k(a){w=a.indexOf("--radial--");-1!=w&&(a=a.substring(0,w));c=a.trim();a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};c[0]==c[c.length-1]&&"'"==c[0]&&(a.ignoreCaps=!0,c=c.substring(1,c.length-1),"`"==c[0]&&"\u00b4"==
c[c.length-1]&&(a.ignoreAcents=!0,c=c.substring(1,c.length-1)));"`"==c[0]&&"\u00b4"==c[c.length-1]&&(a.ignoreAcents=!0,c=c.substring(1,c.length-1),c[0]==c[c.length-1]&&"'"==c[0]&&(a.ignoreCaps=!0,c=c.substring(1,c.length-1)));"*"===c.charAt(0)&&"*"!==c.charAt(c.length-1)?c=c.substring(1)+"$":"*"!==c.charAt(0)&&"*"===c.charAt(c.length-1)?c="^"+c.substring(0,c.length-1):"*"!==c.charAt(0)&&"*"!==c.charAt(c.length-1)?c="^"+c+"$":"*"===c.charAt(0)&&"*"===c.charAt(c.length-1)&&(c=c.substring(1,c.length-
1));c=c.replace(/\?/g,"[\\S\\s]{1}");a.regExp=c;return a}function d(a,b){c=(a||"").trim();a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};a.expr=c.split(",");a.expr[0]=a.expr[0].trim();a.expr[0]={type:a.expr[0].charAt(0),expr:b.parser.parse(a.expr[0].substring(1))};a.expr[1]=a.expr[1].trim();a.expr[1]={type:a.expr[1].charAt(a.expr[1].length-1),expr:b.parser.parse(a.expr[1].substring(0,a.expr[1].length-1))};return a}function f(a,b,c){b=parseFloat(b);u=a.expr[0];n=a.expr[1];r=c.eval(u.expr);q=c.eval(n.expr);
t="("==u.type;v="["==u.type;e=")"==n.type;m="]"==n.type;return(t&&b>r||v&&b>=r)&&(e&&b<q||m&&b<=q)?1:0}function p(a){return a.toString().replace(/\u00e1/g,"a").replace(/\u00e9/g,"e").replace(/\u00ed/g,"i").replace(/\u00f3/g,"o").replace(/\u00fa/g,"u").replace(/\u00c1/g,"A").replace(/\u00c9/g,"E").replace(/\u00cd/g,"I").replace(/\u00d3/g,"O").replace(/\u00da/g,"U").replace(/\u00f1/g,"n").replace(/\u00d1/g,"N")}if(a.loadLib)return a;var c,h,g,b,u,n,r,q,t,v,e,m,w;a.buildRegularExpresionsPatterns=function(a,
b){a=a||"";"("===a.charAt(0)&&")"===a.charAt(a.length-1)&&-1===a.indexOf(",")&&(a=a.substring(1,a.length-1));a=a.replace(/&squot;/g,"'").replace(/&amp;/g,"&").split("|");for(var e=0,n=a.length;e<n;e++){h=a[e].split("&");g=[];for(var q=0,f=h.length;q<f;q++)c=h[q],-1===c.indexOf(",")||"("!==c.charAt(0)&&"["!==c.charAt(0)||")"!==c.charAt(c.length-1)&&"]"!==c.charAt(c.length-1)?g.push(k(c)):g.push(d(c,b));a[e]=g}return a};a.escorrecto=function(e,c,n,g){n=n||a.externalEvaluator;g=g||a.buildRegularExpresionsPatterns(e,
n);c=p(c);e=0;for(var d=g.length;e<d;e++){h=g[e];b=!0;for(var q=0,m=h.length;q<m;q++)b=h[q].regExp?b&&!!c.match(new RegExp(p(h[q].regExp),"i")):b&&f(h[q],c,n);if(b)return 1}return 0};a.esCorrecto=function(e,n,g,d){g=g||a.externalEvaluator;d=d||a.buildRegularExpresionsPatterns(e,g);e=0;for(var q=d.length;e<q;e++){h=d[e];b=!0;for(var m=0,r=h.length;m<r;m++)(c=h[m].regExp)?(h[m].ignoreAcents&&(n=p(n),c=p(c)),h[m].ignoreCaps&&(n=n.toLowerCase(),c=p(c).toLowerCase()),b=b&&!!n.match(c)):b=b=b&&f(h[m],n,
g);if(b)return 1}return 0};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.getCCLImg=function(){var a=new Image;a.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAAAfCAMAAABUFvrSAAABC1BMVEUAAAC1urSEhYRDREMNDg2EhoR5fHkpKSmRk5EbGxuRlJGVmZQoKShAQEBwcHCTmJNQUVAQEBBgYGCAgIC/v78ODg5QUFDf39/////v7++fn5+Rj49aV1jj4+PIx8cwMDB9f3zW1dUyMTGamJkZGRkNDA12c3SjoaEjHyC6ubkpKikoJSY/OzxoZWaHhoesq6s/NzljX2HPz891cnN4dXbx8fGflpqOh4uenZ0xLS4kJCQoKCjo5+ePj4+1tbUtLS3g3+Cvr6/JyMggICAqKip+e3wfGxyEgYIqJyeYlpd/gX5ubGyMiovLyst6fXmeoJ18f3xdXl2ChYJwcm81NjWWmZYyMzE+Pz6JjIk4KLQtAAACdUlEQVR4AdWVBXvbOhiFj8OcGBp/YU5UZrq0cse83f3/X7IvkS0rKnd8ym/8vFWOCD8u1g/JTxHH4glwEvGkZSSVBiedegCJxJksVLI5XZsvAMVSqQgUypKU7yZKXAFgO67nuY4NoKKJF1D1ieNXsVC+LwEQem23RjJ1VheUNw2HGTB9QeLCjDSaBmm12y1FAATejk8qtU405i6qvVBMVXCHKfQH7B2Oxi1F+JmJ4CxKEooz7A2Hq8xBz0vwI+4jPX0Ly2JlFe4a1hXxqS02NsdCNCQJxFnYWzSXmo2sFKNIHAdwiFPElGzvCCHGrV5EaHdP7BMdiENJpDgGuGSkDiSluEQccIhTgiTtMYBxLyK7f4m/uWYh/mESiuOwuQivWiy68se/RGQjfouYHeNDIZqLivz3xJuJjzRxAg4LMU3xGJzp3w4S11chye4B9QRnJSSLkxOidSH0KgAeYgenvnda76DjH5/WZ13MxGdy8gBt8pg0xeEhxuvnFyE5EOLy8ql4pk8e4BEFPau6vUD8HFUylxuT1uVw1NjVyaXgvNiV5E4xZynaICV9g7xsGuTV+npPErOK2tapy1VMf8gqvnFLy8kLZk1NXgmJaFOj45Q60ZFjFe4iUlyBTWq5HRdnP+gUcSvM60cemxnu4toN8g1RW9q/Zkt/u/jNdYdQ5lvFeGtZ79isHUO+PDbf4xvzYf6gr7k28NGy3uKb052O2byaPiGM3B+QXxz1B3PjIbpqfqNfphndCwo+KSLyb+NfhcBow8qE13/Omu8hPDY1EnxoCY8TGPlszeV/aDGLkITMARpA5f8vofWLrr1+xEpuzgPhj81XdrZiwA3vh8AAAAAASUVORK5CYII=";
return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k=Math.floor,d,f,p,c,h,g,b,u,n,r,q,t,v;a.Color=function(a,b){this.b=this.g=this.r=0;this.a=1;this.evaluator=b;if(a){if(babel[a]&&("net"===babel[a]&&(a="rojo"),a=babel[a],this.r=parseInt("0x"+a.substring(1,3),16),this.g=parseInt("0x"+a.substring(3,5),16),this.b=parseInt("0x"+a.substring(5,7),16),this.colorStr=a,this.getColor=this.getColorStr),6===a.length&&(this.r=parseInt("0x"+a.substring(0,2),16),this.g=parseInt("0x"+
a.substring(2,4),16),this.b=parseInt("0x"+a.substring(4,6),16),this.colorStr="#"+a,this.getColor=this.getColorStr),8===a.length&&(this.r=parseInt("0x"+a.substring(2,4),16),this.g=parseInt("0x"+a.substring(4,6),16),this.b=parseInt("0x"+a.substring(6,8),16),this.a=1-parseInt("0x"+a.substring(0,2),16)/255,this.colorStr="rgba("+this.r+","+this.g+","+this.b+","+this.a+")",this.getColor=this.getColorStr),"("===a[0]){f=[];p=this.splitComa(a.substring(1,a.length-1));for(var n=0,g=p.length;n<g;n++)c=parseInt(p[n],
16),p[n]!=c.toString(16)&&p[n]!=="0"+c.toString(16)?("["===p[n].charAt(0)&&"]"===p[n].charAt(p[n].length-1)&&(p[n]=p[n].substring(1,p[n].length-1)),f.push(this.evaluator.parser.parse(p[n]))):f.push(this.evaluator.parser.parse((c/255).toString()));this.rExpr=f[0];this.gExpr=f[1];this.bExpr=f[2];this.aExpr=f[3];this.getColor=this.getColorExp}}else this.colorStr="rgba("+this.r+","+this.g+","+this.b+","+this.a+")",this.getColor=this.getColorStr};a.Color.prototype.splitComa=function(a){h=[];for(var c=
u=b=g=0,d=a.length;c<d;c++)n=a.charAt(c),"("===n?g++:")"===n?g--:"["===n?b++:"]"===n?b--:","===n&&0===g&&0===b&&(h.push(a.substring(u,c)),u=c+1);h.push(a.substring(u));return h};a.Color.prototype.getColorStr=function(){return this.colorStr};a.Color.prototype.getColorExp=function(){d=this.evaluator;this.r=k(255*d.eval(this.rExpr));this.g=k(255*d.eval(this.gExpr));this.b=k(255*d.eval(this.bExpr));this.a=1-d.eval(this.aExpr);return"rgba("+this.r+","+this.g+","+this.b+","+this.a+")"};a.Color.prototype.borderColor=
function(){return 380>this.r+this.g+this.b?"#ffffff":"#000000"};a.RGBAToHexColor=function(b){b=b.substring(5,b.length-1).split(",");r=parseInt(b[0]).toString(16);q=parseInt(b[1]).toString(16);t=parseInt(b[2]).toString(16);v=(255-parseInt(255*parseFloat(b[3]))).toString(16);r=1==r.length?"0"+r:r;q=1==q.length?"0"+q:q;t=1==t.length?"0"+t:t;v=1==v.length?"0"+v:v;return new a.Color(v+r+q+t)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k=document.head,d=document.createElement("meta");
d.setAttribute("http-equiv","X-UA-Compatible");d.setAttribute("content","IE=edge,chrome=1");k.appendChild(d);d=document.createElement("meta");d.setAttribute("name","viewport");d.setAttribute("content","width=device-width,initial-scale=1.0,user-scalable=yes");document.querySelector("meta[name=viewport]")||k.appendChild(d);d=document.createElement("meta");d.setAttribute("name","apple-mobile-web-app-capable");d.setAttribute("content","yes");k.appendChild(d);d=document.createElement("meta");d.setAttribute("name",
"apple-mobile-web-app-status-bar-style");d.setAttribute("content","black");k.appendChild(d);d=document.createElement("meta");d.setAttribute("name","DescartesJS_author");d.setAttribute("content","Joel Espinosa Longi");k.appendChild(d);(k=document.getElementById("StyleDescartesApps2"))&&k.parentNode.removeChild(k);k=document.createElement("style");k.type="text/css";k.id="StyleDescartesApps2";k.setAttribute("rel","stylesheet");document.head.appendChild(k);k.innerHTML="div.DescartesCatcher{background-color:rgba(255,255,255,0);cursor:pointer;position:absolute;}\ndiv.DescartesAppContainer{border:0 solid black;position:relative;overflow:hidden;top:0;left:0;}\ndiv.DescartesLoader{background-color:#CACACA;position:absolute;overflow:hidden;top:0;left:0;}\ndiv.DescartesLoaderImage{position:absolute;background-repeat:no-repeat;background-position:center;overflow:hidden;top:0;left:0;}\ncanvas.DescartesLoaderBar{position:absolute;overflow:hidden;top:0;left:0;}\ncanvas.DescartesSpace2DCanvas,canvas.DescartesSpace3DCanvas,div.blocker{touch-action:none;position:absolute;overflow:hidden;left:0;top:0;}\ndiv.DescartesSpace2DContainer,div.DescartesSpace3DContainer{position:absolute;overflow:hidden;line-height:0;}\ncanvas.DescartesButton{position:absolute;cursor:pointer;}\ndiv.DescartesButtonContainer{position:absolute;background-repeat:no-repeat;}\ndiv.DescartesSpinnerContainer,div.DescartesTextFieldContainer,div.DescartesMenuContainer{background:lightgray;position:absolute;overflow:hidden;}\ndiv.DescartesSpinnerContainer input,div.DescartesTextFieldContainer input,div.DescartesMenuContainer select{border-radius:0;}\ninput.DescartesSpinnerField,input.DescartesTextFieldField,input.DescartesMenuField,input.DescartesScrollbarField{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;font-family:descartesJS_sansserif,Arial,Helvetica,Sans-serif;padding:0;border:solid #666 1px;position:absolute;top:0;}\nlabel.DescartesSpinnerLabel,label.DescartesMenuLabel,label.DescartesScrollbarLabel,label.DescartesTextFieldLabel{font-family:descartesJS_sansserif,Arial,Helvetica,Sans-serif;font-weight:normal;text-align:center;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;background-color:#e0e4e8;position:absolute;left:0;top:0;}\ndiv.DescartesGraphicControl{touch-action:none;border-style:none;position:absolute;}\ndiv.DescartesTextAreaContainer{position:absolute;overflow:hidden;background:#c0d0d8;}\nselect.DescartesMenuSelect{font-family:descartesJS_sansserif,Arial,Helvetica,Sans-serif;padding-top:0;text-align:center;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;background-color:white;position:absolute;left:0;top:0;}\ndiv.DescartesScrollbarContainer{touch-action:none;background:#eee;overflow:hidden;position:absolute;}";
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k=Math.sin,d=Math.floor,f=Math.random,p=Math.round,c=Math.abs,h=String.fromCharCode,g,b,u,n,r,q,t,v,e,m;a.Krypto=function(a){this.key=(a||0).toString()};a.Krypto.prototype.getKey=function(a){g=[];for(var b=0;256>b;b++)g[b]=h(this.alfanum(d(c(7.5*(k(1*b-a)+k(1.4*b+a)+k(.6*b-a)+k(2.2*b+a))))));return g.join("")};a.Krypto.prototype.encode=function(a){b=d(31*f());this.key=this.getKey(b);return h(this.alfanum(b))+this.encripta(a)};
a.Krypto.prototype.decode=function(a){b=this.numalfa(a.charCodeAt(0));this.key=this.getKey(b);return this.desencripta(a.substring(1))};a.Krypto.prototype.encripta=function(a){return this.bytesToString(this.encriptaAux(this.stringToBytes(a)))};a.Krypto.prototype.encriptaAux=function(a){if(null==a||null==this.key)return null;q=Array(3*a.length);for(var b=0,c=a.length;b<c;b++)e=256*d(a[b]+128)+p(255*f())+65536*p(255*f()),m=d((e<<this.shift(b))/256),q[3*b]=this.alfanum(m%32),q[3*b+1]=this.alfanum(m/32%
32),q[3*b+2]=this.alfanum(m/1024%32);return q};a.Krypto.prototype.desencripta=function(a){return this.bytesToString(this.desencriptaAux(this.stringToBytes(a)))};a.Krypto.prototype.desencriptaAux=function(a){if(null==a||null==this.key)return null;t=Array(a.length/3);for(var b=0,c=t.length;b<c;b++)m=this.numalfa(a[3*b])+32*this.numalfa(a[3*b+1])+1024*this.numalfa(a[3*b+2]),e=d(256*m>>this.shift(b)),v=d(e/256)%256-128,0>v&&(v+=256),t[b]=v;return t};a.Krypto.prototype.alfanum=function(a){a=d(a);return 10>
a?48+a:87+a};a.Krypto.prototype.numalfa=function(a){return 58>a?a-48:a-87};a.Krypto.prototype.stringToBytes=function(a){n=Array(a.length);for(var b=0,e=a.length;b<e;b++)n[b]=a.charCodeAt(b);return n};a.Krypto.prototype.bytesToString=function(a){for(var b=0,e=a.length;b<e;b++)a[b]=h(a[b]);return a.join("")};a.Krypto.prototype.shift=function(a){u=this.key.charCodeAt(a%this.key.length);n=this.numalfa(u);r=d(n/2%8);0==r&&(r=4);return r};a.Krypto.prototype.parseByte=function(a){a=parseInt(a);a=0>a?0:a;
return 255<a?255:a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k=Math.max;a.Animation=function(d,f){this.parent=d;var k=d.evaluator,c=k.parser,h=new a.Auxiliary(d),g=this;g.delay=f.delay?c.parse(f.delay):c.parse("60");g.loop=f.loop?f.loop:!1;g.auto=void 0==f.auto?!0:f.auto;g.controls=f.controls;g.init=h.splitInstructions(c,f.init);g.doExpr=h.splitInstructions(c,f.doExpr);f.whileExpr&&(g.whileExpr=c.parse(f.whileExpr));var b,u=g.doExpr.length;g.animExec=function(){for(b=
0;b<u;b++)k.eval(g.doExpr[b]);g.parent.update();g.playing&&(0<k.eval(g.whileExpr)||g.loop)?g.timer=a.setTimeout(g.animExec,k.eval(g.delay)):(g.stop(),g.pause=!1,g.parent.update())};g.playing=!1;g.auto&&g.play()};a.Animation.prototype.play=function(){this.playing?(this.pause=!0,this.stop()):(this.pause||this.reinit(),this.playing=!0,this.pause=!1,this.timer=a.setTimeout(this.animExec,k(10,this.parent.evaluator.eval(this.delay))))};a.Animation.prototype.stop=function(){this.playing=!1;a.clearTimeout(this.timer)};
a.Animation.prototype.reinit=function(){for(var a=0,f=this.init.length;a<f;a++)this.parent.evaluator.eval(this.init[a])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Action=function(a,d){this.parent=a;this.evaluator=this.parent.evaluator};a.Action.prototype.execute=function(){};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Message=function(k,d){a.Action.call(this,k,d);this.parameter=(d||"").replace(/\\n/g,"\n").replace(/&squot;/g,"'")};a.extend(a.Message,
a.Action);a.Message.prototype.execute=function(){alert(this.parameter)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Calculate=function(k,d){a.Action.call(this,k,d);var f=this.evaluator,p=f.parser;d=(d||"").replace(/&squot;/g,"'");d=d.replace(/;/g,"\\n");d=d.split("\\n")||[""];for(var c=[],h,g=0,b=d.length;g<b;g++)(h=p.parse(d[g],!0))&&c.push(h);b=c.length;this.execute=function(){for(g=0;g<b;g++)f.eval(c[g])}};a.extend(a.Calculate,a.Action);return a}(descartesJS||{}),
descartesJS=function(a){if(a.loadLib)return a;a.OpenURL=function(k,d){a.Action.call(this,k,d);this.parameter=d;this.target="_blank";var f=this.parameter.indexOf("target");-1!=f&&(this.target=this.parameter.substring(f),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,f-1));if("javascript"==this.parameter.substring(0,10)){this.parameter=new a.SimpleText(k,this.parameter.substring(11).replace(/&squot;/g,"'"));var p=this;this.actionExec=function(){try{eval(p.parameter.toString())}catch(a){}}}else"http"!=
this.parameter.substring(0,4)&&(this.parameter=window.location.href.substring(0,window.location.href.lastIndexOf("/")+1)+this.parameter),this.actionExec=function(){window.open(this.parameter,this.target)}};a.extend(a.OpenURL,a.Action);a.OpenURL.prototype.execute=function(){this.actionExec()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.OpenScene=function(k,d){a.Action.call(this,k,d);this.parameter=d;this.target="_blank";var f=this.parameter.indexOf("target");-1!=f&&(this.target=
this.parameter.substring(f),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,f-1));"javascript"==this.parameter.substring(0,10)?(this.parameter=this.parameter.substring(11).replace(/&squot;/g,"'"),this.actionExec=function(){eval(this.parameter)}):("http://"!=this.parameter.substring(0,7)&&(this.parameter=window.location.href.substring(0,window.location.href.lastIndexOf("/")+1)+this.parameter),this.actionExec=function(){window.open(this.parameter,
this.target,"width="+this.parent.width+",height="+this.parent.height+",left="+(window.screen.width-this.parent.width)/2+", top="+(window.screen.height-this.parent.height)/2+"location=0,menubar=0,scrollbars=0,status=0,titlebar=0,toolbar=0")})};a.extend(a.OpenScene,a.Action);a.OpenScene.prototype.execute=function(){this.actionExec()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Config=function(k,d){a.Action.call(this,k,d)};a.extend(a.Config,a.Action);a.Config.prototype.execute=
function(){this.parent.editor?this.parent.editor.show():window.open("about:blank","_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes").document.write("<xmp style='width:100%; height:100%;'><script type='text/javascript' src='http://arquimedes.matem.unam.mx/Descartes5/lib/descartes-min.js'>\x3c/script>\n"+this.parent.applet.outerHTML.replace(/<applet/g,"<ajs").replace(/<\/applet/g,"</ajs")+"</xmp>")};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Init=
function(k,d){a.Action.call(this,k,d)};a.extend(a.Init,a.Action);a.Init.prototype.execute=function(){this.parent.init()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Clear=function(k,d){a.Action.call(this,k,d)};a.extend(a.Clear,a.Action);a.Clear.prototype.execute=function(){this.parent.clear()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Animate=function(k,d){a.Action.call(this,k,d)};a.extend(a.Animate,a.Action);a.Animate.prototype.execute=
function(){this.parent.play()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.InitAnimation=function(k,d){a.Action.call(this,k,d)};a.extend(a.InitAnimation,a.Action);a.InitAnimation.prototype.execute=function(){this.parent.reinitAnimation()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k=/[\w\.\-//]*(\.ogg|\.oga|\.mp3|\.wav)/gi;a.PlayAudio=function(d,f){a.Action.call(this,d,f);f&&f.match(k)?this.filenameExpr=this.evaluator.parser.parse("'"+
f.match(k)+"'"):(""!=f&&"["==f[0]&&"]"==f[f.length-1]&&(f=f.substring(1,f.length-1)),this.filenameExpr=this.evaluator.parser.parse(f))};a.extend(a.PlayAudio,a.Action);a.PlayAudio.prototype.execute=function(){var a=this.theAudio=this.parent.getAudio(this.evaluator.eval(this.filenameExpr));a.paused?a.play():(a.pause(),a.currentTime=0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Auxiliary=function(a,d){this.parent=a;this.evaluator=this.parent.evaluator;this.expresion=
this.id="";this.evaluate="onlyOnce";this.local="";for(var c in d)d.hasOwnProperty(c)&&(this[c]=d[c])};a.Auxiliary.prototype.firstRun=function(){};a.Auxiliary.prototype.update=function(){};var k,d;a.Auxiliary.prototype.splitInstructions=function(a,p){d=[];p=p?p.split(";"):[""];for(var c=0,h=p.length;c<h;c++)(k=a.parse(p[c],!0))&&d.push(k);return d};a.Auxiliary.prototype.getPrivateVariables=function(a,p){d=[];p=p?p.split(/;|,/):[""];for(var c=0,h=p.length;c<h;c++)(k=a.parse(p[c],!0))&&d.push(k);c=0;
for(h=d.length;c<h;c++)d[c]="asign"===d[c].type?d[c].childs[0].value:"identifier"===d[c].type?d[c].value:"";return d};a.Auxiliary.prototype.parseExpressions=function(a){this.init=this.splitInstructions(a,this.init);this.privateVars=this.getPrivateVariables(a,this.local);this.doExpr=this.splitInstructions(a,this.doExpr);this.whileExpr=a.parse(this.whileExpr)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Variable=function(k,d){a.Auxiliary.call(this,k,d);var f=this.evaluator.parser;
this.expresionString=this.expresion;(this.expresion=f.parse(this.expresionString))&&f.setVariable(this.id,this.expresion);this.editable&&(this.registerTextField(),this.parent.editableRegionVisible=!0)};a.extend(a.Variable,a.Auxiliary);a.Variable.prototype.registerTextField=function(){var a=document.createElement("div"),d=document.createElement("label");d.appendChild(document.createTextNode("___"+this.id+"=___"));var f=document.createElement("input");f.value=this.expresionString;f.disabled=!this.editable;
a.appendChild(d);a.appendChild(f);var p=this,c=p.evaluator.parser;f.onkeydown=function(a){13==a.keyCode&&(p.expresion=c.parse(this.value),c.setVariable(p.id,p.expresion),p.parent.update())};this.parent.editableRegion.textFields.push({container:a,type:"div"})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Constant=function(k,d){a.Auxiliary.call(this,k,d);this.expresion=this.evaluator.parser.parse(this.expresion);this.update()};a.extend(a.Constant,a.Auxiliary);a.Constant.prototype.update=
function(){this.evaluator.setVariable(this.id,this.evaluator.eval(this.expresion))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k,d,f;a.Vector=function(f,c){k=f.evaluator;d=k.parser;this.size=d.parse("3");a.Auxiliary.call(this,f,c);this.expresion=this.expresion.split(";");this.parseFile=d.parse(this.file);this.update()};a.extend(a.Vector,a.Auxiliary);a.Vector.prototype.update=function(){var p=this.expresion;k=this.evaluator;d=k.parser;this.oldFile=this.file;if(f=k.eval(this.parseFile))this.file=
f;var c;if(this.file){c=(vectorElement=document.getElementById(this.file))&&"descartes/vectorFile"==vectorElement.type?vectorElement.text:a.openExternalFile(this.file);if(null!=c){c=c.replace(/\r/g,"").split("\n");for(var h=[],g=0,b=c.length;g<b;g++)""!=c[g]&&h.push(c[g]);c=h}null==c||1==c.length&&""==c[0]?this.size=d.parse("0"):(p=c,this.size=null);null===this.size&&(this.size=d.parse(p.length+""))}c=[];g=0;for(b=p.length;g<b;g++)(h=d.parse(p[g],!0))&&"asign"!=h.type&&(h=d.parse(this.id+"["+g+"]="+
p[g],!0)),c.push(h);p=[];p._size_=k.eval(this.size);g=0;for(b=this._size_;g<b;g++)p.push(0);k.vectors[this.id]=p;k.setVariable(this.id+".long",p._size_);g=0;for(b=c.length;g<b;g++)k.eval(c[g])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Matrix=function(k,d){var f=k.evaluator,p=f.parser;this.rows=p.parse("3");this.columns=p.parse("3");a.Auxiliary.call(this,k,d);this.expresion=this.splitInstructions(p,this.expresion);var p=f.eval(this.rows),c=f.eval(this.columns),h=[];
h.type="matrix";for(var g,b=0;b<c;b++){g=[];for(var u=0,n=p;u<n;u++)g.push(0);h[b]=g}f.matrices[this.id]=h;this.update()};a.extend(a.Matrix,a.Auxiliary);a.Matrix.prototype.update=function(){var a=this.evaluator,d=a.eval(this.rows),f=a.eval(this.columns);a.setVariable(this.id+".filas",d);a.setVariable(this.id+".columnas",f);var p=a.matrices[this.id];p.rows=d;p.cols=f;d=0;for(f=this.expresion.length;d<f;d++)a.eval(this.expresion[d])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
a.Function=function(k,d){a.Auxiliary.call(this,k,d);var f=this.evaluator,p=f.parser,c=this.id.indexOf("(");this.name=this.id.substring(0,c);this.params=this.id.substring(c+1,this.id.indexOf(")"));this.domain=this.range?p.parse(this.range):p.parse("1");this.params=""==this.params?[]:this.params.split(",");this.numberOfParams=this.params.length;this.algorithm||(this.whileExpr=this.doExpr=this.init="");this.parseExpressions(p);this.expresion=p.parse(this.expresion);var h=this;this.functionExec=function(){this.iterations=
0;if(h.numberOfParams<=arguments.length){for(var c=[],b=0,d=h.privateVars.length;b<d;b++)c.push(f.getVariable(h.privateVars[b])),f.setVariable(h.privateVars[b],0);for(var n=[],b=0,d=h.params.length;b<d;b++)n[b]=f.getVariable(h.params[b])||0,f.setVariable(h.params[b],arguments[b]);b=0;for(d=h.init.length;b<d;b++)f.eval(h.init[b]);do{b=0;for(d=h.doExpr.length;b<d;b++)f.eval(h.doExpr[b]);if(1E5<++this.iterations)return console.log("se ha excedido el l\u00edmite de 100000 repeticiones en la funci\u00f3n << "+
h.name+" >>"),0}while(0<f.eval(h.whileExpr));var r=f.eval(h.expresion);a.rangeOK=f.eval(h.domain);b=0;for(d=h.params.length;b<d;b++)f.setVariable(h.params[b],n[b]);b=0;for(d=h.privateVars.length;b<d;b++)f.setVariable(h.privateVars[b],c[b]);return r}return 0};f.setFunction(this.name,this.functionExec)};a.extend(a.Function,a.Auxiliary);return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Algorithm=function(k,d){a.Auxiliary.call(this,k,d);var f=this.evaluator;this.parseExpressions(f.parser);
this.algorithmExec=function(){for(var a=this.iterations=0,c=this.init.length;a<c;a++)f.eval(this.init[a]);do{a=0;for(c=this.doExpr.length;a<c;a++)f.eval(this.doExpr[a]);if(1E5<++this.iterations)return console.log("se ha excedido el l\u00edmite de 100000 repeticiones en el algoritmo << "+self.name+" >>"),0}while(0<f.eval(this.whileExpr))}};a.extend(a.Algorithm,a.Auxiliary);a.Algorithm.prototype.update=function(){this.algorithmExec();"onlyOnce"===this.evaluate&&(this.update=function(){})};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;a.Event=function(k,d){a.Auxiliary.call(this,k,d);var f=this.evaluator;delete this.evaluate;this.condition=f.parser.parse(this.condition);this.lastEvaluation=!1;this.action=this.parent.lessonParser.parseAction(this);"onlyOnce"==this.execution&&(this.eventExec=function(){0<this.evaluator.eval(this.condition)&&!this.lastEvaluation&&(this.lastEvaluation=!0,this.action.execute())});"alternate"==this.execution&&(this.eventExec=function(){var a=0<this.evaluator.eval(this.condition);
3==this.parent.version?a!=this.lastEvaluation&&(this.action.execute(),this.lastEvaluation=a?!0:!1):a&&!this.lastEvaluation?(this.action.execute(),this.lastEvaluation=!0):!a&&this.lastEvaluation&&(this.lastEvaluation=!1)});"always"==this.execution&&(this.eventExec=function(){0<this.evaluator.eval(this.condition)&&this.action.execute()})};a.extend(a.Event,a.Auxiliary);a.Event.prototype.update=function(){this.eventExec()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k,
d,f,p,c;a.Graphic=function(c,g){this.parent=c;this.evaluator=c.evaluator;var b=this.evaluator.parser;this.spaceID="";this.background=!1;this.type="";this.drawif=b.parse("1");this.abs_coord=!1;this.color=new a.Color("blue");2!==this.parent.version&&(this.color=new a.Color("20303a"),this.parent.arquimedes&&(this.color=new a.Color("black")));this.trace="";this.expresion=b.parse("(0,0)");this.family="";this.family_interval=b.parse("[0,1]");this.family_steps=b.parse("8");this.editable=!1;this.font="Monospaced,PLAIN,"+
(5<=this.parent.version?"15":"12");this.fixed=!0;this.text="";this.decimals=b.parse("2");for(var d in g)g.hasOwnProperty(d)&&(this[d]=g[d]);this.space=this.getSpace();this.canvas=this.background?this.space.backCanvas:this.space.canvas;this.ctx=this.canvas.getContext("2d");this.trace&&(this.traceCtx=this.space.backCtx);this.font=a.convertFont(this.font);this.fontSize=(this.fontSize=this.font.match(/([\d\.]+)px/))?parseFloat(this.fontSize[1]):10};a.Graphic.prototype.getSpace=function(){for(var a=this.parent.spaces,
c,b=0,d=a.length;b<d;b++)if(c=a[b],c.id==this.spaceID)return c;return a[0]};a.Graphic.prototype.getFamilyValues=function(){k=this.evaluator;d=k.eval(this.family_interval);this.familyInf=d[0][0];this.familySup=d[0][1];this.fSteps=Math.round(k.eval(this.family_steps));this.family_sep=0<this.fSteps?(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic.prototype.drawFamilyAux=function(a,c,b){k=this.evaluator;this.getFamilyValues();f=k.getVariable(this.family);if(0<=this.fSteps)for(var d=0,n=this.fSteps;d<=
n;d++)k.setVariable(this.family,this.familyInf+d*this.family_sep),0<k.eval(this.drawif)&&(this.update(),this.drawAux(a,c,b));k.setVariable("_Text_H_",0);k.setVariable(this.family,f)};a.Graphic.prototype.draw=function(a,c){""!=this.family?this.drawFamilyAux(this.ctx,a,c):0<this.evaluator.eval(this.drawif)&&(this.update(),this.drawAux(this.ctx,a,c))};a.Graphic.prototype.drawTrace=function(a,c){""!=this.family?this.drawFamilyAux(this.traceCtx,a,c):0<this.evaluator.eval(this.drawif)&&(this.update(),this.drawAux(this.traceCtx,
a,c))};a.Graphic.prototype.drawText=function(a,d,b,f,n,r,q,t,v,e,m){if("rtfNode"===d.type)a.fillStyle=n.getColor(),a.strokeStyle=n.getColor(),a.textBaseline="alphabetic",d.draw(a,b,f+1,v,e,q,m,n.getColor());else for("simpleText"===d.type&&(d=d.toString(v,e).split("\\n")),b+=/Arial|Times/i.test(r)?-2:0,k=this.evaluator,a.fillStyle=n.getColor(),a.font=r,a.textAlign=q,a.textBaseline=t,this.border&&(a.strokeStyle=this.border.getColor(),a.lineWidth=4),c=1.2*this.fontSize||0,n=0,r=d.length;n<r;n++)p=d[n],
this.border&&(a.lineJoin="round",a.miterLimit=2,a.strokeText(p,b,f+c*n)),a.fillText(p,b,f+c*n)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.SimpleText=function(a,d){this.text=d=d.replace("&#x2013","\u2013").replace(/\&squot;/g,"'");this.textElements=[];this.textElementsMacros=[];this.parent=a;this.evaluator=a.evaluator;this.type="simpleText";for(var c="'",h=0,g=0,b=-1,k,n;h<d.length;)k=d.charAt(h),n=d.charAt(h-1),"["===k&&"\\"===n?(this.textElements.push(d.substring(g,
h-1)+"["),this.textElementsMacros.push("'"+d.substring(g,h-1)+"['"),g=h+1):"]"===k&&"\\"===n?(this.textElements.push(d.substring(g,h-1)+"]"),this.textElementsMacros.push("'"+d.substring(g,h-1)+"]'"),g=h+1):"["===k&&-1===b?(this.textElements.push(d.substring(g,h)),this.textElementsMacros.push("'"+d.substring(g,h)+"'"),g=h,b++):"["===k?b++:"]"===k&&0===b?(this.textElements.push(this.evaluator.parser.parse(d.substring(g,h+1))),this.textElementsMacros.push("["+d.substring(g,h+1)+"]"),g=h+1,b--):("]"==
d.charAt(h)&&(b=0>b?b:b-1),c+=d.charAt(h)),h++;this.textElements.push(d.substring(g,h));this.textElementsMacros.push("'"+d.substring(g,h)+"'")};var k,d;a.SimpleText.prototype.toString=function(f,p){k="";for(var c=0,h=this.textElements.length;c<h;c++)"string"===typeof this.textElements[c]?k+=this.textElements[c]:(d=this.evaluator.eval(this.textElements[c])[0][0],""!==d&&("string"===typeof d?k+=d:(d=parseFloat(d),d=p?d.toFixed(f):a.removeNeedlessDecimals(d.toFixed(f)),k+=d.toString().replace(".",this.parent.decimal_symbol))));
return k};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k,d,f,p,c,h,g,b,u,n,r,q,t,v,e,m,w,l,x,A,D,B,E,G,F,J,C;a._debug_vez=0;a.Equation=function(b,c){this.width=b.evaluator.parser.parse("1");this.fillM=this.fillP="";a.Graphic.call(this,b,c);this.parseExpression();(this.visible=2===this.parent.version&&void 0==this.visible?!0:this.visible)&&this.registerTextField();q=new a.R2;t=new a.R2;v=new a.R2;w=new a.R2;e=new a.R2;this.cInd=0};a.extend(a.Equation,a.Graphic);a.Equation.prototype.parseExpression=
function(){if("compOperator"===this.expresion.type){var b=this.expresion.childs[0],e=this.expresion.childs[1];"identifier"!=b.type||"y"!=b.value||e.contains("y")?"identifier"!=e.type||"y"!=e.value||b.contains("y")?"identifier"!=b.type||"x"!=b.value||e.contains("x")?"identifier"!=e.type||"x"!=e.value||b.contains("x")||(this.funExpr=e,this.of_y=!0,this.drawAux=this.drawAuxFun):(this.funExpr=e,this.of_y=!0,this.drawAux=this.drawAuxFun):(this.funExpr=b,this.of_y=!1,this.drawAux=this.drawAuxFun):(this.funExpr=
e,this.of_y=!1,this.drawAux=this.drawAuxFun)}this.newt=new a.R2Newton(this.evaluator,this.expresion)};a.Equation.prototype.update=function(){};a.Equation.prototype.draw=function(){""!=this.family?this.drawFamilyAux(this.ctx,this.fill,this.color):(this.update(),this.drawAux(this.ctx,this.fill,this.color))};a.Equation.prototype.drawFamilyAux=function(a,b,e){d=this.evaluator;this.getFamilyValues();tempParam=d.getVariable(this.family);if(0<=this.fSteps)for(var c=0,n=this.fSteps;c<=n;c++)d.setVariable(this.family,
this.familyInf+c*this.family_sep),this.update(),this.drawAux(a,b,e);d.setVariable(this.family,tempParam)};a.Equation.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,this.trace)};var z,I,H,M,y,L,K;a.Equation.prototype.drawAux=function(N,T,O){if(!(0>=this.evaluator.eval(this.drawif))){d=this.evaluator;f=d.parser;p=this.space;c=d.eval(this.width);N.strokeStyle=this.color.getColor();N.lineWidth=c;h=f.getVariable("x");g=f.getVariable("y");b=p.w+24;u=p.h+24;n=b/9;3>n&&(n=3);r=u/7;
3>r&&(r=3);0==this.cInd?(k=[],this.cInd++):this.cInd=(this.cInd+1)%1E5;q.set(0,0);t.set(0,0);v.set(0,0);L=.25;K=8;this.abs_coord||(L/=p.scale,K/=p.scale);N.beginPath();for(C=parseInt(r/2);C<u;C+=r)for(J=parseInt(n/2);J<b;J+=n){if(this.abs_coord){w.set(J,C);m=this.newt.findZero(w,L);if(null==m)continue;d.setVariable("x",m.x);d.setVariable("y",m.y);e.set(m.x,m.y)}else{w.set(p.getRelativeX(J),p.getRelativeY(C));m=this.newt.findZero(w,L);if(null==m)continue;d.setVariable("x",m.x);d.setVariable("y",m.y);
e.set(p.getAbsoluteX(m.x),p.getAbsoluteY(m.y))}l=e.ix();x=e.iy();if(-12<=l&&l<b+24&&-12<=x&&x<u+24){if(k[l+12+(x+12)*p.w]===this.cInd)continue;k[l+12+(x+12)*p.w]=this.cInd}a.rangeOK&&(N.moveTo(l,x),N.lineTo(l,x));q.x=m.x;q.y=m.y;t.x=m.x;t.y=m.y;A=this.newt.getUnitNormal();if(0!=A.x||0!=A.y)for(A.rotL90(),v.x=A.x,v.y=A.y,B=D=0,E=!1;2>B;)if(E&&(v.x=-A.x,v.y=-A.y,m.x=q.x,m.y=q.y,t.x=m.x,t.y=m.y,this.abs_coord?e.set(m.x,m.y):e.set(p.getAbsoluteX(m.x),p.getAbsoluteY(m.y)),l=e.ix(),x=e.iy(),E=!1,D=0),m.x+=
K*v.x,m.y+=K*v.y,m=this.newt.findZero(m,L),null!=m){d.setVariable("x",m.x);d.setVariable("y",m.y);v.x=m.x-t.x;v.y=m.y-t.y;v.normalize();if(0==v.x&&0==v.y)break;t.x=m.x;t.y=m.y;this.abs_coord?e.set(m.x,m.y):e.set(p.getAbsoluteX(m.x),p.getAbsoluteY(m.y));G=parseInt(e.ix());F=parseInt(e.iy());if(G!=l||F!=x)if(z=l,I=x,l=G,x=F,-12<=l&&l<b+24&&-12<=x&&x<u+24){D=0;H=k[l+12+(x+12)*p.w];k[l+12+(x+12)*p.w]=this.cInd;for(T=1;8>T;T++)M=z+Math.round((l-z)*T/8),y=I+Math.round((x-I)*T/8),0<=M&&M<b&&0<=y&&y<u&&(k[M+
12+(y+12)*p.w]=this.cInd);a.rangeOK&&(N.moveTo(z,I),N.lineTo(l,x));if(H===this.cInd)break}else E=!0,B++;else 4<++D&&(E=!0,B++)}}N.stroke()}};a.Equation.prototype.X=function(a,b,e){e||(b=this.space.w/2+this.space.Ox+this.space.scale*b);b<-a&&(b=-a);b>this.space.w+a&&(b=this.space.w+a);return b};a.Equation.prototype.Y=function(a,b,e){e||(b=this.space.h/2+this.space.Oy-this.space.scale*b);b<-a&&(b=-a);b>this.space.h+a&&(b=this.space.h+a);return b};a.Equation.prototype.XX=function(a,b,e){return Math.round(this.X(a,
b,e))};a.Equation.prototype.YY=function(a,b,e){return Math.round(this.Y(a,b,e))};a.Equation.prototype.extrapolate=function(b,e,c,n,d,g){for(var q=this.evaluator.getVariable(e),f=g/2,h=0,l,m,r,k,t,v;1E-15<Math.abs(f);){l=this.evaluator.getVariable(e);m=this.evaluator.getVariable(e)+f;this.evaluator.setVariable(e,m);r=!0;try{k=d,d=this.evaluator.eval(this.funExpr),this.evaluator.setVariable(c,d),0<this.evaluator.eval(b)?(t=new a.R2(Math.min(k,d),Math.max(k,d)),v=0,v=0<g?this.Singularity(Math.abs(f),
e,n,l,k,m,d,t):this.Singularity(Math.abs(f),e,n,m,d,l,k,t),0<v&&(r=!1)):r=!1}catch(u){r=!1}r?h+=f:this.evaluator.setVariable(e,l);f/=2}this.evaluator.setVariable(e,q);return new a.R2(h/Math.abs(g),d)};a.Equation.prototype.extrapolateOnSingularity=function(b,e,c,n,d,g){n=this.evaluator.getVariable(e);for(var q=g/2,f=0,h=d,l;1E-15<Math.abs(q);){this.evaluator.setVariable(e,this.evaluator.getVariable(e)+q);l=!0;if(0<this.evaluator.eval(b))try{h=this.evaluator.eval(this.funExpr),this.evaluator.setVariable(c,
h),0>=this.evaluator.eval(b)&&(l=!1)}catch(m){l=!1}else l=!1;l?f+=q:this.evaluator.setVariable(e,this.evaluator.getVariable(e)-q);q/=2}if(0==f)for(q=g/2,f=g,h=d;1E-15<Math.abs(q);){this.evaluator.setVariable(e,this.evaluator.getVariable(e)-q);l=!0;if(0<this.evaluator.eval(b))try{h=this.evaluator.eval(this.funExpr)}catch(m){l=!1}else l=!1;l?f+=-q:this.evaluator.setVariable(e,this.evaluator.getVariable(e)+q);q/=2}this.evaluator.setVariable(e,n);return new a.R2(f/Math.abs(g),h)};a.Equation.prototype.Singularity=
function(a,b,e,c,n,d,g,q){if(isNaN(g)||isNaN(n)||isNaN(q.y)||isNaN(q.x)||c>=d)return 2;var f=this.evaluator.getVariable(b),h=0;try{if(1E-15>Math.abs(d-c)||1E-12>Math.abs(d-c)&&Math.abs(g-n)>Math.abs(a))return this.evaluator.setVariable(b,f),1;var l=(c+d)/2;this.evaluator.setVariable(b,l);var m=NaN;try{m=this.evaluator.eval(this.funExpr)}catch(r){return 2}if(isNaN(m))return 2;if(Math.abs(g-n)>a){this.evaluator.setVariable(b,c-1E-12);var k=this.evaluator.eval(this.funExpr),k=(n-k)/1E-12;this.evaluator.setVariable(b,
d+1E-12);var t=(this.evaluator.eval(this.funExpr)-g)/1E-12;if((10>Math.abs(t)||10>Math.abs(k))&&(0<=t&&0<=k||0>=t&&0>=k)&&4*Math.abs(t)<Math.abs((g-n)/(d-c)))return this.evaluator.setVariable(b,f),2}if(isNaN(q.x)||isNaN(q.y)||isNaN(m))return 2;if(!(q.x<=m&&m<=q.y)){this.evaluator.setVariable(b,l);q.x=Math.min(n,m);q.y=Math.max(n,m);var v=this.Singularity(a/2,b,e,c,n,l,m,q);this.evaluator.setVariable(b,d);q.x=Math.min(g,m);q.y=Math.max(g,m);var u=this.Singularity(a/2,b,e,l,m,d,g,q),h=Math.max(v,u)}}catch(r){h=
1}this.evaluator.setVariable(b,f);return h};a.Equation.prototype.drawAuxFun=function(b,e,c){h=this.evaluator.parser.getVariable("x");g=this.evaluator.parser.getVariable("y");a.rangeOK=1;e="x";c="y";this.of_y&&(e="y",c="x");var n=this.drawif,d=this.evaluator.eval(this.width),q=!1,f=new a.R2(this.space.w/2+this.space.Ox,this.space.h/2+this.space.Oy),f=this.of_y?f.ix():f.iy(),l=0,m=0,r=0,k=0,t=1/this.space.scale,v=t*(this.of_y?Math.ceil(-this.space.h+(this.space.h/2+this.space.Oy)):-Math.ceil(this.space.w/
2+this.space.Ox)),u=0;this.abs_coord&&(v=0,t=1);for(var p,y,x,w,D,z,A,L,B,C=this.of_y?this.space.h+4:this.space.w+4;r<=C;){p=!0;y=0;this.evaluator.setVariable(e,v);try{x=this.evaluator.eval(this.funExpr),isNaN(x)||(this.evaluator.setVariable(c,x),0<this.evaluator.eval(this.drawif)&&a.rangeOK?(q?(w=Math.min(u,x),D=Math.max(u,x),z=new a.R2(w,D),y=this.Singularity(t,e,0,v-t,u,v,x,z),0===y?(u<=x?(u=z.x,x=z.y):(x=z.x,u=z.y),A=parseInt(this.of_y?this.XX(d,u,this.abs_coord):this.YY(d,u,this.abs_coord)),
l=this.abs_coord?Math.round(x):parseInt(this.of_y?this.XX(d,x,this.abs_coord):this.YY(d,x,this.abs_coord)),this.fillM&&l>f&&(b.lineWidth=1,b.strokeStyle=this.fillM.getColor(),b.beginPath(),this.of_y?(b.moveTo(f+1,this.space.h-r+.5),b.lineTo(l,this.space.h-r+.5)):(b.moveTo(r+.5,f+1),b.lineTo(r+.5,l)),b.stroke()),this.fillP&&l<f&&(b.lineWidth=1,b.strokeStyle=this.fillP.getColor(),b.beginPath(),this.of_y?(b.moveTo(f-1,this.space.h-r+.5),b.lineTo(l,this.space.h-r+.5)):(b.moveTo(r+.5,f-1),b.lineTo(r+.5,
l)),b.stroke()),b.lineWidth=d,b.strokeStyle=this.color.getColor(),b.beginPath(),this.of_y?(b.moveTo(A+.5,this.space.h-k),b.lineTo(l+.5,this.space.h-r)):(b.moveTo(k+.5,A),b.lineTo(r+.5,l))):1===y?(this.evaluator.setVariable(e,v-t),L=this.extrapolate(n,e,c,0,u,t),l=parseInt(this.of_y?this.XX(d,L.y,this.abs_coord):this.YY(d,L.y,this.abs_coord)),b.lineWidth=d,b.strokeStyle=this.color.getColor(),b.beginPath(),this.of_y?(b.moveTo(m+.5,this.space.h-k),b.lineTo(l+.5,this.space.h-k+Math.round(L.x))):(b.moveTo(k+
.5,m),b.lineTo(k+Math.round(L.x)+.5,l)),this.evaluator.setVariable(e,v),B=this.extrapolate(n,e,c,0,x,-t),m=this.YY(d,B.y,this.abs_coord),l=this.YY(d,x,this.abs_coord),b.lineWidth=d,b.strokeStyle=this.color.getColor(),b.beginPath(),this.of_y?(b.moveTo(m+.5,this.space.h-r),b.lineTo(l+.5,this.space.h-r)):(b.moveTo(r+.5,m),b.lineTo(r+.5,l))):(l=parseInt(this.of_y?this.XX(d,x,this.abs_coord):this.YY(d,x,this.abs_coord)),b.lineWidth=d,b.strokeStyle=this.color.getColor(),b.beginPath(),this.of_y?(b.moveTo(l+
.5,this.space.h-r),b.lineTo(l+.5,this.space.h-r)):(b.moveTo(r+.5,l),b.lineTo(r+.5,l)))):(B=this.extrapolateOnSingularity(n,e,c,0,x,-t),m=this.of_y?this.XX(d,B.y,this.abs_coord):this.YY(d,B.y,this.abs_coord),l=parseInt(this.of_y?this.XX(d,x,this.abs_coord):this.YY(d,x,this.abs_coord)),b.lineWidth=d,b.strokeStyle=this.color.getColor(),b.beginPath(),this.of_y?(b.moveTo(m,this.space.h-(r+Math.round(B.x))+.5),b.lineTo(l,this.space.h-r+.5)):(b.moveTo(r+Math.round(B.x),m),b.lineTo(r,l))),b.stroke(),u=x):
p=!1)}catch(G){p=!1}q&&!p&&(this.evaluator.setVariable(e,v-t),this.evaluator.setVariable(c,u),L=this.extrapolate(n,e,c,0,u,t),l=parseInt(this.of_y?this.XX(d,L.y,this.abs_coord):this.YY(d,L.y,this.abs_coord)),0<this.evaluator.eval(this.drawif)&&a.rangeOK&&(b.lineWidth=d,b.strokeStyle=this.color.getColor(),b.beginPath(),this.of_y?(b.moveTo(m,this.space.h-(k+Math.round(L.x))+.5),b.lineTo(l,this.space.h-(k+Math.round(L.x))+.5)):(b.moveTo(k+Math.round(L.x)+.5,m),b.lineTo(k+Math.round(L.x)+.5,l)),b.stroke()),
this.evaluator.setVariable(e,v));q=p;v+=t;m=l;k=r++}this.evaluator.parser.setVariable("x",h);this.evaluator.parser.setVariable("y",g)};a.Equation.prototype.registerTextField=function(){var a=document.createElement("input");a.value=this.expresionString;a.disabled=!this.editable;var b=this;a.onkeydown=function(a){13==a.keyCode&&(b.expresion=b.evaluator.parser.parse(this.value),b.parseExpression(),b.parent.update())};this.parent.editableRegion.textFields.push(a)};return a}(descartesJS||{}),descartesJS=
function(a){if(a.loadLib)return a;var k=Math.round,d,f,p,c,h,g,b,u,n,r,q;a.Curve=function(b,c){this.parameter="t";this.parameter_interval=b.evaluator.parser.parse("[0,1]");this.parameter_steps=b.evaluator.parser.parse("8");this.width=b.evaluator.parser.parse("1");this.fill="";a.Graphic.call(this,b,c);(this.visible=2==this.parent.version&&void 0==this.visible)&&this.registerTextField()};a.extend(a.Curve,a.Graphic);a.Curve.prototype.update=function(){d=this.evaluator;f=d.eval(this.parameter_interval);
this.paraInf=f[0][0];this.paraSup=f[0][1];this.pSteps=d.eval(this.parameter_steps);this.paraSep=0<this.pSteps?Math.abs(this.paraSup-this.paraInf)/this.pSteps:0};a.Curve.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};a.Curve.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,this.trace)};a.Curve.prototype.drawAux=function(f,v,e){d=this.evaluator;p=this.space;c=k(d.eval(this.width));f.lineWidth=0<c?c:1E-6;f.lineCap="round";f.lineJoin="round";f.strokeStyle=
e.getColor();h=d.getVariable(this.parameter);f.beginPath();d.setVariable(this.parameter,this.paraInf);g=d.eval(this.expresion);this.exprX=k(this.abs_coord?g[0][0]:p.getAbsoluteX(g[0][0]));this.exprY=k(this.abs_coord?g[0][1]:p.getAbsoluteY(g[0][1]));this.rotateExp&&(b=a.degToRad(d.eval(this.rotateExp)),u=Math.cos(b),n=Math.sin(b),r=this.exprX*u-this.exprY*n,q=this.exprX*n+this.exprY*u,this.exprX=r,this.exprY=q);f.moveTo(this.exprX+.5,this.exprY+.5);for(e=1;e<=this.pSteps;e++)d.setVariable(this.parameter,
this.paraInf+e*this.paraSep),g=d.eval(this.expresion),this.exprX=this.abs_coord?k(g[0][0]):k(p.getAbsoluteX(g[0][0])),this.exprY=this.abs_coord?k(g[0][1]):k(p.getAbsoluteY(g[0][1])),this.rotateExp&&(r=this.exprX*u-this.exprY*n,q=this.exprX*n+this.exprY*u,this.exprX=r,this.exprY=q),f.lineTo(this.exprX+.5,this.exprY+.5);this.fill&&(f.fillStyle=v.getColor(),f.fill("evenodd"));f.stroke();d.setVariable(this.parameter,h)};a.Curve.prototype.registerTextField=function(){var a=document.createElement("input");
a.value=this.expresionString;a.disabled=!this.editable;var b=this;a.onkeydown=function(a){13==a.keyCode&&(b.expresion=b.evaluator.parser.parse(this.value),b.parent.update())};this.parent.editableRegion.textFields.push(a)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k=2*Math.PI,d=Math.round,f,p,c,h,g,b,u,n,r,q,t,v,e,m;a.Sequence=function(b,e){this.size=b.evaluator.parser.parse("2");this.range=b.evaluator.parser.parse("[1, 100]");a.Graphic.call(this,b,e)};a.extend(a.Sequence,
a.Graphic);a.Sequence.prototype.update=function(){f=this.evaluator;c=f.eval(this.expresion);this.exprX=c[0][0];this.exprY=c[0][1];this.rotateExp&&(h=a.degToRad(f.eval(this.rotateExp)),g=Math.cos(h),b=Math.sin(h),u=this.exprX*g-this.exprY*b,n=this.exprX*b+this.exprY*g,this.exprX=u,this.exprY=n);t=f.eval(this.range);this.rangeInf=t[0][0];this.rangeMax=t[0][1]};a.Sequence.prototype.draw=function(){this.uber.draw.call(this,this.color,this.color)};a.Sequence.prototype.drawTrace=function(){this.uber.drawTrace.call(this,
this.trace,this.trace)};a.Sequence.prototype.drawAux=function(a,b){f=this.evaluator;p=this.space;e=v=Math.ceil(f.eval(this.size)-.4);a.fillStyle=b.getColor();a.beginPath();this.rangeInf>this.rangeMax&&(m=this.rangeInf,this.rangeInf=this.rangeMax,this.rangeMax=m);for(var n=f.getVariable("n"),g=this.rangeInf,h=this.rangeMax;g<=h;g++)f.setVariable("n",g),c=f.eval(this.expresion),this.exprX=c[0][0],this.exprY=c[0][1],r=d(this.abs_coord?this.exprX:p.getAbsoluteX(this.exprX)),q=d(this.abs_coord?this.exprY:
p.getAbsoluteY(this.exprY)),a.beginPath(),a.arc(r,q,v,0,k,!0),a.fill();a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,r+e,q-e,this.color,this.font,"start","alphabetic",f.eval(this.decimals),this.fixed,!0);f.setVariable("n",n)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k=2*Math.PI,d=Math.round,f,p,c,h,g,b,u,n,r,q,t,v;a.Point=function(b,c){this.size=b.evaluator.parser.parse("2");a.Graphic.call(this,b,c)};a.extend(a.Point,a.Graphic);a.Point.prototype.update=
function(){f=this.evaluator;c=f.eval(this.expresion);this.exprX=c[0][0];this.exprY=c[0][1];this.rotateExp&&(h=a.degToRad(f.eval(this.rotateExp)),g=Math.cos(h),b=Math.sin(h),u=this.exprX*g-this.exprY*b,n=this.exprX*b+this.exprY*g,this.exprX=u,this.exprY=n)};a.Point.prototype.draw=function(){this.uber.draw.call(this,this.color,this.color)};a.Point.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Point.prototype.drawAux=function(a,b){f=this.evaluator;p=this.space;
t=d(f.eval(this.size));v=t+1;a.fillStyle=b.getColor();r=d(this.abs_coord?this.exprX:p.getAbsoluteX(this.exprX));q=d(this.abs_coord?this.exprY:p.getAbsoluteY(this.exprY));a.beginPath();a.arc(r,q,t,0,k,!0);a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,r+v+1,q-v,this.color,this.font,"start","alphabetic",f.eval(this.decimals),this.fixed,!0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k=Math.round,d=2*Math.PI,f,p,c,h,g,b,u,n,r,q,t,v,e,m,w,l,x,A;a.Segment=
function(b,e){this.width=b.evaluator.parser.parse("1");this.size=b.evaluator.parser.parse("2");a.Graphic.call(this,b,e)};a.extend(a.Segment,a.Graphic);a.Segment.prototype.update=function(){f=this.evaluator;c=f.eval(this.expresion);this.endPoints=[];for(var e=0,d=c.length;e<d;e++)this.endPoints[e]={x:c[e][0],y:c[e][1]};if(this.rotateExp)for(h=a.degToRad(f.eval(this.rotateExp)),g=Math.cos(h),b=Math.sin(h),e=0,d=this.endPoints.length;e<d;e++)u=this.endPoints[e].x*g-this.endPoints[e].y*b,n=this.endPoints[e].x*
b+this.endPoints[e].y*g,this.endPoints[e].x=u,this.endPoints[e].y=n};a.Segment.prototype.draw=function(){this.uber.draw.call(this,this.color,this.color)};a.Segment.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Segment.prototype.drawAux=function(a,b,c){f=this.evaluator;p=this.space;r=k(f.eval(this.width));a.lineWidth=0<r?r:1E-6;e=f.eval(this.size);0>e&&(e=0);a.fillStyle=b.getColor();a.strokeStyle=c.getColor();a.lineCap="round";q=10+a.lineWidth;m=0==a.lineWidth%
2?0:.5;this.abs_coord?(w=k(this.endPoints[0].x),l=k(this.endPoints[0].y),x=k(this.endPoints[1].x),A=k(this.endPoints[1].y)):(w=k(p.getAbsoluteX(this.endPoints[0].x)),l=k(p.getAbsoluteY(this.endPoints[0].y)),x=k(p.getAbsoluteX(this.endPoints[1].x)),A=k(p.getAbsoluteY(this.endPoints[1].y)));a.beginPath();a.moveTo(w+m,l+m);a.lineTo(x+m,A+m);a.stroke();a.beginPath();a.arc(w,l,e,0,d,!0);a.arc(x,A,e,0,d,!0);a.fill();this.text!=[""]&&(t=parseInt((w+x)/2)-3,v=parseInt((l+A)/2)+3,this.uber.drawText.call(this,
a,this.text,t+q,v-q,this.color,this.font,"start","alphabetic",f.eval(this.decimals),this.fixed,!0))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k=Math.floor,d=Math.round,f,p,c,h,g,b,u,n,r,q,t,v,e,m,w,l,x,A;a.Arrow=function(b,e){this.width=b.evaluator.parser.parse("5");this.size=b.evaluator.parser.parse("2");this.spear=b.evaluator.parser.parse("8");this.arrow=new a.Color("ee0022");a.Graphic.call(this,b,e)};a.extend(a.Arrow,a.Graphic);a.Arrow.prototype.update=function(){f=
this.evaluator;p=f.eval(this.expresion);this.endPoints=[];for(var e=0,d=p.length;e<d;e++)this.endPoints[e]={x:p[e][0],y:p[e][1]};if(this.rotateExp)for(c=a.degToRad(f.eval(this.rotateExp)),h=Math.cos(c),g=Math.sin(c),e=0,d=this.endPoints.length;e<d;e++)b=this.endPoints[e].x*h-this.endPoints[e].y*g,u=this.endPoints[e].x*g+this.endPoints[e].y*h,this.endPoints[e].x=b,this.endPoints[e].y=u};a.Arrow.prototype.draw=function(){this.uber.draw.call(this,this.arrow,this.color)};a.Arrow.prototype.drawTrace=function(){this.uber.drawTrace.call(this,
this.arrow,this.trace)};a.Arrow.prototype.drawAux=function(b,c,g){f=this.evaluator;n=this.space;f.eval(this.size);t=f.eval(this.width);0>t&&(t=0);v=Math.ceil(t/2);e=n.scale;this.vect=new a.Vector2D(this.endPoints[1].x-this.endPoints[0].x,this.endPoints[1].y-this.endPoints[0].y);m=this.vect.vectorLength();this.angle=this.vect.angleBetweenVectors(a.Vector2D.AXIS_X);b.fillStyle=c.getColor();b.strokeStyle=g.getColor();b.lineWidth=2;this.abs_coord?(w=d(this.endPoints[0].x),l=d(this.endPoints[0].y),x=d(this.endPoints[1].x),
A=d(this.endPoints[1].y)):(w=d(n.getAbsoluteX(this.endPoints[0].x)),l=d(n.getAbsoluteY(this.endPoints[0].y)),x=d(n.getAbsoluteX(this.endPoints[1].x)),A=d(n.getAbsoluteY(this.endPoints[1].y)));c=f.eval(this.spear);0>c&&(c=0);b.save();b.translate(w,l,m);this.abs_coord?0<=this.vect.x&&0<=this.vect.y||0>=this.vect.x&&0<=this.vect.y?b.rotate(this.angle):b.rotate(-this.angle):(m*=e,0<=this.vect.x&&0<=this.vect.y||0>=this.vect.x&&0<=this.vect.y?b.rotate(-this.angle):b.rotate(this.angle));b.beginPath();b.moveTo(-v,
k(-v));b.lineTo(k(m-c-t),k(-v));b.lineTo(k(m-2*c),k(-c-v));b.lineTo(k(m),0);b.lineTo(k(m-2*c),k(c+v));b.lineTo(k(m-c-t),k(v));b.lineTo(-v,k(v));b.closePath();b.stroke();b.fill();b.restore();this.text!=[""]&&(r=parseInt((w+x)/2)-3,q=parseInt((l+A)/2)+3,this.uber.drawText.call(this,b,this.text,r,q,g,this.font,"start","alphabetic",f.eval(this.decimals),this.fixed,!0))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k=Math.round,d,f,p,c,h,g,b,u,n,r,q,t;a.Polygon=function(b,
e){this.width=b.evaluator.parser.parse("1");this.fill="";a.Graphic.call(this,b,e);this.endPoints=[]};a.extend(a.Polygon,a.Graphic);a.Polygon.prototype.update=function(){d=this.evaluator;p=d.eval(this.expresion);for(var n=0,e=p.length;n<e;n++)this.endPoints[n]={x:p[n][0],y:p[n][1]};if(this.rotateExp)for(c=a.degToRad(d.eval(this.rotateExp)),h=Math.cos(c),g=Math.sin(c),n=0,e=this.endPoints.length;n<e;n++)b=this.endPoints[n].x*h-this.endPoints[n].y*g,u=this.endPoints[n].x*g+this.endPoints[n].y*h,this.endPoints[n].x=
b,this.endPoints[n].y=u};a.Polygon.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};a.Polygon.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Polygon.prototype.drawAux=function(a,b,c){d=this.evaluator;f=this.space;n=k(d.eval(this.width));a.lineWidth=0<n?n:1E-6;a.strokeStyle=c.getColor();a.lineCap="round";a.lineJoin="round";r=0<n?.5:0;q=k(this.abs_coord?this.endPoints[0].x:f.getAbsoluteX(this.endPoints[0].x));t=k(this.abs_coord?this.endPoints[0].y:
f.getAbsoluteY(this.endPoints[0].y));a.beginPath();a.moveTo(q+r,t+r);c=1;for(var g=this.endPoints.length;c<g;c++)q=k(this.abs_coord?this.endPoints[c].x:f.getAbsoluteX(this.endPoints[c].x)),t=k(this.abs_coord?this.endPoints[c].y:f.getAbsoluteY(this.endPoints[c].y)),a.lineTo(q+r,t+r);this.fill&&(a.fillStyle=b.getColor(),a.fill());a.stroke()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k=Math.round,d=Math.min,f=Math.max,p=Math.acos,c=Math.sqrt,h=Math.PI,g=h/2,b=2*h,u,
n,r,q,t,v,e,m,w,l,x,A,D,B,E,G,F,J,C,z,I;a.Arc=function(b,e){this.width=b.evaluator.parser.parse("1");this.fill="";this.center=b.evaluator.parser.parse("(0,0)");this.radius=b.evaluator.parser.parse("1");this.init="0";this.end="90";a.Graphic.call(this,b,e);this.init.match(/^_\(/)&&(this.initFlag=!0,this.init=this.init.substring(1));this.end.match(/^_\(/)&&(this.endFlag=!0,this.end=this.end.substring(1));this.initExpr=b.evaluator.parser.parse(this.init);this.endExpr=b.evaluator.parser.parse(this.end)};
a.extend(a.Arc,a.Graphic);a.Arc.prototype.update=function(){u=this.evaluator;n=u.eval(this.center);this.exprX=n[0][0];this.exprY=n[0][1];r=0;this.rotateExp&&(r=a.degToRad(u.eval(this.rotateExp)),q=Math.cos(r),t=Math.sin(r),v=this.exprX*q-this.exprY*t,e=this.exprX*t+this.exprY*q,this.exprX=v,this.exprY=e);var k=u.eval(this.initExpr),z=u.eval(this.endExpr);/^(\(|\[)expr(\)|\])$/i.test(this.initExpr.type)&&/^(\(|\[)expr(\)|\])$/i.test(this.endExpr.type)?(m=k[0][0],w=k[0][1],l=z[0][0],x=z[0][1],this.vectors?
this.abs_coord&&(w=-w,x=-x):this.abs_coord?(m-=this.exprX,w=-w+this.exprY,l-=this.exprX,x=-x+this.exprY):(m-=this.exprX,w-=this.exprY,l-=this.exprX,x-=this.exprY),A=0==m?0>w?-g:g:p(1*m/c(m*m+w*w)),D=0==l?0>x?-g:g:p(1*l/c(l*l+x*x)),A+=r,D+=r,0<m&&0<w&&this.abs_coord&&(A=b-A),0<m&&0>w&&!this.abs_coord&&(A=b-A),0>m&&0>w&&!this.abs_coord&&(A=b-A),0>m&&0<w&&this.abs_coord&&(A=b-A),0<l&&0<x&&this.abs_coord&&(D=b-D),0<l&&0>x&&!this.abs_coord&&(D=b-D),0>l&&0>x&&!this.abs_coord&&(D=b-D),0>l&&0<x&&this.abs_coord&&
(D=b-D),this.initFlag?(B=A,A=D,D=B):(B=d(A,D),E=f(A,D),A=B,D=E,D-A>h&&this.abs_coord&&(A=E,D=B),D-A<=h&&!this.abs_coord&&(A=E,D=B)),this.iniAng=A,this.endAng=D,this.drawPoints=!0):(this.iniAng=a.degToRad(k)+r,this.endAng=a.degToRad(z)+r,this.drawAngle=!0)};a.Arc.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};a.Arc.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,this.trace)};a.Arc.prototype.drawAux=function(a,b,e){u=this.evaluator;G=this.space;C=u.eval(this.radius);
0>C&&(C=0);I=k(u.eval(this.width));a.lineWidth=0<I?I:1E-6;a.lineCap="round";a.strokeStyle=e.getColor();this.drawAngle?(this.abs_coord?(F=k(this.exprX),J=k(this.exprY)):(F=k(G.getAbsoluteX(this.exprX)),J=k(G.getAbsoluteY(this.exprY)),C*=G.scale,this.iniAng=-this.iniAng,this.endAng=-this.endAng),this.iniAng>this.endAng&&(z=this.iniAng,this.iniAng=this.endAng,this.endAng=z)):this.drawPoints&&(this.abs_coord?(F=k(this.exprX),J=k(this.exprY)):(F=k(G.getAbsoluteX(this.exprX)),J=k(G.getAbsoluteY(this.exprY)),
C*=G.scale,this.iniAng=-this.iniAng,this.endAng=-this.endAng));this.fill&&(a.fillStyle=b.getColor(),a.beginPath(),a.moveTo(F,J),a.arc(F,J,C,this.iniAng,this.endAng,void 0),a.fill());a.beginPath();a.arc(F,J,C,this.iniAng,this.endAng,void 0);a.stroke();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,F+4,J-2,this.color,this.font,"start","alphabetic",u.eval(this.decimals),this.fixed,!0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k,d,f,p,c,h,g,b,u,n,r,q,t,v,
e,m,w,l,x;a.Text=function(b,e){this.width=b.evaluator.parser.parse("0");a.Graphic.call(this,b,e);this.align||(this.align="start");this.ascent=this.fontSize-Math.ceil(this.fontSize/7)-(this.font.match("Courier")?3:0);this.descent=a.getFontMetrics(this.font).descent;this.abs_coord=!0};a.extend(a.Text,a.Graphic);a.Text.prototype.update=function(){k=this.evaluator;d=k.eval(this.expresion);this.exprX=d[0][0];this.exprY=d[0][1];this.rotateExp&&(f=a.degToRad(k.eval(this.rotateExp)),p=Math.cos(f),c=Math.sin(f),
h=this.exprX*p-this.exprY*c,g=this.exprX*c+this.exprY*p,this.exprX=h,this.exprY=g);4<=d[0].length&&(this.centered=!0,this.exprW=d[0][2],this.exprH=d[0][3])};a.Text.prototype.draw=function(){this.uber.draw.call(this,this.color)};a.Text.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.color)};a.Text.prototype.drawAux=function(a,b){l=this.evaluator.eval(this.decimals);"rtfNode"===this.text.type?(r=this.text,this.ascent=0):r=this.splitText(this.text.toString(l,this.fixed).split("\\n"));
if(this.text!=[""]){var e=parseInt(this.exprX)+5,c=parseInt(this.exprY)+this.ascent;this.centered&&(e=this.getMaxWidth(r),e=parseInt(this.exprX+(this.exprW-e)/2),c=parseInt(this.exprY+this.descent+(this.exprH-1.2*this.fontSize*(r.length-1))/2));this.uber.drawText.call(this,a,r,e,c,b,this.font,this.align,"alphabetic",l,this.fixed)}};a.Text.prototype.splitText=function(a){k=this.evaluator;b=k.eval(this.width);r=[];this.ctx.font=this.font;if(20<=b&&"undefined"!=a.type){for(var e=0,c=a.length;e<c;e++)u=
a[e],n=this.ctx.measureText(u).width,n>b?r=r.concat(this.splitWords(u,b)):r.push(u);q=Math.floor(1.2*this.fontSize)*r.length;k.setVariable("_Text_H_",q);return r}k.setVariable("_Text_H_",0);return a};a.Text.prototype.splitWords=function(a,b){t=a;v=[];e="";for(var c=w=0,d=a.length;c<d;c++)m=t.charAt(c)," "===m&&(lastIndexOfWhite=c),e+=m,Math.round(this.ctx.measureText(e).width)>b&&(x=a.substring(w,c+1)," "!==m&&(-1===x.indexOf(" ")?(lastIndexOfWhite=c,c--):c=lastIndexOfWhite),v.push(a.substring(w,
lastIndexOfWhite)),e="",w=c+1);v.push(a.substring(w));return v};a.Text.prototype.getMaxWidth=function(a){var b=-1;this.ctx.font=this.font;for(var e=0,c=a.length;e<c;e++)u=a[e],b=Math.max(b,this.ctx.measureText(u).width);return b};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k=Math.round,d,f,p,c,h,g,b,u,n,r,q,t,v,e,m,w;a.Image=function(b,e){this.file="";this.inirot=b.evaluator.parser.parse("0");a.Graphic.call(this,b,e);this.img=new Image;this.scaleY=this.scaleX=1;this.ratio=
b.ratio;this.update()};a.extend(a.Image,a.Graphic);a.Image.prototype.update=function(){d=this.evaluator;f=d.eval(this.expresion);this.exprX=f[0][0];this.exprY=f[0][1];this.rotateExp&&(p=a.degToRad(d.eval(this.rotateExp)),c=Math.cos(p),h=Math.sin(p),g=this.exprX*c-this.exprY*h,b=this.exprX*h+this.exprY*c,this.exprX=g,this.exprY=b);4<=f[0].length&&(this.centered=!0,this.scaleX=f[0][2],this.scaleY=f[0][3]);f[1]&&2==f[1].length&&(this.centered=!0,this.scaleX=f[1][0],this.scaleY=f[1][1]);0==this.scaleX&&
(this.scaleX=1E-5);0==this.scaleY&&(this.scaleY=1E-5);if((u=d.eval(this.file))||""==u)this.img=this.parent.getImage(u)};a.Image.prototype.draw=function(){this.uber.draw.call(this)};a.Image.prototype.drawTrace=function(){this.uber.drawTrace.call(this)};a.Image.prototype.drawAux=function(b){d=this.evaluator;n=this.space;this.img&&this.img.ready&&this.img.complete&&(m=this.img.width,w=this.img.height,this.img.canvas&&(m=k(m/this.ratio),w=k(w/this.ratio)),r=this.centered?0:k(m/2),q=this.centered?0:k(w/
2),t=k(this.abs_coord?this.exprX:n.getAbsoluteX(this.exprX)),v=k(this.abs_coord?this.exprY:n.getAbsoluteY(this.exprY)),e=a.degToRad(-d.eval(this.inirot)),b.save(),b.translate(t+r,v+q),b.rotate(e),this.opacity&&(b.globalAlpha=d.eval(this.opacity)),b.scale(this.scaleX,this.scaleY),b.drawImage(this.img,-m/2,-w/2,m,w),b.restore())};return a}(descartesJS||{}),descartesJS=function(a){function k(a,c,d){b=4*(c+d*a.width);return{r:a.data[b],g:a.data[b+1],b:a.data[b+2],a:a.data[b+3]}}if(a.loadLib)return a;
var d,f,p,c,h,g,b,u;a.Fill=function(b,c){a.Graphic.call(this,b,c)};a.extend(a.Fill,a.Graphic);a.Fill.prototype.update=function(){d=this.evaluator.eval(this.expresion);this.exprX=d[0][0];this.exprY=d[0][1]};a.Fill.prototype.draw=function(){this.uber.draw.call(this,this.color,this.color)};a.Fill.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Fill.prototype.drawAux=function(a,d){d.getColor();imageData=a.getImageData(0,0,this.space.w,this.space.h);this.abs_coord?
(f=parseInt(this.exprX),p=parseInt(this.exprY)):(f=parseInt(this.space.getAbsoluteX(this.exprX)),p=parseInt(this.space.getAbsoluteY(this.exprY)));if(!(0>f||0>p||f>=this.space.w||p>=this.space.h)){c=[[f,p]];g=k(imageData,f,p);for(u=0;0<c.length;){u++;h=c.pop();f=h[0];p=h[1];var q=k(imageData,f,p);if(g.r===q.r&&g.g===q.g&&g.b===q.b&&g.a===q.a){var q=imageData,t=d;b=4*(f+p*q.width);q.data[b+0]=t.r;q.data[b+1]=t.g;q.data[b+2]=t.b;q.data[b+3]=255*t.a;0<f&&c.push([f-1,p]);f<imageData.width-1&&c.push([f+
1,p]);c.push([f,p-1]);c.push([f,p+1])}if(u>=this.space.w*this.space.h*3)break}a.putImageData(imageData,0,0)}};return a}(descartesJS||{}),descartesJS=function(a,k){if(a.loadLib)return a;var d=new String("-_-rnd-pi-e-sqr-ra\u00edz-sqrt-exp-log-log10-abs-ent-sgn-ind-sen-sin-cos-tan-cot-sec-csc-senh-sinh-cosh-tanh-coth-sech-csch-asen-asin-acos-atan-min-max-_Num_-_Trace_-_Stop_Audios_-esCorrecto-escorrecto-_NumToStr_-_NumACadena_-_charAt_-_letraEn_-_substring_-_subcadena_-_length_-_longitud_-_indexOf_-\u00edndiceDe-_GetValues_-_GetMatrix_-_MatrixToStr_-_StrToMatrix_-_GetVector_-_VectorToStr_-_StrToVector_-_ExecStr_-_ExecBlock_-_Save_-_Open_-_SaveState_-_OpenState_-_AnchoDeCadena_-_strWidth_-_Rojo_-_Red_-_Verde_-_Green_-_Azul_-_Blue_-"),
f=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg)/gi,p;a.Macro=function(c,h){this.hasExpresion=!1;this.inirot=c.evaluator.parser.parse("0");this.inipos=c.evaluator.parser.parse("(0,0)");a.Graphic.call(this,c,h);for(var g in h)"expresion"==g&&(this.hasExpresion=!0),h.hasOwnProperty(g)&&(this[g]=h[g]);this.graphics=[];g=c.lessonParser;var b=new a.Tokenizer;if(this.hasExpresion){"'"!==this.expresion.charAt(0)&&(this.expresion="'"+this.expresion+"'");this.expresion=this.evaluator.parser.parse(this.expresion);var u=
this.evaluator.eval(this.expresion),n;u&&((n=document.getElementById(u))&&"descartes/macro"==n.type?n=n.text:(n=a.openExternalFile(u))&&!n.match(/tipo_de_macro/g)&&(n=null));var r,q;if(n){q=n.replace(/&aacute;/g,"\u00e1").replace(/&eacute;/g,"\u00e9").replace(/&iacute;/g,"\u00ed").replace(/&oacute;/g,"\u00f3").replace(/&uacute;/g,"\u00fa").replace(/&Aacute;/g,"\u00c1").replace(/&Eacute;/g,"\u00c9").replace(/&Iacute;/g,"\u00cd").replace(/&Oacute;/g,"\u00d3").replace(/&Uacute;/g,"\u00da").replace(/&ntilde;/g,
"\u00f1").replace(/&Ntilde;/g,"\u00d1").replace(/\&gt;/g,">").replace(/\&lt;/g,"<").replace(/\&amp;/g,"&").replace(/\r/g,"").split("\n");n=[];for(var u=0,t=q.length;u<t;u++)if(r=q[u].indexOf("="),-1!==r){r=g.split(q[u]);for(var v=0,e=r.length;v<e;v++)r[v]&&1<r.length&&("id"!==k[r[v][0]]&&"type"!==k[r[v][0]]||n.push(r))}for(var m,p,u=0,t=n.length;u<t;u++)for(e=(v=n[u]||[],v[0])&&"id"===v[0][0],q=0,r=v.length;q<r;q++)if(m=v[q][0].indexOf("."),-1===m||e?m=k[v[q][0]]:(m=k[v[q][0].substring(m+1)],v[q][0]=
this.name+"."+v[q][0]),!("font"===m||("fill"===m||"color"===m||"border"===m||"arrow"===m)&&"("!==v[q][1].charAt(0)||"file"===m&&v[q][1].match(f)||"id"!==m&&void 0!==k[v[q][1]]))if("text"==m)if(v[q][1].match(/\{\\rtf1/)){m=v[q][1];var l=this;p=function(a,e){for(var c=b.tokenize(e.replace(/\&squot;/g,"'")),n=0,g=c.length;n<g;n++)"identifier"!=c[n].type||d.match("-"+c[n].value+"-")||(c[n].value=l.name+"."+c[n].value);return(a.match(/^\\expr/)?"\\expr ":"\\decimals ")+b.flatTokens(c)};m=m.replace(/\\expr ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.'\+\-]*)/gi,
p);m=m.replace(/\\decimals ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.'\+\-]*)/gi,p);v[q][1]=m}else{p=g.parseText(v[q][1]).textElementsMacros;for(var x=0,A=p.length;x<A;x++){m=b.tokenize(p[x].replace(/\&squot;/g,"'"));for(var D=0,B=m.length;D<B;D++)"identifier"!==m[D].type||d.match("-"+m[D].value+"-")||(m[D].value=this.name+"."+m[D].value);m=b.flatTokens(m).replace(/&squot;/g,"'").replace(/'\+\(/g,"[").replace(/\)\+'/g,"]");p[x]=m.substring(1,m.length-1)}v[q][1]=p.join("")}else{p=v[q][1].replace(/\&squot;/g,
"'").split(";");x=0;for(A=p.length;x<A;x++){m=b.tokenize(p[x].replace(/\\n/g,";"));D=0;for(B=m.length;D<B;D++)"identifier"!==m[D].type||d.match("-"+m[D].value+"-")||(m[D].value=this.name+"."+m[D].value);p[x]=b.flatTokens(m)}v[q][1]=p.join(";")}u=0;for(t=n.length;u<t;u++)if(n[u][0]){v="";e=!1;q=0;for(r=n[u].length;q<r;q++)"type"===k[n[u][q][0]]&&(v="espacio='"+this.spaceID+"' ",e=!0),v=v+n[u][q][0]+"='"+n[u][q][1]+"' ";n[u]=v;e?this.graphics.push(g.parseGraphic(n[u],this.abs_coord,this.background,
this.inirot)):g.parseAuxiliar(n[u])}}}};a.extend(a.Macro,a.Graphic);a.Macro.prototype.update=function(){p=this.evaluator.eval(this.inipos);this.iniPosX=p[0][0];this.iniPosY=p[0][1]};a.Macro.prototype.drawAux=function(a){for(var d=0,g=this.graphics.length;d<g;d++)this.graphics[d]&&(a.save(),this.graphics[d].abs_coord?a.translate(this.iniPosX,this.iniPosY):a.translate(this.iniPosX*this.space.scale,-this.iniPosY*this.space.scale),this.graphics[d].draw(),a.restore())};return a}(descartesJS||{},babel),
descartesJS=function(a){if(a.loadLib)return a;a.Generic=function(k,d){this.width=k.evaluator.parser.parse("1");a.Graphic.call(this,k,d)};a.extend(a.Generic,a.Graphic);a.Generic.prototype.update=function(){};a.Generic.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};a.Generic.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Generic.prototype.drawAux=function(a,d,f){var p=this.evaluator.getDefinition(this.expresionString);p&&p.draw(a,d,
f,this)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k=Math.sqrt,d=Math.sin,f=Math.cos,p,c,h,g,b,u,n,r,q,t,v,e,m,w,l;a.norm3D=function(a){return k(a.x*a.x+a.y*a.y+a.z*a.z)};a.normalize3D=function(b){p=a.norm3D(b);if(0===p)return{x:0,y:0,z:0};if(1===p)return{x:b.x,y:b.y,z:b.z};p=1/p;return{x:b.x*p,y:b.y*p,z:b.z*p}};a.dotProduct3D=function(a,b){return a.x*b.x+a.y*b.y+a.z*b.z};a.crossProduct3D=function(a,b){return{x:a.y*b.z-a.z*b.y,y:a.z*b.x-a.x*b.z,z:a.x*b.y-a.y*b.x}};
a.scalarProduct3D=function(a,b){return{x:a.x*b,y:a.y*b,z:a.z*b}};a.subtract3D=function(a,b){return{x:a.x-b.x,y:a.y-b.y,z:a.z-b.z}};a.add3D=function(a,b){return{x:a.x+b.x,y:a.y+b.y,z:a.z+b.z}};a.equals3DEpsilon=function(a,b,e){return Math.abs(a.x-b.x)<=e&&Math.abs(a.y-b.y)<=e&&Math.abs(a.z-b.z)<=e};a.Vector4D=function(a,b,e,c){this.x=a||0;this.y=b||0;this.z=e||0;this.w=c||0};a.Matrix4x4=function(a,b,e,c,d,n,g,q,f,l,h,m,r,k,t,v){this.a00=a||0;this.a01=b||0;this.a02=e||0;this.a03=c||0;this.a10=d||0;
this.a11=n||0;this.a12=g||0;this.a13=q||0;this.a20=f||0;this.a21=l||0;this.a22=h||0;this.a23=m||0;this.a30=r||0;this.a31=k||0;this.a32=t||0;this.a33=v||0};a.Matrix4x4.prototype.setIdentity=function(){this.a00=1;this.a10=this.a03=this.a02=this.a01=0;this.a11=1;this.a21=this.a20=this.a13=this.a12=0;this.a22=1;this.a32=this.a31=this.a30=this.a23=0;this.a33=1;return this};a.Matrix4x4.prototype.multiplyVector4=function(b){return new a.Vector4D(b.x*this.a00+b.y*this.a10+b.z*this.a20+b.w*this.a30,b.x*this.a01+
b.y*this.a11+b.z*this.a21+b.w*this.a31,b.x*this.a02+b.y*this.a12+b.z*this.a22+b.w*this.a32,b.x*this.a03+b.y*this.a13+b.z*this.a23+b.w*this.a33)};a.Matrix4x4.prototype.translate=function(b){return new a.Matrix4x4(this.a00,this.a01,this.a02,this.a03,this.a10,this.a11,this.a12,this.a13,this.a20,this.a21,this.a22,this.a23,this.a00*b.x+this.a10*b.y+this.a20*b.z+this.a30,this.a01*b.x+this.a11*b.y+this.a21*b.z+this.a31,this.a02*b.x+this.a12*b.y+this.a22*b.z+this.a32,this.a03*b.x+this.a13*b.y+this.a23*b.z+
this.a33)};a.Matrix4x4.prototype.rotateX=function(b){c=d(b);h=f(b);r=this.a10;q=this.a11;t=this.a12;v=this.a13;e=this.a20;m=this.a21;w=this.a22;l=this.a23;return new a.Matrix4x4(this.a00,this.a01,this.a02,this.a03,r*h+e*c,q*h+m*c,t*h+w*c,v*h+l*c,r*-c+e*h,q*-c+m*h,t*-c+w*h,v*-c+l*h,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateY=function(q){c=d(q);h=f(q);g=this.a00;b=this.a01;u=this.a02;n=this.a03;e=this.a20;m=this.a21;w=this.a22;l=this.a23;return new a.Matrix4x4(g*h+e*-c,b*h+m*
-c,u*h+w*-c,n*h+l*-c,this.a10,this.a11,this.a12,this.a13,g*c+e*h,b*c+m*h,u*c+w*h,n*c+l*h,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateZ=function(e){c=d(e);h=f(e);g=this.a00;b=this.a01;u=this.a02;n=this.a03;r=this.a10;q=this.a11;t=this.a12;v=this.a13;return new a.Matrix4x4(g*h+r*c,b*h+q*c,u*h+t*c,n*h+v*c,g*-c+r*h,b*-c+q*h,u*-c+t*h,n*-c+v*h,this.a20,this.a21,this.a22,this.a23,this.a30,this.a31,this.a32,this.a33)};return a}(descartesJS||{}),descartesJS=function(a){function k(a){0!==
parseInt(this.size)&&(a.lineWidth=1,a.fillStyle=this.backColor,a.strokeStyle=this.frontColor,a.beginPath(),a.arc(this.newV[0].x,this.newV[0].y,this.size+.5,0,h),a.fill(),a.stroke())}function d(a,b){a.lineCap="round";a.lineJoin="round";a.lineWidth="#"==this.backColor.charAt(0)||"#"==this.frontColor.charAt(0)?1:.1;a.beginPath();a.moveTo(this.newV[0].x,this.newV[0].y);for(var c=1,d=this.newV.length;c<d;c++)a.lineTo(this.newV[c].x,this.newV[c].y);a.closePath();"color"===this.model?(a.fillStyle=0<=this.direction?
this.backColor:this.frontColor,a.strokeStyle=a.fillStyle,a.stroke(),a.fill()):"light"===this.model||"metal"===this.model?(a.fillStyle=0<=this.direction?b.computeColor(this.backColor,this,"metal"===this.model):b.computeColor(this.frontColor,this,"metal"===this.model),a.strokeStyle=a.fillStyle,a.stroke(),a.fill()):"wire"===this.model&&(a.lineWidth=1.5,a.strokeStyle=this.frontColor,a.stroke());this.edges&&"wire"!==this.model&&(a.lineWidth=1,a.strokeStyle="#808080",a.stroke())}function f(a){q=this.evaluator.getVariable(this.family);
this.evaluator.setVariable(this.family,this.familyValue);this.drawText(a,this.text,this.newV[0].x,this.newV[0].y+this.displace,this.frontColor,this.font,"left","alphabetic",this.decimals,this.fixed,!0);this.evaluator.setVariable(this.family,q)}function p(a){a.lineCap="round";a.lineJoin="round";a.lineWidth=this.lineWidth;a.strokeStyle=this.frontColor;a.beginPath();a.moveTo(this.newV[0].x,this.newV[0].y);a.lineTo(this.newV[1].x,this.newV[1].y);a.stroke()}function c(c,e,d){g=a.subtract3D(c,e);b=a.subtract3D(c,
d);return a.normalize3D(a.crossProduct3D(g,b))}if(a.loadLib)return a;var h=2*Math.PI,g,b,u,n,r,q;a.Primitive3D=function(a,b){this.space=b;for(var n in a)a.hasOwnProperty(n)&&(this[n]=a[n]);this.newV=[];this.spaceVertices=[];"vertex"===this.type?this.draw=k:"face"===this.type?(this.normal=c(this.vertices[0],this.vertices[1],this.vertices[2]),this.draw=d):"text"===this.type?(this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseInt(this.fontSize[1]):10,this.draw=f):"edge"===this.type&&(this.draw=
p);this.isText&&(this.computeDepth=function(){this.newV=this.vertices;this.depth=this.vertices[0].z;this.average=this.vertices[0];this.passDraw=1})};a.Primitive3D.prototype.computeDepth=function(b){this.average={x:0,y:0,z:0};this.removeDoubles();this.normal={x:0,y:1,z:0};this.direction={x:1,y:0,z:0};for(var e=0,d=this.vertices.length;e<d;e++)this.newV[e]=b.rotateVertex(this.vertices[e]),this.spaceVertices[e]=b.rotateVertex(this.vertices[e]),this.average.x+=this.newV[e].x,this.average.y+=this.newV[e].y,
this.average.z+=this.newV[e].z;this.average=a.scalarProduct3D(this.average,1/d);this.averageP=b.project(this.average);this.depth=this.averageP.z;2<this.vertices.length&&(this.normal=c(this.newV[0],this.newV[1],this.newV[2]),this.direction=a.dotProduct3D(this.normal,a.normalize3D(b.eye)));this.passDraw=1;e=0;for(d=this.vertices.length;e<d;e++)this.newV[e]=b.project(this.newV[e]),this.passDraw=this.passDraw&&0<this.newV[e].z;b.new3D||(this.passDraw=1)};var t;a.Primitive3D.prototype.removeDoubles=function(){if("edge"!==
this.type){t=[];for(var a=0,b=this.vertices.length;a<b;a++)this.vertices[a].x===this.vertices[(a+1)%b].x&&this.vertices[a].y===this.vertices[(a+1)%b].y&&this.vertices[a].z===this.vertices[(a+1)%b].z&&this.vertices[a].w===this.vertices[(a+1)%b].w||t.push(this.vertices[a]);0===t.length&&t.push(this.vertices[0]);this.vertices=t}};a.Primitive3D.prototype.drawText=function(b,e,c,d,g,q,f,h,k,t,p){if("rtfNode"==e.type)b.fillStyle=g,b.strokeStyle=g,b.textBaseline="alphabetic",e.draw(b,c,d,k,t,f,p);else for("simpleText"===
e.type&&(e=e.toString(k,t).split("\\n")),c+=q.match("Arial")?-2:q.match("Times")?-2:0,u=this.evaluator,b.fillStyle=a.getColor(u,g),b.font=q,b.textAlign=f,b.textBaseline=h,n=1.2*this.fontSize||0,g=0,q=e.length;g<q;g++)r=e[g],this.border&&b.strokeText(r,c,d+n*g),b.fillText(r,c,d+n*g)};a.Primitive3D.prototype.splitFace=function(b){if(this.intersects(b)){for(var e=null,c=null,d=0,n=0,g=0,q=b.vertices.length;g<q;g++){var f=this.intersection(b.vertices[g],b.vertices[(g+1)%q]);if(null!==f)if(null===e){if(e=
f,d=g,2===b.vertices.length){c=e;break}}else if(!a.equals3DEpsilon(f,e,1E-8)){c=f;n=g;break}}if(null!==e&&null!==c){var g=this.isInterior(e)||this.isInterior(c),h=null,r=null;if(!g&&3<=b.vertices.length)for(var q=0,k=this.vertices.length;q<k;q++)if(f=b.intersection(this.vertices[q],this.vertices[(q+1)%k]),null!==f)if(null===h)h=f;else if(!a.equals3DEpsilon(f,h,1E-8)){r=f;break}if(g||null!==h&&null!==r&&b.isInterior(h)&&b.isInterior(r)){r=!0;k=b.vertices;h=f=null;if(2===k.length)a.equals(e,k[0],1E-8)||
a.equals(e,k[1],1E-8)?r=!1:(f=[],f[0]=k[0],f[1]=e,h=[],h[0]=e,h[1]=k[1]);else for(var f=[],h=[],t=0,g=q=0;g<k.length;g++)g<d?f[t++]=k[g]:g==d?(f[t++]=k[g],f[t++]=e,h[q++]=e):g<n?h[q++]=k[g]:g==n?(h[q++]=k[g],h[q++]=c,f[t++]=c):f[t++]=k[g];if(r)return e=[],e[0]=new a.Primitive3D({vertices:f,type:"face",frontColor:b.frontColor,backColor:b.backColor,edges:b.edges,model:b.model},this.space),e[0].normal=b.normal,e[1]=new a.Primitive3D({vertices:h,type:"face",frontColor:b.frontColor,backColor:b.backColor,
edges:b.edges,model:b.model},this.space),e[1].normal=b.normal,e}}}return[b]};a.Primitive3D.prototype.intersects=function(a){return this.intersectsPlane(a)&&a.intersectsPlane(this)};a.Primitive3D.prototype.intersectsPlane=function(b){var e=a.dotProduct3D(b.vertices[0],b.normal),c=a.dotProduct3D(this.vertices[0],b.normal);if(1E-8>Math.abs(e-c))return!0;for(var d=1,n=this.vertices.length;d<n;d++){var g=a.dotProduct3D(this.vertices[d],b.normal);if(1E-8>Math.abs(e-g)||g>e&&c<e||g<e&&c>e)return!0}return!1};
a.Primitive3D.prototype.intersection=function(b,e){if(0<this.vertices.length){var c=a.subtract3D(e,b),d=a.dotProduct3D(c,this.normal);if(0!==d&&(d=a.dotProduct3D(a.subtract3D(this.vertices[0],b),this.normal)/d,-1E-8<d&&1.00000001>d))return a.add3D(b,a.scalarProduct3D(c,d))}return null};a.Primitive3D.prototype.isInterior=function(b){if(0<this.vertices.length)for(var e=0,c=a.subtract3D(this.vertices[0],b),d=0,n=this.vertices.length;d<n;d++){var g=a.subtract3D(this.vertices[(d+1)%n],b),q=a.dotProduct3D(a.crossProduct3D(c,
g),this.normal);if(1E-8>Math.abs(q)){if(0>a.dotProduct3D(c,g))break}else{if(0>e&&0<q||0<e&&0>q)return!1;c=g;e=q}}return!0};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k={x:0,y:0,z:0},d,f,p,c,h,g,b=a.degToRad;a.Graphic3D=function(b,c){this.parent=b;this.evaluator=b.evaluator;var d=b.evaluator.parser;this.spaceID="E0";this.background=!1;this.type="";this.color=new a.Color("eeffaa");this.backcolor=new a.Color("6090a0");this.Nu=this.evaluator.parser.parse("7");this.Nv=
this.evaluator.parser.parse("7");this.drawif=d.parse("1");this.abs_coord=!1;this.family="";this.family_interval=d.parse("[0,1]");this.family_steps=d.parse("8");this.font="Monospaced,PLAIN,12";this.fixed=!0;this.text="";this.decimals=d.parse("2");this.inirot="(0,0,0)";this.inirotEuler=!1;this.inipos=d.parse("(0,0,0)");this.endrot="(0,0,0)";this.endrotEuler=!1;this.endpos=d.parse("(0,0,0)");this.model="color";for(var g in c)c.hasOwnProperty(g)&&(this[g]=c[g]);void 0==this.expresion&&"macro"!=this.type&&
(this.expresion=d.parse("(0,0)"));this.space=this.getSpace();this.canvas=this.background?this.space.backCanvas:this.space.canvas;this.ctx=this.canvas.getContext("2d");this.font=a.convertFont(this.font);this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseFloat(this.fontSize[1]):10;this.inirot.match("Euler")&&(this.inirot=this.inirot.replace("Euler",""),this.inirotEuler=!0);this.endrot.match("Euler")&&(this.endrot=this.endrot.replace("Euler",""),this.endrotEuler=!0);this.inirot=d.parse(this.inirot);
this.endrot=d.parse(this.endrot);this.inirotM=new a.Matrix4x4;this.inirotM_X=new a.Matrix4x4;this.inirotM_Y=new a.Matrix4x4;this.inirotM_Z=new a.Matrix4x4;this.iniposM=new a.Matrix4x4;this.endrotM=new a.Matrix4x4;this.endrotM_X=new a.Matrix4x4;this.endrotM_Y=new a.Matrix4x4;this.endrotM_Z=new a.Matrix4x4;this.endposM=new a.Matrix4x4};a.Graphic3D.prototype.getSpace=function(){for(var a=this.parent.spaces,b,c=0,d=a.length;c<d;c++)if(b=a[c],b.id==this.spaceID)return b;return a[0]};a.Graphic3D.prototype.getFamilyValues=
function(){d=this.evaluator;f=d.eval(this.family_interval);this.familyInf=f[0][0];this.familySup=f[0][1];this.fSteps=Math.round(d.eval(this.family_steps));this.family_sep=0<this.fSteps?(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic3D.prototype.buildFamilyPrimitives=function(){d=this.evaluator;this.getFamilyValues();p=d.getVariable(this.family);if(0<=this.fSteps)for(var a=0,b=this.fSteps;a<=b;a++)d.setVariable(this.family,this.familyInf+a*this.family_sep),this.familyValue=this.familyInf+
a*this.family_sep,d.eval(this.drawif)&&this.buildPrimitives();d.setVariable(this.family,p)};a.Graphic3D.prototype.update=function(){this.primitives=[];this.evaluator.eval(this.drawif)&&(this.family||this.buildPrimitives());this.family&&this.buildFamilyPrimitives()};a.Graphic3D.prototype.updateMVMatrix=function(){h=this.evaluator.eval(this.inirot);this.inirotEuler?(this.inirotM=this.inirotM.setIdentity(),this.inirotM=this.inirotM.rotateZ(b(h[0][0])),this.inirotM=this.inirotM.rotateX(b(h[0][1])),this.inirotM=
this.inirotM.rotateZ(b(h[0][2]))):(this.inirotM_X=this.inirotM_X.setIdentity().rotateX(b(h[0][0])),this.inirotM_Y=this.inirotM_Y.setIdentity().rotateY(b(h[0][1])),this.inirotM_Z=this.inirotM_Z.setIdentity().rotateZ(b(h[0][2])));h=this.evaluator.eval(this.inipos);k={x:h[0][0],y:h[0][1],z:h[0][2]};this.iniposM=this.iniposM.setIdentity().translate(k);h=this.evaluator.eval(this.endrot);this.endrotEuler?(this.endrotM=this.endrotM.setIdentity(),this.endrotM=this.endrotM.rotateZ(b(h[0][0])),this.endrotM=
this.endrotM.rotateX(b(h[0][1])),this.endrotM=this.endrotM.rotateZ(b(h[0][2]))):(this.endrotM_X=this.endrotM_X.setIdentity().rotateX(b(h[0][0])),this.endrotM_Y=this.endrotM_Y.setIdentity().rotateY(b(h[0][1])),this.endrotM_Z=this.endrotM_Z.setIdentity().rotateZ(b(h[0][2])));h=this.evaluator.eval(this.endpos);k={x:h[0][0],y:h[0][1],z:h[0][2]};this.endposM=this.endposM.setIdentity().translate(k)};a.Graphic3D.prototype.transformVertex=function(a){this.inirotEuler?c=this.inirotM.multiplyVector4(a):(c=
this.inirotM_X.multiplyVector4(a),c=this.inirotM_Y.multiplyVector4(c),c=this.inirotM_Z.multiplyVector4(c));c=this.iniposM.multiplyVector4(c);this.endrotEuler?c=this.endrotM.multiplyVector4(c):(c=this.endrotM_X.multiplyVector4(c),c=this.endrotM_Y.multiplyVector4(c),c=this.endrotM_Z.multiplyVector4(c));c=this.endposM.multiplyVector4(c);this.macroChildren&&(c=this.applyMacroTransform(c));return c};a.Graphic3D.prototype.applyMacroTransform=function(a){this.macro_inirotEuler?c=this.macro_inirotM.multiplyVector4(a):
(c=this.macro_inirotM_X.multiplyVector4(a),c=this.macro_inirotM_Y.multiplyVector4(c),c=this.macro_inirotM_Z.multiplyVector4(c));c=this.macro_iniposM.multiplyVector4(c);this.macro_endrotEuler?c=this.macro_endrotM.multiplyVector4(c):(c=this.macro_endrotM_X.multiplyVector4(c),c=this.macro_endrotM_Y.multiplyVector4(c),c=this.macro_endrotM_Z.multiplyVector4(c));return c=this.macro_endposM.multiplyVector4(c)};a.Graphic3D.prototype.parseExpression=function(){g=[];for(var a=this.expresion.replace(/\n/g," ").replace(/ ( )+/g,
" ").trim(),b=[],c=0,d,f=a.length,e=a.length-1;-1<e;e--)d=a.charAt(e),0==c?"="==d&&(c=1):1==c?" "!=d&&(c="<"==d||">"==d?0:2):2==c&&" "==d&&(b.unshift(a.substring(e+1,f)),f=e,c=0);b.unshift(a.substring(0,f));e=0;for(a=b.length;e<a;e++)g.push(this.evaluator.parser.parse(b[e],!0));return g};var u;a.Graphic3D.prototype.splitFace=function(a){for(var b=0,c=this.primitives.length;b<c;b++)if(u=[],"face"===this.primitives[b].type){for(var d=0,g=a.primitives.length;d<g;d++)"face"===a.primitives[d].type?u=u.concat(this.primitives[b].splitFace(a.primitives[d])):
u.push(a.primitives[d]);a.primitives=u}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k,d,f,p,c;a.Point3D=function(c,d){a.Graphic3D.call(this,c,d)};a.extend(a.Point3D,a.Graphic3D);a.Point3D.prototype.buildPrimitives=function(){k=this.evaluator;this.updateMVMatrix();d=k.eval(this.expresion);f=d[0][0];p=d[0][1];c=d[0][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(f,p,c,1))],type:"vertex",backColor:this.backcolor.getColor(),frontColor:this.color.getColor(),
size:k.eval(this.width)}));""!==this.text&&this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(f,p,c,1))],type:"text",frontColor:this.color.getColor(),font:this.font,decimals:k.eval(this.decimals),fixed:this.fixed,displace:this.fontSize,evaluator:k,text:this.text,family:this.family,familyValue:this.familyValue},this.space))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k,d,f,p,c,h,g;a.Segment3D=function(b,c){this.width=b.evaluator.parser.parse("1");
a.Graphic3D.call(this,b,c)};a.extend(a.Segment3D,a.Graphic3D);a.Segment3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();g=evaluator.getVariable("u");evaluator.setVariable("u",this.Nu);expr=evaluator.eval(this.expresion);k=expr[0][0];d=expr[0][1];f=expr[0][2];p=expr[1][0];c=expr[1][1];h=expr[1][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(k,d,f,1)),this.transformVertex(new a.Vector4D(p,c,h,1))],type:"edge",frontColor:this.color.getColor(),
lineWidth:evaluator.eval(this.width)},this.space));evaluator.setVariable("u",g)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k,d,f,p,c,h,g,b,u,n,r,q,t,v;a.Surface3D=function(b,c){this.parameter="t";this.parameter_interval=b.evaluator.parser.parse("[0,1]");this.parameter_steps=b.evaluator.parser.parse("8");a.Graphic3D.call(this,b,c);this.expresion=this.parseExpression()};a.extend(a.Surface3D,a.Graphic3D);a.Surface3D.prototype.buildPrimitives=function(){k=this.evaluator;
this.updateMVMatrix();p=k.getVariable("x");c=k.getVariable("y");h=k.getVariable("z");d=k.getVariable("u");f=k.getVariable("v");k.setVariable("u",0);k.setVariable("v",0);g=k.eval(this.Nu);b=k.eval(this.Nv);u=[];for(r=0;r<=g;r++)for(k.setVariable("u",r/g),q=0;q<=b;q++){k.setVariable("v",q/b);t=0;for(v=this.expresion.length;t<v;t++)k.eval(this.expresion[t]);u.push(this.transformVertex(new a.Vector4D(k.getVariable("x"),k.getVariable("y"),k.getVariable("z"),1)))}for(r=0;r<g;r++)for(q=0;q<b;q++)n=[],n.push(u[q+
r*b+r]),n.push(u[q+1+r*b+r]),n.push(u[q+2+(r+1)*b+r]),n.push(u[q+1+(r+1)*b+r]),this.primitives.push(new a.Primitive3D({vertices:n,type:"face",frontColor:this.color.getColor(),backColor:this.backcolor.getColor(),edges:this.edges,model:this.model},this.space));k.setVariable("x",p);k.setVariable("y",c);k.setVariable("z",h);k.setVariable("u",d);k.setVariable("v",f)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k,d,f,p,c,h;a.Polygon3D=function(c,b){this.width=c.evaluator.parser.parse("1");
a.Graphic3D.call(this,c,b)};a.extend(a.Polygon3D,a.Graphic3D);a.Polygon3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.eval(this.expresion);for(var g=0,b=expr.length-1;g<b;g++)k=expr[g][0],d=expr[g][1],f=expr[g][2],p=expr[g+1][0],c=expr[g+1][1],h=expr[g+1][2],this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(k,d,f,1)),this.transformVertex(new a.Vector4D(p,c,h,1))],type:"edge",frontColor:this.color.getColor(),
lineWidth:evaluator.eval(this.width)},this.space))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k,d,f,p,c,h;a.Curve3D=function(c,b){this.width=c.evaluator.parser.parse("1");a.Graphic3D.call(this,c,b);this.expresion=this.parseExpression()};a.extend(a.Curve3D,a.Graphic3D);a.Curve3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();p=evaluator.getVariable("x");c=evaluator.getVariable("y");h=evaluator.getVariable("z");f=evaluator.getVariable("u");
evaluator.setVariable("u",0);d=evaluator.eval(this.Nu);k=[];for(var g=0;g<=d;g++){evaluator.setVariable("u",g/d);for(var b=0,u=this.expresion.length;b<u;b++)evaluator.eval(this.expresion[b]);k.push(this.transformVertex(new a.Vector4D(evaluator.getVariable("x"),evaluator.getVariable("y"),evaluator.getVariable("z"),1)))}g=0;for(b=k.length-1;g<b;g++)this.primitives.push(new a.Primitive3D({vertices:[k[g],k[g+1]],type:"edge",frontColor:this.color.getColor(),lineWidth:evaluator.eval(this.width)},this.space));
evaluator.setVariable("x",p);evaluator.setVariable("y",h);evaluator.setVariable("z",c);evaluator.setVariable("u",f)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k,d,f,p,c,h,g,b,u;a.Triangle3D=function(b,c){a.Graphic3D.call(this,b,c)};a.extend(a.Triangle3D,a.Graphic3D);a.Triangle3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.eval(this.expresion);k=expr[0][0];d=expr[0][1];f=expr[0][2];p=expr[1][0];c=expr[1][1];h=
expr[1][2];g=expr[2][0];b=expr[2][1];u=expr[2][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(k,d,f,1)),this.transformVertex(new a.Vector4D(g,b,u,1)),this.transformVertex(new a.Vector4D(p,c,h,1))],type:"face",frontColor:this.color.getColor(),backColor:this.backcolor.getColor(),edges:this.edges,model:this.model},this.space))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k;a.Face3D=function(d,f){a.Graphic3D.call(this,d,f)};a.extend(a.Face3D,
a.Graphic3D);a.Face3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.eval(this.expresion);k=[];for(var d=expr.length-1;0<=d;d--)k.push(this.transformVertex(new a.Vector4D(expr[d][0],expr[d][1],expr[d][2],1)));this.primitives.push(new a.Primitive3D({vertices:k,type:"face",frontColor:this.color.getColor(),backColor:this.backcolor.getColor(),edges:this.edges,model:this.model},this.space))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var k,d,f,p,c;a.Polireg3D=function(c,d){this.width=c.evaluator.parser.parse("2");this.length=c.evaluator.parser.parse("2");a.Graphic3D.call(this,c,d)};a.extend(a.Polireg3D,a.Graphic3D);a.Polireg3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();k=evaluator.eval(this.Nu);d=[this.transformVertex(new a.Vector4D(0,0,0,1))];f=evaluator.eval(this.width)/2;p=evaluator.eval(this.length)/2;c=2*Math.PI/k;for(var h=0;h<k;h++)d.push(this.transformVertex(new a.Vector4D(f*Math.cos(c*
h),p*Math.sin(c*h),0,1)));for(h=0;h<k;h++)this.primitives.push(new a.Primitive3D({vertices:[d[0],h+2<=k?d[h+2]:d[1],d[h+1]],type:"face",frontColor:this.color.getColor(),backColor:this.backcolor.getColor(),edges:this.edges,model:this.model},this.space))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k,d,f,p;a.Text3D=function(c,d){a.Graphic3D.call(this,c,d)};a.extend(a.Text3D,a.Graphic3D);a.Text3D.prototype.buildPrimitives=function(){k=this.evaluator;d=k.eval(this.expresion);
f=d[0][0];p=d[0][1];this.primitives.push(new a.Primitive3D({vertices:[new a.Vector4D(f,p,0,1)],type:"text",frontColor:this.color.getColor(),font:this.font,decimals:k.eval(this.decimals),fixed:this.fixed,displace:0,isText:!0,evaluator:k,text:this.text,family:this.family,familyValue:this.familyValue},this.space))};return a}(descartesJS||{}),descartesJS=function(a,k){if(a.loadLib)return a;var d=new String("-rnd-pi-e-sqr-sqrt-ra\u00edz-exp-log-log10-abs-ent-sgn-ind-sin-sen-cos-tan-cot-sec-csc-sinh-senh-cosh-tanh-coth-sech-csch-asin-asen-acos-atan-min-max-"),
f=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg)/gi,p,c;a.Macro3D=function(c,g){this.expresion=void 0;this.inirot="(0,0,0)";this.inirotEuler=!1;this.inipos=c.evaluator.parser.parse("(0,0,0)");this.endrot="(0,0,0)";this.endrotEuler=!1;this.endpos=c.evaluator.parser.parse("(0,0,0)");a.Graphic.call(this,c,g);for(var b in g)g.hasOwnProperty(b)&&(this[b]=g[b]);this.inirot.match("Euler")&&(this.inirot=this.inirot.replace("Euler",""),this.inirotEuler=!0);this.endrot.match("Euler")&&(this.endrot=this.endrot.replace("Euler",
""),this.endrotEuler=!0);this.inirot=this.evaluator.parser.parse(this.inirot);this.endrot=this.evaluator.parser.parse(this.endrot);this.inirotM=new a.Matrix4x4;this.inirotM_X=new a.Matrix4x4;this.inirotM_Y=new a.Matrix4x4;this.inirotM_Z=new a.Matrix4x4;this.iniposM=new a.Matrix4x4;this.endrotM=new a.Matrix4x4;this.endrotM_X=new a.Matrix4x4;this.endrotM_Y=new a.Matrix4x4;this.endrotM_Z=new a.Matrix4x4;this.endposM=new a.Matrix4x4;this.graphics=[];b=c.lessonParser;var p=new a.Tokenizer;if(void 0!=this.expresion){"'"!==
this.expresion.charAt(0)&&(this.expresion="'"+this.expresion+"'");this.expresion=this.evaluator.parser.parse(this.expresion);var n=this.evaluator.eval(this.expresion),r;n&&((r=document.getElementById(n))&&"descartes/macro"==r.type?r=r.text:(r=a.openExternalFile(n))&&!r.match(/tipo_de_macro/g)&&(r=null));var q,t;if(r){t=r.replace(/&aacute;/g,"\u00e1").replace(/&eacute;/g,"\u00e9").replace(/&iacute;/g,"\u00ed").replace(/&oacute;/g,"\u00f3").replace(/&uacute;/g,"\u00fa").replace(/&Aacute;/g,"\u00c1").replace(/&Eacute;/g,
"\u00c9").replace(/&Iacute;/g,"\u00cd").replace(/&Oacute;/g,"\u00d3").replace(/&Uacute;/g,"\u00da").replace(/&ntilde;/g,"\u00f1").replace(/&Ntilde;/g,"\u00d1").replace(/\&gt;/g,">").replace(/\&lt;/g,"<").replace(/\&amp;/g,"&").replace(/\r/g,"").split("\n");r=[];for(var n=0,v=t.length;n<v;n++)q=t[n].indexOf("="),-1!==q&&(q=t[n].substring(0,q),"id"!==k[q]&&"type"!==k[q]||r.push(b.split(t[n])));for(var e,m,w,l,n=0,v=r.length;n<v;n++)for(l=(e=r[n]||[],e[0])&&"id"===e[0][0],t=0,q=e.length;t<q;t++)if(m=
e[t][0].indexOf("."),-1===m||l?m=k[e[t][0]]:(m=k[e[t][0].substring(m+1)],e[t][0]=this.name+"."+e[t][0]),!("font"===m||("fill"===m||"color"===m||"backcolor"===m||"arrow"===m)&&"("!==e[t][1].charAt(0)||"file"===m&&e[t][1].match(f)||"id"!==m&&void 0!==k[e[t][1]])||"width"===m||"height"===m||"length"===m)if("text"==m)if(e[t][1].match(/\{\\rtf1/)){m=e[t][1];var x=this;w=function(a,b){for(var e=p.tokenize(b.replace(/\&squot;/g,"'")),c=0,g=e.length;c<g;c++)"identifier"!=e[c].type||d.match("-"+e[c].value+
"-")||(e[c].value=x.name+"."+e[c].value);return(a.match(/^\\expr/)?"\\expr ":"\\decimals ")+p.flatTokens(e)};m=m.replace(/\\expr ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,w);m=m.replace(/\\decimals ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,w);e[t][1]=m}else{w=b.parseText(e[t][1]).textElementsMacro3Ds;for(var A=0,D=w.length;A<D;A++){m=p.tokenize(w[A].replace(/\&squot;/g,"'"));for(var B=0,E=m.length;B<E;B++)"identifier"!==m[B].type||d.match("-"+m[B].value+"-")||(m[B].value=this.name+"."+
m[B].value);m=p.flatTokens(m).replace(/&squot;/g,"'").replace(/'\+\(/g,"[").replace(/\)\+'/g,"]");w[A]=m.substring(1,m.length-1)}e[t][1]=w.join("")}else{m=p.tokenize(e[t][1]);w=0;for(A=m.length;w<A;w++)"identifier"!==m[w].type||d.match("-"+m[w].value+"-")||(m[w].value=this.name+"."+m[w].value);e[t][1]=p.flatTokens(m)}n=0;for(v=r.length;n<v;n++)if(r[n][0]){e="";l=!1;t=0;for(q=r[n].length;t<q;t++)"type"===k[r[n][t][0]]&&(e="espacio='"+this.spaceID+"' ",l=!0),e=e+r[n][t][0]+"='"+r[n][t][1]+"' ";r[n]=
e;l?this.graphics.push(b.parse3DGraphic(r[n],this.abs_coord,this.background,this.inirot)):b.parseAuxiliar(r[n])}}n=0;for(v=this.graphics.length;n<v;n++)this.graphics[n].macroChildren=!0}};a.extend(a.Macro3D,a.Graphic);a.Macro3D.prototype.update=function(){this.updateTransformation();if(this.inipos){var a=this.evaluator.eval(this.inipos);this.iniPosX=a[0][0];this.iniPosY=a[0][1]}this.primitives=[];for(var a=0,d=this.graphics.length;a<d;a++)p=this.graphics[a],p.macro_inirotEuler=this.inirotEuler,p.macro_inirotM=
this.inirotM,p.macro_inirotM_X=this.inirotM_X,p.macro_inirotM_Y=this.inirotM_Y,p.macro_inirotM_Z=this.inirotM_Z,p.macro_iniposM=this.iniposM,p.macro_endrotEuler=this.endrotEuler,p.macro_endrotM=this.endrotM,p.macro_endrotM_X=this.endrotM_X,p.macro_endrotM_Y=this.endrotM_Y,p.macro_endrotM_Z=this.endrotM_Z,p.macro_endposM=this.endposM,p.update();a=0;for(d=this.graphics.length;a<d;a++){p=this.graphics[a];if(p.split||this.split)for(var b=a+1;b<d;b++)c=this.graphics[b],(c.split||this.split)&&p.splitFace(c);
this.primitives=this.primitives.concat(p.primitives||[])}};a.Macro3D.prototype.updateTransformation=function(){tmpExpr=this.evaluator.eval(this.inirot);this.inirotEuler?(this.inirotM=this.inirotM.setIdentity(),this.inirotM=this.inirotM.rotateZ(a.degToRad(tmpExpr[0][0])),this.inirotM=this.inirotM.rotateX(a.degToRad(tmpExpr[0][1])),this.inirotM=this.inirotM.rotateZ(a.degToRad(tmpExpr[0][2]))):(this.inirotM_X=this.inirotM_X.setIdentity().rotateX(a.degToRad(tmpExpr[0][0])),this.inirotM_Y=this.inirotM_Y.setIdentity().rotateY(a.degToRad(tmpExpr[0][1])),
this.inirotM_Z=this.inirotM_Z.setIdentity().rotateZ(a.degToRad(tmpExpr[0][2])));tmpExpr=this.evaluator.eval(this.inipos);translate={x:tmpExpr[0][0],y:tmpExpr[0][1],z:tmpExpr[0][2]};this.iniposM=this.iniposM.setIdentity().translate(translate);tmpExpr=this.evaluator.eval(this.endrot);this.endrotEuler?(this.endrotM=this.endrotM.setIdentity(),this.endrotM=this.endrotM.rotateZ(a.degToRad(tmpExpr[0][0])),this.endrotM=this.endrotM.rotateX(a.degToRad(tmpExpr[0][1])),this.endrotM=this.endrotM.rotateZ(a.degToRad(tmpExpr[0][2]))):
(this.endrotM_X=this.endrotM_X.setIdentity().rotateX(a.degToRad(tmpExpr[0][0])),this.endrotM_Y=this.endrotM_Y.setIdentity().rotateY(a.degToRad(tmpExpr[0][1])),this.endrotM_Z=this.endrotM_Z.setIdentity().rotateZ(a.degToRad(tmpExpr[0][2])));tmpExpr=this.evaluator.eval(this.endpos);translate={x:tmpExpr[0][0],y:tmpExpr[0][1],z:tmpExpr[0][2]};this.endposM=this.endposM.setIdentity().translate(translate)};a.Macro3D.prototype.drawAux=function(a){};return a}(descartesJS||{},babel),descartesJS=function(a){function k(a,
b,e,c,g){d.call(this,a/1.8,a/1.8,a/1.8,c,g)}function d(a,b,c,d,g){a/=2;b/=2;c/=2;this.changeGeometry(a,b,c,d,g)||(this.vertices=[new e(a,c,b,1),new e(a,-c,b,1),new e(a,c,-b,1),new e(a,-c,-b,1),new e(-a,c,b,1),new e(-a,-c,b,1),new e(-a,c,-b,1),new e(-a,-c,-b,1)],this.faces=[[2,3,1,0],[1,5,4,0],[5,7,6,4],[6,7,3,2],[4,6,2,0],[3,7,5,1]],this.updateValues(a,b,c,d,g))}function f(a,b,c,d,g){a/=2;this.changeGeometry(a,b,c,d,g)||(this.vertices=[new e(0,0,a,1),new e(-.49*a,-.86*a,-.32*a,1),new e(-.49*a,.86*
a,-.32*a,1),new e(1*a,0,-.32*a,1)],this.faces=[[3,2,1],[1,2,0],[2,3,0],[3,1,0]],this.updateValues(a,b,c,d,g))}function p(a,b,c,d,g){a/=2;this.changeGeometry(a,b,c,d,g)||(this.vertices=[new e(0,0,a,1),new e(a,0,0,1),new e(-a,0,0,1),new e(0,a,0,1),new e(0,-a,0,1),new e(0,0,-a,1)],this.faces=[[3,1,0],[2,3,0],[1,4,0],[4,2,0],[1,3,5],[3,2,5],[4,1,5],[2,4,5]],this.updateValues(a,b,c,d,g))}function c(b,c,d,g,n){b/=3.4;if(!this.changeGeometry(b,c,d,g,n)){E=b/1.6180339887;G=1.6180339887*b;this.vertices=[new e(b,
b,b,1),new e(b,b,-b,1),new e(b,-b,b,1),new e(b,-b,-b,1),new e(-b,b,b,1),new e(-b,b,-b,1),new e(-b,-b,b,1),new e(-b,-b,-b,1),new e(0,E,G,1),new e(0,E,-G,1),new e(0,-E,G,1),new e(0,-E,-G,1),new e(E,G,0,1),new e(E,-G,0,1),new e(-E,G,0,1),new e(-E,-G,0,1),new e(G,0,E,1),new e(G,0,-E,1),new e(-G,0,E,1),new e(-G,0,-E,1)];F=(new a.Matrix4x4).setIdentity().rotateY(-t/6);z=0;for(I=this.vertices.length;z<I;z++)this.vertices[z]=F.multiplyVector4(this.vertices[z]);this.faces=[[0,16,2,10,8],[12,1,17,16,0],[8,
4,14,12,0],[2,16,17,3,13],[13,15,6,10,2],[6,18,4,8,10],[3,17,1,9,11],[13,3,11,7,15],[1,12,14,5,9],[11,9,5,19,7],[5,14,4,18,19],[6,15,7,19,18]];this.updateValues(b,c,d,g,n)}}function h(b,c,d,g,n){b/=4;if(!this.changeGeometry(b,c,d,g,n)){G=1.6180339887*b;this.vertices=[new e(0,b,G,1),new e(0,b,-G,1),new e(0,-b,G,1),new e(0,-b,-G,1),new e(b,G,0,1),new e(b,-G,0,1),new e(-b,G,0,1),new e(-b,-G,0,1),new e(G,0,b,1),new e(G,0,-b,1),new e(-G,0,b,1),new e(-G,0,-b,1)];this.faces=[[10,0,2],[0,8,2],[8,5,2],[5,
7,2],[7,10,2],[6,0,10],[11,6,10],[7,11,10],[7,3,11],[5,3,7],[9,3,5],[8,9,5],[4,9,8],[0,4,8],[6,4,0],[11,3,1],[6,11,1],[4,6,1],[9,4,1],[3,9,1]];F=(new a.Matrix4x4).setIdentity().rotateY(-1.029);z=0;for(I=this.vertices.length;z<I;z++)this.vertices[z]=F.multiplyVector4(this.vertices[z]);this.updateValues(b,c,d,g,n)}}function g(a,b,c,d,g){a/=2;this.isSphere?c=b=a:(b/=2,c/=2);if(!this.changeGeometry(a,b,c,d,g)){this.vertices=[new e(0,0,b,1)];for(z=1;z<d;z++)for(B=z*t/d,H=0;H<g;H++)D=H*v/g,l=a*r(B)*q(D),
x=c*r(B)*r(D),A=b*q(B),this.vertices.push(new e(l,x,A,1));this.vertices.push(new e(0,0,-b,1));this.faces=[];for(z=0;z<g;z++)this.faces.push([0,(z+1)%g+1,z%g+1]);for(z=1;z<d-1;z++)for(H=0;H<g;H++)this.faces.push([H+1+(z-1)*g,(H+1)%g+1+(z-1)*g,(H+1)%g+1+z*g,H+1+z*g]);for(z=0;z<g;z++)this.faces.push([this.vertices.length-1,this.vertices.length-1-g+z,this.vertices.length-1-g+(z+1)%g]);this.updateValues(a,b,c,d,g)}}function b(a,b,c,d,g){a/=2;b/=2;c/=2;if(!this.changeGeometry(a,b,c,d,g)){this.vertices=
[];for(z=0;z<g;z++)for(H=0;H<d;H++)l=a*(g-z)/g*q(H*v/d),x=c*(g-z)/g*r(H*v/d),A=b-2*z*b/g,this.vertices.push(new e(l,x,A,1));this.vertices.push(new e(0,0,-b,1));this.faces=[];for(z=0;z<g-1;z++)for(H=0;H<d;H++)this.faces.push([H+z*d,(H+1)%d+z*d,(H+1)%d+(z+1)*d,H+(z+1)*d]);for(z=0;z<d;z++)this.faces.push([this.vertices.length-1,this.vertices.length-1-d+z,this.vertices.length-1-d+(z+1)%d]);this.updateValues(a,b,c,d,g)}}function u(a,b,c,d,g){a/=2;b/=2;c/=2;if(!this.changeGeometry(a,b,c,d,g)){this.vertices=
[];for(z=0;z<g+1;z++)for(H=0;H<d;H++)l=a*q(H*v/d),x=c*r(H*v/d),A=b-2*z*b/g,this.vertices.push(new e(l,x,A,1));this.faces=[];for(z=0;z<g;z++)for(H=0;H<d;H++)this.faces.push([H+z*d,(H+1)%d+z*d,(H+1)%d+(z+1)*d,H+(z+1)*d]);this.updateValues(a,b,c,d,g)}}function n(){function a(b){return parseInt(b)}function b(a){return parseFloat(a)}this.vertices=[];this.faces=[];z=0;for(I=this.fileData.length;z<I;z++)J=this.fileData[z],J.match(/^V\(/)?(C=J.substring(2,J.length-1).split(",").map(b),this.vertices.push(new e(C[0]||
0,C[1]||0,C[2]||0,1))):J.match(/^F\(/)&&(C=J.substring(2,J.length-1).split(",").map(a),this.faces.push(C.reverse()))}if(a.loadLib)return a;var r=Math.sin,q=Math.cos,t=Math.PI,v=2*t,e,m,w,l,x,A,D,B,E,G,F,J,C,z,I,H,M;a.OtherGeometry=function(q,l){this.width=q.evaluator.parser.parse("2");this.height=q.evaluator.parser.parse("2");this.length=q.evaluator.parser.parse("2");e=a.Vector4D;a.Graphic3D.call(this,q,l);switch(this.type){case "cube":this.buildGeometry=k;break;case "box":this.buildGeometry=d;break;
case "tetrahedron":this.buildGeometry=f;break;case "octahedron":this.buildGeometry=p;break;case "sphere":this.isSphere=!0;case "ellipsoid":this.buildGeometry=g;break;case "dodecahedron":this.buildGeometry=c;break;case "icosahedron":this.buildGeometry=h;break;case "cone":this.buildGeometry=b;break;case "cylinder":this.buildGeometry=u;break;case "mesh":this.fileData=a.openExternalFile(this.evaluator.eval(this.file)).split(/\r/),this.buildGeometry=n}};a.extend(a.OtherGeometry,a.Graphic3D);a.OtherGeometry.prototype.buildPrimitives=
function(){m=this.evaluator;this.updateMVMatrix();this.buildGeometry(m.eval(this.width),m.eval(this.height),m.eval(this.length),m.eval(this.Nu),m.eval(this.Nv));z=0;for(I=this.faces.length;z<I;z++){w=[];H=0;for(M=this.faces[z].length;H<M;H++)w.push(this.transformVertex(this.vertices[this.faces[z][H]]));this.primitives.push(new a.Primitive3D({vertices:w,type:"face",frontColor:this.color.getColor(),backColor:this.backcolor.getColor(),edges:this.edges,model:this.model},this.space))}};a.OtherGeometry.prototype.changeGeometry=
function(a,b,c,e,d){return this.oldWidth===a&&this.oldHeight===b&&this.oldLength===c&&this.oldNu===e&&this.oldNv===d};a.OtherGeometry.prototype.updateValues=function(a,b,c,e,d){this.oldWidth=a;this.oldHeight=b;this.oldLength=c;this.oldNv=d;this.oldNu=e};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k=Math.max,d=Math.min,f=Math.PI,p=Math.cos,c=Math.sin,h=Math.abs,g=Math.round,b,u,n,r,q,t,v,e,m,w,l,x,A,D,B,E,G,F;a.R2=function(a,b){this.x=a||0;this.y=b||0};a.R2.prototype.set=
function(a,b){this.x=a||0;this.y=b||0;return this};a.R2.prototype.copy=function(){return new a.R2(this.x,this.y)};a.R2.prototype.ix=function(){return g(k(d(this.x,32E3),-32E3))};a.R2.prototype.iy=function(){return g(k(d(this.y,32E3),-32E3))};a.R2.prototype.equals=function(a){return this.x==a.x&&this.y==a.y};a.R2.prototype.norm2=function(){return this.x*this.x+this.y*this.y};a.R2.prototype.norm=function(){return Math.sqrt(this.norm2())};a.R2.prototype.distance=function(a){u=this.copy();u.sub(a);return u.norm()};
a.R2.prototype.dot=function(a){return this.x*a.x+this.y*a.y};a.R2.prototype.det=function(a){return this.x*a.y-this.y*a.x};a.R2.prototype.mul=function(a){this.x*=a;this.y*=a};a.R2.prototype.div=function(a){this.x/=a;this.y/=a};a.R2.prototype.add=function(a){this.x+=a.x;this.y+=a.y};a.R2.prototype.sub=function(a){this.x-=a.x;this.y-=a.y};a.R2.prototype.normalize=function(){b=this.norm();0!=b&&this.div(b)};a.R2.prototype.rotR90=function(){b=this.x;this.x=this.y;this.y=-b};a.R2.prototype.rotL90=function(){b=
this.x;this.x=-this.y;this.y=b};a.R2.prototype.rot=function(a){n=this.copy();t=p(a);v=c(a);this.x=n.x*t-n.y*v;this.y=n.x*v+n.y*t};a.R2.prototype.rot=function(a){this.rot(a*f/180)};a.R2.prototype.intersection=function(b,c,g,n){e=c.x-b.x;m=g.x-n.x;w=g.x-b.x;l=c.y-b.y;x=g.y-n.y;A=g.y-b.y;F=e*x-m*l;return 1E-6<h(F)?(r=(w*x-A*m)/F,q=(-w*l+A*e)/F,0<=r&&1>=r&&0<=q&&1>=q?new a.R2(b.x+e*r,b.y+l*r):null):(c.x-g.x)*A!=(c.y-g.y)*w?null:b.x!=c.x?(D=d(b.x,c.x),B=k(b.x,c.x),D<=g.x&&g.x<=B?g:D<=n.x&&n.x<=B?n:null):
g.x!=n.x?(E=d(g.x,n.x),G=k(g.x,n.x),E<=b.x&&b.x<=G?b:E<=c.x&&c.x<=G?c:null):b.y!=c.y?(D=d(b.y,c.y),B=k(b.y,c.y),D<=g.y&&g.y<=B?g:D<=n.y&&n.y<=B?n:null):g.y!=n.y?(E=d(g.y,n.y),G=k(g.y,n.y),E<=b.y&&b.y<=G?b:E<=c.y&&c.y<=G?c:null):b.x==g.x&&b.y==g.y?b:null};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k,d,f,p,c,h,g,b,u;a.R2Newton=function(b,d){this.evaluator=b;this.constraint=d;if("=="==this.constraint.value||"<"==this.constraint.value||"<="==this.constraint.value||">"==
this.constraint.value||">="==this.constraint.value)this.sign="<"==this.constraint.value||"<="==this.constraint.value?"menor":">"==this.constraint.value||">="==this.constraint.value?"mayor":"igual",this.constraint=this.constraint.equalToMinus(),this.constraint=this.constraint.childs[0];h=new a.R2(0,0);c=new a.R2(0,0);u=new a.R2(0,0)};a.R2Newton.prototype.getUnitNormal=function(){this.normal.normalize();return u.set(this.normal.x,this.normal.y)};a.R2Newton.prototype.gradient=function(a){k=this.evaluator;
h.x=0;h.y=0;g=k.getVariable("x");b=k.getVariable("y");k.setVariable("x",a.x);k.setVariable("y",a.y);this.f0=k.eval(this.constraint);k.setVariable("x",k.getVariable("x")+1E-6);d=k.eval(this.constraint);h.x=(d-this.f0)/1E-6;h.x=isNaN(h.x)?Infinity:h.x;k.setVariable("x",k.getVariable("x")-1E-6);k.setVariable("y",k.getVariable("y")+1E-6);d=k.eval(this.constraint);h.y=(d-this.f0)/1E-6;h.y=isNaN(h.y)?Infinity:h.y;k.setVariable("x",g);k.setVariable("y",b);return h};a.R2Newton.prototype.findZero=function(a,
d,q){k=this.evaluator;c.x=a.x;c.y=a.y;g=k.getVariable("x");b=k.getVariable("y");k.setVariable("x",a.x);k.setVariable("y",a.y);this.f0=k.eval(this.constraint);if("menor"===this.sign&&0>=this.f0||"mayor"===this.sign&&0<=this.f0)return c;k.setVariable("x",g);k.setVariable("y",b);for(var h=0;16>h;h++)if(f=c.x,p=c.y,this.normal=this.gradient(c),0!=this.normal.norm2()&&this.normal.mul(-this.f0/this.normal.norm2()),c.x=f+this.normal.x,c.y=p+this.normal.y,this.normal.norm()<d)return 0===this.normal.x&&0===
this.normal.y&&(this.normal.x=c.x-a.x,this.normal.y=c.y-a.y),c;return q?c:null};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Vector2D=function(a,d){this.x=a;this.y=d};a.Vector2D.AXIS_X=new a.Vector2D(1,0);a.Vector2D.AXIS_Y=new a.Vector2D(0,1);a.Vector2D.prototype.vectorLength=function(){return Math.sqrt(this.x*this.x+this.y*this.y)};a.Vector2D.prototype.dotProduct=function(a){return this.x*a.x+this.y*a.y};a.Vector2D.prototype.angleBetweenVectors=function(a){return Math.acos(this.dotProduct(a)/
(this.vectorLength()*a.vectorLength()))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k=Math.floor,d=Math.round,f,p,c,h,g,b,u,n,r,q,t,v,e,m,w,l,x,A,D,B;a.Control=function(b,c){this.parent=b;this.evaluator=b.evaluator;var e=this.parser=b.evaluator.parser;this.id="graphic"!==c.type?"C":"G";this.gui=this.type="";this.region="south";this.y=this.x=0;this.w="video"!==c.type?100:350;this.h="video"!==c.type?23:120;"graphic"!==c.type&&"audio"!==c.type&&"video"!==c.type?"text"!==
c.type?this.expresion=e.parse("(0,0,100,23)"):(this.expresion=e.parse("(0,0,300,200)"),this.w=300,this.h=200):this.expresion=e.parse("(0,0)");this.fixed=2!=this.parent.version?!1:!0;this.visible=!0;this.color=new a.Color(4>this.parent.version?"000000":"222222");this.colorInt=new a.Color("graphic"!==c.type?"f0f8ff":"cc0022");this.underlined=this.italics=this.bold="";this.font_size=4>this.parent.version?-1:e.parse("12");this.parameter=this.action="";this.parameterFont="Monospace 12px";this.drawif=e.parse("1");
this.activeif=e.parse("1");this.tooltip="";this.tooltipFont="Monospace 12px";this.Explanation="";this.ExplanationFont="Monospace 12px";this.cID=this.msg_pos="";this.valueExpr=e.parse("0");this.decimals=e.parse("2");this.min=e.parse("-Infinity");this.max=e.parse("Infinity");this.incr=e.parse("0.1");this.exponentialif=this.discrete=!1;this.zIndex=-1;for(var g in c)c.hasOwnProperty(g)&&(this[g]=c[g]);"video"!==this.type&&"audio"!==this.type||"interior"===this.region||(this.region="interior");void 0==
this.name&&(this.name=2==this.parent.version?this.id:"_nada_");this.name="_._"==this.name||"_nada_"==this.name||"_void_"==this.name?"":this.name;e=this.evaluator.eval(this.expresion);this.x=d(e[0][0]);this.y=d(e[0][1]);4==e[0].length&&(this.w=d(e[0][2]),this.h=d(e[0][3]));this.actionExec=b.lessonParser.parseAction(this)};a.Control.prototype.init=function(){};a.Control.prototype.update=function(){};a.Control.prototype.draw=function(){};a.Control.prototype.getContainer=function(){var a=this.parent.spaces,
b;if("interior"===this.region)for(var c=0,e=a.length;c<e;c++){if(b=a[c],b.id===this.spaceID)return b.addCtr(this),this.zIndex=b.zIndex,b.numericalControlContainer}else{if("external"===this.region)return this.parent.externalSpace.addCtr(this),this.parent.externalSpace.container;if("scenario"===this.region)return this.cID?(this.expresion=this.evaluator.parser.parse("(0,-1000,"+this.w+","+this.h+")"),this.parent.stage.stageSpace.addCtr(this),this.zIndex=this.parent.stage.stageSpace.zIndex,this.parent.stage.stageSpace.numericalControlContainer):
this.parent.externalSpace.container;if(/north|south|east|west/.test(this.region))return this.parent[this.region+"Space"].controls.push(this),this.parent[this.region+"Space"].container}a[0].addCtr(this);this.zIndex=a[0].zIndex;return a[0].numericalControlContainer};a.Control.prototype.addControlContainer=function(a){var b=this.getContainer();b.childNodes[0]?b.insertBefore(a,b.childNodes[0]):b.appendChild(a)};a.Control.prototype.updatePositionAndSize=function(){c=h=g=b=!1;u=this.evaluator.eval(this.expresion);
n=d(u[0][0]);c=d(this.x)!==n;this.x=n;n=d(u[0][1]);h=d(this.y)!==n;this.y=n;4===u[0].length&&(n=d(u[0][2]),g=d(this.w)!==n,this.w=n,n=d(u[0][3]),b=d(this.h)!==n,this.h=n);if(g||b||c||h)this.init(!0),this.draw()};a.Control.prototype.formatOutputValue=function(a){e=this.parent;r=a+"";q=this.evaluator.eval(this.decimals);t=r.indexOf(".");-1!=t&&(v=r.substring(t+1),v.length>q&&(r=parseFloat(r).toFixed(q)));this.fixed&&(2!==e.version||2===e.version&&!this.exponentialif)&&(r=parseFloat(a).toFixed(q));this.exponentialif&&
0!=parseFloat(r)&&(r=this.fixed&&2!==e.version?parseFloat(r).toExponential(q):parseFloat(r).toExponential(),r=r.toUpperCase().replace("+",""));return r.replace(".",e.decimal_symbol)};a.Control.prototype.updateAndExecAction=function(){this.parent.updateControls();"init"===this.action&&(this.click=!1);this.actionExec.execute();this.parent.updateControls();"animate"!==this.action&&this.parent.update()};a.Control.prototype.createGradient=function(a,b){this.linearGradient=this.ctx.createLinearGradient(0,
0,0,b);f=b*b;for(var c=0;c<b;c++)p=k(c-35*b/100),this.linearGradient.addColorStop(c/b,"rgba(0,0,0,"+p*p*192/f/255+")")};a.Control.prototype.getScreenshot=function(){l=this;m=document.createElement("canvas");m.setAttribute("width",l.w);m.setAttribute("height",l.h);w=m.getContext("2d");w.font=l.fieldFontSize+"px Arial, Helvetica, Sans-serif";l.canvas&&(x=l.canvas.offsetLeft,A=l.canvas.offsetTop,w.drawImage(l.canvas,x,A));l.label&&(x=l.label.offsetLeft,A=l.label.offsetTop,D=l.label.offsetWidth,B=l.label.offsetHeight,
w.fillStyle="#e0e4e8",w.fillRect(x,A,D,B),w.fillStyle="black",w.textAlign="center",w.textBaseline="middle",w.fillText(l.name,x+D/2,A+B/2));l.field&&(x=l.field.offsetLeft,A=l.field.offsetTop,D=l.field.offsetWidth,B=l.field.offsetHeight,w.fillStyle="white",w.strokeStyle="#666",w.lineWidth=1,w.fillRect(x,0,D,B),w.strokeRect(x+.5,.5,D-1,B-1),w.fillStyle="black",w.textAlign="center",w.textAlign="left",w.fillText(l.field.value,x+2,B/2));l.select&&(x=l.select.offsetLeft,A=l.select.offsetTop,D=l.select.offsetWidth,
B=l.select.offsetHeight,w.fillStyle="#e0e4e8",w.strokeStyle="#666",w.lineWidth=1,w.fillRect(x,0,D,B),w.strokeRect(x+.5,.5,D,B-1),w.fillStyle="black",w.textAlign="center",w.textAlign="left",w.fillText(l.select.value,x+2,B/2),w.fillStyle="#c0c0c0",w.fillRect(x+D-15+.5,.5,15,B-1),w.strokeRect(x+D-15+.5,.5,15,B-1),w.fillStyle="black",w.beginPath(),w.moveTo(x+D-15+4.5,B/2-2.5),w.lineTo(x+D-15+8,B/2+2.5),w.lineTo(x+D-15+11.5,B/2-2.5),w.closePath(),w.fill());return m};return a}(descartesJS||{}),descartesJS=
function(a){if(a.loadLib)return a;var k=Math.floor,d=Math.abs,f,p,c,h,g,b,u,n,r,q,t,v,e,m,w,l,x,A,D=/[\w\.\-//]*(\.gif)/gi,B,E,G,F,J,C,z,I,H,M,y,L,K;a.Button=function(b,c){this.imageSrc="";this.image=new Image;this.imageOver=new Image;this.imageDown=new Image;a.Control.call(this,b,c);this.ratio=b.ratio;-1===this.font_size&&(this.fontSizeNotSet=!0);"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=
this.parser.parse("'"+this.name+"'");var e;this.classContainer="";if(this.imageSrc.trim().match("^_STYLE_")){this.customStyle=!0;this.canvasStyle=[];this.conStyle=[];this.conStyle.textBorder=3;e=this.imageSrc.trim().substring(8).split("|");for(var d,g,n=0,q=e.length;n<q;n++)d=e[n],g=d.match(/rgb/g),d.match("class=")?this.classContainer=" "+d.substring(6):d.match("border=")?(this.canvasStyle.push({type:"border-style",value:"solid"}),this.canvasStyle.push({type:"border-width",value:d.substring(7).trim()+
"px"})):d.match("borderRadius=")?(this.canvasStyle.push({type:"border-radius",value:d.substring(13).trim()+"px"}),this.conStyle.push({type:"border-radius",value:d.substring(13).trim()+"px"})):d.match("borderColor=")?this.canvasStyle.push({type:"border-color",value:(g?"":"#")+d.substring(12).trim()}):d.match("overColor=")?this.conStyle.overColor=(g?"":"#")+d.substring(10).trim():d.match("downColor=")?this.conStyle.downColor=(g?"":"#")+d.substring(10).trim():d.match("font=")?this.conStyle.font=d.substring(5).trim().toLowerCase():
d.match("inactiveColor=")?this.conStyle.inactiveColor=(g?"":"#")+d.substring(14).trim():d.match("inactiveColorBorder=")?this.conStyle.inactiveColorBorder=(g?"":"#")+d.substring(20).trim():d.match("shadowTextBlur=")?this.conStyle.shadowTextBlur=parseFloat(d.substring(15).trim()):d.match("shadowTextOffsetX=")?this.conStyle.shadowTextOffsetX=parseFloat(d.substring(18).trim()):d.match("shadowTextOffsetY=")?this.conStyle.shadowTextOffsetY=parseFloat(d.substring(18).trim()):d.match("shadowTextColor=")?
this.conStyle.shadowTextColor=(g?"":"#")+d.substring(16).trim():d.match("shadowBoxBlur=")?this.conStyle.shadowBoxBlur=parseFloat(d.substring(14).trim()):d.match("shadowBoxOffsetX=")?this.conStyle.shadowBoxOffsetX=parseFloat(d.substring(17).trim()):d.match("shadowBoxOffsetY=")?this.conStyle.shadowBoxOffsetY=parseFloat(d.substring(17).trim()):d.match("shadowBoxColor=")?this.conStyle.shadowBoxColor=(g?"":"#")+d.substring(15).trim():d.match("shadowInsetBoxBlur=")?this.conStyle.shadowInsetBoxBlur=parseFloat(d.substring(19).trim()):
d.match("shadowInsetBoxOffsetX=")?this.conStyle.shadowInsetBoxOffsetX=parseFloat(d.substring(22).trim()):d.match("shadowInsetBoxOffsetY=")?this.conStyle.shadowInsetBoxOffsetY=parseFloat(d.substring(22).trim()):d.match("shadowInsetBoxColor=")?this.conStyle.shadowInsetBoxColor=(g?"":"#")+d.substring(20).trim():d.match("textBorder=")&&(this.conStyle.textBorder=parseFloat(d.substring(11).trim()));this.imageSrc="vacio.gif"}this.imageSrc.match("_COLORES_")&&(e=this.imageSrc.split("_"),this.colorInt=new a.Color(e[2]),
this.color=new a.Color(e[3]),this.font_size=this.parser.parse(e[5]),this.imageSrc="");"["==this.imageSrc.charAt(0)?this.imageSrc=this.parser.parse(this.imageSrc.substring(1,this.imageSrc.length-1)):this.imageSrc=this.parser.parse("'"+this.imageSrc+"'");e=this.evaluator.eval(this.imageSrc).toString().trim();""!=e&&(d=e.substr(0,e.lastIndexOf(".")),g=e.substr(e.lastIndexOf(".")),e.toLowerCase().match(/vacio.gif$/)?(this.imageSrc=this.parser.parse("'vacio.gif'"),this.image.ready=1,3===this.parent.version&&
(this.name=this.parser.parse("")),this.emptyImage={ready:!0},this.parser.parse("'vacio.gif'")):(this.image=this.parent.getImage(e),d&&(this.imageOver=this.parent.getImage(d+"_over"+g),this.imageDown=this.parent.getImage(d+"_down"+g))));this.container=document.createElement("div");this.container.setAttribute("class","DescartesButtonContainer"+this.classContainer);this.container.setAttribute("id",this.id);this.container.setAttribute("style","width:"+this.w+"px; height:"+this.h+"px; left:"+this.x+"px; top:"+
this.y+"px; z-index:"+this.zIndex+";");this.canvas=document.createElement("canvas");this.canvas.width=this.w*this.ratio;this.canvas.height=this.h*this.ratio;this.canvas.setAttribute("style","position:absolute; left:0px; top:0px; width:"+this.w+"px; height:"+this.h+"px; -webkit-box-sizing:border-box; -moz-box-sizing:border-box; box-sizing:border-box;");this.ctx=this.canvas.getContext("2d");this.ctx.imageSmoothingEnabled=!1;this.container.appendChild(this.canvas);this.addControlContainer(this.container);
this.addEvents();this.init()};a.extend(a.Button,a.Control);a.Button.prototype.init=function(b){f=this.evaluator;B=this.container;p=this.canvas;c=this.ctx;h=f.eval(this.expresion);this.x=h[0][0];this.y=h[0][1];4==h[0].length&&(this.w=parseInt(h[0][2]),this.h=parseInt(h[0][3]));p.width=this.w*this.ratio;p.height=this.h*this.ratio;p.setAttribute("style","position:absolute; left:0px; top:0px; width:"+this.w+"px; height:"+this.h+"px; -webkit-box-sizing:border-box; -moz-box-sizing:border-box; box-sizing:border-box;");
B.setAttribute("style","width:"+this.w+"px; height:"+this.h+"px; left:"+this.x+"px; top:"+this.y+"px; z-index:"+this.zIndex+"; display:block;");if(this.canvasStyle)for(var e=0,d=this.canvasStyle.length;e<d;e++)p.style[this.canvasStyle[e].type]=this.canvasStyle[e].value;if(this.conStyle){e=0;for(d=this.conStyle.length;e<d;e++)B.style[this.conStyle[e].type]=this.conStyle[e].value;if(this.conStyle.shadowBoxColor){var e=this.conStyle.shadowBoxOffsetX||0,d=this.conStyle.shadowBoxOffsetY||2,g=this.conStyle.shadowBoxBlur||
2;B.style.boxShadow=e+"px "+d+"px "+g+"px 1px "+this.conStyle.shadowBoxColor}this.conStyle.shadowInsetBoxColor&&(e=this.conStyle.shadowInsetBoxOffsetX||0,d=this.conStyle.shadowInsetBoxOffsetY||-2,g=this.conStyle.shadowInsetBoxBlur||1,p.style.boxShadow=e+"px "+d+"px "+g+"px 1px "+this.conStyle.shadowInsetBoxColor+" inset");this.conStyle.shadowTextColor&&(c.shadowBlur=this.conStyle.shadowTextBlur||1,c.shadowOffsetX=this.conStyle.shadowTextOffsetX||0,c.shadowOffsetY=this.conStyle.shadowTextOffsetY||
2,c.shadowColor=this.conStyle.shadowTextColor)}this.fontSizeNotSet&&(this.font_size=f.parser.parse(a.getFieldFontSize(this.h)+""));this.fs_evaluated=f.eval(this.font_size);this.createGradient(this.w,this.h);B.style.display=0<f.eval(this.drawif)?"block":"none";c.textAlign="center";c.textBaseline="middle";c.lineJoin="round";c.font=this.italics+" "+this.bold+" "+this.fs_evaluated+"px descartesJS_sansserif,Arial,Helvetica,Sans-serif";this.customStyle&&("serif"==this.conStyle.font?c.font=this.italics+
" "+this.bold+" "+this.fs_evaluated+"px descartesJS_serif,Times,'Times New Roman', serif":"monospace"==this.conStyle.font?c.font=this.italics+" "+this.bold+" "+this.fs_evaluated+"px descartesJS_monospace,Courier,'Courier New',Monospace":"icons"==this.conStyle.font&&(c.font=this.italics+" "+this.bold+" "+this.fs_evaluated+"px descartesJS_icons,Arial,Helvetica,Sans-serif"));this.draw(b)};a.Button.prototype.update=function(){f=this.evaluator;B=this.container;p=this.canvas;this.activeIfValue=0<f.eval(this.activeif);
(this.drawIfValue=0<f.eval(this.drawif))?(B.style.display="block",this.draw()):(B.style.display="none",this.buttonClick=!1);B.style.cursor=this.activeIfValue?"pointer":"not-allowed";p.style.cursor=this.activeIfValue?"pointer":"not-allowed";B.setAttribute("data-active",this.activeIfValue?"true":"false");this.updatePositionAndSize()};a.Button.prototype.draw=function(d){B=this.container;f=this.evaluator;p=this.canvas;c=this.ctx;b=f.eval(this.name);u=this.evaluator.eval(this.imageSrc).toString().trim();
if(!d&&(E=this.over===this.oldOver,G=this.buttonClick===this.oldButtonClick,F=this.activeIfValue===this.oldActiveIfValue,J=this.drawIfValue===this.oldDrawIfValue,C=b===this.oldName,z=u===this.oldImageSrc,this.oldOver=this.over,this.oldButtonClick=this.buttonClick,this.oldActiveIfValue=this.activeIfValue,this.oldDrawIfValue=this.drawIfValue,this.oldName=b,this.oldImageSrc=u,E&&G&&F&&J&&C&&z))return;c.save();c.setTransform(this.ratio,0,0,this.ratio,0,0);g=this.fs_evaluated;B.setAttribute("data-name",
b);u?(n="vacio.gif"===u?this.emptyImage:this.parent.getImage(u),I=u.substr(0,u.lastIndexOf(".")),H=u.substr(u.lastIndexOf(".")),M=I+"_over"+H,y=I+"_down"+H,L="vacio.gif"===u?this.emptyImage:this.parent.getImage(M),K="vacio.gif"===u?this.emptyImage:this.parent.getImage(y)):K=L=n=this.emptyImage;c.clearRect(0,0,this.w,this.h);q=r=0;this.buttonClick&&(q=r=1);m=k(this.w/2+r)-.5;w=k(this.h/2+q)-.5;n&&(l=n.height||1E8,x=a.getFontMetrics(this.italics+" "+this.bold+" "+g+"px descartesJS_sansserif, Arial, Helvetica, Sans-serif").h,
A=""!=b?0<=this.h-l-x-2?!0:!1:!1,v=parseInt((this.w-n.width)/2)+r,e=A?parseInt((this.h-x-n.height+2)/2):parseInt((this.h-n.height)/2)+q,A&&(w=parseInt(this.h-x/2-2),B.style.backgroundColor=this.colorInt.getColor(),c.strokeStyle=this.color.getColor(),c.lineWidth=1,c.beginPath(),c.moveTo(.5,.5),c.lineTo(this.w-.5,.5),c.lineTo(this.w-.5,this.h-.5),c.lineTo(.5,this.h-.5),c.closePath(),c.stroke()));n&&n.ready?n!==this.emptyImage&&n.complete?u.match(D)?(this.canvas.style.backgroundRepeat="no-repeat",this.canvas.style.backgroundImage=
"url('"+u+"')",this.canvas.style.backgroundPosition=v+"px "+e+"px"):c.drawImage(n,v,e):this.emptyImage&&this.customStyle&&(B.style.backgroundColor=this.colorInt.getColor()):(B.style.backgroundColor=this.colorInt.getColor(),this.buttonClick||(a.drawLine(c,this.w-1,0,this.w-1,this.h,"rgba(0,0,0,0.5)"),a.drawLine(c,0,0,0,this.h,"rgba(0,0,0,0.09)"),a.drawLine(c,1,0,1,this.h,"rgba(0,0,0,0.03)")),c.fillStyle=this.linearGradient,c.fillRect(0,0,this.w,this.h));this.activeIfValue&&(L!==this.emptyImage&&this.over&&
L.ready&&L.complete?M.match(D)?(this.canvas.style.backgroundImage="url('"+M+"')",this.canvas.style.backgroundPosition=v+"px "+e+"px"):c.drawImage(L,v,e):this.customStyle&&this.conStyle.overColor&&this.over&&(B.style.backgroundColor=this.conStyle.overColor));this.activeIfValue?K!==this.emptyImage&&this.buttonClick&&K.ready&&K.complete?y.match(D)?(this.canvas.style.backgroundImage="url('"+y+"')",this.canvas.style.backgroundPosition=v+"px "+e+"px"):c.drawImage(K,v,e):this.customStyle&&this.conStyle.downColor&&
this.buttonClick&&(B.style.backgroundColor=this.conStyle.downColor):this.buttonClick&&!n&&(c.fillStyle="rgba(0,0,0,0.09)",c.fillRect(0,0,this.w,this.h));c.fillStyle=this.color.getColor();this.customStyle&&this.conStyle.shadowTextColor&&0<this.conStyle.textBorder&&(c.lineWidth=this.conStyle.textBorder,c.strokeStyle=this.conStyle.shadowTextColor,c.strokeText(b,m,w));A||this.conStyle||!this.drawTextBorder()||(c.lineWidth=parseInt(g/6),c.strokeStyle=this.colorInt.getColor(),c.strokeText(b,m,w));c.fillText(b,
m,w);this.underlined&&(t=c.measureText(b).width,c.strokeStyle=this.color.getColor(),c.lineWidth=k(g/10)||2,c.lineCap="round",c.beginPath(),c.moveTo(parseInt((this.w-t)/2)+r,w+k(g/2)+k(g/5)-1.5),c.lineTo(parseInt((this.w+t)/2)+r,w+k(g/2)+k(g/5)-1.5),c.stroke());this.activeIfValue||(this.customStyle&&this.conStyle.inactiveColor?B.style.backgroundColor=this.conStyle.inactiveColor:(c.fillStyle="rgba(240,240,240,0.6)",c.fillRect(0,0,this.w,this.h)));c.restore();this._image_pos_x=v;this._image_pos_y=e};
a.Button.prototype.drawTextBorder=function(){this.colorInt.getColor();this.color.getColor();return!(.5>(d(this.colorInt.r-this.color.r)+d(this.colorInt.g-this.color.g)+d(this.colorInt.b-this.color.b))/255)};a.Button.prototype.buttonPressed=function(){this.updateAndExecAction()};a.Button.prototype.addEvents=function(){function b(c,e,n){a.clearTimeout(g);d.buttonClick&&d.drawIfValue&&d.activeIfValue&&(e.call(d),c=n?c:100,g=a.setTimeout(function(){b(c,e,!1)},c))}function c(g){this.focus();g.preventDefault();
g.stopPropagation();document.activeElement!=document.body&&document.activeElement.blur();d.whichBtn=a.whichBtn(g);"L"==d.whichBtn&&d.activeIfValue&&(d.buttonClick=!0,d.draw(),"calculate"==d.action&&(d.evaluator.setVariable(d.id,d.evaluator.eval(d.valueExpr)),b(1E3,d.buttonPressed,!0)),d.canvas.removeEventListener("touchend",e),d.canvas.addEventListener("touchend",e),d.canvas.removeEventListener("mouseup",e),d.canvas.addEventListener("mouseup",e))}function e(a){this.focus();a.preventDefault();a.stopPropagation();
if(d.activeIfValue||d.buttonClick)d.buttonClick=!1,d.draw(),"calculate"!=d.action&&(d.evaluator.setVariable(d.id,d.evaluator.eval(d.valueExpr)),d.buttonPressed()),d.canvas.removeEventListener("touchend",e),d.canvas.removeEventListener("mouseup",e);d.parent.update()}var d=this,g;d.canvas.oncontextmenu=function(){return!1};this.over=this.buttonClick=!1;this.canvas.addEventListener("touchstart",c);this.canvas.addEventListener("mousedown",c);this.canvas.addEventListener("mouseover",function(a){a.preventDefault();
a.stopPropagation();d.over=!0;d.draw()});this.canvas.addEventListener("mouseout",function(a){a.preventDefault();a.stopPropagation();d.over=!1;d.buttonClick=!1;d.draw()});document.addEventListener("visibilitychange",function(a){d.buttonClick=!1})};a.Button.prototype.getScreenshot=function(){var a=document.createElement("canvas");a.width=this.w;a.height=this.h;c=a.getContext("2d");u=f.eval(this.imageSrc);(n="vacio.gif"===u?this.emptyImage:this.parent.getImage(u))&&n.ready?c.drawImage(n,this._image_pos_x,
this._image_pos_y):(c.fillStyle=this.colorInt.getColor(),c.fillRect(0,0,this.w,this.h));c.drawImage(this.canvas,0,0);return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k,d,f,p,c,h,g,b,u,n,r,q,t,v,e,m,w,l;a.Spinner=function(b,c){a.Control.call(this,b,c);this.tabindex=++this.parent.tabindex;"_._"==this.name&&(this.name="");"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=
this.parser.parse("'"+this.name+"'");this.containerControl=document.createElement("div");this.canvas=document.createElement("canvas");this.divUp=document.createElement("div");this.divDown=document.createElement("div");this.field=document.createElement("input");this.label=document.createElement("label");this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.field);this.containerControl.appendChild(this.canvas);this.containerControl.appendChild(this.divUp);this.containerControl.appendChild(this.divDown);
this.addControlContainer(this.containerControl);l=this.evaluator.parser.parse("1");this.originalIncr=this.incr;if(0>=this.evaluator.eval(this.decimals)||0==this.evaluator.eval(this.incr)){var d=this.evaluator.eval(this.incr);0<d?this.originalIncr=this.incr=this.evaluator.parser.parse(parseInt(d).toString()):this.incr=l}this.addEvents();this.init()};a.extend(a.Spinner,a.Control);a.Spinner.prototype.init=function(){k=this.evaluator;var b=k.eval(this.name).toString();this.label.innerHTML=b;this.value=
this.validateValue(k.eval(this.valueExpr));var c=this.formatOutputValue(this.value);this.fieldFontSize=2!==this.parent.version?a.getFieldFontSize(this.h):10;var d=2!==this.parent.version?"__":"_____",e=a.getTextWidth(c+"_",this.fieldFontSize+"px Arial"),g=2+parseInt(this.h/2),n=parseInt(this.w/2-g/2),d=a.getTextWidth(b+d,this.fieldFontSize+"px Arial");this.visible||(n=this.w-g,e=0);n<d&&(n=d);""==b&&(n=0);this.w-n-g<e&&(n=this.w-g-e);0>n&&(n=0);b=this.w-(n+g);this.containerControl.setAttribute("class",
"DescartesSpinnerContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.containerControl.setAttribute("id",this.id);this.canvas.setAttribute("width",g+"px");this.canvas.setAttribute("height",this.h+"px");this.canvas.setAttribute("style","position: absolute; left: "+n+"px; top: 0px;");this.ctx=this.canvas.getContext("2d");this.ctx.imageSmoothingEnabled=!1;this.divUp.setAttribute("class",
"up");this.divUp.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+g+"px; height : "+this.h/2+"px; left: "+n+"px; top: 0px;");this.divDown.setAttribute("class","down");this.divDown.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+g+"px; height : "+this.h/2+"px; left: "+n+"px; top: "+this.h/2+"px;");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"_spinner");
this.field.setAttribute("class","DescartesSpinnerField");this.field.setAttribute("style","font-family: Arial; font-size: "+this.fieldFontSize+"px; width : "+b+"px; height : "+this.h+"px; left: "+(g+n)+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.value=c;this.visible||(this.field.style.display="none");this.label.setAttribute("class","DescartesSpinnerLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+n+"px; height: "+this.h+"px; line-height: "+
this.h+"px;");k.setVariable(this.id,this.value);this.createGradient(this.h/2,this.h)};a.Spinner.prototype.update=function(){k=this.evaluator;this.label.innerHTML=k.eval(this.name).toString();0>=k.eval(this.decimals)?(d=k.eval(this.incr),0<d?this.originalIncr=this.incr=k.parser.parse(parseInt(d).toString()):this.incr=l):this.incr=0!=k.eval(this.originalIncr)?this.originalIncr:l;this.activeIfValue=0<k.eval(this.activeif);this.drawIfValue=0<k.eval(this.drawif);this.field.disabled=!this.activeIfValue;
this.drawIfValue?(this.containerControl.style.display="block",this.draw()):(this.click=!1,this.containerControl.style.display="none");this.updatePositionAndSize();this.parent.animation.playing&&document.activeElement==this.field||(f=this.field.value,p=this.value,this.value=this.validateValue(k.getVariable(this.id)),this.field.value=this.formatOutputValue(this.value),this.value==p&&this.field.value!=f&&(this.value=this.validateValue(f),this.field.value=this.formatOutputValue(this.value)),k.setVariable(this.id,
this.value))};a.Spinner.prototype.draw=function(){c=this.ctx;h=this.canvas.width;g=this.canvas.height;c.fillStyle="#f0f8ff";c.fillRect(0,0,h,g);c.fillStyle=this.linearGradient;c.fillRect(0,0,h,g);this.up?(b="gray",u="#f0f8ff"):(b="#f0f8ff",u="gray");a.drawLine(c,0,0,h,0,b);a.drawLine(c,0,0,0,g/2,b);a.drawLine(c,0,g/2,h,g/2,u);this.down?(b="gray",u="#f0f8ff"):(b="#f0f8ff",u="gray");a.drawLine(c,0,g/2+1,h,g/2+1,b);a.drawLine(c,0,g/2+1,0,g,b);a.drawLine(c,0,g-1,h,g-1,u);n=[parseInt(h/2+1),parseInt(h/
5+1),parseInt(h-h/5+1)];r=[parseInt(g/8+1),parseInt(g/8+1+g/4),parseInt(g/8+1+g/4)];c.fillStyle=this.activeIfValue?"#2244cc":"#8888aa";c.beginPath();c.moveTo(n[0],r[0]);c.lineTo(n[1],r[1]);c.lineTo(n[2],r[2]);c.fill();r=[parseInt(g-g/8),parseInt(g-g/8-g/4),parseInt(g-g/8-g/4)];c.fillStyle=this.activeIfValue?"#d00018":"#aa8888";c.beginPath();c.moveTo(n[0],r[0]);c.lineTo(n[1],r[1]);c.lineTo(n[2],r[2]);c.fill();c.fillStyle="rgba(0,0,0,"+24/255+")";this.up&&c.fillRect(0,0,h,g/2);this.down&&c.fillRect(0,
g/2,h,g)};a.Spinner.prototype.validateValue=function(a){k=this.evaluator;isNaN(parseFloat(a))||a.toString().match("e")&&(a=parseFloat(a).toFixed(20));a=void 0!=a?a.toString():"0";a=a.replace(this.parent.decimal_symbol,".");q=a==parseFloat(a)?parseFloat(a):parseFloat(k.eval(k.parser.parse(a)));isNaN(q)&&(q=0);e=k.eval(this.min);m=k.eval(this.max);""===e&&(e=-Infinity);""===m&&(m=Infinity);q<e&&(q=e);q>m&&(q=m);this.discrete&&(t=k.eval(this.incr),q=0==t?0:t*Math.round(q/t));v=k.eval(this.decimals);
0>=v&&(v=0);return q=parseFloat(parseFloat(q).toFixed(v))};a.Spinner.prototype.increase=function(){this.changeValue(parseFloat(this.value)+this.evaluator.eval(this.incr))};a.Spinner.prototype.decrease=function(){this.changeValue(parseFloat(this.value)-this.evaluator.eval(this.incr))};a.Spinner.prototype.changeValue=function(a){this.activeIfValue&&(this.value=this.validateValue(a),this.field.value=this.formatOutputValue(this.value),this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction())};
a.Spinner.prototype.addEvents=function(){function b(c,d,e){a.clearTimeout(f);if(n.up||n.down)d.call(n),c=e?c:30,f=a.setTimeout(function(){b(c,d)},c)}function c(d){d.preventDefault();n.whichBtn=a.whichBtn(d);"L"==n.whichBtn&&n.activeIfValue&&(n.up=!0,b(q,n.increase,!0),n.draw())}function d(c){c.preventDefault();n.whichBtn=a.whichBtn(c);"L"==n.whichBtn&&n.activeIfValue&&(n.down=!0,b(q,n.decrease,!0),n.draw())}function e(b){n.up=!1;a.clearTimeout(f);n.draw()}function g(b){n.down=!1;a.clearTimeout(f);
n.draw()}w=a.hasTouchSupport;var n=this,q=w?500:200,f;n.divUp.oncontextmenu=n.divDown.oncontextmenu=n.field.oncontextmenu=n.label.oncontextmenu=function(){return!1};this.label.addEventListener("touchstart",function(a){a.preventDefault();return!1});this.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.field.addEventListener("keydown",function(a){13==a.keyCode&&n.changeValue(n.field.value)});this.divUp.addEventListener("touchstart",c);this.divUp.addEventListener("mousedown",
c);this.divDown.addEventListener("touchstart",d);this.divDown.addEventListener("mousedown",d);this.divUp.addEventListener("mouseout",function(b){n.up=!1;a.clearTimeout(f);n.draw();b.preventDefault()});this.divDown.addEventListener("mouseout",function(b){n.down=!1;a.clearTimeout(f);n.draw();b.preventDefault()});this.divUp.addEventListener("touchend",e);window.addEventListener("touchend",e);this.divUp.addEventListener("mouseup",e);window.addEventListener("mouseup",e);this.divDown.addEventListener("touchend",
g);window.addEventListener("touchend",g);this.divDown.addEventListener("mouseup",g);window.addEventListener("mouseup",g);document.addEventListener("visibilitychange",function(b){n.up=!1;n.down=!1;a.clearTimeout(f);n.draw()});n.field.addEventListener("click",function(a){this.select();this.focus()})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k,d,f,p,c,h;a.TextField=function(c,b){a.Control.call(this,c,b);"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-
1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name.trim()+"'");void 0===this.valueExprString&&(this.valueExprString=this.onlyText?"0":"");this.emptyString=!1;this.ok=0;this.tabindex=++this.parent.tabindex;this.regExpDecimalSymbol=new RegExp("\\"+this.parent.decimal_symbol,"g");if(this.answer)if(this.answer.match("krypto_")&&(this.answer=(new a.Krypto).decode(this.answer.substring(7))),this.answerPattern=this.answer,this.answer=a.buildRegularExpresionsPatterns(this.answer,
this.evaluator),this.onlyText){var d=this.answerPattern.indexOf("|");this.firstAnswer=-1==d?this.answerPattern:this.answerPattern.substring(0,d)}else this.firstAnswer=this.parser.parse(this.answerPattern.substring(1,this.answerPattern.indexOf(",")));this.onlyText&&(this.valueExprString.match(/^'/)&&this.valueExprString.match(/'$/)||(this.valueExpr=this.evaluator.parser.parse("'"+this.valueExprString+"'")),this.validateValue=function(a){a=a.toString();return"''"==a||"'"==a?"":a&&a.match(/^'/)&&a.match(/'$/)?
a.substring(1,a.length-1):a},this.formatOutputValue=function(a){return a.toString()});""==name.trim()&&(name="");this.containerControl=document.createElement("div");this.field=document.createElement("input");this.label=document.createElement("label");this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.field);this.addControlContainer(this.containerControl);this.addEvents();this.init()};a.extend(a.TextField,a.Control);a.TextField.prototype.init=function(){k=this.evaluator;
var c=k.eval(this.name).toString();this.label.innerHTML=c;this.value=this.validateValue(k.eval(this.valueExpr));var b=this.formatOutputValue(this.value);this.fieldFontSize=a.getFieldFontSize(this.h);var d=a.getTextWidth(b+"_",this.fieldFontSize+"px Arial"),n=parseInt(this.w/2),f=a.getTextWidth(c,this.fieldFontSize+"px Arial");this.visible||(n=this.w,d=0);n<f&&(n=f);""==c&&(n=0);this.w-n<d&&(n=this.w-d);0>n&&(n=0);c=this.w-n;this.containerControl.setAttribute("class","DescartesTextFieldContainer");
this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"TextField");this.field.setAttribute("class","DescartesTextFieldField");this.field.setAttribute("style","font-size: "+this.fieldFontSize+"px; width : "+c+"px; height : "+this.h+"px; left: "+n+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.value=b;this.label.setAttribute("class",
"DescartesTextFieldLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+n+"px; height: "+this.h+"px; line-height: "+this.h+"px;");this.evaluate&&(this.ok=this.evaluateAnswer());this.evaluator.setVariable(this.id,this.value);this.evaluator.setVariable(this.id+".ok",this.ok);this.oldValue=this.value;this.update()};a.TextField.prototype.update=function(){k=this.evaluator;this.label.innerHTML=k.eval(this.name).toString();this.activeIfValue=0<k.eval(this.activeif);this.drawIfValue=
0<k.eval(this.drawif);this.field.disabled=!this.activeIfValue;this.containerControl.style.display=this.drawIfValue?"block":"none";this.updatePositionAndSize();this.parent.animation.playing&&document.activeElement==this.field||(d=this.field.value,f=this.value,this.value=this.validateValue(k.getVariable(this.id)),this.field.value=this.formatOutputValue(this.value),this.value===f&&this.field.value!=d&&(this.value=this.validateValue(d),this.field.value=this.formatOutputValue(this.value)),k.setVariable(this.id,
this.value))};a.TextField.prototype.validateValue=function(a){if(""===a||"''"==a)return"";k=this.evaluator;a=a.toString().replace(this.regExpDecimalSymbol,".","g");p=a==parseFloat(a)?parseFloat(a):parseFloat(k.eval(k.parser.parse(a)));isNaN(p)&&(p=0);c=k.eval(this.min);""==c&&(c=-Infinity);h=k.eval(this.max);""==h&&(h=Infinity);this.discrete&&(a=k.eval(this.incr),p=0==a?0:a*Math.round(p/a));return p=parseFloat(parseFloat(p).toFixed(k.eval(this.decimals)))};a.TextField.prototype.formatOutputValue=
function(a){return""===a?"":this.uber.formatOutputValue.call(this,a)};a.TextField.prototype.changeValue=function(a,b){this.activeIfValue&&(this.value=this.validateValue(a),this.field.value=this.formatOutputValue(this.value),this.evaluate&&(this.ok=this.evaluateAnswer()),this.evaluator.setVariable(this.id,this.value),this.evaluator.setVariable(this.id+".ok",this.ok),this.updateAndExecAction())};a.TextField.prototype.evaluateAnswer=function(){return a.esCorrecto(this.answer,this.value,this.evaluator,
this.answer)};a.TextField.prototype.getFirstAnswer=function(){return this.answer?this.onlyText?this.firstAnswer:this.evaluator.eval(this.firstAnswer):""};a.TextField.prototype.addEvents=function(){var a=this;a.field.oncontextmenu=a.label.oncontextmenu=function(){return!1};a.label.addEventListener("touchstart",function(a){a.preventDefault();return!1});a.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.field.addEventListener("blur",function(b){a.evaluator.eval(a.drawIf)&&
a.changeValue(a.field.value,!0)});this.field.addEventListener("keydown",function(b){a.activeIfValue&&13==b.keyCode&&a.changeValue(a.field.value,!0)});a.field.addEventListener("click",function(a){this.select();this.focus()})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k=Math.abs,d,f,p,c,h,g,b,u,n,r;a.Menu=function(b,c){function g(a){e.options=a.split(",");e.menuOptions=[];e.strValue=[];var b;a=0;for(var c=e.options.length;a<c;a++)b=e.customSplit(e.options[a]),1==b.length?
(e.menuOptions.push(b[0]),e.strValue.push(a.toString())):2==b.length&&(e.menuOptions.push(b[0]),""==b[1]?e.strValue.push(a.toString()):e.strValue.push(b[1]));a=0;for(c=e.menuOptions.length;a<c;a++)e.menuOptions[a].match(/^\[/)&&e.menuOptions[a].match(/\]$/)?e.menuOptions[a]=d.parse(e.menuOptions[a].substring(1,e.menuOptions[a].length-1)):e.menuOptions[a]=d.parse("'"+e.menuOptions[a]+"'");a=0;for(c=e.strValue.length;a<c;a++)e.strValue[a].match(/^\[/)&&e.strValue[a].match(/\]$/)?e.strValue[a]=d.parse(e.strValue[a].substring(1,
e.strValue[a].length-1)):e.strValue[a]=d.parse(e.strValue[a]);for(;e.select.firstChild;)e.select.removeChild(e.select.firstChild);a=0;for(c=e.menuOptions.length;a<c;a++)b=document.createElement("option"),b.innerHTML=f.eval(e.menuOptions[a]),e.select.appendChild(b);return 0}this.options="";a.Control.call(this,b,c);d=this.parser;f=this.evaluator;this.ok=0;this.tabindex=++this.parent.tabindex;this.answer&&(this.answer.match("krypto_")&&(this.answer=(new a.Krypto).decode(this.answer.substring(7))),this.answer=
parseInt(this.answer.split(",")[0].replace("[",""))||0);"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");var e=this;this.evaluator.setFunction(this.id+".setOptions",g);this.containerControl=document.createElement("div");this.label=document.createElement("label");this.select=document.createElement("select");this.field=document.createElement("input");g(this.options);
this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.select);this.visible&&this.containerControl.appendChild(this.field);this.addControlContainer(this.containerControl);this.addEvents();this.init()};a.extend(a.Menu,a.Control);a.Menu.prototype.init=function(b){f=this.evaluator;var c=f.eval(this.name).toString();this.label.innerHTML=c;this.fieldFontSize=2!=this.parent.version?a.getFieldFontSize(this.h):10;var d=0,e=0,g=0;this.value=b?this.value:f.eval(this.valueExpr);
this.indexValue=this.getIndex(this.value);b=0;for(var n=this.menuOptions.length;b<n;b++)g=a.getTextWidth(f.eval(this.menuOptions[b]).toString(),this.fieldFontSize+"px Arial"),g>d&&(d=g,e=b);d+=25;g=a.getTextWidth(this.formatOutputValue(f.eval(this.strValue[e])),this.fieldFontSize+"px Arial")+7;e=a.getTextWidth(c,this.fieldFontSize+"px Arial")+10;""==c&&(e=0);this.visible||(g=0);for(c=this.w-g-e;c<d&&0<e;)e--,c++;for(;c<d&&0<g;)g--,c++;for(;e+c+g+1<this.w;)c++,g++;d=e;b=d+c;g=this.w-b;n=this.formatOutputValue(f.eval(this.strValue[this.indexValue]));
this.containerControl.setAttribute("class","DescartesMenuContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index:"+this.zIndex+";");this.label.setAttribute("class","DescartesMenuLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width:"+e+"px; height:"+this.h+"px; line-height:"+this.h+"px;");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"_menuField");this.field.value=
n;this.field.setAttribute("class","DescartesMenuField");this.field.setAttribute("style","font-size: "+this.fieldFontSize+"px; width: "+g+"px; height: "+this.h+"px; left:"+b+"px;");this.field.setAttribute("tabindex",this.tabindex);this.select.setAttribute("id",this.id+"_menuSelect");this.select.setAttribute("class","DescartesMenuSelect");this.select.setAttribute("style","text-align:left; font-size:"+this.fieldFontSize+"px; width: "+c+"px; height: "+this.h+"px; left: "+d+"px; border: 1.5px solid #7a8a99; background-color: #eeeeee;");
this.select.setAttribute("tabindex",this.tabindex);this.select.selectedIndex=this.indexValue;f.setVariable(this.id,parseFloat(n.replace(this.parent.decimal_symbol,".")));this.update()};a.Menu.prototype.update=function(){f=this.evaluator;this.activeIfValue=0<f.eval(this.activeif);this.drawIfValue=0<f.eval(this.drawif);this.field.disabled=this.activeIfValue?!1:!0;this.select.disabled=this.activeIfValue?!1:!0;this.drawIfValue?this.containerControl.style.display="block":(this.click=!1,this.containerControl.style.display=
"none");if(!this.parent.animation.playing||document.activeElement!=this.select){this.label.innerHTML=f.eval(this.name).toString();for(var a=0,b=this.menuOptions.length;a<b;a++)this.select.options[a].innerHTML=f.eval(this.menuOptions[a]);this.value=f.getVariable(this.id);isNaN(this.value)&&(this.value=0);this.field.value=this.formatOutputValue(this.value);f.setVariable(this.id,parseFloat(this.value));this.select.selectedIndex=parseFloat(this.getIndex(this.value))}this.ok=this.value==this.answer?1:
0;this.evaluator.setVariable(this.id+".ok",this.ok);this.updatePositionAndSize()};a.Menu.prototype.customSplit=function(a){g=!1;b="";u=0;for(n=-1;u<a.length;){r=a.charAt(u);a.charAt(u-1);if("["===r&&-1===n){if(g||""!=b)b+="\u00a6";n++}else"["===r?n++:"]"===r&&0===n?(g=!0,n--):"]"==a.charAt(u)&&(n=0>n?n:n-1);b+=a.charAt(u);u++}return b.split("\u00a6")};a.Menu.prototype.getIndex=function(a){a=parseFloat(a.toString().replace(this.parent.decimal_symbol,"."));p=-1;c=Infinity;for(var b=0,d=this.strValue.length;b<
d;b++)h=k(a-parseFloat(this.evaluator.eval(this.strValue[b]))),h<=c&&(c=h,p=b);return p};a.Menu.prototype.changeValue=function(){this.activeIfValue&&(this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction())};a.Menu.prototype.addEvents=function(){var a=this;a.select.oncontextmenu=a.label.oncontextmenu=a.field.oncontextmenu=function(){return!1};a.label.addEventListener("touchstart",function(a){a.preventDefault();return!1});a.label.addEventListener("mousedown",function(a){a.preventDefault();
return!1});this.select.addEventListener("change",function(b){a.value=a.evaluator.eval(a.strValue[this.selectedIndex]);a.field.value=a.formatOutputValue(a.value);a.evaluator.setVariable(a.id,a.field.value);a.changeValue();b.preventDefault()});this.field.addEventListener("keydown",function(b){13==b.keyCode&&(a.indexValue=a.getIndex(a.field.value),a.value=a.evaluator.eval(a.strValue[a.indexValue]),a.field.value=a.formatOutputValue(a.indexValue),a.select.selectedIndex=a.indexValue,a.changeValue())});
a.field.addEventListener("click",function(a){this.focus()})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k=Math.floor,d,f,p,c,h,g,b,u,n,r,q,t,v,e,m,w,l,x;a.Scrollbar=function(b,c){a.Control.call(this,b,c);"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");this.orientation=this.w>=this.h?"h":"v";this.containerControl=document.createElement("div");
this.canvas=document.createElement("canvas");this.divUp=document.createElement("div");this.divDown=document.createElement("div");this.field=document.createElement("input");this.scrollManipulator=document.createElement("div");this.label=document.createElement("label");this.containerControl.appendChild(this.canvas);this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.divUp);this.containerControl.appendChild(this.divDown);this.containerControl.appendChild(this.field);
this.containerControl.appendChild(this.scrollManipulator);this.addControlContainer(this.containerControl);this.addEvents();this.init()};a.extend(a.Scrollbar,a.Control);a.Scrollbar.prototype.init=function(){d=this.evaluator;0==d.eval(this.decimals)?this.incr=1:this.incr=(d.eval(this.max)-d.eval(this.min))/100;this.value=this.validateValue(d.eval(this.valueExpr));p=this.formatOutputValue(this.value);c=this.evaluator.eval(this.expresion);this.x=c[0][0];this.y=c[0][1];4==c[0].length&&(this.w=c[0][2],
this.h=c[0][3]);this.orientation=this.w>=this.h?"h":"v";this.initScroll(p);this.changeScrollPositionFromValue();this.prePos=this.pos;d.setVariable(this.id,this.value)};a.Scrollbar.prototype.initScroll=function(b){f=this;d=f.evaluator;var c=d.eval(f.name).toString();f.label.innerHTML=c;var e="v"===f.orientation?parseInt(19+5*(f.h-100)/100):f.h;f.fieldFontSize="v"===f.orientation?e-parseInt(f.h/20)-1:2!==f.parent.version?a.getFieldFontSize(e):10;var g=a.getTextWidth(b+"_",f.fieldFontSize+"px Arial"),
n=f.parent.getSpaceById(f.spaceID).h;f.labelHeight=""==c?0:e;f.fieldHeight=""==f.visible?0:e;if("v"===f.orientation)f.canvasWidth=f.w,f.canvasHeight=f.h-f.labelHeight-f.fieldHeight,18<=f.canvasHeight+f.y-n&&(f.canvasHeight=n),c=0,c=f.fieldHeight,g=c+f.canvasHeight,f.canvasX=0,f.canvasY=f.fieldHeight,f.labelWidth=f.w,f.labelY=g,f.upWidth=f.downW=f.w,f.upHeight=f.downH=15,f.upX=0,f.upY=f.fieldHeight,f.downX=0,f.downY=g-f.downH,f.fieldWidth=f.w,f.fieldX=0,f.scrollManipulatorW=f.w,f.scrollManipulatorH=
parseInt((f.canvasHeight-f.upHeight-f.downH-f.labelHeight-f.fieldHeight)/10),f.scrollManipulatorH=15>f.scrollManipulatorH?15:f.scrollManipulatorH,f.scrollManipulatorLimInf=g-f.downH-f.scrollManipulatorH,f.scrollManipulatorLimSup=c+f.downH;else{e=a.getTextWidth(c,f.fieldFontSize+"px Arial")+10;f.labelWidth=e;f.fieldWidth=g;""==c&&(f.labelWidth=0);f.visible||(f.fieldWidth=0);for(g=f.w-f.fieldWidth-f.labelWidth;58>g&&0<f.labelWidth;)f.labelWidth--,g++;for(;58>g&&0<f.fieldWidth;)f.fieldWidth--,g++;c=
f.labelWidth;e=c+g;f.fieldWidth=f.w-e;f.canvasWidth=g;f.canvasHeight=f.h;f.canvasX=f.labelWidth;f.canvasY=0;f.fieldX=f.canvasWidth+f.labelWidth;f.labelHeight=f.h;f.labelY=0;f.upWidth=f.downW=15;f.upHeight=f.downH=f.h;f.upX=e-f.downW;f.upY=0;f.downX=f.labelWidth;f.downY=0;f.scrollManipulatorW=parseInt((f.canvasWidth-f.upWidth-f.downW)/10);f.scrollManipulatorW=15>f.scrollManipulatorW?15:f.scrollManipulatorW;f.scrollManipulatorH=f.h;f.scrollManipulatorLimInf=c+f.downW;f.scrollManipulatorLimSup=c+f.canvasWidth-
f.downW-f.scrollManipulatorW}f.containerControl.setAttribute("class","DescartesScrollbarContainer");f.containerControl.setAttribute("id",f.id);f.containerControl.setAttribute("style","width: "+f.w+"px; height: "+f.h+"px; left: "+f.x+"px; top: "+f.y+"px; z-index: "+f.zIndex+";");f.canvas.setAttribute("width",f.w+"px");f.canvas.setAttribute("height",f.h+"px");f.canvas.setAttribute("style","position: absolute; left: 0px; top: 0px;");f.ctx=f.canvas.getContext("2d");f.ctx.imageSmoothingEnabled=!1;f.divUp.setAttribute("class",
"DescartesCatcher up");f.divUp.setAttribute("style","width : "+f.upWidth+"px; height : "+f.upHeight+"px; left: "+f.upX+"px; top: "+f.upY+"px;");f.divDown.setAttribute("class","DescartesCatcher down");f.divDown.setAttribute("style","width : "+f.downW+"px; height : "+f.downH+"px; left: "+f.downX+"px; top: "+f.downY+"px;");f.scrollManipulator.setAttribute("class","DescartesCatcher manipulator");f.scrollManipulator.setAttribute("style","width : "+f.scrollManipulatorW+"px; height : "+f.scrollManipulatorH+
"px;");f.scrollManipulator.style.top=("v"===f.orientation?f.scrollManipulatorLimInf:0)+"px";f.scrollManipulator.style.left=("v"===f.orientation?0:f.scrollManipulatorLimInf)+"px";f.field.setAttribute("type","text");f.field.setAttribute("id",f.id+"scrollbar");f.field.setAttribute("class","DescartesScrollbarField");f.field.setAttribute("style","font-size: "+f.fieldFontSize+"px; width : "+f.fieldWidth+"px; height : "+f.fieldHeight+"px; left: "+f.fieldX+"px; top: 0px;");f.field.value=b;0===f.fieldHeight&&
(f.field.style.display="none");f.label.setAttribute("class","DescartesScrollbarLabel");f.label.setAttribute("style","font-size:"+f.fieldFontSize+"px; width: "+f.labelWidth+"px; height: "+f.labelHeight+"px; line-height: "+f.labelHeight+"px; left: 0px; top:"+f.labelY+"px;")};a.Scrollbar.prototype.update=function(){d=this.evaluator;this.label.innerHTML=d.eval(this.name).toString();0==d.eval(this.decimals)?this.incr=1:this.incr=(d.eval(this.max)-d.eval(this.min))/100;this.activeIfValue=0<d.eval(this.activeif);
this.drawIfValue=0<d.eval(this.drawif);this.field.disabled=!this.activeIfValue;this.drawIfValue?(this.containerControl.style.display="block",this.draw()):this.containerControl.style.display="none";this.updatePositionAndSize();var a=this.validateValue(d.getVariable(this.id));a==this.value||0<Math.abs(a-this.value)&&1E-9>Math.abs(a-this.value)||(this.value=a,this.changeScrollPositionFromValue(),this.prePos=this.pos);this.value=a;this.field.value=this.formatOutputValue(this.value);d.setVariable(this.id,
this.value)};a.Scrollbar.prototype.draw=function(){f=this;h=f.ctx;b=k(this.w);g=k(this.h);h.fillStyle="#e0e4e8";h.fillRect(0,0,b,g);h.strokeStyle="#7a8a99";f.down&&(h.fillStyle="#ccdcec",h.fillRect(f.downX+.5,f.downY+.5,f.downW,f.downH-1));h.strokeRect(f.downX+.5,f.downY+.5,f.downW,f.downH-1);f.up&&(h.fillStyle="#ccdcec",h.fillRect(f.upX+.5,f.upY-.5,f.upWidth,f.upHeight+1));h.strokeRect(f.upX+.5,f.upY-.5,f.upWidth,f.upHeight+1);u=4;h.fillStyle="black";h.beginPath();"h"===f.orientation?(h.moveTo(f.downX+
u,f.downH/2),h.lineTo(f.downX+f.downW-u,u),h.lineTo(f.downX+f.downW-u,f.downH-u),h.moveTo(f.upX+f.upWidth-u,f.downH/2),h.lineTo(f.upX+u,u),h.lineTo(f.upX+u,f.downH-u),h.fill(),f.activeIfValue&&(n=k(f.pos),h.fillStyle="#ccdcec",h.fillRect(n+.5,0,k(f.scrollManipulatorW),g),h.strokeStyle="#6382bf",h.strokeRect(n+.5,0,k(f.scrollManipulatorW),g),r=k(f.scrollManipulatorW/2),h.beginPath(),h.moveTo(n+r+.5-2,3),h.lineTo(n+r+.5-2,g-3),h.moveTo(n+r+.5,3),h.lineTo(n+r+.5,g-3),h.moveTo(n+r+.5+2,3),h.lineTo(n+
r+.5+2,g-3),h.stroke())):(h.moveTo(f.downX+f.downW/2,f.downY+f.downH-u),h.lineTo(f.downX+u,f.downY+u),h.lineTo(f.downX+f.downW-u,f.downY+u),h.moveTo(f.upX+f.upWidth/2,f.upY+u),h.lineTo(f.upX+u,f.upY+f.upHeight-u),h.lineTo(f.upX+f.upWidth-u,f.upY+f.upHeight-u),h.fill(),f.activeIfValue&&(n=k(f.pos),h.fillStyle="#ccdcec",h.fillRect(0,n+.5,b,k(f.scrollManipulatorH)),h.strokeStyle="#6382bf",h.strokeRect(0,n+.5,b,k(f.scrollManipulatorH)),r=k(f.scrollManipulatorH/2),h.beginPath(),h.moveTo(3,n+r+.5-2),h.lineTo(b-
3,n+r+.5-2),h.moveTo(3,n+r+.5),h.lineTo(b-3,n+r+.5),h.moveTo(3,n+r+.5+2),h.lineTo(b-3,n+r+.5+2),h.stroke()));h.strokeRect(.5,.5,b-1,g-1);f.activeIfValue||(h.fillStyle="rgba(240,240,240,"+160/255+")",h.fillRect(0,0,b,g.h))};a.Scrollbar.prototype.validateValue=function(a){d=this.evaluator;q=a.toString();q=parseFloat(q.replace(this.parent.decimal_symbol,"."));isNaN(q)&&(q=0);this.minimo=d.eval(this.min);q<this.minimo&&(this.value=null,q=this.minimo);this.maximo=d.eval(this.max);q>this.maximo&&(this.value=
null,q=this.maximo);t=this.incr;q=0!=t?q*t/t:0;this.fixed&&(q=parseFloat(parseFloat(q).toFixed(d.eval(this.decimals))));return q};a.Scrollbar.prototype.increase=function(){this.changeValue(parseFloat(this.value)+this.incr)};a.Scrollbar.prototype.decrease=function(){this.changeValue(parseFloat(this.value)-this.incr)};a.Scrollbar.prototype.increase10=function(){u=(this.evaluator.eval(this.max)-this.evaluator.eval(this.min))/10;"h"==this.orientation?this.clickPos.x>this.prePos&&this.changeValue(parseFloat(this.value)+
u):this.clickPos.y<this.prePos&&this.changeValue(parseFloat(this.value)+u)};a.Scrollbar.prototype.decrease10=function(){u=(this.evaluator.eval(this.max)-this.evaluator.eval(this.min))/10;"h"==this.orientation?this.clickPos.x<this.prePos&&this.changeValue(parseFloat(this.value)-u):this.clickPos.y>this.prePos&&this.changeValue(parseFloat(this.value)-u)};a.Scrollbar.prototype.changeValue=function(a){this.activeIfValue&&(v=this.validateValue(a),v!=this.value&&(this.value=v,this.field.value=this.formatOutputValue(v),
this.changeScrollPositionFromValue(),this.prePos=this.pos,this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction()))};a.Scrollbar.prototype.changeValueForScrollMovement=function(){d=this.evaluator;e=this.scrollManipulatorLimInf;m=this.scrollManipulatorLimSup;w=d.eval(this.min);l=d.eval(this.max);t=this.incr;v=k((this.pos-e)*(l-w)/(m-e)/t)*t+w;v!=this.value&&(this.value=v,this.field.value=this.formatOutputValue(v),d.setVariable(this.id,this.value),this.parent.updateControls(),this.actionExec.execute(),
this.parent.update())};a.Scrollbar.prototype.changeScrollPositionFromValue=function(){d=this.evaluator;e=this.scrollManipulatorLimInf;m=this.scrollManipulatorLimSup;w=d.eval(this.min);l=d.eval(this.max);t=this.incr;this.pos=(this.value-w)*(m-e)/(l-w)+e;"h"==this.orientation?this.scrollManipulator.style.left=this.pos+"px":this.scrollManipulator.style.top=this.pos+"px"};a.Scrollbar.prototype.addEvents=function(){function b(c,d,e,g){a.clearTimeout(p);(m.up||m.down||m.canvasClick)&&1E-7<Math.abs(m.value-
g)&&(d.call(m),c=e?c:30,p=a.setTimeout(function(){b(c,d,!1,g)},c))}function c(d){d.preventDefault();m.whichBtn=a.whichBtn(d);"L"==m.whichBtn&&m.activeIfValue&&(m.clickPos=a.getCursorPosition(d,m.containerControl),m.canvasClick=!0,"h"==m.orientation?m.clickPos.x<m.prePos?b(t,m.decrease10,!0,m.minimo):b(t,m.increase10,!0,m.maximo):m.clickPos.y<m.prePos?b(t,m.increase10,!0,m.maximo):b(t,m.decrease10,!0,m.minimo))}function d(b){m.canvasClick=!1;a.clearTimeout(p)}function e(b){1==m.canvasClick&&(m.clickPos=
a.getCursorPosition(b,m.containerControl),b.preventDefault())}function g(a){m.scrollClick=!1;m.prePos=m.pos;window.removeEventListener("mouseup",g,!1);window.removeEventListener("mousemove",f,!1);a.preventDefault()}function n(a){m.scrollClick=!1;m.prePos=m.pos;window.removeEventListener("touchend",n,!1);window.removeEventListener("touchmove",f,!1);a.preventDefault()}function f(b){var c=a.getCursorPosition(b,m.containerControl);"h"==m.orientation?(m.pos=m.prePos-(m.initPos.x-c.x),m.pos<m.scrollManipulatorLimInf&&
(m.pos=m.scrollManipulatorLimInf),m.pos>m.scrollManipulatorLimSup&&(m.pos=m.scrollManipulatorLimSup),m.scrollManipulator.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+m.scrollManipulatorW+"px; height : "+m.h+"px; left: "+m.pos+"px; top: 0px;")):(m.pos=m.prePos-(m.initPos.y-c.y),m.pos>m.scrollManipulatorLimInf&&(m.pos=m.scrollManipulatorLimInf),m.pos<m.scrollManipulatorLimSup&&(m.pos=m.scrollManipulatorLimSup),m.scrollManipulator.setAttribute("style",
"background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+m.w+"px; height : "+m.scrollManipulatorH+"px; left: 0px; top: "+m.pos+"px;"));m.changeValueForScrollMovement();b.preventDefault()}function q(c){c.preventDefault();m.whichBtn=a.whichBtn(c);"L"==m.whichBtn&&m.activeIfValue&&(m.up=!0,b(t,m.increase,!0,m.maximo))}function h(c){c.preventDefault();m.whichBtn=a.whichBtn(c);"L"==m.whichBtn&&m.activeIfValue&&(m.down=!0,b(t,m.decrease,!0,m.minimo))}function l(b){m.down=
!1;a.clearTimeout(p);b.preventDefault()}function k(b){m.up=!1;a.clearTimeout(p);m.draw()}function r(b){m.down=!1;a.clearTimeout(p);m.draw()}x=a.hasTouchSupport;var m=this,t=x?500:200,p;m.canvas.oncontextmenu=m.divUp.oncontextmenu=m.divDown.oncontextmenu=m.label.oncontextmenu=m.field.oncontextmenu=m.scrollManipulator.oncontextmenu=function(){return!1};this.field.addEventListener("keydown",function(a){13==a.keyCode&&m.changeValue(m.field.value)});this.canvas.addEventListener("touchstart",c);this.canvas.addEventListener("mousedown",
c);this.divDown.addEventListener("mouseout",l);window.addEventListener("touchend",d);window.addEventListener("mouseup",d);this.canvas.addEventListener("touchmove",e);this.canvas.addEventListener("mousemove",e);this.scrollManipulator.addEventListener("touchstart",function(b){m.activeIfValue&&(m.scrollClick=!0,m.initPos=a.getCursorPosition(b,m.containerControl),window.addEventListener("touchend",n),window.addEventListener("touchmove",f),b.preventDefault())});this.scrollManipulator.addEventListener("mousedown",
function(b){m.activeIfValue&&(m.scrollClick=!0,m.initPos=a.getCursorPosition(b,m.containerControl),window.addEventListener("mouseup",g),window.addEventListener("mousemove",f),b.preventDefault())});this.divUp.addEventListener("touchstart",q);this.divUp.addEventListener("mousedown",q);this.divDown.addEventListener("touchstart",h);this.divDown.addEventListener("mousedown",h);this.divUp.addEventListener("mouseout",function(b){m.up=!1;a.clearTimeout(p);b.preventDefault()});this.divDown.addEventListener("mouseout",
l);window.addEventListener("touchend",k);window.addEventListener("mouseup",k);window.addEventListener("touchend",r);window.addEventListener("mouseup",r)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k;a.Audio=function(d,k){this.controls=!0;this.file="";this.oldDrawIf=0;a.Control.call(this,d,k);var c=this,h=c.evaluator.eval(c.expresion);4==h[0].length?(c.w=h[0][2],c.h=h[0][3]):(c.w=200,c.h=28);c.audio=c.parent.getAudio(c.file);c.autoplay&&(c.audio.setAttribute("autoplay",
"autoplay"),c.audio.play());c.loop&&c.audio.setAttribute("loop","loop");c.controls&&c.audio.setAttribute("controls","controls");c.audio.setAttribute("style","position: absolute; width: "+c.w+"px; left: "+c.x+"px; top: "+c.y+"px; z-index: "+c.zIndex+";");c.addControlContainer(c.audio);c.evaluator.setFunction(c.id+".play",function(){try{c.audio.play()}catch(a){}return 0});c.evaluator.setFunction(c.id+".pause",function(){try{c.audio.pause()}catch(a){}return 0});c.evaluator.setFunction(c.id+".stop",function(){try{c.audio.pause(),
c.audio.currentTime=0}catch(a){}return 0});c.evaluator.setFunction(c.id+".currentTime",function(a){try{c.audio.currentTime=parseFloat(a)}catch(b){}return 0});c.audio.addEventListener("timeupdate",function(a){c.evaluator.setVariable(c.id+".currentTime",c.audio.currentTime)})};a.extend(a.Audio,a.Control);a.Audio.prototype.init=function(){this.audio.style.left=this.x+"px";this.audio.style.top=this.y+"px";this.update()};var d;a.Audio.prototype.update=function(){k=this.evaluator;(d=0<k.eval(this.drawif))?
this.audio.style.display="block":(this.audio.style.display="none",d!==this.oldDrawIf&&this.audio.pause());this.oldDrawIf=d;this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k;a.Video=function(d,p){this.controls=!0;this.file="";this.oldDrawIf=0;a.Control.call(this,d,p);var c=this;k=c.evaluator;var h=c.evaluator.eval(c.expresion);4==h[0].length?(c.w=h[0][2],c.h=h[0][3]):(c.w=null,c.h=null);var h=c.file,g=h.lastIndexOf(".");-1!=g&&(h=c.file.substring(0,
g));c.video=document.createElement("video");c.autoplay&&c.video.setAttribute("autoplay","autoplay");c.loop&&c.video.setAttribute("loop","loop");c.controls&&c.video.setAttribute("controls","controls");c.video.setAttribute("poster",h+".png");c.w&&(c.video.setAttribute("width",c.w),c.video.setAttribute("height",c.h));c.video.setAttribute("style","position:absolute; overflow:hidden; left:"+c.x+"px; top:"+c.y+"px; outline:none; background:rgba(0,0,0,0);");c.video.canPlayType("video/mp4")&&(g=document.createElement("source"),
g.setAttribute("src",h+".mp4"),c.video.appendChild(g));c.video.canPlayType("video/ogg")&&(g=document.createElement("source"),g.setAttribute("src",h+".ogg"),g.setAttribute("type","video/ogg"),c.video.appendChild(g),g=document.createElement("source"),g.setAttribute("src",h+".ogv"),g.setAttribute("type","video/ogg"),c.video.appendChild(g));c.video.canPlayType("video/webm")&&(g=document.createElement("source"),g.setAttribute("src",h+".webm"),g.setAttribute("type","video/webm"),c.video.appendChild(g));
c.addControlContainer(c.video);c.evaluator.setFunction(c.id+".play",function(){try{c.video.play()}catch(a){}return 0});c.evaluator.setFunction(c.id+".pause",function(){try{c.video.pause()}catch(a){}return 0});c.evaluator.setFunction(c.id+".stop",function(){try{c.video.pause(),c.video.currentTime=0}catch(a){}return 0});c.evaluator.setFunction(c.id+".currentTime",function(a){try{c.video.currentTime=parseFloat(a)}catch(d){}return 0});c.video.addEventListener("timeupdate",function(a){c.evaluator.setVariable(c.id+
".currentTime",c.video.currentTime)})};a.extend(a.Video,a.Control);a.Video.prototype.init=function(){this.video.style.left=this.x+"px";this.video.style.top=this.y+"px";this.update()};var d;a.Video.prototype.update=function(){k=this.evaluator;(d=0<k.eval(this.drawif))?this.video.style.display="block":(this.video.style.display="none",d!==this.oldDrawIf&&this.video.pause());this.oldDrawIf=d;this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k,d;
a.TextArea=function(d,k){this.font="Monospaced,PLAIN,12";a.Control.call(this,d,k);this.region="interior";this.tabindex=++this.parent.tabindex;if(this.answer){this.answer.match("krypto_")&&(this.answer=(new a.Krypto).decode(this.answer.substring(7)));var c=this.parent.lessonParser.parseText(this.answer)}this.containerControl=document.createElement("div");this.textArea=document.createElement("div");this.textAreaAnswer=document.createElement("div");this.showButton=document.createElement("div");this.activeCover=
document.createElement("div");this.containerControl.appendChild(this.textArea);this.containerControl.appendChild(this.textAreaAnswer);this.containerControl.appendChild(this.showButton);this.containerControl.appendChild(this.activeCover);this.addControlContainer(this.containerControl);this.showAnswer=!1;this.text=void 0==this.text||"simpleText"==this.text.type?this.rawText||"":this.text.hasFormula?this.rawText:this.text.toHTML();c&&"simpleText"!=c.type&&(this.answer=this.text.hasFormula?"":c.toHTML());
this.evaluator.setVariable(this.id,this.text);this.drawButton();this.addEvents();this.init()};a.extend(a.TextArea,a.Control);a.TextArea.prototype.init=function(){d=this.answer?28:8;k=this.evaluator;var f;f=this.text.match(/<span/)?this.text:this.text.replace(/\\n/g,"<br/>");this.containerControl.setAttribute("class","DescartesTextAreaContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");
this.containerControl.style.display=0<k.eval(this.drawif)?"block":"none";this.containerControl.setAttribute("spellcheck","false");this.textArea.setAttribute("class","DescartesTextAreaContainer");this.textArea.setAttribute("style","width: "+(this.w-8)+"px; height: "+(this.h-d)+"px; left: 4px; top: 4px; background-color: white; text-align: left; font: "+a.convertFont(this.font)+";");this.textArea.setAttribute("contenteditable","true");this.textArea.innerHTML="<span style='position: relative; top: 10px; left: 10px; white-space: nowrap;' >"+
f+"</span>";this.textAreaAnswer.setAttribute("class","DescartesTextAreaContainer");this.textAreaAnswer.setAttribute("style","width: "+(this.w-8)+"px; height: "+(this.h-d)+"px; left: 4px; top: 4px; background-color: white; text-align: left; font: "+a.convertFont(this.font)+";");this.textAreaAnswer.style.display=this.showAnswer?"block":"none";this.textAreaAnswer.innerHTML="<span style='position: relative; top: 10px; left: 10px; white-space: nowrap;'>"+this.answer+"</span>";this.showButton.setAttribute("style",
"width: 20px; height: 16px; position: absolute; bottom: 4px; right: 4px; cursor: pointer;");this.showButton.style.backgroundImage="url("+this.imageUnPush+")";this.showButton.style.display=this.answer?"block":"none";this.showButton.innerHTML="<span style='position: relative; top: 2px; text-align: center; font: 9px Arial'> S </span>";this.activeCover.setAttribute("style","position: absolute; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px;");this.update()};a.TextArea.prototype.drawButton=
function(){var d=document.createElement("canvas");d.setAttribute("width",20);d.setAttribute("height",16);var k=d.getContext("2d");k.imageSmoothingEnabled=!1;this.canvas=d;this.ctx=k;this.createGradient(20,16);k.lineWidth=1;k.fillStyle="white";k.fillRect(0,0,20,16);k.fillStyle=this.linearGradient;k.fillRect(0,0,20,16);a.drawLine(k,19,0,19,16,"rgba(0,0,0,"+128/255+")");a.drawLine(k,0,0,0,16,"rgba(0,0,0,"+24/255+")");a.drawLine(k,1,0,1,16,"rgba(0,0,0,"+8/255+")");this.imageUnPush=d.toDataURL();k.fillStyle=
"white";k.fillRect(0,0,20,16);k.fillStyle=this.linearGradient;k.fillRect(0,0,20,16);a.drawLine(k,0,0,0,14,"gray");a.drawLine(k,0,0,19,0,"gray");k.fillStyle="rgba(0, 0, 0,"+24/255+")";k.fillRect(0,0,this.w,this.h);this.imagePush=d.toDataURL()};a.TextArea.prototype.update=function(){k=this.evaluator;this.activeIfValue=0<k.eval(this.activeif);this.drawIfValue=0<k.eval(this.drawif);var a;a=this.text.match(/<span/)?this.rawText:this.text;k.setVariable(this.id,a);this.activeCover.style.display=this.activeIfValue?
"none":"block";this.containerControl.style.display=this.drawIfValue?"block":"none";this.updatePositionAndSize()};a.TextArea.prototype.addEvents=function(){function a(c){c.preventDefault();d.showButton.style.backgroundImage="url("+d.imageUnPush+")"}var d=this;this.showButton.addEventListener("mousedown",function(a){a.preventDefault();d.showAnswer=!d.showAnswer;d.textAreaAnswer.style.display=d.showAnswer?"block":"none";d.showButton.childNodes[0].childNodes[0].textContent=d.showAnswer?"T":"S";d.showButton.style.backgroundImage=
"url("+d.imagePush+")"});this.showButton.addEventListener("mouseup",a);this.showButton.addEventListener("mouseout",a)};a.TextArea.prototype.getScreenshot=function(){var a=document.createElement("canvas");a.setAttribute("width",this.w);a.setAttribute("height",this.h);var d=a.getContext("2d");d.fillStyle="white";d.strokeStyle="black";d.lineWidth=1;d.fillRect(0,0,this.w,this.h);d.strokeRect(0,0,this.w,this.h);return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k=2*
Math.PI,d,f,p,c,h,g,b,u,n,r;a.GraphicControl=function(b,c){f=b.evaluator.parser;this.text=this.spaceID="";this.size=f.parse("4");this.font="Monospaced,PLAIN,12";this.image=new Image;this.image.onload=function(){this.ready=1};this.imageSrc="";a.Control.call(this,b,c);this.touchId=null;this.font=a.convertFont(this.font);if(this.constraintExpr){this.constraint=f.parse(this.constraintExpr);"(expr)"==this.constraint.type&&(this.constraint=f.parse(this.constraintExpr.substring(1,this.constraintExpr.length-
1)));if("compOperator"==this.constraint.type){var d=this.constraint.childs[0],e=this.constraint.childs[1];"identifier"!=d.type||"y"!=d.value||e.contains("y")?"identifier"!=d.type||"x"!=d.value||e.contains("x")?this.newt=new a.R2Newton(this.evaluator,this.constraint):(this.constVar="y",this.noConstVar="x",this.evalConst=this.evalConstXoY,this.constraint=e):(this.constVar="x",this.noConstVar="y",this.evalConst=this.evalConstXoY,this.constraint=e)}else this.constraint=null;u=new a.R2(0,0)}this.container=
this.getContainer();this.mouseCacher=document.createElement("div");this.mouseCacher.setAttribute("class","DescartesGraphicControl");this.mouseCacher.setAttribute("id",this.id);this.mouseCacher.setAttribute("dragged",!0);this.mouseCacher.setAttribute("tabindex","-1");this.ctx=this.space.ctx;this.container.appendChild(this.mouseCacher);this.addEvents();this.xString=this.id+".x";this.yString=this.id+".y";this.activoString=this.id+".activo";this.activeString=this.id+".active";""!==this.space.id&&2!==
b.version?(this.mxString=this.space.id+".mouse_x",this.myString=this.space.id+".mouse_y",this.mclickedString=this.space.id+".mouse_clicked",this.mclicizquierdoString=this.space.id+".clic_izquierdo"):(this.mxString="mouse_x",this.myString="mouse_y",this.mclickedString="mouse_clicked",this.mclicizquierdoString="clic_izquierdo");this.init()};a.GraphicControl.prototype.init=function(){d=this.evaluator;n=a.hasTouchSupport;var b=d.eval(this.expresion);this.x=b[0][0];this.y=b[0][1];d.setVariable(this.xString,
this.x);d.setVariable(this.yString,this.y);this.mouseCacher.setAttribute("style","cursor:pointer;background-color:rgba(255, 255, 255, 0);z-index:"+this.zIndex+";");""==this.imageSrc||this.imageSrc.toLowerCase().match(/vacio.gif$/)?(this.width=2*d.eval(this.size),this.height=2*d.eval(this.size),this._w=n&&48>this.width?48:this.width,this._h=n&&48>this.height?48:this.height,this.mouseCacher.style.borderRadius=parseInt(Math.min(this._w,this._h)/2)+"px"):(this.image=this.parent.getImage(this.imageSrc),
this.width=this.image.width,this.height=this.image.height,this._w=Math.max(this.width,32),this._h=Math.max(this.height,32));this.mouseCacher.style.width=this._w+"px";this.mouseCacher.style.height=this._h+"px";this.mouseCacher.style.left=parseInt(this.space.getAbsoluteX(this.x)-this._w/2)+"px";this.mouseCacher.style.top=parseInt(this.space.getAbsoluteY(this.y)-this._h/2)+"px";d.setVariable(this.activoString,0);d.setVariable(this.activeString,0);this.setImage=!1;this.update()};a.GraphicControl.prototype.update=
function(){d=this.evaluator;this.activeIfValue=0<d.eval(this.activeif);this.drawIfValue=0<d.eval(this.drawif);this.x=d.getVariable(this.xString);this.y=d.getVariable(this.yString);p=this.space.getAbsoluteX(this.x);c=this.space.getAbsoluteY(this.y);this.mouseCacher.style.display=this.activeIfValue?"block":"none";this.mouseCacher.style.left=parseInt(p-this._w/2)+"px";this.mouseCacher.style.top=parseInt(c-this._h/2)+"px";this.constraint&&this.evalConst();this.draw()};a.GraphicControl.prototype.draw=
function(){d=this.evaluator;this.drawIfValue&&(g=this.ctx,b=this.space.backgroundCtx,p=parseInt(this.space.getAbsoluteX(this.x))+.5,c=parseInt(this.space.getAbsoluteY(this.y))+.5,""!=this.text&&this.drawText(p,c),this.image.ready?(this.image.complete&&!this.setImage&&g.drawImage(this.image,parseInt(p-this.image.width/2),parseInt(c-this.image.height/2)),this.trace&&(b.save(),b.translate(p,c),b.scale(parseInt(this.image.width/2),parseInt(this.image.height/2)),b.beginPath(),b.arc(0,0,1,0,k,!1),b.restore(),
b.lineWidth=1,b.strokeStyle=this.trace.getColor(),b.stroke())):(g.beginPath(),g.arc(p,c,parseInt(this.width/2),0,k,!1),g.fillStyle=this.colorInt.getColor(),g.fill(),g.lineWidth=1,g.strokeStyle=this.color.getColor(),g.stroke(),this.active&&(g.beginPath(),g.arc(p,c,parseInt(this.width/2)-2,0,k,!1),g.strokeStyle=this.colorInt.borderColor(),g.stroke()),this.trace&&(b.lineWidth=1,b.strokeStyle=this.trace.getColor(),b.beginPath(),b.arc(p,c,parseInt(this.width/2),0,k,!1),b.stroke())))};a.GraphicControl.prototype.evalConst=
function(){u.set(this.x,this.y);h=this.newt.findZero(u,1/this.space.scale,!0);this.x=h.x;this.y=h.y;this.evaluator.setVariable(this.xString,this.x);this.evaluator.setVariable(this.yString,this.y)};a.GraphicControl.prototype.evalConstXoY=function(){d=this.evaluator;r=d.getVariable(this.constVar);d.setVariable(this.constVar,this[this.constVar]);this[this.noConstVar]=d.eval(this.constraint);d.setVariable(this.xString,this.x);d.setVariable(this.yString,this.y);d.setVariable(this.constVar,r)};a.GraphicControl.prototype.drawText=
function(a,b){g=this.ctx;d=this.evaluator;"simpleText"==this.text.type?(g.fillStyle=this.color.getColor(),g.font=this.font,g.textBaseline="alphabetic",g.fillText(this.text.toString(d.eval(this.decimals),this.fixed),parseInt(a+1+this.width/2),parseInt(b-1-this.height/2))):(g.fillStyle=this.color.getColor(),g.strokeStyle=this.color.getColor(),g.textBaseline="alphabetic",this.text.draw(g,parseInt(a+1+this.width/2),parseInt(b-1-this.height/2),this.decimals,this.fixed,"start",!0,this.color.getColor()))};
a.GraphicControl.prototype.getContainer=function(){for(var a=this.parent.spaces,b,c=0,d=a.length;c<d;c++)if(b=a[c],b.id==this.spaceID)return b.addCtr(this),this.zIndex=b.zIndex,this.space=b,b.graphicControlContainer;a[0].addCtr(this);this.zIndex=a[0].zIndex;this.space=a[0];return a[0].graphicControlContainer};a.GraphicControl.prototype.deactivate=function(){this.active=!1;this.evaluator.setVariable(this.activoString,0);this.evaluator.setVariable(this.activeString,0);this.evaluator.setVariable(this.mclicizquierdoString,
0)};a.GraphicControl.prototype.addEvents=function(){function b(d){document.body.focus();d.preventDefault();d.stopPropagation();e.touchId=null;e.evaluator.setVariable(e.mclickedString,1);e.evaluator.setVariable(e.mclicizquierdoString,1);if(e.activeIfValue||e.active)e.click=!1,window.removeEventListener("touchmove",c,!1),window.removeEventListener("touchend",b,!1),window.removeEventListener("mouseup",b,!1),window.removeEventListener("mousemove",c,!1),g=a.getCursorPosition(d,e.container),e.posX=e.prePos.x-
(e.posAnte.x-g.x),e.posY=e.prePos.y-(e.posAnte.y-g.y),e.evaluator.setVariable(e.xString,e.space.getRelativeX(e.posX)),e.evaluator.setVariable(e.yString,e.space.getRelativeY(e.posY)),e.evaluator.setVariable(e.mxString,e.space.getRelativeX(g.x)),e.evaluator.setVariable(e.myString,e.space.getRelativeY(g.y)),e.parent.update(),e.mouseCacher.style.left=e.space.getAbsoluteX(e.x)-e._w/2+"px",e.mouseCacher.style.top=e.space.getAbsoluteY(e.y)-e._h/2+"px";e.parent.deactivateGraphiControls()}function c(b){b.preventDefault();
b.touchId=e.touchId;e.evaluator.setVariable(e.mclickedString,0);e.evaluator.setVariable(e.mclicizquierdoString,0);g=a.getCursorPosition(b,e.container);e.posX=e.prePos.x-(e.posAnte.x-g.x);e.posY=e.prePos.y-(e.posAnte.y-g.y);e.evaluator.setVariable(e.xString,e.space.getRelativeX(e.posX));e.evaluator.setVariable(e.yString,e.space.getRelativeY(e.posY));e.evaluator.setVariable(e.mxString,e.space.getRelativeX(g.x));e.evaluator.setVariable(e.myString,e.space.getRelativeY(g.y));10<Date.now()-d&&(e.parent.updateControls(),
e.parent.update(),d=Date.now())}var d=0,e=this;this.active=this.over=this.click=!1;this.mouseCacher.oncontextmenu=function(){return!1};this.mouseCacher.addEventListener("touchstart",function(d){document.body.focus();d.preventDefault();e.activeIfValue&&(e.parent.deactivateGraphiControls(),e.click=!0,e.active=!0,e.evaluator.setVariable(e.activoString,1),e.evaluator.setVariable(e.activeString,1),e.evaluator.setVariable(e.mclickedString,0),e.evaluator.setVariable(e.mclicizquierdoString,0),e.posAnte=a.getCursorPosition(d,
e.container),e.prePos={x:e.space.getAbsoluteX(e.x),y:e.space.getAbsoluteY(e.y)},e.evaluator.setVariable(e.mxString,e.space.getRelativeX(e.posAnte.x)),e.evaluator.setVariable(e.myString,e.space.getRelativeY(e.posAnte.y)),e.parent.update(),window.addEventListener("touchmove",c),window.addEventListener("touchend",b))});this.mouseCacher.addEventListener("mousedown",function(d){document.body.focus();d.preventDefault();e.whichBtn=a.whichBtn(d);"L"==e.whichBtn&&e.activeIfValue&&e.over&&(e.parent.deactivateGraphiControls(),
e.click=!0,e.active=!0,e.evaluator.setVariable(e.activoString,1),e.evaluator.setVariable(e.activeString,1),e.evaluator.setVariable(e.mclickedString,0),e.evaluator.setVariable(e.mclicizquierdoString,0),e.posAnte=a.getCursorPosition(d,e.container),e.prePos={x:e.space.getAbsoluteX(e.x),y:e.space.getAbsoluteY(e.y)},e.evaluator.setVariable(e.mxString,e.space.getRelativeX(e.posAnte.x)),e.evaluator.setVariable(e.myString,e.space.getRelativeY(e.posAnte.y)),e.parent.update(),window.addEventListener("mouseup",
b),window.addEventListener("mousemove",c))});this.mouseCacher.addEventListener("mouseover",function(a){e.over=!0});this.mouseCacher.addEventListener("mouseout",function(a){e.over=!1;e.click=!1});var g};return a}(descartesJS||{}),descartesJS=function(a,k){var d,f,p,c,h,g,b,u,n,r;if(a.loadLib)return a;var q,t,v,e,m,w,l,x,A=/[\w-//]*(\.png|\.jpg|\.gif|\.svg)/gi,D,B,E,G,F,J,C,z,I,H,M,y,L,K,N,T,O,U,R,P,Q;a.LessonParser=function(b){this.parent=b;this.parser=b.evaluator.parser;this.RTFparser=new a.RTFParser(b.evaluator)};
a.LessonParser.prototype.parseButtonsConfig=function(a){var b={rowsNorth:0,rowsSouth:0,widthEast:125,widthWest:125,height:23};a=this.split(a);for(var d=0,c=a.length;d<c;d++)switch(v=a[d][0],e=a[d][1],t=k[v],t){case "rowsNorth":case "rowsSouth":case "widthEast":case "widthWest":case "height":b[t]=parseInt(e);break;case "about":case "config":case "init":case "clear":b[t]="true"===k[e];break;default:console.log("Propiedad de botones no identificada: <"+v+"> valor: <"+e+">")}return b};a.LessonParser.prototype.parseSpace=
function(b){m={};b=this.split(b);for(var d=0,c=b.length;d<c;d++)switch(v=b[d][0],e=b[d][1],t=k[v],t){case "type":case "id":case "cID":case "file":m[t]=e;break;case "fixed":case "numbers":case "sensitive_to_mouse_movements":case "R3":case "split":m[t]="true"===k[e];break;case "bg_display":case "render":m[t]=k[e];break;case "net":case "net10":case "axes":case "text":m[t]=""!=e?"false"===k[e]?"":new a.Color(e,this.parent.evaluator):"";break;case "x_axis":case "y_axis":m[t]="false"===k[e]?"":e;break;
case "O.x":m.OxExpr=e;break;case "O.y":m.OyExpr=e;break;case "image":m.imageSrc=e;break;case "x":q=e;"%"===q[q.length-1]?(m.xPercentExpr=q.trim(),q=(this.parent.container.width*parseFloat(q)/100).toString()):q=e;m.xExpr=this.parser.parse(q);break;case "y":q=e;"%"===q[q.length-1]?(m.yPercentExpr=q.trim(),q=(this.parent.container.height*parseFloat(q)/100).toString()):q=e;m.yExpr=this.parser.parse(q);break;case "width":q=e.trim();"%"===q[q.length-1]?(m.wExpr=q,q=this.parent.container.width*parseFloat(q)/
100):(q=parseFloat(e),q!=e&&(q=this.parent.container.width,m._w_=e.trim()));m.w=q;break;case "height":q=e.trim();"%"===q[q.length-1]?(m.hExpr=q,q=this.parent.container.height*parseFloat(q)/100):(q=parseFloat(e),q!=e&&(q=this.parent.container.height,m._h_=e.trim()));m.h=q;break;case "drawif":""!=e&&(m.drawif=this.parser.parse(e));break;case "scale":q=parseFloat(e);isNaN(q)&&(q=48);m.scale=q;break;case "background":m.background=new a.Color(e,this.parent.evaluator);break;default:console.log("Propiedad del espacio no identificada: <"+
v+"> valor: <"+e+">")}switch(m.type){case "R2":return new a.Space2D(this.parent,m);case "R3":return new a.Space3D(this.parent,m);case "AP":return new a.SpaceAP(this.parent,m);case "HTMLIFrame":return new a.SpaceHTML_IFrame(this.parent,m);default:return new a.Space2D(this.parent,m)}};a.LessonParser.prototype.parseControl=function(b){w={type:"numeric"};b=this.split(b);for(var d=0,c=b.length;d<c;d++)switch(v=b[d][0],e=b[d][1],t=k[v],t){case "id":case "name":case "parameter":case "tooltip":case "tooltipFont":case "Explanation":case "ExplanationFont":case "cID":case "options":case "font":case "file":case "answer":w[t]=
e;break;case "gui":case "region":case "action":case "msg_pos":case "poster":w[t]=k[e];break;case "fixed":case "visible":case "discrete":case "onlyText":case "evaluate":case "autoplay":case "loop":case "controls":w[t]="true"===k[e];break;case "color":case "colorInt":case "trace":w[t]=new a.Color(e,this.parent.evaluator);break;case "font_size":case "drawif":case "activeif":case "decimals":case "min":case "max":case "size":""!=e&&(w[t]=this.parser.parse(e));break;case "constraint":w.constraintExpr=e;
break;case "image":w.imageSrc=e;break;case "space":w.spaceID=e;break;case "type":w.type=k[e.trim()];break;case "expresion":w.expresion=this.parser.parse(e.replace(")(",","));break;case "bold":"false"!=k[e]&&(w.bold="bold");break;case "italics":"false"!=k[e]&&(w.italics="italic");break;case "underlined":"false"!=k[e]&&(w.underlined=!0);break;case "value":var g=e.replace(/&squot;/g,"'");g.match(/^\|/)&&(g="'"+g.substring(1),g.match(/\|$/)&&(g=g.substring(0,g.length-1)+"'"));w.valueExpr=this.parser.parse(g);
w.valueExprString=g;break;case "incr":0!=e&&(w.incr=this.parser.parse(e));break;case "exponentialif":w.exponentialif=parseFloat(e);break;case "text":w.rawText=e;for(var g=this.parseText(e),n=0,f=g.length;n<f;n++)g[n]=this.parser.parse(g[n],!1);w.text=g;break;default:n=v.indexOf(".");g=k[v.substring(0,n)];n=k[v.substring(n+1)];if("parameter"===g&&"font"===n){w.parameterFont=e;break}else if("Explanation"===g&&"font"===n){w.ExplanationFont=e;break}else if("tooltip"===g&&"font"===n){w.tooltipFont=e;break}console.log("Propiedad de control no identificada: <"+
v+"> valor: <"+e+">")}if("numeric"===w.type)switch(w.gui){case "spinner":return new a.Spinner(this.parent,w);case "button":return new a.Button(this.parent,w);case "textfield":return new a.TextField(this.parent,w);case "menu":return new a.Menu(this.parent,w);case "scrollbar":return new a.Scrollbar(this.parent,w);default:return new a.Spinner(this.parent,w)}else{if("video"===w.type)return new a.Video(this.parent,w);if("audio"===w.type)return new a.Audio(this.parent,w);if("graphic"===w.type)return new a.GraphicControl(this.parent,
w);if("text"===w.type)return new a.TextArea(this.parent,w)}};a.LessonParser.prototype.parseGraphic=function(b,d,c,g){l={rotateExp:g,parameter:"t"};b=this.split(b);g=0;for(var n=b.length;g<n;g++)if(v=b[g][0],e=b[g][1],t=k[v],""!=e)switch(t){case "type":case "align":l[t]=k[e];break;case "background":case "abs_coord":case "visible":case "editable":case "fixed":case "vectors":l[t]="true"===k[e];break;case "color":case "fill":case "fillP":case "fillM":case "arrow":case "trace":l[t]="false"===k[e]?"":new a.Color(e,
this.parent.evaluator);break;case "family":case "parameter":case "info":case "font":case "name":case "init":case "end":l[t]=e;break;case "drawif":case "width":case "decimals":case "size":case "spear":case "center":case "radius":case "opacity":case "inirot":case "inipos":case "range":""!=e&&(l[t]=this.parser.parse(e));break;case "space":l.spaceID=e;break;case "expresion":""!=e&&("macro"!=l.type?(l.expresion=this.parser.parse(e),l.expresionString=e):l.expresion=e);break;case "text":l.text=this.parseText(e);
break;case "file":var f=e.replace(/&squot;/g,"'");"["===f.charAt(0)&&"]"===f.charAt(f.length-1)&&(f=f.substring(1,f.length-1));f.match(A)&&(f="'"+f+"'");l.file=this.parser.parse(f);break;case "border":""!=e&&"false"!=k[e]&&(l.border=new a.Color(e,this.parent.evaluator));break;default:if(void 0!=l.family&&v.substring(0,l.family.length+1)===l.family+"."){switch(k[v.substring(l.family.length+1)]){case "interval":""!=e&&(l.family_interval=this.parser.parse(e));break;case "steps":""!=e&&(l.family_steps=
this.parser.parse(e))}break}if(void 0!=l.parameter&&v.match(l.parameter+".")){l.parameter!==v.substring(0,v.indexOf(l.parameter)+l.parameter.length)&&(l.parameter=v.substring(0,v.indexOf(l.parameter)+l.parameter.length));switch(k[v.substring(l.parameter.length+1)]){case "interval":""!=e&&(l.parameter_interval=this.parser.parse(e));break;case "steps":""!=e&&(l.parameter_steps=this.parser.parse(e))}break}console.log("Propiedad del grafico no identificada: <"+v+"> valor: <"+e+">")}d&&(l.abs_coord=d);
c&&(l.background=c);switch(l.type){case "text":return new a.Text(this.parent,l);case "image":return new a.Image(this.parent,l);case "point":return new a.Point(this.parent,l);case "polygon":return new a.Polygon(this.parent,l);case "arc":return new a.Arc(this.parent,l);case "segment":return new a.Segment(this.parent,l);case "arrow":return new a.Arrow(this.parent,l);case "macro":return new a.Macro(this.parent,l);case "curve":return new a.Curve(this.parent,l);case "equation":return new a.Equation(this.parent,
l);case "sequence":return new a.Sequence(this.parent,l);case "fill":return new a.Fill(this.parent,l)}};a.LessonParser.prototype.parse3DGraphic=function(b,d,c,g){l={rotateExp:g,parameter:"t"};b=this.split(b);d=0;for(c=b.length;d<c;d++)switch(v=b[d][0],e=b[d][1],t=k[v],t){case "type":case "model":l[t]=k[e];break;case "background":case "fixed":case "edges":l[t]="true"===k[e];break;case "color":case "backcolor":l[t]=new a.Color(e,this.parent.evaluator);break;case "type":case "model":l[t]=k[e];break;case "background":case "fixed":case "edges":case "split":l[t]=
"true"===k[e];break;case "color":case "backcolor":l[t]=new a.Color(e,this.parent.evaluator);break;case "drawif":case "width":case "length":case "height":case "decimals":case "Nu":case "Nv":case "inipos":case "endpos":""!=e&&(l[t]=this.parser.parse(e));break;case "family":case "parameter":case "font":case "name":case "inirot":case "endrot":l[t]=e;break;case "space":l.spaceID=e;break;case "expresion":"macro"!=l.type&&"curve"!=l.type&&"surface"!=l.type?(l.expresion=this.parser.parse(e),l.expresionString=
e):l.expresion=e.replace(/\\n/g," ").replace(/;/g," ");break;case "text":g=this.parseText(e);for(var n=0,f=g.length;n<f;n++)g[n]=this.parser.parse(g[n],!1);l.text=g;break;case "file":g=e.replace(/&squot;/g,"'");"["===g.charAt(0)&&"]"===g.charAt(g.length-1)&&(g=g.substring(1,g.length-1));g.match(/./)&&(g="'"+g+"'");l.file=this.parser.parse(g);break;case "drawif":case "width":case "length":case "decimals":case "Nu":case "Nv":case "inirot":case "endrot":case "inipos":case "endpos":""!=e&&(l[t]=this.parser.parse(e));
break;case "family":case "parameter":case "font":case "name":l[t]=e;break;case "space":l.spaceID=e;break;case "expresion":"macro"!=l.type&&"curve"!=l.type&&"surface"!=l.type?(l.expresion=this.parser.parse(e),l.expresionString=e):l.expresion=e;break;case "text":g=this.parseText(e);n=0;for(f=g.length;n<f;n++)g[n]=this.parser.parse(g[n],!1);l.text=g;break;case "file":g=e.replace(/&squot;/g,"'");"["===g.charAt(0)&&"]"===g.charAt(g.length-1)&&(g=g.substring(1,g.length-1));g.match(/./)&&(g="'"+g+"'");l.file=
this.parser.parse(g);break;default:if(void 0!==l.family&&v.substring(0,l.family.length+1)===l.family+"."){"interval"===k[v.substring(l.family.length+1)]?""!=e&&(l.family_interval=this.parser.parse(e)):""!=e&&(l.family_steps=this.parser.parse(e));break}console.log("Propiedad del grafico 3D no identificada: <"+v+"> valor: <"+e+">")}switch(l.type){case "point":return new a.Point3D(this.parent,l);case "segment":return new a.Segment3D(this.parent,l);case "polygon":return new a.Polygon3D(this.parent,l);
case "curve":return new a.Curve3D(this.parent,l);case "triangle":return new a.Triangle3D(this.parent,l);case "face":return new a.Face3D(this.parent,l);case "polireg":return new a.Polireg3D(this.parent,l);case "surface":return new a.Surface3D(this.parent,l);case "text":return new a.Text3D(this.parent,l);case "cube":case "box":case "tetrahedron":case "octahedron":case "sphere":case "dodecahedron":case "icosahedron":case "ellipsoid":case "cone":case "cylinder":case "mesh":return new a.OtherGeometry(this.parent,
l);case "macro":return new a.Macro3D(this.parent,l)}};a.LessonParser.prototype.parseAuxiliar=function(b){x={};b=this.split(b);for(var d=0,c=b.length;d<c;d++)b[d][1]=b[d][1].replace(/&squot;/g,"'");d=0;for(c=b.length;d<c;d++)switch(v=b[d][0],e=b[d][1],t=k[v],t){case "id":case "file":case "init":case "doExpr":case "whileExpr":case "range":case "local":case "expresion":case "condition":case "parameter":x[t]=e.replace(/&squot;/g,"'");break;case "editable":case "constant":case "array":case "matrix":case "algorithm":case "event":case "sequence":x[t]=
"true"===k[e];break;case "size":case "rows":case "columns":x[t]=this.parser.parse(e);break;case "evaluate":case "execution":case "msg_pos":case "action":x[t]=k[e];break;case "type":x[t]=k[e];break;case "x":case "y":case "width":case "height":x[t]=this.parser.parse(e);break;default:var g=v.indexOf("."),n=k[v.substring(0,g)],g=k[v.substring(g+1)];if("parameter"===n&&"font"===g){x.parameterFont=e;break}console.log("Propiedad del auxiliar no identificada: <"+v+"> valor: <"+e+">")}x.sequence?new a.Function(this.parent,
x):x.constant?(b=new a.Constant(this.parent,x),x.evaluate&&"always"===x.evaluate&&this.parent.auxiliaries.push(b)):x.algorithm&&x.evaluate?(b=new a.Algorithm(this.parent,x),this.parent.auxiliaries.push(b)):x.array&&!x.matrix&&")"!=x.id.charAt(x.id.length-1)?(b=new a.Vector(this.parent,x),x.evaluate&&"always"===x.evaluate&&this.parent.auxiliaries.push(b)):x.matrix&&")"!=x.id.charAt(x.id.length-1)?(b=new a.Matrix(this.parent,x),x.evaluate&&"always"===x.evaluate&&this.parent.auxiliaries.push(b)):x.event&&
")"!=x.id.charAt(x.id.length-1)?this.parent.events.push(new a.Event(this.parent,x)):")"===x.id.charAt(x.id.length-1)?new a.Function(this.parent,x):new a.Variable(this.parent,x)};a.LessonParser.prototype.parseAction=function(b){D=b.action;B=b.parent;E=b.parameter;if(D)switch(D){case "message":return new a.Message(B,E);case "calculate":return new a.Calculate(B,E);case "openURL":return new a.OpenURL(B,E);case "openScene":return new a.OpenScene(B,E);case "about":return new a.About(B,E);case "config":return new a.Config(B,
E);case "init":return new a.Init(B,E);case "clear":return new a.Clear(B,E);case "animate":return new a.Animate(B,E);case "initAnimation":return new a.InitAnimation(B,E);case "playAudio":return new a.PlayAudio(B,E);default:console.log("Accion no soportada: <"+D+">")}else return{execute:function(){}}};a.LessonParser.prototype.parseAnimation=function(b){var d={};b=this.split(b);for(var c=0,g=b.length;c<g;c++)switch(v=b[c][0],e=b[c][1],t=k[v],t){case "id":case "delay":case "init":case "doExpr":case "whileExpr":d[t]=
e.replace(/&squot;/g,"'");break;case "controls":case "auto":case "loop":case "algorithm":case "evaluate":d[t]="true"===k[e];break;default:console.log("Propiedad de la animacion no identificada: <"+v+">  <"+e+">")}return new a.Animation(this.parent,d)};a.LessonParser.prototype.parsePleca=function(q,k){q=this.split(q);f=d="";p=0;c="#536891";h="white";g="left";b="";u="SansSerif,BOLD,20";n="SansSerif,PLAIN,18";r=void 0;for(var m=0,l=q.length;m<l;m++)switch(v=q[m][0],e=q[m][1],v){case "title":d=e;break;
case "subtitle":f=e;break;case "subtitlines":p=e;break;case "bgcolor":""!=e&&(c=(new a.Color(e,this.parent.evaluator)).getColor());break;case "fgcolor":""!=e&&(h=(new a.Color(e,this.parent.evaluator)).getColor());break;case "align":""!=e&&(g=e);break;case "titleimage":b=e;break;case "titlefont":u=""!=e?a.convertFont(e):a.convertFont(u);break;case "subtitlefont":n=""!=e?a.convertFont(e):a.convertFont(n);break;default:console.log("Propiedad de la pleca no identificada: <"+v+">  <"+e+">")}if(""===d&&
""===f)return document.createElement("div");H=n.substring(0,n.indexOf("px"));H=H.substring(H.lastIndexOf(" "));""!=b&&(M=this.parent.getImage(b),y=M.height);r=document.createElement("div");r.setAttribute("id","descartesPleca");y?(r.setAttribute("style","position:absolute;left:0;top:0;text-align:"+g+";width:"+(k-30)+"px;height:"+(y-16)+"px;background:"+c+";color:"+h+";padding-top:8px;padding-bottom:8px;padding-left:15px;padding-right:15px;margin:0;overflow:hidden;z-index:100;"),M.setAttribute("style",
"position: absolute;left:0;top:0;z-index:-1;width:100%;height:100%;"),r.appendChild(M)):r.setAttribute("style","position:absolute;left:0;top:0;text-align:"+g+";width:"+(k-30)+"px;background:"+c+";color:"+h+";padding-top:12px;padding-bottom:12px;padding-left:15px;padding-right:15px;margin:0;z-index:100;");L=document.createElement("div");L.setAttribute("style","padding:0;margin:0;font:"+u+";overflow:hidden;white-space:nowrap;");L.innerHTML=d;K=document.createElement("div");if(1===parseInt(p)){R=0;N=
document.createElement("div");N.innerHTML=f;document.body.appendChild(N);O=H;do O-=R,N.setAttribute("style","padding:0;margin:0;font:"+n+";font-size:"+O+"px;width:"+(k-30)+"px;line-height:"+O+"px;"),T=N.offsetHeight,U=T/O,R=1;while(1<U&&8<O);document.body.removeChild(N);K.setAttribute("style","padding:0;margin:0;font:"+n+";font-size:"+O+"px;line-height: 110%;overflow:hidden;white-space:nowrap;")}else K.setAttribute("style","padding:0;margin:0;font:"+n+";line-height:110%;");K.innerHTML=f;r.appendChild(L);
r.appendChild(K);r.imageHeight=y;return r};a.LessonParser.prototype.split=function(a){if("string"!=typeof a)return[];a=(a||"").replace(/\\'/g,"\u2019");G=[];J=F=0;C=!1;z=0;for(I=!1;F<a.length;)" "!==a.charAt(F)||C||F++," "===a.charAt(F)||C||(C=!0,z=F),"="!==a.charAt(F)||"'"!==a.charAt(F+1)||I||(I=!0,G[J]=[a.substring(z,F)],z=F+2,F+=2),I&&"'"===a.charAt(F)&&(C=I=!1,G[J].push(a.substring(z,F)),J++),"="!==a.charAt(F)||"'"===a.charAt(F+1)||I||(G[J]=[a.substring(z,F)],z=F+1,F++,P=a.substring(F).indexOf("="),
-1===P?Q=P=a.length:(P+=F,Q=a.substring(F,P).lastIndexOf(" "),Q=-1===Q?a.length:Q+F),G[J].push(a.substring(z,Q)),J++,C=!1,F=Q),F++;return G};a.LessonParser.prototype.parseText=function(b){b=b||"";return b.match(/^\{\\rtf1/)?this.RTFparser.parse(b.substring(10)):new a.SimpleText(this.parent,b)};return a}(descartesJS||{},babel),descartesJS=function(a){function k(a,b){v=[];v.type="matrix";v.rows=a;v.cols=b;var d;m=0;for(w=b;m<w;m++){d=[];e=0;for(l=a;e<l;e++)d.push(0);v[m]=d}return v}function d(a,b){q=
a.rows;t=a.cols;v=k(q,t);var d;for(m=0;m<q;m++)for(e=0;e<t;e++){for(w=d=0;w<t;w++)d+=a[w][m]*b[e][w];v[e][m]=d}return v}function f(a,b,d){for(var c=k(d.length-1,d.length-1),e=0,g=c.length;e<g;e++)for(var n=0;n<g;n++)c[e][n]=e<a?n<b?d[e][n]:d[e][n+1]:e<b?d[e+1][n]:d[e+1][n+1];return c}function p(a){if(1<a.cols){for(var b=0,d=1,c=0,e=a.cols;c<e;c++)b+=d*a[0][c]*p(f(0,c,a)),d=-d;return b}return a[0][0]}if(a.loadLib)return a;var c,h={},g=Math.floor,b,u,n,r;a.fullDecimals=!1;a.Node=function(a,b){this.sep=
"";this.type=a;this.value=b;this.parent=null;this.childs=[]};a.Node.prototype.getRoot=function(){return null===this.parent?this:this.parent.getRoot()};a.Node.prototype.addChild=function(a){a.parent=this;this.childs.push(a)};a.Node.prototype.replaceLastChild=function(a){b=this.childs.length-1;lastChild=this.childs[b];lastChild.parent=null;this.childs[b]=a;a.parent=this;return a};a.Node.prototype.contains=function(a){if(this.value===a)return!0;for(var b=0,d=this.childs.length;b<d;b++)if(this.childs[b].contains(a))return!0;
return!1};a.Node.prototype.equalToMinus=function(){return"compOperator"===this.type?(this.type="operator",this.value="-",n=new a.Node("compOperator","=="),r=new a.Node("number","0"),n.addChild(this),n.addChild(r),u=this.getRoot(),u.setAllEvalFun(),u):this};a.Node.prototype.setAllEvalFun=function(){this.setEvalFun();for(var a=0,b=this.childs.length;a<b;a++)this.childs[a].setAllEvalFun()};a.Node.prototype.setEvalFun=function(){if("number"===this.type)this.evaluate=function(a){return parseFloat(this.value)};
else if("string"===this.type)this.evaluate=function(a){return this.value};else if("identifier"===this.type&&0===this.childs.length)if("rnd"==this.value)this.evaluate=function(a){return Math.random()};else{var b;this.evaluate=function(a,d){b=a.variables[this.value];if("object"===typeof b&&void 0==b.length)return b.evaluate(a);void 0==b&&(d||a.matrices[this.value]?b=a.matrices[this.value]:a.vectors[this.value]&&(b=a.vectors[this.value]));return void 0!==b?b:0}}else if("identifier"===this.type&&"square_bracket"===
this.childs[0].type&&1===this.childs[0].childs.length){var n,l;this.evaluate=function(a){n=this.childs[0].childs[0].evaluate(a);try{return l=a.vectors[this.value][0>n?0:g(n)],void 0!==l?l:0}catch(b){return 0}}}else if("identifier"===this.type&&"square_bracket"===this.childs[0].type&&1<this.childs[0].childs.length){var r,u;this.evaluate=function(a){r=this.childs[0].childs[0].evaluate(a);u=this.childs[0].childs[1].evaluate(a);try{return l=a.matrices[this.value][0>r?0:g(r)][0>u?0:g(u)],void 0!==l?l:
0}catch(b){return 0}}}else if("identifier"===this.type&&"parentheses"===this.childs[0].type){var w,F,J;this.evaluate=function(a){w=[];for(var b=0,d=this.childs[0].childs.length;b<d;b++)w[b]=this.childs[0].childs[b].evaluate(a);if("_Eval_"===this.value){c=0<w.length?w[0]:0;if("number"==typeof c)return"NaN";c.match(",")&&parseFloat(c.replace(",","."))==c.replace(",",".")&&(c="'"+c+"'");void 0==h[c]&&(F=c.match(/:=/g)?!0:!1,h[c]=a.parser.parse(c,F));J=a.eval(h[c]);return void 0!=J?J:NaN}return a.functions[this.value].apply(a,
w)}}else if("operator"===this.type)"+"===this.value?this.evaluate=function(b){var d=this.childs[0].evaluate(b,!0);b=this.childs[1].evaluate(b,!0);if("matrix"!==d.type||"matrix"!==b.type)return"number"==typeof d&&"string"==typeof b?d=a.removeNeedlessDecimals(d.toString()):"string"==typeof d&&"number"==typeof b&&(b=a.removeNeedlessDecimals(b.toString())),d+b;q=d.rows;t=d.cols;v=k(q,t);for(m=0;m<q;m++)for(e=0;e<t;e++)v[e][m]=d[e][m]+b[e][m];return v}:"-"===this.value?this.evaluate=function(a){var b=
this.childs[0].evaluate(a,!0);a=this.childs[1].evaluate(a,!0);if("matrix"!==b.type||"matrix"!==a.type)return b-a;q=b.rows;t=b.cols;v=k(q,t);for(m=0;m<q;m++)for(e=0;e<t;e++)v[e][m]=b[e][m]-a[e][m];return v}:"*"===this.value?this.evaluate=function(a){var b=this.childs[0].evaluate(a,!0);a=this.childs[1].evaluate(a,!0);return"matrix"!==b.type||"matrix"!==a.type?b*a:d(b,a)}:"/"===this.value?this.evaluate=function(a){var b=this.childs[0].evaluate(a,!0);a=this.childs[1].evaluate(a,!0);if("matrix"!==b.type||
"matrix"!==a.type)return b/a;var c=k(a.length,a.length),e=p(a);if(0===e)a=0;else{var e=1/e,g;if(1<a.length)for(var n=0,q=a.length;n<q;n++){g=e;for(var m=0;m<q;m++)c[m][n]=g*p(f(n,m,a)),g=-g;e=-e}else c[0][0]=e;a=c}b=0===a?k(b.rows,b.cols):d(b,a);return b}:"%"===this.value?this.evaluate=function(a){var b=this.childs[0].evaluate(a);a=this.childs[1].evaluate(a);return b-g(b/a)*a}:"^"===this.value&&(this.evaluate=function(a){return Math.pow(this.childs[0].evaluate(a),this.childs[1].evaluate(a))});else if("compOperator"===
this.type)"<"===this.value?this.evaluate=function(a){return this.childs[0].evaluate(a)<this.childs[1].evaluate(a)?1:0}:"<="===this.value?this.evaluate=function(a){return this.childs[0].evaluate(a)<=this.childs[1].evaluate(a)?1:0}:">"===this.value?this.evaluate=function(a){return this.childs[0].evaluate(a)>this.childs[1].evaluate(a)?1:0}:">="===this.value?this.evaluate=function(a){return this.childs[0].evaluate(a)>=this.childs[1].evaluate(a)?1:0}:"=="===this.value?this.evaluate=function(a){return this.childs[0].evaluate(a)===
this.childs[1].evaluate(a)?1:0}:"!="===this.value&&(this.evaluate=function(a){return this.childs[0].evaluate(a)!==this.childs[1].evaluate(a)?1:0});else if("boolOperator"===this.type)"&"===this.value?this.evaluate=function(a){return this.childs[0].evaluate(a)?this.childs[1].evaluate(a)?1:0:0}:"|"===this.value?this.evaluate=function(a){return this.childs[0].evaluate(a)?1:this.childs[1].evaluate(a)?1:0}:"!"===this.value&&(this.evaluate=function(a){return this.childs[0].evaluate(a)?0:1});else if("conditional"===
this.type)this.evaluate=function(a){return 0<this.childs[0].evaluate(a)?this.childs[1].evaluate(a):this.childs[2].evaluate(a)};else if("sign"===this.type)this.evaluate="sign+"===this.value?function(a){return this.childs[0].evaluate(a)}:function(a){return-this.childs[0].evaluate(a)};else if("parentheses"===this.type)this.evaluate=function(a,b){return this.childs[0].evaluate(a,b)};else if("(expr)"===this.type||"[expr]"===this.type)this.evaluate=function(a){var b=this.childs.length,d=[],c;if(1===b&&
1===this.childs[0].childs.length&&"(expr)"===this.type)d=this.childs[0].childs[0].evaluate(a);else for(var e=0;e<b;e++){c=[];for(var g=0,n=this.childs[e].childs.length;g<n;g++)c.push(this.childs[e].childs[g].evaluate(a));d[e]=c}return d};else if("asign"===this.type){var C,z,I,H,M,y;this.evaluate=function(a){C=this.childs[0];z=this.childs[1];if(1===C.childs.length&&"square_bracket"===C.childs[0].type){n=C.childs[0].childs;if(1===n.length)return I=n[0].evaluate(a),I=0>I?0:g(I),a.vectors[C.value][I]=
z.evaluate(a),z.evaluate(a);if(2===n.length)return H=n[0].evaluate(a),M=n[1].evaluate(a),H=0>H?0:g(H),M=0>M?0:g(M),a.matrices[C.value][H]||(a.matrices[C.value][H]=[]),a.matrices[C.value][H][M]=z.evaluate(a),z.evaluate(a)}else return y=z.evaluate(a),y.type?a.matrices[C.value]=y:"object"!==typeof a.variables[C.value]?a.variables[C.value]=y:0}}};var q,t,v,e,m,w,l;a.Node.prototype.toString=function(){var a="tipo: "+this.type+", valor: "+this.value+"\n";this.sep="   "+(this.parent?this.parent.sep:"");
for(var b=0,d=this.childs.length;b<d;b++)a+=this.sep+this.childs[b].toString();return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k,d,f,p,c,h,g,b,u,n=/^\s+/,r=/^[a-zA-Z_\u00C0-\u021B\u0391-\u03C9]+[a-zA-Z_0-9\u00C0-\u021B\u0391-\u03C9]*([.]*[0-9a-zA-Z_\u00C0-\u021B\u0391-\u03C9]+[0-9]*)*/,q=/^[0-9]+[.][0-9]+|^[.][0-9]+|^[0-9]+/,t=/^==|^!=|^<=|^<|^>=|^>|^#/,v=/^\!|^\~|^\&\&|^\&|^\|\||^\|/,e=/^=|^:=/,m=/^[\?\:]/,w=/^[\+\-\*\/\%\^\u2212\u00b7\u00D7\u00F7]/,l=/^\[|^\]/,
x=/^\(|^\)/,A=/^,/,D=/^;/,B=/\|/g,E=/\|\*/g,G=/\*\|/g;a.Tokenizer=function(){};a.Tokenizer.prototype.tokenize=function(a){function z(a,c,e){d.push({type:a,value:c});h=h.slice(e);p+=e;b++;u=a}if(k=a){a=a.replace(/\\u(\S+) /g,function(a,b){return String.fromCharCode(parseInt(b,16))});a=a.replace(/\&sup(.+);/g,"^ $1 ");a=a.replace(/&squot;/g,"'");a.match(/\=\|\*/g)&&(a=a.replace(E,"'").replace(G,"'"));a.match(/\=\|/g)&&(a=a.replace(B,"'"));var I=a.trim();"|"==I.charAt(0)&&"|"==I.charAt(I.length-1)&&
(a=I.replace(B,"'"))}d=[];f=!1;p=0;h=a;b=0;for(u="";a&&p<a.length;)if(f=p,"'"==h[0]){for(g=1;"'"!=h[g];)if(g<h.length)g++;else{console.log(">Error, unknown symbol: ["+h+"], in the string <<"+k+">>");return}c=h.substring(1,g);z("string",c,c.length+2)}else if(c=h.match(n))h=h.slice(c[0].length),p+=c[0].length,b++;else if(c=h.match(w))c[0]=c[0].replace(/\u00F7/g,"/").replace(/\u2212/g,"-").replace(/\u00b7/g,"*").replace(/\u00D7/g,"*"),z("operator",c[0],c[0].length);else if(c=h.match(r))"number"===u&&
d.push({type:"operator",value:"*"}),z("identifier",c[0],c[0].length);else if(c=h.match(q))z("number",c[0],c[0].length);else if(c=h.match(t))I=c[0],"#"==I&&(I="!="),z("compOperator",I,c[0].length);else if(c=h.match(v))I=c[0],"||"==I?I="|":"&&"==I?I="&":"~"==I&&(I="!"),z("boolOperator",I,c[0].length);else if((c=h.match(e))&&!h.match(/^==/))z("asign",c[0],c[0].length);else if(c=h.match(m))z("conditional",c[0],c[0].length);else if(c=h.match(l))z("square_bracket",c[0],c[0].length);else if(c=h.match(x))"("==
c&&"number"===u&&d.push({type:"operator",value:"*"}),z("parentheses",c[0],c[0].length);else if(c=h.match(A))z("separator",c[0],c[0].length);else if(178===h.charCodeAt(0))d.push({type:"operator",value:"^"}),z("number",2,1);else if(179===h.charCodeAt(0))d.push({type:"operator",value:"^"}),z("number",3,1);else if(c=h.match(D))z("final_of_expresion",c[0],c[0].length);else if(f==p){console.log("Error, simbolo no conocido: ["+h+"], en la cadena <<"+k+">>");return}return d};var F,J=/rnd|pi|e|Infinity|-Infinity|sqr|sqrt|ra\u00edz|exp|log|log10|abs|ent|sgn|ind|sin|sen|cos|tan|cot|sec|csc|sinh|senh|cosh|tanh|coth|sech|csch|asin|asen|acos|atan|min|max/;
a.Tokenizer.prototype.flatTokens=function(a,b){a=a||[];b=b||"";F="";for(var d=0,c=a.length;d<c;d++)F="string"==a[d].type?F+"&squot;"+a[d].value+"&squot;":"identifier"!=a[d].type||a[d].value.match(J)?F+a[d].value:F+b+a[d].value;return F};return a}(descartesJS||{}),descartesJS=function(a){function k(a){switch(a){case "=":return 1;case ":=":return 1;case "(":return 2;case "[":return 2;case "?":return 2;case ":":return 3;case "?:":return 3;case "|":return 6;case "&":return 7;case "<":return 5;case "<=":return 5;
case ">":return 5;case ">=":return 5;case "==":return 5;case "!=":return 5;case "+":return 6;case "-":return 6;case "/":return 7;case "*":return 7;case "sign-":return 7;case "sign+":return 7;case "!":return 8;case "%":return 8;case "^":return 9;default:return 9}}function d(a){return isNaN(parseFloat(a))?a.replace(/^\s|\s$/g,"").replace(/^'|'$/g,""):parseFloat(a)==a?parseFloat(a):a.replace(/^\s|\s$/g,"").replace(/^'|'$/g,"")}if(a.loadLib)return a;a.Parser=function(b){this.evaluator=b;this.tokenizer=
new a.Tokenizer;this.vectors={};this.matrices={};this.variables={};this.functions={};this.definitions={};this.registerDefaultValues();this.registerExternalValues&&this.registerExternalValues()};a.Parser.prototype.setDefinition=function(a,b){this.definitions[a]=b};a.Parser.prototype.getDefinition=function(a){return this.definitions[a]};a.Parser.prototype.setVariable=function(a,b){this.variables[a]=b};a.Parser.prototype.getVariable=function(a,b){b&&(this.variables[a]=void 0!==this.variables[a]?this.variables[a]:
void 0);return this.variables[a]};a.Parser.prototype.setVector=function(a,b,d){this.vectors[a][b]=d};a.Parser.prototype.getVector=function(a){this.vectors.hasOwnProperty(a)||(this.vectors[a]=[0,0,0]);return this.vectors[a]};a.Parser.prototype.setMatrix=function(a,b,d,c){this.matrices[a][b][d]=c};a.Parser.prototype.getMatrix=function(a){this.matrices.hasOwnProperty(a)||(this.matrices[a]=[[0,0,0],[0,0,0],[0,0,0]]);return this.matrices[a]};a.Parser.prototype.setFunction=function(a,b){this.functions[a]=
b};a.Parser.prototype.getFunction=function(a){this.functions.hasOwnProperty(a)||(this.functions[a]=function(){return 0});return this.functions[a]};var f,p,c,h,g,b,u,n,r,q,t,v;a.Parser.prototype.parse=function(d,m){(c=this.tokenizer.tokenize(d))||(c=[]);h=null;m=!m||!1;f=n=u=b=0;for(p=c.length;f<p;f++){r=c[f];q=r.value;t=r.type;if("identifier"===t)if(f+1<p&&"parentheses"===c[f+1].type&&"("===c[f+1].value)this.getFunction(q);else if(f+1<p&&"square_bracket"===c[f+1].type&&"["===c[f+1].value)c[f+3]&&
"square_bracket"===c[f+3].type&&"]"===c[f+3].value?this.getVector(q):this.getMatrix(q);else{var w=q.match(/(\w*)\.mouse_x|(\w*)\.mouse_y|(\w*)\.mouse_pressed|(\w*)\.mouse_clicked|(\w*)\.clic_izquierdo/);w&&(this.variables[w[1]+".DESCARTESJS_no_fixed"]=1);this.getVariable(q,!0)}"asign"===t&&m&&":="!=q&&(t="compOperator",q="==");if("asign"===t)if(g=new a.Node(t,q),null!=h)if("identifier"===h.type)h.parent&&h.parent.replaceLastChild(g),g.addChild(h),h=g,m=!0;else if("square_bracket"===h.type)g.addChild(h.parent),
h=g,m=!0;else{g.type="compOperator";g.value="==";for(m=!0;h.parent&&k(h.parent.value)>=k(g.value);)h=h.parent;h.parent&&h.parent.replaceLastChild(g);g.addChild(h);h=g}else{console.log("Error1: en la expresion <<"+d+">>, en el token {valor: "+q+", tipo: "+t+"}");break}else if("parentheses"===t&&"("===q||"square_bracket"===t&&"["===q)if(g=new a.Node(t,q),"("===q&&b++,"["===q&&u++,null===h)"("===q&&(new a.Node("(expr)","(expr)")).addChild(g),"["===q&&(new a.Node("[expr]","[expr]")).addChild(g),h=g;else if("operator"===
h.type||"boolOperator"===h.type||"compOperator"===h.type||"conditional"===h.type||"asign"===h.type)h.addChild(g),h=g;else if("sign"===h.type)h.addChild(g),h=g;else if("parentheses"===h.type&&"("===h.value)h.addChild(g),h=g;else if("square_bracket"===h.type&&"["===h.value)h.addChild(g),h=g;else if("parentheses"===h.type&&"()"===h.value)h.parent.addChild(g),h=g;else if("square_bracket"===h.type&&"[]"===h.value)h.parent.addChild(g),h=g;else if("identifier"===h.type)h.addChild(g),h=g;else{console.log("Error2: en la expresion <<"+
d+">>, en el token ["+f+"] {valor: "+q+", tipo: "+t+"}");break}else if("parentheses"===t&&")"===q)if(b--,null===h)console.log("Error3: en la expresion <<"+d+">>, en el token (valor:"+q+", tipo:"+t);else{for(;h&&h.parent&&("("!=h.value||"("==h.value&&"parentheses"!=h.type);)h=h.parent;if(h&&"("===h.value)h.value="()";else{console.log("Error4: en la expresion <<"+d+">>, en el token {valor: "+q+", tipo: "+t+"}");break}}else if("square_bracket"===t&&"]"===q)if(u--,null===h)console.log("Error5: en la expresion <<"+
d+">>, en el token (valor:"+q+", tipo:"+t);else{for(;h&&h.parent&&("["!=h.value||"["==h.value&&"square_bracket"!=h.type);)h=h.parent;if(h&&"["===h.value)h.value="[]";else{console.log("Error6: en la expresion <<"+d+">>, en el token {valor: "+q+", tipo: "+t+"}");break}}else if("number"===t||"string"===t||"identifier"===t)if(g=new a.Node(t,q),null===h)h=g;else if("operator"===h.type||"compOperator"===h.type||"boolOperator"===h.type||"parentheses"===h.type&&"("===h.value||"square_bracket"===h.type&&"["===
h.value||"sign"===h.type||"conditional"===h.type||"asign"===h.type)h.addChild(g),h=g;else{console.log("Error7: en la expresion <<"+d+">>, en el token {valor: "+q+", tipo: "+t+"}");break}else if("operator"===t||"compOperator"===t||"boolOperator"===t)if(g=new a.Node(t,q),null===h)if("-"===q||"+"===q)g.type="sign",g.value="sign"+q,h=g;else if("!"===q)h=g;else{console.log("Error8: en la expresion <<"+d+">>, en el token {valor: "+q+", tipo: "+t+"}");break}else if("operator"===h.type||"compOperator"===
h.type||"boolOperator"===h.type||"asign"===h.type||"conditional"===h.type||"square_bracket"===h.type&&"["===h.value&&("-"===q||"+"===q||"!"===q)||"parentheses"===h.type&&"("===h.value&&("-"===q||"+"===q||"!"===q)){if("-"===q||"+"===q)g.type="sign",g.value="sign"+q;h.addChild(g);h=g}else if("number"===h.type||"parentheses"===h.type&&"()"===h.value||"square_bracket"===h.type&&"[]"===h.value||"string"===h.type||"identifier"===h.type||"conditional"===h.type||"asign"===h.type){for(;h.parent&&k(h.parent.value)>=
k(g.value);)h=h.parent;h.parent&&h.parent.replaceLastChild(g);g.addChild(h);h=g}else{console.log("Error9: en la expresion <<"+d+">>, en el token {valor: "+q+", tipo: "+t+"}");break}else if("conditional"===t)if(g=new a.Node(t,q),null!=h)if("?"===g.value){for(n++;h.parent&&k(h.parent.value)>k(g.value);)h=h.parent;h.parent&&h.parent.replaceLastChild(g);g.addChild(h);h=g}else{for(n--;h&&h.parent&&("?"!=h.value||"?"==h.value&&"conditional"!=h.type);)h=h.parent;if(h&&"?"===h.value)h.value="?:";else{console.log("Error10: en la expresion <<"+
d+">>, en el token {valor: "+q+", tipo: "+t+"}");break}}else{console.log("Error11: en la expresion <<"+d+">>, en el token {valor: "+q+", tipo: "+t+"}");break}else if("separator"===t)if(null!=h)for(;h.parent&&"("!=h.value&&"["!=h.value;)h=h.parent;else{console.log("Error12: en la expresion <<"+d+">>, en el token {valor: "+q+", tipo: "+t+"}");break}else{console.log("Error13: en la expresion <<"+d+">>, en el token {valor: "+q+", tipo: "+t+"}");break}}0<b&&alert("Error, faltan parentesis por cerrar: "+
d);0>b&&alert("Error, faltan parentesis por abrir: "+d);0<u&&alert("Error, faltan corchetes por cerrar: "+d);0>u&&alert("Error, faltan corchetes por abrir: "+d);0!=n&&alert("Error, condicional incompleta: "+d);(v=h?h.getRoot():null)&&v.setAllEvalFun();return v};a.Parser.prototype.registerDefaultValues=function(){function b(a,c){for(var d in c)c.hasOwnProperty(d)&&(a[d]=c[d])}var c=this;c.variables.rnd=Math.random;c.variables.pi=c.variables["\u03c0"]=a.returnValue(Math.PI);c.variables.e=a.returnValue(Math.E);
c.variables.Infinity=Infinity;c.variables["-Infinity"]=-Infinity;c.variables.isTouch=c.variables["esT\u00e1ctil"]=a.hasTouchSupport?1:0;c.functions.sqr=function(a){return a*a};c.functions.sqrt=c.functions["ra\u00edz"]=Math.sqrt;c.functions.exp=Math.exp;c.functions.log=Math.log;c.functions.log10=function(a){return Math.log(a)/Math.log(10)};c.functions.abs=Math.abs;c.functions.ent=Math.floor;c.functions.sgn=function(a){return 0<a?1:0>a?-1:0};c.functions.ind=function(a){return a?1:0};c.functions.sin=
c.functions.sen=Math.sin;c.functions.cos=Math.cos;c.functions.tan=Math.tan;c.functions.cot=function(a){return 1/Math.tan(a)};c.functions.sec=function(a){return 1/Math.cos(a)};c.functions.csc=function(a){return 1/Math.sin(a)};c.functions.sinh=c.functions.senh=function(a){return(Math.exp(a)-Math.exp(-a))/2};c.functions.cosh=function(a){return(Math.exp(a)+Math.exp(-a))/2};c.functions.tanh=function(a){return(Math.exp(a)-Math.exp(-a))/(Math.exp(a)+Math.exp(-a))};c.functions.coth=function(a){return 1/c.functions.tanh(a)};
c.functions.sech=function(a){return 1/c.functions.cosh(a)};c.functions.csch=function(a){return 1/c.functions.sinh(a)};c.functions.asin=c.functions.asen=Math.asin;c.functions.acos=Math.acos;c.functions.atan=Math.atan;c.functions.min=Math.min;c.functions.max=Math.max;c.functions._Trace_=c.functions._Print_=function(){console.log.apply(console,arguments);return 0};c.functions._Num_=function(a){if("number"==typeof a)return"NaN";a=a.replace(",",".");return parseFloat(a)==a?parseFloat(a):"NaN"};c.functions._Stop_Audios_=
function(){c.evaluator.parent.stopAudios()};c.functions.esCorrecto=function(b,d,e){return a.esCorrecto(b,d,c.evaluator,e)};c.functions.escorrecto=function(b,d,e){return a.escorrecto(b,d,c.evaluator,e)};window.parent!==window&&(c.functions["parent.set"]=function(a,b){window.parent.postMessage({type:"set",name:a,value:b},"*");return 0},c.functions["parent.update"]=function(){window.parent.postMessage({type:"update"},"*");return 0},c.functions["parent.exec"]=function(a,b){window.parent.postMessage({type:"exec",
name:a,value:b},"*");return 0});c.functions._NumToStr_=c.functions._NumACadena_=function(a,b){a=isNaN(parseFloat(a))?0:parseFloat(a);return a.toFixed(parseInt(b||0))};c.functions._charAt_=c.functions._letraEn_=function(a,b){a=(a||"").toString();b=isNaN(parseInt(b))?0:parseInt(b);return a.charAt(b)};c.functions._substring_=c.functions._subcadena_=function(a,b,c){a=(a||"").toString();b=isNaN(parseInt(b))?0:parseInt(b);c=isNaN(parseInt(c))?0:parseInt(c);return 0<=b&&0<=c?a.substring(b,c):0>b&&0<=c?a.substring(c):
0>c&&0<=b?a.substring(b):""};c.functions._length_=c.functions._longitud_=function(a){return(a||"").toString().length};c.functions._indexOf_=c.functions["_\u00edndiceDe_"]=function(a,b){return(a||"").toString().indexOf((b||"").toString())};this.functions._Load_=function(b){var c="";b&&(c=(c=document.getElementById(b))&&"descartes/archivo"==c.type?c.text:a.openExternalFile(b));return c||""};this.functions._GetValues_=function(a,b){var c=this.functions._Load_(a).replace(/&brvbar;/g,String.fromCharCode("166"));
return this.functions._ExecBlock_(c,b)};this.functions._GetMatrix_=function(a,b){var c=this.functions._Load_(a).replace(/&brvbar;/g,String.fromCharCode("166"));return this.functions._StrToMatrix_(c,b)};this.functions._MatrixToStr_=function(a){var b=this.matrices[a];if(b){for(var c="<"+a+">\\n",d=this.getVariable(a+".columnas_usadas")||b.rows||0,e=this.getVariable(a+".filas_usadas")||b.cols||0,g,n=0;n<d;n++){for(var f=0;f<e;f++)g=b[n][f],void 0!==g&&("string"==typeof g&&(g="'"+g+"'"),c+=g+(f<e-1?" \u00a6 ":
""));c=c.replace(/(\u00A6 )$/g,"")+"\\n"}return c+("</"+a+">")}return""};this.functions._StrToMatrix_=function(a,b){var e=[],g=!1;e.type="matrix";if(a){a=a.replace(/\r|\\r/g,"").split(/\n|\\n/);for(var n=0,f=a.length;n<f;n++)a[n].match("<"+b+">")?(g=a[n].trim().split("<"+b+">"),2==g.length&&""!=g[1]&&e.push(g[1].split(String.fromCharCode("166")).map(d)),g=!0):a[n].match("</"+b+">")?(g=a[n].trim().split("</"+b+">"),2==g.length&&""!=g[0]&&e.push(g[0].split(String.fromCharCode("166")).map(d)),g=!1):
g&&e.push(a[n].split(String.fromCharCode("166")).map(d));c.matrices[b]=e;c.setVariable(b+".filas",e[0].length);c.setVariable(b+".columnas",e.length)}return"OK"};this.functions._GetVector_=function(a,b){var c=this.functions._Load_(a);return this.functions._StrToVector_(c,b)};this.functions._VectorToStr_=function(a){var b=this.vectors[a];if(b){for(var c="<"+a+">\\n",d=this.getVariable(a+".long_usada")||b._size_||0,e,g=0;g<d;g++)e=b[g],void 0!==e?("number"==typeof e&&(e=parseFloat(e)),c+=e+"\\n"):c+=
"0\\n";return c+("</"+a+">")}return""};this.functions._StrToVector_=function(a,b){var e=[],g=!1;e.type="vector";if(a){a=a.replace(/\r|\\r/g,"").split(/\n|\\n/);for(var n=0,f=a.length;n<f;n++)a[n].match("<"+b+">")?g=!0:a[n].match("</"+b+">")?g=!1:g&&e.push(d(a[n]));e._size_=e.length;c.vectors[b]=e;c.setVariable(b+".long",e.length);c.setVariable(b+".long_usada",e.length)}return"OK"};this.functions._ExecStr_=function(a){return this.functions._ExecBlock_(a,"")};this.functions._ExecBlock_=function(a,b){var d=
[],e=""==b;if(a){a=a.replace(/\r|\\r/g,"").split(/\n|\\n/);for(var g=0,n=a.length;g<n;g++)a[g].match("<"+b+">")?(e=a[g].trim().split("<"+b+">"),2==e.length&&""!=e[1]&&(d=d.concat(e[1].split(String.fromCharCode("166")))),e=!0):a[g].match("</"+b+">")?(e=a[g].trim().split("</"+b+">"),2==e.length&&""!=e[0]&&(d=d.concat(e[0].split(String.fromCharCode("166")))),e=!1):e&&(d=d.concat(a[g].split(String.fromCharCode("166"))));g=0;for(n=d.length;g<n;g++)e=d[g].split("="),e[0]=e[0].trim(),2==e.length&&""!=e[0]&&
(isNaN(parseFloat(e[1]))?c.setVariable(e[0],e[1].replace(/^\s|\s$/g,"").replace(/^'|'$/g,"")):c.setVariable(e[0],parseFloat(e[1])))}return 0};var g=document.createElement("a");g.setAttribute("target","_blank");var n,f=null;this.functions._Save_=function(b,c){document.body.appendChild(g);n=new Blob(["\ufeff",c.replace(/\\n/g,"\n").replace(/\\q/g,"'").replace(/\\r/g,"").replace(/\\_/g,"\\")],{type:"text/plain"});g.setAttribute("download",b);g.setAttribute("href",window.URL.createObjectURL(n));null==
f&&(g.click(),f=!0,a.setTimeout(function(){f=null},1E3));document.body.removeChild(g);return 0};var q,k,h,r,t=document.createElement("input");t.setAttribute("type","file");onHandleFileSelect=function(b){q=b.target.files;k=new FileReader;k.onload=function(b){a.addExternalFileContent(q[0].name,b.target.result);c.setVariable(h,q[0].name);c.getFunction(r)&&(c.getFunction(r).apply(c.evaluator,[]),c.evaluator.parent.update())};0<q.length&&k.readAsText(q[0])};t.addEventListener("change",onHandleFileSelect);
this.functions._Open_=function(a,b){h=a;r=b;t.click();return 0};var u,p,v=document.createElement("input");v.setAttribute("type","file");onHandleFileSelect2=function(a){a.stopPropagation();a.preventDefault();u=a.target.files;p=new FileReader;p.onload=function(a){var d={};try{d=JSON.parse(a.target.result)}catch(g){}d.variables&&b(c.variables,d.variables);d.vectors&&b(c.vectors,d.vectors);d.matrices&&b(c.matrices,d.matrices);c.evaluator.parent.update()};0<u.length&&p.readAsText(u[0])};v.removeEventListener("change",
onHandleFileSelect2);v.addEventListener("change",onHandleFileSelect2);this.functions._AnchoDeCadena_=this.functions._strWidth_=function(b,c,d,e){return a.getTextWidth(b,a.convertFont(c+","+d+","+e))};this.functions._Rojo_=this.functions._Red_=function(b){return(new a.Color(b)).r/255};this.functions._Verde_=this.functions._Green_=function(b){return(new a.Color(b)).g/255};this.functions._Azul_=this.functions._Blue_=function(b){return(new a.Color(b)).b/255}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var k=Math.floor;a.Evaluator=function(d){this.parent=d;this.parser=new a.Parser(this);this.variables=this.parser.variables;this.functions=this.parser.functions;this.vectors=this.parser.vectors;this.matrices=this.parser.matrices;this.definitions=this.parser.definitions};a.Evaluator.prototype.setDefinition=function(a,f){this.definitions[a]=f};a.Evaluator.prototype.getDefinition=function(a){return this.definitions[a]};a.Evaluator.prototype.setVariable=function(a,f){this.variables[a]=f};a.Evaluator.prototype.getVariable=
function(a){return this.variables[a]};a.Evaluator.prototype.setVector=function(a,f,p){f=0>f?0:k(f);this.vectors[a][f]=p};a.Evaluator.prototype.getVector=function(a,f){f=0>f?0:k(f);return this.vectors[a][f]};a.Evaluator.prototype.setMatrix=function(a,f,p,c){f=0>f?0:k(f);p=0>p?0:k(p);this.matrices[a][f][p]=c};a.Evaluator.prototype.getMatrix=function(a,f,p){f=0>f?0:k(f);p=0>p?0:k(p);return this.matrices[a][f][p]};a.Evaluator.prototype.setFunction=function(a,f){this.functions[a]=f};a.Evaluator.prototype.getFunction=
function(a){return this.functions[a]};a.Evaluator.prototype.eval=function(a){return a?a.evaluate(this):0};a.externalEvaluator=new a.Evaluator;return a}(descartesJS||{}),descartesJS=function(a){function k(a){for(var b="",c,d=0;d<a.children.length;d++)if(c=a.children[d],"text"===c.nodeType)b+=c.value.replace(/\[/g,"\\left[").replace(/\]/g,"\\right]").replace(/_/g,"\\_").replace(/ /g,"\\;").replace(/</g,"&lt;").replace(/>/g,"&gt;");else if("mathSymbol"===c.nodeType)b+=c.value.replace(/\(/g,"\\left(").replace(/\)/g,
"\\right)");else if("superIndex"===c.nodeType)b+="^{"+k(c)+"}";else if("subIndex"===c.nodeType)b+="_{"+k(c)+"}";else if("fraction"===c.nodeType)b+="\\frac{"+k(c.children[0])+"}{"+k(c.children[1])+"}";else if("radical"===c.nodeType)b+="\\sqrt["+k(c.children[0])+"]{"+k(c.children[1])+"}";else if("sum"===c.nodeType)b+="\\sum_{"+k(c.children[0])+"}^{"+k(c.children[1])+"}{"+k(c.children[2])+"}";else if("integral"===c.nodeType)b+="\\int_{"+k(c.children[0])+"}^{"+k(c.children[1])+"}{"+k(c.children[2])+"}";
else if("limit"===c.nodeType)b+="\\lim_{"+k(c.children[0])+" \\to "+k(c.children[1])+"}{"+k(c.children[2])+"}";else if("matrix"===c.nodeType){for(var b=b+"\\begin{bmatrix}",g=0;g<c.rows;g++){for(var e=0;e<c.columns;e++)b+=k(c.children[e+g*c.columns])+" &";b=b.substring(0,b.length-2)+"\\\\"}b+="\\end{bmatrix}"}else if("defparts"===c.nodeType){b+="\\begin{cases}";for(g=0;g<c.parts;g++)b+=k(c.children[g])+" \\\\";b+="\\end{cases}"}else console.log("<<",a.children[d].nodeType,">>");return b}if(a.loadLib)return a;
var d=Math.floor,f=Math.max,p=2,c=!1,h;a.RTFNode=function(a,b,c,d){this.evaluator=a;this.type="rtfNode";this.value=b;this.nodeType=c;this.style=d;this.styleString=d.toString();this.color=d.textColor;this.underline=d.textUnderline;this.overline=d.textOverline;this.parent=null;this.children=[];switch(this.nodeType){case "textBlock":this.draw=this.drawTextBlock;break;case "textLineBlock":this.draw=this.drawTextLineBlock;break;case "formula":this.draw=this.drawFormula;break;case "superIndex":this.draw=
this.drawSuperIndex;break;case "subIndex":this.draw=this.drawSubIndex;break;case "dynamicText":this.draw=this.drawDynamicText;this.decimal_symbol=this.evaluator.parent.decimal_symbol;break;case "fraction":this.draw=this.drawFraction;break;case "numerator":case "denominator":this.draw=this.drawNumDen;break;case "radical":this.draw=this.drawRadical;break;case "limit":this.draw=this.drawLimit;break;case "integral":this.draw=this.drawIntegral;break;case "sum":this.draw=this.drawSum;break;case "matrix":this.draw=
this.drawMatrix;break;case "defparts":this.draw=this.drawDefparts;break;case "text":case "newLine":this.draw=this.drawText;break;case "hyperlink":this.draw=this.drawHyperlink;break;case "mathSymbol":this.draw=this.drawMathSymbol;break;case "index":case "radicand":case "from":case "to":case "what":case "element":this.draw=this.drawGenericBlock;break;case "componentNumCtrl":this.draw=this.drawComponentNumCtrl;break;case "componentSpace":this.draw=this.drawComponentSpace}};a.RTFNode.prototype.getRoot=
function(){return null==this.parent?this:this.parent.getRoot()};a.RTFNode.prototype.addChild=function(a){a.parent=this;this.children.push(a)};var g=0,b=0,u=0;a.RTFNode.prototype.getTextMetrics=function(){if("textBlock"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);for(var d=0,k=this.children.length;d<k;d++)this.children[d].getTextMetrics()}else if("textLineBlock"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),this.getBlockMetric();else if("newLine"==this.nodeType){this.spaceWidth=
a.getTextWidth(" ",this.styleString);var h=a.getFontMetrics(this.styleString);this.baseline=h.baseline;this.descent=h.descent;this.ascent=h.ascent;this.w=0;this.h=h.h}else if("text"==this.nodeType||"dynamicText"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);h=a.getFontMetrics(this.styleString);this.baseline=h.baseline;this.descent=h.descent;this.ascent=h.ascent;var d=this.value,t;"string"!=typeof this.value&&(k=void 0==this.decimals?p:this.evaluator.eval(this.decimals),t=void 0==
this.fixed?c:this.fixed,d=this.evaluator.eval(this.value,k,t),parseFloat(d).toString()===d.toString()&&(d=t?parseFloat(d).toFixed(k):a.removeNeedlessDecimals(parseFloat(d).toFixed(k)),d=(""+d).replace(".",this.decimal_symbol)),d+=" ");this.w=a.getTextWidth(d,this.styleString);this.h=h.h}else if("formula"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),this.getBlockMetric();else if("hyperlink"===this.nodeType){d=a.getFontMetrics(this.styleString);this.baseline=d.baseline;this.descent=
d.descent;this.ascent=d.ascent;this.w=a.getTextWidth(this.value,this.styleString);this.h=d.h;this.clickCacher=document.createElement("div");this.clickCacher.setAttribute("style","position: absolute; width: "+this.w+"px; height: "+this.h+"px; cursor: pointer;");var v=new a.OpenURL(this.evaluator.parent,this.URL),e=this;this.clickCacher.addEventListener("click",function(a){e.click=!0;v.actionExec()})}else if("superIndex"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),k=g,h=b,t=
u,d=a.getFontMetrics(this.styleString),this.getBlockMetric(),0>this.h&&(this.ascent=d.ascent,this.descent=d.descent,this.h=this.ascent+this.descent,this.w=1.5*this.spaceWidth),d=t/2-h+this.h,this.superIndexPos=d-this.ascent,this.ascent=d,this.descent=h,this.baseline=this.ascent,this.h=this.ascent+this.descent;else if("subIndex"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),k=g,h=b,t=u,d=a.getFontMetrics(this.styleString),this.getBlockMetric(),0>this.h&&(this.ascent=d.ascent,
this.descent=d.descent,this.h=this.ascent+this.descent,this.w=1.5*this.spaceWidth),this.subIndexPos=h+1,this.ascent=k,this.descent=this.subIndexPos+this.descent,this.baseline=this.ascent,this.h=this.ascent+this.descent;else if("fraction"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);var m=this.children[0],w=this.children[1],d=a.getFontMetrics(m.styleString);m.getBlockMetric();w.getBlockMetric();k=g;h=b;t=u;0>m.h&&(m.h=d.h,m.w=this.spaceWidth);0>w.h&&(w.h=d.h,w.w=this.spaceWidth);
this.h=m.h+w.h-1;this.ascent=m.h+Math.round(t/2)-h;this.descent=this.h-this.ascent;this.baseline=this.ascent;this.w=f(m.w,w.w)+this.spaceWidth+8}else if("radical"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);h=this.children[0].style.clone();if(1===this.children.length)this.children[1]=new a.RTFNode(this.evaluator," ","radicand",h),this.children[1].addChild(this.children[0]),this.children[0]=new a.RTFNode(this.evaluator," ","index",h);else if("index"!==this.children[0].nodeType||
"radicand"!==this.children[1].nodeType){t=new a.RTFNode(this.evaluator,"","radicand",h);d=0;for(k=this.children.length;d<k;d++)t.addChild(this.children[d]);this.children=[];this.children[0]=new a.RTFNode(this.evaluator,"","index",h);this.children[1]=t}d=this.children[0];k=this.children[1];0>=d.children.length&&(h=this.style.clone(),h.fontSize=parseInt(h.fontSize-.2*h.fontSize),d.addChild(new a.RTFNode(this.evaluator," ","text",h)));0>=k.children.length&&k.addChild(new a.RTFNode(this.evaluator," ",
"text",this.style.clone()));d.getBlockMetric();k.getBlockMetric();this.ascent=k.h/2<d.h?k.h/2+d.h+2-k.descent:k.ascent+4;this.descent=k.descent;this.baseline=this.ascent;this.h=this.ascent+this.descent;this.w=d.w+k.w+4*this.spaceWidth}else if("sum"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),k=g,h=b,t=u,h=this.children[0],k=this.children[1],t=this.children[2],h.getBlockMetric(),k.getBlockMetric(),t.getBlockMetric(),-1==h.ascent&&(m=a.getFontMetrics(h.styleString),h.ascent=
m.ascent,h.descent=m.descent,h.h=m.h),-1==k.ascent&&(m=a.getFontMetrics(k.styleString),k.ascent=m.ascent,k.descent=m.descent,k.h=m.h),d=a.getFontMetrics(this.styleString),this.ascent=d.h+k.h>t.ascent?d.h-d.descent+k.h:t.ascent,this.descent=h.h>t.descent?h.h+d.descent:t.descent,this.baseline=this.ascent,this.h=this.ascent+this.descent,d=this.style.clone(),d.fontType="Times New Roman",d.Bold="bold",d=d.toString(),d=a.getTextWidth(String.fromCharCode(8721),d),this.w=f(h.w,k.w,d)+f(t.w,this.spaceWidth)+
this.spaceWidth;else if("integral"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),k=g,h=b,t=u,h=this.children[0],k=this.children[1],t=this.children[2],h.getBlockMetric(),k.getBlockMetric(),t.getBlockMetric(),-1==h.ascent&&(m=a.getFontMetrics(h.styleString),h.ascent=m.ascent,h.descent=m.descent,h.h=m.h),-1==k.ascent&&(m=a.getFontMetrics(k.styleString),k.ascent=m.ascent,k.descent=m.descent,k.h=m.h),d=a.getFontMetrics(this.styleString),this.ascent=d.h+k.h>t.ascent?d.h-d.descent+
k.h:t.ascent,this.descent=h.h>t.descent?h.h+d.descent:t.descent,this.baseline=this.ascent,this.h=this.ascent+this.descent,d=this.style.clone(),d.fontSize*=1.5,d.fontType="Times New Roman",d.Bold="bold",d=d.toString(),d=a.getTextWidth(String.fromCharCode(8747),d),this.w=f(h.w,k.w,d)+f(t.w,this.spaceWidth)+2*this.spaceWidth;else if("limit"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),k=g,h=b,t=u,h=this.children[0],k=this.children[1],t=this.children[2],d=a.getFontMetrics(this.styleString),
h.getBlockMetric(),k.getBlockMetric(),t.getBlockMetric(),-1==h.ascent&&(m=a.getFontMetrics(h.styleString),h.ascent=m.ascent,h.descent=m.descent,h.h=m.h),-1==k.ascent&&(m=a.getFontMetrics(k.styleString),k.ascent=m.ascent,k.descent=m.descent,k.h=m.h),-1==t.ascent&&(m=a.getFontMetrics(t.styleString),t.ascent=m.ascent,t.descent=m.descent,t.h=m.h),this.ascent=t.ascent,this.descent=f(d.h,t.descent),this.baseline=this.ascent,this.h=this.ascent+this.descent,d=a.getTextWidth(" "+String.fromCharCode(8594),
this.styleString),0==h.w&&(h.w=this.spaceWidth),0==k.w&&(k.w=this.spaceWidth),0==t.w&&(t.w=this.spaceWidth),this.w=k.w+h.w+t.w+d+this.spaceWidth;else if("matrix"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);d=a.getFontMetrics(this.styleString);k=g;h=b;t=u;t=d.ascent;for(var m=d.descent,w=d.h,l=this.spaceWidth,x,A,d=0,k=this.children.length;d<k;d++)this.children[d].getBlockMetric(),x=this.children[d].h,A=this.children[d].w,w<x&&(w=x,t=this.children[d].ascent,m=this.children[d].descent),
l<A&&(l=A);this.childWidth=l+2*this.spaceWidth;this.childHeight=w;this.childAscent=t;this.childDescent=m;this.h=this.rows*w;this.ascent=this.h/2;this.descent=this.h/2;this.w=this.columns*this.childWidth+this.spaceWidth}else if("defparts"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);d=a.getFontMetrics(this.styleString);k=g;h=b;t=u;t=d.ascent;m=d.descent;w=d.h;l=this.spaceWidth;d=0;for(k=this.children.length;d<k;d++)this.children[d].getBlockMetric(),x=this.children[d].h,A=this.children[d].w,
w<x&&(w=x,t=this.children[d].ascent,m=this.children[d].descent),l<A&&(l=A);this.childWidth=l+2*this.spaceWidth;this.childHeight=w;this.childAscent=t;this.childDescent=m;this.h=this.parts*w;this.ascent=this.h/2+h;this.descent=this.h-this.ascent;this.w=l+this.spaceWidth/2}else"mathSymbol"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),h=a.getFontMetrics(this.styleString),this.baseline=h.baseline,this.descent=h.descent,this.ascent=h.ascent,this.w=a.getTextWidth(this.value,this.styleString)+
this.spaceWidth,this.h=h.h):"componentNumCtrl"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),h=a.getFontMetrics(this.styleString),this.componentNumCtrl=this.evaluator.parent.getControlByCId(this.value),this.baseline=h.baseline-2,this.descent=h.descent-2,this.ascent=h.ascent+2,this.h=this.componentNumCtrl.h||1,this.w=this.componentNumCtrl.w||1):"componentSpace"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),this.componentSpace=this.evaluator.parent.getSpaceByCId(this.value),
this.h=this.ascent=this.descent=this.baseline=0,this.w=this.componentSpace.w):console.log("Element i=unknown",this.nodeType)};a.RTFNode.prototype.getBlockMetric=function(){this.w=0;for(var a=-1,d=-1,c,f=0,h=this.children.length;f<h;f++){c=this.children[f];c.getTextMetrics();childAscent=c.ascent;childDescent=c.descent;this.w+=c.w;var e=childDescent;c=c.h;g=childAscent;b=e;u=c;d<childAscent&&(d=childAscent);a<childDescent&&(a=childDescent)}this.ascent=d;this.descent=a;this.baseline=this.ascent;this.h=
this.ascent+this.descent};a.RTFNode.prototype.drawTextBlock=function(a,b,d,g,f,e,k,u){h=u;this.stableWidth||(p=g,c=f,this.getTextMetrics());k=k?-this.children[0].ascent:0;f=g=0;for(e=this.children.length;f<e;f++)0<f&&(g+=this.children[f-1].h),this.children[f].draw(a,b+0,d+k+g)};a.RTFNode.prototype.drawTextLineBlock=function(a,b,d){for(var c=0,g=0,e=this.children.length;g<e;g++)a.strokeStyle=h,a.fillStyle=h,0<g&&(c+=this.children[g-1].w,"formula"==this.children[g-1].nodeType&&(c+=2*this.children[g-
1].spaceWidth)),this.children[g].draw(a,b+c,d+this.baseline)};a.RTFNode.prototype.drawFormula=function(a,b,d){for(var c=0,g=0,e=this.children.length;g<e;g++)0<g&&(c+=this.children[g-1].w),this.children[g].draw(a,b+this.spaceWidth+c,d)};a.RTFNode.prototype.drawText=function(a,b,d){null!=this.color&&(a.fillStyle=this.color);a.font=this.styleString;a.textAlign="start";a.textBaseline="alphabetic";a.fillText(this.value,b-1,d);if(this.underline){var c="bold"==this.style.textBold,g=c?1:.5;a.lineWidth=c?
2:1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(b-1,parseInt(d+this.descent/2)+g);a.lineTo(b-1+this.w,parseInt(d+this.descent/2)+g);a.stroke()}this.overline&&(g=(c="bold"==this.style.textBold)?2:1.5,a.lineWidth=c?2:1,null!=this.color&&(a.strokeStyle=this.color),a.beginPath(),a.moveTo(b-1,parseInt(d-this.ascent)+g),a.lineTo(b-1+this.w,parseInt(d-this.ascent)+g),a.stroke())};a.RTFNode.prototype.drawDynamicText=function(b,g,f){var h=d(.5*this.spaceWidth),k=void 0==this.decimals?
p:this.evaluator.eval(this.decimals),e=void 0==this.fixed?c:this.fixed,m=this.evaluator.eval(this.value);parseFloat(m).toString()===m.toString()&&(m=e?parseFloat(m).toFixed(k):a.removeNeedlessDecimals(parseFloat(m).toFixed(k)),m=(""+m).replace(".",this.decimal_symbol));null!=this.color&&(b.fillStyle=this.color);b.font=this.styleString;b.textAlign="start";b.textBaseline="alphabetic";this.w=a.getTextWidth(m,this.styleString);b.fillText(m,h+g,f);this.underline&&(e=(k="bold"==this.style.textBold)?1:.5,
b.lineWidth=k?2:1,null!=this.color&&(b.strokeStyle=this.color),b.beginPath(),b.moveTo(h+g-1,parseInt(f+this.descent/2)+e),b.lineTo(h+g-1+this.w,parseInt(f+this.descent/2)+e),b.stroke());this.overline&&(e=(k="bold"==this.style.textBold)?2:1.5,b.lineWidth=k?2:1,null!=this.color&&(b.strokeStyle=this.color),b.beginPath(),b.moveTo(h+g-1,parseInt(f-this.ascent)+e),b.lineTo(h+g-1+this.w,parseInt(f-this.ascent)+e),b.stroke());this.w+=2*h};a.RTFNode.prototype.drawHyperlink=function(a,b,d){this.clickCacher.parentNode||
(a.canvas.nextSibling.className?a.canvas.parentNode.insertBefore(this.clickCacher,a.canvas.nextSibling.nextSibling):a.canvas.parentNode.insertBefore(this.clickCacher,a.canvas.nextSibling),this.clickCacher.style.left=b-2+"px",this.clickCacher.style.top=d-this.ascent-2+"px");a.save();this.click?(a.fillStyle="red",a.strokeStyle="red"):(a.fillStyle="blue",a.strokeStyle="blue");a.font=this.styleStr;a.textAlign="start";a.textBaseline="alphabetic";a.fillText(this.value,b-1,d);var c="bold"==this.style.textBold,
g=c?1:.5;a.lineWidth=c?2:1;a.beginPath();a.moveTo(b-1,Math.ceil(d+this.descent/2)+g-2);a.lineTo(b-1+this.w,Math.ceil(d+this.descent/2)+g-2);a.stroke();a.restore()};a.RTFNode.prototype.drawRadical=function(a,b,c){var g=d(this.spaceWidth);this.children[0].draw(a,b,d(c+this.children[1].descent-this.children[1].h/2-this.children[0].descent));this.children[1].draw(a,b+1.5*g+this.children[0].w,c);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(b,d(c+this.children[1].descent-
this.children[1].h/2));a.lineTo(b+this.children[0].w,d(c+this.children[1].descent-this.children[1].h/2));a.lineTo(b+this.children[0].w+.5*g,c+this.children[1].descent);a.lineTo(b+this.children[0].w+1*g,c-this.children[1].ascent);a.lineTo(b+this.children[0].w+2*g+this.children[1].w,c-this.children[1].ascent);a.stroke()};a.RTFNode.prototype.drawFraction=function(a,b,c){this.children[0].draw(a,b+(this.w-this.children[0].w)/2,c-this.ascent);this.children[1].draw(a,b+(this.w-this.children[1].w)/2,c-this.ascent+
this.children[0].h-1);var g=d(.5*this.spaceWidth);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(b+g,parseInt(c-this.ascent+this.children[0].h)-.5);a.lineTo(b-g+this.w-1,parseInt(c-this.ascent+this.children[0].h)-.5);a.stroke()};a.RTFNode.prototype.drawNumDen=function(a,b,d){for(var c=0,g=0,e=this.children.length;g<e;g++)0<g&&(c+=this.children[g-1].w),this.children[g].draw(a,b+c,d+this.baseline)};a.RTFNode.prototype.drawSubIndex=function(a,b,d){for(var c=0,g=0,e=
this.children.length;g<e;g++)0<g&&(c+=this.children[g-1].w),this.children[g].draw(a,b+c,d+this.subIndexPos)};a.RTFNode.prototype.drawSuperIndex=function(a,b,d){for(var c=0,g=0,e=this.children.length;g<e;g++)0<g&&(c+=this.children[g-1].w),this.children[g].draw(a,b+c,d-this.superIndexPos)};a.RTFNode.prototype.drawLimit=function(b,d,c){var g=a.getFontMetrics(this.styleString),f=" "+String.fromCharCode(8594),e=a.getTextWidth(f,this.styleString);this.children[0].draw(b,d,c+g.descent+this.children[0].ascent);
this.children[1].draw(b,d+this.children[0].w+e,c+g.descent+this.children[1].ascent);this.children[2].draw(b,d+e+this.children[0].w+this.children[1].w,c);null!=this.color&&(b.fillStyle=this.color);b.font=this.styleString;b.textAlign="start";b.textBaseline="alphabetic";b.fillText("l\u00edm",d+this.children[0].w,c);b.fillText(f,d+this.children[0].w,c+g.descent+this.children[0].ascent)};a.RTFNode.prototype.drawIntegral=function(b,c,g){var h=this.style.clone();h.fontSize*=1.5;h.fontType="Times New Roman";
h.Bold="bold";var h=h.toString(),k=a.getTextWidth(String.fromCharCode(8747),h),e=a.getFontMetrics(h),m=f(this.children[0].w,this.children[1].w,d(1.5*k));this.children[0].draw(b,c+k,g+e.descent+this.children[0].ascent);this.children[1].draw(b,c+k+this.spaceWidth/2,g-this.ascent+this.children[1].ascent);this.children[2].draw(b,c+m+k,g);null!=this.color&&(b.fillStyle=this.color);b.font=h;b.textAlign="start";b.textBaseline="alphabetic";b.fillText(String.fromCharCode(8747),c,g+e.descent/2)};a.RTFNode.prototype.drawSum=
function(b,c,g){var h=this.style.clone();h.fontType="Times New Roman";h.Bold="bold";var h=h.toString(),k=a.getTextWidth(String.fromCharCode(8721),h),e=a.getFontMetrics(this.styleString),m=f(this.children[0].w,this.children[1].w,k);this.children[0].draw(b,c+(m-this.children[0].w)/2,g+e.descent+this.children[0].ascent);this.children[1].draw(b,c+(m-this.children[1].w)/2,g-e.ascent-this.children[1].descent);this.children[2].draw(b,c+m,g);null!=this.color&&(b.fillStyle=this.color);b.font=h;b.textAlign=
"start";b.textBaseline="alphabetic";b.fillText(String.fromCharCode(8721),c+d((m-k)/2),g-5)};a.RTFNode.prototype.drawMatrix=function(a,b,c){for(var g,f,e=0,h=this.children.length;e<h;e++)g=e%this.columns,f=d(e/this.columns),this.children[e].draw(a,2*this.spaceWidth+b+g*this.childWidth,c-this.ascent+this.childAscent+f*this.childHeight);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(d(b+this.spaceWidth)+.5,c-this.ascent+.5);a.lineTo(d(b+this.spaceWidth/2)+.5,c-this.ascent+
.5);a.lineTo(d(b+this.spaceWidth/2)+.5,c+this.descent+.5);a.lineTo(d(b+this.spaceWidth)+.5,c+this.descent+.5);a.moveTo(d(b+this.w-this.spaceWidth)-.5,c-this.ascent+.5);a.lineTo(d(b+this.w-this.spaceWidth/2)-.5,c-this.ascent+.5);a.lineTo(d(b+this.w-this.spaceWidth/2)-.5,c+this.descent+.5);a.lineTo(d(b+this.w-this.spaceWidth)-.5,c+this.descent+.5);a.stroke()};a.RTFNode.prototype.drawDefparts=function(a,b,c){for(var d=0,g=this.children.length;d<g;d++)this.children[d].draw(a,b+3*this.spaceWidth,c-this.ascent+
this.childAscent+d%this.parts*this.childHeight);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(parseInt(b+2*this.spaceWidth)+.5,c-this.ascent+.5);a.lineTo(parseInt(b+2*this.spaceWidth)-4.5,c-this.ascent+4.5);a.lineTo(parseInt(b+2*this.spaceWidth)-4.5,c+this.descent-this.h/2-4.5);a.lineTo(b-.5,c+this.descent-this.h/2);a.lineTo(parseInt(b+2*this.spaceWidth)-4.5,c+this.descent-this.h/2+4.5);a.lineTo(parseInt(b+2*this.spaceWidth)-4.5,c+this.descent-4.5);a.lineTo(parseInt(b+
2*this.spaceWidth)+.5,c+this.descent+.5);a.stroke()};a.RTFNode.prototype.drawMathSymbol=function(a,b,c){a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color,a.fillStyle=this.color);a.beginPath();"("==this.value?(a.font=this.styleString,a.textAlign="start",a.textBaseline="alphabetic",a.fillText("(",b,c)):")"==this.value?(a.font=this.styleString,a.textAlign="start",a.textBaseline="alphabetic",a.fillText(")",b+this.spaceWidth,c)):(a.font=this.styleString,a.textAlign="center",a.textBaseline="alphabetic",
a.fillText(this.value,b+this.w/2,c))};a.RTFNode.prototype.drawGenericBlock=function(a,b,c){for(var d=0,g=0,e=this.children.length;g<e;g++)0<g&&(d+=this.children[g-1].w),this.children[g].draw(a,b+d,c)};a.RTFNode.prototype.drawComponentNumCtrl=function(a,b,c){this.parent.getTextMetrics();this.componentNumCtrl.expresion=this.evaluator.parser.parse("("+b+","+(c-this.ascent)+","+this.componentNumCtrl.w+","+this.componentNumCtrl.h+")")};a.RTFNode.prototype.drawComponentSpace=function(a,b,c){this.getTextMetrics();
this.componentSpace.xExpr=this.evaluator.parser.parse(b.toString());this.componentSpace.yExpr=this.evaluator.parser.parse((c-this.parent.ascent).toString())};a.RTFNode.prototype.draw=function(a,b,c){console.log(">>> Dibujo desconocido ",this.nodeType)};a.RTFNode.prototype.toHTML=function(a){var b="";if("textLineBlock"===this.nodeType||"textBlock"===this.nodeType)for(var c=0,d=this.children.length;c<d;c++)b+=this.children[c].toHTML(a);else"text"===this.nodeType?b="<span "+this.style.toCSS()+">"+this.value.replace(/ {2}/g,
"&nbsp;&nbsp;").replace(/&nbsp; /g,"&nbsp;")+"</span>":"newLine"===this.nodeType?b="<span "+this.style.toCSS()+">"+this.value+"<br /></span>":"hyperlink"===this.nodeType?b="<span "+this.style.toCSS()+"> <a target='_blank' href='"+this.URL+"'>"+this.value+"</a></span>":"formula"===this.nodeType?b="<span "+this.style.toCSS()+"> \\( \\displaystyle "+k(this)+"\\) </span>":"componentSpace"===this.nodeType?(a.spaces.push({cID:"cID_"+this.value,value:this.componentSpace}),b="<div style='display:inline-block; vertical-align:top; width:"+
this.componentSpace.w+"px; height:0px;' id='cID_"+this.value+"'></div>"):"componentNumCtrl"===this.nodeType?(a.ctrs.push({cID:"cID_"+this.value,value:this.componentNumCtrl}),b="<div style='display:inline-block; vertical-align:middle; width:"+this.componentNumCtrl.w+"px; height:"+this.componentNumCtrl.h+"px;' id='cID_"+this.value+"'></div>"):console.log(">>>",this,"<<<");return b};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k=String.fromCharCode,d,f,p,c,h,g,b,u,n,r,
q,t;a.RTFTokenizer=function(){};a.RTFTokenizer.prototype.tokenize=function(a){if(a)a=a.replace(/\&gt;/g,">").replace(/\&lt;/g,"<").replace(/\&quote;/g,"''").replace(/\&squot;/g,"'").replace(/\\rquote /g,"'").replace(/\\endash /g,"-").replace(/\n/g," ").replace(/\r/g,"").replace(/\\uc(\d+) /g,"").replace(/\\uc(\d+)/g,"");else return[];d=[];f=a.length;d=[];p="";h=c=0;b=a.charAt(0);u=!1;for(n="text";c<f;)g=b,b=a.charAt(c+1),u?"\\"===b||"{"===b||"}"===b||" "===b||";"===b?(u=!1,p+=g," "===b?(c++,b=a.charAt(c+
1),t=!0):t=!1,(r=p.match(/^\'([0-9a-f]{2})/))?(q="","text"===n&&(q=d.pop().value),p=q+=k(parseInt(r[1],16))+p.substring(3)):(r=p.match(/^u[0-9]+/))?(q="","text"===n&&(q=d.pop().value),p=q+=k(r[0].substring(1))):("{"===p||"}"===p||"\\"==g?(d.push({type:"text",value:p+(t?" ":"")}),n="text"):(d.push({type:"controlWord",value:p}),n="controlWord"),p="")):"{"==g||"}"==g||"\\"==g?(u=!1,d.push({type:"text",value:g}),n="text"):p+=g:"\\"===g?(u=!0,""!==p&&(d.push({type:"text",value:p}),n="text"),p=""):"{"===
g?(h++,""!==p&&d.push({type:"text",value:p}),p="",d.push({type:"openBlock",value:h}),n="openBlock"):"}"===g?(""!==p&&d.push({type:"text",value:p}),p="",d.push({type:"closeBlock",value:h}),n="closeBlock",h--):p+=g,c++;""!==p&&d.push({type:"text",value:p});return d};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k=Math.max,d,f,p,c,h,g,b,u,n,r,q,t,v,e,m,w,l,x,A,D,B,E,G,F,J,C,z,I,H,M;a.RTFParser=function(b){this.evaluator=b;this.tokenizer=new a.RTFTokenizer};a.RTFParser.prototype.parse=
function(y){y=d=this.tokenizer.tokenize(y);for(var L=[],K=!1,N=!1,T=[],O=0,U=y.length;O<U;O++)if("openBlock"==y[O].type&&T.push(y[O].value),"closeBlock"==y[O].type&&(T.pop(),0>=T.length&&(K=!1)),"controlWord"!=y[O].type||"expr"!=y[O].value&&"decimals"!=y[O].value||(N=!0),"controlWord"==y[O].type&&"mjaformula"==y[O].value&&(K=!0),"text"==y[O].type&&K&&!N){for(var R=0,P=y[O].value,Q="",S=0,ca=P.length;S<ca;S++)if("("==P.charAt(S)||")"==P.charAt(S)||"+"==P.charAt(S)||"-"==P.charAt(S)||"*"==P.charAt(S)||
"="==P.charAt(S))Q=P.substring(R,S),""!=Q&&L.push({type:"text",value:Q}),L.push({type:P.charAt(S),value:P.charAt(S)}),R=S+1;Q=P.substring(R,S);""!=Q&&L.push({type:"text",value:Q})}else L.push(y[O]),"text"==y[O].type&&N&&(N=!1);d=L;f={};c=2;if("openBlock"==d[0].type&&"fonttbl"==d[1].value){for(p=d[0].value;"closeBlock"!=d[c].type&&d[c].value!=p;)f[d[c].value]=d[c+2].value.substring(0,d[c+2].value.length-1),c+=3;c++}h={};g=0;if("openBlock"==d[c].type&&"colortbl"==d[c+1].value){p=d[c++].value;for(c++;"closeBlock"!=
d[c].type&&d[c].value!=p;)b=parseInt(d[c++].value.substring(3)).toString(16),u=parseInt(d[c++].value.substring(5)).toString(16),n=parseInt(d[c++].value.substring(4)).toString(16),";"===d[c].value&&c++,h[g++]="#"+(2>b.length?"0"+b:b)+(2>u.length?"0"+u:u)+(2>n.length?"0"+n:n);c++}r=new a.RTFNode(this.evaluator,"","textBlock","",!1,"");q=new a.RTFNode(this.evaluator,"","textLineBlock","",!1,"");r.addChild(q);e=v=t=null;D=A=x=l=w=m=!1;B=[new a.FontStyle(20,"Arial","","",!1,!1,null)];E=B[0];G=!0;J=F=-1;
C=[];M=H=I=z=!1;y=c;for(L=d.length;y<L;y++)if("controlWord"==d[y].type&&f[d[y].value])E.fontType=f[d[y].value];else if("controlWord"==d[y].type&&d[y].value.match(/^fs(\d+)/))E.fontSize=parseInt(d[y].value.match(/^fs(\d+)/)[1]/2);else if("controlWord"==d[y].type&&"b"==d[y].value)E.textBold="bold";else if("controlWord"==d[y].type&&"b0"==d[y].value)E.textBold="";else if("controlWord"==d[y].type&&"i"==d[y].value)E.textItalic="oblique";else if("controlWord"==d[y].type&&"i0"==d[y].value)E.textItalic="";
else if("controlWord"==d[y].type&&"ul"==d[y].value)E.textUnderline=!0;else if("controlWord"==d[y].type&&"ulnone"==d[y].value)E.textUnderline=!1;else if("controlWord"==d[y].type&&"ol"==d[y].value)E.textOverline=!0;else if("controlWord"==d[y].type&&"olnone"==d[y].value)E.textOverline=!1;else if("controlWord"==d[y].type&&d[y].value.match(/^cf(\d+)/))E.textColor=h[parseInt(d[y].value.substring(2))],0<C.length&&(C[C.length-1].style.textColor=E.textColor);else if("openBlock"==d[y].type)F=d[y].value,E=E.clone(),
B.push(E),C.push(null);else if("closeBlock"==d[y].type)d[y].value==J&&(J=-1,m=!1,q=q.parent),B.pop(),E=B[B.length-1],C.pop();else if("controlWord"==d[y].type&&"par"==d[y].value){q.addChild(new a.RTFNode(this.evaluator,"","newLine",E.clone()));r=new a.RTFNode(this.evaluator,"","textLineBlock",E.clone());if("textBlock"!=q.nodeType)for(q=q.parent;"textBlock"!=q.nodeType;)q=q.parent;q.addChild(r);q=r}else if("controlWord"==d[y].type&&"mjaformula"==d[y].value)z=!0,J=F,m=!0,r=new a.RTFNode(this.evaluator,
"","formula",E.clone()),q.addChild(r),q=r,C[C.length-1]=r;else if("controlWord"==d[y].type&&("fraction"==d[y].value||"radicand"==d[y].value||"radical"==d[y].value||"what"==d[y].value||"sum"==d[y].value||"integral"==d[y].value||"limit"==d[y].value))K=C[C.length-2].style.clone(),r=new a.RTFNode(this.evaluator,"",d[y].value,K),C[C.length-2].addChild(r),C[C.length-1]=r;else if("controlWord"==d[y].type&&"index"==d[y].value||"to"==d[y].value||"from"==d[y].value)K=C[C.length-2].style.clone(),K.fontSize=
k(parseInt(K.fontSize-.2*K.fontSize),8),r=new a.RTFNode(this.evaluator,"",d[y].value,K),C[C.length-2].addChild(r),C[C.length-1]=r;else if("controlWord"==d[y].type&&("num"==d[y].value||"den"==d[y].value))K=C[C.length-2].style.clone(),K.fontSize=k(Math.round(K.fontSize-.1*K.fontSize),8),"num"==d[y].value?r=new a.RTFNode(this.evaluator,"","numerator",K):"den"==d[y].value&&(r=new a.RTFNode(this.evaluator,"","denominator",K)),C[C.length-2].addChild(r),C[C.length-1]=r;else if("controlWord"==d[y].type&&
("subix"==d[y].value||"supix"==d[y].value))K=C[C.length-2].style.clone(),K.fontSize=k(Math.floor(K.fontSize-K.fontSize/3),8),"subix"==d[y].value?r=new a.RTFNode(this.evaluator,"","subIndex",K):"supix"==d[y].value&&(r=new a.RTFNode(this.evaluator,"","superIndex",K)),r.originalStyle=C[C.length-2].style.clone(),C[C.length-2].addChild(r),C[C.length-1]=r;else if("controlWord"==d[y].type&&("defparts"==d[y].value||"matrix"==d[y].value||"element"==d[y].value))K=C[C.length-2].style.clone(),r=new a.RTFNode(this.evaluator,
"",d[y].value,K),C[C.length-2].addChild(r),C[C.length-1]=r,"defparts"==d[y].value?e=r:"matrix"==d[y].value&&(v=r);else if("controlWord"==d[y].type&&"parts"==d[y].value)D=!0;else if("text"==d[y].type&&D)e.parts=parseInt(d[y].value),D=!1;else if("controlWord"==d[y].type&&"rows"==d[y].value)x=!0;else if("text"==d[y].type&&x)v.rows=parseInt(d[y].value),x=!1;else if("controlWord"==d[y].type&&"columns"==d[y].value)A=!0;else if("text"==d[y].type&&A)v.columns=parseInt(d[y].value),A=!1;else if("controlWord"==
d[y].type&&"expr"==d[y].value)G=!1,w=!0;else if("controlWord"==d[y].type&&"decimals"==d[y].value)l=!0;else if("text"==d[y].type&&l)t.decimals=this.evaluator.parser.parse(d[y].value+""),l=!1;else if("controlWord"==d[y].type&&"fixed1"==d[y].value)t.fixed=!0;else if("controlWord"==d[y].type&&"fixed0"==d[y].value)t.fixed=!1;else if("controlWord"!=d[y].type||"component"!=d[y].value)if("controlWord"==d[y].type&&"NumCtrl"==d[y].value)I=!0;else if("controlWord"==d[y].type&&"Space"==d[y].value)H=!0;else if("controlWord"==
d[y].type&&"hyperlink"==d[y].value)M=!0;else if("text"==d[y].type&&M){textContent=d[y].value.split("|")[0];K=E.clone();r=new a.RTFNode(this.evaluator,textContent,"hyperlink",K);r.URL=d[y].value.split("|")[1];if("textLineBlock"!=q.nodeType)for(q=q.parent;"textLineBlock"!=q.nodeType;)q=q.parent;q.addChild(r);M=!1}else if("text"==d[y].type&&I)r=new a.RTFNode(this.evaluator,d[y].value,"componentNumCtrl",E.clone()),q.addChild(r),I=!1;else if("text"==d[y].type&&H)r=new a.RTFNode(this.evaluator,d[y].value,
"componentSpace",E.clone()),q.addChild(r),H=!1;else if("text"==d[y].type&&w)K=C[C.length-2].style.clone(),textContent=this.evaluator.parser.parse(d[y].value),r=new a.RTFNode(this.evaluator,textContent,"dynamicText",K),C[C.length-2].addChild(r),t=C[C.length-1]=r,w=!1;else if("text"==d[y].type&&!w&&!m){textContent=d[y].value;r=new a.RTFNode(this.evaluator,textContent,"text",E.clone());if("textLineBlock"!=q.nodeType)for(q=q.parent;"textLineBlock"!=q.nodeType;)q=q.parent;q.addChild(r)}else if("text"==
d[y].type&&!w&&m)textContent=d[y].value,r=new a.RTFNode(this.evaluator,textContent,"text",C[C.length-1].style.clone()),C[C.length-1].addChild(r);else if("("==d[y].type||")"==d[y].type)K=C[C.length-1].style.clone(),K.textItalic="",r=new a.RTFNode(this.evaluator,d[y].type,"mathSymbol",K),C[C.length-1].addChild(r);else if("+"==d[y].type||"-"==d[y].type||"*"==d[y].type||"="==d[y].type)r=new a.RTFNode(this.evaluator,d[y].type,"mathSymbol",C[C.length-1].style.clone()),C[C.length-1].addChild(r);if(null!=
q){var W=q.getRoot();W.stableWidth=G;W.getTextMetrics();W.hasFormula=z}return W};a.FontStyle=function(a,b,c,d,g,e,f){this.fontSize=a;this.fontType=b;this.textItalic=c;this.textBold=d;this.textUnderline=g;this.textOverline=e;this.textColor=f};a.FontStyle.prototype.toString=function(){/arial/i.test(this.fontType)?this.fontType="descartesJS_sansserif,Arial,Helvetica,Sans-serif":/times/i.test(this.fontType)?this.fontType="descartesJS_serif,'Times New Roman',Times,serif":/courier/i.test(this.fontType)&&
(this.fontType="descartesJS_monospace,'Courier New',Courier,Monospace");return(this.textBold+" "+this.textItalic+" "+this.fontSize+"px "+this.fontType).trim()};a.FontStyle.prototype.toCSS=function(){var a='style="font-size:'+this.fontSize+"px; font-family:"+this.fontType+";";this.textUnderline&&!this.textOverline&&(a+="text-decoration:underline;");!this.textUnderline&&this.textOverline&&(a+="text-decoration:overline;");this.textUnderline&&this.textOverline&&(a+="text-decoration:underline overline;");
this.textBold&&!this.textItalic&&(a+="font-style:normal;font-weight:bold;");!this.textBold&&this.textItalic&&(a+="font-style:italic;font-weight:normal;");this.textBold&&this.textItalic&&(a+="font-style:italic;font-weight:bold;");this.textBold||this.textItalic||(a+="font-style:normal;font-weight:normal;");this.textColor&&(a+="color:"+this.textColor+";");return a+'"'};a.FontStyle.prototype.clone=function(){return new a.FontStyle(this.fontSize,this.fontType,this.textItalic,this.textBold,this.textUnderline,
this.textOverline,this.textColor)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k,d,f,p,c,h,g,b,u,n,r;a.Space=function(b,c){this.parent=b;d=this.evaluator=this.parent.evaluator;f=d.parser;this.id="";this.values=c;this.type="R2";this.xExpr=f.parse("0");this.yExpr=f.parse("0");this.w=parseInt(b.container.width);this.h=parseInt(b.container.height);this.drawif=f.parse("1");this.fixed=2==b.version;this.scale=48;this.Oy=this.Ox=0;this.image=new Image;this.image.onload=function(){this.ready=
1};this.imageSrc="";this.bg_display="topleft";this.background=new a.Color(/DescartesJS.class/i.test(b.code)||b.arquimedes?"f0f8fa":"ffffff");this.net=2!=b.version?new a.Color("c0c0c0"):"";this.net10=2!=b.version?new a.Color("808080"):"";this.axes=2!=b.version?new a.Color("808080"):"";this.text=new a.Color("ffafaf");this.numbers=!1;this.y_axis=this.x_axis=2!=b.version?"":" ";this.sensitive_to_mouse_movements=!1;this.cID="";this.mouse_y=this.mouse_x=0;this.ctrs=[];this.graphicsCtr=[];this.graphics=
[];this.backGraphics=[];this.zIndex=b.zIndex;this.plecaHeight=b.plecaHeight||0;this.displaceRegionNorth=b.displaceRegionNorth||0;this.displaceRegionWest=b.displaceRegionWest||0;for(var g in c)c.hasOwnProperty(g)&&(this[g]=c[g]);this.init()};a.Space.prototype.init=function(){k=this.parent;d=this.evaluator;p=this.id;this.displaceRegionNorth=k.displaceRegionNorth||0;this.displaceRegionSouth=k.displaceRegionSouth||0;this.displaceRegionEast=k.displaceRegionEast||0;this.displaceRegionWest=k.displaceRegionWest||
0;b=parseInt(k.container.width);g=parseInt(k.container.height);void 0!=this.wExpr&&(this.w=parseInt(b-this.displaceRegionWest-this.displaceRegionEast)*parseFloat(this.wExpr)/100);void 0!=this.hExpr&&(this.h=parseInt(g-this.displaceRegionNorth-this.displaceRegionSouth)*parseFloat(this.hExpr)/100);void 0!=this.xPercentExpr&&(this.xExpr=d.parser.parse((parseInt(b-this.displaceRegionWest-this.displaceRegionEast)*parseFloat(this.xPercentExpr)/100).toString()));void 0!=this.yPercentExpr&&(this.yExpr=d.parser.parse((parseInt(g-
this.displaceRegionNorth-this.displaceRegionSouth)*parseFloat(this.yPercentExpr)/100).toString()));this.x=d.eval(this.xExpr)+this.displaceRegionWest;this.y=d.eval(this.yExpr)+this.plecaHeight+this.displaceRegionNorth;this.container&&(this.container.style.left=this.x+"px",this.container.style.top=this.y+"px");0<=this.y?(c=g-this.y,this.h>c&&(this.h=c)):(c=this.h+this.y,this.h=c>=g?g:c);0<=this.x?(h=b-this.x,this.w>h&&(this.w=h)):(h=this.w+this.x,this.w=h>=b?b:h);""==this.imageSrc&&/vacio.gif$/i.test(this.imageSrc.trim())||
(this.image=k.getImage(this.imageSrc));this.OxExpr&&(n=this.OxExpr,"%"===n[n.length-1]?this.Ox=this.w*parseFloat(n)/100:(u=parseFloat(n),u!=n&&(u=0),this.Ox=u));this.OyExpr&&(r=this.OyExpr,"%"===r[r.length-1]?this.Oy=this.h*parseFloat(r)/100:(u=parseFloat(r),u!=r&&(u=0),this.Oy=u));""!==this.id&&2!==k.version?(d.setVariable(p+"._w",this.w),d.setVariable(p+"._h",this.h),d.setVariable(p+".escala",this.scale),d.setVariable(p+".Ox",this.Ox),d.setVariable(p+".Oy",this.Oy),d.setVariable(p+".mouse_x",0),
d.setVariable(p+".mouse_y",0),d.setVariable(p+".mouse_pressed",0),d.setVariable(p+".mouse_clicked",0),d.setVariable(p+".clic_izquierdo",0)):(u=d.getVariable("_w"),void 0===u&&(u=this.w),d.setVariable("_w",u),u=d.getVariable("_h"),void 0===u&&(u=this.h),d.setVariable("_h",u),u=d.getVariable("escala"),void 0===u&&(u=this.scale),d.setVariable("escala",u),u=d.getVariable("Ox"),void 0===u&&(u=this.Ox),d.setVariable("Ox",u),u=d.getVariable("Oy"),void 0===u&&(u=this.Oy),d.setVariable("Oy",u),d.setVariable("mouse_x",
0),d.setVariable("mouse_y",0),d.setVariable("mouse_pressed",0),d.setVariable("mouse_clicked",0),d.setVariable("clic_izquierdo",0),2==k.version&&""===this.x_axis&&""===this.y_axis&&(this.axes=""));this.w_2=this.w/2;this.h_2=this.h/2};a.Space.prototype.addCtr=function(a){"graphic"===a.type?this.graphicsCtr.push(a):this.ctrs.push(a)};a.Space.prototype.addGraph=function(a,b){"R2"===this.type&&b||"R3"===this.type&&!b||(a.background&&"R3"!==this.type?this.backGraphics.push(a):this.graphics.push(a))};a.Space.prototype.clearClick=
function(){this.evaluator.setVariable(this.mclickedString,0);this.evaluator.setVariable(this.mclicizquierdoString,0)};a.Space.prototype.getRelativeX=function(a){return(parseInt(a)-this.w_2-this.Ox)/this.scale};a.Space.prototype.getRelativeY=function(a){return(-parseInt(a)+this.h_2+this.Oy)/this.scale};a.Space.prototype.getAbsoluteX=function(a){return a*this.scale+this.w_2+this.Ox};a.Space.prototype.getAbsoluteY=function(a){return-a*this.scale+this.h_2+this.Oy};return a}(descartesJS||{}),descartesJS=
function(a){if(a.loadLib)return a;var k;a.SpaceExternal=function(a){k=this;k.parent=a;k.width=228;k.vSpace=25;k.container=document.createElement("div");k.container.setAttribute("style","box-sizing:border-box;border-style:ridge;border-width:5px;border-color:gray;box-shadow:#000 0 0 25px 5px;overflow-y:scroll;overflow-x:hidden;position:fixed;left:0;top:0;z-index:10000;width:"+(k.width+27)+"px;height:460px;background-color:#63b4fb");k.movable=document.createElement("div");k.movable.setAttribute("style",
" position:absolute;left:0;top:0;width:"+(k.width+27)+"px;height:"+k.vSpace+"px;line-height:"+k.vSpace+"px;background-color:#ddd;cursor:move;padding-left:75px;font-family:Sans-Serif;font-size:18px;");k.movable.innerHTML="Descartes";k.container.appendChild(k.movable);k.ctrs=[]};a.SpaceExternal.prototype.init=function(){function d(c){k.newPos=a.getCursorPosition(c,document.body);k.container.style.left=k.initialPosition.x+(k.newPos.x-k.oldPos.x)*a.cssScale+"px";k.container.style.top=k.initialPosition.y+
(k.newPos.y-k.oldPos.y)*a.cssScale+"px"}function f(a){a.preventDefault();document.body.removeEventListener("mousemove",d);document.body.removeEventListener("mouseup",f)}document.body.appendChild(this.container);k=this;for(var p=k.parent.evaluator.parser,c=0,h=k.ctrs.length;c<h;c++)k.ctrs[c].expresion=p.parse("(0,"+(k.vSpace+23+35*c)+","+k.width+",35)"),k.ctrs[c].update();k.numCtr=h;c=new a.Button(k.parent,{region:"external",name:"english"==k.language?"about":"cr\u00e9ditos",font_size:p.parse("15"),
expresion:p.parse("(0,"+k.vSpace+","+k.width/2+",25)")});c.actionExec={execute:a.showAbout};c.update();(new a.Button(k.parent,{region:"external",name:"config",font_size:p.parse("15"),action:"config",expresion:p.parse("("+k.width/2+","+k.vSpace+","+k.width/2+",25)")})).update();(new a.Button(k.parent,{region:"external",name:"english"==k.language?"init":"inicio",font_size:p.parse("15"),action:"init",expresion:p.parse("(0,"+(k.vSpace+23+35*h)+","+k.width/2+",25)")})).update();(new a.Button(k.parent,
{region:"external",name:"english"==k.language?"clear":"limpiar",font_size:p.parse("15"),action:"clear",expresion:p.parse("("+k.width/2+","+(k.vSpace+23+35*h)+","+k.width/2+",25)")})).update();p=new a.Button(k.parent,{region:"external",name:"english"==k.language?"close":"cerrar",font_size:p.parse("15"),expresion:p.parse("("+k.width/4+","+(k.vSpace+46+35*h)+","+k.width/2+",25)")});p.update();p.canvas.addEventListener("click",function(a){k.hide()});k.setPositionAndSize();k.movable.addEventListener("mousedown",
function(c){c.preventDefault();k.oldPos=a.getCursorPosition(c,document.body);k.initialPosition={x:k.container.offsetLeft,y:k.container.offsetTop};document.body.addEventListener("mousemove",d);document.body.addEventListener("mouseup",f)});k.hide()};a.SpaceExternal.prototype.addCtr=function(a){this.ctrs.push(a)};a.SpaceExternal.prototype.show=function(){this.setPositionAndSize();this.container.style.display="block"};a.SpaceExternal.prototype.hide=function(){this.container.style.display="none"};a.SpaceExternal.prototype.setPositionAndSize=
function(){k=this;var a=k.vSpace+46+35*k.numCtr+25+10;k.container.style.left=Math.max(parseInt(window.innerWidth-k.width)/2,0)+"px";k.container.style.top="5px";k.container.style.height=window.innerHeight<k.vSpace+75?k.vSpace+75+"px":a>window.innerHeight-10?window.innerHeight-10:a+"px"};return a}(descartesJS||{}),descartesJS=function(a){var k,d;if(a.loadLib)return a;var f=Math.floor,p=Math.round,c=2*Math.PI,h=a.convertFont("SansSerif,PLAIN,12"),g=a.convertFont("Monospaced,PLAIN,12"),b,u,n,r,q,t,v,
e,m,w,l,x,A,D,B,E,G,F,J,C,z,I,H,M,y,L,K,N;a.Space2D=function(c,d){a.Space.call(this,c,d);b=this;b.ratio=c.ratio;b.canvas=document.createElement("canvas");b.canvas.setAttribute("id",b.id+"_canvas");b.canvas.setAttribute("class","DescartesSpace2DCanvas");b.backCanvas=document.createElement("canvas");b.backCanvas.setAttribute("id",b.id+"_background");b.canvas.style.zIndex=b.zIndex;b.canvas.width=b.backCanvas.width=b.w*b.ratio;b.canvas.height=b.backCanvas.height=b.h*b.ratio;b.canvas.style.width=b.backCanvas.style.width=
b.w+"px";b.canvas.style.height=b.backCanvas.style.height=b.h+"px";b.ctx=b.canvas.getContext("2d");b.backCtx=b.backCanvas.getContext("2d");b.ctx.imageSmoothingEnabled=b.backCtx.imageSmoothingEnabled=!1;b.graphicControlContainer=document.createElement("div");b.graphicControlContainer.setAttribute("id",b.id+"_graphicControls");b.graphicControlContainer.setAttribute("style","position:absolute;left:0;top:0;z-index:"+b.zIndex+";");b.numericalControlContainer=document.createElement("div");b.numericalControlContainer.setAttribute("id",
b.id+"_numericalControls");b.numericalControlContainer.setAttribute("style","position:absolute;left:0;top:0;z-index:"+b.zIndex+";");b.container=document.createElement("div");b.container.setAttribute("id",b.id);b.container.setAttribute("class","DescartesSpace2DContainer");b.container.setAttribute("style","left:"+b.x+"px;top:"+b.y+"px;z-index:"+b.zIndex+";");b.parent.arquimedes&&"#f0f8fa"===b.background.getColor()&&(b.container.style.border="1px solid #b8c4c8");b.container.appendChild(b.backCanvas);
b.container.appendChild(b.canvas);b.container.appendChild(b.graphicControlContainer);b.container.appendChild(b.numericalControlContainer);c.container.insertBefore(b.container,c.loader);b.parent.images[b.id+".image"]=b.canvas;b.parent.images[b.id+".image"].ready=1;b.parent.images[b.id+".image"].complete=!0;b.parent.images[b.id+".image"].canvas=!0;b.evaluator.setVariable(b.id+".image",b.id+".image");b.parent.images[b.id+".back"]=b.backCanvas;b.parent.images[b.id+".back"].ready=1;b.parent.images[b.id+
".back"].complete=!0;b.parent.images[b.id+".back"].canvas=!0;b.evaluator.setVariable(b.id+".back",b.id+".back");var g=""!==b.id&&2!==c.version?b.id+".":"";b.OxStr=g+"Ox";b.OyStr=g+"Oy";b.scaleStr=g+"escala";b.wStr=g+"_w";b.hStr=g+"_h";b.mxStr=g+"mouse_x";b.myStr=g+"mouse_y";b.mpressedStr=g+"mouse_pressed";b.mclickedStr=g+"mouse_clicked";b.mclickIzqStr=g+"clic_izquierdo";b.click=0;"descartesJS_stage"!==b.id?b.addEvents():b.canvas.oncontextmenu=function(a){return!1}};a.extend(a.Space2D,a.Space);a.Space2D.prototype.init=
function(){b=this;b.uber.init.call(b);b.canvas&&(b.canvas.width=b.backCanvas.width=b.w*b.ratio,b.canvas.height=b.backCanvas.height=b.h*b.ratio,b.canvas.style.width=b.backCanvas.style.width=b.w+"px",b.canvas.style.height=b.backCanvas.style.height=b.h+"px")};a.Space2D.prototype.update=function(a){b=this;u=b.evaluator;n=b.parent;u.setVariable(b.wStr,b.w);u.setVariable(b.hStr,b.h);b.drawIfValue=0<u.eval(b.drawif);if(b.drawIfValue){q=b.x!==u.eval(b.xExpr)+b.displaceRegionWest;t=b.y!==u.eval(b.yExpr)+n.plecaHeight+
b.displaceRegionNorth;b.spaceChange=a||q||t||b.drawBefore!==b.drawIfValue||b.Ox!==u.getVariable(b.OxStr)||b.Oy!==u.getVariable(b.OyStr)||b.scale!==u.getVariable(b.scaleStr)||b.backColor!==b.background.getColor();b.x=q?u.eval(b.xExpr)+b.displaceRegionWest:b.x;b.y=t?u.eval(b.yExpr)+n.plecaHeight+b.displaceRegionNorth:b.y;b.Ox=u.getVariable(b.OxStr);b.Oy=u.getVariable(b.OyStr);b.scale=u.getVariable(b.scaleStr);b.drawBefore=b.drawIfValue;b.scale=Math.max(1E-6,Math.min(1E6,b.scale));u.setVariable(b.scaleStr,
b.scale);if(q||t)b.container.style.left=b.x+"px",b.container.style.top=b.y+"px";b.container.style.display="block";b.drawTrace=!b.spaceChange&&(!b.fixed&&!b.click||b.fixed);b.spaceChange&&(b.backCtx.setTransform(b.ratio,0,0,b.ratio,0,0),b.drawBackground());b.ctx.setTransform(b.ratio,0,0,b.ratio,0,0);b.draw()}else b.container.style.display="none"};a.Space2D.prototype.drawBackground=function(){b=this;u=b.evaluator;r=b.backCtx;r.clearRect(0,0,b.backCanvas.width,b.backCanvas.height);b.backColor=b.background.getColor();
r.fillStyle=b.backColor;r.fillRect(0,0,b.backCanvas.width,b.backCanvas.height);b.image&&""!=b.image.src&&b.image.ready&&b.image.complete&&("topleft"===b.bg_display?r.drawImage(b.image,0,0):"stretch"===b.bg_display?r.drawImage(b.image,0,0,b.w,b.h):"patch"===b.bg_display?(r.fillStyle=r.createPattern(b.image,"repeat"),r.fillRect(0,0,b.w,b.h)):"imgcenter"===b.bg_display&&r.drawImage(b.image,(b.w-b.image.width)/2,(b.h-b.image.height)/2));e=b.scale;m=0;for(w=0>b.w+b.h?0:b.w+b.h;e>w;)e/=10,m++;for(;e<w/
10;)e*=10;r.lineWidth=1;""!==b.net&&(r.strokeStyle=b.net.getColor(),b.drawMarks(r,e/10,-1));if(2!==b.parent.version&&""!==b.net10||2===b.parent.version&&""!==b.net&&""!==b.net10)r.strokeStyle=b.net10.getColor(),b.drawMarks(r,e,-1);if(""!==b.axes){r.strokeStyle=b.axes.getColor();r.beginPath();if(""!==b.x_axis||2!==b.parent.version)r.moveTo(0,f(b.h/2+b.Oy)+.5),r.lineTo(b.w,f(b.h/2+b.Oy)+.5);if(""!==b.y_axis||2!==b.parent.version)r.moveTo(f(b.w/2+b.Ox)+.5,0),r.lineTo(f(b.w/2+b.Ox)+.5,b.h);r.stroke();
b.drawMarks(r,e,4);b.drawMarks(r,e/2,2);b.drawMarks(r,e/10,1)}if(""!==b.x_axis||""!==b.y_axis)r.fillStyle=""!==b.axes?b.axes.getColor():"#000",r.font=h,r.textAlign="right",r.textBaseline="alphabetic",r.fillText(b.x_axis,f(b.w)-2,f(b.h/2+b.Oy)+12),r.fillText(b.y_axis,f(b.w/2+b.Ox)-2,12);b.numbers&&""!=b.axes&&(r.fillStyle=b.axes.getColor(),r.font=h,r.textAlign="start",r.textBaseline="bottom",e>(b.w+b.h)/2?b.drawNumbers(r,e/5,e<=b.scale?m+1:m):e>(b.w+b.h)/4?b.drawNumbers(r,e/2,e<=b.scale?m+1:m):b.drawNumbers(r,
e,m));for(var a=0,c=b.backGraphics.length;a<c;a++)b.backGraphics[a].draw()};a.Space2D.prototype.draw=function(){b=this;r=b.ctx;r.clearRect(0,0,b.canvas.width,b.canvas.height);for(var a=0,d=b.graphics.length;a<d;a++)v=b.graphics[a],""!==v.trace&&b.drawTrace&&v.drawTrace(),v.draw();a=0;for(d=b.graphicsCtr.length;a<d;a++)b.graphicsCtr[a].draw();""!=b.text&&b.click&&"L"===b.whichBtn&&(r.fillStyle=b.text.getColor(),r.strokeStyle=r.fillStyle,r.lineWidth=1,r.font=g,r.textAlign="center",r.textBaseline="alphabetic",
z=1>=b.scale?b.mouse_x.toFixed(0):b.mouse_x.toFixed(b.scale.toString().length),I=1>=b.scale?b.mouse_y.toFixed(0):b.mouse_y.toFixed(b.scale.toString().length),H="("+z+","+I+")",M=f(r.measureText(H).width/2),y=b.getAbsoluteX(b.mouse_x),L=b.getAbsoluteY(b.mouse_y),K=f(y),N=f(L-10),K+M>b.w?K=b.w-M:0>K-M&&(K=M),N+1>b.h?N=b.h:0>N-14&&(N=15),r.fillText(H,K,N),r.beginPath(),r.arc(y,L,2.5,0,c,!0),r.stroke())};a.Space2D.prototype.drawMarks=function(a,b,c){l=this.w;x=this.h;G=0;F=l;J=0;C=x;B=f(l/2+this.Ox);
E=f(x/2+this.Oy);0<=c&&(G=B-c,F=B+c,J=E-c,C=E+c);a.beginPath();for(c=-p(B/b);(A=B+p(c*b))<l;c++)a.moveTo(A+.5,J+.5),a.lineTo(A+.5,C+.5);for(c=-p(E/b);(D=E+p(c*b))<x;c++)a.moveTo(G+.5,D+.5),a.lineTo(F+.5,D+.5);a.stroke()};a.Space2D.prototype.drawNumbers=function(a,b,c){l=this.w;x=this.h;B=f(l/2+this.Ox);E=f(x/2+this.Oy);for(c=-p(B/b);(A=B+p(c*b))<l;c++)a.fillText(parseFloat((c*b/this.scale).toFixed(4)),A+1,E-2);for(c=-p(E/b);(D=E+p(c*b))<x;c++)0!==parseFloat(-c*b/this.scale)&&a.fillText(parseFloat((-c*
b/this.scale).toFixed(4)),B+5,D+5)};a.Space2D.prototype.addEvents=function(){function b(a){window.focus();if(h.evaluator.variables[h.id+".DESCARTESJS_no_fixed"]||!h.fixed||h.sensitive_to_mouse_movements)h.click=0,h.evaluator.setVariable(h.mpressedStr,0),h.evaluator.setVariable(h.mclickedStr,1),h.evaluator.setVariable(h.mclickIzqStr,1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",b),a.stopPropagation(),a.preventDefault(),h.parent.update()}function c(b){window.focus();
b.stopPropagation();b.preventDefault();h.click=0;h.evaluator.setVariable(h.mpressedStr,0);h.evaluator.setVariable(h.mclickedStr,1);h.evaluator.setVariable(h.mclickIzqStr,1);"R"===h.whichBtn&&(window.removeEventListener("mousemove",e),h.posZoom==h.posZoomNew&&a.showConfig&&(h.parent.externalSpace.show(),h.posZoom=!1,h.posZoomNew=!0));window.removeEventListener("mousemove",f);window.removeEventListener("mouseup",c);h.parent.deactivateGraphiControls();h.parent.update()}function g(b){h.posAnte=a.getCursorPosition(b,
h.container);h.mouse_x=h.getRelativeX(h.posAnte.x);h.mouse_y=h.getRelativeY(h.posAnte.y);h.evaluator.setVariable(h.mxStr,h.mouse_x);h.evaluator.setVariable(h.myStr,h.mouse_y);h.evaluator.setVariable(h.mclickedStr,0);h.evaluator.setVariable(h.mclickIzqStr,0);h.parent.update()}function e(b){b.preventDefault();h.posZoomNew=a.getCursorPosition(b,h.container).y;h.evaluator.setVariable(h.scaleStr,h.tempScale+h.tempScale/45*((h.posZoom-h.posZoomNew)/10));h.parent.update()}function f(b){b.preventDefault();
b.stopPropagation();h.fixed||(h.posNext=a.getCursorPosition(b,h.container),k=(h.posAnte.x-h.posNext.x).toFixed(8),d=(h.posAnte.y-h.posNext.y).toFixed(8),h.evaluator.setVariable(h.OxStr,h.Ox-k),h.evaluator.setVariable(h.OyStr,h.Oy-d));g(b)}var h=this;h.posZoom=null;h.posZoomNew=null;h.canvas.oncontextmenu=function(a){return!1};this.sensitive_to_mouse_movements&&this.canvas.addEventListener("touchmove",g);this.canvas.addEventListener("touchstart",function(a){window.focus();if(h.evaluator.variables[h.id+
".DESCARTESJS_no_fixed"]||!h.fixed||h.sensitive_to_mouse_movements)h.parent.clearClick(),h.click=1,h.evaluator.setVariable(h.mpressedStr,1),h.evaluator.setVariable(h.mclickedStr,0),h.evaluator.setVariable(h.mclickIzqStr,0),h.parent.deactivateGraphiControls(),g(a),window.addEventListener("touchmove",f),window.addEventListener("touchend",b),a.stopPropagation(),a.preventDefault()});this.sensitive_to_mouse_movements&&this.canvas.addEventListener("mousemove",g);this.canvas.addEventListener("mousedown",
function(b){window.focus();b.stopPropagation();b.preventDefault();h.parent.clearClick();h.click=1;h.parent.deactivateGraphiControls();h.whichBtn=a.whichBtn(b);"R"===h.whichBtn?(window.addEventListener("mouseup",c),h.posZoom=a.getCursorPosition(b,h.container).y,h.posZoomNew=h.posZoom,h.fixed||(h.tempScale=h.scale,window.addEventListener("mousemove",e))):"L"===h.whichBtn&&(h.evaluator.setVariable(h.mpressedStr,1),h.evaluator.setVariable(h.mclickedStr,0),h.evaluator.setVariable(h.mclickIzqStr,0),g(b),
window.addEventListener("mousemove",f),window.addEventListener("mouseup",c))});document.addEventListener("visibilitychange",function(a){c(a)})};return a}(descartesJS||{}),descartesJS=function(a){var k,d,f;function p(a,b){return b.depth-a.depth}function c(b,c){W=a.subtract3D(b,a.scalarProduct3D(c,a.dotProduct3D(b,c)));ia=a.add3D(b,a.scalarProduct3D(W,-2));ja=a.norm3D(ia);return 0!==ja?a.scalarProduct3D(ia,1/ja):a.scalarProduct3D(b,-1)}if(a.loadLib)return a;var h=Math.floor,g=Math.round,b=Math.max,
u=Math.cos,n=Math.sin,r=Math.sqrt,q=15*Math.PI/180,t=Math.cos(q),v=Math.sin(q),e=Math.tan(q),m,w,l,x,A,D,B,E,G,F,J,C,z,I,H,M,y,L,K,N,T,O=[],U,R,P,Q,S,ca,W,ia,ja,oa;a.Space3D=function(b,c){a.Space.call(this,b,c);l=this;l.backCanvas=document.createElement("canvas");l.backCanvas.setAttribute("id",l.id+"_background");l.backCanvas.setAttribute("width",l.w+"px");l.backCanvas.setAttribute("height",l.h+"px");l.canvas=document.createElement("canvas");l.canvas.setAttribute("id",l.id+"_canvas");l.canvas.setAttribute("width",
l.w+"px");l.canvas.setAttribute("height",l.h+"px");l.canvas.setAttribute("class","DescartesSpace3DCanvas");l.canvas.setAttribute("style","z-index: "+l.zIndex+";");l.ctx=l.canvas.getContext("2d");l.ctx.imageSmoothingEnabled=!1;l.parent.images[l.id+".image"]=l.canvas;l.parent.images[l.id+".image"].ready=1;l.parent.images[l.id+".image"].complete=!0;l.evaluator.setVariable(l.id+".image",l.id+".image");l.graphicControlContainer=document.createElement("div");l.graphicControlContainer.setAttribute("id",
l.id+"_graphicControls");l.graphicControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+l.zIndex+";");l.numericalControlContainer=document.createElement("div");l.numericalControlContainer.setAttribute("id",l.id+"_numericalControls");l.numericalControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+l.zIndex+";");l.container=document.createElement("div");l.container.setAttribute("id",l.id);l.container.setAttribute("class","DescartesSpace3DContainer");
l.container.setAttribute("style","left: "+l.x+"px; top: "+l.y+"px; z-index: "+l.zIndex+";");l.container.appendChild(l.backCanvas);l.container.appendChild(l.canvas);l.container.appendChild(l.graphicControlContainer);l.container.appendChild(l.numericalControlContainer);b.container.insertBefore(l.container,b.loader);l.eye={x:0,y:0,z:0};l.lights=[{x:50,y:50,z:70},{x:50,y:-50,z:30},{x:20,y:0,z:-80},{x:0,y:0,z:0}];for(var d=0,g=l.lights.length;d<g;d++)l.lights[d]=a.normalize3D(l.lights[d]);l.light3={x:0,
y:0,z:0};l.intensity=[.4,.5,.3,0];l.userIntensity=0;l.dim=1;l.tmpIntensity=[];l.OxStr=l.id+".Ox";l.OyStr=l.id+".Oy";l.scaleStr=l.id+".escala";l.wStr=l.id+"._w";l.hStr=l.id+"._h";l.obsStr=l.id+".observador";l.rotZStr=l.id+".rot.z";l.rotYStr=l.id+".rot.y";l.userIDimStr=l.id+".userIlum.dim";l.userIIStr=l.id+".userIlum.I";l.userIxStr=l.id+".userIlum.x";l.userIyStr=l.id+".userIlum.y";l.userIzStr=l.id+".userIlum.z";l.new3DStr=l.id+"._3Dnew_";l.xOStr=l.id+".xO";l.yOStr=l.id+".yO";l.zOStr=l.id+".zO";l.AOStr=
l.id+".AO";l.BOStr=l.id+".BO";l.COStr=l.id+".CO";l.zoomStr=l.id+".zoom";l.evaluator.setVariable(l.rotZStr,0);l.evaluator.setVariable(l.rotYStr,0);l.evaluator.setVariable(l.userIDimStr,l.dim);l.evaluator.setVariable(l.userIIStr,l.userIntensity);l.evaluator.setVariable(l.userIxStr,0);l.evaluator.setVariable(l.userIyStr,0);l.evaluator.setVariable(l.userIzStr,0);l.addEvents()};a.extend(a.Space3D,a.Space);a.Space3D.prototype.init=function(a){l=this;l.uber.init.call(l);l.canvas&&(l.canvas.width=l.backCanvas.width=
l.w,l.canvas.height=l.backCanvas.height=l.h,l.canvas.style.width=l.backCanvas.style.width=l.w+"px",l.canvas.style.height=l.backCanvas.style.height=l.h+"px");l.w_2=l.w/2;l.h_2=l.h/2;l.w_plus_h=l.w+l.h;l.oldMouse={x:0,y:0}};a.Space3D.prototype.update=function(a){l=this;m=l.evaluator;w=l.parent;l.new3D=0<m.getVariable(l.new3DStr);m.setVariable(l.wStr,l.w);m.setVariable(l.hStr,l.h);l.drawIfValue=0<m.eval(l.drawif);if(l.drawIfValue){E=l.x!==m.eval(l.xExpr)+l.displaceRegionWest;G=l.y!==m.eval(l.yExpr)+
w.plecaHeight+l.displaceRegionNorth;l.spaceChange=a||E||G||l.drawBefore!==l.drawIfValue||l.Ox!==m.getVariable(l.OxStr)||l.Oy!==m.getVariable(l.OyStr)||l.scale!==m.getVariable(l.scaleStr);l.x=E?m.eval(l.xExpr)+l.displaceRegionWest:l.x;l.y=G?m.eval(l.yExpr)+w.plecaHeight+l.displaceRegionNorth:l.y;l.Ox=m.getVariable(l.OxStr);l.Oy=m.getVariable(l.OyStr);l.scale=m.getVariable(l.scaleStr);l.drawBefore=l.drawIfValue;if(a||void 0==l.observer){a=0;for(var c=l.parent.controls.length;a<c;a++)l.parent.controls[a].id===
l.obsStr&&(oa=!0);l.observer=oa?m.getVariable(l.obsStr)||2.5*l.w_plus_h:2.5*l.w_plus_h;l.observer=b(l.observer,.25*l.w_plus_h);m.setVariable(l.obsStr,l.observer)}l.new3D?(void 0==m.getVariable(l.xOStr)&&m.setVariable(l.xOStr,l.observer/l.scale*t),void 0==m.getVariable(l.yOStr)&&m.setVariable(l.yOStr,0),void 0==m.getVariable(l.zOStr)&&m.setVariable(l.zOStr,l.observer/l.scale*v),void 0==m.getVariable(l.AOStr)&&m.setVariable(l.AOStr,0),void 0==m.getVariable(l.BOStr)&&m.setVariable(l.BOStr,345),void 0==
m.getVariable(l.COStr)&&m.setVariable(l.COStr,0),l.xO=m.getVariable(l.xOStr),l.yO=m.getVariable(l.yOStr),l.zO=m.getVariable(l.zOStr),l.AO=m.getVariable(l.AOStr),l.BO=m.getVariable(l.BOStr),l.CO=m.getVariable(l.COStr),l.zoom=m.getVariable(l.zoomStr),l.eye={x:parseFloat(m.getVariable(l.xOStr)),y:parseFloat(m.getVariable(l.yOStr)),z:parseFloat(m.getVariable(l.zOStr))}):(l.D=l.observer/3,l.eye={x:l.D/l.scale,y:0,z:l.D/l.scale*e},l.RX0=l.Ox,l.RY0=l.Oy-l.D*e,l.bfactor=l.scale*l.eye.x,l.observer=b(m.getVariable(l.obsStr),
.25*l.w_plus_h),l.observer!=m.getVariable(l.obsStr)&&(m.setVariable(l.obsStr,l.observer),l.parent.updateControls()));1E-6>l.scale?(l.scale=1E-6,m.setVariable(l.scaleStr,1E-6)):1E6<l.scale&&(l.scale=1E6,m.setVariable(l.scaleStr,1E6));if(E||G)l.container.style.left=l.x+"px",l.container.style.top=l.y+"px";l.container.style.display="block";l.dim=m.getVariable(l.userIDimStr);l.userIntensity=m.getVariable(l.userIIStr);l.light3={x:parseInt(m.getVariable(l.userIxStr)),y:parseInt(m.getVariable(l.userIyStr)),
z:parseInt(m.getVariable(l.userIzStr))};l.updateCamera();l.draw()}else l.container.style.display="none"};a.Space3D.prototype.updateCamera=function(){l=this;l.new3D?(l.D=l.scale*l.eye.x/t,l.XE=g(l.scale*l.eye.y+.5),l.YE=g(l.scale*l.eye.z+.5)):(l.D=l.observer/3,l.eye.x=l.D/l.scale,l.eye.y=0,l.eye.z=l.D/l.scale*e)};a.Space3D.prototype.rotateVertex=function(b){H=a.degToRad(l.evaluator.getVariable(l.rotZStr));M=u(H);y=n(H);k=b.x*M-b.y*y;d=b.x*y+b.y*M;f=b.z;H=a.degToRad(l.evaluator.getVariable(l.rotYStr));
M=u(H);y=n(H);return{x:f*y+k*M,y:d,z:f*M-k*y}};var pa,ka,X,Y,qa,la,da,Z,ra,ma,aa,ba,sa,ta,ua,va,wa,xa,ya,za,Aa,ea,fa,ga,ha,Ba,Ca,na;a.Space3D.prototype.project=function(a){l=this;if(l.new3D){C=l.eye.x-a.x;z=l.eye.y-a.y;I=l.eye.z-a.z;var b=r(C*C+z*z+I*I);pa=l.AO%360;ka=pa*Math.PI/180;X=Math.cos(ka);Y=Math.sin(ka);qa=l.BO%360;la=qa*Math.PI/180;da=Math.cos(la);Z=Math.sin(la);ra=l.CO%360;ma=ra*Math.PI/180;aa=Math.cos(ma);ba=Math.sin(ma);sa=da*X;ta=-aa*da*Y-ba*Z;ua=-ba*da*Y+aa*Z;va=Y;wa=aa*X;xa=ba*X;ya=
-Z*X;za=aa*Z*Y-ba*X;Aa=ba*Z*Y+aa*X;ea=-l.eye.x+a.x;fa=-l.eye.y+a.y;ga=-l.eye.z+a.z;ha=sa*ea+va*fa+ya*ga;Ba=ta*ea+wa*fa+za*ga;Ca=ua*ea+xa*fa+Aa*ga;na=parseFloat(l.evaluator.getVariable(l.zoomStr));return{x:this.getAbsoluteX(-na*Ba/ha),y:this.getAbsoluteY(-na*Ca/ha),z:0<ha?-b:b}}var c=l.bfactor/(a.x-l.eye.x);C=l.eye.x-a.x;z=l.eye.y-a.y;I=l.eye.z-a.z;b=r(C*C+z*z+I*I);C=this.w_2+l.RX0-c*(a.y-l.eye.y);z=this.h_2+l.RY0+c*(a.z-l.eye.z);return{x:C,y:z,z:b}};a.Space3D.prototype.computeColor=function(b,d,g){b.match("rgba")?
b=a.RGBAToHexColor(b):b.match("#")&&(b=new a.Color(b.substring(1)));Q=a.subtract3D(this.eye,d.average);S=a.norm3D(Q);ca=a.scalarProduct3D(Q,1/S);this.lights[3]=a.subtract3D(this.light3,d.average);T=a.norm3D(this.lights[3]);for(var e=0,f=this.intensity.length-1;e<f;e++)O[e]=this.intensity[e]*this.dim;O[3]=this.userIntensity*this.userIntensity/T||0;U=g?this.dim/2:this.dim/4;R=0;P=0<=d.direction?d.normal:a.scalarProduct3D(d.normal,-1);e=0;for(f=this.lights.length;e<f;e++)g?(R=Math.max(0,a.dotProduct3D(c(this.lights[e],
P),ca)),R*=R*R):R=Math.max(0,a.dotProduct3D(this.lights[e],P)),U+=O[e]*R;U=Math.min(U,1);L=h(b.r*U);K=h(b.g*U);N=h(b.b*U);return"rgba("+L+","+K+","+N+","+b.a+")"};a.Space3D.prototype.draw=function(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);this.ctx.fillStyle=this.background.getColor();this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height);this.image&&""!=this.image.src&&this.image.ready&&this.image.complete&&("topleft"===this.bg_display?this.ctx.drawImage(this.image,0,0):
"stretch"===this.bg_display?this.ctx.drawImage(this.image,0,0,this.w,this.h):"patch"===this.bg_display?(this.ctx.fillStyle=ctx.createPattern(this.image,"repeat"),this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height)):"center"===this.bg_display&&this.ctx.drawImage(this.image,(this.w-this.image.width)/2,(this.h-this.image.height)/2));for(var a=0,b=this.graphics.length;a<b;a++)this.graphics[a].update();this.primitives=[];a=0;for(b=this.graphics.length;a<b;a++){x=this.graphics[a];if(x.split||this.split)for(var c=
a+1;c<b;c++)A=this.graphics[c],(A.split||this.split)&&x.splitFace(A);this.primitives=this.primitives.concat(x.primitives||[])}D=this.primitives;B=D.length;for(a=0;a<B;a++)D[a].computeDepth(this);if("painter"===this.render)this.drawPainter(D);else for(D=D.sort(p),a=0;a<B;a++)D[a].passDraw&&D[a].draw(this.ctx,this);a=0;for(b=this.graphicsCtr.length;a<b;a++)this.graphicsCtr[a].draw()};var V;a.renderNode=function(a){this.value=a;this.front=this.back=null};a.renderNode.prototype.inOrder=function(){var a=
[];this.back&&(a=a.concat(this.back.inOrder()));a.push(this.value);this.front&&(a=a.concat(this.front.inOrder()));return a};a.Space3D.prototype.buildTree=function(b){if(0===b.length)return null;var c,d=[],g=[];V=b.shift();for(var e=0,h=b.length;e<h;e++){c=null;for(var f=0,k=b[e].spaceVertices.length;f<k;f++)whereIs=2<V.spaceVertices.length?this.inPlane2(V.spaceVertices[0],V.normal,b[e].spaceVertices[f]):0,whereIs=0<V.direction?-whereIs:whereIs,null===c?0>whereIs?c="front":0<whereIs&&(c="back"):0>
whereIs?"back"===c&&(c="cross"):0<whereIs&&"front"===c&&(c="cross");if("back"===c)d.push(b[e]);else if("front"===c)g.push(b[e]);else if(null==c)d.push(b[e]);else{c=null;f=0;for(k=V.spaceVertices.length;f<k;f++)whereIs=2<b[e].spaceVertices.length?this.inPlane2(b[e].spaceVertices[0],b[e].normal,V.spaceVertices[f]):-1,whereIs=0<b[e].direction?-whereIs:whereIs,null===c?0>whereIs?c="front":0<whereIs&&(c="back"):0>whereIs?"back"===c&&(c="cross"):0<whereIs&&"front"===c&&(c="cross");"front"===c?d.push(b[e]):
g.push(b[e])}}b=new a.renderNode(V);b.back=this.buildTree(d);b.front=this.buildTree(g);return b};a.Space3D.prototype.drawPainter=function(a){if(a=this.buildTree(a)){a=a.inOrder();for(var b=0;b<a.length;b++)a[b].passDraw&&a[b].draw(this.ctx,this)}};a.Space3D.prototype.inPlane=function(a,b,c,d){return parseFloat(((d.x-a.x)*(b.y-a.y)*(c.z-a.z)+(d.y-a.y)*(b.z-a.z)*(c.x-a.x)+(d.z-a.z)*(b.x-a.x)*(c.y-a.y)-(d.z-a.z)*(b.y-a.y)*(c.x-a.x)-(d.y-a.y)*(b.x-a.x)*(c.z-a.z)-(d.x-a.x)*(b.z-a.z)*(c.y-a.y)).toFixed(8))};
a.Space3D.prototype.inPlane2=function(a,b,c){return parseFloat((b.x*(c.x-a.x)+b.y*(c.y-a.y)+b.z*(c.z-a.z)).toFixed(8))};a.Space3D.prototype.addEvents=function(){function b(a){document.body.focus();f.click=0;f.evaluator.setVariable(f.id+".mouse_pressed",0);window.removeEventListener("touchmove",h,!1);window.removeEventListener("touchend",b,!1);a.preventDefault()}function c(b){document.body.focus();f.click=0;f.evaluator.setVariable(f.id+".mouse_pressed",0);b.preventDefault();"R"===f.whichBtn&&(window.removeEventListener("mousemove",
e,!1),f.posZoom==f.posZoomNew&&a.showConfig&&f.parent.externalSpace.show());window.removeEventListener("mousemove",h,!1);window.removeEventListener("mouseup",c,!1);f.parent.update()}function d(b){f.posAnte=a.getCursorPosition(b,f.container);f.mouse_x=f.getRelativeX(f.posAnte.x);f.mouse_y=f.getRelativeY(f.posAnte.y);f.evaluator.setVariable(f.id+".mouse_x",f.mouse_x);f.evaluator.setVariable(f.id+".mouse_y",f.mouse_y);70<Date.now()-k&&(f.parent.update(),k=Date.now())}function e(b){b.preventDefault();
f.posZoomNew=a.getCursorPosition(b,f.container).y;f.evaluator.setVariable(f.scaleStr,f.tempScale+f.tempScale/45*((f.posZoom-f.posZoomNew)/10));f.posObserverNew=a.getCursorPosition(b,f.container).x;f.evaluator.setVariable(f.obsStr,f.tempObserver-2.5*(f.posObserver-f.posObserverNew));f.parent.update()}function h(b){if(!f.fixed&&f.click){F=parseInt(50*(f.oldMouse.x-f.mouse_x));J=parseInt(50*(f.oldMouse.y-f.mouse_y));if(F!==f.disp.x||J!==f.disp.y)f.alpha=a.degToRad(f.evaluator.getVariable(f.rotZStr)),
f.beta=a.degToRad(-f.evaluator.getVariable(f.rotYStr)),f.alpha=g(a.radToDeg(f.alpha)-F),f.beta=g(a.radToDeg(f.beta)-J),f.evaluator.setVariable(f.rotZStr,f.alpha),f.evaluator.setVariable(f.rotYStr,-f.beta),f.disp.x=F,f.disp.y=J,f.oldMouse.x=f.getRelativeX(f.posAnte.x),f.oldMouse.y=f.getRelativeY(f.posAnte.y);d(b);b.preventDefault()}}var f=this,k=0;this.canvas.oncontextmenu=function(){return!1};this.canvas.addEventListener("touchstart",function(c){document.body.focus();f.click=1;f.evaluator.setVariable(f.id+
".mouse_pressed",1);f.parent.deactivateGraphiControls();f.posAnte=a.getCursorPosition(c,f.container);f.oldMouse.x=f.getRelativeX(f.posAnte.x);f.oldMouse.y=f.getRelativeY(f.posAnte.y);d(c);window.addEventListener("touchmove",h);window.addEventListener("touchend",b);c.preventDefault()});this.canvas.addEventListener("mousedown",function(b){document.body.focus();f.click=1;f.parent.deactivateGraphiControls();f.whichBtn=a.whichBtn(b);"R"===f.whichBtn?(window.addEventListener("mouseup",c),f.posObserver=
a.getCursorPosition(b,f.container).x,f.posObserverNew=f.posObserver,f.posZoom=a.getCursorPosition(b,f.container).y,f.posZoomNew=f.posZoom,f.fixed||(f.tempScale=f.scale,f.tempObserver=f.observer,window.addEventListener("mousemove",e))):"L"==f.whichBtn&&(f.evaluator.setVariable(f.id+".mouse_pressed",1),f.posAnte=a.getCursorPosition(b,f.container),f.oldMouse.x=f.getRelativeX(f.posAnte.x),f.oldMouse.y=f.getRelativeY(f.posAnte.y),d(b),window.addEventListener("mousemove",h),window.addEventListener("mouseup",
c));b.preventDefault()});this.disp={x:0,y:0}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k;a.SpaceAP=function(d,f){a.Space.call(this,d,f);this.eVars=this.iVars=null;k=d.evaluator;this.file.match(/^\[/)&&this.file.match(/\]$/)?this.file=k.parser.parse(this.file.substring(1,this.file.length-1)):this.file.match(/^\'/)&&this.file.match(/\'$/)?this.file=k.parser.parse(this.file):this.file=k.parser.parse("'"+this.file+"'");this.oldFile=k.eval(this.file);this.initFile()};
a.extend(a.SpaceAP,a.Space);a.SpaceAP.prototype.initFile=function(){this.firstUpdate=!0;var d;if(this.oldFile){var f=document.getElementById(this.oldFile);d=f&&"descartes/spaceApFile"==f.type?f.text:a.openExternalFile(this.oldFile);null!=d&&(d=d.split("\n"))}if(d&&d.toString().match(/<applet/gi)){for(var f="",k=!1,c=0,h=d.length;c<h&&(d[c].match("<applet")&&(k=!0),k&&(f+=d[c]),!d[c].match("</applet"));c++);d=document.createElement("div");d.innerHTML=f;d.firstChild.setAttribute("width",this.w);d.firstChild.setAttribute("height",
this.h);f=this.descApp?this.descApp.container:null;this.descApp=new a.DescartesApp(d.firstChild);this.descApp.container.setAttribute("class","DescartesAppContainer");this.descApp.container.setAttribute("style","position:absolute;overflow:hidden;background-color:"+this.background+";width:"+this.w+"px;height:"+this.h+"px;left:"+this.x+"px;top:"+this.y+"px;z-index:"+this.zIndex+";");f?this.parent.container.replaceChild(this.descApp.container,f):this.parent.container.insertBefore(this.descApp.container,
this.parent.loader);this.descApp.container.style.display=0<this.evaluator.eval(this.drawif)?"block":"none";var g=this;this.descApp.update=function(){this.updateAuxiliaries();this.updateEvents();this.updateControls();this.updateSpaces();g.exportar()}}else f=this.descApp?this.descApp.container:null,this.descApp={},this.descApp.container=document.createElement("div"),this.descApp.container.setAttribute("class","DescartesAppContainer"),d="position:absolute;overflow:hidden;background-color:"+this.background+
";width:"+this.w+"px;height:"+this.h+"px;left:"+this.x+"px;top:"+this.y+"px;z-index:"+this.zIndex+";",this.image&&("topleft"==this.bg_display?d+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat;":"stretch"==this.bg_display?d+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat; background-size: 100% 100%;":"patch"==this.bg_display?d+="background-image: url("+this.imageSrc+");":"imgcenter"==this.bg_display&&(d+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat; background-position: center center;")),
this.descApp.container.setAttribute("style",d),f?this.parent.container.replaceChild(this.descApp.container,f):this.parent.container.insertBefore(this.descApp.container,this.parent.loader),this.descApp.container.style.display=0<this.evaluator.eval(this.drawif)?"block":"none"};a.SpaceAP.prototype.update=function(){var a=this.evaluator.eval(this.file);if(this.oldFile!=a)this.oldFile=a,this.initFile();else{var a=this.x!=this.evaluator.eval(this.xExpr),f=this.y!=this.evaluator.eval(this.yExpr)+this.plecaHeight;
this.x=a?this.evaluator.eval(this.xExpr):this.x;this.y=f?this.evaluator.eval(this.yExpr)+this.plecaHeight:this.y;a&&(this.descApp.container.style.left=this.x+"px");f&&(this.descApp.container.style.top=this.y+"px");this.descApp.container.style.display=0<this.evaluator.eval(this.drawif)?"block":"none";if(this.firstUpdate&&(this.firstUpdate=!1,null==this.iVars)){this.iVars=[];for(var k in this.evaluator.variables)this.evaluator.variables.hasOwnProperty(k)&&k.match(/^public./)&&this.iVars.push({varName:k,
value:this.evaluator.getVariable(k)})}this.importar()}};a.SpaceAP.prototype.importar=function(){for(var a,f=!1,k=0,c=this.iVars.length;k<c;k++)a=this.evaluator.getVariable(this.iVars[k].varName),a!=this.iVars[k].value&&(this.iVars[k].value=a,this.descApp.evaluator.setVariable(this.iVars[k].varName,this.iVars[k].value),f=!0);f&&this.descApp.update()};a.SpaceAP.prototype.exportar=function(){};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k,d,f,p,c,h;a.SpaceHTML_IFrame=
function(c,b){a.Space.call(this,c,b);k=this.parent.evaluator;if(void 0!=this._w_){var d=k.parser.parse(this._w_);this._w_="number"!=d.type?d:void 0}void 0!=this._h_&&(d=k.parser.parse(this._h_),this._h_="number"!=d.type?d:void 0);this.isFirefox=/firefox/i.test(window.navigator.userAgent);this.file=this.file?this.file.trim():"";this.file.match(/^\[/)&&this.file.match(/\]$/)?this.file=k.parser.parse(this.file.substring(1,this.file.length-1)):this.file.match(/^\'/)&&this.file.match(/\'$/)?this.file=
k.parser.parse(this.file):this.file=k.parser.parse("'"+this.file+"'");this.oldFile=k.eval(this.file);this.MyIFrame=document.createElement("iframe");0!=this.oldFile&&this.MyIFrame.setAttribute("src",this.oldFile);this.MyIFrame.setAttribute("marginheight",0);this.MyIFrame.setAttribute("marginwidth",0);this.MyIFrame.setAttribute("frameborder",0);this.MyIFrame.setAttribute("scrolling","auto");this.MyIFrame.setAttribute("style","position:static;left:0px;top:0px;");this.container=document.createElement("div");
this.container.setAttribute("id",this.id);this.container.setAttribute("style",(a.isIOS?"overflow:scroll;-webkit-overflow-scrolling:touch;overflow-scrolling:touch;":"")+"position:absolute; width:"+this.w+"px;height:"+this.h+"px;left:"+this.x+"px;top:"+this.y+"px;z-index:"+this.zIndex+";background-repeat:no-repeat;background-position:center;");this.container.appendChild(this.MyIFrame);this.imageSrc&&(this.container.style.backgroundImage="url("+this.imageSrc+")");this.parent.container.insertBefore(this.container,
this.parent.loader);var f=this;this.MyIFrame.onload=function(a){var b=this;f.evaluator.setFunction(f.id+".set",function(a,c){b.contentWindow.postMessage({type:"set",name:a,value:c},"*");return 0});f.evaluator.setFunction(f.id+".update",function(){b.contentWindow.postMessage({type:"update"},"*");return 0});f.evaluator.setFunction(f.id+".exec",function(a,c){b.contentWindow.postMessage({type:"exec",name:a,value:c},"*");return 0});f.ImReady=!f.isFirefox;f.isFirefox||(f.container.style.visibility="visible",
f.container.style.opacity="1",f.container.style.zIndex=f.zIndex,f.container.style.display=f.drawIfValue?"block":"none");f.MyIFrame.style.visibility="visible";f.container.style.backgroundImage=""};this.update=this.iframeUpdate;this.evaluator.setVariable(this.id+"._scroll",0)};a.extend(a.SpaceHTML_IFrame,a.Space);a.SpaceHTML_IFrame.prototype.init=function(){c=this;c.uber.init.call(c);c.MyIFrame&&(c.MyIFrame.style.width=c.w+"px",c.MyIFrame.style.height=c.h+"px",c.MyIFrame.style.left=c.x+"px",c.MyIFrame.style.top=
c.y+"px")};a.SpaceHTML_IFrame.prototype.iframeUpdate=function(a){k=this.evaluator;this.drawIfValue=0<k.eval(this.drawif);this.ImReady?this.container.style.display=this.drawIfValue?"block":"none":(this.container.style.visibility=this.drawIfValue?"visible":"hidden",this.container.style.opacity=this.drawIfValue?"1":"0",this.container.style.zIndex=this.drawIfValue?this.zIndex:-1E3);if(this.drawIfValue){this.MyIFrame.contentWindow.focus();a&&(this.y=this.x=Infinity);d=this.x!==k.eval(this.xExpr)+this.displaceRegionWest;
f=this.y!==k.eval(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth;this.x=d?k.eval(this.xExpr)+this.displaceRegionWest:this.x;this.y=f?k.eval(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth:this.y;void 0!=this._w_&&(a=k.eval(this._w_),this.w!==a&&(this.container.style.width=a+"px",this.MyIFrame.style.width=a+"px",this.w=a));void 0!=this._h_&&(a=k.eval(this._h_),this.h!==a&&(this.container.style.height=a+"px",this.MyIFrame.style.height=a+"px",this.h=a));if(d||f)this.container.style.left=
this.x+"px",this.container.style.top=this.y+"px";p=k.eval(this.file);p!==this.oldFile&&(this.ImReady=!1,this.isFirefox||(this.container.style.display="block",this.container.style.visibility=this.drawIfValue?"visible":"hidden",this.container.style.opacity=this.drawIfValue?"1":"0",this.container.style.zIndex=this.drawIfValue?this.zIndex:-1E3),this.imageSrc&&(this.container.style.backgroundImage="url("+this.imageSrc+")"),this.MyIFrame.style.visibility="hidden",this.oldFile=p,this.MyIFrame.contentWindow.location.replace(p));
h=k.getVariable(this.id+"._scroll");1==h?(this.MyIFrame.setAttribute("scrolling","yes"),this.MyIFrame.style.overflow=""):-1==h?(this.MyIFrame.setAttribute("scrolling","no"),this.MyIFrame.style.overflow="hidden"):(this.MyIFrame.setAttribute("scrolling","auto"),this.MyIFrame.style.overflow="")}else this.MyIFrame.contentWindow.blur()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var k,d,f;a.DescartesLoader=function(c){var d=this;this.children=c.children;this.lessonParser=
c.lessonParser;this.images=c.images;this.images.length=c.images.length;this.audios=c.audios;this.audios.length=c.audios.length;this.descartesApp=c;var g=c.imgLoader?c.imgLoader:p(c.loader.width,c.loader.height,c.ratio);this.imageLoader=document.createElement("div");this.imageLoader.width=c.width;this.imageLoader.height=c.height;this.imageLoader.setAttribute("class","DescartesLoaderImage");this.imageLoader.setAttribute("style","background-image:url("+g+");background-size:cover;width:"+c.width+"px;height:"+
c.height+"px;");c.loader.appendChild(this.imageLoader);this.loaderBar=document.createElement("canvas");this.loaderBar.width=c.width;this.loaderBar.height=c.height;this.loaderBar.setAttribute("class","DescartesLoaderBar");this.loaderBar.setAttribute("style","width:"+c.width+"px;height:"+c.height+"px;");this.loaderBar.ctx=this.loaderBar.getContext("2d");c.loader.appendChild(this.loaderBar);this.barWidth=80;this.barHeight=Math.floor(c.loader.height/70);this.timer=a.setInterval(function(){d.drawLoaderBar(d.loaderBar.ctx,
c.width,c.height)},10);c.firstRun=!1;this.initPreloader()};a.DescartesLoader.prototype.initPreloader=function(){var c=this.children,d=this.images,g=this.audios,b=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg)/gi,f=/[\w\.\-//]*(\.ogg|\.oga|\.mp3|\.wav)/gi;d["lib/DescartesCCLicense.png"]=a.getCCLImg();d["lib/DescartesCCLicense.png"].addEventListener("load",function(){this.ready=1});d["lib/DescartesCCLicense.png"].addEventListener("error",function(){this.errorload=1});var k,r,q,p,v,e;q=0;for(v=c.length;q<v;q++)if("rtf"!==
c[q].name){if(c[q].value.match(/'macro'|'makro'/g)){p="";var m;k=this.lessonParser.split(c[q].value);r=0;for(e=k.length;r<e;r++)"expresion"===babel[k[r][0]]&&(p=k[r][1]);p&&((m=document.getElementById(p))&&"descartes/macro"==m.type?m=m.text:(m=a.openExternalFile(p))&&!m.match(/tipo_de_macro/g)&&(m=null));if(m&&(k=m.match(b)))for(p=0,e=k.length;p<e;p++)r=k[p],r.toLowerCase().match(/vacio.gif$/)||""==r.substring(0,r.length-4)||(d[r]=new Image,d[r].addEventListener("load",function(){this.ready=1}),d[r].addEventListener("error",
function(){this.errorload=1}),d[r].src=r)}if(k=c[q].value.match(b))for(p=0,e=k.length;p<e;p++)r=k[p],r.toLowerCase().match(/vacio.gif$/)||""==r.substring(0,r.length-4)||(d[r]=new Image,d[r].addEventListener("load",function(){this.ready=1}),d[r].addEventListener("error",function(){this.errorload=1}),d[r].src=r);if(k=c[q].value.match(f))for(p=0,r=k.length;p<r;p++)this.initAudio(k[p])}for(var w in d)d.hasOwnProperty(w)&&this.images.length++;for(w in g)g.hasOwnProperty(w)&&this.audios.length++;var l=
this,x=this.images.length+this.audios.length;this.sep=2*(this.barWidth-2)/x;var A=function(){l.readys=0;for(var b in d)d.hasOwnProperty(b)&&(d[b].ready||d[b].errorload)&&l.readys++;for(b in l.audios)g.hasOwnProperty(b)&&(g[b].ready||g[b].errorload)&&l.readys++;l.readys!=x?a.setTimeout(A,30):(a.clearInterval(l.timer),l.descartesApp.initBuildApp())};A()};a.DescartesLoader.prototype.initAudio=function(c){var d=this.audios;d[c]=new Audio(c);d[c].filename=c;var g=function(){this.ready=1},b=function(){this.canPlayType("audio/"+
this.filename.substring(this.filename.length-3))||"mp3"!=this.filename.substring(this.filename.length-3)?(console.log("El archivo '"+c+"' no puede ser reproducido"),this.errorload=1):(d[c]=new Audio(this.filename.replace("mp3","ogg")),d[c].filename=this.filename.replace("mp3","ogg"),d[c].addEventListener("canplaythrough",g),d[c].addEventListener("load",g),d[c].addEventListener("error",b),d[c].load())};d[c].addEventListener("canplaythrough",g);d[c].addEventListener("load",g);d[c].addEventListener("error",
b);a.hasTouchSupport?(d[c].load(),d[c].play(),a.setTimeout(function(){d[c].pause()},20),d[c].ready=1):d[c].load()};a.DescartesLoader.prototype.drawLoaderBar=function(a,h,g){d=this.barWidth;f=this.barHeight;a.translate(h/2,(g-65*k)/2+90*k);a.scale(k,k);a.strokeRect(-d,-f,2*d,f);a.fillStyle="#888";a.fillRect(-d+2,-f+2,2*(d-2),f-4);a.fillStyle="#1f358d";a.fillRect(-d+2,-f+2,this.readys*this.sep,f-4);a.setTransform(1,0,0,1,0,0)};var p=function(a,d,g){var b=document.createElement("canvas");g=5E6<a*this.ratio*
d*this.ratio?1:g;b.width=a*g;b.height=d*g;b.style.width=a+"px";b.style.height=d+"px";var f=b.getContext("2d");f.save();f.setTransform(g,0,0,g,0,0);f.strokeStyle=f.fillStyle="#1f358d";f.lineCap="round";f.lineWidth=2;f.beginPath();k=a<d?a/360:d/195;k=2.5<k?2.5:k;f.translate((a-120*k)/2,(d-65*k)/2);f.scale(k,k);f.moveTo(3,25);f.lineTo(3,1);f.lineTo(21,1);f.bezierCurveTo(33,1,41,15,41,25);f.stroke();f.beginPath();f.moveTo(1,63);f.lineTo(1,64);f.moveTo(5,62);f.lineTo(5,64);f.moveTo(9,61);f.lineTo(9,64);
f.moveTo(13,60);f.lineTo(13,64);f.moveTo(17,58);f.lineTo(17,64);f.moveTo(21,56);f.lineTo(21,64);f.moveTo(25,53);f.lineTo(25,64);f.moveTo(29,50);f.lineTo(29,64);f.moveTo(33,46);f.lineTo(33,64);f.moveTo(37,41);f.lineTo(37,64);f.moveTo(41,32);f.lineTo(41,64);f.stroke();f.font="20px descartesJS_sansserif, Arial, Helvetica, Sans-serif";f.fillText("escartes",45,33);f.fillText("JS",98,64);f.restore();return b.toDataURL()};return a}(descartesJS||{}),descartesJS=function(a){function k(a){for(var b="[",c=0,
d=a.length;c<d;c++)a[c]instanceof Array?b+=k(a[c]):(f=a[c],"undefined"!=typeof f&&f||(f=0),"string"==typeof f&&(f="'"+f+"'"),b+=f),c<d-1&&(b+=",");return b+"]"}function d(){p=window.innerWidth/this.width;c=window.innerHeight/this.height;h=Math.min(p,c);a.cssScale=h.toFixed(3);this.container.parentNode.setAttribute("align","");this.container.style.transformOrigin="0 0";p<c?(this.container.style.left="",this.container.style.transform="perspective(1px) scale("+h+") translate3d(0, 0, 0)"):(this.container.style.left=
"50%",this.container.style.transform="perspective(1px) scale("+h+") translate3d(-50%, 0, 0)")}if(a.loadLib)return a;a.DescartesApp=function(c){this.animation={playing:!1,stop:function(){}};this.ratio=a._ratio;this.applet=c;this.parentC=c.parentNode;this.width=parseFloat(c.getAttribute("width"));this.height=parseFloat(c.getAttribute("height"));this.decimal_symbol=".";this.decimal_symbol_regexp=new RegExp("\\"+this.decimal_symbol,"g");this.language="espa\u00f1ol";this.children=c.getElementsByTagName("param");
a.ccLicense=!0;for(var b=0,d=this.children.length;b<d;b++)"CreativeCommonsLicense"===this.children[b].name&&(a.ccLicense="no"===this.children[b].value?!1:!0);this.code=c.getAttribute("code");this.saveState=[];this.images={};this.images.length=-1;this.audios={};this.audios.length=-1;this.firstRun=!0;this.scaleToFit=function(){};this.init()};a.DescartesApp.prototype.init=function(){this.stop();this.evaluator=new a.Evaluator(this);this.lessonParser=new a.LessonParser(this);this.arquimedes=/DescartesWeb2_0|Arquimedes|Discurso/i.test(this.code);
this.licenseA=a.ccLicense?"{\\rtf1\\uc0{\\fonttbl\\f0\\fcharset0 Arial;\\f1\\fcharset0 Arial;\\f2\\fcharset0 Arial;\\f3\\fcharset0 Arial;\\f4\\fcharset0 Arial;}{\\f0\\fs34 __________________________________________________________________________________\\par \\fs22                                        Los contenidos de esta unidad did\u00e1ctica interactiva est\u00e1n bajo una {\\*\\hyperlink licencia Creative Commons|http://creativecommons.org/licenses/by-nc-sa/4.0/}, si no se indica lo contrario.\\par                                        La unidad did\u00e1ctica fue creada con Arqu\u00edmedes, que es un producto de c\u00f3digo abierto, {\\*\\hyperlink Creditos|http://arquimedes.matem.unam.mx/Descartes5/creditos/conCCL.html}\\par }":
"";for(var c=this.children,b,f=0,h=0,k=a.ccLicense?90:0,q=0,p=c.length;q<p;q++)b=c[q],"rtf_height"==b.name&&(f=parseInt(b.value)||this.height),"Buttons"==babel[b.name]&&(this.buttonsConfig=this.lessonParser.parseButtonsConfig(b.value),h=this.buttonsConfig.height),"image_loader"==b.name&&(this.imgLoader=b.value),"expand"==b.name&&("cover"==b.value?this.expand=b.value:"fit"==b.value&&(this.scaleToFit=d)),"docBase"==b.name&&(this.docBase=b.value,b=document.createElement("base"),b.setAttribute("id","descartesJS_base"),
b.setAttribute("href",this.docBase),document.head.appendChild(b));this.expand&&"cover"==this.expand&&(this.width=window.innerWidth,this.height=window.innerHeight);this.arquimedes&&(this.ratio=1,f&&(this.height=f+h+k));this.spaces=[];this.externalSpace&&document.body.removeChild(this.externalSpace.container);this.externalSpace=new a.SpaceExternal(this);this.northSpace={container:document.createElement("div"),controls:[]};this.southSpace={container:document.createElement("div"),controls:[]};this.eastSpace=
{container:document.createElement("div"),controls:[]};this.westSpace={container:document.createElement("div"),controls:[]};this.editableRegion={container:document.createElement("div"),textFields:[]};a.Editor&&(this.editor=new a.Editor(this));this.controls=[];this.auxiliaries=[];this.events=[];this.nIframes=this.plecaHeight=this.tabindex=this.zIndex=0;void 0!=this.container&&this.parentC.removeChild(this.container);this.container=document.createElement("div");this.loader=document.createElement("div");
this.parentC.appendChild(this.container);this.container.width=this.width;this.container.height=this.height;this.container.setAttribute("class","DescartesAppContainer");this.container.setAttribute("style","width:"+this.width+"px;height:"+this.height+"px;");this.scaleToFit();this.container.appendChild(this.loader);this.loader.width=this.width;this.loader.height=this.height;this.loader.setAttribute("class","DescartesLoader");this.loader.setAttribute("style","width:"+this.width+"px;height:"+this.height+
"px;z-index:1000;");this.imgLoader&&(this.loader.style.backgroundColor="rgba(0,0,0,0)");this.firstRun?this.descartesLoader=new a.DescartesLoader(this):this.initBuildApp()};a.DescartesApp.prototype.initBuildApp=function(){a.showConfig=!0;for(var c=this.children,b=this.lessonParser,d=[],f=[],h=[],k=[],p=[],v=[],e,m=0,w=c.length;m<w;m++)if(e=c[m],"editable"==babel[e.name]&&(a.showConfig="false"==babel[e.value]?!1:!0),"language"==babel[e.name]&&(this.language=e.value),"pleca"==e.name)e=b.parsePleca(e.value,
this.width),this.container.insertBefore(e,this.loader),this.plecaHeight=e.imageHeight?e.imageHeight:e.offsetHeight;else if("Buttons"==babel[e.name])this.buttonsConfig=b.parseButtonsConfig(e.value);else if("decimal_symbol"==babel[e.name])this.decimal_symbol=e.value,this.decimal_symbol_regexp=new RegExp("\\"+this.decimal_symbol,"g");else if("version"==babel[e.name])this.version=parseInt(e.value);else if("language"==babel[e.name])this.language=e.value;else if("rtf"==e.name){var l=(this.width-780)/2,
x=parseInt(this.height)-this.plecaHeight-this.buttonsConfig.height-45;k.push("space='descartesJS_stage' type='text' expresion='[10,20]' background='yes' text='"+e.value.replace(/'/g,"&squot;")+"'");k.push("space='descartesJS_stage' type='text' expresion='["+l+","+(x-25)+"]' background='yes' text='"+this.licenseA+"'");a.ccLicense&&k.push("space='descartesJS_stage' type='image' expresion='["+(l+15)+","+x+"]' background='yes' abs_coord='yes' file='lib/DescartesCCLicense.png'")}else if("E"==e.name.charAt(0))e.value.match(/'HTMLIFrame'/)&&
this.nIframes++,d.push(e.value);else if(/^C_/.test(e.name))f.push(e.value);else if(/^A_/.test(e.name))h.push(e.value);else if(/^G_/.test(e.name)){if(e.value.match("type='fill'")||e.value.match("tipo='relleno'")||e.value.match("tipus='ple'")||e.value.match("mota='betea'")||e.value.match("type='plein'")||e.value.match("tipo='recheo'")||e.value.match("tipo='curva_piena'")||e.value.match("tipo='preencher'")||e.value.match("tipus='ple'"))this.ratio=1;k.push(e.value)}else/^S_/.test(e.name)?p.push(e.value):
"Animation"==babel[e.name]&&v.push(e.value);this.stage={container:document.createElement("div"),scroll:0};this.stage.container.setAttribute("id","descartesJS_Stage");this.stage.stageSpace=this.lessonParser.parseSpace("tipo='R2' id='descartesJS_stage' fondo='blanco' x='0' y='0' fijo='yes' red='no' red10='no' ejes='no' text='no' ancho='"+this.width+"' alto='"+this.height+"'");this.stage.container.appendChild(this.stage.stageSpace.container);this.arquimedes&&(this.container.appendChild(this.stage.container),
this.spaces.push(this.stage.stageSpace));m=0;for(w=d.length;m<w;m++)c=b.parseSpace(d[m]),this.arquimedes&&this.stage.container.appendChild(c.container),this.spaces.push(c),this.zIndex++;m=0;for(w=k.length;m<w;m++)if(d=b.parseGraphic(k[m]))d.visible&&(this.editableRegionVisible=!0),d.space.addGraph(d);m=0;for(w=p.length;m<w;m++)(d=b.parse3DGraphic(p[m]))&&d.space.addGraph(d,!0);m=0;for(w=f.length;m<w;m++)this.controls.push(b.parseControl(f[m]));m=0;for(w=h.length;m<w;m++)b.parseAuxiliar(h[m]);m=0;
for(w=v.length;m<w;m++)this.animation=b.parseAnimation(v[m]);this.configRegions();this.updateAuxiliaries();this.updateAuxiliaries();m=0;for(w=this.controls.length;m<w;m++)this.controls[m].init();this.updateControls();this.updateSpaces(!0);var A=this;this.nIframes?a.setTimeout(function(){A.finishInit()},200*this.nIframes):this.finishInit()};a.DescartesApp.prototype.finishInit=function(){this.evaluator.setVariable("decimalSymbol",this.decimal_symbol);this.update();this.loader.style.display="none";window.parent!==
window&&(this.parentC.style.margin="0px",this.parentC.style.padding="0px",window.parent.postMessage({type:"reportSize",href:window.location.href,width:this.width,height:this.height},"*"),window.parent.postMessage({type:"ready",value:window.location.href},"*"),a.onResize());window.opener&&window.opener.postMessage({type:"isResizeNeeded",href:window.location.href},"*");this.externalSpace.init();var c;try{c=new CustomEvent("descartesReady",{detail:""})}catch(b){c=document.createEvent("CustomEvent"),
c.initCustomEvent("descartesReady",!1,!1,{cmd:""})}window.dispatchEvent(c)};a.DescartesApp.prototype.adjustSize=function(){document.body.style.margin="0px";document.body.style.padding="0px";this.parentC.style.margin="0px";this.parentC.style.padding="0px";var c=parseInt(this.width)+30,b=parseInt(this.height)+90;window.moveTo((parseInt(screen.width)-c)/2,(parseInt(screen.height)-b)/2);window.resizeTo(c,b);a.onResize()};a.DescartesApp.prototype.adjustDimensions=function(){var a,b,c;if(void 0==this.init_w||
void 0==this.init_h)this.init_w=parseInt(this.container.style.width),this.init_h=parseInt(this.container.style.height);b=parseInt(this.parentC.offsetWidth);a=this.init_w;c=b/a;a>b?(this.parentC!=document.body&&(this.parentC.style.height=this.init_h*c+"px"),this.percent=c,this.container.style.webkitTransform=this.container.style.MozTransform="scale("+c+")",this.container.style.webkitTransformOrigin=this.container.style.MozTransformOrigin="top left"):(this.parentC!=document.body&&(this.parentC.style.height=
"auto"),this.percent=1,this.container.style.webkitTransform=this.container.style.MozTransform="",this.container.style.webkitTransformOrigin=this.container.style.MozTransformOrigin="")};a.DescartesApp.prototype.configRegions=function(){var c=this.evaluator.parser,b=this.buttonsConfig,d=this.container,f="15",h=100,k=100,p=100,v=100;2==this.version&&(f="14",h=63,k=50,p=44,v=53);var e=0,m=0,w=0,l=0,x=0,A=0,D=0,B=0,E=0,D=this.northSpace.controls,B=this.southSpace.controls,G=this.eastSpace.controls,x=this.westSpace.controls;
if(0<b.rowsNorth||0<D.length||b.about||b.config){0>=b.rowsNorth?(e=b.height,b.rowsNorth=1):e=b.height*b.rowsNorth;A=this.northSpace.container;A.setAttribute("id","descartesJS_north");A.setAttribute("style","width:"+d.width+"px; height:"+e+"px; background:#c0c0c0; position:absolute; left:0px; top: "+this.plecaHeight+"px; z-index:100;");d.insertBefore(A,this.loader);var A=d.width,F=0;b.about?(F=h,A-=F):h=0;b.config&&(A-=k);for(var J=Math.ceil(D.length/b.rowsNorth),C=A/J,l=0,z=D.length;l<z;l++)D[l].expresion=
c.parse("("+(F+l%J*C)+","+b.height*Math.floor(l/J)+","+C+","+b.height+")"),D[l].drawif=c.parse("1"),D[l].init();b.about&&(l=new a.Button(this,{region:"north",name:"english"==this.language?"about":"cr\u00e9ditos",font_size:c.parse(f),expresion:c.parse("(0, 0, "+h+", "+e+")")}),l.actionExec={execute:a.showAbout},l.update());b.config&&(new a.Button(this,{region:"north",name:"config",font_size:c.parse(f),action:"config",expresion:c.parse("("+(A+h)+", 0, "+k+", "+e+")")})).update()}if(0<b.rowsSouth||0<
B.length||b.init||b.clear){0>=b.rowsSouth?(m=b.height,b.rowsSouth=1):m=b.height*b.rowsSouth;D=d.width;F=0;b.init?(F=p,D-=F):p=0;b.clear&&(D-=v);A=this.southSpace.container;A.setAttribute("id","descartesJS_south");A.setAttribute("style","width:"+d.width+"px; height:"+m+"px; background:#c0c0c0; position:absolute; left: 0px; top:"+(d.height-m)+"px; z-index:100;");d.insertBefore(A,this.loader);J=Math.ceil(B.length/b.rowsSouth);C=D/J;l=0;for(z=B.length;l<z;l++)B[l].expresion=c.parse("("+(F+l%J*C)+","+
b.height*Math.floor(l/J)+","+C+","+b.height+")"),B[l].drawif=c.parse("1"),B[l].init();b.init&&(new a.Button(this,{region:"south",name:"english"==this.language?"init":"inicio",font_size:c.parse(f),action:"init",expresion:c.parse("(0, 0, "+p+", "+m+")")})).update();b.clear&&(new a.Button(this,{region:"south",name:"english"==this.language?"clear":"limpiar",font_size:c.parse(f),action:"clear",expresion:c.parse("("+(D+p)+", 0, "+v+", "+m+")")})).update()}if(0<G.length)for(w=d.height-e-m,B=b.widthEast,
A=this.eastSpace.container,A.setAttribute("id","descartesJS_east"),A.setAttribute("style","width:"+B+"px; height:"+w+"px; background:#c0c0c0; position:absolute; left:"+(d.width-B)+"px; top:"+e+"px; z-index:100;"),d.insertBefore(A,this.loader),l=0,z=G.length;l<z;l++)G[l].expresion=c.parse("(0,"+b.height*l+","+B+","+b.height+")"),G[l].drawif=c.parse("1"),G[l].init();if(0<x.length)for(l=d.height-e-m,E=b.widthWest,A=this.westSpace.container,A.setAttribute("id","descartesJS_west"),A.setAttribute("style",
"width: "+E+"px; height: "+l+"px; background: #c0c0c0; position: absolute; left: 0px; top: "+e+"px; z-index: 100;"),d.insertBefore(A,this.loader),l=0,z=x.length;l<z;l++)x[l].expresion=c.parse("(0,"+b.height*l+","+E+","+b.height+")"),x[l].drawif=c.parse("1"),x[l].init();if(this.editableRegionVisible)for(x=b.height,A=this.editableRegion.container,A.setAttribute("id","descartesJS_editableRegion"),A.setAttribute("style","width:"+d.width+"px; height:"+x+"px; position:absolute; left:0px; top:"+(d.height-
m-b.height)+"px; z-index:100; background:#c0c0c0; overflow:hidden;"),d.insertBefore(A,this.loader),c=this.editableRegion.textFields,d=d.width/c.length,b=a.getFieldFontSize(x),l=0,z=c.length;l<z;l++)"div"==c[l].type?(A.appendChild(c[l].container),c[l].container.setAttribute("style","font-family:descartesJS_sansserif,Arial,Sans-serif;width:"+(d-4)+"px;height:"+x+"px;position:absolute;left:"+l*d+"px;top:0;"),f=c[l].container.firstChild,f.setAttribute("style","font-family:descartesJS_sansserif,Arial,Sans-serif;font-size:"+
b+"px;padding-top:0%;background-color:#e0e4e8;position:absolute;left:0;top:0;height:"+x+"px;text-align:center;line-height:"+x+"px;"),h=f.offsetWidth,f.style.width=h+"px",f.firstChild.textContent=f.firstChild.textContent.substring(3,f.firstChild.textContent.length-3),c[l].container.lastChild.setAttribute("style","font-family:descartesJS_monospace,'Courier New',Monospace;font-size:"+b+"px;width:"+(d-h)+"px;height:"+x+"px;position:absolute;left:"+h+"px;top:0;border:2px groove white;")):(A.appendChild(c[l]),
c[l].setAttribute("style","font-family:descartesJS_monospace,'Courier New',Monospace;font-size:"+b+"px;width:"+d+"px;height:"+x+"px;position:absolute;left:"+l*d+"px;top:0;border:2px groove white;"));this.displaceRegionNorth=e;this.displaceRegionSouth=m;this.displaceRegionEast=w;this.displaceRegionWest=E;l=0;for(z=this.spaces.length;l<z;l++)this.spaces[l].init()};a.DescartesApp.prototype.update=function(){this.updateAuxiliaries();this.updateControls();this.updateEvents();this.updateControls();this.updateSpaces()};
a.DescartesApp.prototype.clearClick=function(){for(var a=0,b=this.spaces.length;a<b;a++)this.spaces[a].clearClick()};a.DescartesApp.prototype.deactivateGraphiControls=function(){for(var a,b=0,c=this.controls.length;b<c;b++)a=this.controls[b],"graphic"==a.type&&a.deactivate()};a.DescartesApp.prototype.updateAuxiliaries=function(){for(var a=0,b=this.auxiliaries.length;a<b;a++)this.auxiliaries[a].update()};a.DescartesApp.prototype.updateEvents=function(){for(var a=0,b=this.events.length;a<b;a++)this.events[a].update()};
a.DescartesApp.prototype.updateControls=function(){for(var a=0,b=this.controls.length;a<b;a++)this.controls[a].update()};a.DescartesApp.prototype.updateSpaces=function(a){for(var b=0,c=this.spaces.length;b<c;b++)this.spaces[b].update(a)};a.DescartesApp.prototype.clear=function(){for(var a=0,b=this.spaces.length;a<b;a++)this.spaces[a].spaceChange=!0,this.spaces[a].drawBackground&&this.spaces[a].drawBackground()};a.DescartesApp.prototype.play=function(){this.animation&&this.animation.play()};a.DescartesApp.prototype.stop=
function(){this.animation&&this.animation.stop()};a.DescartesApp.prototype.reinitAnimation=function(){this.animation&&this.animation.reinit()};a.DescartesApp.prototype.stopAudios=function(){this.stop();for(var a in this.audios)this.audios.hasOwnProperty(a)&&this.audios[a].pause&&(this.audios[a].pause(),this.audios[a].currentTime=0)};a.DescartesApp.prototype.getImage=function(a){var b=this.images;return a?(b[a]||(b[a]=new Image,b[a].addEventListener("load",function(){this.ready=1}),b[a].addEventListener("error",
function(){this.ready=0;this.errorload=1}),b[a].src=a),b[a]):new Image};a.DescartesApp.prototype.getAudio=function(c){var b=this.audios;if(c){if(!b[c]){var d=c.lastIndexOf("."),d=-1===d?c.lenght:d;c.substring(0,d);b[c]=new Audio(c);var f=function(a){this.ready=1};b[c].addEventListener("canplaythrough",f);var h=function(a){this.canPlayType("audio/"+c.substring(c.length-3))||"mp3"!=c.substring(c.length-3)?(console.log("El archivo '"+c+"' no puede ser reproducido"),this.errorload=1):(b[c]=new Audio(c.replace("mp3",
"ogg")),b[c].addEventListener("canplaythrough",f),b[c].addEventListener("load",f),b[c].addEventListener("error",h),b[c].load())};b[c].addEventListener("error",h);b[c].play();a.setTimeout(function(){b[c].pause()},15)}return b[c]}return new Audio};a.DescartesApp.prototype.getControlByCId=function(a){for(var b,c=0,d=this.controls.length;c<d;c++)if(b=this.controls[c],b.cID==a)return b;return{update:function(){},w:0}};a.DescartesApp.prototype.getControlById=function(a){for(var b,c=0,d=this.controls.length;c<
d;c++)if(b=this.controls[c],b.id==a)return b;return{update:function(){}}};a.DescartesApp.prototype.getSpaceByCId=function(a){for(var b,c=0,d=this.spaces.length;c<d;c++)if(b=this.spaces[c],b.cID==a)return b;return{update:function(){},w:0}};a.DescartesApp.prototype.getSpaceById=function(a){for(var b,c=0,d=this.spaces.length;c<d;c++)if(b=this.spaces[c],b.id==a)return b;return{update:function(){},w:0}};var f;a.DescartesApp.prototype.getState=function(){var a,b="",c=this.evaluator.variables,d;for(d in c)c.hasOwnProperty(d)&&
(a=c[d],"string"==typeof a&&(a="'"+a+"'"),void 0!=a&&"rnd"!=d&&"pi"!=d&&"e"!=d&&"Infinity"!=d&&"-Infinity"!=d&&"object"!=typeof a&&(b=""!=b?b+"\n"+d+"="+a:d+"="+a));var c=this.evaluator.vectors,f;for(f in c)c.hasOwnProperty(f)&&(a=c[f],b=b+"\n"+f+"="+k(a));f=this.evaluator.matrices;for(var h in f)f.hasOwnProperty(h)&&(a=f[h],b=b+"\n"+h+"="+k(a));return b};a.DescartesApp.prototype.setState=function(a,b){for(var c=a.split("\n"),d,f,h=0,k=c.length;h<k;h++)d=c[h].split("="),2<=d.length&&(f=eval(d[1]),
-1!=d[1].indexOf("[[")?(this.evaluator.matrices[d[0]]=f,this.evaluator.matrices[d[0]].rows=f.length,this.evaluator.matrices[d[0]].cols=f[0].length):-1!=d[1].indexOf("[")?(this.evaluator.vectors[d[0]]=f,this.evaluator.variables[d[0]+".long"]=f.length):this.evaluator.variables[d[0]]=f);b||this.update()};a.DescartesApp.prototype.getEvaluation=function(){for(var a=0,b=0,c="",d=0,f=this.controls.length;d<f;d++)"textfield"==this.controls[d].gui&&this.controls[d].evaluate&&(a++,b+=this.controls[d].ok,this.controls[d].value=
""==this.controls[d].value?"''":this.controls[d].value,c+=" \\n "+this.controls[d].id+"="+this.controls[d].value+"|"+this.controls[d].ok);return"questions="+a+" \\n correct="+b+" \\n wrong="+(a-b)+c};a.DescartesApp.prototype.showSolution=function(){for(var a=this.controls,b=0,c=a.length;b<c;b++)"textfield"==a[b].gui&&a[b].evaluate&&a[b].changeValue(a[b].getFirstAnswer());this.update()};a.DescartesApp.prototype.showAnswer=function(){for(var a=0,b=this.saveState.length;a<b;a++)this.evaluator.eval(this.saveState[a]);
this.update()};var p,c,h;return a}(descartesJS||{}),descartesJS=function(a){function k(){var a=document.getElementById("StyleDescartesApps");a&&a.parentNode.removeChild(a);a=document.createElement("style");a.id="StyleDescartesApps";a.type="text/css";a.setAttribute("rel","stylesheet");a.innerHTML="applet.DescartesJS {display:none;} applet {display:none;} ajs.DescartesJS {display:none;} ajs {display:none;}";document.head.appendChild(a)}function d(c){c=document.createElement("div");c.innerHTML='<div style="font-size:12px;visibility:hidden;">\n<div style="font-family:descartesJS_serif;">\n<span>_</span>\n<span style="font-weight:bold;">_</span>\n<span style="font-style:italic;">_</span>\n<span style="font-weight:bold;font-style:italic;">_</span>\n</div>\n<div style="font-family:descartesJS_sansserif;">\n<span>_</span>\n<span style="font-weight:bold;">_</span>\n<span style="font-style:italic;">_</span>\n<span style="font-weight:bold;font-style:italic;">_</span>\n</div>\n<div style="font-family:descartesJS_monospace;">\n<span>_</span>\n<span style="font-weight:bold;">_</span>\n<span style="font-style:italic;">_</span>\n<span style="font-weight:bold;font-style:italic;">_</span>\n</div>\n<div style="font-family:descartesJS_extra;">\n<span>_</span>\n<span style="font-weight:bold;">_</span>\n<span style="font-style:italic;">_</span>\n<span style="font-weight:bold;font-style:italic;">_</span>\n</div>\n</div>';
document.body.appendChild(c);a.getFeatures();if(a.hasCanvas){window.scrollTo(0,10);for(var d=document.querySelectorAll(".DescartesAppContainer"),b=0,f=d.length;b<f;b++)d[b].parentNode.removeChild(d[b]);for(var b=document.querySelectorAll("applet,ajs"),f=/Descartes|DescartesJS|descinst.DescartesWeb2_0.class|Arquimedes|Discurso/i,d=[],k=0,p=b.length;k<p;k++)f.test(b[k].getAttribute("code"))&&d.push(b[k]);b=0;for(f=d.length;b<f;b++)a.apps.push(new a.DescartesApp(d[b])),d[b].className="DescartesJS";window.addEventListener("resize",
a.onResize);window.scrollTo(0,0)}else document.getElementById("StyleDescartesApps").innerHTML="applet.DescartesJS {display:block;} applet {display:block;} ajs.DescartesJS {display:block;} ajs {display:block;}";document.body.removeChild(c)}if(a.loadLib)return a;a.apps=[];a.getDescartesApps=function(){return a.apps};window.hasOwnProperty("debugDescartesJS")&&debugDescartesJS||k();a.onResize=function(c){0<a.apps.length&&a.apps[0].scaleToFit()};a.onMessage=function(c){if(0<a.apps.length){var d=c.data;
d&&("set"===d.type?"string"==typeof d.value||"number"==typeof d.value?a.apps[0].evaluator.setVariable(d.name,d.value):d.value&&void 0!=d.value.rows?a.apps[0].evaluator.matrices[d.name]=d.value:a.apps[0].evaluator.vectors[d.name]=d.value:"update"===d.type?a.apps[0].update():"exec"===d.type?(c=a.apps[0].evaluator.getFunction(d.name),d=d.value.toString().split(","),c&&c.apply(a.apps[0].evaluator,d)):"isResizeNeeded"===d.type?c.source.postMessage({type:"doResize"},"*"):"doResize"===d.type&&0<a.apps.length&&
a.apps[0].adjustSize())}};if(void 0==a.loadLib){a.loadLib=!0;window.addEventListener("load",d);window.addEventListener("message",a.onMessage);for(var f=["webkitTransitionEnd","transitionend","oTransitionEnd","MSTransitionEnd"],p=0,c=f.length;p<c;p++)window.addEventListener(f[p],function(c){a.onResize(c)})}return a}(descartesJS||{});
