/*
 Joel Espinosa Longi
 j.longi@gmail.com
 https://github.com/jlongi/DescartesJS
 LGPL - http://www.gnu.org/licenses/lgpl.html
 2013-11-27
*/
var babel=function(a){if(a.loadLib)return a;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="#000000";a.maxenta=a.magenta="#ff00ff";a.azul=a.blue=a.blau=a.urdina=a.bleu="#0000ff";a.turquesa=a.cyan=a.turkesa=a.turquoise="#00ffff";a.verde=a.green=a.verd=a.berdea=a.vert="#00ff00";
a.amarillo=a.yellow=a.groc=a.horia=a.jaune=a.amarelo="#ffff00";a.naranja=a.orange=a.taronja=a.laranja=a.laranxa="#ffc800";a.rojo=a.red=a.vermell=a.gorria=a.rouge=a.vermello=a.vermelho="#ff0000";a.pink=a.rosa=a.arrosa=a.rose="#ffafaf";a.grisObscuro=a.darkGray=a.grisFosc=a["gris iluna"]=a.grisObscur=a.grisEscuro=a.cinzaEscuro="#404040";a.gris=a.gray=a.grisa=a.cinza="#808080";a.grisClaro=a.lightGray=a.grisClar=a["gris argia"]=a.grisClair=a.cinzaClaro="#c0c0c0";a.blanco=a.white=a.blanc=a.zuria=a.branco=
"#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.colour=a.color=a.kolorea=a.couleur=a.cor="color";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.inicio=a.init=a.inici=a.hasiera=a.commencement=a["in\u00edcio"]="init";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+"]="fillP";a["relleno-"]=a["fill-"]=a["ple-"]=a["betea-"]=a["plein-"]=a["recheo-"]=
a["preencher-"]="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"]="version";a.Idioma=a.Language=a.Hizkuntza=a.Langue=
"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.texto=a.text=a.testu=a.texte="text";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="doExpr";a.mientras=a["while"]=a.mentre=a.bitartean=a["tandis que"]=a.mentres=a.enquanto="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"]="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"]="x_axis";a["eje-y"]=a["y-axis"]=a["eix-y"]=a["y-ardatza"]=a["axe-y"]=a["eixe-y"]=
a["eixo-y"]="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"]="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"]="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"]="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="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="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"]="raytrace";a.imagen=a.bg_image=a.imatge=a.irudia=a.imaxe=a.imagem_de_fundo="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="center";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="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="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="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="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"]="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"]="openURL";a["abrir Escena"]=a["open Scene"]=a["obre Escena"]=a["eszena zabaldu"]=a["ouvrir Escena"]=a["abrir Cena"]="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="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="playAudio";a["activo-si"]=a["active-if"]=a["actiu-si"]=a["altiboa-baldin"]=a["actif-si"]=a["activo-se"]=a["ativo-se"]="activeif";a.rotfin=a.finrot=a.bukrot="endrot";a.posfin=
a.finpos=a.bukpos="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"]="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="onlyText";a.evaluar=a.evaluate="evaluate";a.respuesta=a.answer="answer";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="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";a.loadLib=!0;return a}(babel||{}),descartesJS=function(a){function d(a,b,c){a.fillStyle=
"#c0c0c0";a.fillRect(b.offsetLeft,b.offsetTop,b.offsetWidth,b.offsetHeight);e(a,b,c.controls)}function e(a,b,c){for(var f,g=c.length-1;0<=g;g--)f=c[g],a.drawImage(f.getScreenshot(),b.offsetLeft+f.x,b.offsetTop+f.y)}if(a.loadLib)return a;var h=2*Math.PI,b=360/h,c=h/360,l=Math.floor,f,g,r,n,j,p,q,u,k,s;a.rangeOK=1;a.extend=function(a,b){if(a.prototype.__proto__)a.prototype.__proto__=b.prototype;else for(var c in b.prototype)b.prototype.hasOwnProperty(c)&&(a.prototype[c]=b.prototype[c]);a.prototype.uber=
b.prototype};a.radToDeg=function(a){return a*b};a.degToRad=function(a){return a*c};a.convertFont=function(a){if(""==a)return a;f=a.split(",");g="";"bold"==f[1].toLowerCase()?g+="Bold ":"italic"==f[1].toLowerCase()||"italics"==f[1].toLowerCase()?g+="Italic ":"bold+italic"==f[1].toLowerCase()&&(g+="Italic Bold ");g+=f[2]+"px ";r=f[0].split(" ")[0].toLowerCase();return g="serif"===r||"times new roman"===r||"timesroman"===r||"times"===r?g+"'Times New Roman', Times, 'Droid Serif', serif":"sansserif"===
r||"arial"===r||"helvetica"===r?g+"Arial, Helvetica, 'Droid Sans', Sans-serif":g+"'Courier New', Courier, 'Droid Sans Mono', Monospace"};a.drawLine=function(a,b,c,f,g,d,m){a.lineWidth=m||1;a.strokeStyle=d||"black";d=a.lineWidth%2?0.5:0;a.beginPath();a.moveTo(l(b)+d,l(c)+d);a.lineTo(l(f)+d,l(g)+d);a.stroke()};a.getColor=function(a,b){if("string"==typeof b)return b;n=a.evalExpression(b);j=l(255*n[0][0]);p=l(255*n[0][1]);q=l(255*n[0][2]);u=1-n[0][3];return"rgba("+j+","+p+","+q+","+u+")"};a.getFeatures=
function(){a.hasJavaSupport=navigator.javaEnabled();var b=navigator.appVersion.toLowerCase();a.hasTouchSupport=window.hasOwnProperty&&window.hasOwnProperty("ontouchstart")||b.match("android")&&!0;a.hasTouchSupport=navigator.userAgent.toLowerCase().match("qt")?!1:a.hasTouchSupport;a.isIOS=!(!navigator.userAgent.match(/iPad/i)&&!navigator.userAgent.match(/iPhone/i));b=document.createElement("canvas");a.hasCanvasSupport=b.getContext&&b.getContext("2d");a.hasCanvasSupport&&(a.ctx=document.createElement("canvas").getContext("2d"));
var c,f,g,d,m,h,l,j,k;Number.prototype.originalToFixed=Number.prototype.toFixed;Number.prototype.toFixed=function(a){a=a?a:0;a=0>a?0:parseInt(a);c=this.toString();m=c.indexOf("e");if(-1!==m)if(h=c.split("e"),j="-"===h[0][0]?"-":"",l="-"===j?parseFloat(h[0].substring(1)).originalToFixed(11):parseFloat(h[0]).originalToFixed(11),k=parseInt(h[1]),f=l.indexOf("."),0>f+k){f=0>f?1:f;var b=j+"0.",e;e=Math.abs(f+k);e=Array(e+1).join("0");c=b+e+l.replace(".","")}else l=l.replace(".",""),c=j+l+Array(k-l.length+
2).join("0");f=c.indexOf(".");g="";if(-1===f)0<a&&(g="."),g+=Array(a+1).join("0"),c+=g;else if(d=c.length-f-1,d>=a)11>=a&&(c=parseFloat(c).originalToFixed(a)),c=0<a?c.substring(0,f+1+a):c.substring(0,f);else{b=0;for(a-=d;b<a;b++)g+="0";c+=g}return c}};a.removeNeedlessDecimals=function(a){var b,c;if("string"==typeof a&&(b=a.indexOf("."),-1!=b)){c=a.substring(b);if(0==parseFloat(c))return a.substring(0,b);for(var f=c.length;0<f;f--)if(0!=c.charAt(f))return a.substring(0,b+f+1)}return a};a.returnValue=
function(a){return"number"===typeof a?parseFloat(a.toFixed(11)):a};a.whichButton=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(a){a.touches?(a=a.touches[0],k=a.pageX,s=a.pageY):void 0!=a.pageX&&void 0!=a.pageY?(k=a.pageX,s=a.pageY):(k=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,s=a.clientY+document.body.scrollTop+document.documentElement.scrollTop);return{x:k,y:s}};a.getTextWidth=function(b,
c){a.ctx.font=c;return Math.round(a.ctx.measureText(b).width)};var m=document.createElement("span");m.appendChild(document.createTextNode("\u00c1p"));var t=document.createElement("div");t.setAttribute("style","display: inline-block; w: 1px; h: 0px;");var v=document.createElement("div");v.setAttribute("style","margin: 0; padding: 0;");v.appendChild(m);v.appendChild(t);var y={};a.getFontMetrics=function(a){if(y[a])return y[a];m.setAttribute("style","font: "+a+"; margin: 0px; padding: 0px;");document.body.appendChild(v);
var b={ascent:0,descent:0,h:0,baseline:0};v.getBoundingClientRect?(t.style.verticalAlign="baseline",b.ascent=t.offsetTop-m.offsetTop,b.h=v.getBoundingClientRect().height||0):(t.style.verticalAlign="baseline",b.ascent=t.offsetTop-m.offsetTop,t.style.verticalAlign="bottom",b.h=t.offsetTop-m.offsetTop);b.descent=b.h-b.ascent;b.baseline=b.ascent;document.body.removeChild(v);return y[a]=b};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};a.getScreenshot=function(){var b=a.apps[0],c,f=document.createElement("canvas"),g=new Image;if(b){f.setAttribute("width",b.width);f.setAttribute("height",b.height);for(var m=f.getContext("2d"),h=0,l=b.spaces.length;h<l;h++)c=b.spaces[h],"R2"===c.type&&(m.drawImage(c.backgroundCanvas,c.x,c.y),m.drawImage(c.canvas,c.x,c.y),e(m,c.container,c.ctrs));0<b.northSpace.controls.length&&d(m,b.northSpace.container,b.northSpace);0<b.southSpace.controls.length&&d(m,b.southSpace.container,b.southSpace);0<b.eastSpace.controls.length&&
d(m,b.eastSpace.container,b.eastSpace);0<b.westSpace.controls.length&&d(m,b.westSpace.container,b.westSpace);g.src=f.toDataURL("image/png")}return g};a.showAbout=function(){var b="data:text/html;charset=utf-8,",b=a.creativeCommonsLicense?b+encodeURI("<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><p>\nEste objeto, creado con Descartes, est&aacute; licenciado\npor sus autores como\n<a href='http://creativecommons.org/licenses/by-nc-sa/2.5/es/'><nobr>Creative Commons</nobr></a>\n<br>\n<a href='http://creativecommons.org/licenses/by-nc-sa/2.5/es/'><img src='http://i.creativecommons.org/l/by-nc-sa/3.0/es/88x31.png'></a>\n</p></body> </html>"):
b+encodeURI("<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></body> </html>");
window.open(b,"creditos","width=700,height=500,titlebar=0,toolbar=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0")};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,e;a._externalFilesContent={};a.openExternalFile=function(h){if(a._externalFilesContent[h])return a._externalFilesContent[h];d=null;var b=!1;if(window.XMLHttpRequest)try{b=new XMLHttpRequest}catch(c){b=!1}else if(window.ActiveXObject)try{b=new ActiveXObject("Msxml2.XMLHTTP")}catch(l){try{b=new ActiveXObject("Microsoft.XMLHTTP")}catch(f){b=
!1}}e=b;e.open("GET",h,!1);try{e.send(null),d=e.responseText,d.match(String.fromCharCode(65533))&&(e.open("GET",h,!1),e.overrideMimeType("text/plain; charset=ISO-8859-1"),e.send(null),d=e.responseText)}catch(g){console.log("Error to load the file :",h),d=null}return d};a.addExternalFileContent=function(d,b){a._externalFilesContent[d]=b};return a}(descartesJS||{}),descartesJS=function(a){function d(a){m=a.indexOf("--radial--");-1!=m&&(a=a.substring(0,m));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 e(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 h(a,b,c){b=parseFloat(b);r=a.expr[0];n=a.expr[1];j=c.evalExpression(r.expr);p=c.evalExpression(n.expr);q="("==r.type;u="["==r.type;k=")"==n.type;s="]"==n.type;return(q&&b>j||u&&b>=j)&&(k&&b<p||s&&b<=p)?1:0}function b(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,l,f,g,r,n,j,p,q,u,k,s,m;a.buildRegularExpresionsPatterns=function(a,b){"("===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 g=0,m=a.length;g<m;g++){l=a[g].split("&");f=[];for(var h=0,j=l.length;h<j;h++)c=l[h],-1!==c.indexOf(",")&&("("===c.charAt(0)||"["===c.charAt(0))&&(")"===c.charAt(c.length-1)||"]"===c.charAt(c.length-1))?f.push(e(c,
b)):f.push(d(c));a[g]=f}return a};a.escorrecto=function(c,f,d,m){d=d||a.externalEvaluator;m=m||a.buildRegularExpresionsPatterns(c,d);f=b(f);c=0;for(var j=m.length;c<j;c++){l=m[c];g=!0;for(var k=0,e=l.length;k<e;k++)g=l[k].regExp?g&&!!f.match(RegExp(b(l[k].regExp),"i")):g&&h(l[k],f,d);if(g)return 1}return 0};a.esCorrecto=function(f,d,m,j){m=m||a.externalEvaluator;j=j||a.buildRegularExpresionsPatterns(f,m);f=0;for(var k=j.length;f<k;f++){l=j[f];g=!0;for(var e=0,r=l.length;e<r;e++)(c=l[e].regExp)?(l[e].ignoreAcents&&
(d=b(d),c=b(c)),l[e].ignoreCaps&&(d=d.toLowerCase(),c=b(c).toLowerCase()),g=g&&!!d.match(c)):g=g=g&&h(l[e],d,m);if(g)return 1}return 0};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.getCreativeCommonsLicenseImage=function(){var a=new Image;a.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAAAfCAYAAABjyArgAAAABHNCSVQICAgIfAhkiAAACpVJREFUaIHtWm1sU9cZfu61iUYnPP/bJgdhhDbFkVYcCrR0tLHXrVNL01wvgUJDh820tivrkpQQtpEvA4HGhDoe/dCmNfbaVa1WKszX2oUO3xC0OHESm9Hi/FhloyQq1aY5OGgq8ce7H9f3xI7txKFsdKyPdHSPz8dzz33Oe77eY46IVBzHXcUXuOkgIo4DQABwuucUeJ4Hz/NQKBTgeQUUPA9ekXryPDiOB89x4DgO4DiZBQQCJQlJSiKZlEIikZCeyQQSiSSSyQTLS1KSlSciuTEsfjtgY+UmAAAHgGRxFQqFFHjFTFyhkPJ4RUpkDhzHp+ubEiclbFISM5FIhfR4IlPkZDLJhE0X+nbBxspNUALIFFehhDLjKYWTx0/B4/FgcHAQU9GpDKIlqiVYu3YtjN8xouLRR5BIKsDzcalDEjw4cJD6cgaUJGkkANIY4iRxR3x+uN9xIxgMZpTX6XQQqgSsWlNW0Md9Xng4APSns+9BqVQyUZVKpRQUSvSK52B73oaJiYmCGqTRaND4i0aUl9+PeCKBRCKOeDwVEnHE4wlm4emW/PHExzjS9SJGg6MAAIPBAL1eDwAIBAIQRREAUKIrwY7aHfja17+a8/1XPv4ELzle+lzwbKzcJAn8fu8ZKBXKGWGVi7BIqURrcxvcx9ysglqthiAI0Gq1KC8vBwD09vYiHA7D7XZjcnKSlRVMAhoad2LxHYsRj8cRi8cRj8cQj8czpwxK4mrkKn769LOIRqMQBAF2ux1arTajseFwGPX19XC73VCpVGi3tWd91LXoNdTuqPvc8MjzMJ3tO0t9/eeo39dPQwEfXfggQIJJIEiDl9RqNbW1tVEkEqG54HQ6Sa1Ws3oluhI6399HQ4Eh8g71U1//OfL0naUzYg+99+d36XTPKTrx7nHS6XQEgMxmcwafzDP7HTL328f/kBFKdCU5eRx2Oz3+2ObPxDM2Nkbe/n7y9vfT2NhYQTwAiAcARWoOVioUUCoyLVev18Pv96O1tRVqtTprGKTDbDYjFAqxoTQaHEWn7XDGXM6zHYm0G/F5fQgGgxAEAY27ds3JL79DEASMBkcx4vOz9BGfH6PBUawqK8O996xj6b/q6sLzNhtOnj6N3Q27MD4+XhBPent+/9prMKy/DzWbt6Bm8xYY1t+HMz09c/Kkg/q8feQd8tLIhWFyHHEwy9Hr9fNabS5EIhHS6/WMx/Gig0b+OkIDw1467+0jz3nJit99/4+kK5WsNxQKFcwfCoUIAOl0OmYt8igo+cY3acUyLZV/ez09/eMnCQC1tbXRwQMHCQAdffvtgnjk9nj7+yW+u9fRj7ZZqHFnA61YpqUVy7TksNvz8uSwYMmKbc/bAEjzrdPpnNdqc0GtVsPj8bC6toO21F46ZcFcak/N8wheCsJgMGTNcRaLhVm5xWLJyNNqtTAYDBkrezAo8VRUVGDjpk0YHx/HmZ4erFimxb+mrmHrE1tx6cMPUVVdXRCPVqtFNBpF0H8RAFAp/AC/dXWjo/MQ9rQ0AwBc3c68PDJ4AKlhK23F5N1CXV0dG+o3ArVaDbvdDgCYmJjAyROn2IFFEplj27Rc73G5XDnjMnLV0ev1sB3uxEFbB954601UVVfjo8th2A53YunSpXB1OxG8dKkgHhntL0gG95vfvcrSvvfggwCAaDSKT65cycsDpASWrcnj8QCQxKmtrWWFRFGEyWSC0WiE0WiE1WrNm9fV1cXyzGYzs2LPWU+a9XLg+BmB/xO4+5570NF5CGNjY2jc2YCyb92Jd44eRcXDG1CzeQubQ+eCSqWCw+HAHaoleOWVV3KW+fTT63NySAcNjgPPcRgcHAQACILAhBFFEUajMaOSKIoQRRG1tbUwmUxZeRcuXIDT6WRcLpcLg4OD0gkwJawkriRwIBDIapjZbGaWazabs/Jz1ZmdFo1GcaanBx2dh2C+ZEHFwxsAAANeLwa8XhQXF4NbpJyTZ5FSicaGBtyxeDFLG/B6WXyZdlne9gDMgqUPlk9oK1euZAXq6+sBSPNMKBSCx+OBVqvFtm3bmCXr9XqEQiEcO3YsY48MgMWnolPSe8ClPYHS0lKIoohwOJzRMLmDZscBaQ8qiiJ0Oh1L0+l0WTw/efIptO/dh1V3rkTN5i346HIYVdXV6Og8hJqtWwviGR8fR1tLKx5/bDPa9+5D+959aGlqAgDs2r07b3syBAaHjOGaPp/IPWM2m9lkHgqFYDabWZ58+BAEgeXJSF+8JKPNPDZvfExadOSOLARyWaFKYGlyPJ2no/MQLNu348o//o6/hUJw2O3Y09KMqupqWPfvQ9ma1fPyWLZvh2X7dgCAs7sbzu5uXP/0OjZUPIItNY/nbY+M7PHxX8a69eugK9XB7XbDYrFkWetsyKenEl1Jhh9g1ZoylOhKMniKi4uxp6UZX1q8GCPDw/hZXd0N8expacb3H3oIly+HAUijTldaOiePDMmCKdOLlT6fyNbscrkwOTmJQCCA5cuXw2q1sjz5mJyeJyN9yEpnM3l7PIPmtmaoVCq4XC6YTCZWh9K8bOFwGCaTCV1dXVCpVNhRuyPrY3b/sjEnz85dDXjjrTc/E8/qNatRVV2Nqupq6EpLC+IBUs4e38ggioqKsP7e+zAVnYLZbGaW5Ha7sxYyQJoyKisr8+bJ9evr69HV1YUlqiU4/5c+TE9PYzo2jVg8hlgsLjmDEnFE/jmJA9YDbC+p1+uh1+uhVqshiiLr9PmcNNei19BxwMacNLeShzl7BoYHUFRUBGuLFe5jbqjVakQiEVZQFEU4HA7mzDEYDGhtbWUd4HA4WNn0PABYvnw5wuEwHvjuAzhs78T16WnEZgks+42TiSR8Az4cO3rr3Yw3g4cJ7B3qx6JFRTh/7jxqn5X2v3a7HXVpc9aNwOVysVPY/gP78fCGhzAdm8Z0LIZ4LIZYfJbAORzw/8vYWLlJmoPlKx2DsRwajQYAYLVas7ZOC8Hk5CRbXTUaTcoRn7rFSCaRTM3FlLpyul3BA0CSkkgkpHu0fe17AUgCmUymDB9voZicnITRaGR1G3/emHKwJ2ZETrsyYovsrMX2dgEBoKbWJvKNDFLgop+e+OETGR41v9+/IE9XuidNMAkUuOgn38gg7W3fy9L/j8LMj7rnamnI76PADTjcI5EItbW1ZTjc16xdQxc+CNBQwEdNrU23+kNvSWDX9jKaW5tQaRKgVCpx2HYYr7/2Ostb6JWRdV8b4vE4BgYG8cxTz2A+pE8P8smSiDJOmbN/5+PJV0d+R6GOpnxtWhDH7NDc2iRZ8kU/dbteJY1GU3CPaTQachxxUOCin4YCPnr51y8XXJeI5oynp83HM1/9QrhylVkoR5YFy6h7rhY1W2vYVY/o6cWJ4yfmvLZ/VHgUBkM5u9A8fvwE9lv3F9DHEnJZS3reQqyO47i8z4VgtrXOXoTn48srMACsuqsMza0tKF6qSbuNSHc3ImPfKv/xZGJ8HC902nGu99yCP+azTA35eABkCbxQsXN1UiEccwos4/7y+7GhYgPuWn0XvqJSpf46Jb9ZetHVaBTDQ8M4ffL0goVN/wjWsJtgwbl+L2T+nG9NuGkCf4EbB09EX77VjbhdQUTcvwFtwhQyXNo3TwAAAABJRU5ErkJggg==";
return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.floor,e,h,b,c,l,f,g,r,n;a.Color=function(a,f){this.b=this.g=this.r=0;this.a=1;this.evaluator=f;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.getColorString),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.getColorString),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.getColorString),"("===a[0]){h=[];b=this.splitComa(a.substring(1,a.length-1));for(var g=0,d=b.length;g<d;g++)c=
parseInt(b[g],16),b[g]!=c.toString(16)&&b[g]!=="0"+c.toString(16)?("["===b[g].charAt(0)&&"]"===b[g].charAt(b[g].length-1)&&(b[g]=b[g].substring(1,b[g].length-1)),h.push(this.evaluator.parser.parse(b[g]))):h.push(this.evaluator.parser.parse((c/255).toString()));this.rExpr=h[0];this.gExpr=h[1];this.bExpr=h[2];this.aExpr=h[3];this.getColor=this.getColorExpression}}else this.colorStr="rgba("+this.r+","+this.g+","+this.b+","+this.a+")",this.getColor=this.getColorString};a.Color.prototype.splitComa=function(a){l=
[];for(var b=r=g=f=0,c=a.length;b<c;b++)n=a.charAt(b),"("===n?f++:")"===n?f--:"["===n?g++:"]"===n?g--:","===n&&(0===f&&0===g)&&(l.push(a.substring(r,b)),r=b+1);l.push(a.substring(r));return l};a.Color.prototype.getColorString=function(){return this.colorStr};a.Color.prototype.getColorExpression=function(){e=this.evaluator;this.r=d(255*e.evalExpression(this.rExpr));this.g=d(255*e.evalExpression(this.gExpr));this.b=d(255*e.evalExpression(this.bExpr));this.a=1-e.evalExpression(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?"white":"black"};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=document.head,e=document.createElement("meta");e.setAttribute("http-equiv","X-UA-Compatible");e.setAttribute("content","chrome=1");d.appendChild(e);e=document.createElement("meta");e.setAttribute("name","viewport");e.setAttribute("content","width=device-width, initial-scale=1.0, user-scalable=yes");
d.appendChild(e);e=document.createElement("meta");e.setAttribute("name","apple-mobile-web-app-capable");e.setAttribute("content","yes");d.appendChild(e);e=document.createElement("meta");e.setAttribute("name","apple-mobile-web-app-status-bar-style");e.setAttribute("content","black-translucent");d.appendChild(e);(d=document.getElementById("StyleDescartesApps2"))&&d.parentNode.removeChild(d);d=document.createElement("style");d.type="text/css";d.id="StyleDescartesApps2";d.setAttribute("rel","stylesheet");
document.head.appendChild(d);d.innerHTML="body{ text-rendering:geometricPrecision; }\ncanvas{ image-rendering:optimizeSpeed; image-rendering:-moz-crisp-edges; image-rendering:-webkit-optimize-contrast; image-rendering:optimize-contrast; -ms-interpolation-mode:nearest-neighbor; }\ndiv.DescartesCatcher{ background-color:rgba(255, 255, 255, 0); cursor:pointer; position:absolute; }\ndiv.DescartesAppContainer{ border:0px solid black; position:relative; overflow:hidden; top:0px; left:0px; }\ndiv.DescartesLoader{ background-color :#efefef; position:absolute; overflow:hidden; -box-shadow:0px 0px 0px #888; background-image:linear-gradient(bottom, #bbb 0%, #efefef 50%, #bbb 100%); background-image:-o-linear-gradient(bottom, #bbb 0%, #efefef 50%, #bbb 100%); background-image:-moz-linear-gradient(bottom, #bbb 0%, #efefef 50%, #bbb 100%); background-image:-webkit-linear-gradient(bottom, #bbb 0%, #efefef 50%, #bbb 100%); background-image:-ms-linear-gradient(bottom, #bbb 0%, #efefef 50%, #bbb 100%); top:0px; left:0px; }\ndiv.DescartesLoaderImage{ background-repeat:no-repeat; background-position:center; position:absolute; overflow:hidden; top:0px; left:0px; }\ncanvas.DescartesLoaderBar{ position:absolute; overflow:hidden; top:0px; left:0px; }\ncanvas.DescartesSpace2DCanvas, canvas.DescartesSpace3DCanvas, div.blocker{ position:absolute; overflow:hidden; left:0px; top:0px; }\ndiv.DescartesSpace2DContainer, div.DescartesSpace3DContainer{ position:absolute; overflow:hidden; line-height:0px; }\ncanvas.DescartesButton{ position:absolute; cursor:pointer; }\ndiv.DescartesButtonContainer{ position:absolute; }\ndiv.DescartesSpinnerContainer, div.DescartesTextFieldContainer, div.DescartesMenuContainer{ background:lightgray; position:absolute; overflow:hidden; }\ninput.DescartesSpinnerField, input.DescartesTextFieldField, input.DescartesMenuField, input.DescartesScrollbarField{ -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; font-family:Arial, Helvetica, 'Droid Sans', Sans-serif; padding:0px; border:solid #666 1px; position:absolute; top:0px; }\nlabel.DescartesSpinnerLabel, label.DescartesMenuLabel, label.DescartesScrollbarLabel, label.DescartesTextFieldLabel{ font-family:Arial, Helvetica, 'Droid Sans', Sans-serif; font-weight:normal; text-align:center; text-overflow:ellipsis; white-space:nowrap; overflow:hidden; background-color:#e0e4e8; position:absolute; left:0px; top:0px; }\ndiv.DescartesGraphicControl{ border-style:none; position:absolute; }\ndiv.DescartesTextAreaContainer{ position:absolute; overflow:hidden; background:#c0d0d8; }\nselect.DescartesMenuSelect{ font-family:Arial, Helvetica, 'Droid Sans', Sans-serif; padding-top:0%; text-align:center; text-overflow:ellipsis; white-space:nowrap; overflow:hidden; background-color:white; position:absolute; left:0px; top:0px; }\ndiv.DescartesScrollbarContainer{ background:#eee; overflow:hidden; position:absolute; }\n";
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.sin,e=Math.floor,h=Math.random,b=Math.round,c=Math.abs,l=String.fromCharCode,f,g,r,n,j,p,q,u,k,s;a.Krypto=function(a){this.key=(a||0).toString()};a.Krypto.prototype.getKey=function(a){f=[];for(var b=0;256>b;b++)f[b]=l(this.alfanum(e(c(7.5*(d(1*b-a)+d(1.4*b+a)+d(0.6*b-a)+d(2.2*b+a))))));return f.join("")};a.Krypto.prototype.encode=function(a){g=e(31*h());this.key=this.getKey(g);n=l(this.alfanum(g));return n+this.encripta(a)};
a.Krypto.prototype.decode=function(a){g=this.numalfa(a.charCodeAt(0));this.key=this.getKey(g);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;p=Array(3*a.length);for(var c=0,f=a.length;c<f;c++)k=256*e(a[c]+128)+b(255*h())+65536*b(255*h()),s=e((k<<this.shift(c))/256),p[3*c]=this.alfanum(s%32),p[3*c+1]=this.alfanum(s/32%
32),p[3*c+2]=this.alfanum(s/1024%32);return p};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;q=Array(a.length/3);for(var b=0,c=q.length;b<c;b++)s=this.numalfa(a[3*b])+32*this.numalfa(a[3*b+1])+1024*this.numalfa(a[3*b+2]),k=e(256*s>>this.shift(b)),u=e(k/256)%256-128,0>u&&(u+=256),q[b]=u;return q};a.Krypto.prototype.alfanum=function(a){a=e(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,c=a.length;b<c;b++)n[b]=a.charCodeAt(b);return n};a.Krypto.prototype.bytesToString=function(a){for(var b=0,c=a.length;b<c;b++)a[b]=l(a[b]);return a.join("")};a.Krypto.prototype.shift=function(a){r=this.key.charCodeAt(a%this.key.length);n=this.numalfa(r);j=e(n/2%8);0==j&&(j=4);return j};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;a.Animation=function(d,e){this.parent=d;var h=d.evaluator,b=h.parser,c=new a.Auxiliary(d);this.delay=e.delay?b.parse(e.delay):b.parse("60");this.loop=e.loop?e.loop:!1;this.auto=void 0==e.auto?!0:e.auto;this.controls=e.controls;this.init=c.splitInstructions(b,e.init);this.doExpr=c.splitInstructions(b,e.doExpr);e.whileExpr&&(this.whileExpr=b.parse(e.whileExpr));var l=this,f,g,r=l.doExpr.length;this.animationExec=
function(){for(g=0;g<r;g++)h.evalExpression(l.doExpr[g]);l.parent.update();l.playing&&(0<h.evalExpression(l.whileExpr)||l.loop)?(f=h.evalExpression(l.delay),l.timer=setTimeout(l.animationExec,10>f?10:f)):(l.stop(),l.parent.update())};this.playing=!1;this.auto&&this.play()};a.Animation.prototype.play=function(){this.playing?this.stop():(this.reinit(),this.playing=!0,this.timer=setTimeout(this.animationExec,this.parent.evaluator.evalExpression(this.delay)))};a.Animation.prototype.stop=function(){this.playing=
!1;clearInterval(this.timer)};a.Animation.prototype.reinit=function(){for(var a=0,e=this.init.length;a<e;a++)this.parent.evaluator.evalExpression(this.init[a])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Action=function(a){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(d,e){a.Action.call(this,d,e);this.parameter=(e||"").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(d,e){a.Action.call(this,d,e);var h=this.evaluator,b=h.parser;e=(e||"").replace(/&squot;/g,"'");e=e.replace(/;/g,"\\n");e=e.split("\\n")||[""];for(var c=[],l,f=0,g=e.length;f<g;f++)(l=b.parse(e[f],!0))&&c.push(l);g=c.length;this.execute=function(){for(f=0;f<g;f++)h.evalExpression(c[f])}};
a.extend(a.Calculate,a.Action);return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.OpenURL=function(d,e){a.Action.call(this,d,e);this.parameter=e;this.target="_blank";var h=this.parameter.indexOf("target");-1!=h&&(this.target=this.parameter.substring(h),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,h-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)})};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(d,e){a.Action.call(this,d,e);this.parameter=e;this.target=
"_blank";var h=this.parameter.indexOf("target");-1!=h&&(this.target=this.parameter.substring(h),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,h-1));"_blank"!==this.target&&"_parent"!==this.target&&"_self"!==this.target&&"_top"!==this.target?this.actionExec=function(){window.parent.postMessage({type:"changeTarget",name:this.target,value:this.parameter},"*")}:"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.About=function(d,e){a.Action.call(this,d,e);e||(this.urlAbout=window.location.href.substring(0,window.location.href.lastIndexOf("/")+1)+e)};a.extend(a.About,a.Action);a.About.prototype.execute=function(){if(this.urlAbout)var a=window.open(this.urlAbout,"_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes");else a=
window.open("about:blank","_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes"),a.document.write("<hmtl><head><title>Cr\u00e9ditos</title></head><body><h1>Aqu\u00ed van los cr\u00e9ditos</h1></body></html>")};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Config=function(d,e){a.Action.call(this,d,e)};a.extend(a.Config,a.Action);a.Config.prototype.execute=function(){window.open("about:blank","_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes").document.write("<xmp style='width:100%; height:100%;'>"+
this.parent.applet.outerHTML+"</xmp>")};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Init=function(d,e){a.Action.call(this,d,e)};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(d,e){a.Action.call(this,d,e)};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(d,e){a.Action.call(this,d,e)};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(d,e){a.Action.call(this,d,e)};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 d=/[\w\.\-//]*(\.ogg|\.oga|\.mp3|\.wav|\.OGG|\.OGA\.MP3|\.WAV)/g;
a.PlayAudio=function(e,h){a.Action.call(this,e,h);this.filenameExpr=h&&h.match(d)?this.evaluator.parser.parse("'"+h.match(d)+"'"):this.evaluator.parser.parse(h)};a.extend(a.PlayAudio,a.Action);a.PlayAudio.prototype.execute=function(){var a=this.theAudio=this.parent.getAudio(this.evaluator.evalExpression(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,b){this.parent=a;this.evaluator=this.parent.evaluator;
this.expresion=this.id="";this.evaluate="onlyOnce";this.local="";for(var c in b)b.hasOwnProperty(c)&&(this[c]=b[c])};a.Auxiliary.prototype.firstRun=function(){};a.Auxiliary.prototype.update=function(){};var d,e;a.Auxiliary.prototype.splitInstructions=function(a,b){e=[];b=b?b.split(";"):[""];for(var c=0,l=b.length;c<l;c++)(d=a.parse(b[c],!0))&&e.push(d);return e};a.Auxiliary.prototype.getPrivateVariables=function(a,b){e=[];b=b?b.split(/;|,/):[""];for(var c=0,l=b.length;c<l;c++)(d=a.parse(b[c],!0))&&
e.push(d);c=0;for(l=e.length;c<l;c++)e[c]="asign"===e[c].type?e[c].childs[0].value:"identifier"===e[c].type?e[c].value:"";return e};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(d,e){a.Auxiliary.call(this,d,e);var h=
this.evaluator.parser;this.expresionString=this.expresion;(this.expresion=h.parse(this.expresionString))&&h.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"),e=document.createElement("label");e.appendChild(document.createTextNode("___"+this.id+"=___"));var h=document.createElement("input");h.value=this.expresionString;
h.disabled=!this.editable;a.appendChild(e);a.appendChild(h);var b=this,c=b.evaluator.parser;h.onkeydown=function(a){13==a.keyCode&&(b.expresion=c.parse(this.value),c.setVariable(b.id,b.expresion),b.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(d,e){a.Auxiliary.call(this,d,e);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.evalExpression(this.expresion))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,e,h;a.Vector=function(b,c){d=b.evaluator;e=d.parser;this.size=e.parse("3");a.Auxiliary.call(this,b,c);this.expresion=this.expresion.split(";");this.parseFile=e.parse(this.file);this.update()};a.extend(a.Vector,a.Auxiliary);a.Vector.prototype.update=function(){var b=this.expresion;d=this.evaluator;
e=d.parser;this.oldFile=this.file;if(h=d.evalExpression(this.parseFile))this.file=h;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 l=[],f=0,g=c.length;f<g;f++)""!=c[f]&&l.push(c[f]);c=l}null==c||1==c.length&&""==c[0]?this.size=0:(b=c,this.size=null);null===this.size&&(this.size=e.parse(b.length+""))}c=[];f=0;for(g=b.length;f<g;f++)(l=
e.parse(b[f],!0))&&"asign"!=l.type&&(l=e.parse(this.id+"["+f+"]="+b[f],!0)),c.push(l);b=[];f=0;for(g=d.evalExpression(this.size);f<g;f++)b.push(0);d.vectors[this.id]=b;d.setVariable(this.id+".long",d.evalExpression(this.size));f=0;for(g=c.length;f<g;f++)d.evalExpression(c[f])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Matrix=function(d,e){var h=d.evaluator,b=h.parser;this.rows=b.parse("3");this.columns=b.parse("3");a.Auxiliary.call(this,d,e);this.expresion=this.splitInstructions(b,
this.expresion);var b=h.evalExpression(this.rows),c=h.evalExpression(this.columns),l=[];l.type="matrix";for(var f,g=0;g<c;g++){f=[];for(var r=0,n=b;r<n;r++)f.push(0);l[g]=f}h.matrices[this.id]=l;this.update()};a.extend(a.Matrix,a.Auxiliary);a.Matrix.prototype.update=function(){var a=this.evaluator,e=a.evalExpression(this.rows),h=a.evalExpression(this.columns);a.setVariable(this.id+".filas",e);a.setVariable(this.id+".columnas",h);var b=a.matrices[this.id];b.rows=e;b.cols=h;e=0;for(h=this.expresion.length;e<
h;e++)a.evalExpression(this.expresion[e])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Function=function(d,e){a.Auxiliary.call(this,d,e);var h=this.evaluator,b=h.parser,c=this.id.indexOf("(");this.name=this.id.substring(0,c);this.params=this.id.substring(c+1,this.id.length-1);this.domain=this.range?b.parse(this.range):b.parse("1");this.params=""==this.params?[]:this.params.split(",");this.numberOfParams=this.params.length;this.algorithm||(this.whileExpr=this.doExpr=
this.init="");this.parseExpressions(b);this.expresion=b.parse(this.expresion);var l=this;this.functionExec=function(){this.iterations=0;if(l.numberOfParams<=arguments.length){for(var b=[],c=0,d=l.privateVars.length;c<d;c++)b.push(h.getVariable(l.privateVars[c])),h.setVariable(l.privateVars[c],0);for(var e=[],c=0,d=l.params.length;c<d;c++)e[c]=h.getVariable(l.params[c]),h.setVariable(l.params[c],arguments[c]);c=0;for(d=l.init.length;c<d;c++)h.evalExpression(l.init[c]);do{c=0;for(d=l.doExpr.length;c<
d;c++)h.evalExpression(l.doExpr[c]);if(1E5<++this.iterations)return console.log("se ha excedido el l\u00edmite de 100000 repeticiones en la funci\u00f3n",this.id),0}while(0<h.evalExpression(l.whileExpr));var j=h.evalExpression(l.expresion);a.rangeOK=h.evalExpression(l.domain);c=0;for(d=l.params.length;c<d;c++)h.setVariable(l.params[c],e[c]);c=0;for(d=l.privateVars.length;c<d;c++)h.setVariable(l.privateVars[c],b[c]);return j}return 0};h.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(d,e){a.Auxiliary.call(this,d,e);var h=this.evaluator;this.parseExpressions(h.parser);this.algorithmExec=function(){for(var a=this.iterations=0,c=this.init.length;a<c;a++)h.evalExpression(this.init[a]);do{a=0;for(c=this.doExpr.length;a<c;a++)h.evalExpression(this.doExpr[a]);if(1E5<++this.iterations)return console.log("se ha excedido el l\u00edmite de 100000 repeticiones en el algoritmo",this.id),
0}while(0<h.evalExpression(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(d,e){a.Auxiliary.call(this,d,e);var h=this.evaluator;this.condition=h.parser.parse(this.condition);this.lastEvaluation=!1;this.action=this.parent.lessonParser.parseAction(this);"onlyOnce"==this.execution&&(this.eventExec=
function(){0<h.evalExpression(this.condition)&&!this.lastEvaluation&&(this.lastEvaluation=!0,this.action.execute())});"alternate"==this.execution&&(this.eventExec=function(){var a=0<h.evalExpression(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<h.evalExpression(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 d,e,h,b,c;a.Graphic=function(b,c){this.parent=b;this.evaluator=b.evaluator;var g=this.evaluator.parser;this.spaceID="";this.background=!1;this.type="";this.drawif=g.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=g.parse("(0,0)");this.family="";this.family_interval=g.parse("[0,1]");this.family_steps=g.parse("8");this.editable=!1;this.font=5<=this.parent.version?"Monospaced,PLAIN,15":"Monospaced,PLAIN,12";this.fixed=!0;this.text="";this.decimals=g.parse("2");for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);this.space=this.getSpace();this.canvas=this.background?this.space.backgroundCanvas:this.space.canvas;this.ctx=this.canvas.getContext("2d");this.trace&&
(this.traceCtx=this.space.backgroundCanvas.getContext("2d"));this.font=a.convertFont(this.font);this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseInt(this.fontSize[1]):10};a.Graphic.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.Graphic.prototype.getFamilyValues=function(){d=this.evaluator;e=d.evalExpression(this.family_interval);this.familyInf=e[0][0];this.familySup=e[0][1];this.fSteps=Math.round(d.evalExpression(this.family_steps));
this.family_sep=0<this.fSteps?(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic.prototype.drawFamilyAux=function(a,b,c){d=this.evaluator;this.getFamilyValues();h=d.getVariable(this.family);if(0<=this.fSteps)for(var e=0,n=this.fSteps;e<=n;e++)d.setVariable(this.family,this.familyInf+e*this.family_sep),0<d.evalExpression(this.drawif)&&(this.update(),this.drawAux(a,b,c));d.setVariable("_Text_H_",0);d.setVariable(this.family,h)};a.Graphic.prototype.draw=function(a,b){""!=this.family?this.drawFamilyAux(this.ctx,
a,b):0<this.evaluator.evalExpression(this.drawif)&&(this.update(),this.drawAux(this.ctx,a,b))};a.Graphic.prototype.drawTrace=function(a,b){""!=this.family?this.drawFamilyAux(this.traceCtx,a,b):0<this.evaluator.evalExpression(this.drawif)&&(this.update(),this.drawAux(this.traceCtx,a,b))};a.Graphic.prototype.drawText=function(a,f,g,h,e,j,p,q,u,k,s){if("rtfNode"===f.type)a.fillStyle=e.getColor(),a.strokeStyle=e.getColor(),a.textBaseline="alphabetic",f.draw(a,g,h,u,k,p,s,e.getColor());else{"simpleText"===
f.type&&(f=f.toString(u,k).split("\\n"));g+=j.match("Arial")?-2:j.match("Times")?-2:0;d=this.evaluator;a.fillStyle=e.getColor();a.font=j;a.textAlign=p;a.textBaseline=q;this.border&&(a.strokeStyle=this.border.getColor(),a.lineWidth=3);c=1.2*this.fontSize||0;e=0;for(j=f.length;e<j;e++)b=f[e],this.border&&(a.lineJoin="round",a.strokeText(b,g,h+c*e)),a.fillText(b,g,h+c*e)}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.SimpleText=function(a,b){this.text=b=b.replace("&#x2013",
"\u2013").replace(/\&squot;/g,"'");this.textElements=[];this.textElementsMacros=[];this.parent=a;this.evaluator=a.evaluator;this.type="simpleText";for(var c="'",d=0,f=0,g=-1,e,n;d<b.length;)e=b.charAt(d),n=b.charAt(d-1),"["===e&&"\\"===n?(this.textElements.push(b.substring(f,d-1)+"["),this.textElementsMacros.push("'"+b.substring(f,d-1)+"['"),f=d+1):"]"===e&&"\\"===n?(this.textElements.push(b.substring(f,d-1)+"]"),this.textElementsMacros.push("'"+b.substring(f,d-1)+"]'"),f=d+1):"["===e&&-1===g?(this.textElements.push(b.substring(f,
d)),this.textElementsMacros.push("'"+b.substring(f,d)+"'"),f=d,g++):"["===e?g++:"]"===e&&0===g?(this.textElements.push(this.evaluator.parser.parse(b.substring(f,d+1))),this.textElementsMacros.push("["+b.substring(f,d+1)+"]"),f=d+1,g--):("]"==b.charAt(d)&&(g=0>g?g:g-1),c+=b.charAt(d)),d++;this.textElements.push(b.substring(f,d));this.textElementsMacros.push("'"+b.substring(f,d)+"'")};var d,e;a.SimpleText.prototype.toString=function(h,b){d="";for(var c=0,l=this.textElements.length;c<l;c++)"string"===
typeof this.textElements[c]?d+=this.textElements[c]:(e=this.evaluator.evalExpression(this.textElements[c])[0][0],""!==e&&("string"===typeof e?d+=e:(e=parseFloat(e),e=b?e.toFixed(h):a.removeNeedlessDecimals(e.toFixed(h)),d+=e.toString().replace(".",this.parent.decimal_symbol))));return d};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,e,h,b,c,l,f,g,r,n,j,p,q,u,k,s,m,t,v,y,B,z,D,E,A,x,F;a.Equation=function(b,c){this.width=b.evaluator.parser.parse("1");this.fillM=this.fillP=
"";a.Graphic.call(this,b,c);this.generateStroke();this.parseExpression();(this.visible=2===this.parent.version&&void 0==this.visible?!0:this.visible)&&this.registerTextField();p=new a.R2;q=new a.R2;u=new a.R2;m=new a.R2;k=new a.R2};a.extend(a.Equation,a.Graphic);a.Equation.prototype.parseExpression=function(){if("compOperator"===this.expresion.type){var b=this.expresion.childs[0],c=this.expresion.childs[1];"identifier"==b.type&&"y"==b.value&&!c.contains("y")?(this.funExpr=c,this.of_y=!1,this.drawAux=
this.drawAuxFun):"identifier"==c.type&&"y"==c.value&&!b.contains("y")?(this.funExpr=b,this.of_y=!1,this.drawAux=this.drawAuxFun):"identifier"==b.type&&"x"==b.value&&!c.contains("x")?(this.funExpr=c,this.of_y=!0,this.drawAux=this.drawAuxFun):"identifier"==c.type&&("x"==c.value&&!b.contains("x"))&&(this.of_y=!0,this.funExpr=c,this.drawAux=this.drawAuxFun)}this.newt=new a.R2Newton(this.evaluator,this.expresion)};a.Equation.prototype.generateStroke=function(){this.auxCanvas=document.createElement("canvas");
this.oldWwidth=parseInt(this.evaluator.evalExpression(this.width));this.width_2=parseInt(this.oldWwidth/2)||1;this.auxCanvas.setAttribute("width",this.oldWwidth);this.auxCanvas.setAttribute("height",this.oldWwidth);this.auxCtx=this.auxCanvas.getContext("2d");this.auxCtx.fillStyle=this.color.getColor();this.auxCtx.fillRect(0,0,this.oldWwidth,this.oldWwidth)};var G;a.Equation.prototype.update=function(){G=parseInt(this.evaluator.evalExpression(this.width));G!==this.oldWwidth&&this.generateStroke()};
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,c){e=this.evaluator;this.getFamilyValues();tempParam=e.getVariable(this.family);if(0<=this.fSteps)for(var f=0,d=this.fSteps;f<=d;f++)e.setVariable(this.family,this.familyInf+f*this.family_sep),this.update(),this.drawAux(a,b,c);e.setVariable(this.family,tempParam)};a.Equation.prototype.drawTrace=
function(){this.uber.drawTrace.call(this,this.fill,this.trace)};a.Equation.prototype.drawAux=function(J,H,w){J.lineWidth=1;e=this.evaluator;h=e.parser;b=this.space;c=e.evalExpression(this.width);J.fillStyle=w.getColor();J.translate(-parseInt(c/2),-parseInt(c/2));l=h.getVariable("x");f=h.getVariable("y");g=b.w;r=b.h;n=g/9;3>n&&(n=3);j=r/7;3>j&&(j=3);d=[];p.set(0,0);q.set(0,0);u.set(0,0);for(F=parseInt(j/2);F<r;F+=j)for(x=parseInt(n/2);x<g;x+=n)if(this.abs_coord?(m.set(x,F),s=this.newt.findZero(m),
e.setVariable("x",s.x),e.setVariable("y",s.y),k.set(s.x,s.y)):(m.set(b.getRelativeX(x),b.getRelativeY(F)),s=this.newt.findZero(m),e.setVariable("x",s.x),e.setVariable("y",s.y),k.set(b.getAbsoluteX(s.x),b.getAbsoluteY(s.y))),t=k.ix(),v=k.iy(),!(0>t||t>=g||0>v||v>=r||d[t+v*b.w]))if(d[t+v*b.w]=!0,a.rangeOK&&e.evalExpression(this.drawif)&&J.drawImage(this.auxCanvas,t,v),p.x=s.x,p.y=s.y,q.x=s.x,q.y=s.y,y=this.newt.getUnitNormal(),!(0==y.x&&0==y.y)){y.rotL90();u.x=y.x;u.y=y.y;z=B=0;for(D=!1;2>z;){D&&(u.x=
-y.x,u.y=-y.y,s.x=p.x,s.y=p.y,q.x=s.x,q.y=s.y,this.abs_coord?k.set(s.x,s.y):k.set(b.getAbsoluteX(s.x),b.getAbsoluteY(s.y)),t=k.ix(),v=k.iy(),D=!1,B=0);this.abs_coord?(s.x+=u.x,s.y+=u.y):(s.x+=u.x/b.scale,s.y+=u.y/b.scale);s=this.newt.findZero(s);e.setVariable("x",s.x);e.setVariable("y",s.y);u.x=s.x-q.x;u.y=s.y-q.y;u.normalize();if(0==u.x&&0==u.y)break;q.x=s.x;q.y=s.y;this.abs_coord?k.set(s.x,s.y):k.set(b.getAbsoluteX(s.x),b.getAbsoluteY(s.y));E=parseInt(k.ix());A=parseInt(k.iy());if(E!=t||A!=v)if(H=
t,w=v,t=E,v=A,0<=t&&t<g&&0<=v&&v<r){B=0;var G=d[t+v*b.w];d[t+v*b.w]=!0;for(var C=1;8>C;C++){var I=H+Math.round((t-H)*C/8),L=w+Math.round((v-w)*C/8);0<=I&&(I<g&&0<=L&&L<r)&&(d[I+L*b.w]=!0)}a.rangeOK&&e.evalExpression(this.drawif)&&J.drawImage(this.auxCanvas,t,v);if(G)break}else D=!0,z++;else 4<++B&&(D=!0,z++)}}J.setTransform(1,0,0,1,0,0)};a.Equation.prototype.X=function(a,b,c){c||(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,c){c||(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,c){return Math.round(this.X(a,b,c))};a.Equation.prototype.YY=function(a,b,c){return Math.round(this.Y(a,b,c))};a.Equation.prototype.extrapolate=function(b,c,f,d,g,m){for(var h=this.evaluator.getVariable(c),j=m/2,l=0;1E-12<Math.abs(j);){var e=this.evaluator.getVariable(c),k=this.evaluator.getVariable(c)+j;this.evaluator.setVariable(c,
k);var n=!0,r=g;g=this.evaluator.evalExpression(this.funExpr);this.evaluator.setVariable(f,g);if(0<this.evaluator.evalExpression(b)){var q=new a.R2(Math.min(r,g),Math.max(r,g)),p=0,p=0<m?this.Singularity(Math.abs(j),c,d,e,r,k,g,q):this.Singularity(Math.abs(j),c,d,k,g,e,r,q);0<p&&(n=!1)}else n=!1;n?l+=j:this.evaluator.setVariable(c,e);j/=2}this.evaluator.setVariable(c,h);return new a.R2(l/Math.abs(m),g)};a.Equation.prototype.extrapolateOnSingularity=function(b,c,f,d,g,m){d=this.evaluator.getVariable(c);
for(var h=m/2,j=0,l=g;1E-12<Math.abs(h);){this.evaluator.setVariable(this.evaluator.getVariable(c)+h);var e=!0;0<this.evaluator.evalExpression(b)?(l=this.evaluator.evalExpression(this.funExpr),this.evaluator.setVariable(f,l),0>=this.evaluator.evalExpression(b)&&(e=!1)):e=!1;e?j+=h:this.evaluator.setVariable(this.evaluator.getVariable(c)-h);h/=2}if(0==j){h=m/2;j=m;for(l=g;1E-12<Math.abs(h);)this.evaluator.setVariable(this.evaluator.getVariable(c)-h),e=!0,0<this.evaluator.evalExpression(b)?l=this.evaluator.evalExpression(this.funExpr):
e=!1,e?j+=-h:this.evaluator.setVariable(this.evaluator.getVariable(c)+h),h/=2}this.evaluator.setVariable(d);return new a.R2(j/Math.abs(m),l)};a.Equation.prototype.Singularity=function(a,b,c,f,d,g,m,h){if(f>=g)return 2;var j=this.evaluator.getVariable(b),e=0;if(1E-12>Math.abs(g-f)||1E-8>Math.abs(g-f)&&Math.abs(m-d)>Math.abs(a))return this.evaluator.setVariable(b,j),1;var l=(f+g)/2;this.evaluator.setVariable(b,l);var k=this.evaluator.evalExpression(this.funExpr);if(Math.abs(m-d)>a){this.evaluator.setVariable(b,
f-1E-6);var r=this.evaluator.evalExpression(this.funExpr),r=(d-r)/1E-6;this.evaluator.setVariable(b,g+1E-6);var n=(this.evaluator.evalExpression(this.funExpr)-m)/1E-6,q=(m-d)/(g-f);if(10>Math.abs(n)||10>Math.abs(r))if((0<=n&&0<=r||0>=n&&0>=r)&&8*Math.abs(n)<Math.abs(q))return this.evaluator.setVariable(b,j),2}h.x<=k&&k<=h.y||(this.evaluator.setVariable(b,l),h.x=Math.min(d,k),h.y=Math.max(d,k),f=this.Singularity(a/2,b,c,f,d,l,k,h),this.evaluator.setVariable(b,g),h.x=Math.min(m,k),h.y=Math.max(m,k),
a=this.Singularity(a/2,b,c,l,k,g,m,h),e=Math.max(f,a));this.evaluator.setVariable(b,j);return e};a.Equation.prototype.drawAuxFun=function(b){l=this.evaluator.parser.getVariable("x");f=this.evaluator.parser.getVariable("y");var c="x",d="y";this.of_y&&(c="y",d="x");var g=this.drawif,m=this.evaluator.evalExpression(this.width),h=!1,j=new a.R2(this.space.w/2+this.space.Ox,this.space.h/2+this.space.Oy),j=this.of_y?j.ix():j.iy(),e=0,k=0,r=0,n=1/this.space.scale,q=n*(this.of_y?-this.space.h+(this.space.h/
2+this.space.Oy):-(this.space.w/2+this.space.Ox)),e=0;this.abs_coord&&(q=0,n=1);for(var p=this.of_y?this.space.h:this.space.w;k<p;){var s=!0,u=0;this.evaluator.setVariable(c,q);var v=this.evaluator.evalExpression(this.funExpr);if(isNaN(v))s=!1;else{this.evaluator.setVariable(d,v);if(0<this.evaluator.evalExpression(this.drawif)&&a.rangeOK){if(h){var u=Math.min(e,v),t=Math.max(e,v),t=new a.R2(u,t),u=this.Singularity(n,c,0,q-n,e,q,v,t);0===u?(e<=v?(e=t.x,v=t.y):(v=t.x,e=t.y),u=this.of_y?this.XX(m,e,
this.abs_coord):this.YY(m,e,this.abs_coord),e=this.abs_coord?Math.round(v):this.of_y?this.XX(m,v,this.abs_coord):this.YY(m,v,this.abs_coord),this.fillM&&e>j&&(b.lineWidth=1,b.strokeStyle=this.fillM.getColor(),b.beginPath(),this.of_y?(b.moveTo(j+1,this.space.h-k+0.5),b.lineTo(e,this.space.h-k+0.5)):(b.moveTo(k+0.5,j+1),b.lineTo(k+0.5,e)),b.stroke()),this.fillP&&e<j&&(b.lineWidth=1,b.strokeStyle=this.fillP.getColor(),b.beginPath(),this.of_y?(b.moveTo(j-1,this.space.h-k+0.5),b.lineTo(e,this.space.h-
k+0.5)):(b.moveTo(k+0.5,j-1),b.lineTo(k+0.5,e)),b.stroke()),b.lineWidth=m,b.strokeStyle=this.color.getColor(),b.beginPath(),this.of_y?(b.moveTo(u+0.5,this.space.h-r),b.lineTo(e+0.5,this.space.h-k)):(b.moveTo(r+0.5,u),b.lineTo(k+0.5,e)),b.stroke()):(1===u&&(this.evaluator.setVariable(c,q-n),r=this.extrapolate(g,c,d,0,e,n),this.YY(m,r.y,this.abs_coord),this.evaluator.setVariable(c,q),r=this.extrapolate(g,c,d,0,v,-n),this.YY(m,r.y,this.abs_coord)),this.YY(m,v,this.abs_coord))}else r=this.extrapolateOnSingularity(g,
c,d,0,v,-n),this.YY(m,r.y,this.abs_coord),this.YY(m,v,this.abs_coord);e=v}else s=!1;h&&!s&&(this.evaluator.setVariable(c,q-n),this.evaluator.setVariable(d,e),r=this.extrapolate(g,c,d,0,e,n),this.YY(m,r.y,this.abs_coord),this.evaluator.setVariable(c,q))}h=s;q+=n;r=k++}this.evaluator.parser.setVariable("x",l);this.evaluator.parser.setVariable("y",f)};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 d=Math.round;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?!0:!1)&&this.registerTextField()};a.extend(a.Curve,a.Graphic);var e,h,b,c,l,f,g,r,n,j,p;a.Curve.prototype.update=function(){e=this.evaluator;h=e.evalExpression(this.parameter_interval);this.paraInf=h[0][0];this.paraSup=h[0][1];this.pSteps=e.evalExpression(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(h,u,k){e=this.evaluator;b=this.space;c=d(e.evalExpression(this.width));h.lineWidth=0<c?c:1E-6;h.lineCap="round";h.lineJoin="round";h.strokeStyle=k.getColor();l=e.getVariable(this.parameter);h.beginPath();e.setVariable(this.parameter,this.paraInf);f=e.evalExpression(this.expresion);this.exprX=this.abs_coord?d(f[0][0]):d(b.getAbsoluteX(f[0][0]));this.exprY=this.abs_coord?d(f[0][1]):d(b.getAbsoluteY(f[0][1]));
this.rotateExp&&(g=a.degToRad(e.evalExpression(this.rotateExp)),r=Math.cos(g),n=Math.sin(g),j=this.exprX*r-this.exprY*n,p=this.exprX*n+this.exprY*r,this.exprX=j,this.exprY=p);h.moveTo(this.exprX+0.5,this.exprY+0.5);for(k=1;k<=this.pSteps;k++)e.setVariable(this.parameter,this.paraInf+k*this.paraSep),f=e.evalExpression(this.expresion),this.exprX=this.abs_coord?d(f[0][0]):d(b.getAbsoluteX(f[0][0])),this.exprY=this.abs_coord?d(f[0][1]):d(b.getAbsoluteY(f[0][1])),this.rotateExp&&(j=this.exprX*r-this.exprY*
n,p=this.exprX*n+this.exprY*r,this.exprX=j,this.exprY=p),h.lineTo(this.exprX+0.5,this.exprY+0.5);this.fill&&(h.fillStyle=u.getColor(),h.fill());h.stroke();e.setVariable(this.parameter,l)};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 d=2*Math.PI,e=Math.round,h,b,c,l,f,g,r,n,j,p,q,u,k;a.Sequence=function(b,c){this.size=b.evaluator.parser.parse("2");this.range=b.evaluator.parser.parse("[1, 100]");a.Graphic.call(this,b,c)};a.extend(a.Sequence,a.Graphic);a.Sequence.prototype.update=function(){h=this.evaluator;c=h.evalExpression(this.expresion);this.exprX=c[0][0];this.exprY=c[0][1];this.rotateExp&&(l=a.degToRad(h.evalExpression(this.rotateExp)),f=Math.cos(l),g=Math.sin(l),r=this.exprX*
f-this.exprY*g,n=this.exprX*g+this.exprY*f,this.exprX=r,this.exprY=n);q=h.evalExpression(this.range);this.rangeInf=q[0][0];this.rangeMax=q[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,f){h=this.evaluator;b=this.space;u=Math.ceil(h.evalExpression(this.size)-0.4);a.fillStyle=f.getColor();a.beginPath();this.rangeInf>this.rangeMax&&
(k=this.rangeInf,this.rangeInf=this.rangeMax,this.rangeMax=k);for(var g=h.getVariable("n"),l=this.rangeInf,r=this.rangeMax;l<=r;l++)h.setVariable("n",l),c=h.evalExpression(this.expresion),this.exprX=c[0][0],this.exprY=c[0][1],j=this.abs_coord?e(this.exprX):e(b.getAbsoluteX(this.exprX)),p=this.abs_coord?e(this.exprY):e(b.getAbsoluteY(this.exprY)),a.beginPath(),a.arc(j,p,u,0,d,!0),a.fill();a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,j+u,p-u,this.color,this.font,"start","alphabetic",
h.evalExpression(this.decimals),this.fixed,!0);h.setVariable("n",g)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=2*Math.PI,e=Math.round,h,b,c,l,f,g,r,n,j,p,q,u;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(){h=this.evaluator;c=h.evalExpression(this.expresion);this.exprX=c[0][0];this.exprY=c[0][1];this.rotateExp&&(l=a.degToRad(h.evalExpression(this.rotateExp)),
f=Math.cos(l),g=Math.sin(l),r=this.exprX*f-this.exprY*g,n=this.exprX*g+this.exprY*f,this.exprX=r,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,c){h=this.evaluator;b=this.space;q=e(h.evalExpression(this.size));u=q+1;a.fillStyle=c.getColor();j=this.abs_coord?e(this.exprX):e(b.getAbsoluteX(this.exprX));p=this.abs_coord?e(this.exprY):
e(b.getAbsoluteY(this.exprY));a.beginPath();a.arc(j,p,q,0,d,!0);a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,j+u+1,p-u,this.color,this.font,"start","alphabetic",h.evalExpression(this.decimals),this.fixed,!0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.round,e=2*Math.PI,h,b,c,l,f,g,r,n,j,p,q,u,k,s,m,t,v,y;a.Segment=function(b,c){this.width=b.evaluator.parser.parse("1");this.size=b.evaluator.parser.parse("2");a.Graphic.call(this,b,c)};a.extend(a.Segment,
a.Graphic);a.Segment.prototype.update=function(){h=this.evaluator;c=h.evalExpression(this.expresion);this.endPoints=[];for(var b=0,d=c.length;b<d;b++)this.endPoints[b]={x:c[b][0],y:c[b][1]};if(this.rotateExp){l=a.degToRad(h.evalExpression(this.rotateExp));f=Math.cos(l);g=Math.sin(l);b=0;for(d=this.endPoints.length;b<d;b++)r=this.endPoints[b].x*f-this.endPoints[b].y*g,n=this.endPoints[b].x*g+this.endPoints[b].y*f,this.endPoints[b].x=r,this.endPoints[b].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,c,f){h=this.evaluator;b=this.space;j=d(h.evalExpression(this.width));a.lineWidth=0<j?j:1E-6;k=h.evalExpression(this.size);0>k&&(k=0);a.fillStyle=c.getColor();a.strokeStyle=f.getColor();a.lineCap="round";p=10+a.lineWidth;s=0==a.lineWidth%2?0:0.5;this.abs_coord?(m=d(this.endPoints[0].x),t=d(this.endPoints[0].y),v=d(this.endPoints[1].x),y=d(this.endPoints[1].y)):
(m=d(b.getAbsoluteX(this.endPoints[0].x)),t=d(b.getAbsoluteY(this.endPoints[0].y)),v=d(b.getAbsoluteX(this.endPoints[1].x)),y=d(b.getAbsoluteY(this.endPoints[1].y)));a.beginPath();a.moveTo(m+s,t+s);a.lineTo(v+s,y+s);a.stroke();a.beginPath();a.arc(m,t,k,0,e,!0);a.arc(v,y,k,0,e,!0);a.fill();this.text!=[""]&&(q=parseInt((m+v)/2)-3,u=parseInt((t+y)/2)+3,this.uber.drawText.call(this,a,this.text,q+p,u-p,this.color,this.font,"start","alphabetic",h.evalExpression(this.decimals),this.fixed,!0))};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.floor,e=Math.round,h,b,c,l,f,g,r,n,j,p,q,u,k,s,m,t,v,y;a.Arrow=function(b,c){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,c)};a.extend(a.Arrow,a.Graphic);a.Arrow.prototype.update=function(){h=this.evaluator;b=h.evalExpression(this.expresion);this.endPoints=[];for(var d=0,m=b.length;d<m;d++)this.endPoints[d]=
{x:b[d][0],y:b[d][1]};if(this.rotateExp){c=a.degToRad(h.evalExpression(this.rotateExp));l=Math.cos(c);f=Math.sin(c);d=0;for(m=this.endPoints.length;d<m;d++)g=this.endPoints[d].x*l-this.endPoints[d].y*f,r=this.endPoints[d].x*f+this.endPoints[d].y*l,this.endPoints[d].x=g,this.endPoints[d].y=r}};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,f){h=this.evaluator;n=this.space;h.evalExpression(this.size);q=h.evalExpression(this.width);0>q&&(q=0);u=Math.ceil(q/2);k=n.scale;this.vect=new a.Vector2D(this.endPoints[1].x-this.endPoints[0].x,this.endPoints[1].y-this.endPoints[0].y);s=this.vect.vectorLength();this.angle=this.vect.angleBetweenVectors(a.Vector2D.AXIS_X);b.fillStyle=c.getColor();b.strokeStyle=f.getColor();b.lineWidth=2;this.abs_coord?(m=e(this.endPoints[0].x),t=e(this.endPoints[0].y),v=e(this.endPoints[1].x),y=e(this.endPoints[1].y)):
(m=e(n.getAbsoluteX(this.endPoints[0].x)),t=e(n.getAbsoluteY(this.endPoints[0].y)),v=e(n.getAbsoluteX(this.endPoints[1].x)),y=e(n.getAbsoluteY(this.endPoints[1].y)));c=h.evalExpression(this.spear);0>c&&(c=0);b.save();b.translate(m,t,s);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):(s*=k,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(-u,d(-u));
b.lineTo(d(s-c-q),d(-u));b.lineTo(d(s-2*c),d(-c-u));b.lineTo(d(s),0);b.lineTo(d(s-2*c),d(c+u));b.lineTo(d(s-c-q),d(u));b.lineTo(-u,d(u));b.closePath();b.stroke();b.fill();b.restore();this.text!=[""]&&(j=parseInt((m+v)/2)-3,p=parseInt((t+y)/2)+3,this.uber.drawText.call(this,b,this.text,j,p,f,this.font,"start","alphabetic",h.evalExpression(this.decimals),this.fixed,!0))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.round,e,h,b,c,l,f,g,r,n,j,p,q;a.Polygon=function(b,
c){this.width=b.evaluator.parser.parse("1");this.fill="";a.Graphic.call(this,b,c);this.endPoints=[]};a.extend(a.Polygon,a.Graphic);a.Polygon.prototype.update=function(){e=this.evaluator;b=e.evalExpression(this.expresion);for(var d=0,h=b.length;d<h;d++)this.endPoints[d]={x:b[d][0],y:b[d][1]};if(this.rotateExp){c=a.degToRad(e.evalExpression(this.rotateExp));l=Math.cos(c);f=Math.sin(c);d=0;for(h=this.endPoints.length;d<h;d++)g=this.endPoints[d].x*l-this.endPoints[d].y*f,r=this.endPoints[d].x*f+this.endPoints[d].y*
l,this.endPoints[d].x=g,this.endPoints[d].y=r}};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){e=this.evaluator;h=this.space;n=d(e.evalExpression(this.width));a.lineWidth=0<n?n:1E-6;a.strokeStyle=c.getColor();a.lineCap="round";a.lineJoin="round";j=0<n?0.5:0;p=this.abs_coord?d(this.endPoints[0].x):d(h.getAbsoluteX(this.endPoints[0].x));
q=this.abs_coord?d(this.endPoints[0].y):d(h.getAbsoluteY(this.endPoints[0].y));a.beginPath();a.moveTo(p+j,q+j);c=1;for(var f=this.endPoints.length;c<f;c++)p=this.abs_coord?d(this.endPoints[c].x):d(h.getAbsoluteX(this.endPoints[c].x)),q=this.abs_coord?d(this.endPoints[c].y):d(h.getAbsoluteY(this.endPoints[c].y)),a.lineTo(p+j,q+j);this.fill&&(a.fillStyle=b.getColor(),a.fill());a.stroke()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.round,e,h,b,c,l,f,g,r,n,j,p,
q,u,k,s,m,t,v,y,B,z;a.Arc=function(b,c){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=b.evaluator.parser.parse("0");this.end=b.evaluator.parser.parse("90");a.Graphic.call(this,b,c)};a.extend(a.Arc,a.Graphic);a.Arc.prototype.update=function(){e=this.evaluator;h=e.evalExpression(this.center);this.exprX=h[0][0];this.exprY=h[0][1];this.rotateExp&&(b=a.degToRad(e.evalExpression(this.rotateExp)),c=
Math.cos(b),l=Math.sin(b),f=this.exprX*c-this.exprY*l,g=this.exprX*l+this.exprY*c,this.exprX=f,this.exprY=g);var d=e.evalExpression(this.init),m=e.evalExpression(this.end);"(expr)"==this.init.type&&"(expr)"==this.end.type||"[expr]"==this.init.type&&"[expr]"==this.end.type||"(expr)"==this.init.type&&"[expr]"==this.end.type||"[expr]"==this.init.type&&"(expr)"==this.end.type?(r=d[0][0],n=d[0][1],j=m[0][0],p=m[0][1],this.vectors?this.abs_coord&&(n=-n,p=-p):this.abs_coord?(r-=this.exprX,n=-n+this.exprY,
j-=this.exprX,p=-p+this.exprY):(r-=this.exprX,n-=this.exprY,j-=this.exprX,p-=this.exprY),q=0==r?0>n?-Math.PI/2:Math.PI/2:Math.acos(1*r/Math.sqrt(r*r+n*n)),u=0==j?0>p?-Math.PI/2:Math.PI/2:Math.acos(1*j/Math.sqrt(j*j+p*p)),0<r&&(0<n&&this.abs_coord)&&(q=2*Math.PI-q),0<r&&(0>n&&!this.abs_coord)&&(q=2*Math.PI-q),0>r&&(0>n&&!this.abs_coord)&&(q=2*Math.PI-q),0>r&&(0<n&&this.abs_coord)&&(q=2*Math.PI-q),0<j&&(0<p&&this.abs_coord)&&(u=2*Math.PI-u),0<j&&(0>p&&!this.abs_coord)&&(u=2*Math.PI-u),0>j&&(0>p&&!this.abs_coord)&&
(u=2*Math.PI-u),0>j&&(0<p&&this.abs_coord)&&(u=2*Math.PI-u),k=Math.min(q,u),s=Math.max(q,u),q=k,u=s,u-q>Math.PI&&this.abs_coord&&(q=s,u=k),u-q<=Math.PI&&!this.abs_coord&&(q=s,u=k),this.iniAng=q,this.endAng=u,this.drawPoints=!0):(this.iniAng=a.degToRad(d),this.endAng=a.degToRad(m),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,c){e=this.evaluator;m=this.space;y=e.evalExpression(this.radius);0>y&&(y=0);z=d(e.evalExpression(this.width));a.lineWidth=0<z?z:1E-6;a.lineCap="round";a.strokeStyle=c.getColor();this.drawAngle?(this.abs_coord?(t=d(this.exprX),v=d(this.exprY)):(t=d(m.getAbsoluteX(this.exprX)),v=d(m.getAbsoluteY(this.exprY)),y*=m.scale,this.iniAng=-this.iniAng,this.endAng=-this.endAng),this.iniAng>this.endAng&&(B=this.iniAng,this.iniAng=this.endAng,this.endAng=B)):this.drawPoints&&(this.abs_coord?(t=d(this.exprX),
v=d(this.exprY)):(t=d(m.getAbsoluteX(this.exprX)),v=d(m.getAbsoluteY(this.exprY)),y*=m.scale,this.iniAng=-this.iniAng,this.endAng=-this.endAng));this.fill&&(a.fillStyle=b.getColor(),a.beginPath(),a.moveTo(t,v),a.arc(t,v,y,this.iniAng,this.endAng,void 0),a.fill());a.beginPath();a.arc(t,v,y,this.iniAng,this.endAng,void 0);a.stroke();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,t+4,v-2,this.color,this.font,"start","alphabetic",e.evalExpression(this.decimals),this.fixed,!0)};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;var d,e,h,b,c,l,f,g,r,n,j,p,q,u,k,s,m,t;a.Text=function(b,c){this.width=b.evaluator.parser.parse("0");a.Graphic.call(this,b,c);this.align||(this.align="start");this.ascent=this.fontSize-Math.ceil(this.fontSize/7)-(this.font.match("Courier")?3:0);this.abs_coord=!0};a.extend(a.Text,a.Graphic);a.Text.prototype.update=function(){d=this.evaluator;e=d.evalExpression(this.expresion);this.exprX=e[0][0];this.exprY=e[0][1];this.rotateExp&&(h=a.degToRad(d.evalExpression(this.rotateExp)),
b=Math.cos(h),c=Math.sin(h),l=this.exprX*b-this.exprY*c,f=this.exprX*c+this.exprY*b,this.exprX=l,this.exprY=f)};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){t=this.evaluator.evalExpression(this.decimals);"rtfNode"===this.text.type?(j=this.text,this.ascent=0):j=this.splitText(this.text.toString(t,this.fixed).split("\\n"));this.text!=[""]&&this.uber.drawText.call(this,
a,j,parseInt(this.exprX)+5,parseInt(this.exprY)+this.ascent,b,this.font,this.align,"alphabetic",t,this.fixed)};a.Text.prototype.splitText=function(a){d=this.evaluator;g=d.evalExpression(this.width);j=[];this.ctx.font=this.font;if(20<=g&&"undefined"!=a.type){for(var b=0,c=a.length;b<c;b++)r=a[b],n=this.ctx.measureText(r).width,n>g?j=j.concat(this.splitWords(r,g)):j.push(r);p=Math.floor(1.2*this.fontSize)*j.length;d.setVariable("_Text_H_",p);return j}d.setVariable("_Text_H_",0);d.setVariable("_Text_W_",
1E3);return a};a.Text.prototype.splitWords=function(a,b){q=a;u=[];k="";m=0;for(var c,f=0,d=a.length;f<d;f++)s=q.charAt(f)," "===s&&(lastIndexOfWhite=f),k+=s,Math.round(this.ctx.measureText(k).width)>b&&(c=a.substring(m,f+1)," "!==s&&(-1===c.indexOf(" ")?(lastIndexOfWhite=f,f--):f=lastIndexOfWhite),u.push(a.substring(m,lastIndexOfWhite)),k="",m=f+1);u.push(a.substring(m));return u};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.round,e,h,b,c,l,f,g,r,n,j,p,q,u,k;
a.Image=function(b,c){this.file="";this.inirot=b.evaluator.parser.parse("0");a.Graphic.call(this,b,c);this.img=new Image;this.scaleY=this.scaleX=1;this.update()};a.extend(a.Image,a.Graphic);a.Image.prototype.update=function(){e=this.evaluator;h=e.evalExpression(this.expresion);this.exprX=h[0][0];this.exprY=h[0][1];this.rotateExp&&(b=a.degToRad(e.evalExpression(this.rotateExp)),c=Math.cos(b),l=Math.sin(b),f=this.exprX*c-this.exprY*l,g=this.exprX*l+this.exprY*c,this.exprX=f,this.exprY=g);4==h[0].length&&
(this.centered=!0,this.scaleX=h[0][2],0==this.scaleX&&(this.scaleX=1E-5),this.scaleY=h[0][3],0==this.scaleY&&(this.scaleY=1E-5));h[1]&&2==h[1].length&&(this.centered=!0,this.scaleX=h[1][0],0==this.scaleX&&(this.scaleX=1E-5),this.scaleY=h[1][1],0==this.scaleY&&(this.scaleY=1E-5));if((r=e.evalExpression(this.file))||""==r)this.img=this.parent.getImage(r)};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){e=this.evaluator;n=this.space;this.img&&(this.img.ready&&this.img.complete)&&(j=this.centered?0:this.img.width/2,p=this.centered?0:this.img.height/2,q=this.abs_coord?d(this.exprX):d(n.getAbsoluteX(this.exprX)),u=this.abs_coord?d(this.exprY):d(n.getAbsoluteY(this.exprY)),k=a.degToRad(-e.evalExpression(this.inirot)),b.translate(q+j,u+p),b.rotate(k),b.scale(this.scaleX,this.scaleY),this.opacity&&(b.globalAlpha=e.evalExpression(this.opacity)),b.drawImage(this.img,-this.img.width/2,-this.img.height/
2),b.setTransform(1,0,0,1,0,0),b.globalAlpha=1)};return a}(descartesJS||{}),descartesJS=function(a){function d(a,b,c){g=4*(b+c*a.width);return{r:a.data[g],g:a.data[g+1],b:a.data[g+2],a:a.data[g+3]}}if(a.loadLib)return a;var e,h,b,c,l,f,g;a.Fill=function(b,c){a.Graphic.call(this,b,c)};a.extend(a.Fill,a.Graphic);a.Fill.prototype.update=function(){e=this.evaluator.evalExpression(this.expresion);this.exprX=e[0][0];this.exprY=e[0][1]};a.Fill.prototype.draw=function(){this.uber.draw.call(this,this.color,
this.color)};a.Fill.prototype.drawTrace=function(){};a.Fill.prototype.drawAux=function(a,e){e.getColor();imageData=this.ctx.getImageData(0,0,this.space.w,this.space.h);this.abs_coord?(h=parseInt(this.exprX),b=parseInt(this.exprY)):(h=parseInt(this.space.getAbsoluteX(this.exprX)),b=parseInt(this.space.getAbsoluteY(this.exprY)));if(!(0>h||0>b||h>=this.space.w||b>=this.space.h)){c=[{x:h,y:b}];for(f=d(imageData,h,b);0<c.length;){l=c.pop();h=l.x;b=l.y;var j=d(imageData,h,b);if(f.r===j.r&&f.g===j.g&&f.b===
j.b&&f.a===j.a){var j=imageData,p=e;g=4*(h+b*j.width);j.data[g+0]=p.r;j.data[g+1]=p.g;j.data[g+2]=p.b;j.data[g+3]=255-p.a;0<h&&c.push({x:h-1,y:b});h<imageData.width-1&&c.push({x:h+1,y:b});c.push({x:h,y:b-1});c.push({x:h,y:b+1})}}this.ctx.putImageData(imageData,0,0)}};return a}(descartesJS||{}),descartesJS=function(a,d){if(a.loadLib)return a;var e=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg)/gi,h;a.Macro=function(b,c){this.expresion=void 0;this.inirot=b.evaluator.parser.parse("0");this.inipos=b.evaluator.parser.parse("(0,0)");
a.Graphic.call(this,b,c);for(var h in c)c.hasOwnProperty(h)&&(this[h]=c[h]);this.graphics=[];h=b.lessonParser;var f=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 g=this.evaluator.evalExpression(this.expresion),r;g&&((r=document.getElementById(g))&&"descartes/macro"==r.type?r=r.text:(r=a.openExternalFile(g))&&!r.match(/tipo_de_macro/g)&&(r=null));var n,j;if(r){j=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 g=0,p=j.length;g<p;g++)if(n=j[g].indexOf("="),-1!==
n){n=h.split(j[g]);for(var q=0,u=n.length;q<u;q++)n[q]&&1<n.length&&("id"===d[n[q][0]]||"type"===d[n[q][0]])&&r.push(n)}for(var k,s,g=0,p=r.length;g<p;g++){u=(q=r[g]||[])&&q[0]&&"id"===q[0][0];j=0;for(n=q.length;j<n;j++)if(k=q[j][0].indexOf("."),-1!==k&&!u?(k=d[q[j][0].substring(k+1)],q[j][0]=this.name+"."+q[j][0]):k=d[q[j][0]],!("font"===k||("fill"===k||"color"===k||"arrow"===k)&&"("!==q[j][1].charAt(0)||"file"===k&&q[j][1].match(e)||"id"!==k&&void 0!==d[q[j][1]]))if("text"==k)if(q[j][1].match(/\{\\rtf1/)){k=
q[j][1];var m=this;s=function(a,b){for(var c=f.tokenize(b.replace(/\&squot;/g,"'")),d=0,g=c.length;d<g;d++)"identifier"==c[d].type&&!"-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-_GetValues_-_GetMatrix_-_Save_-_Open_-_SaveState_-_OpenState_-_AnchoDeCadena_-_Rojo_-_Verde_-_Azul_-".match("-"+c[d].value+"-")&&(c[d].value=m.name+"."+c[d].value);return(a.match(/^\\expr/)?
"\\expr ":"\\decimals ")+f.flatTokens(c)};k=k.replace(/\\expr ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.'\+\-]*)/gi,s);k=k.replace(/\\decimals ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.'\+\-]*)/gi,s);q[j][1]=k}else{s=h.parseText(q[j][1]).textElementsMacros;for(var t=0,v=s.length;t<v;t++){k=f.tokenize(s[t].replace(/\&squot;/g,"'"));for(var y=0,B=k.length;y<B;y++)"identifier"===k[y].type&&!"-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-_GetValues_-_GetMatrix_-_Save_-_Open_-_SaveState_-_OpenState_-_AnchoDeCadena_-_Rojo_-_Verde_-_Azul_-".match("-"+
k[y].value+"-")&&(k[y].value=this.name+"."+k[y].value);k=f.flatTokens(k).replace(/&squot;/g,"'").replace(/'\+\(/g,"[").replace(/\)\+'/g,"]");s[t]=k.substring(1,k.length-1)}q[j][1]=s.join("")}else{s=q[j][1].replace(/\&squot;/g,"'").split(";");t=0;for(v=s.length;t<v;t++){k=f.tokenize(s[t]);y=0;for(B=k.length;y<B;y++)"identifier"===k[y].type&&!"-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-_GetValues_-_GetMatrix_-_Save_-_Open_-_SaveState_-_OpenState_-_AnchoDeCadena_-_Rojo_-_Verde_-_Azul_-".match("-"+
k[y].value+"-")&&(k[y].value=this.name+"."+k[y].value);s[t]=f.flatTokens(k)}q[j][1]=s.join(";")}}g=0;for(p=r.length;g<p;g++)if(r[g][0]){q="";u=!1;j=0;for(n=r[g].length;j<n;j++)"type"===d[r[g][j][0]]&&(q="espacio='"+this.spaceID+"' ",u=!0),q=q+r[g][j][0]+"='"+r[g][j][1]+"' ";r[g]=q;u?this.graphics.push(h.parseGraphic(r[g],this.abs_coord,this.background,this.inirot)):h.parseAuxiliar(r[g])}}}};a.extend(a.Macro,a.Graphic);a.Macro.prototype.update=function(){h=this.evaluator.evalExpression(this.inipos);
this.iniPosX=h[0][0];this.iniPosY=h[0][1]};a.Macro.prototype.drawAux=function(a){for(var c=0,d=this.graphics.length;c<d;c++)this.graphics[c]&&(this.graphics[c].abs_coord?a.translate(this.iniPosX,this.iniPosY):a.translate(this.iniPosX*this.space.scale,-this.iniPosY*this.space.scale),this.graphics[c].draw(),a.setTransform(1,0,0,1,0,0))};return a}(descartesJS||{},babel),descartesJS=function(a){if(a.loadLib)return a;var d=Math.sqrt,e=Math.sin,h=Math.cos,b,c,l,f,g,r,n,j,p,q,u,k,s,m,t;a.norm3D=function(a){return d(a.x*
a.x+a.y*a.y+a.z*a.z)};a.normalize3D=function(c){b=a.norm3D(c);if(0===b)return{x:0,y:0,z:0};if(1===b)return{x:c.x,y:c.y,z:c.z};b=1/b;return{x:c.x*b,y:c.y*b,z:c.z*b}};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,c){return Math.abs(a.x-b.x)<=c&&Math.abs(a.y-b.y)<=c&&Math.abs(a.z-b.z)<=c};a.Vector4D=function(a,b,c,f){this.x=a||0;this.y=b||0;this.z=c||0;this.w=f||0};a.Matrix4x4=function(a,b,c,f,d,g,m,h,j,e,l,k,r,n,p,q){this.a00=a||0;this.a01=b||0;this.a02=c||0;this.a03=f||0;this.a10=d||0;this.a11=g||0;this.a12=m||0;this.a13=h||0;this.a20=j||0;this.a21=e||0;this.a22=l||0;this.a23=k||0;this.a30=r||0;this.a31=n||0;this.a32=p||0;this.a33=q||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=e(b);l=h(b);j=this.a10;p=this.a11;q=this.a12;u=this.a13;k=this.a20;s=this.a21;m=this.a22;t=this.a23;return new a.Matrix4x4(this.a00,this.a01,this.a02,this.a03,j*l+k*
c,p*l+s*c,q*l+m*c,u*l+t*c,j*-c+k*l,p*-c+s*l,q*-c+m*l,u*-c+t*l,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateY=function(b){c=e(b);l=h(b);f=this.a00;g=this.a01;r=this.a02;n=this.a03;k=this.a20;s=this.a21;m=this.a22;t=this.a23;return new a.Matrix4x4(f*l+k*-c,g*l+s*-c,r*l+m*-c,n*l+t*-c,this.a10,this.a11,this.a12,this.a13,f*c+k*l,g*c+s*l,r*c+m*l,n*c+t*l,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateZ=function(b){c=e(b);l=h(b);f=this.a00;g=this.a01;r=this.a02;n=this.a03;
j=this.a10;p=this.a11;q=this.a12;u=this.a13;return new a.Matrix4x4(f*l+j*c,g*l+p*c,r*l+q*c,n*l+u*c,f*-c+j*l,g*-c+p*l,r*-c+q*l,n*-c+u*l,this.a20,this.a21,this.a22,this.a23,this.a30,this.a31,this.a32,this.a33)};return a}(descartesJS||{}),descartesJS=function(a){function d(a){a.lineWidth=1;a.fillStyle=this.backColor.getColor();a.strokeStyle=this.frontColor.getColor();a.beginPath();a.arc(this.newV[0].x,this.newV[0].y,this.size+0.5,0,l);a.fill();a.stroke()}function e(a,b){a.lineCap=f;a.lineJoin=g;this.frontColor.getColor();
this.backColor.getColor();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.getColor():this.frontColor.getColor(),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.fill()):"wire"===this.model&&
(a.lineWidth=1.25,a.strokeStyle=this.frontColor.getColor(),a.stroke());this.edges&&"wire"!==this.model&&(a.lineWidth=1,a.strokeStyle="#808080",a.stroke())}function h(a){u=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.getColor(),this.font,"left","alphabetic",this.decimals,this.fixed,!0);this.evaluator.setVariable(this.family,u)}function b(a){a.lineCap=f;a.lineJoin=
g;a.lineWidth=this.lineWidth;a.strokeStyle=this.frontColor.getColor();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(b,c,f){r=a.subtract3D(b,c);n=a.subtract3D(b,f);return a.normalize3D(a.crossProduct3D(r,n))}if(a.loadLib)return a;var l=2*Math.PI,f="round",g="round",r,n,j,p,q,u;a.Primitive3D=function(a,f){this.space=f;for(var g in a)a.hasOwnProperty(g)&&(this[g]=a[g]);this.newV=[];this.spaceVertices=[];"vertex"===this.type?this.draw=
d:"face"===this.type?(this.normal=c(this.vertices[0],this.vertices[1],this.vertices[2]),this.draw=e):"text"===this.type?(this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseInt(this.fontSize[1]):10,this.draw=h):"edge"===this.type&&(this.draw=b);this.isText&&(this.computeDepth=function(){this.newV=this.vertices;this.depth=this.vertices[0].z;this.average=this.vertices[0]})};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 f=0,d=this.vertices.length;f<d;f++)this.newV[f]=b.rotateVertex(this.vertices[f]),this.spaceVertices[f]=b.rotateVertex(this.vertices[f]),this.average.x+=this.newV[f].x,this.average.y+=this.newV[f].y,this.average.z+=this.newV[f].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)));f=0;for(d=this.vertices.length;f<d;f++)this.newV[f]=b.project(this.newV[f])};var k;a.Primitive3D.prototype.removeDoubles=function(){k=[];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)&&k.push(this.vertices[a]);0===k.length&&k.push(this.vertices[0]);this.vertices=k};a.Primitive3D.prototype.drawText=
function(b,c,f,d,g,h,e,l,k,r,n){if("rtfNode"==c.type)b.fillStyle=g,b.strokeStyle=g,b.textBaseline="alphabetic",c.draw(b,f,d,k,r,e,n);else{"simpleText"===c.type&&(c=c.toString(k,r).split("\\n"));f+=h.match("Arial")?-2:h.match("Times")?-2:0;j=this.evaluator;b.fillStyle=a.getColor(j,g);b.font=h;b.textAlign=e;b.textBaseline=l;p=1.2*this.fontSize||0;g=0;for(h=c.length;g<h;g++)q=c[g],this.border&&b.strokeText(q,f,d+p*g),b.fillText(q,f,d+p*g)}};a.Primitive3D.prototype.splitFace=function(b){if(this.intersects(b)){for(var c=
null,f=null,d=0,g=0,h=0,j=b.vertices.length;h<j;h++){var e=this.intersection(b.vertices[h],b.vertices[(h+1)%j]);if(null!==e)if(null===c){if(c=e,d=h,2===b.vertices.length){f=c;break}}else if(!a.equals3DEpsilon(e,c,1E-8)){f=e;g=h;break}}if(null!==c&&null!==f){var h=this.isInterior(c)||this.isInterior(f),l=null,k=null;if(!h&&3<=b.vertices.length)for(var j=0,r=this.vertices.length;j<r;j++)if(e=b.intersection(this.vertices[j],this.vertices[(j+1)%r]),null!==e)if(null===l)l=e;else if(!a.equals3DEpsilon(e,
l,1E-8)){k=e;break}if(h||null!==l&&null!==k&&b.isInterior(l)&&b.isInterior(k)){k=!0;r=b.vertices;l=e=null;if(2===r.length)a.equals(c,r[0],1E-8)||a.equals(c,r[1],1E-8)?k=!1:(e=[],e[0]=r[0],e[1]=c,l=[],l[0]=c,l[1]=r[1]);else for(var e=[],l=[],n=0,h=j=0;h<r.length;h++)h<d?e[n++]=r[h]:h==d?(e[n++]=r[h],e[n++]=c,l[j++]=c):h<g?l[j++]=r[h]:h==g?(l[j++]=r[h],l[j++]=f,e[n++]=f):e[n++]=r[h];if(k)return c=[],c[0]=new a.Primitive3D({vertices:e,type:"face",frontColor:b.frontColor,backColor:b.backColor,edges:b.edges,
model:b.model},this.space),c[0].normal=b.normal,c[1]=new a.Primitive3D({vertices:l,type:"face",frontColor:b.frontColor,backColor:b.backColor,edges:b.edges,model:b.model},this.space),c[1].normal=b.normal,c}}}return[b]};a.Primitive3D.prototype.intersects=function(a){return this.intersectsPlane(a)&&a.intersectsPlane(this)};a.Primitive3D.prototype.intersectsPlane=function(b){var c=a.dotProduct3D(b.vertices[0],b.normal),f=a.dotProduct3D(this.vertices[0],b.normal);if(1E-8>Math.abs(c-f))return!0;for(var d=
1,g=this.vertices.length;d<g;d++){var h=a.dotProduct3D(this.vertices[d],b.normal);if(1E-8>Math.abs(c-h)||h>c&&f<c||h<c&&f>c)return!0}return!1};a.Primitive3D.prototype.intersection=function(b,c){if(0<this.vertices.length){var f=a.subtract3D(c,b),d=a.dotProduct3D(f,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(f,d))}return null};a.Primitive3D.prototype.isInterior=function(b){if(0<this.vertices.length)for(var c=
0,f=a.subtract3D(this.vertices[0],b),d=0,g=this.vertices.length;d<g;d++){var h=a.subtract3D(this.vertices[(d+1)%g],b),e=a.dotProduct3D(a.crossProduct3D(f,h),this.normal);if(1E-8>Math.abs(e)){if(0>a.dotProduct3D(f,h))break}else{if(0>c&&0<e||0<c&&0>e)return!1;f=h;c=e}}return!0};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d={x:0,y:0,z:0},e,h,b,c,l,f,g,r;a.Graphic3D=function(b,c){this.parent=b;this.evaluator=b.evaluator;var f=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=f.parse("1");this.abs_coord=!1;this.family="";this.family_interval=f.parse("[0,1]");this.family_steps=f.parse("8");this.font="Monospaced,PLAIN,12";this.fixed=!0;this.text="";this.decimals=f.parse("2");this.inirot="(0,0,0)";this.inirotEuler=!1;this.inipos=f.parse("(0,0,0)");this.endrot="(0,0,0)";this.endrotEuler=!1;this.endpos=
f.parse("(0,0,0)");this.model="color";for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);void 0==this.expresion&&"macro"!=this.type&&(this.expresion=f.parse("(0,0)"));this.space=this.getSpace();this.canvas=this.background?this.space.backgroundCanvas:this.space.canvas;this.ctx=this.canvas.getContext("2d");this.font=a.convertFont(this.font);this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseInt(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=f.parse(this.inirot);this.endrot=f.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,f=a.length;c<f;c++)if(b=a[c],b.id==this.spaceID)return b;return a[0]};a.Graphic3D.prototype.getFamilyValues=function(){e=this.evaluator;h=e.evalExpression(this.family_interval);this.familyInf=h[0][0];this.familySup=h[0][1];this.fSteps=Math.round(e.evalExpression(this.family_steps));this.family_sep=0<this.fSteps?(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic3D.prototype.buildFamilyPrimitives=function(){e=this.evaluator;this.getFamilyValues();
b=e.getVariable(this.family);if(0<=this.fSteps)for(var a=0,c=this.fSteps;a<=c;a++)e.setVariable(this.family,this.familyInf+a*this.family_sep),this.familyValue=this.familyInf+a*this.family_sep,e.evalExpression(this.drawif)&&this.buildPrimitives();e.setVariable(this.family,b)};a.Graphic3D.prototype.update=function(){this.primitives=[];this.evaluator.evalExpression(this.drawif)&&(this.family?this.buildFamilyPrimitives():this.buildPrimitives())};a.Graphic3D.prototype.updateMVMatrix=function(){l=this.evaluator.evalExpression(this.inirot);
this.inirotEuler?(this.inirotM=this.inirotM.setIdentity(),this.inirotM=this.inirotM.rotateZ(a.degToRad(l[0][0])),this.inirotM=this.inirotM.rotateX(a.degToRad(l[0][1])),this.inirotM=this.inirotM.rotateZ(a.degToRad(l[0][2]))):(this.inirotM_X=this.inirotM_X.setIdentity().rotateX(a.degToRad(l[0][0])),this.inirotM_Y=this.inirotM_Y.setIdentity().rotateY(a.degToRad(l[0][1])),this.inirotM_Z=this.inirotM_Z.setIdentity().rotateZ(a.degToRad(l[0][2])));l=this.evaluator.evalExpression(this.inipos);d={x:l[0][0],
y:l[0][1],z:l[0][2]};this.iniposM=this.iniposM.setIdentity().translate(d);l=this.evaluator.evalExpression(this.endrot);this.endrotEuler?(this.endrotM=this.endrotM.setIdentity(),this.endrotM=this.endrotM.rotateZ(a.degToRad(l[0][0])),this.endrotM=this.endrotM.rotateX(a.degToRad(l[0][1])),this.endrotM=this.endrotM.rotateZ(a.degToRad(l[0][2]))):(this.endrotM_X=this.endrotM_X.setIdentity().rotateX(a.degToRad(l[0][0])),this.endrotM_Y=this.endrotM_Y.setIdentity().rotateY(a.degToRad(l[0][1])),this.endrotM_Z=
this.endrotM_Z.setIdentity().rotateZ(a.degToRad(l[0][2])));l=this.evaluator.evalExpression(this.endpos);d={x:l[0][0],y:l[0][1],z:l[0][2]};this.endposM=this.endposM.setIdentity().translate(d)};a.Graphic3D.prototype.transformVertex=function(a){this.macroChildren&&(a=this.applyMacroTransform(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));return c=this.endposM.multiplyVector4(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(){l=this.expresion.split("=");f=l[0];g=[];for(var a=1;a<l.length;a++)f+="=",r=l[a].lastIndexOf(" "),f+=-1!==r?l[a].substring(0,r):l[a],g.push(this.evaluator.parser.parse(f,!0)),f=l[a].substring(r+1);return g};var n;a.Graphic3D.prototype.splitFace=function(a){for(var b=0,c=this.primitives.length;b<
c;b++)if(n=[],"face"===this.primitives[b].type){for(var f=0,d=a.primitives.length;f<d;f++)"face"===a.primitives[f].type?n=n.concat(this.primitives[b].splitFace(a.primitives[f])):n.push(a.primitives[f]);a.primitives=n}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,e,h,b,c;a.Point3D=function(b,c){a.Graphic3D.call(this,b,c)};a.extend(a.Point3D,a.Graphic3D);a.Point3D.prototype.buildPrimitives=function(){d=this.evaluator;this.updateMVMatrix();e=d.evalExpression(this.expresion);
h=e[0][0];b=e[0][1];c=e[0][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(h,b,c,1))],type:"vertex",backColor:this.backcolor,frontColor:this.color,size:d.evalExpression(this.width)}));""!==this.text&&this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(h,b,c,1))],type:"text",frontColor:this.color,font:this.font,decimals:d.evalExpression(this.decimals),fixed:this.fixed,displace:this.fontSize,evaluator:d,text:this.text,family:this.family,
familyValue:this.familyValue},this.space))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,e,h,b,c,l;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();expr=evaluator.evalExpression(this.expresion);d=expr[0][0];e=expr[0][1];h=expr[0][2];b=expr[1][0];c=expr[1][1];l=expr[1][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(d,
e,h,1)),this.transformVertex(new a.Vector4D(b,c,l,1))],type:"edge",frontColor:this.color,lineWidth:evaluator.evalExpression(this.width)},this.space))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,e,h,b,c,l,f;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(){d=this.evaluator;this.updateMVMatrix();h=d.getVariable("x");h=d.getVariable("y");h=d.getVariable("z");e=d.getVariable("u");h=d.getVariable("v");d.setVariable("u",0);d.setVariable("v",0);b=d.evalExpression(this.Nu);c=d.evalExpression(this.Nv);l=[];for(var g=0;g<=b;g++){d.setVariable("u",g/b);for(var r=0;r<=c;r++){d.setVariable("v",r/c);for(var n=0,j=this.expresion.length;n<j;n++)d.evalExpression(this.expresion[n]);l.push(this.transformVertex(new a.Vector4D(d.getVariable("x"),d.getVariable("y"),
d.getVariable("z"),1)))}}for(g=0;g<b;g++)for(r=0;r<c;r++)f=[],f.push(l[r+g*c+g]),f.push(l[r+1+g*c+g]),f.push(l[r+2+(g+1)*c+g]),f.push(l[r+1+(g+1)*c+g]),this.primitives.push(new a.Primitive3D({vertices:f,type:"face",frontColor:this.color,backColor:this.backcolor,edges:this.edges,model:this.model},this.space));d.setVariable("x",void 0);d.setVariable("y",void 0);d.setVariable("z",void 0);d.setVariable("u",e);d.setVariable("v",h)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var d,e,h,b,c,l;a.Polygon3D=function(b,c){this.width=b.evaluator.parser.parse("1");a.Graphic3D.call(this,b,c)};a.extend(a.Polygon3D,a.Graphic3D);a.Polygon3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);for(var f=0,g=expr.length-1;f<g;f++)d=expr[f][0],e=expr[f][1],h=expr[f][2],b=expr[f+1][0],c=expr[f+1][1],l=expr[f+1][2],this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(d,e,h,1)),
this.transformVertex(new a.Vector4D(b,c,l,1))],type:"edge",frontColor:this.color,lineWidth:evaluator.evalExpression(this.width)},this.space))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,e,h,b,c,l;a.Curve3D=function(b,c){this.width=b.evaluator.parser.parse("1");a.Graphic3D.call(this,b,c);this.expresion=this.parseExpression()};a.extend(a.Curve3D,a.Graphic3D);a.Curve3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();b=evaluator.getVariable("x");
c=evaluator.getVariable("y");l=evaluator.getVariable("z");h=evaluator.getVariable("u");evaluator.setVariable("u",0);e=evaluator.evalExpression(this.Nu);d=[];for(var f=0;f<=e;f++){evaluator.setVariable("u",f/e);for(var g=0,r=this.expresion.length;g<r;g++)evaluator.evalExpression(this.expresion[g]);d.push(this.transformVertex(new a.Vector4D(evaluator.getVariable("x"),evaluator.getVariable("y"),evaluator.getVariable("z"),1)))}f=0;for(g=d.length-1;f<g;f++)this.primitives.push(new a.Primitive3D({vertices:[d[f],
d[f+1]],type:"edge",frontColor:this.color,lineWidth:evaluator.evalExpression(this.width)},this.space));evaluator.setVariable("x",b);evaluator.setVariable("y",l);evaluator.setVariable("z",c);evaluator.setVariable("u",h)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,e,h,b,c,l,f,g,r;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.evalExpression(this.expresion);d=expr[0][0];e=expr[0][1];h=expr[0][2];b=expr[1][0];c=expr[1][1];l=expr[1][2];f=expr[2][0];g=expr[2][1];r=expr[2][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(d,e,h,1)),this.transformVertex(new a.Vector4D(f,g,r,1)),this.transformVertex(new a.Vector4D(b,c,l,1))],type:"face",frontColor:this.color,backColor:this.backcolor,edges:this.edges,model:this.model},this.space))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var d;a.Face3D=function(d,h){a.Graphic3D.call(this,d,h)};a.extend(a.Face3D,a.Graphic3D);a.Face3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);d=[];for(var e=expr.length-1;0<=e;e--)d.push(this.transformVertex(new a.Vector4D(expr[e][0],expr[e][1],expr[e][2],1)));this.primitives.push(new a.Primitive3D({vertices:d,type:"face",frontColor:this.color,backColor:this.backcolor,edges:this.edges,model:this.model},this.space))};
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,e,h,b,c;a.Polireg3D=function(b,c){this.width=b.evaluator.parser.parse("2");this.length=b.evaluator.parser.parse("2");a.Graphic3D.call(this,b,c)};a.extend(a.Polireg3D,a.Graphic3D);a.Polireg3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();d=evaluator.evalExpression(this.Nu);e=[this.transformVertex(new a.Vector4D(0,0,0,1))];h=evaluator.evalExpression(this.width)/2;b=evaluator.evalExpression(this.length)/
2;c=2*Math.PI/d;for(var l=0;l<d;l++)e.push(this.transformVertex(new a.Vector4D(h*Math.cos(c*l),b*Math.sin(c*l),0,1)));for(l=0;l<d;l++)this.primitives.push(new a.Primitive3D({vertices:[e[0],l+2<=d?e[l+2]:e[1],e[l+1]],type:"face",frontColor:this.color,backColor:this.backcolor,edges:this.edges,model:this.model},this.space))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,e,h,b;a.Text3D=function(b,d){a.Graphic3D.call(this,b,d)};a.extend(a.Text3D,a.Graphic3D);a.Text3D.prototype.buildPrimitives=
function(){d=this.evaluator;e=d.evalExpression(this.expresion);h=e[0][0];b=e[0][1];this.primitives.push(new a.Primitive3D({vertices:[new a.Vector4D(h,b,0,1)],type:"text",frontColor:this.color,font:this.font,decimals:d.evalExpression(this.decimals),fixed:this.fixed,displace:0,isText:!0,evaluator:d,text:this.text,family:this.family,familyValue:this.familyValue,joel:"hola"},this.space))};return a}(descartesJS||{}),descartesJS=function(a,d){if(a.loadLib)return a;var e=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg)/gi,
h,b;a.Macro3D=function(b,h){this.expresion=void 0;this.inirot="(0,0,0)";this.inirotEuler=!1;this.inipos=b.evaluator.parser.parse("(0,0,0)");this.endrot="(0,0,0)";this.endrotEuler=!1;this.endpos=b.evaluator.parser.parse("(0,0,0)");a.Graphic.call(this,b,h);for(var f in h)h.hasOwnProperty(f)&&(this[f]=h[f]);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=[];f=b.lessonParser;var g=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 r=this.evaluator.evalExpression(this.expresion),n;r&&((n=document.getElementById(r))&&"descartes/macro"==n.type?n=n.text:(n=a.openExternalFile(r))&&!n.match(/tipo_de_macro/g)&&(n=null));var j,p;if(n){p=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 r=0,q=p.length;r<q;r++)j=p[r].indexOf("="),-1!==j&&(j=p[r].substring(0,j),("id"===d[j]||"type"===d[j])&&n.push(f.split(p[r])));for(var u,k,s,m,r=0,q=n.length;r<q;r++){m=(u=n[r]||[])&&u[0]&&"id"===u[0][0];p=0;for(j=u.length;p<j;p++)if(k=
u[p][0].indexOf("."),-1!==k&&!m?(k=d[u[p][0].substring(k+1)],u[p][0]=this.name+"."+u[p][0]):k=d[u[p][0]],!("font"===k||("fill"===k||"color"===k||"arrow"===k)&&"("!==u[p][1].charAt(0)||"file"===k&&u[p][1].match(e)||"id"!==k&&void 0!==d[u[p][1]])||!("width"!==k&&"height"!==k&&"length"!==k))if("text"==k)if(u[p][1].match(/\{\\rtf1/)){k=u[p][1];var t=this;s=function(a,b){for(var c=g.tokenize(b.replace(/\&squot;/g,"'")),f=0,d=c.length;f<d;f++)"identifier"==c[f].type&&!"-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-".match("-"+
c[f].value+"-")&&(c[f].value=t.name+"."+c[f].value);return(a.match(/^\\expr/)?"\\expr ":"\\decimals ")+g.flatTokens(c)};k=k.replace(/\\expr ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,s);k=k.replace(/\\decimals ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,s);u[p][1]=k}else{s=f.parseText(u[p][1]).textElementsMacro3Ds;for(var v=0,y=s.length;v<y;v++){k=g.tokenize(s[v].replace(/\&squot;/g,"'"));for(var B=0,z=k.length;B<z;B++)"identifier"===k[B].type&&!"-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-".match("-"+
k[B].value+"-")&&(k[B].value=this.name+"."+k[B].value);k=g.flatTokens(k).replace(/&squot;/g,"'").replace(/'\+\(/g,"[").replace(/\)\+'/g,"]");s[v]=k.substring(1,k.length-1)}u[p][1]=s.join("")}else{k=g.tokenize(u[p][1]);s=0;for(v=k.length;s<v;s++)"identifier"===k[s].type&&!"-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-".match("-"+k[s].value+"-")&&(k[s].value=this.name+"."+k[s].value);u[p][1]=g.flatTokens(k)}}r=
0;for(q=n.length;r<q;r++)if(n[r][0]){u="";m=!1;p=0;for(j=n[r].length;p<j;p++)"type"===d[n[r][p][0]]&&(u="espacio='"+this.spaceID+"' ",m=!0),u=u+n[r][p][0]+"='"+n[r][p][1]+"' ";n[r]=u;m?this.graphics.push(f.parse3DGraphic(n[r],this.abs_coord,this.background,this.inirot)):f.parseAuxiliar(n[r])}}r=0;for(q=this.graphics.length;r<q;r++)this.graphics[r].macroChildren=!0}};a.extend(a.Macro3D,a.Graphic);a.Macro3D.prototype.update=function(){this.updateTransformation();if(this.inipos){var a=this.evaluator.evalExpression(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++)h=this.graphics[a],h.macro_inirotEuler=this.inirotEuler,h.macro_inirotM=this.inirotM,h.macro_inirotM_X=this.inirotM_X,h.macro_inirotM_Y=this.inirotM_Y,h.macro_inirotM_Z=this.inirotM_Z,h.macro_iniposM=this.iniposM,h.macro_endrotEuler=this.endrotEuler,h.macro_endrotM=this.endrotM,h.macro_endrotM_X=this.endrotM_X,h.macro_endrotM_Y=this.endrotM_Y,h.macro_endrotM_Z=this.endrotM_Z,h.macro_endposM=this.endposM,
h.update();a=0;for(d=this.graphics.length;a<d;a++){h=this.graphics[a];if(h.split||this.split)for(var f=a+1;f<d;f++)b=this.graphics[f],(b.split||this.split)&&h.splitFace(b);this.primitives=this.primitives.concat(h.primitives||[])}};a.Macro3D.prototype.updateTransformation=function(){tmpExpr=this.evaluator.evalExpression(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.evalExpression(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.evalExpression(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.evalExpression(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(){};return a}(descartesJS||{},babel),descartesJS=function(a){function d(a,b,c,f,d){e.call(this,a/1.8,a/1.8,a/1.8,f,d)}function e(a,b,c,f,d){a/=2;b/=2;c/=2;this.changeGeometry(a,b,c,f,d)||(this.vertices=[new k(a,c,b,1),new k(a,-c,b,1),new k(a,c,-b,1),new k(a,-c,-b,1),new k(-a,c,b,1),new k(-a,-c,b,1),new k(-a,c,-b,1),new k(-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,f,d))}function h(a,b,c,f,d){a/=2;this.changeGeometry(a,b,c,f,d)||(this.vertices=[new k(0,0,a,1),new k(-0.49*a,-0.86*a,-0.32*a,1),new k(-0.49*a,0.86*a,-0.32*a,1),new k(1*a,0,-0.32*a,1)],this.faces=[[3,2,1],[1,2,0],[2,3,0],[3,1,0]],this.updateValues(a,b,c,f,d))}function b(a,b,c,f,d){a/=2;this.changeGeometry(a,b,c,f,d)||(this.vertices=[new k(0,0,a,1),new k(a,0,0,1),new k(-a,0,0,1),new k(0,a,0,1),new k(0,-a,0,1),new k(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,f,d))}function c(b,c,f,d,g){b/=3.4;if(!this.changeGeometry(b,c,f,d,g)){E=b/D;A=b*D;this.vertices=[new k(b,b,b,1),new k(b,b,-b,1),new k(b,-b,b,1),new k(b,-b,-b,1),new k(-b,b,b,1),new k(-b,b,-b,1),new k(-b,-b,b,1),new k(-b,-b,-b,1),new k(0,E,A,1),new k(0,E,-A,1),new k(0,-E,A,1),new k(0,-E,-A,1),new k(E,A,0,1),new k(E,-A,0,1),new k(-E,A,0,1),new k(-E,-A,0,1),new k(A,0,E,1),new k(A,0,-E,1),new k(-A,
0,E,1),new k(-A,0,-E,1)];x=(new a.Matrix4x4).setIdentity().rotateY(-q/6);for(var h=0,e=this.vertices.length;h<e;h++)this.vertices[h]=x.multiplyVector4(this.vertices[h]);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,f,d,g)}}function l(b,c,f,d,g){b/=4;if(!this.changeGeometry(b,c,f,d,g)){A=b*D;this.vertices=[new k(0,b,A,1),new k(0,b,-A,1),
new k(0,-b,A,1),new k(0,-b,-A,1),new k(b,A,0,1),new k(b,-A,0,1),new k(-b,A,0,1),new k(-b,-A,0,1),new k(A,0,b,1),new k(A,0,-b,1),new k(-A,0,b,1),new k(-A,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]];x=(new a.Matrix4x4).setIdentity().rotateY(-1.029);for(var h=0,e=this.vertices.length;h<e;h++)this.vertices[h]=x.multiplyVector4(this.vertices[h]);this.updateValues(b,
c,f,d,g)}}function f(a,b,c,f,d){a/=2;this.isSphere?c=b=a:(b/=2,c/=2);if(!this.changeGeometry(a,b,c,f,d)){this.vertices=[new k(0,0,b,1)];for(var g=1;g<f;g++){z=g*q/f;for(var h=0;h<d;h++)B=h*u/d,t=a*j(z)*p(B),v=c*j(z)*j(B),y=b*p(z),this.vertices.push(new k(t,v,y,1))}this.vertices.push(new k(0,0,-b,1));this.faces=[];for(g=0;g<d;g++)this.faces.push([0,(g+1)%d+1,g%d+1]);for(g=1;g<f-1;g++)for(h=0;h<d;h++)this.faces.push([h+1+(g-1)*d,(h+1)%d+1+(g-1)*d,(h+1)%d+1+g*d,h+1+g*d]);for(g=0;g<d;g++)this.faces.push([this.vertices.length-
1,this.vertices.length-1-d+g,this.vertices.length-1-d+(g+1)%d]);this.updateValues(a,b,c,f,d)}}function g(a,b,c,f,d){a/=2;b/=2;c/=2;if(!this.changeGeometry(a,b,c,f,d)){this.vertices=[];for(var g=0;g<d;g++)for(var h=0;h<f;h++)t=a*(d-g)/d*p(h*u/f),v=c*(d-g)/d*j(h*u/f),y=b-2*g*b/d,this.vertices.push(new k(t,v,y,1));this.vertices.push(new k(0,0,-b,1));this.faces=[];for(g=0;g<d-1;g++)for(h=0;h<f;h++)this.faces.push([h+g*f,(h+1)%f+g*f,(h+1)%f+(g+1)*f,h+(g+1)*f]);for(g=0;g<f;g++)this.faces.push([this.vertices.length-
1,this.vertices.length-1-f+g,this.vertices.length-1-f+(g+1)%f]);this.updateValues(a,b,c,f,d)}}function r(a,b,c,f,d){a/=2;b/=2;c/=2;if(!this.changeGeometry(a,b,c,f,d)){this.vertices=[];for(var g=0;g<d+1;g++)for(var h=0;h<f;h++)t=a*p(h*u/f),v=c*j(h*u/f),y=b-2*g*b/d,this.vertices.push(new k(t,v,y,1));this.faces=[];for(g=0;g<d;g++)for(h=0;h<f;h++)this.faces.push([h+g*f,(h+1)%f+g*f,(h+1)%f+(g+1)*f,h+(g+1)*f]);this.updateValues(a,b,c,f,d)}}function n(){function a(b){return parseInt(b)}function b(a){return parseFloat(a)}
this.vertices=[];this.faces=[];for(var c=0,f=this.fileData.length;c<f;c++)F=this.fileData[c],F.match(/^V\(/)?(G=F.substring(2,F.length-1).split(",").map(b),this.vertices.push(new k(G[0]||0,G[1]||0,G[2]||0,1))):F.match(/^F\(/)&&(G=F.substring(2,F.length-1).split(",").map(a),this.faces.push(G.reverse()))}if(a.loadLib)return a;var j=Math.sin,p=Math.cos,q=Math.PI,u=2*q,k,s,m,t,v,y,B,z,D=1.6180339887,E,A,x,F,G;a.OtherGeometry=function(m,j){this.width=m.evaluator.parser.parse("2");this.height=m.evaluator.parser.parse("2");
this.length=m.evaluator.parser.parse("2");k=a.Vector4D;a.Graphic3D.call(this,m,j);switch(this.type){case "cube":this.buildGeometry=d;break;case "box":this.buildGeometry=e;break;case "tetrahedron":this.buildGeometry=h;break;case "octahedron":this.buildGeometry=b;break;case "sphere":this.isSphere=!0;case "ellipsoid":this.buildGeometry=f;break;case "dodecahedron":this.buildGeometry=c;break;case "icosahedron":this.buildGeometry=l;break;case "cone":this.buildGeometry=g;break;case "cylinder":this.buildGeometry=
r;break;case "mesh":this.fileData=a.openExternalFile(this.evaluator.evalExpression(this.file)).split(/\r/),this.buildGeometry=n}};a.extend(a.OtherGeometry,a.Graphic3D);a.OtherGeometry.prototype.buildPrimitives=function(){s=this.evaluator;this.updateMVMatrix();this.buildGeometry(s.evalExpression(this.width),s.evalExpression(this.height),s.evalExpression(this.length),s.evalExpression(this.Nu),s.evalExpression(this.Nv));for(var b=0,c=this.faces.length;b<c;b++){m=[];for(var f=0,d=this.faces[b].length;f<
d;f++)m.push(this.transformVertex(this.vertices[this.faces[b][f]]));this.primitives.push(new a.Primitive3D({vertices:m,type:"face",frontColor:this.color,backColor:this.backcolor,edges:this.edges,model:this.model},this.space))}};a.OtherGeometry.prototype.changeGeometry=function(a,b,c,f,d){return this.oldWidth===a&&this.oldHeight===b&&this.oldLength===c&&this.oldNu===f&&this.oldNv===d};a.OtherGeometry.prototype.updateValues=function(a,b,c,f,d){this.oldWidth=a;this.oldHeight=b;this.oldLength=c;this.oldNv=
d;this.oldNu=f};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.max,e=Math.min,h=Math.PI,b=Math.cos,c=Math.sin,l=Math.abs,f,g,r,n,j,p,q,u,k,s,m,t,v,y,B,z,D,E;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};a.R2.prototype.copy=function(){return new a.R2(this.x,this.y)};a.R2.prototype.ix=function(){return Math.round(d(e(this.x,32E3),-32E3))};a.R2.prototype.iy=function(){return Math.round(d(e(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){g=this.copy();g.sub(a);return g.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(){f=this.norm();0!=f&&this.div(f)};a.R2.prototype.rotR90=function(){f=this.x;this.x=this.y;this.y=-f};a.R2.prototype.rotL90=function(){f=this.x;this.x=-this.y;this.y=f};a.R2.prototype.rot=function(a){r=this.copy();p=b(a);q=c(a);this.x=r.x*p-r.y*q;this.y=r.x*q+r.y*p};a.R2.prototype.rot=function(a){this.rot(a*h/180)};a.R2.prototype.intersection=function(b,c,f,g){u=c.x-b.x;k=
f.x-g.x;s=f.x-b.x;m=c.y-b.y;t=f.y-g.y;v=f.y-b.y;E=u*t-k*m;return 1E-6<l(E)?(n=(s*t-v*k)/E,j=(-s*m+v*u)/E,0<=n&&1>=n&&0<=j&&1>=j?new a.R2(b.x+u*n,b.y+m*n):null):(c.x-f.x)*v!=(c.y-f.y)*s?null:b.x!=c.x?(y=e(b.x,c.x),B=d(b.x,c.x),y<=f.x&&f.x<=B?f:y<=g.x&&g.x<=B?g:null):f.x!=g.x?(z=e(f.x,g.x),D=d(f.x,g.x),z<=b.x&&b.x<=D?b:z<=c.x&&c.x<=D?c:null):b.y!=c.y?(y=e(b.y,c.y),B=d(b.y,c.y),y<=f.y&&f.y<=B?f:y<=g.y&&g.y<=B?g:null):f.y!=g.y?(z=e(f.y,g.y),D=d(f.y,g.y),z<=b.y&&b.y<=D?b:z<=c.y&&c.y<=D?c:null):b.x==f.x&&
b.y==f.y?b:null};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,e,h,b,c,l,f,g;a.R2Newton=function(b,c){this.evaluator=b;this.constraint=c;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];l=new a.R2(0,0)};a.R2Newton.prototype.getUnitNormal=function(){this.normal.normalize();return this.normal.copy()};a.R2Newton.prototype.gradient=function(a){d=this.evaluator;f=d.getVariable("x");g=d.getVariable("y");d.setVariable("x",a.x);d.setVariable("y",a.y);this.f0=d.evalExpression(this.constraint);d.setVariable("x",d.getVariable("x")+1E-12);e=d.evalExpression(this.constraint);l.x=(e-this.f0)/1E-12;l.x=!isNaN(l.x)?l.x:Infinity;d.setVariable("x",d.getVariable("x")-
1E-12);d.setVariable("y",d.getVariable("y")+1E-12);e=d.evalExpression(this.constraint);l.y=(e-this.f0)/1E-12;l.y=!isNaN(l.y)?l.y:Infinity;d.setVariable("x",f);d.setVariable("y",g);return l};a.R2Newton.prototype.findZero=function(a){d=this.evaluator;c=a.copy();f=d.getVariable("x");g=d.getVariable("y");d.setVariable("x",a.x);d.setVariable("y",a.y);this.f0=d.evalExpression(this.constraint);if("menor"===this.sign&&0>=this.f0||"mayor"===this.sign&&0<=this.f0)return c;d.setVariable("x",f);d.setVariable("y",
g);for(var e=0;256>e;e++)if(h=c.x,b=c.y,this.normal=this.gradient(c),0!=this.normal.norm2()&&this.normal.mul(-this.f0/this.normal.norm2()),c.x=h+this.normal.x,c.y=b+this.normal.y,1E-6>this.normal.norm()){0===this.normal.x&&0===this.normal.y&&(this.normal.x=c.x-a.x,this.normal.y=c.y-a.y);break}return c};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Vector2D=function(a,e){this.x=a;this.y=e};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 d=Math.floor,e=Math.round,h,b,c,l,f,g,r,n,j,p,q,u,k,s,m,t,v,y,B,z;a.Control=function(b,c){this.parent=b;this.evaluator=b.evaluator;var f=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=f.parse("(0,0,100,23)"):(this.expresion=f.parse("(0,0,300,200)"),this.w=300,this.h=200):this.expresion=f.parse("(0,0)");this.fixed=2!=this.parent.version?!1:!0;this.visible=!0;this.color=4>this.parent.version?new a.Color("000000"):new a.Color("222222");this.colorInt=
"graphic"!==c.type?new a.Color("f0f8ff"):new a.Color("cc0022");this.underlined=this.italics=this.bold="";this.font_size=4>this.parent.version?-1:f.parse("12");this.parameter=this.action="";this.parameterFont="Monospace 12px";this.drawif=f.parse("1");this.activeif=f.parse("1");this.tooltip="";this.tooltipFont="Monospace 12px";this.Explanation="";this.ExplanationFont="Monospace 12px";this.cID=this.msg_pos="";this.valueExpr=f.parse("0");this.decimals=f.parse("2");this.min=f.parse("-Infinity");this.max=
f.parse("Infinity");this.incr=f.parse("0.1");this.exponentialif=this.discrete=!1;this.zIndex=-1;for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);if(("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;f=this.evaluator.evalExpression(this.expresion);this.x=e(f[0][0]);this.y=e(f[0][1]);4==f[0].length&&(this.w=
e(f[0][2]),this.h=e(f[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,f=a.length;c<f;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.scenarioRegion.scenarioSpace.addCtr(this),this.zIndex=this.parent.scenarioRegion.scenarioSpace.zIndex,this.parent.scenarioRegion.scenarioSpace.numericalControlContainer):this.parent.externalSpace.container;if("north"===this.region)return this.parent.northSpace.controls.push(this),this.parent.northSpace.container;if("south"===this.region)return this.parent.southSpace.controls.push(this),
this.parent.southSpace.container;if("east"===this.region)return this.parent.eastSpace.controls.push(this),this.parent.eastSpace.container;if("west"===this.region)return this.parent.westSpace.controls.push(this),this.parent.westSpace.container;if("special"===this.region)return this.parent.specialSpace.controls.push(this),this.parent.specialSpace.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);b.childNodes[0]?b.insertBefore(a,b.childNodes[0]):b.appendChild(a)};a.Control.prototype.updatePositionAndSize=function(){c=l=f=g=!1;r=this.evaluator.evalExpression(this.expresion);n=e(r[0][0]);c=e(this.x)!==n;this.x=n;n=e(r[0][1]);l=e(this.y)!==n;this.y=n;4===r[0].length&&(n=e(r[0][2]),f=e(this.w)!==n,this.w=n,n=e(r[0][3]),g=e(this.h)!==n,this.h=n);if(f||g||c||l)this.init(),this.draw()};a.Control.prototype.formatOutputValue=function(a){k=
this.parent;j=a+"";p=this.evaluator.evalExpression(this.decimals);q=j.indexOf(".");-1!=q&&(u=j.substring(q+1),u.length>p&&(j=parseFloat(j).toFixed(p)));if(this.fixed&&(2!==k.version||2===k.version&&!this.exponentialif))j=parseFloat(a).toFixed(p);this.exponentialif&&0!=parseFloat(j)&&(j=this.fixed&&2!==k.version?parseFloat(j).toExponential(p):parseFloat(j).toExponential(),j=j.toUpperCase(),j=j.replace("+",""));return j=j.replace(".",k.decimal_symbol)};a.Control.prototype.updateAndExecAction=function(){this.parent.updateControls();
"init"===this.action&&(this.click=!1);this.actionExec.execute();"animate"!==this.action&&this.parent.update()};a.Control.prototype.createGradient=function(a,c){this.linearGradient=this.ctx.createLinearGradient(0,0,0,c);h=c*c;for(var f=0;f<c;f++)b=d(f-35*c/100),this.linearGradient.addColorStop(f/c,"rgba(0,0,0,"+192*b*b/h/255+")")};a.Control.prototype.getScreenshot=function(){t=this;s=document.createElement("canvas");s.setAttribute("width",t.w);s.setAttribute("height",t.h);m=s.getContext("2d");m.font=
t.fieldFontSize+"px Arial, Helvetica, 'Droid Sans', Sans-serif";t.canvas&&(v=t.canvas.offsetLeft,y=t.canvas.offsetTop,m.drawImage(t.canvas,v,y));t.label&&(v=t.label.offsetLeft,y=t.label.offsetTop,B=t.label.offsetWidth,z=t.label.offsetHeight,m.fillStyle="#e0e4e8",m.fillRect(v,y,B,z),m.fillStyle="black",m.textAlign="center",m.textBaseline="middle",m.fillText(t.name,v+B/2,y+z/2));t.field&&(v=t.field.offsetLeft,y=t.field.offsetTop,B=t.field.offsetWidth,z=t.field.offsetHeight,m.fillStyle="white",m.strokeStyle=
"#666666",m.lineWidth=1,m.fillRect(v,0,B,z),m.strokeRect(v+0.5,0.5,B-1,z-1),m.fillStyle="black",m.textAlign="center",m.textAlign="left",m.fillText(t.field.value,v+2,z/2));t.select&&(v=t.select.offsetLeft,y=t.select.offsetTop,B=t.select.offsetWidth,z=t.select.offsetHeight,m.fillStyle="#e0e4e8",m.strokeStyle="#666666",m.lineWidth=1,m.fillRect(v,0,B,z),m.strokeRect(v+0.5,0.5,B,z-1),m.fillStyle="black",m.textAlign="center",m.textAlign="left",m.fillText(t.select.value,v+2,z/2),m.fillStyle="#c0c0c0",m.fillRect(v+
B-15+0.5,0.5,15,z-1),m.strokeRect(v+B-15+0.5,0.5,15,z-1),m.fillStyle="black",m.beginPath(),m.moveTo(v+B-15+4.5,z/2-2.5),m.lineTo(v+B-15+8,z/2+2.5),m.lineTo(v+B-15+11.5,z/2-2.5),m.closePath(),m.fill());return s};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.floor,e,h,b,c,l,f,g,r,n,j,p,q,u=2E3;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);-1===this.font_size&&(this.fontSizeNotSet=
!0);this.name="["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.parser.parse(this.name.substring(1,this.name.length-1)):this.parser.parse("'"+this.name+"'");var f;this.imageSrc.match("_COLORES_")&&(f=this.imageSrc.split("_"),this.colorInt=new a.Color(f[2]),this.color=new a.Color(f[3]),this.font_size=this.parser.parse(f[5]),this.imageSrc="");this.imageSrc=this.parser.parse("'"+this.imageSrc+"'");f=this.evaluator.evalExpression(this.imageSrc).trim();if(""!=f){var d=f.substr(0,
f.lastIndexOf(".")),g=f.substr(f.lastIndexOf("."));f.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(f),this.imageOver=this.parent.getImage(d+"_over"+g),this.imageDown=this.parent.getImage(d+"_down"+g))}this.canvas=document.createElement("canvas");this.canvas.setAttribute("class","DescartesButton");
this.canvas.setAttribute("id",this.id);this.canvas.setAttribute("width",this.w+"px");this.canvas.setAttribute("height",this.h+"px");this.canvas.setAttribute("style","left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.ctx=this.canvas.getContext("2d");this.ctx.imageSmoothingEnabled=!1;this.ctx.mozImageSmoothingEnabled=!1;this.ctx.webkitImageSmoothingEnabled=!1;this.addControlContainer(this.canvas);this.registerMouseAndTouchEvents();this.init()};a.extend(a.Button,a.Control);a.Button.prototype.init=
function(){e=this.evaluator;h=this.canvas;c=e.evalExpression(this.expresion);this.x=c[0][0];this.y=c[0][1];4==c[0].length&&(this.w=parseInt(c[0][2]),this.h=parseInt(c[0][3]));h.setAttribute("width",this.w+"px");h.setAttribute("height",this.h+"px");h.setAttribute("style","left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+"; display: block; background-repeat: no-repeat;");this.fontSizeNotSet&&(this.font_size=e.parser.parse(a.getFieldFontSize(this.h)+""));this.createGradient(this.w,this.h);
h.style.display=0<e.evalExpression(this.drawif)?"block":"none"};a.Button.prototype.update=function(){e=this.evaluator;h=this.canvas;this.activeIfValue=0<e.evalExpression(this.activeif);(this.drawIfValue=0<e.evalExpression(this.drawif))?(h.style.display="block",this.draw()):(this.click=!1,h.style.display="none");this.canvas.style.cursor=this.activeIfValue?"pointer":"not-allowed";this.updatePositionAndSize()};a.Button.prototype.draw=function(){e=this.evaluator;b=this.ctx;l=e.evalExpression(this.font_size);
f=e.evalExpression(this.name);g=e.evalExpression(this.imageSrc);r="vacio.gif"===g?this.emptyImage:this.parent.getImage(g);b.clearRect(0,0,this.w,this.h);j=n=0;this.click&&(j=n=1);r&&r.ready?r!==this.emptyImage&&r.complete&&(this.canvas.style.backgroundImage="url("+this.image.src+")",this.canvas.style.backgroundPosition=parseInt((this.w-r.width)/2)+n+"px "+(parseInt((this.h-r.height)/2)+j)+"px"):(b.fillStyle=this.colorInt.getColor(),b.fillRect(0,0,this.w,this.h),this.click||(a.drawLine(b,this.w-1,
0,this.w-1,this.h,"rgba(0,0,0,"+128/255+")"),a.drawLine(b,0,0,0,this.h,"rgba(0,0,0,"+24/255+")"),a.drawLine(b,1,0,1,this.h,"rgba(0,0,0,"+8/255+")")),b.fillStyle=this.linearGradient,b.fillRect(0,0,this.w,this.h));this.activeIfValue&&(""!=this.imageOver.src&&this.imageOver.ready&&this.over)&&(this.canvas.style.backgroundImage="url("+this.imageOver.src+")",this.canvas.style.backgroundPosition=parseInt((this.w-r.width)/2)+n+"px "+(parseInt((this.h-r.height)/2)+j)+"px");this.activeIfValue&&""!=this.imageDown.src&&
this.imageDown.ready&&this.click?(this.canvas.style.backgroundImage="url("+this.imageDown.src+")",this.canvas.style.backgroundPosition=parseInt((this.w-r.width)/2)+n+"px "+(parseInt((this.h-r.height)/2)+j)+"px"):this.click&&!r&&(a.drawLine(b,0,0,0,this.h-2,"gray"),a.drawLine(b,0,0,this.w-1,0,"gray"),b.fillStyle="rgba(0, 0, 0,"+24/255+")",b.fillRect(0,0,this.w,this.h));b.fillStyle=this.color.getColor();b.font=this.italics+" "+this.bold+" "+l+"px Arial";b.textAlign="center";b.textBaseline="middle";
this.colorInt.getColor()!=this.color.getColor()&&(b.lineJoin="round",b.lineWidth=parseInt(l/6),b.strokeStyle=this.colorInt.getColor(),b.strokeText(f,d(this.w/2+n)+0.5,d(this.h/2+j)+0.5));b.fillText(f,d(this.w/2+n)+0.5,d(this.h/2+j)+0.5);this.underlined&&(p=b.measureText(f).width,b.strokeStyle=this.color.getColor(),b.lineWidth=d(l/10)||2,b.lineCap="round",b.beginPath(),b.moveTo(parseInt((this.w-p)/2)+n,d((this.h+l)/2)+d(l/5)-1.5+j),b.lineTo(parseInt((this.w+p)/2)+n,d((this.h+l)/2)+d(l/5)-1.5+j),b.stroke());
this.activeIfValue||(b.fillStyle="rgba(240,240,240,"+160/255+")",b.fillRect(0,0,this.w,this.h))};a.Button.prototype.bottonPressed=function(){this.updateAndExecAction()};a.Button.prototype.registerMouseAndTouchEvents=function(){function b(a,c,f){clearInterval(e);h.click&&(c.call(h),a=f?a:100,e=setTimeout(function(){b(a,c)},a))}function c(d){document.body.focus();d.preventDefault();d.stopPropagation();document.activeElement!=document.body&&document.activeElement.blur();h.whichButton=a.whichButton(d);
"L"==h.whichButton&&h.activeIfValue&&(h.click=!0,h.draw(),h.evaluator.setVariable(h.id,h.evaluator.evalExpression(h.valueExpr)),"calculate"==h.action&&b(u,h.bottonPressed,!0),q?window.addEventListener("touchend",f):window.addEventListener("mouseup",f))}function f(a){document.body.focus();if(h.activeIfValue||h.click)h.click=!1,h.draw(),"calculate"!=h.action&&h.bottonPressed(),a.preventDefault(),a.stopPropagation(),q?window.removeEventListener("touchend",f,!1):window.removeEventListener("mouseup",f,
!1)}function d(){h.over=!0;h.draw()}function g(){h.over=!1;h.click=!1;h.draw()}q=a.hasTouchSupport;var h=this,e;h.canvas.oncontextmenu=function(){return!1};this.over=this.click=!1;q?this.canvas.addEventListener("touchstart",c):(this.canvas.addEventListener("mousedown",c),this.canvas.addEventListener("mouseover",d),this.canvas.addEventListener("mouseout",g))};a.Button.prototype.getScreenshot=function(){return this.canvas};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,
e,h,b,c,l,f,g,r,n,j,p,q,u,k,s,m;a.Spinner=function(b,c){a.Control.call(this,b,c);this.tabindex=++this.parent.tabindex;this.name="["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.parser.parse(this.name.substring(1,this.name.length-1)):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);this.originalIncr=this.incr;if(0>=this.evaluator.evalExpression(this.decimals)){var f=this.evaluator.evalExpression(this.incr);0<f?this.originalIncr=this.incr=this.evaluator.parser.parse(parseInt(f).toString()):
this.incr=this.evaluator.parser.parse("1")}this.registerMouseAndTouchEvents();this.init()};a.extend(a.Spinner,a.Control);a.Spinner.prototype.init=function(){d=this.evaluator;var b=d.evalExpression(this.name).toString();this.label.innerHTML=b;this.value=this.validateValue(d.evalExpression(this.valueExpr));var c=this.formatOutputValue(this.value);this.fieldFontSize=2!==this.parent.version?a.getFieldFontSize(this.h):10;var f=2!==this.parent.version?"":"_____",g=a.getTextWidth(c+"_",this.fieldFontSize+
"px Arial"),h=2+parseInt(this.h/2),e=parseInt(this.w/2-h/2),f=a.getTextWidth(b+f,this.fieldFontSize+"px Arial");this.visible||(e=this.w-h,g=0);e<f&&(e=f);""==b&&(e=0);this.w-e-h<g&&(e=this.w-h-g);0>e&&(e=0);b=this.w-(e+h);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",
h+"px");this.canvas.setAttribute("height",this.h+"px");this.canvas.setAttribute("style","position: absolute; left: "+e+"px; top: 0px;");this.ctx=this.canvas.getContext("2d");this.divUp.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+h+"px; height : "+this.h/2+"px; left: "+e+"px; top: 0px;");this.divDown.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+h+"px; height : "+this.h/
2+"px; left: "+e+"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: "+(h+e)+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.value=c;this.label.setAttribute("class","DescartesSpinnerLabel");this.label.setAttribute("style","font-size:"+
this.fieldFontSize+"px; width: "+e+"px; height: "+this.h+"px; line-height: "+this.h+"px;");d.setVariable(this.id,this.value);this.createGradient(this.h/2,this.h)};a.Spinner.prototype.update=function(){d=this.evaluator;this.label.innerHTML=d.evalExpression(this.name).toString();0>=d.evalExpression(this.decimals)?(e=d.evalExpression(this.incr),0<e?this.originalIncr=this.incr=d.parser.parse(parseInt(e).toString()):this.incr=d.parser.parse("1")):this.incr=this.originalIncr;this.activeIfValue=0<d.evalExpression(this.activeif);
this.drawIfValue=0<d.evalExpression(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();if(!this.parent.animation.playing||document.activeElement!=this.field)h=this.field.value,b=this.value,this.value=this.validateValue(d.getVariable(this.id)),this.field.value=this.formatOutputValue(this.value),this.value==b&&this.field.value!=h&&(this.value=
this.validateValue(h),this.field.value=this.formatOutputValue(this.value)),d.setVariable(this.id,this.value)};a.Spinner.prototype.draw=function(){c=this.ctx;l=this.canvas.width;f=this.canvas.height;c.fillStyle="#f0f8ff";c.fillRect(0,0,l,f);c.fillStyle=this.linearGradient;c.fillRect(0,0,l,f);this.up?(g="gray",r="#f0f8ff"):(g="#f0f8ff",r="gray");a.drawLine(c,0,0,l,0,g);a.drawLine(c,0,0,0,f/2,g);a.drawLine(c,0,f/2,l,f/2,r);this.down?(g="gray",r="#f0f8ff"):(g="#f0f8ff",r="gray");a.drawLine(c,0,f/2+1,
l,f/2+1,g);a.drawLine(c,0,f/2+1,0,f,g);a.drawLine(c,0,f-1,l,f-1,r);n=[parseInt(l/2+1),parseInt(l/5+1),parseInt(l-l/5+1)];j=[parseInt(f/8+1),parseInt(f/8+1+f/4),parseInt(f/8+1+f/4)];c.fillStyle=this.activeIfValue?"#2244cc":"#8888aa";c.beginPath();c.moveTo(n[0],j[0]);c.lineTo(n[1],j[1]);c.lineTo(n[2],j[2]);c.fill();j=[parseInt(f-f/8),parseInt(f-f/8-f/4),parseInt(f-f/8-f/4)];c.fillStyle=this.activeIfValue?"#d00018":"#aa8888";c.beginPath();c.moveTo(n[0],j[0]);c.lineTo(n[1],j[1]);c.lineTo(n[2],j[2]);c.fill();
c.fillStyle="rgba(0,0,0,"+24/255+")";this.up&&c.fillRect(0,0,l,f/2);this.down&&c.fillRect(0,f/2,l,f)};a.Spinner.prototype.validateValue=function(a){d=this.evaluator;isNaN(parseFloat(a))||a.toString().match("e")&&(a=parseFloat(a).toFixed(20));a=a.toString();p=parseFloat(d.evalExpression(d.parser.parse(a.replace(this.parent.decimal_symbol,"."))));isNaN(p)&&(p=0);k=d.evalExpression(this.min);s=d.evalExpression(this.max);""===k&&(k=-Infinity);""===s&&(s=Infinity);p<k&&(p=k);p>s&&(p=s);this.discrete&&
(q=d.evalExpression(this.incr),p=0==q?0:q*Math.round(p/q));u=d.evalExpression(this.decimals);0>=u&&(u=0);return p=parseFloat(parseFloat(p).toFixed(u))};a.Spinner.prototype.increase=function(){this.changeValue(parseFloat(this.value)+this.evaluator.evalExpression(this.incr))};a.Spinner.prototype.decrease=function(){this.changeValue(parseFloat(this.value)-this.evaluator.evalExpression(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.registerMouseAndTouchEvents=function(){function b(a,c,f){clearInterval(k);if(j.up||j.down)c.call(j),a=f?a:30,k=setTimeout(function(){b(a,c)},a)}function c(f){f.preventDefault();j.whichButton=a.whichButton(f);"L"==j.whichButton&&j.activeIfValue&&(j.up=!0,b(l,j.increase,!0),j.draw())}function f(c){c.preventDefault();j.whichButton=a.whichButton(c);"L"==j.whichButton&&j.activeIfValue&&
(j.down=!0,b(l,j.decrease,!0),j.draw())}function d(a){j.up=!1;clearInterval(k);j.draw();a.preventDefault()}function g(a){j.down=!1;clearInterval(k);j.draw();a.preventDefault()}function h(a){j.up=!1;clearInterval(k);j.draw();a.preventDefault()}function e(a){j.down=!1;clearInterval(k);j.draw();a.preventDefault()}m=a.hasTouchSupport;var j=this,l=m?500:200,k;j.divUp.oncontextmenu=j.divDown.oncontextmenu=j.field.oncontextmenu=j.label.oncontextmenu=function(){return!1};m?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&&j.changeValue(j.field.value)});m?this.divUp.addEventListener("touchstart",c):this.divUp.addEventListener("mousedown",c);m?this.divDown.addEventListener("touchstart",f):this.divDown.addEventListener("mousedown",f);m||this.divUp.addEventListener("mouseout",d);m||this.divDown.addEventListener("mouseout",g);m?(this.divUp.addEventListener("touchend",
h),window.addEventListener("touchend",h)):(this.divUp.addEventListener("mouseup",h),window.addEventListener("mouseup",h));m?(this.divDown.addEventListener("touchend",e),window.addEventListener("touchend",e)):(this.divDown.addEventListener("mouseup",e),window.addEventListener("mouseup",e));j.field.addEventListener("click",function(){this.select();this.focus()})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,e,h,b,c,l,f;a.TextField=function(b,c){a.Control.call(this,
b,c);this.name="["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.parser.parse(this.name.substring(1,this.name.length-1)):this.parser.parse("'"+this.name+"'");void 0===this.valueExprString&&(this.valueExprString=this.onlyText?"0":"");this.emptyString=!1;this.ok=0;this.tabindex=++this.parent.tabindex;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 f=this.answerPattern.indexOf("|");this.firstAnswer=-1==f?this.answerPattern:this.answerPattern.substring(0,f)}else this.firstAnswer=this.parser.parse(this.answerPattern.substring(1,this.answerPattern.indexOf(",")));if(this.onlyText){if(!this.valueExprString.match(/^'/)||!this.valueExprString.match(/'$/))this.valueExpr=this.evaluator.parser.parse("'"+this.valueExprString+"'");this.validateValue=function(a){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.registerMouseAndTouchEvents();this.init()};a.extend(a.TextField,a.Control);a.TextField.prototype.init=function(){d=
this.evaluator;var b=d.evalExpression(this.name).toString();this.label.innerHTML=b;this.value=this.validateValue(d.evalExpression(this.valueExpr));var c=this.formatOutputValue(this.value);this.fieldFontSize=a.getFieldFontSize(this.h);var f=a.getTextWidth(c+"_",this.fieldFontSize+"px Arial"),h=parseInt(this.w/2),e=a.getTextWidth(b,this.fieldFontSize+"px Arial");h<e&&(h=e);""==b&&(h=0);this.w-h<f&&(h=this.w-f);0>h&&(h=0);b=this.w-h;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 : "+b+"px; height : "+this.h+"px; left: "+h+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.value=c;this.label.setAttribute("class",
"DescartesTextFieldLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+h+"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(){d=this.evaluator;this.label.innerHTML=d.evalExpression(this.name).toString();this.activeIfValue=0<d.evalExpression(this.activeif);
this.drawIfValue=0<d.evalExpression(this.drawif);this.field.disabled=!this.activeIfValue;this.containerControl.style.display=this.drawIfValue?"block":"none";this.updatePositionAndSize();if(!this.parent.animation.playing||document.activeElement!=this.field)e=this.field.value,h=this.value,this.value=this.validateValue(d.getVariable(this.id)),this.field.value=this.formatOutputValue(this.value),this.value===h&&this.field.value!=e&&(this.value=this.validateValue(e),this.field.value=this.formatOutputValue(this.value)),
d.setVariable(this.id,this.value)};a.TextField.prototype.validateValue=function(a){if(""===a||"''"==a)return"";d=this.evaluator;b=parseFloat(d.evalExpression(d.parser.parse(a.toString().replace(this.parent.decimal_symbol,"."))));isNaN(b)&&(b=0);c=d.evalExpression(this.min);""==c&&(c=-Math.Infinity);l=d.evalExpression(this.max);""==l&&(l=Math.Infinity);this.discrete&&(a=d.evalExpression(this.incr),b=0==a?0:a*Math.round(b/a));return b=parseFloat(parseFloat(b).toFixed(d.evalExpression(this.decimals)))};
a.TextField.prototype.formatOutputValue=function(a){return""===a?"":this.uber.formatOutputValue.call(this,a)};a.TextField.prototype.changeValue=function(a){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.evalExpression(this.firstAnswer):""};a.TextField.prototype.registerMouseAndTouchEvents=function(){f=a.hasTouchSupport;var b=this;b.field.oncontextmenu=b.label.oncontextmenu=function(){return!1};f?b.label.addEventListener("touchstart",function(a){a.preventDefault();return!1}):b.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});
this.field.addEventListener("blur",function(){b.changeValue(b.field.value,!0)});this.field.addEventListener("keydown",function(a){b.activeIfValue&&13==a.keyCode&&b.changeValue(b.field.value,!0)});b.field.addEventListener("click",function(){this.select();this.focus()})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.abs,e,h,b,c,l,f,g,r,n,j,p;a.Menu=function(b,c){this.options="";a.Control.call(this,b,c);e=this.parser;h=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="["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.parser.parse(this.name.substring(1,this.name.length-1)):this.parser.parse("'"+this.name+"'");this.options=this.options.split(",");this.menuOptions=[];this.strValue=[];for(var f,d=0,g=this.options.length;d<g;d++)f=this.customSplit(this.options[d]),
1==f.length?(this.menuOptions.push(f[0]),this.strValue.push(d.toString())):2==f.length&&(this.menuOptions.push(f[0]),""==f[1]?this.strValue.push(d.toString()):this.strValue.push(f[1]));d=0;for(g=this.menuOptions.length;d<g;d++)this.menuOptions[d]=this.menuOptions[d].match(/^\[/)&&this.menuOptions[d].match(/\]$/)?e.parse(this.menuOptions[d].substring(1,this.menuOptions[d].length-1)):e.parse("'"+this.menuOptions[d]+"'");d=0;for(g=this.strValue.length;d<g;d++)this.strValue[d]=this.strValue[d].match(/^\[/)&&
this.strValue[d].match(/\]$/)?e.parse(this.strValue[d].substring(1,this.strValue[d].length-1)):e.parse(this.strValue[d]);this.containerControl=document.createElement("div");this.label=document.createElement("label");this.select=document.createElement("select");d=0;for(g=this.menuOptions.length;d<g;d++)f=document.createElement("option"),f.innerHTML=h.evalExpression(this.menuOptions[d]),this.select.appendChild(f);this.field=document.createElement("input");this.containerControl.appendChild(this.label);
this.containerControl.appendChild(this.select);this.visible&&this.containerControl.appendChild(this.field);this.addControlContainer(this.containerControl);this.registerMouseAndTouchEvents();this.init()};a.extend(a.Menu,a.Control);a.Menu.prototype.init=function(){h=this.evaluator;var b=h.evalExpression(this.name).toString();this.label.innerHTML=b;this.fieldFontSize=2!=this.parent.version?a.getFieldFontSize(this.h):10;var c=0,f=0,d=0;this.value=h.evalExpression(this.valueExpr);this.indexValue=this.getIndex(this.value);
for(var g=0,e=this.menuOptions.length;g<e;g++)d=a.getTextWidth(h.evalExpression(this.menuOptions[g]).toString(),this.fieldFontSize+"px Arial"),d>c&&(c=d,f=g);c+=25;d=a.getTextWidth(this.formatOutputValue(h.evalExpression(this.strValue[f])),this.fieldFontSize+"px Arial")+7;f=a.getTextWidth(b,this.fieldFontSize+"px Arial")+10;""==b&&(f=0);this.visible||(d=0);for(b=this.w-d-f;b<c&&0<f;)f--,b++;for(;b<c&&0<d;)d--,b++;for(;f+b+d+1<this.w;)b++,d++;c=f;g=c+b;d=this.w-g;e=this.formatOutputValue(h.evalExpression(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: "+f+"px; height: "+this.h+"px; line-height: "+this.h+"px;");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"menu");this.field.value=
e;this.field.setAttribute("class","DescartesMenuField");this.field.setAttribute("style","font-size: "+this.fieldFontSize+"px; width : "+d+"px; height : "+this.h+"px; left: "+g+"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; line-height: "+this.h+"px; width : "+b+"px; height : "+this.h+"px; left: "+
c+"px; border-color: #7a8a99; border-width: 1.5px; border-style: solid; background-color: #eeeeee;");this.select.setAttribute("tabindex",this.tabindex);this.select.selectedIndex=this.indexValue;h.setVariable(this.id,parseFloat(e));this.update()};a.Menu.prototype.update=function(){h=this.evaluator;this.label.innerHTML=h.evalExpression(this.name).toString();this.activeIfValue=0<h.evalExpression(this.activeif);this.drawIfValue=0<h.evalExpression(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");this.updatePositionAndSize();if(!this.parent.animation.playing||document.activeElement!=this.select){for(var a=0,b=this.menuOptions.length;a<b;a++)this.select.options[a].innerHTML=h.evalExpression(this.menuOptions[a]);this.value=h.getVariable(this.id);isNaN(this.value)&&(this.value=0);this.field.value=this.formatOutputValue(this.value);
h.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)};a.Menu.prototype.customSplit=function(a){g=!1;r="";n=0;for(j=-1;n<a.length;){p=a.charAt(n);a.charAt(n-1);if("["===p&&-1===j){if(g||""!=r)r+="\u00a6";j++}else"["===p?j++:"]"===p&&0===j?(g=!0,j--):"]"==a.charAt(n)&&(j=0>j?j:j-1);r+=a.charAt(n);n++}return r.split("\u00a6")};a.Menu.prototype.getIndex=function(a){a=
parseFloat(a.toString().replace(this.parent.decimal_symbol,"."));b=-1;c=Infinity;for(var f=0,g=this.strValue.length;f<g;f++)l=d(a-parseFloat(this.evaluator.evalExpression(this.strValue[f]))),l<=c&&(c=l,b=f);return b};a.Menu.prototype.changeValue=function(){this.activeIfValue&&(this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction())};a.Menu.prototype.registerMouseAndTouchEvents=function(){f=a.hasTouchSupport;var b=this;b.select.oncontextmenu=b.label.oncontextmenu=b.field.oncontextmenu=
function(){return!1};f?b.label.addEventListener("touchstart",function(a){a.preventDefault();return!1}):b.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.select.addEventListener("change",function(a){b.value=b.evaluator.evalExpression(b.strValue[this.selectedIndex]);b.field.value=b.formatOutputValue(b.value);b.evaluator.setVariable(b.id,b.field.value);b.changeValue();a.preventDefault()});this.field.addEventListener("keydown",function(a){13==a.keyCode&&(b.indexValue=
b.getIndex(b.field.value),b.value=b.evaluator.evalExpression(b.strValue[b.indexValue]),b.field.value=b.formatOutputValue(b.indexValue),b.select.selectedIndex=b.indexValue,b.changeValue())});b.field.addEventListener("click",function(){this.select();this.focus()});b.select.addEventListener("click",function(){this.focus()})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.floor,e="h",h,b,c,l,f,g,r,n,j,p,q,u,k,s,m,t,v,y,B,z,D;a.Scrollbar=function(b,c){a.Control.call(this,
b,c);this.name="["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.parser.parse(this.name.substring(1,this.name.length-1)):this.parser.parse("'"+this.name+"'");this.orientation=this.w>=this.h?e:"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.registerMouseAndTouchEvents();this.init()};a.extend(a.Scrollbar,a.Control);a.Scrollbar.prototype.init=function(){h=this.evaluator;
this.findOffset();this.incr=0==h.evalExpression(this.decimals)?1:(h.evalExpression(this.max)-h.evalExpression(this.min))/100;this.value=this.validateValue(h.evalExpression(this.valueExpr));c=this.formatOutputValue(this.value);l=this.evaluator.evalExpression(this.expresion);this.x=l[0][0];this.y=l[0][1];4==l[0].length&&(this.w=l[0][2],this.h=l[0][3]);this.orientation=this.w>=this.h?e:"v";this.initScroll(c);this.changeScrollPositionFromValue();this.prePos=this.pos;h.setVariable(this.id,this.value)};
a.Scrollbar.prototype.initScroll=function(c){b=this;h=b.evaluator;var f=h.evalExpression(b.name).toString();b.label.innerHTML=f;var d="v"===b.orientation?parseInt(19+5*(b.h-100)/100):b.h;b.fieldFontSize="v"===b.orientation?d-parseInt(b.h/20)-1:2!==b.parent.version?a.getFieldFontSize(d):10;var g=a.getTextWidth(c+"_",b.fieldFontSize+"px Arial"),e=b.parent.getSpaceById(b.spaceID).h;b.labelHeight=""==f?0:d;b.fieldHeight=""==b.visible?0:d;if("v"===b.orientation)b.canvasWidth=b.w,b.canvasHeight=b.h-b.labelHeight-
b.fieldHeight,18<=b.canvasHeight+b.y-e&&(b.canvasHeight=e),f=0,f=b.fieldHeight,g=f+b.canvasHeight,b.canvasX=0,b.canvasY=b.fieldHeight,b.labelWidth=b.w,b.labelY=g,b.upWidth=b.downW=b.w,b.upHeight=b.downH=15,b.upX=0,b.upY=b.fieldHeight,b.downX=0,b.downY=g-b.downH,b.fieldWidth=b.w,b.fieldX=0,b.scrollManipulatorW=b.w,b.scrollManipulatorH=parseInt((b.canvasHeight-b.upHeight-b.downH-b.labelHeight-b.fieldHeight)/10),b.scrollManipulatorH=15>b.scrollManipulatorH?15:b.scrollManipulatorH,b.scrollManipulatorLimInf=
g-b.downH-b.scrollManipulatorH,b.scrollManipulatorLimSup=f+b.downH;else{d=a.getTextWidth(f,b.fieldFontSize+"px Arial")+10;b.labelWidth=d;b.fieldWidth=g;""==f&&(b.labelWidth=0);b.visible||(b.fieldWidth=0);for(g=b.w-b.fieldWidth-b.labelWidth;58>g&&0<b.labelWidth;)b.labelWidth--,g++;for(;58>g&&0<b.fieldWidth;)b.fieldWidth--,g++;f=b.labelWidth;d=f+g;b.fieldWidth=b.w-d;b.canvasWidth=g;b.canvasHeight=b.h;b.canvasX=b.labelWidth;b.canvasY=0;b.fieldX=b.canvasWidth+b.labelWidth;b.labelHeight=b.h;b.labelY=0;
b.upWidth=b.downW=15;b.upHeight=b.downH=b.h;b.upX=d-b.downW;b.upY=0;b.downX=b.labelWidth;b.downY=0;b.scrollManipulatorW=parseInt((b.canvasWidth-b.upWidth-b.downW)/10);b.scrollManipulatorW=15>b.scrollManipulatorW?15:b.scrollManipulatorW;b.scrollManipulatorH=b.h;b.scrollManipulatorLimInf=f+b.downW;b.scrollManipulatorLimSup=f+b.canvasWidth-b.downW-b.scrollManipulatorW}b.containerControl.setAttribute("class","DescartesScrollbarContainer");b.containerControl.setAttribute("style","width: "+b.w+"px; height: "+
b.h+"px; left: "+b.x+"px; top: "+b.y+"px; z-index: "+b.zIndex+";");b.canvas.setAttribute("width",b.w+"px");b.canvas.setAttribute("height",b.h+"px");b.canvas.setAttribute("style","position: absolute; left: 0px; top: 0px;");b.ctx=b.canvas.getContext("2d");b.divUp.setAttribute("class","DescartesCatcher");b.divUp.setAttribute("style","width : "+b.upWidth+"px; height : "+b.upHeight+"px; left: "+b.upX+"px; top: "+b.upY+"px;");b.divDown.setAttribute("class","DescartesCatcher");b.divDown.setAttribute("style",
"width : "+b.downW+"px; height : "+b.downH+"px; left: "+b.downX+"px; top: "+b.downY+"px;");b.scrollManipulator.setAttribute("class","DescartesCatcher");b.scrollManipulator.setAttribute("style","width : "+b.scrollManipulatorW+"px; height : "+b.scrollManipulatorH+"px;");b.scrollManipulator.style.top=("v"===b.orientation?b.scrollManipulatorLimInf:0)+"px";b.scrollManipulator.style.left=("v"===b.orientation?0:b.scrollManipulatorLimInf)+"px";b.field.setAttribute("type","text");b.field.setAttribute("id",
b.id+"scrollbar");b.field.setAttribute("class","DescartesScrollbarField");b.field.setAttribute("style","font-size: "+b.fieldFontSize+"px; width : "+b.fieldWidth+"px; height : "+b.fieldHeight+"px; left: "+b.fieldX+"px; top: 0px;");b.field.value=c;0===b.fieldHeight&&(b.field.style.display="none");b.label.setAttribute("class","DescartesScrollbarLabel");b.label.setAttribute("style","font-size:"+b.fieldFontSize+"px; width: "+b.labelWidth+"px; height: "+b.labelHeight+"px; line-height: "+b.labelHeight+"px; left: 0px; top:"+
b.labelY+"px;")};a.Scrollbar.prototype.update=function(){h=this.evaluator;this.label.innerHTML=h.evalExpression(this.name).toString();this.incr=0==h.evalExpression(this.decimals)?1:(h.evalExpression(this.max)-h.evalExpression(this.min))/100;this.activeIfValue=0<h.evalExpression(this.activeif);this.drawIfValue=0<h.evalExpression(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(h.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);h.setVariable(this.id,this.value)};a.Scrollbar.prototype.draw=function(){b=this;f=b.ctx;r=d(this.w);g=d(this.h);f.fillStyle="#e0e4e8";f.fillRect(0,0,r,g);f.strokeStyle="#7a8a99";b.down&&(f.fillStyle="#ccdcec",f.fillRect(b.downX+
0.5,b.downY+0.5,b.downW,b.downH-1));f.strokeRect(b.downX+0.5,b.downY+0.5,b.downW,b.downH-1);b.up&&(f.fillStyle="#ccdcec",f.fillRect(b.upX+0.5,b.upY-0.5,b.upWidth,b.upHeight+1));f.strokeRect(b.upX+0.5,b.upY-0.5,b.upWidth,b.upHeight+1);n=4;f.fillStyle="black";f.beginPath();b.orientation===e?(f.moveTo(b.downX+n,b.downH/2),f.lineTo(b.downX+b.downW-n,n),f.lineTo(b.downX+b.downW-n,b.downH-n),f.moveTo(b.upX+b.upWidth-n,b.downH/2),f.lineTo(b.upX+n,n),f.lineTo(b.upX+n,b.downH-n),f.fill(),b.activeIfValue&&
(j=d(b.pos),f.fillStyle="#ccdcec",f.fillRect(j+0.5,0,d(b.scrollManipulatorW),g),f.strokeStyle="#6382bf",f.strokeRect(j+0.5,0,d(b.scrollManipulatorW),g),p=d(b.scrollManipulatorW/2),f.beginPath(),f.moveTo(j+p+0.5-2,3),f.lineTo(j+p+0.5-2,g-3),f.moveTo(j+p+0.5,3),f.lineTo(j+p+0.5,g-3),f.moveTo(j+p+0.5+2,3),f.lineTo(j+p+0.5+2,g-3),f.stroke())):(f.moveTo(b.downX+b.downW/2,b.downY+b.downH-n),f.lineTo(b.downX+n,b.downY+n),f.lineTo(b.downX+b.downW-n,b.downY+n),f.moveTo(b.upX+b.upWidth/2,b.upY+n),f.lineTo(b.upX+
n,b.upY+b.upHeight-n),f.lineTo(b.upX+b.upWidth-n,b.upY+b.upHeight-n),f.fill(),b.activeIfValue&&(j=d(b.pos),f.fillStyle="#ccdcec",f.fillRect(0,j+0.5,r,d(b.scrollManipulatorH)),f.strokeStyle="#6382bf",f.strokeRect(0,j+0.5,r,d(b.scrollManipulatorH)),p=d(b.scrollManipulatorH/2),f.beginPath(),f.moveTo(3,j+p+0.5-2),f.lineTo(r-3,j+p+0.5-2),f.moveTo(3,j+p+0.5),f.lineTo(r-3,j+p+0.5),f.moveTo(3,j+p+0.5+2),f.lineTo(r-3,j+p+0.5+2),f.stroke()));f.strokeRect(0.5,0.5,r-1,g-1);b.activeIfValue||(f.fillStyle="rgba(240,240,240,"+
160/255+")",f.fillRect(0,0,r,g.h))};a.Scrollbar.prototype.validateValue=function(a){h=this.evaluator;q=a.toString();q=parseFloat(q.replace(this.parent.decimal_symbol,"."));isNaN(q)&&(q=0);this.minimo=h.evalExpression(this.min);q<this.minimo&&(this.value=null,q=this.minimo);this.maximo=h.evalExpression(this.max);q>this.maximo&&(this.value=null,q=this.maximo);u=this.incr;q=0!=u?q*u/u:0;this.fixed&&(q=parseFloat(parseFloat(q).toFixed(h.evalExpression(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(){n=(this.evaluator.evalExpression(this.max)-this.evaluator.evalExpression(this.min))/10;this.orientation==e?this.clickPos.x>this.prePos&&this.changeValue(parseFloat(this.value)+n):this.clickPos.y<this.prePos&&this.changeValue(parseFloat(this.value)+n)};a.Scrollbar.prototype.decrease10=function(){n=(this.evaluator.evalExpression(this.max)-
this.evaluator.evalExpression(this.min))/10;this.orientation==e?this.clickPos.x<this.prePos&&this.changeValue(parseFloat(this.value)-n):this.clickPos.y>this.prePos&&this.changeValue(parseFloat(this.value)-n)};a.Scrollbar.prototype.changeValue=function(a){this.activeIfValue&&(k=this.validateValue(a),k!=this.value&&(this.value=k,this.field.value=this.formatOutputValue(k),this.changeScrollPositionFromValue(),this.prePos=this.pos,this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction()))};
a.Scrollbar.prototype.changeValueForScrollMovement=function(){h=this.evaluator;s=this.scrollManipulatorLimInf;m=this.scrollManipulatorLimSup;t=h.evalExpression(this.min);v=h.evalExpression(this.max);u=this.incr;k=d((this.pos-s)*(v-t)/(m-s)/u)*u+t;k!=this.value&&(this.value=k,this.field.value=this.formatOutputValue(k),h.setVariable(this.id,this.value),this.parent.updateControls(),this.actionExec.execute(),this.parent.update())};a.Scrollbar.prototype.changeScrollPositionFromValue=function(){h=this.evaluator;
s=this.scrollManipulatorLimInf;m=this.scrollManipulatorLimSup;t=h.evalExpression(this.min);v=h.evalExpression(this.max);u=this.incr;this.pos=(this.value-t)*(m-s)/(v-t)+s;this.orientation==e?this.scrollManipulator.style.left=this.pos+"px":this.scrollManipulator.style.top=this.pos+"px"};a.Scrollbar.prototype.registerMouseAndTouchEvents=function(){function b(a,c,f,d){clearInterval(v);if((s.up||s.down||s.canvasClick)&&1E-7<Math.abs(s.value-d))c.call(s),a=f?a:30,v=setTimeout(function(){b(a,c,!1,d)},a)}
function c(f){f.preventDefault();s.whichButton=a.whichButton(f);"L"==s.whichButton&&s.activeIfValue&&(s.clickPos=s.getCursorPosition(f),s.canvasClick=!0,s.orientation==e?s.clickPos.x<s.prePos?b(t,s.decrease10,!0,s.minimo):b(t,s.increase10,!0,s.maximo):s.clickPos.y<s.prePos?b(t,s.increase10,!0,s.maximo):b(t,s.decrease10,!0,s.minimo))}function f(a){s.canvasClick=!1;clearInterval(v);a.preventDefault()}function d(a){!0==s.canvasClick&&(s.clickPos=s.getCursorPosition(a),a.preventDefault())}function g(a){s.activeIfValue&&
(s.scrollClick=!0,s.initPos=s.getCursorPosition(a),window.addEventListener("mouseup",j),window.addEventListener("mousemove",l),a.preventDefault())}function h(a){s.activeIfValue&&(s.scrollClick=!0,s.initPos=s.getCursorPosition(a),window.addEventListener("touchend",m),window.addEventListener("touchmove",onToucheMove_scrollManipulator),a.preventDefault())}function j(a){s.scrollClick=!1;s.prePos=s.pos;window.removeEventListener("mouseup",j,!1);window.removeEventListener("mousemove",l,!1);a.preventDefault()}
function m(a){s.scrollClick=!1;s.prePos=s.pos;window.removeEventListener("touchend",m,!1);window.removeEventListener("touchmove",l,!1);a.preventDefault()}function l(a){var b=s.getCursorPosition(a);s.orientation==e?(s.pos=s.prePos-(s.initPos.x-b.x),s.pos<s.scrollManipulatorLimInf&&(s.pos=s.scrollManipulatorLimInf),s.pos>s.scrollManipulatorLimSup&&(s.pos=s.scrollManipulatorLimSup),s.scrollManipulator.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+
s.scrollManipulatorW+"px; height : "+s.h+"px; left: "+s.pos+"px; top: 0px;")):(s.pos=s.prePos-(s.initPos.y-b.y),s.pos>s.scrollManipulatorLimInf&&(s.pos=s.scrollManipulatorLimInf),s.pos<s.scrollManipulatorLimSup&&(s.pos=s.scrollManipulatorLimSup),s.scrollManipulator.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+s.w+"px; height : "+s.scrollManipulatorH+"px; left: 0px; top: "+s.pos+"px;"));s.changeValueForScrollMovement();a.preventDefault()}
function k(c){c.preventDefault();s.whichButton=a.whichButton(c);"L"==s.whichButton&&s.activeIfValue&&(s.up=!0,b(t,s.increase,!0,s.maximo))}function r(c){c.preventDefault();s.whichButton=a.whichButton(c);"L"==s.whichButton&&s.activeIfValue&&(s.down=!0,b(t,s.decrease,!0,s.minimo))}function n(a){s.up=!1;clearInterval(v);a.preventDefault()}function p(a){s.down=!1;clearInterval(v);a.preventDefault()}function q(a){s.up=!1;clearInterval(v);a.preventDefault();s.draw()}function u(a){s.down=!1;clearInterval(v);
a.preventDefault();s.draw()}y=a.hasTouchSupport;var s=this,t=y?500:200,v;s.canvas.oncontextmenu=s.divUp.oncontextmenu=s.divDown.oncontextmenu=s.label.oncontextmenu=s.field.oncontextmenu=s.scrollManipulator.oncontextmenu=function(){return!1};this.field.addEventListener("keydown",function(a){13==a.keyCode&&s.changeValue(s.field.value)});y?this.canvas.addEventListener("touchstart",c):this.canvas.addEventListener("mousedown",c);y||this.divDown.addEventListener("mouseout",p);y?window.addEventListener("touchend",
f):window.addEventListener("mouseup",f);y?this.canvas.addEventListener("touchmove",d):this.canvas.addEventListener("mousemove",d);y?this.scrollManipulator.addEventListener("touchstart",h):this.scrollManipulator.addEventListener("mousedown",g);y?this.divUp.addEventListener("touchstart",k):this.divUp.addEventListener("mousedown",k);y?this.divDown.addEventListener("touchstart",r):this.divDown.addEventListener("mousedown",r);y||this.divUp.addEventListener("mouseout",n);y||this.divDown.addEventListener("mouseout",
p);y?window.addEventListener("touchend",q):window.addEventListener("mouseup",q);y?window.addEventListener("touchend",u):window.addEventListener("mouseup",u)};a.Scrollbar.prototype.findOffset=function(){B=this.containerControl;this.offsetTop=this.offsetLeft=0;z=this.containerControl.style.display;for(this.containerControl.style.display="block";B;)this.offsetLeft+=B.offsetLeft||0,this.offsetTop+=B.offsetTop||0,B=B.parentNode;this.containerControl.style.display=z};a.Scrollbar.prototype.getCursorPosition=
function(b){D=a.getCursorPosition(b);return{x:D.x-this.offsetLeft,y:D.y-this.offsetTop}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d;a.Audio=function(d,b){this.controls=!0;this.file="";this.oldDrawIf=0;a.Control.call(this,d,b);var c=this,e=c.evaluator.evalExpression(c.expresion);4==e[0].length?(c.w=e[0][2],c.h=e[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(){c.audio.play()});c.evaluator.setFunction(c.id+".pause",function(){c.audio.pause()});c.evaluator.setFunction(c.id+".stop",function(){c.audio.pause();c.audio.currentTime=0});c.audio.addEventListener("timeupdate",function(){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 e;a.Audio.prototype.update=function(){d=this.evaluator;(e=0<d.evalExpression(this.drawif))?this.audio.style.display="block":(this.audio.style.display="none",e!==this.oldDrawIf&&this.audio.pause());this.oldDrawIf=e;this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var d;a.Video=function(h,b){this.controls=!0;this.file="";this.oldDrawIf=0;a.Control.call(this,h,b);var c=this;d=c.evaluator;var e=c.evaluator.evalExpression(c.expresion);4==e[0].length?(c.w=e[0][2],c.h=e[0][3]):(c.w=null,c.h=null);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.poster&&c.video.setAttribute("poster",c.poster);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;");var e=c.file,f=e.lastIndexOf(".");-1!=f&&(e=c.file.substring(0,f));c.video.canPlayType("video/mp4")&&(f=document.createElement("source"),f.setAttribute("src",e+".mp4"),f.setAttribute("type","video/mp4"),c.video.appendChild(f));c.video.canPlayType("video/ogg")&&(f=document.createElement("source"),f.setAttribute("src",e+".ogg"),f.setAttribute("type","video/ogg"),
c.video.appendChild(f),f=document.createElement("source"),f.setAttribute("src",e+".ogv"),f.setAttribute("type","video/ogg"),c.video.appendChild(f));c.video.canPlayType("video/webm")&&(f=document.createElement("source"),f.setAttribute("src",e+".webm"),f.setAttribute("type","video/webm"),c.video.appendChild(f));c.addControlContainer(c.video);c.evaluator.setFunction(c.id+".play",function(){c.video.play()});c.evaluator.setFunction(c.id+".pause",function(){c.video.pause()});c.evaluator.setFunction(c.id+
".stop",function(){c.video.pause();c.video.currentTime=0});c.video.addEventListener("timeupdate",function(){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 e;a.Video.prototype.update=function(){d=this.evaluator;e=0<d.evalExpression(this.drawif);0<d.evalExpression(this.drawif)?this.video.style.display="block":(this.video.style.display=
"none",e!==this.oldDrawIf&&this.video.pause());this.oldDrawIf=e;this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,e;a.TextArea=function(d,b){this.font="Monospaced,PLAIN,12";a.Control.call(this,d,b);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.registerMouseAndTouchEvents();this.init()};a.extend(a.TextArea,a.Control);a.TextArea.prototype.init=function(){e=this.answer?28:8;d=this.evaluator;var h;h=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<d.evalExpression(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-e)+"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;' >"+h+"</span>";this.textAreaAnswer.setAttribute("class","DescartesTextAreaContainer");this.textAreaAnswer.setAttribute("style","width: "+(this.w-8)+"px; height: "+(this.h-e)+"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 b=d.getContext("2d");this.canvas=d;this.ctx=b;this.createGradient(20,16);b.lineWidth=1;b.fillStyle="white";b.fillRect(0,0,20,16);b.fillStyle=this.linearGradient;b.fillRect(0,0,20,16);a.drawLine(b,19,0,19,
16,"rgba(0,0,0,"+128/255+")");a.drawLine(b,0,0,0,16,"rgba(0,0,0,"+24/255+")");a.drawLine(b,1,0,1,16,"rgba(0,0,0,"+8/255+")");this.imageUnPush=d.toDataURL();b.fillStyle="white";b.fillRect(0,0,20,16);b.fillStyle=this.linearGradient;b.fillRect(0,0,20,16);a.drawLine(b,0,0,0,14,"gray");a.drawLine(b,0,0,19,0,"gray");b.fillStyle="rgba(0, 0, 0,"+24/255+")";b.fillRect(0,0,this.w,this.h);this.imagePush=d.toDataURL()};a.TextArea.prototype.update=function(){d=this.evaluator;this.activeIfValue=0<d.evalExpression(this.activeif);
this.drawIfValue=0<d.evalExpression(this.drawif);var a;a=this.text.match(/<span/)?this.rawText:this.text;d.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.registerMouseAndTouchEvents=function(){function a(c){c.preventDefault();b.showButton.style.backgroundImage="url("+b.imageUnPush+")"}var b=this;this.showButton.addEventListener("mousedown",
function(a){a.preventDefault();b.showAnswer=!b.showAnswer;b.textAreaAnswer.style.display=b.showAnswer?"block":"none";b.showButton.childNodes[0].childNodes[0].textContent=b.showAnswer?"T":"S";b.showButton.style.backgroundImage="url("+b.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 b=a.getContext("2d");
b.fillStyle="white";b.strokeStyle="black";b.lineWidth=1;b.fillRect(0,0,this.w,this.h);b.strokeRect(0,0,this.w,this.h);return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=2*Math.PI,e,h,b,c,l,f,g,r,n;a.GraphicControl=function(b,c){h=b.evaluator.parser;this.text=this.spaceID="";this.size=h.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);this.constraintExpr&&(this.constraint=h.parse(this.constraintExpr),"(expr)"==this.constraint.type&&(this.constraint=h.parse(this.constraintExpr.substring(1,this.constraintExpr.length-1))),"compOperator"==this.constraint.type?this.newt=new a.R2Newton(this.evaluator,this.constraint):this.constraint=null,r=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.registerMouseAndTouchEvents();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(){e=this.evaluator;n=a.hasTouchSupport;var b=e.evalExpression(this.expresion);this.x=b[0][0];this.y=b[0][1];e.setVariable(this.xString,this.x);e.setVariable(this.yString,this.y);""!=this.imageSrc&&!this.imageSrc.toLowerCase().match(/vacio.gif$/)?(this.image=this.parent.getImage(this.imageSrc),
this.width=this.image.width,this.height=this.image.height):(this.width=2*e.evalExpression(this.size),this.height=2*e.evalExpression(this.size));this._w=n&&70>this.width?70:this.width;this._h=n&&70>this.height?70:this.height;this.mouseCacher.setAttribute("style","cursor: pointer; background-color: rgba(255, 255, 255, 0); width: "+this._w+"px; height: "+this._h+"px; z-index: "+this.zIndex+";");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";e.setVariable(this.activoString,0);e.setVariable(this.activeString,0);this.setImage=!1;this.update()};a.GraphicControl.prototype.update=function(){e=this.evaluator;this.activeIfValue=0<e.evalExpression(this.activeif);this.drawIfValue=0<e.evalExpression(this.drawif);this.x=e.getVariable(this.xString);this.y=e.getVariable(this.yString);b=this.space.getAbsoluteX(this.x);c=this.space.getAbsoluteY(this.y);this.mouseCacher.style.display=!this.activeIfValue?
"none":"block";this.mouseCacher.style.left=parseInt(b-this._w/2)+"px";this.mouseCacher.style.top=parseInt(c-this._h/2)+"px";this.constraint&&this.evalConstraint();this.draw()};a.GraphicControl.prototype.draw=function(){e=this.evaluator;this.drawIfValue&&(f=this.ctx,g=this.space.backgroundCtx,b=parseInt(this.space.getAbsoluteX(this.x))+0.5,c=parseInt(this.space.getAbsoluteY(this.y))+0.5,""!=this.text&&this.drawText(b,c),this.image.ready?(this.image.complete&&!this.setImage&&f.drawImage(this.image,
parseInt(b-this.image.width/2),parseInt(c-this.image.height/2)),this.trace&&(g.save(),g.translate(b,c),g.scale(parseInt(this.image.width/2),parseInt(this.image.height/2)),g.beginPath(),g.arc(0,0,1,0,d,!1),g.restore(),g.lineWidth=1,g.strokeStyle=this.trace.getColor(),g.stroke())):(f.beginPath(),f.arc(b,c,parseInt(this.width/2),0,d,!1),f.fillStyle=this.colorInt.getColor(),f.fill(),f.lineWidth=1,f.strokeStyle=this.color.getColor(),f.stroke(),this.active&&(f.beginPath(),f.arc(b,c,parseInt(this.width/
2)-2,0,d,!1),f.strokeStyle=this.colorInt.borderColor(),f.stroke()),this.trace&&(g.lineWidth=1,g.strokeStyle=this.trace.getColor(),g.beginPath(),g.arc(b,c,parseInt(this.width/2),0,d,!1),g.stroke())))};a.GraphicControl.prototype.evalConstraint=function(){r.set(this.x,this.y);l=this.newt.findZero(r);this.x=l.x;this.y=l.y;this.evaluator.setVariable(this.xString,this.x);this.evaluator.setVariable(this.yString,this.y)};a.GraphicControl.prototype.drawText=function(a,b){f=this.ctx;e=this.evaluator;f.fillStyle=
this.color.getColor();f.font=this.font;f.textBaseline="alphabetic";f.fillText(e.evalExpression(this.text[0],e.evalExpression(this.decimals),this.fixed),parseInt(a+1+this.width/2),parseInt(b-1-this.height/2))};a.GraphicControl.prototype.getContainer=function(){for(var a=this.parent.spaces,b,c=0,f=a.length;c<f;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)};a.GraphicControl.prototype.registerMouseAndTouchEvents=function(){function b(c){document.body.focus();c.preventDefault();e.whichButton=a.whichButton(c);"L"==e.whichButton&&(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=e.getCursorPosition(c),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",f),window.addEventListener("mousemove",d))}function c(a){document.body.focus();a.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=e.getCursorPosition(a),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",
d),window.addEventListener("touchend",f))}function f(b){document.body.focus();b.preventDefault();e.touchId=null;e.evaluator.setVariable(e.mclickedString,1);e.evaluator.setVariable(e.mclicizquierdoString,1);if(e.activeIfValue||e.active)e.click=!1,a.hasTouchSupport?(window.removeEventListener("touchmove",d,!1),window.removeEventListener("touchend",f,!1)):(window.removeEventListener("mouseup",f,!1),window.removeEventListener("mousemove",d,!1)),e.evaluator.setVariable(e.mxString,e.space.getRelativeX(e.posAnte.x)+
e.x),e.evaluator.setVariable(e.myString,e.space.getRelativeY(e.posAnte.y)+e.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"}function d(a){a.preventDefault();a.touchId=e.touchId;e.evaluator.setVariable(e.mclickedString,0);e.evaluator.setVariable(e.mclicizquierdoString,0);l=e.getCursorPosition(a);e.posX=e.prePos.x-(e.posAnte.x-l.x);e.posY=e.prePos.y-(e.posAnte.y-l.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(e.posAnte.x)+e.space.getRelativeX(e.posX));e.evaluator.setVariable(e.myString,e.space.getRelativeY(e.posAnte.y)+e.space.getRelativeY(e.posY));e.parent.updateControls();e.parent.update()}function g(){e.over=!0}function h(){e.over=!1;e.click=!1}var e=this;this.active=this.over=this.click=!1;this.mouseCacher.oncontextmenu=function(){return!1};a.hasTouchSupport?this.mouseCacher.addEventListener("touchstart",
c):(this.mouseCacher.addEventListener("mousedown",b),this.mouseCacher.addEventListener("mouseover",g),this.mouseCacher.addEventListener("mouseout",h));var l};a.GraphicControl.prototype.getCursorPosition=function(a){if(a.touches){var b;if(a.touchId){c=0;for(f=a.touches.length;c<f;c++)if(a.touches[c].identifier==a.touchId){b=a.touches[c];break}}else for(var c=0,f=a.touches.length;c<f;c++)if(a.target==a.touches[c].target){b=a.touches[c];this.touchId=b.identifier;break}mouseX=b.pageX;mouseY=b.pageY}else void 0!=
a.pageX&&void 0!=a.pageY?(mouseX=a.pageX,mouseY=a.pageY):(mouseX=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,mouseY=a.clientY+document.body.scrollTop+document.documentElement.scrollTop);return{x:mouseX-(this.space.container.offsetLeft+this.space.container.parentNode.offsetLeft),y:mouseY-(this.space.container.offsetTop+this.space.container.parentNode.offsetTop)}};return a}(descartesJS||{}),descartesJS=function(a,d){var e,h,b,c,l,f,g,r,n,j;if(a.loadLib)return a;var p,q,u,
k,s,m,t,v,y=/[\w-//]*(\.png|\.jpg|\.gif|\.svg)/gi,B,z,D,E,A,x,F,G,J,H,w,K,C,I,L,N,Q,R,O,P,M;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 c=0,f=a.length;c<f;c++)switch(u=a[c][0],k=a[c][1],q=d[u],q){case "rowsNorth":case "rowsSouth":case "widthEast":case "widthWest":case "height":b[q]=
parseInt(k);break;case "about":case "config":case "init":case "clear":b[q]="true"===d[k];break;default:console.log("----- attributo de space no identificado: <"+u+"> valor: <"+k+"> -----")}return b};a.LessonParser.prototype.parseSpace=function(b){s={};b=this.split(b);for(var c=0,f=b.length;c<f;c++)switch(u=b[c][0],k=b[c][1],q=d[u],q){case "type":case "id":case "cID":case "file":s[q]=k;break;case "fixed":case "numbers":case "sensitive_to_mouse_movements":case "R3":case "split":s[q]="true"===d[k];break;
case "bg_display":case "render":s[q]=d[k];break;case "net":case "net10":case "axes":case "text":s[q]="false"===d[k]?"":new a.Color(k,this.parent.evaluator);break;case "x_axis":case "y_axis":s[q]="false"===d[k]?"":k;break;case "O.x":s.OxExpr=k;break;case "O.y":s.OyExpr=k;break;case "image":s.imageSrc=k;break;case "x":p=k;p="%"===p[p.length-1]?(this.parent.container.width*parseFloat(p)/100).toString():k;s.xExpr=this.parser.parse(p);break;case "y":p=k;p="%"===p[p.length-1]?(this.parent.container.height*
parseFloat(p)/100).toString():k;s.yExpr=this.parser.parse(p);break;case "width":p=k;"%"===p[p.length-1]?(s.wExpr=p,p=this.parent.container.width*parseFloat(p)/100):(p=parseFloat(k),p!=k&&(p=this.parent.container.width));s.w=p;break;case "height":p=k;"%"===p[p.length-1]?(s.hExpr=p,p=this.parent.container.height*parseFloat(p)/100):(p=parseFloat(k),p!=k&&(p=this.parent.container.height));s.h=p;break;case "drawif":s.drawif=this.parser.parse(k);break;case "scale":p=parseFloat(k);isNaN(p)&&(p=48);s.scale=
p;break;case "background":s.background=new a.Color(k,this.parent.evaluator);break;default:console.log("----- attributo de space no identificado: <"+u+"> valor: <"+k+"> -----")}switch(s.type){case "R2":return new a.Space2D(this.parent,s);case "R3":return new a.Space3D(this.parent,s);case "AP":return new a.SpaceAP(this.parent,s);case "HTMLIFrame":return new a.SpaceHTML_IFrame(this.parent,s);default:return new a.Space2D(this.parent,s)}};a.LessonParser.prototype.parseControl=function(b){m={type:"numeric"};
b=this.split(b);for(var c=0,f=b.length;c<f;c++)switch(u=b[c][0],k=b[c][1],q=d[u],q){case "id":case "name":case "parameter":case "tooltip":case "tooltipFont":case "Explanation":case "ExplanationFont":case "cID":case "options":case "font":case "file":case "answer":m[q]=k;break;case "gui":case "region":case "action":case "msg_pos":case "poster":m[q]=d[k];break;case "fixed":case "visible":case "discrete":case "onlyText":case "evaluate":case "autoplay":case "loop":case "controls":m[q]="true"===d[k];break;
case "color":case "colorInt":case "trace":m[q]=new a.Color(k,this.parent.evaluator);break;case "font_size":case "drawif":case "activeif":case "decimals":case "min":case "max":case "size":m[q]=this.parser.parse(k);break;case "constraint":m.constraintExpr=k;break;case "image":m.imageSrc=k;break;case "space":m.spaceID=k;break;case "type":m.type=d[k.trim()];break;case "expresion":m.expresion=this.parser.parse(k.replace(")(",","));break;case "bold":"false"!=d[k]&&(m.bold="bold");break;case "italics":"false"!=
d[k]&&(m.italics="italic");break;case "underlined":"false"!=d[k]&&(m.underlined=!0);break;case "value":var g=k.replace(/&squot;/g,"'");g.match(/^\|/)&&(g="'"+g.substring(1),g.match(/\|$/)&&(g=g.substring(0,g.length-1)+"'"));m.valueExpr=this.parser.parse(g);m.valueExprString=g;break;case "incr":0!=k&&(m.incr=this.parser.parse(k));break;case "exponentialif":m.exponentialif=parseFloat(k);break;case "text":m.rawText=k;for(var g=this.parseText(k),e=0,h=g.length;e<h;e++)g[e]=this.parser.parse(g[e],!1);
m.text=g;break;default:e=u.indexOf(".");g=d[u.substring(0,e)];e=d[u.substring(e+1)];if("parameter"===g&&"font"===e){m.parameterFont=k;break}else if("Explanation"===g&&"font"===e){m.ExplanationFont=k;break}else if("tooltip"===g&&"font"===e){m.tooltipFont=k;break}console.log("----- attributo de control no identificado: <"+u+"> valor: <"+k+"> -----")}if("numeric"===m.type)switch(m.gui){case "spinner":return new a.Spinner(this.parent,m);case "button":return new a.Button(this.parent,m);case "textfield":return new a.TextField(this.parent,
m);case "menu":return new a.Menu(this.parent,m);case "scrollbar":return new a.Scrollbar(this.parent,m);default:return new a.Spinner(this.parent,m)}else{if("video"===m.type)return new a.Video(this.parent,m);if("audio"===m.type)return new a.Audio(this.parent,m);if("graphic"===m.type)return new a.GraphicControl(this.parent,m);if("text"===m.type)return new a.TextArea(this.parent,m)}};a.LessonParser.prototype.parseGraphic=function(b,c,f,g){t={rotateExp:g,parameter:"t"};b=this.split(b);g=0;for(var e=b.length;g<
e;g++)switch(u=b[g][0],k=b[g][1],q=d[u],q){case "type":case "align":t[q]=d[k];break;case "background":case "abs_coord":case "visible":case "editable":case "fixed":case "vectors":t[q]="true"===d[k];break;case "color":case "fill":case "fillP":case "fillM":case "arrow":case "trace":t[q]="false"===d[k]?"":new a.Color(k,this.parent.evaluator);break;case "family":case "parameter":case "info":case "font":case "name":t[q]=k;break;case "drawif":case "width":case "decimals":case "size":case "spear":case "center":case "radius":case "init":case "end":case "opacity":case "inirot":case "inipos":case "range":t[q]=
this.parser.parse(k);break;case "space":t.spaceID=k;break;case "expresion":"macro"!=t.type?(t.expresion=this.parser.parse(k),t.expresionString=k):t.expresion=k;break;case "text":t.text=this.parseText(k);break;case "file":var h=k.replace(/&squot;/g,"'");"["===h.charAt(0)&&"]"===h.charAt(h.length-1)&&(h=h.substring(1,h.length-1));h.match(y)&&(h="'"+h+"'");t.file=this.parser.parse(h);break;case "border":"false"!=d[k]&&(t.border=new a.Color(k,this.parent.evaluator));break;default:if(void 0!=t.family&&
u.substring(0,t.family.length+1)===t.family+"."){switch(d[u.substring(t.family.length+1)]){case "interval":t.family_interval=this.parser.parse(k);break;case "steps":t.family_steps=this.parser.parse(k)}break}if(void 0!=t.parameter&&u.match(t.parameter+".")){t.parameter!==u.substring(0,u.indexOf(t.parameter)+t.parameter.length)&&(t.parameter=u.substring(0,u.indexOf(t.parameter)+t.parameter.length));switch(d[u.substring(t.parameter.length+1)]){case "interval":t.parameter_interval=this.parser.parse(k);
break;case "steps":t.parameter_steps=this.parser.parse(k)}break}console.log("----- attributo del graphic no identificado: <"+u+"> valor: <"+k+"> -----")}c&&(t.abs_coord=c);f&&(t.background=f);switch(t.type){case "text":return new a.Text(this.parent,t);case "image":return new a.Image(this.parent,t);case "point":return new a.Point(this.parent,t);case "polygon":return new a.Polygon(this.parent,t);case "arc":return new a.Arc(this.parent,t);case "segment":return new a.Segment(this.parent,t);case "arrow":return new a.Arrow(this.parent,
t);case "macro":return new a.Macro(this.parent,t);case "curve":return new a.Curve(this.parent,t);case "equation":return new a.Equation(this.parent,t);case "sequence":return new a.Sequence(this.parent,t);case "fill":return new a.Fill(this.parent,t)}};a.LessonParser.prototype.parse3DGraphic=function(b,c,f,g){t={rotateExp:g,parameter:"t"};b=this.split(b);c=0;for(f=b.length;c<f;c++)switch(u=b[c][0],k=b[c][1],q=d[u],q){case "type":case "model":t[q]=d[k];break;case "background":case "fixed":case "edges":t[q]=
"true"===d[k];break;case "color":case "backcolor":t[q]=new a.Color(k,this.parent.evaluator);break;case "type":case "model":t[q]=d[k];break;case "background":case "fixed":case "edges":case "split":t[q]="true"===d[k];break;case "color":case "backcolor":t[q]=new a.Color(k,this.parent.evaluator);break;case "drawif":case "width":case "length":case "height":case "decimals":case "Nu":case "Nv":case "inipos":case "endpos":t[q]=this.parser.parse(k);break;case "family":case "parameter":case "font":case "name":case "inirot":case "endrot":t[q]=
k;break;case "space":t.spaceID=k;break;case "expresion":"macro"!=t.type&&"curve"!=t.type&&"surface"!=t.type?(t.expresion=this.parser.parse(k),t.expresionString=k):t.expresion=k.replace(/\\n/g," ").replace(/;/g," ");break;case "text":g=this.parseText(k);for(var e=0,h=g.length;e<h;e++)g[e]=this.parser.parse(g[e],!1);t.text=g;break;case "file":g=k.replace(/&squot;/g,"'");"["===g.charAt(0)&&"]"===g.charAt(g.length-1)&&(g=g.substring(1,g.length-1));g.match(/./)&&(g="'"+g+"'");t.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":t[q]=this.parser.parse(k);break;case "family":case "parameter":case "font":case "name":t[q]=k;break;case "space":t.spaceID=k;break;case "expresion":"macro"!=t.type&&"curve"!=t.type&&"surface"!=t.type?(t.expresion=this.parser.parse(k),t.expresionString=k):t.expresion=k;break;case "text":g=this.parseText(k);e=0;for(h=g.length;e<h;e++)g[e]=this.parser.parse(g[e],
!1);t.text=g;break;case "file":g=k.replace(/&squot;/g,"'");"["===g.charAt(0)&&"]"===g.charAt(g.length-1)&&(g=g.substring(1,g.length-1));g.match(/./)&&(g="'"+g+"'");t.file=this.parser.parse(g);break;default:if(void 0!==t.family&&u.substring(0,t.family.length+1)===t.family+"."){"interval"===d[u.substring(t.family.length+1)]?t.family_interval=this.parser.parse(k):t.family_steps=this.parser.parse(k);break}console.log("----- attributo del graphic3D no identificado: <"+u+"> valor: <"+k+"> -----")}switch(t.type){case "point":return new a.Point3D(this.parent,
t);case "segment":return new a.Segment3D(this.parent,t);case "polygon":return new a.Polygon3D(this.parent,t);case "curve":return new a.Curve3D(this.parent,t);case "triangle":return new a.Triangle3D(this.parent,t);case "face":return new a.Face3D(this.parent,t);case "polireg":return new a.Polireg3D(this.parent,t);case "surface":return new a.Surface3D(this.parent,t);case "text":return new a.Text3D(this.parent,t);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,
t);case "macro":return new a.Macro3D(this.parent,t);default:console.log(t.type)}};a.LessonParser.prototype.parseAuxiliar=function(b){v={};b=this.split(b);for(var c=0,f=b.length;c<f;c++)b[c][1]=b[c][1].replace(/&squot;/g,"'");c=0;for(f=b.length;c<f;c++)switch(u=b[c][0],k=b[c][1],q=d[u],q){case "id":case "file":case "init":case "doExpr":case "whileExpr":case "range":case "local":case "expresion":case "condition":case "parameter":v[q]=k.replace(/&squot;/g,"'");break;case "editable":case "constant":case "array":case "matrix":case "algorithm":case "event":case "sequence":v[q]=
"true"===d[k];break;case "size":case "rows":case "columns":v[q]=this.parser.parse(k);break;case "evaluate":case "execution":case "msg_pos":case "action":v[q]=d[k];break;default:var g=u.indexOf("."),e=d[u.substring(0,g)],g=d[u.substring(g+1)];if("parameter"===e&&"font"===g){v.parameterFont=k;break}console.log("----- attributo de auxiliar no identificado: <"+u+"> valor: <"+k+"> -----")}v.sequence?new a.Function(this.parent,v):v.constant?(b=new a.Constant(this.parent,v),v.evaluate&&"always"===v.evaluate&&
this.parent.auxiliaries.push(b)):v.algorithm&&v.evaluate?(b=new a.Algorithm(this.parent,v),this.parent.auxiliaries.push(b)):v.array&&!v.matrix&&")"!=v.id.charAt(v.id.length-1)?(b=new a.Vector(this.parent,v),v.evaluate&&"always"===v.evaluate&&this.parent.auxiliaries.push(b)):v.matrix&&")"!=v.id.charAt(v.id.length-1)?(b=new a.Matrix(this.parent,v),v.evaluate&&"always"===v.evaluate&&this.parent.auxiliaries.push(b)):v.event&&")"!=v.id.charAt(v.id.length-1)?this.parent.events.push(new a.Event(this.parent,
v)):")"===v.id.charAt(v.id.length-1)?new a.Function(this.parent,v):new a.Variable(this.parent,v)};a.LessonParser.prototype.parseAction=function(b){B=b.action;z=b.parent;D=b.parameter;if(B)switch(B){case "message":return new a.Message(z,D);case "calculate":return new a.Calculate(z,D);case "openURL":return new a.OpenURL(z,D);case "openScene":return new a.OpenScene(z,D);case "about":return new a.About(z,D);case "config":return new a.Config(z,D);case "init":return new a.Init(z,D);case "clear":return new a.Clear(z,
D);case "animate":return new a.Animate(z,D);case "initAnimation":return new a.InitAnimation(z,D);case "playAudio":return new a.PlayAudio(z,D);default:console.log("----- Accion no soportada aun: <"+B+"> -----")}else return{execute:function(){}}};a.LessonParser.prototype.parseAnimation=function(b){var c={};b=this.split(b);for(var f=0,g=b.length;f<g;f++)switch(u=b[f][0],k=b[f][1],q=d[u],q){case "id":case "delay":case "init":case "doExpr":case "whileExpr":c[q]=k.replace(/&squot;/g,"'");break;case "controls":case "auto":case "loop":case "algorithm":case "evaluate":c[q]=
"true"===d[k];break;default:console.log("----- attributo de la animacion no identificado: <"+u+">  <"+k+"> -----")}return new a.Animation(this.parent,c)};a.LessonParser.prototype.parsePleca=function(d,m){d=this.split(d);h=e="";b=0;c="#536891";l="white";f="left";g="";r="SansSerif,BOLD,20";n="SansSerif,PLAIN,18";j=void 0;for(var p=0,q=d.length;p<q;p++)switch(u=d[p][0],k=d[p][1],u){case "title":e=k;break;case "subtitle":h=k;break;case "subtitlines":b=k;break;case "bgcolor":""!=k&&(c=(new a.Color(k,this.parent.evaluator)).getColor());
break;case "fgcolor":""!=k&&(l=(new a.Color(k,this.parent.evaluator)).getColor());break;case "align":""!=k&&(f=k);break;case "titleimage":g=k;break;case "titlefont":r=""!=k?a.convertFont(k):a.convertFont(r);break;case "subtitlefont":n=""!=k?a.convertFont(k):a.convertFont(n);break;default:console.log("----- attributo de la pleca no identificado: <"+u+">  <"+k+"> -----")}if(""===e&&""===h)return document.createElement("div");H=n.substring(0,n.indexOf("px"));H=H.substring(H.lastIndexOf(" "));""!=g&&
(w=this.parent.getImage(g),K=w.height);j=document.createElement("div");j.setAttribute("id","descartesPleca");K?(j.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+f+"; width: "+(m-30)+"px; height: "+(K-16)+"px; background: "+c+"; color: "+l+"; padding-top: 8px; padding-bottom: 8px; padding-left: 15px; padding-right: 15px; margin: 0px; overflow: hidden; z-index: 100;"),w.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: -1; width: 100%; height: 100%"),
j.appendChild(w)):j.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+f+"; width: "+(m-30)+"px; background: "+c+"; color: "+l+"; padding-top: 8px; padding-bottom: 8px; padding-left: 15px; padding-right: 15px; margin: 0px; z-index: 100;");C=document.createElement("div");C.setAttribute("style","padding: 0px; margin: 0px; font: "+r+"; overflow: hidden; white-space: nowrap;");C.innerHTML=e;I=document.createElement("div");if(1===parseInt(b)){O=0;L=document.createElement("div");
L.innerHTML=h;document.body.appendChild(L);Q=H;do Q-=O,L.setAttribute("style","padding: 0px; margin: 0px; font: "+n+"; font-size: "+Q+"px; width: "+(m-30)+"px; line-height: "+Q+"px;"),N=L.offsetHeight,R=N/Q,O=1;while(1<R&&8<Q);document.body.removeChild(L);I.setAttribute("style","padding: 0px; margin: 0px; font: "+n+"; font-size: "+Q+"px; line-height: 110%; overflow: hidden; white-space: nowrap;")}else I.setAttribute("style","padding: 0px; margin: 0px; font: "+n+"; line-height: 110%;");I.innerHTML=
h;j.appendChild(C);j.appendChild(I);j.imageHeight=K;return j};a.LessonParser.prototype.split=function(a){if("string"!=typeof a)return[];a=(a||"").replace(/\\'/g,"\u2019");E=[];x=A=0;F=!1;G=0;for(J=!1;A<a.length;)" "===a.charAt(A)&&!F&&A++," "!==a.charAt(A)&&!F&&(F=!0,G=A),"="===a.charAt(A)&&("'"===a.charAt(A+1)&&!J)&&(J=!0,E[x]=[a.substring(G,A)],G=A+2,A+=2),J&&"'"===a.charAt(A)&&(F=J=!1,E[x].push(a.substring(G,A)),x++),"="===a.charAt(A)&&("'"!==a.charAt(A+1)&&!J)&&(E[x]=[a.substring(G,A)],G=A+1,
A++,P=a.substring(A).indexOf("="),-1===P?M=P=a.length:(P+=A,M=a.substring(A,P).lastIndexOf(" "),M=-1===M?a.length:M+A),E[x].push(a.substring(G,M)),x++,F=!1,A=M),A++;return E};a.LessonParser.prototype.parseText=function(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 d(a,b){u=[];u.type="matrix";u.rows=a;u.cols=b;var c;s=0;for(m=b;s<m;s++){c=[];k=0;for(t=a;k<t;k++)c.push(0);u[s]=c}return u}
function e(a,b){p=a.rows;q=a.cols;u=d(p,q);var c;for(s=0;s<p;s++)for(k=0;k<q;k++){for(m=c=0;m<q;m++)c+=a[m][s]*b[k][m];u[k][s]=c}return u}function h(a,b,c){for(var f=d(c.length-1,c.length-1),g=0,e=f.length;g<e;g++)for(var h=0;h<e;h++)f[g][h]=g<a?h<b?c[g][h]:c[g][h+1]:g<b?c[g+1][h]:c[g+1][h+1];return f}function b(a){if(1<a.cols){for(var c=0,f=1,d=0,g=a.cols;d<g;d++)c+=f*a[0][d]*b(h(0,d,a)),f=-f;return c}return a[0][0]}if(a.loadLib)return a;var c,l={},f=Math.floor,g,r,n,j;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){g=this.childs.length-1;lastChild=this.childs[g];lastChild.parent=null;this.childs[g]=a;a.parent=this;return a};a.Node.prototype.contains=function(a){if(this.value===a)return!0;for(var b=0,c=this.childs.length;b<c;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","=="),j=new a.Node("number","0"),n.addChild(this),n.addChild(j),r=this.getRoot(),r.setAllEvaluateFunction(),r):this};a.Node.prototype.setAllEvaluateFunction=function(){this.setEvaluateFunction();for(var a=0,b=this.childs.length;a<b;a++)this.childs[a].setAllEvaluateFunction()};a.Node.prototype.setEvaluateFunction=function(){if("number"===this.type)this.evaluate=
function(){return parseFloat(this.value)};else if("string"===this.type)this.evaluate=function(){return this.value};else if("identifier"===this.type&&0===this.childs.length)if("rnd"==this.value)this.evaluate=function(){return Math.random()};else{var a;this.evaluate=function(b,c){a=b.variables[this.value];if("object"===typeof a)return a.evaluate(b);if(void 0==a&&(c||b.matrices[this.value]))a=b.matrices[this.value];return void 0!==a?a:0}}else if("identifier"===this.type&&"square_bracket"===this.childs[0].type&&
1===this.childs[0].childs.length){var g,j;this.evaluate=function(a){g=this.childs[0].childs[0].evaluate(a);try{return j=a.vectors[this.value][0>g?0:f(g)],void 0!==j?j:0}catch(b){return 0}}}else if("identifier"===this.type&&"square_bracket"===this.childs[0].type&&1<this.childs[0].childs.length){var r,n;this.evaluate=function(a){r=this.childs[0].childs[0].evaluate(a);n=this.childs[0].childs[1].evaluate(a);try{return j=a.matrices[this.value][0>r?0:f(r)][0>n?0:f(n)],void 0!==j?j:0}catch(b){return 0}}}else if("identifier"===
this.type&&"parentheses"===this.childs[0].type){var m;this.evaluate=function(a){m=[];for(var b=0,f=this.childs[0].childs.length;b<f;b++)m[b]=this.childs[0].childs[b].evaluate(a);return"_Eval_"===this.value?(m[0]=0<m.length?m[0].toString():"",c=m[0].replace(a.parent.decimal_symbol_regexp,"."),void 0==l[c]&&(l[c]=a.parser.parse(c)),a.evalExpression(l[c])):a.functions[this.value].apply(a,m)}}else if("operator"===this.type){var t,x,F;"+"===this.value?this.evaluate=function(a){t=this.childs[0].evaluate(a,
!0);x=this.childs[1].evaluate(a,!0);if("matrix"!==t.type||"matrix"!==x.type)return t+x;a=t;var b=x;p=a.rows;q=a.cols;u=d(p,q);for(s=0;s<p;s++)for(k=0;k<q;k++)u[k][s]=a[k][s]+b[k][s];return u}:"-"===this.value?this.evaluate=function(a){t=this.childs[0].evaluate(a,!0);x=this.childs[1].evaluate(a,!0);if("matrix"!==t.type||"matrix"!==x.type)return t-x;a=t;var b=x;p=a.rows;q=a.cols;u=d(p,q);for(s=0;s<p;s++)for(k=0;k<q;k++)u[k][s]=a[k][s]-b[k][s];return u}:"*"===this.value?this.evaluate=function(a){t=this.childs[0].evaluate(a,
!0);x=this.childs[1].evaluate(a,!0);return"matrix"!==t.type||"matrix"!==x.type?t*x:e(t,x)}:"/"===this.value?this.evaluate=function(a){t=this.childs[0].evaluate(a,!0);x=this.childs[1].evaluate(a,!0);if("matrix"!==t.type||"matrix"!==x.type)return t/x;a=t;var c;c=x;var f=d(c.length,c.length),g=b(c);if(0===g)c=0;else{var g=1/g,j;if(1<c.length)for(var l=0,k=c.length;l<k;l++){j=g;for(var r=0;r<k;r++)f[r][l]=j*b(h(l,r,c)),j=-j;g=-g}else f[0][0]=g;c=f}a=0===c?d(a.rows,a.cols):e(a,c);return a}:"%"===this.value?
this.evaluate=function(a){t=this.childs[0].evaluate(a);x=this.childs[1].evaluate(a);return t-f(t/x)*x}:"^"===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))+0}:"<="===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)<=this.childs[1].evaluate(a))+0}:">"===this.value?this.evaluate=
function(a){return(this.childs[0].evaluate(a)>this.childs[1].evaluate(a))+0}:">="===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)>=this.childs[1].evaluate(a))+0}:"=="===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)===this.childs[1].evaluate(a))+0}:"!="===this.value&&(this.evaluate=function(a){return(this.childs[0].evaluate(a)!=this.childs[1].evaluate(a))+0});else if("boolOperator"===this.type)"&"===this.value?this.evaluate=function(a){return(t=this.childs[0].evaluate(a)?
1:0)?this.childs[1].evaluate(a)?1:0:0}:"|"===this.value?this.evaluate=function(a){return(t=this.childs[0].evaluate(a)?1:0)?1:this.childs[1].evaluate(a)?1:0}:"!"===this.value&&(this.evaluate=function(a){t=this.childs[0].evaluate(a)?1:0;return!t+0});else if("conditional"===this.type)this.evaluate=function(a){t=this.childs[0].evaluate(a);return 0<t?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){var G,J;this.evaluate=function(a){G=this.childs.length;F=[];if(1===G&&1===this.childs[0].childs.length&&"(expr)"===this.type)F=this.childs[0].childs[0].evaluate(a);else for(var b=0;b<G;b++){J=[];for(var c=0,f=this.childs[b].childs.length;c<f;c++)J.push(this.childs[b].childs[c].evaluate(a));F[b]=J}return F}}else if("asign"===
this.type){var H,w,K,C,I,L;this.evaluate=function(a){H=this.childs[0];w=this.childs[1];1===H.childs.length&&"square_bracket"===H.childs[0].type?(g=H.childs[0].childs,1===g.length?(K=g[0].evaluate(a),K=0>K?0:f(K),a.vectors[H.value][K]=w.evaluate(a)):2===g.length&&(C=g[0].evaluate(a),I=g[1].evaluate(a),C=0>C?0:f(C),I=0>I?0:f(I),a.matrices[H.value][C]||(a.matrices[H.value][C]=[]),a.matrices[H.value][C][I]=w.evaluate(a))):(L=w.evaluate(a),L.type?a.matrices[H.value]=L:"object"!==typeof a.variables[H.value]&&
(a.variables[H.value]=L))}}};var p,q,u,k,s,m,t;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,c=this.childs.length;b<c;b++)a+=this.sep+this.childs[b].toString();return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,e,h,b,c,l,f,g,r,n=/^\s+/,j=/^[a-zA-Z_\u00C0-\u021B]+[a-zA-Z_0-9\u00C0-\u021B]*([.]*[0-9a-zA-Z_\u00C0-\u021B]+[0-9]*)*/,p=/^[0-9]+[.][0-9]+|^[.][0-9]+|^[0-9]+/,
q=/^==|^!=|^<=|^<|^>=|^>|^#/,u=/^\!|^\~|^\&\&|^\&|^\|\||^\|/,k=/^=/,s=/^[\?\:]/,m=/^[\+\-\*\/\%\^]/,t=/^\[|^\]/,v=/^\(|^\)/,y=/^,/,B=/^;/,z=/\|/g,D=/\|\*/g,E=/\*\|/g;a.Tokenizer=function(){};a.Tokenizer.prototype.tokenize=function(a){function x(a,c,f){e.push({type:a,value:c});l=l.slice(f);b+=f;g++;r=a}if(d=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(D,"'").replace(E,
"'"));a.match(/\=\|/g)&&(a=a.replace(z,"'"));var A=a.trim();"|"==A.charAt(0)&&"|"==A.charAt(A.length-1)&&(a=A.replace(z,"'"))}e=[];h=!1;b=0;l=a;g=0;for(r="";a&&b<a.length;)if(h=b,"'"==l[0]){for(f=1;"'"!=l[f];)if(f<l.length)f++;else{console.log(">Error, unknown symbol: ["+l+"], in the string <<"+d+">>");return}c=l.substring(1,f);x("string",c,c.length+2)}else if(c=l.match(n))l=l.slice(c[0].length),b+=c[0].length,g++;else if(c=l.match(j))"number"===r&&e.push({type:"operator",value:"*"}),x("identifier",
c[0],c[0].length);else if(c=l.match(p))x("number",c[0],c[0].length);else if(c=l.match(q))A=c[0],"#"==A&&(A="!="),x("compOperator",A,c[0].length);else if(c=l.match(u))A=c[0],"||"==A?A="|":"&&"==A?A="&":"~"==A&&(A="!"),x("boolOperator",A,c[0].length);else if((c=l.match(k))&&!l.match(/^==/))x("asign",c[0],c[0].length);else if(c=l.match(s))x("conditional",c[0],c[0].length);else if(c=l.match(m))x("operator",c[0],c[0].length);else if(c=l.match(t))x("square_bracket",c[0],c[0].length);else if(c=l.match(v))"("==
c&&"number"===r&&e.push({type:"operator",value:"*"}),x("parentheses",c[0],c[0].length);else if(c=l.match(y))x("separator",c[0],c[0].length);else if(178===l.charCodeAt(0))e.push({type:"operator",value:"^"}),x("number",2,1);else if(179===l.charCodeAt(0))e.push({type:"operator",value:"^"}),x("number",3,1);else if(c=l.match(B))x("final_of_expresion",c[0],c[0].length);else if(h==b){console.log("Error, simbolo no conocido: ["+l+"], en la cadena <<"+d+">>");return}return e};var A,x=/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||"";A="";for(var c=0,f=a.length;c<f;c++)A="string"==a[c].type?A+"&squot;"+a[c].value+"&squot;":"identifier"==a[c].type&&!a[c].value.match(x)?A+b+a[c].value:A+a[c].value;return A};return a}(descartesJS||{}),descartesJS=function(a){function d(a){return isNaN(parseFloat(a))?a.replace(/^\s|\s$/g,"").replace(/^'|'$/g,""):parseFloat(a)}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.registerDefaultValues()};a.Parser.prototype.setVariable=function(a,b){this.variables[a]=b};a.Parser.prototype.getVariable=function(a){return this.variables[a]};a.Parser.prototype.setVector=function(a,b,c){this.vectors[a][b]=c};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,c,f){this.matrices[a][b][c]=f};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 e,h,b,c,l,f,g,r,n,j,p,q;a.Parser.prototype.parse=function(d,k){(b=this.tokenizer.tokenize(d))||(b=[]);c=null;k=!k||!1;e=r=g=f=0;for(h=b.length;e<h;e++)if(n=b[e],j=n.value,p=n.type,"identifier"===p&&(e+1<h&&"parentheses"===
b[e+1].type&&"("===b[e+1].value?this.getFunction(j):e+1<h&&"square_bracket"===b[e+1].type&&"["===b[e+1].value?b[e+3]&&"square_bracket"===b[e+3].type&&"]"===b[e+3].value?this.getVector(j):this.getMatrix(j):this.getVariable(j)),"asign"===p&&k&&(p="compOperator",j="=="),"asign"===p)if(l=new a.Node(p,j),null!=c)if("identifier"===c.type)c.parent&&c.parent.replaceLastChild(l),l.addChild(c),c=l,k=!0;else if("square_bracket"===c.type)l.addChild(c.parent),c=l,k=!0;else{l.type="compOperator";l.value="==";for(k=
!0;c.parent&&this.getPrecedence(c.parent.value)>=this.getPrecedence(l.value);)c=c.parent;c.parent&&c.parent.replaceLastChild(l);l.addChild(c);c=l}else{console.log("Error1: en la expresion <<"+d+">>, en el token {valor: "+j+", tipo: "+p+"}");break}else if("parentheses"===p&&"("===j||"square_bracket"===p&&"["===j)if(l=new a.Node(p,j),"("===j&&f++,"["===j&&g++,null===c)"("===j&&(new a.Node("(expr)","(expr)")).addChild(l),"["===j&&(new a.Node("[expr]","[expr]")).addChild(l),c=l;else if("operator"===c.type||
"boolOperator"===c.type||"compOperator"===c.type||"conditional"===c.type||"asign"===c.type)c.addChild(l),c=l;else if("sign"===c.type)c.addChild(l),c=l;else if("parentheses"===c.type&&"("===c.value)c.addChild(l),c=l;else if("square_bracket"===c.type&&"["===c.value)c.addChild(l),c=l;else if("parentheses"===c.type&&"()"===c.value)c.parent.addChild(l),c=l;else if("square_bracket"===c.type&&"[]"===c.value)c.parent.addChild(l),c=l;else if("identifier"===c.type)c.addChild(l),c=l;else{console.log("Error2: en la expresion <<"+
d+">>, en el token ["+e+"] {valor: "+j+", tipo: "+p+"}");break}else if("parentheses"===p&&")"===j)if(f--,null===c)console.log("Error3: en la expresion <<"+d+">>, en el token (valor:"+j+", tipo:"+p);else{for(;c&&c.parent&&"("!=c.value;)c=c.parent;if(c&&"("===c.value)c.value="()";else{console.log("Error4: en la expresion <<"+d+">>, en el token {valor: "+j+", tipo: "+p+"}");break}}else if("square_bracket"===p&&"]"===j)if(g--,null===c)console.log("Error5: en la expresion <<"+d+">>, en el token (valor:"+
j+", tipo:"+p);else{for(;c&&c.parent&&"["!=c.value;)c=c.parent;if(c&&"["===c.value)c.value="[]";else{console.log("Error6: en la expresion <<"+d+">>, en el token {valor: "+j+", tipo: "+p+"}");break}}else if("number"===p||"string"===p||"identifier"===p)if(l=new a.Node(p,j),null===c)c=l;else if("operator"===c.type||"compOperator"===c.type||"boolOperator"===c.type||"parentheses"===c.type&&"("===c.value||"square_bracket"===c.type&&"["===c.value||"sign"===c.type||"conditional"===c.type||"asign"===c.type)c.addChild(l),
c=l;else{console.log("Error7: en la expresion <<"+d+">>, en el token {valor: "+j+", tipo: "+p+"}");break}else if("operator"===p||"compOperator"===p||"boolOperator"===p)if(l=new a.Node(p,j),null===c)if("-"===j||"+"===j)l.type="sign",l.value="sign"+j,c=l;else if("!"===j)c=l;else{console.log("Error8: en la expresion <<"+d+">>, en el token {valor: "+j+", tipo: "+p+"}");break}else if("operator"===c.type||"compOperator"===c.type||"boolOperator"===c.type||"asign"===c.type||"conditional"===c.type||"square_bracket"===
c.type&&"["===c.value&&("-"===j||"+"===j||"!"===j)||"parentheses"===c.type&&"("===c.value&&("-"===j||"+"===j||"!"===j)){if("-"===j||"+"===j)l.type="sign",l.value="sign"+j;c.addChild(l);c=l}else if("number"===c.type||"parentheses"===c.type&&"()"===c.value||"square_bracket"===c.type&&"[]"===c.value||"string"===c.type||"identifier"===c.type||"conditional"===c.type||"asign"===c.type){for(;c.parent&&this.getPrecedence(c.parent.value)>=this.getPrecedence(l.value);)c=c.parent;c.parent&&c.parent.replaceLastChild(l);
l.addChild(c);c=l}else{console.log("Error9: en la expresion <<"+d+">>, en el token {valor: "+j+", tipo: "+p+"}");break}else if("conditional"===p)if(l=new a.Node(p,j),null!=c)if("?"===l.value){for(r++;c.parent&&this.getPrecedence(c.parent.value)>this.getPrecedence(l.value);)c=c.parent;c.parent&&c.parent.replaceLastChild(l);l.addChild(c);c=l}else{for(r--;c&&c.parent&&"?"!=c.value;)c=c.parent;if(c&&"?"===c.value)c.value="?:";else{console.log("Error10: en la expresion <<"+d+">>, en el token {valor: "+
j+", tipo: "+p+"}");break}}else{console.log("Error11: en la expresion <<"+d+">>, en el token {valor: "+j+", tipo: "+p+"}");break}else if("separator"===p)if(null!=c)for(;c.parent&&"("!=c.value&&"["!=c.value;)c=c.parent;else{console.log("Error12: en la expresion <<"+d+">>, en el token {valor: "+j+", tipo: "+p+"}");break}else{console.log("Error13: en la expresion <<"+d+">>, en el token {valor: "+j+", tipo: "+p+"}");break}0<f&&alert("Error, faltan parentesis por cerrar: "+d);0>f&&alert("Error, faltan parentesis por abrir: "+
d);0<g&&alert("Error, faltan square bracketss por cerrar: "+d);0>g&&alert("Error, faltan square bracketss por abrir: "+d);0!=r&&alert("Error, condicional incompleta: "+d);(q=c?c.getRoot():null)&&q.setAllEvaluateFunction();return q};a.Parser.prototype.getPrecedence=function(a){switch(a){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}};a.Parser.prototype.registerDefaultValues=function(){function b(a,c){for(var f in c)c.hasOwnProperty(f)&&(a[f]=c[f])}this.variables.rnd=Math.random;this.variables.pi=a.returnValue(Math.PI);this.variables.e=a.returnValue(Math.E);this.variables.Infinity=Infinity;this.variables["-Infinity"]=
-Infinity;this.functions.sqr=function(a){return a*a};this.functions.sqrt=this.functions["ra\u00edz"]=Math.sqrt;this.functions.exp=Math.exp;this.functions.log=Math.log;this.functions.log10=function(a){return Math.log(a)/Math.log(10)};this.functions.abs=Math.abs;this.functions.ent=Math.floor;this.functions.sgn=function(a){return 0<a?1:0>a?-1:0};this.functions.ind=function(a){return a?1:0};this.functions.sin=this.functions.sen=Math.sin;this.functions.cos=Math.cos;this.functions.tan=Math.tan;this.functions.cot=
function(a){return 1/Math.tan(a)};this.functions.sec=function(a){return 1/Math.cos(a)};this.functions.csc=function(a){return 1/Math.sin(a)};this.functions.sinh=this.functions.senh=function(a){return(Math.exp(a)-Math.exp(-a))/2};this.functions.cosh=function(a){return(Math.exp(a)+Math.exp(-a))/2};this.functions.tanh=function(a){return(Math.exp(a)-Math.exp(-a))/(Math.exp(a)+Math.exp(-a))};this.functions.coth=function(a){return 1/this.functions.tanh(a)};this.functions.sech=function(a){return 1/this.functions.cosh(a)};
this.functions.csch=function(a){return 1/this.functions.sinh(a)};this.functions.asin=this.functions.asen=Math.asin;this.functions.acos=Math.acos;this.functions.atan=Math.atan;this.functions.min=Math.min;this.functions.max=Math.max;this.functions._Num_=function(a){return parseFloat(a)};var c=this;this.functions._Trace_=function(a){console.log(a)};this.functions._Stop_Audios_=function(){c.evaluator.parent.stopAudios()};this.functions.esCorrecto=function(b,f,d){return a.esCorrecto(b,f,c.evaluator,d)};
this.functions.escorrecto=function(b,f,d){return a.escorrecto(b,f,c.evaluator,d)};window.parent!==window&&(this.functions["parent.set"]=function(a,b){window.parent.postMessage({type:"set",name:a,value:b},"*");return 0},this.functions["parent.update"]=function(){window.parent.postMessage({type:"update"},"*");return 0},this.functions["parent.exec"]=function(a,b){window.parent.postMessage({type:"exec",name:a,value:b},"*");return 0});this.functions._GetValues_=function(b,f){var d;if(b){d=(d=document.getElementById(b))&&
"descartes/archivo"==d.type?d.text.replace(/&brvbar;/g,"\u00a6"):a.openExternalFile(b);var g=[],e=!1;if(d){d=d.replace(/\r/g,"").split("\n");for(var h=0,j=d.length;h<j;h++)d[h].match("<"+f+">")?(e=d[h].trim().split("<"+f+">"),2==e.length&&""!=e[1]&&(g=g.concat(e[1].split("\u00a6"))),e=!0):d[h].match("</"+f+">")?(e=d[h].trim().split("</"+f+">"),2==e.length&&""!=e[0]&&(g=g.concat(e[0].split("\u00a6"))),e=!1):e&&(g=g.concat(d[h].split("\u00a6")));h=0;for(j=g.length;h<j;h++)e=g[h].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}};this.functions._GetMatrix_=function(b,f){var g;if(b){g=(g=document.getElementById(b))&&"descartes/archivo"==g.type?g.text.replace(/&brvbar;/g,"\u00a6"):a.openExternalFile(b);var e=[],h=!1;e.type="matrix";if(g){g=g.replace(/\r/g,"").split("\n");for(var j=0,l=g.length;j<l;j++)g[j].match("<"+f+">")?(h=g[j].trim().split("<"+f+">"),2==h.length&&
""!=h[1]&&e.push(h[1].split("\u00a6").map(d)),h=!0):g[j].match("</"+f+">")?(h=g[j].trim().split("</"+f+">"),2==h.length&&""!=h[0]&&e.push(h[0].split("\u00a6").map(d)),h=!1):h&&e.push(g[j].split("\u00a6").map(d));c.matrices[f]=e;c.setVariable(f+".filas",e[0].length);c.setVariable(f+".columnas",e.length)}return 0}};var f=document.createElement("a"),g;this.functions._Save_=function(a,b){document.body.appendChild(f);g=new Blob([b.replace(/\\n/g,"\n").replace(/\\q/g,"'")],{type:"text/plain"});f.setAttribute("download",
a);f.setAttribute("href",window.URL.createObjectURL(g));f.click();document.body.removeChild(f);return 0};var e,h,j,l,r=document.createElement("input");r.setAttribute("type","file");onHandleFileSelect=function(b){e=b.target.files;h=new FileReader;h.onload=function(b){a.addExternalFileContent(e[0].name,b.target.result);c.setVariable(j,e[0].name);c.getFunction(l)&&(c.getFunction(l).apply(c.evaluator,[]),c.evaluator.parent.update())};0<e.length&&h.readAsText(e[0])};r.addEventListener("change",onHandleFileSelect);
this.functions._Open_=function(a,b){j=a;l=b;r.click();return 0};this.functions._SaveState_=function(){this.functions._Save_("state.txt",JSON.stringify({variables:this.variables,vectors:this.vectors,matrices:this.matrices}));return 0};var n,p,q=document.createElement("input");q.setAttribute("type","file");onHandleFileSelect2=function(a){a.stopPropagation();a.preventDefault();n=a.target.files;p=new FileReader;p.onload=function(a){var f={};try{f=JSON.parse(a.target.result)}catch(d){}f.variables&&b(c.variables,
f.variables);f.vectors&&b(c.vectors,f.vectors);f.matrices&&b(c.matrices,f.matrices);c.evaluator.parent.update()};0<n.length&&p.readAsText(n[0])};q.removeEventListener("change",onHandleFileSelect2);q.addEventListener("change",onHandleFileSelect2);this.functions._OpenState_=function(){q.click();return 0};this.functions._Rojo_=function(b){return(new a.Color(b)).r/255};this.functions._Verde_=function(b){return(new a.Color(b)).g/255};this.functions._Azul_=function(b){return(new a.Color(b)).b/255};this.functions._AnchoDeCadena_=
function(b,c,f,d){return a.getTextWidth(b,a.convertFont(c+","+f+","+d))};this.functions._GetDay_=function(){return(new Date).getDate()};this.functions._GetMonth_=function(){return(new Date).getMonth()+1};this.functions._GetYear_=function(){return(new Date).getFullYear()};this.functions._GetHours_=function(){return(new Date).getHours()};this.functions._GetMinutes_=function(){return(new Date).getMinutes()};this.functions._GetSeconds_=function(){return(new Date).getSeconds()}};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;var d=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};a.Evaluator.prototype.setVariable=function(a,d){this.variables[a]=d};a.Evaluator.prototype.getVariable=function(a){return this.variables[a]};a.Evaluator.prototype.setVector=function(a,h,b){h=0>h?0:d(h);this.vectors[a][h]=b};
a.Evaluator.prototype.getVector=function(a,h){h=0>h?0:d(h);return this.vectors[a][h]};a.Evaluator.prototype.setMatrix=function(a,h,b,c){h=0>h?0:d(h);b=0>b?0:d(b);this.matrices[a][h][b]=c};a.Evaluator.prototype.getMatrix=function(a,h,b){h=0>h?0:d(h);b=0>b?0:d(b);return this.matrices[a][h][b]};a.Evaluator.prototype.setFunction=function(a,d){this.functions[a]=d};a.Evaluator.prototype.getFunction=function(a){return this.functions[a]};a.Evaluator.prototype.evalExpression=function(a){return a?a.evaluate(this):
0};a.externalEvaluator=new a.Evaluator;return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=2,e=!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 b=0,c=0,l=0;a.RTFNode.prototype.getTextMetrics=function(){if("textBlock"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);for(var f=0,g=this.children.length;f<g;f++)this.children[f].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 f=
this.value,n;"string"!=typeof this.value&&(g=void 0==this.decimals?d:this.evaluator.evalExpression(this.decimals),n=void 0==this.fixed?e:this.fixed,f=this.evaluator.evalExpression(this.value,g,n),parseFloat(f).toString()===f.toString()&&(f=n?parseFloat(f).toFixed(g):a.removeNeedlessDecimals(parseFloat(f).toFixed(g)),f=(""+f).replace(".",this.decimal_symbol)),f+=" ");this.w=a.getTextWidth(f,this.styleString);this.h=h.h}else if("formula"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),
this.getBlockMetric();else if("hyperlink"===this.nodeType){f=a.getFontMetrics(this.styleString);this.baseline=f.baseline;this.descent=f.descent;this.ascent=f.ascent;this.w=a.getTextWidth(this.value,this.styleString);this.h=f.h;this.clickCacher=document.createElement("div");this.clickCacher.setAttribute("style","position: absolute; width: "+this.w+"px; height: "+this.h+"px; cursor: pointer;");var j=this;this.clickCacher.addEventListener("click",function(){j.click=!0;window.open(j.URL,j.URL)})}else if("superIndex"==
this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),g=b,h=c,n=l,f=a.getFontMetrics(this.styleString),this.getBlockMetric(),0>this.h&&(this.ascent=f.ascent,this.descent=f.descent,this.h=this.ascent+this.descent,this.w=1.5*this.spaceWidth),f=n/2-h+this.h,this.superIndexPos=f-this.ascent,this.ascent=f,this.descent=h,this.baseline=this.ascent,this.h=this.ascent+this.descent;else if("subIndex"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),g=b,h=c,n=l,f=a.getFontMetrics(this.styleString),
this.getBlockMetric(),0>this.h&&(this.ascent=f.ascent,this.descent=f.descent,this.h=this.ascent+this.descent,this.w=1.5*this.spaceWidth),this.subIndexPos=h+1,this.ascent=g,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 p=this.children[0],q=this.children[1],f=a.getFontMetrics(p.styleString);p.getBlockMetric();q.getBlockMetric();g=b;h=c;n=l;0>p.h&&(p.h=f.h,
p.w=this.spaceWidth);0>q.h&&(q.h=f.h,q.w=this.spaceWidth);this.h=p.h+q.h-1;this.ascent=p.h+Math.round(n/2)-h;this.descent=this.h-this.ascent;this.baseline=this.ascent;this.w=Math.max(p.w,q.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){n=new a.RTFNode(this.evaluator,"","radicand",h);f=0;for(g=this.children.length;f<g;f++)n.addChild(this.children[f]);this.children=[];this.children[0]=new a.RTFNode(this.evaluator,"","index",h);this.children[1]=n}f=this.children[0];g=this.children[1];0>=f.children.length&&(h=this.style.clone(),h.fontSize=parseInt(h.fontSize-0.2*h.fontSize),f.addChild(new a.RTFNode(this.evaluator," ","text",h)));0>=g.children.length&&
g.addChild(new a.RTFNode(this.evaluator," ","text",this.style.clone()));f.getBlockMetric();g.getBlockMetric();this.ascent=g.h/2<f.h?g.h/2+f.h+2-g.descent:g.ascent+4;this.descent=g.descent;this.baseline=this.ascent;this.h=this.ascent+this.descent;this.w=f.w+g.w+4*this.spaceWidth}else if("sum"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),g=b,h=c,n=l,h=this.children[0],g=this.children[1],n=this.children[2],h.getBlockMetric(),g.getBlockMetric(),n.getBlockMetric(),-1==h.ascent&&
(p=a.getFontMetrics(h.styleString),h.ascent=p.ascent,h.descent=p.descent,h.h=p.h),-1==g.ascent&&(p=a.getFontMetrics(g.styleString),g.ascent=p.ascent,g.descent=p.descent,g.h=p.h),f=a.getFontMetrics(this.styleString),this.ascent=f.h+g.h>n.ascent?f.h-f.descent+g.h:n.ascent,this.descent=h.h>n.descent?h.h+f.descent:n.descent,this.baseline=this.ascent,this.h=this.ascent+this.descent,f=this.style.clone(),f.fontType="Times New Roman",f.Bold="bold",f=f.toString(),f=a.getTextWidth(String.fromCharCode(8721),
f),this.w=Math.max(h.w,g.w,f)+Math.max(n.w,this.spaceWidth)+this.spaceWidth;else if("integral"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),g=b,h=c,n=l,h=this.children[0],g=this.children[1],n=this.children[2],h.getBlockMetric(),g.getBlockMetric(),n.getBlockMetric(),-1==h.ascent&&(p=a.getFontMetrics(h.styleString),h.ascent=p.ascent,h.descent=p.descent,h.h=p.h),-1==g.ascent&&(p=a.getFontMetrics(g.styleString),g.ascent=p.ascent,g.descent=p.descent,g.h=p.h),f=a.getFontMetrics(this.styleString),
this.ascent=f.h+g.h>n.ascent?f.h-f.descent+g.h:n.ascent,this.descent=h.h>n.descent?h.h+f.descent:n.descent,this.baseline=this.ascent,this.h=this.ascent+this.descent,f=this.style.clone(),f.fontSize*=1.5,f.fontType="Times New Roman",f.Bold="bold",f=f.toString(),f=a.getTextWidth(String.fromCharCode(8747),f),this.w=Math.max(h.w,g.w,f)+Math.max(n.w,this.spaceWidth)+2*this.spaceWidth;else if("limit"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),g=b,h=c,n=l,h=this.children[0],g=this.children[1],
n=this.children[2],f=a.getFontMetrics(this.styleString),h.getBlockMetric(),g.getBlockMetric(),n.getBlockMetric(),-1==h.ascent&&(p=a.getFontMetrics(h.styleString),h.ascent=p.ascent,h.descent=p.descent,h.h=p.h),-1==g.ascent&&(p=a.getFontMetrics(g.styleString),g.ascent=p.ascent,g.descent=p.descent,g.h=p.h),-1==n.ascent&&(p=a.getFontMetrics(n.styleString),n.ascent=p.ascent,n.descent=p.descent,n.h=p.h),this.ascent=n.ascent,this.descent=Math.max(f.h,n.descent),this.baseline=this.ascent,this.h=this.ascent+
this.descent,f=a.getTextWidth(" "+String.fromCharCode(8594),this.styleString),0==h.w&&(h.w=this.spaceWidth),0==g.w&&(g.w=this.spaceWidth),0==n.w&&(n.w=this.spaceWidth),this.w=g.w+h.w+n.w+f+this.spaceWidth;else if("matrix"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);f=a.getFontMetrics(this.styleString);g=b;h=c;n=l;n=f.ascent;for(var p=f.descent,q=f.h,u=this.spaceWidth,k,s,f=0,g=this.children.length;f<g;f++)this.children[f].getBlockMetric(),k=this.children[f].h,s=this.children[f].w,
q<k&&(q=k,n=this.children[f].ascent,p=this.children[f].descent),u<s&&(u=s);this.childWidth=u+2*this.spaceWidth;this.childh=q;this.childAscent=n;this.childDescent=p;this.h=this.rows*q;this.ascent=this.h/2+h;this.descent=this.h-this.ascent;this.w=this.columns*this.childWidth+this.spaceWidth}else if("defparts"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);f=a.getFontMetrics(this.styleString);g=b;h=c;n=l;n=f.ascent;p=f.descent;q=f.h;u=this.spaceWidth;f=0;for(g=this.children.length;f<
g;f++)this.children[f].getBlockMetric(),k=this.children[f].h,s=this.children[f].w,q<k&&(q=k,n=this.children[f].ascent,p=this.children[f].descent),u<s&&(u=s);this.childWidth=u+2*this.spaceWidth;this.childh=q;this.childAscent=n;this.childDescent=p;this.h=this.parts*q;this.ascent=this.h/2+h;this.descent=this.h-this.ascent;this.w=u+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),this.componentNumCtrl=this.evaluator.parent.getControlByCId(this.value),h=this.componentNumCtrl.h||0,this.baseline=Math.round(3*h/5),this.descent=Math.round(2*h/5),this.ascent=this.baseline,this.h=h,this.w=this.componentNumCtrl.w):"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,h,e=0,j=this.children.length;e<j;e++){h=this.children[e];h.getTextMetrics();childAscent=h.ascent;childDescent=h.descent;this.w+=h.w;var p=childDescent;h=h.h;b=childAscent;c=p;l=h;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,c,l,j,p,q,u){h=u;this.stableWidth||(d=l,e=j,this.getTextMetrics());q=q?-this.children[0].ascent:0;j=l=0;for(p=this.children.length;j<p;j++)0<j&&(l+=this.children[j-1].h),this.children[j].draw(a,b+0,c+q+l)};a.RTFNode.prototype.drawTextLineBlock=function(a,b,c){for(var d=0,e=0,l=this.children.length;e<l;e++)a.strokeStyle=h,a.fillStyle=h,0<e&&(d+=this.children[e-1].w,"formula"==
this.children[e-1].nodeType&&(d+=2*this.children[e-1].spaceWidth)),this.children[e].draw(a,b+d,c+this.baseline)};a.RTFNode.prototype.drawFormula=function(a,b,c){for(var d=0,h=0,e=this.children.length;h<e;h++)0<h&&(d+=this.children[h-1].w),this.children[h].draw(a,b+this.spaceWidth+d,c)};a.RTFNode.prototype.drawText=function(a,b,c){null!=this.color&&(a.fillStyle=this.color);a.font=this.styleString;a.textAlign="start";a.textBaseline="alphabetic";a.fillText(this.value,b-1,c);if(this.underline){var d=
"bold"==this.style.textBold,h=d?1:0.5;a.lineWidth=d?2:1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(b-1,parseInt(c+this.descent/2)+h);a.lineTo(b-1+this.w,parseInt(c+this.descent/2)+h);a.stroke()}this.overline&&(h=(d="bold"==this.style.textBold)?2:1.5,a.lineWidth=d?2:1,null!=this.color&&(a.strokeStyle=this.color),a.beginPath(),a.moveTo(b-1,parseInt(c-this.ascent)+h),a.lineTo(b-1+this.w,parseInt(c-this.ascent)+h),a.stroke())};a.RTFNode.prototype.drawDynamicText=function(b,c,
h){var l=Math.floor(0.5*this.spaceWidth),j=void 0==this.decimals?d:this.evaluator.evalExpression(this.decimals),p=void 0==this.fixed?e:this.fixed,q=this.evaluator.evalExpression(this.value);parseFloat(q).toString()===q.toString()&&(q=p?parseFloat(q).toFixed(j):a.removeNeedlessDecimals(parseFloat(q).toFixed(j)),q=(""+q).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(q,this.styleString);
b.fillText(q,l+c,h);this.underline&&(p=(j="bold"==this.style.textBold)?1:0.5,b.lineWidth=j?2:1,null!=this.color&&(b.strokeStyle=this.color),b.beginPath(),b.moveTo(l+c-1,parseInt(h+this.descent/2)+p),b.lineTo(l+c-1+this.w,parseInt(h+this.descent/2)+p),b.stroke());this.overline&&(p=(j="bold"==this.style.textBold)?2:1.5,b.lineWidth=j?2:1,null!=this.color&&(b.strokeStyle=this.color),b.beginPath(),b.moveTo(l+c-1,parseInt(h-this.ascent)+p),b.lineTo(l+c-1+this.w,parseInt(h-this.ascent)+p),b.stroke());this.w+=
2*l};a.RTFNode.prototype.drawHyperlink=function(a,b,c){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=c-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,c);var d="bold"==this.style.textBold,h=d?1:0.5;a.lineWidth=d?2:1;a.beginPath();a.moveTo(b-1,Math.ceil(c+this.descent/2)+h-2);a.lineTo(b-1+this.w,Math.ceil(c+this.descent/2)+h-2);a.stroke();a.restore()};a.RTFNode.prototype.drawRadical=function(a,b,c){var d=Math.floor(this.spaceWidth);this.children[0].draw(a,b,Math.floor(c+this.children[1].descent-this.children[1].h/2-this.children[0].descent));this.children[1].draw(a,b+1.5*d+this.children[0].w,
c);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(b,Math.floor(c+this.children[1].descent-this.children[1].h/2));a.lineTo(b+this.children[0].w,Math.floor(c+this.children[1].descent-this.children[1].h/2));a.lineTo(b+this.children[0].w+0.5*d,c+this.children[1].descent);a.lineTo(b+this.children[0].w+1*d,c-this.children[1].ascent);a.lineTo(b+this.children[0].w+2*d+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 d=Math.floor(0.5*this.spaceWidth);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(b+d,parseInt(c-this.ascent+this.children[0].h)-0.5);a.lineTo(b-d+this.w-1,parseInt(c-this.ascent+this.children[0].h)-0.5);a.stroke()};a.RTFNode.prototype.drawNumDen=function(a,b,c){for(var d=0,h=0,e=this.children.length;h<
e;h++)0<h&&(d+=this.children[h-1].w),this.children[h].draw(a,b+d,c+this.baseline)};a.RTFNode.prototype.drawSubIndex=function(a,b,c){for(var d=0,h=0,e=this.children.length;h<e;h++)0<h&&(d+=this.children[h-1].w),this.children[h].draw(a,b+d,c+this.subIndexPos)};a.RTFNode.prototype.drawSuperIndex=function(a,b,c){for(var d=0,h=0,e=this.children.length;h<e;h++)0<h&&(d+=this.children[h-1].w),this.children[h].draw(a,b+d,c-this.superIndexPos)};a.RTFNode.prototype.drawLimit=function(b,c,d){var h=a.getFontMetrics(this.styleString),
e=" "+String.fromCharCode(8594),l=a.getTextWidth(e,this.styleString);this.children[0].draw(b,c,d+h.descent+this.children[0].ascent);this.children[1].draw(b,c+this.children[0].w+l,d+h.descent+this.children[1].ascent);this.children[2].draw(b,c+l+this.children[0].w+this.children[1].w,d);null!=this.color&&(b.fillStyle=this.color);b.font=this.styleString;b.textAlign="start";b.textBaseline="alphabetic";b.fillText("l\u00edm",c+this.children[0].w,d);b.fillText(e,c+this.children[0].w,d+h.descent+this.children[0].ascent)};
a.RTFNode.prototype.drawIntegral=function(b,c,d){var h=this.style.clone();h.fontSize*=1.5;h.fontType="Times New Roman";h.Bold="bold";var h=h.toString(),e=a.getTextWidth(String.fromCharCode(8747),h),l=a.getFontMetrics(h),q=Math.max(this.children[0].w,this.children[1].w,Math.floor(1.5*e));this.children[0].draw(b,c+e,d+l.descent+this.children[0].ascent);this.children[1].draw(b,c+e+this.spaceWidth/2,d-this.ascent+this.children[1].ascent);this.children[2].draw(b,c+q+e,d);null!=this.color&&(b.fillStyle=
this.color);b.font=h;b.textAlign="start";b.textBaseline="alphabetic";b.fillText(String.fromCharCode(8747),c,d+l.descent/2)};a.RTFNode.prototype.drawSum=function(b,c,d){var h=this.style.clone();h.fontType="Times New Roman";h.Bold="bold";var h=h.toString(),e=a.getTextWidth(String.fromCharCode(8721),h),l=a.getFontMetrics(this.styleString),q=Math.max(this.children[0].w,this.children[1].w,e);this.children[0].draw(b,c+(q-this.children[0].w)/2,d+l.descent+this.children[0].ascent);this.children[1].draw(b,
c+(q-this.children[1].w)/2,d-l.ascent-this.children[1].descent);this.children[2].draw(b,c+q,d);null!=this.color&&(b.fillStyle=this.color);b.font=h;b.textAlign="start";b.textBaseline="alphabetic";b.fillText(String.fromCharCode(8721),c+Math.floor((q-e)/2),d-5)};a.RTFNode.prototype.drawMatrix=function(a,b,c){for(var d,h,e=0,l=this.children.length;e<l;e++)d=e%this.columns,h=Math.floor(e/this.columns),this.children[e].draw(a,2*this.spaceWidth+b+d*this.childWidth,c-this.ascent+this.childAscent+h*this.childh);
a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(Math.floor(b+this.spaceWidth)+0.5,c-this.ascent+0.5);a.lineTo(Math.floor(b+this.spaceWidth/2)+0.5,c-this.ascent+0.5);a.lineTo(Math.floor(b+this.spaceWidth/2)+0.5,c+this.descent+0.5);a.lineTo(Math.floor(b+this.spaceWidth)+0.5,c+this.descent+0.5);a.moveTo(Math.floor(b+this.w-this.spaceWidth)-0.5,c-this.ascent+0.5);a.lineTo(Math.floor(b+this.w-this.spaceWidth/2)-0.5,c-this.ascent+0.5);a.lineTo(Math.floor(b+this.w-this.spaceWidth/
2)-0.5,c+this.descent+0.5);a.lineTo(Math.floor(b+this.w-this.spaceWidth)-0.5,c+this.descent+0.5);a.stroke()};a.RTFNode.prototype.drawDefparts=function(a,b,c){for(var d=0,h=this.children.length;d<h;d++)this.children[d].draw(a,b+3*this.spaceWidth,c-this.ascent+this.childAscent+d%this.parts*this.childh);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(parseInt(b+2*this.spaceWidth)+0.5,c-this.ascent+0.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-0.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)+0.5,c+this.descent+0.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,h=0,e=this.children.length;h<e;h++)0<h&&(d+=this.children[h-1].w),this.children[h].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+"");this.componentSpace.yExpr=this.evaluator.parser.parse(c-this.parent.ascent+"")};a.RTFNode.prototype.draw=function(){console.log(">>> Dibujo desconocido ",this.nodeType)};a.RTFNode.prototype.toHTML=
function(){var a="";if("textLineBlock"===this.nodeType||"textBlock"===this.nodeType)for(var b=0,c=this.children.length;b<c;b++)a+=this.children[b].toHTML();else"text"===this.nodeType?a="<span "+this.style.toCSS()+">"+this.value+"</span>":"newLine"===this.nodeType&&(a="<span "+this.style.toCSS()+">"+this.value+"<br /></span>");return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=String.fromCharCode,e,h,b,c,l,f,g,r,n,j,p;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[];e=[];h=a.length;e=[];b="";l=c=0;g=a.charAt(0);r=!1;for(n="text";c<h;)f=g,g=a.charAt(c+1),r?"\\"===g||"{"===g||"}"===g||" "===g||";"===g?(r=!1,b+=f," "===g&&(c++,g=a.charAt(c+1)),(j=b.match(/^\'([0-9a-f]{2})/))?(p="","text"===n&&(p=
e.pop().value),b=p+=d(parseInt(j[1],16))+b.substring(3)):(j=b.match(/^u[0-9]+/))?(p="","text"===n&&(p=e.pop().value),b=p+=d(j[0].substring(1))):("{"===b||"}"===b?(e.push({type:"text",value:b}),n="text"):(e.push({type:"controlWord",value:b}),n="controlWord"),b="")):b+=f:"\\"===f?(r=!0,""!==b&&(e.push({type:"text",value:b}),n="text"),b=""):"{"===f?(l++,""!==b&&e.push({type:"text",value:b}),b="",e.push({type:"openBlock",value:l}),n="openBlock"):"}"===f?(""!==b&&e.push({type:"text",value:b}),b="",e.push({type:"closeBlock",
value:l}),n="closeBlock",l--):b+=f,c++;""!==b&&e.push({type:"text",value:b});return e};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,e,h,b,c,l,f,g,r,n,j,p,q,u,k,s,m,t,v,y,B,z,D,E,A,x,F,G,J,H;a.RTFParser=function(b){this.evaluator=b;this.tokenizer=new a.RTFTokenizer};a.RTFParser.prototype.parse=function(w){w=d=this.tokenizer.tokenize(w);for(var K=[],C=!1,I=!1,L=[],N=0,Q=w.length;N<Q;N++){"openBlock"==w[N].type&&L.push(w[N].value);"closeBlock"==w[N].type&&(L.pop(),0>=
L.length&&(C=!1));if("controlWord"==w[N].type&&("expr"==w[N].value||"decimals"==w[N].value))I=!0;"controlWord"==w[N].type&&"mjaformula"==w[N].value&&(C=!0);if("text"==w[N].type&&C&&!I){for(var R=0,O=w[N].value,P="",M=0,U=O.length;M<U;M++)if("("==O.charAt(M)||")"==O.charAt(M)||"+"==O.charAt(M)||"-"==O.charAt(M)||"*"==O.charAt(M)||"="==O.charAt(M))P=O.substring(R,M),""!=P&&K.push({type:"text",value:P}),K.push({type:O.charAt(M),value:O.charAt(M)}),R=M+1;P=O.substring(R,M);""!=P&&K.push({type:"text",
value:P})}else K.push(w[N]),"text"==w[N].type&&I&&(I=!1)}d=K;e={};b=2;if("openBlock"==d[0].type&&"fonttbl"==d[1].value){for(h=d[0].value;"closeBlock"!=d[b].type&&d[b].value!=h;)e[d[b].value]=d[b+2].value.substring(0,d[b+2].value.length-1),b+=3;b++}c={};l=0;if("openBlock"==d[b].type&&"colortbl"==d[b+1].value){h=d[b++].value;for(b++;"closeBlock"!=d[b].type&&d[b].value!=h;)f=parseInt(d[b++].value.substring(3)).toString(16),g=parseInt(d[b++].value.substring(5)).toString(16),r=parseInt(d[b++].value.substring(4)).toString(16),
";"===d[b].value&&b++,c[l++]="#"+(2>f.length?"0"+f:f)+(2>g.length?"0"+g:g)+(2>r.length?"0"+r:r);b++}n=new a.RTFNode(this.evaluator,"","textBlock","",!1,"");j=new a.RTFNode(this.evaluator,"","textLineBlock","",!1,"");n.addChild(j);u=q=p=null;y=v=t=m=s=k=!1;B=[new a.FontStyle(20,"Arial","","",!1,!1,null)];z=B[0];D=!0;A=E=-1;x=[];H=J=G=F=!1;w=b;for(K=d.length;w<K;w++)if("controlWord"==d[w].type&&e[d[w].value])z.fontType=e[d[w].value];else if("controlWord"==d[w].type&&d[w].value.match(/^fs(\d+)/))z.fontSize=
parseInt(d[w].value.match(/^fs(\d+)/)[1]/2);else if("controlWord"==d[w].type&&"b"==d[w].value)z.textBold="bold";else if("controlWord"==d[w].type&&"b0"==d[w].value)z.textBold="";else if("controlWord"==d[w].type&&"i"==d[w].value)z.textItalic="italic";else if("controlWord"==d[w].type&&"i0"==d[w].value)z.textItalic="";else if("controlWord"==d[w].type&&"ul"==d[w].value)z.textUnderline=!0;else if("controlWord"==d[w].type&&"ulnone"==d[w].value)z.textUnderline=!1;else if("controlWord"==d[w].type&&"ol"==d[w].value)z.textOverline=
!0;else if("controlWord"==d[w].type&&"olnone"==d[w].value)z.textOverline=!1;else if("controlWord"==d[w].type&&d[w].value.match(/^cf(\d+)/))z.textColor=c[parseInt(d[w].value.substring(2))],0<x.length&&(x[x.length-1].style.textColor=z.textColor);else if("openBlock"==d[w].type)E=d[w].value,z=z.clone(),B.push(z),x.push(null);else if("closeBlock"==d[w].type)d[w].value==A&&(A=-1,k=!1,j=j.parent),B.pop(),z=B[B.length-1],x.pop();else if("controlWord"==d[w].type&&"par"==d[w].value){j.addChild(new a.RTFNode(this.evaluator,
"","newLine",z.clone()));n=new a.RTFNode(this.evaluator,"","textLineBlock",z.clone());if("textBlock"!=j.nodeType)for(j=j.parent;"textBlock"!=j.nodeType;)j=j.parent;j.addChild(n);j=n}else if("controlWord"==d[w].type&&"mjaformula"==d[w].value)F=!0,A=E,k=!0,n=new a.RTFNode(this.evaluator,"","formula",z.clone()),j.addChild(n),j=n,x[x.length-1]=n;else if("controlWord"==d[w].type&&("fraction"==d[w].value||"radicand"==d[w].value||"radical"==d[w].value||"what"==d[w].value||"sum"==d[w].value||"integral"==
d[w].value||"limit"==d[w].value))C=x[x.length-2].style.clone(),n=new a.RTFNode(this.evaluator,"",d[w].value,C),x[x.length-2].addChild(n),x[x.length-1]=n;else if("controlWord"==d[w].type&&"index"==d[w].value||"to"==d[w].value||"from"==d[w].value)C=x[x.length-2].style.clone(),C.fontSize=parseInt(C.fontSize-0.2*C.fontSize),8>C.fontSize&&(C.fontSize=8),n=new a.RTFNode(this.evaluator,"",d[w].value,C),x[x.length-2].addChild(n),x[x.length-1]=n;else if("controlWord"==d[w].type&&("num"==d[w].value||"den"==
d[w].value))C=x[x.length-2].style.clone(),C.fontSize=Math.round(C.fontSize-0.1*C.fontSize),8>C.fontSize&&(C.fontSize=8),"num"==d[w].value?n=new a.RTFNode(this.evaluator,"","numerator",C):"den"==d[w].value&&(n=new a.RTFNode(this.evaluator,"","denominator",C)),x[x.length-2].addChild(n),x[x.length-1]=n;else if("controlWord"==d[w].type&&("subix"==d[w].value||"supix"==d[w].value))C=x[x.length-2].style.clone(),C.fontSize=Math.floor(C.fontSize-C.fontSize/3),8>C.fontSize&&(C.fontSize=8),"subix"==d[w].value?
n=new a.RTFNode(this.evaluator,"","subIndex",C):"supix"==d[w].value&&(n=new a.RTFNode(this.evaluator,"","superIndex",C)),n.originalStyle=x[x.length-2].style.clone(),x[x.length-2].addChild(n),x[x.length-1]=n;else if("controlWord"==d[w].type&&("defparts"==d[w].value||"matrix"==d[w].value||"element"==d[w].value))C=x[x.length-2].style.clone(),n=new a.RTFNode(this.evaluator,"",d[w].value,C),x[x.length-2].addChild(n),x[x.length-1]=n,"defparts"==d[w].value?u=n:"matrix"==d[w].value&&(q=n);else if("controlWord"==
d[w].type&&"parts"==d[w].value)y=!0;else if("text"==d[w].type&&y)u.parts=parseInt(d[w].value),y=!1;else if("controlWord"==d[w].type&&"rows"==d[w].value)t=!0;else if("text"==d[w].type&&t)q.rows=parseInt(d[w].value),t=!1;else if("controlWord"==d[w].type&&"columns"==d[w].value)v=!0;else if("text"==d[w].type&&v)q.columns=parseInt(d[w].value),v=!1;else if("controlWord"==d[w].type&&"expr"==d[w].value)D=!1,s=!0;else if("controlWord"==d[w].type&&"decimals"==d[w].value)m=!0;else if("text"==d[w].type&&m)p.decimals=
this.evaluator.parser.parse(d[w].value+""),m=!1;else if("controlWord"==d[w].type&&"fixed1"==d[w].value)p.fixed=!0;else if("controlWord"==d[w].type&&"fixed0"==d[w].value)p.fixed=!1;else if(!("controlWord"==d[w].type&&"component"==d[w].value))if("controlWord"==d[w].type&&"NumCtrl"==d[w].value)G=!0;else if("controlWord"==d[w].type&&"Space"==d[w].value)J=!0;else if("controlWord"==d[w].type&&"hyperlink"==d[w].value)H=!0;else if("text"==d[w].type&&H){textContent=d[w].value.split("|")[0];C=z.clone();n=new a.RTFNode(this.evaluator,
textContent,"hyperlink",C);n.URL=d[w].value.split("|")[1];if("textLineBlock"!=j.nodeType)for(j=j.parent;"textLineBlock"!=j.nodeType;)j=j.parent;j.addChild(n);H=!1}else if("text"==d[w].type&&G)n=new a.RTFNode(this.evaluator,d[w].value,"componentNumCtrl",z.clone()),j.addChild(n),G=!1;else if("text"==d[w].type&&J)n=new a.RTFNode(this.evaluator,d[w].value,"componentSpace",z.clone()),j.addChild(n),J=!1;else if("text"==d[w].type&&s)C=x[x.length-2].style.clone(),textContent=this.evaluator.parser.parse(d[w].value),
n=new a.RTFNode(this.evaluator,textContent,"dynamicText",C),x[x.length-2].addChild(n),p=x[x.length-1]=n,s=!1;else if("text"==d[w].type&&!s&&!k){textContent=d[w].value;n=new a.RTFNode(this.evaluator,textContent,"text",z.clone());if("textLineBlock"!=j.nodeType)for(j=j.parent;"textLineBlock"!=j.nodeType;)j=j.parent;j.addChild(n)}else if("text"==d[w].type&&!s&&k)textContent=d[w].value,n=new a.RTFNode(this.evaluator,textContent,"text",x[x.length-1].style.clone()),x[x.length-1].addChild(n);else if("("==
d[w].type||")"==d[w].type)C=x[x.length-1].style.clone(),C.textItalic="",n=new a.RTFNode(this.evaluator,d[w].type,"mathSymbol",C),x[x.length-1].addChild(n);else if("+"==d[w].type||"-"==d[w].type||"*"==d[w].type||"="==d[w].type)n=new a.RTFNode(this.evaluator,d[w].type,"mathSymbol",x[x.length-1].style.clone()),x[x.length-1].addChild(n);if(null!=j){var T=j.getRoot();T.stableWidth=D;T.getTextMetrics();T.hasFormula=F}return T};a.FontStyle=function(a,b,c,d,f,h,e){this.fontSize=a;this.fontType=b;this.textItalic=
c;this.textBold=d;this.textUnderline=f;this.textOverline=h;this.textColor=e};a.FontStyle.prototype.toString=function(){return(this.textBold+" "+this.textItalic+" "+this.fontSize+"px "+this.fontType).trim()};a.FontStyle.prototype.toCSS=function(){var a="style='font: "+this.fontSize+"px "+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 d,e,h,b,c,l,f,g,r,n,j,p,q,u;a.Space=function(b,c){this.parent=b;e=this.evaluator=this.parent.evaluator;h=e.parser;this.id="";this.values=c;this.type="R2";this.xExpr=h.parse("0");this.yExpr=h.parse("0");this.w=parseInt(b.container.width);this.h=parseInt(b.container.height);this.drawif=h.parse("1");this.fixed=2!=b.version?!1:!0;
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="descinst.com.mja.descartes.DescartesJS.class"===b.code||b.arquimedes?new a.Color("f0f8fa"):new a.Color("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.x_axis=2!=b.version?"":" ";this.y_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.backgroundGraphics=[];this.zIndex=b.zIndex;this.plecaHeight=b.plecaHeight||0;this.displaceRegionNorth=b.displaceRegionNorth||0;this.displaceRegionWest=b.displaceRegionWest||0;for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);this.init()};a.Space.prototype.init=function(){d=this.parent;e=this.evaluator;b=this.id;this.displaceRegionNorth=d.displaceRegionNorth||
0;this.displaceRegionWest=d.displaceRegionWest||0;void 0!=this.wExpr&&(this.w=(parseInt(d.container.width)-this.displaceRegionWest)*parseFloat(this.wExpr)/100);void 0!=this.hExpr&&(this.h=(parseInt(d.container.height)-this.displaceRegionNorth)*parseFloat(this.hExpr)/100);f=parseInt(d.container.height);g=parseInt(d.container.width);this.x=e.evalExpression(this.xExpr)+this.displaceRegionWest;this.y=e.evalExpression(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=f-this.y,this.h>c&&(this.h=c)):(c=this.h+this.y,this.h=c>=f?f:c);0<=this.x?(l=g-this.x,this.w>l&&(this.w=l)):(l=this.w+this.x,this.w=l>=g?g:l);if(""!=this.imageSrc||!this.imageSrc.trim().toLowerCase().match(/vacio.gif$/))this.image=d.getImage(this.imageSrc);this.OxExpr&&(n=this.OxExpr,"%"===n[n.length-1]?this.Ox=this.w*parseFloat(n)/100:(r=parseFloat(n),r!=n&&(r=0),this.Ox=r));this.OyExpr&&(j=this.OyExpr,"%"===j[j.length-1]?this.Oy=this.h*
parseFloat(j)/100:(r=parseFloat(j),r!=j&&(r=0),this.Oy=r));""!==this.id&&2!==d.version?(e.setVariable(b+"._w",this.w),e.setVariable(b+"._h",this.h),e.setVariable(b+".escala",this.scale),e.setVariable(b+".Ox",this.Ox),e.setVariable(b+".Oy",this.Oy),e.setVariable(b+".mouse_x",0),e.setVariable(b+".mouse_y",0),e.setVariable(b+".mouse_pressed",0),e.setVariable(b+".mouse_clicked",0),e.setVariable(b+".clic_izquierdo",0)):(r=e.getVariable("_w"),void 0===r&&(r=this.w),e.setVariable("_w",r),r=e.getVariable("_h"),
void 0===r&&(r=this.h),e.setVariable("_h",r),r=e.getVariable("escala"),void 0===r&&(r=this.scale),e.setVariable("escala",r),r=e.getVariable("Ox"),void 0===r&&(r=this.Ox),e.setVariable("Ox",r),r=e.getVariable("Oy"),void 0===r&&(r=this.Oy),e.setVariable("Oy",r),e.setVariable("mouse_x",0),e.setVariable("mouse_y",0),e.setVariable("mouse_pressed",0),e.setVariable("mouse_clicked",0),e.setVariable("clic_izquierdo",0),""===this.x_axis&&(""===this.y_axis&&2==d.version)&&(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){a.background&&"R3"!==this.type?this.backgroundGraphics.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};a.Space.prototype.findOffset=function(){p=this.container;this.offsetTop=this.offsetLeft=0;this.container&&this.container.style&&(q=this.container.style.display);this.container.style.display="block";if(p.getBoundingClientRect){var a=p.getBoundingClientRect();this.offsetLeft=a.left;
this.offsetTop=a.top}else for(;p;)p.tagName&&"html"!==p.tagName.toLowerCase()?(this.offsetLeft+=p.offsetLeft||0,this.offsetTop+=p.offsetTop||0,p=p.parentNode):p=null;this.container&&this.container.style&&(this.container.style.display=q)};a.Space.prototype.getCursorPosition=function(b){u=a.getCursorPosition(b);return{x:u.x-this.offsetLeft,y:u.y-this.offsetTop}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d;a.SpaceExternal=function(a){d=this;d.parent=a;d.width=228;d.vSpace=
25;d.container=document.createElement("div");d.container.setAttribute("id","_DescartesExternalRegion_");d.container.setAttribute("style","-webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; border-style: ridge; border-width: 5px; border-color: gray; box-shadow: 0px 0px 25px 5px #000; overflow-y: scroll; overflow-x: hidden; position: absolute; left: 0px; top: 0px; z-index: 10000; width: "+(d.width+27)+"px; height: 460px; background-color: #63b4fb");d.moveManipulator=
document.createElement("div");d.moveManipulator.setAttribute("style"," position: absolute; left: 0px; top: 0px; width: "+(d.width+27)+"; height: "+d.vSpace+"px; line-height: "+d.vSpace+"px; background-color: ddd; cursor: move; padding-left: 75px; font-family: Sans-Serif; font-size: 18px;");d.moveManipulator.innerHTML="Descartes";d.container.appendChild(d.moveManipulator);d.ctrs=[]};a.SpaceExternal.prototype.init=function(){function e(b){d.newPosition=a.getCursorPosition(b);d.container.style.left=
d.initialPosition.x+(d.newPosition.x-d.oldPosition.x)+"px";d.container.style.top=d.initialPosition.y+(d.newPosition.y-d.oldPosition.y)+"px"}function h(a){a.preventDefault();d.findOffset();document.body.removeEventListener("mousemove",e);document.body.removeEventListener("mouseup",h)}document.body.appendChild(this.container);d=this;var b=d.parent.evaluator.parser,c;c=0;for(var l=d.ctrs.length;c<l;c++)d.ctrs[c].expresion=b.parse("(0,"+(d.vSpace+23+35*c)+","+d.width+",35)"),d.ctrs[c].update();d.numCtr=
l;c="espa\u00f1ol"==d.language?"cr\u00e9ditos":"english"==d.language?"about":"cr\u00e9ditos";c=new a.Button(d.parent,{region:"external",name:c,font_size:b.parse("15"),expresion:b.parse("(0,"+d.vSpace+","+d.width/2+",25)")});c.actionExec={execute:a.showAbout};c.update();(new a.Button(d.parent,{region:"external",name:"config",font_size:b.parse("15"),action:"config",expresion:b.parse("("+d.width/2+","+d.vSpace+","+d.width/2+",25)")})).update();c="espa\u00f1ol"==d.language?"inicio":"english"==d.language?
"init":"inicio";(new a.Button(d.parent,{region:"external",name:c,font_size:b.parse("15"),action:"init",expresion:b.parse("(0,"+(d.vSpace+23+35*l)+","+d.width/2+",25)")})).update();c="espa\u00f1ol"==d.language?"limpiar":"english"==d.language?"clear":"limpiar";(new a.Button(d.parent,{region:"external",name:c,font_size:b.parse("15"),action:"clear",expresion:b.parse("("+d.width/2+","+(d.vSpace+23+35*l)+","+d.width/2+",25)")})).update();c="espa\u00f1ol"==d.language?"cerrar":"close";b=new a.Button(d.parent,
{region:"external",name:c,font_size:b.parse("15"),expresion:b.parse("("+d.width/4+","+(d.vSpace+46+35*l)+","+d.width/2+",25)")});b.update();b.canvas.addEventListener("click",function(){d.hide()});d.setPositionAndSize();d.moveManipulator.addEventListener("mousedown",function(b){b.preventDefault();d.oldPosition=a.getCursorPosition(b);d.initialPosition={x:d.container.offsetLeft,y:d.container.offsetTop};document.body.addEventListener("mousemove",e);document.body.addEventListener("mouseup",h)});d.findOffset();
d.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(){var a=this.vSpace+46+35*this.numCtr+25+10;this.container.style.left=Math.max(parseInt(window.innerWidth-this.width)/2,0)+"px";this.container.style.top="5px";this.container.style.height=window.innerHeight<
this.vSpace+75?this.vSpace+75+"px":a>window.innerHeight-10?window.innerHeight-10:a+"px"};a.SpaceExternal.prototype.findOffset=function(){tmpContainer=this.container;this.offsetTop=this.offsetLeft=0;this.container&&this.container.style&&(tmpDisplay=this.container.style.display);this.container.style.display="block";if(tmpContainer.getBoundingClientRect){var a=tmpContainer.getBoundingClientRect();this.offsetLeft=a.left;this.offsetTop=a.top}else for(;tmpContainer;)tmpContainer.tagName&&"html"!==tmpContainer.tagName.toLowerCase()?
(this.offsetLeft+=tmpContainer.offsetLeft||0,this.offsetTop+=tmpContainer.offsetTop||0,tmpContainer=tmpContainer.parentNode):tmpContainer=null;this.container&&this.container.style&&(this.container.style.display=tmpDisplay);for(var a=0,d=this.ctrs.length;a<d;a++)this.ctrs[a].findOffset&&this.ctrs[a].findOffset()};return a}(descartesJS||{}),descartesJS=function(a){var d,e;if(a.loadLib)return a;var h=Math.floor,b=Math.round,c=2*Math.PI,l=a.convertFont("SansSerif,PLAIN,12"),f=a.convertFont("Monospaced,PLAIN,12"),
g,r,n,j,p,q,u,k,s,m,t,v,y,B,z,D,E,A,x,F,G,J,H,w,K,C,I,L,N;a.Space2D=function(b,c){a.Space.call(this,b,c);g=this;g.backgroundCanvas=document.createElement("canvas");g.backgroundCanvas.setAttribute("id",g.id+"_background");g.backgroundCanvas.setAttribute("width",g.w+"px");g.backgroundCanvas.setAttribute("height",g.h+"px");g.backgroundCtx=g.backgroundCanvas.getContext("2d");g.backgroundCtx.imageSmoothingEnabled=!1;g.backgroundCtx.mozImageSmoothingEnabled=!1;g.backgroundCtx.webkitImageSmoothingEnabled=
!1;g.canvas=document.createElement("canvas");g.canvas.setAttribute("id",g.id+"_canvas");g.canvas.setAttribute("width",g.w+"px");g.canvas.setAttribute("height",g.h+"px");g.canvas.setAttribute("class","DescartesSpace2DCanvas");g.canvas.setAttribute("style","z-index: "+g.zIndex+";");g.ctx=g.canvas.getContext("2d");g.ctx.imageSmoothingEnabled=!1;g.ctx.mozImageSmoothingEnabled=!1;g.ctx.webkitImageSmoothingEnabled=!1;g.graphicControlContainer=document.createElement("div");g.graphicControlContainer.setAttribute("id",
g.id+"_graphicControls");g.graphicControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+g.zIndex+";");g.numericalControlContainer=document.createElement("div");g.numericalControlContainer.setAttribute("id",g.id+"_numericalControls");g.numericalControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+g.zIndex+";");g.container=document.createElement("div");g.container.setAttribute("id",g.id);g.container.setAttribute("class","DescartesSpace2DContainer");
g.container.setAttribute("style","left: "+g.x+"px; top: "+g.y+"px; z-index: "+g.zIndex+";");g.parent.arquimedes&&"#f0f8fa"===g.background.getColor()&&(g.container.style.border="1px solid #b8c4c8");g.container.appendChild(g.backgroundCanvas);g.container.appendChild(g.canvas);g.container.appendChild(g.graphicControlContainer);g.container.appendChild(g.numericalControlContainer);b.container.insertBefore(g.container,b.loader);g.parent.images[g.id+".image"]=g.canvas;g.parent.images[g.id+".image"].ready=
1;g.parent.images[g.id+".image"].complete=!0;g.evaluator.setVariable(g.id+".image",g.id+".image");g.parent.images[g.id+".back"]=g.backgroundCanvas;g.parent.images[g.id+".back"].ready=1;g.parent.images[g.id+".back"].complete=!0;g.evaluator.setVariable(g.id+".back",g.id+".back");""!==g.id&&2!==b.version?(g.OxString=g.id+".Ox",g.OyString=g.id+".Oy",g.scaleString=g.id+".escala",g.wString=g.id+"._w",g.hString=g.id+"._h",g.mxString=g.id+".mouse_x",g.myString=g.id+".mouse_y",g.mpressedString=g.id+".mouse_pressed",
g.mclickedString=g.id+".mouse_clicked",g.mclicizquierdoString=g.id+".clic_izquierdo"):(g.OxString="Ox",g.OyString="Oy",g.scaleString="escala",g.wString="_w",g.hString="_h",g.mxString="mouse_x",g.myString="mouse_y",g.mpressedString="mouse_pressed",g.mclickedString="mouse_clicked",g.mclicizquierdoString="clic_izquierdo");g.click=0;g.registerMouseAndTouchEvents()};a.extend(a.Space2D,a.Space);a.Space2D.prototype.init=function(){g=this;g.uber.init.call(g);g.canvas&&(g.backgroundCanvas.setAttribute("width",
g.w+"px"),g.backgroundCanvas.setAttribute("height",g.h+"px"),g.canvas.setAttribute("width",g.w+"px"),g.canvas.setAttribute("height",g.h+"px"));g.container&&g.findOffset()};a.Space2D.prototype.update=function(a){g=this;r=g.evaluator;n=g.parent;r.setVariable(g.wString,g.w);r.setVariable(g.hString,g.h);g.drawIfValue=0<r.evalExpression(g.drawif);if(g.drawIfValue){p=g.x!==r.evalExpression(g.xExpr)+g.displaceRegionWest;q=g.y!==r.evalExpression(g.yExpr)+n.plecaHeight+g.displaceRegionNorth;g.spaceChange=
a||p||q||g.drawBefore!==g.drawIfValue||g.Ox!==r.getVariable(g.OxString)||g.Oy!==r.getVariable(g.OyString)||g.scale!==r.getVariable(g.scaleString);g.x=p?r.evalExpression(g.xExpr)+g.displaceRegionWest:g.x;g.y=q?r.evalExpression(g.yExpr)+n.plecaHeight+g.displaceRegionNorth:g.y;g.Ox=r.getVariable(g.OxString);g.Oy=r.getVariable(g.OyString);g.scale=r.getVariable(g.scaleString);g.drawBefore=g.drawIfValue;1E-6>g.scale?(g.scale=1E-6,r.setVariable(g.scaleString,1E-6)):1E6<g.scale&&(g.scale=1E6,r.setVariable(g.scaleString,
1E6));if(p||q)g.container.style.left=g.x+"px",g.container.style.top=g.y+"px",g.findOffset();g.container.style.display="block";g.drawTrace=!g.spaceChange&&(!g.fixed&&!g.click||g.fixed);g.spaceChange&&g.drawBackground();g.draw()}else g.container.style.display="none"};a.Space2D.prototype.drawBackground=function(){r=this.evaluator;j=this.backgroundCtx;j.clearRect(0,0,this.backgroundCanvas.width,this.backgroundCanvas.height);j.fillStyle=this.background.getColor();j.fillRect(0,0,this.backgroundCanvas.width,
this.backgroundCanvas.height);this.image&&(""!=this.image.src&&this.image.ready&&this.image.complete)&&("topleft"===this.bg_display?j.drawImage(this.image,0,0):"stretch"===this.bg_display?j.drawImage(this.image,0,0,this.w,this.h):"patch"===this.bg_display?(j.fillStyle=j.createPattern(this.image,"repeat"),j.fillRect(0,0,this.canvas.width,this.canvas.height)):"center"===this.bg_display&&j.drawImage(this.image,(this.w-this.image.width)/2,(this.h-this.image.height)/2));k=this.scale;s=0;for(m=0>this.w+
this.h?0:this.w+this.h;k>m;)k/=10,s++;for(;k<m/10;)k*=10;j.lineWidth=1;""!==this.net&&(j.strokeStyle=this.net.getColor(),this.drawMarks(j,k/10,-1));if(2!==this.parent.version&&""!==this.net10||2===this.parent.version&&""!==this.net&&""!==this.net10)j.strokeStyle=this.net10.getColor(),this.drawMarks(j,k,-1);if(""!==this.axes){j.strokeStyle=this.axes.getColor();j.beginPath();if(""!==this.x_axis||2!==this.parent.version)j.moveTo(0,h(this.h/2+this.Oy)+0.5),j.lineTo(this.w,h(this.h/2+this.Oy)+0.5);if(""!==
this.y_axis||2!==this.parent.version)j.moveTo(h(this.w/2+this.Ox)+0.5,0),j.lineTo(h(this.w/2+this.Ox)+0.5,this.h);j.stroke();this.drawMarks(j,k,4);this.drawMarks(j,k/2,2);this.drawMarks(j,k/10,1)}if(""!==this.x_axis||""!==this.y_axis)j.fillStyle=""!==this.axes?this.axes.getColor():"black",j.font=l,j.textAlign="right",j.textBaseline="alphabetic",j.fillText(this.x_axis,h(this.w)-2,h(this.h/2+this.Oy)+12),j.fillText(this.y_axis,h(this.w/2+this.Ox)-2,12);this.numbers&&""!=this.axes&&(j.fillStyle=this.axes.getColor(),
j.font=l,j.textAlign="start",j.textBaseline="bottom",k>(this.w+this.h)/2?this.drawNumbers(j,k/5,k<=this.scale?s+1:s):k>(this.w+this.h)/4?this.drawNumbers(j,k/2,k<=this.scale?s+1:s):this.drawNumbers(j,k,s));for(var a=0,b=this.backgroundGraphics.length;a<b;a++)this.backgroundGraphics[a].draw()};a.Space2D.prototype.draw=function(){j=this.ctx;j.clearRect(0,0,this.canvas.width,this.canvas.height);for(var a=0,b=this.graphics.length;a<b;a++)u=this.graphics[a],""!==u.trace&&this.drawTrace&&u.drawTrace(),
u.draw();a=0;for(b=this.graphicsCtr.length;a<b;a++)this.graphicsCtr[a].update(),this.graphicsCtr[a].draw();""!=this.text&&(this.click&&"L"===this.whichButton)&&(j.fillStyle=this.text.getColor(),j.strokeStyle=j.fillStyle,j.lineWidth=1,j.font=f,j.textAlign="center",j.textBaseline="alphabetic",G=1>=this.scale?this.mouse_x.toFixed(0):this.mouse_x.toFixed(this.scale.toString().length),J=1>=this.scale?this.mouse_y.toFixed(0):this.mouse_y.toFixed(this.scale.toString().length),H="("+G+","+J+")",w=h(j.measureText(H).width/
2),K=this.getAbsoluteX(this.mouse_x),C=this.getAbsoluteY(this.mouse_y),I=h(K),L=h(C-10),I+w>this.w?I=this.w-w:0>I-w&&(I=w),L+1>this.h?L=this.h:0>L-14&&(L=15),j.fillText(H,I,L),j.beginPath(),j.arc(K,C,2.5,0,c,!0),j.stroke())};a.Space2D.prototype.drawMarks=function(a,c,d){t=this.w;v=this.h;E=0;A=t;x=0;F=v;z=h(t/2+this.Ox);D=h(v/2+this.Oy);0<=d&&(E=z-d,A=z+d,x=D-d,F=D+d);a.beginPath();for(d=-b(z/c);(y=z+b(d*c))<t;d++)a.moveTo(y+0.5,x+0.5),a.lineTo(y+0.5,F+0.5);for(d=-b(D/c);(B=D+b(d*c))<v;d++)a.moveTo(E+
0.5,B+0.5),a.lineTo(A+0.5,B+0.5);a.stroke()};a.Space2D.prototype.drawNumbers=function(a,c){t=this.w;v=this.h;z=h(t/2+this.Ox);D=h(v/2+this.Oy);for(var d=-b(z/c);(y=z+b(d*c))<t;d++)a.fillText(parseFloat((d*c/this.scale).toFixed(4)),y+1,D-2);for(d=-b(D/c);(B=D+b(d*c))<v;d++)0!==parseFloat(-d*c/this.scale)&&a.fillText(parseFloat((-d*c/this.scale).toFixed(4)),z+5,B+5)};a.Space2D.prototype.registerMouseAndTouchEvents=function(){function b(a){document.body.focus();n.parent.clearClick();n.click=1;n.evaluator.setVariable(n.mpressedString,
1);n.evaluator.setVariable(n.mclickedString,0);n.evaluator.setVariable(n.mclicizquierdoString,0);n.parent.deactivateGraphiControls();l(a);window.addEventListener("touchmove",k);window.addEventListener("touchend",c);a.stopPropagation();a.preventDefault()}function c(a){document.body.focus();n.click=0;n.evaluator.setVariable(n.mpressedString,0);n.evaluator.setVariable(n.mclickedString,1);n.evaluator.setVariable(n.mclicizquierdoString,1);window.removeEventListener("touchmove",k,!1);window.removeEventListener("touchend",
c,!1);a.preventDefault();n.parent.update()}function f(b){document.body.focus();b.stopPropagation();b.preventDefault();n.parent.clearClick();n.click=1;n.parent.deactivateGraphiControls();n.whichButton=a.whichButton(b);"R"===n.whichButton&&(window.addEventListener("mouseup",g),n.clickPosForZoom=n.getCursorPosition(b).y,n.clickPosForZoomNew=n.clickPosForZoom,n.fixed||(n.tempScale=n.scale,window.addEventListener("mousemove",j)));"L"===n.whichButton&&(n.evaluator.setVariable(n.mpressedString,1),n.evaluator.setVariable(n.mclickedString,
0),n.evaluator.setVariable(n.mclicizquierdoString,0),l(b),window.addEventListener("mousemove",k),window.addEventListener("mouseup",g))}function g(a){document.body.focus();a.stopPropagation();a.preventDefault();n.click=0;n.evaluator.setVariable(n.mpressedString,0);n.evaluator.setVariable(n.mclickedString,1);n.evaluator.setVariable(n.mclicizquierdoString,1);"R"===n.whichButton&&(window.removeEventListener("mousemove",j,!1),n.clickPosForZoom==n.clickPosForZoomNew&&n.parent.externalSpace.show());window.removeEventListener("mousemove",
k,!1);window.removeEventListener("mouseup",g,!1);n.parent.update()}function l(a){n.posAnte=n.getCursorPosition(a);n.mouse_x=n.getRelativeX(n.posAnte.x);n.mouse_y=n.getRelativeY(n.posAnte.y);n.evaluator.setVariable(n.mxString,n.mouse_x);n.evaluator.setVariable(n.myString,n.mouse_y);n.evaluator.setVariable(n.mclickedString,0);n.evaluator.setVariable(n.mclicizquierdoString,0);10<Date.now()-m&&(n.parent.update(),m=Date.now())}function j(a){a.preventDefault();n.clickPosForZoomNew=n.getCursorPosition(a).y;
n.evaluator.setVariable(n.scaleString,n.tempScale+n.tempScale/45*((n.clickPosForZoom-n.clickPosForZoomNew)/10));n.parent.update()}function k(a){a.preventDefault();a.stopPropagation();n.fixed||(n.posNext=n.getCursorPosition(a),d=h(n.posAnte.x-n.posNext.x),e=h(n.posAnte.y-n.posNext.y),n.evaluator.setVariable(n.OxString,n.Ox-d),n.evaluator.setVariable(n.OyString,n.Oy-e),n.posAnte.x-=d,n.posAnte.y-=e);l(a)}var m=0,n=this;N=a.hasTouchSupport;n.canvas.oncontextmenu=function(){return!1};N&&(this.sensitive_to_mouse_movements&&
this.canvas.addEventListener("touchmove",l),this.canvas.addEventListener("touchstart",b));N||(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("mousemove",l),this.canvas.addEventListener("mousedown",f))};return a}(descartesJS||{}),descartesJS=function(a){var d,e,h;function b(a,b){return b.depth-a.depth}function c(b,c){Y=a.subtract3D(b,a.scalarProduct3D(c,a.dotProduct3D(b,c)));V=a.add3D(b,a.scalarProduct3D(Y,-2));W=a.norm3D(V);return 0!==W?a.scalarProduct3D(V,1/W):a.scalarProduct3D(b,
-1)}if(a.loadLib)return a;var l=Math.floor,f=Math.round,g=Math.max,r=Math.cos,n=Math.sin,j=Math.sqrt,p=15*Math.PI/180,q=Math.cos(p),u=Math.sin(p),k,s,m,t,v,y,B,z,D,E,A,x,F,G,J,H,w,K,C,I,L,N,Q,R=[],O,P,M,U,T,X,Y,V,W;a.Space3D=function(b,c){a.Space.call(this,b,c);m=this;m.backgroundCanvas=document.createElement("canvas");m.backgroundCanvas.setAttribute("id",m.id+"_background");m.backgroundCanvas.setAttribute("width",m.w+"px");m.backgroundCanvas.setAttribute("height",m.h+"px");m.canvas=document.createElement("canvas");
m.canvas.setAttribute("id",m.id+"_canvas");m.canvas.setAttribute("width",m.w+"px");m.canvas.setAttribute("height",m.h+"px");m.canvas.setAttribute("class","DescartesSpace3DCanvas");m.canvas.setAttribute("style","z-index: "+m.zIndex+";");m.ctx=m.canvas.getContext("2d");m.ctx.imageSmoothingEnabled=!1;m.ctx.mozImageSmoothingEnabled=!1;m.ctx.webkitImageSmoothingEnabled=!1;m.graphicControlContainer=document.createElement("div");m.graphicControlContainer.setAttribute("id",m.id+"_graphicControls");m.graphicControlContainer.setAttribute("style",
"position: absolute; left: 0px; top: 0px; z-index: "+m.zIndex+";");m.numericalControlContainer=document.createElement("div");m.numericalControlContainer.setAttribute("id",m.id+"_numericalControls");m.numericalControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+m.zIndex+";");m.container=document.createElement("div");m.container.setAttribute("id",m.id);m.container.setAttribute("class","DescartesSpace3DContainer");m.container.setAttribute("style","left: "+m.x+"px; top: "+
m.y+"px; z-index: "+m.zIndex+";");m.container.appendChild(m.backgroundCanvas);m.container.appendChild(m.canvas);m.container.appendChild(m.graphicControlContainer);m.container.appendChild(m.numericalControlContainer);b.container.insertBefore(m.container,b.loader);m.eye={x:0,y:0,z:0};m.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,f=m.lights.length;d<f;d++)m.lights[d]=a.normalize3D(m.lights[d]);m.light3={x:0,y:0,z:0};m.intensity=[0.4,0.5,0.3,0];m.userIntensity=
0;m.dim=1;m.tmpIntensity=[];m.OxStr=m.id+".Ox";m.OyStr=m.id+".Oy";m.scaleStr=m.id+".escala";m.wStr=m.id+"._w";m.hStr=m.id+"._h";m.obsStr=m.id+".observador";m.rotZStr=m.id+".rot.z";m.rotYStr=m.id+".rot.y";m.userI_Dim_Str=m.id+".userIlum.dim";m.userI_I_Str=m.id+".userIlum.I";m.userI_x_Str=m.id+".userIlum.x";m.userI_y_Str=m.id+".userIlum.y";m.userI_z_Str=m.id+".userIlum.z";m.evaluator.setVariable(m.rotZStr,0);m.evaluator.setVariable(m.rotYStr,0);m.evaluator.setVariable(m.userI_Dim_Str,m.dim);m.evaluator.setVariable(m.userI_I_Str,
m.userIntensity);m.evaluator.setVariable(m.userI_x_Str,0);m.evaluator.setVariable(m.userI_y_Str,0);m.evaluator.setVariable(m.userI_z_Str,0);m.registerMouseAndTouchEvents()};a.extend(a.Space3D,a.Space);a.Space3D.prototype.init=function(){m=this;m.uber.init.call(m);m.canvas&&(m.canvas.setAttribute("width",m.w+"px"),m.canvas.setAttribute("height",m.h+"px"));m.container&&m.findOffset();m.w_2=m.w/2;m.h_2=m.h/2;m.oldMouse={x:0,y:0}};a.Space3D.prototype.update=function(a){m=this;k=m.evaluator;s=m.parent;
k.setVariable(m.wStr,m.w);k.setVariable(m.hStr,m.h);m.drawIfValue=0<k.evalExpression(m.drawif);if(m.drawIfValue){D=m.x!==k.evalExpression(m.xExpr)+m.displaceRegionWest;E=m.y!==k.evalExpression(m.yExpr)+s.plecaHeight+m.displaceRegionNorth;m.spaceChange=a||D||E||m.drawBefore!==m.drawIfValue||m.Ox!==k.getVariable(m.OxStr)||m.Oy!==k.getVariable(m.OyStr)||m.scale!==k.getVariable(m.scaleStr);m.x=D?k.evalExpression(m.xExpr)+m.displaceRegionWest:m.x;m.y=E?k.evalExpression(m.yExpr)+s.plecaHeight+m.displaceRegionNorth:
m.y;m.Ox=k.getVariable(m.OxStr);m.Oy=k.getVariable(m.OyStr);m.scale=k.getVariable(m.scaleStr);m.drawBefore=m.drawIfValue;if(a||void 0==m.observer){var b;a=0;for(var c=m.parent.controls.length;a<c;a++)m.parent.controls[a].id===m.obsStr&&(b=!0);m.observer=b?k.getVariable(m.obsStr)||0.5*(m.w+m.h):2.5*(m.w+m.h);m.observer=g(m.observer,0.1*(m.w+m.h));k.setVariable(m.obsStr,m.observer);m.eye={x:m.observer/m.scale*q,y:0,z:m.observer/m.scale*u};m.D=m.scale*m.eye.x/q;m.XE=f(m.scale*m.eye.y+0.5);m.YE=f(m.scale*
m.eye.z+0.5)}m.observer=g(k.getVariable(m.obsStr),0.1*(m.w+m.h));k.setVariable(m.obsStr,m.observer);1E-6>m.scale?(m.scale=1E-6,k.setVariable(m.scaleStr,1E-6)):1E6<m.scale&&(m.scale=1E6,k.setVariable(m.scaleStr,1E6));if(D||E)m.container.style.left=m.x+"px",m.container.style.top=m.y+"px",m.findOffset();m.container.style.display="block";m.dim=k.getVariable(m.userI_Dim_Str);m.userIntensity=k.getVariable(m.userI_I_Str);m.light3={x:parseInt(k.getVariable(m.userI_x_Str)),y:parseInt(k.getVariable(m.userI_y_Str)),
z:parseInt(k.getVariable(m.userI_z_Str))};m.updateCamera();m.draw()}else m.container.style.display="none"};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,c=this.graphics.length;a<c;a++)this.graphics[a].update();this.primitives=[];a=0;for(c=this.graphics.length;a<c;a++){t=this.graphics[a];if(t.split||this.split)for(var d=a+1;d<c;d++)v=this.graphics[d],(v.split||
this.split)&&t.splitFace(v);this.primitives=this.primitives.concat(t.primitives||[])}y=this.primitives;B=y.length;for(a=0;a<B;a++)y[a].computeDepth(this);if("painter"===this.render)this.drawPainter(y);else{y=y.sort(b);for(a=0;a<B;a++)y[a].draw(this.ctx,this)}a=0;for(c=this.graphicsCtr.length;a<c;a++)this.graphicsCtr[a].draw()};var S;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=[],f=[];S=b.shift();for(var h=0,g=b.length;h<g;h++){c=null;for(var e=0,l=b[h].spaceVertices.length;e<l;e++)whereIs=2<S.spaceVertices.length?this.inPlane2(S.spaceVertices[0],S.normal,b[h].spaceVertices[e]):0,whereIs=0<S.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[h]);else if("front"===c)f.push(b[h]);else if(null==c)d.push(b[h]);else{c=null;e=0;for(l=S.spaceVertices.length;e<l;e++)whereIs=2<b[h].spaceVertices.length?this.inPlane2(b[h].spaceVertices[0],b[h].normal,S.spaceVertices[e]):-1,whereIs=0<b[h].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[h]):f.push(b[h])}}b=new a.renderNode(S);b.back=this.buildTree(d);b.front=
this.buildTree(f);return b};a.Space3D.prototype.drawPainter=function(a){a=this.buildTree(a).inOrder();for(var b=0;b<a.length;b++)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)).originalToFixed(8))};a.Space3D.prototype.updateCamera=function(){m=this;m.D=m.observer;m.eye.x=m.D/m.scale;m.eye.y=m.XE/m.scale;m.eye.z=m.YE/m.scale};a.Space3D.prototype.rotateVertex=function(b){w=a.degToRad(m.evaluator.getVariable(m.rotZStr));K=r(w);C=n(w);d=b.x*K-b.y*C;e=b.x*C+b.y*K;h=b.z;w=a.degToRad(m.evaluator.getVariable(m.rotYStr));K=r(w);C=n(w);return{x:h*C+d*K,y:e,z:h*K-d*C}};a.Space3D.prototype.project=function(a){m=this;F=m.eye.x-a.x;G=m.eye.y-a.y;J=m.eye.z-a.z;var b=
j(F*F+G*G+J*J);H=-a.x/b||0;F=this.w_2+this.Ox+m.scale*(a.y+H*(m.eye.y-a.y));G=this.h_2+this.Oy-m.scale*(a.z+H*(m.eye.z-a.z));return{x:F,y:G,z:b}};a.Space3D.prototype.computeColor=function(b,d,h){U=a.subtract3D(this.eye,d.average);T=a.norm3D(U);X=a.scalarProduct3D(U,1/T);this.lights[3]=a.subtract3D(this.light3,d.average);Q=a.norm3D(this.lights[3]);for(var f=0,g=this.intensity.length-1;f<g;f++)R[f]=this.intensity[f]*this.dim;R[3]=this.userIntensity*this.userIntensity/Q||0;O=h?this.dim/2:this.dim/4;
P=0;M=0<=d.direction?d.normal:a.scalarProduct3D(d.normal,-1);f=0;for(g=this.lights.length;f<g;f++)h?(P=Math.max(0,a.dotProduct3D(c(this.lights[f],M),X)),P*=P*P):P=Math.max(0,a.dotProduct3D(this.lights[f],M)),O+=R[f]*P;O=Math.min(O,1);I=l(b.r*O);L=l(b.g*O);N=l(b.b*O);return"rgba("+I+","+L+","+N+","+b.a+")"};a.Space3D.prototype.registerMouseAndTouchEvents=function(){function b(a){document.body.focus();j.click=1;j.evaluator.setVariable(j.id+".mouse_pressed",1);j.parent.deactivateGraphiControls();j.posAnte=
j.getCursorPosition(a);j.oldMouse.x=j.getRelativeX(j.posAnte.x);j.oldMouse.y=j.getRelativeY(j.posAnte.y);g(a);window.addEventListener("touchmove",l);window.addEventListener("touchend",c);a.preventDefault()}function c(a){document.body.focus();j.click=0;j.evaluator.setVariable(j.id+".mouse_pressed",0);window.removeEventListener("touchmove",l,!1);window.removeEventListener("touchend",c,!1);a.preventDefault()}function d(b){document.body.focus();j.click=1;j.parent.deactivateGraphiControls();j.whichButton=
a.whichButton(b);"R"===j.whichButton?(window.addEventListener("mouseup",h),j.clickPosForZoom=j.getCursorPosition(b).y,j.clickPosForZoomNew=j.clickPosForZoom,j.fixed||(j.tempScale=j.scale,window.addEventListener("mousemove",e))):"L"==j.whichButton&&(j.evaluator.setVariable(j.id+".mouse_pressed",1),j.posAnte=j.getCursorPosition(b),j.oldMouse.x=j.getRelativeX(j.posAnte.x),j.oldMouse.y=j.getRelativeY(j.posAnte.y),g(b),window.addEventListener("mousemove",l),window.addEventListener("mouseup",h));b.preventDefault()}
function h(a){document.body.focus();j.click=0;j.evaluator.setVariable(j.id+".mouse_pressed",0);a.preventDefault();"R"===j.whichButton&&(window.removeEventListener("mousemove",e,!1),j.clickPosForZoom==j.clickPosForZoomNew&&j.parent.externalSpace.show());window.removeEventListener("mousemove",l,!1);window.removeEventListener("mouseup",h,!1)}function g(a){j.posAnte=j.getCursorPosition(a);j.mouse_x=j.getRelativeX(j.posAnte.x);j.mouse_y=j.getRelativeY(j.posAnte.y);j.evaluator.setVariable(j.id+".mouse_x",
j.mouse_x);j.evaluator.setVariable(j.id+".mouse_y",j.mouse_y);70<Date.now()-n&&(j.parent.update(),n=Date.now())}function e(a){a.preventDefault();j.clickPosForZoomNew=j.getCursorPosition(a).y;j.evaluator.setVariable(j.scaleStr,j.tempScale+j.tempScale/45*((j.clickPosForZoom-j.clickPosForZoomNew)/10));j.parent.update()}function l(b){if(!j.fixed&&j.click){A=parseInt(50*(j.oldMouse.x-j.mouse_x));x=parseInt(50*(j.oldMouse.y-j.mouse_y));if(A!==j.disp.x||x!==j.disp.y)j.alpha=a.degToRad(j.evaluator.getVariable(j.rotZStr)),
j.beta=a.degToRad(-j.evaluator.getVariable(j.rotYStr)),j.alpha=f(a.radToDeg(j.alpha)-A),j.beta=f(a.radToDeg(j.beta)-x),j.evaluator.setVariable(j.rotZStr,j.alpha),j.evaluator.setVariable(j.rotYStr,-j.beta),j.disp.x=A,j.disp.y=x,j.oldMouse.x=j.getRelativeX(j.posAnte.x),j.oldMouse.y=j.getRelativeY(j.posAnte.y);g(b);b.preventDefault()}}var j=this,n=0;z=a.hasTouchSupport;this.canvas.oncontextmenu=function(){return!1};z&&this.canvas.addEventListener("touchstart",b);z||this.canvas.addEventListener("mousedown",
d);this.disp={x:0,y:0}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d;a.SpaceAP=function(e,h){a.Space.call(this,e,h);this.exportarVars=this.importarVars=null;d=e.evaluator;this.file=this.file.match(/^\[/)&&this.file.match(/\]$/)?d.parser.parse(this.file.substring(1,this.file.length-1)):this.file.match(/^\'/)&&this.file.match(/\'$/)?d.parser.parse(this.file):d.parser.parse("'"+this.file+"'");this.oldFile=d.evalExpression(this.file);this.initFile()};a.extend(a.SpaceAP,
a.Space);a.SpaceAP.prototype.initFile=function(){this.firstUpdate=!0;var d;if(this.oldFile){var h=document.getElementById(this.oldFile);d=h&&"descartes/spaceApFile"==h.type?h.text:a.openExternalFile(this.oldFile);null!=d&&(d=d.split("\n"))}if(d&&d.toString().match(/<applet/gi)){for(var h="",b=!1,c=0,l=d.length;c<l&&!(d[c].match("<applet")&&(b=!0),b&&(h+=d[c]),d[c].match("</applet"));c++);c=document.createElement("div");c.innerHTML=h;c.firstChild.setAttribute("width",this.w);c.firstChild.setAttribute("height",
this.h);h=this.descApp?this.descApp.container:null;this.descApp=new a.DescartesApp(c.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+";");h?this.parent.container.replaceChild(this.descApp.container,h):this.parent.container.insertBefore(this.descApp.container,
this.parent.loader);h=this.descApp.spaces;c=0;for(l=h.length;c<l;c++)h[c].findOffset();this.descApp.container.style.display=0<this.evaluator.evalExpression(this.drawif)?"block":"none";var f=this;this.descApp.update=function(){this.updateAuxiliaries();this.updateEvents();this.updateControls();this.updateSpaces();f.exportar()}}else h=this.descApp?this.descApp.container:null,this.descApp={},this.descApp.container=document.createElement("div"),this.descApp.container.setAttribute("class","DescartesAppContainer"),
c="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?c+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat;":"stretch"==this.bg_display?c+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat; background-size: 100% 100%;":"patch"==this.bg_display?c+="background-image: url("+this.imageSrc+
");":"center"==this.bg_display&&(c+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat; background-position: center center;")),this.descApp.container.setAttribute("style",c),h?this.parent.container.replaceChild(this.descApp.container,h):this.parent.container.insertBefore(this.descApp.container,this.parent.loader),this.descApp.container.style.display=0<this.evaluator.evalExpression(this.drawif)?"block":"none"};a.SpaceAP.prototype.update=function(){var a=this.evaluator.evalExpression(this.file);
if(this.oldFile!=a)this.oldFile=a,this.initFile();else{var a=this.x!=this.evaluator.evalExpression(this.xExpr),d=this.y!=this.evaluator.evalExpression(this.yExpr)+this.plecaHeight;this.x=a?this.evaluator.evalExpression(this.xExpr):this.x;this.y=d?this.evaluator.evalExpression(this.yExpr)+this.plecaHeight:this.y;a&&(this.descApp.container.style.left=this.x+"px");d&&(this.descApp.container.style.top=this.y+"px");if(a||d)for(var a=this.descApp.spaces,d=0,b=a.length;d<b;d++)a[d].findOffset();this.descApp.container.style.display=
0<this.evaluator.evalExpression(this.drawif)?"block":"none";if(this.firstUpdate&&(this.firstUpdate=!1,null==this.importarVars)){this.importarVars=[];for(var c in this.evaluator.variables)this.evaluator.variables.hasOwnProperty(c)&&c.match(/^public./)&&this.importarVars.push({varName:c,value:this.evaluator.getVariable(c)})}this.importar()}};a.SpaceAP.prototype.importar=function(){for(var a,d=!1,b=0,c=this.importarVars.length;b<c;b++)a=this.evaluator.getVariable(this.importarVars[b].varName),a!=this.importarVars[b].value&&
(this.importarVars[b].value=a,this.descApp.evaluator.setVariable(this.importarVars[b].varName,this.importarVars[b].value),d=!0);d&&this.descApp.update()};a.SpaceAP.prototype.exportar=function(){};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,e,h,b;a.SpaceHTML_IFrame=function(b,d){a.Space.call(this,b,d);var f=this.parent.evaluator;window.navigator.userAgent.toLowerCase().match(/firefox/);this.file=this.file?this.file.trim():"";this.file=this.file.match(/^\[/)&&this.file.match(/\]$/)?
f.parser.parse(this.file.substring(1,this.file.length-1)):this.file.match(/^\'/)&&this.file.match(/\'$/)?f.parser.parse(this.file):f.parser.parse("'"+this.file+"'");this.oldFile=f.evalExpression(this.file);this.MyIFrame=document.createElement("iframe");0!=this.oldFile&&this.MyIFrame.setAttribute("src",this.oldFile);this.MyIFrame.setAttribute("id",this.id);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");a.isIOS?this.container.setAttribute("style","overflow: scroll; -webkit-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+";"):this.container.setAttribute("style","position: absolute; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+
this.zIndex+";");this.container.appendChild(this.MyIFrame);this.parent.container.insertBefore(this.container,this.parent.loader);var h=this;this.MyIFrame.onload=function(){var a=this;h.evaluator.setFunction(h.id+".set",function(b,c){a.contentWindow.postMessage({type:"set",name:b,value:c},"*");return 0});h.evaluator.setFunction(h.id+".update",function(){a.contentWindow.postMessage({type:"update"},"*");return 0});h.evaluator.setFunction(h.id+".exec",function(b,c){a.contentWindow.postMessage({type:"exec",
name:b,value:c},"*");return 0})};this.update=this.iframeUpdate;this.evaluator.setVariable(this.id+"._scroll",0)};a.extend(a.SpaceHTML_IFrame,a.Space);a.SpaceHTML_IFrame.prototype.init=function(){self=this;self.uber.init.call(self);self.MyIFrame&&(self.MyIFrame.style.width=self.w+"px",self.MyIFrame.style.height=self.h+"px",self.MyIFrame.style.left=self.x+"px",self.MyIFrame.style.top=self.y+"px")};a.SpaceHTML_IFrame.prototype.iframeUpdate=function(a){d=this.evaluator;this.drawIfValue=0<d.evalExpression(this.drawif);
this.container.style.display=this.drawIfValue?"block":"none";if(this.drawIfValue){a&&(this.y=this.x=Math.Infinity);e=this.x!==d.evalExpression(this.xExpr)+this.displaceRegionWest;h=this.y!==d.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth;this.x=e?d.evalExpression(this.xExpr)+this.displaceRegionWest:this.x;this.y=h?d.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth:this.y;if(e||h)this.MyIFrame.style.left=this.x+"px",this.MyIFrame.style.top=this.y+
"px";b=d.evalExpression(this.file);b!==this.oldFile&&(this.oldFile=b,this.MyIFrame.setAttribute("src",b));this.scrollVar=d.getVariable(this.id+"._scroll");1==this.scrollVar?(this.MyIFrame.setAttribute("scrolling","yes"),this.MyIFrame.style.overflow=""):-1==this.scrollVar?(this.MyIFrame.setAttribute("scrolling","no"),this.MyIFrame.style.overflow="hidden"):(this.MyIFrame.setAttribute("scrolling","auto"),this.MyIFrame.style.overflow="")}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var d;a.DescartesLoader=function(a){this.children=a.children;this.lessonParser=a.lessonParser;this.images=a.images;this.images.length=a.images.length;this.audios=a.audios;this.audios.length=a.audios.length;this.arquimedes=a.arquimedes;this.descartesApp=a;var b;if(a.image_loader)b=a.image_loader;else{b=a.loader.width;var c=a.loader.height,h=document.createElement("canvas");h.width=b;h.height=c;var e=h.getContext("2d");e.save();e.strokeStyle="#1f375d";e.fillStyle="#1f375d";e.lineCap="round";e.lineWidth=
2;e.beginPath();d=b<c?b/360:c/195;d=2.5<d?2.5:d;e.translate((b-120*d)/2,(c-65*d)/2);e.scale(d,d);e.moveTo(3,25);e.lineTo(3,1);e.lineTo(21,1);e.bezierCurveTo(33,1,41,15,41,25);e.stroke();e.beginPath();e.moveTo(1,63);e.lineTo(1,64);e.moveTo(5,62);e.lineTo(5,64);e.moveTo(9,61);e.lineTo(9,64);e.moveTo(13,60);e.lineTo(13,64);e.moveTo(17,58);e.lineTo(17,64);e.moveTo(21,56);e.lineTo(21,64);e.moveTo(25,53);e.lineTo(25,64);e.moveTo(29,50);e.lineTo(29,64);e.moveTo(33,46);e.lineTo(33,64);e.moveTo(37,41);e.lineTo(37,
64);e.moveTo(41,32);e.lineTo(41,64);e.stroke();e.font="20px Arial, Helvetica, 'Droid Sans', Sans-serif";e.fillText("escartes",45,33);e.fillText("JS",98,64);e.restore();b=h.toDataURL()}this.imageLoader=document.createElement("div");this.imageLoader.width=a.width;this.imageLoader.height=a.height;this.imageLoader.setAttribute("class","DescartesLoaderImage");this.imageLoader.setAttribute("style","background-image: url("+b+"); width: "+a.width+"px; height: "+a.height+"px;");a.loader.appendChild(this.imageLoader);
this.loaderBar=document.createElement("canvas");this.loaderBar.width=a.width;this.loaderBar.height=a.height;this.loaderBar.setAttribute("class","DescartesLoaderBar");this.loaderBar.setAttribute("style","width: "+a.width+"px; height:"+a.height+"px;");this.loaderBar.ctx=this.loaderBar.getContext("2d");a.loader.appendChild(this.loaderBar);this.barWidth=Math.floor(80);this.barHeight=Math.floor(a.loader.height/70);var j=this;this.timer=setInterval(function(){j.drawLoaderBar(j.loaderBar.ctx,a.width,a.height)},
10);a.firstRun=!1;this.initPreloader()};a.DescartesLoader.prototype.initPreloader=function(){var b=this.children,c=this.images,d=this.audios,h=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg)/gi,e=/[\w\.\-//]*(\.ogg|\.oga|\.mp3|\.wav)/gi;this.arquimedes&&(c["lib/DescartesCCLicense.png"]=a.getCreativeCommonsLicenseImage(),c["lib/DescartesCCLicense.png"].addEventListener("load",function(){this.ready=1}),c["lib/DescartesCCLicense.png"].addEventListener("error",function(){this.errorload=1}));var j,p,q,u,k,s;q=0;
for(k=b.length;q<k;q++)if("rtf"!==b[q].name){if(b[q].value.match(/'macro'|'makro'/g)){j="";var m;p=this.lessonParser.split(b[q].value);s=0;for(var t=p.length;s<t;s++)"expresion"===babel[p[s][0]]&&(j=p[s][1]);j&&((m=document.getElementById(j))&&"descartes/macro"==m.type?m=m.text:(m=a.openExternalFile(j))&&!m.match(/tipo_de_macro/g)&&(m=null));if(m&&(j=m.match(h)))for(s=j.length;u<s;u++)p=j[u],!p.toLowerCase().match(/vacio.gif$/)&&""!=p.substring(0,p.length-4)&&(c[p]=new Image,c[p].addEventListener("load",
function(){this.ready=1}),c[p].addEventListener("error",function(){this.errorload=1}),c[p].src=p)}if(j=b[q].value.match(h)){u=0;for(s=j.length;u<s;u++)p=j[u],!p.toLowerCase().match(/vacio.gif$/)&&""!=p.substring(0,p.length-4)&&(c[p]=new Image,c[p].addEventListener("load",function(){this.ready=1}),c[p].addEventListener("error",function(){this.errorload=1}),c[p].src=p)}if(j=b[q].value.match(e)){u=0;for(p=j.length;u<p;u++)this.initAudio(j[u])}}for(var v in c)c.hasOwnProperty(v)&&this.images.length++;
for(v in d)d.hasOwnProperty(v)&&this.audios.length++;var y=this,B=this.images.length+this.audios.length,z=function(){y.readys=0;for(var a in c)c.hasOwnProperty(a)&&(c[a].ready||c[a].errorload)&&y.readys++;for(a in y.audios)d.hasOwnProperty(a)&&(d[a].ready||d[a].errorload)&&y.readys++;y.readys!=B?setTimeout(z,30):(clearTimeout(y.timer),y.descartesApp.initBuildApp())};z()};a.DescartesLoader.prototype.initAudio=function(b){var c=this.audios;c[b]=new Audio(b);c[b].filename=b;var d=function(){this.ready=
1},h=function(){!this.canPlayType("audio/"+this.filename.substring(this.filename.length-3))&&"mp3"==this.filename.substring(this.filename.length-3)?(c[b]=new Audio(this.filename.replace("mp3","ogg")),c[b].filename=this.filename.replace("mp3","ogg"),c[b].addEventListener("canplaythrough",d),c[b].addEventListener("load",d),c[b].addEventListener("error",h),c[b].load()):(console.log("El archivo '"+b+"' no puede ser reproducido"),this.errorload=1)};c[b].addEventListener("canplaythrough",d);c[b].addEventListener("load",
d);c[b].addEventListener("error",h);a.hasTouchSupport?(c[b].load(),c[b].play(),setTimeout(function(){console.log("detenido");c[b].pause()},10),c[b].ready=1):c[b].load()};var e,h,b,c;a.DescartesLoader.prototype.drawLoaderBar=function(a,f,g){e=this.barWidth;h=this.barHeight;b=this.images.length+this.audios.length;c=2*(e-2)/b;a.translate(f/2,(g-65*d)/2+90*d);a.scale(d,d);a.strokeRect(-e,-h,2*e,h);a.fillStyle="gray";a.fillRect(-e+2,-h+2,2*(e-2),h-4);a.fillStyle="#1f375d";a.fillRect(-e+2,-h+2,this.readys*
c,h-4);a.setTransform(1,0,0,1,0,0)};return a}(descartesJS||{}),descartesJS=function(a){function d(a){for(var b="[",c=0,l=a.length;c<l;c++){if(a[c]instanceof Array)b+=d(a[c]);else{e=a[c];if("undefined"==typeof e||!e)e=0;"string"==typeof e&&(e="'"+e+"'");b+=e}c<l-1&&(b+=",")}return b+"]"}if(a.loadLib)return a;a.DescartesApp=function(d){this.animation={playing:!1};this.applet=d;this.parentContainer=d.parentNode;this.width=parseFloat(d.getAttribute("width"));this.height=parseFloat(d.getAttribute("height"));
this.decimal_symbol=".";this.decimal_symbol_regexp=RegExp("\\"+this.decimal_symbol,"g");this.children=d.getElementsByTagName("param");a.creativeCommonsLicense=!0;for(var b=0,c=this.children.length;b<c;b++)"CreativeCommonsLicense"==this.children[b].name&&(a.creativeCommonsLicense="no"==this.children[b].value?!1:!0);this.code=d.getAttribute("code");this.saveState=[];this.images={};this.images.length=-1;this.audios={};this.audios.length=-1;this.firstRun=!0;this.init()};a.DescartesApp.prototype.init=
function(){this.evaluator=new a.Evaluator(this);this.lessonParser=new a.LessonParser(this);this.arquimedes=!!this.code.match("descinst.DescartesWeb2_0.class","i")||!!this.code.match("Arquimedes","i")||!!this.code.match("Discurso","i");this.licenseA=a.creativeCommonsLicense?"{\\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/2.5/es/}, 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 d=this.children,b,c=0,e=0,f=a.creativeCommonsLicense?90:0,g=0,r=d.length;g<r;g++)b=d[g],"rtf_height"==b.name&&(c=parseInt(b.value)),"Buttons"==babel[b.name]&&(this.buttonsConfig=this.lessonParser.parseButtonsConfig(b.value),e=this.buttonsConfig.height),"image_loader"==b.name&&(this.image_loader=b.value);this.arquimedes&&c&&(this.height=c+e+f);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.specialSpace={container:document.createElement("div"),controls:[]};this.editableRegion={container:document.createElement("div"),textFields:[]};this.controls=[];this.auxiliaries=[];this.events=[];this.cacheVars={};this.getVarsNames={};
this.numberOfIframes=this.plecaHeight=this.tabindex=this.zIndex=0;void 0!=this.container&&this.parentContainer.removeChild(this.container);this.container=document.createElement("div");this.loader=document.createElement("div");this.parentContainer.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.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.firstRun?this.descartesLoader=new a.DescartesLoader(this):this.initBuildApp()};a.DescartesApp.prototype.initBuildApp=function(){for(var d=this.children,b=this.lessonParser,c=[],e=[],f=[],g=[],r=[],n=[],j,p=0,q=d.length;p<q;p++)if(j=d[p],"pleca"==j.name)j=b.parsePleca(j.value,this.width),
this.container.insertBefore(j,this.loader),this.plecaHeight=j.imageHeight?j.imageHeight:j.offsetHeight;else if("Buttons"==babel[j.name])this.buttonsConfig=b.parseButtonsConfig(j.value);else if("decimal_symbol"==babel[j.name])this.decimal_symbol=j.value,this.decimal_symbol_regexp=RegExp("\\"+this.decimal_symbol,"g");else if("version"==babel[j.name])this.version=parseInt(j.value);else if("language"==babel[j.name])this.language=j.value;else if("rtf"==j.name){var u=(this.width-780)/2,k=parseInt(this.height)-
this.plecaHeight-this.buttonsConfig.height-45;g.push("space='descartesJS_scenario' type='text' expresion='[10,20]' background='yes' text='"+j.value.replace(/'/g,"&squot;")+"'");g.push("space='descartesJS_scenario' type='text' expresion='["+u+","+(k-25)+"]' background='yes' text='"+this.licenseA+"'");a.creativeCommonsLicense&&g.push("space='descartesJS_scenario' type='image' expresion='["+(u+15)+","+k+"]' background='yes' abs_coord='yes' file='lib/DescartesCCLicense.png'")}else"E"==j.name.charAt(0)?
(j.value.match(/'HTMLIFrame'/)&&this.numberOfIframes++,c.push(j.value)):"C"==j.name.charAt(0)&&"_"==j.name.charAt(1)?e.push(j.value):"A"==j.name.charAt(0)&&"_"==j.name.charAt(1)?f.push(j.value):"G"==j.name.charAt(0)?g.push(j.value):"S"==j.name.charAt(0)?r.push(j.value):"Animation"==babel[j.name]&&n.push(j.value);this.scenarioRegion={container:document.createElement("div"),scroll:0};this.scenarioRegion.container.setAttribute("id","descartesJS_Scenario_Region");this.scenarioRegion.scenarioSpace=this.lessonParser.parseSpace("tipo='R2' id='descartesJS_scenario' fondo='blanco' x='0' y='0' fijo='yes' red='no' red10='no' ejes='no' text='no' ancho='"+
this.width+"' alto='"+this.height+"'");this.scenarioRegion.container.appendChild(this.scenarioRegion.scenarioSpace.container);this.arquimedes&&(this.container.appendChild(this.scenarioRegion.container),this.spaces.push(this.scenarioRegion.scenarioSpace));p=0;for(q=c.length;p<q;p++)d=b.parseSpace(c[p]),this.arquimedes&&this.scenarioRegion.container.appendChild(d.container),this.spaces.push(d),this.zIndex++;p=0;for(q=g.length;p<q;p++)if(c=b.parseGraphic(g[p]))c.visible&&(this.editableRegionVisible=
!0),c.space.addGraph(c);p=0;for(q=r.length;p<q;p++)(c=b.parse3DGraphic(r[p]))&&c.space.addGraph(c);p=0;for(q=e.length;p<q;p++)this.controls.push(b.parseControl(e[p]));p=0;for(q=f.length;p<q;p++)b.parseAuxiliar(f[p]);p=0;for(q=n.length;p<q;p++)this.animation=b.parseAnimation(n[p]);this.configRegions();this.updateAuxiliaries();this.updateAuxiliaries();p=0;for(q=this.controls.length;p<q;p++)this.controls[p].init();this.updateControls();this.updateSpaces(!0);var s=this;this.numberOfIframes?setTimeout(function(){s.finishInit()},
300*this.numberOfIframes):this.finishInit()};a.DescartesApp.prototype.finishInit=function(){this.update();this.loader.style.display="none";window.parent!==window&&(this.parentContainer.style.margin="0px",this.parentContainer.style.padding="0px",window.parent.postMessage({type:"reportSize",href:window.location.href,width:this.width,height:this.height},"*"),window.parent.postMessage({type:"ready"},"*"),a.onResize());window.opener&&window.opener.postMessage({type:"isResizeNeeded",href:window.location.href},
"*");this.externalSpace.init()};a.DescartesApp.prototype.adjustSize=function(){document.body.style.margin="0px";document.body.style.padding="0px";this.parentContainer.style.margin="0px";this.parentContainer.style.padding="0px";var d=parseInt(this.width)+30,b=parseInt(this.height)+90;window.moveTo((parseInt(screen.width)-d)/2,(parseInt(screen.height)-b)/2);window.resizeTo(d,b);a.onResize()};a.DescartesApp.prototype.configRegions=function(){var d=this.evaluator.parser,b=this.buttonsConfig,c=this.container;
if(2!=this.version)var e="15",f=100,g=100,r=100,n=100;else e="14",f=63,g=50,r=44,n=53;var j=0,p=0,q=0,u=q=0,k=0,s=0,m=0,t=0,s=this.northSpace.controls,v=this.southSpace.controls,y=this.eastSpace.controls,B=this.westSpace.controls;if(0<b.rowsNorth||0<s.length||b.about||b.config){0>=b.rowsNorth?(j=b.height,b.rowsNorth=1):j=b.height*b.rowsNorth;k=this.northSpace.container;k.setAttribute("id","descartesJS_northRegion");k.setAttribute("style","width:"+c.width+"px; height:"+j+"px; background:#c0c0c0; position:absolute; left:0px; top:0px; z-index:100;");
c.insertBefore(k,this.loader);var k=c.width,z=0;b.about&&(z=f,k-=z);b.config&&(k-=g);for(var D=Math.ceil(s.length/b.rowsNorth),E=k/D,q=0,A=s.length;q<A;q++)s[q].expresion=d.parse("("+(z+E*(q%D))+","+b.height*Math.floor(q/D)+","+E+","+b.height+")"),s[q].drawif=d.parse("1"),s[q].init();b.about&&(q="espa\u00f1ol"==this.language?"cr\u00e9ditos":"english"==this.language?"about":"cr\u00e9ditos",q=new a.Button(this,{region:"north",name:q,font_size:d.parse(e),expresion:d.parse("(0, 0, "+f+", "+j+")")}),q.actionExec=
{execute:a.showAbout},q.update());b.config&&(new a.Button(this,{region:"north",name:"config",font_size:d.parse(e),action:"config",expresion:d.parse("("+(k+f)+", 0, "+g+", "+j+")")})).update()}if(0<b.rowsSouth||0<v.length||b.init||b.clear){0>=b.rowsSouth?(p=b.height,b.rowsSouth=1):p=b.height*b.rowsSouth;s=c.width;z=0;b.init&&(z=r,s-=z);b.clear&&(s-=n);k=this.southSpace.container;k.setAttribute("id","descartesJS_southRegion");k.setAttribute("style","width:"+c.width+"px; height:"+p+"px; background:#c0c0c0; position:absolute; left: 0px; top:"+
(c.height-p)+"px; z-index:100;");c.insertBefore(k,this.loader);D=Math.ceil(v.length/b.rowsSouth);E=s/D;q=0;for(A=v.length;q<A;q++)v[q].expresion=d.parse("("+(z+E*(q%D))+","+b.height*Math.floor(q/D)+","+E+","+b.height+")"),v[q].drawif=d.parse("1"),v[q].init();b.init&&(q="espa\u00f1ol"==this.language?"inicio":"english"==this.language?"init":"inicio",(new a.Button(this,{region:"south",name:q,font_size:d.parse(e),action:"init",expresion:d.parse("(0, 0, "+r+", "+p+")")})).update());b.clear&&(q="espa\u00f1ol"==
this.language?"limpiar":"english"==this.language?"clear":"limpiar",(new a.Button(this,{region:"south",name:q,font_size:d.parse(e),action:"clear",expresion:d.parse("("+(s+r)+", 0, "+n+", "+p+")")})).update())}if(0<y.length){q=c.height-j-p;m=b.widthEast;k=this.eastSpace.container;k.setAttribute("id","descartesJS_eastRegion");k.setAttribute("style","width:"+m+"px; height:"+q+"px; background:#c0c0c0; position:absolute; left:"+(c.width-m)+"px; top:"+j+"px; z-index:100;");c.insertBefore(k,this.loader);
q=0;for(A=y.length;q<A;q++)y[q].expresion=d.parse("(0,"+b.height*q+","+m+","+b.height+")"),y[q].drawif=d.parse("1"),y[q].init()}if(0<B.length){q=c.height-j-p;t=b.widthWest;k=this.westSpace.container;k.setAttribute("id","descartesJS_westRegion");k.setAttribute("style","width: "+t+"px; height: "+q+"px; background: #c0c0c0; position: absolute; left: 0px; top: "+j+"px; z-index: 100;");c.insertBefore(k,this.loader);q=0;for(A=B.length;q<A;q++)B[q].expresion=d.parse("(0,"+b.height*q+","+t+","+b.height+")"),
B[q].drawif=d.parse("1"),B[q].init()}if(this.editableRegionVisible){u=b.height;k=this.editableRegion.container;k.setAttribute("id","descartesJS_editableRegion");k.setAttribute("style","width:"+c.width+"px; height:"+u+"px; position:absolute; left:0px; top:"+(c.height-p-b.height)+"px; z-index:100; background:#c0c0c0; overflow:hidden;");c.insertBefore(k,this.loader);d=this.editableRegion.textFields;b=c.width/d.length;e=a.getFieldFontSize(u);q=0;for(A=d.length;q<A;q++)"div"==d[q].type?(k.appendChild(d[q].container),
d[q].container.setAttribute("style","font-family: Arial, Helvetica, 'Droid Sans', Sans-serif; width: "+(b-4)+"px; height: "+u+"px; position: absolute; left: "+q*b+"px; top: 0px;"),f=d[q].container.firstChild,f.setAttribute("style","font-family: Arial, Helvetica, 'Droid Sans', Sans-serif; font-size: "+e+"px; padding-top: 0%; background-color: #e0e4e8; position: absolute; left: 0px; top: 0px; height:"+u+"px; text-align: center; line-height: "+u+"px;"),g=f.offsetWidth,f.style.width=g+"px",f.firstChild.textContent=
f.firstChild.textContent.substring(3,f.firstChild.textContent.length-3),d[q].container.lastChild.setAttribute("style","font-family:'Courier New', Courier, 'Droid Sans Mono', Monospace; font-size: "+e+"px; width:"+(b-g)+"px; height:"+u+"px; position:absolute; left:"+g+"px; top:0px; border:2px groove white;")):(k.appendChild(d[q]),d[q].setAttribute("style","font-family:'Courier New', Courier, 'Droid Sans Mono', Monospace; font-size: "+e+"px; width:"+b+"px; height:"+u+"px; position:absolute; left:"+
q*b+"px; top:0px; border:2px groove white;"))}this.displaceRegionNorth=j;this.displaceRegionWest=t;c.width-=m;c.height=c.height-p-u;q=0;for(A=this.spaces.length;q<A;q++)this.spaces[q].init()};a.DescartesApp.prototype.update=function(){this.updateAuxiliaries();this.updateControls();this.updateEvents();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.play()};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;if(a)return b[a]||(b[a]=new Image,b[a].addEventListener("load",function(){this.ready=1}),b[a].addEventListener("error",function(){this.errorload=1}),b[a].src=a),b[a]};a.DescartesApp.prototype.getAudio=function(a){var b=this.audios;if(a){if(!b[a]){var c=a.lastIndexOf("."),c=-1===c?
a.lenght:c;a.substring(0,c);b[a]=new Audio(a);var d=function(){this.ready=1};b[a].addEventListener("canplaythrough",d);var f=function(){!this.canPlayType("audio/"+a.substring(a.length-3))&&"mp3"==a.substring(a.length-3)?(b[a]=new Audio(a.replace("mp3","ogg")),b[a].addEventListener("canplaythrough",d),b[a].addEventListener("load",d),b[a].addEventListener("error",f),b[a].load()):(console.log("El archivo '"+a+"' no puede ser reproducido"),this.errorload=1)};b[a].addEventListener("error",f);b[a].play();
setTimeout(function(){b[a].pause()},15)}return b[a]}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 e;a.DescartesApp.prototype.getState=function(){var a,b="",c=this.evaluator.variables,e;for(e in c)c.hasOwnProperty(e)&&(a=c[e],"string"==typeof a&&(a="'"+a+"'"),void 0!=a&&("rnd"!=e&&"pi"!=e&&"e"!=e&&"Infinity"!=e&&"-Infinity"!=e&&"object"!=typeof a)&&(b=""!=b?b+"\n"+
e+"="+a:e+"="+a));var c=this.evaluator.vectors,f;for(f in c)c.hasOwnProperty(f)&&(a=c[f],b=b+"\n"+f+"="+d(a));f=this.evaluator.matrices;for(var g in f)f.hasOwnProperty(g)&&(a=f[g],b=b+"\n"+g+"="+d(a));return b};a.DescartesApp.prototype.setState=function(a,b){for(var c=a.split("\n"),d,f,e=0,r=c.length;e<r;e++)d=c[e].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.evalExpression(this.saveState[a]);this.update()};return a}(descartesJS||{}),descartesJS=function(a){function d(){a.getFeatures();if(a.hasCanvasSupport){window.scrollTo(0,
10);for(var d=document.getElementsByTagName("*"),b=[],c=0,e=d.length;c<e;c++)"DescartesAppContainer"==d[c].className&&b.push(d[c]);c=0;for(e=b.length;c<e;c++)b[c].parentNode.removeChild(b[c]);for(var b=document.getElementsByTagName("applet"),c=document.getElementsByTagName("ajs"),d=[],f=0,g=b.length;f<g;f++)e=b[f],(e.getAttribute("code").match("DescartesJS")||e.getAttribute("code").match("descinst.DescartesWeb2_0.class")||e.getAttribute("code").match("Descartes")||e.getAttribute("code").match("Arquimedes")||
e.getAttribute("code").match("Discurso"))&&d.push(e);f=0;for(g=c.length;f<g;f++)e=c[f],(e.getAttribute("code").match("DescartesJS")||e.getAttribute("code").match("descinst.DescartesWeb2_0.class")||e.getAttribute("code").match("Descartes")||e.getAttribute("code").match("Arquimedes")||e.getAttribute("code").match("Discurso"))&&d.push(e);b=0;for(c=d.length;b<c;b++)a.apps.push(new a.DescartesApp(d[b])),d[b].className="DescartesJS";window.addEventListener("resize",a.onResize);window.scrollTo(0,2);document.body.setAttribute("tabIndex",
1E6)}else document.getElementById("StyleDescartesApps").innerHTML="applet.DescartesJS {display:block;} applet {display:block;} ajs.DescartesJS {display:block;} ajs {display:block;}"}if(a.loadLib)return a;a.apps=[];a.getDescartesApps=function(){return a.apps};if(!window.hasOwnProperty("debugDescartesJS")||!debugDescartesJS){var e=document.getElementById("StyleDescartesApps");e&&e.parentNode.removeChild(e);e=document.createElement("style");e.id="StyleDescartesApps";e.type="text/css";e.setAttribute("rel",
"stylesheet");e.innerHTML="applet.DescartesJS {display:none;} applet {display:none;} ajs.DescartesJS {display:none;} ajs {display:none;}";document.head.appendChild(e)}a.onResize=function(){for(var d,b=0,c=a.apps.length;b<c;b++){d=a.apps[b].spaces;for(var e=0,f=d.length;e<f;e++)d[e].findOffset()}};a.receiveMessage=function(d){if(0<a.apps.length){var b=d.data;if(b)if("set"===b.type)a.apps[0].evaluator.setVariable(b.name,b.value);else if("update"===b.type)a.apps[0].update();else if("exec"===b.type){d=
a.apps[0].evaluator.getFunction(b.name);var c=[];""!==b.value&&(c=b.value.toString().split(","));d&&d.apply(a.apps[0].evaluator,c)}else"isResizeNeeded"===b.type?d.source.postMessage({type:"doResize"},"*"):"doResize"===b.type&&0<a.apps.length&&a.apps[0].adjustSize()}};void 0==a.loadLib&&(a.loadLib=!0,window.addEventListener("load",d),window.addEventListener("message",a.receiveMessage));return a}(descartesJS||{});
