1if(document.all&&!window.setTimeout.isPolyfill){var __nativeST__=window.setTimeout;window.setTimeout=function(e,t){var a=Array.prototype.slice.call(arguments,2);return __nativeST__(e instanceof Function?function(){e.apply(null,a)}:e,t)},window.setTimeout.isPolyfill=!0}window.location.origin||(window.location.origin=window.location.protocol+"//"+window.location.hostname+(window.location.port?":"+window.location.port:""));var SupportDialog,originalXMLHttpRequest=window.XMLHttpRequest,AutoScript=function(e,t){var a,r=null,n=null,o=null,s=!1,l=!1,c=!1,u=null,d=null,p=!0;try{a=e.location.hostname}catch(e){a=null}var g=new Array;g.es_ES={access_from_pc:"Acceda desde un PC para realizar el trámite.",android_download_url:"<a href='https://play.google.com/store/apps/details?id=es.gob.afirma'><img alt='Descárgalo de Google Play' src='https://play.google.com/intl/en_us/badges/images/generic/es-play-badge-border.png'/></a>",checktime_warn:"Se ha detectado un desfase horario entre su sistema y el servidor. Se recomienda que se corrija antes de pulsar Aceptar para continuar.",checktime_err:"Se ha detectado un desfase horario entre su sistema y el servidor. Debe corregir la hora de su sistema y recargar esta página antes de continuar.",checktime_local_time:"Hora de su sistema",checktime_server_time:"Hora del servidor",close:"Cerrar",contact_admin:"Por favor, informe del error si el problema persiste: ",error_connecting_autofirma:"No es posible conectar con Autofirma debido a un problema de comunicación o de instalación del cliente. En caso de no tenerlo instalado, puede descargarse desde el siguiente enlace:",error_connecting_client:"No es posible conectar con el cliente de firma debido a un problema de comunicación o de instalación del cliente. En caso de no tenerlo instalado, puede descargarse desde el siguiente enlace:",error_connecting_service:"No se ha podido conectar con el servicio de la aplicación de firma. Es probable que no pueda completar firmas electrónicas desde esta página.",error_connecting_server_recovering:"No se pudo conectar con el servicio de la aplicación para recuperar el resultado de la operación.",firefox_reinstall_message:"Instalar o restaurar Autofirma requerirá cerrar el navegador y reiniciar el trámite.",install_client:"<br>Si lo tiene instalado o lo acaba de instalar, pulse el botón para reintentar la operación.",ios_download_url:"<a href='https://apps.apple.com/us/app/cliente-firma-movil/id627410001?itsct=apps_box_badge&itscg=30200'><img src='https://tools.applemediaservices.com/api/badges/download-on-the-app-store/black/es-es?size=250x83&releaseDate=1381536000' alt='Descarga en la App Store'></a>",loading:"Cargando",no_compatible_procedure:"Esta aplicación no permite firmar desde el navegador en dispositivos móviles.",pc_download_url:"<a target='_blank' href='https://firmaelectronica.gob.es/ciudadanos/descargas'>Portal de Firma Electrónica</a>",procedure_from_url:"Puede realizar el trámite desde la siguiente aplicación:",restore_installation:"Si lo tiene instalado, puede restaurar la instalación desde Autofirma en Herramientas -> Restaurar instalación",retry_operation:"Reintentar operación",timeout_receiving_sign:"No se ha podido conectar con el cliente de firma. Si no lo tiene instalado, puede descargarlo desde:",unsecure_context:"El contexto de ejecución no es seguro y no se usarán las funciones de cifrado avanzadas.",ok:"Aceptar",warning:"Advertencia:"},g.gl_ES={access_from_pc:"Acceso desde un PC para realizar o trámite.",android_download_url:"<a href='https://play.google.com/store/apps/details?id=es.gob.afirma'><img alt='Descárgao de Google Play' src='https://play.google.com/intl/en_us/badges/images/generic/es-play-badge-border.png'/></a>",checktime_warn:"Destectouse un desfase horario entre o seu sistema e o servidor. Recoméndase corrixilo antes de pulsar Aceptar para continuar.",checktime_err:"Destectouse un desfase horario entre o seu sistema e o servidor. Debe corrixir a hora do seu sistema antes de continuar.",checktime_local_time:"Hora do seu sistema",checktime_server_time:"Hora do servidor",close:"Pechar",contact_admin:"Por favor, informe do erro se o problema persiste: ",error_connecting_autofirma:"Non se puido conectar con Autofirma debido a un problema de comunicación ou de instalación do cliente. Se non o tes instalado, pódese descargar dende a seguinte ligazón:",error_connecting_client:"Non se puido conectar ao cliente da sinatura debido a un problema de comunicación ou de instalación do cliente. Se non o tes instalado, pódese descargar dende a seguinte ligazón:",error_connecting_service:"Non se puido conectar ao servizo da aplicación de sinatura. É posible que non poida completar sinaturas electrónicas desde esta páxina.",error_connecting_server_recovering:"Non se puido conectar ao servizo de aplicación para recuperar o resultado da operación",firefox_reinstall_message:"Será necesario instalar ou restaurar Autofirma pecha o navegador e reinicia o proceso.",install_client:"Se o tes instalado ou o acabas de instalar, preme o botón para tentar de novo a operación.",ios_download_url:"<a href='https://apps.apple.com/us/app/cliente-firma-movil/id627410001?itsct=apps_box_badge&itscg=30200'><img src='https://tools.applemediaservices.com/api/badges/download-on-the-app-store/black/es-es?size=250x83&releaseDate=1381536000' alt='Descarga na App Store'></a>",loading:"Cargando",no_compatible_procedure:"Esta aplicación non permite asinar desde o navegador en dispositivos móbiles.",pc_download_url:"<a target='_blank' href='https://firmaelectronica.gob.es/gl/ciudadanos/descargas'>Portal de Sinatura Electrónica</a>",procedure_from_url:"Podes realizar o trámite dende a seguinte aplicación:",restore_installation:"Se o tes instalado, podes restaurar a instalación desde Autofirma en Ferramentas -> Restaurar instalación.",retry_operation:"Reintento a operación",timeout_receiving_sign:"Non se puido conectar co cliente que asina. Se non o tes instalado, podes descargalo desde:",unsecure_context:"O contexto de execución non é seguro e non se usarán as funcións de cifrado avanzadas.",ok:"Aceptar",warning:"Aviso:"},g.va_ES={access_from_pc:"Accedisca des d'un PC per a realitzar el tràmit.",android_download_url:"<a href='https://play.google.com/store/apps/details?id=es.gob.afirma'><img alt='Descarrega-ho de Google Play' src='https://play.google.com/intl/en_us/badges/images/generic/es-play-badge-border.png' style='width: 140px;'/></a>",checktime_warn:"S'ha detectat un desfasament horari entre el seu sistema i el servidor. Es recomana que es corregisca abans de polsar Acceptar per a continuar.",checktime_err:"S'ha detectat un desfasament horari entre el seu sistema i el servidor. Ha de corregir l'hora del seu sistema i recarregar esta pàgina abans de continuar.",checktime_local_time:"Hora del seu sistema",checktime_server_time:"Hora del servidor",close:"Tancar",contact_admin:"Per favor, informe de l'error si el problema persisteix: ",error_connecting_autofirma:"No és possible connectar amb Autofirma a causa d'un problema de comunicació o d'instal·lació del client. En cas de no tindre-ho instal·lat, pot descarregar-se des del següent enllaç:",error_connecting_client:"No és possible connectar amb el client de signatura a causa d'un problema de comunicació o d'instal·lació del client. En cas de no tindre-ho instal·lat, pot descarregar-se des del següent enllaç:",error_connecting_service:"No s'ha pogut connectar amb el servei de l'aplicació de signatura. és probable que no puga completar signatures electròniques des d'esta pàgina.",error_connecting_server_recovering:"No es va poder connectar amb el servei de l'aplicació per a recuperar el resultat de l'operació.",firefox_reinstall_message:"Instal·lar o restaurar Autofirma requerirà tancar el navegador i reiniciar el trà
1mit.",install_client:"<br>Si el té instal·lat o l'acaba d'instal·lar, polse el botó per a reintentar l'operació.",ios_download_url:"<a href='https://apps.apple.com/us/app/cliente-firma-movil/id627410001?itsct=apps_box_badge&itscg=30200' style='display: inline-block; overflow: hidden; border-radius: 13px; width: 140px; height: 40px;'><img src='https://tools.applemediaservices.com/api/badges/download-on-the-app-store/black/es-es?size=250x83&releaseDate=1381536000' alt='Descàrrega en l'App Store' style='border-radius: 13px; width: 140px; height: 40px;'></a>",loading:"Carregant",no_compatible_procedure:"Esta aplicació no permet signar des del navegador en dispositius mòbils. ",pc_download_url:"<a target='_blank' href='https://firmaelectronica.gob.es/va/ciudadanos/descargas'>Portal de Signatura Electrònica</a>",procedure_from_url:"Pot realitzar el tràmit des de la següent aplicació:",restore_installation:"Si el té instal·lat, pot restaurar la
1instal·lació des d'Autofirma en Eines -> Restaurar instal·lació",retry_operation:"Reintentar operació",timeout_receiving_sign:"No s'ha pogut connectar amb el client de signatura. Si no el té instal·lat, pot descarregar-ho des de:",unsecure_context:"El context d'execució no és segur i no s'usaran les funcions de xifrat avançades.",ok:"Acceptar",warning:"Advertiment:"},g.ca_ES={access_from_pc:"Accedeixi des d'un PC per a realitzar el tràmit.",android_download_url:"<a href='https://play.google.com/store/apps/details?id=es.gob.afirma'><img alt='Descarrega-ho de Google Play' src='https://play.google.com/intl/en_us/badges/images/generic/es-play-badge-border.png' style='width: 140px;'/></a>",checktime_warn:"S'ha detectat un desfasament horari entre el seu sistema i el servidor. Es recomana que es corregeixi abans de prémer Acceptar per a continuar.",checktime_err:"S'ha detectat un desfasament horari entre el seu sistema i el servidor. Ha de corregir l'hora del seu sistema i recarregar aquesta pàgina abans de continuar.",checktime_local_time:"Hora del seu sistema",checktime_server_time:"Hora del servidor",close:"Tancar",contact_admin:"Si us plau, informe de l'error si el problema persisteix: ",error_connecting_autofirma:"No és possible connectar amb Autofirma a causa d'un problema de comunicació o d'instal·lació del client. En cas de no tenir-ho instal·lat, pot descarregar-se des del següent enllaç:",error_connecting_client:"No és possible connectar amb el client de signatura a causa d'un problema de comunicació o d'instal·lació del client. En cas de no tenir-ho instal·lat, pot descarregar-se des del següent enllaç:",error_connecting_service:"No s'ha pogut connectar amb el servei de l'aplicació de signatura. és probable que no pugui completar signatures electròniques des d'aquesta pàgina.",error_connecting_server_recovering:"No es va poder connectar amb el servei de l'aplicació per a recuperar el resultat de l'operació.",firefox_reinstall_message:"Instal·lar o restaurar Autofirma requerirà tancar el navegador i reiniciar el tràmit.",install_client:"<br>Si el té instal·lat o l'acaba d'instal·lar, premi el botó per a reintentar l'operació.",ios_download_url:"<a href='https://apps.apple.com/us/app/cliente-firma-movil/id627410001?itsct=apps_box_badge&itscg=30200' style='display: inline-block; overflow: hidden; border-radius: 13px; width: 140px; height: 40px;'><img src='https://tools.applemediaservices.com/api/badges/download-on-the-app-store/black/es-es?size=250x83&releaseDate=1381536000' alt='Descàrrega en l'App Store' style='border-radius: 13px; width: 140px; height: 40px;'></a>",loading:"Carregant",no_compatible_procedure:"Aquesta aplicació no permet signar des del navegador en dispositius mòbils. ",pc_download_url:"<a target='_blank' href='https://firmaelectronica.gob.es/ca/ciudadanos/descargas'>Portal de Signatura Electrònica</a>",procedure_from_url:"Pot realitzar el tràmit des de la següent aplicació:",restore_installation:"Si el té instal·lat, pot restaurar la instal·lació des d'Autofirma en Eines -> Restaurar instal·lació",retry_operation:"Reintentar operació",timeout_receiving_sign:"No s'ha pogut connectar amb el client de signatura. Si no el té instal·lat, pot descarregar-ho des de:",unsecure_context:"El context d'execució no és segur i no s'usaran les funcions de xifrat avançades.",ok:"Acceptar",warning:"Advertiment:"},g.eu_ES={access_from_pc:"Sartu PC batetik tramitea egiteko. ",android_download_url:"<a href='https://play.google.com/store/apps/details?id=es.gob.afirma'><img alt='Deskargatu Google Playtik' src='https://play.google.com/intl/en_us/badges/images/generic/es-play-badge-border.png' style='width: 140px;'/></a>",checktime_warn:"Zure sistemaren eta zerbitzariaren arteko ordu-desfasea detektatu da. Jarraitzeko, Ados sakatu aurretik zuzentzea gomendatzen da. ",checktime_err:"Zure sistemaren eta zerbitzariaren artean ordu-desfase bat detektatu da. Zure sistemaren ordua zuzendu behar duzu, eta orri hau kargatu jarraitu aurretik. ",checktime_local_time:"Zure sistemaren ordua",checktime_server_time:"Zerbitzariaren ordua",close:"Itxi",contact_admin:"Mesedez, eman akatsaren berri, arazoak bere horretan jarraitzen badu: ",error_connecting_autofirma:"Ezin da Autofirma-rekin konektatu, bezeroaren komunikazio- edo instalazio-arazo bat dela eta. Instalatuta ez baduzu, esteka honetatik deskarga dezakezu:",error_connecting_client:"Ezin da bezeroarekin konektatu, komunikazio- edo instalazio-arazo bat dela eta. Instalatuta ez baduzu, esteka honetatik deskarga dezakezu:",error_connecting_service:"Ezin
1izan da sinadura-aplikazioaren zerbitzuarekin konektatu. Litekeena da orrialde honetatik sinadura elektronikorik ezin osatzea. ",error_connecting_server_recovering:"Ezin izan da aplikazioaren zerbitzuarekin konektatu eragiketaren emaitza berreskuratzeko. ",firefox_reinstall_message:"Autofirma instalatu edo berrezartzeko, nabigatzailea itxi eta izapidea berrabiarazi behar da. ",install_client:"<br>Instalatuta baduzu edo instalatu berri baduzu, sakatu botoia eragiketa berriro saiatzeko. ",ios_download_url:"<a href='https://apps.apple.com/us/app/cliente-firma-movil/id627410001?itsct=apps_box_badge&itscg=30200' style='display: inline-block; overflow: hidden; border-radius: 13px; width: 140px; height: 40px;'><img src='https://tools.applemediaservices.com/api/badges/download-on-the-app-store/black/es-es?size=250x83&releaseDate=1381536000' alt='Deskargatu App Store-n' style='border-radius: 13px'; height: 140px></40px>",loading:"Kargatzen",no_compatible_procedure:"Aplikazio honek ez du uzten nabigatzailetik gailu mugikorretan sinatzen. ",pc_download_url:"<a target='_blank' href='https://firmaelectronica.gob.es/eu/ciudadanos/descargas'>Sinadura elektronikoaren ataria</a>",procedure_from_url:"Tramitea aplikazio honetatik egin dezakezu:",restore_installation:"Instalatuta baduzu, instalazioa Autofirma-tik berrezar dezakezu Tresnak aukeran -> Instalazioa leheneratu",retry_operation:"Saiatu berriro",timeout_receiving_sign:"Ezin izan da konektatu sinadura-bezeroarekin. Instalatuta ez baduzu, hemendik deskarga dezakezu:",unsecure_context:"Exekuzio-testuingurua ez da segurua eta ez dira enkriptatze-funtzio aurreratuak erabiliko.",ok:"Onartu",warning:"Oharra:"},g.en_US={access_from_pc:"Access from a PC to perform the procedure. ",android_download_url:"<a href='https://play.google.com/store/apps/details?id=es.gob.afirma'><img alt='Download Google Play' src='https://play.google.com/intl/en_us/badges/images/generic/es-play-badge-border.png' style='width: 140px;'/></a>",checktime_warn:"A time lag between your system and the server has been detected. It is recommended that it be corrected before pressing OK to continue. ",checktime_err:"A time lag between your system and the server has been detected. You must correct the time of your system and recharge this page before continuing. ",checktime_local_time:"Time of your system",checktime_server_time:"Server time",close:"Close",contact_admin:"Please report the error if the problem persists:",error_connecting_autofirma:"It is not possible to connect with Autofirma due to a communication or installation problem of the client. If you do not have it installed, you can download it from the following link:",error_connecting_client:"It is not possible to connect with the signature client due to a communication or installation problem of the client. If you do not have it installed, you can download it from the following link:",error_connecting_service:"It has not been possible to connect with the service of the signature application. You may not be able to complete electronic signatures from this page. ",error_connecting_server_recovering:"It was not possible to connect with the application service to recover the result of the operation. ",firefox_reinstall_message:"Installing or restoring Autofirma will require closing the browser and restarting the process. ",install_client:"<br>If you have it installed or just installed, press the button to retry the operation. ",ios_download_url:"<a href='https://apps.apple.com/us/app/cliente-firma-movil/id627410001?itsct=apps_box_badge&itscg=30200' style='display: inline-block; overflow: hidden; border-radius: 13px; width: 140px; height: 40px;'><img src='https://tools.applemediaservices.com/api/badges/download-on-the-app-store/black/es-es?size=250x83&releaseDate=1381536000' alt='Download from App Store' style='border-radius: 13px; width: 140px; height: 40px;'></a>",loading:"Loading",no_compatible_procedure:"This application does not allow you to sign from your browser on mobile devices. ",pc_download_url:"<a target='_blank' href='https://firmaelectronica.gob.es/en/ciudadanos/descargas'>Electronic Signature Portal</a>",procedure_from_url:"You can complete the procedure from the following application:",restore_installation:"If you have it installed, you can restore the installation from Autofirma on Tools -> Restore Installation",retry_operation:"Retry operation",timeout_receiving_sign:"It was not possible to connect with the signature client. If you don't have it installed, you can download it from:",unsecure_context:"The execution context is not secure and advanced encryption functions will not be used.",ok:"Ok",warning:"Warning:"};var f,m,h,v,b,A,y=g.es_ES,x=y,_="MOZ_UNI",S="CT_NO",E="CT_RECOMMENDED",w="CT_OBLIGATORY",C=!1,k=null,O=!1,T=!1,R=!0,I=!1,B=0;function N(e){return null!=e&&e.length>8&&("http:"==e.substring(0,5)||"https:"==e.substring(0,6))}
1var D=null,L=null,j=null,z={code:"AS200007",message:"Error al cifrar los datos para el envio al cliente de firma"},P={code:"AS200008",message:"Error al descifrar los datos recibidos del cliente de firma"},M={code:"AS220005",message:"Su navegador no permite preprocesar los datos que desea tratar"},U={code:"AS220006",message:"Respuesta no valida"},F={code:"AS220007",message:"Su navegador no permite obtener el resultado de la operacion"},q={code:"AS300302",message:"Ocurrio un error al enviar los datos al servicio intermedio para la comunicacion con la aplicacion nativa"},H={code:"AS400003",message:"No se pudo conectar con el servidor remoto"},K={code:"AS420002",message:"Autofirma se ha cerrado o ha cerrado el websocket de comunicacion"},J={code:"AS420503",message:"Se ha perdido la conexion con la aplicacion Autofirma"},X={code:"AS420504",message:"Ocurrio un error de red en la llamada al servicio de firma"},W={code:"AS420505",message:"Ocurrio un error de red en la llamada al servicio de firma"},V={code:"AS500001",message:"Operacion cancelada por el usuario"},Y={code:"AS500008",message:"La operacion de carga de fichero no esta disponible por servidor intermedio"},G={code:"AS500009",message:"La operacion de carga de multiples ficheros no esta disponible por servidor intermedio"},Q={code:"AS500010",message:"El metodo JavaScript no se encuentra operativo"},Z={code:"AS600101",message:"No se ha indicado la direccion del servlet para la recuperacion de datos"},$={code:"AS600102",message:"No se ha indicado la direccion del servlet para el guardado de datos"},ee={code:"AS620014",message:"La URL de invocacion al servicio de firma es demasiado larga"},te={code:"AS620015",message:"Ocurrio un error al enviar los datos a la aplicacion nativa"},ae={code:"AS620017",message:"Ha ocurrido un error al intentar invocar a la aplicacion nativa mediante websocket"},re={code:"AS620018",message:"El fichero que se pretende firmar o guardar excede de la memoria disponible para aplicacion"},ne={code:"AS620019",message:"Error desconocido"},oe={code:"AS620020",message:"Ha ocurrido un error al intentar invocar a la aplicacion nativa mediante socket"},ie={code:"AS620021",message:"Problema de memoria en servidor"},se={code:"AS620022",message:"Error desconocido"},le={code:"AS620023",message:"Ha ocurrido un error al intentar invocar a la aplicacion nativa mediante servidor intermedio"},ce={code:"AS620024",message:"El tiempo para la recepcion de la firma por la pagina web ha expirado"},ue={code:"AS620025",message:"Error al conectar con el servicio de la aplicacion para recuperar el resultado de la operacion"};function de(){var t=null;if("undefined"!=typeof XMLHttpRequest)t="undefined"!=typeof Sarissa&&Sarissa.originalXMLHttpRequest?new Sarissa.originalXMLHttpRequest:new originalXMLHttpRequest;else if(void 0!==e.ActiveXObject)try{t=new ActiveXObject("Msxml2.XMLHTTP.4.0")}catch(e){try{t=new ActiveXObject("MSXML2.XMLHTTP")}catch(e){try{t=new ActiveXObject("Microsoft.XMLHTTP")}catch(e){t=null}}}return t}var pe=function(e,t,a){if(e&&e!=S&&!(t&&t<=0)){t||(t=3e5);try{var r;r=a||document.URL+"/"+Math.random();var n=de();n.open("GET",r,!1),n.send();var o=new Date,i=new Date(n.getResponseHeader("Date"));if(null==i||0==i.getTime())return;console.log("Hora cliente: "+o),console.log("Hora servidor: "+i),Math.abs(o.getTime()-i.getTime())>t&&(e==E?alert(x.checktime_warn+"\n"+x.checktime_local_time+": "+o.toLocaleString()+"\n"+x.checktime_server_time+": "+i.toLocaleString()):e==w&&(s=!0,alert(x.checktime_err+"\n"+x.checktime_local_time+": "+o.toLocaleString()+"\n"+x.checktime_server_time+": "+i.toLocaleString())))}catch(e){return void console.log("Error en la obtencion de la hora del servidor: "+e)}}},ge=function(e){l&&!e&&(c=!0),l=e},fe=function(e){x=e&&g[e]?g[e]:y},me=function(e){x=e||y},he=function(e,t,a){if(!document.getElementById("afirmaSupportDialog")){var r=de();if(!r)throw new Error("java.lang.Exception","Su navegador no permite preprocesar los datos que desea tratar");var n=++B;r.open("GET",e+"?op=check",!0),r.setRequestHeader("Content-type","application/x-www-form-urlencoded"),r.onreadystatechange=function(){4==r.readyState&&(200==r.status?(T=!1,R=!0,console.log("Conexion correcta con el servicio de almacenamiento")):n==B&&(T=!0,a?(R=!1,xe.showErrorDialog(2)):(R=!0,xe.showErrorDialog(4))))},r.send("");var o=de();o.open("GET",t+"?op=check",!0),o.setRequestHeader("Content-type","application/x-www-form-urlencoded"),o.onreadystatechange=function(){4==o.readyState&&(200==o.status?(T=!1,R=!0,console.log("Conexion correcta con el servicio de recuperacion")):n==B&&(T=!0,a?(R=!1,xe.showErrorDialog(2)):(R=!0,xe.showErrorDialog(4))))},o.send(""),I=!0}};function ve(e){if(ye.isChrome()||ye.isIOS()||ye.isAndroid()&&ye.isFirefox())document.location=e;else{if(null!=document.getElementById("iframeAfirma"))try{var t=document.getElementById("iframeAfirma");t.outerHTML="",delete t}catch(e){}navigator.msLaunchUri?navigator.msLaunchUri(e,null,function(){wrongInstallation=!0}):function(e){var t=document.createElement("iframe"),a=document.createAttribute("id");a.value="iframeAfirma",t.setAttributeNode(a);var r=document.createAttribute("src");r.value=e,t.setAttributeNode(r);var n=document.createAttribute("height");n.value=1,t.setAttributeNode(n);var o=document.createAttribute("width");
1if(o.value=1,t.setAttributeNode(o),!ye.isInternetExplorer7orLower()){var i=document.createAttribute("style");i.value="display: none;",t.setAttributeNode(i)}document.body.appendChild(t)}(e)}}function be(a,i){var l;xe.isEnabled()&&((l=document.createElement("style")).innerText="\t\t /* Backdrop que siempre ocupa todo el viewport y centra el modal */\t\t .afirma-modal-backdrop {\t\t position: fixed;\t\t top: 0;\t\t left: 0;\t\t width: 100vw;\t\t height: 100vh;\t\t background: rgba(0, 0, 0, 0.6);\t\t z-index: 9990;\t\t display: flex;\t\t align-items: center;\t\t justify-content: center;\t\t box-sizing: border-box;\t\t }\t\t /* Contenedor principal del dialogo */\t\t .afirma-modal-container {\t\t background-color: #ffffff;\t\t border-radius: 8px;\t\t padding: 20px;\t\t box-shadow: 0 0px 15px 2px rgb(0 0 0 / 50%);\t\t width: 90%;\t\t max-width: 500px;\t\t max-height: 90vh;\t\t overflow-y: auto;\t\t box-sizing: border-box;\t\t display: flex;\t\t flex-direction: column;\t\t align-items: center;\t\t text-align: center;\t\t }\t\t /* Ajuste para pantallas mas grandes */\t\t @media (min-width: 600px) {\t\t .afirma-modal-container {\t\t width: 500px;\t\t }\t\t /* En pantallas grandes, botones en columna */\t\t .afirma-modal-button-container {\t\t display: flex;\t\t flex-direction: row !important;\t\t justify-content: flex-end;\t\t }\t\t\t\t\t\t\t .afirma-modal-button-container button {\t\t margin: 0 0.5rem 0 0;\t\t }\t\t }\t\t /* Panel de contenido: logo + texto */\t\t .afirma-modal-message-panel {\t\t display: flex;\t\t flex-direction: column;\t\t align-items: center;\t\t }\t\t /* Logo (reutiliza la clase existente) */\t\t .afirma-modal-logo {\t\t width: 15%;\t\t min-width: 64px;\t\t height: 64px;\t\t background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAABg2lDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AcxV9TpaJVBzuIOGSoTnZRkY6likWwUNoKrTqYXPoFTRqSFBdHwbXg4Mdi1cHFWVcHV0EQ/ABxF5wUXaTE/yWFFjEeHPfj3b3H3TtAaFaZavbEAFWzjHQiLubyq2LgFQL8GMAQohIz9WRmMQvP8XUPH1/vIjzL+9yfY1ApmAzwicQxphsW8Qbx3Kalc94nDrGypBCfE08ZdEHiR67LLr9xLjks8MyQkU3PE4eIxVIXy13MyoZKPEscVlSN8oWcywrnLc5qtc7a9+QvDBa0lQzXaY4jgSUkkYIIGXVUUIWFCK0aKSbStB/38I85/hS5ZHJVwMixgBpUSI4f/A9+d2sWZ6bdpGAc6H2x7Y8JILALtBq2/X1s260TwP8MXGkdf60JRD9Jb3S08BEwvA1cXHc0eQ+43AFGn3TJkBzJT1MoFoH3M/qmPDByC/Svub2193H6AGSpq+Ub4OAQmCxR9rrHu/u6e/v3TLu/H5arcrVRvvChAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH6QIDCxUWWt6gwAAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAR1SURBVHja7ZtNiFtVFMd/5+XVacGCHyuno9jaDwcZpZOXmY5m4hTGliKIFoqKFnQhKgjWRS0IikhFcCVYETeKDCjYhQpSEXRC5sXUkgxdVAXRWnShCxdarRTG5B0Xk5E2ZJLcmzd3XjLeZfJezrm/e8+5/3PeC6zxIavtQCHNiCc8dJlTA7yc/ZK/XNj3VxtAymNYlSOXfqYXKQKfuLDvJXIXCtOujK86gEibAtizZgBI8zw0XMxwS18CKIyxuRgwUxhnG4Bo80Qcwf19CUCURxUe9qpcU/egKQCJeKDvACiI6OKRp4LWV1qWiY1tcxnu7CsAxQx7gS0NO0Ja7Jan+isElKcNxdi9hQzX9wWAUpqbgb2NK99qBwB+SnmmLwDUPJ6/dLX/ywFeazmu8GRpgk09DSAcYzva/FiT9vXI+lqVZ3t7B0S8AqSWWWLpIHc8vqQbeg5AMc1uYL+hEmwcA16NN3oOQH4KX4XXjGuB5uOucIz7egrAur85DNzaxgMxCKVjp8a4ticAFAN2qPKCZTG03BhcUN5MPID8FL7C28D6DmoDs66UciAMOJhoAP4FjgK3t7omVdcBqFVb7q1wlHQiAcyluRs43FYY1Sce2fUlN+BxPI58ECuAQsBOEd43+V3xrBuzmxcijp/YykAiAOR3caO32MjcaBjT3XSmd2+8ivc+OLCMyHIFID/OkF/lc2Cw03uWcoB035rff9053lHLuXQNoLiTQb/KLHCTlUrWWJ5NHAzT7HMOID/OkKaYRex1usT0cMbzGHYKoJBmxK9RAnZ0mYZX9emUFYAwYDolhNB9t0biCQE0qusKU81iae+EwjqSNdRlCKRi81rjOYmWOkyuAERd+ltFuVh3/CzwSwyx3BsAVHhXlRvuqPA1QK7Cx5MVNqkwjfJ9v++AF3NlHsnN82vjF7kyX7DAuMAZS4+cAjA3JoTZCi+1umTyDL8jPGgDWJMeAl7EUenAyWyZb4CC8e8nPARq5893PimFT5O+A0yN6b4fWOjYKTV/P0jVLi/ZARBqpoLr5ARXG3h1ZaKlMGq+3apV7jFYzT0WE0l2EpSIQ/mp9tI7DJgCi5eknCZBsYg34bbUBV7XFuVvaZStwAwWJbJbIWSZcASeKAbMzqUZvWziE2yYy/BY1eMrYMgyKzutBrupBaZEmA8DfgR+AgZq/zAipr3EmJSgb7kD4qjit9DwukxXfQVxewxGJG30WDm8Et0QdwBE7YytqKBxWQ1qAkPA6TGoCQwBnIYAa3wHJDEJeiS9I7TSI0q2EqwpPCfCHx3RjUiJcMxkgWxDwLfNAYbWZnMVXjW5IQw4BGxPpA4w7b6oUrGgbHSP056gqe72PAsAEfNGlytVlzpADSdjDEA9MwDgEIBhEvwtO8/Ppgau8DhtYsdtNWjgmMJJGwO7TvEn8K1BfeJwBxjQFqXUxeleMrBTcweg81NARfioixr/w46FhmcHwE4HKDO6+IZIO3FydrLMd7bzz5b5LAw4ItT/Ytfap3P8P8zHv6ZaYpBH636jAAAAAElFTkSuQmCC);\t\t background-repeat: no-repeat;\t\t background-position: center;\t\t background-size: contain;\t\t margin-bottom: 1rem;\t\t }\t\t .afirma-modal-close-button {\t\t background-color: #878787;\t\t color: #fff;\t\t flex: 1;\t\t margin-top: 0.4rem;\t\t padding: 0.5rem 1rem;\t\t border: none;\t\t border-radius: 4px;\t\t font-family: Helvetica, Arial, sans-serif;\t\t font-size: 16px;\t\t cursor: pointer;\t\t box-sizing: border-box;\t\t }\t\t .afirma-modal-action-button {\t\t background-color: #c33400;\t\t color: #fff;\t\t flex: 1;\t\t margin-top: 0.4rem;\t\t padding: 0.5rem 1rem;\t\t border: none;\t\t border-radius: 4px;\t\t font-family: Helvetica, Arial, sans-serif;\t\t font-size: 16px;\t\t cursor: pointer;\t\t box-sizing: border-box;\t\t }\t\t /* Texto del mensaje */\t\t .afirma-modal-loading-message, .afirma-modal-error-message {\t\t margin-top: 10px;\t\t font-family: Helvetica, Arial, sans-serif;\t\t font-size: 16px;\t\t color: #333;\t\t }\t\t\t\t\t\t .afirma-modal-loading-message a, .afirma-modal-error-message a {\t\t color: #c33400;\t\t line-height: 1.5rem;\t\t }\t\t\t\t\t\t .afirma-modal-loading-message a img, .afirma-modal-error-message a img {\t\t margin-top: 1rem;\t\t width: 140px;\t\t max-width: 140px;\t\t }\t\t /* Panel de botones: por defecto en fila (pantallas pequenas) */\t\t .afirma-modal-button-container {\t\t display: flex;\t\t flex-direction: column;\t\t justify-content: flex-end;\t\t width: 100%;\t\t margin-top: 20px;\t\t box-sizing: border-box;\t\t }\t\t /* Elimina margen derecho del ultimo boton */\t\t .afirma-modal-button-container button:last-child {\t\t margin-right: 0;\t\t }
1\t\t /* Spinner para indicar carga */\t\t .afirma-modal-spinner {\t\t border: 4px solid rgba(0, 0, 0, 0.1);\t\t border-top-color: #c33400;\t\t width: 24px;\t\t height: 24px;\t\t border-radius: 50%;\t\t animation: spin 1s linear infinite;\t\t margin-top: 10px;\t\t }\t\t @keyframes spin {\t\t to { transform: rotate(360deg); }\t\t }\t\t ",document.head.appendChild(l)),s?console&&console.log&&console.log("Se ha detectado un desfase grave entre la hora del sistema y la del servidor. Se cancela la carga del cliente de firma"):(C||ye.isIOS()||ye.isAndroid()?(r=new we(a,e,t),(n||o)&&r.setServlets(n,o),I||Ae(a)):!("WebSocket"in e)&&!("MozWebSocket"in e)||ye.isInternetExplorer()||ye.isFirefox60orLower()?ye.isInternetExplorer10orLower()||ye.isSafari10()?(r=new we(a,e,t),(n||o)&&r.setServlets(n,o),I||Ae(a)):(r=new Ee(a,e,t),f&&r.setPortRange(f,m)):(r=new Se(e,t),f&&r.setPortRange(f,m)),i||(i=ye.isFirefox()?_:null),r.setKeyStore(i))}function Ae(t){var a,r;null==n||null==o?(t?(a=t+"/afirma-signature-storage/StorageService",r=t+"/afirma-signature-retriever/RetrieveService"):(a=e.location.origin+"/afirma-signature-storage/StorageService",r=e.location.origin+"/afirma-signature-retriever/RetrieveService"),ye.isIOS()||ye.isAndroid()?he(a,r,!0):he(a,r,!1)):he(n,o,!1)}var ye={isAndroid:function(){return-1!=navigator.userAgent.toUpperCase().indexOf("ANDROID")||-1!=navigator.appVersion.toUpperCase().indexOf("ANDROID")||-1!=navigator.userAgent.toUpperCase().indexOf("SILK/")||-1!=navigator.userAgent.toUpperCase().indexOf("KFJWI")||-1!=navigator.userAgent.toUpperCase().indexOf("KFJWA")||-1!=navigator.userAgent.toUpperCase().indexOf("KFTT")||-1!=navigator.userAgent.toUpperCase().indexOf("KFOT")||-1!=navigator.userAgent.toUpperCase().indexOf("KINDLE FIRE")},isIOS:function(){return-1!=navigator.userAgent.toUpperCase().indexOf("IPAD")||-1!=navigator.userAgent.toUpperCase().indexOf("IPOD")||-1!=navigator.userAgent.toUpperCase().indexOf("IPHONE")||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1},isInternetExplorer:function(){return!!navigator.userAgent.match(/MSIE/)||!(!navigator.userAgent.match(/Trident/)||!navigator.userAgent.match(/rv:11/))||!!navigator.userAgent.match(/Trident.*rv[ :]*11\./)},isInternetExplorer10orLower:function(){return!!navigator.userAgent.match(/MSIE/)},isInternetExplorer7orLower:function(){var e=navigator.userAgent.toLowerCase();return 7>=(-1!=e.indexOf("msie"))&&parseInt(e.split("msie")[1])},isSafari10:function(){var e,t,a;return navigator.sayswho=(a=(t=navigator.userAgent).match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[],/trident/i.test(a[1])?"IE "+((e=/\brv[ :]+(\d+)/g.exec(t)||[])[1]||""):"Chrome"===a[1]&&null!=(e=t.match(/\b(OPR|Edge)\/(\d+)/))?e.slice(1).join(" ").replace("OPR","Opera"):(a=a[2]?[a[1],a[2]]:[navigator.appName,navigator.appVersion,"-?"],null!=(e=t.match(/version\/(\d+)/i))&&a.splice(1,1,e[1]),a.join(" "))),"Safari 10"==navigator.sayswho},isFirefox:function(){return-1!=navigator.userAgent.toUpperCase().indexOf("FIREFOX")},isFirefox60orLower:function(){var e,t,a;navigator.sayswho=(a=(t=navigator.userAgent).match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[],/trident/i.test(a[1])?"IE "+((e=/\brv[ :]+(\d+)/g.exec(t)||[])[1]||""):"Chrome"===a[1]&&null!=(e=t.match(/\b(OPR|Edge)\/(\d+)/))?e.slice(1).join(" ").replace("OPR","Opera"):(a=a[2]?[a[1],a[2]]:[navigator.appName,navigator.appVersion,"-?"],null!=(e=t.match(/version\/(\d+)/i))&&a.splice(1,1,e[1]),a.join(" ")));var r=navigator.sayswho;return-1!=r.indexOf("Firefox")&&60>=parseInt(r.split("Firefox")[1])},isChrome:function(){return-1!=navigator.userAgent.toUpperCase().indexOf("CHROME/")||-1!=navigator.userAgent.toUpperCase().indexOf("CHROMIUM")}},xe=function(){var e=x.pc_download_url,t=x.android_download_url,a=x.ios_download_url,r="afirma-modal-backdrop",n="afirma-modal-container",o="afirma-modal-message-panel",i="afirma-modal-loading-message",s="afirma-modal-error-message",l="afirma-modal-button-container",c="afirma-modal-action-button",u="afirma-modal-close-button",d="afirma-modal-logo",p="afirma-modal-spinner",g="afirma-modal-warning",f=null,m=null,h=null,v=!0,b=!0,A=!0,y="<span id='afirmaWarningText' class='"+g+"'>"+x.warning+"</span> ";function _(e,t,a,g,f){if(!xe.isEnabled())return!1;S();var m=document.createElement("div");m.setAttribute("id","afirmaSupportDialog"),m.setAttribute("class",r);var h=document.createElement("div");h.setAttribute("id","afirmaChildDiv"),h.setAttribute("class",n),h.setAttribute("role","dialog"),h.setAttribute("aria-modal","true"),h.setAttribute("aria-label","Autofirma");var v=document.createElement("div");v.setAttribute("id","afirmaMessagePanel"),v.setAttribute("class",o);var y=document.createElement("div");y.setAttribute("id","afirmaImgDiv"),y.setAttribute("class",d);var x=!0;null==t&&null==g||(x=!1);var _=document.createElement("div"),E=document.createElement("span");x?E.setAttribute("class",i):E.setAttribute("class",s),E.setAttribute("id","afirmaSupportDialogLabel"),E.innerHTML=e,_.appendChild(E),v.appendChild(y),v.appendChild(_);var w=document.createElement("div");if(w.setAttribute("class",l),null!=t){var C=document.createElement("button");C.setAttribute("id","afirmaActionButton"),C.setAttribute("class",c),C.textContent=t,C.addEventListener("click",function(){S(),a&&a()}),w.appendChild(C),x=!1}if(null!=g){var k=document.createElement("button");k.setAttribute("id","afirmaCloseButton"),k.setAttribute("class",u),k.textContent=g,k.addEventListener("click",function(){S(),f&&f()}),w.appendChild(k),x=!1}if(x){if(!b)return!1;var O=document.createElement("div");O.setAttribute("class",p),v.appendChild(O)}else if(!A)return!1;
1h.appendChild(v),x||h.appendChild(w),m.appendChild(h),document.body.appendChild(m),Array.from(document.body.children).forEach(function(e){e!==m&&e.setAttribute("aria-hidden","true")}),document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden";var T=document.activeElement;m._previousActive=T,h.setAttribute("tabindex","-1"),h.focus();var R=function(e){"Escape"===e.key&&(S(),f&&f())};return document.addEventListener("keydown",R),m._escListener=R,!0}function S(){var e=document.getElementById("afirmaSupportDialog");if(e){Array.from(document.body.children).forEach(function(t){t!==e&&t.removeAttribute("aria-hidden")}),document.body.style.overflow="",document.documentElement.style.overflow="";var t=e._previousActive;t&&"function"==typeof t.focus&&t.focus(),document.removeEventListener("keydown",e._escListener),e.remove()}}function E(){var e=x.no_compatible_procedure;return ye.isAndroid()&&null!=m?e+=x.procedure_from_url+" "+m:ye.isIOS()&&null!=h?e+=x.procedure_from_url+" "+h:e+=x.access_from_pc,e}return{buildErrorConnectingApplicationMsg:function(){return ye.isAndroid()||ye.isIOS()?x.error_connecting_client+"<br>"+xe.buildCustomUrl():x.error_connecting_autofirma+"<br>"+xe.buildCustomUrl()},buildCustomUrl:function(){var r;return ye.isAndroid()?(r=t,r+="<br>"+x.install_client):ye.isIOS()?(r=a,r+="<br>"+x.install_client):(r=e,r+="<br>"+x.restore_installation,ye.isFirefox()&&(r+="<br>"+y+x.firefox_reinstall_message)),r},buildCustomNoCompatibleProcedure:E,buildCustomErrorServerMsg:function(){var e=x.error_connecting_server_recovering;return R?T&&f&&(e+=" "+x.contact_admin+" "+f):e=E(),e},enableSupportDialog:function(e){v=e},enableLoadingDialog:function(e){b=e},enableErrorDialog:function(e){A=e},setBackgroundClass:function(e){r=e},setDialogClass:function(e){n=e},setLoadingTextClass:function(e){i=e},setErrorTextClass:function(e){s=e},setWarningClass:function(e){y="<span id='afirmaWarningText' class='"+(g=e)+"'>"+x.warning+"</span> "},setMessagePannelClass:function(e){o=e},setButtonContainerClass:function(e){l=e},setActionButtonClass:function(e){c=e},setCloseButtonClass:function(e){u=e},setLogoClass:function(e){d=e},setSpinnerClass:function(e){p=e},isEnabled:function(){return v&&!ye.isInternetExplorer()},setAlternativeAndroidAppLink:function(e){m=e},setAlternativeIOSAppLink:function(e){h=e},setPCDownloadURL:function(t){e=t},setAndroidDownloadURL:function(e){t=e},setIOSDownloadURL:function(e){a=e},setAdminContactInfo:function(e){f=e},showLoadingDialog:function(){_(x.loading)},showErrorDialog:function(e,t,a){var r,n=null,o=x.close;switch(e){case 1:r=xe.buildErrorConnectingApplicationMsg(),n=x.retry_operation;break;case 2:r=xe.buildCustomNoCompatibleProcedure();break;case 3:r=xe.buildCustomErrorServerMsg(),R&&(n=x.retry_operation);break;case 4:var i="";null!=f&&(i=" "+x.contact_admin+" "+f),r=x.error_connecting_service+i}return _(r,n,t,o,a)},showWarningDialog:function(e,t){var a,r;return 1===e&&(a=y+x.unsecure_context,r=x.ok),_(a,null,null,r,t)},disposeSupportDialog:S}}();SupportDialog={enableSupportDialog:xe.enableSupportDialog,enableLoadingDialog:xe.enableLoadingDialog,enableErrorDialog:xe.enableErrorDialog,setLoadingTextClass:xe.setLoadingTextClass,setPCDownloadURL:xe.setPCDownloadURL,setBackgroundClass:xe.setBackgroundClass,setDialogClass:xe.setDialogClass,setLoadingTextClass:xe.setLoadingTextClass,setErrorTextClass:xe.setErrorTextClass,setWarningClass:xe.setWarningClass,setMessagePannelClass:xe.setMessagePannelClass,setButtonContainerClass:xe.setButtonContainerClass,setActionButtonClass:xe.setActionButtonClass,setCloseButtonClass:xe.setCloseButtonClass,setLogoClass:xe.setLogoClass,setSpinnerClass:xe.setSpinnerClass,setPCDownloadURL:xe.setPCDownloadURL,setAndroidDownloadURL:xe.setAndroidDownloadURL,setIOSDownloadURL:xe.setIOSDownloadURL,setAdminContactInfo:xe.setAdminContactInfo,setAlternativeAndroidAppLink:xe.setAlternativeAndroidAppLink,setAlternativeIOSAppLink:xe.setAlternativeIOSAppLink};var _e=function(e,t){var a;function r(){return 2147483648*(a==t&&(a=1e3*(new Date).getMilliseconds()*Math.random()),(a=(9301*a+49297)%233280)/233280)}function n(e,t,a){if(a.length>t-e)return 0;var r;do{var n=Math.floor(Math.random()*(t+1-e))+e;r=o(n,a)}while(r);return n}function o(e,t){for(var a=0;a<t.length;a++)if(t[a]===e)return!0;return!1}return{generateNewIdSession:function(){var t,a="";if(void 0!==e.crypto&&void 0!==e.crypto.getRandomValues)t=new Uint32Array(20),e.crypto.getRandomValues(t);else{t=new Array(20);for(var n=0;n<20;n++)t[n]=r()}for(n=0;n<20;n++)a+="1234567890abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt(Math.floor(t[n]%61));return a},getRandomPorts:function(e,t){var a=e?Math.max(e,1024):49152,r=t?Math.min(t,65535):65535,o=new Array;switch(r-a){case 0:o[0]=a;break;case 1:o[0]=n(a,r,o),o[1]=n(a,r,o);break;default:o[0]=n(a,r,o),o[1]=n(a,r,o),o[2]=n(a,r,o)}return o},parseJSONData:function(e){var t=Base64.decode(e);return JSON.parse(t)},checkExistingId:function(e,t){for(var a=0;a<e.length;a++)if(e[a].id==t)throw new Error('El id de la firma a agregar = "'+e[a].id+'" ya existe en el lote')},getRandom:r}}(e,t),Se=function(e,t){var r="load",n="multiload",o="save",s="batch",g="certificate",f="sign",m="",y="",x="",_="",S="",E="",w=!1,C=_e.generateNewIdSession(),k=null,T=null,R=null,I=null,B=null;function N(e,t,r,n,o,i,s){S=f;var p=function(e,t,r,n,o){var i=new Object;return i.op=X("op",e),i.idsession=X("idsession",C),i.algorithm=X("algorithm",t),i.format=X("format",r),i.properties=X("properties",null!=n?Base64.encode(n,!0):null,!0),i.ksb64=X("ksb64",null!=k?Base64.encode(k,!0):null,!0),i.sticky=X("sticky",l),c&&(i.resetSticky=X("resetsticky",c)),i.appname=X("appname",u?a:u),i.dat=X("dat",""==o?null:o,!0),null!=d&&d>=0&&(i.servicetimeout=X("servicetimeout",d,!0)),i}(e,r,n,o,L(t));v(P(p),i,s)}function D(e,t){T=e,R=t}function L(e){return e?e.replace(/\+/g,"-").replace(/\//g,"_"):null}function j(e,t,r,n,o){var i=new Object;return i.op=X("op","batch"),i.idsession=X("idsession",C),i.batchpresignerurl=X("batchpresignerurl",e),i.batchpostsignerurl=X("batchpostsignerurl",t),i.properties=X("properties",null!=r?Base64.encode(r,!0):null,!0),i.ksb64=X("ksb64",null!=k?Base64.encode(k,!0):null,!0),i.sticky=X("sticky",l),c&&(i.resetSticky=X("resetsticky",c)),i.appname=X("appname",u?a:u),i.needcert=X("needcert",!0),i.dat=X("dat",""==n?null:n,!0),o&&(i.jsonbatch=X("jsonbatch",!0),O&&(i.localBatchProcess=X("localBatchProcess",!0))),null!=d&&d>=0&&(i.servicetimeout=X("servicetimeout",d,!0)),i}function z(e,t,a,r,n,o){var i=new Object;return i.op=X("op",e),i.idsession=X("idsession",C),i.title=X("title",t),i.extensions=X("exts",a),i.description=X("desc",r),i.filePath=X("filePath",n),i.multiload=X("multiload",o),i}function P(e){var t=[];for(var a in h&&t.push(X("mcv",h)),e)t.push(e[a]);for(var r="afirma://"+encodeURIComponent(e.op.value)+"?",n=0;n<t.length;n++)null!=t[n].value&&"null"!=t[n].value&&(r+=(0!=n?"&":"")+t[n].key+"="+(!0===t[n].avoidEncoding?t[n].value:encodeURIComponent(t[n].value)));return r}function M(e){var t;try{t=new WebSocket("wss://127.0.0.1:"+e)}catch(e){console.log("Error estableciendo el WebSocket: "+e),xe.showErrorDialog(1)}return t.onopen=function(){w=!0,_=this,console.log("Se abre el socket")},t.onclose=function(e){null!=_&&_===this&&(w=!1,_=null,console.log("Se cierra el socket. Codigo WebSocket de cierre: "+(e?e.code:null)),H("java.lang.InterruptedException",K))},t.onmessage=function(){console.log("Procesado por defecto del mensaje")},t.onerror=function(e){console.log("Procesado por defecto del error")},t}function F(e){_.onmessage=q,_.onerror=function(t){console.log("Error en la comunicacion por websocket: "+t),A(_,C,e-1)},A(_,C,e)}v=function(e,t,a){if(D(t,a),E=e,_&&w)console.log("Enviamos el mensaje al socket abierto"),F(AutoScript.AUTOFIRMA_CONNECTION_RETRIES);else{var r=_e.getRandomPorts(I,B);try{!function(e){xe.showLoadingDialog();for(var t="",a=0;a<e.length;a++)t+=e[a],a<e.length-1&&(t+=",");var r="afirma://websocket?ports="+t+"&v=4&jvc=4&idsession="+C;p||(r+="&dlgload="+p),ve(r)}(r),console.log("Tratamos de conectar con el cliente a traves de WebSockets en los puertos "+r),setTimeout(b,3e3,r,AutoScript.AUTOFIRMA_CONNECTION_RETRIES,e,t,a)}catch(r){x=ae.code,xe.showErrorDialog(1,function(){v(e,t,a)},function(){a("java.lang.IOException",ae.message,x)})||a("java.lang.IOException",ae.message,x)}}},b=function(e,t,a,r,n){if(w)console.log("Enviamos el mensaje al socket"),F(AutoScript.AUTOFIRMA_CONNECTION_RETRIES);else if(t>0){for(var o=0;!w&&o<e.length;o++)M(e[o]);setTimeout(b,AutoScript.AUTOFIRMA_LAUNCHING_TIME,e,t-1,a,r,n)}else xe.disposeSupportDialog(),e=_e.getRandomPorts(I,B),x=ae.code,xe.showErrorDialog(1,function(){v(a,r,n)},function(){n("es.gob.afirma.standalone.ApplicationNotFoundException",ae.message,x)})||n("es.gob.afirma.standalone.ApplicationNotFoundException",ae.message,x)};var q=function(){console.log("Respuesta de la peticion de eco"),_.onmessage=function(e){console.log("Respuesta obtenida de la o
1peracion enviada"),function(e){if(e!=t&&null!=e&&"CANCEL"!=e)if("#wait"!=e){if(e.length>7&&"err-"==e.substring(0,4).toLowerCase()&&-1!=e.indexOf(":=")){var a;a="err-11:"==e.substring(0,7).toLowerCase()?"es.gob.afirma.core.AOCancelledOperationException":"java.lang.Exception";var i=e.substring(e.indexOf(":=")+2);return 8!=i.indexOf(" - ")?m=i:(x=i.substring(0,8),m=i.substring(11)),void H(a,x,m)}if("MEMORY_ERROR"!=e)if(e.length>4&&"SAF_"==e.substring(0,4))H("java.lang.Exception",e);else if("NULL"!=e)if(S==o)!function(e){if("OK"==e||"SAVE_OK"==e)if(T){var t=T;D(null,null),t(e)}else console.log("No se ha proporcionado funcion callback a la notificar el resultado");else H("java.lang.Exception",ne)}(e);else if(S==r)J(e,!1);else if(S==n)J(e,!0);else if(S==g)!function(e){if(T){var t=T;D(null,null),t(e.replace(/\-/g,"+").replace(/\_/g,"/"))}else console.log("No se ha proporcionado funcion callback para devolver el certificado seleccionado")}(e);else if(S==s)!function(e){if(T){var t,a=null,r=e.indexOf("|");-1==r?t=e:(t=e.substring(0,r).replace(/\-/g,"+").replace(/\_/g,"/"),a=e.substring(r+1).replace(/\-/g,"+").replace(/\_/g,"/"));try{t=_e.parseJSONData(t)}catch(e){}if(T){var n=T;D(null,null),n(t,a)}else console.log("No se ha proporcionado funcion callback a la que devolver el resultado del lote")}else console.log("No se ha proporcionado funcion callback para procesar el resultado del lote de firma")}(e);else if(S==f)!function(e){if(T){var t,a=null,r=null,n=e.indexOf("|");if(-1==n)t=Base64.decode(e,!0).replace(/\-/g,"+").replace(/\_/g,"/");else{a=e.substring(0,n).replace(/\-/g,"+").replace(/\_/g,"/");var o=e.indexOf("|",n+1);-1==o?t=e.substring(n+1).replace(/\-/g,"+").replace(/\_/g,"/"):(t=e.substring(n+1,o).replace(/\-/g,"+").replace(/\_/g,"/"),r=Base64.decode(e.substring(o),!0))}if(T){var i=T;D(null,null),i(t,a,r)}else console.log("No se ha proporcionado funcion callback a la que devolver la firma generada")}else console.log("No se ha proporcionado funcion callback para procesar el resultado de la firma")}(e);else if(console.log("Operacion desconocida. Se devuelve directamente su resultado."),T){var l=T;D(null,null),l(e)}else console.log("No se ha proporcionado funcion callback para procesar el resultado de la operacion");else H("java.lang.Exception",ne);else H("es.gob.afirma.core.OutOfMemoryError",re)}else setTimeout(function(){_.send("getresult?idsession="+C)},2e3);else H("es.gob.afirma.core.AOCancelledOperationException",V)}(e.data)},_.send(E)};function H(e,t,a){if(y=e,m=a||t.message,x=t.code?t.code:t,R){var r=R;D(null,null),r(e,m,x)}}function J(e,t){if(e.indexOf(":")<=0)H("java.lang.Exception",U);else if(T){var a,r,n=e.split("|");if(t)for(a=new Array,r=new Array,i=0;i<n.length;i++)o=n[i].indexOf(":"),a.push(n[i].substring(0,o)),r.push(n[i].substring(o+1).replace(/\-/g,"+").replace(/\_/g,"/"));else{var o=n[0].indexOf(":");a=n[0].substring(0,o),r=n[0].substring(o+1).replace(/\-/g,"+").replace(/\_/g,"/")}if(T){var s=T;D(null,null),s(a,r)}else console.log("No se ha proporcionado funcion callback a la que notificar el resultado de la carga de datos")}else console.log("No se ha proporcionado funcion callback para procesar el resultado del lote de firma")}function X(e,t,a){var r=new Object;return r.key=e,r.value=t,r.avoidEncoding=!!a,r}return A=function(e,t,a){if(a<=0)xe.showErrorDialog(1,function(){A(e,t,1)},function(){H("java.util.concurrent.TimeoutException",ae)})||H("java.util.concurrent.TimeoutException",ae);else if(1===e.readyState)try{e.send("echo=-idsession="+t+"@EOF"),xe.disposeSupportDialog()}catch(r){console.log("Error en echo: "+r),setTimeout(A,AutoScript.AUTOFIRMA_LAUNCHING_TIME,e,t,a-1)}else console.log("El socket aun no esta preparado"),setTimeout(A,AutoScript.AUTOFIRMA_LAUNCHING_TIME,e,t,a-1)},{echo:function(){return"Cliente JavaScript"},setKeyStore:function(e){k=e},setPortRange:function(e,t){I=e,B=t},sign:function(e,t,a,r,n,o){N("sign",e,t,a,r,n,o)},coSign:function(e,t,a,r,n,o){N("cosign",e,t,a,r,n,o)},counterSign:function(e,t,a,r,n,o){N("countersign",e,t,a,r,n,o)},signBatchJSON:function(e,t,a,r,n,o){S=s;var i=j(t,a,r,e,!0);v(P(i),n,o)},signBatchXML:function(e,t,a,r,n,o){S=s;
1var i=j(t,a,r,L(e),!1);v(P(i),n,o)},selectCertificate:function(e,t,a){S=g;var r=function(e){var t=new Object;return t.op=X("op","selectcert"),t.idsession=X("idsession",C),t.properties=X("properties",null!=e?Base64.encode(e,!0):null,!0),t.ksb64=X("ksb64",null!=k?Base64.encode(k,!0):null,!0),t.sticky=X("sticky",l),c&&(t.resetSticky=X("resetsticky",c)),t}(e);v(P(r),t,a)},saveDataToFile:function(e,t,a,r,n,i,s){S=o;var l=function(e,t,a,r,n){var o=new Object;return o.op=X("op","save"),o.idsession=X("idsession",C),o.title=X("title",t),o.filename=X("filename",a),o.extension=X("exts",r),o.description=X("desc",n),o.dat=X("dat",""==e?null:e,!0),o}(L(e),t,a,r,n);v(P(l),i,s)},signAndSaveToFile:function(e,t,r,n,o,i,s,p){S=f;var g=function(e,t,r,n,o,i){var s=new Object;return s.op=X("op","signandsave"),s.idsession=X("idsession",C),s.cryptoOp=X("cop",e),s.algorithm=X("algorithm",r),s.format=X("format",n),s.properties=X("properties",o?Base64.encode(o,!0):null,!0),s.filename=X("filename",i),s.ksb64=X("ksb64",k?Base64.encode(k,!0):null,!0),s.sticky=X("sticky",l),c&&(s.resetSticky=X("resetsticky",c)),s.appname=X("appname",u?a:u),s.dat=X("dat",""==t?null:t,!0),null!=d&&d>=0&&(s.servicetimeout=X("servicetimeout",d,!0)),s}(e,L(t),r,n,o,i);v(P(g),s,p)},getFileNameContentBase64:function(e,t,a,n,o,i){S=r;var s=z("load",e,t,a,n,!1);v(P(s),o,i)},getMultiFileNameContentBase64:function(e,t,a,r,o,i){S=n;var s=z("load",e,t,a,r,!0);v(P(s),o,i)},setStickySignatory:ge,setLocale:fe,setLocaleMessages:me,getErrorMessage:function(){return m},getErrorType:function(){return y},getErrorType:function(){return x},getErrorCodeNumber:function(){return x?x.substring(2):null}}},Ee=function(e,t,r){var n,o="",s="",g="",f="",m=500,b="https://127.0.0.1:",A="",y=0,x=!1,_=!1,S=!1,E="",w=ye.isInternetExplorer()?12e3:ye.isFirefox()?458752:1048576,C=!1,k=null,T=null,R=null,I=null,B=null,D=null;function L(e,t,n,o,i){t!=r&&""!=t||(t=null),null==t||N(t)||(t=t.replace(/\+/g,"-").replace(/\//g,"_"));var s=function(e,t,r,n,o,i){var s=new Object;return s.op=G("op",e),s.keystore=G("keystore",null!=i?i:null),s.ksb64=G("ksb64",null!=i?Base64.encode(i):null),s.algorithm=G("algorithm",t),s.format=G("format",r),s.properties=G("properties",null!=n?Base64.encode(n):null),s.dat=G("dat",""==o?null:o),s.sticky=G("sticky",l),c&&(s.resetSticky=G("resetsticky",c)),s.appname=G("appname",u?a:u),null!=d&&d>=0&&(s.servicetimeout=createKeyValuePair("servicetimeout",d,!0)),s}(e,n,o,i,t,k);v(z(s))}function j(e,t,n,o,i){e!=r&&""!=e||(e=null),null!=e&&(e=e.replace(/\+/g,"-").replace(/\//g,"_"));var s=function(e,t,r,n,o,i){var s=new Object;return s.op=G("op","batch"),s.keystore=G("keystore",null!=e?e:null),s.ksb64=G("ksb64",null!=e?Base64.encode(e):null),s.batchpresignerurl=G("batchpresignerurl",t),s.batchpostsignerurl=G("batchpostsignerurl",r),s.properties=G("properties",null!=n?Base64.encode(n):null),s.dat=G("dat",""==o?null:o),s.needcert=G("needcert",!0),s.sticky=G("sticky",l),c&&(s.resetSticky=G("resetsticky",c)),s.appname=G("appname",u?a:u),i&&(s.jsonbatch=G("jsonbatch",!0)),O&&(s.localBatchProcess=G("localBatchProcess",!0)),s}(k,t,n,o,e,i);v(z(s))}function z(e){var t=[];for(var a in h&&t.push(G("mcv",h)),e)t.push(e[a]);for(var r="afirma://"+encodeURIComponent(e.op.value)+"?",n=0;n<t.length;n++)null!=t[n].value&&"null"!=t[n].value&&(r+=(0!=n?"&":"")+t[n].key+"="+encodeURIComponent(t[n].value));return r}function P(e,t){C=!1;var a=new Object;a.locked=!1;for(var r=0;!C&&r<e.length;r++)M(e[r],t,AutoScript.AUTOFIRMA_CONNECTION_RETRIES,a)}function M(e,t,a,r){I=t;var o=de();o.open("POST",b+e+"/afirma",!0),o.setRequestHeader("Content-type","application/x-www-form-urlencoded"),o.onreadystatechange=function(){if(4!=o.readyState||200!=o.status||"OK"!=Base64.decode(o.responseText,!0)||C){if(!(r&&r.locked||C||2==o.readyState||3==o.readyState))if(a--,""!=f&&a<AutoScript.AUTOFIRMA_CONNECTION_RETRIES/2)f="",r&&(r.locked=!0),a=AutoScript.AUTOFIRMA_CONNECTION_RETRIES,v(I);else{if(0==a)return void(r&&r.locked||(r&&(r.locked=!0),xe.showErrorDialog(1,function(){v(t)},function(){Y("es.gob.afirma.standalone.ApplicationNotFoundException",oe.message,oe)})||Y("es.gob.afirma.standalone.ApplicationNotFoundException",oe.message,oe)));setTimeout(U,AutoScript.AUTOFIRMA_LAUNCHING_TIME,e,a,r)}}else E=b+(f=e)+"/afirma",C=!0,r&&(r.locked=!0),x=I.indexOf("afirma://selectcert")>-1,_=I.indexOf("afirma://save")>-1,S=I.indexOf("afirma://batch")>-1,F()},C||o.send("echo=-idsession="+n+"@EOF")}function U(e,t,a){M(e,I,t,a)}function F(){var e=I;if(e.length>w)q(e,1,Math.ceil(e.length/w));else{var t=de();t.open("POST",E,!0),t.setRequestHeader("Content-type","application/x-www-form-urlencoded"),t.onreadystatechange=function(){if(404==t.status&&Y("java.lang.IOException",t.responseText,J),_)4==t.readyState&&""!=Base64.decode(t.responseText)&&W(Base64.decode(t.responseText));else if(4==t.readyState&&200==t.status&&""!=t.responseText){if("MEMORY_ERROR"==Base64.decode(t.responseText))return void Y("java.lang.OutOfMemoryError","Problema de memoria en servidor",ie);A="",K(1,Base64.decode(t.responseText,!0))}else""==t.responseText&&0==t.status&&0==t.readyState&&setTimeout(F,m)};try{t.onerror=function(e){0==e.target.status?Y("java.lang.IOException","Se ha perdido la conexion con la aplicacion Autofirma "+e.target.statusText,J):Y("java.lang.IOException","Ocurrio un error de red en la llamada al servicio de firma "+e.target.statusText,X)}}catch(e){}t.send("cmd="+Base64.encode(e,!0)+"idsession="+n+"@EOF")}}function q(e,t,a){var r=de();r.open("POST",E,!0),r.setRequestHeader("Content-type","application/x-www-form-urlencoded");var o=e.substring((t-1)*w,Math.min(w*t,e.length));r.onreadystatechange=function(){404!=r.status?4==r.readyState&&200==r.status&&""!=r.responseText?(y++,"MORE_DATA_NEED"==Base64.decode(r.responseText,!0)?y<a&&q(e,t+1,a):"OK"==Base64.decode(r.responseText,!0)?y==a&&(y=0,H()):"MEMORY_ERROR"==Base64.decode(r.responseText)&&W(Base64.decode(r.responseText))):""==r.responseText&&0==r.status&&0==r.readyState&&setTimeout(q,m,e,t,a):Y("java.lang.Exception",r.responseText,J)};try{r.onerror=function(e){0==e.target.status?Y("java.lang.IOException","Se ha perdido la conexion con la aplicacion Autofirma "+e.target.statusText,J):Y("java.lang.IOException","Ocurrio un error de red en la llamada al servicio de firma "+e.target.statusText,X)}}catch(e){}r.send("fragment=@"+t+"@"+a+"@"+Base64.encode(o,!0)+"idsession="+n+"@EOF")}function H(){httpRequest=de(),httpRequest.open("POST",E,!0),httpRequest.setRequestHeader("Content-type","application/x-www-form-urlencoded"),httpRequest.onreadystatechange=function(){404==httpRequest.status&&Y("java.lang.Exception",httpRequest.responseText,J),_?4==httpRequest.readyState&&""!=Base64.decode(httpRequest.responseText)&&W(Base64.decode(httpRequest.responseText)):4==httpRequest.readyState&&200==
1httpRequest.status&&""!=httpRequest.responseText?("MEMORY_ERROR"==Base64.decode(httpRequest.responseText)&&W(Base64.decode(httpRequest.responseText)),A="",K(1,Base64.decode(httpRequest.responseText,!0))):0==httpRequest.status&&0==httpRequest.readyState&&setTimeout(H,m)};try{httpRequest.onerror=function(e){0==e.target.status?Y("java.lang.IOException","Se ha perdido la conexion con la aplicacion Autofirma "+e.target.statusText,J):Y("java.lang.IOException","Ocurrio un error de red en la llamada al servicio de firma "+e.target.statusText,X)}}catch(e){}httpRequest.send("firm=idsession="+n+"@EOF")}function K(e,t){httpRequest=de(),httpRequest.open("POST",E,!0),httpRequest.setRequestHeader("Content-type","application/x-www-form-urlencoded"),httpRequest.onreadystatechange=function(){if(4==httpRequest.readyState&&200==httpRequest.status&&""!=httpRequest.responseText){if("MEMORY_ERROR"==Base64.decode(httpRequest.responseText))return void Y("java.lang.OutOfMemoryError","Problema de memoria en servidor",ie);A+=Base64.decode(httpRequest.responseText,!0),e==t?(xe.disposeSupportDialog(),S?(function(e){if(e==r||null==e||"CANCEL"==e)return g=V.code,void R("es.gob.afirma.core.AOCancelledOperationException",V.message,g);if(e.length>7&&"err-"==e.substring(0,4).toLowerCase()&&-1!=e.indexOf(":=")){var t;t="err-11:"==e.substring(0,7).toLowerCase()?"es.gob.afirma.core.AOCancelledOperationException":"java.lang.Exception";var a=e.substring(e.indexOf(":=")+2);return 8!=a.indexOf(" - ")?o=a:(g=a.substring(0,8),o=a.substring(11)),void R(t,o,g)}if(e.length>4&&"SAF_"==e.substring(0,4))R("java.lang.Exception",e);else{if("NULL"==e)return g=se.code,void R("java.lang.Exception",se.message,g);var n,i=null,s=e.indexOf("|");-1==s?n=e:(n=e.substring(0,s).replace(/\-/g,"+").replace(/\_/g,"/"),i=e.substring(s+1).replace(/\-/g,"+").replace(/\_/g,"/"));try{n=_e.parseJSONData(n)}catch(e){}T(n,i)}}(A),S=!1):x?(function(e){if(e==r||null==e||"CANCEL"==e)return g=V.code,void R("es.gob.afirma.core.AOCancelledOperationException",V.message,g);if(e.length>7&&"err-"==e.substring(0,4).toLowerCase()&&-1!=e.indexOf(":=")){s="err-11:"==e.substring(0,7).toLowerCase()?"es.gob.afirma.core.AOCancelledOperationException":"java.lang.Exception";var t=e.substring(e.indexOf(":=")+2);return 8!=t.indexOf(" - ")?o=t:(g=t.substring(0,8),o=t.substring(11)),void R(s,o,g)}if(!(e.length>4&&"SAF_"==e.substring(0,4)))return"NULL"==e?(g=se.code,void R("java.lang.Exception",se.message,g)):void T(e.replace(/\-/g,"+").replace(/\_/g,"/"));R("java.lang.Exception",e)}(A),x=!1):W(A),A=""):K(e+1,t)}else""==httpRequest.responseText&&0==httpRequest.status&&0==httpRequest.readyState&&setTimeout(K,m,e,t)};try{httpRequest.onerror=function(e){0==e.target.status?Y("java.lang.IOException","Se ha perdido la conexion con la aplicacion Autofirma "+e.target.statusText,J):Y("java.lang.IOException","Ocurrio un error de red en la llamada al servicio de firma "+e.target.statusText,X)}}catch(e){}e<=t&&httpRequest.send("send=@"+e+"@"+t+"idsession="+n+"@EOF")}function W(e){if(e==r||null==e||"CANCEL"==e)return g=V.code,void R("es.gob.afirma.core.AOCancelledOperationException",V.message,g);if(e.length>7&&"err-"==e.substring(0,4).toLowerCase()&&-1!=e.indexOf(":=")){var t;t="err-11:"==e.substring(0,7).toLowerCase()?"es.gob.afirma.core.AOCancelledOperationException":"java.lang.Exception";var a=e.substring(e.indexOf(":=")+2);return 8!=a.indexOf(" - ")?o=a:(g=a.substring(0,8),o=a.substring(11)),void R(t,o,g)}if("OK"!=e)if("MEMORY_ERROR"!=e)if(e.length>4&&"SAF_"==e.substring(0,4))R("java.lang.Exception",e);else{if("NULL"==e)return g=se.code,void R("java.lang.Exception",se.message,g);if("SAVE_OK"!=e)if(e.indexOf(":")>0){var n=e.split("|");if(1==n.length){var s=n[0].indexOf(":"),l=n[0];return-1==s?fileName=Base64.decode(l,!0):(fileName=l.substring(0,s),dataB64=l.substring(s+1).replace(/\-/g,"+").replace(/\_/g,"/")),void T(fileName,dataB64)}if(n.length>1){var c=new Array,u=new Array;for(i=0;i<n.length;i++)-1==(s=n[i].indexOf(":"))?(c.push(n[i]),u.push("")):(c.push(n[i].substring(0,s)),u.push(n[i].substring(s+1).replace(/\-/g,"+").replace(/\_/g,"/")))}T(c,u)}else{var d,p=null;-1==(s=e.indexOf("|"))?d=Base64.decode(e,!0).replace(/\-/g,"+").replace(/\_/g,"/"):(p=e.substring(0,s).replace(/\-/g,"+").replace(/\_/g,"/"),d=e.substring(s+1).replace(/\-/g,"+").replace(/\_/g,"/")),T(d,p)}else T&&T(e)}else R("es.gob.afirma.core.OutOfMemoryError",ie.message,ie.code);else{try{e=_e.parseJSONData(e)}catch(e){}T(e,null)}}function Y(e,t,a){g=a.code,R&&R(e,t,g)}function G(e,t){var a=new Object;return a.key=e,a.value=t,a}function Q(e,t,a,r,n,o){var i=function(e,t,a,r,n,o){var i=new Object;
1return i.op=G("op",e),i.title=G("title",t),i.extensions=G("exts",a),i.description=G("desc",r),i.filePath=G("filePath",n),i.multiload=G("multiload",o),i}(e,t,a,r,n,o);v(z(i))}return v=function(e){if(""==f){var t=_e.getRandomPorts(B,D);try{!function(e){xe.showLoadingDialog();for(var t="",a=0;a<e.length;a++)t+=e[a],a<e.length-1&&(t+=",");var r="afirma://service?ports="+t+"&v=4&jvc=4&idsession="+(n=_e.generateNewIdSession());p||(r+="&dlgload="+p),ve(r)}(t),setTimeout(P,AutoScript.AUTOFIRMA_LAUNCHING_TIME,t,e)}catch(t){xe.showErrorDialog(1,function(){v(e)},function(){Y("java.lang.IOException",oe.message,oe)})||Y("java.lang.IOException",oe.message,oe)}}else C=!1,M(f,e,AutoScript.AUTOFIRMA_CONNECTION_RETRIES)},{echo:function(){return"Cliente JavaScript"},checkTime:pe,setKeyStore:function(e){k=e},setPortRange:function(e,t){B=e,D=t},sign:function(e,t,a,r,n,o){T=n,R=o,L("sign",e,t,a,r)},coSign:function(e,t,a,r,n,o){T=n,R=o,L("cosign",e,t,a,r)},counterSign:function(e,t,a,r,n,o){T=n,R=o,L("countersign",e,t,a,r)},signBatchJSON:function(e,t,a,r,n,o){T=n,R=o,j(e,t,a,r,!0)},signBatchXML:function(e,t,a,r,n,o){T=n,R=o,j(e,t,a,r,!1)},selectCertificate:function(e,t,a){T=t,R=a,function(e){var t=new Object;t.op=G("op","selectcert"),t.properties=G("properties",null!=e?Base64.encode(e):null),t.keystore=G("keystore",null!=k?k:null),t.ksb64=G("ksb64",null!=k?Base64.encode(k):null),t.sticky=G("sticky",l),c&&(t.resetSticky=G("resetsticky",c)),v(z(t))}(e)},saveDataToFile:function(e,t,a,n,o,i,s){T=i,R=s,function(e,t,a,n,o){e!=r&&""!=e||(e=null),null==e||N(e)||(e=e.replace(/\+/g,"-").replace(/\//g,"_"));var i=function(e,t,a,r,n){var o=new Object;return o.op=G("op","save"),o.title=G("title",t),o.filename=G("filename",a),o.extension=G("exts",r),o.description=G("desc",n),o.dat=G("dat",""==e?null:e),o}(e,t,a,n,o);v(z(i))}(e,t,a,n,o)},signAndSaveToFile:function(e,t,n,o,i,s,p,g){T=p,R=g,function(e,t,n,o,i,s){t!=r&&""!=t||(t=null),null==t||N(t)||(t=t.replace(/\+/g,"-").replace(/\//g,"_"));var p=function(e,t,r,n,o,i,s){var p=new Object;return p.op=G("op","signandsave"),p.cryptoOp=G("cop",e),p.keystore=G("keystore",null!=s?s:null),p.ksb64=G("ksb64",null!=s?Base64.encode(s):null),p.algorithm=G("algorithm",t),p.format=G("format",r),p.properties=G("properties",null!=n?Base64.encode(n):null),p.filename=G("filename",o),p.dat=G("dat",""==i?null:i),p.sticky=G("sticky",l),c&&(p.resetSticky=G("resetsticky",c)),p.appname=G("appname",u?a:u),null!=d&&d>=0&&(p.servicetimeout=createKeyValuePair("servicetimeout",d,!0)),p}(e,n,o,i,s,t,k);v(z(p))}(e,t,n,o,i,s)},getFileNameContentBase64:function(e,t,a,r,n,o){T=n,R=o,Q("load",e,t,a,r,!1)},getMultiFileNameContentBase64:function(e,t,a,r,n,o){T=n,R=o,Q("load",e,t,a,r,!0)},getBase64FromText:function(e){return null!=e?Base64.encode(e):null},getTextFromBase64:function(e){return null!=e?Base64.decode(e):null},setStickySignatory:ge,setLocale:fe,getErrorMessage:function(){return o},getErrorType:function(){return s},getErrorCode:function(){return g},getErrorCodeNumber:function(){return g?g.substring(2):null}}},we=function(e,t,r){var n,o,i,s=ye.isAndroid()||ye.isIOS()?4e3:3e3,g=ye.isAndroid()||ye.isIOS()?15:10,f=!0,m="batch",b="certificate",A="sign",y=A,x="",_="",S="",E=null,w=null,C=null;if(e!=r&&null!=e)if(-1!=e.indexOf("://")&&-1!=e.indexOf("/",e.indexOf("://")+3)){var k=e.substring(0,e.indexOf("/",e.indexOf("://")+3));w=k+"/afirma-signature-retriever/RetrieveService",C=k+"/afirma-signature-storage/StorageService"}else w=e+"/afirma-signature-retriever/RetrieveService",C=e+"/afirma-signature-storage/StorageService";else w=t.location.origin+"/afirma-signature-retriever/RetrieveService",C=t.location.origin+"/afirma-signature-storage/StorageService";var T=!1;function I(){return t.crypto&&t.crypto.subtle&&t.crypto.subtle.generateKey}function B(e,t,a,r){y=b,n=B,o=t;var i=new Array;E&&(i[i.length]={key:"ksb64",value:Base64.encode(E)}),Ee(i,t.extraParams),ie("selectcert",e,i,a,r)}function D(e,t,a,r,n,o,i){ne(L,{signId:e,dataB64:t,algorithm:a,format:r,extraParams:n},o,i)}function L(e,t,a,i){y=A,n=L,o=t;var s=t.dataB64,l=t.algorithm,c=t.format,u=t.extraParams;s&&!N(s)&&(s=s.replace(/\+/g,"-").replace(/\//g,"_").replace(/\n/g,"").replace(/\r/g,""));var p=t.signId,g=new Array;E&&(g[g.length]={key:"ksb64",value:Base64.encode(E)}),c&&(g[g.length]={key:"format",value:c}),l&&(g[g.length]={key:"algorithm",value:l}),null!=!!d&&d!=r&&d>=0&&(g[g.length]={key:"servicetimeout",value:d}),Ee(g,u),s&&(g[g.length]={key:"dat",value:s}),ie(p,e,g,a,i)}function j(e,t,a,i){y=A,n=j,o=t;var s=t.signId,l=t.dataB64,c=t.algorithm,u=t.format,p=t.extraParams,g=t.outputFileName;l&&!N(l)&&(l=l.replace(/\+/g,"-").replace(/\//g,"_").replace(/\n/g,"").replace(/\r/g,""));var f=new Array;s&&(f[f.length]={key:"cop",value:s}),E&&(f[f.length]={key:"ksb64",value:Base64.encode(E)}),u&&(f[f.length]={key:"format",value:u}),c&&(f[f.length]={key:"algorithm",value:c}),g&&(f[f.length]={key:"filename",value:g}),null!=d&&d!=r&&d>=0&&(f[f.length]={key:"servicetimeout",value:d}),Ee(f,p),l&&(f[f.length]={key:"dat",value:l}),ie("signandsave",e,f,a,i)}function U(e,t,a,i){y=m,n=U,o=t;var s=t.batchB64,l=t.batchPreSignerUrl,c=t.batchPostSignerUrl,u=t.extraParams;dataB64&&!N(dataB64)&&(dataB64=dataB64.replace(/\+/g,"-").replace(/\//g,"_").replace(/\n/g,"").replace(/\r/g,""));var p=new Array;E&&(p[p.length]={key:"ksb64",value:Base64.encode(E)}),l&&(p[p.length]={key:"batchpresignerurl",value:l}),c&&(p[p.length]={key:"batchpostsignerurl",value:c}),null!=d&&d!=r&&d>=0&&(p[p.length]={key:"servicetimeout",value:d}),Ee(p,u),p[p.length]={key:"needcert",value:"true"},s&&(p[p.length]={key:"dat",value:s}),ie("batch",e,p,a,i)}function K(e,t,a,i){y=m,n=K,o=t;var s=t.jsonRequestB64,l=t.batchPreSignerUrl,c=t.batchPostSignerUrl,u=t.certFilters,p=new Array;E&&(p[p.length]={key:"ksb64",value:Base64.encode(E)}),l&&(p[p.length]={key:"batchpresignerurl",value:l}),c&&(p[p.length]={key:"batchpostsignerurl",value:c}),O&&(p[p.length]={key:"localBatchProcess",value:!0}),null!=d&&d!=r&&d>=0&&(p[p.length]={key:"servicetimeout",value:d}),Ee(p,u),p[p.length]={key:"needcert",value:!0},p[p.length]={key:"jsonbatch",value:!0},s&&(p[p.length]={key:"dat",value:s}),ie("batch",e,p,a,i)}function J(e,t,a,r){n=J,o=t;var i=t.dataB64,s=t.title,l=t.filename,c=t.extension,u=t.description,d=new Array;s&&(d[d.length]={key:"title",value:s}),l&&(d[d.length]={key:"filename",value:l}),c&&(d[d.length]={key:"extension",value:c}),u&&(d[d.length]={key:"description",value:u}),i&&(d[d.length]={key:"dat",value:i.replace(/\+/g,"-").replace(/\//g,"_")}),ie("save",e,d,a,r)}function X(e,t){throw _=e,x=t.message,S=t.code,new Error}function Q(e){return e.length>2e3}function ae(){var e;if(void 0!==t.crypto&&void 0!==t.crypto.getRandomValues){var a=new Uint32Array(1);t.crypto.getRandomValues(a),e=re(a[0]%1e8,8)}else e=re(Math.floor((_e.getRandom()+1)%1e8),8);return e}function re(e,t){return(t-=e.toString().length)>0?new Array(t+(/\./.test(e)?2:1)).join("0")+e:e+""}function ne(e,a,n,o){null!=C&&C!=r?null!=w&&w!=r?I()?function(e,a,r,n){var o=t.crypto.subtle;o.generateKey({name:"AES-CBC",length:256},!0,["encrypt","decrypt"]).then(function(e){return o.exportKey("raw",e)}).then(function(o){var i=Oe(new Uint8Array(o)),s=t.crypto.getRandomValues(new Uint8Array(16)),l=new Uint8Array(s.length);l.set(s,0);var c={algo:"AES",key:i,iv:Oe(l),legDes:ae()};e(c,a,r,n)})}(e,a,n,o):"https:"!=t.location.protocol&&xe.showWarningDialog(1,function(){e(null,a,n,o)})||e(null,a,n,o):X("java.lang.IllegalArgumentException",Z):X("java.lang.IllegalArgumentException",$)}function oe(e){var t=JSON.stringify(e);return Base64.encode(t)}function ie(e,t,r,n,o){var i=_e.generateNewIdSession(),s=t?t.legDes:ae(),l=t?oe(t):null,c=u||a;r[r.length]={key:"ver",value:4},r[r.length]={key:"op",value:e},r[r.length]={key:"id",value:i},r[r.length]={key:"appname",value:c},s&&(r[r.length]={key:"key",value:s}),l&&(r[r.length]={key:"cipher",value:l}),C&&(r[r.length]={key:"stservlet",value:C}),p||(r[r.length]={key:"dlgload",showDialog:p}),ye.isAndroid()||ye.isIOS()||(r[r.length]={key:"aw",value:"true"});var d=me(e,r);t||(t={legDes:s}),Q(d)?se(i,t,C,w,e,r,n,o):v(d,i,t,n,o)}function se(e,a,n,o,i,s,l,c){xe.showLoadingDialog();var u=_e.generateNewIdSession(),d=de();d||X("java.lang.Exception",M),d.open("POST",n,!0),d.setRequestHeader("Content-type","application/x-www-form-urlencoded");for(var p=!1,g="",f=0;f<s.length&&!g;
1f++)"id"==s[f].key&&(g=s[f].value);d.onreadystatechange=function(){if(4==d.readyState)if(200==d.status){if(url=function(e,t,a,n,o,i){var s=0,l=new Array;return l[s++]={key:"fileid",value:t},l[s++]={key:"rid",value:a},(null!=n||n!=r)&&(l[s++]={key:"rtservlet",value:n}),null==o&&o==r||(l[s++]={key:"stservlet",value:o}),i&&(i.legDes&&(l[s++]={key:"key",value:i.legDes}),i.algo&&"DES"!=i.algo&&(l[s++]={key:"cipher",value:oe(i)})),me(e,l)}(i,u,g,o,n,a),Q(url))return S=ee.code,void c("java.lang.IllegalArgumentException",ee.message,S);console.log("URL: "+url),v(url,e,a,l,c)}else p=!0,console.log("Error al enviar los datos al servidor intermedio. HTTP Status: "+d.status),S=te.code,xe.showErrorDialog(3,function(){se(e,a,n,o,i,s,l,c)},function(){c("java.lang.IOException",te.message,S)})||c("java.lang.IOException",te.message,S)};try{d.onerror=function(e){p||(console.log("Error al enviar los datos al servidor intermedio (HTTP Status: "+d.status+"): "+e.message),S=q.code,c("java.lang.IOException",q.message,S))}}catch(e){}h&&(s[s.length]={key:"mcv",value:h});var m=function(e,t){var a="<"+(e=null==e?"op":e)+">";if(null!=t)for(var r=0;r<t.length;r++)a+='<e k="'+t[r].key+'" v="'+t[r].value+'"/>';return Base64.encode(a+"</"+e+">")}(i,s);!function(e,a,r,n,o){var i=a;if(T){var s=Te(i.key);t.crypto.subtle.importKey("raw",s,{name:"AES-CBC"},!1,["encrypt"]).then(function(a){var r=Te(i.iv),n=Te(e);return t.crypto.subtle.encrypt({name:"AES-CBC",iv:r},a,n)}).then(function(e){pe(Re(e),r,n,o)}).catch(function(e){console.log("Error al hacer el cifrado avanzado de los datos para la subida al servidor: "+e),S=z.code,o("java.lang.Exception",z.message,S)})}else{let t=function(e,t){var a=Cipher.base64ToString(Ie(e));return(8-a.length%8)%8+"."+Cipher.stringToBase64(Cipher.des(t,a,1,0,null)).replace(/\+/g,"-").replace(/\//g,"_")}(e,a.legDes);pe(t,r,n,o)}}(m,a,u,d,c)}function pe(e,t,a,r){var n="op=put&v=1_0&id="+t+"&dat="+e.replace(/\+/g,"-").replace(/\//g,"_");try{a.send(n)}catch(e){S=H.code,r("java.lang.IOException",H.message,S)}}function me(e,t){var a="jvc=4";if(h&&(a+="&mcv="+encodeURIComponent(h)),null!=t&&t!=r)for(var n=0;n<t.length;n++)null!=t[n].value&&"null"!=t[n].value&&(a+="&"+t[n].key+"="+encodeURIComponent(t[n].value));return ye.isChrome()&&ye.isAndroid()?"intent://"+e+"?"+a+"#Intent;scheme=afirma;package=es.gob.afirma;end":"afirma://"+e+"?"+a}function he(e,t,a,r){if("err-06"==e.substring(0,6).toLowerCase())return!0;if(xe.disposeSupportDialog(),"#wait"==e.substring(0,5).toLowerCase())return"reset";if("err-"==e.substring(0,4).toLowerCase()&&-1!=e.indexOf(":=")){var n;n="err-11:"==e.substring(0,7).toLowerCase()?"es.gob.afirma.core.AOCancelledOperationException":"java.lang.Exception";var o=e.substring(e.indexOf(":=")+2);if(-1!=o.indexOf(" - ")){var i=o.substring(0,o.indexOf(" - "));8==i.length?(S=i,x=o.substring(o.indexOf(" - ")+3)):x=o}else x=o;return r&&r(n,x,S),!1}if("CANCEL"==e||"CANCEL\r\n"==e||"CANCEL\n"==e)return r&&r("es.gob.afirma.core.AOCancelledOperationException",V.message,V.code),!1;if("OK"==e||"OK\r\n"==e||"OK\n"==e)return a&&a(),!1;if(e.length>4&&"SAF_"==e.substring(0,4))return r&&r("java.lang.Exception",e),!1;var s=new Array,l=0,c=e.indexOf("|");if(-1==c)s.push(e);else{do{s.push(e.substring(l,c)),l=c+1,c=e.indexOf("|",l)}while(-1!=c);s.push(e.substring(l))}if(I()&&t)try{return void function(e,t,a,r){var n=t,o=Te(n.key),i=Te(n.iv);Ae(e,new Array,o,i,a,r)}(s,t,a,r)}catch(e){console.log("El cliente de firma no uso el cifrado avanzado, se usara el corriente")}t&&(s=function(e,t){var a=new Array;do{var r=e[a.length],n=r.indexOf("."),o=r.substring(0,n),i=a.length<e.length-1,s=Cipher.des(t,Cipher.base64ToString(Ie(r.substring(n+1))),0,0,null),l=Cipher.stringToBase64(s.substring(0,s.length-parseInt(o)-(i?0:8)));a.push(l)}while(a.length<e.length);return a}(s,t.legDes)),be(s,a)}function be(e,t){if(y==m){var a,r=null;a=Ie(e[0]),e.length>1&&(r=Ie(e[1])),l?r&&(i=r):i=null;try{a=_e.parseJSONData(a)}catch(e){}return t&&t(a,r),!1}if(y==b)return r=Ie(e[0]),i=l?r:null,t&&t(r),!1;r=null;var n,o=null;1==e.length?n=Ie(e[0]):2==e.length?(r=Ie(e[0]),n=Ie(e[1])):(r=Ie(e[0]),n=Ie(e[1]),o=Base64.decode(Ie(e[2]))),l?r&&(i=r):i=null,t&&t(n,r,o)}function Ae(e,a,r,n,o,i){var s=Te(Ie(e[a.length])),l=t.crypto.subtle;l.importKey("raw",r,{name:"AES-CBC",length:256}
1,!1,["encrypt","decrypt"]).then(function(e){return l.decrypt({name:"AES-CBC",iv:n},e,s)}).then(function(t){a.push(Re(t)),T=!0,e.length==a.length?be(a,o):Ae(e,a,r,n,o,i)}).catch(function(e){console.log("Error en el descifrado de la respuesta: "+e),S=P.code,i("java.lang.Exception",P.message,S)})}function Se(e,t,a,r){xe.disposeSupportDialog(),_=null!=e&&e.length>0?e:"java.lang.Exception",x=null!=t&&t.length>0?t:"No se ha podido extablecer la comunicación entre la aplicación de firma y la página web",S=r,a&&a(_,x,S)}function Ee(e,t){l&&(ye.isIOS()||ye.isAndroid()?(e[e.length]={key:"sticky",value:l},c&&(e[e.length]={key:"resetsticky",value:c})):!c&&i&&(t=function(e,t){for(var a=function(e){var t=[];if(e){for(var a,r=0;-1!=(a=e.indexOf("\n",r));)t.push(e.substring(r,a)),r=a+1;t.push(e.substring(r))}return t}(t),r=[],n=0;n<a.length;n++)a[n]&&!we(a[n])&&r.push(a[n]);r.push("filters=encodedcert:"+e),r.push("headless=true");var o="";if(r.length>0)for(o=r[0],n=1;n<r.length;n++)o+="\n"+r[n];return o}(i,t))),t&&(e[e.length]={key:"properties",value:Base64.encode(t)})}function we(e){return 0==e.indexOf("filters=")||0==e.indexOf("filter=")||0==e.indexOf("filters.")||0==e.indexOf("headless=")}v=function(e,t,a,r,i){xe.showLoadingDialog(),f=!1,ve(e),t&&function(e,t,a,r,n,o,i){var l=de();l||X("java.lang.Exception",F),Ce=0,setTimeout(ke,s,l,t,"op=get&v=1_0&id="+e+"&it=0",a,r,n,!1,o,i)}(t,w,a,n,o,r,i)};var Ce=0;function ke(e,t,a,r,n,o,i,l,c){if(f)xe.showErrorDialog(1,function(){n(r,o,l,c)},function(){Se("es.gob.afirma.standalone.ApplicationNotFoundException",le.message,c,le.code)})||Se("es.gob.afirma.standalone.ApplicationNotFoundException",le.message,c,le.code);else if(Ce>g){var u;i?xe.showErrorDialog(3,function(){n(r,o,l,c)},function(){Se("java.util.concurrent.TimeoutException",ce.message,c,ce.code)})||Se("java.util.concurrent.TimeoutException",ce.message,c,ce.code):(u=R?1:3,xe.showErrorDialog(u,function(){n(r,o,l,c)},function(){c("java.lang.IOException",ce.message,ce.code)})||Se("java.util.concurrent.TimeoutException",ce.message,c,ce.code))}else{Ce++,e.onreadystatechange=function(){if(4==e.readyState)if(200==e.status){var u=he(e.responseText,r,l,c);if(u){var d=Ce-1;"reset"==u&&(Ce=0,i=!0),setTimeout(ke,s,e,t,a.replace("&it="+d,"&it="+Ce),r,n,o,i,l,c)}}else 0==e.status?(d=Ce-1,setTimeout(ke,s,e,t,a.replace("&it="+d,"&it="+Ce),r,n,o,i,l,c)):xe.showErrorDialog(3,function(){n(r,o,l,c)},function(){Se("java.lang.IOException",ue.message+" (Status: "+e.status+")",c,ue.code)})||Se("java.lang.IOException",ue.message+" (Status: "+e.status+")",c,ue.code)},e.open("POST",t,!0),e.setRequestHeader("Content-type","application/x-www-form-urlencoded");try{e.send(a)}catch(e){return void Se("java.lang.IOException",W.message,c,W.code)}}}function Oe(e){var t=Array.from(e,function(e){return String.fromCodePoint(e)}).join("");return btoa(t)}function Te(e){var t=atob(e);return Uint8Array.from(t,function(e){return e.codePointAt(0)})}function Re(e){let t="",a=new Uint8Array(e),r=a.byteLength;for(let e=0;e<r;e++)t+=String.fromCharCode(a[e]);return btoa(t)}function Ie(e){return e?e.replace(/\-/g,"+").replace(/\_/g,"/"):e}return{echo:function(){return"Cliente JavaScript"},setKeyStore:function(e){E=e},sign:function(e,t,a,r,n,o){D("sign",e,t,a,r,n,o)},coSign:function(e,t,a,r,n,o){D("cosign",e,t,a,r,n,o)},counterSign:function(e,t,a,r,n,o){D("countersign",e,t,a,r,n,o)},signBatchJSON:function(e,t,a,r,n,o){ne(K,{jsonRequestB64:e,batchPreSignerUrl:t,batchPostSignerUrl:a,certFilters:r},n,o)},signBatchXML:function(e,t,a,r,n,o){ne(U,{batchB64:e,batchPreSignerUrl:t,batchPostSignerUrl:a,extraParams:r},n,o)},selectCertificate:function(e,t,a){ne(B,{extraParams:e},t,a)},saveDataToFile:function(e,t,a,r,n,o,i){ne(J,{dataB64:e,title:t,filename:a,extension:r,description:n},o,i)},signAndSaveToFile:function(e,t,a,r,n,o,i,s){ne(j,{signId:e,dataB64:t,algorithm:a,format:r,extraParams:n,outputFileName:o},i,s)},getFileNameContentBase64:function(e,t,a,r,n,o){_="java.lang.UnsupportedOperationException",x=Y.message,S=Y.code,o?o(_,x,S):X(_,Y)},getMultiFileNameContentBase64:function(e,t,a,r,n,o){_="java.lang.UnsupportedOperationException",x=G.message,S=G.code,o?o(_,x,S):X(_,G)},setServlets:function(e,t){C=e,w=t},setStickySignatory:ge,setLocale:fe,getErrorMessage:function(){return x},getErrorType:function(){return _},getErrorCode:function(){return S},getErrorCodeNumber:function(){return S?S.substring(2):null}}};return{VERSION:"1.10.1",CHECKTIME_NO:S,CHECKTIME_RECOMMENDED:E,CHECKTIME_OBLIGATORY:w,JAVA_ARGUMENTS:null,SYSTEM_PROPERTIES:null,setForceAFirma:function(){},cargarMiniApplet:be,echo:function(){return r.echo()},setJnlpService:function(){},isJNLP:function(){return!1},needNativeAppInstalled:function(){return!0},KEYSTORE_WINDOWS:"WINDOWS",KEYSTORE_APPLE:"APPLE",KEYSTORE_PKCS12:"PKCS12",KEYSTORE_PKCS11:"PKCS11",KEYSTORE_MOZILLA:_,KEY
1STORE_SHARED_NSS:"SHARED_NSS",KEYSTORE_JAVA:"JAVA",KEYSTORE_JCEKS:"JCEKS",KEYSTORE_JAVACE:"JAVACE",KEYSTORE_DNIE:"DNIEJAVA",AUTOFIRMA_LAUNCHING_TIME:2e3,AUTOFIRMA_CONNECTION_RETRIES:15,cargarAppAfirma:be,sign:function(e,t,a,n,o,i){r.sign(e,t,a,n,o,i),c=!1},coSign:function(e,t,a,n,o,i,s){r.coSign(e,a,n,o,i,s),c=!1},cosign:function(e,t,a,n,o,i){r.coSign(e,t,a,n,o,i),c=!1},counterSign:function(e,t,a,n,o,i){r.counterSign(e,t,a,n,o,i),c=!1},createBatch:function(e,t,a,r){var n=new Object;n.algorithm=e,n.format=t,n.suboperation=a,r&&(n.extraparams=Base64.encode(r)),n.singlesigns=new Array,k=n},addDocumentToBatch:function(e,t,a,r,n){if(!e||null==t)throw new Error("No se ha indicado el id o datareference de la firma");if(!k)throw new Error("No hay ningun lote creado. Es necesario crear uno antes de agregar firmas");_e.checkExistingId(k.singlesigns,e);var o=new Object;o.id=e,o.datareference=t,a&&(o.format=a),r&&(o.suboperation=r),n&&(o.extraparams=Base64.encode(n)),k.singlesigns.push(o)},setLocalBatchProcess:function(e){O=e},signBatchProcess:function(e,t,a,n,o,i){if(!k)throw new Error("No hay ningun lote creado. Es necesario crear uno antes de firmar.");k.stoponerror=e;var s=Base64.encode(JSON.stringify(k),!0);r.signBatchJSON(s,t,a,n,o,i),k=null,c=!1},signBatch:function(e,t,a,n,o,i){r.signBatchXML(e,t,a,n,o,i),c=!1},selectCertificate:function(e,t,a){r.selectCertificate(e,t,a),c=!1},signAndSaveToFile:function(e,t,a,n,o,i,s,l){r.signAndSaveToFile(e,t,a,n,o,i,s,l),c=!1},getCurrentLog:function(e,t){t&&t("java.lang.UnsupportedOperationException",Q.message,Q.code)},saveDataToFile:function(e,t,a,n,o,i,s){r.saveDataToFile(e,t,a,n,o,i,s)},getFileNameContentBase64:function(e,t,a,n,o,i){r.getFileNameContentBase64(e,t,a,n,o,i)},getMultiFileNameContentBase64:function(e,t,a,n,o,i){r.getMultiFileNameContentBase64(e,t,a,n,o,i)},checkTime:pe,setKeyStore:function(e){r.setKeyStore(null!=e?e:null),c=!0},setForceWSMode:function(e){C=e},setServlets:function(e,t){xe.disposeSupportDialog(),(C||ye.isIOS()||ye.isAndroid())&&he(e,t,!1),n=e,o=t,r&&r.setServlets&&r.setServlets(e,t)},setPortRange:function(e,t){var a=65535;f=e&&e>=1024&&e<=a?e:1024,m=t?t<=a&&t>=f?t:a:e&&e==f?f:a,r&&r.setPortRange&&r.setPortRange(f,m)},setStickySignatory:ge,setLocale:fe,setMinimumClientVersion:function(e){h=e},setAppName:function(e){u=encodeURIComponent(e)},setServiceTimeout:function(e){d=e},enableProgressDialog:function(e){p=e},getErrorMessage:function(){return r.getErrorMessage()},getErrorType:function(){return r.getErrorType()},getErrorCode:function(){return r.getErrorCode()},getErrorCodeNumber:function(){return r.getErrorCodeNumber()},getBase64FromText:function(e){return null!=e?Base64.encode(e):null},getTextFromBase64:function(e){return null!=e?Base64.decode(e):null},downloadRemoteData:function(e,t,a){D=t,L=a;var r=de();r.open("GET",e,!0),"responseType"in r&&Uint8Array?(r.responseType="arraybuffer",j="arraybuffer"):"overrideMimeType"in r?(r.overrideMimeType("text/plain; charset=x-user-defined"),j="string"):(r.setRequestHeader("Accept-Charset","x-user-
1defined"),j="bytearray"),"onload"in r||(r.onreadystatechange=function(){4===this.readyState&&this.onload()}),r.onload=function(){var e;4==r.readyState&&200==r.status&&D&&("response"in this||(this.response=new VBArray(this.responseBody).toArray()),"arraybuffer"==j?e=Base64.encodeArrayBuffer(this.response):"bytearray"==j?e=Base64.encodeByteArray(this.response):"string"==j?e=Base64.encode(this.response):this.onerror(new Error("No se conoce el modo usado para la descarga de los datos")),D(e))};try{r.onerror=function(e){L&&L(e)}}catch(e){}r.send()},isAndroid:ye.isAndroid,isIOS:ye.isIOS}}(window,void 0),MiniApplet=AutoScript,Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_keyStr_URL_SAFE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",encode:function(e,t){var a,r,n,o,i,s,l,c=1==t?this._keyStr_URL_SAFE:this._keyStr,u="",d=0;for(e=Base64._utf8_encode(e);d<e.length;)o=(a=e.charCodeAt(d++))>>2,i=(3&a)<<4|(r=e.charCodeAt(d++))>>4,s=(15&r)<<2|(n=e.charCodeAt(d++))>>6,l=63&n,isNaN(r)?s=l=64:isNaN(n)&&(l=64),u=u+c.charAt(o)+c.charAt(i)+c.charAt(s)+c.charAt(l);return u},encodeArrayBuffer:function(e,t){for(var a=new Uint8Array(e),r=a.length,n=new Array(r);r--;)n[r]=String.fromCharCode(a[r]);return t?window.btoa(n.join("")).replace("+","-").replace("/","_"):window.btoa(n.join(""))},encodeByteArray:function(e,t){for(var a=1==t?this._keyStr_URL_SAFE:this._keyStr,r=[],n=0;n<e.length;n+=3){var o=e[n],i=n+1<e.length,s=i?e[n+1]:0,l=n+2<e.length,c=l?e[n+2]:0,u=o>>2,d=(3&o)<<4|s>>4,p=(15&s)<<2|c>>6,g=63&c;l||(g=64,i||(p=64)),r.push(a.charAt(u),a.charAt(d),a.charAt(p),a.charAt(g))}return r.join("")},decode:function(e,t){var a,r,n,o,i,s,l=1==t?this._keyStr_URL_SAFE:this._keyStr,c="",u=0;for(e=1==t?e.replace(/[^A-Za-z0-9\-\_\=]/g,""):e.replace(/[^A-Za-z0-9\+\/\=]/g,"");u<e.length;)a=l.indexOf(e.charAt(u++))<<2|(o=l.indexOf(e.charAt(u++)))>>4,r=(15&o)<<4|(i=l.indexOf(e.charAt(u++)))>>2,n=(3&i)<<6|(s=l.indexOf(e.charAt(u++))),c+=String.fromCharCode(a),64!=i&&(c+=String.fromCharCode(r)),64!=s&&(c+=String.fromCharCode(n));return Base64._utf8_decode(c)},_utf8_encode:function(e){e=e.replace(/\r\n/g,"\n");for(var t="",a=0;a<e.length;a++){var r=e.charCodeAt(a);r<128?t+=String.fromCharCode(r):r>127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(63&r|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(63&r|128))}return t},_utf8_decode:function(e){for(var t="",a=0,r=0,n=0;a<e.length;)if((r=e.charCodeAt(a))<128)t+=String.fromCharCode(r),a++;else if(r>191&&r<224)n=e.charCodeAt(a+1),t+=String.fromCharCode((31&r)<<6|63&n),a+=2;else{n=e.charCodeAt(a+1);var o=e.charCodeAt(a+2);t+=String.fromCharCode((15&r)<<12|(63&n)<<6|63&o),a+=3}return t}},Cipher={tableStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",tableStr_URL_SAFE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",des:function(e,t,a,r,n,o){var i,s,l,c,u,d,p,g,f,m,h,v,b,A,y=new Array(16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756),x=new Array(-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344),_=new Array(520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584),S=new Array(8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928),E=new Array(256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080),w=new Array(536870928,541065216,16384,541081616,54106
15216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312),C=new Array(2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154),k=new Array(268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696),O=Cipher.des_createKeys(e),T=0,R=t.length,I=0,B=32==O.length?3:9;g=3==B?a?new Array(0,32,2):new Array(30,-2,-2):a?new Array(0,32,2,62,30,-2,64,96,2):new Array(94,62,-2,32,64,2,30,-2,-2),2==o?t+=" ":1==o?(l=8-R%8,t+=String.fromCharCode(l,l,l,l,l,l,l,l),8==l&&(R+=8)):o||(t+="\0\0\0\0\0\0\0\0");var N="",D="";for(1==r&&(f=n.charCodeAt(T++)<<24|n.charCodeAt(T++)<<16|n.charCodeAt(T++)<<8|n.charCodeAt(T++),h=n.charCodeAt(T++)<<24|n.charCodeAt(T++)<<16|n.charCodeAt(T++)<<8|n.charCodeAt(T++),T=0);T<R;){for(d=t.charCodeAt(T++)<<24|t.charCodeAt(T++)<<16|t.charCodeAt(T++)<<8|t.charCodeAt(T++),p=t.charCodeAt(T++)<<24|t.charCodeAt(T++)<<16|t.charCodeAt(T++)<<8|t.charCodeAt(T++),1==r&&(a?(d^=f,p^=h):(m=f,v=h,f=d,h=p)),d^=(l=252645135&(d>>>4^p))<<4,d^=(l=65535&(d>>>16^(p^=l)))<<16,d^=l=858993459&((p^=l)>>>2^d),d^=l=16711935&((p^=l<<2)>>>8^d),d=(d^=(l=1431655765&(d>>>1^(p^=l<<8)))<<1)<<1|d>>>31,p=(p^=l)<<1|p>>>31,s=0;s<B;s+=3){for(b=g[s+1],A=g[s+2],i=g[s];i!=b;i+=A)c=p^O[i],u=(p>>>4|p<<28)^O[i+1],l=d,d=p,p=l^(x[c>>>24&63]|S[c>>>16&63]|w[c>>>8&63]|k[63&c]|y[u>>>24&63]|_[u>>>16&63]|E[u>>>8&63]|C[63&u]);l=d,d=p,p=l}p=p>>>1|p<<31,p^=l=1431655765&((d=d>>>1|d<<31)>>>1^p),p^=(l=16711935&(p>>>8^(d^=l<<1)))<<8,p^=(l=858993459&(p>>>2^(d^=l)))<<2,p^=l=65535&((d^=l)>>>16^p),p^=l=252645135&((d^=l<<16)>>>4^p),d^=l<<4,1==r&&(a?(f=d,h=p):(d^=m,p^=v)),D+=String.fromCharCode(d>>>24,d>>>16&255,d>>>8&255,255&d,p>>>24,p>>>16&255,p>>>8&255,255&p),512==(I+=8)&&(N+=D,D="",I=0)}return N+D},des_createKeys:function(e){for(var t,a,r,n=new Array(0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964),o=new Array(0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697),i=new Array(0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272),s=new Array(0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144),l=new Array(0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256),c=new Array(0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488),u=new Array(0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746),d=new Array(0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568),p=new Array(0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578),g=new Array(0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488),f=new Array(0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800),m=new Array(0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744),h=new Array(0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128),v=new Array(0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261),b=e.length>8?3:1,A=new Array(32*b),y=new Array(0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0),x=0,_=0,S=0;S<b;S++){var E=e.charCodeAt(x++)<<24|e.charCodeAt(x++)<<16|e.charCodeAt(x++)<<8|e.charCodeAt(x++),w=e.charCodeAt(x++)<<24|e.charCodeAt(x++)<<16|e.charCodeAt(x++)<<8|e.charCodeAt(x++);E^=(r=252645135&(E>>>4^w))<<4,E^=r=65535&((w^=r)>>>-16^E),E^=(r=858993459&(E>>>2^(w^=r<<-16)))<<2,E^=r=65535&((w^=r)>>>-16^E),E^=(r=1431655765&(E>>>1^(w^=r<<-16)))<<1,E^=r=16711935&((w^=r)>>>8^E),r=(E^=(r=1431655765&(E>>>1^(w^=r<<8)))<<1)<<8|(w^=r)>>>20&240,E=w<<24|w<<8&16711680|w>>>8&65280|w>>>24&240,w=r;for(var C=0;C<y.length;C++)y[C]?(E=E<<2|E>>>26,w=w<<2|w>>>26):(E=E<<1|E>>>27,w=w<<1|w>>>27),w&=-15,t=n[(E&=-15)>>>28]|o[E>>>24&15]|i[E>>>20&15]|s[E>>>16&15]|l[E>>>12&15]|c[E>>>8&15]|u[E>>>4&15],r=65535&((a=d[w>>>28]|p[w>>>24&15]|g[w>>>20&15]|f[w>>>16&15]|m[w>>>12&15]|h[w>>>8&15]|v[w>>>4&15])>>>16^t),A[_++]=t^r,A[_++]=a^r<<16}return A},stringToBase64:function(e){for(var t="",a=new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"),r=0;r<e.length;r++)t+=a[e.charCodeAt(r)>>4]+a[15&e.charCodeAt(r)];var n=t.replace(/\r|\n/g,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ");t="";try{o=String.fromCharCode.apply(null,n)}catch(e){for(var o="",i=(r=0,n.length);r<i;r++)o+=String.fromCharCode(n[r])}return Cipher.btoa(o,null)},base64ToString:function(e){for(var t=new Array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","+","/"),a=new Object,r=0;r<t.length;r++)a[t[r]]=r;a["="]=0;var n,o,i,s,l="",c=e.length;for(e+="====",r=0;r<c;r+=4)n=e.charAt(r),o=e.charAt(r+1),i=e.charAt(r+2),s=e.charAt(r+3),l+=String.fromCharCode(a[n]<<2&255|a[o]>>4),"="!=i&&(l+=String.fromCharCode(a[o]<<4&255|a[i]>>2)),"="!=s&&(l+=String.fromCharCode(a[i]<<6&255|a[s]));return l},btoa:function(e,t){for(var a=(1==t?Cipher.tableStr_URL_SAFE:Cipher.tableStr).split(""),r=0,n=0,o=e.length/3,i=[];r<o;++r){var s=e.charCodeAt(n++),l=e.charCodeAt(n++),c=e.charCodeAt(n++);if((s|l|c)>
1255)throw new Error("String contains an invalid character");i[i.length]=a[s>>2]+a[s<<4&63|l>>4]+(isNaN(l)?"=":a[l<<2&63|c>>6])+(isNaN(l+c)?"=":a[63&c])}return i.join("")}};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.