ar-poncho 2.0.280 → 2.0.282

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/js/poncho.js CHANGED
@@ -579,6 +579,7 @@ function ponchoTableDependant(opt) {
579
579
  var gapi_data;
580
580
  var filtersList = [];
581
581
  var filtro = {};
582
+ var asFilter = {};
582
583
 
583
584
  // Loader
584
585
  document.querySelector("#ponchoTable").classList.add("state-loading");
@@ -653,7 +654,7 @@ function ponchoTableDependant(opt) {
653
654
  * Retorna los valores de los filtros
654
655
  */
655
656
  const _filterValues = () => {
656
- return [...document.querySelectorAll("[data-filter]")].map(e => e.value);
657
+ return [...document.querySelectorAll("[data-filter]")].map(e => e.value);
657
658
  };
658
659
 
659
660
  /**
@@ -711,7 +712,8 @@ function ponchoTableDependant(opt) {
711
712
  .sort(sortAlphaNumeric);
712
713
 
713
714
  const tplCol = document.createElement("div");
714
- tplCol.className = (opt.filterClassList ? opt.filterClassList : "col-sm-4");
715
+ tplCol.className = (opt.filterClassList ?
716
+ opt.filterClassList : "col-sm-4");
715
717
 
716
718
  const tplForm = document.createElement("div");
717
719
  tplForm.className = "form-group";
@@ -769,7 +771,8 @@ function ponchoTableDependant(opt) {
769
771
  // CONTENIDO FILAS
770
772
  gapi_data.entries.forEach(entry => {
771
773
  // si se desea modificar la entrada desde opciones
772
- entry = (opt.customEntry ? opt.customEntry(entry) : entry);
774
+ entry = (typeof opt.customEntry === "function" &&
775
+ opt.customEntry !== null ? opt.customEntry(entry) : entry);
773
776
 
774
777
  // Inserta el row.
775
778
  const tbodyRow = tableTbody.insertRow();
@@ -817,7 +820,13 @@ function ponchoTableDependant(opt) {
817
820
  const flterMatrix = (gapi_data, filtersList) => {
818
821
  let filters = {};
819
822
  filtersList.forEach((filter, key) => {
820
- const entiresByFilter = gapi_data.entries.map(entry => entry[filter]);
823
+ let entiresByFilter = [];
824
+ if(asFilter.hasOwnProperty(filtersList[key])){
825
+ entiresByFilter = asFilter[filtersList[key]];
826
+ } else {
827
+ entiresByFilter = gapi_data.entries.map(entry => entry[filter]);
828
+ }
829
+
821
830
  const uniqueEntries = distinct(entiresByFilter);
822
831
  uniqueEntries.sort(sortAlphaNumeric);
823
832
  filter = filter.replace("filtro-", "");
@@ -867,11 +876,21 @@ function ponchoTableDependant(opt) {
867
876
  * @return {object} Listado de elementos únicos para el select.
868
877
  */
869
878
  const _allFromParent = (parent, children, label) => {
870
- const filterList = gapi_data.entries.map(e => {
879
+ const filterList = gapi_data.entries.flatMap(e => {
880
+ const evaluatedEntry = e[filtersList[_parentElement(children)]];
871
881
  if(e[filtersList[_parentElement(parent)]] == label || label == ""){
872
- return e[filtersList[_parentElement(children)]];
882
+ if(_isCustomFilter(children, filtro)){
883
+ const customFilters = _customFilter(children, filtro)
884
+ .filter(e => {
885
+ return _toCompareString(evaluatedEntry)
886
+ .includes(_toCompareString(e));
887
+ });
888
+ return customFilters;
889
+ }
890
+ return evaluatedEntry;
873
891
  }
874
892
  return false;
893
+
875
894
  }).filter(f => f);
876
895
 
877
896
  const uniqueList = distinct(filterList);
@@ -879,6 +898,14 @@ function ponchoTableDependant(opt) {
879
898
  return uniqueList;
880
899
  };
881
900
 
901
+ /**
902
+ * Prepara un string para una comparación case sensitive y sin
903
+ * caracteres especiales.
904
+ * @param {string} value Valor a comparar.
905
+ * @returns {boolean}
906
+ */
907
+ const _toCompareString = (value) => replaceSpecialChars(value.toLowerCase());
908
+
882
909
  /**
883
910
  * Lista los valores que deben ir en un filtro según su parent.
884
911
  *
@@ -891,12 +918,23 @@ function ponchoTableDependant(opt) {
891
918
  const values = _filterValues();
892
919
 
893
920
  // Recorro todas las entradas del JSON
894
- const items = gapi_data.entries.map(entry => {
921
+ const items = gapi_data.entries.flatMap(entry => {
895
922
  const range = _validateSteps(parent, entry, label, values);
896
923
  if(
897
924
  (entry[filtersList[_parentElement(children - 1)]] == label) &&
898
925
  (range)){
899
- return entry[filtersList[_parentElement(children)]];
926
+ const evaluatedEntry = entry[filtersList[_parentElement(children)]];
927
+ if(_isCustomFilter(children, filtro)){
928
+ const customFilters = _customFilter(children, filtro)
929
+ .filter(e => {
930
+ return _toCompareString(evaluatedEntry)
931
+ .includes(_toCompareString(e));
932
+ });
933
+ return customFilters;
934
+ } else {
935
+ return evaluatedEntry;
936
+ }
937
+
900
938
  }
901
939
  return;
902
940
  }).filter(f => f);
@@ -906,6 +944,32 @@ function ponchoTableDependant(opt) {
906
944
  return uniqueList;
907
945
  };
908
946
 
947
+ /**
948
+ * Tiene filtros personalizados
949
+ * @param {integer} key Indice de filtro
950
+ * @returns {boolean}
951
+ */
952
+ _isCustomFilter = (key) => {
953
+ const filtersKeys = Object.keys(filtro);
954
+ if(asFilter.hasOwnProperty(`filtro-${filtersKeys[key]}`)){
955
+ return true
956
+ }
957
+ return false;
958
+ };
959
+
960
+ /**
961
+ * Listado de filtros personalizado
962
+ * @param {integer} key Indice de filtro
963
+ * @returns {object}
964
+ */
965
+ _customFilter = (key) => {
966
+ const filtersKeys = Object.keys(filtro);
967
+ if(asFilter.hasOwnProperty(`filtro-${filtersKeys[key]}`)){
968
+ return asFilter[`filtro-${filtersKeys[key]}`];
969
+ }
970
+ return [];
971
+ };
972
+
909
973
  /**
910
974
  * Filtra select hijos en base a un item del padre.
911
975
  *
@@ -931,7 +995,8 @@ function ponchoTableDependant(opt) {
931
995
 
932
996
  select.appendChild(_optionSelect(i, "Todos", "", true));
933
997
  itemList.forEach(e => {
934
- // Mantengo el filtro del hijo si existe en el listado filtrado.
998
+ // Mantengo el filtro del hijo si existe en el
999
+ // listado filtrado.
935
1000
  let checked = (filterValues[i] == e ? true : false);
936
1001
  select.appendChild(_optionSelect(i, e, e, checked));
937
1002
  });
@@ -995,8 +1060,10 @@ function ponchoTableDependant(opt) {
995
1060
  "sPrevious": "<"
996
1061
  },
997
1062
  "oAria": {
998
- "sSortAscending": ": Activar para ordenar la columna de manera ascendente",
999
- "sSortDescending": ": Activar para ordenar la columna de manera descendente",
1063
+ "sSortAscending":
1064
+ ": Activar para ordenar la columna de manera ascendente",
1065
+ "sSortDescending":
1066
+ ": Activar para ordenar la columna de manera descendente",
1000
1067
  "paginate": {
1001
1068
  "first": 'Ir a la primera página',
1002
1069
  "previous": 'Ir a la página anterior',
@@ -1052,14 +1119,22 @@ function ponchoTableDependant(opt) {
1052
1119
  .indexOf(`filtro-${filter}`);
1053
1120
  };
1054
1121
  filterValues.forEach((f, k) => {
1122
+
1055
1123
  const columnIndex = filterIndex(filters[k]);
1056
1124
  const term = _searchTerm(filterValues[k]);
1057
- const cleanTerm = _searchTerm(replaceSpecialChars(filterValues[k]));
1058
-
1059
- tabla.columns(columnIndex).search(
1060
- (filterValues[k] ? `^(${term}|${cleanTerm})$` : ""),
1061
- true, false, true
1062
- )
1125
+ const cleanTerm = _searchTerm(
1126
+ replaceSpecialChars(filterValues[k]));
1127
+ if(_isCustomFilter(k, filtro)){
1128
+ tabla.columns(columnIndex)
1129
+ .search(_toCompareString(filterValues[k]));
1130
+ } else {
1131
+ tabla
1132
+ .columns(columnIndex)
1133
+ .search(
1134
+ (filterValues[k] ? `^(${term}|${cleanTerm})$` : ""),
1135
+ true, false, true
1136
+ );
1137
+ }
1063
1138
  });
1064
1139
  tabla.draw();
1065
1140
  });
@@ -1074,17 +1149,27 @@ function ponchoTableDependant(opt) {
1074
1149
  jQuery.getJSON(url, function(data){
1075
1150
  const gapi = new GapiSheetData();
1076
1151
  gapi_data = gapi.json_data(data);
1152
+
1153
+ gapi_data.entries = (
1154
+ typeof opt.refactorEntries === "function" &&
1155
+ opt.refactorEntries !== null ?
1156
+ opt.refactorEntries(gapi_data.entries) : gapi_data.entries
1157
+ );
1077
1158
  // Listado de filtros
1078
1159
  filtersList = Object
1079
1160
  .keys(gapi_data.headers)
1080
1161
  .filter(e => e.startsWith("filtro-"));
1081
1162
 
1163
+ asFilter = (opt.asFilter ? opt.asFilter(gapi_data.entries) : {});
1082
1164
  filtro = flterMatrix(gapi_data, filtersList);
1165
+
1083
1166
  createTable(gapi_data);
1084
1167
  createFilters(gapi_data);
1085
1168
 
1086
- document.querySelector("#ponchoTableSearchCont").style.display = "block";
1087
- document.querySelector("#ponchoTable").classList.remove("state-loading");
1169
+ document.querySelector("#ponchoTableSearchCont")
1170
+ .style.display = "block";
1171
+ document.querySelector("#ponchoTable")
1172
+ .classList.remove("state-loading");
1088
1173
  initDataTable();
1089
1174
  }); // end async
1090
1175
  };
@@ -1 +1 @@
1
- const ponchoColor=e=>{let t;switch(e.toLocaleLowerCase()){case"celeste":case"info":t="#2897d4";break;case"verde":case"success":t="#2e7d33";break;case"rojo":case"danger":t="#c62828";break;case"amarillo":case"warning":t="#f9a822";break;case"azul":case"primary":t="#0072bb";break;case"negro":case"black":t="#333";break;case"uva":t="#6a1b99";break;case"gris":case"muted":t="#525252";break;case"grisintermedio":case"gris-area":case"gray":t="#f2f2f2";break;case"celesteargentina":case"celeste-argentina":t="#37bbed";break;case"fucsia":t="#ec407a";break;case"arandano":t="#c2185b";break;case"cielo":t="#039be5";break;case"verdin":t="#6ea100";break;case"lima":t="#cddc39";break;case"maiz":case"maíz":t="#ffce00";break;case"tomate":t="#ef5350";break;case"naranjaoscuro":case"naranja":t="#EF6C00";break;case"verdeazulado":case"verde-azulado":t="#008388";break;case"escarapela":t="#2cb9ee";break;case"lavanda":t="#9284be";break;case"mandarina":t="#f79525";break;case"palta":t="#50b7b2";break;case"cereza":t="#ed3d8f";break;case"limon":t="#d7df23";break;case"verdejade":case"verde-jade":t="#066";break;case"verdealoe":case"verde-aloe":t="#4fbb73";break;case"verdecemento":case"verde-cemento":t="#b4beba";break;default:t=e}return t},replaceSpecialChars=e=>{if(!e)return"";var t="àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìıİłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż",a="aaaaaaaaaacccddeeeeeeeegghiiiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz";const s=t+t.toUpperCase(),r=a+a.toUpperCase();t=new RegExp(s.split("").join("|"),"g");return e.toString().replace(t,e=>r.charAt(s.indexOf(e)))},slugify=e=>{if(!e)return e;const t="àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìıİłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;";var a=new RegExp(t.split("").join("|"),"g");return e.toString().toLowerCase().replace(/\s+/g,"-").replace(a,e=>"aaaaaaaaaacccddeeeeeeeegghiiiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------".charAt(t.indexOf(e))).replace(/&/g,"-and-").replace(/[^\w\-]+/g,"").replace(/\-\-+/g,"-").replace(/^-+/,"").replace(/-+$/,"")};async function fetch_json(e,t="GET"){e=await fetch(e,{method:t,headers:{Accept:"application/json","Content-Type":"application/json"}});if(e.ok)return e.json();throw new Error("HTTP error! status: "+e.status)}const secureHTML=(e,t=[])=>{var a;return!t.some(e=>"*"===e)&&(e=e.toString().replace(/</g,"&lt;").replace(/>/g,"&gt;"),0<t.length)?(a=new RegExp("&lt;("+t.join("|")+")(.*?)&gt;","g"),t=new RegExp("&lt;/("+t.join("|")+")(.*?)&gt;","g"),e.replace(a,"<$1$2>").replace(t,"</$1>")):e},getScroll=()=>{var e,t;return null!=window.pageYOffset?[pageXOffset,pageYOffset]:(e=(t=document).documentElement,t=t.body,[e.scrollLeft||t.scrollLeft||0,e.scrollTop||t.scrollTop||0])};function ponchoTable(s){var l,t,c=[],d=[],r=[],p=[],o="",h=[],u="";function a(e){jQuery.getJSON(e,function(e){function t(e){return e.replace(/έ/g,"ε").replace(/[ύϋΰ]/g,"υ").replace(/ό/g,"ο").replace(/ώ/g,"ω").replace(/ά/g,"α").replace(/[ίϊΐ]/g,"ι").replace(/ή/g,"η").replace(/\n/g," ").replace(/[áÁ]/g,"a").replace(/[éÉ]/g,"e").replace(/[íÍ]/g,"i").replace(/[óÓ]/g,"o").replace(/[úÚ]/g,"u").replace(/ê/g,"e").replace(/î/g,"i").replace(/ô/g,"o").replace(/è/g,"e").replace(/ï/g,"i").replace(/ü/g,"u").replace(/ã/g,"a").replace(/õ/g,"o").replace(/ç/g,"c").replace(/ì/g,"i")}c=e.values,jQuery.each(Object.keys(c[0]),function(e,t){c[0][t]&&(d.push(c[0][t]),r.push(t),o+="<th>"+c[1][t]+"</th>",h.push(c[1][t]))}),jQuery("#ponchoTable caption").html(s.tituloTabla),jQuery("#ponchoTable thead tr").empty(),jQuery("#ponchoTable thead tr").append(o),jQuery.each(c,function(o,e){var i,n;1<o&&(n=i="",jQuery.each(d,function(e,t){var a,s="",r=c[o][e];d[e].includes("btn-")&&r&&(r='<a aria-label="'+(a=c[0][e].replace("btn-","").replace("-"," "))+'" class="btn btn-primary btn-sm margin-btn" target="_blank" href="'+r+'">'+a+"</a>"),d[e].includes("filtro-")&&r&&(l=e,a=c[1][e],jQuery("#tituloFiltro").html(a),p.push(r)),d[e].includes("fecha-")&&r&&(a=r.split("/"),r='<span style="display:none;">'+new Date(a[2],a[1]-1,a[0]).toISOString().split("T")[0]+"</span>"+r),r||(r="",s="hidden-xs"),i+=r,r=(new showdown.Converter).makeHtml(r),n+='<td class="'+s+'" data-title="'+h[e]+'">'+r+"</td>"}),""!=i&&(u=(u+="<tr>")+n+"</tr>"))}),jQuery.each(p.filter(function(e,t,a){return t===a.indexOf(e)}),function(e,t){jQuery("#ponchoTableFiltro").append("<option>"+t+"</option>")}),jQuery("#ponchoTable tbody").empty(),jQuery("#ponchoTableSearchCont").show(),jQuery("#ponchoTable tbody").append(u),jQuery("#ponchoTable").removeClass("state-loading");var e=jQuery.fn.DataTable.ext.type.search,a=(e.string=function(e){return e?"string"==typeof e?t(e):e:""},e.html=function(e){return e?"string"==typeof e?t(e.replace(/<.*?>/g,"")):e:""},jQuery.isFunction(jQuery.fn.DataTable.ext.order.intl)&&(jQuery.fn.DataTable.ext.order.intl("es"),jQuery.fn.DataTable.ext.order.htmlIntl("es")),jQuery("#ponchoTable").DataTable({lengthChange:!1,autoWidth:!1,pageLength:s.cantidadItems,columnDefs:[{type:"html-num",targets:s.tipoNumero},{targets:s.ocultarColumnas,visible:!1}],ordering:s.orden,order:[[s.ordenColumna-1,s.ordenTipo]],dom:"<'row'<'col-sm-6'l><'col-sm-6'f>><'row'<'col-sm-12'i>><'row'<'col-sm-12'tr>><'row'<'col-md-offset-3 col-md-6 col-sm-offset-2 col-sm-8'p>>",language:{sProcessing:"Procesando...",sLengthMenu:"Mostrar _MENU_ registros",sZeroRecords:"No se encontraron resultados",sEmptyTable:"Ningún dato disponible en esta tabla",sInfo:"_TOTAL_ resultados",sInfoEmpty:"No hay resultados",sInfoFiltered:"",sInfoPostFix:"",sSearch:"Buscar:",sUrl:"",sInfoThousands:".",sLoadingRecords:"Cargando...",oPaginate:{sFirst:"<<",sLast:">>",sNext:">",sPrevious:"<"},oAria:{sSortAscending:": Activar para ordenar la columna de manera ascendente",sSortDescending:": Activar para ordenar la columna de manera descendente",paginate:{first:"Ir a la primera página",previous:"Ir a la página anterior",next:"Ir a la página siguiente",last:"Ir a la última página"}}}}));jQuery(document).ready(function(){jQuery("#ponchoTableSearch").keyup(function(){a.search(jQuery.fn.DataTable.ext.type.search.string(this.value)).draw()})}),jQuery("#ponchoTable_filter").parent().parent().remove(),1<jQuery("#ponchoTableFiltro option").length&&jQuery("#ponchoTableFiltroCont").show(),jQuery("#ponchoTableFiltro").on("change",function(){var e=jQuery.fn.DataTable.ext.type.search.string(jQuery(this).val());""!=e?a.column(l).every(function(){this.search(e?"^"+e+"$":"",!0,!1).draw()}):a.search("").columns().search("").draw()})})}jQuery.fn.DataTable.isDataTable("#ponchoTable")&&jQuery("#ponchoTable").DataTable().destroy(),s.jsonUrl?a(s.jsonUrl):(t=s.hojaNumero,jQuery.getJSON("https://sheets.googleapis.com/v4/spreadsheets/"+s.idSpread+"/?alt=json&key=AIzaSyCq2wEEKL9-6RmX-TkW23qJsrmnFHFf5tY",function(e){e=e.sheets[t-1].properties.title;a("https://sheets.googleapis.com/v4/spreadsheets/"+s.idSpread+"/values/"+e+"?alt=json&key=AIzaSyCq2wEEKL9-6RmX-TkW23qJsrmnFHFf5tY")}))}function ponchoTableDependant(u){var m,_=[],b={};document.querySelector("#ponchoTable").classList.add("state-loading"),jQuery.fn.DataTable.isDataTable("#ponchoTable")&&jQuery("#ponchoTable").DataTable().destroy();const g=(e,t)=>e.toString().localeCompare(t.toString(),"es",{numeric:!0}),y=e=>[...new Set(e)],v=(e=0,t,a,s=!1)=>{var r=document.createElement("option");return r.value=a.toString().trim(),r.dataset.column=e,r.textContent=t.toString().trim(),s&&r.setAttribute("selected","selected"),r},l=e=>e.toString().replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),d=e=>e<=0?0:e,a=()=>[...document.querySelectorAll("[data-filter]")].map(e=>e.value),k=(e,t)=>{var a=document.createElement("a");return a.setAttribute("aria-label",e),a.classList.add("btn","btn-primary","btn-sm","margin-btn"),a.href=t,a.textContent=e,a.outerHTML},C=e=>{var t=e.split("/"),t=(t.reverse(),t.join("-")),a=document.createElement("datetime");return a.setAttribute("datetime",t),a.textContent=e,a.outerHTML},n=(i,n,l)=>{n=n==_.length?n-1:n;const c=a();var e=m.entries.map(e=>{t=i,a=e,s=l,r=c;var t,a,s,r,o=[...Array(d(t+1)).keys()].map(e=>a[_[d(t-1)]]==r[d(t-1)]&&a[_[d(t)]]==s||""==r[d(t-1)]).every(e=>e);if(e[_[d(n-1)]]==l&&o)return e[_[d(n)]]}).filter(e=>e),e=y(e);return e.sort(g),e},s=(t,s)=>{var r=Object.keys(b);const o=a();for(let a=t+1;a<=r.length&&r.length!=a;a++){let e=n(t,a,s);0==e.length&&(e=((t,a,s)=>{var e=m.entries.map(e=>(e[_[d(t)]]==s||""==s)&&e[_[d(a)]]).filter(e=>e),e=y(e);return e.sort(g),e})(t,a,s));const i=document.querySelector("#"+r[a]);i.innerHTML="",i.appendChild(v(a,"Todos","",!0)),e.forEach(e=>{var t=o[a]==e;i.appendChild(v(a,e,e,t))})}};function x(){var e=jQuery.fn.DataTable.ext.type.search;e.string=function(e){return e?"string"==typeof e?replaceSpecialChars(e):e:""},e.html=function(e){return e?"string"==typeof e?replaceSpecialChars(e.replace(/<.*?>/g,"")):e:""};let n=jQuery("#ponchoTable").DataTable({lengthChange:!1,autoWidth:!1,pageLength:u.cantidadItems,columnDefs:[{type:"html-num",targets:u.tipoNumero},{targets:u.ocultarColumnas,visible:!1}],ordering:u.orden,order:[[u.ordenColumna-1,u.ordenTipo]],dom:"<'row'<'col-sm-6'l><'col-sm-6'f>><'row'<'col-sm-12'i>><'row'<'col-sm-12'tr>><'row'<'col-md-offset-3 col-md-6 col-sm-offset-2 col-sm-8'p>>",language:{sProcessing:"Procesando...",sLengthMenu:"Mostrar _MENU_ registros",sZeroRecords:"No se encontraron resultados",sEmptyTable:"Ningún dato disponible en esta tabla",sInfo:"_TOTAL_ resultados",sInfoEmpty:"No hay resultados",sInfoFiltered:"",sInfoPostFix:"",sSearch:"Buscar:",sUrl:"",sInfoThousands:".",sLoadingRecords:"Cargando...",oPaginate:{sFirst:"<<",sLast:">>",sNext:">",sPrevious:"<"},oAria:{sSortAscending:": Activar para ordenar la columna de manera ascendente",sSortDescending:": Activar para ordenar la columna de manera descendente",paginate:{first:"Ir a la primera página",previous:"Ir a la página anterior",next:"Ir a la página siguiente",last:"Ir a la última página"}}}});jQuery("#ponchoTableSearch").keyup(function(){n.search(jQuery.fn.DataTable.ext.type.search.string(this.value)).draw()}),jQuery("#ponchoTable_filter").parent().parent().remove(),1<jQuery("#ponchoTableFiltro option").length&&jQuery("#ponchoTableFiltroCont").show(),jQuery("select[data-filter]").change(function(){var e=jQuery(this).find("option:selected").data("column"),t=jQuery(this).find("option:selected").val();s(e,t),n.columns().search("").columns().search("").draw();const o=Object.keys(b),i=a();i.forEach((e,t)=>{a=o[t];var a=Object.keys(m.headers).indexOf("filtro-"+a),s=l(i[t]),r=l(replaceSpecialChars(i[t]));n.columns(a).search(i[t]?`^(${s}|${r})$`:"",!0,!1,!0)}),n.draw()})}const t=e=>{jQuery.getJSON(e,function(e){var t=new GapiSheetData;m=t.json_data(e),_=Object.keys(m.headers).filter(e=>e.startsWith("filtro-")),b=((s,e)=>{let r={};return e.forEach((t,a)=>{var e=s.entries.map(e=>e[t]),e=y(e);e.sort(g),t=t.replace("filtro-",""),r[t]=[],e.forEach(e=>{r[t].push({columna:a,value:e})})}),r})(m,_);{var r=m;(t=document.querySelector("#ponchoTable thead")).innerHTML="";const c=document.createElement("tr"),d=(Object.keys(r.headers).forEach((e,t)=>{var a=document.createElement("th");a.textContent=r.headers[e],a.setAttribute("scope","col"),c.appendChild(a)}),t.appendChild(c),(t=document.querySelector("#ponchoTable caption")).innerHTML="",t.textContent=u.tituloTabla,document.querySelector("#ponchoTable tbody"));d.innerHTML="",r.entries.forEach(a=>{a=u.customEntry?u.customEntry(a):a;const s=d.insertRow();Object.keys(r.headers).forEach(e=>{filas=a[e],e.startsWith("btn-")&&""!=filas?filas=k(r.headers[e],filas):e.startsWith("fecha-")&&""!=filas&&(filas=C(filas));var t=s.insertCell(),e=(t.dataset.title=r.headers[e],""==filas&&(t.className="hidden-xs"),new showdown.Converter);t.innerHTML=e.makeHtml(filas)})})}var a=m,s=document.querySelector("#ponchoTableFiltro");for(f in s.innerHTML="",b){const p=b[f][0].columna||0;var o=b[f].map(e=>e.value).sort(g),i=document.createElement("div"),n=(i.className=u.filterClassList||"col-sm-4",document.createElement("div")),l=(n.className="form-group",document.createElement("label"));l.setAttribute("for",f),l.textContent=a.headers["filtro-"+f];const h=document.createElement("select");h.classList.add("form-control"),h.dataset.filter=1,h.name=f,h.id=f,h.appendChild(v(p,"Todos","",!0)),o.forEach(e=>{h.appendChild(v(p,e,e,!1))}),n.appendChild(l),n.appendChild(h),i.appendChild(n),s.appendChild(i)}document.querySelector("#ponchoTableSearchCont").style.display="block",document.querySelector("#ponchoTable").classList.remove("state-loading"),x()})};if(u.jsonUrl)t(u.jsonUrl);else if(u.hojaNombre&&u.idSpread){var e=(new GapiSheetData).url(u.hojaNombre,u.idSpread);t(e)}else{if(!u.hojaNumero||!u.idSpread)throw"¡Error! No hay datos suficientes para crear la tabla.";{var r=u.hojaNumero;const o=new GapiSheetData;e=["https://sheets.googleapis.com/v4/spreadsheets/",u.idSpread,"/?alt=json&key=",o.gapi_key].join("");jQuery.getJSON(e,function(e){e=e.sheets[r-1].properties.title,e=o.url(e,u.idSpread);t(e)})}}}jQuery("#ponchoTable").addClass("state-loading");var content_popover=document.getElementById("content-popover");function popshow(){content_popover.classList.toggle("hidden")}function pophidde(){content_popover.classList.add("hidden")}var ponchoUbicacion=function(e){var a,s,r,o,t="/profiles/argentinagobar/themes/contrib/poncho/resources/jsons/geoprovincias.json",i="/profiles/argentinagobar/themes/contrib/poncho/resources/jsons/geolocalidades.json",n=jQuery('input[name="submitted['+e.provincia+']"]'),l=jQuery('input[name="submitted['+e.localidad+']"]');function c(e){return e.charAt(0).toUpperCase()+e.slice(1)}function d(e,t,a,s=!1,r=!1,o=!1){var i=jQuery("<select></select>").attr("id",t).attr("name",e).addClass("form-control form-select").prop("required",s);return r&&i.append("<option value=''>Seleccione una opción</option>"),jQuery.each(a,function(e,t){let a="";o==t.nombre&&(a='selected="selected"'),i.append("<option value='"+t.id+"' "+a+">"+t.nombre+"</option>")}),i}function p(e,t){var a=l.prop("required");return n.val()?d("sLocalidades","sLocalidades",e.filter(function(e){return String(e.provincia.id)==String(t)}).map(function(e){return e.departamento.nombre&&(e.nombre=c(e.departamento.nombre.toLowerCase())+" - "+c(e.nombre.toLowerCase())),e}).sort(function(e,t){e=e.nombre.toUpperCase(),t=t.nombre.toUpperCase();return e.localeCompare(t)}),a,emptyOption=!!l.val(),l.val()):d("sLocalidades","sLocalidades",[],a,!0,!1)}t=e.urlProvincias||t,i=e.urlLocalidades||i,jQuery.getJSON(t,function(e){var t;a=[],e.results.forEach(function(e,t){a.push(e)}),e=[],e=(t=a).sort(function(e,t){e=e.nombre.toUpperCase(),t=t.nombre.toUpperCase();return e.localeCompare(t)}),t=n.prop("required"),(r=d("sProvincias","sProvincias",e,t,!0,n.val())).on("change",function(e){var t;n.val(""),l.val(""),o.children("option:not(:first)").remove(),""!=r.val()&&(n.val(r.find(":selected").text()),t=p(s,r.val()).find("option"),o.append(t),o.val(""))}),n.after(r),jQuery(r).select2()}),jQuery.getJSON(i,function(e){s=[],e.results.forEach(function(e,t){s.push(e)}),(o=p(s,r.val())).on("change",function(e){l.val(""),""!=o.val()&&l.val(o.find(":selected").text())}),l.after(o),jQuery(o).select2()}),n.hide(),l.hide()};function ponchoChart(t){"use strict";var e;function _e(e){return"HeatMap"==e?"heatmap":"Mixed"==e?"mixed":"Stacked Bar"==e?"bar":"Horizontal Bar"==e?"horizontalBar":"Area"==e?"line":"Pie"==e?"pie":"Bar"==e?"bar":"Line"==e?"line":""}function be(e){var t="";switch(e){case"celeste":case"info":t="#2897d4";break;case"verde":case"success":t="#2e7d33";break;case"rojo":case"danger":t="#c62828";break;case"amarillo":case"warning":t="#f9a822";break;case"azul":case"primary":t="#0072bb";break;case"negro":case"black":t="#333";break;case"uva":t="#6a1b99";break;case"gris":case"muted":t="#525252";break;case"grisintermedio":case"gris-area":case"gray":t="#f2f2f2";break;case"celesteargentina":case"celeste-argentina":t="#37bbed";break;case"fucsia":t="#ec407a";break;case"arandano":t="#c2185b";break;case"cielo":t="#039be5";break;case"verdin":t="#6ea100";break;case"lima":t="#cddc39";break;case"maiz":case"maíz":t="#ffce00";break;case"tomate":t="#ef5350";break;case"naranjaoscuro":case"naranja":t="#EF6C00";break;case"verdeazulado":case"verde-azulado":t="#008388";break;case"escarapela":t="#2cb9ee";break;case"lavanda":t="#9284be";break;case"mandarina":t="#f79525";break;case"palta":t="#50b7b2";break;case"cereza":t="#ed3d8f";break;case"limon":t="#d7df23";break;case"verdejade":case"verde-jade":t="#066";break;case"verdealoe":case"verde-aloe":t="#4fbb73";break;case"verdecemento":case"verde-cemento":t="#b4beba";break;default:console.log("No existe color "+e)}return t}function ge(e){var e=e.toString().replace(".",","),t=e.split(","),a=new Intl.NumberFormat("es-AR",{maximumFractionDigits:2}).format(t[0]);return e=1<t.length?a.concat(",",t[1].substr(0,2)):a}function a(e,s){var P,t,a,H,r,o,Q,N,z,i,n,D,B,l,c,G,$,R,d,p,U,h,J,u,V,m,f=[],_=[],b=[],W=[],g=[],y=[],v=[],k=[],C=0,x="",Y=[],j=0,w=[],Z=[],X=0,S=s.posicionLeyendas||"top",E="",E=void 0===s.mostrarLeyendas||s.mostrarLeyendas,T="",T=void 0===s.mostrarTotalStacked||s.mostrarTotalStacked,L=_e(s.tipoGrafico),A=e.values;if(jQuery.each(Object.keys(A[0]),function(e,t){var a;"eje-y"==A[0][e].substr(0,5)?(a=(a=A[0][e].split("-"))[0]+a[1],_.push(a),b.push(e)):"nombre-corto"==A[0][e]&&"heatmap"==L&&(X=e)}),jQuery.each(A,function(r,e){var s;0==r&&jQuery.each(b,function(e,t){var a=A[r][b[e]].split("-"),s=a[0]+a[1];v[s]=[],W.push(a[2]),"mixed"==L&&(3<a.length&&("barra"==a[3]||"linea"==a[3])?Y.push(a[3]):(0==e&&Y.push("barra"),1==e&&Y.push("linea")))}),1==r&&jQuery.each(b,function(e,t){"pie"==L||"heatmap"==L?f.push(A[r][b[e]]):(y.push(A[r][b[e]]),C+=1)}),1<r&&(s=!1,jQuery.each(b,function(e,t){var a=A[0][b[e]].split("-"),a=a[0]+a[1];"pie"==L?v[a].push(A[r][b[e]]):"heatmap"==L?(0==s&&(y.push(A[r][0]),s=!0,C+=1),e!=X&&v[a].push(A[r][b[e]]),e+2==X&&(void 0===A[r][e+2]?Z.push("*"):Z.push(A[r][e+2]))):(0==s&&(f.push(A[r][0]),s=!0),v[a].push(A[r][b[e]]))}))}),"pie"==L?(P=[],jQuery.each(Object.keys(_),function(e,t){e=_[e];v.hasOwnProperty(e)&&P.push(v[e])}),k=P):1==C&&jQuery.each(Object.keys(_),function(e,t){e=_[e];v.hasOwnProperty(e)&&(k=v[e])}),"mixed"!=L||0<(t=s.porcentajesMixed||"").length&&(w=t.split(",")),x=1==s.porcentajes?"line"==L&&1<C?{enabled:!0,callbacks:{label:function(e,t){var a=ge(t.datasets[e.datasetIndex].data[e.index]);return t.datasets[e.datasetIndex].label+": "+a+"%"}},mode:"index",intersect:!1}:"pie"==L?{enabled:!0,callbacks:{label:function(e,t){var a=ge(t.datasets[e.datasetIndex].data[e.index]);return t.labels[e.index]+": "+a+"%"}}}:"Stacked Bar"==s.tipoGrafico?1==T?{enabled:!0,mode:"index",callbacks:{label:function(e,t){var a=ge(t.datasets[e.datasetIndex].data[e.index]);return t.datasets[e.datasetIndex].label+": "+a+"%"},footer:(e,t)=>{e=e.reduce((e,t)=>e+parseFloat(t.yLabel),0);return"Total: "+new Intl.NumberFormat("es-AR",{maximumFractionDigits:2}).format(e)+"%"}}}:{enabled:!0,mode:"index",callbacks:{label:function(e,t){var a=ge(t.datasets[e.datasetIndex].data[e.index]);return t.datasets[e.datasetIndex].label+": "+a+"%"}}}:{enabled:!0,mode:"index",callbacks:{label:function(e,t){var a=ge(t.datasets[e.datasetIndex].data[e.index]);return t.datasets[e.datasetIndex].label+": "+a+"%"}}}:"line"==L&&1<C?{enabled:!0,callbacks:{label:function(e,t){var a=ge(t.datasets[e.datasetIndex].data[e.index]);return t.datasets[e.datasetIndex].label+": "+a}},mode:"index",intersect:!1}:"pie"==L?{enabled:!0,callbacks:{label:function(e,t){var a=ge(t.datasets[e.datasetIndex].data[e.index]);return t.labels[e.index]+": "+a}}}:"Stacked Bar"==s.tipoGrafico&&1<C?1==T?{enabled:!0,mode:"index",intersect:!1,callbacks:{label:function(e,t){var a=ge(t.datasets[e.datasetIndex].data[e.index]);return t.datasets[e.datasetIndex].label+": "+a},footer:(e,t)=>{e=e.reduce((e,t)=>e+parseFloat(t.yLabel),0);return"Total: "+new Intl.NumberFormat("es-AR",{maximumFractionDigits:2}).format(e)}}}:{enabled:!0,mode:"index",intersect:!1,callbacks:{label:function(e,t){var a=ge(t.datasets[e.datasetIndex].data[e.index]);return t.datasets[e.datasetIndex].label+": "+a}}}:{enabled:!0,mode:"index",callbacks:{label:function(e,t){var a=ge(t.datasets[e.datasetIndex].data[e.index]);return t.datasets[e.datasetIndex].label+": "+a}}},"pie"==L&&(W.forEach(function(e,t,a){g.push(be(e))}),console.log("etiquetas --\x3e "+f),console.log("datos --\x3e "+k),console.log("colores --\x3e "+g),t=f,T=k,z=L,i=g,a=s.idComponenteGrafico,D=S,B=x,n=E,a=document.getElementById(a),new Chart(a,{type:z,data:{labels:t,datasets:[{data:T,borderColor:i,backgroundColor:i,borderWidth:2}]},options:{legend:{display:n,position:D},responsive:!0,tooltips:B}})),1==C&&(console.log("etiquetas --\x3e "+f),console.log("datos --\x3e "+k),a=be(W[0]),console.log("color --\x3e "+a),"Line"==s.tipoGrafico&&(z=f,T=k,i=L,n=a,D=y[0],B=s.ejeYenCero,l=s.idComponenteGrafico,c=S,G=x,$=E,l=document.getElementById(l),new Chart(l,{type:i,data:{labels:z,datasets:[{data:T,borderColor:n,backgroundColor:n,borderWidth:2,lineTension:0,fill:!1,label:D}]},options:{legend:{display:$,position:c},tooltips:G,responsive:!0,scales:{yAxes:[{ticks:{beginAtZero:B}}]}}})),"bar"!=L&&"Area"!=s.tipoGrafico||(l=f,T=k,$=L,c=a,G=y[0],H=s.ejeYenCero,r=s.idComponenteGrafico,o=S,Q=x,N=E,r=document.getElementById(r),new Chart(r,{type:$,data:{labels:l,datasets:[{data:T,borderColor:c,backgroundColor:c,borderWidth:2,lineTension:0,label:G}]},options:{legend:{display:N,position:o},tooltips:Q,responsive:!0,scales:{yAxes:[{ticks:{beginAtZero:H}}]}}})),"horizontalBar"==L&&(r=f,T=k,N=L,o=a,Q=y[0],H=s.ejeYenCero,I=s.idComponenteGrafico,re=S,oe=x,ee=E,I=document.getElementById(I),new Chart(I,{type:N,data:{labels:r,datasets:[{data:T,borderColor:o,backgroundColor:o,borderWidth:2,lineTension:0,label:Q}]},options:{legend:{display:ee,position:re},tooltips:oe,responsive:!0,scales:{xAxes:[{ticks:{beginAtZero:H}}]}}}))),1<C)if("heatmap"==L)if(void 0!==s.heatMapColors&&""!=s.heatMapColors&&void 0!==s.heatMapColorsRange&&""!=s.heatMapColorsRange){for(var K=[],I="labelFila",T="labelColumna",ee="labelValor",te=(void 0!==s.datosTooltip&&0<s.datosTooltip.length&&(void 0!==s.datosTooltip[0]&&void 0!==s.datosTooltip[0].labelFila&&(I=s.datosTooltip[0].labelFila),void 0!==s.datosTooltip[1]&&void 0!==s.datosTooltip[1].labelColumna&&(T=s.datosTooltip[1].labelColumna),void 0!==s.datosTooltip[2]&&void 0!==s.datosTooltip[2].labelValor&&(ee=s.datosTooltip[2].labelValor)),jQuery.each(Object.keys(_),function(e,t){e=_[e];v.hasOwnProperty(e)&&(k=v[e],K.push(k))}),[]),O=0;O<y.length;O++){for(var e=[],ae=0;ae<f.length;ae++){k={x:f[ae],y:parseInt(K[ae][O])};e.push(k)}te.push({name:("*"!=Z[O]?Z:y)[O],data:e})}for(var se=[],O=0;O<s.heatMapColorsRange.length-1;O++){e={from:s.heatMapColorsRange[O],to:s.heatMapColorsRange[O+1],color:be(s.heatMapColors[O])};se.push(e)}var re="",re=void 0===s.mostrarEjeY||s.mostrarEjeY,oe=te,ie=s.idComponenteGrafico,ne=y,le=se,ce=I,de=T,pe=ee,T=s.tituloGrafico,M=re,he=S,ue=E,ie=document.getElementById(ie),me=(new ApexCharts(ie,{series:oe,chart:{height:650,type:"heatmap"},dataLabels:{enabled:!1},title:{text:T},tooltip:{custom:function({series:e,seriesIndex:t,dataPointIndex:a,w:s}){e=ge(e[t][a]);return'<div class="arrow_box"><span>'+ce+": "+ne[t]+"<br>"+de+": "+s.globals.labels[a]+"<br>"+pe+": "+e+"</span></div>"}},plotOptions:{heatmap:{shadeIntensity:.5,radius:0,useFillColorAsStroke:!1,colorScale:{ranges:le}}},yaxis:{show:M},legend:{show:ue,position:he},responsive:[{breakpoint:1e3,options:{yaxis:{show:!1},legend:{show:ue,position:"top"}}}]}).render(),document.getElementsByClassName("apexcharts-toolbar"));for(let e=0;e<me.length;e++)me[e].style.display="none"}else void 0!==s.heatMapColors&&""!=s.heatMapColors||console.log("Completar vector con valores para los colores"),void 0!==s.heatMapColorsRange&&""!=s.heatMapColorsRange||console.log("Completar vector con el rango de valores para los colores");else{var q=[],F=0,fe=(W.forEach(function(e,t,a){g.push(be(e))}),console.log("colores --\x3e "+g),0);jQuery.each(Object.keys(_),function(e,t){var a,e=_[e];v.hasOwnProperty(e)&&(k=v[e],console.log("datos --\x3e "+k),"Line"==s.tipoGrafico?a={label:y[F],data:k,borderColor:g[F],fill:!1,borderWidth:2,lineTension:0,backgroundColor:g[F]}:"Bar"==s.tipoGrafico||"Area"==s.tipoGrafico||"Horizontal Bar"==s.tipoGrafico||"Stacked Bar"==s.tipoGrafico?a={label:y[F],data:k,borderColor:g[F],backgroundColor:g[F],borderWidth:2,lineTension:0}:"Mixed"==s.tipoGrafico&&("barra"==(e=Y[fe])?a={label:y[F],data:k,backgroundColor:g[F],yAxisID:"left-y-axis",type:"bar"}:"linea"==e&&(a={label:y[F],data:k,borderColor:g[F],backgroundColor:g[F],type:"line",yAxisID:"right-y-axis",fill:!1})),q.push(a),F+=1,fe+=1)}),"mixed"==L&&(2==w.length?j=2:1==w.length?"eje-y1"==w[0]?j=0:"eje-y2"==w[0]&&(j=1):j=3),console.log("etiquetas --\x3e "+f),console.log("toltip --\x3e"+JSON.stringify(x)),"Stacked Bar"==s.tipoGrafico?(ie=f,T=L,le=q,M=s.idComponenteGrafico,he=s.ejeYenCero,ue=S,w=x,V=E,M=document.getElementById(M),new Chart(M,{type:T,data:{labels:ie,datasets:le},options:{legend:{display:V,position:ue,labels:{textAlign:"center"}},tooltips:w,responsive:!0,scales:{yAxes:[{ticks:{beginAtZero:he},stacked:!0}],xAxes:[{stacked:!0}]}}})):"Mixed"==s.tipoGrafico?(T=f,V="bar",w=q,d=s.idComponenteGrafico,p=s.ejeYenCero,U=S,h=j,j=y[0],J=y[1],u=E,d=document.getElementById(d),new Chart(d,{type:V,data:{labels:T,datasets:w},options:{legend:{display:u,position:U,labels:{textAlign:"center"}},tooltips:{enabled:!0,mode:"single",callbacks:{label:function(e,t){var a="",s=((2==h||e.datasetIndex==h)&&(a="%"),ge(e.yLabel));return t.datasets[e.datasetIndex].label+": "+s+" "+a}}},responsive:!0,scales:{yAxes:[{id:"left-y-axis",type:"linear",position:"left",ticks:{beginAtZero:p,callback:function(e){return e+(1!=h&&2!=h?"":"%")}},scaleLabel:{display:!0,labelString:J,fontColor:"black"}},{id:"right-y-axis",type:"linear",position:"right",ticks:{beginAtZero:p,callback:function(e){return e+(0!=h&&2!=h?"":"%")}},scaleLabel:{display:!0,labelString:j,fontColor:"black"}}]}}})):"Horizontal Bar"==s.tipoGrafico?(d=f,T=L,w=q,u=s.idComponenteGrafico,U=s.ejeYenCero,J=S,p=x,j=E,u=document.getElementById(u),new Chart(u,{type:T,data:{labels:d,datasets:w},options:{legend:{display:j,position:J,labels:{textAlign:"center"}},tooltips:p,responsive:!0,maintainAspectRatio:!0,scales:{xAxes:[{ticks:{beginAtZero:U}}]}}})):(T=f,w=L,j=q,m=s.idComponenteGrafico,R=s.ejeYenCero,S=S,x=x,E=E,m=document.getElementById(m),new Chart(m,{type:w,data:{labels:T,datasets:j},options:{legend:{display:E,position:S,labels:{textAlign:"center"}},tooltips:x,responsive:!0,maintainAspectRatio:!0,scales:{yAxes:[{ticks:{beginAtZero:R}}]}}}))}""!=s.tituloGrafico&&void 0!==s.tituloGrafico&&(m=s.idTagTituloGrafico,w=s.tituloGrafico,document.getElementById(m)&&(document.getElementById(m).innerHTML=w))}!function(e){var t=!1;(e.idSpread&&e.hojaNombre||e.jsonUrl||e.jsonInput)&&void 0!==e.tipoGrafico&&""!=e.tipoGrafico&&void 0!==e.idComponenteGrafico&&""!=e.idComponenteGrafico&&""!=_e(e.tipoGrafico)&&(t=!0);return t}(t)?(void 0!==t.idSpread&&""!=t.idSpread||console.log("Completar valor para la opción de Configuración idSpread"),void 0!==t.hojaNombre&&""!=t.hojaNombre||console.log("Completar valor para la opción de Configuración hojaNombre"),void 0!==t.tipoGrafico&&""!=t.tipoGrafico||console.log("Completar valor para la opción de Configuración tipoGrafico"),void 0!==t.idComponenteGrafico&&""!=t.idComponenteGrafico||console.log("Completar valor para la opción de Configuración idComponenteGrafico"),""==_e(t.tipoGrafico)&&console.log("Ingrese un tipo de gafico válido")):t.jsonInput?(console.log(t.jsonInput),a(jQuery.parseJSON(t.jsonInput),t)):(e=t.jsonUrl||"https://sheets.googleapis.com/v4/spreadsheets/"+t.idSpread+"/values/"+t.hojaNombre+"?alt=json&key=AIzaSyCq2wEEKL9-6RmX-TkW23qJsrmnFHFf5tY",jQuery.getJSON(e,function(e){a(e,t)}))}const gapi_legacy=e=>{const o=e.values[0],i=/ |\/|_/gi;let n=[];return e.values.forEach((e,t)=>{if(0<t){var a={};for(const r in o){var s=e.hasOwnProperty(r)?e[r].trim():"";a["gsx$"+o[r].toLowerCase().replace(i,"")]={$t:s}}n.push(a)}}),{feed:{entry:n}}};class PonchoMap{constructor(e,t){var a={error_reporting:!0,no_info:!1,title:!1,id:"id",template:!1,template_structure:{container_classlist:["info-container"],title_classlist:["h4","text-primary","m-t-0"],definition_list_classlist:["definition-list"],term_classlist:["h6","m-b-0"],definition_classlist:[],definition_list_tag:"dl",term_tag:"dt",definition_tag:"dd"},allowed_tags:[],template_innerhtml:!1,template_markdown:!1,markdown_options:{tables:!0,simpleLineBreaks:!0,extensions:["details","images","alerts","numbers","ejes","button","target","bootstrap-tables","video"]},render_slider:!0,scope:"",slider:!1,scroll:!1,hash:!1,headers:{},header_icons:[],content_selector:!1,map_selector:"map",anchor_delay:0,slider_selector:".slider",map_view:[-40.44,-63.59],map_anchor_zoom:16,map_zoom:4,min_zoom:2,reset_zoom:!0,latitud:"latitud",longitud:"longitud",marker:"azul",tooltip:!1,tooltip_options:{direction:"auto",className:"leaflet-tooltip-own"},marker_cluster_options:{spiderfyOnMaxZoom:!1,showCoverageOnHover:!1,zoomToBoundsOnClick:!0,maxClusterRadius:45,spiderfyDistanceMultiplier:3,spiderLegPolylineOptions:{weight:1,color:"#666",opacity:.5,"fill-opacity":.5}},accesible_menu_extras:[{text:"Ayudá a mejorar el mapa",anchor:"https://www.argentina.gob.ar/sugerencias"}]},s=Object.assign({},a,t);this.error_reporting=s.error_reporting,this.scope=s.scope,this.render_slider=s.render_slider,this.template=s.template,this.template_structure={...a.template_structure,...t.template_structure},this.template_innerhtml=s.template_innerhtml,this.template_markdown=s.template_markdown,this.markdown_options=s.markdown_options,this.allowed_tags=s.allowed_tags,this.map_selector=s.map_selector,this.headers=this.setHeaders(s.headers),this.header_icons=s.header_icons,this.hash=s.hash,this.scroll=s.scroll,this.map_view=s.map_view,this.anchor_delay=s.anchor_delay,this.map_zoom=s.map_zoom,this.min_zoom=s.min_zoom,this.map_anchor_zoom=s.map_anchor_zoom,this.tooltip_options=s.tooltip_options,this.tooltip=s.tooltip,this.marker_cluster_options=s.marker_cluster_options,this.marker_color=s.marker,this.id=s.id,this.title=s.title,this.latitude=s.latitud,this.longitude=s.longitud,this.slider=s.slider,this.no_info=s.no_info,this.reset_zoom=s.reset_zoom,this.slider_selector=this._selectorName(s.slider_selector),this.selected_marker,this.scope_selector=`[data-scope="${this.scope}"]`,this.scope_sufix="--"+this.scope,this.content_selector=s.content_selector||".js-content"+this.scope_sufix,this.data=this.formatInput(e),this.geometryTypes=["Point","LineString","Polygon","MultiPoint","MultiLineString"],this.featureStyle={stroke:"dodgerblue","stroke-opacity":1,"stroke-width":2,"fill-opacity":.5},this.accesible_menu_search=[],this.accesible_menu_filter=[],this.accesible_menu_extras=s.accesible_menu_extras,this.geojson,this.map=new L.map(this.map_selector,{renderer:L.svg()}).setView(this.map_view,this.map_zoom),new L.tileLayer("https://mapa-ign.argentina.gob.ar/osm/{z}/{x}/{-y}.png",{attribution:'Contribuidores: <a href="https://www.ign.gob.ar/AreaServicios/Argenmap/Introduccion" target="_blank">Instituto Geográfico Nacional</a>, <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>'}).addTo(this.map),this.markers=new L.markerClusterGroup(this.marker_cluster_options)}isGeoJSON=e=>"FeatureCollection"===e?.type;get entries(){return this.data.features}get geoJSON(){return this.featureCollection(this.entries)}formatInput=e=>{e.length<1&&this.errorMessage("No se puede visualizar el mapa, el documento está vacío","warning");let t;return t=this.isGeoJSON(e)?e:(e=this.features(e),this.featureCollection(e)),this._setIdIfNotExists(t)};errorMessage=(e=!1,t="danger")=>{document.querySelectorAll("#js-error-message"+this.scope_sufix).forEach(e=>e.remove());var a=document.createElement("div"),s=(a.id="js-error-message"+this.scope_sufix,a.classList.add("poncho-map--message",t),document.createElement("h2")),r=(s.classList.add("h6","title"),s.textContent="¡Se produjo un error!",document.createElement("pre")),o=(r.textContent=e,document.createElement("a"));throw o.href="https://github.com/argob/poncho/blob/master/src/demo/poncho-maps/readme-poncho-maps.md",o.target="_blank",o.textContent="Ayuda sobre las opciones de PonchoMap",o.className="small",o.title="Abre el enlace en una nueva ventana",a.appendChild(s),a.appendChild(r),a.appendChild(o),this.error_reporting&&(s=document.querySelector(this.scope_selector+".poncho-map")).parentNode.insertBefore(a,s),"danger"==t&&document.getElementById(this.map_selector).remove(),console.log(this.critical_error),e};feature=e=>{var t=e[this.latitude],a=e[this.longitude];return[t,a].forEach(e=>{isNaN(Number(e))&&this.errorMessage("El archivo contiene errores en la definición de latitud y longitud.\n "+e)}),delete e[this.latitude],delete e[this.longitude],{type:"Feature",properties:e,geometry:{type:"Point",coordinates:[a,t]}}};featureCollection=e=>({type:"FeatureCollection",features:e});features=e=>e.map(this.feature);_setIdIfNotExists=e=>{var t;return e.features.filter((e,t)=>0===t).every(e=>e.properties.hasOwnProperty("id"))||(t=e.features.map((e,t)=>{var t=t+1,a=this.title&&e.properties[this.title]?"-"+slugify(e.properties[this.title]):"";return e.properties.id=t+a,e}),e.features=t),e};addHash=e=>{if(!this.hash||this.no_info)return null;window.location.hash="#"+e};entry=t=>this.entries.find(e=>e.properties[this.id]==t);searchEntries=(t,e)=>{return e=void 0===e?this.geoJSON:e,t?e.filter(e=>{if(this.searchEntry(t,e.properties))return e}):e};searchEntry=(e,t)=>{for(const r of[...new Set([this.title,...this.search_fields])].filter(e=>e))if(t.hasOwnProperty(r)){var a=replaceSpecialChars(e).toUpperCase(),s=replaceSpecialChars(t[r]).toString().toUpperCase();try{if(s.includes(a))return t}catch(e){console.error(e)}}return null};_selectorName=e=>e.replace(/^(\.|\#)/,"");scrollCenter=()=>{var e=document.getElementById(this.map_selector),t=e.getBoundingClientRect(),e=(e.offsetLeft+e.offsetWidth)/2,t=t.top+window.scrollY;window.scrollTo({top:t,left:e,behavior:"smooth"})};_clearContent=()=>document.querySelector(".js-content"+this.scope_sufix).innerHTML="";toggleSlider=()=>{this.no_info||(document.querySelectorAll(".js-slider"+this.scope_sufix).forEach(e=>{e.classList.toggle(this.slider_selector+"--in")}),document.querySelectorAll(".js-slider"+this.scope_sufix).forEach(e=>{e.style.display=this.isSliderOpen()?"block":"none"}))};_focusOnFeature=t=>{this.map.eachLayer(e=>{e?.options?.id==t&&(e?._path?e._path.focus():e?._icon&&e._icon.focus())})};_clickToggleSlider=()=>document.querySelectorAll(".js-close-slider"+this.scope_sufix).forEach(e=>e.addEventListener("click",()=>{this._clearContent(),this.toggleSlider(),this._focusOnFeature(e.dataset.entryId)}));isSliderOpen=()=>{let t=[];return document.querySelectorAll(".js-slider"+this.scope_sufix).forEach(e=>{e.classList.contains(this.slider_selector+"--in")&&t.push(!0)}),t.some(e=>e)};setContent=t=>{if(!this.no_info){this._focusOnSlider(),this.isSliderOpen()||this.toggleSlider();const a="function"==typeof this.template?this.template(this,t):this.defaultTemplate(this,t);document.querySelectorAll(this.content_selector).forEach(e=>{e.innerHTML=a}),document.querySelectorAll(".js-close-slider"+this.scope_sufix).forEach(e=>{e.dataset.entryId=t[this.id]})}};_focusOnSlider=()=>{var e;this.no_info||(this.isSliderOpen()?document.querySelector(".js-close-slider"+this.scope_sufix).focus():(e=document.querySelector(".js-slider"+this.scope_sufix))&&e.addEventListener("animationend",()=>{document.querySelector(".js-close-slider"+this.scope_sufix).focus()}))};setHeaders=e=>{var t;return[this.template_structure,this.template_structure.mixing].every(e=>e)?(t=this.template_structure.mixing.reduce((e,t)=>{if([t.key].every(e=>e))return{...e,[t.key]:t.header||""}},{}),{...e,...t}):e};header=e=>this.headers.hasOwnProperty(e)?this.headers[e]:e;_renderSlider=()=>{var e,t,a,s;this.render_slider&&!this.no_info&&(document.querySelectorAll(".js-slider"+this.scope_sufix).forEach(e=>e.remove()),(e=document.createElement("button")).classList.add("btn","btn-xs","btn-secondary","btn-close","js-close-slider"+this.scope_sufix),e.title="Cerrar panel",e.setAttribute("role","button"),e.setAttribute("aria-label","Cerrar panel de información"),e.innerHTML='<span class="sr-only">Cerrar</span>✕',(t=document.createElement("a")).setAttribute("tabindex",0),t.id="js-anchor-slider"+this.scope_sufix,(a=document.createElement("div")).classList.add("content-container"),(s=document.createElement("div")).classList.add("content","js-content"+this.scope_sufix),s.tabIndex=0,a.appendChild(s),(s=document.createElement("div")).style.display="none",s.setAttribute("role","region"),s.setAttribute("aria-live","polite"),s.setAttribute("aria-label","Panel de información"),s.classList.add("slider","js-slider"+this.scope_sufix),s.id="slider"+this.scope_sufix,s.appendChild(e),s.appendChild(t),s.appendChild(a),document.querySelector(this.scope_selector+".poncho-map").appendChild(s))};_showSlider=(e,t)=>{e.hasOwnProperty("_latlng")?this.map.setView(e._latlng,this.map_anchor_zoom):this.map.fitBounds(e.getBounds()),e.fireEvent("click")};_showPopup=e=>{e.hasOwnProperty("_latlng")?this.markers.zoomToShowLayer(e,()=>{e.openPopup()}):(this.map.fitBounds(e.getBounds()),e.openPopup())};removeHash=()=>history.replaceState(null,null," ");hasHash=()=>{return window.location.hash.replace("#","")||!1};gotoHashedEntry=()=>{var e=this.hasHash();e&&this.gotoEntry(e)};gotoEntry=t=>{const a=this.entry(t),s=(e,t,a)=>{e.options.hasOwnProperty("id")&&e.options.id==t&&(this._setSelectedMarker(t,e),this.hash&&this.addHash(t),this.slider&&this.hash?this._showSlider(e,a):this._showPopup(e))};this.markers.eachLayer(e=>s(e,t,a)),this.map.eachLayer(e=>{e.hasOwnProperty("feature")&&"Point"!=e.feature.geometry.type&&s(e,t,a)})};_setClickeable=a=>{a.on("keypress click",t=>{document.querySelectorAll(".marker--active").forEach(e=>e.classList.remove("marker--active")),["_icon","_path"].forEach(e=>{t.sourceTarget.hasOwnProperty(e)&&t.sourceTarget[e].classList.add("marker--active")});var e=this.entries.find(e=>e.properties[this.id]==a.options.id);this.setContent(e.properties)})};isFeature=e=>!!e.hasOwnProperty("feature");_clickeableFeatures=()=>{this.reset_zoom&&this.map.eachLayer(e=>{this.isFeature(e)&&"Point"!=e.feature.geometry.type&&"MultiPoint"!=e.feature.geometry.type&&this._setClickeable(e)})};_clickeableMarkers=()=>{this.no_info||this.markers.eachLayer(this._setClickeable)};_urlHash=()=>{const t=e=>{e.on("click",()=>{this.addHash(e.options.id)})};this.markers.eachLayer(t),this.map.eachLayer(e=>{e.hasOwnProperty("feature")&&"Point"!=e.feature.geometry.type&&"MultiPoint"!=e.feature.geometry.type&&t(e)})};removeListElement=(e,t)=>{t=e.indexOf(t);return-1<t&&e.splice(t,1),e};_templateTitle=e=>{if(!e.hasOwnProperty(this.title))return!1;var t=this.template_structure,a=!!t.hasOwnProperty("title")&&t.title,s=this.title||!1;if(t.hasOwnProperty("title")&&"boolean"==typeof t.title)return!1;if(!a&&!s)return!1;a=a||s;let r;t?.header?((s=document.createElement("div")).innerHTML=this._mdToHtml(t.header(this,e)),this.template_innerhtml&&(s.innerHTML=t.header(this,e)),r=s):((r=document.createElement("h2")).classList.add(...t.title_classlist),r.textContent=e[a]);s=document.createElement("header");return s.className="header",s.appendChild(r),s};_templateList=e=>{var t=this.template_structure,a=Object.keys(e);let s=a;if(t.hasOwnProperty("values")&&0<t?.values?.length)s=t.values;else if(t.hasOwnProperty("exclude")&&0<t.exclude.length)for(const r of t.exclude)s=this.removeListElement(a,r);return s};_mdToHtml=e=>{var t,a;return this.template_markdown&&this._markdownEnable()?(t=new showdown.Converter(this.markdown_options),a=secureHTML(e,this.allowed_tags),t.makeHtml((""+a).trim())):e};_markdownEnable=()=>!("undefined"==typeof showdown||!showdown.hasOwnProperty("Converter"));_templateMixing=r=>{if(this.template_structure.hasOwnProperty("mixing")&&0<this.template_structure.mixing.length){var e=this.template_structure.mixing;let s={};return e.forEach(e=>{var{values:e,separator:t=", ",key:a}=e;void 0===a&&this.errorMessage("Mixing requiere un valor en el atributo «key».","warning"),s[a]=e.map(e=>e in r?r[e]:e.toString()).filter(e=>e).join(t)}),Object.assign({},r,s)}return r};_setType=(e,t=!1,a=!1)=>"function"==typeof e?e(this,t,a):e;_lead=e=>{var t,a,s,r;if(this.template_structure.hasOwnProperty("lead"))return this.template_structure.lead.hasOwnProperty("key")||this.errorMessage("Lead requiere un valor en el atributo «key».","warning"),{key:s=!1,css:t="small",style:r=!1}=this.template_structure.lead,(a=document.createElement("p")).textContent=e[s],(s=this._setType(r,e))&&a.setAttribute("style",s),(r=this._setType(t,e))&&a.classList.add(...r.split(" ")),a};_termIcon=(e,t)=>{var a=this.header_icons.find(e=>e.key==t);if(a){var{css:a=!1,style:s=!1,html:r=!1}=a,r=this._setType(r,e,t),s=this._setType(s,e,t),a=this._setType(a,e,t);if(a)return(e=document.createElement("i")).setAttribute("aria-hidden","true"),e.classList.add(...a.split(" ")),s&&e.setAttribute("style",s),e;if(r)return(a=document.createElement("template")).innerHTML=r,a.content}return!1};defaultTemplate=(e,t)=>{t=this._templateMixing(t);var a,s,r=this["template_structure"],o=this._templateList(t),i=this._templateTitle(t),n=document.createElement("article"),l=(n.classList.add(...r.container_classlist),document.createElement(r.definition_list_tag));l.classList.add(...r.definition_list_classlist),l.style.fontSize="1rem";for(const c of o)t.hasOwnProperty(c)&&t[c]&&((a=document.createElement(r.term_tag)).classList.add(...r.term_classlist),(s=this._termIcon(t,c))&&(a.appendChild(s),a.insertAdjacentText("beforeend"," ")),a.insertAdjacentText("beforeend",this.header(c)),(s=document.createElement(r.definition_tag)).classList.add(...r.definition_classlist),s.textContent=t[c],this.template_markdown?s.innerHTML=this._mdToHtml(t[c]):this.template_innerhtml&&(s.innerHTML=secureHTML(t[c],this.allowed_tags)),""!=this.header(c)&&l.appendChild(a),l.appendChild(s));o=this._lead(t);return o&&n.appendChild(o),i&&n.appendChild(i),n.appendChild(l),n.outerHTML};icon=(e="azul")=>new L.icon({iconUrl:"https://www.argentina.gob.ar/sites/default/files/"+`marcador-${e}.svg`,iconSize:[29,40],iconAnchor:[14,40],popupAnchor:[0,-37]});resetView=()=>this.map.setView(this.map_view,this.map_zoom);fitBounds=()=>{try{this.map.fitBounds(this.geojson.getBounds())}catch(e){console.error(e)}};_resetViewButton=()=>{this.reset_zoom&&(document.querySelectorAll(".js-reset-view"+this.scope_sufix).forEach(e=>e.remove()),document.querySelectorAll(this.scope_selector+" .leaflet-control-zoom-in").forEach(e=>{var t=document.createElement("i"),a=(t.classList.add("fa","fa-expand"),t.setAttribute("aria-hidden","true"),document.createElement("a"));a.classList.add("js-reset-view"+this.scope_sufix,"leaflet-control-zoom-reset"),a.href="#",a.title="Zoom para ver todo el mapa",a.setAttribute("role","button"),a.setAttribute("aria-label","Zoom para ver todo el mapa"),a.appendChild(t),a.onclick=e=>{e.preventDefault(),this.resetView()},e.after(a)}))};marker=e=>{var t;return this.marker_color&&"boolean"!=typeof this.marker_color?"string"==typeof this.marker_color?this.icon(this.marker_color):"string"==typeof this.marker_color(this,e)?(t=this.marker_color(this,e),this.icon(t)):"function"==typeof this.marker_color?this.marker_color(this,e):void 0:null};_clearLayers=()=>{this.markers.clearLayers(),this.map.eachLayer(e=>{this.isFeature(e)&&this.map.removeLayer(e)})};markersMap=e=>{var r=this;this._clearLayers(),this.geojson=new L.geoJson(e,{pointToLayer:function(e,t){var e=e["properties"],a=r.marker(e),s={},a=(s.id=e[r.id],a&&(s.icon=a),r.title&&(s.alt=e[r.title]),new L.marker(t,s));return r.map.options.minZoom=r.min_zoom,r.markers.addLayer(a),r.tooltip&&e[r.title]&&a.bindTooltip(e[r.title],r.tooltip_options),r.no_info||r.slider||(t="function"==typeof r.template?r.template(r,e):r.defaultTemplate(r,e),a.bindPopup(t)),r.markers},onEachFeature:function(e,t){var{properties:a,geometry:s}=e;t.options.id=a[r.id],e.properties.name=a[r.title],r.tooltip&&a[r.title]&&"Point"!=s.type&&"MultiPoint"!=s.type&&t.bindTooltip(a[r.title],r.tooltip_options),r.no_info||r.slider||"Point"==s.type||"MultiPoint"==s.type||(e="function"==typeof r.template?r.template(r,a):r.defaultTemplate(r,a),t.bindPopup(e))},style:function(e){const a=e["properties"];e=(e,t=!1)=>a.hasOwnProperty(e)?a[e]:t||r.featureStyle[e];return{color:e("stroke-color",e("stroke")),strokeOpacity:e("stroke-opacity"),weight:e("stroke-width"),fillColor:e("stroke"),opacity:e("stroke-opacity"),fillOpacity:e("fill-opacity")}}}),this.geojson.addTo(this.map)};_setSelectedMarker=(e,t)=>{e={entry:this.entry(e),marker:t};return this.selected_marker=e};_selectedMarker=()=>{this.map.eachLayer(t=>{this.isFeature(t)&&t.on("click",e=>{this._setSelectedMarker(t.options.id,t)})})};_hiddenSearchInput=()=>{const t=document.createElement("input");t.type="hidden",t.name="js-search-input"+this.scope_sufix,t.setAttribute("disabled","disabled"),t.id="js-search-input"+this.scope_sufix,document.querySelectorAll(this.scope_selector+".poncho-map").forEach(e=>e.appendChild(t))};_setFetureAttributes=()=>{const t=(e,t)=>{e.hasOwnProperty(t)&&(e[t].setAttribute("aria-label",e?.feature?.properties?.[this.title]),e[t].setAttribute("role","button"),e[t].setAttribute("tabindex",0),e[t].dataset.entryId=e?.feature?.properties?.[this.id],e[t].dataset.leafletId=e._leaflet_id)};this.map.eachLayer(e=>t(e,"_path"))};_accesibleAnchors=()=>{var e=[[this.scope_selector+" .leaflet-map-pane","leaflet-map-pane"+this.scope_sufix,[["role","region"]]],[this.scope_selector+" .leaflet-control-zoom","leaflet-control-zoom"+this.scope_sufix,[["aria-label","Herramientas de zoom"],["role","region"]]]];return e.forEach(e=>{const t=document.querySelector(e[0]);t.id=e[1],e[2].forEach(e=>t.setAttribute(e[0],e[1]))}),e};_accesibleMenu=()=>{document.querySelectorAll(this.scope_selector+" .accesible-nav").forEach(e=>e.remove());var e=this._accesibleAnchors(),e=[...e=[{text:"Ir a los marcadores del mapa",anchor:"#"+e[0][1]},{text:"Ajustar marcadores al mapa",anchor:"#",class:"js-fit-bounds"},{text:"Ir al panel de zoom",anchor:"#"+e[1][1]}],...this.accesible_menu_filter,...this.accesible_menu_search,...this.accesible_menu_extras],t=document.createElement("i");t.classList.add("icono-arg-sitios-accesibles","accesible-nav__icon"),t.setAttribute("aria-hidden","true");const a=document.createElement("div"),s=(a.classList.add("accesible-nav","top"),a.id="accesible-nav"+this.scope_sufix,a.setAttribute("aria-label","Menú para el mapa"),a.setAttribute("role","navigation"),a.tabIndex=0,document.createElement("ul"));e.forEach((e,t)=>{var a=document.createElement("a"),e=(a.textContent=e.text,a.tabIndex=0,a.href=e.anchor,e.hasOwnProperty("class")&&""!=e.class&&a.classList.add(...e.class.split(" ")),document.createElement("li"));e.appendChild(a),s.appendChild(e)}),a.appendChild(t),a.appendChild(s);e=document.createElement("a");e.textContent="Ir a la navegación del mapa",e.href="#accesible-nav"+this.scope_sufix,e.id="accesible-return-nav"+this.scope_sufix;const r=document.createElement("div");r.classList.add("accesible-nav","bottom"),r.appendChild(t.cloneNode(!0)),r.appendChild(e),document.querySelectorAll(""+this.scope_selector).forEach(e=>{e.insertBefore(a,e.children[0]),e.appendChild(r)}),this.fit()};fit=()=>document.querySelectorAll(this.scope_selector+" .js-fit-bounds").forEach(e=>{e.onclick=e=>{e.preventDefault(),this.fitBounds()}});render=()=>{this._hiddenSearchInput(),this._resetViewButton(),this.markersMap(this.entries),this._selectedMarker(),this.slider&&(this._renderSlider(),this._clickeableFeatures(),this._clickeableMarkers(),this._clickToggleSlider()),this.hash&&this._urlHash(),this.scroll&&this.hasHash()&&this.scrollCenter(),setTimeout(this.gotoHashedEntry,this.anchor_delay),this._setFetureAttributes(),this._accesibleMenu()}}class PonchoMapFilter extends PonchoMap{constructor(e,t){super(e,t);e=Object.assign({},{filters:[],filters_visible:!1,filters_info:!1,check_uncheck_all:!1,search_fields:[],messages:{reset:' <a href="#" class="{{reset_search}}" title="Restablece el mapa a su estado inicial">Restablecer mapa</a>',initial:"Hay {{total_results}} puntos en el mapa.",no_results_by_term:"No encontramos resultados para tu búsqueda.",no_results:"No s + this.messages.resete encontraron entradas.",results:"{{total_results}} resultados coinciden con tu búsqueda.",one_result:"{{total_results}} resultado coincide con tu búsqueda.",has_filters:'<i title="¡Advertencia!" aria-hidden="true" class="fa fa-warning text-danger"></i> Se están usando filtros.'}},t);this.filters=e.filters,this.filters_info=e.filters_info,this.filters_visible=e.filters_visible,this.check_uncheck_all=e.check_uncheck_all,this.valid_fields=["checkbox","radio"],this.search_fields=e.search_fields,this.messages=e.messages,this.accesible_menu_filter=[{text:"Ir al panel de filtros",anchor:"#filtrar-busqueda"+this.scope_sufix}]}tplParser=(e,s)=>Object.keys(s).reduce(function(e,t){var a=new RegExp("\\{\\{\\s{0,2}"+t+"\\s{0,2}\\}\\}","gm");return e=e.replace(a,s[t])},e);_helpText=e=>{var t=document.querySelectorAll(this.scope_selector+" .js-poncho-map__help");const s={total_results:e.length,total_entries:this.entries.length,total_filtered_entries:this.filtered_entries.length,filter_class:"js-close-filter"+this.scope_sufix,anchor:"#",term:this.inputSearchValue,reset_search:"js-poncho-map-reset"+this.scope_sufix};t.forEach(e=>{e.innerHTML="";var t=document.createElement("ul"),a=(t.classList.add("m-b-0","list-unstyled"),t.setAttribute("aria-live","polite"),e=>{var t=document.createElement("li");return t.innerHTML=e,t});s.total_entries===s.total_results?t.appendChild(a(this.tplParser(this.messages.initial,s))):s.total_results<1?t.appendChild(a(this.tplParser(this.messages.no_results_by_term+this.messages.reset,s))):""===this.inputSearchValue&&s.total_results<1?t.appendChild(a(this.tplParser(this.messages.no_results+this.messages.reset,s))):1==s.total_results?t.appendChild(a(this.tplParser(this.messages.one_result+this.messages.reset,s))):1<s.total_results&&t.appendChild(a(this.tplParser(this.messages.results+this.messages.reset,s))),this.usingFilters(),e.appendChild(t)})};_filterPosition=e=>{e=/^([\w\-]+?)(?:__([0-9]+))(?:__([0-9]+))?$/gm.exec(e);return e?[e[1],e[2]]:null};isFilterOpen=()=>document.querySelector(".js-poncho-map-filters"+this.scope_sufix).classList.contains("filter--in");toggleFilter=()=>{document.querySelector(".js-poncho-map-filters"+this.scope_sufix).classList.toggle("filter--in")};_filterContainerHeight=()=>{var e=document.querySelector(".js-filter-container"+this.scope_sufix),t=document.querySelector(".js-close-filter"+this.scope_sufix),e=e.offsetParent.offsetHeight-e.offsetTop-t.offsetHeight-20,t=document.querySelector(".js-poncho-map-filters"+this.scope_sufix),e=(t.style.maxHeight=e+"px",t.offsetHeight-45),t=document.querySelector(".js-filters"+this.scope_sufix);t.style.height=e+"px",t.style.overflow="auto"};_clickToggleFilter=()=>document.querySelectorAll(".js-close-filter"+this.scope_sufix).forEach(e=>e.onclick=e=>{e.preventDefault(),this.toggleFilter(),this._filterContainerHeight()});_setFilter=e=>{const[t,a="checked"]=e;e=this.entries.map(e=>{if(e.properties.hasOwnProperty(t))return e.properties[t]}).filter(e=>e),e=[...new Set(e)].map(e=>[t,e,[e],a]);return e.sort((e,t)=>{e=e[1].toUpperCase(),t=t[1].toUpperCase();return t<e?1:e<t?-1:0}),e};_fieldsToUse=e=>{var{fields:e=!1,field:t=!1}=e,e=(e||t||this.errorMessage("Filters requiere el uso del atributo `field` o `fields`.","warning"),e||this._setFilter(t));return e};_fields=(e,t)=>{var a=document.createElement("div"),s=(a.classList.add("field-list","p-b-1"),this._fieldsToUse(e));for(const c in s){var r=s[c],o=document.createElement("input"),i=(o.type=this.valid_fields.includes(e.type)?e.type:"checkbox",o.id=`id__${r[0]}__${t}__`+c,"radio"==e.type?o.name=r[0]+"__"+t:o.name=r[0]+`__${t}__`+c,o.className="form-check-input",o.value=c,void 0!==r[3]&&"checked"==r[3]&&o.setAttribute("checked","checked"),document.createElement("label")),n=(i.style.marginLeft=".33rem",i.textContent=r[1],i.className="form-check-label",i.setAttribute("for",`id__${r[0]}__${t}__`+c),document.createElement("span")),r=(n.dataset.info=r[0]+`__${t}__`+c,i.appendChild(n),document.createElement("div"));r.className="form-check",r.appendChild(o),r.appendChild(i),a.appendChild(r)}var l=document.createElement("div");return l.appendChild(a),l};_filterButton=()=>{var e=document.createElement("i"),t=(e.setAttribute("aria-hidden","true"),e.classList.add("fa","fa-filter"),document.createElement("span")),a=(t.textContent="Abre o cierra el filtro de búsqueda",t.classList.add("sr-only"),document.createElement("button")),e=(a.classList.add("btn","btn-secondary","btn-filter","js-close-filter"+this.scope_sufix),a.id="filtrar-busqueda"+this.scope_sufix,a.appendChild(e),a.appendChild(t),a.setAttribute("role","button"),a.setAttribute("aria-label","Abre o cierra el filtro de búsqueda"),a.setAttribute("aria-controls","poncho-map-filters"+this.scope_sufix),document.createElement("div"));e.classList.add("js-filter-container"+this.scope_sufix,"filter-container"),this.reset_zoom&&e.classList.add("filter-container--zoom-expand"),e.appendChild(a),document.querySelector(".poncho-map"+this.scope_selector).appendChild(e)};_filterContainer=()=>{var e=document.createElement("div"),t=(e.className="js-filters"+this.scope_sufix,document.createElement("button")),a=(t.classList.add("btn","btn-xs","btn-secondary","btn-close","js-close-filter"+this.scope_sufix),t.title="Cerrar panel",t.setAttribute("role","button"),t.setAttribute("aria-label","Cerrar panel de filtros"),t.innerHTML='<span class="sr-only">Cerrar </span>✕',document.createElement("form"));a.classList.add("js-formulario"+this.scope_sufix),a.appendChild(t),a.appendChild(e);const s=document.createElement("div");s.classList.add("js-poncho-map-filters"+this.scope_sufix,"poncho-map-filters"),s.setAttribute("role","region"),s.setAttribute("aria-live","polite"),s.setAttribute("aria-label","Panel de filtros"),s.id="poncho-map-filters"+this.scope_sufix,this.filters_visible&&s.classList.add("filter--in"),s.appendChild(a),document.querySelectorAll(".js-filter-container"+this.scope_sufix).forEach(e=>e.appendChild(s))};_checkUncheckButtons=e=>{var t=document.createElement("button"),a=(t.classList.add("js-select-items","select-items__button"),t.textContent="Marcar todos",t.dataset.field=e.field[0],t.dataset.value=1,document.createElement("button")),e=(a.classList.add("js-select-items","select-items__button"),a.textContent="Desmarcar todos",a.dataset.field=e.field[0],a.dataset.value=0,document.createElement("div"));return e.classList.add("select-items"),e.appendChild(t),e.appendChild(a),e};_createFilters=e=>{const r=document.querySelector(".js-filters"+this.scope_sufix);e.forEach((e,t)=>{var a=document.createElement("legend"),s=(a.textContent=e.legend,a.classList.add("m-b-1","text-primary","h6"),document.createElement("fieldset"));s.appendChild(a),this.check_uncheck_all&&s.appendChild(this._checkUncheckButtons(e)),s.appendChild(this._fields(e,t)),r.appendChild(s)})};formFilters=()=>{var e;return this.filters.length<1?[]:(e=document.querySelector(".js-formulario"+this.scope_sufix),e=new FormData(e),Array.from(e).map(e=>{var t=this._filterPosition(e[0]);return[parseInt(t[1]),parseInt(e[1]),t[0]]}))};defaultFiltersConfiguration=()=>{return this.filters.map((e,a)=>{return this._fieldsToUse(e).map((e,t)=>[a,t,e[0],"undefinded"!=typeof e[3]&&"checked"==e[3]])}).flat()};usingFilters=()=>{return this.defaultFiltersConfiguration().every(e=>document.querySelector(`#id__${e[2]}__${e[0]}__`+e[1]).checked)};_resetFormFilters=()=>{this.defaultFiltersConfiguration().forEach(e=>{document.querySelector(`#id__${e[2]}__${e[0]}__`+e[1]).checked=e[3]})};get inputSearchValue(){var e=document.querySelector("#js-search-input"+this.scope_sufix).value.trim();return""!==e&&e}_countOccurrences=(e,a,s)=>{return e.reduce((e,t)=>a.some(e=>t.properties[s].includes(e))?e+1:e,0)};totals=()=>{return this.formFilters().map(e=>{var t=this._fieldsToUse(this.filters[e[0]])[e[1]];return[t[1],this._countOccurrences(this.filtered_entries,t[2],t[0]),...e]})};_totalsInfo=()=>{if(!this.filters_info)return"";this.totals().forEach(e=>{var t=document.querySelector(""+this.scope_selector+` [data-info="${e[4]}__${e[2]}__${e[3]}"]`),a=e[1]<2?"":"s",s=document.createElement("i"),r=(s.style.cursor="help",s.style.opacity=".75",s.style.marginLeft=".5em",s.style.marginRight=".25em",s.classList.add("fa","fa-info-circle","small","text-info"),s.title=e[1]+" resultado"+a,s.setAttribute("aria-hidden","true"),document.createElement("span")),e=(r.className="sr-only",r.style.fontWeight="400",r.textContent=e[1]+` elemento${a}.`,document.createElement("small"));e.appendChild(s),e.appendChild(r),t.appendChild(e)})};_validateEntry=(t,a)=>{var s=this.filters.length,r=[];for(let e=0;e<s;e++)r.push(this._validateGroup(t,(t=>a.filter(e=>e[0]==t))(e)));return r.every(e=>e)};_search=(t,e,a)=>{const s=this._fieldsToUse(this.filters[e])[a];return s[2].filter(e=>e).some(e=>{if(t.hasOwnProperty(s[0]))return t[s[0]].includes(e)})};_validateGroup=(t,e)=>{return e.map(e=>this._search(t,e[0],e[1])).some(e=>e)};_filterData=()=>{var e=this.formFilters(),t=this.entries.filter(e=>this._validateEntry(e.properties,this.formFilters())),t=this.searchEntries(this.inputSearchValue,t);return t=this.filters.length<1||0<e.length?t:[],this.filtered_entries=t};_filteredData=e=>{e=void 0!==e?this.entries:this._filterData(),this.markersMap(e),this._selectedMarker(),this._helpText(e),this._resetSearch(),this._clickToggleFilter(),this.slider&&(this._renderSlider(),this._clickeableMarkers(),this._clickeableFeatures(),this._clickToggleSlider()),this.hash&&this._urlHash(),this._setFetureAttributes(),this._accesibleMenu()};_clearSearchInput=()=>document.querySelectorAll("#js-search-input"+this.scope_sufix).forEach(e=>e.value="");_resetSearch=()=>{document.querySelectorAll(".js-poncho-map-reset"+this.scope_sufix).forEach(e=>{e.onclick=e=>{e.preventDefault(),this._resetFormFilters(),this._filteredData(this.entries),this._clearSearchInput(),this.resetView()}})};filterChange=t=>document.querySelectorAll(".js-filters"+this.scope_sufix).forEach(e=>{e.onchange=t});checkUncheckFilters=()=>{if(!this.check_uncheck_all)return null;document.querySelectorAll(this.scope_selector+" .js-select-items").forEach(t=>{t.onclick=e=>{e.preventDefault(),document.querySelectorAll(`${this.scope_selector} [id^=id__${t.dataset.field}]`).forEach(e=>{e.checked=parseInt(t.dataset.value)}),this._filteredData()}})};render=()=>{this._hiddenSearchInput(),this._resetViewButton(),0<this.filters.length&&(this._filterButton(),this._filterContainer(),this._createFilters(this.filters)),this._filteredData(),this._totalsInfo(),this.scroll&&this.hasHash()&&this.scrollCenter(),this.checkUncheckFilters(),this.filterChange(e=>{e.preventDefault(),this._filteredData()}),setTimeout(this.gotoHashedEntry,this.anchor_delay),this.filters_visible&&this._filterContainerHeight()}}class PonchoMapSearch{constructor(e,t){var a={scope:!1,placeholder:"Su búsqueda",search_fields:e.search_fields,sort:!0,sort_reverse:!1,sort_key:"text",datalist:!0},a=(this.instance=e,Object.assign({},a,t));this.text=e.title||!1,this.datalist=a.datalist,this.placeholder=a.placeholder,this.scope=a.scope,this.scope_sufix="--"+this.scope,this.sort=a.sort,this.sort_reverse=a.sort_reverse,this.search_scope_selector=this.scope?`[data-scope="${this.scope}"]`:"",this.instance.search_fields=a.search_fields,this.instance.accesible_menu_search=[{text:"Hacer una búsqueda",anchor:"#id-poncho-map-search"+this.scope_sufix}]}sortData=(e,s)=>{e=e.sort((e,t)=>{var a=e=>{this.instance.removeAccents(e).toUpperCase()};return a(e[s]),a(t[s]),a(e[s]),a(t[s]),0});return this.sort_reverse?e.reverse():e};_triggerSearch=()=>{const t=document.querySelector(this.search_scope_selector+" .js-poncho-map-search__input");t.id="id-poncho-map-search"+this.scope_sufix,document.querySelectorAll(this.search_scope_selector+" .js-poncho-map-search__submit").forEach(e=>{e.onclick=e=>{e.preventDefault();document.querySelector("#js-search-input"+this.instance.scope_sufix).value=t.value;e=t.value;this._renderSearch(e)}})};_keyup=()=>{document.querySelectorAll(this.search_scope_selector+" .js-poncho-map-search__input").forEach(e=>{const t=document.querySelector("#js-search-input"+this.instance.scope_sufix);e.onkeyup=()=>{t.value=e.value},e.onkeydown=()=>{t.value=e.value}})};_placeHolder=()=>{if(!this.placeholder)return"";document.querySelectorAll(this.search_scope_selector+" .js-poncho-map-search__input").forEach(e=>e.placeholder=this.placeholder.toString())};_renderSearch=e=>{var t=this.instance._filterData();this.instance.markersMap(t),this.instance.slider&&(this.instance._renderSlider(),this.instance._clickeableFeatures(),this.instance._clickeableMarkers(),this.instance._clickToggleSlider()),this.instance.hash&&this.instance._urlHash(),this.instance.resetView(),1==t.length?this.instance.gotoEntry(t[0].properties[this.instance.id]):""!=e.trim()&&(this.instance.removeHash(),setTimeout(this.instance.fitBounds,this.instance.anchor_delay)),this.instance._helpText(t),this.instance._resetSearch(),this.instance._clickToggleFilter(),this.instance._setFetureAttributes(),this.instance._accesibleMenu()};_addDataListOptions=()=>{if(!this.datalist)return null;document.querySelectorAll(this.search_scope_selector+" .js-porcho-map-search__list,"+` ${this.search_scope_selector} .js-poncho-map-search__list`).forEach(a=>{a.innerHTML="";var e=document.querySelector(this.search_scope_selector+" .js-poncho-map-search__input"),t="id-datalist"+this.scope_sufix;e.setAttribute("list",t),a.id=t,this.instance.filtered_entries.forEach(e=>{return a.appendChild((e=e.properties[this.text],(t=document.createElement("option")).value=e,t));var t})})};_searchRegion=()=>{var e=document.querySelector(this.search_scope_selector);e.setAttribute("role","region"),e.setAttribute("aria-label","Buscador")};render=()=>{this._placeHolder(),this._triggerSearch(),this._addDataListOptions(),this.instance.filterChange(e=>{e.preventDefault(),this.instance._filteredData(),this._addDataListOptions()}),this._searchRegion(),this._keyup(),this.instance._accesibleMenu()}}class GapiSheetData{constructor(e){e=Object.assign({},{gapi_key:"AIzaSyCq2wEEKL9-6RmX-TkW23qJsrmnFHFf5tY",gapi_uri:"https://sheets.googleapis.com/v4/spreadsheets/"},e);this.gapi_key=e.gapi_key,this.gapi_uri=e.gapi_uri}url=(e,t,a)=>{return["https://sheets.googleapis.com/v4/spreadsheets/",t,"/values/",e,"?key=",void 0!==a?a:this.gapi_key,"&alt=json"].join("")};json_data=e=>{e=this.feed(e);return{feed:e,entries:this.entries(e),headers:this.headers(e)}};feed=(e,o=!0)=>{const i=e.values[0],n=/ |\/|_/gi;let l=[];return e.values.forEach((e,t)=>{if(0<t){var a,s={};for(a in i){var r=e.hasOwnProperty(a)?e[a].trim():"";o?s[""+i[a].toLowerCase().replace(n,"")]=r:s[""+i[a].replace(n,"")]=r}l.push(s)}}),l};gapi_feed_row=(e,t="-",a=!0)=>{const s=a?"filtro-":"";a=Object.entries(e);let r={};return a.map(e=>{return r[e[0].replace("gsx$","").replace(s,"").replace(/-/g,t)]=e[1].$t}),r};entries=e=>e.filter((e,t)=>0<t);headers=e=>e.find((e,t)=>0==t)}
1
+ const ponchoColor=e=>{let t;switch(e.toLocaleLowerCase()){case"celeste":case"info":t="#2897d4";break;case"verde":case"success":t="#2e7d33";break;case"rojo":case"danger":t="#c62828";break;case"amarillo":case"warning":t="#f9a822";break;case"azul":case"primary":t="#0072bb";break;case"negro":case"black":t="#333";break;case"uva":t="#6a1b99";break;case"gris":case"muted":t="#525252";break;case"grisintermedio":case"gris-area":case"gray":t="#f2f2f2";break;case"celesteargentina":case"celeste-argentina":t="#37bbed";break;case"fucsia":t="#ec407a";break;case"arandano":t="#c2185b";break;case"cielo":t="#039be5";break;case"verdin":t="#6ea100";break;case"lima":t="#cddc39";break;case"maiz":case"maíz":t="#ffce00";break;case"tomate":t="#ef5350";break;case"naranjaoscuro":case"naranja":t="#EF6C00";break;case"verdeazulado":case"verde-azulado":t="#008388";break;case"escarapela":t="#2cb9ee";break;case"lavanda":t="#9284be";break;case"mandarina":t="#f79525";break;case"palta":t="#50b7b2";break;case"cereza":t="#ed3d8f";break;case"limon":t="#d7df23";break;case"verdejade":case"verde-jade":t="#066";break;case"verdealoe":case"verde-aloe":t="#4fbb73";break;case"verdecemento":case"verde-cemento":t="#b4beba";break;default:t=e}return t},replaceSpecialChars=e=>{if(!e)return"";var t="àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìıİłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż",a="aaaaaaaaaacccddeeeeeeeegghiiiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz";const s=t+t.toUpperCase(),r=a+a.toUpperCase();t=new RegExp(s.split("").join("|"),"g");return e.toString().replace(t,e=>r.charAt(s.indexOf(e)))},slugify=e=>{if(!e)return e;const t="àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìıİłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;";var a=new RegExp(t.split("").join("|"),"g");return e.toString().toLowerCase().replace(/\s+/g,"-").replace(a,e=>"aaaaaaaaaacccddeeeeeeeegghiiiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------".charAt(t.indexOf(e))).replace(/&/g,"-and-").replace(/[^\w\-]+/g,"").replace(/\-\-+/g,"-").replace(/^-+/,"").replace(/-+$/,"")};async function fetch_json(e,t="GET"){e=await fetch(e,{method:t,headers:{Accept:"application/json","Content-Type":"application/json"}});if(e.ok)return e.json();throw new Error("HTTP error! status: "+e.status)}const secureHTML=(e,t=[])=>{var a;return!t.some(e=>"*"===e)&&(e=e.toString().replace(/</g,"&lt;").replace(/>/g,"&gt;"),0<t.length)?(a=new RegExp("&lt;("+t.join("|")+")(.*?)&gt;","g"),t=new RegExp("&lt;/("+t.join("|")+")(.*?)&gt;","g"),e.replace(a,"<$1$2>").replace(t,"</$1>")):e},getScroll=()=>{var e,t;return null!=window.pageYOffset?[pageXOffset,pageYOffset]:(e=(t=document).documentElement,t=t.body,[e.scrollLeft||t.scrollLeft||0,e.scrollTop||t.scrollTop||0])};function ponchoTable(s){var l,t,c=[],d=[],r=[],p=[],o="",h=[],u="";function a(e){jQuery.getJSON(e,function(e){function t(e){return e.replace(/έ/g,"ε").replace(/[ύϋΰ]/g,"υ").replace(/ό/g,"ο").replace(/ώ/g,"ω").replace(/ά/g,"α").replace(/[ίϊΐ]/g,"ι").replace(/ή/g,"η").replace(/\n/g," ").replace(/[áÁ]/g,"a").replace(/[éÉ]/g,"e").replace(/[íÍ]/g,"i").replace(/[óÓ]/g,"o").replace(/[úÚ]/g,"u").replace(/ê/g,"e").replace(/î/g,"i").replace(/ô/g,"o").replace(/è/g,"e").replace(/ï/g,"i").replace(/ü/g,"u").replace(/ã/g,"a").replace(/õ/g,"o").replace(/ç/g,"c").replace(/ì/g,"i")}c=e.values,jQuery.each(Object.keys(c[0]),function(e,t){c[0][t]&&(d.push(c[0][t]),r.push(t),o+="<th>"+c[1][t]+"</th>",h.push(c[1][t]))}),jQuery("#ponchoTable caption").html(s.tituloTabla),jQuery("#ponchoTable thead tr").empty(),jQuery("#ponchoTable thead tr").append(o),jQuery.each(c,function(o,e){var i,n;1<o&&(n=i="",jQuery.each(d,function(e,t){var a,s="",r=c[o][e];d[e].includes("btn-")&&r&&(r='<a aria-label="'+(a=c[0][e].replace("btn-","").replace("-"," "))+'" class="btn btn-primary btn-sm margin-btn" target="_blank" href="'+r+'">'+a+"</a>"),d[e].includes("filtro-")&&r&&(l=e,a=c[1][e],jQuery("#tituloFiltro").html(a),p.push(r)),d[e].includes("fecha-")&&r&&(a=r.split("/"),r='<span style="display:none;">'+new Date(a[2],a[1]-1,a[0]).toISOString().split("T")[0]+"</span>"+r),r||(r="",s="hidden-xs"),i+=r,r=(new showdown.Converter).makeHtml(r),n+='<td class="'+s+'" data-title="'+h[e]+'">'+r+"</td>"}),""!=i&&(u=(u+="<tr>")+n+"</tr>"))}),jQuery.each(p.filter(function(e,t,a){return t===a.indexOf(e)}),function(e,t){jQuery("#ponchoTableFiltro").append("<option>"+t+"</option>")}),jQuery("#ponchoTable tbody").empty(),jQuery("#ponchoTableSearchCont").show(),jQuery("#ponchoTable tbody").append(u),jQuery("#ponchoTable").removeClass("state-loading");var e=jQuery.fn.DataTable.ext.type.search,a=(e.string=function(e){return e?"string"==typeof e?t(e):e:""},e.html=function(e){return e?"string"==typeof e?t(e.replace(/<.*?>/g,"")):e:""},jQuery.isFunction(jQuery.fn.DataTable.ext.order.intl)&&(jQuery.fn.DataTable.ext.order.intl("es"),jQuery.fn.DataTable.ext.order.htmlIntl("es")),jQuery("#ponchoTable").DataTable({lengthChange:!1,autoWidth:!1,pageLength:s.cantidadItems,columnDefs:[{type:"html-num",targets:s.tipoNumero},{targets:s.ocultarColumnas,visible:!1}],ordering:s.orden,order:[[s.ordenColumna-1,s.ordenTipo]],dom:"<'row'<'col-sm-6'l><'col-sm-6'f>><'row'<'col-sm-12'i>><'row'<'col-sm-12'tr>><'row'<'col-md-offset-3 col-md-6 col-sm-offset-2 col-sm-8'p>>",language:{sProcessing:"Procesando...",sLengthMenu:"Mostrar _MENU_ registros",sZeroRecords:"No se encontraron resultados",sEmptyTable:"Ningún dato disponible en esta tabla",sInfo:"_TOTAL_ resultados",sInfoEmpty:"No hay resultados",sInfoFiltered:"",sInfoPostFix:"",sSearch:"Buscar:",sUrl:"",sInfoThousands:".",sLoadingRecords:"Cargando...",oPaginate:{sFirst:"<<",sLast:">>",sNext:">",sPrevious:"<"},oAria:{sSortAscending:": Activar para ordenar la columna de manera ascendente",sSortDescending:": Activar para ordenar la columna de manera descendente",paginate:{first:"Ir a la primera página",previous:"Ir a la página anterior",next:"Ir a la página siguiente",last:"Ir a la última página"}}}}));jQuery(document).ready(function(){jQuery("#ponchoTableSearch").keyup(function(){a.search(jQuery.fn.DataTable.ext.type.search.string(this.value)).draw()})}),jQuery("#ponchoTable_filter").parent().parent().remove(),1<jQuery("#ponchoTableFiltro option").length&&jQuery("#ponchoTableFiltroCont").show(),jQuery("#ponchoTableFiltro").on("change",function(){var e=jQuery.fn.DataTable.ext.type.search.string(jQuery(this).val());""!=e?a.column(l).every(function(){this.search(e?"^"+e+"$":"",!0,!1).draw()}):a.search("").columns().search("").draw()})})}jQuery.fn.DataTable.isDataTable("#ponchoTable")&&jQuery("#ponchoTable").DataTable().destroy(),s.jsonUrl?a(s.jsonUrl):(t=s.hojaNumero,jQuery.getJSON("https://sheets.googleapis.com/v4/spreadsheets/"+s.idSpread+"/?alt=json&key=AIzaSyCq2wEEKL9-6RmX-TkW23qJsrmnFHFf5tY",function(e){e=e.sheets[t-1].properties.title;a("https://sheets.googleapis.com/v4/spreadsheets/"+s.idSpread+"/values/"+e+"?alt=json&key=AIzaSyCq2wEEKL9-6RmX-TkW23qJsrmnFHFf5tY")}))}function ponchoTableDependant(u){var m,_=[],b={},g={};document.querySelector("#ponchoTable").classList.add("state-loading"),jQuery.fn.DataTable.isDataTable("#ponchoTable")&&jQuery("#ponchoTable").DataTable().destroy();const y=(e,t)=>e.toString().localeCompare(t.toString(),"es",{numeric:!0}),v=e=>[...new Set(e)],k=(e=0,t,a,s=!1)=>{var r=document.createElement("option");return r.value=a.toString().trim(),r.dataset.column=e,r.textContent=t.toString().trim(),s&&r.setAttribute("selected","selected"),r},l=e=>e.toString().replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),p=e=>e<=0?0:e,a=()=>[...document.querySelectorAll("[data-filter]")].map(e=>e.value),C=(e,t)=>{var a=document.createElement("a");return a.setAttribute("aria-label",e),a.classList.add("btn","btn-primary","btn-sm","margin-btn"),a.href=t,a.textContent=e,a.outerHTML},x=e=>{var t=e.split("/"),t=(t.reverse(),t.join("-")),a=document.createElement("datetime");return a.setAttribute("datetime",t),a.textContent=e,a.outerHTML},h=e=>replaceSpecialChars(e.toLowerCase()),n=(n,l,c)=>{l=l==_.length?l-1:l;const d=a();var e=m.entries.flatMap(e=>{t=n,a=e,s=c,r=d;var t,a,s,r,o=[...Array(p(t+1)).keys()].map(e=>a[_[p(t-1)]]==r[p(t-1)]&&a[_[p(t)]]==s||""==r[p(t-1)]).every(e=>e);if(e[_[p(l-1)]]==c&&o){const i=e[_[p(l)]];return _isCustomFilter(l,b)?_customFilter(l,b).filter(e=>h(i).includes(h(e))):i}}).filter(e=>e),e=v(e);return e.sort(y),e},s=(_isCustomFilter=e=>{var t=Object.keys(b);return!!g.hasOwnProperty("filtro-"+t[e])},_customFilter=e=>{var t=Object.keys(b);return g.hasOwnProperty("filtro-"+t[e])?g["filtro-"+t[e]]:[]},(t,s)=>{var r=Object.keys(b);const o=a();for(let a=t+1;a<=r.length&&r.length!=a;a++){let e=n(t,a,s);0==e.length&&(e=((a,s,r)=>{var e=m.entries.flatMap(e=>{const t=e[_[p(s)]];return(e[_[p(a)]]==r||""==r)&&(_isCustomFilter(s,b)?_customFilter(s,b).filter(e=>h(t).includes(h(e))):t)}).filter(e=>e),e=v(e);return e.sort(y),e})(t,a,s));const i=document.querySelector("#"+r[a]);i.innerHTML="",i.appendChild(k(a,"Todos","",!0)),e.forEach(e=>{var t=o[a]==e;i.appendChild(k(a,e,e,t))})}});function j(){var e=jQuery.fn.DataTable.ext.type.search;e.string=function(e){return e?"string"==typeof e?replaceSpecialChars(e):e:""},e.html=function(e){return e?"string"==typeof e?replaceSpecialChars(e.replace(/<.*?>/g,"")):e:""};let n=jQuery("#ponchoTable").DataTable({lengthChange:!1,autoWidth:!1,pageLength:u.cantidadItems,columnDefs:[{type:"html-num",targets:u.tipoNumero},{targets:u.ocultarColumnas,visible:!1}],ordering:u.orden,order:[[u.ordenColumna-1,u.ordenTipo]],dom:"<'row'<'col-sm-6'l><'col-sm-6'f>><'row'<'col-sm-12'i>><'row'<'col-sm-12'tr>><'row'<'col-md-offset-3 col-md-6 col-sm-offset-2 col-sm-8'p>>",language:{sProcessing:"Procesando...",sLengthMenu:"Mostrar _MENU_ registros",sZeroRecords:"No se encontraron resultados",sEmptyTable:"Ningún dato disponible en esta tabla",sInfo:"_TOTAL_ resultados",sInfoEmpty:"No hay resultados",sInfoFiltered:"",sInfoPostFix:"",sSearch:"Buscar:",sUrl:"",sInfoThousands:".",sLoadingRecords:"Cargando...",oPaginate:{sFirst:"<<",sLast:">>",sNext:">",sPrevious:"<"},oAria:{sSortAscending:": Activar para ordenar la columna de manera ascendente",sSortDescending:": Activar para ordenar la columna de manera descendente",paginate:{first:"Ir a la primera página",previous:"Ir a la página anterior",next:"Ir a la página siguiente",last:"Ir a la última página"}}}});jQuery("#ponchoTableSearch").keyup(function(){n.search(jQuery.fn.DataTable.ext.type.search.string(this.value)).draw()}),jQuery("#ponchoTable_filter").parent().parent().remove(),1<jQuery("#ponchoTableFiltro option").length&&jQuery("#ponchoTableFiltroCont").show(),jQuery("select[data-filter]").change(function(){var e=jQuery(this).find("option:selected").data("column"),t=jQuery(this).find("option:selected").val();s(e,t),n.columns().search("").columns().search("").draw();const o=Object.keys(b),i=a();i.forEach((e,t)=>{a=o[t];var a=Object.keys(m.headers).indexOf("filtro-"+a),s=l(i[t]),r=l(replaceSpecialChars(i[t]));_isCustomFilter(t,b)?n.columns(a).search(h(i[t])):n.columns(a).search(i[t]?`^(${s}|${r})$`:"",!0,!1,!0)}),n.draw()})}const t=e=>{jQuery.getJSON(e,function(e){var t=new GapiSheetData;(m=t.json_data(e)).entries="function"==typeof u.refactorEntries&&null!==u.refactorEntries?u.refactorEntries(m.entries):m.entries,_=Object.keys(m.headers).filter(e=>e.startsWith("filtro-")),g=u.asFilter?u.asFilter(m.entries):{},b=((r,o)=>{let i={};return o.forEach((t,a)=>{let e=[];e=g.hasOwnProperty(o[a])?g[o[a]]:r.entries.map(e=>e[t]);var s=v(e);s.sort(y),t=t.replace("filtro-",""),i[t]=[],s.forEach(e=>{i[t].push({columna:a,value:e})})}),i})(m,_);{var r=m;(t=document.querySelector("#ponchoTable thead")).innerHTML="";const c=document.createElement("tr"),d=(Object.keys(r.headers).forEach((e,t)=>{var a=document.createElement("th");a.textContent=r.headers[e],a.setAttribute("scope","col"),c.appendChild(a)}),t.appendChild(c),(t=document.querySelector("#ponchoTable caption")).innerHTML="",t.textContent=u.tituloTabla,document.querySelector("#ponchoTable tbody"));d.innerHTML="",r.entries.forEach(a=>{a="function"==typeof u.customEntry&&null!==u.customEntry?u.customEntry(a):a;const s=d.insertRow();Object.keys(r.headers).forEach(e=>{filas=a[e],e.startsWith("btn-")&&""!=filas?filas=C(r.headers[e],filas):e.startsWith("fecha-")&&""!=filas&&(filas=x(filas));var t=s.insertCell(),e=(t.dataset.title=r.headers[e],""==filas&&(t.className="hidden-xs"),new showdown.Converter);t.innerHTML=e.makeHtml(filas)})})}var a=m,s=document.querySelector("#ponchoTableFiltro");for(f in s.innerHTML="",b){const p=b[f][0].columna||0;var o=b[f].map(e=>e.value).sort(y),i=document.createElement("div"),n=(i.className=u.filterClassList||"col-sm-4",document.createElement("div")),l=(n.className="form-group",document.createElement("label"));l.setAttribute("for",f),l.textContent=a.headers["filtro-"+f];const h=document.createElement("select");h.classList.add("form-control"),h.dataset.filter=1,h.name=f,h.id=f,h.appendChild(k(p,"Todos","",!0)),o.forEach(e=>{h.appendChild(k(p,e,e,!1))}),n.appendChild(l),n.appendChild(h),i.appendChild(n),s.appendChild(i)}document.querySelector("#ponchoTableSearchCont").style.display="block",document.querySelector("#ponchoTable").classList.remove("state-loading"),j()})};if(u.jsonUrl)t(u.jsonUrl);else if(u.hojaNombre&&u.idSpread){var e=(new GapiSheetData).url(u.hojaNombre,u.idSpread);t(e)}else{if(!u.hojaNumero||!u.idSpread)throw"¡Error! No hay datos suficientes para crear la tabla.";{var r=u.hojaNumero;const o=new GapiSheetData;e=["https://sheets.googleapis.com/v4/spreadsheets/",u.idSpread,"/?alt=json&key=",o.gapi_key].join("");jQuery.getJSON(e,function(e){e=e.sheets[r-1].properties.title,e=o.url(e,u.idSpread);t(e)})}}}jQuery("#ponchoTable").addClass("state-loading");var content_popover=document.getElementById("content-popover");function popshow(){content_popover.classList.toggle("hidden")}function pophidde(){content_popover.classList.add("hidden")}var ponchoUbicacion=function(e){var a,s,r,o,t="/profiles/argentinagobar/themes/contrib/poncho/resources/jsons/geoprovincias.json",i="/profiles/argentinagobar/themes/contrib/poncho/resources/jsons/geolocalidades.json",n=jQuery('input[name="submitted['+e.provincia+']"]'),l=jQuery('input[name="submitted['+e.localidad+']"]');function c(e){return e.charAt(0).toUpperCase()+e.slice(1)}function d(e,t,a,s=!1,r=!1,o=!1){var i=jQuery("<select></select>").attr("id",t).attr("name",e).addClass("form-control form-select").prop("required",s);return r&&i.append("<option value=''>Seleccione una opción</option>"),jQuery.each(a,function(e,t){let a="";o==t.nombre&&(a='selected="selected"'),i.append("<option value='"+t.id+"' "+a+">"+t.nombre+"</option>")}),i}function p(e,t){var a=l.prop("required");return n.val()?d("sLocalidades","sLocalidades",e.filter(function(e){return String(e.provincia.id)==String(t)}).map(function(e){return e.departamento.nombre&&(e.nombre=c(e.departamento.nombre.toLowerCase())+" - "+c(e.nombre.toLowerCase())),e}).sort(function(e,t){e=e.nombre.toUpperCase(),t=t.nombre.toUpperCase();return e.localeCompare(t)}),a,emptyOption=!!l.val(),l.val()):d("sLocalidades","sLocalidades",[],a,!0,!1)}t=e.urlProvincias||t,i=e.urlLocalidades||i,jQuery.getJSON(t,function(e){var t;a=[],e.results.forEach(function(e,t){a.push(e)}),e=[],e=(t=a).sort(function(e,t){e=e.nombre.toUpperCase(),t=t.nombre.toUpperCase();return e.localeCompare(t)}),t=n.prop("required"),(r=d("sProvincias","sProvincias",e,t,!0,n.val())).on("change",function(e){var t;n.val(""),l.val(""),o.children("option:not(:first)").remove(),""!=r.val()&&(n.val(r.find(":selected").text()),t=p(s,r.val()).find("option"),o.append(t),o.val(""))}),n.after(r),jQuery(r).select2()}),jQuery.getJSON(i,function(e){s=[],e.results.forEach(function(e,t){s.push(e)}),(o=p(s,r.val())).on("change",function(e){l.val(""),""!=o.val()&&l.val(o.find(":selected").text())}),l.after(o),jQuery(o).select2()}),n.hide(),l.hide()};function ponchoChart(t){"use strict";var e;function _e(e){return"HeatMap"==e?"heatmap":"Mixed"==e?"mixed":"Stacked Bar"==e?"bar":"Horizontal Bar"==e?"horizontalBar":"Area"==e?"line":"Pie"==e?"pie":"Bar"==e?"bar":"Line"==e?"line":""}function be(e){var t="";switch(e){case"celeste":case"info":t="#2897d4";break;case"verde":case"success":t="#2e7d33";break;case"rojo":case"danger":t="#c62828";break;case"amarillo":case"warning":t="#f9a822";break;case"azul":case"primary":t="#0072bb";break;case"negro":case"black":t="#333";break;case"uva":t="#6a1b99";break;case"gris":case"muted":t="#525252";break;case"grisintermedio":case"gris-area":case"gray":t="#f2f2f2";break;case"celesteargentina":case"celeste-argentina":t="#37bbed";break;case"fucsia":t="#ec407a";break;case"arandano":t="#c2185b";break;case"cielo":t="#039be5";break;case"verdin":t="#6ea100";break;case"lima":t="#cddc39";break;case"maiz":case"maíz":t="#ffce00";break;case"tomate":t="#ef5350";break;case"naranjaoscuro":case"naranja":t="#EF6C00";break;case"verdeazulado":case"verde-azulado":t="#008388";break;case"escarapela":t="#2cb9ee";break;case"lavanda":t="#9284be";break;case"mandarina":t="#f79525";break;case"palta":t="#50b7b2";break;case"cereza":t="#ed3d8f";break;case"limon":t="#d7df23";break;case"verdejade":case"verde-jade":t="#066";break;case"verdealoe":case"verde-aloe":t="#4fbb73";break;case"verdecemento":case"verde-cemento":t="#b4beba";break;default:console.log("No existe color "+e)}return t}function ge(e){var e=e.toString().replace(".",","),t=e.split(","),a=new Intl.NumberFormat("es-AR",{maximumFractionDigits:2}).format(t[0]);return e=1<t.length?a.concat(",",t[1].substr(0,2)):a}function a(e,s){var P,t,a,H,r,o,Q,N,z,i,n,D,B,l,c,G,$,R,d,p,U,h,J,u,V,m,f=[],_=[],b=[],W=[],g=[],y=[],v=[],k=[],C=0,x="",Y=[],j=0,w=[],Z=[],X=0,S=s.posicionLeyendas||"top",E="",E=void 0===s.mostrarLeyendas||s.mostrarLeyendas,T="",T=void 0===s.mostrarTotalStacked||s.mostrarTotalStacked,L=_e(s.tipoGrafico),A=e.values;if(jQuery.each(Object.keys(A[0]),function(e,t){var a;"eje-y"==A[0][e].substr(0,5)?(a=(a=A[0][e].split("-"))[0]+a[1],_.push(a),b.push(e)):"nombre-corto"==A[0][e]&&"heatmap"==L&&(X=e)}),jQuery.each(A,function(r,e){var s;0==r&&jQuery.each(b,function(e,t){var a=A[r][b[e]].split("-"),s=a[0]+a[1];v[s]=[],W.push(a[2]),"mixed"==L&&(3<a.length&&("barra"==a[3]||"linea"==a[3])?Y.push(a[3]):(0==e&&Y.push("barra"),1==e&&Y.push("linea")))}),1==r&&jQuery.each(b,function(e,t){"pie"==L||"heatmap"==L?f.push(A[r][b[e]]):(y.push(A[r][b[e]]),C+=1)}),1<r&&(s=!1,jQuery.each(b,function(e,t){var a=A[0][b[e]].split("-"),a=a[0]+a[1];"pie"==L?v[a].push(A[r][b[e]]):"heatmap"==L?(0==s&&(y.push(A[r][0]),s=!0,C+=1),e!=X&&v[a].push(A[r][b[e]]),e+2==X&&(void 0===A[r][e+2]?Z.push("*"):Z.push(A[r][e+2]))):(0==s&&(f.push(A[r][0]),s=!0),v[a].push(A[r][b[e]]))}))}),"pie"==L?(P=[],jQuery.each(Object.keys(_),function(e,t){e=_[e];v.hasOwnProperty(e)&&P.push(v[e])}),k=P):1==C&&jQuery.each(Object.keys(_),function(e,t){e=_[e];v.hasOwnProperty(e)&&(k=v[e])}),"mixed"!=L||0<(t=s.porcentajesMixed||"").length&&(w=t.split(",")),x=1==s.porcentajes?"line"==L&&1<C?{enabled:!0,callbacks:{label:function(e,t){var a=ge(t.datasets[e.datasetIndex].data[e.index]);return t.datasets[e.datasetIndex].label+": "+a+"%"}},mode:"index",intersect:!1}:"pie"==L?{enabled:!0,callbacks:{label:function(e,t){var a=ge(t.datasets[e.datasetIndex].data[e.index]);return t.labels[e.index]+": "+a+"%"}}}:"Stacked Bar"==s.tipoGrafico?1==T?{enabled:!0,mode:"index",callbacks:{label:function(e,t){var a=ge(t.datasets[e.datasetIndex].data[e.index]);return t.datasets[e.datasetIndex].label+": "+a+"%"},footer:(e,t)=>{e=e.reduce((e,t)=>e+parseFloat(t.yLabel),0);return"Total: "+new Intl.NumberFormat("es-AR",{maximumFractionDigits:2}).format(e)+"%"}}}:{enabled:!0,mode:"index",callbacks:{label:function(e,t){var a=ge(t.datasets[e.datasetIndex].data[e.index]);return t.datasets[e.datasetIndex].label+": "+a+"%"}}}:{enabled:!0,mode:"index",callbacks:{label:function(e,t){var a=ge(t.datasets[e.datasetIndex].data[e.index]);return t.datasets[e.datasetIndex].label+": "+a+"%"}}}:"line"==L&&1<C?{enabled:!0,callbacks:{label:function(e,t){var a=ge(t.datasets[e.datasetIndex].data[e.index]);return t.datasets[e.datasetIndex].label+": "+a}},mode:"index",intersect:!1}:"pie"==L?{enabled:!0,callbacks:{label:function(e,t){var a=ge(t.datasets[e.datasetIndex].data[e.index]);return t.labels[e.index]+": "+a}}}:"Stacked Bar"==s.tipoGrafico&&1<C?1==T?{enabled:!0,mode:"index",intersect:!1,callbacks:{label:function(e,t){var a=ge(t.datasets[e.datasetIndex].data[e.index]);return t.datasets[e.datasetIndex].label+": "+a},footer:(e,t)=>{e=e.reduce((e,t)=>e+parseFloat(t.yLabel),0);return"Total: "+new Intl.NumberFormat("es-AR",{maximumFractionDigits:2}).format(e)}}}:{enabled:!0,mode:"index",intersect:!1,callbacks:{label:function(e,t){var a=ge(t.datasets[e.datasetIndex].data[e.index]);return t.datasets[e.datasetIndex].label+": "+a}}}:{enabled:!0,mode:"index",callbacks:{label:function(e,t){var a=ge(t.datasets[e.datasetIndex].data[e.index]);return t.datasets[e.datasetIndex].label+": "+a}}},"pie"==L&&(W.forEach(function(e,t,a){g.push(be(e))}),console.log("etiquetas --\x3e "+f),console.log("datos --\x3e "+k),console.log("colores --\x3e "+g),t=f,T=k,z=L,i=g,a=s.idComponenteGrafico,D=S,B=x,n=E,a=document.getElementById(a),new Chart(a,{type:z,data:{labels:t,datasets:[{data:T,borderColor:i,backgroundColor:i,borderWidth:2}]},options:{legend:{display:n,position:D},responsive:!0,tooltips:B}})),1==C&&(console.log("etiquetas --\x3e "+f),console.log("datos --\x3e "+k),a=be(W[0]),console.log("color --\x3e "+a),"Line"==s.tipoGrafico&&(z=f,T=k,i=L,n=a,D=y[0],B=s.ejeYenCero,l=s.idComponenteGrafico,c=S,G=x,$=E,l=document.getElementById(l),new Chart(l,{type:i,data:{labels:z,datasets:[{data:T,borderColor:n,backgroundColor:n,borderWidth:2,lineTension:0,fill:!1,label:D}]},options:{legend:{display:$,position:c},tooltips:G,responsive:!0,scales:{yAxes:[{ticks:{beginAtZero:B}}]}}})),"bar"!=L&&"Area"!=s.tipoGrafico||(l=f,T=k,$=L,c=a,G=y[0],H=s.ejeYenCero,r=s.idComponenteGrafico,o=S,Q=x,N=E,r=document.getElementById(r),new Chart(r,{type:$,data:{labels:l,datasets:[{data:T,borderColor:c,backgroundColor:c,borderWidth:2,lineTension:0,label:G}]},options:{legend:{display:N,position:o},tooltips:Q,responsive:!0,scales:{yAxes:[{ticks:{beginAtZero:H}}]}}})),"horizontalBar"==L&&(r=f,T=k,N=L,o=a,Q=y[0],H=s.ejeYenCero,I=s.idComponenteGrafico,re=S,oe=x,ee=E,I=document.getElementById(I),new Chart(I,{type:N,data:{labels:r,datasets:[{data:T,borderColor:o,backgroundColor:o,borderWidth:2,lineTension:0,label:Q}]},options:{legend:{display:ee,position:re},tooltips:oe,responsive:!0,scales:{xAxes:[{ticks:{beginAtZero:H}}]}}}))),1<C)if("heatmap"==L)if(void 0!==s.heatMapColors&&""!=s.heatMapColors&&void 0!==s.heatMapColorsRange&&""!=s.heatMapColorsRange){for(var K=[],I="labelFila",T="labelColumna",ee="labelValor",te=(void 0!==s.datosTooltip&&0<s.datosTooltip.length&&(void 0!==s.datosTooltip[0]&&void 0!==s.datosTooltip[0].labelFila&&(I=s.datosTooltip[0].labelFila),void 0!==s.datosTooltip[1]&&void 0!==s.datosTooltip[1].labelColumna&&(T=s.datosTooltip[1].labelColumna),void 0!==s.datosTooltip[2]&&void 0!==s.datosTooltip[2].labelValor&&(ee=s.datosTooltip[2].labelValor)),jQuery.each(Object.keys(_),function(e,t){e=_[e];v.hasOwnProperty(e)&&(k=v[e],K.push(k))}),[]),O=0;O<y.length;O++){for(var e=[],ae=0;ae<f.length;ae++){k={x:f[ae],y:parseInt(K[ae][O])};e.push(k)}te.push({name:("*"!=Z[O]?Z:y)[O],data:e})}for(var se=[],O=0;O<s.heatMapColorsRange.length-1;O++){e={from:s.heatMapColorsRange[O],to:s.heatMapColorsRange[O+1],color:be(s.heatMapColors[O])};se.push(e)}var re="",re=void 0===s.mostrarEjeY||s.mostrarEjeY,oe=te,ie=s.idComponenteGrafico,ne=y,le=se,ce=I,de=T,pe=ee,T=s.tituloGrafico,M=re,he=S,ue=E,ie=document.getElementById(ie),me=(new ApexCharts(ie,{series:oe,chart:{height:650,type:"heatmap"},dataLabels:{enabled:!1},title:{text:T},tooltip:{custom:function({series:e,seriesIndex:t,dataPointIndex:a,w:s}){e=ge(e[t][a]);return'<div class="arrow_box"><span>'+ce+": "+ne[t]+"<br>"+de+": "+s.globals.labels[a]+"<br>"+pe+": "+e+"</span></div>"}},plotOptions:{heatmap:{shadeIntensity:.5,radius:0,useFillColorAsStroke:!1,colorScale:{ranges:le}}},yaxis:{show:M},legend:{show:ue,position:he},responsive:[{breakpoint:1e3,options:{yaxis:{show:!1},legend:{show:ue,position:"top"}}}]}).render(),document.getElementsByClassName("apexcharts-toolbar"));for(let e=0;e<me.length;e++)me[e].style.display="none"}else void 0!==s.heatMapColors&&""!=s.heatMapColors||console.log("Completar vector con valores para los colores"),void 0!==s.heatMapColorsRange&&""!=s.heatMapColorsRange||console.log("Completar vector con el rango de valores para los colores");else{var F=[],q=0,fe=(W.forEach(function(e,t,a){g.push(be(e))}),console.log("colores --\x3e "+g),0);jQuery.each(Object.keys(_),function(e,t){var a,e=_[e];v.hasOwnProperty(e)&&(k=v[e],console.log("datos --\x3e "+k),"Line"==s.tipoGrafico?a={label:y[q],data:k,borderColor:g[q],fill:!1,borderWidth:2,lineTension:0,backgroundColor:g[q]}:"Bar"==s.tipoGrafico||"Area"==s.tipoGrafico||"Horizontal Bar"==s.tipoGrafico||"Stacked Bar"==s.tipoGrafico?a={label:y[q],data:k,borderColor:g[q],backgroundColor:g[q],borderWidth:2,lineTension:0}:"Mixed"==s.tipoGrafico&&("barra"==(e=Y[fe])?a={label:y[q],data:k,backgroundColor:g[q],yAxisID:"left-y-axis",type:"bar"}:"linea"==e&&(a={label:y[q],data:k,borderColor:g[q],backgroundColor:g[q],type:"line",yAxisID:"right-y-axis",fill:!1})),F.push(a),q+=1,fe+=1)}),"mixed"==L&&(2==w.length?j=2:1==w.length?"eje-y1"==w[0]?j=0:"eje-y2"==w[0]&&(j=1):j=3),console.log("etiquetas --\x3e "+f),console.log("toltip --\x3e"+JSON.stringify(x)),"Stacked Bar"==s.tipoGrafico?(ie=f,T=L,le=F,M=s.idComponenteGrafico,he=s.ejeYenCero,ue=S,w=x,V=E,M=document.getElementById(M),new Chart(M,{type:T,data:{labels:ie,datasets:le},options:{legend:{display:V,position:ue,labels:{textAlign:"center"}},tooltips:w,responsive:!0,scales:{yAxes:[{ticks:{beginAtZero:he},stacked:!0}],xAxes:[{stacked:!0}]}}})):"Mixed"==s.tipoGrafico?(T=f,V="bar",w=F,d=s.idComponenteGrafico,p=s.ejeYenCero,U=S,h=j,j=y[0],J=y[1],u=E,d=document.getElementById(d),new Chart(d,{type:V,data:{labels:T,datasets:w},options:{legend:{display:u,position:U,labels:{textAlign:"center"}},tooltips:{enabled:!0,mode:"single",callbacks:{label:function(e,t){var a="",s=((2==h||e.datasetIndex==h)&&(a="%"),ge(e.yLabel));return t.datasets[e.datasetIndex].label+": "+s+" "+a}}},responsive:!0,scales:{yAxes:[{id:"left-y-axis",type:"linear",position:"left",ticks:{beginAtZero:p,callback:function(e){return e+(1!=h&&2!=h?"":"%")}},scaleLabel:{display:!0,labelString:J,fontColor:"black"}},{id:"right-y-axis",type:"linear",position:"right",ticks:{beginAtZero:p,callback:function(e){return e+(0!=h&&2!=h?"":"%")}},scaleLabel:{display:!0,labelString:j,fontColor:"black"}}]}}})):"Horizontal Bar"==s.tipoGrafico?(d=f,T=L,w=F,u=s.idComponenteGrafico,U=s.ejeYenCero,J=S,p=x,j=E,u=document.getElementById(u),new Chart(u,{type:T,data:{labels:d,datasets:w},options:{legend:{display:j,position:J,labels:{textAlign:"center"}},tooltips:p,responsive:!0,maintainAspectRatio:!0,scales:{xAxes:[{ticks:{beginAtZero:U}}]}}})):(T=f,w=L,j=F,m=s.idComponenteGrafico,R=s.ejeYenCero,S=S,x=x,E=E,m=document.getElementById(m),new Chart(m,{type:w,data:{labels:T,datasets:j},options:{legend:{display:E,position:S,labels:{textAlign:"center"}},tooltips:x,responsive:!0,maintainAspectRatio:!0,scales:{yAxes:[{ticks:{beginAtZero:R}}]}}}))}""!=s.tituloGrafico&&void 0!==s.tituloGrafico&&(m=s.idTagTituloGrafico,w=s.tituloGrafico,document.getElementById(m)&&(document.getElementById(m).innerHTML=w))}!function(e){var t=!1;(e.idSpread&&e.hojaNombre||e.jsonUrl||e.jsonInput)&&void 0!==e.tipoGrafico&&""!=e.tipoGrafico&&void 0!==e.idComponenteGrafico&&""!=e.idComponenteGrafico&&""!=_e(e.tipoGrafico)&&(t=!0);return t}(t)?(void 0!==t.idSpread&&""!=t.idSpread||console.log("Completar valor para la opción de Configuración idSpread"),void 0!==t.hojaNombre&&""!=t.hojaNombre||console.log("Completar valor para la opción de Configuración hojaNombre"),void 0!==t.tipoGrafico&&""!=t.tipoGrafico||console.log("Completar valor para la opción de Configuración tipoGrafico"),void 0!==t.idComponenteGrafico&&""!=t.idComponenteGrafico||console.log("Completar valor para la opción de Configuración idComponenteGrafico"),""==_e(t.tipoGrafico)&&console.log("Ingrese un tipo de gafico válido")):t.jsonInput?(console.log(t.jsonInput),a(jQuery.parseJSON(t.jsonInput),t)):(e=t.jsonUrl||"https://sheets.googleapis.com/v4/spreadsheets/"+t.idSpread+"/values/"+t.hojaNombre+"?alt=json&key=AIzaSyCq2wEEKL9-6RmX-TkW23qJsrmnFHFf5tY",jQuery.getJSON(e,function(e){a(e,t)}))}const gapi_legacy=e=>{const o=e.values[0],i=/ |\/|_/gi;let n=[];return e.values.forEach((e,t)=>{if(0<t){var a={};for(const r in o){var s=e.hasOwnProperty(r)?e[r].trim():"";a["gsx$"+o[r].toLowerCase().replace(i,"")]={$t:s}}n.push(a)}}),{feed:{entry:n}}};class PonchoMap{constructor(e,t){var a={error_reporting:!0,no_info:!1,title:!1,id:"id",template:!1,template_structure:{container_classlist:["info-container"],title_classlist:["h4","text-primary","m-t-0"],definition_list_classlist:["definition-list"],term_classlist:["h6","m-b-0"],definition_classlist:[],definition_list_tag:"dl",term_tag:"dt",definition_tag:"dd"},allowed_tags:[],template_innerhtml:!1,template_markdown:!1,markdown_options:{tables:!0,simpleLineBreaks:!0,extensions:["details","images","alerts","numbers","ejes","button","target","bootstrap-tables","video"]},render_slider:!0,scope:"",slider:!1,scroll:!1,hash:!1,headers:{},header_icons:[],content_selector:!1,map_selector:"map",anchor_delay:0,slider_selector:".slider",map_view:[-40.44,-63.59],map_anchor_zoom:16,map_zoom:4,min_zoom:2,reset_zoom:!0,latitud:"latitud",longitud:"longitud",marker:"azul",tooltip:!1,tooltip_options:{direction:"auto",className:"leaflet-tooltip-own"},marker_cluster_options:{spiderfyOnMaxZoom:!1,showCoverageOnHover:!1,zoomToBoundsOnClick:!0,maxClusterRadius:45,spiderfyDistanceMultiplier:3,spiderLegPolylineOptions:{weight:1,color:"#666",opacity:.5,"fill-opacity":.5}},accesible_menu_extras:[{text:"Ayudá a mejorar el mapa",anchor:"https://www.argentina.gob.ar/sugerencias"}]},s=Object.assign({},a,t);this.error_reporting=s.error_reporting,this.scope=s.scope,this.render_slider=s.render_slider,this.template=s.template,this.template_structure={...a.template_structure,...t.template_structure},this.template_innerhtml=s.template_innerhtml,this.template_markdown=s.template_markdown,this.markdown_options=s.markdown_options,this.allowed_tags=s.allowed_tags,this.map_selector=s.map_selector,this.headers=this.setHeaders(s.headers),this.header_icons=s.header_icons,this.hash=s.hash,this.scroll=s.scroll,this.map_view=s.map_view,this.anchor_delay=s.anchor_delay,this.map_zoom=s.map_zoom,this.min_zoom=s.min_zoom,this.map_anchor_zoom=s.map_anchor_zoom,this.tooltip_options=s.tooltip_options,this.tooltip=s.tooltip,this.marker_cluster_options=s.marker_cluster_options,this.marker_color=s.marker,this.id=s.id,this.title=s.title,this.latitude=s.latitud,this.longitude=s.longitud,this.slider=s.slider,this.no_info=s.no_info,this.reset_zoom=s.reset_zoom,this.slider_selector=this._selectorName(s.slider_selector),this.selected_marker,this.scope_selector=`[data-scope="${this.scope}"]`,this.scope_sufix="--"+this.scope,this.content_selector=s.content_selector||".js-content"+this.scope_sufix,this.data=this.formatInput(e),this.geometryTypes=["Point","LineString","Polygon","MultiPoint","MultiLineString"],this.featureStyle={stroke:"dodgerblue","stroke-opacity":1,"stroke-width":2,"fill-opacity":.5},this.accesible_menu_search=[],this.accesible_menu_filter=[],this.accesible_menu_extras=s.accesible_menu_extras,this.geojson,this.map=new L.map(this.map_selector,{renderer:L.svg()}).setView(this.map_view,this.map_zoom),new L.tileLayer("https://mapa-ign.argentina.gob.ar/osm/{z}/{x}/{-y}.png",{attribution:'Contribuidores: <a href="https://www.ign.gob.ar/AreaServicios/Argenmap/Introduccion" target="_blank">Instituto Geográfico Nacional</a>, <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>'}).addTo(this.map),this.markers=new L.markerClusterGroup(this.marker_cluster_options)}isGeoJSON=e=>"FeatureCollection"===e?.type;get entries(){return this.data.features}get geoJSON(){return this.featureCollection(this.entries)}formatInput=e=>{e.length<1&&this.errorMessage("No se puede visualizar el mapa, el documento está vacío","warning");let t;return t=this.isGeoJSON(e)?e:(e=this.features(e),this.featureCollection(e)),this._setIdIfNotExists(t)};errorMessage=(e=!1,t="danger")=>{document.querySelectorAll("#js-error-message"+this.scope_sufix).forEach(e=>e.remove());var a=document.createElement("div"),s=(a.id="js-error-message"+this.scope_sufix,a.classList.add("poncho-map--message",t),document.createElement("h2")),r=(s.classList.add("h6","title"),s.textContent="¡Se produjo un error!",document.createElement("pre")),o=(r.textContent=e,document.createElement("a"));throw o.href="https://github.com/argob/poncho/blob/master/src/demo/poncho-maps/readme-poncho-maps.md",o.target="_blank",o.textContent="Ayuda sobre las opciones de PonchoMap",o.className="small",o.title="Abre el enlace en una nueva ventana",a.appendChild(s),a.appendChild(r),a.appendChild(o),this.error_reporting&&(s=document.querySelector(this.scope_selector+".poncho-map")).parentNode.insertBefore(a,s),"danger"==t&&document.getElementById(this.map_selector).remove(),console.log(this.critical_error),e};feature=e=>{var t=e[this.latitude],a=e[this.longitude];return[t,a].forEach(e=>{isNaN(Number(e))&&this.errorMessage("El archivo contiene errores en la definición de latitud y longitud.\n "+e)}),delete e[this.latitude],delete e[this.longitude],{type:"Feature",properties:e,geometry:{type:"Point",coordinates:[a,t]}}};featureCollection=e=>({type:"FeatureCollection",features:e});features=e=>e.map(this.feature);_setIdIfNotExists=e=>{var t;return e.features.filter((e,t)=>0===t).every(e=>e.properties.hasOwnProperty("id"))||(t=e.features.map((e,t)=>{var t=t+1,a=this.title&&e.properties[this.title]?"-"+slugify(e.properties[this.title]):"";return e.properties.id=t+a,e}),e.features=t),e};addHash=e=>{if(!this.hash||this.no_info)return null;window.location.hash="#"+e};entry=t=>this.entries.find(e=>e.properties[this.id]==t);searchEntries=(t,e)=>{return e=void 0===e?this.geoJSON:e,t?e.filter(e=>{if(this.searchEntry(t,e.properties))return e}):e};searchEntry=(e,t)=>{for(const r of[...new Set([this.title,...this.search_fields])].filter(e=>e))if(t.hasOwnProperty(r)){var a=replaceSpecialChars(e).toUpperCase(),s=replaceSpecialChars(t[r]).toString().toUpperCase();try{if(s.includes(a))return t}catch(e){console.error(e)}}return null};_selectorName=e=>e.replace(/^(\.|\#)/,"");scrollCenter=()=>{var e=document.getElementById(this.map_selector),t=e.getBoundingClientRect(),e=(e.offsetLeft+e.offsetWidth)/2,t=t.top+window.scrollY;window.scrollTo({top:t,left:e,behavior:"smooth"})};_clearContent=()=>document.querySelector(".js-content"+this.scope_sufix).innerHTML="";toggleSlider=()=>{this.no_info||(document.querySelectorAll(".js-slider"+this.scope_sufix).forEach(e=>{e.classList.toggle(this.slider_selector+"--in")}),document.querySelectorAll(".js-slider"+this.scope_sufix).forEach(e=>{e.style.display=this.isSliderOpen()?"block":"none"}))};_focusOnFeature=t=>{this.map.eachLayer(e=>{e?.options?.id==t&&(e?._path?e._path.focus():e?._icon&&e._icon.focus())})};_clickToggleSlider=()=>document.querySelectorAll(".js-close-slider"+this.scope_sufix).forEach(e=>e.addEventListener("click",()=>{this._clearContent(),this.toggleSlider(),this._focusOnFeature(e.dataset.entryId)}));isSliderOpen=()=>{let t=[];return document.querySelectorAll(".js-slider"+this.scope_sufix).forEach(e=>{e.classList.contains(this.slider_selector+"--in")&&t.push(!0)}),t.some(e=>e)};setContent=t=>{if(!this.no_info){this._focusOnSlider(),this.isSliderOpen()||this.toggleSlider();const a="function"==typeof this.template?this.template(this,t):this.defaultTemplate(this,t);document.querySelectorAll(this.content_selector).forEach(e=>{e.innerHTML=a}),document.querySelectorAll(".js-close-slider"+this.scope_sufix).forEach(e=>{e.dataset.entryId=t[this.id]})}};_focusOnSlider=()=>{var e;this.no_info||(this.isSliderOpen()?document.querySelector(".js-close-slider"+this.scope_sufix).focus():(e=document.querySelector(".js-slider"+this.scope_sufix))&&e.addEventListener("animationend",()=>{document.querySelector(".js-close-slider"+this.scope_sufix).focus()}))};setHeaders=e=>{var t;return[this.template_structure,this.template_structure.mixing].every(e=>e)?(t=this.template_structure.mixing.reduce((e,t)=>{if([t.key].every(e=>e))return{...e,[t.key]:t.header||""}},{}),{...e,...t}):e};header=e=>this.headers.hasOwnProperty(e)?this.headers[e]:e;_renderSlider=()=>{var e,t,a,s;this.render_slider&&!this.no_info&&(document.querySelectorAll(".js-slider"+this.scope_sufix).forEach(e=>e.remove()),(e=document.createElement("button")).classList.add("btn","btn-xs","btn-secondary","btn-close","js-close-slider"+this.scope_sufix),e.title="Cerrar panel",e.setAttribute("role","button"),e.setAttribute("aria-label","Cerrar panel de información"),e.innerHTML='<span class="sr-only">Cerrar</span>✕',(t=document.createElement("a")).setAttribute("tabindex",0),t.id="js-anchor-slider"+this.scope_sufix,(a=document.createElement("div")).classList.add("content-container"),(s=document.createElement("div")).classList.add("content","js-content"+this.scope_sufix),s.tabIndex=0,a.appendChild(s),(s=document.createElement("div")).style.display="none",s.setAttribute("role","region"),s.setAttribute("aria-live","polite"),s.setAttribute("aria-label","Panel de información"),s.classList.add("slider","js-slider"+this.scope_sufix),s.id="slider"+this.scope_sufix,s.appendChild(e),s.appendChild(t),s.appendChild(a),document.querySelector(this.scope_selector+".poncho-map").appendChild(s))};_showSlider=(e,t)=>{e.hasOwnProperty("_latlng")?this.map.setView(e._latlng,this.map_anchor_zoom):this.map.fitBounds(e.getBounds()),e.fireEvent("click")};_showPopup=e=>{e.hasOwnProperty("_latlng")?this.markers.zoomToShowLayer(e,()=>{e.openPopup()}):(this.map.fitBounds(e.getBounds()),e.openPopup())};removeHash=()=>history.replaceState(null,null," ");hasHash=()=>{return window.location.hash.replace("#","")||!1};gotoHashedEntry=()=>{var e=this.hasHash();e&&this.gotoEntry(e)};gotoEntry=t=>{const a=this.entry(t),s=(e,t,a)=>{e.options.hasOwnProperty("id")&&e.options.id==t&&(this._setSelectedMarker(t,e),this.hash&&this.addHash(t),this.slider&&this.hash?this._showSlider(e,a):this._showPopup(e))};this.markers.eachLayer(e=>s(e,t,a)),this.map.eachLayer(e=>{e.hasOwnProperty("feature")&&"Point"!=e.feature.geometry.type&&s(e,t,a)})};_setClickeable=a=>{a.on("keypress click",t=>{document.querySelectorAll(".marker--active").forEach(e=>e.classList.remove("marker--active")),["_icon","_path"].forEach(e=>{t.sourceTarget.hasOwnProperty(e)&&t.sourceTarget[e].classList.add("marker--active")});var e=this.entries.find(e=>e.properties[this.id]==a.options.id);this.setContent(e.properties)})};isFeature=e=>!!e.hasOwnProperty("feature");_clickeableFeatures=()=>{this.reset_zoom&&this.map.eachLayer(e=>{this.isFeature(e)&&"Point"!=e.feature.geometry.type&&"MultiPoint"!=e.feature.geometry.type&&this._setClickeable(e)})};_clickeableMarkers=()=>{this.no_info||this.markers.eachLayer(this._setClickeable)};_urlHash=()=>{const t=e=>{e.on("click",()=>{this.addHash(e.options.id)})};this.markers.eachLayer(t),this.map.eachLayer(e=>{e.hasOwnProperty("feature")&&"Point"!=e.feature.geometry.type&&"MultiPoint"!=e.feature.geometry.type&&t(e)})};removeListElement=(e,t)=>{t=e.indexOf(t);return-1<t&&e.splice(t,1),e};_templateTitle=e=>{if(!e.hasOwnProperty(this.title))return!1;var t=this.template_structure,a=!!t.hasOwnProperty("title")&&t.title,s=this.title||!1;if(t.hasOwnProperty("title")&&"boolean"==typeof t.title)return!1;if(!a&&!s)return!1;a=a||s;let r;t?.header?((s=document.createElement("div")).innerHTML=this._mdToHtml(t.header(this,e)),this.template_innerhtml&&(s.innerHTML=t.header(this,e)),r=s):((r=document.createElement("h2")).classList.add(...t.title_classlist),r.textContent=e[a]);s=document.createElement("header");return s.className="header",s.appendChild(r),s};_templateList=e=>{var t=this.template_structure,a=Object.keys(e);let s=a;if(t.hasOwnProperty("values")&&0<t?.values?.length)s=t.values;else if(t.hasOwnProperty("exclude")&&0<t.exclude.length)for(const r of t.exclude)s=this.removeListElement(a,r);return s};_mdToHtml=e=>{var t,a;return this.template_markdown&&this._markdownEnable()?(t=new showdown.Converter(this.markdown_options),a=secureHTML(e,this.allowed_tags),t.makeHtml((""+a).trim())):e};_markdownEnable=()=>!("undefined"==typeof showdown||!showdown.hasOwnProperty("Converter"));_templateMixing=r=>{if(this.template_structure.hasOwnProperty("mixing")&&0<this.template_structure.mixing.length){var e=this.template_structure.mixing;let s={};return e.forEach(e=>{var{values:e,separator:t=", ",key:a}=e;void 0===a&&this.errorMessage("Mixing requiere un valor en el atributo «key».","warning"),s[a]=e.map(e=>e in r?r[e]:e.toString()).filter(e=>e).join(t)}),Object.assign({},r,s)}return r};_setType=(e,t=!1,a=!1)=>"function"==typeof e?e(this,t,a):e;_lead=e=>{var t,a,s,r;if(this.template_structure.hasOwnProperty("lead"))return this.template_structure.lead.hasOwnProperty("key")||this.errorMessage("Lead requiere un valor en el atributo «key».","warning"),{key:s=!1,css:t="small",style:r=!1}=this.template_structure.lead,(a=document.createElement("p")).textContent=e[s],(s=this._setType(r,e))&&a.setAttribute("style",s),(r=this._setType(t,e))&&a.classList.add(...r.split(" ")),a};_termIcon=(e,t)=>{var a=this.header_icons.find(e=>e.key==t);if(a){var{css:a=!1,style:s=!1,html:r=!1}=a,r=this._setType(r,e,t),s=this._setType(s,e,t),a=this._setType(a,e,t);if(a)return(e=document.createElement("i")).setAttribute("aria-hidden","true"),e.classList.add(...a.split(" ")),s&&e.setAttribute("style",s),e;if(r)return(a=document.createElement("template")).innerHTML=r,a.content}return!1};defaultTemplate=(e,t)=>{t=this._templateMixing(t);var a,s,r=this["template_structure"],o=this._templateList(t),i=this._templateTitle(t),n=document.createElement("article"),l=(n.classList.add(...r.container_classlist),document.createElement(r.definition_list_tag));l.classList.add(...r.definition_list_classlist),l.style.fontSize="1rem";for(const c of o)t.hasOwnProperty(c)&&t[c]&&((a=document.createElement(r.term_tag)).classList.add(...r.term_classlist),(s=this._termIcon(t,c))&&(a.appendChild(s),a.insertAdjacentText("beforeend"," ")),a.insertAdjacentText("beforeend",this.header(c)),(s=document.createElement(r.definition_tag)).classList.add(...r.definition_classlist),s.textContent=t[c],this.template_markdown?s.innerHTML=this._mdToHtml(t[c]):this.template_innerhtml&&(s.innerHTML=secureHTML(t[c],this.allowed_tags)),""!=this.header(c)&&l.appendChild(a),l.appendChild(s));o=this._lead(t);return o&&n.appendChild(o),i&&n.appendChild(i),n.appendChild(l),n.outerHTML};icon=(e="azul")=>new L.icon({iconUrl:"https://www.argentina.gob.ar/sites/default/files/"+`marcador-${e}.svg`,iconSize:[29,40],iconAnchor:[14,40],popupAnchor:[0,-37]});resetView=()=>this.map.setView(this.map_view,this.map_zoom);fitBounds=()=>{try{this.map.fitBounds(this.geojson.getBounds())}catch(e){console.error(e)}};_resetViewButton=()=>{this.reset_zoom&&(document.querySelectorAll(".js-reset-view"+this.scope_sufix).forEach(e=>e.remove()),document.querySelectorAll(this.scope_selector+" .leaflet-control-zoom-in").forEach(e=>{var t=document.createElement("i"),a=(t.classList.add("fa","fa-expand"),t.setAttribute("aria-hidden","true"),document.createElement("a"));a.classList.add("js-reset-view"+this.scope_sufix,"leaflet-control-zoom-reset"),a.href="#",a.title="Zoom para ver todo el mapa",a.setAttribute("role","button"),a.setAttribute("aria-label","Zoom para ver todo el mapa"),a.appendChild(t),a.onclick=e=>{e.preventDefault(),this.resetView()},e.after(a)}))};marker=e=>{var t;return this.marker_color&&"boolean"!=typeof this.marker_color?"string"==typeof this.marker_color?this.icon(this.marker_color):"string"==typeof this.marker_color(this,e)?(t=this.marker_color(this,e),this.icon(t)):"function"==typeof this.marker_color?this.marker_color(this,e):void 0:null};_clearLayers=()=>{this.markers.clearLayers(),this.map.eachLayer(e=>{this.isFeature(e)&&this.map.removeLayer(e)})};markersMap=e=>{var r=this;this._clearLayers(),this.geojson=new L.geoJson(e,{pointToLayer:function(e,t){var e=e["properties"],a=r.marker(e),s={},a=(s.id=e[r.id],a&&(s.icon=a),r.title&&(s.alt=e[r.title]),new L.marker(t,s));return r.map.options.minZoom=r.min_zoom,r.markers.addLayer(a),r.tooltip&&e[r.title]&&a.bindTooltip(e[r.title],r.tooltip_options),r.no_info||r.slider||(t="function"==typeof r.template?r.template(r,e):r.defaultTemplate(r,e),a.bindPopup(t)),r.markers},onEachFeature:function(e,t){var{properties:a,geometry:s}=e;t.options.id=a[r.id],e.properties.name=a[r.title],r.tooltip&&a[r.title]&&"Point"!=s.type&&"MultiPoint"!=s.type&&t.bindTooltip(a[r.title],r.tooltip_options),r.no_info||r.slider||"Point"==s.type||"MultiPoint"==s.type||(e="function"==typeof r.template?r.template(r,a):r.defaultTemplate(r,a),t.bindPopup(e))},style:function(e){const a=e["properties"];e=(e,t=!1)=>a.hasOwnProperty(e)?a[e]:t||r.featureStyle[e];return{color:e("stroke-color",e("stroke")),strokeOpacity:e("stroke-opacity"),weight:e("stroke-width"),fillColor:e("stroke"),opacity:e("stroke-opacity"),fillOpacity:e("fill-opacity")}}}),this.geojson.addTo(this.map)};_setSelectedMarker=(e,t)=>{e={entry:this.entry(e),marker:t};return this.selected_marker=e};_selectedMarker=()=>{this.map.eachLayer(t=>{this.isFeature(t)&&t.on("click",e=>{this._setSelectedMarker(t.options.id,t)})})};_hiddenSearchInput=()=>{const t=document.createElement("input");t.type="hidden",t.name="js-search-input"+this.scope_sufix,t.setAttribute("disabled","disabled"),t.id="js-search-input"+this.scope_sufix,document.querySelectorAll(this.scope_selector+".poncho-map").forEach(e=>e.appendChild(t))};_setFetureAttributes=()=>{const t=(e,t)=>{e.hasOwnProperty(t)&&(e[t].setAttribute("aria-label",e?.feature?.properties?.[this.title]),e[t].setAttribute("role","button"),e[t].setAttribute("tabindex",0),e[t].dataset.entryId=e?.feature?.properties?.[this.id],e[t].dataset.leafletId=e._leaflet_id)};this.map.eachLayer(e=>t(e,"_path"))};_accesibleAnchors=()=>{var e=[[this.scope_selector+" .leaflet-map-pane","leaflet-map-pane"+this.scope_sufix,[["role","region"]]],[this.scope_selector+" .leaflet-control-zoom","leaflet-control-zoom"+this.scope_sufix,[["aria-label","Herramientas de zoom"],["role","region"]]]];return e.forEach(e=>{const t=document.querySelector(e[0]);t.id=e[1],e[2].forEach(e=>t.setAttribute(e[0],e[1]))}),e};_accesibleMenu=()=>{document.querySelectorAll(this.scope_selector+" .accesible-nav").forEach(e=>e.remove());var e=this._accesibleAnchors(),e=[...e=[{text:"Ir a los marcadores del mapa",anchor:"#"+e[0][1]},{text:"Ajustar marcadores al mapa",anchor:"#",class:"js-fit-bounds"},{text:"Ir al panel de zoom",anchor:"#"+e[1][1]}],...this.accesible_menu_filter,...this.accesible_menu_search,...this.accesible_menu_extras],t=document.createElement("i");t.classList.add("icono-arg-sitios-accesibles","accesible-nav__icon"),t.setAttribute("aria-hidden","true");const a=document.createElement("div"),s=(a.classList.add("accesible-nav","top"),a.id="accesible-nav"+this.scope_sufix,a.setAttribute("aria-label","Menú para el mapa"),a.setAttribute("role","navigation"),a.tabIndex=0,document.createElement("ul"));e.forEach((e,t)=>{var a=document.createElement("a"),e=(a.textContent=e.text,a.tabIndex=0,a.href=e.anchor,e.hasOwnProperty("class")&&""!=e.class&&a.classList.add(...e.class.split(" ")),document.createElement("li"));e.appendChild(a),s.appendChild(e)}),a.appendChild(t),a.appendChild(s);e=document.createElement("a");e.textContent="Ir a la navegación del mapa",e.href="#accesible-nav"+this.scope_sufix,e.id="accesible-return-nav"+this.scope_sufix;const r=document.createElement("div");r.classList.add("accesible-nav","bottom"),r.appendChild(t.cloneNode(!0)),r.appendChild(e),document.querySelectorAll(""+this.scope_selector).forEach(e=>{e.insertBefore(a,e.children[0]),e.appendChild(r)}),this.fit()};fit=()=>document.querySelectorAll(this.scope_selector+" .js-fit-bounds").forEach(e=>{e.onclick=e=>{e.preventDefault(),this.fitBounds()}});render=()=>{this._hiddenSearchInput(),this._resetViewButton(),this.markersMap(this.entries),this._selectedMarker(),this.slider&&(this._renderSlider(),this._clickeableFeatures(),this._clickeableMarkers(),this._clickToggleSlider()),this.hash&&this._urlHash(),this.scroll&&this.hasHash()&&this.scrollCenter(),setTimeout(this.gotoHashedEntry,this.anchor_delay),this._setFetureAttributes(),this._accesibleMenu()}}class PonchoMapFilter extends PonchoMap{constructor(e,t){super(e,t);e=Object.assign({},{filters:[],filters_visible:!1,filters_info:!1,check_uncheck_all:!1,search_fields:[],messages:{reset:' <a href="#" class="{{reset_search}}" title="Restablece el mapa a su estado inicial">Restablecer mapa</a>',initial:"Hay {{total_results}} puntos en el mapa.",no_results_by_term:"No encontramos resultados para tu búsqueda.",no_results:"No s + this.messages.resete encontraron entradas.",results:"{{total_results}} resultados coinciden con tu búsqueda.",one_result:"{{total_results}} resultado coincide con tu búsqueda.",has_filters:'<i title="¡Advertencia!" aria-hidden="true" class="fa fa-warning text-danger"></i> Se están usando filtros.'}},t);this.filters=e.filters,this.filters_info=e.filters_info,this.filters_visible=e.filters_visible,this.check_uncheck_all=e.check_uncheck_all,this.valid_fields=["checkbox","radio"],this.search_fields=e.search_fields,this.messages=e.messages,this.accesible_menu_filter=[{text:"Ir al panel de filtros",anchor:"#filtrar-busqueda"+this.scope_sufix}]}tplParser=(e,s)=>Object.keys(s).reduce(function(e,t){var a=new RegExp("\\{\\{\\s{0,2}"+t+"\\s{0,2}\\}\\}","gm");return e=e.replace(a,s[t])},e);_helpText=e=>{var t=document.querySelectorAll(this.scope_selector+" .js-poncho-map__help");const s={total_results:e.length,total_entries:this.entries.length,total_filtered_entries:this.filtered_entries.length,filter_class:"js-close-filter"+this.scope_sufix,anchor:"#",term:this.inputSearchValue,reset_search:"js-poncho-map-reset"+this.scope_sufix};t.forEach(e=>{e.innerHTML="";var t=document.createElement("ul"),a=(t.classList.add("m-b-0","list-unstyled"),t.setAttribute("aria-live","polite"),e=>{var t=document.createElement("li");return t.innerHTML=e,t});s.total_entries===s.total_results?t.appendChild(a(this.tplParser(this.messages.initial,s))):s.total_results<1?t.appendChild(a(this.tplParser(this.messages.no_results_by_term+this.messages.reset,s))):""===this.inputSearchValue&&s.total_results<1?t.appendChild(a(this.tplParser(this.messages.no_results+this.messages.reset,s))):1==s.total_results?t.appendChild(a(this.tplParser(this.messages.one_result+this.messages.reset,s))):1<s.total_results&&t.appendChild(a(this.tplParser(this.messages.results+this.messages.reset,s))),this.usingFilters(),e.appendChild(t)})};_filterPosition=e=>{e=/^([\w\-]+?)(?:__([0-9]+))(?:__([0-9]+))?$/gm.exec(e);return e?[e[1],e[2]]:null};isFilterOpen=()=>document.querySelector(".js-poncho-map-filters"+this.scope_sufix).classList.contains("filter--in");toggleFilter=()=>{document.querySelector(".js-poncho-map-filters"+this.scope_sufix).classList.toggle("filter--in")};_filterContainerHeight=()=>{var e=document.querySelector(".js-filter-container"+this.scope_sufix),t=document.querySelector(".js-close-filter"+this.scope_sufix),e=e.offsetParent.offsetHeight-e.offsetTop-t.offsetHeight-20,t=document.querySelector(".js-poncho-map-filters"+this.scope_sufix),e=(t.style.maxHeight=e+"px",t.offsetHeight-45),t=document.querySelector(".js-filters"+this.scope_sufix);t.style.height=e+"px",t.style.overflow="auto"};_clickToggleFilter=()=>document.querySelectorAll(".js-close-filter"+this.scope_sufix).forEach(e=>e.onclick=e=>{e.preventDefault(),this.toggleFilter(),this._filterContainerHeight()});_setFilter=e=>{const[t,a="checked"]=e;e=this.entries.map(e=>{if(e.properties.hasOwnProperty(t))return e.properties[t]}).filter(e=>e),e=[...new Set(e)].map(e=>[t,e,[e],a]);return e.sort((e,t)=>{e=e[1].toUpperCase(),t=t[1].toUpperCase();return t<e?1:e<t?-1:0}),e};_fieldsToUse=e=>{var{fields:e=!1,field:t=!1}=e,e=(e||t||this.errorMessage("Filters requiere el uso del atributo `field` o `fields`.","warning"),e||this._setFilter(t));return e};_fields=(e,t)=>{var a=document.createElement("div"),s=(a.classList.add("field-list","p-b-1"),this._fieldsToUse(e));for(const c in s){var r=s[c],o=document.createElement("input"),i=(o.type=this.valid_fields.includes(e.type)?e.type:"checkbox",o.id=`id__${r[0]}__${t}__`+c,"radio"==e.type?o.name=r[0]+"__"+t:o.name=r[0]+`__${t}__`+c,o.className="form-check-input",o.value=c,void 0!==r[3]&&"checked"==r[3]&&o.setAttribute("checked","checked"),document.createElement("label")),n=(i.style.marginLeft=".33rem",i.textContent=r[1],i.className="form-check-label",i.setAttribute("for",`id__${r[0]}__${t}__`+c),document.createElement("span")),r=(n.dataset.info=r[0]+`__${t}__`+c,i.appendChild(n),document.createElement("div"));r.className="form-check",r.appendChild(o),r.appendChild(i),a.appendChild(r)}var l=document.createElement("div");return l.appendChild(a),l};_filterButton=()=>{var e=document.createElement("i"),t=(e.setAttribute("aria-hidden","true"),e.classList.add("fa","fa-filter"),document.createElement("span")),a=(t.textContent="Abre o cierra el filtro de búsqueda",t.classList.add("sr-only"),document.createElement("button")),e=(a.classList.add("btn","btn-secondary","btn-filter","js-close-filter"+this.scope_sufix),a.id="filtrar-busqueda"+this.scope_sufix,a.appendChild(e),a.appendChild(t),a.setAttribute("role","button"),a.setAttribute("aria-label","Abre o cierra el filtro de búsqueda"),a.setAttribute("aria-controls","poncho-map-filters"+this.scope_sufix),document.createElement("div"));e.classList.add("js-filter-container"+this.scope_sufix,"filter-container"),this.reset_zoom&&e.classList.add("filter-container--zoom-expand"),e.appendChild(a),document.querySelector(".poncho-map"+this.scope_selector).appendChild(e)};_filterContainer=()=>{var e=document.createElement("div"),t=(e.className="js-filters"+this.scope_sufix,document.createElement("button")),a=(t.classList.add("btn","btn-xs","btn-secondary","btn-close","js-close-filter"+this.scope_sufix),t.title="Cerrar panel",t.setAttribute("role","button"),t.setAttribute("aria-label","Cerrar panel de filtros"),t.innerHTML='<span class="sr-only">Cerrar </span>✕',document.createElement("form"));a.classList.add("js-formulario"+this.scope_sufix),a.appendChild(t),a.appendChild(e);const s=document.createElement("div");s.classList.add("js-poncho-map-filters"+this.scope_sufix,"poncho-map-filters"),s.setAttribute("role","region"),s.setAttribute("aria-live","polite"),s.setAttribute("aria-label","Panel de filtros"),s.id="poncho-map-filters"+this.scope_sufix,this.filters_visible&&s.classList.add("filter--in"),s.appendChild(a),document.querySelectorAll(".js-filter-container"+this.scope_sufix).forEach(e=>e.appendChild(s))};_checkUncheckButtons=e=>{var t=document.createElement("button"),a=(t.classList.add("js-select-items","select-items__button"),t.textContent="Marcar todos",t.dataset.field=e.field[0],t.dataset.value=1,document.createElement("button")),e=(a.classList.add("js-select-items","select-items__button"),a.textContent="Desmarcar todos",a.dataset.field=e.field[0],a.dataset.value=0,document.createElement("div"));return e.classList.add("select-items"),e.appendChild(t),e.appendChild(a),e};_createFilters=e=>{const r=document.querySelector(".js-filters"+this.scope_sufix);e.forEach((e,t)=>{var a=document.createElement("legend"),s=(a.textContent=e.legend,a.classList.add("m-b-1","text-primary","h6"),document.createElement("fieldset"));s.appendChild(a),this.check_uncheck_all&&s.appendChild(this._checkUncheckButtons(e)),s.appendChild(this._fields(e,t)),r.appendChild(s)})};formFilters=()=>{var e;return this.filters.length<1?[]:(e=document.querySelector(".js-formulario"+this.scope_sufix),e=new FormData(e),Array.from(e).map(e=>{var t=this._filterPosition(e[0]);return[parseInt(t[1]),parseInt(e[1]),t[0]]}))};defaultFiltersConfiguration=()=>{return this.filters.map((e,a)=>{return this._fieldsToUse(e).map((e,t)=>[a,t,e[0],"undefinded"!=typeof e[3]&&"checked"==e[3]])}).flat()};usingFilters=()=>{return this.defaultFiltersConfiguration().every(e=>document.querySelector(`#id__${e[2]}__${e[0]}__`+e[1]).checked)};_resetFormFilters=()=>{this.defaultFiltersConfiguration().forEach(e=>{document.querySelector(`#id__${e[2]}__${e[0]}__`+e[1]).checked=e[3]})};get inputSearchValue(){var e=document.querySelector("#js-search-input"+this.scope_sufix).value.trim();return""!==e&&e}_countOccurrences=(e,a,s)=>{return e.reduce((e,t)=>a.some(e=>t.properties[s].includes(e))?e+1:e,0)};totals=()=>{return this.formFilters().map(e=>{var t=this._fieldsToUse(this.filters[e[0]])[e[1]];return[t[1],this._countOccurrences(this.filtered_entries,t[2],t[0]),...e]})};_totalsInfo=()=>{if(!this.filters_info)return"";this.totals().forEach(e=>{var t=document.querySelector(""+this.scope_selector+` [data-info="${e[4]}__${e[2]}__${e[3]}"]`),a=e[1]<2?"":"s",s=document.createElement("i"),r=(s.style.cursor="help",s.style.opacity=".75",s.style.marginLeft=".5em",s.style.marginRight=".25em",s.classList.add("fa","fa-info-circle","small","text-info"),s.title=e[1]+" resultado"+a,s.setAttribute("aria-hidden","true"),document.createElement("span")),e=(r.className="sr-only",r.style.fontWeight="400",r.textContent=e[1]+` elemento${a}.`,document.createElement("small"));e.appendChild(s),e.appendChild(r),t.appendChild(e)})};_validateEntry=(t,a)=>{var s=this.filters.length,r=[];for(let e=0;e<s;e++)r.push(this._validateGroup(t,(t=>a.filter(e=>e[0]==t))(e)));return r.every(e=>e)};_search=(t,e,a)=>{const s=this._fieldsToUse(this.filters[e])[a];return s[2].filter(e=>e).some(e=>{if(t.hasOwnProperty(s[0]))return t[s[0]].includes(e)})};_validateGroup=(t,e)=>{return e.map(e=>this._search(t,e[0],e[1])).some(e=>e)};_filterData=()=>{var e=this.formFilters(),t=this.entries.filter(e=>this._validateEntry(e.properties,this.formFilters())),t=this.searchEntries(this.inputSearchValue,t);return t=this.filters.length<1||0<e.length?t:[],this.filtered_entries=t};_filteredData=e=>{e=void 0!==e?this.entries:this._filterData(),this.markersMap(e),this._selectedMarker(),this._helpText(e),this._resetSearch(),this._clickToggleFilter(),this.slider&&(this._renderSlider(),this._clickeableMarkers(),this._clickeableFeatures(),this._clickToggleSlider()),this.hash&&this._urlHash(),this._setFetureAttributes(),this._accesibleMenu()};_clearSearchInput=()=>document.querySelectorAll("#js-search-input"+this.scope_sufix).forEach(e=>e.value="");_resetSearch=()=>{document.querySelectorAll(".js-poncho-map-reset"+this.scope_sufix).forEach(e=>{e.onclick=e=>{e.preventDefault(),this._resetFormFilters(),this._filteredData(this.entries),this._clearSearchInput(),this.resetView()}})};filterChange=t=>document.querySelectorAll(".js-filters"+this.scope_sufix).forEach(e=>{e.onchange=t});checkUncheckFilters=()=>{if(!this.check_uncheck_all)return null;document.querySelectorAll(this.scope_selector+" .js-select-items").forEach(t=>{t.onclick=e=>{e.preventDefault(),document.querySelectorAll(`${this.scope_selector} [id^=id__${t.dataset.field}]`).forEach(e=>{e.checked=parseInt(t.dataset.value)}),this._filteredData()}})};render=()=>{this._hiddenSearchInput(),this._resetViewButton(),0<this.filters.length&&(this._filterButton(),this._filterContainer(),this._createFilters(this.filters)),this._filteredData(),this._totalsInfo(),this.scroll&&this.hasHash()&&this.scrollCenter(),this.checkUncheckFilters(),this.filterChange(e=>{e.preventDefault(),this._filteredData()}),setTimeout(this.gotoHashedEntry,this.anchor_delay),this.filters_visible&&this._filterContainerHeight()}}class PonchoMapSearch{constructor(e,t){var a={scope:!1,placeholder:"Su búsqueda",search_fields:e.search_fields,sort:!0,sort_reverse:!1,sort_key:"text",datalist:!0},a=(this.instance=e,Object.assign({},a,t));this.text=e.title||!1,this.datalist=a.datalist,this.placeholder=a.placeholder,this.scope=a.scope,this.scope_sufix="--"+this.scope,this.sort=a.sort,this.sort_reverse=a.sort_reverse,this.search_scope_selector=this.scope?`[data-scope="${this.scope}"]`:"",this.instance.search_fields=a.search_fields,this.instance.accesible_menu_search=[{text:"Hacer una búsqueda",anchor:"#id-poncho-map-search"+this.scope_sufix}]}sortData=(e,s)=>{e=e.sort((e,t)=>{var a=e=>{this.instance.removeAccents(e).toUpperCase()};return a(e[s]),a(t[s]),a(e[s]),a(t[s]),0});return this.sort_reverse?e.reverse():e};_triggerSearch=()=>{const t=document.querySelector(this.search_scope_selector+" .js-poncho-map-search__input");t.id="id-poncho-map-search"+this.scope_sufix,document.querySelectorAll(this.search_scope_selector+" .js-poncho-map-search__submit").forEach(e=>{e.onclick=e=>{e.preventDefault();document.querySelector("#js-search-input"+this.instance.scope_sufix).value=t.value;e=t.value;this._renderSearch(e)}})};_keyup=()=>{document.querySelectorAll(this.search_scope_selector+" .js-poncho-map-search__input").forEach(e=>{const t=document.querySelector("#js-search-input"+this.instance.scope_sufix);e.onkeyup=()=>{t.value=e.value},e.onkeydown=()=>{t.value=e.value}})};_placeHolder=()=>{if(!this.placeholder)return"";document.querySelectorAll(this.search_scope_selector+" .js-poncho-map-search__input").forEach(e=>e.placeholder=this.placeholder.toString())};_renderSearch=e=>{var t=this.instance._filterData();this.instance.markersMap(t),this.instance.slider&&(this.instance._renderSlider(),this.instance._clickeableFeatures(),this.instance._clickeableMarkers(),this.instance._clickToggleSlider()),this.instance.hash&&this.instance._urlHash(),this.instance.resetView(),1==t.length?this.instance.gotoEntry(t[0].properties[this.instance.id]):""!=e.trim()&&(this.instance.removeHash(),setTimeout(this.instance.fitBounds,this.instance.anchor_delay)),this.instance._helpText(t),this.instance._resetSearch(),this.instance._clickToggleFilter(),this.instance._setFetureAttributes(),this.instance._accesibleMenu()};_addDataListOptions=()=>{if(!this.datalist)return null;document.querySelectorAll(this.search_scope_selector+" .js-porcho-map-search__list,"+` ${this.search_scope_selector} .js-poncho-map-search__list`).forEach(a=>{a.innerHTML="";var e=document.querySelector(this.search_scope_selector+" .js-poncho-map-search__input"),t="id-datalist"+this.scope_sufix;e.setAttribute("list",t),a.id=t,this.instance.filtered_entries.forEach(e=>{return a.appendChild((e=e.properties[this.text],(t=document.createElement("option")).value=e,t));var t})})};_searchRegion=()=>{var e=document.querySelector(this.search_scope_selector);e.setAttribute("role","region"),e.setAttribute("aria-label","Buscador")};render=()=>{this._placeHolder(),this._triggerSearch(),this._addDataListOptions(),this.instance.filterChange(e=>{e.preventDefault(),this.instance._filteredData(),this._addDataListOptions()}),this._searchRegion(),this._keyup(),this.instance._accesibleMenu()}}class GapiSheetData{constructor(e){e=Object.assign({},{gapi_key:"AIzaSyCq2wEEKL9-6RmX-TkW23qJsrmnFHFf5tY",gapi_uri:"https://sheets.googleapis.com/v4/spreadsheets/"},e);this.gapi_key=e.gapi_key,this.gapi_uri=e.gapi_uri}url=(e,t,a)=>{return["https://sheets.googleapis.com/v4/spreadsheets/",t,"/values/",e,"?key=",void 0!==a?a:this.gapi_key,"&alt=json"].join("")};json_data=e=>{e=this.feed(e);return{feed:e,entries:this.entries(e),headers:this.headers(e)}};feed=(e,o=!0)=>{const i=e.values[0],n=/ |\/|_/gi;let l=[];return e.values.forEach((e,t)=>{if(0<t){var a,s={};for(a in i){var r=e.hasOwnProperty(a)?e[a].trim():"";o?s[""+i[a].toLowerCase().replace(n,"")]=r:s[""+i[a].replace(n,"")]=r}l.push(s)}}),l};gapi_feed_row=(e,t="-",a=!0)=>{const s=a?"filtro-":"";a=Object.entries(e);let r={};return a.map(e=>{return r[e[0].replace("gsx$","").replace(s,"").replace(/-/g,t)]=e[1].$t}),r};entries=e=>e.filter((e,t)=>0<t);headers=e=>e.find((e,t)=>0==t)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ar-poncho",
3
- "version": "2.0.280",
3
+ "version": "2.0.282",
4
4
  "description": "Base de html y css para la creación de sitios pertenecientes a la Administración Pública Nacional de la República Argentina.",
5
5
  "main": "index.js",
6
6
  "scripts": {