/*
 Joel Espinosa Longi
 joel.espinosa@amite.mx
 j.longi@gmail.com
 LGPL - http://www.gnu.org/licenses/lgpl.html
 2013-08-07_1
*/
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 e(){var a,
b,c,n,f,d,h,e,g;Number.prototype.originalToFixed=Number.prototype.toFixed;Number.prototype.toFixed=function(l){if(20>=l)return this.originalToFixed(l);l=0>l?0:parseInt(l);a=this.toString();f=a.indexOf("e");b=a.indexOf(".");if(-1!==f)if(d=a.split("e"),e="-"===d[0][0]?"-":"",h="-"===e?d[0].substring(1):d[0],g=parseInt(d[1]),0>b+g){var p=e+"0.",m;m=Math.abs(b+g);m=Array(m+1).join("0");a=p+m+h.replace(".","");b=1}else h=h.replace(".",""),a=e+h+Array(g-h.length+2).join("0"),b=-1;c="";if(-1===b)return 0<
l&&(c="."),c+=Array(l+1).join("0"),a+c;n=a.length-b-1;if(n>=l)return 0<l?a.substring(0,b+1+l):a.substring(0,b);p=0;for(l-=n;p<l;p++)c+="0";return a+c}}function k(a,b,c){a.fillStyle="#c0c0c0";a.fillRect(b.offsetLeft,b.offsetTop,b.offsetWidth,b.offsetHeight);g(a,b,c.controls)}function g(a,b,c){for(var n,f=c.length-1;0<=f;f--)n=c[f],a.drawImage(n.getScreenshot(),b.offsetLeft+n.x,b.offsetTop+n.y)}if(a.loadLib)return a;var b=2*Math.PI,d=360/b,f=b/360,h=Math.floor,c,r,m,l,t,q,u,p,v,n;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*d};a.degToRad=function(a){return a*f};a.convertFont=function(a){if(""==a)return a;c=a.split(",");r="";"bold"==c[1].toLowerCase()?r+="Bold ":"italic"==c[1].toLowerCase()||"italics"==c[1].toLowerCase()?r+="Italic ":"bold+italic"==c[1].toLowerCase()&&(r+="Italic Bold ");r+=c[2]+
"px ";m=c[0].split(" ")[0].toLowerCase();return r="serif"===m||"times new roman"===m||"timesroman"===m||"times"===m?r+"'Times New Roman', Times, 'Droid Serif', serif":"sansserif"===m||"arial"===m||"helvetica"===m?r+"Arial, Helvetica, 'Droid Sans', Sans-serif":r+"'Courier New', Courier, 'Droid Sans Mono', Monospace"};a.drawLine=function(a,b,c,n,f,d,e){a.lineWidth=e||1;a.strokeStyle=d||"black";d=a.lineWidth%2?0.5:0;a.beginPath();a.moveTo(h(b)+d,h(c)+d);a.lineTo(h(n)+d,h(f)+d);a.stroke()};a.getColor=
function(a,b){if("string"==typeof b)return b;l=a.evalExpression(b);t=h(255*l[0][0]);q=h(255*l[0][1]);u=h(255*l[0][2]);p=1-l[0][3];return"rgba("+t+","+q+","+u+","+p+")"};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;b=document.createElement("canvas");a.hasCanvasSupport=
b.getContext&&b.getContext("2d");a.hasCanvasSupport&&(a.ctx=document.createElement("canvas").getContext("2d"));e()};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],v=a.pageX,n=a.pageY):void 0!=a.pageX&&void 0!=a.pageY?(v=a.pageX,n=a.pageY):(v=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,n=a.clientY+document.body.scrollTop+document.documentElement.scrollTop);
return{x:v,y:n}};a.getTextWidth=function(b,c){a.ctx.font=c;return a.ctx.measureText(b).width};var s=document.createElement("span");s.appendChild(document.createTextNode("\u00c1p"));var w=document.createElement("div");w.setAttribute("style","display: inline-block; w: 1px; h: 0px;");var z=document.createElement("div");z.setAttribute("style","margin: 0; padding: 0;");z.appendChild(s);z.appendChild(w);var C={};a.getFontMetrics=function(a){if(C[a])return C[a];s.setAttribute("style","font: "+a+"; margin: 0px; padding: 0px;");
document.body.appendChild(z);var b={};z.getBoundingClientRect?(w.style.verticalAlign="baseline",b.ascent=w.offsetTop-s.offsetTop,b.h=z.getBoundingClientRect().height||0):(w.style.verticalAlign="baseline",b.ascent=w.offsetTop-s.offsetTop,w.style.verticalAlign="bottom",b.h=w.offsetTop-s.offsetTop);b.descent=b.h-b.ascent;b.baseline=b.ascent;document.body.removeChild(z);return C[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,n=document.createElement("canvas"),f=new Image;if(b){n.setAttribute("width",b.width);n.setAttribute("height",b.height);for(var d=n.getContext("2d"),h=0,e=b.spaces.length;h<e;h++)c=b.spaces[h],"R2"===c.type&&(d.drawImage(c.backgroundCanvas,c.x,c.y),d.drawImage(c.canvas,c.x,c.y),g(d,c.container,c.ctrs));0<b.northSpace.controls.length&&k(d,b.northSpace.container,b.northSpace);0<b.southSpace.controls.length&&k(d,b.southSpace.container,b.southSpace);0<b.eastSpace.controls.length&&
k(d,b.eastSpace.container,b.eastSpace);0<b.westSpace.controls.length&&k(d,b.westSpace.container,b.westSpace);f.src=n.toDataURL("image/png")}return f};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k;a.openExternalFile=function(a){e=null;var b=!1;if(window.XMLHttpRequest)try{b=new XMLHttpRequest}catch(d){b=!1}else if(window.ActiveXObject)try{b=new ActiveXObject("Msxml2.XMLHTTP")}catch(f){try{b=new ActiveXObject("Microsoft.XMLHTTP")}catch(h){b=!1}}k=b;k.open("GET",a,
!1);try{k.send(null),e=k.responseText,e.match(String.fromCharCode(65533))&&(k.open("GET",a,!1),k.overrideMimeType("text/plain; charset=ISO-8859-1"),k.send(null),e=k.responseText)}catch(c){console.log("Error to load the file :",a),e=null}return e};return a}(descartesJS||{}),descartesJS=function(a){function e(a){d=a.trim();a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};d[0]==d[d.length-1]&&"'"==d[0]&&(a.ignoreCaps=!0,d=d.substring(1,d.length-1),"`"==d[0]&&"\u00b4"==d[d.length-1]&&(a.ignoreAcents=!0,
d=d.substring(1,d.length-1)));"`"==d[0]&&"\u00b4"==d[d.length-1]&&(a.ignoreAcents=!0,d=d.substring(1,d.length-1),d[0]==d[d.length-1]&&"'"==d[0]&&(a.ignoreCaps=!0,d=d.substring(1,d.length-1)));"*"===d.charAt(0)&&"*"!==d.charAt(d.length-1)?d=d.substring(1)+"$":"*"!==d.charAt(0)&&"*"===d.charAt(d.length-1)?d="^"+d.substring(0,d.length-1):"*"!==d.charAt(0)&&"*"!==d.charAt(d.length-1)?d="^"+d+"$":"*"===d.charAt(0)&&"*"===d.charAt(d.length-1)&&(d=d.substring(1,d.length-1));d=d.replace(/\?/g,"[\\S\\s]{1}");
a.regExp=d;return a}function k(a,b){d=a.trim();a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};a.expr=d.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 g(a,b,c){b=parseFloat(b);r=a.expr[0];m=a.expr[1];l=c.evalExpression(r.expr);t=c.evalExpression(m.expr);q="("==r.type;u=
"["==r.type;p=")"==m.type;v="]"==m.type;return(q&&b>l||u&&b>=l)&&(p&&b<t||v&&b<=t)?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 d,f,h,c,r,m,l,t,q,u,p,v;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 c=0,g=a.length;c<g;c++){f=a[c].split("&");h=[];for(var l=0,p=f.length;l<p;l++)d=f[l],-1!==d.indexOf(",")&&("("===d.charAt(0)||"["===d.charAt(0))&&(")"===d.charAt(d.length-1)||"]"===d.charAt(d.length-1))?h.push(k(d,b)):h.push(e(d));a[c]=h}return a};a.escorrecto=function(d,h,e,l){e=e||a.externalEvaluator;l=l||a.buildRegularExpresionsPatterns(d,e);h=b(h);
d=0;for(var p=l.length;d<p;d++){f=l[d];c=!0;for(var m=0,k=f.length;m<k;m++)c=f[m].regExp?c&&!!h.match(b(f[m].regExp),"i"):c&&g(f[m],h,e);if(c)return 1}return 0};a.esCorrecto=function(h,e,l,p){l=l||a.externalEvaluator;p=p||a.buildRegularExpresionsPatterns(h,l);h=0;for(var m=p.length;h<m;h++){f=p[h];c=!0;for(var k=0,r=f.length;k<r;k++)(d=f[k].regExp)?(f[k].ignoreAcents&&(e=b(e),d=b(d)),f[k].ignoreCaps&&(e=e.toLowerCase(),d=b(d).toLowerCase()),c=c&&!!e.match(d)):c=c=c&&g(f[k],e,l);if(c)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 e=Math.floor,k,g,b,d,f,h,c,r,m;a.Color=function(a,c){this.b=this.g=this.r=0;this.a=1;this.evaluator=c;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]){g=[];b=this.splitComa(a.substring(1,a.length-1));for(var f=0,h=b.length;f<h;f++)d=
parseInt(b[f],16),b[f]!=d.toString(16)&&b[f]!=="0"+d.toString(16)?("["===b[f].charAt(0)&&"]"===b[f].charAt(b[f].length-1)&&(b[f]=b[f].substring(1,b[f].length-1)),g.push(this.evaluator.parser.parse(b[f]))):g.push(this.evaluator.parser.parse((d/255).toString()));this.rExpr=g[0];this.gExpr=g[1];this.bExpr=g[2];this.aExpr=g[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){f=
[];for(var b=r=c=h=0,d=a.length;b<d;b++)m=a.charAt(b),"("===m?h++:")"===m?h--:"["===m?c++:"]"===m?c--:","===m&&(0===h&&0===c)&&(f.push(a.substring(r,b)),r=b+1);f.push(a.substring(r));return f};a.Color.prototype.getColorString=function(){return this.colorStr};a.Color.prototype.getColorExpression=function(){k=this.evaluator;this.r=e(255*k.evalExpression(this.rExpr));this.g=e(255*k.evalExpression(this.gExpr));this.b=e(255*k.evalExpression(this.bExpr));this.a=1-k.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 e=document.head,k=document.createElement("meta");k.setAttribute("http-equiv","X-UA-Compatible");k.setAttribute("content","chrome=1");e.appendChild(k);k=document.createElement("meta");k.setAttribute("name","viewport");k.setAttribute("content","width=device-width, initial-scale=1.0, user-scalable=yes");
e.appendChild(k);k=document.createElement("meta");k.setAttribute("name","apple-mobile-web-app-capable");k.setAttribute("content","yes");e.appendChild(k);k=document.createElement("meta");k.setAttribute("name","apple-mobile-web-app-status-bar-style");k.setAttribute("content","black-translucent");e.appendChild(k);(e=document.getElementById("StyleDescartesApps2"))&&e.parentNode.removeChild(e);e=document.createElement("style");e.type="text/css";e.id="StyleDescartesApps2";e.setAttribute("rel","stylesheet");
document.head.appendChild(e);e.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; -moz-box-shadow:0px 0px 0px #888; -webkit-box-shadow:0px 0px 100px #888; box-shadow:0px 0px 100px #888; background-image:linear-gradient(bottom, #bbbbbb 0%, #efefef 50%, #bbbbbb 100%); background-image:-o-linear-gradient(bottom, #bbbbbb 0%, #efefef 50%, #bbbbbb 100%); background-image:-moz-linear-gradient(bottom, #bbbbbb 0%, #efefef 50%, #bbbbbb 100%); background-image:-webkit-linear-gradient(bottom, #bbbbbb 0%, #efefef 50%, #bbbbbb 100%); background-image:-ms-linear-gradient(bottom, #bbbbbb 0%, #efefef 50%, #bbbbbb 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.DescartesSpinnerContainer, div.DescartesTextFieldContainer{ background:lightgray; position:absolute; overflow:hidden; }\ninput.DescartesSpinnerField, input.DescartesTextFieldField, input.DescartesMenuField, input.DescartesScrollbarField{ font-family:Arial, Helvetica, 'Droid Sans', Sans-serif; padding:0px; border:solid #666666 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:#eeeeee; overflow:hidden; position:absolute; }\n";
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.sin,k=Math.floor,g=Math.random,b=Math.round,d=Math.abs,f=String.fromCharCode,h,c,r,m,l,t,q,u,p,v;a.Krypto=function(a){this.key=(a||0).toString()};a.Krypto.prototype.getKey=function(a){h=[];for(var b=0;256>b;b++)h[b]=f(this.alfanum(k(d(7.5*(e(1*b-a)+e(1.4*b+a)+e(0.6*b-a)+e(2.2*b+a))))));return h.join("")};a.Krypto.prototype.encode=function(a){c=k(31*g());this.key=this.getKey(c);m=f(this.alfanum(c));return m+this.encripta(a)};
a.Krypto.prototype.decode=function(a){c=this.numalfa(a.charCodeAt(0));this.key=this.getKey(c);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;t=Array(3*a.length);for(var c=0,f=a.length;c<f;c++)p=256*k(a[c]+128)+b(255*g())+65536*b(255*g()),v=k((p<<this.shift(c))/256),t[3*c]=this.alfanum(v%32),t[3*c+1]=this.alfanum(v/32%
32),t[3*c+2]=this.alfanum(v/1024%32);return t};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++)v=this.numalfa(a[3*b])+32*this.numalfa(a[3*b+1])+1024*this.numalfa(a[3*b+2]),p=k(256*v>>this.shift(b)),u=k(p/256)%256-128,0>u&&(u+=256),q[b]=u;return q};a.Krypto.prototype.alfanum=function(a){a=k(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){m=Array(a.length);for(var b=0,c=a.length;b<c;b++)m[b]=a.charCodeAt(b);return m};a.Krypto.prototype.bytesToString=function(a){for(var b=0,c=a.length;b<c;b++)a[b]=f(a[b]);return a.join("")};a.Krypto.prototype.shift=function(a){r=this.key.charCodeAt(a%this.key.length);m=this.numalfa(r);l=k(m/2%8);0==l&&(l=4);return l};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(e,k){this.parent=e;var g=e.evaluator,b=g.parser,d=new a.Auxiliary(e);this.delay=k.delay?b.parse(k.delay):b.parse("60");this.loop=k.loop?k.loop:!1;this.auto=void 0==k.auto?!0:k.auto;this.controls=k.controls;this.init=d.splitInstructions(b,k.init);this.doExpr=d.splitInstructions(b,k.doExpr);k.whileExpr&&(this.whileExpr=b.parse(k.whileExpr));var f=this,h,c,r=f.doExpr.length;this.animationExec=
function(){for(c=0;c<r;c++)g.evalExpression(f.doExpr[c]);f.parent.update();f.playing&&(0<g.evalExpression(f.whileExpr)||f.loop)?(h=g.evalExpression(f.delay),f.timer=setTimeout(f.animationExec,10>h?10:h)):(f.stop(),f.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,k=this.init.length;a<k;a++)this.parent.evaluator.evalExpression(this.init[a])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Action=function(a,k){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(e,k){a.Action.call(this,e,k);this.parameter=(k||"").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(e,k){a.Action.call(this,e,k);var g=this.evaluator,b=g.parser;k=(k||"").replace(/&squot;/g,"'");k=k.replace(/;/g,"\\n");k=k.split("\\n")||[""];for(var d=[],f,h=0,c=k.length;h<c;h++)(f=b.parse(k[h],!0))&&d.push(f);c=d.length;this.execute=function(){for(h=0;h<c;h++)g.evalExpression(d[h])}};
a.extend(a.Calculate,a.Action);return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.OpenURL=function(e,k){a.Action.call(this,e,k);this.parameter=k;this.target="_blank";var g=this.parameter.indexOf("target");-1!=g&&(this.target=this.parameter.substring(g),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,g-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(e,k){a.Action.call(this,e,k);this.parameter=k;this.target=
"_blank";var g=this.parameter.indexOf("target");-1!=g&&(this.target=this.parameter.substring(g),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,g-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(){this.window=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");
this.window.onload=function(a){a=this.document;var d=a.getElementsByTagName("applet");d&&0<d.length&&(this.innerWidth=d[0].width,this.height=d[0].height,a.body.style.margin="0px",a.body.style.padding="0px",d[0].parentNode.style.margin="0px",d[0].parentNode.style.padding="0px")}})};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(e,k){a.Action.call(this,e,k);k||(this.urlAbout=
window.location.href.substring(0,window.location.href.lastIndexOf("/")+1)+k)};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(e,k){a.Action.call(this,e,k)};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(e,k){a.Action.call(this,e,k)};
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(e,k){a.Action.call(this,e,k)};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(e,k){a.Action.call(this,e,k)};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(e,k){a.Action.call(this,e,k)};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 e=/[\w\.\-//]*(\.ogg|\.oga|\.mp3|\.wav|\.OGG|\.OGA\.MP3|\.WAV)/g;a.PlayAudio=function(k,g){a.Action.call(this,k,g);g&&g.match(e)?this.filenameExpr=this.evaluator.parser.parse("'"+g.match(e)+"'"):this.filenameExpr=
this.evaluator.parser.parse(g)};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 d in b)b.hasOwnProperty(d)&&(this[d]=
b[d])};a.Auxiliary.prototype.firstRun=function(){};a.Auxiliary.prototype.update=function(){};var e,k;a.Auxiliary.prototype.splitInstructions=function(a,b){k=[];b=b?b.split(";"):[""];for(var d=0,f=b.length;d<f;d++)(e=a.parse(b[d],!0))&&k.push(e);return k};a.Auxiliary.prototype.getPrivateVariables=function(a,b){k=[];b=b?b.split(/;|,/):[""];for(var d=0,f=b.length;d<f;d++)(e=a.parse(b[d],!0))&&k.push(e);d=0;for(f=k.length;d<f;d++)k[d]="asign"===k[d].type?k[d].childs[0].value:"identifier"===k[d].type?
k[d].value:"";return k};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(e,k){a.Auxiliary.call(this,e,k);var g=this.evaluator.parser;this.expresionString=this.expresion;(this.expresion=g.parse(this.expresionString))&&
g.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"),k=document.createElement("label");k.appendChild(document.createTextNode("___"+this.id+"=___"));var g=document.createElement("input");g.value=this.expresionString;g.disabled=!this.editable;a.appendChild(k);a.appendChild(g);var b=this,d=b.evaluator.parser;g.onkeydown=
function(a){13==a.keyCode&&(b.expresion=d.parse(this.value),d.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(e,k){a.Auxiliary.call(this,e,k);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 e,k,g;a.Vector=function(b,d){e=b.evaluator;k=e.parser;this.size=k.parse("3");a.Auxiliary.call(this,b,d);this.expresion=this.expresion.split(";");this.parseFile=k.parse(this.file);this.update()};a.extend(a.Vector,a.Auxiliary);a.Vector.prototype.update=function(){var b=this.expresion;e=this.evaluator;k=e.parser;this.oldFile=this.file;if(g=e.evalExpression(this.parseFile))this.file=g;var d;this.file&&((vectorElement=document.getElementById(this.file))&&
"descartes/vectorFile"==vectorElement.type?(d=vectorElement.text,"\n"==d[0]&&(d=d.substring(1))):d=a.openExternalFile(this.file),null!=d&&(d=d.replace(/\r/g,"").split("\n")),null==d||1==d.length&&""==d[0]?this.size=0:(b=d,this.size=null),null===this.size&&(this.size=k.parse(b.length+"")));var f;d=[];for(var h=0,c=b.length;h<c;h++)(f=k.parse(b[h],!0))&&"asign"!=f.type&&(f=k.parse(this.id+"["+h+"]="+b[h],!0)),d.push(f);b=[];h=0;for(c=e.evalExpression(this.size);h<c;h++)b.push(0);e.vectors[this.id]=
b;e.setVariable(this.id+".long",e.evalExpression(this.size));h=0;for(c=d.length;h<c;h++)e.evalExpression(d[h])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Matrix=function(e,k){var g=e.evaluator,b=g.parser;this.rows=b.parse("3");this.columns=b.parse("3");a.Auxiliary.call(this,e,k);this.expresion=this.splitInstructions(b,this.expresion);var b=g.evalExpression(this.rows),d=g.evalExpression(this.columns),f=[];f.type="matrix";for(var h,c=0;c<d;c++){h=[];for(var r=0,m=b;r<
m;r++)h.push(0);f[c]=h}g.matrices[this.id]=f;this.update()};a.extend(a.Matrix,a.Auxiliary);a.Matrix.prototype.update=function(){var a=this.evaluator,k=a.evalExpression(this.rows),g=a.evalExpression(this.columns);a.setVariable(this.id+".filas",k);a.setVariable(this.id+".columnas",g);var b=a.matrices[this.id];b.rows=k;b.cols=g;k=0;for(g=this.expresion.length;k<g;k++)a.evalExpression(this.expresion[k])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Function=function(e,k){a.Auxiliary.call(this,
e,k);var g=this.evaluator,b=g.parser,d=this.id.indexOf("(");this.name=this.id.substring(0,d);this.params=this.id.substring(d+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 f=this;this.functionExec=function(){this.iterations=0;if(f.numberOfParams<=arguments.length){for(var b=
[],c=0,d=f.privateVars.length;c<d;c++)b.push(g.getVariable(f.privateVars[c])),g.setVariable(f.privateVars[c],0);for(var e=[],c=0,d=f.params.length;c<d;c++)e[c]=g.getVariable(f.params[c]),g.setVariable(f.params[c],arguments[c]);c=0;for(d=f.init.length;c<d;c++)g.evalExpression(f.init[c]);do{c=0;for(d=f.doExpr.length;c<d;c++)g.evalExpression(f.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<g.evalExpression(f.whileExpr));
var l=g.evalExpression(f.expresion);a.rangeOK=g.evalExpression(f.domain);c=0;for(d=f.params.length;c<d;c++)g.setVariable(f.params[c],e[c]);c=0;for(d=f.privateVars.length;c<d;c++)g.setVariable(f.privateVars[c],b[c]);return l}return 0};g.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(e,k){a.Auxiliary.call(this,e,k);var g=this.evaluator;this.parseExpressions(g.parser);this.algorithmExec=
function(){for(var a=this.iterations=0,d=this.init.length;a<d;a++)g.evalExpression(this.init[a]);do{a=0;for(d=this.doExpr.length;a<d;a++)g.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<g.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(e,k){a.Auxiliary.call(this,e,k);var g=this.evaluator;this.condition=g.parser.parse(this.condition);this.lastEvaluation=!1;this.action=this.parent.lessonParser.parseAction(this);"onlyOnce"==this.execution&&(this.eventExec=function(){0<g.evalExpression(this.condition)&&!this.lastEvaluation&&(this.lastEvaluation=!0,this.action.execute())});"alternate"==this.execution&&(this.eventExec=function(){var a=0<g.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<g.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 e,k,
g,b,d;a.Graphic=function(b,d){this.parent=b;this.evaluator=b.evaluator;var c=this.evaluator.parser;this.spaceID="";this.background=!1;this.type="";this.drawif=c.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=c.parse("(0,0)");this.family="";this.family_interval=c.parse("[0,1]");this.family_steps=c.parse("8");this.editable=!1;this.font=5<=this.parent.version?
"Monospaced,PLAIN,15":"Monospaced,PLAIN,12";this.fixed=!0;this.text="";this.decimals=c.parse("2");for(var e in d)d.hasOwnProperty(e)&&(this[e]=d[e]);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(){e=this.evaluator;k=e.evalExpression(this.family_interval);this.familyInf=k[0][0];this.familySup=k[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.Graphic.prototype.drawFamilyAux=function(a,b,c){e=this.evaluator;this.getFamilyValues();g=e.getVariable(this.family);
if(0<=this.fSteps)for(var d=0,m=this.fSteps;d<=m;d++)e.setVariable(this.family,this.familyInf+d*this.family_sep),0<e.evalExpression(this.drawif)&&(this.update(),this.drawAux(a,b,c));e.setVariable("_Text_H_",0);e.setVariable(this.family,g)};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,h,c,g,m,l,k,q,u,p,v){if("rtfNode"===h.type)a.fillStyle=m.getColor(),a.strokeStyle=m.getColor(),a.textBaseline="alphabetic",h.draw(a,c,g,u,p,k,v);else{"simpleText"===h.type&&(h=h.toString(u,p).split("\\n"));c+=l.match("Arial")?-2:l.match("Times")?-2:0;e=this.evaluator;a.fillStyle=m.getColor();a.font=l;a.textAlign=k;a.textBaseline=q;this.border&&(a.strokeStyle=
this.border.getColor(),a.lineWidth=3);d=1.2*this.fontSize||0;m=0;for(l=h.length;m<l;m++)b=h[m],this.border&&(a.lineJoin="round",a.strokeText(b,c,g+d*m)),a.fillText(b,c,g+d*m)}};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 d="'",f=0,h=0,c=-1,e,m;f<b.length;)e=
b.charAt(f),m=b.charAt(f-1),"["===e&&"\\"===m?(this.textElements.push(b.substring(h,f-1)+"["),this.textElementsMacros.push("'"+b.substring(h,f-1)+"['"),h=f+1):"]"===e&&"\\"===m?(this.textElements.push(b.substring(h,f-1)+"]"),this.textElementsMacros.push("'"+b.substring(h,f-1)+"]'"),h=f+1):"["===e&&-1===c?(this.textElements.push(b.substring(h,f)),this.textElementsMacros.push("'"+b.substring(h,f)+"'"),h=f,c++):"["===e?c++:"]"===e&&0===c?(this.textElements.push(this.evaluator.parser.parse(b.substring(h,
f+1))),this.textElementsMacros.push("["+b.substring(h,f+1)+"]"),h=f+1,c--):("]"==b.charAt(f)&&(c=0>c?c:c-1),d+=b.charAt(f)),f++;this.textElements.push(b.substring(h,f));this.textElementsMacros.push("'"+b.substring(h,f)+"'")};var e,k;a.SimpleText.prototype.toString=function(a,b){e="";for(var d=0,f=this.textElements.length;d<f;d++)"string"===typeof this.textElements[d]?e+=this.textElements[d]:(k=this.evaluator.evalExpression(this.textElements[d])[0][0],""!==k&&("string"===typeof k?e+=k:(k=parseFloat(k),
k=b?k.toFixed(a):parseFloat(k.toFixed(a)),e+=k.toString().replace(".",this.parent.decimal_symbol))));return e};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,k,g,b,d,f,h,c,r,m,l,t,q,u,p,v,n,s,w,z,C,y,E,D,B,A,H,G;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();
q=new a.R2;u=new a.R2;p=new a.R2;s=new a.R2;v=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");var a=parseInt(this.evaluator.evalExpression(this.width));this.width_2=parseInt(a/2)||1;this.auxCanvas.setAttribute("width",a);this.auxCanvas.setAttribute("height",a);this.auxCtx=
this.auxCanvas.getContext("2d");this.auxCtx.fillStyle=this.color.getColor();this.auxCtx.fillRect(0,0,a,a)};a.Equation.prototype.update=function(){};a.Equation.prototype.draw=function(){""!=this.family?this.drawFamilyAux(this.ctx,this.fill,this.color):(this.update(),this.drawAux(this.ctx,this.fill,this.color))};a.Equation.prototype.drawFamilyAux=function(a,b,c){g=this.evaluator;this.getFamilyValues();tempParam=g.getVariable(this.family);if(0<=this.fSteps)for(var d=0,f=this.fSteps;d<=f;d++)g.setVariable(this.family,
this.familyInf+d*this.family_sep),this.drawAux(a,b,c);g.setVariable(this.family,tempParam)};a.Equation.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,this.trace)};a.Equation.prototype.drawAux=function(I,K,x){I.lineWidth=1;g=this.evaluator;b=g.parser;d=this.space;f=g.evalExpression(this.width);I.fillStyle=x.getColor();I.translate(-parseInt(f/2),-parseInt(f/2));h=b.getVariable("x");c=b.getVariable("y");r=d.w;m=d.h;l=parseInt(r/8);3>l&&(l=3);t=parseInt(m/8);3>t&&(t=3);k=[];q.set(0,
0);u.set(0,0);p.set(0,0);for(G=parseInt(t/2);G<m;G+=t)for(H=parseInt(l/2);H<r;H+=l)if(this.abs_coord?(s.set(H,G),n=this.newt.findZero(s),g.setVariable("x",n.x),g.setVariable("y",n.y),v.set(n.x,n.y)):(s.set(d.getRelativeX(H),d.getRelativeY(G)),n=this.newt.findZero(s),g.setVariable("x",n.x),g.setVariable("y",n.y),v.set(d.getAbsoluteX(n.x),d.getAbsoluteY(n.y))),w=v.ix(),z=v.iy(),!(0>w||w>=r||0>z||z>=m||k[w+z*d.w]))if(k[w+z*d.w]=!0,a.rangeOK&&g.evalExpression(this.drawif)&&I.drawImage(this.auxCanvas,
w,z),q.x=n.x,q.y=n.y,u.x=n.x,u.y=n.y,C=this.newt.getUnitNormal(),!(0==C.x&&0==C.y)){C.rotL90();p.x=C.x;p.y=C.y;E=y=0;for(D=!1;2>E;){D&&(p.x=-C.x,p.y=-C.y,n.x=q.x,n.y=q.y,u.x=n.x,u.y=n.y,this.abs_coord?v.set(n.x,n.y):v.set(d.getAbsoluteX(n.x),d.getAbsoluteY(n.y)),w=v.ix(),z=v.iy(),D=!1,y=0);this.abs_coord?(n.x+=p.x,n.y+=p.y):(n.x+=p.x/d.scale,n.y+=p.y/d.scale);n=this.newt.findZero(n);g.setVariable("x",n.x);g.setVariable("y",n.y);p.x=n.x-u.x;p.y=n.y-u.y;p.normalize();if(0==p.x&&0==p.y)break;u.x=n.x;
u.y=n.y;this.abs_coord?v.set(n.x,n.y):v.set(d.getAbsoluteX(n.x),d.getAbsoluteY(n.y));B=e(v.ix());A=e(v.iy());if(B!=w||A!=z)if(w=B,z=A,0<=w&&w<r&&0<=z&&z<m)if(y=0,k[w+z*d.w])break;else k[w+z*d.w]=!0,a.rangeOK&&g.evalExpression(this.drawif)&&I.drawImage(this.auxCanvas,w,z);else D=!0,E++;else 4<++y&&(D=!0,E++)}}I.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,d,f,h,n){for(var e=this.evaluator.getVariable(c),g=n/2,l=0;1E-12<Math.abs(g);){var p=this.evaluator.getVariable(c),m=this.evaluator.getVariable(c)+g;this.evaluator.setVariable(c,
m);var k=!0,r=h;h=this.evaluator.evalExpression(this.funExpr);this.evaluator.setVariable(d,h);if(0<this.evaluator.evalExpression(b)){var q=new a.R2(Math.min(r,h),Math.max(r,h)),t=0,t=0<n?this.Singularity(Math.abs(g),c,f,p,r,m,h,q):this.Singularity(Math.abs(g),c,f,m,h,p,r,q);0<t&&(k=!1)}else k=!1;k?l+=g:this.evaluator.setVariable(c,p);g/=2}this.evaluator.setVariable(c,e);return new a.R2(l/Math.abs(n),h)};a.Equation.prototype.extrapolateOnSingularity=function(b,c,d,f,h,n){f=this.evaluator.getVariable(c);
for(var e=n/2,g=0,l=h;1E-12<Math.abs(e);){this.evaluator.setVariable(this.evaluator.getVariable(c)+e);var p=!0;0<this.evaluator.evalExpression(b)?(l=this.evaluator.evalExpression(this.funExpr),this.evaluator.setVariable(d,l),0>=this.evaluator.evalExpression(b)&&(p=!1)):p=!1;p?g+=e:this.evaluator.setVariable(this.evaluator.getVariable(c)-e);e/=2}if(0==g){e=n/2;g=n;for(l=h;1E-12<Math.abs(e);)this.evaluator.setVariable(this.evaluator.getVariable(c)-e),p=!0,0<this.evaluator.evalExpression(b)?l=this.evaluator.evalExpression(this.funExpr):
p=!1,p?g+=-e:this.evaluator.setVariable(this.evaluator.getVariable(c)+e),e/=2}this.evaluator.setVariable(f);return new a.R2(g/Math.abs(n),l)};a.Equation.prototype.Singularity=function(a,b,c,d,f,h,n,e){if(d>=h)return 2;var g=this.evaluator.getVariable(b),l=0;if(1E-12>Math.abs(h-d)||1E-8>Math.abs(h-d)&&Math.abs(n-f)>Math.abs(a))return this.evaluator.setVariable(b,g),1;var p=(d+h)/2;this.evaluator.setVariable(b,p);var m=this.evaluator.evalExpression(this.funExpr);if(Math.abs(n-f)>a){this.evaluator.setVariable(b,
d-1E-6);var k=this.evaluator.evalExpression(this.funExpr),k=(f-k)/1E-6;this.evaluator.setVariable(b,h+1E-6);var r=(this.evaluator.evalExpression(this.funExpr)-n)/1E-6,q=(n-f)/(h-d);if(10>Math.abs(r)||10>Math.abs(k))if((0<=r&&0<=k||0>=r&&0>=k)&&8*Math.abs(r)<Math.abs(q))return this.evaluator.setVariable(b,g),2}e.x<=m&&m<=e.y||(this.evaluator.setVariable(b,p),e.x=Math.min(f,m),e.y=Math.max(f,m),d=this.Singularity(a/2,b,c,d,f,p,m,e),this.evaluator.setVariable(b,h),e.x=Math.min(n,m),e.y=Math.max(n,m),
a=this.Singularity(a/2,b,c,p,m,h,n,e),l=Math.max(d,a));this.evaluator.setVariable(b,g);return l};a.Equation.prototype.drawAuxFun=function(b,d,f){h=this.evaluator.parser.getVariable("x");c=this.evaluator.parser.getVariable("y");d="x";f="y";this.of_y&&(d="y",f="x");var n=this.drawif,e=this.evaluator.evalExpression(this.width),g=!1,l=new a.R2(this.space.w/2+this.space.Ox,this.space.h/2+this.space.Oy),l=this.of_y?l.ix():l.iy(),p=0,m=0,k=0,r=1/this.space.scale,q=r*(this.of_y?-this.space.h+(this.space.h/
2+this.space.Oy):-(this.space.w/2+this.space.Ox)),p=0;this.abs_coord&&(q=this.space.h,r=-1);for(var t=this.of_y?this.space.h:this.space.w;m<t;){var u=!0,w=0;this.evaluator.setVariable(d,q);var s=this.evaluator.evalExpression(this.funExpr);if(isNaN(s))u=!1;else{this.evaluator.setVariable(f,s);if(0<this.evaluator.evalExpression(this.drawif)&&a.rangeOK){if(g){var w=Math.min(p,s),v=Math.max(p,s),v=new a.R2(w,v),w=this.Singularity(r,d,0,q-r,p,q,s,v);0===w?(p<=s?(p=v.x,s=v.y):(s=v.x,p=v.y),w=this.of_y?
this.XX(e,p,this.abs_coord):this.YY(e,p,this.abs_coord),p=this.abs_coord?Math.round(s):this.of_y?this.XX(e,s,this.abs_coord):this.YY(e,s,this.abs_coord),this.fillM&&p>l&&(b.lineWidth=1,b.strokeStyle=this.fillM.getColor(),b.beginPath(),this.of_y?(b.moveTo(l+1,this.space.h-m+0.5),b.lineTo(p,this.space.h-m+0.5)):(b.moveTo(m+0.5,l+1),b.lineTo(m+0.5,p)),b.stroke()),this.fillP&&p<l&&(b.lineWidth=1,b.strokeStyle=this.fillP.getColor(),b.beginPath(),this.of_y?(b.moveTo(l-1,this.space.h-m+0.5),b.lineTo(p,this.space.h-
m+0.5)):(b.moveTo(m+0.5,l-1),b.lineTo(m+0.5,p)),b.stroke()),b.lineWidth=e,b.strokeStyle=this.color.getColor(),b.beginPath(),this.of_y?(b.moveTo(w+0.5,this.space.h-k),b.lineTo(p+0.5,this.space.h-m)):(b.moveTo(k+0.5,w),b.lineTo(m+0.5,p)),b.stroke()):(1===w&&(this.evaluator.setVariable(d,q-r),k=this.extrapolate(n,d,f,0,p,r),this.YY(e,k.y,this.abs_coord),this.evaluator.setVariable(d,q),k=this.extrapolate(n,d,f,0,s,-r),this.YY(e,k.y,this.abs_coord)),this.YY(e,s,this.abs_coord))}else k=this.extrapolateOnSingularity(n,
d,f,0,s,-r),this.YY(e,k.y,this.abs_coord),this.YY(e,s,this.abs_coord);p=s}else u=!1;g&&!u&&(this.evaluator.setVariable(d,q-r),this.evaluator.setVariable(f,p),k=this.extrapolate(n,d,f,0,p,r),this.YY(e,k.y,this.abs_coord),this.evaluator.setVariable(d,q))}g=u;q+=r;k=m++}this.evaluator.parser.setVariable("x",h);this.evaluator.parser.setVariable("y",c)};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 e=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 k,g,b,d,f,h,c,r,m,l,t;a.Curve.prototype.update=function(){k=this.evaluator;g=k.evalExpression(this.parameter_interval);this.paraInf=g[0][0];this.paraSup=g[0][1];this.pSteps=k.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(g,u,p){k=this.evaluator;b=this.space;d=e(k.evalExpression(this.width));g.lineWidth=0<d?d:1E-6;g.lineCap="round";g.lineJoin="round";g.strokeStyle=p.getColor();f=k.getVariable(this.parameter);g.beginPath();k.setVariable(this.parameter,this.paraInf);h=k.evalExpression(this.expresion);this.exprX=this.abs_coord?e(h[0][0]):e(b.getAbsoluteX(h[0][0]));this.exprY=this.abs_coord?e(h[0][1]):e(b.getAbsoluteY(h[0][1]));
this.rotateExp&&(c=a.degToRad(k.evalExpression(this.rotateExp)),r=Math.cos(c),m=Math.sin(c),l=this.exprX*r-this.exprY*m,t=this.exprX*m+this.exprY*r,this.exprX=l,this.exprY=t);g.moveTo(this.exprX+0.5,this.exprY+0.5);for(p=1;p<=this.pSteps;p++)k.setVariable(this.parameter,this.paraInf+p*this.paraSep),h=k.evalExpression(this.expresion),this.exprX=this.abs_coord?e(h[0][0]):e(b.getAbsoluteX(h[0][0])),this.exprY=this.abs_coord?e(h[0][1]):e(b.getAbsoluteY(h[0][1])),this.rotateExp&&(l=this.exprX*r-this.exprY*
m,t=this.exprX*m+this.exprY*r,this.exprX=l,this.exprY=t),g.lineTo(this.exprX+0.5,this.exprY+0.5);this.fill&&(g.fillStyle=u.getColor(),g.fill());g.stroke();k.setVariable(this.parameter,f)};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 e=2*Math.PI,k=Math.round,g,b,d,f,h,c,r,m,l,t,q,u,p;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(){g=this.evaluator;d=g.evalExpression(this.expresion);this.exprX=d[0][0];this.exprY=d[0][1];this.rotateExp&&(f=a.degToRad(g.evalExpression(this.rotateExp)),h=Math.cos(f),c=Math.sin(f),r=this.exprX*
h-this.exprY*c,m=this.exprX*c+this.exprY*h,this.exprX=r,this.exprY=m);q=g.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,c){g=this.evaluator;b=this.space;u=Math.ceil(g.evalExpression(this.size)-0.4);a.fillStyle=c.getColor();a.beginPath();this.rangeInf>this.rangeMax&&
(p=this.rangeInf,this.rangeInf=this.rangeMax,this.rangeMax=p);for(var f=g.getVariable("n"),h=this.rangeInf,m=this.rangeMax;h<=m;h++)g.setVariable("n",h),d=g.evalExpression(this.expresion),this.exprX=d[0][0],this.exprY=d[0][1],l=this.abs_coord?k(this.exprX):k(b.getAbsoluteX(this.exprX)),t=this.abs_coord?k(this.exprY):k(b.getAbsoluteY(this.exprY)),a.beginPath(),a.arc(l,t,u,0,e,!0),a.fill();a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,l+u,t-u,this.color,this.font,"start","alphabetic",
g.evalExpression(this.decimals),this.fixed,!0);g.setVariable("n",f)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=2*Math.PI,k=Math.round,g,b,d,f,h,c,r,m,l,t,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(){g=this.evaluator;d=g.evalExpression(this.expresion);this.exprX=d[0][0];this.exprY=d[0][1];this.rotateExp&&(f=a.degToRad(g.evalExpression(this.rotateExp)),
h=Math.cos(f),c=Math.sin(f),r=this.exprX*h-this.exprY*c,m=this.exprX*c+this.exprY*h,this.exprX=r,this.exprY=m)};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){g=this.evaluator;b=this.space;q=k(g.evalExpression(this.size));u=q+1;a.fillStyle=c.getColor();l=this.abs_coord?k(this.exprX):k(b.getAbsoluteX(this.exprX));t=this.abs_coord?k(this.exprY):
k(b.getAbsoluteY(this.exprY));a.beginPath();a.arc(l,t,q,0,e,!0);a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,l+u+1,t-u,this.color,this.font,"start","alphabetic",g.evalExpression(this.decimals),this.fixed,!0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.round,k=2*Math.PI,g,b,d,f,h,c,r,m,l,t,q,u,p,v,n,s,w,z;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(){g=this.evaluator;d=g.evalExpression(this.expresion);this.endPoints=[];for(var b=0,e=d.length;b<e;b++)this.endPoints[b]={x:d[b][0],y:d[b][1]};if(this.rotateExp){f=a.degToRad(g.evalExpression(this.rotateExp));h=Math.cos(f);c=Math.sin(f);b=0;for(e=this.endPoints.length;b<e;b++)r=this.endPoints[b].x*h-this.endPoints[b].y*c,m=this.endPoints[b].x*c+this.endPoints[b].y*h,this.endPoints[b].x=r,this.endPoints[b].y=m}};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,d){g=this.evaluator;b=this.space;l=e(g.evalExpression(this.width));a.lineWidth=0<l?l:1E-6;p=g.evalExpression(this.size);0>p&&(p=0);a.fillStyle=c.getColor();a.strokeStyle=d.getColor();a.lineCap="round";t=10+a.lineWidth;v=0==a.lineWidth%2?0:0.5;this.abs_coord?(n=e(this.endPoints[0].x),s=e(this.endPoints[0].y),w=e(this.endPoints[1].x),z=e(this.endPoints[1].y)):
(n=e(b.getAbsoluteX(this.endPoints[0].x)),s=e(b.getAbsoluteY(this.endPoints[0].y)),w=e(b.getAbsoluteX(this.endPoints[1].x)),z=e(b.getAbsoluteY(this.endPoints[1].y)));a.beginPath();a.moveTo(n+v,s+v);a.lineTo(w+v,z+v);a.stroke();a.beginPath();a.arc(n,s,p,0,k,!0);a.arc(w,z,p,0,k,!0);a.fill();this.text!=[""]&&(q=parseInt((n+w)/2)-3,u=parseInt((s+z)/2)+3,this.uber.drawText.call(this,a,this.text,q+t,u-t,this.color,this.font,"start","alphabetic",g.evalExpression(this.decimals),this.fixed,!0))};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,k=Math.round,g,b,d,f,h,c,r,m,l,t,q,u,p,v,n,s,w,z;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(){g=this.evaluator;b=g.evalExpression(this.expresion);this.endPoints=[];for(var e=0,n=b.length;e<n;e++)this.endPoints[e]=
{x:b[e][0],y:b[e][1]};if(this.rotateExp){d=a.degToRad(g.evalExpression(this.rotateExp));f=Math.cos(d);h=Math.sin(d);e=0;for(n=this.endPoints.length;e<n;e++)c=this.endPoints[e].x*f-this.endPoints[e].y*h,r=this.endPoints[e].x*h+this.endPoints[e].y*f,this.endPoints[e].x=c,this.endPoints[e].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,d){g=this.evaluator;m=this.space;g.evalExpression(this.size);q=g.evalExpression(this.width);0>q&&(q=0);u=Math.ceil(q/2);p=m.scale;this.vect=new a.Vector2D(this.endPoints[1].x-this.endPoints[0].x,this.endPoints[1].y-this.endPoints[0].y);v=this.vect.vectorLength();this.angle=this.vect.angleBetweenVectors(a.Vector2D.AXIS_X);b.fillStyle=c.getColor();b.strokeStyle=d.getColor();b.lineWidth=2;this.abs_coord?(n=k(this.endPoints[0].x),s=k(this.endPoints[0].y),w=k(this.endPoints[1].x),z=k(this.endPoints[1].y)):
(n=k(m.getAbsoluteX(this.endPoints[0].x)),s=k(m.getAbsoluteY(this.endPoints[0].y)),w=k(m.getAbsoluteX(this.endPoints[1].x)),z=k(m.getAbsoluteY(this.endPoints[1].y)));c=g.evalExpression(this.spear);0>c&&(c=0);b.save();b.translate(n,s,v);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):(v*=p,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,e(-u));
b.lineTo(e(v-c-q),e(-u));b.lineTo(e(v-2*c),e(-c-u));b.lineTo(e(v),0);b.lineTo(e(v-2*c),e(c+u));b.lineTo(e(v-c-q),e(u));b.lineTo(-u,e(u));b.closePath();b.stroke();b.fill();b.restore();this.text!=[""]&&(l=parseInt((n+w)/2)-3,t=parseInt((s+z)/2)+3,this.uber.drawText.call(this,b,this.text,l,t,d,this.font,"start","alphabetic",g.evalExpression(this.decimals),this.fixed,!0))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.round,k,g,b,d,f,h,c,r,m,l,t,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(){k=this.evaluator;b=k.evalExpression(this.expresion);for(var e=0,g=b.length;e<g;e++)this.endPoints[e]={x:b[e][0],y:b[e][1]};if(this.rotateExp){d=a.degToRad(k.evalExpression(this.rotateExp));f=Math.cos(d);h=Math.sin(d);e=0;for(g=this.endPoints.length;e<g;e++)c=this.endPoints[e].x*f-this.endPoints[e].y*h,r=this.endPoints[e].x*h+this.endPoints[e].y*
f,this.endPoints[e].x=c,this.endPoints[e].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){k=this.evaluator;g=this.space;m=e(k.evalExpression(this.width));a.lineWidth=0<m?m:1E-6;a.strokeStyle=c.getColor();a.lineCap="round";a.lineJoin="round";l=0<m?0.5:0;t=this.abs_coord?e(this.endPoints[0].x):e(g.getAbsoluteX(this.endPoints[0].x));
q=this.abs_coord?e(this.endPoints[0].y):e(g.getAbsoluteY(this.endPoints[0].y));a.beginPath();a.moveTo(t+l,q+l);c=1;for(var d=this.endPoints.length;c<d;c++)t=this.abs_coord?e(this.endPoints[c].x):e(g.getAbsoluteX(this.endPoints[c].x)),q=this.abs_coord?e(this.endPoints[c].y):e(g.getAbsoluteY(this.endPoints[c].y)),a.lineTo(t+l,q+l);this.fill&&(a.fillStyle=b.getColor(),a.fill());a.stroke()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.round,k,g,b,d,f,h,c,r,m,l,t,
q,u,p,v,n,s,w,z,C,y;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(){k=this.evaluator;g=k.evalExpression(this.center);this.exprX=g[0][0];this.exprY=g[0][1];this.rotateExp&&(b=a.degToRad(k.evalExpression(this.rotateExp)),d=
Math.cos(b),f=Math.sin(b),h=this.exprX*d-this.exprY*f,c=this.exprX*f+this.exprY*d,this.exprX=h,this.exprY=c);var e=k.evalExpression(this.init),n=k.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=e[0][0],m=e[0][1],l=n[0][0],t=n[0][1],this.vectors?this.abs_coord&&(m=-m,t=-t):this.abs_coord?(r-=this.exprX,m=-m+this.exprY,
l-=this.exprX,t=-t+this.exprY):(r-=this.exprX,m-=this.exprY,l-=this.exprX,t-=this.exprY),q=Math.acos((1*r+0*m)/Math.sqrt(r*r+m*m)),u=Math.acos((1*l+0*t)/Math.sqrt(l*l+t*t)),0<r&&(0<m&&this.abs_coord)&&(q=2*Math.PI-q),0<r&&(0>m&&!this.abs_coord)&&(q=2*Math.PI-q),0>r&&(0>m&&!this.abs_coord)&&(q=2*Math.PI-q),0>r&&(0<m&&this.abs_coord)&&(q=2*Math.PI-q),0<l&&(0<t&&this.abs_coord)&&(u=2*Math.PI-u),0<l&&(0>t&&!this.abs_coord)&&(u=2*Math.PI-u),0>l&&(0>t&&!this.abs_coord)&&(u=2*Math.PI-u),0>l&&(0<t&&this.abs_coord)&&
(u=2*Math.PI-u),p=Math.min(q,u),v=Math.max(q,u),q=p,u=v,u-q>Math.PI&&this.abs_coord&&(q=v,u=p),u-q<=Math.PI&&!this.abs_coord&&(q=v,u=p),this.iniAng=q,this.endAng=u,this.drawPoints=!0):(this.iniAng=a.degToRad(e),this.endAng=a.degToRad(n),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){k=this.evaluator;n=this.space;z=k.evalExpression(this.radius);
0>z&&(z=0);y=e(k.evalExpression(this.width));a.lineWidth=0<y?y:1E-6;a.lineCap="round";a.strokeStyle=c.getColor();this.drawAngle?(this.abs_coord?(s=e(this.exprX),w=e(this.exprY)):(s=e(n.getAbsoluteX(this.exprX)),w=e(n.getAbsoluteY(this.exprY)),z*=n.scale,this.iniAng=-this.iniAng,this.endAng=-this.endAng),this.iniAng>this.endAng&&(C=this.iniAng,this.iniAng=this.endAng,this.endAng=C)):this.drawPoints&&(this.abs_coord?(s=e(this.exprX),w=e(this.exprY)):(s=e(n.getAbsoluteX(this.exprX)),w=e(n.getAbsoluteY(this.exprY)),
z*=n.scale,this.iniAng=-this.iniAng,this.endAng=-this.endAng));this.fill&&(a.fillStyle=b.getColor(),a.beginPath(),a.moveTo(s,w),a.arc(s,w,z,this.iniAng,this.endAng,void 0),a.fill());a.beginPath();a.arc(s,w,z,this.iniAng,this.endAng,void 0);a.stroke();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,s+4,w-2,this.color,this.font,"start","alphabetic",k.evalExpression(this.decimals),this.fixed,!0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b,d,f,h,c,r,
m,l,t,q,u,p,v,n,s;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(){e=this.evaluator;k=e.evalExpression(this.expresion);this.exprX=k[0][0];this.exprY=k[0][1];this.rotateExp&&(g=a.degToRad(e.evalExpression(this.rotateExp)),b=Math.cos(g),d=Math.sin(g),f=this.exprX*b-
this.exprY*d,h=this.exprX*d+this.exprY*b,this.exprX=f,this.exprY=h)};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){s=this.evaluator.evalExpression(this.decimals);"rtfNode"===this.text.type?(l=this.text,this.ascent=0):l=this.splitText(this.text.toString(s,this.fixed).split("\\n"));this.text!=[""]&&this.uber.drawText.call(this,a,l,parseInt(this.exprX)+5,parseInt(this.exprY)+
this.ascent,b,this.font,this.align,"alphabetic",s,this.fixed)};a.Text.prototype.splitText=function(a){e=this.evaluator;c=e.evalExpression(this.width);l=[];this.ctx.font=this.font;if(20<=c&&"undefined"!=a.type){for(var b=0,d=a.length;b<d;b++)r=a[b],m=this.ctx.measureText(r).width,m>c?l=l.concat(this.splitWords(r,c)):l.push(r);t=Math.floor(1.2*this.fontSize)*l.length;e.setVariable("_Text_H_",t);return l}e.setVariable("_Text_H_",0);e.setVariable("_Text_W_",1E3);return a};a.Text.prototype.splitWords=
function(a,b){q=a;u=[];p="";n=0;for(var c,d=0,f=a.length;d<f;d++)v=q.charAt(d)," "===v&&(lastIndexOfWhite=d),p+=v,Math.round(this.ctx.measureText(p).width)>b&&(c=a.substring(n,d+1)," "!==v&&(-1===c.indexOf(" ")?(lastIndexOfWhite=d,d--):d=lastIndexOfWhite),u.push(a.substring(n,lastIndexOfWhite)),p="",n=d+1);u.push(a.substring(n));return u};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.round,k,g,b,d,f,h,c,r,m,l,t,q,u,p;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(){k=this.evaluator;g=k.evalExpression(this.expresion);this.exprX=g[0][0];this.exprY=g[0][1];this.rotateExp&&(b=a.degToRad(k.evalExpression(this.rotateExp)),d=Math.cos(b),f=Math.sin(b),h=this.exprX*d-this.exprY*f,c=this.exprX*f+this.exprY*d,this.exprX=h,this.exprY=c);4==g[0].length&&(this.centered=!0,this.scaleX=g[0][2],0==
this.scaleX&&(this.scaleX=1E-5),this.scaleY=g[0][3],0==this.scaleY&&(this.scaleY=1E-5));g[1]&&2==g[1].length&&(this.centered=!0,this.scaleX=g[1][0],0==this.scaleX&&(this.scaleX=1E-5),this.scaleY=g[1][1],0==this.scaleY&&(this.scaleY=1E-5));if((r=k.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){k=this.evaluator;
m=this.space;this.img&&(this.img.ready&&this.img.complete)&&(l=this.centered?0:this.img.width/2,t=this.centered?0:this.img.height/2,q=this.abs_coord?e(this.exprX):e(m.getAbsoluteX(this.exprX)),u=this.abs_coord?e(this.exprY):e(m.getAbsoluteY(this.exprY)),p=a.degToRad(-k.evalExpression(this.inirot)),b.translate(q+l,u+t),b.rotate(p),b.scale(this.scaleX,this.scaleY),this.opacity&&(b.globalAlpha=k.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 e(a,b,d){c=4*(b+d*a.width);return{r:a.data[c],g:a.data[c+1],b:a.data[c+2],a:a.data[c+3]}}if(a.loadLib)return a;var k,g,b,d,f,h,c;a.Fill=function(b,c){a.Graphic.call(this,b,c)};a.extend(a.Fill,a.Graphic);a.Fill.prototype.update=function(){k=this.evaluator.evalExpression(this.expresion);this.exprX=k[0][0];this.exprY=k[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,m){m.getColor();imageData=this.ctx.getImageData(0,0,this.space.w,this.space.h);this.abs_coord?(g=parseInt(this.exprX),b=parseInt(this.exprY)):(g=parseInt(this.space.getAbsoluteX(this.exprX)),b=parseInt(this.space.getAbsoluteY(this.exprY)));if(!(0>g||0>b||g>=this.space.w||b>=this.space.h)){d=[{x:g,y:b}];for(h=e(imageData,g,b);0<d.length;){f=d.pop();g=f.x;b=f.y;var l=e(imageData,g,b);if(h.r===l.r&&h.g===l.g&&h.b===l.b&&h.a===l.a){var l=imageData,k=m;
c=4*(g+b*l.width);l.data[c+0]=k.r;l.data[c+1]=k.g;l.data[c+2]=k.b;l.data[c+3]=255-k.a;0<g&&d.push({x:g-1,y:b});g<imageData.width-1&&d.push({x:g+1,y:b});d.push({x:g,y:b-1});d.push({x:g,y:b+1})}}this.ctx.putImageData(imageData,0,0)}};return a}(descartesJS||{}),descartesJS=function(a,e){if(a.loadLib)return a;var k=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg|\.PNG|\.JPG|\.GIF|\.SVG)/g;a.Macro=function(g,b){this.expresion=void 0;this.inirot=g.evaluator.parser.parse("0");a.Graphic.call(this,g,b);for(var d in b)b.hasOwnProperty(d)&&
(this[d]=b[d]);this.graphics=[];d=g.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 h=this.evaluator.evalExpression(this.expresion),c;h&&((c=document.getElementById(h))&&"descartes/macro"==c.type?c=c.text:(c=a.openExternalFile(h))&&!c.match(/tipo_de_macro/g)&&(c=null));var r,m;if(c){m=c.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");c=[];for(var h=0,l=m.length;h<l;h++)r=m[h].indexOf("="),-1!==r&&(r=m[h].substring(0,r),("id"===e[r]||"type"===e[r])&&c.push(d.split(m[h])));
for(var t,q,u,p,h=0,l=c.length;h<l;h++){p=(t=c[h]||[])&&t[0]&&"id"===t[0][0];m=0;for(r=t.length;m<r;m++)if(q=t[m][0].indexOf("."),-1!==q&&!p?(q=e[t[m][0].substring(q+1)],t[m][0]=this.name+"."+t[m][0]):q=e[t[m][0]],!("font"===q||("fill"===q||"color"===q||"arrow"===q)&&"("!==t[m][1].charAt(0)||"file"===q&&t[m][1].match(k)||"id"!==q&&void 0!==e[t[m][1]]))if("text"==q)if(t[m][1].match(/\{\\rtf1/)){q=t[m][1];var v=this;u=function(a,b){for(var c=f.tokenize(b.replace(/\&squot;/g,"'")),d=0,h=c.length;d<h;d++)"identifier"==
c[d].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[d].value+"-")&&(c[d].value=v.name+"."+c[d].value);return(a.match(/^\\expr/)?"\\expr ":"\\decimals ")+f.flatTokens(c)};q=q.replace(/\\expr ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,u);q=q.replace(/\\decimals ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,u);t[m][1]=q}else{u=d.parseText(t[m][1]).textElementsMacros;for(var n=
0,s=u.length;n<s;n++){q=f.tokenize(u[n].replace(/\&squot;/g,"'"));for(var w=0,z=q.length;w<z;w++)"identifier"===q[w].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("-"+q[w].value+"-")&&(q[w].value=this.name+"."+q[w].value);q=f.flatTokens(q).replace(/&squot;/g,"'").replace(/'\+\(/g,"[").replace(/\)\+'/g,"]");u[n]=q.substring(1,q.length-1)}t[m][1]=u.join("")}else{q=f.tokenize(t[m][1]);
u=0;for(n=q.length;u<n;u++)"identifier"===q[u].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("-"+q[u].value+"-")&&(q[u].value=this.name+"."+q[u].value);t[m][1]=f.flatTokens(q)}}h=0;for(l=c.length;h<l;h++)if(c[h][0]){t="";p=!1;m=0;for(r=c[h].length;m<r;m++)"type"===e[c[h][m][0]]&&(t="espacio='"+this.spaceID+"' ",p=!0),t=t+c[h][m][0]+"='"+c[h][m][1]+"' ";c[h]=t;p?this.graphics.push(d.parseGraphic(c[h],
this.abs_coord,this.background,this.inirot)):d.parseAuxiliar(c[h])}}}};a.extend(a.Macro,a.Graphic);a.Macro.prototype.update=function(){if(this.inipos){var a=this.evaluator.evalExpression(this.inipos);this.iniPosX=a[0][0];this.iniPosY=a[0][1]}};a.Macro.prototype.drawAux=function(a){for(var b=0,d=this.graphics.length;b<d;b++)this.inipos&&(this.graphics[b].abs_coord?a.translate(this.iniPosX,this.iniPosY):a.translate(this.iniPosX*this.space.scale,-this.iniPosY*this.space.scale)),this.graphics[b].draw(),
a.setTransform(1,0,0,1,0,0)};return a}(descartesJS||{},babel),descartesJS=function(a){if(a.loadLib)return a;var e=Math.sqrt,k=Math.sin,g=Math.cos,b,d,f,h,c,r,m,l,t,q,u,p,v,n,s;a.norm3D=function(a){return e(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,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d||0};a.Matrix4x4=function(a,b,c,d,f,h,e,n,g,l,p,m,k,r,q,t){this.a00=a||0;this.a01=b||0;this.a02=c||0;
this.a03=d||0;this.a10=f||0;this.a11=h||0;this.a12=e||0;this.a13=n||0;this.a20=g||0;this.a21=l||0;this.a22=p||0;this.a23=m||0;this.a30=k||0;this.a31=r||0;this.a32=q||0;this.a33=t||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){d=k(b);f=g(b);l=this.a10;t=this.a11;q=this.a12;u=this.a13;p=this.a20;v=this.a21;n=this.a22;s=this.a23;return new a.Matrix4x4(this.a00,this.a01,this.a02,this.a03,l*f+p*d,t*f+v*d,q*f+n*d,u*f+s*d,l*-d+p*f,t*-d+v*f,q*-d+n*f,u*-d+s*f,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateY=function(b){d=k(b);f=g(b);h=this.a00;c=this.a01;r=this.a02;m=this.a03;p=this.a20;v=this.a21;n=this.a22;s=this.a23;return new a.Matrix4x4(h*
f+p*-d,c*f+v*-d,r*f+n*-d,m*f+s*-d,this.a10,this.a11,this.a12,this.a13,h*d+p*f,c*d+v*f,r*d+n*f,m*d+s*f,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateZ=function(b){d=k(b);f=g(b);h=this.a00;c=this.a01;r=this.a02;m=this.a03;l=this.a10;t=this.a11;q=this.a12;u=this.a13;return new a.Matrix4x4(h*f+l*d,c*f+t*d,r*f+q*d,m*f+u*d,h*-d+l*f,c*-d+t*f,r*-d+q*f,m*-d+u*f,this.a20,this.a21,this.a22,this.a23,this.a30,this.a31,this.a32,this.a33)};return a}(descartesJS||{}),descartesJS=function(a){function e(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,f);a.fill();a.stroke()}function k(a,b){a.lineCap=h;a.lineJoin=c;this.frontColor.getColor();this.backColor.getColor();a.beginPath();a.moveTo(this.newV[0].x,this.newV[0].y);for(var d=1,f=this.newV.length;d<f;d++)a.lineTo(this.newV[d].x,this.newV[d].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 g(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=h;a.lineJoin=c;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 d(b,c,d){r=a.subtract3D(b,c);m=a.subtract3D(b,d);return a.normalize3D(a.crossProduct3D(r,m))}if(a.loadLib)return a;
var f=2*Math.PI,h="round",c="round",r,m,l,t,q,u;a.Primitive3D=function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);this.newV=[];"vertex"===this.type?this.draw=e:"face"===this.type?(this.normal=d(this.vertices[0],this.vertices[1],this.vertices[2]),this.draw=k):"text"===this.type?(this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseInt(this.fontSize[1]):10,this.draw=g):"edge"===this.type&&(this.draw=b);this.isText&&(this.computeDepth=function(){this.newV=this.vertices;this.depth=
this.vertices[0].z})};a.Primitive3D.prototype.computeDepth=function(b){this.average={x:0,y:0,z:0};for(var c=0,f=this.vertices.length;c<f;c++)this.newV[c]=b.rotateVertex(this.vertices[c]),this.average.x+=this.newV[c].x,this.average.y+=this.newV[c].y,this.average.z+=this.newV[c].z;this.average=a.scalarProduct3D(this.average,1/f);2<this.vertices.length&&(this.normal=d(this.newV[0],this.newV[1],this.newV[2]),this.direction=a.dotProduct3D(this.normal,a.normalize3D(b.eye)));c=this.depth=0;for(f=this.vertices.length;c<
f;c++)this.newV[c]=b.project(this.newV[c]),this.depth+=this.newV[c].z;this.depth/=f};a.Primitive3D.prototype.drawText=function(b,c,d,f,h,e,g,m,k,r,u){if("rtfNode"==c.type)b.fillStyle=h,b.strokeStyle=h,b.textBaseline="alphabetic",c.draw(b,d,f,k,r,g,u);else{"simpleText"===c.type&&(c=c.toString(k,r).split("\\n"));d+=e.match("Arial")?-2:e.match("Times")?-2:0;l=this.evaluator;b.fillStyle=a.getColor(l,h);b.font=e;b.textAlign=g;b.textBaseline=m;t=1.2*this.fontSize||0;h=0;for(e=c.length;h<e;h++)q=c[h],this.border&&
b.strokeText(q,d,f+t*h),b.fillText(q,d,f+t*h)}};a.Primitive3D.prototype.splitFace=function(b){if(this.intersects(b)){for(var c=null,d=null,f=0,h=0,e=0,g=b.vertices.length;e<g;e++){var l=this.intersection(b.vertices[e],b.vertices[(e+1)%g]);if(null!==l)if(null===c){if(c=l,f=e,2===b.vertices.length){d=c;break}}else if(!a.equals3DEpsilon(l,c,1E-8)){d=l;h=e;break}}if(null!==c&&null!==d){var e=this.isInterior(c)||this.isInterior(d),m=null,k=null;if(!e&&3<=b.vertices.length)for(var g=0,r=this.vertices.length;g<
r;g++)if(l=b.intersection(this.vertices[g],this.vertices[(g+1)%r]),null!==l)if(null===m)m=l;else if(!a.equals3DEpsilon(l,m,1E-8)){k=l;break}if(e||null!==m&&null!==k&&b.isInterior(m)&&b.isInterior(k)){k=!0;r=b.vertices;m=l=null;if(2===r.length)a.equals(c,r[0],1E-8)||a.equals(c,r[1],1E-8)?k=!1:(l=[],l[0]=r[0],l[1]=c,m=[],m[0]=c,m[1]=r[1]);else for(var l=[],m=[],q=0,e=g=0;e<r.length;e++)e<f?l[q++]=r[e]:e==f?(l[q++]=r[e],l[q++]=c,m[g++]=c):e<h?m[g++]=r[e]:e==h?(m[g++]=r[e],m[g++]=d,l[q++]=d):l[q++]=r[e];
if(k)return c=[],c[0]=new a.Primitive3D({vertices:l,type:"face",frontColor:b.frontColor,backColor:b.backColor,edges:b.edges,model:b.model}),c[0].normal=b.normal,c[1]=new a.Primitive3D({vertices:m,type:"face",frontColor:b.frontColor,backColor:b.backColor,edges:b.edges,model:b.model}),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),d=a.dotProduct3D(this.vertices[0],b.normal);if(1E-8>Math.abs(c-d))return!0;for(var f=1,h=this.vertices.length;f<h;f++){var e=a.dotProduct3D(this.vertices[f],b.normal);if(1E-8>Math.abs(c-e)||e>c&&d<c||e<c&&d>c)return!0}return!1};a.Primitive3D.prototype.intersection=function(b,c){if(0<this.vertices.length){var d=a.subtract3D(c,b),f=a.dotProduct3D(d,this.normal);if(0!==f&&(f=a.dotProduct3D(a.subtract3D(this.vertices[0],b),this.normal)/f,-1E-8<f&&1.00000001>f))return a.add3D(b,a.scalarProduct3D(d,
f))}return null};a.Primitive3D.prototype.isInterior=function(b){if(0<this.vertices.length)for(var c=0,d=a.subtract3D(this.vertices[0],b),f=0,h=this.vertices.length;f<h;f++){var e=a.subtract3D(this.vertices[(f+1)%h],b),g=a.dotProduct3D(a.crossProduct3D(d,e),this.normal);if(1E-8>Math.abs(g)){if(0>a.dotProduct3D(d,e))break}else{if(0>c&&0<g||0<c&&0>g)return!1;d=e;c=g}}return!0};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e={x:0,y:0,z:0},k,g,b,d,f,h,c,r;a.Graphic3D=function(b,
c){this.parent=b;this.evaluator=b.evaluator;var d=b.evaluator.parser;this.spaceID="E0";this.background=!1;this.type="";this.color=new a.Color("eeffaa");this.backcolor=new a.Color("6090a0");this.Nu=this.evaluator.parser.parse("7");this.Nv=this.evaluator.parser.parse("7");this.drawif=d.parse("1");this.abs_coord=!1;this.family="";this.family_interval=d.parse("[0,1]");this.family_steps=d.parse("8");this.font="Monospaced,PLAIN,12";this.fixed=!0;this.text="";this.decimals=d.parse("2");this.inirot="(0,0,0)";
this.inirotEuler=!1;this.inipos=d.parse("(0,0,0)");this.endrot="(0,0,0)";this.endrotEuler=!1;this.endpos=d.parse("(0,0,0)");this.model="color";for(var f in c)c.hasOwnProperty(f)&&(this[f]=c[f]);void 0==this.expresion&&"macro"!=this.type&&(this.expresion=d.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=d.parse(this.inirot);this.endrot=d.parse(this.endrot);this.inirotM=new a.Matrix4x4;this.inirotM_X=new a.Matrix4x4;this.inirotM_Y=new a.Matrix4x4;this.inirotM_Z=new a.Matrix4x4;this.iniposM=new a.Matrix4x4;this.endrotM=new a.Matrix4x4;this.endrotM_X=new a.Matrix4x4;this.endrotM_Y=
new a.Matrix4x4;this.endrotM_Z=new a.Matrix4x4;this.endposM=new a.Matrix4x4};a.Graphic3D.prototype.getSpace=function(){for(var a=this.parent.spaces,b,c=0,d=a.length;c<d;c++)if(b=a[c],b.id==this.spaceID)return b;return a[0]};a.Graphic3D.prototype.getFamilyValues=function(){k=this.evaluator;g=k.evalExpression(this.family_interval);this.familyInf=g[0][0];this.familySup=g[0][1];this.fSteps=Math.round(k.evalExpression(this.family_steps));this.family_sep=0<this.fSteps?(this.familySup-this.familyInf)/this.fSteps:
0};a.Graphic3D.prototype.buildFamilyPrimitives=function(){k=this.evaluator;this.getFamilyValues();b=k.getVariable(this.family);if(0<=this.fSteps)for(var a=0,c=this.fSteps;a<=c;a++)k.setVariable(this.family,this.familyInf+a*this.family_sep),this.familyValue=this.familyInf+a*this.family_sep,k.evalExpression(this.drawif)&&this.buildPrimitives();k.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(b){f=this.evaluator.evalExpression(this.inirot);this.inirotEuler?(this.inirotM=this.inirotM.setIdentity(),this.inirotM=this.inirotM.rotateZ(a.degToRad(f[0][0])),this.inirotM=this.inirotM.rotateX(a.degToRad(f[0][1])),this.inirotM=this.inirotM.rotateZ(a.degToRad(f[0][2]))):(this.inirotM_X=this.inirotM_X.setIdentity().rotateX(a.degToRad(f[0][0])),this.inirotM_Y=this.inirotM_Y.setIdentity().rotateY(a.degToRad(f[0][1])),this.inirotM_Z=
this.inirotM_Z.setIdentity().rotateZ(a.degToRad(f[0][2])));f=this.evaluator.evalExpression(this.inipos);e={x:f[0][0],y:f[0][1],z:f[0][2]};this.iniposM=this.iniposM.setIdentity().translate(e);f=this.evaluator.evalExpression(this.endrot);this.endrotEuler?(this.endrotM=this.endrotM.setIdentity(),this.endrotM=this.endrotM.rotateZ(a.degToRad(f[0][0])),this.endrotM=this.endrotM.rotateX(a.degToRad(f[0][1])),this.endrotM=this.endrotM.rotateZ(a.degToRad(f[0][2]))):(this.endrotM_X=this.endrotM_X.setIdentity().rotateX(a.degToRad(f[0][0])),
this.endrotM_Y=this.endrotM_Y.setIdentity().rotateY(a.degToRad(f[0][1])),this.endrotM_Z=this.endrotM_Z.setIdentity().rotateZ(a.degToRad(f[0][2])));f=this.evaluator.evalExpression(this.endpos);e={x:f[0][0],y:f[0][1],z:f[0][2]};this.endposM=this.endposM.setIdentity().translate(e)};a.Graphic3D.prototype.transformVertex=function(a){this.inirotEuler?d=this.inirotM.multiplyVector4(a):(d=this.inirotM_X.multiplyVector4(a),d=this.inirotM_Y.multiplyVector4(d),d=this.inirotM_Z.multiplyVector4(d));d=this.iniposM.multiplyVector4(d);
this.endrotEuler?d=this.endrotM.multiplyVector4(d):(d=this.endrotM_X.multiplyVector4(d),d=this.endrotM_Y.multiplyVector4(d),d=this.endrotM_Z.multiplyVector4(d));return d=this.endposM.multiplyVector4(d)};a.Graphic3D.prototype.parseExpression=function(){f=this.expresion.split("=");h=f[0];c=[];for(var a=1;a<f.length;a++)h+="=",r=f[a].lastIndexOf(" "),h+=-1!==r?f[a].substring(0,r):f[a],c.push(this.evaluator.parser.parse(h,!0)),h=f[a].substring(r+1);return c};var m;a.Graphic3D.prototype.splitFace=function(a){for(var b=
0,c=this.primitives.length;b<c;b++)if(m=[],"face"===this.primitives[b].type){for(var d=0,f=a.primitives.length;d<f;d++)"face"===a.primitives[d].type?m=m.concat(this.primitives[b].splitFace(a.primitives[d])):m.push(a.primitives[d]);a.primitives=m}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b,d;a.Point3D=function(b,d){a.Graphic3D.call(this,b,d)};a.extend(a.Point3D,a.Graphic3D);a.Point3D.prototype.buildPrimitives=function(){e=this.evaluator;this.updateMVMatrix();
k=e.evalExpression(this.expresion);g=k[0][0];b=k[0][1];d=k[0][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(g,b,d,1))],type:"vertex",backColor:this.backcolor,frontColor:this.color,size:e.evalExpression(this.width)}));""!==this.text&&this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(g,b,d,1))],type:"text",frontColor:this.color,font:this.font,decimals:e.evalExpression(this.decimals),fixed:this.fixed,displace:this.fontSize,
evaluator:e,text:this.text,family:this.family,familyValue:this.familyValue}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b,d,f;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);e=expr[0][0];k=expr[0][1];g=expr[0][2];b=expr[1][0];d=expr[1][1];
f=expr[1][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(e,k,g,1)),this.transformVertex(new a.Vector4D(b,d,f,1))],type:"edge",frontColor:this.color,lineWidth:evaluator.evalExpression(this.width)}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b,d,f,h;a.Surface3D=function(b,d){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,d);this.expresion=this.parseExpression()};a.extend(a.Surface3D,a.Graphic3D);a.Surface3D.prototype.buildPrimitives=function(){e=this.evaluator;this.updateMVMatrix();g=e.getVariable("x");g=e.getVariable("y");g=e.getVariable("z");k=e.getVariable("u");g=e.getVariable("v");e.setVariable("u",0);e.setVariable("v",0);b=e.evalExpression(this.Nu);d=e.evalExpression(this.Nv);f=[];for(var c=0;c<=b;c++){e.setVariable("u",c/b);for(var r=0;r<=d;r++){e.setVariable("v",r/d);for(var m=0,l=this.expresion.length;m<
l;m++)e.evalExpression(this.expresion[m]);f.push(this.transformVertex(new a.Vector4D(e.getVariable("x"),e.getVariable("y"),e.getVariable("z"),1)))}}for(c=0;c<b;c++)for(r=0;r<d;r++)h=[],h.push(f[r+c*d+c]),h.push(f[r+1+c*d+c]),h.push(f[r+2+(c+1)*d+c]),h.push(f[r+1+(c+1)*d+c]),this.primitives.push(new a.Primitive3D({vertices:h,type:"face",frontColor:this.color,backColor:this.backcolor,edges:this.edges,model:this.model}));e.setVariable("x",void 0);e.setVariable("y",void 0);e.setVariable("z",void 0);e.setVariable("u",
k);e.setVariable("v",g)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b,d,f;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 h=0,c=expr.length-1;h<c;h++)e=expr[h][0],k=expr[h][1],g=expr[h][2],b=expr[h+1][0],d=expr[h+1][1],f=expr[h+1][2],
this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(e,k,g,1)),this.transformVertex(new a.Vector4D(b,d,f,1))],type:"edge",frontColor:this.color,lineWidth:evaluator.evalExpression(this.width)}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b,d,f;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");d=evaluator.getVariable("y");f=evaluator.getVariable("z");g=evaluator.getVariable("u");evaluator.setVariable("u",0);k=evaluator.evalExpression(this.Nu);e=[];for(var h=0;h<=k;h++){evaluator.setVariable("u",h/k);for(var c=0,r=this.expresion.length;c<r;c++)evaluator.evalExpression(this.expresion[c]);e.push(this.transformVertex(new a.Vector4D(evaluator.getVariable("x"),evaluator.getVariable("y"),evaluator.getVariable("z"),
1)))}h=0;for(c=e.length-1;h<c;h++)this.primitives.push(new a.Primitive3D({vertices:[e[h],e[h+1]],type:"edge",frontColor:this.color,lineWidth:evaluator.evalExpression(this.width)}));evaluator.setVariable("x",b);evaluator.setVariable("y",f);evaluator.setVariable("z",d);evaluator.setVariable("u",g)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b,d,f,h,c,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);e=expr[0][0];k=expr[0][1];g=expr[0][2];b=expr[1][0];d=expr[1][1];f=expr[1][2];h=expr[2][0];c=expr[2][1];r=expr[2][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(e,k,g,1)),this.transformVertex(new a.Vector4D(h,c,r,1)),this.transformVertex(new a.Vector4D(b,d,f,1))],type:"face",frontColor:this.color,backColor:this.backcolor,edges:this.edges,model:this.model}))};
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e;a.Face3D=function(e,g){a.Graphic3D.call(this,e,g)};a.extend(a.Face3D,a.Graphic3D);a.Face3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);e=[];for(var k=expr.length-1;0<=k;k--)e.push(this.transformVertex(new a.Vector4D(expr[k][0],expr[k][1],expr[k][2],1)));this.primitives.push(new a.Primitive3D({vertices:e,type:"face",frontColor:this.color,
backColor:this.backcolor,edges:this.edges,model:this.model}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b,d;a.Polireg3D=function(b,d){this.width=b.evaluator.parser.parse("2");this.length=b.evaluator.parser.parse("2");a.Graphic3D.call(this,b,d)};a.extend(a.Polireg3D,a.Graphic3D);a.Polireg3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();e=evaluator.evalExpression(this.Nu);k=[this.transformVertex(new a.Vector4D(0,0,0,1))];
g=evaluator.evalExpression(this.width)/2;b=evaluator.evalExpression(this.length)/2;d=2*Math.PI/e;for(var f=0;f<e;f++)k.push(this.transformVertex(new a.Vector4D(g*Math.cos(d*f),b*Math.sin(d*f),0,1)));for(f=0;f<e;f++)this.primitives.push(new a.Primitive3D({vertices:[k[0],f+2<=e?k[f+2]:k[1],k[f+1]],type:"face",frontColor:this.color,backColor:this.backcolor,edges:this.edges,model:this.model}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b;a.Text3D=function(b,f){a.Graphic3D.call(this,
b,f)};a.extend(a.Text3D,a.Graphic3D);a.Text3D.prototype.buildPrimitives=function(){e=this.evaluator;k=e.evalExpression(this.expresion);g=k[0][0];b=k[0][1];this.primitives.push(new a.Primitive3D({vertices:[new a.Vector4D(g,b,0,1)],type:"text",frontColor:this.color,font:this.font,decimals:e.evalExpression(this.decimals),fixed:this.fixed,displace:0,isText:!0,evaluator:e,text:this.text,family:this.family,familyValue:this.familyValue}))};return a}(descartesJS||{}),descartesJS=function(a){function e(a,
b,c,d,f){k.call(this,a/1.8,a/1.8,a/1.8,d,f)}function k(a,b,c,d,f){a/=2;b/=2;c/=2;this.changeGeometry(a,b,c,d,f)||(this.vertices=[new p(a,c,b,1),new p(a,-c,b,1),new p(a,c,-b,1),new p(a,-c,-b,1),new p(-a,c,b,1),new p(-a,-c,b,1),new p(-a,c,-b,1),new p(-a,-c,-b,1)],this.faces=[[2,3,1,0],[1,5,4,0],[5,7,6,4],[6,7,3,2],[4,6,2,0],[3,7,5,1]],this.updateValues(a,b,c,d,f))}function g(a,b,c,d,f){a/=2;this.changeGeometry(a,b,c,d,f)||(this.vertices=[new p(0,0,a,1),new p(-0.49*a,-0.86*a,-0.32*a,1),new p(-0.49*a,
0.86*a,-0.32*a,1),new p(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,d,f))}function b(a,b,c,d,f){a/=2;this.changeGeometry(a,b,c,d,f)||(this.vertices=[new p(0,0,a,1),new p(a,0,0,1),new p(-a,0,0,1),new p(0,a,0,1),new p(0,-a,0,1),new p(0,0,-a,1)],this.faces=[[3,1,0],[2,3,0],[1,4,0],[4,2,0],[1,3,5],[3,2,5],[4,1,5],[2,4,5]],this.updateValues(a,b,c,d,f))}function d(b,c,d,f,e){b/=3.4;if(!this.changeGeometry(b,c,d,f,e)){D=b/E;B=b*E;this.vertices=[new p(b,b,b,1),new p(b,
b,-b,1),new p(b,-b,b,1),new p(b,-b,-b,1),new p(-b,b,b,1),new p(-b,b,-b,1),new p(-b,-b,b,1),new p(-b,-b,-b,1),new p(0,D,B,1),new p(0,D,-B,1),new p(0,-D,B,1),new p(0,-D,-B,1),new p(D,B,0,1),new p(D,-B,0,1),new p(-D,B,0,1),new p(-D,-B,0,1),new p(B,0,D,1),new p(B,0,-D,1),new p(-B,0,D,1),new p(-B,0,-D,1)];A=(new a.Matrix4x4).setIdentity().rotateY(-q/6);for(var h=0,g=this.vertices.length;h<g;h++)this.vertices[h]=A.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,d,f,e)}}function f(b,c,d,f,e){b/=4;if(!this.changeGeometry(b,c,d,f,e)){B=b*E;this.vertices=[new p(0,b,B,1),new p(0,b,-B,1),new p(0,-b,B,1),new p(0,-b,-B,1),new p(b,B,0,1),new p(b,-B,0,1),new p(-b,B,0,1),new p(-b,-B,0,1),new p(B,0,b,1),new p(B,0,-b,1),new p(-B,0,b,1),new p(-B,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]];A=(new a.Matrix4x4).setIdentity().rotateY(-1.029);for(var h=0,g=this.vertices.length;h<g;h++)this.vertices[h]=A.multiplyVector4(this.vertices[h]);this.updateValues(b,c,d,f,e)}}function h(a,b,c,d,f){a/=2;this.isSphere?c=b=a:(b/=2,c/=2);if(!this.changeGeometry(a,b,c,d,f)){this.vertices=[new p(0,0,b,1)];for(var e=1;e<d;e++){y=e*q/d;for(var h=0;h<f;h++)C=h*u/f,s=a*l(y)*t(C),w=c*l(y)*
l(C),z=b*t(y),this.vertices.push(new p(s,w,z,1))}this.vertices.push(new p(0,0,-b,1));this.faces=[];for(e=0;e<f;e++)this.faces.push([0,(e+1)%f+1,e%f+1]);for(e=1;e<d-1;e++)for(h=0;h<f;h++)this.faces.push([h+1+(e-1)*f,(h+1)%f+1+(e-1)*f,(h+1)%f+1+e*f,h+1+e*f]);for(e=0;e<f;e++)this.faces.push([this.vertices.length-1,this.vertices.length-1-f+e,this.vertices.length-1-f+(e+1)%f]);this.updateValues(a,b,c,d,f)}}function c(a,b,c,d,f){a/=2;b/=2;c/=2;if(!this.changeGeometry(a,b,c,d,f)){this.vertices=[];for(var e=
0;e<f;e++)for(var h=0;h<d;h++)s=a*(f-e)/f*t(h*u/d),w=c*(f-e)/f*l(h*u/d),z=b-2*e*b/f,this.vertices.push(new p(s,w,z,1));this.vertices.push(new p(0,0,-b,1));this.faces=[];for(e=0;e<f-1;e++)for(h=0;h<d;h++)this.faces.push([h+e*d,(h+1)%d+e*d,(h+1)%d+(e+1)*d,h+(e+1)*d]);for(e=0;e<d;e++)this.faces.push([this.vertices.length-1,this.vertices.length-1-d+e,this.vertices.length-1-d+(e+1)%d]);this.updateValues(a,b,c,d,f)}}function r(a,b,c,d,f){a/=2;b/=2;c/=2;if(!this.changeGeometry(a,b,c,d,f)){this.vertices=
[];for(var e=0;e<f+1;e++)for(var h=0;h<d;h++)s=a*t(h*u/d),w=c*l(h*u/d),z=b-2*e*b/f,this.vertices.push(new p(s,w,z,1));this.faces=[];for(e=0;e<f;e++)for(h=0;h<d;h++)this.faces.push([h+e*d,(h+1)%d+e*d,(h+1)%d+(e+1)*d,h+(e+1)*d]);this.updateValues(a,b,c,d,f)}}function m(){function a(b){return parseInt(b)}function b(a){return parseFloat(a)}this.vertices=[];this.faces=[];for(var c=0,d=this.fileData.length;c<d;c++)H=this.fileData[c],H.match(/^V\(/)?(G=H.substring(2,H.length-1).split(",").map(b),this.vertices.push(new p(G[0]||
0,G[1]||0,G[2]||0,1))):H.match(/^F\(/)&&(G=H.substring(2,H.length-1).split(",").map(a),this.faces.push(G.reverse()))}if(a.loadLib)return a;var l=Math.sin,t=Math.cos,q=Math.PI,u=2*q,p,v,n,s,w,z,C,y,E=1.6180339887,D,B,A,H,G;a.OtherGeometry=function(n,l){this.width=n.evaluator.parser.parse("2");this.height=n.evaluator.parser.parse("2");this.length=n.evaluator.parser.parse("2");p=a.Vector4D;a.Graphic3D.call(this,n,l);switch(this.type){case "cube":this.buildGeometry=e;break;case "box":this.buildGeometry=
k;break;case "tetrahedron":this.buildGeometry=g;break;case "octahedron":this.buildGeometry=b;break;case "sphere":this.isSphere=!0;case "ellipsoid":this.buildGeometry=h;break;case "dodecahedron":this.buildGeometry=d;break;case "icosahedron":this.buildGeometry=f;break;case "cone":this.buildGeometry=c;break;case "cylinder":this.buildGeometry=r;break;case "mesh":this.fileData=a.openExternalFile(this.evaluator.evalExpression(this.file)).split(/\r/),this.buildGeometry=m}};a.extend(a.OtherGeometry,a.Graphic3D);
a.OtherGeometry.prototype.buildPrimitives=function(){v=this.evaluator;this.updateMVMatrix();this.buildGeometry(v.evalExpression(this.width),v.evalExpression(this.height),v.evalExpression(this.length),v.evalExpression(this.Nu),v.evalExpression(this.Nv));for(var b=0,c=this.faces.length;b<c;b++){n=[];for(var d=0,f=this.faces[b].length;d<f;d++)n.push(this.transformVertex(this.vertices[this.faces[b][d]]));this.primitives.push(new a.Primitive3D({vertices:n,type:"face",frontColor:this.color,backColor:this.backcolor,
edges:this.edges,model:this.model}))}};a.OtherGeometry.prototype.changeGeometry=function(a,b,c,d,f){return this.oldWidth===a&&this.oldHeight===b&&this.oldLength===c&&this.oldNu===d&&this.oldNv===f};a.OtherGeometry.prototype.updateValues=function(a,b,c,d,f){this.oldWidth=a;this.oldHeight=b;this.oldLength=c;this.oldNv=f;this.oldNu=d};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.max,k=Math.min,g=Math.PI,b=Math.cos,d=Math.sin,f=Math.abs,h,c,r,m,l,t,q,u,p,v,n,s,w,
z,C,y,E,D;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(e(k(this.x,32E3),-32E3))};a.R2.prototype.iy=function(){return Math.round(e(k(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){c=this.copy();c.sub(a);return c.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(){h=this.norm();0!=h&&this.div(h)};a.R2.prototype.rotR90=
function(){h=this.x;this.x=this.y;this.y=-h};a.R2.prototype.rotL90=function(){h=this.x;this.x=-this.y;this.y=h};a.R2.prototype.rot=function(a){r=this.copy();t=b(a);q=d(a);this.x=r.x*t-r.y*q;this.y=r.x*q+r.y*t};a.R2.prototype.rot=function(a){this.rot(a*g/180)};a.R2.prototype.intersection=function(b,c,d,h){u=c.x-b.x;p=d.x-h.x;v=d.x-b.x;n=c.y-b.y;s=d.y-h.y;w=d.y-b.y;D=u*s-p*n;return 1E-6<f(D)?(m=(v*s-w*p)/D,l=(-v*n+w*u)/D,0<=m&&1>=m&&0<=l&&1>=l?new a.R2(b.x+u*m,b.y+n*m):null):(c.x-d.x)*w!=(c.y-d.y)*
v?null:b.x!=c.x?(z=k(b.x,c.x),C=e(b.x,c.x),z<=d.x&&d.x<=C?d:z<=h.x&&h.x<=C?h:null):d.x!=h.x?(y=k(d.x,h.x),E=e(d.x,h.x),y<=b.x&&b.x<=E?b:y<=c.x&&c.x<=E?c:null):b.y!=c.y?(z=k(b.y,c.y),C=e(b.y,c.y),z<=d.y&&d.y<=C?d:z<=h.y&&h.y<=C?h:null):d.y!=h.y?(y=k(d.y,h.y),E=e(d.y,h.y),y<=b.y&&b.y<=E?b:y<=c.y&&c.y<=E?c:null):b.x==d.x&&b.y==d.y?b:null};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b,d,f,h,c;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];f=new a.R2(0,0)};a.R2Newton.prototype.getUnitNormal=function(){this.normal.normalize();return this.normal.copy()};a.R2Newton.prototype.gradient=function(a){e=
this.evaluator;h=e.getVariable("x");c=e.getVariable("y");e.setVariable("x",a.x);e.setVariable("y",a.y);this.f0=e.evalExpression(this.constraint);e.setVariable("x",e.getVariable("x")+1E-12);k=e.evalExpression(this.constraint);f.x=(k-this.f0)/1E-12;f.x=!isNaN(f.x)?f.x:Infinity;e.setVariable("x",e.getVariable("x")-1E-12);e.setVariable("y",e.getVariable("y")+1E-12);k=e.evalExpression(this.constraint);f.y=(k-this.f0)/1E-12;f.y=!isNaN(f.y)?f.y:Infinity;e.setVariable("x",h);e.setVariable("y",c);return f};
a.R2Newton.prototype.findZero=function(a){e=this.evaluator;d=a.copy();h=e.getVariable("x");c=e.getVariable("y");e.setVariable("x",a.x);e.setVariable("y",a.y);this.f0=e.evalExpression(this.constraint);if("menor"===this.sign&&0>=this.f0||"mayor"===this.sign&&0<=this.f0)return d;e.setVariable("x",h);e.setVariable("y",c);for(var f=0;256>f;f++)if(g=d.x,b=d.y,this.normal=this.gradient(d),0!=this.normal.norm2()&&this.normal.mul(-this.f0/this.normal.norm2()),d.x=g+this.normal.x,d.y=b+this.normal.y,1E-6>this.normal.norm()){0===
this.normal.x&&0===this.normal.y&&(this.normal.x=d.x-a.x,this.normal.y=d.y-a.y);break}return d};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Vector2D=function(a,k){this.x=a;this.y=k};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 e=Math.floor,k=Math.round,g,b,d,f,h,c,r,m,l,t,q,u,p,v,n,s,w,z,C,y;a.Control=function(b,c){this.parent=b;this.evaluator=b.evaluator;var d=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=d.parse("(0,0,100,23)"):(this.expresion=d.parse("(0,0,300,200)"),this.w=300,this.h=200):this.expresion=d.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:d.parse("12");this.parameter=this.action="";this.parameterFont="Monospace 12px";
this.drawif=d.parse("1");this.activeif=d.parse("1");this.tooltip="";this.tooltipFont="Monospace 12px";this.Explanation="";this.ExplanationFont="Monospace 12px";this.cID=this.msg_pos="";this.valueExpr=d.parse("0");this.decimals=d.parse("2");this.min=d.parse("-Infinity");this.max=d.parse("Infinity");this.incr=d.parse("0.1");this.exponentialif=this.discrete=!1;this.zIndex=-1;for(var f in c)c.hasOwnProperty(f)&&(this[f]=c[f]);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;d=this.evaluator.evalExpression(this.expresion);this.x=k(d[0][0]);this.y=k(d[0][1]);4==d[0].length&&(this.w=k(d[0][2]),this.h=k(d[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,d=a.length;c<d;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.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(){d=f=h=c=!1;r=this.evaluator.evalExpression(this.expresion);
m=k(r[0][0]);d=k(this.x)!==m;this.x=m;m=k(r[0][1]);f=k(this.y)!==m;this.y=m;4===r[0].length&&(m=k(r[0][2]),h=k(this.w)!==m,this.w=m,m=k(r[0][3]),c=k(this.h)!==m,this.h=m);if(h||c||d||f)this.init(),this.draw()};a.Control.prototype.formatOutputValue=function(a){p=this.parent;l=a+"";t=this.evaluator.evalExpression(this.decimals);q=l.indexOf(".");-1!=q&&(u=l.substring(q+1),u.length>t&&(l=parseFloat(l).toFixed(t)));if(this.fixed&&(2!==p.version||2===p.version&&!this.exponentialif))l=parseFloat(a).toFixed(t);
this.exponentialif&&0!=parseFloat(l)&&(l=this.fixed&&2!==p.version?parseFloat(l).toExponential(t):parseFloat(l).toExponential(),l=l.toUpperCase(),l=l.replace("+",""));return l=l.replace(".",p.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);g=c*c;for(var d=0;d<c;d++)b=e(d-35*c/100),this.linearGradient.addColorStop(d/c,"rgba(0,0,0,"+192*b*b/g/255+")")};a.Control.prototype.getScreenshot=function(){s=this;v=document.createElement("canvas");v.setAttribute("width",s.w);v.setAttribute("height",s.h);n=v.getContext("2d");n.font=s.fieldFontSize+"px Arial, Helvetica, 'Droid Sans', Sans-serif";s.canvas&&(w=s.canvas.offsetLeft,z=s.canvas.offsetTop,n.drawImage(s.canvas,w,z));s.label&&(w=s.label.offsetLeft,z=s.label.offsetTop,C=s.label.offsetWidth,
y=s.label.offsetHeight,n.fillStyle="#e0e4e8",n.fillRect(w,z,C,y),n.fillStyle="black",n.textAlign="center",n.textBaseline="middle",n.fillText(s.name,w+C/2,z+y/2));s.field&&(w=s.field.offsetLeft,z=s.field.offsetTop,C=s.field.offsetWidth,y=s.field.offsetHeight,n.fillStyle="white",n.strokeStyle="#666666",n.lineWidth=1,n.fillRect(w,0,C,y),n.strokeRect(w+0.5,0.5,C-1,y-1),n.fillStyle="black",n.textAlign="center",n.textAlign="left",n.fillText(s.field.value,w+2,y/2));s.select&&(w=s.select.offsetLeft,z=s.select.offsetTop,
C=s.select.offsetWidth,y=s.select.offsetHeight,n.fillStyle="#e0e4e8",n.strokeStyle="#666666",n.lineWidth=1,n.fillRect(w,0,C,y),n.strokeRect(w+0.5,0.5,C,y-1),n.fillStyle="black",n.textAlign="center",n.textAlign="left",n.fillText(s.select.value,w+2,y/2),n.fillStyle="#c0c0c0",n.fillRect(w+C-15+0.5,0.5,15,y-1),n.strokeRect(w+C-15+0.5,0.5,15,y-1),n.fillStyle="black",n.beginPath(),n.moveTo(w+C-15+4.5,y/2-2.5),n.lineTo(w+C-15+8,y/2+2.5),n.lineTo(w+C-15+11.5,y/2-2.5),n.closePath(),n.fill());return v};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,k,g,b,d,f,h,c,r,m,l,t,q,u=900;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.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");var d;this.imageSrc.match("_COLORES_")&&
(d=this.imageSrc.split("_"),this.colorInt=new a.Color(d[2]),this.color=new a.Color(d[3]),this.font_size=this.parser.parse(d[5]),this.imageSrc="");this.imageSrc=this.parser.parse("'"+this.imageSrc+"'");d=this.evaluator.evalExpression(this.imageSrc).trim();if(""!=d){var f=d.substr(0,d.lastIndexOf(".")),e=d.substr(d.lastIndexOf("."));d.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(d),this.imageOver=this.parent.getImage(f+"_over"+e),this.imageDown=this.parent.getImage(f+"_down"+e))}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(){k=this.evaluator;g=this.canvas;d=k.evalExpression(this.expresion);this.x=d[0][0];this.y=d[0][1];4==d[0].length&&(this.w=parseInt(d[0][2]),this.h=parseInt(d[0][3]));g.setAttribute("width",this.w+"px");
g.setAttribute("height",this.h+"px");g.setAttribute("style","left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+"; display: block;");this.fontSizeNotSet&&(this.font_size=k.parser.parse(a.getFieldFontSize(this.h)+""));this.createGradient(this.w,this.h);g.style.display=0<k.evalExpression(this.drawif)?"block":"none"};a.Button.prototype.update=function(){k=this.evaluator;g=this.canvas;this.activeIfValue=0<k.evalExpression(this.activeif);(this.drawIfValue=0<k.evalExpression(this.drawif))?(g.style.display=
"block",this.draw()):(this.click=!1,g.style.display="none");this.updatePositionAndSize()};a.Button.prototype.draw=function(){k=this.evaluator;b=this.ctx;f=k.evalExpression(this.font_size);h=k.evalExpression(this.name);c=k.evalExpression(this.imageSrc);r="vacio.gif"===c?this.emptyImage:this.parent.getImage(c);b.clearRect(0,0,this.w,this.h);l=m=0;this.click&&(l=m=1);r&&r.ready?r!==this.emptyImage&&r.complete&&b.drawImage(r,parseInt((this.w-r.width)/2)+m,parseInt((this.h-r.height)/2)+l):(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.imageOver.src&&(this.imageOver.ready&&this.over)&&b.drawImage(this.imageOver,parseInt((this.w-r.width)/2)+m,parseInt((this.h-r.height)/2)+l);""!=this.imageDown.src&&this.imageDown.ready&&this.click?
b.drawImage(this.imageDown,parseInt((this.w-r.width)/2)+m,parseInt((this.h-r.height)/2)+l):this.click&&(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+" "+f+"px Arial";b.textAlign="center";b.textBaseline="middle";this.colorInt.getColor()!=this.color.getColor()&&(b.lineJoin="round",b.lineWidth=parseInt(f/6),b.strokeStyle=this.colorInt.getColor(),
b.strokeText(h,e(this.w/2+m)+0.5,e(this.h/2+l)+0.5));b.fillText(h,e(this.w/2+m)+0.5,e(this.h/2+l)+0.5);this.underlined&&(t=b.measureText(h).width,b.strokeStyle=this.color.getColor(),b.lineWidth=e(f/10)||2,b.lineCap="round",b.beginPath(),b.moveTo(parseInt((this.w-t)/2)+m,e((this.h+f)/2)+e(f/5)-1.5+l),b.lineTo(parseInt((this.w+t)/2)+m,e((this.h+f)/2)+e(f/5)-1.5+l),b.stroke());this.activeIfValue||(b.save(),b.globalCompositeOperation="destination-in",b.fillStyle="rgba(240,240,240,"+160/255+")",b.fillRect(0,
0,this.w,this.h),b.restore())};a.Button.prototype.bottonPressed=function(){this.updateAndExecAction()};a.Button.prototype.registerMouseAndTouchEvents=function(){function b(a,c,d){clearInterval(g);h.click&&(c.call(h),a=d?a:30,g=setTimeout(function(){b(a,c)},a))}function c(f){f.preventDefault();document.activeElement.blur();h.whichButton=a.whichButton(f);"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",d):window.addEventListener("mouseup",d))}function d(a){if(h.activeIfValue||h.click)h.click=!1,h.draw(),"calculate"!=h.action&&h.bottonPressed(),a.preventDefault(),q?window.removeEventListener("touchend",d,!1):window.removeEventListener("mouseup",d,!1)}function f(a){h.over=!0;h.draw()}function e(a){h.over=!1;h.click=!1;h.draw()}q=a.hasTouchSupport;var h=this,g;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",f),this.canvas.addEventListener("mouseout",e))};a.Button.prototype.getScreenshot=function(){return this.canvas};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b,d,f,h,c,r,m,l,t,q,u,p,v,n;a.Spinner=function(b,c){a.Control.call(this,b,c);this.tabindex=++this.parent.tabindex;"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,
this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");this.containerControl=document.createElement("div");this.canvas=document.createElement("canvas");this.divUp=document.createElement("div");this.divDown=document.createElement("div");this.field=document.createElement("input");this.label=document.createElement("label");this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.field);this.containerControl.appendChild(this.canvas);this.containerControl.appendChild(this.divUp);
this.containerControl.appendChild(this.divDown);this.addControlContainer(this.containerControl);this.originalIncr=this.incr;if(0>=this.evaluator.evalExpression(this.decimals)){var d=this.evaluator.evalExpression(this.incr);0<d?this.originalIncr=this.incr=this.evaluator.parser.parse(parseInt(d).toString()):this.incr=this.evaluator.parser.parse("1")}this.registerMouseAndTouchEvents();this.init()};a.extend(a.Spinner,a.Control);a.Spinner.prototype.init=function(){e=this.evaluator;var b=e.evalExpression(this.name).toString();
this.label.innerHTML=b;this.value=this.validateValue(e.evalExpression(this.valueExpr));var c=this.formatOutputValue(this.value);this.fieldFontSize=2!==this.parent.version?a.getFieldFontSize(this.h):10;var d=2!==this.parent.version?"":"_____",f=a.getTextWidth(c+"_",this.fieldFontSize+"px Arial"),h=2+parseInt(this.h/2),g=parseInt(this.w/2-h/2),d=a.getTextWidth(b+d,this.fieldFontSize+"px Arial");this.visible||(g=this.w-h,f=0);g<d&&(g=d);""==b&&(g=0);this.w-g-h<f&&(g=this.w-h-f);0>g&&(g=0);b=this.w-(g+
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.canvas.setAttribute("width",h+"px");this.canvas.setAttribute("height",this.h+"px");this.canvas.setAttribute("style","position: absolute; left: "+g+"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: "+g+"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: "+g+"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-
2)+"px; height : "+(this.h-2)+"px; left: "+(h+g)+"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: "+g+"px; height: "+this.h+"px; line-height: "+this.h+"px;");e.setVariable(this.id,this.value);this.createGradient(this.h/2,this.h)};a.Spinner.prototype.update=function(){e=this.evaluator;this.label.innerHTML=e.evalExpression(this.name).toString();
0>=e.evalExpression(this.decimals)?(k=e.evalExpression(this.incr),0<k?this.originalIncr=this.incr=e.parser.parse(parseInt(k).toString()):this.incr=e.parser.parse("1")):this.incr=this.originalIncr;this.activeIfValue=0<e.evalExpression(this.activeif);this.drawIfValue=0<e.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();
g=this.field.value;b=this.value;this.value=this.validateValue(e.getVariable(this.id));this.field.value=this.formatOutputValue(this.value);this.value==b&&this.field.value!=g&&(this.value=this.validateValue(g),this.field.value=this.formatOutputValue(this.value));e.setVariable(this.id,this.value)};a.Spinner.prototype.draw=function(){d=this.ctx;f=this.canvas.width;h=this.canvas.height;d.fillStyle="#f0f8ff";d.fillRect(0,0,f,h);d.fillStyle=this.linearGradient;d.fillRect(0,0,f,h);this.up?(c="gray",r="#f0f8ff"):
(c="#f0f8ff",r="gray");a.drawLine(d,0,0,f,0,c);a.drawLine(d,0,0,0,h/2,c);a.drawLine(d,0,h/2,f,h/2,r);this.down?(c="gray",r="#f0f8ff"):(c="#f0f8ff",r="gray");a.drawLine(d,0,h/2+1,f,h/2+1,c);a.drawLine(d,0,h/2+1,0,h,c);a.drawLine(d,0,h-1,f,h-1,r);m=[parseInt(f/2+1),parseInt(f/5+1),parseInt(f-f/5+1)];l=[parseInt(h/8+1),parseInt(h/8+1+h/4),parseInt(h/8+1+h/4)];d.fillStyle=this.activeIfValue?"#2244cc":"#8888aa";d.beginPath();d.moveTo(m[0],l[0]);d.lineTo(m[1],l[1]);d.lineTo(m[2],l[2]);d.fill();l=[parseInt(h-
h/8),parseInt(h-h/8-h/4),parseInt(h-h/8-h/4)];d.fillStyle=this.activeIfValue?"#d00018":"#aa8888";d.beginPath();d.moveTo(m[0],l[0]);d.lineTo(m[1],l[1]);d.lineTo(m[2],l[2]);d.fill();d.fillStyle="rgba(0,0,0,"+24/255+")";this.up&&d.fillRect(0,0,f,h/2);this.down&&d.fillRect(0,h/2,f,h)};a.Spinner.prototype.validateValue=function(a){e=this.evaluator;isNaN(parseFloat(a))||a.toString().match("e")&&(a=parseFloat(a).toFixed(20));a=a.toString();t=parseFloat(e.evalExpression(e.parser.parse(a.replace(this.parent.decimal_symbol,
"."))));isNaN(t)&&(t=0);p=e.evalExpression(this.min);v=e.evalExpression(this.max);""===p&&(p=-Infinity);""===v&&(v=Infinity);t<p&&(t=p);t>v&&(t=v);this.discrete&&(q=e.evalExpression(this.incr),t=0==q?0:q*Math.round(t/q));u=e.evalExpression(this.decimals);0>=u&&(u=0);return t=parseFloat(parseFloat(t).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,d){clearInterval(k);if(l.up||l.down)c.call(l),a=d?a:30,k=setTimeout(function(){b(a,c)},a)}function c(d){d.preventDefault();l.whichButton=a.whichButton(d);"L"==
l.whichButton&&l.activeIfValue&&(l.up=!0,b(m,l.increase,!0),l.draw())}function d(c){c.preventDefault();l.whichButton=a.whichButton(c);"L"==l.whichButton&&l.activeIfValue&&(l.down=!0,b(m,l.decrease,!0),l.draw())}function f(a){l.up=!1;clearInterval(k);l.draw();a.preventDefault()}function h(a){l.down=!1;clearInterval(k);l.draw();a.preventDefault()}function e(a){l.up=!1;clearInterval(k);l.draw();a.preventDefault()}function g(a){l.down=!1;clearInterval(k);l.draw();a.preventDefault()}n=a.hasTouchSupport;
var l=this,m=n?500:200,k;l.divUp.oncontextmenu=l.divDown.oncontextmenu=l.field.oncontextmenu=l.label.oncontextmenu=function(){return!1};n?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&&l.changeValue(l.field.value)});n?this.divUp.addEventListener("touchstart",c):this.divUp.addEventListener("mousedown",c);n?this.divDown.addEventListener("touchstart",
d):this.divDown.addEventListener("mousedown",d);n||this.divUp.addEventListener("mouseout",f);n||this.divDown.addEventListener("mouseout",h);n?(this.divUp.addEventListener("touchend",e),window.addEventListener("touchend",e)):(this.divUp.addEventListener("mouseup",e),window.addEventListener("mouseup",e));n?(this.divDown.addEventListener("touchend",g),window.addEventListener("touchend",g)):(this.divDown.addEventListener("mouseup",g),window.addEventListener("mouseup",g))};return a}(descartesJS||{}),descartesJS=
function(a){if(a.loadLib)return a;var e,k,g,b,d,f,h;a.TextField=function(b,d){a.Control.call(this,b,d);"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");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.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(){e=this.evaluator;var b=e.evalExpression(this.name).toString();this.label.innerHTML=b;this.value=this.validateValue(e.evalExpression(this.valueExpr));var d=this.formatOutputValue(this.value);this.fieldFontSize=a.getFieldFontSize(this.h);var f=a.getTextWidth(d+"_",this.fieldFontSize+"px Arial"),h=parseInt(this.w/2),g=a.getTextWidth(b,this.fieldFontSize+"px Arial");h<g&&(h=g);""==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-2)+"px; height : "+(this.h-
2)+"px; left: "+h+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.value=d;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(){e=this.evaluator;this.label.innerHTML=e.evalExpression(this.name).toString();this.activeIfValue=0<e.evalExpression(this.activeif);this.drawIfValue=0<e.evalExpression(this.drawif);this.field.disabled=!this.activeIfValue;this.containerControl.style.display=this.drawIfValue?"block":"none";this.updatePositionAndSize();k=this.field.value;g=this.value;this.value=this.validateValue(e.getVariable(this.id));this.field.value=this.formatOutputValue(this.value);this.value===g&&this.field.value!=k&&
(this.value=this.validateValue(k),this.field.value=this.formatOutputValue(this.value));e.setVariable(this.id,this.value)};a.TextField.prototype.validateValue=function(a){if(""===a||"''"==a)return"";e=this.evaluator;b=parseFloat(e.evalExpression(e.parser.parse(a.toString().replace(this.parent.decimal_symbol,"."))));isNaN(b)&&(b=0);d=e.evalExpression(this.min);""==d&&(d=-Math.Infinity);f=e.evalExpression(this.max);""==f&&(f=Math.Infinity);this.discrete&&(a=e.evalExpression(this.incr),b=0==a?0:a*Math.round(b/
a));return b=parseFloat(parseFloat(b).toFixed(e.evalExpression(this.decimals)))};a.TextField.prototype.formatOutputValue=function(a){return""===a?"":this.uber.formatOutputValue.call(this,a)};a.TextField.prototype.changeValue=function(a,b){this.activeIfValue&&(this.value=this.validateValue(a),this.field.value=this.formatOutputValue(this.value),this.evaluate&&(this.ok=this.evaluateAnswer()),this.evaluator.setVariable(this.id,this.value),this.evaluator.setVariable(this.id+".ok",this.ok),this.updateAndExecAction())};
a.TextField.prototype.evaluateAnswer=function(){return a.esCorrecto(this.answer,this.value,this.evaluator,this.answer)};a.TextField.prototype.getFirstAnswer=function(){return this.answer?this.onlyText?this.firstAnswer:this.evaluator.evalExpression(this.firstAnswer):""};a.TextField.prototype.registerMouseAndTouchEvents=function(){h=a.hasTouchSupport;var b=this;b.label.oncontextmenu=function(){return!1};h?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(a){b.changeValue(b.field.value,!0)});this.field.addEventListener("keydown",function(a){b.activeIfValue&&13==a.keyCode&&b.changeValue(b.field.value,!0)})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.abs,k,g,b,d;a.Menu=function(b,c){this.options="";a.Control.call(this,b,c);var d=this.parser;"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,
this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");this.options=this.options.split(",");this.menuOptions=[];this.strValue=[];for(var f,e=0,g=this.options.length;e<g;e++)f=this.options[e].split(/[\[\]]/,2),1==f.length?(this.menuOptions.push(f[0]),this.strValue.push(e.toString())):2==f.length&&(this.menuOptions.push(f[0]),""==f[1]?this.strValue.push(e.toString()):this.strValue.push(f[1]));e=0;for(g=this.strValue.length;e<g;e++)this.strValue[e]=d.parse(this.strValue[e]);this.containerControl=
document.createElement("div");this.label=document.createElement("label");this.select=document.createElement("select");e=0;for(g=this.menuOptions.length;e<g;e++)d=document.createElement("option"),d.innerHTML=this.menuOptions[e],this.select.appendChild(d);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);var f;a.Menu.prototype.init=function(){f=this.evaluator;var b=f.evalExpression(this.name).toString();this.label.innerHTML=b;this.fieldFontSize=2!=this.parent.version?a.getFieldFontSize(this.h):10;var c=0,d=0,e=0;this.value=f.evalExpression(this.valueExpr);this.indexValue=this.getIndex(this.value);for(var g=0,k=this.menuOptions.length;g<k;g++)e=a.getTextWidth(this.menuOptions[g],this.fieldFontSize+"px Arial"),e>c&&(c=e,d=g);c+=25;e=a.getTextWidth(this.formatOutputValue(f.evalExpression(this.strValue[d])),
this.fieldFontSize+"px Arial")+7;d=a.getTextWidth(b,this.fieldFontSize+"px Arial")+10;""==b&&(d=0);this.visible||(e=0);for(b=this.w-e-d;b<c&&0<d;)d--,b++;for(;b<c&&0<e;)e--,b++;for(;d+b+e+1<this.w;)b++,e++;c=d;g=c+b;e=this.w-g;k=this.formatOutputValue(f.evalExpression(this.strValue[this.indexValue]));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.label.setAttribute("class","DescartesMenuLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+d+"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=k;this.field.setAttribute("class","DescartesMenuField");this.field.setAttribute("style","font-size: "+this.fieldFontSize+"px; width : "+(e-2)+"px; height : "+(this.h-2)+"px; left: "+g+"px;");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.selectedIndex=this.indexValue;f.setVariable(this.id,parseFloat(k));this.update()};a.Menu.prototype.update=function(){f=this.evaluator;this.label.innerHTML=
f.evalExpression(this.name).toString();this.activeIfValue=0<f.evalExpression(this.activeif);this.drawIfValue=0<f.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();this.value=f.getVariable(this.id);this.field.value=this.formatOutputValue(this.value);f.setVariable(this.id,parseFloat(this.value));
this.select.selectedIndex=parseFloat(this.getIndex(this.value))};a.Menu.prototype.getIndex=function(a){a=parseFloat(a.toString().replace(this.parent.decimal_symbol,"."));k=-1;g=Infinity;for(var c=0,d=this.strValue.length;c<d;c++)b=e(a-parseFloat(this.evaluator.evalExpression(this.strValue[c]))),b<=g&&(g=b,k=c);return k};a.Menu.prototype.changeValue=function(){this.activeIfValue&&(this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction())};a.Menu.prototype.registerMouseAndTouchEvents=
function(){d=a.hasTouchSupport;var b=this;b.select.oncontextmenu=b.label.oncontextmenu=b.field.oncontextmenu=function(){return!1};d?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())})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,k="h",g,b,d,f,h,c,r,m,l,t,q,u,p,v,n,s,w,z,C,y,E;a.Scrollbar=function(b,c){a.Control.call(this,b,c);"["===this.name.charAt(0)&&
"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");this.orientation=this.w>=this.h?k:"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(){g=this.evaluator;this.findOffset();0==g.evalExpression(this.decimals)?
this.incr=1:this.incr=(g.evalExpression(this.max)-g.evalExpression(this.min))/100;this.value=this.validateValue(g.evalExpression(this.valueExpr));d=this.formatOutputValue(this.value);f=this.evaluator.evalExpression(this.expresion);this.x=f[0][0];this.y=f[0][1];4==f[0].length&&(this.w=f[0][2],this.h=f[0][3]);this.orientation=this.w>=this.h?k:"v";this.initScroll(d);this.changeScrollPositionFromValue();this.prePos=this.pos;g.setVariable(this.id,this.value)};a.Scrollbar.prototype.initScroll=function(c){b=
this;g=b.evaluator;var d=g.evalExpression(b.name).toString();b.label.innerHTML=d;var f="v"===b.orientation?parseInt(19+5*(b.h-100)/100):b.h;b.fieldFontSize="v"===b.orientation?f-parseInt(b.h/20)-1:2!==b.parent.version?a.getFieldFontSize(f):10;var e=a.getTextWidth(c+"_",b.fieldFontSize+"px Arial"),h=b.parent.getSpaceById(b.spaceID).h;b.labelHeight=""==d?0:f;b.fieldHeight=""==b.visible?0:f;if("v"===b.orientation)b.canvasWidth=b.w,b.canvasHeight=b.h-b.labelHeight-b.fieldHeight,18<=b.canvasHeight+b.y-
h&&(b.canvasHeight=h),d=0,d=b.fieldHeight,e=d+b.canvasHeight,b.canvasX=0,b.canvasY=b.fieldHeight,b.labelWidth=b.w,b.labelY=e,b.upWidth=b.downW=b.w,b.upHeight=b.downH=15,b.upX=0,b.upY=b.fieldHeight,b.downX=0,b.downY=e-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=e-b.downH-b.scrollManipulatorH,
b.scrollManipulatorLimSup=d+b.downH;else{f=a.getTextWidth(d,b.fieldFontSize+"px Arial")+10;b.labelWidth=f;b.fieldWidth=e;""==d&&(b.labelWidth=0);b.visible||(b.fieldWidth=0);for(e=b.w-b.fieldWidth-b.labelWidth;58>e&&0<b.labelWidth;)b.labelWidth--,e++;for(;58>e&&0<b.fieldWidth;)b.fieldWidth--,e++;d=b.labelWidth;f=d+e;b.fieldWidth=b.w-f;b.canvasWidth=e;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=f-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=d+b.downW;b.scrollManipulatorLimSup=d+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-2)+"px; height : "+(b.fieldHeight-2)+"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(){g=this.evaluator;this.label.innerHTML=g.evalExpression(this.name).toString();0==g.evalExpression(this.decimals)?this.incr=1:this.incr=(g.evalExpression(this.max)-g.evalExpression(this.min))/100;this.activeIfValue=0<g.evalExpression(this.activeif);this.drawIfValue=0<g.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(g.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);g.setVariable(this.id,this.value)};a.Scrollbar.prototype.draw=function(){b=this;h=b.ctx;r=e(this.w);c=e(this.h);h.fillStyle="#e0e4e8";h.fillRect(0,0,r,c);h.strokeStyle="#7a8a99";b.down&&(h.fillStyle="#ccdcec",h.fillRect(b.downX+0.5,b.downY+0.5,b.downW,b.downH-1));h.strokeRect(b.downX+0.5,b.downY+
0.5,b.downW,b.downH-1);b.up&&(h.fillStyle="#ccdcec",h.fillRect(b.upX+0.5,b.upY-0.5,b.upWidth,b.upHeight+1));h.strokeRect(b.upX+0.5,b.upY-0.5,b.upWidth,b.upHeight+1);m=4;h.fillStyle="black";h.beginPath();b.orientation===k?(h.moveTo(b.downX+m,b.downH/2),h.lineTo(b.downX+b.downW-m,m),h.lineTo(b.downX+b.downW-m,b.downH-m),h.moveTo(b.upX+b.upWidth-m,b.downH/2),h.lineTo(b.upX+m,m),h.lineTo(b.upX+m,b.downH-m),h.fill(),b.activeIfValue&&(l=e(b.pos),h.fillStyle="#ccdcec",h.fillRect(l+0.5,0,e(b.scrollManipulatorW),
c),h.strokeStyle="#6382bf",h.strokeRect(l+0.5,0,e(b.scrollManipulatorW),c),t=e(b.scrollManipulatorW/2),h.beginPath(),h.moveTo(l+t+0.5-2,3),h.lineTo(l+t+0.5-2,c-3),h.moveTo(l+t+0.5,3),h.lineTo(l+t+0.5,c-3),h.moveTo(l+t+0.5+2,3),h.lineTo(l+t+0.5+2,c-3),h.stroke())):(h.moveTo(b.downX+b.downW/2,b.downY+b.downH-m),h.lineTo(b.downX+m,b.downY+m),h.lineTo(b.downX+b.downW-m,b.downY+m),h.moveTo(b.upX+b.upWidth/2,b.upY+m),h.lineTo(b.upX+m,b.upY+b.upHeight-m),h.lineTo(b.upX+b.upWidth-m,b.upY+b.upHeight-m),h.fill(),
b.activeIfValue&&(l=e(b.pos),h.fillStyle="#ccdcec",h.fillRect(0,l+0.5,r,e(b.scrollManipulatorH)),h.strokeStyle="#6382bf",h.strokeRect(0,l+0.5,r,e(b.scrollManipulatorH)),t=e(b.scrollManipulatorH/2),h.beginPath(),h.moveTo(3,l+t+0.5-2),h.lineTo(r-3,l+t+0.5-2),h.moveTo(3,l+t+0.5),h.lineTo(r-3,l+t+0.5),h.moveTo(3,l+t+0.5+2),h.lineTo(r-3,l+t+0.5+2),h.stroke()));h.strokeRect(0.5,0.5,r-1,c-1);b.activeIfValue||(h.fillStyle="rgba(240,240,240,"+160/255+")",h.fillRect(0,0,r,c.h))};a.Scrollbar.prototype.validateValue=
function(a){g=this.evaluator;q=a.toString();q=parseFloat(q.replace(this.parent.decimal_symbol,"."));isNaN(q)&&(q=0);this.minimo=g.evalExpression(this.min);q<this.minimo&&(this.value=null,q=this.minimo);this.maximo=g.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(g.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(){m=(this.evaluator.evalExpression(this.max)-this.evaluator.evalExpression(this.min))/10;this.orientation==k?this.clickPos.x>this.prePos&&this.changeValue(parseFloat(this.value)+m):this.clickPos.y<this.prePos&&this.changeValue(parseFloat(this.value)+m)};a.Scrollbar.prototype.decrease10=function(){m=(this.evaluator.evalExpression(this.max)-this.evaluator.evalExpression(this.min))/
10;this.orientation==k?this.clickPos.x<this.prePos&&this.changeValue(parseFloat(this.value)-m):this.clickPos.y>this.prePos&&this.changeValue(parseFloat(this.value)-m)};a.Scrollbar.prototype.changeValue=function(a){this.activeIfValue&&(p=this.validateValue(a),p!=this.value&&(this.value=p,this.field.value=this.formatOutputValue(p),this.changeScrollPositionFromValue(),this.prePos=this.pos,this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction()))};a.Scrollbar.prototype.changeValueForScrollMovement=
function(){g=this.evaluator;v=this.scrollManipulatorLimInf;n=this.scrollManipulatorLimSup;s=g.evalExpression(this.min);w=g.evalExpression(this.max);u=this.incr;p=e((this.pos-v)*(w-s)/(n-v)/u)*u+s;p!=this.value&&(this.value=p,this.field.value=this.formatOutputValue(p),g.setVariable(this.id,this.value),this.parent.updateControls(),this.actionExec.execute(),this.parent.update())};a.Scrollbar.prototype.changeScrollPositionFromValue=function(){g=this.evaluator;v=this.scrollManipulatorLimInf;n=this.scrollManipulatorLimSup;
s=g.evalExpression(this.min);w=g.evalExpression(this.max);u=this.incr;this.pos=(this.value-s)*(n-v)/(w-s)+v;this.orientation==k?this.scrollManipulator.style.left=this.pos+"px":this.scrollManipulator.style.top=this.pos+"px"};a.Scrollbar.prototype.registerMouseAndTouchEvents=function(){function b(a,c,d,f){clearInterval(v);if((s.up||s.down||s.canvasClick)&&1E-7<Math.abs(s.value-f))c.call(s),a=d?a:30,v=setTimeout(function(){b(a,c,!1,f)},a)}function c(d){d.preventDefault();s.whichButton=a.whichButton(d);
"L"==s.whichButton&&s.activeIfValue&&(s.clickPos=s.getCursorPosition(d),s.canvasClick=!0,s.orientation==k?s.clickPos.x<s.prePos?b(w,s.decrease10,!0,s.minimo):b(w,s.increase10,!0,s.maximo):s.clickPos.y<s.prePos?b(w,s.increase10,!0,s.maximo):b(w,s.decrease10,!0,s.minimo))}function d(a){s.canvasClick=!1;clearInterval(v);a.preventDefault()}function f(a){!0==s.canvasClick&&(s.clickPos=s.getCursorPosition(a),a.preventDefault())}function e(a){s.activeIfValue&&(s.scrollClick=!0,s.initPos=s.getCursorPosition(a),
window.addEventListener("mouseup",g),window.addEventListener("mousemove",l),a.preventDefault())}function h(a){s.activeIfValue&&(s.scrollClick=!0,s.initPos=s.getCursorPosition(a),window.addEventListener("touchend",n),window.addEventListener("touchmove",onToucheMove_scrollManipulator),a.preventDefault())}function g(a){s.scrollClick=!1;s.prePos=s.pos;window.removeEventListener("mouseup",g,!1);window.removeEventListener("mousemove",l,!1);a.preventDefault()}function n(a){s.scrollClick=!1;s.prePos=s.pos;
window.removeEventListener("touchend",n,!1);window.removeEventListener("touchmove",l,!1);a.preventDefault()}function l(a){var b=s.getCursorPosition(a);s.orientation==k?(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 m(c){c.preventDefault();
s.whichButton=a.whichButton(c);"L"==s.whichButton&&s.activeIfValue&&(s.up=!0,b(w,s.increase,!0,s.maximo))}function p(c){c.preventDefault();s.whichButton=a.whichButton(c);"L"==s.whichButton&&s.activeIfValue&&(s.down=!0,b(w,s.decrease,!0,s.minimo))}function r(a){s.up=!1;clearInterval(v);a.preventDefault()}function q(a){s.down=!1;clearInterval(v);a.preventDefault()}function t(a){s.up=!1;clearInterval(v);a.preventDefault();s.draw()}function u(a){s.down=!1;clearInterval(v);a.preventDefault();s.draw()}
z=a.hasTouchSupport;var s=this,w=z?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)});z?this.canvas.addEventListener("touchstart",c):this.canvas.addEventListener("mousedown",c);z||this.divDown.addEventListener("mouseout",q);z?window.addEventListener("touchend",d):window.addEventListener("mouseup",
d);z?this.canvas.addEventListener("touchmove",f):this.canvas.addEventListener("mousemove",f);z?this.scrollManipulator.addEventListener("touchstart",h):this.scrollManipulator.addEventListener("mousedown",e);z?this.divUp.addEventListener("touchstart",m):this.divUp.addEventListener("mousedown",m);z?this.divDown.addEventListener("touchstart",p):this.divDown.addEventListener("mousedown",p);z||this.divUp.addEventListener("mouseout",r);z||this.divDown.addEventListener("mouseout",q);z?window.addEventListener("touchend",
t):window.addEventListener("mouseup",t);z?window.addEventListener("touchend",u):window.addEventListener("mouseup",u)};a.Scrollbar.prototype.findOffset=function(){C=this.containerControl;this.offsetTop=this.offsetLeft=0;y=this.containerControl.style.display;for(this.containerControl.style.display="block";C;)this.offsetLeft+=C.offsetLeft||0,this.offsetTop+=C.offsetTop||0,C=C.parentNode;this.containerControl.style.display=y};a.Scrollbar.prototype.getCursorPosition=function(b){E=a.getCursorPosition(b);
return{x:E.x-this.offsetLeft,y:E.y-this.offsetTop}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e;a.Audio=function(e,b){this.controls=!0;this.file="";this.oldDrawIf=0;a.Control.call(this,e,b);var d=this,f=d.evaluator.evalExpression(d.expresion);4==f[0].length?(d.w=f[0][2],d.h=f[0][3]):(d.w=200,d.h=28);d.audio=d.parent.getAudio(d.file);d.autoplay&&(d.audio.setAttribute("autoplay","autoplay"),d.audio.play());d.loop&&d.audio.setAttribute("loop","loop");d.controls&&d.audio.setAttribute("controls",
"controls");d.audio.setAttribute("style","position: absolute; width: "+d.w+"px; left: "+d.x+"px; top: "+d.y+"px; z-index: "+d.zIndex+";");d.addControlContainer(d.audio);d.evaluator.setFunction(d.id+".play",function(){d.audio.play()});d.evaluator.setFunction(d.id+".pause",function(){d.audio.pause()});d.evaluator.setFunction(d.id+".stop",function(){d.audio.pause();d.audio.currentTime=0});d.audio.addEventListener("timeupdate",function(a){d.evaluator.setVariable(d.id+".currentTime",d.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 k;a.Audio.prototype.update=function(){e=this.evaluator;(k=0<e.evalExpression(this.drawif))?this.audio.style.display="block":(this.audio.style.display="none",k!==this.oldDrawIf&&this.audio.pause());this.oldDrawIf=k;this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e;a.Video=function(g,b){this.controls=
!0;this.file="";this.oldDrawIf=0;a.Control.call(this,g,b);var d=this;e=d.evaluator;var f=d.evaluator.evalExpression(d.expresion);4==f[0].length?(d.w=f[0][2],d.h=f[0][3]):(d.w=null,d.h=null);d.video=document.createElement("video");d.autoplay&&d.video.setAttribute("autoplay","autoplay");d.loop&&d.video.setAttribute("loop","loop");d.controls&&d.video.setAttribute("controls","controls");d.poster&&d.video.setAttribute("poster",d.poster);d.w&&(d.video.setAttribute("width",d.w),d.video.setAttribute("height",
d.h));d.video.setAttribute("style","position: absolute; overflow: hidden; left: "+d.x+"px; top: "+d.y+"px;");var f=d.file,h=f.lastIndexOf(".");-1!=h&&(f=d.file.substring(0,h));d.video.canPlayType("video/mp4")&&(h=document.createElement("source"),h.setAttribute("src",f+".mp4"),h.setAttribute("type","video/mp4"),d.video.appendChild(h));d.video.canPlayType("video/ogg")&&(h=document.createElement("source"),h.setAttribute("src",f+".ogg"),h.setAttribute("type","video/ogg"),d.video.appendChild(h),h=document.createElement("source"),
h.setAttribute("src",f+".ogv"),h.setAttribute("type","video/ogg"),d.video.appendChild(h));d.video.canPlayType("video/webm")&&(h=document.createElement("source"),h.setAttribute("src",f+".webm"),h.setAttribute("type","video/webm"),d.video.appendChild(h));d.addControlContainer(d.video);d.evaluator.setFunction(d.id+".play",function(){d.video.play()});d.evaluator.setFunction(d.id+".pause",function(){d.video.pause()});d.evaluator.setFunction(d.id+".stop",function(){d.video.pause();d.video.currentTime=0});
d.video.addEventListener("timeupdate",function(a){d.evaluator.setVariable(d.id+".currentTime",d.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 k;a.Video.prototype.update=function(){e=this.evaluator;k=0<e.evalExpression(this.drawif);0<e.evalExpression(this.drawif)?this.video.style.display="block":(this.video.style.display="none",k!==this.oldDrawIf&&this.video.pause());this.oldDrawIf=
k;this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k;a.TextArea=function(e,b){this.font="Monospaced,PLAIN,12";a.Control.call(this,e,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 d=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();d&&"simpleText"!=d.type&&(this.answer=this.text.hasFormula?"":d.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(){k=this.answer?28:8;e=this.evaluator;var g;g=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<e.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-k)+"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;' >"+g+"</span>";this.textAreaAnswer.setAttribute("class","DescartesTextAreaContainer");this.textAreaAnswer.setAttribute("style","width: "+(this.w-8)+"px; height: "+(this.h-k)+"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 e=document.createElement("canvas");e.setAttribute("width",20);e.setAttribute("height",16);var b=e.getContext("2d");this.canvas=e;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=e.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=e.toDataURL()};a.TextArea.prototype.update=function(){e=this.evaluator;this.activeIfValue=0<e.evalExpression(this.activeif);
this.drawIfValue=0<e.evalExpression(this.drawif);var a;a=this.text.match(/<span/)?this.rawText:this.text;e.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(d){d.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 e=2*Math.PI,k,g,b,d,f,h,c,r,m;a.GraphicControl=function(b,c){g=b.evaluator.parser;this.text=this.spaceID="";this.size=g.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=g.parse(this.constraintExpr),"(expr)"==this.constraint.type&&(this.constraint=g.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.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.extend(a.GraphicControl,a.Control);a.GraphicControl.prototype.init=function(){k=this.evaluator;m=a.hasTouchSupport;var b=k.evalExpression(this.expresion);this.x=b[0][0];this.y=b[0][1];k.setVariable(this.xString,this.x);k.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*k.evalExpression(this.size),this.height=2*k.evalExpression(this.size));this._w=m&&70>this.width?70:this.width;this._h=m&&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";k.setVariable(this.activoString,0);this.update()};a.GraphicControl.prototype.update=function(){k=this.evaluator;this.activeIfValue=0<k.evalExpression(this.activeif);this.drawIfValue=0<k.evalExpression(this.drawif);this.x=k.getVariable(this.xString);this.y=k.getVariable(this.yString);b=this.space.getAbsoluteX(this.x);d=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(d-this._h/2)+"px";this.constraint&&this.evalConstraint();this.draw()};a.GraphicControl.prototype.draw=function(){k=this.evaluator;this.drawIfValue&&(h=this.ctx,c=this.space.backgroundCtx,b=parseInt(this.space.getAbsoluteX(this.x))+0.5,d=parseInt(this.space.getAbsoluteY(this.y))+0.5,""!=this.text&&this.drawText(b,d),this.image.ready?(this.image.complete&&h.drawImage(this.image,parseInt(b-this.image.width/2),parseInt(d-this.image.height/
2)),this.trace&&(c.save(),c.translate(b,d),c.scale(parseInt(this.image.width/2),parseInt(this.image.height/2)),c.beginPath(),c.arc(0,0,1,0,e,!1),c.restore(),c.lineWidth=1,c.strokeStyle=this.trace.getColor(),c.stroke())):(h.beginPath(),h.arc(b,d,parseInt(this.width/2),0,e,!1),h.fillStyle=this.colorInt.getColor(),h.fill(),h.lineWidth=1,h.strokeStyle=this.color.getColor(),h.stroke(),this.active&&(h.beginPath(),h.arc(b,d,parseInt(this.width/2)-2,0,e,!1),h.strokeStyle=this.colorInt.borderColor(),h.stroke()),
this.trace&&(c.lineWidth=1,c.strokeStyle=this.trace.getColor(),c.beginPath(),c.arc(b,d,parseInt(this.width/2),0,e,!1),c.stroke())))};a.GraphicControl.prototype.evalConstraint=function(a,b){r.set(this.x,this.y);f=this.newt.findZero(r);this.x=f.x;this.y=f.y;this.evaluator.setVariable(this.xString,this.x);this.evaluator.setVariable(this.yString,this.y)};a.GraphicControl.prototype.drawText=function(a,b){h=this.ctx;k=this.evaluator;h.fillStyle=this.color.getColor();h.font=this.font;h.textBaseline="alphabetic";
h.fillText(k.evalExpression(this.text[0],k.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,d=a.length;c<d;c++)if(b=a[c],b.id==this.spaceID)return b.addCtr(this),this.zIndex=b.zIndex,this.space=b,b.graphicControlContainer;a[0].addCtr(this);this.zIndex=a[0].zIndex;this.space=a[0];return a[0].graphicControlContainer};a.GraphicControl.prototype.deactivate=function(){this.active=
!1;this.evaluator.setVariable(this.activoString,0)};a.GraphicControl.prototype.registerMouseAndTouchEvents=function(){function b(c){c.preventDefault();g.whichButton=a.whichButton(c);"L"==g.whichButton&&(g.activeIfValue&&g.over)&&(g.parent.deactivateGraphiControls(),g.click=!0,g.active=!0,g.evaluator.setVariable(g.activoString,1),g.evaluator.setVariable(g.mclickedString,0),g.evaluator.setVariable(g.mclicizquierdoString,0),g.posAnte=g.getCursorPosition(c),g.prePos={x:g.space.getAbsoluteX(g.x),y:g.space.getAbsoluteY(g.y)},
g.evaluator.setVariable(g.mxString,g.space.getRelativeX(g.posAnte.x)),g.evaluator.setVariable(g.myString,g.space.getRelativeY(g.posAnte.y)),g.parent.update(),window.addEventListener("mouseup",d),window.addEventListener("mousemove",f))}function c(a){a.preventDefault();g.activeIfValue&&(g.parent.deactivateGraphiControls(),g.click=!0,g.active=!0,g.evaluator.setVariable(g.activoString,1),g.evaluator.setVariable(g.mclickedString,0),g.evaluator.setVariable(g.mclicizquierdoString,0),g.posAnte=g.getCursorPosition(a),
g.prePos={x:g.space.getAbsoluteX(g.x),y:g.space.getAbsoluteY(g.y)},g.evaluator.setVariable(g.mxString,g.space.getRelativeX(g.posAnte.x)),g.evaluator.setVariable(g.myString,g.space.getRelativeY(g.posAnte.y)),g.parent.update(),window.addEventListener("touchmove",f),window.addEventListener("touchend",d))}function d(b){b.preventDefault();g.touchId=null;g.evaluator.setVariable(g.mclickedString,1);g.evaluator.setVariable(g.mclicizquierdoString,1);if(g.activeIfValue||g.active)g.click=!1,a.hasTouchSupport?
(window.removeEventListener("touchmove",f,!1),window.removeEventListener("touchend",d,!1)):(window.removeEventListener("mouseup",d,!1),window.removeEventListener("mousemove",f,!1)),g.evaluator.setVariable(g.mxString,g.space.getRelativeX(g.posAnte.x)+g.x),g.evaluator.setVariable(g.myString,g.space.getRelativeY(g.posAnte.y)+g.y),g.parent.update(),g.mouseCacher.style.left=g.space.getAbsoluteX(g.x)-g._w/2+"px",g.mouseCacher.style.top=g.space.getAbsoluteY(g.y)-g._h/2+"px"}function f(a){a.preventDefault();
a.touchId=g.touchId;g.evaluator.setVariable(g.mclickedString,0);g.evaluator.setVariable(g.mclicizquierdoString,0);k=g.getCursorPosition(a);g.posX=g.prePos.x-(g.posAnte.x-k.x);g.posY=g.prePos.y-(g.posAnte.y-k.y);g.evaluator.setVariable(g.xString,g.space.getRelativeX(g.posX));g.evaluator.setVariable(g.yString,g.space.getRelativeY(g.posY));g.evaluator.setVariable(g.mxString,g.space.getRelativeX(g.posAnte.x)+g.space.getRelativeX(g.posX));g.evaluator.setVariable(g.myString,g.space.getRelativeY(g.posAnte.y)+
g.space.getRelativeY(g.posY));g.parent.updateControls();g.parent.update()}function e(a){g.over=!0}function h(a){g.over=!1;g.click=!1}var g=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",e),this.mouseCacher.addEventListener("mouseout",h));var k};a.GraphicControl.prototype.getCursorPosition=function(a){if(a.touches){var b;
if(a.touchId){c=0;for(d=a.touches.length;c<d;c++)if(a.touches[c].identifier==a.touchId){b=a.touches[c];break}}else for(var c=0,d=a.touches.length;c<d;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,e){var k,g,b,d,f,h,c,r,m,l;if(a.loadLib)return a;var t,q,u,p,v,n,s,w,z=/[\w-//]*(\.png|\.jpg|\.gif|\.svg|\.PNG|\.JPG|\.GIF|\.SVG)/g,C,y,E,D,B,A,H,G,I,K,x,J,F,P,Q,M,R,S,N,O,L;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,d=a.length;c<d;c++)switch(u=a[c][0],p=a[c][1],q=e[u],q){case "rowsNorth":case "rowsSouth":case "widthEast":case "widthWest":case "height":b[q]=parseInt(p);break;case "about":case "config":case "init":case "clear":b[q]="true"===e[p];break;default:console.log("----- attributo de space no identificado: <"+u+"> valor: <"+p+"> -----")}return b};a.LessonParser.prototype.parseSpace=
function(b){v={};b=this.split(b);for(var c=0,d=b.length;c<d;c++)switch(u=b[c][0],p=b[c][1],q=e[u],q){case "type":case "id":case "cID":case "file":v[q]=p;break;case "fixed":case "numbers":case "sensitive_to_mouse_movements":case "R3":case "split":v[q]="true"===e[p];break;case "bg_display":case "render":v[q]=e[p];break;case "net":case "net10":case "axes":case "text":v[q]="false"===e[p]?"":new a.Color(p,this.parent.evaluator);break;case "x_axis":case "y_axis":v[q]="false"===e[p]?"":p;break;case "O.x":v.OxExpr=
p;break;case "O.y":v.OyExpr=p;break;case "image":v.imageSrc=p;break;case "x":t=p;t="%"===t[t.length-1]?(this.parent.container.width*parseFloat(t)/100).toString():p;v.xExpr=this.parser.parse(t);break;case "y":t=p;t="%"===t[t.length-1]?(this.parent.container.height*parseFloat(t)/100).toString():p;v.yExpr=this.parser.parse(t);break;case "width":t=p;"%"===t[t.length-1]?(v.wExpr=t,t=this.parent.container.width*parseFloat(t)/100):(t=parseFloat(p),t!=p&&(t=this.parent.container.width));v.w=t;break;case "height":t=
p;"%"===t[t.length-1]?(v.hExpr=t,t=this.parent.container.height*parseFloat(t)/100):(t=parseFloat(p),t!=p&&(t=this.parent.container.height));v.h=t;break;case "drawif":v.drawif=this.parser.parse(p);break;case "scale":t=parseFloat(p);t.toString()!=p&&(t=48);v.scale=t;break;case "background":v.background=new a.Color(p,this.parent.evaluator);break;default:console.log("----- attributo de space no identificado: <"+u+"> valor: <"+p+"> -----")}switch(v.type){case "R2":return new a.Space2D(this.parent,v);case "R3":return new a.Space3D(this.parent,
v);case "AP":return new a.SpaceAP(this.parent,v);case "HTMLIFrame":return new a.SpaceHTML_IFrame(this.parent,v);default:return new a.Space2D(this.parent,v)}};a.LessonParser.prototype.parseControl=function(b){n={type:"numeric"};b=this.split(b);for(var c=0,d=b.length;c<d;c++)switch(u=b[c][0],p=b[c][1],q=e[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":n[q]=p;break;
case "gui":case "region":case "action":case "msg_pos":case "poster":n[q]=e[p];break;case "fixed":case "visible":case "discrete":case "onlyText":case "evaluate":case "autoplay":case "loop":case "controls":n[q]="true"===e[p];break;case "color":case "colorInt":case "trace":n[q]=new a.Color(p,this.parent.evaluator);break;case "font_size":case "drawif":case "activeif":case "decimals":case "min":case "max":case "size":n[q]=this.parser.parse(p);break;case "constraint":n.constraintExpr=p;break;case "image":n.imageSrc=
p;break;case "space":n.spaceID=p;break;case "type":n.type=e[p.trim()];break;case "expresion":n.expresion=this.parser.parse(p.replace(")(",","));break;case "bold":"false"!=e[p]&&(n.bold="bold");break;case "italics":"false"!=e[p]&&(n.italics="italic");break;case "underlined":"false"!=e[p]&&(n.underlined=!0);break;case "value":var f=p.replace(/&squot;/g,"'");f.match(/^\|/)&&(f="'"+f.substring(1),f.match(/\|$/)&&(f=f.substring(0,f.length-1)+"'"));n.valueExpr=this.parser.parse(f);n.valueExprString=f;break;
case "incr":0!=p&&(n.incr=this.parser.parse(p));break;case "exponentialif":n.exponentialif=parseFloat(p);break;case "text":n.rawText=p;for(var f=this.parseText(p),g=0,h=f.length;g<h;g++)f[g]=this.parser.parse(f[g],!1);n.text=f;break;default:g=u.indexOf(".");f=e[u.substring(0,g)];g=e[u.substring(g+1)];if("parameter"===f&&"font"===g){n.parameterFont=p;break}else if("Explanation"===f&&"font"===g){n.ExplanationFont=p;break}else if("tooltip"===f&&"font"===g){n.tooltipFont=p;break}console.log("----- attributo de control no identificado: <"+
u+"> valor: <"+p+"> -----")}if("numeric"===n.type)switch(n.gui){case "spinner":return new a.Spinner(this.parent,n);case "button":return new a.Button(this.parent,n);case "textfield":return new a.TextField(this.parent,n);case "menu":return new a.Menu(this.parent,n);case "scrollbar":return new a.Scrollbar(this.parent,n);default:return new a.Spinner(this.parent,n)}else{if("video"===n.type)return new a.Video(this.parent,n);if("audio"===n.type)return new a.Audio(this.parent,n);if("graphic"===n.type)return new a.GraphicControl(this.parent,
n);if("text"===n.type)return new a.TextArea(this.parent,n)}};a.LessonParser.prototype.parseGraphic=function(b,c,d,f){s={rotateExp:f,parameter:"t"};b=this.split(b);f=0;for(var g=b.length;f<g;f++)switch(u=b[f][0],p=b[f][1],q=e[u],q){case "type":case "align":s[q]=e[p];break;case "background":case "abs_coord":case "visible":case "editable":case "fixed":case "vectors":s[q]="true"===e[p];break;case "color":case "fill":case "fillP":case "fillM":case "arrow":case "trace":s[q]="false"===e[p]?"":new a.Color(p,
this.parent.evaluator);break;case "family":case "parameter":case "info":case "font":case "name":s[q]=p;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":s[q]=this.parser.parse(p);break;case "space":s.spaceID=p;break;case "expresion":"macro"!=s.type?(s.expresion=this.parser.parse(p),s.expresionString=p):s.expresion=p;break;case "text":s.text=this.parseText(p);break;case "file":var h=
p.replace(/&squot;/g,"'");"["===h.charAt(0)&&"]"===h.charAt(h.length-1)&&(h=h.substring(1,h.length-1));h.match(z)&&(h="'"+h+"'");s.file=this.parser.parse(h);break;case "border":"false"!=e[p]&&(s.border=new a.Color(p,this.parent.evaluator));break;default:if(void 0!=s.family&&u.substring(0,s.family.length+1)===s.family+"."){switch(e[u.substring(s.family.length+1)]){case "interval":s.family_interval=this.parser.parse(p);break;case "steps":s.family_steps=this.parser.parse(p)}break}if(void 0!=s.parameter&&
u.match(s.parameter+".")){s.parameter!==u.substring(0,u.indexOf(s.parameter)+s.parameter.length)&&(s.parameter=u.substring(0,u.indexOf(s.parameter)+s.parameter.length));switch(e[u.substring(s.parameter.length+1)]){case "interval":s.parameter_interval=this.parser.parse(p);break;case "steps":s.parameter_steps=this.parser.parse(p)}break}console.log("----- attributo del graphic no identificado: <"+u+"> valor: <"+p+"> -----")}c&&(s.abs_coord=c);d&&(s.background=d);switch(s.type){case "text":return new a.Text(this.parent,
s);case "image":return new a.Image(this.parent,s);case "point":return new a.Point(this.parent,s);case "polygon":return new a.Polygon(this.parent,s);case "arc":return new a.Arc(this.parent,s);case "segment":return new a.Segment(this.parent,s);case "arrow":return new a.Arrow(this.parent,s);case "macro":return new a.Macro(this.parent,s);case "curve":return new a.Curve(this.parent,s);case "equation":return new a.Equation(this.parent,s);case "sequence":return new a.Sequence(this.parent,s);case "fill":return new a.Fill(this.parent,
s)}};a.LessonParser.prototype.parse3DGraphic=function(b,c,d,f){s={rotateExp:f,parameter:"t"};b=this.split(b);c=0;for(d=b.length;c<d;c++)switch(u=b[c][0],p=b[c][1],q=e[u],q){case "type":case "model":s[q]=e[p];break;case "background":case "fixed":case "edges":s[q]="true"===e[p];break;case "color":case "backcolor":s[q]=new a.Color(p,this.parent.evaluator);break;case "type":case "model":s[q]=e[p];break;case "background":case "fixed":case "edges":case "split":s[q]="true"===e[p];break;case "color":case "backcolor":s[q]=
new a.Color(p,this.parent.evaluator);break;case "drawif":case "width":case "length":case "height":case "decimals":case "Nu":case "Nv":case "inipos":case "endpos":s[q]=this.parser.parse(p);break;case "family":case "parameter":case "font":case "name":case "inirot":case "endrot":s[q]=p;break;case "space":s.spaceID=p;break;case "expresion":"macro"!=s.type&&"curve"!=s.type&&"surface"!=s.type?(s.expresion=this.parser.parse(p),s.expresionString=p):s.expresion=p.replace(/\\n/g,"");break;case "text":f=this.parseText(p);
for(var g=0,h=f.length;g<h;g++)f[g]=this.parser.parse(f[g],!1);s.text=f;break;case "file":f=p.replace(/&squot;/g,"'");"["===f.charAt(0)&&"]"===f.charAt(f.length-1)&&(f=f.substring(1,f.length-1));f.match(/./)&&(f="'"+f+"'");s.file=this.parser.parse(f);break;case "drawif":case "width":case "length":case "decimals":case "Nu":case "Nv":case "inirot":case "endrot":case "inipos":case "endpos":s[q]=this.parser.parse(p);break;case "family":case "parameter":case "font":case "name":s[q]=p;break;case "space":s.spaceID=
p;break;case "expresion":"macro"!=s.type&&"curve"!=s.type&&"surface"!=s.type?(s.expresion=this.parser.parse(p),s.expresionString=p):s.expresion=p;break;case "text":f=this.parseText(p);g=0;for(h=f.length;g<h;g++)f[g]=this.parser.parse(f[g],!1);s.text=f;break;case "file":f=p.replace(/&squot;/g,"'");"["===f.charAt(0)&&"]"===f.charAt(f.length-1)&&(f=f.substring(1,f.length-1));f.match(/./)&&(f="'"+f+"'");s.file=this.parser.parse(f);break;default:if(void 0!==s.family&&u.substring(0,s.family.length+1)===
s.family+"."){"interval"===e[u.substring(s.family.length+1)]?s.family_interval=this.parser.parse(p):s.family_steps=this.parser.parse(p);break}console.log("----- attributo del graphic3D no identificado: <"+u+"> valor: <"+p+"> -----")}switch(s.type){case "point":return new a.Point3D(this.parent,s);case "segment":return new a.Segment3D(this.parent,s);case "polygon":return new a.Polygon3D(this.parent,s);case "curve":return new a.Curve3D(this.parent,s);case "triangle":return new a.Triangle3D(this.parent,
s);case "face":return new a.Face3D(this.parent,s);case "polireg":return new a.Polireg3D(this.parent,s);case "surface":return new a.Surface3D(this.parent,s);case "text":return new a.Text3D(this.parent,s);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,s);default:console.log(s.type)}};a.LessonParser.prototype.parseAuxiliar=function(b){w={};
b=this.split(b);for(var c=0,d=b.length;c<d;c++)b[c][1]=b[c][1].replace(/&squot;/g,"'");c=0;for(d=b.length;c<d;c++)switch(u=b[c][0],p=b[c][1],q=e[u],q){case "id":case "file":case "init":case "doExpr":case "whileExpr":case "range":case "local":case "expresion":case "condition":case "parameter":w[q]=p;break;case "editable":case "constant":case "array":case "matrix":case "algorithm":case "event":case "sequence":w[q]="true"===e[p];break;case "size":case "rows":case "columns":w[q]=this.parser.parse(p);
break;case "evaluate":case "execution":case "msg_pos":case "action":w[q]=e[p];break;default:var f=u.indexOf("."),g=e[u.substring(0,f)],f=e[u.substring(f+1)];if("parameter"===g&&"font"===f){w.parameterFont=p;break}console.log("----- attributo de auxiliar no identificado: <"+u+"> valor: <"+p+"> -----")}w.sequence?new a.Function(this.parent,w):w.constant?(b=new a.Constant(this.parent,w),w.evaluate&&"always"===w.evaluate&&this.parent.auxiliaries.push(b)):w.algorithm&&w.evaluate?(b=new a.Algorithm(this.parent,
w),this.parent.auxiliaries.push(b)):w.array&&!w.matrix&&")"!=w.id.charAt(w.id.length-1)?(b=new a.Vector(this.parent,w),w.evaluate&&"always"===w.evaluate&&this.parent.auxiliaries.push(b)):w.matrix&&")"!=w.id.charAt(w.id.length-1)?(b=new a.Matrix(this.parent,w),w.evaluate&&"always"===w.evaluate&&this.parent.auxiliaries.push(b)):w.event&&")"!=w.id.charAt(w.id.length-1)?this.parent.events.push(new a.Event(this.parent,w)):")"===w.id.charAt(w.id.length-1)?new a.Function(this.parent,w):new a.Variable(this.parent,
w)};a.LessonParser.prototype.parseAction=function(b){C=b.action;y=b.parent;E=b.parameter;if(C)switch(C){case "message":return new a.Message(y,E);case "calculate":return new a.Calculate(y,E);case "openURL":return new a.OpenURL(y,E);case "openScene":return new a.OpenScene(y,E);case "about":return new a.About(y,E);case "config":return new a.Config(y,E);case "init":return new a.Init(y,E);case "clear":return new a.Clear(y,E);case "animate":return new a.Animate(y,E);case "initAnimation":return new a.InitAnimation(y,
E);case "playAudio":return new a.PlayAudio(y,E);default:console.log("----- Accion no soportada aun: <"+C+"> -----")}else return{execute:function(){}}};a.LessonParser.prototype.parseAnimation=function(b){var c={};b=this.split(b);for(var d=0,f=b.length;d<f;d++)switch(u=b[d][0],p=b[d][1],q=e[u],q){case "id":case "delay":case "init":case "doExpr":case "whileExpr":c[q]=p;break;case "controls":case "auto":case "loop":case "algorithm":case "evaluate":c[q]="true"===e[p];break;default:console.log("----- attributo de la animacion no identificado: <"+
u+">  <"+p+"> -----")}return new a.Animation(this.parent,c)};a.LessonParser.prototype.parsePleca=function(e,n){e=this.split(e);g=k="";b=0;d="#536891";f="white";h="left";c="";r="SansSerif,BOLD,20";m="SansSerif,PLAIN,18";l=void 0;for(var q=0,s=e.length;q<s;q++)switch(u=e[q][0],p=e[q][1],u){case "title":k=p;break;case "subtitle":g=p;break;case "subtitlines":b=p;break;case "bgcolor":""!=p&&(d=(new a.Color(p,this.parent.evaluator)).getColor());break;case "fgcolor":""!=p&&(f=(new a.Color(p,this.parent.evaluator)).getColor());
break;case "align":""!=p&&(h=p);break;case "titleimage":c=p;break;case "titlefont":r=""!=p?a.convertFont(p):a.convertFont(r);break;case "subtitlefont":m=""!=p?a.convertFont(p):a.convertFont(m);break;default:console.log("----- attributo de la pleca no identificado: <"+u+">  <"+p+"> -----")}if(""===k&&""===g)return document.createElement("div");K=m.substring(0,m.indexOf("px"));K=K.substring(K.lastIndexOf(" "));""!=c&&(x=this.parent.getImage(c),J=x.height);l=document.createElement("div");l.setAttribute("id",
"descartesPleca");J?(l.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+h+"; width: "+(n-30)+"px; height: "+(J-16)+"px; background: "+d+"; color: "+f+"; padding-top: 8px; padding-bottom: 8px; padding-left: 15px; padding-right: 15px; margin: 0px; overflow: hidden; z-index: 100;"),x.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: -1; width: 100%; height: 100%"),l.appendChild(x)):l.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+
h+"; width: "+(n-30)+"px; background: "+d+"; color: "+f+"; padding-top: 8px; padding-bottom: 8px; padding-left: 15px; padding-right: 15px; margin: 0px; z-index: 100;");F=document.createElement("div");F.setAttribute("style","padding: 0px; margin: 0px; font: "+r+"; overflow: hidden; white-space: nowrap;");F.innerHTML=k;P=document.createElement("div");if(1===parseInt(b)){N=0;Q=document.createElement("div");Q.innerHTML=g;document.body.appendChild(Q);R=K;do R-=N,Q.setAttribute("style","padding: 0px; margin: 0px; font: "+
m+"; font-size: "+R+"px; width: "+(n-30)+"px; line-height: "+R+"px;"),M=Q.offsetHeight,S=M/R,N=1;while(1<S&&8<R);document.body.removeChild(Q);P.setAttribute("style","padding: 0px; margin: 0px; font: "+m+"; font-size: "+R+"px; line-height: 110%; overflow: hidden; white-space: nowrap;")}else P.setAttribute("style","padding: 0px; margin: 0px; font: "+m+"; line-height: 110%;");P.innerHTML=g;l.appendChild(F);l.appendChild(P);l.imageHeight=J;return l};a.LessonParser.prototype.split=function(a){if("string"!=
typeof a)return[];a=(a||"").replace(/\\'/g,"\u2019");D=[];A=B=0;H=!1;G=0;for(I=!1;B<a.length;)" "===a.charAt(B)&&!H&&B++," "!==a.charAt(B)&&!H&&(H=!0,G=B),"="===a.charAt(B)&&("'"===a.charAt(B+1)&&!I)&&(I=!0,D[A]=[a.substring(G,B)],G=B+2,B+=2),I&&"'"===a.charAt(B)&&(H=I=!1,D[A].push(a.substring(G,B)),A++),"="===a.charAt(B)&&("'"!==a.charAt(B+1)&&!I)&&(D[A]=[a.substring(G,B)],G=B+1,B++,O=a.substring(B).indexOf("="),-1===O?L=O=a.length:(O+=B,L=a.substring(B,O).lastIndexOf(" "),L=-1===L?a.length:L+B),
D[A].push(a.substring(G,L)),A++,H=!1,B=L),B++;return D};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 e(a,b){t=[];t.type="matrix";t.rows=a;t.cols=b;var c;u=0;for(p=b;u<p;u++){c=[];q=0;for(v=a;q<v;q++)c.push(0);t[u]=c}return t}function k(a,b){m=a.rows;l=a.cols;t=e(m,l);var c;for(u=0;u<m;u++)for(q=0;q<l;q++){for(p=c=0;p<l;p++)c+=a[p][u]*
b[q][p];t[q][u]=c}return t}function g(a,b,c){for(var d=e(c.length-1,c.length-1),f=0,g=d.length;f<g;f++)for(var h=0;h<g;h++)d[f][h]=f<a?h<b?c[f][h]:c[f][h+1]:f<b?c[f+1][h]:c[f+1][h+1];return d}function b(a){if(1<a.cols){for(var c=0,d=1,f=0,e=a.cols;f<e;f++)c+=d*a[0][f]*b(g(0,f,a)),d=-d;return c}return a[0][0]}if(a.loadLib)return a;var d=Math.floor,f,h,c,r;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){f=this.childs.length-1;lastChild=this.childs[f];lastChild.parent=null;this.childs[f]=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="-",c=new a.Node("compOperator","=="),r=new a.Node("number","0"),c.addChild(this),c.addChild(r),h=this.getRoot(),h.setAllEvaluateFunction(),h):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(a){return parseFloat(this.value)};else if("string"===this.type)this.evaluate=function(a){return this.value};
else if("identifier"===this.type&&0===this.childs.length)if("rnd"==this.value)this.evaluate=function(a){return Math.random()};else{var 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 c,f;this.evaluate=function(a){c=this.childs[0].childs[0].evaluate(a);
try{return f=a.vectors[this.value][0>c?0:d(c)],void 0!==f?f:0}catch(b){return 0}}}else if("identifier"===this.type&&"square_bracket"===this.childs[0].type&&1<this.childs[0].childs.length){var h,p;this.evaluate=function(a){h=this.childs[0].childs[0].evaluate(a);p=this.childs[0].childs[1].evaluate(a);try{return f=a.matrices[this.value][0>h?0:d(h)][0>p?0:d(p)],void 0!==f?f:0}catch(b){return 0}}}else if("identifier"===this.type&&"parentheses"===this.childs[0].type){var r;this.evaluate=function(a){r=[];
for(var b=0,c=this.childs[0].childs.length;b<c;b++)r[b]=this.childs[0].childs[b].evaluate(a);return"_Eval_"===this.value?(r[0]=0<r.length?r[0].toString():"",a.evalExpression(a.parser.parse(r[0].replace(a.parent.decimal_symbol_regexp,".")))):a.functions[this.value].apply(a,r)}}else if("operator"===this.type){var v,D,B;"+"===this.value?this.evaluate=function(a){v=this.childs[0].evaluate(a,!0);D=this.childs[1].evaluate(a,!0);if("matrix"!==v.type||"matrix"!==D.type)return v+D;a=v;var b=D;m=a.rows;l=a.cols;
t=e(m,l);for(u=0;u<m;u++)for(q=0;q<l;q++)t[q][u]=a[q][u]+b[q][u];return t}:"-"===this.value?this.evaluate=function(a){v=this.childs[0].evaluate(a,!0);D=this.childs[1].evaluate(a,!0);if("matrix"!==v.type||"matrix"!==D.type)return v-D;a=v;var b=D;m=a.rows;l=a.cols;t=e(m,l);for(u=0;u<m;u++)for(q=0;q<l;q++)t[q][u]=a[q][u]-b[q][u];return t}:"*"===this.value?this.evaluate=function(a){v=this.childs[0].evaluate(a,!0);D=this.childs[1].evaluate(a,!0);return"matrix"!==v.type||"matrix"!==D.type?v*D:k(v,D)}:"/"===
this.value?this.evaluate=function(a){v=this.childs[0].evaluate(a,!0);D=this.childs[1].evaluate(a,!0);if("matrix"!==v.type||"matrix"!==D.type)return v/D;a=v;var c;c=D;var d=e(c.length,c.length),f=b(c);if(0===f)c=0;else{var f=1/f,h;if(1<c.length)for(var l=0,m=c.length;l<m;l++){h=f;for(var n=0;n<m;n++)d[n][l]=h*b(g(l,n,c)),h=-h;f=-f}else d[0][0]=f;c=d}a=0===c?e(a.rows,a.cols):k(a,c);return a}:"%"===this.value?this.evaluate=function(a){v=this.childs[0].evaluate(a);D=this.childs[1].evaluate(a);return v-
d(v/D)*D}:"^"===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(v=this.childs[0].evaluate(a)?1:0)?this.childs[1].evaluate(a)?1:0:0}:"|"===this.value?this.evaluate=function(a){return(v=
this.childs[0].evaluate(a)?1:0)?1:this.childs[1].evaluate(a)?1:0}:"!"===this.value&&(this.evaluate=function(a){v=this.childs[0].evaluate(a)?1:0;return!v+0});else if("conditional"===this.type)this.evaluate=function(a){v=this.childs[0].evaluate(a);return 0<v?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 A,H;this.evaluate=function(a){A=this.childs.length;B=[];if(1===A&&1===this.childs[0].childs.length&&"(expr)"===this.type)B=this.childs[0].childs[0].evaluate(a);else for(var b=0;b<A;b++){H=[];for(var c=0,d=this.childs[b].childs.length;c<d;c++)H.push(this.childs[b].childs[c].evaluate(a));B[b]=H}return B}}else if("asign"===this.type){var G,I,K,x,J,F;this.evaluate=function(a){G=this.childs[0];I=
this.childs[1];1===G.childs.length&&"square_bracket"===G.childs[0].type?(c=G.childs[0].childs,1===c.length?(K=c[0].evaluate(a),K=0>K?0:d(K),a.vectors[G.value][K]=I.evaluate(a)):2===c.length&&(x=c[0].evaluate(a),J=c[1].evaluate(a),x=0>x?0:d(x),J=0>J?0:d(J),a.matrices[G.value][x]||(a.matrices[G.value][x]=[]),a.matrices[G.value][x][J]=I.evaluate(a))):(F=I.evaluate(a),F.type?a.matrices[G.value]=F:"object"!==typeof a.variables[G.value]&&(a.variables[G.value]=F))}}};var m,l,t,q,u,p,v;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 e,k,g,b,d,f,h,c,r,m=/^\s+/,l=/^[a-zA-Z_\u00C0-\u021B]+[a-zA-Z_0-9\u00C0-\u021B]*([.]*[0-9a-zA-Z_\u00C0-\u021B]+[0-9]*)*/,t=/^[0-9]+[.][0-9]+|^[.][0-9]+|^[0-9]+/,q=/^==|^!=|^<=|^<|^>=|^>|^#/,u=/^\!|^\~|^\&\&|^\&|^\|\||^\|/,p=
/^=/,v=/^[\?\:]/,n=/^[\+\-\*\/\%\^]/,s=/^\[|^\]/,w=/^\(|^\)/,z=/^,/,C=/^;/;a.Tokenizer=function(){};a.Tokenizer.prototype.tokenize=function(a){function y(a,d,e){k.push({type:a,value:d});f=f.slice(e);b+=e;c++;r=a}if(e=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("|*","'","g").replace("*|","'","g")),a.match(/\=\|/g)&&(a=a.replace("|","'","g"));k=[];g=!1;b=0;f=a;c=
0;for(r="";a&&b<a.length;)if(g=b,"'"==f[0]){for(h=1;"'"!=f[h];)if(h<f.length)h++;else{console.log(">Error, unknown symbol: ["+f+"], in the string <<"+e+">>");return}d=f.substring(1,h);y("string",d,d.length+2)}else if(d=f.match(m))f=f.slice(d[0].length),b+=d[0].length,c++;else if(d=f.match(l))"number"===r&&k.push({type:"operator",value:"*"}),y("identifier",d[0],d[0].length);else if(d=f.match(t))y("number",d[0],d[0].length);else if(d=f.match(q)){var A=d[0];"#"==A&&(A="!=");y("compOperator",A,d[0].length)}else if(d=
f.match(u))A=d[0],"||"==A?A="|":"&&"==A?A="&":"~"==A&&(A="!"),y("boolOperator",A,d[0].length);else if((d=f.match(p))&&!f.match(/^==/))y("asign",d[0],d[0].length);else if(d=f.match(v))y("conditional",d[0],d[0].length);else if(d=f.match(n))y("operator",d[0],d[0].length);else if(d=f.match(s))y("square_bracket",d[0],d[0].length);else if(d=f.match(w))"("==d&&"number"===r&&k.push({type:"operator",value:"*"}),y("parentheses",d[0],d[0].length);else if(d=f.match(z))y("separator",d[0],d[0].length);else if(178===
f.charCodeAt(0))k.push({type:"operator",value:"^"}),y("number",2,1);else if(179===f.charCodeAt(0))k.push({type:"operator",value:"^"}),y("number",3,1);else if(d=f.match(C))y("final_of_expresion",d[0],d[0].length);else if(g==b){console.log("Error, simbolo no conocido: ["+f+"], en la cadena <<"+e+">>");return}return k};var y,E=/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||"";y="";for(var c=0,d=a.length;c<d;c++)y="string"==a[c].type?y+"&squot;"+a[c].value+"&squot;":"identifier"==a[c].type&&!a[c].value.match(E)?y+b+a[c].value:y+a[c].value;return y};return a}(descartesJS||{}),descartesJS=function(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,d){this.matrices[a][b][c]=d};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,k,g,b,d,f,h,c,r,m,l,t;a.Parser.prototype.parse=function(q,u){(g=this.tokenizer.tokenize(q))||(g=[]);b=null;u=!u||!1;e=c=h=f=0;for(k=g.length;e<k;e++)if(r=g[e],m=r.value,l=r.type,"identifier"===l&&(e+1<k&&"parentheses"===g[e+1].type&&"("===g[e+1].value?this.getFunction(m):e+1<k&&"square_bracket"===g[e+1].type&&"["===
g[e+1].value?g[e+3]&&"square_bracket"===g[e+3].type&&"]"===g[e+3].value?this.getVector(m):this.getMatrix(m):this.getVariable(m)),"asign"===l&&u&&(l="compOperator",m="=="),"asign"===l)if(d=new a.Node(l,m),null!=b)if("identifier"===b.type)b.parent&&b.parent.replaceLastChild(d),d.addChild(b),b=d,u=!0;else if("square_bracket"===b.type)d.addChild(b.parent),b=d,u=!0;else{d.type="compOperator";d.value="==";for(u=!0;b.parent&&this.getPrecedence(b.parent.value)>=this.getPrecedence(d.value);)b=b.parent;b.parent&&
b.parent.replaceLastChild(d);d.addChild(b);b=d}else{console.log("Error1: en la expresion <<"+q+">>, en el token {valor: "+m+", tipo: "+l+"}");break}else if("parentheses"===l&&"("===m||"square_bracket"===l&&"["===m)if(d=new a.Node(l,m),"("===m&&f++,"["===m&&h++,null===b)"("===m&&(new a.Node("(expr)","(expr)")).addChild(d),"["===m&&(new a.Node("[expr]","[expr]")).addChild(d),b=d;else if("operator"===b.type||"boolOperator"===b.type||"compOperator"===b.type||"conditional"===b.type||"asign"===b.type)b.addChild(d),
b=d;else if("sign"===b.type)b.addChild(d),b=d;else if("parentheses"===b.type&&"("===b.value)b.addChild(d),b=d;else if("square_bracket"===b.type&&"["===b.value)b.addChild(d),b=d;else if("parentheses"===b.type&&"()"===b.value)b.parent.addChild(d),b=d;else if("square_bracket"===b.type&&"[]"===b.value)b.parent.addChild(d),b=d;else if("identifier"===b.type)b.addChild(d),b=d;else{console.log("Error2: en la expresion <<"+q+">>, en el token ["+e+"] {valor: "+m+", tipo: "+l+"}");break}else if("parentheses"===
l&&")"===m)if(f--,null===b)console.log("Error3: en la expresion <<"+q+">>, en el token (valor:"+m+", tipo:"+l);else{for(;b&&b.parent&&"("!=b.value;)b=b.parent;if(b&&"("===b.value)b.value="()";else{console.log("Error4: en la expresion <<"+q+">>, en el token {valor: "+m+", tipo: "+l+"}");break}}else if("square_bracket"===l&&"]"===m)if(h--,null===b)console.log("Error5: en la expresion <<"+q+">>, en el token (valor:"+m+", tipo:"+l);else{for(;b&&b.parent&&"["!=b.value;)b=b.parent;if(b&&"["===b.value)b.value=
"[]";else{console.log("Error6: en la expresion <<"+q+">>, en el token {valor: "+m+", tipo: "+l+"}");break}}else if("number"===l||"string"===l||"identifier"===l)if(d=new a.Node(l,m),null===b)b=d;else if("operator"===b.type||"compOperator"===b.type||"boolOperator"===b.type||"parentheses"===b.type&&"("===b.value||"square_bracket"===b.type&&"["===b.value||"sign"===b.type||"conditional"===b.type||"asign"===b.type)b.addChild(d),b=d;else{console.log("Error7: en la expresion <<"+q+">>, en el token {valor: "+
m+", tipo: "+l+"}");break}else if("operator"===l||"compOperator"===l||"boolOperator"===l)if(d=new a.Node(l,m),null===b)if("-"===m||"+"===m)d.type="sign",d.value="sign"+m,b=d;else if("!"===m)b=d;else{console.log("Error8: en la expresion <<"+q+">>, en el token {valor: "+m+", tipo: "+l+"}");break}else if("operator"===b.type||"compOperator"===b.type||"boolOperator"===b.type||"asign"===b.type||"conditional"===b.type||"square_bracket"===b.type&&"["===b.value&&("-"===m||"+"===m||"!"===m)||"parentheses"===
b.type&&"("===b.value&&("-"===m||"+"===m||"!"===m)){if("-"===m||"+"===m)d.type="sign",d.value="sign"+m;b.addChild(d);b=d}else if("number"===b.type||"parentheses"===b.type&&"()"===b.value||"square_bracket"===b.type&&"[]"===b.value||"string"===b.type||"identifier"===b.type||"conditional"===b.type||"asign"===b.type){for(;b.parent&&this.getPrecedence(b.parent.value)>=this.getPrecedence(d.value);)b=b.parent;b.parent&&b.parent.replaceLastChild(d);d.addChild(b);b=d}else{console.log("Error9: en la expresion <<"+
q+">>, en el token {valor: "+m+", tipo: "+l+"}");break}else if("conditional"===l)if(d=new a.Node(l,m),null!=b)if("?"===d.value){for(c++;b.parent&&this.getPrecedence(b.parent.value)>this.getPrecedence(d.value);)b=b.parent;b.parent&&b.parent.replaceLastChild(d);d.addChild(b);b=d}else{for(c--;b&&b.parent&&"?"!=b.value;)b=b.parent;if(b&&"?"===b.value)b.value="?:";else{console.log("Error10: en la expresion <<"+q+">>, en el token {valor: "+m+", tipo: "+l+"}");break}}else{console.log("Error11: en la expresion <<"+
q+">>, en el token {valor: "+m+", tipo: "+l+"}");break}else if("separator"===l)if(null!=b)for(;b.parent&&"("!=b.value&&"["!=b.value;)b=b.parent;else{console.log("Error12: en la expresion <<"+q+">>, en el token {valor: "+m+", tipo: "+l+"}");break}else{console.log("Error13: en la expresion <<"+q+">>, en el token {valor: "+m+", tipo: "+l+"}");break}0<f&&alert("Error, faltan parentesis por cerrar: "+q);0>f&&alert("Error, faltan parentesis por abrir: "+q);0<h&&alert("Error, faltan square bracketss por cerrar: "+
q);0>h&&alert("Error, faltan square bracketss por abrir: "+q);0!=c&&alert("Error, condicional incompleta: "+q);(t=b?b.getRoot():null)&&t.setAllEvaluateFunction();return t};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(){this.variables.rnd=Math.random;this.variables.pi=Math.PI;this.variables.e=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;var b=this;this.functions._Trace_=function(a){console.log(a)};this.functions._Stop_Audios_=function(){b.evaluator.parent.stopAudios()};this.functions.esCorrecto=function(c,d,f){return a.esCorrecto(c,d,b.evaluator,f)};this.functions.escorrecto=function(c,d,f){return a.escorrecto(c,d,b.evaluator,f)};window.parent!==window&&(this.functions["parent.set"]=function(a,b){window.parent.postMessage({type:"set",
name:a,value:b},"*")},this.functions["parent.update"]=function(){window.parent.postMessage({type:"update"},"*")},this.functions["parent.exec"]=function(a,b){window.parent.postMessage({type:"exec",name:a,value:b},"*")})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor;a.Evaluator=function(e){this.parent=e;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,e){this.variables[a]=e};a.Evaluator.prototype.getVariable=function(a){return this.variables[a]};a.Evaluator.prototype.setVector=function(a,g,b){g=0>g?0:e(g);this.vectors[a][g]=b};a.Evaluator.prototype.getVector=function(a,g){g=0>g?0:e(g);return this.vectors[a][g]};a.Evaluator.prototype.setMatrix=function(a,g,b,d){g=0>g?0:e(g);b=0>b?0:e(b);this.matrices[a][g][b]=d};a.Evaluator.prototype.getMatrix=function(a,g,b){g=0>g?0:e(g);b=0>b?0:e(b);return this.matrices[a][g][b]};
a.Evaluator.prototype.setFunction=function(a,e){this.functions[a]=e};a.Evaluator.prototype.getFunction=function(a){return this.functions[a]};a.Evaluator.prototype.evalExpression=function(a){return a?a.evaluate(this):0};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=2,k=!1;a.RTFNode=function(a,b,c,d){this.evaluator=a;this.type="rtfNode";this.value=b;this.nodeType=c;this.style=d;this.styleString=d.toString();this.color=d.textColor;this.underline=d.textUnderline;this.overline=
d.textOverline;this.parent=null;this.children=[];switch(this.nodeType){case "textBlock":this.draw=this.drawTextBlock;break;case "textLineBlock":this.draw=this.drawTextLineBlock;break;case "formula":this.draw=this.drawFormula;break;case "superIndex":this.draw=this.drawSuperIndex;break;case "subIndex":this.draw=this.drawSubIndex;break;case "dynamicText":this.draw=this.drawDynamicText;this.decimal_symbol=this.evaluator.parent.decimal_symbol;break;case "fraction":this.draw=this.drawFraction;break;case "numerator":case "denominator":this.draw=
this.drawNumDen;break;case "radical":this.draw=this.drawRadical;break;case "limit":this.draw=this.drawLimit;break;case "integral":this.draw=this.drawIntegral;break;case "sum":this.draw=this.drawSum;break;case "matrix":this.draw=this.drawMatrix;break;case "defparts":this.draw=this.drawDefparts;break;case "text":case "newLine":this.draw=this.drawText;break;case "hyperlink":this.draw=this.drawHyperlink;break;case "mathSymbol":this.draw=this.drawMathSymbol;break;case "index":case "radicand":case "from":case "to":case "what":case "element":this.draw=
this.drawGenericBlock;break;case "componentNumCtrl":this.draw=this.drawComponentNumCtrl;break;case "componentSpace":this.draw=this.drawComponentSpace}};a.RTFNode.prototype.getRoot=function(){return null==this.parent?this:this.parent.getRoot()};a.RTFNode.prototype.addChild=function(a){a.parent=this;this.children.push(a)};var g=0,b=0,d=0;a.RTFNode.prototype.getTextMetrics=function(){if("textBlock"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);for(var f=0,h=this.children.length;f<
h;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 c=a.getFontMetrics(this.styleString);this.baseline=c.baseline;this.descent=c.descent;this.ascent=c.ascent;this.w=c.w;this.h=c.h}else if("text"==this.nodeType||"dynamicText"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);c=a.getFontMetrics(this.styleString);
this.baseline=c.baseline;this.descent=c.descent;this.ascent=c.ascent;var f=this.value,r;"string"!=typeof this.value&&(h=void 0==this.decimals?e:this.evaluator.evalExpression(this.decimals),r=void 0==this.fixed?k:this.fixed,f=this.evaluator.evalExpression(this.value,h,r),parseFloat(f)==f&&(f=parseFloat(f).toFixed(h),f=r?f:parseFloat(f),f=f.toString().replace(".",this.decimal_symbol)),f+=" ");this.w=a.getTextWidth(f,this.styleString);this.h=c.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 m=this;this.clickCacher.addEventListener("click",function(a){m.click=!0;window.open(m.URL,
m.URL)})}else if("superIndex"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),r=g,c=b,h=d,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=h/2-c+this.h,this.superIndexPos=f-this.ascent,this.ascent=f,this.descent=c,this.baseline=this.ascent,this.h=this.ascent+this.descent;else if("subIndex"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),
r=g,c=b,h=d,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=c+1,this.ascent=r,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);r=g;c=b;h=d;r=this.children[0];var l=this.children[1],f=a.getFontMetrics(r.styleString);r.getBlockMetric();
l.getBlockMetric();0>r.h&&(r.h=f.h,r.w=this.spaceWidth);0>l.h&&(l.h=f.h,l.w=this.spaceWidth);this.h=r.h+l.h-1;this.ascent=r.h+h/2-c;this.descent=this.h-this.ascent;this.baseline=this.ascent;this.w=Math.max(r.w,l.w)+this.spaceWidth+8}else if("radical"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);c=this.children[0].style.clone();if(1===this.children.length)this.children[1]=new a.RTFNode(this.evaluator," ","radicand",c),this.children[1].addChild(this.children[0]),this.children[0]=
new a.RTFNode(this.evaluator," ","index",c);else if("index"!==this.children[0].nodeType||"radicand"!==this.children[1].nodeType){r=new a.RTFNode(this.evaluator,"","radicand",c);f=0;for(h=this.children.length;f<h;f++)r.addChild(this.children[f]);this.children=[];this.children[0]=new a.RTFNode(this.evaluator,"","index",c);this.children[1]=r}f=this.children[0];h=this.children[1];0>=f.children.length&&(c=this.style.clone(),c.fontSize=parseInt(c.fontSize-0.2*c.fontSize),f.addChild(new a.RTFNode(this.evaluator,
" ","text",c)));0>=h.children.length&&h.addChild(new a.RTFNode(this.evaluator," ","text",this.style.clone()));f.getBlockMetric();h.getBlockMetric();this.ascent=h.h/2<f.h?h.h/2+f.h+2-h.descent:h.ascent+4;this.descent=h.descent;this.baseline=this.ascent;this.h=this.ascent+this.descent;this.w=f.w+h.w+4*this.spaceWidth}else if("sum"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),r=g,c=b,h=d,c=this.children[0],h=this.children[1],r=this.children[2],c.getBlockMetric(),h.getBlockMetric(),
r.getBlockMetric(),-1==c.ascent&&(l=a.getFontMetrics(c.styleString),c.ascent=l.ascent,c.descent=l.descent,c.h=l.h),-1==h.ascent&&(l=a.getFontMetrics(h.styleString),h.ascent=l.ascent,h.descent=l.descent,h.h=l.h),f=a.getFontMetrics(this.styleString),this.ascent=f.h+h.h>r.ascent?f.h-f.descent+h.h:r.ascent,this.descent=c.h>r.descent?c.h+f.descent:r.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(c.w,h.w,f)+Math.max(r.w,this.spaceWidth)+this.spaceWidth;else if("integral"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),r=g,c=b,h=d,c=this.children[0],h=this.children[1],r=this.children[2],c.getBlockMetric(),h.getBlockMetric(),r.getBlockMetric(),-1==c.ascent&&(l=a.getFontMetrics(c.styleString),c.ascent=l.ascent,c.descent=l.descent,c.h=l.h),-1==h.ascent&&(l=a.getFontMetrics(h.styleString),h.ascent=l.ascent,h.descent=l.descent,h.h=l.h),f=a.getFontMetrics(this.styleString),
this.ascent=f.h+h.h>r.ascent?f.h-f.descent+h.h:r.ascent,this.descent=c.h>r.descent?c.h+f.descent:r.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(c.w,h.w,f)+Math.max(r.w,this.spaceWidth)+2*this.spaceWidth;else if("limit"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),r=g,c=b,h=d,c=this.children[0],h=this.children[1],
r=this.children[2],f=a.getFontMetrics(this.styleString),c.getBlockMetric(),h.getBlockMetric(),r.getBlockMetric(),-1==c.ascent&&(l=a.getFontMetrics(c.styleString),c.ascent=l.ascent,c.descent=l.descent,c.h=l.h),-1==h.ascent&&(l=a.getFontMetrics(h.styleString),h.ascent=l.ascent,h.descent=l.descent,h.h=l.h),-1==r.ascent&&(l=a.getFontMetrics(r.styleString),r.ascent=l.ascent,r.descent=l.descent,r.h=l.h),this.ascent=r.ascent,this.descent=Math.max(f.h,r.descent),this.baseline=this.ascent,this.h=this.ascent+
this.descent,f=a.getTextWidth(" "+String.fromCharCode(8594),this.styleString),0==c.w&&(c.w=this.spaceWidth),0==h.w&&(h.w=this.spaceWidth),0==r.w&&(r.w=this.spaceWidth),this.w=h.w+c.w+r.w+f+this.spaceWidth;else if("matrix"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);f=a.getFontMetrics(this.styleString);r=g;c=b;h=d;r=f.ascent;for(var l=f.descent,t=f.h,q=this.spaceWidth,u,p,f=0,h=this.children.length;f<h;f++)this.children[f].getBlockMetric(),u=this.children[f].h,p=this.children[f].w,
t<u&&(t=u,r=this.children[f].ascent,l=this.children[f].descent),q<p&&(q=p);this.childWidth=q+2*this.spaceWidth;this.childh=t;this.childAscent=r;this.childDescent=l;this.h=this.rows*t;this.ascent=this.h/2+c;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);r=g;c=b;h=d;r=f.ascent;l=f.descent;t=f.h;q=this.spaceWidth;f=0;for(h=this.children.length;f<
h;f++)this.children[f].getBlockMetric(),u=this.children[f].h,p=this.children[f].w,t<u&&(t=u,r=this.children[f].ascent,l=this.children[f].descent),q<p&&(q=p);this.childWidth=q+2*this.spaceWidth;this.childh=t;this.childAscent=r;this.childDescent=l;this.h=this.parts*t;this.ascent=this.h/2+c;this.descent=this.h-this.ascent;this.w=q+this.spaceWidth/2}else"mathSymbol"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),c=a.getFontMetrics(this.styleString),this.baseline=c.baseline,this.descent=
c.descent,this.ascent=c.ascent,this.w=a.getTextWidth(this.value,this.styleString)+a.getTextWidth(" ",this.styleString),this.h=c.h):"componentNumCtrl"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),this.componentNumCtrl=this.evaluator.parent.getControlByCId(this.value),c=this.componentNumCtrl.h||0,this.baseline=Math.round(3*c/5),this.descent=Math.round(2*c/5),this.ascent=this.baseline,this.h=c,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,e=-1,c,k=0,m=this.children.length;k<m;k++){c=this.children[k];c.getTextMetrics();childAscent=c.ascent;childDescent=c.descent;this.w+=c.w;var l=childDescent;c=c.h;g=childAscent;b=l;d=c;e<childAscent&&(e=childAscent);a<childDescent&&
(a=childDescent)}this.ascent=e;this.descent=a;this.baseline=this.ascent;this.h=this.ascent+this.descent};a.RTFNode.prototype.drawTextBlock=function(a,b,c,d,g,l,t){this.stableWidth||(this.getTextMetrics(),e=d,k=g);t=t?-this.children[0].ascent:0;g=d=0;for(l=this.children.length;g<l;g++)0<g&&(d+=this.children[g-1].h),this.children[g].draw(a,b+0,c+t+d)};a.RTFNode.prototype.drawTextLineBlock=function(b,d,c){for(var e=0,g=0,l=this.children.length;g<l;g++)0<g&&(e+=this.children[g-1].w,"formula"==this.children[g-
1].nodeType&&(e+=2*a.getTextWidth(" ",this.children[g].styleString))),this.children[g].draw(b,d+e,c+this.baseline)};a.RTFNode.prototype.drawFormula=function(a,b,c){for(var d=0,e=0,g=this.children.length;e<g;e++)0<e&&(d+=this.children[e-1].w),this.children[e].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,e=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)+e);a.lineTo(b-1+this.w,parseInt(c+this.descent/2)+e);a.stroke()}this.overline&&(e=(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)+e),a.lineTo(b-1+this.w,parseInt(c-this.ascent)+e),a.stroke())};a.RTFNode.prototype.drawDynamicText=function(b,d,
c){var g=Math.floor(0.5*this.spaceWidth),m=void 0==this.decimals?e:this.evaluator.evalExpression(this.decimals),l=void 0==this.fixed?k:this.fixed,t=this.evaluator.evalExpression(this.value,m,l);parseFloat(t).toString()===t.toString()&&(t=l?parseFloat(t).toFixed(m):parseFloat(parseFloat(t).toFixed(m)),t=(""+t).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(t,this.styleString);
b.fillText(t,g+d,c);this.underline&&(l=(m="bold"==this.style.textBold)?1:0.5,b.lineWidth=m?2:1,null!=this.color&&(b.strokeStyle=this.color),b.beginPath(),b.moveTo(g+d-1,parseInt(c+this.descent/2)+l),b.lineTo(g+d-1+this.w,parseInt(c+this.descent/2)+l),b.stroke());this.overline&&(l=(m="bold"==this.style.textBold)?2:1.5,b.lineWidth=m?2:1,null!=this.color&&(b.strokeStyle=this.color),b.beginPath(),b.moveTo(g+d-1,parseInt(c-this.ascent)+l),b.lineTo(g+d-1+this.w,parseInt(c-this.ascent)+l),b.stroke());this.w+=
2*g};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,e=d?1:0.5;a.lineWidth=d?2:1;a.beginPath();a.moveTo(b-1,Math.ceil(c+this.descent/2)+e-2);a.lineTo(b-1+this.w,Math.ceil(c+this.descent/2)+e-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,e=0,g=this.children.length;e<
g;e++)0<e&&(d+=this.children[e-1].w),this.children[e].draw(a,b+d,c+this.baseline)};a.RTFNode.prototype.drawSubIndex=function(a,b,c){for(var d=0,e=0,g=this.children.length;e<g;e++)0<e&&(d+=this.children[e-1].w),this.children[e].draw(a,b+d,c+this.subIndexPos)};a.RTFNode.prototype.drawSuperIndex=function(a,b,c){for(var d=0,e=0,g=this.children.length;e<g;e++)0<e&&(d+=this.children[e-1].w),this.children[e].draw(a,b+d,c-this.superIndexPos)};a.RTFNode.prototype.drawLimit=function(b,d,c){var e=a.getFontMetrics(this.styleString),
g=" "+String.fromCharCode(8594),k=a.getTextWidth(g,this.styleString);this.children[0].draw(b,d,c+e.descent+this.children[0].ascent);this.children[1].draw(b,d+this.children[0].w+k,c+e.descent+this.children[1].ascent);this.children[2].draw(b,d+k+this.children[0].w+this.children[1].w,c);null!=this.color&&(b.fillStyle=this.color);b.font=this.styleString;b.textAlign="start";b.textBaseline="alphabetic";b.fillText("l\u00edm",d+this.children[0].w,c);b.fillText(g,d+this.children[0].w,c+e.descent+this.children[0].ascent)};
a.RTFNode.prototype.drawIntegral=function(b,d,c){var e=this.style.clone();e.fontSize*=1.5;e.fontType="Times New Roman";e.Bold="bold";var e=e.toString(),g=a.getTextWidth(String.fromCharCode(8747),e),k=a.getFontMetrics(e),t=Math.max(this.children[0].w,this.children[1].w,Math.floor(1.5*g));this.children[0].draw(b,d+g,c+k.descent+this.children[0].ascent);this.children[1].draw(b,d+g+this.spaceWidth/2,c-this.ascent+this.children[1].ascent);this.children[2].draw(b,d+t+g,c);null!=this.color&&(b.fillStyle=
this.color);b.font=e;b.textAlign="start";b.textBaseline="alphabetic";b.fillText(String.fromCharCode(8747),d,c+k.descent/2)};a.RTFNode.prototype.drawSum=function(b,d,c){var e=this.style.clone();e.fontType="Times New Roman";e.Bold="bold";var e=e.toString(),g=a.getTextWidth(String.fromCharCode(8721),e),k=a.getFontMetrics(this.styleString),t=Math.max(this.children[0].w,this.children[1].w,g);this.children[0].draw(b,d+(t-this.children[0].w)/2,c+k.descent+this.children[0].ascent);this.children[1].draw(b,
d+(t-this.children[1].w)/2,c-k.ascent-this.children[1].descent);this.children[2].draw(b,d+t,c);null!=this.color&&(b.fillStyle=this.color);b.font=e;b.textAlign="start";b.textBaseline="alphabetic";b.fillText(String.fromCharCode(8721),d+Math.floor((t-g)/2),c-5)};a.RTFNode.prototype.drawMatrix=function(a,b,c){for(var d,e,g=0,k=this.children.length;g<k;g++)d=g%this.columns,e=Math.floor(g/this.columns),this.children[g].draw(a,2*this.spaceWidth+b+d*this.childWidth,c-this.ascent+this.childAscent+e*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,e=this.children.length;d<e;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,e=0,g=this.children.length;e<g;e++)0<e&&(d+=this.children[e-1].w),this.children[e].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(a,b,c){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 e=String.fromCharCode,k,g,b,d,f,h,c,r,m,l,t;a.RTFTokenizer=function(){};a.RTFTokenizer.prototype.tokenize=
function(a){if(a)a=a.replace(/\&gt;/g,">").replace(/\&lt;/g,"<").replace(/\&quote;/g,"''").replace(/\&squot;/g,"'").replace(/\\rquote /g,"'").replace(/\\endash /g,"-").replace(/\n/g," ").replace(/\r/g,"").replace(/\\uc(\d+) /g,"").replace(/\\uc(\d+)/g,"");else return[];k=[];g=a.length;k=[];b="";f=d=0;c=a.charAt(0);r=!1;for(m="text";d<g;)h=c,c=a.charAt(d+1),r?"\\"===c||"{"===c||"}"===c||" "===c||";"===c?(r=!1,b+=h," "===c&&(d++,c=a.charAt(d+1)),(l=b.match(/^\'([0-9a-f]{2})/))?(t="","text"===m&&(t=
k.pop().value),b=t+=e(parseInt(l[1],16))+b.substring(3)):(l=b.match(/^u[0-9]+/))?(t="","text"===m&&(t=k.pop().value),b=t+=e(l[0].substring(1))):("{"===b||"}"===b?(k.push({type:"text",value:b}),m="text"):(k.push({type:"controlWord",value:b}),m="controlWord"),b="")):b+=h:"\\"===h?(r=!0,""!==b&&(k.push({type:"text",value:b}),m="text"),b=""):"{"===h?(f++,""!==b&&k.push({type:"text",value:b}),b="",k.push({type:"openBlock",value:f}),m="openBlock"):"}"===h?(""!==b&&k.push({type:"text",value:b}),b="",k.push({type:"closeBlock",
value:f}),m="closeBlock",f--):b+=h,d++;""!==b&&k.push({type:"text",value:b});return k};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b,d,f,h,c,r,m,l,t,q,u,p,v,n,s,w,z,C,y,E,D,B,A,H,G,I,K;a.RTFParser=function(b){this.evaluator=b;this.tokenizer=new a.RTFTokenizer};a.RTFParser.prototype.parse=function(x){x=e=this.tokenizer.tokenize(x);for(var J=[],F=!1,P=!1,Q=[],M=0,R=x.length;M<R;M++){"openBlock"==x[M].type&&Q.push(x[M].value);"closeBlock"==x[M].type&&(Q.pop(),0>=
Q.length&&(F=!1));if("controlWord"==x[M].type&&("expr"==x[M].value||"decimals"==x[M].value))P=!0;"controlWord"==x[M].type&&"mjaformula"==x[M].value&&(F=!0);if("text"==x[M].type&&F&&!P){for(var S=0,N=x[M].value,O="",L=0,U=N.length;L<U;L++)if("("==N.charAt(L)||")"==N.charAt(L)||"+"==N.charAt(L)||"-"==N.charAt(L)||"*"==N.charAt(L)||"="==N.charAt(L))O=N.substring(S,L),""!=O&&J.push({type:"text",value:O}),J.push({type:N.charAt(L),value:N.charAt(L)}),S=L+1;O=N.substring(S,L);""!=O&&J.push({type:"text",
value:O})}else J.push(x[M]),"text"==x[M].type&&P&&(P=!1)}e=J;k={};b=2;if("openBlock"==e[0].type&&"fonttbl"==e[1].value){for(g=e[0].value;"closeBlock"!=e[b].type&&e[b].value!=g;)k[e[b].value]=e[b+2].value.substring(0,e[b+2].value.length-1),b+=3;b++}d={};f=0;if("openBlock"==e[b].type&&"colortbl"==e[b+1].value){g=e[b++].value;for(b++;"closeBlock"!=e[b].type&&e[b].value!=g;)h=parseInt(e[b++].value.substring(3)).toString(16),c=parseInt(e[b++].value.substring(5)).toString(16),r=parseInt(e[b++].value.substring(4)).toString(16),
";"===e[b].value&&b++,d[f++]="#"+(2>h.length?"0"+h:h)+(2>c.length?"0"+c:c)+(2>r.length?"0"+r:r);b++}m=new a.RTFNode(this.evaluator,"","textBlock","",!1,"");l=new a.RTFNode(this.evaluator,"","textLineBlock","",!1,"");m.addChild(l);u=q=t=null;z=w=s=n=v=p=!1;C=[new a.FontStyle(20,"Arial","","",!1,!1,null)];y=C[0];E=!0;B=D=-1;A=[];K=I=G=H=!1;x=b;for(J=e.length;x<J;x++)if("controlWord"==e[x].type&&k[e[x].value])y.fontType=k[e[x].value];else if("controlWord"==e[x].type&&e[x].value.match(/^fs(\d+)/))y.fontSize=
parseInt(e[x].value.match(/^fs(\d+)/)[1]/2);else if("controlWord"==e[x].type&&"b"==e[x].value)y.textBold="bold";else if("controlWord"==e[x].type&&"b0"==e[x].value)y.textBold="";else if("controlWord"==e[x].type&&"i"==e[x].value)y.textItalic="italic";else if("controlWord"==e[x].type&&"i0"==e[x].value)y.textItalic="";else if("controlWord"==e[x].type&&"ul"==e[x].value)y.textUnderline=!0;else if("controlWord"==e[x].type&&"ulnone"==e[x].value)y.textUnderline=!1;else if("controlWord"==e[x].type&&"ol"==e[x].value)y.textOverline=
!0;else if("controlWord"==e[x].type&&"olnone"==e[x].value)y.textOverline=!1;else if("controlWord"==e[x].type&&e[x].value.match(/^cf(\d+)/))y.textColor=d[parseInt(e[x].value.substring(2))];else if("openBlock"==e[x].type)D=e[x].value,y=y.clone(),C.push(y),A.push(null);else if("closeBlock"==e[x].type)e[x].value==B&&(B=-1,p=!1,l=l.parent),C.pop(),y=C[C.length-1],A.pop();else if("controlWord"==e[x].type&&"par"==e[x].value){l.addChild(new a.RTFNode(this.evaluator,"","newLine",y.clone()));m=new a.RTFNode(this.evaluator,
"","textLineBlock",y.clone());if("textBlock"!=l.nodeType)for(l=l.parent;"textBlock"!=l.nodeType;)l=l.parent;l.addChild(m);l=m}else if("controlWord"==e[x].type&&"mjaformula"==e[x].value)H=!0,B=D,p=!0,m=new a.RTFNode(this.evaluator,"","formula",y.clone()),l.addChild(m),l=m,A[A.length-1]=m;else if("controlWord"==e[x].type&&("fraction"==e[x].value||"radicand"==e[x].value||"radical"==e[x].value||"what"==e[x].value||"sum"==e[x].value||"integral"==e[x].value||"limit"==e[x].value))F=A[A.length-2].style.clone(),
m=new a.RTFNode(this.evaluator,"",e[x].value,F),A[A.length-2].addChild(m),A[A.length-1]=m;else if("controlWord"==e[x].type&&"index"==e[x].value||"to"==e[x].value||"from"==e[x].value)F=A[A.length-2].style.clone(),F.fontSize=parseInt(F.fontSize-0.2*F.fontSize),8>F.fontSize&&(F.fontSize=8),m=new a.RTFNode(this.evaluator,"",e[x].value,F),A[A.length-2].addChild(m),A[A.length-1]=m;else if("controlWord"==e[x].type&&("num"==e[x].value||"den"==e[x].value))F=A[A.length-2].style.clone(),F.fontSize=Math.round(F.fontSize-
0.1*F.fontSize),8>F.fontSize&&(F.fontSize=8),"num"==e[x].value?m=new a.RTFNode(this.evaluator,"","numerator",F):"den"==e[x].value&&(m=new a.RTFNode(this.evaluator,"","denominator",F)),A[A.length-2].addChild(m),A[A.length-1]=m;else if("controlWord"==e[x].type&&("subix"==e[x].value||"supix"==e[x].value))F=A[A.length-2].style.clone(),F.fontSize=Math.floor(F.fontSize-F.fontSize/3),8>F.fontSize&&(F.fontSize=8),"subix"==e[x].value?m=new a.RTFNode(this.evaluator,"","subIndex",F):"supix"==e[x].value&&(m=
new a.RTFNode(this.evaluator,"","superIndex",F)),m.originalStyle=A[A.length-2].style.clone(),A[A.length-2].addChild(m),A[A.length-1]=m;else if("controlWord"==e[x].type&&("defparts"==e[x].value||"matrix"==e[x].value||"element"==e[x].value))F=A[A.length-2].style.clone(),m=new a.RTFNode(this.evaluator,"",e[x].value,F),A[A.length-2].addChild(m),A[A.length-1]=m,"defparts"==e[x].value?u=m:"matrix"==e[x].value&&(q=m);else if("controlWord"==e[x].type&&"parts"==e[x].value)z=!0;else if("text"==e[x].type&&z)u.parts=
parseInt(e[x].value),z=!1;else if("controlWord"==e[x].type&&"rows"==e[x].value)s=!0;else if("text"==e[x].type&&s)q.rows=parseInt(e[x].value),s=!1;else if("controlWord"==e[x].type&&"columns"==e[x].value)w=!0;else if("text"==e[x].type&&w)q.columns=parseInt(e[x].value),w=!1;else if("controlWord"==e[x].type&&"expr"==e[x].value)E=!1,v=!0;else if("controlWord"==e[x].type&&"decimals"==e[x].value)n=!0;else if("text"==e[x].type&&n)t.decimals=this.evaluator.parser.parse(e[x].value+""),n=!1;else if("controlWord"==
e[x].type&&"fixed1"==e[x].value)t.fixed=!0;else if("controlWord"==e[x].type&&"fixed0"==e[x].value)t.fixed=!1;else if(!("controlWord"==e[x].type&&"component"==e[x].value))if("controlWord"==e[x].type&&"NumCtrl"==e[x].value)G=!0;else if("controlWord"==e[x].type&&"Space"==e[x].value)I=!0;else if("controlWord"==e[x].type&&"hyperlink"==e[x].value)K=!0;else if("text"==e[x].type&&K){textContent=e[x].value.split("|")[0];F=y.clone();m=new a.RTFNode(this.evaluator,textContent,"hyperlink",F);m.URL=e[x].value.split("|")[1];
if("textLineBlock"!=l.nodeType)for(l=l.parent;"textLineBlock"!=l.nodeType;)l=l.parent;l.addChild(m);K=!1}else if("text"==e[x].type&&G)m=new a.RTFNode(this.evaluator,e[x].value,"componentNumCtrl",y.clone()),l.addChild(m),G=!1;else if("text"==e[x].type&&I)m=new a.RTFNode(this.evaluator,e[x].value,"componentSpace",y.clone()),l.addChild(m),I=!1;else if("text"==e[x].type&&v)F=A[A.length-2].style.clone(),textContent=this.evaluator.parser.parse(e[x].value),m=new a.RTFNode(this.evaluator,textContent,"dynamicText",
F),A[A.length-2].addChild(m),t=A[A.length-1]=m,v=!1;else if("text"==e[x].type&&!v&&!p){textContent=e[x].value;m=new a.RTFNode(this.evaluator,textContent,"text",y.clone());if("textLineBlock"!=l.nodeType)for(l=l.parent;"textLineBlock"!=l.nodeType;)l=l.parent;l.addChild(m)}else if("text"==e[x].type&&!v&&p)textContent=e[x].value,m=new a.RTFNode(this.evaluator,textContent,"text",A[A.length-1].style.clone()),A[A.length-1].addChild(m);else if("("==e[x].type||")"==e[x].type)F=A[A.length-1].style.clone(),
F.textItalic="",m=new a.RTFNode(this.evaluator,e[x].type,"mathSymbol",F),A[A.length-1].addChild(m);else if("+"==e[x].type||"-"==e[x].type||"*"==e[x].type||"="==e[x].type)m=new a.RTFNode(this.evaluator,e[x].type,"mathSymbol",A[A.length-1].style.clone()),A[A.length-1].addChild(m);if(null!=l){var T=l.getRoot();T.stableWidth=E;T.getTextMetrics();T.hasFormula=H}return T};a.FontStyle=function(a,b,c,d,e,g,f){this.fontSize=a;this.fontType=b;this.textItalic=c;this.textBold=d;this.textUnderline=e;this.textOverline=
g;this.textColor=f};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 e,k,g,b,d,f,h,c,r,m,l,t,q,u;a.Space=function(b,c){this.parent=b;k=this.evaluator=this.parent.evaluator;g=k.parser;this.id="";this.values=c;this.type="R2";this.xExpr=g.parse("0");this.yExpr=g.parse("0");this.w=parseInt(b.container.width);this.h=parseInt(b.container.height);this.drawif=g.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(){e=this.parent;k=this.evaluator;b=this.id;this.displaceRegionNorth=e.displaceRegionNorth||0;this.displaceRegionWest=e.displaceRegionWest||0;void 0!=this.wExpr&&(this.w=(parseInt(e.container.width)-
this.displaceRegionWest)*parseFloat(this.wExpr)/100);void 0!=this.hExpr&&(this.h=(parseInt(e.container.height)-this.displaceRegionNorth)*parseFloat(this.hExpr)/100);h=parseInt(e.container.height);c=parseInt(e.container.width);this.x=k.evalExpression(this.xExpr)+this.displaceRegionWest;this.y=k.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?(d=h-this.y,this.h>d&&(this.h=d)):
(d=this.h+this.y,this.h=d>=h?h:d);0<=this.x?(f=c-this.x,this.w>f&&(this.w=f)):(f=this.w+this.x,this.w=f>=c?c:f);if(""!=this.imageSrc||!this.imageSrc.trim().toLowerCase().match(/vacio.gif$/))this.image=e.getImage(this.imageSrc);this.OxExpr&&(m=this.OxExpr,"%"===m[m.length-1]?this.Ox=this.w*parseFloat(m)/100:(r=parseFloat(m),r!=m&&(r=0),this.Ox=r));this.OyExpr&&(l=this.OyExpr,"%"===l[l.length-1]?this.Oy=this.h*parseFloat(l)/100:(r=parseFloat(l),r!=l&&(r=0),this.Oy=r));""!==this.id&&2!==e.version?(k.setVariable(b+
"._w",this.w),k.setVariable(b+"._h",this.h),k.setVariable(b+".escala",this.scale),k.setVariable(b+".Ox",this.Ox),k.setVariable(b+".Oy",this.Oy),k.setVariable(b+".mouse_x",0),k.setVariable(b+".mouse_y",0),k.setVariable(b+".mouse_pressed",0),k.setVariable(b+".mouse_clicked",0),k.setVariable(b+".clic_izquierdo",0)):(r=k.getVariable("_w"),void 0===r&&(r=this.w),k.setVariable("_w",r),r=k.getVariable("_h"),void 0===r&&(r=this.h),k.setVariable("_h",r),r=k.getVariable("escala"),void 0===r&&(r=this.scale),
k.setVariable("escala",r),r=k.getVariable("Ox"),void 0===r&&(r=this.Ox),k.setVariable("Ox",r),r=k.getVariable("Oy"),void 0===r&&(r=this.Oy),k.setVariable("Oy",r),k.setVariable("mouse_x",0),k.setVariable("mouse_y",0),k.setVariable("mouse_pressed",0),k.setVariable("mouse_clicked",0),k.setVariable("clic_izquierdo",0),""===this.x_axis&&(""===this.y_axis&&2==e.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.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(){t=this.container;this.offsetTop=this.offsetLeft=0;this.container&&this.container.style&&(q=this.container.style.display);this.container.style.display="block";if(t.getBoundingClientRect){var a=t.getBoundingClientRect();this.offsetLeft=a.left;this.offsetTop=a.top}else for(;t;)t.tagName&&"html"!==t.tagName.toLowerCase()?(this.offsetLeft+=t.offsetLeft||0,this.offsetTop+=t.offsetTop||0,t=t.parentNode):t=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){var e,k;if(a.loadLib)return a;var g=Math.floor,b=Math.round,d=2*Math.PI,f=a.convertFont("SansSerif,PLAIN,12"),h=a.convertFont("Monospaced,PLAIN,12"),c,r,m,l,t,q,u,p,v,n,s,w,z,C,y,E,D,B,A,H,G,I,K,x,J,F,P,Q,M;a.Space2D=function(b,d){a.Space.call(this,b,d);c=this;c.backgroundCanvas=document.createElement("canvas");c.backgroundCanvas.setAttribute("id",c.id+"_background");
c.backgroundCanvas.setAttribute("width",c.w+"px");c.backgroundCanvas.setAttribute("height",c.h+"px");c.backgroundCtx=c.backgroundCanvas.getContext("2d");c.backgroundCtx.imageSmoothingEnabled=!1;c.backgroundCtx.mozImageSmoothingEnabled=!1;c.backgroundCtx.webkitImageSmoothingEnabled=!1;c.canvas=document.createElement("canvas");c.canvas.setAttribute("id",c.id+"_canvas");c.canvas.setAttribute("width",c.w+"px");c.canvas.setAttribute("height",c.h+"px");c.canvas.setAttribute("class","DescartesSpace2DCanvas");
c.canvas.setAttribute("style","z-index: "+c.zIndex+";");c.ctx=c.canvas.getContext("2d");c.ctx.imageSmoothingEnabled=!1;c.ctx.mozImageSmoothingEnabled=!1;c.ctx.webkitImageSmoothingEnabled=!1;c.graphicControlContainer=document.createElement("div");c.graphicControlContainer.setAttribute("id",c.id+"_graphicControls");c.graphicControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+c.zIndex+";");c.numericalControlContainer=document.createElement("div");c.numericalControlContainer.setAttribute("id",
c.id+"_numericalControls");c.numericalControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+c.zIndex+";");c.container=document.createElement("div");c.container.setAttribute("id",c.id);c.container.setAttribute("class","DescartesSpace2DContainer");c.container.setAttribute("style","left: "+c.x+"px; top: "+c.y+"px; z-index: "+c.zIndex+";");c.parent.arquimedes&&"#f0f8fa"===c.background.getColor()&&(c.container.style.border="1px solid #b8c4c8");c.container.appendChild(c.backgroundCanvas);
c.container.appendChild(c.canvas);c.container.appendChild(c.graphicControlContainer);c.container.appendChild(c.numericalControlContainer);b.container.insertBefore(c.container,b.loader);c.parent.images[c.id+".image"]=c.canvas;c.parent.images[c.id+".image"].ready=1;c.parent.images[c.id+".image"].complete=!0;c.evaluator.setVariable(c.id+".image",c.id+".image");c.parent.images[c.id+".back"]=c.backgroundCanvas;c.parent.images[c.id+".back"].ready=1;c.parent.images[c.id+".back"].complete=!0;c.evaluator.setVariable(c.id+
".back",c.id+".back");""!==c.id&&2!==b.version?(c.OxString=c.id+".Ox",c.OyString=c.id+".Oy",c.scaleString=c.id+".escala",c.wString=c.id+"._w",c.hString=c.id+"._h",c.mxString=c.id+".mouse_x",c.myString=c.id+".mouse_y",c.mpressedString=c.id+".mouse_pressed",c.mclickedString=c.id+".mouse_clicked",c.mclicizquierdoString=c.id+".clic_izquierdo"):(c.OxString="Ox",c.OyString="Oy",c.scaleString="escala",c.wString="_w",c.hString="_h",c.mxString="mouse_x",c.myString="mouse_y",c.mpressedString="mouse_pressed",
c.mclickedString="mouse_clicked",c.mclicizquierdoString="clic_izquierdo");"descartesJS_scenario"!==c.id&&c.registerMouseAndTouchEvents()};a.extend(a.Space2D,a.Space);a.Space2D.prototype.init=function(){c=this;c.uber.init.call(c);c.canvas&&(c.backgroundCanvas.setAttribute("width",c.w+"px"),c.backgroundCanvas.setAttribute("height",c.h+"px"),c.canvas.setAttribute("width",c.w+"px"),c.canvas.setAttribute("height",c.h+"px"));c.container&&c.findOffset()};a.Space2D.prototype.update=function(a){c=this;r=c.evaluator;
m=c.parent;r.setVariable(c.wString,c.w);r.setVariable(c.hString,c.h);c.drawIfValue=0<r.evalExpression(c.drawif);if(c.drawIfValue){t=c.x!==r.evalExpression(c.xExpr)+c.displaceRegionWest;q=c.y!==r.evalExpression(c.yExpr)+m.plecaHeight+c.displaceRegionNorth;c.spaceChange=a||t||q||c.drawBefore!==c.drawIfValue||c.Ox!==r.getVariable(c.OxString)||c.Oy!==r.getVariable(c.OyString)||c.scale!==r.getVariable(c.scaleString);c.x=t?r.evalExpression(c.xExpr)+c.displaceRegionWest:c.x;c.y=q?r.evalExpression(c.yExpr)+
m.plecaHeight+c.displaceRegionNorth:c.y;c.Ox=r.getVariable(c.OxString);c.Oy=r.getVariable(c.OyString);c.scale=r.getVariable(c.scaleString);c.drawBefore=c.drawIfValue;1E-6>c.scale?(c.scale=1E-6,r.setVariable(c.scaleString,1E-6)):1E6<c.scale&&(c.scale=1E6,r.setVariable(c.scaleString,1E6));if(t||q)c.container.style.left=c.x+"px",c.container.style.top=c.y+"px",c.findOffset();c.container.style.display="block";c.drawTrace=!c.spaceChange&&!c.click;c.spaceChange&&c.drawBackground();c.draw()}else c.container.style.display=
"none"};a.Space2D.prototype.drawBackground=function(){r=this.evaluator;l=this.backgroundCtx;l.clearRect(0,0,this.backgroundCanvas.width,this.backgroundCanvas.height);l.fillStyle=this.background.getColor();l.fillRect(0,0,this.backgroundCanvas.width,this.backgroundCanvas.height);this.image&&(""!=this.image.src&&this.image.ready&&this.image.complete)&&("topleft"===this.bg_display?l.drawImage(this.image,0,0):"stretch"===this.bg_display?l.drawImage(this.image,0,0,this.w,this.h):"patch"===this.bg_display?
(l.fillStyle=l.createPattern(this.image,"repeat"),l.fillRect(0,0,this.canvas.width,this.canvas.height)):"center"===this.bg_display&&l.drawImage(this.image,(this.w-this.image.width)/2,(this.h-this.image.height)/2));p=this.scale;v=0;for(n=0>this.w+this.h?0:this.w+this.h;p>n;)p/=10,v++;for(;p<n/10;)p*=10;l.lineWidth=1;""!==this.net&&(l.strokeStyle=this.net.getColor(),this.drawMarks(l,p/10,-1));if(2!==this.parent.version&&""!==this.net10||2===this.parent.version&&""!==this.net&&""!==this.net10)l.strokeStyle=
this.net10.getColor(),this.drawMarks(l,p,-1);if(""!==this.axes){l.strokeStyle=this.axes.getColor();l.beginPath();if(""!==this.x_axis||2!==this.parent.version)l.moveTo(0,g(this.h/2+this.Oy)+0.5),l.lineTo(this.w,g(this.h/2+this.Oy)+0.5);if(""!==this.y_axis||2!==this.parent.version)l.moveTo(g(this.w/2+this.Ox)+0.5,0),l.lineTo(g(this.w/2+this.Ox)+0.5,this.h);l.stroke();this.drawMarks(l,p,4);this.drawMarks(l,p/2,2);this.drawMarks(l,p/10,1)}if(""!==this.x_axis||""!==this.y_axis)l.fillStyle=""!==this.axes?
this.axes.getColor():"black",l.font=f,l.textAlign="right",l.textBaseline="alphabetic",l.fillText(this.x_axis,g(this.w)-2,g(this.h/2+this.Oy)+12),l.fillText(this.y_axis,g(this.w/2+this.Ox)-2,12);this.numbers&&""!=this.axes&&(l.fillStyle=this.axes.getColor(),l.font=f,l.textAlign="start",l.textBaseline="bottom",p>(this.w+this.h)/2?this.drawNumbers(l,p/5,p<=this.scale?v+1:v):p>(this.w+this.h)/4?this.drawNumbers(l,p/2,p<=this.scale?v+1:v):this.drawNumbers(l,p,v));for(var a=0,b=this.backgroundGraphics.length;a<
b;a++)this.backgroundGraphics[a].draw()};a.Space2D.prototype.draw=function(){l=this.ctx;l.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)&&(l.fillStyle=this.text.getColor(),l.strokeStyle=l.fillStyle,l.lineWidth=1,l.font=h,l.textAlign=
"center",l.textBaseline="alphabetic",G=1>=this.scale?this.mouse_x.toFixed(0):this.mouse_x.toFixed(this.scale.toString().length),I=1>=this.scale?this.mouse_y.toFixed(0):this.mouse_y.toFixed(this.scale.toString().length),K="("+G+","+I+")",x=g(l.measureText(K).width/2),J=this.getAbsoluteX(this.mouse_x),F=this.getAbsoluteY(this.mouse_y),P=g(J),Q=g(F-10),P+x>this.w?P=this.w-x:0>P-x&&(P=x),Q+1>this.h?Q=this.h:0>Q-14&&(Q=15),l.fillText(K,P,Q),l.beginPath(),l.arc(J,F,2.5,0,d,!0),l.stroke())};a.Space2D.prototype.drawMarks=
function(a,c,d){s=this.w;w=this.h;D=0;B=s;A=0;H=w;y=g(s/2+this.Ox);E=g(w/2+this.Oy);0<=d&&(D=y-d,B=y+d,A=E-d,H=E+d);a.beginPath();for(d=-b(y/c);(z=y+b(d*c))<s;d++)a.moveTo(z+0.5,A+0.5),a.lineTo(z+0.5,H+0.5);for(d=-b(E/c);(C=E+b(d*c))<w;d++)a.moveTo(D+0.5,C+0.5),a.lineTo(B+0.5,C+0.5);a.stroke()};a.Space2D.prototype.drawNumbers=function(a,c,d){s=this.w;w=this.h;y=g(s/2+this.Ox);E=g(w/2+this.Oy);for(d=-b(y/c);(z=y+b(d*c))<s;d++)a.fillText(parseFloat((d*c/this.scale).toFixed(4)),z+1,E-2);for(d=-b(E/c);(C=
E+b(d*c))<w;d++)0!==parseFloat(-d*c/this.scale)&&a.fillText(parseFloat((-d*c/this.scale).toFixed(4)),y+5,C+5)};a.Space2D.prototype.registerMouseAndTouchEvents=function(){function b(a){m.click=1;m.evaluator.setVariable(m.mpressedString,1);m.evaluator.setVariable(m.mclickedString,0);m.evaluator.setVariable(m.mclicizquierdoString,0);m.parent.deactivateGraphiControls();h(a);window.addEventListener("touchmove",n);window.addEventListener("touchend",c);a.preventDefault()}function c(a){m.click=0;m.evaluator.setVariable(m.mpressedString,
0);m.evaluator.setVariable(m.mclickedString,1);m.evaluator.setVariable(m.mclicizquierdoString,1);window.removeEventListener("touchmove",n,!1);window.removeEventListener("touchend",c,!1);a.preventDefault();m.parent.update()}function d(b){m.click=1;m.parent.deactivateGraphiControls();m.whichButton=a.whichButton(b);"R"===m.whichButton&&(window.addEventListener("mouseup",f),m.fixed||(m.clickPosForZoom=m.getCursorPosition(b).y,m.tempScale=m.scale,window.addEventListener("mousemove",l)));"L"===m.whichButton&&
(m.evaluator.setVariable(m.mpressedString,1),m.evaluator.setVariable(m.mclickedString,0),m.evaluator.setVariable(m.mclicizquierdoString,0),h(b),window.addEventListener("mousemove",n),window.addEventListener("mouseup",f));b.preventDefault()}function f(a){m.click=0;m.evaluator.setVariable(m.mpressedString,0);m.evaluator.setVariable(m.mclickedString,1);m.evaluator.setVariable(m.mclicizquierdoString,1);a.preventDefault();"R"===m.whichButton&&window.removeEventListener("mousemove",l,!1);m.sensitive_to_mouse_movements||
window.removeEventListener("mousemove",n,!1);window.removeEventListener("mouseup",f,!1);m.parent.update()}function h(a){m.posAnte=m.getCursorPosition(a);m.mouse_x=m.getRelativeX(m.posAnte.x);m.mouse_y=m.getRelativeY(m.posAnte.y);m.evaluator.setVariable(m.mxString,m.mouse_x);m.evaluator.setVariable(m.myString,m.mouse_y);m.evaluator.setVariable(m.mclickedString,0);m.evaluator.setVariable(m.mclicizquierdoString,0);m.parent.update()}function l(a){a.preventDefault();m.clickPosForZoomNew=m.getCursorPosition(a).y;
m.evaluator.setVariable(m.scaleString,m.tempScale+m.tempScale/45*((m.clickPosForZoom-m.clickPosForZoomNew)/10));m.parent.update()}function n(a){m.fixed||(m.posNext=m.getCursorPosition(a),e=g(m.posAnte.x-m.posNext.x),k=g(m.posAnte.y-m.posNext.y),m.evaluator.setVariable(m.OxString,m.Ox-e),m.evaluator.setVariable(m.OyString,m.Oy-k),m.posAnte.x-=e,m.posAnte.y-=k);h(a);a.preventDefault()}var m=this;M=a.hasTouchSupport;m.canvas.oncontextmenu=function(){return!1};M&&(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("touchmove",
h),this.canvas.addEventListener("touchstart",b));M||(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("mousemove",h),this.canvas.addEventListener("mousedown",d))};return a}(descartesJS||{}),descartesJS=function(a){var e,k,g;function b(a,b){return b.depth-a.depth}function d(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 f=Math.floor,
h=Math.round,c=Math.max,r=Math.cos,m=Math.sin,l=Math.sqrt,t=15*Math.PI/180,q=Math.cos(t),u=Math.sin(t),p,v,n,s,w,z,C,y,E,D,B,A,H,G,I,K,x,J,F,P,Q,M,R,S=[],N,O,L,U,T,X,Y,V,W;a.Space3D=function(b,c){a.Space.call(this,b,c);n=this;n.backgroundCanvas=document.createElement("canvas");n.backgroundCanvas.setAttribute("id",n.id+"_background");n.backgroundCanvas.setAttribute("width",n.w+"px");n.backgroundCanvas.setAttribute("height",n.h+"px");n.canvas=document.createElement("canvas");n.canvas.setAttribute("id",
n.id+"_canvas");n.canvas.setAttribute("width",n.w+"px");n.canvas.setAttribute("height",n.h+"px");n.canvas.setAttribute("class","DescartesSpace3DCanvas");n.canvas.setAttribute("style","z-index: "+n.zIndex+";");n.ctx=n.canvas.getContext("2d");n.ctx.imageSmoothingEnabled=!1;n.ctx.mozImageSmoothingEnabled=!1;n.ctx.webkitImageSmoothingEnabled=!1;n.graphicControlContainer=document.createElement("div");n.graphicControlContainer.setAttribute("id",n.id+"_graphicControls");n.graphicControlContainer.setAttribute("style",
"position: absolute; left: 0px; top: 0px; z-index: "+n.zIndex+";");n.numericalControlContainer=document.createElement("div");n.numericalControlContainer.setAttribute("id",n.id+"_numericalControls");n.numericalControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+n.zIndex+";");n.container=document.createElement("div");n.container.setAttribute("id",n.id);n.container.setAttribute("class","DescartesSpace3DContainer");n.container.setAttribute("style","left: "+n.x+"px; top: "+
n.y+"px; z-index: "+n.zIndex+";");n.container.appendChild(n.backgroundCanvas);n.container.appendChild(n.canvas);n.container.appendChild(n.graphicControlContainer);n.container.appendChild(n.numericalControlContainer);b.container.insertBefore(n.container,b.loader);n.eye={x:0,y:0,z:0};n.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,e=n.lights.length;d<e;d++)n.lights[d]=a.normalize3D(n.lights[d]);n.light3={x:0,y:0,z:0};n.intensity=[0.4,0.5,0.3,0];n.userIntensity=
0;n.dim=1;n.tmpIntensity=[];n.OxStr=n.id+".Ox";n.OyStr=n.id+".Oy";n.scaleStr=n.id+".escala";n.wStr=n.id+"._w";n.hStr=n.id+"._h";n.obsStr=n.id+".observador";n.rotZStr=n.id+".rot.z";n.rotYStr=n.id+".rot.y";n.userI_Dim_Str=n.id+".userIlum.dim";n.userI_I_Str=n.id+".userIlum.I";n.userI_x_Str=n.id+".userIlum.x";n.userI_y_Str=n.id+".userIlum.y";n.userI_z_Str=n.id+".userIlum.z";n.evaluator.setVariable(n.rotZStr,0);n.evaluator.setVariable(n.rotYStr,0);n.evaluator.setVariable(n.userI_Dim_Str,n.dim);n.evaluator.setVariable(n.userI_I_Str,
n.userIntensity);n.evaluator.setVariable(n.userI_x_Str,0);n.evaluator.setVariable(n.userI_y_Str,0);n.evaluator.setVariable(n.userI_z_Str,0);n.registerMouseAndTouchEvents()};a.extend(a.Space3D,a.Space);a.Space3D.prototype.init=function(a){n=this;n.uber.init.call(n);n.canvas&&(n.canvas.setAttribute("width",n.w+"px"),n.canvas.setAttribute("height",n.h+"px"));n.container&&n.findOffset();n.w_2=n.w/2;n.h_2=n.h/2;n.oldMouse={x:0,y:0}};a.Space3D.prototype.update=function(a){n=this;p=n.evaluator;v=n.parent;
p.setVariable(n.wStr,n.w);p.setVariable(n.hStr,n.h);n.drawIfValue=0<p.evalExpression(n.drawif);if(n.drawIfValue){E=n.x!==p.evalExpression(n.xExpr)+n.displaceRegionWest;D=n.y!==p.evalExpression(n.yExpr)+v.plecaHeight+n.displaceRegionNorth;n.spaceChange=a||E||D||n.drawBefore!==n.drawIfValue||n.Ox!==p.getVariable(n.OxStr)||n.Oy!==p.getVariable(n.OyStr)||n.scale!==p.getVariable(n.scaleStr);n.x=E?p.evalExpression(n.xExpr)+n.displaceRegionWest:n.x;n.y=D?p.evalExpression(n.yExpr)+v.plecaHeight+n.displaceRegionNorth:
n.y;n.Ox=p.getVariable(n.OxStr);n.Oy=p.getVariable(n.OyStr);n.scale=p.getVariable(n.scaleStr);n.drawBefore=n.drawIfValue;if(a){var b;a=0;for(var d=n.parent.controls.length;a<d;a++)n.parent.controls[a].id===n.obsStr&&(b=!0);n.observer=b?p.getVariable(n.obsStr)||0.5*(n.w+n.h):2.5*(n.w+n.h);n.observer=c(n.observer,0.1*(n.w+n.h));p.setVariable(n.obsStr,n.observer);n.eye={x:n.observer/n.scale*q,y:0,z:n.observer/n.scale*u};n.D=n.scale*n.eye.x/q;n.XE=h(n.scale*n.eye.y+0.5);n.YE=h(n.scale*n.eye.z+0.5)}n.observer=
c(p.getVariable(n.obsStr),0.1*(n.w+n.h));p.setVariable(n.obsStr,n.observer);1E-6>n.scale?(n.scale=1E-6,p.setVariable(n.scaleStr,1E-6)):1E6<n.scale&&(n.scale=1E6,p.setVariable(n.scaleStr,1E6));if(E||D)n.container.style.left=n.x+"px",n.container.style.top=n.y+"px",n.findOffset();n.container.style.display="block";n.dim=p.getVariable(n.userI_Dim_Str);n.userIntensity=p.getVariable(n.userI_I_Str);n.light3={x:parseInt(p.getVariable(n.userI_x_Str)),y:parseInt(p.getVariable(n.userI_y_Str)),z:parseInt(p.getVariable(n.userI_z_Str))};
n.updateCamera();n.draw()}else n.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++)s=this.graphics[a],s.update();this.primitives=[];a=0;for(c=this.graphics.length;a<c;a++){s=this.graphics[a];if(s.split||this.split)for(var d=a+1;d<c;d++)w=this.graphics[d],(w.split||this.split)&&s.splitFace(w);this.primitives=
this.primitives.concat(s.primitives||[])}z=this.primitives;C=z.length;for(a=0;a<C;a++)z[a].computeDepth(this);z=z.sort(b);for(a=0;a<C;a++)z[a].draw(this.ctx,this);a=0;for(c=this.graphicsCtr.length;a<c;a++)this.graphicsCtr[a].draw()};a.Space3D.prototype.updateCamera=function(){n=this;n.D=n.observer;n.eye.x=n.D/n.scale;n.eye.y=n.XE/n.scale;n.eye.z=n.YE/n.scale};a.Space3D.prototype.rotateVertex=function(b){x=a.degToRad(n.evaluator.getVariable(n.rotZStr));J=r(x);F=m(x);e=b.x*J-b.y*F;k=b.x*F+b.y*J;g=b.z;
x=a.degToRad(n.evaluator.getVariable(n.rotYStr));J=r(x);F=m(x);return{x:g*F+e*J,y:k,z:g*J-e*F}};a.Space3D.prototype.project=function(a){n=this;H=n.eye.x-a.x;G=n.eye.y-a.y;I=n.eye.z-a.z;K=-a.x/l(H*H+G*G+I*I)||0;H=n.scale*(a.y+K*(n.eye.y-a.y));G=-n.scale*(a.z+K*(n.eye.z-a.z));return{x:parseInt(H+this.w_2+this.Ox),y:parseInt(G+this.h_2+this.Oy),z:K}};a.Space3D.prototype.computeColor=function(b,c,e){U=a.subtract3D(this.eye,c.average);T=a.norm3D(U);X=a.scalarProduct3D(U,1/T);this.lights[3]=a.subtract3D(this.light3,
c.average);R=a.norm3D(this.lights[3]);for(var g=0,h=this.intensity.length-1;g<h;g++)S[g]=this.intensity[g]*this.dim;S[3]=this.userIntensity*this.userIntensity/R||0;N=e?this.dim/2:this.dim/4;O=0;L=0<=c.direction?c.normal:a.scalarProduct3D(c.normal,-1);g=0;for(h=this.lights.length;g<h;g++)e?(O=Math.max(0,a.dotProduct3D(d(this.lights[g],L),X)),O*=O*O):O=Math.max(0,a.dotProduct3D(this.lights[g],L)),N+=S[g]*O;N=Math.min(N,1);P=f(b.r*N);Q=f(b.g*N);M=f(b.b*N);return"rgba("+P+","+Q+","+M+","+b.a+")"};a.Space3D.prototype.registerMouseAndTouchEvents=
function(){function b(a){k.click=1;k.evaluator.setVariable(k.id+".mouse_pressed",1);k.parent.deactivateGraphiControls();k.posAnte=k.getCursorPosition(a);k.oldMouse.x=k.getRelativeX(k.posAnte.x);k.oldMouse.y=k.getRelativeY(k.posAnte.y);g(a);window.addEventListener("touchmove",m);window.addEventListener("touchend",c);a.preventDefault()}function c(a){k.click=0;k.evaluator.setVariable(k.id+".mouse_pressed",0);window.removeEventListener("touchmove",m,!1);window.removeEventListener("touchend",c,!1);a.preventDefault()}
function d(b){k.click=1;k.parent.deactivateGraphiControls();k.whichButton=a.whichButton(b);"R"===k.whichButton?(window.addEventListener("mouseup",e),k.fixed||(k.clickPosForZoom=k.getCursorPosition(b).y,k.tempScale=k.scale,window.addEventListener("mousemove",f))):"L"==k.whichButton&&(k.evaluator.setVariable(k.id+".mouse_pressed",1),k.posAnte=k.getCursorPosition(b),k.oldMouse.x=k.getRelativeX(k.posAnte.x),k.oldMouse.y=k.getRelativeY(k.posAnte.y),g(b),window.addEventListener("mousemove",m),window.addEventListener("mouseup",
e));b.preventDefault()}function e(a){k.click=0;k.evaluator.setVariable(k.id+".mouse_pressed",0);a.preventDefault();"R"===k.whichButton&&window.removeEventListener("mousemove",f,!1);window.removeEventListener("mousemove",m,!1);window.removeEventListener("mouseup",e,!1)}function g(a){k.posAnte=k.getCursorPosition(a);k.mouse_x=k.getRelativeX(k.posAnte.x);k.mouse_y=k.getRelativeY(k.posAnte.y);k.evaluator.setVariable(k.id+".mouse_x",k.mouse_x);k.evaluator.setVariable(k.id+".mouse_y",k.mouse_y);k.parent.update()}
function f(a){a.preventDefault();k.clickPosForZoomNew=k.getCursorPosition(a).y;k.evaluator.setVariable(k.scaleStr,k.tempScale+k.tempScale/45*((k.clickPosForZoom-k.clickPosForZoomNew)/10));k.parent.update()}function m(b){if(!k.fixed&&k.click){B=parseInt(50*(k.oldMouse.x-k.mouse_x));A=parseInt(50*(k.oldMouse.y-k.mouse_y));if(B!==k.disp.x||A!==k.disp.y)k.alpha=a.degToRad(k.evaluator.getVariable(k.rotZStr)),k.beta=a.degToRad(-k.evaluator.getVariable(k.rotYStr)),k.alpha=h(a.radToDeg(k.alpha)-B),k.beta=
h(a.radToDeg(k.beta)-A),k.evaluator.setVariable(k.rotZStr,k.alpha),k.evaluator.setVariable(k.rotYStr,-k.beta),k.disp.x=B,k.disp.y=A,k.oldMouse.x=k.getRelativeX(k.posAnte.x),k.oldMouse.y=k.getRelativeY(k.posAnte.y);g(b);b.preventDefault()}}var k=this;y=a.hasTouchSupport;this.canvas.oncontextmenu=function(){return!1};y&&this.canvas.addEventListener("touchstart",b);y||this.canvas.addEventListener("mousedown",d);this.disp={x:0,y:0}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var e;a.SpaceAP=function(k,g){a.Space.call(this,k,g);this.exportarVars=this.importarVars=null;e=k.evaluator;this.file.match(/^\[/)&&this.file.match(/\]$/)?this.file=e.parser.parse(this.file.substring(1,this.file.length-1)):this.file.match(/^\'/)&&this.file.match(/\'$/)?this.file=e.parser.parse(this.file):this.file=e.parser.parse("'"+this.file+"'");this.oldFile=e.evalExpression(this.file);this.initFile()};a.extend(a.SpaceAP,a.Space);a.SpaceAP.prototype.initFile=function(){this.firstUpdate=!0;var e;
if(this.oldFile){var g=document.getElementById(this.oldFile);e=g&&"descartes/spaceApFile"==g.type?g.text:a.openExternalFile(this.oldFile);null!=e&&(e=e.split("\n"))}if(e&&e.toString().match(/<applet/gi)){for(var g="",b=!1,d=0,f=e.length;d<f&&!(e[d].match("<applet")&&(b=!0),b&&(g+=e[d]),e[d].match("</applet"));d++);d=document.createElement("div");d.innerHTML=g;d.firstChild.setAttribute("width",this.w);d.firstChild.setAttribute("height",this.h);g=this.descApp?this.descApp.container:null;this.descApp=
new a.DescartesApp(d.firstChild);this.descApp.container.setAttribute("class","DescartesAppContainer");this.descApp.container.setAttribute("style","position: absolute; overflow: hidden; background-color: "+this.background+"; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");g?this.parent.container.replaceChild(this.descApp.container,g):this.parent.container.insertBefore(this.descApp.container,this.parent.loader);g=this.descApp.spaces;d=0;
for(f=g.length;d<f;d++)g[d].findOffset();this.descApp.container.style.display=0<this.evaluator.evalExpression(this.drawif)?"block":"none";var h=this;this.descApp.update=function(){this.updateAuxiliaries();this.updateEvents();this.updateControls();this.updateSpaces();h.exportar()}}else g=this.descApp?this.descApp.container:null,this.descApp={},this.descApp.container=document.createElement("div"),this.descApp.container.setAttribute("class","DescartesAppContainer"),d="position: absolute; overflow: hidden; background-color: "+
this.background+"; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";",this.image&&("topleft"==this.bg_display?d+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat;":"stretch"==this.bg_display?d+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat; background-size: 100% 100%;":"patch"==this.bg_display?d+="background-image: url("+this.imageSrc+");":"center"==this.bg_display&&(d+="background-image: url("+
this.imageSrc+"); background-repeat:no-repeat; background-position: center center;")),this.descApp.container.setAttribute("style",d),g?this.parent.container.replaceChild(this.descApp.container,g):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),e=this.y!=this.evaluator.evalExpression(this.yExpr)+this.plecaHeight;this.x=a?this.evaluator.evalExpression(this.xExpr):this.x;this.y=e?this.evaluator.evalExpression(this.yExpr)+this.plecaHeight:this.y;a&&(this.descApp.container.style.left=this.x+"px");e&&(this.descApp.container.style.top=this.y+"px");if(a||e)for(var a=this.descApp.spaces,e=0,b=a.length;e<b;e++)a[e].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 d in this.evaluator.variables)this.evaluator.variables.hasOwnProperty(d)&&d.match(/^public./)&&this.importarVars.push({varName:d,value:this.evaluator.getVariable(d)})}this.importar()}};a.SpaceAP.prototype.importar=function(){for(var a,e=!1,b=0,d=this.importarVars.length;b<d;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),e=!0);e&&this.descApp.update()};a.SpaceAP.prototype.exportar=function(){};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b;a.SpaceHTML_IFrame=function(b,e){a.Space.call(this,b,e);var g=this.parent.evaluator;window.navigator.userAgent.toLowerCase().match(/firefox/);this.file=this.file?this.file.trim():"";this.file.match(/^\[/)&&this.file.match(/\]$/)?this.file=g.parser.parse(this.file.substring(1,
this.file.length-1)):this.file.match(/^\'/)&&this.file.match(/\'$/)?this.file=g.parser.parse(this.file):this.file=g.parser.parse("'"+this.file+"'");this.oldFile=g.evalExpression(this.file);this.MyIFrame=document.createElement("iframe");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: absolute; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px;");this.parent.container.insertBefore(this.MyIFrame,this.parent.loader);var c=this;this.MyIFrame.onload=function(a){var b=this;c.evaluator.setFunction(c.id+".set",function(a,c){b.contentWindow.postMessage({type:"set",name:a,value:c},"*")});c.evaluator.setFunction(c.id+".update",function(){b.contentWindow.postMessage({type:"update"},"*")});c.evaluator.setFunction(c.id+
".exec",function(a,c){b.contentWindow.postMessage({type:"exec",name:a,value:c},"*")})};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){e=
this.evaluator;this.drawIfValue=0<e.evalExpression(this.drawif);if(this.drawif){this.MyIFrame.style.display=this.drawIfValue?"block":"none";a&&(this.y=this.x=Math.Infinity);k=this.x!==e.evalExpression(this.xExpr)+this.displaceRegionWest;g=this.y!==e.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth;this.x=k?e.evalExpression(this.xExpr)+this.displaceRegionWest:this.x;this.y=g?e.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth:this.y;if(k||g)this.MyIFrame.style.left=
this.x+"px",this.MyIFrame.style.top=this.y+"px";b=e.evalExpression(this.file);b!==this.oldFile&&(this.oldFile=b,this.MyIFrame.setAttribute("src",b));this.scrollVar=e.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 e;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=a.image_loader?a.image_loader:f(a.loader.width,a.loader.height);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 d=this;this.timer=setInterval(function(){d.drawLoaderBar(d.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,e=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg|\.PNG|\.JPG|\.GIF|\.SVG)/g,g=/[\w\.\-//]*(\.ogg|\.oga|\.mp3|\.wav|\.OGG|\.OGA\.MP3|\.WAV)/g;var f,k,u,p,v,n;u=0;for(v=b.length;u<v;u++)if("rtf"!==b[u].name){if(b[u].value.match(/'macro'|'makro'/g)){f="";var s;k=this.lessonParser.split(b[u].value);n=0;for(var w=k.length;n<w;n++)"expresion"===babel[k[n][0]]&&(f=k[n][1]);f&&((s=document.getElementById(f))&&"descartes/macro"==s.type?s=s.text:(s=a.openExternalFile(f))&&!s.match(/tipo_de_macro/g)&&
(s=null));if(s&&(f=s.match(e)))for(n=f.length;p<n;p++)k=f[p],!k.toLowerCase().match(/vacio.gif$/)&&""!=k.substring(0,k.length-4)&&(c[k]=new Image,c[k].addEventListener("load",function(){this.ready=1}),c[k].addEventListener("error",function(){this.errorload=1}),c[k].src=k)}if(f=b[u].value.match(e)){p=0;for(n=f.length;p<n;p++)k=f[p],!k.toLowerCase().match(/vacio.gif$/)&&""!=k.substring(0,k.length-4)&&(c[k]=new Image,c[k].addEventListener("load",function(){this.ready=1}),c[k].addEventListener("error",
function(){this.errorload=1}),c[k].src=k)}if(f=b[u].value.match(g)){p=0;for(k=f.length;p<k;p++)this.initAudio(f[p])}}for(var z in c)c.hasOwnProperty(z)&&this.images.length++;for(z in d)d.hasOwnProperty(z)&&this.audios.length++;var C=this,y=this.images.length+this.audios.length,E=function(){C.readys=0;for(var a in c)c.hasOwnProperty(a)&&(c[a].ready||c[a].errorload)&&C.readys++;for(a in C.audios)d.hasOwnProperty(a)&&(d[a].ready||d[a].errorload)&&C.readys++;C.readys!=y?setTimeout(E,30):(clearTimeout(C.timer),
C.descartesApp.initBuildApp())};E()};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},e=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",
e),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",e);a.hasTouchSupport?(c[b].load(),c[b].play(),c[b].ready=1):c[b].load()};var k,g,b,d;a.DescartesLoader.prototype.drawLoaderBar=function(a,c,f){k=this.barWidth;g=this.barHeight;b=this.images.length+this.audios.length;d=2*(k-2)/b;a.translate(c/2,(f-65*e)/2+90*e);a.scale(e,e);a.strokeRect(-k,-g,2*k,g);a.fillStyle=
"gray";a.fillRect(-k+2,-g+2,2*(k-2),g-4);a.fillStyle="#1f375d";a.fillRect(-k+2,-g+2,this.readys*d,g-4);a.setTransform(1,0,0,1,0,0)};var f=function(a,b){var d=document.createElement("canvas");d.width=a;d.height=b;var g=d.getContext("2d");g.save();g.strokeStyle="#1f375d";g.fillStyle="#1f375d";g.lineCap="round";g.lineWidth=2;g.beginPath();e=a<b?a/360:b/195;e=2.5<e?2.5:e;g.translate((a-120*e)/2,(b-65*e)/2);g.scale(e,e);g.moveTo(3,25);g.lineTo(3,1);g.lineTo(21,1);g.bezierCurveTo(33,1,41,15,41,25);g.stroke();
g.beginPath();g.moveTo(1,63);g.lineTo(1,64);g.moveTo(5,62);g.lineTo(5,64);g.moveTo(9,61);g.lineTo(9,64);g.moveTo(13,60);g.lineTo(13,64);g.moveTo(17,58);g.lineTo(17,64);g.moveTo(21,56);g.lineTo(21,64);g.moveTo(25,53);g.lineTo(25,64);g.moveTo(29,50);g.lineTo(29,64);g.moveTo(33,46);g.lineTo(33,64);g.moveTo(37,41);g.lineTo(37,64);g.moveTo(41,32);g.lineTo(41,64);g.stroke();g.font="20px Arial, Helvetica, 'Droid Sans', Sans-serif";g.fillText("escartes",45,33);g.fillText("JS",98,64);g.restore();return d.toDataURL()};
return a}(descartesJS||{}),descartesJS=function(a){function e(a){for(var b="[",d=0,f=a.length;d<f;d++){if(a[d]instanceof Array)b+=e(a[d]);else{k=a[d];if("undefined"==typeof k||!k)k=0;"string"==typeof k&&(k="'"+k+"'");b+=k}d<f-1&&(b+=",")}return b+"]"}if(a.loadLib)return a;a.DescartesApp=function(a){this.applet=a;this.parentContainer=a.parentNode;this.width=parseFloat(a.getAttribute("width"));this.height=parseFloat(a.getAttribute("height"));this.decimal_symbol=".";this.decimal_symbol_regexp=RegExp("\\"+
this.decimal_symbol,"g");this.children=a.getElementsByTagName("param");this.code=a.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=
"";
for(var e=this.children,b,d=0,f=0,h=0,c=e.length;h<c;h++)b=e[h],"rtf_height"==b.name&&(d=parseInt(b.value)),"Buttons"==babel[b.name]&&(this.buttonsConfig=this.lessonParser.parseButtonsConfig(b.value),f=this.buttonsConfig.height),"image_loader"==b.name&&(this.image_loader=b.value);this.arquimedes&&d&&(this.height=d+f+90);this.spaces=[];this.externalSpace={container:document.createElement("div"),controls:[]};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 a=this.children,b=this.lessonParser,d=[],e=[],h=[],c=[],k=[],m=[],l,t=0,q=a.length;t<q;t++)if(l=a[t],"pleca"==l.name)l=b.parsePleca(l.value,this.width),this.container.insertBefore(l,this.loader),this.plecaHeight=l.imageHeight?l.imageHeight:l.offsetHeight;else if("Buttons"==
babel[l.name])this.buttonsConfig=b.parseButtonsConfig(l.value);else if("decimal_symbol"==babel[l.name])this.decimal_symbol=l.value,this.decimal_symbol_regexp=RegExp("\\"+this.decimal_symbol,"g");else if("version"==babel[l.name])this.version=parseInt(l.value);else if("language"==babel[l.name])this.language=l.value;else if("rtf"==l.name){var u=(this.width-780)/2,p=parseInt(this.height)-this.plecaHeight-this.buttonsConfig.height-45;c.push("space='descartesJS_scenario' type='text' expresion='[10,20]' background='yes' text='"+
l.value.replace(/'/g,"&squot;")+"'");c.push("space='descartesJS_scenario' type='text' expresion='["+u+","+(p-25)+"]' background='yes' text='"+this.licenseA+"'");c.push("space='descartesJS_scenario' type='image' expresion='["+(u+15)+","+p+"]' background='yes' abs_coord='yes' file='lib/DescartesCCLicense.png'")}else"E"==l.name.charAt(0)?(l.value.match(/'HTMLIFrame'/)&&this.numberOfIframes++,d.push(l.value)):"C"==l.name.charAt(0)&&"_"==l.name.charAt(1)?e.push(l.value):"A"==l.name.charAt(0)&&"_"==l.name.charAt(1)?
h.push(l.value):"G"==l.name.charAt(0)?c.push(l.value):"S"==l.name.charAt(0)?k.push(l.value):"Animation"==babel[l.name]&&m.push(l.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));t=0;for(q=d.length;t<q;t++)a=b.parseSpace(d[t]),this.arquimedes&&this.scenarioRegion.container.appendChild(a.container),this.spaces.push(a),this.zIndex++;t=0;for(q=c.length;t<q;t++)if(d=b.parseGraphic(c[t]))d.visible&&(this.editableRegionVisible=!0),d.space.addGraph(d);t=0;for(q=
k.length;t<q;t++)(d=b.parse3DGraphic(k[t]))&&d.space.addGraph(d);t=0;for(q=e.length;t<q;t++)this.controls.push(b.parseControl(e[t]));t=0;for(q=h.length;t<q;t++)b.parseAuxiliar(h[t]);t=0;for(q=m.length;t<q;t++)this.animation=b.parseAnimation(m[t]);this.configRegions();this.updateAuxiliaries();this.updateAuxiliaries();t=0;for(q=this.controls.length;t<q;t++)this.controls[t].init();this.updateControls();this.updateSpaces(!0);var v=this;this.numberOfIframes?setTimeout(function(){v.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());if(window.opener){document.body.style.margin="0px";document.body.style.padding="0px";this.parentContainer.style.margin=
"0px";this.parentContainer.style.padding="0px";var e=parseInt(this.width)+20,b=parseInt(this.height)+80;window.moveTo((parseInt(screen.width)-e)/2,(parseInt(screen.height)-b)/2);window.resizeTo(e,b);a.onResize()}a.externalEvaluator=new a.Evaluator};a.DescartesApp.prototype.configRegions=function(){var e=this.evaluator.parser,b=this.buttonsConfig,d=this.container;if(2!=this.version)var f="15",h=100,c=100,k=100,m=100;else f="14",h=63,c=50,k=44,m=53;var l=0,t=0,q=0,u=q=0,p=0,v=0,n=0,s=0,v=this.northSpace.controls,
w=this.southSpace.controls,z=this.eastSpace.controls,C=this.westSpace.controls;if(0<b.rowsNorth||0<v.length||b.about||b.config){0>=b.rowsNorth?(l=b.height,b.rowsNorth=1):l=b.height*b.rowsNorth;p=this.northSpace.container;p.setAttribute("id","descartesJS_northRegion");p.setAttribute("style","width:"+d.width+"px; height:"+l+"px; background:#c0c0c0; position:absolute; left:0px; top:0px; z-index:100;");d.insertBefore(p,this.loader);var p=d.width,y=0;b.about&&(y=h,p-=y);b.config&&(p-=c);for(var E=Math.ceil(v.length/
b.rowsNorth),D=p/E,q=0,B=v.length;q<B;q++)v[q].expresion=e.parse("("+(y+D*(q%E))+","+b.height*Math.floor(q/E)+","+D+","+b.height+")"),v[q].drawif=e.parse("1"),v[q].init();b.about&&(q="espa\u00f1ol"==this.language?"cr\u00e9ditos":"english"==this.language?"about":"cr\u00e9ditos",(new a.Button(this,{region:"north",name:q,font_size:e.parse(f),expresion:e.parse("(0, 0, "+h+", "+l+")")})).update());b.config&&(new a.Button(this,{region:"north",name:"config",font_size:e.parse(f),action:"config",expresion:e.parse("("+
(p+h)+", 0, "+c+", "+l+")")})).update()}if(0<b.rowsSouth||0<w.length||b.init||b.clear){0>=b.rowsSouth?(t=b.height,b.rowsSouth=1):t=b.height*b.rowsSouth;v=d.width;y=0;b.init&&(y=k,v-=y);b.clear&&(v-=m);p=this.southSpace.container;p.setAttribute("id","descartesJS_southRegion");p.setAttribute("style","width:"+d.width+"px; height:"+t+"px; background:#c0c0c0; position:absolute; left: 0px; top:"+(d.height-t)+"px; z-index:100;");d.insertBefore(p,this.loader);E=Math.ceil(w.length/b.rowsSouth);D=v/E;q=0;for(B=
w.length;q<B;q++)w[q].expresion=e.parse("("+(y+D*(q%E))+","+b.height*Math.floor(q/E)+","+D+","+b.height+")"),w[q].drawif=e.parse("1"),w[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:e.parse(f),action:"init",expresion:e.parse("(0, 0, "+k+", "+t+")")})).update());b.clear&&(q="espa\u00f1ol"==this.language?"limpiar":"english"==this.language?"clear":"limpiar",(new a.Button(this,{region:"south",name:q,
font_size:e.parse(f),action:"clear",expresion:e.parse("("+(v+k)+", 0, "+m+", "+t+")")})).update())}if(0<z.length){q=d.height-l-t;n=b.widthEast;p=this.eastSpace.container;p.setAttribute("id","descartesJS_eastRegion");p.setAttribute("style","width:"+n+"px; height:"+q+"px; background:#c0c0c0; position:absolute; left:"+(d.width-n)+"px; top:"+l+"px; z-index:100;");d.insertBefore(p,this.loader);q=0;for(B=z.length;q<B;q++)z[q].expresion=e.parse("(0,"+b.height*q+","+n+","+b.height+")"),z[q].drawif=e.parse("1"),
z[q].init()}if(0<C.length){q=d.height-l-t;s=b.widthWest;p=this.westSpace.container;p.setAttribute("id","descartesJS_westRegion");p.setAttribute("style","width: "+s+"px; height: "+q+"px; background: #c0c0c0; position: absolute; left: 0px; top: "+l+"px; z-index: 100;");d.insertBefore(p,this.loader);q=0;for(B=C.length;q<B;q++)C[q].expresion=e.parse("(0,"+b.height*q+","+s+","+b.height+")"),C[q].drawif=e.parse("1"),C[q].init()}if(this.editableRegionVisible){u=b.height;p=this.editableRegion.container;p.setAttribute("id",
"descartesJS_editableRegion");p.setAttribute("style","width:"+d.width+"px; height:"+u+"px; position:absolute; left:0px; top:"+(d.height-t-b.height)+"px; z-index:100; background:#c0c0c0; overflow:hidden;");d.insertBefore(p,this.loader);e=this.editableRegion.textFields;b=d.width/e.length;f=a.getFieldFontSize(u);q=0;for(B=e.length;q<B;q++)"div"==e[q].type?(p.appendChild(e[q].container),e[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;"),h=e[q].container.firstChild,h.setAttribute("style","font-family: Arial, Helvetica, 'Droid Sans', Sans-serif; font-size: "+f+"px; padding-top: 0%; background-color: #e0e4e8; position: absolute; left: 0px; top: 0px; height:"+u+"px; text-align: center; line-height: "+u+"px;"),c=h.offsetWidth,h.style.width=c+"px",h.firstChild.textContent=h.firstChild.textContent.substring(3,h.firstChild.textContent.length-3),e[q].container.lastChild.setAttribute("style",
"font-family:'Courier New', Courier, 'Droid Sans Mono', Monospace; font-size: "+f+"px; width:"+(b-c)+"px; height:"+u+"px; position:absolute; left:"+c+"px; top:0px; border:2px groove white;")):(p.appendChild(e[q]),e[q].setAttribute("style","font-family:'Courier New', Courier, 'Droid Sans Mono', Monospace; font-size: "+f+"px; width:"+b+"px; height:"+u+"px; position:absolute; left:"+q*b+"px; top:0px; border:2px groove white;"))}this.displaceRegionNorth=l;this.displaceRegionWest=s;d.width-=n;d.height=
d.height-t-u;q=0;for(B=this.spaces.length;q<B;q++)this.spaces[q].init()};a.DescartesApp.prototype.update=function(){this.updateAuxiliaries();this.updateEvents();this.updateControls();this.updateSpaces()};a.DescartesApp.prototype.deactivateGraphiControls=function(){for(var a,b=0,d=this.controls.length;b<d;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,d=this.spaces.length;b<d;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()};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 d=a.lastIndexOf("."),d=-1===d?a.lenght:d;a.substring(0,d);b[a]=new Audio(a);var e=function(a){this.ready=1};b[a].addEventListener("canplaythrough",e);var h=function(c){!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",
e),b[a].addEventListener("load",e),b[a].addEventListener("error",h),b[a].load()):(console.log("El archivo '"+a+"' no puede ser reproducido"),this.errorload=1)};b[a].addEventListener("error",h);b[a].play();setTimeout(function(){b[a].pause()},15)}return b[a]}return new Audio};a.DescartesApp.prototype.getControlByCId=function(a){for(var b,d=0,e=this.controls.length;d<e;d++)if(b=this.controls[d],b.cID==a)return b;return{update:function(){},w:0}};a.DescartesApp.prototype.getControlById=function(a){for(var b,
d=0,e=this.controls.length;d<e;d++)if(b=this.controls[d],b.id==a)return b;return{update:function(){}}};a.DescartesApp.prototype.getSpaceByCId=function(a){for(var b,d=0,e=this.spaces.length;d<e;d++)if(b=this.spaces[d],b.cID==a)return b;return{update:function(){},w:0}};a.DescartesApp.prototype.getSpaceById=function(a){for(var b,d=0,e=this.spaces.length;d<e;d++)if(b=this.spaces[d],b.id==a)return b;return{update:function(){},w:0}};var k;a.DescartesApp.prototype.getState=function(){var a,b="",d=this.evaluator.variables,
f;for(f in d)d.hasOwnProperty(f)&&(a=d[f],"string"==typeof a&&(a="'"+a+"'"),void 0!=a&&("rnd"!=f&&"pi"!=f&&"e"!=f&&"Infinity"!=f&&"-Infinity"!=f&&"object"!=typeof a)&&(b=""!=b?b+"\n"+f+"="+a:f+"="+a));var d=this.evaluator.vectors,h;for(h in d)d.hasOwnProperty(h)&&(a=d[h],b=b+"\n"+h+"="+e(a));h=this.evaluator.matrices;for(var c in h)h.hasOwnProperty(c)&&(a=h[c],b=b+"\n"+c+"="+e(a));return b};a.DescartesApp.prototype.setState=function(a){a=a.split("\n");for(var b,d,e=0,h=a.length;e<h;e++)b=a[e].split("="),
2<=b.length&&(d=eval(b[1]),-1!=b[1].indexOf("[[")?(this.evaluator.matrices[b[0]]=d,this.evaluator.matrices[b[0]].rows=d.length,this.evaluator.matrices[b[0]].cols=d[0].length):-1!=b[1].indexOf("[")?(this.evaluator.vectors[b[0]]=d,this.evaluator.variables[b[0]+".long"]=d.length):this.evaluator.variables[b[0]]=d),this.update()};a.DescartesApp.prototype.getEvaluation=function(){for(var a=0,b=0,d="",e=0,h=this.controls.length;e<h;e++)"textfield"==this.controls[e].gui&&this.controls[e].evaluate&&(a++,b+=
this.controls[e].ok,this.controls[e].value=""==this.controls[e].value?"''":this.controls[e].value,d+=" \\n "+this.controls[e].id+"="+this.controls[e].value+"|"+this.controls[e].ok);return"questions="+a+" \\n correct="+b+" \\n wrong="+(a-b)+d};a.DescartesApp.prototype.showSolution=function(){for(var a=this.controls,b=0,d=a.length;b<d;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 e(){var a=document.getElementById("StyleDescartesApps");a&&a.parentNode.removeChild(a);a=document.createElement("style");a.id="StyleDescartesApps";a.type="text/css";a.setAttribute("rel","stylesheet");a.innerHTML="applet.DescartesJS {display:none;} applet {display:none;} ajs.DescartesJS {display:none;} ajs {display:none;}";document.head.appendChild(a)}function k(e){a.getFeatures();
if(a.hasCanvasSupport){e=document.getElementsByTagName("*");for(var b=[],d=0,f=e.length;d<f;d++)"DescartesAppContainer"==e[d].className&&b.push(e[d]);d=0;for(f=b.length;d<f;d++)b[d].parentNode.removeChild(b[d]);b=document.getElementsByTagName("applet");d=document.getElementsByTagName("ajs");e=[];for(var h=0,c=b.length;h<c;h++)f=b[h],(f.getAttribute("code").match("DescartesJS")||f.getAttribute("code").match("descinst.DescartesWeb2_0.class")||f.getAttribute("code").match("Descartes")||f.getAttribute("code").match("Arquimedes")||
f.getAttribute("code").match("Discurso"))&&e.push(f);h=0;for(c=d.length;h<c;h++)f=d[h],(f.getAttribute("code").match("DescartesJS")||f.getAttribute("code").match("descinst.DescartesWeb2_0.class")||f.getAttribute("code").match("Descartes")||f.getAttribute("code").match("Arquimedes")||f.getAttribute("code").match("Discurso"))&&e.push(f);b=0;for(d=e.length;b<d;b++)a.apps.push(new a.DescartesApp(e[b])),e[b].className="DescartesJS";window.addEventListener("resize",a.onResize);window.scrollTo(0,2)}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};(!window.hasOwnProperty("debugDescartesJS")||!debugDescartesJS)&&e();a.onResize=function(e){for(var b=0,d=a.apps.length;b<d;b++){e=a.apps[b].spaces;for(var f=0,h=e.length;f<h;f++)e[f].findOffset()}};a.receiveMessage=function(e){if(0<a.apps.length&&(e=e.data))if("set"===e.type)a.apps[0].evaluator.setVariable(e.name,
e.value);else if("update"===e.type)a.apps[0].update();else if("exec"===e.type){var b=a.apps[0].evaluator.getFunction(e.name),d=[];""!==e.value&&(d=e.value.toString().split(","));b&&b.apply(a.apps[0].evaluator,d)}};void 0==a.loadLib&&(a.loadLib=!0,window.addEventListener("load",k),window.addEventListener("message",a.receiveMessage));return a}(descartesJS||{});
