@datosgeo-atdt/geo-ui 0.4.7 → 0.4.8
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/components/MapaPMTiles.d.ts.map +1 -1
- package/dist/geo-ui.js +31 -29
- package/dist/geo-ui.js.map +1 -1
- package/dist/geo-ui.umd.cjs +1 -1
- package/dist/geo-ui.umd.cjs.map +1 -1
- package/package.json +1 -1
package/dist/geo-ui.umd.cjs
CHANGED
|
@@ -819,5 +819,5 @@ License: MIT
|
|
|
819
819
|
`&&(ze=`
|
|
820
820
|
`);var Re=0,xt=!1;this.parse=function(rt,nt,We){if(typeof rt!="string")throw new Error("Input must be a string");var Et=rt.length,ft=he.length,It=ze.length,Wt=qe.length,at=et(Ue),Tt=[],jt=[],dt=[],Ot=Re=0;if(!rt)return Di();if(Nt||Nt!==!1&&rt.indexOf(ut)===-1){for(var si=rt.split(ze),vt=0;vt<si.length;vt++){if(dt=si[vt],Re+=dt.length,vt!==si.length-1)Re+=ze.length;else if(We)return Di();if(!qe||dt.substring(0,Wt)!==qe){if(at){if(Tt=[],mr(dt.split(he)),vi(),xt)return Di()}else mr(dt.split(he));if(ct&&ct<=vt)return Tt=Tt.slice(0,ct),Di(!0)}}return Di()}for(var Bt=rt.indexOf(he,Re),bt=rt.indexOf(ze,Re),qt=new RegExp(ge(Mt)+ge(ut),"g"),mt=rt.indexOf(ut,Re);;)if(rt[Re]===ut)for(mt=Re,Re++;;){if((mt=rt.indexOf(ut,mt+1))===-1)return We||jt.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:Tt.length,index:Re}),Oi();if(mt===Et-1)return Oi(rt.substring(Re,mt).replace(qt,ut));if(ut===Mt&&rt[mt+1]===Mt)mt++;else if(ut===Mt||mt===0||rt[mt-1]!==Mt){Bt!==-1&&Bt<mt+1&&(Bt=rt.indexOf(he,mt+1));var Kt=gr((bt=bt!==-1&&bt<mt+1?rt.indexOf(ze,mt+1):bt)===-1?Bt:Math.min(Bt,bt));if(rt.substr(mt+1+Kt,ft)===he){dt.push(rt.substring(Re,mt).replace(qt,ut)),rt[Re=mt+1+Kt+ft]!==ut&&(mt=rt.indexOf(ut,Re)),Bt=rt.indexOf(he,Re),bt=rt.indexOf(ze,Re);break}if(Kt=gr(bt),rt.substring(mt+1+Kt,mt+1+Kt+It)===ze){if(dt.push(rt.substring(Re,mt).replace(qt,ut)),Or(mt+1+Kt+It),Bt=rt.indexOf(he,Re),mt=rt.indexOf(ut,Re),at&&(vi(),xt))return Di();if(ct&&Tt.length>=ct)return Di(!0);break}jt.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:Tt.length,index:Re}),mt++}}else if(qe&&dt.length===0&&rt.substring(Re,Re+Wt)===qe){if(bt===-1)return Di();Re=bt+It,bt=rt.indexOf(ze,Re),Bt=rt.indexOf(he,Re)}else if(Bt!==-1&&(Bt<bt||bt===-1))dt.push(rt.substring(Re,Bt)),Re=Bt+ft,Bt=rt.indexOf(he,Re);else{if(bt===-1)break;if(dt.push(rt.substring(Re,bt)),Or(bt+It),at&&(vi(),xt))return Di();if(ct&&Tt.length>=ct)return Di(!0)}return Oi();function mr(ce){Tt.push(ce),Ot=Re}function gr(ce){var B=0;return B=ce!==-1&&(ce=rt.substring(mt+1,ce))&&ce.trim()===""?ce.length:B}function Oi(ce){return We||(ce===void 0&&(ce=rt.substring(Re)),dt.push(ce),Re=Et,mr(dt),at&&vi()),Di()}function Or(ce){Re=ce,mr(dt),dt=[],bt=rt.indexOf(ze,Re)}function Di(ce){if(pe.header&&!nt&&Tt.length&&!$t){var B=Tt[0],O=Object.create(null),U=new Set(B);let re=!1;for(let ne=0;ne<B.length;ne++){let fe=B[ne];if(O[fe=et(pe.transformHeader)?pe.transformHeader(fe,ne):fe]){let de,ae=O[fe];for(;de=fe+"_"+ae,ae++,U.has(de););U.add(de),B[ne]=de,O[fe]++,re=!0,(Zt=Zt===null?{}:Zt)[de]=fe}else O[fe]=1,B[ne]=fe;U.add(fe)}re&&console.warn("Duplicate headers found and renamed."),$t=!0}return{data:Tt,errors:jt,meta:{delimiter:he,linebreak:ze,aborted:xt,truncated:!!ce,cursor:Ot+(nt||0),renamedHeaders:Zt}}}function vi(){Ue(Di()),Tt=[],jt=[]}},this.abort=function(){xt=!0},this.getCharIndex=function(){return Re}}function Rt(pe){var he=pe.data,ze=c[he.workerId],qe=!1;if(he.error)ze.userError(he.error,he.file);else if(he.results&&he.results.data){var Ue={abort:function(){qe=!0,ht(he.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:ni,resume:ni};if(et(ze.userStep)){for(var ct=0;ct<he.results.data.length&&(ze.userStep({data:he.results.data[ct],errors:he.results.errors,meta:he.results.meta},Ue),!qe);ct++);delete he.results}else et(ze.userChunk)&&(ze.userChunk(he.results,Ue,he.file),delete he.results)}he.finished&&!qe&&ht(he.workerId,he.results)}function ht(pe,he){var ze=c[pe];et(ze.userComplete)&&ze.userComplete(he),ze.terminate(),delete c[pe]}function ni(){throw new Error("Not implemented.")}function pi(pe){if(typeof pe!="object"||pe===null)return pe;var he,ze=Array.isArray(pe)?[]:{};for(he in pe)ze[he]=pi(pe[he]);return ze}function Mi(pe,he){return function(){pe.apply(he,arguments)}}function et(pe){return typeof pe=="function"}return Pe.parse=function(pe,he){var ze=(he=he||{}).dynamicTyping||!1;if(et(ze)&&(he.dynamicTypingFunction=ze,ze={}),he.dynamicTyping=ze,he.transform=!!et(he.transform)&&he.transform,!he.worker||!Pe.WORKERS_SUPPORTED)return ze=null,Pe.NODE_STREAM_INPUT,typeof pe=="string"?(pe=(qe=>qe.charCodeAt(0)!==65279?qe:qe.slice(1))(pe),ze=new(he.download?Ne:ot)(he)):pe.readable===!0&&et(pe.read)&&et(pe.on)?ze=new zt(he):($.File&&pe instanceof File||pe instanceof Object)&&(ze=new Ke(he)),ze.stream(pe);(ze=(()=>{var qe;return!!Pe.WORKERS_SUPPORTED&&(qe=(()=>{var Ue=$.URL||$.webkitURL||null,ct=D.toString();return Pe.BLOB_URL||(Pe.BLOB_URL=Ue.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",ct,")();"],{type:"text/javascript"})))})(),(qe=new $.Worker(qe)).onmessage=Rt,qe.id=le++,c[qe.id]=qe)})()).userStep=he.step,ze.userChunk=he.chunk,ze.userComplete=he.complete,ze.userError=he.error,he.step=et(he.step),he.chunk=et(he.chunk),he.complete=et(he.complete),he.error=et(he.error),delete he.worker,ze.postMessage({input:pe,config:he,workerId:ze.id})},Pe.unparse=function(pe,he){var ze=!1,qe=!0,Ue=",",ct=`\r
|
|
821
821
|
`,Nt='"',Zt=Nt+Nt,$t=!1,ut=null,Mt=!1,Re=((()=>{if(typeof he=="object"){if(typeof he.delimiter!="string"||Pe.BAD_DELIMITERS.filter(function(nt){return he.delimiter.indexOf(nt)!==-1}).length||(Ue=he.delimiter),typeof he.quotes!="boolean"&&typeof he.quotes!="function"&&!Array.isArray(he.quotes)||(ze=he.quotes),typeof he.skipEmptyLines!="boolean"&&typeof he.skipEmptyLines!="string"||($t=he.skipEmptyLines),typeof he.newline=="string"&&(ct=he.newline),typeof he.quoteChar=="string"&&(Nt=he.quoteChar),typeof he.header=="boolean"&&(qe=he.header),Array.isArray(he.columns)){if(he.columns.length===0)throw new Error("Option columns is empty");ut=he.columns}he.escapeChar!==void 0&&(Zt=he.escapeChar+Nt),he.escapeFormulae instanceof RegExp?Mt=he.escapeFormulae:typeof he.escapeFormulae=="boolean"&&he.escapeFormulae&&(Mt=/^[=+\-@\t\r].*$/)}})(),new RegExp(ge(Nt),"g"));if(typeof pe=="string"&&(pe=JSON.parse(pe)),Array.isArray(pe)){if(!pe.length||Array.isArray(pe[0]))return xt(null,pe,$t);if(typeof pe[0]=="object")return xt(ut||Object.keys(pe[0]),pe,$t)}else if(typeof pe=="object")return typeof pe.data=="string"&&(pe.data=JSON.parse(pe.data)),Array.isArray(pe.data)&&(pe.fields||(pe.fields=pe.meta&&pe.meta.fields||ut),pe.fields||(pe.fields=Array.isArray(pe.data[0])?pe.fields:typeof pe.data[0]=="object"?Object.keys(pe.data[0]):[]),Array.isArray(pe.data[0])||typeof pe.data[0]=="object"||(pe.data=[pe.data])),xt(pe.fields||[],pe.data||[],$t);throw new Error("Unable to serialize unrecognized input");function xt(nt,We,Et){var ft="",It=(typeof nt=="string"&&(nt=JSON.parse(nt)),typeof We=="string"&&(We=JSON.parse(We)),Array.isArray(nt)&&0<nt.length),Wt=!Array.isArray(We[0]);if(It&&qe){for(var at=0;at<nt.length;at++)0<at&&(ft+=Ue),ft+=rt(nt[at],at);0<We.length&&(ft+=ct)}for(var Tt=0;Tt<We.length;Tt++){var jt=(It?nt:We[Tt]).length,dt=!1,Ot=It?Object.keys(We[Tt]).length===0:We[Tt].length===0;if(Et&&!It&&(dt=Et==="greedy"?We[Tt].join("").trim()==="":We[Tt].length===1&&We[Tt][0].length===0),Et==="greedy"&&It){for(var si=[],vt=0;vt<jt;vt++){var Bt=Wt?nt[vt]:vt;si.push(We[Tt][Bt])}dt=si.join("").trim()===""}if(!dt){for(var bt=0;bt<jt;bt++){0<bt&&!Ot&&(ft+=Ue);var qt=It&&Wt?nt[bt]:bt;ft+=rt(We[Tt][qt],bt)}Tt<We.length-1&&(!Et||0<jt&&!Ot)&&(ft+=ct)}}return ft}function rt(nt,We){var Et,ft;return nt==null?"":nt.constructor===Date?JSON.stringify(nt).slice(1,25):(ft=!1,Mt&&typeof nt=="string"&&Mt.test(nt)&&(nt="'"+nt,ft=!0),Et=nt.toString().replace(Re,Zt),(ft=ft||ze===!0||typeof ze=="function"&&ze(nt,We)||Array.isArray(ze)&&ze[We]||((It,Wt)=>{for(var at=0;at<Wt.length;at++)if(-1<It.indexOf(Wt[at]))return!0;return!1})(Et,Pe.BAD_DELIMITERS)||-1<Et.indexOf(Ue)||Et.charAt(0)===" "||Et.charAt(Et.length-1)===" ")?Nt+Et+Nt:Et)}},Pe.RECORD_SEP="",Pe.UNIT_SEP="",Pe.BYTE_ORDER_MARK="\uFEFF",Pe.BAD_DELIMITERS=["\r",`
|
|
822
|
-
`,'"',Pe.BYTE_ORDER_MARK],Pe.WORKERS_SUPPORTED=!ue&&!!$.Worker,Pe.NODE_STREAM_INPUT=1,Pe.LocalChunkSize=10485760,Pe.RemoteChunkSize=5242880,Pe.DefaultDelimiter=",",Pe.Parser=ti,Pe.ParserHandle=Qe,Pe.NetworkStreamer=Ne,Pe.FileStreamer=Ke,Pe.StringStreamer=ot,Pe.ReadableStreamStreamer=zt,$.jQuery&&((Q=$.jQuery).fn.parse=function(pe){var he=pe.config||{},ze=[];return this.each(function(ct){if(!(Q(this).prop("tagName").toUpperCase()==="INPUT"&&Q(this).attr("type").toLowerCase()==="file"&&$.FileReader)||!this.files||this.files.length===0)return!0;for(var Nt=0;Nt<this.files.length;Nt++)ze.push({file:this.files[Nt],inputElem:this,instanceConfig:Q.extend({},he)})}),qe(),this;function qe(){if(ze.length===0)et(pe.complete)&&pe.complete();else{var ct,Nt,Zt,$t,ut=ze[0];if(et(pe.before)){var Mt=pe.before(ut.file,ut.inputElem);if(typeof Mt=="object"){if(Mt.action==="abort")return ct="AbortError",Nt=ut.file,Zt=ut.inputElem,$t=Mt.reason,void(et(pe.error)&&pe.error({name:ct},Nt,Zt,$t));if(Mt.action==="skip")return void Ue();typeof Mt.config=="object"&&(ut.instanceConfig=Q.extend(ut.instanceConfig,Mt.config))}else if(Mt==="skip")return void Ue()}var Re=ut.instanceConfig.complete;ut.instanceConfig.complete=function(xt){et(Re)&&Re(xt,ut.file,ut.inputElem),Ue()},Pe.parse(ut.file,ut.instanceConfig)}}function Ue(){ze.splice(0,1),qe()}}),P&&($.onmessage=function(pe){pe=pe.data,Pe.WORKER_ID===void 0&&pe&&(Pe.WORKER_ID=pe.workerId),typeof pe.input=="string"?$.postMessage({workerId:Pe.WORKER_ID,results:Pe.parse(pe.input,pe.config),finished:!0}):($.File&&pe.input instanceof File||pe.input instanceof Object)&&(pe=Pe.parse(pe.input,pe.config))&&$.postMessage({workerId:Pe.WORKER_ID,results:pe,finished:!0})}),(Ne.prototype=Object.create(Oe.prototype)).constructor=Ne,(Ke.prototype=Object.create(Oe.prototype)).constructor=Ke,(ot.prototype=Object.create(ot.prototype)).constructor=ot,(zt.prototype=Object.create(Oe.prototype)).constructor=zt,Pe})})(yc)),yc.exports}var cg=lg();const np=Fd(cg);async function sp(F,C,D){return new Promise(($,Q)=>{np.parse(F,{download:!0,header:!0,skipEmptyLines:!0,complete:ue=>{try{const P=ue.data,c=ue.meta.fields||[],le=new Map;P.forEach(Pe=>{const Oe=Pe[C],Ne=Pe[D];if(Oe!=null){const Ke=parseFloat(Ne),ot=isNaN(Ke)?Ne:Ke;le.set(String(Oe),ot)}}),$({headers:c,rows:P,joinMap:le})}catch(P){Q(P)}},error:ue=>{Q(ue)}})})}async function ap(F,C,D){return new Promise(($,Q)=>{np.parse(F,{header:!0,skipEmptyLines:!0,complete:ue=>{try{const P=ue.data,c=ue.meta.fields||[],le=new Map;P.forEach(Pe=>{const Oe=Pe[C],Ne=Pe[D];if(Oe!=null){const Ke=parseFloat(Ne),ot=isNaN(Ke)?Ne:Ke;le.set(String(Oe),ot)}}),$({headers:c,rows:P,joinMap:le})}catch(P){Q(P)}},error:ue=>{Q(ue)}})})}function op(F,C){if(F.length===0)return[];if(C>=F.length)return[...new Set(F)].sort((le,Pe)=>le-Pe);const D=[...F].sort((le,Pe)=>le-Pe);let $=D.length;const Q=Array($+1).fill(0).map(()=>Array(C+1).fill(0)),ue=Array($+1).fill(0).map(()=>Array(C+1).fill(0));for(let le=1;le<=C;le++){Q[1][le]=1,ue[1][le]=0;for(let Pe=2;Pe<=$;Pe++)ue[Pe][le]=1/0}for(let le=2;le<=$;le++){let Pe=0,Oe=0,Ne=0;for(let Ke=1;Ke<=le;Ke++){const ot=le-Ke+1,zt=D[ot-1];Oe+=zt*zt,Pe+=zt,Ne++;const Qe=Oe-Pe*Pe/Ne,ge=ot-1;if(ge!==0)for(let ti=2;ti<=C;ti++)ue[le][ti]>=Qe+ue[ge][ti-1]&&(Q[le][ti]=ot,ue[le][ti]=Qe+ue[ge][ti-1])}Q[le][1]=1,ue[le][1]=ue[le-1][1]+(le-1)*(D[le-1]-D[le-2])**2}const P=[];let c=C;for(;c>=2;){const le=Q[$][c]-1;P.push(D[le]),$=Q[$][c]-1,c--}return P.push(D[0]),P.reverse(),P.push(D[D.length-1]),[...new Set(P)].sort((le,Pe)=>le-Pe)}function lp(F,C,D){const $=[],Q=c=>{const le=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(c);return le?{r:parseInt(le[1],16),g:parseInt(le[2],16),b:parseInt(le[3],16)}:{r:0,g:0,b:0}},ue=Q(F),P=Q(C);for(let c=0;c<D;c++){const le=c/(D-1),Pe=Math.round(ue.r+le*(P.r-ue.r)),Oe=Math.round(ue.g+le*(P.g-ue.g)),Ne=Math.round(ue.b+le*(P.b-ue.b));$.push(`rgb(${Pe}, ${Oe}, ${Ne})`)}return $}function ls(F,C){this.x=F,this.y=C}ls.prototype={clone(){return new ls(this.x,this.y)},add(F){return this.clone()._add(F)},sub(F){return this.clone()._sub(F)},multByPoint(F){return this.clone()._multByPoint(F)},divByPoint(F){return this.clone()._divByPoint(F)},mult(F){return this.clone()._mult(F)},div(F){return this.clone()._div(F)},rotate(F){return this.clone()._rotate(F)},rotateAround(F,C){return this.clone()._rotateAround(F,C)},matMult(F){return this.clone()._matMult(F)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(F){return this.x===F.x&&this.y===F.y},dist(F){return Math.sqrt(this.distSqr(F))},distSqr(F){const C=F.x-this.x,D=F.y-this.y;return C*C+D*D},angle(){return Math.atan2(this.y,this.x)},angleTo(F){return Math.atan2(this.y-F.y,this.x-F.x)},angleWith(F){return this.angleWithSep(F.x,F.y)},angleWithSep(F,C){return Math.atan2(this.x*C-this.y*F,this.x*F+this.y*C)},_matMult(F){const C=F[0]*this.x+F[1]*this.y,D=F[2]*this.x+F[3]*this.y;return this.x=C,this.y=D,this},_add(F){return this.x+=F.x,this.y+=F.y,this},_sub(F){return this.x-=F.x,this.y-=F.y,this},_mult(F){return this.x*=F,this.y*=F,this},_div(F){return this.x/=F,this.y/=F,this},_multByPoint(F){return this.x*=F.x,this.y*=F.y,this},_divByPoint(F){return this.x/=F.x,this.y/=F.y,this},_unit(){return this._div(this.mag()),this},_perp(){const F=this.y;return this.y=this.x,this.x=-F,this},_rotate(F){const C=Math.cos(F),D=Math.sin(F),$=C*this.x-D*this.y,Q=D*this.x+C*this.y;return this.x=$,this.y=Q,this},_rotateAround(F,C){const D=Math.cos(F),$=Math.sin(F),Q=C.x+D*(this.x-C.x)-$*(this.y-C.y),ue=C.y+$*(this.x-C.x)+D*(this.y-C.y);return this.x=Q,this.y=ue,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:ls},ls.convert=function(F){if(F instanceof ls)return F;if(Array.isArray(F))return new ls(+F[0],+F[1]);if(F.x!==void 0&&F.y!==void 0)return new ls(+F.x,+F.y);throw new Error("Expected [x, y] or {x, y} point format")};class cp{constructor(C,D,$,Q,ue){this.properties={},this.extent=$,this.type=0,this.id=void 0,this._pbf=C,this._geometry=-1,this._keys=Q,this._values=ue,C.readFields(ug,this,D)}loadGeometry(){const C=this._pbf;C.pos=this._geometry;const D=C.readVarint()+C.pos,$=[];let Q,ue=1,P=0,c=0,le=0;for(;C.pos<D;){if(P<=0){const Pe=C.readVarint();ue=Pe&7,P=Pe>>3}if(P--,ue===1||ue===2)c+=C.readSVarint(),le+=C.readSVarint(),ue===1&&(Q&&$.push(Q),Q=[]),Q&&Q.push(new ls(c,le));else if(ue===7)Q&&Q.push(Q[0].clone());else throw new Error(`unknown command ${ue}`)}return Q&&$.push(Q),$}bbox(){const C=this._pbf;C.pos=this._geometry;const D=C.readVarint()+C.pos;let $=1,Q=0,ue=0,P=0,c=1/0,le=-1/0,Pe=1/0,Oe=-1/0;for(;C.pos<D;){if(Q<=0){const Ne=C.readVarint();$=Ne&7,Q=Ne>>3}if(Q--,$===1||$===2)ue+=C.readSVarint(),P+=C.readSVarint(),ue<c&&(c=ue),ue>le&&(le=ue),P<Pe&&(Pe=P),P>Oe&&(Oe=P);else if($!==7)throw new Error(`unknown command ${$}`)}return[c,Pe,le,Oe]}toGeoJSON(C,D,$){const Q=this.extent*Math.pow(2,$),ue=this.extent*C,P=this.extent*D,c=this.loadGeometry();function le(Ke){return[(Ke.x+ue)*360/Q-180,360/Math.PI*Math.atan(Math.exp((1-(Ke.y+P)*2/Q)*Math.PI))-90]}function Pe(Ke){return Ke.map(le)}let Oe;if(this.type===1){const Ke=[];for(const zt of c)Ke.push(zt[0]);const ot=Pe(Ke);Oe=Ke.length===1?{type:"Point",coordinates:ot[0]}:{type:"MultiPoint",coordinates:ot}}else if(this.type===2){const Ke=c.map(Pe);Oe=Ke.length===1?{type:"LineString",coordinates:Ke[0]}:{type:"MultiLineString",coordinates:Ke}}else if(this.type===3){const Ke=dg(c),ot=[];for(const zt of Ke)ot.push(zt.map(Pe));Oe=ot.length===1?{type:"Polygon",coordinates:ot[0]}:{type:"MultiPolygon",coordinates:ot}}else throw new Error("unknown feature type");const Ne={type:"Feature",geometry:Oe,properties:this.properties};return this.id!=null&&(Ne.id=this.id),Ne}}cp.types=["Unknown","Point","LineString","Polygon"];function ug(F,C,D){F===1?C.id=D.readVarint():F===2?hg(D,C):F===3?C.type=D.readVarint():F===4&&(C._geometry=D.pos)}function hg(F,C){const D=F.readVarint()+F.pos;for(;F.pos<D;){const $=C._keys[F.readVarint()],Q=C._values[F.readVarint()];C.properties[$]=Q}}function dg(F){const C=F.length;if(C<=1)return[F];const D=[];let $,Q;for(let ue=0;ue<C;ue++){const P=pg(F[ue]);P!==0&&(Q===void 0&&(Q=P<0),Q===P<0?($&&D.push($),$=[F[ue]]):$&&$.push(F[ue]))}return $&&D.push($),D}function pg(F){let C=0;for(let D=0,$=F.length,Q=$-1,ue,P;D<$;Q=D++)ue=F[D],P=F[Q],C+=(P.x-ue.x)*(ue.y+P.y);return C}class fg{constructor(C,D){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=C,this._keys=[],this._values=[],this._features=[],C.readFields(mg,this,D),this.length=this._features.length}feature(C){if(C<0||C>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[C];const D=this._pbf.readVarint()+this._pbf.pos;return new cp(this._pbf,D,this.extent,this._keys,this._values)}}function mg(F,C,D){F===15?C.version=D.readVarint():F===1?C.name=D.readString():F===5?C.extent=D.readVarint():F===2?C._features.push(D.pos):F===3?C._keys.push(D.readString()):F===4&&C._values.push(gg(D))}function gg(F){let C=null;const D=F.readVarint()+F.pos;for(;F.pos<D;){const $=F.readVarint()>>3;C=$===1?F.readString():$===2?F.readFloat():$===3?F.readDouble():$===4?F.readVarint64():$===5?F.readVarint():$===6?F.readSVarint():$===7?F.readBoolean():null}if(C==null)throw new Error("unknown feature value");return C}class _g{constructor(C,D){this.layers=C.readFields(yg,{},D)}}function yg(F,C,D){if(F===3){const $=new fg(D,D.readVarint()+D.pos);$.length&&(C[$.name]=$)}}const ah=65536*65536,up=1/ah,xg=12,hp=typeof TextDecoder>"u"?null:new TextDecoder("utf-8"),oh=0,xc=1,Qo=2,vc=5;class vg{constructor(C=new Uint8Array(16)){this.buf=ArrayBuffer.isView(C)?C:new Uint8Array(C),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(C,D,$=this.length){for(;this.pos<$;){const Q=this.readVarint(),ue=Q>>3,P=this.pos;this.type=Q&7,C(ue,D,this),this.pos===P&&this.skip(Q)}return D}readMessage(C,D){return this.readFields(C,D,this.readVarint()+this.pos)}readFixed32(){const C=this.dataView.getUint32(this.pos,!0);return this.pos+=4,C}readSFixed32(){const C=this.dataView.getInt32(this.pos,!0);return this.pos+=4,C}readFixed64(){const C=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*ah;return this.pos+=8,C}readSFixed64(){const C=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*ah;return this.pos+=8,C}readFloat(){const C=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,C}readDouble(){const C=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,C}readVarint(C){const D=this.buf;let $,Q;return Q=D[this.pos++],$=Q&127,Q<128||(Q=D[this.pos++],$|=(Q&127)<<7,Q<128)||(Q=D[this.pos++],$|=(Q&127)<<14,Q<128)||(Q=D[this.pos++],$|=(Q&127)<<21,Q<128)?$:(Q=D[this.pos],$|=(Q&15)<<28,bg($,C,this))}readVarint64(){return this.readVarint(!0)}readSVarint(){const C=this.readVarint();return C%2===1?(C+1)/-2:C/2}readBoolean(){return!!this.readVarint()}readString(){const C=this.readVarint()+this.pos,D=this.pos;return this.pos=C,C-D>=xg&&hp?hp.decode(this.buf.subarray(D,C)):Rg(this.buf,D,C)}readBytes(){const C=this.readVarint()+this.pos,D=this.buf.subarray(this.pos,C);return this.pos=C,D}readPackedVarint(C=[],D){const $=this.readPackedEnd();for(;this.pos<$;)C.push(this.readVarint(D));return C}readPackedSVarint(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readSVarint());return C}readPackedBoolean(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readBoolean());return C}readPackedFloat(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readFloat());return C}readPackedDouble(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readDouble());return C}readPackedFixed32(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readFixed32());return C}readPackedSFixed32(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readSFixed32());return C}readPackedFixed64(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readFixed64());return C}readPackedSFixed64(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readSFixed64());return C}readPackedEnd(){return this.type===Qo?this.readVarint()+this.pos:this.pos+1}skip(C){const D=C&7;if(D===oh)for(;this.buf[this.pos++]>127;);else if(D===Qo)this.pos=this.readVarint()+this.pos;else if(D===vc)this.pos+=4;else if(D===xc)this.pos+=8;else throw new Error(`Unimplemented type: ${D}`)}writeTag(C,D){this.writeVarint(C<<3|D)}realloc(C){let D=this.length||16;for(;D<this.pos+C;)D*=2;if(D!==this.length){const $=new Uint8Array(D);$.set(this.buf),this.buf=$,this.dataView=new DataView($.buffer),this.length=D}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(C){this.realloc(4),this.dataView.setInt32(this.pos,C,!0),this.pos+=4}writeSFixed32(C){this.realloc(4),this.dataView.setInt32(this.pos,C,!0),this.pos+=4}writeFixed64(C){this.realloc(8),this.dataView.setInt32(this.pos,C&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(C*up),!0),this.pos+=8}writeSFixed64(C){this.realloc(8),this.dataView.setInt32(this.pos,C&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(C*up),!0),this.pos+=8}writeVarint(C){if(C=+C||0,C>268435455||C<0){wg(C,this);return}this.realloc(4),this.buf[this.pos++]=C&127|(C>127?128:0),!(C<=127)&&(this.buf[this.pos++]=(C>>>=7)&127|(C>127?128:0),!(C<=127)&&(this.buf[this.pos++]=(C>>>=7)&127|(C>127?128:0),!(C<=127)&&(this.buf[this.pos++]=C>>>7&127)))}writeSVarint(C){this.writeVarint(C<0?-C*2-1:C*2)}writeBoolean(C){this.writeVarint(+C)}writeString(C){C=String(C),this.realloc(C.length*4),this.pos++;const D=this.pos;this.pos=Fg(this.buf,C,this.pos);const $=this.pos-D;$>=128&&dp(D,$,this),this.pos=D-1,this.writeVarint($),this.pos+=$}writeFloat(C){this.realloc(4),this.dataView.setFloat32(this.pos,C,!0),this.pos+=4}writeDouble(C){this.realloc(8),this.dataView.setFloat64(this.pos,C,!0),this.pos+=8}writeBytes(C){const D=C.length;this.writeVarint(D),this.realloc(D);for(let $=0;$<D;$++)this.buf[this.pos++]=C[$]}writeRawMessage(C,D){this.pos++;const $=this.pos;C(D,this);const Q=this.pos-$;Q>=128&&dp($,Q,this),this.pos=$-1,this.writeVarint(Q),this.pos+=Q}writeMessage(C,D,$){this.writeTag(C,Qo),this.writeRawMessage(D,$)}writePackedVarint(C,D){D.length&&this.writeMessage(C,Pg,D)}writePackedSVarint(C,D){D.length&&this.writeMessage(C,Mg,D)}writePackedBoolean(C,D){D.length&&this.writeMessage(C,Cg,D)}writePackedFloat(C,D){D.length&&this.writeMessage(C,Ig,D)}writePackedDouble(C,D){D.length&&this.writeMessage(C,Eg,D)}writePackedFixed32(C,D){D.length&&this.writeMessage(C,Ag,D)}writePackedSFixed32(C,D){D.length&&this.writeMessage(C,Dg,D)}writePackedFixed64(C,D){D.length&&this.writeMessage(C,zg,D)}writePackedSFixed64(C,D){D.length&&this.writeMessage(C,kg,D)}writeBytesField(C,D){this.writeTag(C,Qo),this.writeBytes(D)}writeFixed32Field(C,D){this.writeTag(C,vc),this.writeFixed32(D)}writeSFixed32Field(C,D){this.writeTag(C,vc),this.writeSFixed32(D)}writeFixed64Field(C,D){this.writeTag(C,xc),this.writeFixed64(D)}writeSFixed64Field(C,D){this.writeTag(C,xc),this.writeSFixed64(D)}writeVarintField(C,D){this.writeTag(C,oh),this.writeVarint(D)}writeSVarintField(C,D){this.writeTag(C,oh),this.writeSVarint(D)}writeStringField(C,D){this.writeTag(C,Qo),this.writeString(D)}writeFloatField(C,D){this.writeTag(C,vc),this.writeFloat(D)}writeDoubleField(C,D){this.writeTag(C,xc),this.writeDouble(D)}writeBooleanField(C,D){this.writeVarintField(C,+D)}}function bg(F,C,D){const $=D.buf;let Q,ue;if(ue=$[D.pos++],Q=(ue&112)>>4,ue<128||(ue=$[D.pos++],Q|=(ue&127)<<3,ue<128)||(ue=$[D.pos++],Q|=(ue&127)<<10,ue<128)||(ue=$[D.pos++],Q|=(ue&127)<<17,ue<128)||(ue=$[D.pos++],Q|=(ue&127)<<24,ue<128)||(ue=$[D.pos++],Q|=(ue&1)<<31,ue<128))return Na(F,Q,C);throw new Error("Expected varint not more than 10 bytes")}function Na(F,C,D){return D?C*4294967296+(F>>>0):(C>>>0)*4294967296+(F>>>0)}function wg(F,C){let D,$;if(F>=0?(D=F%4294967296|0,$=F/4294967296|0):(D=~(-F%4294967296),$=~(-F/4294967296),D^4294967295?D=D+1|0:(D=0,$=$+1|0)),F>=18446744073709552e3||F<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");C.realloc(10),Tg(D,$,C),Sg($,C)}function Tg(F,C,D){D.buf[D.pos++]=F&127|128,F>>>=7,D.buf[D.pos++]=F&127|128,F>>>=7,D.buf[D.pos++]=F&127|128,F>>>=7,D.buf[D.pos++]=F&127|128,F>>>=7,D.buf[D.pos]=F&127}function Sg(F,C){const D=(F&7)<<4;C.buf[C.pos++]|=D|((F>>>=3)?128:0),F&&(C.buf[C.pos++]=F&127|((F>>>=7)?128:0),F&&(C.buf[C.pos++]=F&127|((F>>>=7)?128:0),F&&(C.buf[C.pos++]=F&127|((F>>>=7)?128:0),F&&(C.buf[C.pos++]=F&127|((F>>>=7)?128:0),F&&(C.buf[C.pos++]=F&127)))))}function dp(F,C,D){const $=C<=16383?1:C<=2097151?2:C<=268435455?3:Math.floor(Math.log(C)/(Math.LN2*7));D.realloc($);for(let Q=D.pos-1;Q>=F;Q--)D.buf[Q+$]=D.buf[Q]}function Pg(F,C){for(let D=0;D<F.length;D++)C.writeVarint(F[D])}function Mg(F,C){for(let D=0;D<F.length;D++)C.writeSVarint(F[D])}function Ig(F,C){for(let D=0;D<F.length;D++)C.writeFloat(F[D])}function Eg(F,C){for(let D=0;D<F.length;D++)C.writeDouble(F[D])}function Cg(F,C){for(let D=0;D<F.length;D++)C.writeBoolean(F[D])}function Ag(F,C){for(let D=0;D<F.length;D++)C.writeFixed32(F[D])}function Dg(F,C){for(let D=0;D<F.length;D++)C.writeSFixed32(F[D])}function zg(F,C){for(let D=0;D<F.length;D++)C.writeFixed64(F[D])}function kg(F,C){for(let D=0;D<F.length;D++)C.writeSFixed64(F[D])}function Rg(F,C,D){let $="",Q=C;for(;Q<D;){const ue=F[Q];let P=null,c=ue>239?4:ue>223?3:ue>191?2:1;if(Q+c>D)break;let le,Pe,Oe;c===1?ue<128&&(P=ue):c===2?(le=F[Q+1],(le&192)===128&&(P=(ue&31)<<6|le&63,P<=127&&(P=null))):c===3?(le=F[Q+1],Pe=F[Q+2],(le&192)===128&&(Pe&192)===128&&(P=(ue&15)<<12|(le&63)<<6|Pe&63,(P<=2047||P>=55296&&P<=57343)&&(P=null))):c===4&&(le=F[Q+1],Pe=F[Q+2],Oe=F[Q+3],(le&192)===128&&(Pe&192)===128&&(Oe&192)===128&&(P=(ue&15)<<18|(le&63)<<12|(Pe&63)<<6|Oe&63,(P<=65535||P>=1114112)&&(P=null))),P===null?(P=65533,c=1):P>65535&&(P-=65536,$+=String.fromCharCode(P>>>10&1023|55296),P=56320|P&1023),$+=String.fromCharCode(P),Q+=c}return $}function Fg(F,C,D){for(let $=0,Q,ue;$<C.length;$++){if(Q=C.charCodeAt($),Q>55295&&Q<57344)if(ue)if(Q<56320){F[D++]=239,F[D++]=191,F[D++]=189,ue=Q;continue}else Q=ue-55296<<10|Q-56320|65536,ue=null;else{Q>56319||$+1===C.length?(F[D++]=239,F[D++]=191,F[D++]=189):ue=Q;continue}else ue&&(F[D++]=239,F[D++]=191,F[D++]=189,ue=null);Q<128?F[D++]=Q:(Q<2048?F[D++]=Q>>6|192:(Q<65536?F[D++]=Q>>12|224:(F[D++]=Q>>18|240,F[D++]=Q>>12&63|128),F[D++]=Q>>6&63|128),F[D++]=Q&63|128)}return D}async function Lg(F,C,D,$="bbox",Q){try{const ue=new sh(F),P=await ue.getHeader(),c=Math.min(Math.floor((P.minZoom+P.maxZoom)/2),8),le=Math.pow(2,c);for(let Pe=0;Pe<le;Pe++)for(let Oe=0;Oe<le;Oe++)try{const Ne=await ue.getZxy(c,Pe,Oe);if(!Ne||!Ne.data)continue;const ot=new _g(new vg(Ne.data)).layers[C];if(!ot)continue;for(let zt=0;zt<ot.length;zt++){const Qe=ot.feature(zt),ge=Qe.properties,ti=String(Q?ge[Q]:Qe.id);if(ti===String(D)){let Rt=null;if(ge[$]){const ht=ge[$];if(typeof ht=="string")try{const ni=JSON.parse(ht);Array.isArray(ni)&&ni.length===4&&(Rt=ni)}catch{const ni=ht.split(",").map(pi=>parseFloat(pi.trim()));ni.length===4&&ni.every(pi=>!isNaN(pi))&&(Rt=ni)}else Array.isArray(ht)&&ht.length===4&&(Rt=ht)}if(!Rt){const ht=Qe.loadGeometry();let ni=1/0,pi=1/0,Mi=-1/0,et=-1/0;ht.forEach(Zt=>{Zt.forEach($t=>{ni=Math.min(ni,$t.x),pi=Math.min(pi,$t.y),Mi=Math.max(Mi,$t.x),et=Math.max(et,$t.y)})});const pe=4096,he=(Pe+ni/pe)/le*360-180,ze=(Pe+Mi/pe)/le*360-180,qe=Math.PI-2*Math.PI*(Oe+pi/pe)/le,Ue=Math.PI-2*Math.PI*(Oe+et/pe)/le,ct=180/Math.PI*Math.atan(.5*(Math.exp(qe)-Math.exp(-qe))),Nt=180/Math.PI*Math.atan(.5*(Math.exp(Ue)-Math.exp(-Ue)));Rt=[Math.min(he,ze),Math.min(ct,Nt),Math.max(he,ze),Math.max(ct,Nt)]}return{id:ti,bbox:Rt,properties:ge}}}}catch{continue}return console.warn(`Feature con id "${D}" no encontrada en PMTiles`),null}catch(ue){return console.error("Error buscando feature en PMTiles:",ue),null}}const el="pmtiles-source",lh="pmtiles-fill",js="municipios-source",ch="municipios-fill",Bg="https://www.datosgeoespaciales.atdt.gob.mx/datalake/pmtiles/componente/entidad.pmtiles",Og="entidad",Vg="cvegeo",pp="https://www.datosgeoespaciales.atdt.gob.mx/datalake/pmtiles/transformador/municipio.pmtiles",ja="municipio",uh="CVEGEO",Ng=({pmtilesUrl:F=Bg,sourceLayer:C=Og,joinGeomKey:D=Vg,csvUrl:$,csvFile:Q,joinCsvKey:ue,field:P="valor",mode:c="boolean",width:le="100%",height:Pe=520,initialView:Oe,fitToIds:Ne,bboxField:Ke="bbox",jenksK:ot=5,showMunicipios:zt=!1,municipiosCsvUrl:Qe,municipiosCsvFile:ge,municipiosField:ti="valor"})=>{const Rt=Ln.useRef(null),ht=Ln.useRef(null),[ni,pi]=Ln.useState(null);Ln.useEffect(()=>{if(!Rt.current)return;if(!$&&!Q){pi("Debe proporcionar csvUrl o csvFile"),console.error("MapaPMTiles: Debe proporcionar csvUrl o csvFile");return}let et=null;return(async()=>{try{const he=new Km;Od.addProtocol("pmtiles",he.tile);const ze=(Oe==null?void 0:Oe.center)||[-102,23],qe=(Oe==null?void 0:Oe.zoom)||4;et=new Bd.Map({container:Rt.current,style:{version:8,sources:{},layers:[]},center:ze,zoom:qe,boxZoom:!1,doubleClickZoom:!1,dragRotate:!1,keyboard:!1,scrollZoom:!1,touchPitch:!1,touchZoomRotate:!0,dragPan:!1,maxBounds:void 0,attributionControl:!1}),ht.current=et,et.on("load",async()=>{if(et)try{et.addSource(el,{type:"vector",url:`pmtiles://${F}`,promoteId:D});const Ue=ue||D,ct=Q?await ap(Q,Ue,P):await sp($,Ue,P);ct.joinMap.forEach((Mt,Re)=>{try{et.setFeatureState({source:el,sourceLayer:C,id:Re},{value:Mt})}catch(xt){console.warn(`Error setting feature state for key ${Re}:`,xt)}});let Nt;if(c==="boolean")Nt=["case",["==",["feature-state","value"],1],"#66827f","#f3f3f3"];else{const Mt=Array.from(ct.joinMap.values()).filter(Re=>typeof Re=="number").map(Re=>Re);if(Mt.length===0)console.warn("No hay valores numéricos para clasificación Jenks"),Nt=["case",["!=",["feature-state","value"],null],"#66827f","#f3f3f3"];else{const Re=op(Mt,ot),xt=Re.length-1,rt=lp("#f3f3f3","#66827f",xt),nt=["step",["feature-state","value"],rt[0]];for(let We=1;We<xt;We++)nt.push(Re[We]),nt.push(rt[We]);Nt=nt}}const Zt=Ne?Array.isArray(Ne)?Ne:[Ne]:[];let $t;Zt.length>0&&($t=["in",["get",D],["literal",Zt]]),zt?et.addLayer({id:lh,type:"fill",source:el,"source-layer":C,paint:{"fill-color":Nt,"fill-opacity":["case",["!=",["feature-state","value"],null],.75,0]},filter:$t}):et.addLayer({id:lh,type:"fill",source:el,"source-layer":C,paint:{"fill-color":Nt,"fill-opacity":.75},filter:$t}),et.addLayer({id:`${lh}-outline`,type:"line",source:el,"source-layer":C,paint:{"line-color":"#2c3e50","line-width":zt?1.5:.5},filter:$t});let ut=null;if(Zt.length>0){const Re=(await Promise.all(Zt.map(xt=>Lg(F,C,xt,Ke,D)))).filter(xt=>xt!==null&&xt.bbox);if(Re.length>0){let xt=1/0,rt=1/0,nt=-1/0,We=-1/0;Re.forEach(Et=>{Et&&Et.bbox&&(xt=Math.min(xt,Et.bbox[0]),rt=Math.min(rt,Et.bbox[1]),nt=Math.max(nt,Et.bbox[2]),We=Math.max(We,Et.bbox[3]))}),ut=[[xt,rt],[nt,We]],et.fitBounds(ut,{padding:50,duration:0})}else console.warn(`No se pudieron encontrar bboxes para los IDs: ${Zt.join(", ")}`)}if(zt&&Zt.length>0){console.log("[GEO-UI DEBUG] Iniciando capa de municipios"),console.log("[GEO-UI DEBUG] fitIdsArray:",Zt),console.log("[GEO-UI DEBUG] MUNICIPIOS_URL:",pp),et.addSource(js,{type:"vector",url:`pmtiles://${pp}`,promoteId:uh});const Mt=["in",["slice",["to-string",["get","CVEGEO"]],0,2],["literal",Zt]];if(console.log("[GEO-UI DEBUG] Filtro de municipios:",JSON.stringify(Mt,null,2)),et.addLayer({id:"debug-municipios-temp",type:"line",source:js,"source-layer":ja,paint:{"line-color":"transparent","line-width":0}}),console.log("[GEO-UI DEBUG] Esperando a que el mapa cargue tiles..."),et.once("idle",()=>{var xt,rt,nt,We,Et,ft;console.log("[GEO-UI DEBUG] Mapa idle - tiles cargados");const Re=et.querySourceFeatures(js,{sourceLayer:ja});if(console.log("[GEO-UI DEBUG] Total features sin filtro:",Re.length),Re.length>0){console.log("[GEO-UI DEBUG] Primeras 3 features de municipios:");for(let Wt=0;Wt<Math.min(3,Re.length);Wt++){const at=Re[Wt];console.log(` Feature ${Wt+1}:`,{id:at.id,properties:at.properties,CVEGEO:(xt=at.properties)==null?void 0:xt.CVEGEO,CVE_ENT:(rt=at.properties)==null?void 0:rt.CVE_ENT,cvegeo:(nt=at.properties)==null?void 0:nt.cvegeo,cve_ent:(We=at.properties)==null?void 0:We.cve_ent})}const It=Re.filter(Wt=>{var Tt;return String(((Tt=Wt.properties)==null?void 0:Tt.CVEGEO)||"").startsWith("09")});console.log('[GEO-UI DEBUG] Municipios que empiezan con "09":',It.length),It.length>0&&console.log("[GEO-UI DEBUG] Ejemplo de municipio 09:",{id:It[0].id,CVEGEO:(Et=It[0].properties)==null?void 0:Et.CVEGEO,CVE_ENT:(ft=It[0].properties)==null?void 0:ft.CVE_ENT})}else console.warn("[GEO-UI DEBUG] No se encontraron features de municipios!");et.getLayer("debug-municipios-temp")&&et.removeLayer("debug-municipios-temp")}),Qe||ge){const Re=ge?await ap(ge,uh,ti):await sp(Qe,uh,ti);Re.joinMap.forEach((rt,nt)=>{try{et.setFeatureState({source:js,sourceLayer:ja,id:nt},{value:rt})}catch(We){console.warn(`Error setting municipio feature state for key ${nt}:`,We)}});let xt;if(c==="boolean")xt=["case",["==",["feature-state","value"],1],"#66827f","#f3f3f3"];else{const rt=Array.from(Re.joinMap.values()).filter(nt=>typeof nt=="number").map(nt=>nt);if(rt.length>0){const nt=op(rt,ot),We=nt.length-1,Et=lp("#f3f3f3","#66827f",We),ft=["step",["feature-state","value"],Et[0]];for(let It=1;It<We;It++)ft.push(nt[It]),ft.push(Et[It]);xt=ft}else xt=["case",["!=",["feature-state","value"],null],"#66827f","#f3f3f3"]}et.addLayer({id:ch,type:"fill",source:js,"source-layer":ja,paint:{"fill-color":xt,"fill-opacity":.75},filter:Mt})}else et.addLayer({id:ch,type:"line",source:js,"source-layer":ja,paint:{"line-color":"#2c3e50","line-width":.5},filter:Mt});et.addLayer({id:`${ch}-outline`,type:"line",source:js,"source-layer":ja,paint:{"line-color":"#2c3e50","line-width":.5},filter:Mt})}}catch(Ue){console.error("Error cargando datos en el mapa:",Ue),pi(`Error cargando datos: ${Ue instanceof Error?Ue.message:String(Ue)}`)}}),et.on("error",Ue=>{var ct;console.error("Error del mapa:",Ue),pi(`Error del mapa: ${((ct=Ue.error)==null?void 0:ct.message)||"Error desconocido"}`)})}catch(he){console.error("Error inicializando mapa:",he),pi(`Error inicializando: ${he instanceof Error?he.message:String(he)}`)}})(),()=>{ht.current&&(ht.current.remove(),ht.current=null),Od.removeProtocol("pmtiles")}},[F,C,D,$,Q,ue,P,c,ot,Ne,Ke,Oe,zt,Qe,ge,ti]);const Mi={width:typeof le=="number"?`${le}px`:le,height:typeof Pe=="number"?`${Pe}px`:Pe,position:"relative"};return Ar.jsxs("div",{style:Mi,children:[Ar.jsx("div",{ref:Rt,style:{width:"100%",height:"100%"}}),ni&&Ar.jsx("div",{style:{position:"absolute",top:10,left:10,right:10,background:"rgba(231, 76, 60, 0.9)",color:"white",padding:"10px",borderRadius:"4px",fontSize:"12px",zIndex:1e3},children:ni})]})};Br.MapaPMTiles=Ng,Object.defineProperty(Br,Symbol.toStringTag,{value:"Module"})}));
|
|
822
|
+
`,'"',Pe.BYTE_ORDER_MARK],Pe.WORKERS_SUPPORTED=!ue&&!!$.Worker,Pe.NODE_STREAM_INPUT=1,Pe.LocalChunkSize=10485760,Pe.RemoteChunkSize=5242880,Pe.DefaultDelimiter=",",Pe.Parser=ti,Pe.ParserHandle=Qe,Pe.NetworkStreamer=Ne,Pe.FileStreamer=Ke,Pe.StringStreamer=ot,Pe.ReadableStreamStreamer=zt,$.jQuery&&((Q=$.jQuery).fn.parse=function(pe){var he=pe.config||{},ze=[];return this.each(function(ct){if(!(Q(this).prop("tagName").toUpperCase()==="INPUT"&&Q(this).attr("type").toLowerCase()==="file"&&$.FileReader)||!this.files||this.files.length===0)return!0;for(var Nt=0;Nt<this.files.length;Nt++)ze.push({file:this.files[Nt],inputElem:this,instanceConfig:Q.extend({},he)})}),qe(),this;function qe(){if(ze.length===0)et(pe.complete)&&pe.complete();else{var ct,Nt,Zt,$t,ut=ze[0];if(et(pe.before)){var Mt=pe.before(ut.file,ut.inputElem);if(typeof Mt=="object"){if(Mt.action==="abort")return ct="AbortError",Nt=ut.file,Zt=ut.inputElem,$t=Mt.reason,void(et(pe.error)&&pe.error({name:ct},Nt,Zt,$t));if(Mt.action==="skip")return void Ue();typeof Mt.config=="object"&&(ut.instanceConfig=Q.extend(ut.instanceConfig,Mt.config))}else if(Mt==="skip")return void Ue()}var Re=ut.instanceConfig.complete;ut.instanceConfig.complete=function(xt){et(Re)&&Re(xt,ut.file,ut.inputElem),Ue()},Pe.parse(ut.file,ut.instanceConfig)}}function Ue(){ze.splice(0,1),qe()}}),P&&($.onmessage=function(pe){pe=pe.data,Pe.WORKER_ID===void 0&&pe&&(Pe.WORKER_ID=pe.workerId),typeof pe.input=="string"?$.postMessage({workerId:Pe.WORKER_ID,results:Pe.parse(pe.input,pe.config),finished:!0}):($.File&&pe.input instanceof File||pe.input instanceof Object)&&(pe=Pe.parse(pe.input,pe.config))&&$.postMessage({workerId:Pe.WORKER_ID,results:pe,finished:!0})}),(Ne.prototype=Object.create(Oe.prototype)).constructor=Ne,(Ke.prototype=Object.create(Oe.prototype)).constructor=Ke,(ot.prototype=Object.create(ot.prototype)).constructor=ot,(zt.prototype=Object.create(Oe.prototype)).constructor=zt,Pe})})(yc)),yc.exports}var cg=lg();const np=Fd(cg);async function sp(F,C,D){return new Promise(($,Q)=>{np.parse(F,{download:!0,header:!0,skipEmptyLines:!0,complete:ue=>{try{const P=ue.data,c=ue.meta.fields||[],le=new Map;P.forEach(Pe=>{const Oe=Pe[C],Ne=Pe[D];if(Oe!=null){const Ke=parseFloat(Ne),ot=isNaN(Ke)?Ne:Ke;le.set(String(Oe),ot)}}),$({headers:c,rows:P,joinMap:le})}catch(P){Q(P)}},error:ue=>{Q(ue)}})})}async function ap(F,C,D){return new Promise(($,Q)=>{np.parse(F,{header:!0,skipEmptyLines:!0,complete:ue=>{try{const P=ue.data,c=ue.meta.fields||[],le=new Map;P.forEach(Pe=>{const Oe=Pe[C],Ne=Pe[D];if(Oe!=null){const Ke=parseFloat(Ne),ot=isNaN(Ke)?Ne:Ke;le.set(String(Oe),ot)}}),$({headers:c,rows:P,joinMap:le})}catch(P){Q(P)}},error:ue=>{Q(ue)}})})}function op(F,C){if(F.length===0)return[];if(C>=F.length)return[...new Set(F)].sort((le,Pe)=>le-Pe);const D=[...F].sort((le,Pe)=>le-Pe);let $=D.length;const Q=Array($+1).fill(0).map(()=>Array(C+1).fill(0)),ue=Array($+1).fill(0).map(()=>Array(C+1).fill(0));for(let le=1;le<=C;le++){Q[1][le]=1,ue[1][le]=0;for(let Pe=2;Pe<=$;Pe++)ue[Pe][le]=1/0}for(let le=2;le<=$;le++){let Pe=0,Oe=0,Ne=0;for(let Ke=1;Ke<=le;Ke++){const ot=le-Ke+1,zt=D[ot-1];Oe+=zt*zt,Pe+=zt,Ne++;const Qe=Oe-Pe*Pe/Ne,ge=ot-1;if(ge!==0)for(let ti=2;ti<=C;ti++)ue[le][ti]>=Qe+ue[ge][ti-1]&&(Q[le][ti]=ot,ue[le][ti]=Qe+ue[ge][ti-1])}Q[le][1]=1,ue[le][1]=ue[le-1][1]+(le-1)*(D[le-1]-D[le-2])**2}const P=[];let c=C;for(;c>=2;){const le=Q[$][c]-1;P.push(D[le]),$=Q[$][c]-1,c--}return P.push(D[0]),P.reverse(),P.push(D[D.length-1]),[...new Set(P)].sort((le,Pe)=>le-Pe)}function lp(F,C,D){const $=[],Q=c=>{const le=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(c);return le?{r:parseInt(le[1],16),g:parseInt(le[2],16),b:parseInt(le[3],16)}:{r:0,g:0,b:0}},ue=Q(F),P=Q(C);for(let c=0;c<D;c++){const le=c/(D-1),Pe=Math.round(ue.r+le*(P.r-ue.r)),Oe=Math.round(ue.g+le*(P.g-ue.g)),Ne=Math.round(ue.b+le*(P.b-ue.b));$.push(`rgb(${Pe}, ${Oe}, ${Ne})`)}return $}function ls(F,C){this.x=F,this.y=C}ls.prototype={clone(){return new ls(this.x,this.y)},add(F){return this.clone()._add(F)},sub(F){return this.clone()._sub(F)},multByPoint(F){return this.clone()._multByPoint(F)},divByPoint(F){return this.clone()._divByPoint(F)},mult(F){return this.clone()._mult(F)},div(F){return this.clone()._div(F)},rotate(F){return this.clone()._rotate(F)},rotateAround(F,C){return this.clone()._rotateAround(F,C)},matMult(F){return this.clone()._matMult(F)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(F){return this.x===F.x&&this.y===F.y},dist(F){return Math.sqrt(this.distSqr(F))},distSqr(F){const C=F.x-this.x,D=F.y-this.y;return C*C+D*D},angle(){return Math.atan2(this.y,this.x)},angleTo(F){return Math.atan2(this.y-F.y,this.x-F.x)},angleWith(F){return this.angleWithSep(F.x,F.y)},angleWithSep(F,C){return Math.atan2(this.x*C-this.y*F,this.x*F+this.y*C)},_matMult(F){const C=F[0]*this.x+F[1]*this.y,D=F[2]*this.x+F[3]*this.y;return this.x=C,this.y=D,this},_add(F){return this.x+=F.x,this.y+=F.y,this},_sub(F){return this.x-=F.x,this.y-=F.y,this},_mult(F){return this.x*=F,this.y*=F,this},_div(F){return this.x/=F,this.y/=F,this},_multByPoint(F){return this.x*=F.x,this.y*=F.y,this},_divByPoint(F){return this.x/=F.x,this.y/=F.y,this},_unit(){return this._div(this.mag()),this},_perp(){const F=this.y;return this.y=this.x,this.x=-F,this},_rotate(F){const C=Math.cos(F),D=Math.sin(F),$=C*this.x-D*this.y,Q=D*this.x+C*this.y;return this.x=$,this.y=Q,this},_rotateAround(F,C){const D=Math.cos(F),$=Math.sin(F),Q=C.x+D*(this.x-C.x)-$*(this.y-C.y),ue=C.y+$*(this.x-C.x)+D*(this.y-C.y);return this.x=Q,this.y=ue,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:ls},ls.convert=function(F){if(F instanceof ls)return F;if(Array.isArray(F))return new ls(+F[0],+F[1]);if(F.x!==void 0&&F.y!==void 0)return new ls(+F.x,+F.y);throw new Error("Expected [x, y] or {x, y} point format")};class cp{constructor(C,D,$,Q,ue){this.properties={},this.extent=$,this.type=0,this.id=void 0,this._pbf=C,this._geometry=-1,this._keys=Q,this._values=ue,C.readFields(ug,this,D)}loadGeometry(){const C=this._pbf;C.pos=this._geometry;const D=C.readVarint()+C.pos,$=[];let Q,ue=1,P=0,c=0,le=0;for(;C.pos<D;){if(P<=0){const Pe=C.readVarint();ue=Pe&7,P=Pe>>3}if(P--,ue===1||ue===2)c+=C.readSVarint(),le+=C.readSVarint(),ue===1&&(Q&&$.push(Q),Q=[]),Q&&Q.push(new ls(c,le));else if(ue===7)Q&&Q.push(Q[0].clone());else throw new Error(`unknown command ${ue}`)}return Q&&$.push(Q),$}bbox(){const C=this._pbf;C.pos=this._geometry;const D=C.readVarint()+C.pos;let $=1,Q=0,ue=0,P=0,c=1/0,le=-1/0,Pe=1/0,Oe=-1/0;for(;C.pos<D;){if(Q<=0){const Ne=C.readVarint();$=Ne&7,Q=Ne>>3}if(Q--,$===1||$===2)ue+=C.readSVarint(),P+=C.readSVarint(),ue<c&&(c=ue),ue>le&&(le=ue),P<Pe&&(Pe=P),P>Oe&&(Oe=P);else if($!==7)throw new Error(`unknown command ${$}`)}return[c,Pe,le,Oe]}toGeoJSON(C,D,$){const Q=this.extent*Math.pow(2,$),ue=this.extent*C,P=this.extent*D,c=this.loadGeometry();function le(Ke){return[(Ke.x+ue)*360/Q-180,360/Math.PI*Math.atan(Math.exp((1-(Ke.y+P)*2/Q)*Math.PI))-90]}function Pe(Ke){return Ke.map(le)}let Oe;if(this.type===1){const Ke=[];for(const zt of c)Ke.push(zt[0]);const ot=Pe(Ke);Oe=Ke.length===1?{type:"Point",coordinates:ot[0]}:{type:"MultiPoint",coordinates:ot}}else if(this.type===2){const Ke=c.map(Pe);Oe=Ke.length===1?{type:"LineString",coordinates:Ke[0]}:{type:"MultiLineString",coordinates:Ke}}else if(this.type===3){const Ke=dg(c),ot=[];for(const zt of Ke)ot.push(zt.map(Pe));Oe=ot.length===1?{type:"Polygon",coordinates:ot[0]}:{type:"MultiPolygon",coordinates:ot}}else throw new Error("unknown feature type");const Ne={type:"Feature",geometry:Oe,properties:this.properties};return this.id!=null&&(Ne.id=this.id),Ne}}cp.types=["Unknown","Point","LineString","Polygon"];function ug(F,C,D){F===1?C.id=D.readVarint():F===2?hg(D,C):F===3?C.type=D.readVarint():F===4&&(C._geometry=D.pos)}function hg(F,C){const D=F.readVarint()+F.pos;for(;F.pos<D;){const $=C._keys[F.readVarint()],Q=C._values[F.readVarint()];C.properties[$]=Q}}function dg(F){const C=F.length;if(C<=1)return[F];const D=[];let $,Q;for(let ue=0;ue<C;ue++){const P=pg(F[ue]);P!==0&&(Q===void 0&&(Q=P<0),Q===P<0?($&&D.push($),$=[F[ue]]):$&&$.push(F[ue]))}return $&&D.push($),D}function pg(F){let C=0;for(let D=0,$=F.length,Q=$-1,ue,P;D<$;Q=D++)ue=F[D],P=F[Q],C+=(P.x-ue.x)*(ue.y+P.y);return C}class fg{constructor(C,D){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=C,this._keys=[],this._values=[],this._features=[],C.readFields(mg,this,D),this.length=this._features.length}feature(C){if(C<0||C>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[C];const D=this._pbf.readVarint()+this._pbf.pos;return new cp(this._pbf,D,this.extent,this._keys,this._values)}}function mg(F,C,D){F===15?C.version=D.readVarint():F===1?C.name=D.readString():F===5?C.extent=D.readVarint():F===2?C._features.push(D.pos):F===3?C._keys.push(D.readString()):F===4&&C._values.push(gg(D))}function gg(F){let C=null;const D=F.readVarint()+F.pos;for(;F.pos<D;){const $=F.readVarint()>>3;C=$===1?F.readString():$===2?F.readFloat():$===3?F.readDouble():$===4?F.readVarint64():$===5?F.readVarint():$===6?F.readSVarint():$===7?F.readBoolean():null}if(C==null)throw new Error("unknown feature value");return C}class _g{constructor(C,D){this.layers=C.readFields(yg,{},D)}}function yg(F,C,D){if(F===3){const $=new fg(D,D.readVarint()+D.pos);$.length&&(C[$.name]=$)}}const ah=65536*65536,up=1/ah,xg=12,hp=typeof TextDecoder>"u"?null:new TextDecoder("utf-8"),oh=0,xc=1,Qo=2,vc=5;class vg{constructor(C=new Uint8Array(16)){this.buf=ArrayBuffer.isView(C)?C:new Uint8Array(C),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(C,D,$=this.length){for(;this.pos<$;){const Q=this.readVarint(),ue=Q>>3,P=this.pos;this.type=Q&7,C(ue,D,this),this.pos===P&&this.skip(Q)}return D}readMessage(C,D){return this.readFields(C,D,this.readVarint()+this.pos)}readFixed32(){const C=this.dataView.getUint32(this.pos,!0);return this.pos+=4,C}readSFixed32(){const C=this.dataView.getInt32(this.pos,!0);return this.pos+=4,C}readFixed64(){const C=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*ah;return this.pos+=8,C}readSFixed64(){const C=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*ah;return this.pos+=8,C}readFloat(){const C=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,C}readDouble(){const C=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,C}readVarint(C){const D=this.buf;let $,Q;return Q=D[this.pos++],$=Q&127,Q<128||(Q=D[this.pos++],$|=(Q&127)<<7,Q<128)||(Q=D[this.pos++],$|=(Q&127)<<14,Q<128)||(Q=D[this.pos++],$|=(Q&127)<<21,Q<128)?$:(Q=D[this.pos],$|=(Q&15)<<28,bg($,C,this))}readVarint64(){return this.readVarint(!0)}readSVarint(){const C=this.readVarint();return C%2===1?(C+1)/-2:C/2}readBoolean(){return!!this.readVarint()}readString(){const C=this.readVarint()+this.pos,D=this.pos;return this.pos=C,C-D>=xg&&hp?hp.decode(this.buf.subarray(D,C)):Rg(this.buf,D,C)}readBytes(){const C=this.readVarint()+this.pos,D=this.buf.subarray(this.pos,C);return this.pos=C,D}readPackedVarint(C=[],D){const $=this.readPackedEnd();for(;this.pos<$;)C.push(this.readVarint(D));return C}readPackedSVarint(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readSVarint());return C}readPackedBoolean(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readBoolean());return C}readPackedFloat(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readFloat());return C}readPackedDouble(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readDouble());return C}readPackedFixed32(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readFixed32());return C}readPackedSFixed32(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readSFixed32());return C}readPackedFixed64(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readFixed64());return C}readPackedSFixed64(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readSFixed64());return C}readPackedEnd(){return this.type===Qo?this.readVarint()+this.pos:this.pos+1}skip(C){const D=C&7;if(D===oh)for(;this.buf[this.pos++]>127;);else if(D===Qo)this.pos=this.readVarint()+this.pos;else if(D===vc)this.pos+=4;else if(D===xc)this.pos+=8;else throw new Error(`Unimplemented type: ${D}`)}writeTag(C,D){this.writeVarint(C<<3|D)}realloc(C){let D=this.length||16;for(;D<this.pos+C;)D*=2;if(D!==this.length){const $=new Uint8Array(D);$.set(this.buf),this.buf=$,this.dataView=new DataView($.buffer),this.length=D}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(C){this.realloc(4),this.dataView.setInt32(this.pos,C,!0),this.pos+=4}writeSFixed32(C){this.realloc(4),this.dataView.setInt32(this.pos,C,!0),this.pos+=4}writeFixed64(C){this.realloc(8),this.dataView.setInt32(this.pos,C&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(C*up),!0),this.pos+=8}writeSFixed64(C){this.realloc(8),this.dataView.setInt32(this.pos,C&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(C*up),!0),this.pos+=8}writeVarint(C){if(C=+C||0,C>268435455||C<0){wg(C,this);return}this.realloc(4),this.buf[this.pos++]=C&127|(C>127?128:0),!(C<=127)&&(this.buf[this.pos++]=(C>>>=7)&127|(C>127?128:0),!(C<=127)&&(this.buf[this.pos++]=(C>>>=7)&127|(C>127?128:0),!(C<=127)&&(this.buf[this.pos++]=C>>>7&127)))}writeSVarint(C){this.writeVarint(C<0?-C*2-1:C*2)}writeBoolean(C){this.writeVarint(+C)}writeString(C){C=String(C),this.realloc(C.length*4),this.pos++;const D=this.pos;this.pos=Fg(this.buf,C,this.pos);const $=this.pos-D;$>=128&&dp(D,$,this),this.pos=D-1,this.writeVarint($),this.pos+=$}writeFloat(C){this.realloc(4),this.dataView.setFloat32(this.pos,C,!0),this.pos+=4}writeDouble(C){this.realloc(8),this.dataView.setFloat64(this.pos,C,!0),this.pos+=8}writeBytes(C){const D=C.length;this.writeVarint(D),this.realloc(D);for(let $=0;$<D;$++)this.buf[this.pos++]=C[$]}writeRawMessage(C,D){this.pos++;const $=this.pos;C(D,this);const Q=this.pos-$;Q>=128&&dp($,Q,this),this.pos=$-1,this.writeVarint(Q),this.pos+=Q}writeMessage(C,D,$){this.writeTag(C,Qo),this.writeRawMessage(D,$)}writePackedVarint(C,D){D.length&&this.writeMessage(C,Pg,D)}writePackedSVarint(C,D){D.length&&this.writeMessage(C,Mg,D)}writePackedBoolean(C,D){D.length&&this.writeMessage(C,Cg,D)}writePackedFloat(C,D){D.length&&this.writeMessage(C,Ig,D)}writePackedDouble(C,D){D.length&&this.writeMessage(C,Eg,D)}writePackedFixed32(C,D){D.length&&this.writeMessage(C,Ag,D)}writePackedSFixed32(C,D){D.length&&this.writeMessage(C,Dg,D)}writePackedFixed64(C,D){D.length&&this.writeMessage(C,zg,D)}writePackedSFixed64(C,D){D.length&&this.writeMessage(C,kg,D)}writeBytesField(C,D){this.writeTag(C,Qo),this.writeBytes(D)}writeFixed32Field(C,D){this.writeTag(C,vc),this.writeFixed32(D)}writeSFixed32Field(C,D){this.writeTag(C,vc),this.writeSFixed32(D)}writeFixed64Field(C,D){this.writeTag(C,xc),this.writeFixed64(D)}writeSFixed64Field(C,D){this.writeTag(C,xc),this.writeSFixed64(D)}writeVarintField(C,D){this.writeTag(C,oh),this.writeVarint(D)}writeSVarintField(C,D){this.writeTag(C,oh),this.writeSVarint(D)}writeStringField(C,D){this.writeTag(C,Qo),this.writeString(D)}writeFloatField(C,D){this.writeTag(C,vc),this.writeFloat(D)}writeDoubleField(C,D){this.writeTag(C,xc),this.writeDouble(D)}writeBooleanField(C,D){this.writeVarintField(C,+D)}}function bg(F,C,D){const $=D.buf;let Q,ue;if(ue=$[D.pos++],Q=(ue&112)>>4,ue<128||(ue=$[D.pos++],Q|=(ue&127)<<3,ue<128)||(ue=$[D.pos++],Q|=(ue&127)<<10,ue<128)||(ue=$[D.pos++],Q|=(ue&127)<<17,ue<128)||(ue=$[D.pos++],Q|=(ue&127)<<24,ue<128)||(ue=$[D.pos++],Q|=(ue&1)<<31,ue<128))return Na(F,Q,C);throw new Error("Expected varint not more than 10 bytes")}function Na(F,C,D){return D?C*4294967296+(F>>>0):(C>>>0)*4294967296+(F>>>0)}function wg(F,C){let D,$;if(F>=0?(D=F%4294967296|0,$=F/4294967296|0):(D=~(-F%4294967296),$=~(-F/4294967296),D^4294967295?D=D+1|0:(D=0,$=$+1|0)),F>=18446744073709552e3||F<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");C.realloc(10),Tg(D,$,C),Sg($,C)}function Tg(F,C,D){D.buf[D.pos++]=F&127|128,F>>>=7,D.buf[D.pos++]=F&127|128,F>>>=7,D.buf[D.pos++]=F&127|128,F>>>=7,D.buf[D.pos++]=F&127|128,F>>>=7,D.buf[D.pos]=F&127}function Sg(F,C){const D=(F&7)<<4;C.buf[C.pos++]|=D|((F>>>=3)?128:0),F&&(C.buf[C.pos++]=F&127|((F>>>=7)?128:0),F&&(C.buf[C.pos++]=F&127|((F>>>=7)?128:0),F&&(C.buf[C.pos++]=F&127|((F>>>=7)?128:0),F&&(C.buf[C.pos++]=F&127|((F>>>=7)?128:0),F&&(C.buf[C.pos++]=F&127)))))}function dp(F,C,D){const $=C<=16383?1:C<=2097151?2:C<=268435455?3:Math.floor(Math.log(C)/(Math.LN2*7));D.realloc($);for(let Q=D.pos-1;Q>=F;Q--)D.buf[Q+$]=D.buf[Q]}function Pg(F,C){for(let D=0;D<F.length;D++)C.writeVarint(F[D])}function Mg(F,C){for(let D=0;D<F.length;D++)C.writeSVarint(F[D])}function Ig(F,C){for(let D=0;D<F.length;D++)C.writeFloat(F[D])}function Eg(F,C){for(let D=0;D<F.length;D++)C.writeDouble(F[D])}function Cg(F,C){for(let D=0;D<F.length;D++)C.writeBoolean(F[D])}function Ag(F,C){for(let D=0;D<F.length;D++)C.writeFixed32(F[D])}function Dg(F,C){for(let D=0;D<F.length;D++)C.writeSFixed32(F[D])}function zg(F,C){for(let D=0;D<F.length;D++)C.writeFixed64(F[D])}function kg(F,C){for(let D=0;D<F.length;D++)C.writeSFixed64(F[D])}function Rg(F,C,D){let $="",Q=C;for(;Q<D;){const ue=F[Q];let P=null,c=ue>239?4:ue>223?3:ue>191?2:1;if(Q+c>D)break;let le,Pe,Oe;c===1?ue<128&&(P=ue):c===2?(le=F[Q+1],(le&192)===128&&(P=(ue&31)<<6|le&63,P<=127&&(P=null))):c===3?(le=F[Q+1],Pe=F[Q+2],(le&192)===128&&(Pe&192)===128&&(P=(ue&15)<<12|(le&63)<<6|Pe&63,(P<=2047||P>=55296&&P<=57343)&&(P=null))):c===4&&(le=F[Q+1],Pe=F[Q+2],Oe=F[Q+3],(le&192)===128&&(Pe&192)===128&&(Oe&192)===128&&(P=(ue&15)<<18|(le&63)<<12|(Pe&63)<<6|Oe&63,(P<=65535||P>=1114112)&&(P=null))),P===null?(P=65533,c=1):P>65535&&(P-=65536,$+=String.fromCharCode(P>>>10&1023|55296),P=56320|P&1023),$+=String.fromCharCode(P),Q+=c}return $}function Fg(F,C,D){for(let $=0,Q,ue;$<C.length;$++){if(Q=C.charCodeAt($),Q>55295&&Q<57344)if(ue)if(Q<56320){F[D++]=239,F[D++]=191,F[D++]=189,ue=Q;continue}else Q=ue-55296<<10|Q-56320|65536,ue=null;else{Q>56319||$+1===C.length?(F[D++]=239,F[D++]=191,F[D++]=189):ue=Q;continue}else ue&&(F[D++]=239,F[D++]=191,F[D++]=189,ue=null);Q<128?F[D++]=Q:(Q<2048?F[D++]=Q>>6|192:(Q<65536?F[D++]=Q>>12|224:(F[D++]=Q>>18|240,F[D++]=Q>>12&63|128),F[D++]=Q>>6&63|128),F[D++]=Q&63|128)}return D}async function Lg(F,C,D,$="bbox",Q){try{const ue=new sh(F),P=await ue.getHeader(),c=Math.min(Math.floor((P.minZoom+P.maxZoom)/2),8),le=Math.pow(2,c);for(let Pe=0;Pe<le;Pe++)for(let Oe=0;Oe<le;Oe++)try{const Ne=await ue.getZxy(c,Pe,Oe);if(!Ne||!Ne.data)continue;const ot=new _g(new vg(Ne.data)).layers[C];if(!ot)continue;for(let zt=0;zt<ot.length;zt++){const Qe=ot.feature(zt),ge=Qe.properties,ti=String(Q?ge[Q]:Qe.id);if(ti===String(D)){let Rt=null;if(ge[$]){const ht=ge[$];if(typeof ht=="string")try{const ni=JSON.parse(ht);Array.isArray(ni)&&ni.length===4&&(Rt=ni)}catch{const ni=ht.split(",").map(pi=>parseFloat(pi.trim()));ni.length===4&&ni.every(pi=>!isNaN(pi))&&(Rt=ni)}else Array.isArray(ht)&&ht.length===4&&(Rt=ht)}if(!Rt){const ht=Qe.loadGeometry();let ni=1/0,pi=1/0,Mi=-1/0,et=-1/0;ht.forEach(Zt=>{Zt.forEach($t=>{ni=Math.min(ni,$t.x),pi=Math.min(pi,$t.y),Mi=Math.max(Mi,$t.x),et=Math.max(et,$t.y)})});const pe=4096,he=(Pe+ni/pe)/le*360-180,ze=(Pe+Mi/pe)/le*360-180,qe=Math.PI-2*Math.PI*(Oe+pi/pe)/le,Ue=Math.PI-2*Math.PI*(Oe+et/pe)/le,ct=180/Math.PI*Math.atan(.5*(Math.exp(qe)-Math.exp(-qe))),Nt=180/Math.PI*Math.atan(.5*(Math.exp(Ue)-Math.exp(-Ue)));Rt=[Math.min(he,ze),Math.min(ct,Nt),Math.max(he,ze),Math.max(ct,Nt)]}return{id:ti,bbox:Rt,properties:ge}}}}catch{continue}return console.warn(`Feature con id "${D}" no encontrada en PMTiles`),null}catch(ue){return console.error("Error buscando feature en PMTiles:",ue),null}}const el="pmtiles-source",lh="pmtiles-fill",js="municipios-source",ch="municipios-fill",Bg="https://www.datosgeoespaciales.atdt.gob.mx/datalake/pmtiles/componente/entidad.pmtiles",Og="entidad",Vg="cvegeo",pp="https://www.datosgeoespaciales.atdt.gob.mx/datalake/pmtiles/transformador/municipio.pmtiles",ja="municipio",uh="CVEGEO",Ng=({pmtilesUrl:F=Bg,sourceLayer:C=Og,joinGeomKey:D=Vg,csvUrl:$,csvFile:Q,joinCsvKey:ue,field:P="valor",mode:c="boolean",width:le="100%",height:Pe=520,initialView:Oe,fitToIds:Ne,bboxField:Ke="bbox",jenksK:ot=5,showMunicipios:zt=!1,municipiosCsvUrl:Qe,municipiosCsvFile:ge,municipiosField:ti="valor"})=>{const Rt=Ln.useRef(null),ht=Ln.useRef(null),[ni,pi]=Ln.useState(null);Ln.useEffect(()=>{if(!Rt.current)return;if(!$&&!Q){pi("Debe proporcionar csvUrl o csvFile"),console.error("MapaPMTiles: Debe proporcionar csvUrl o csvFile");return}let et=null;return(async()=>{try{const he=new Km;Od.addProtocol("pmtiles",he.tile);const ze=(Oe==null?void 0:Oe.center)||[-102,23],qe=(Oe==null?void 0:Oe.zoom)||4;et=new Bd.Map({container:Rt.current,style:{version:8,sources:{},layers:[]},center:ze,zoom:qe,boxZoom:!1,doubleClickZoom:!1,dragRotate:!1,keyboard:!1,scrollZoom:!1,touchPitch:!1,touchZoomRotate:!0,dragPan:!1,maxBounds:void 0,attributionControl:!1}),ht.current=et,et.on("load",async()=>{if(et)try{et.addSource(el,{type:"vector",url:`pmtiles://${F}`,promoteId:D});const Ue=ue||D,ct=Q?await ap(Q,Ue,P):await sp($,Ue,P);ct.joinMap.forEach((Mt,Re)=>{try{et.setFeatureState({source:el,sourceLayer:C,id:Re},{value:Mt})}catch(xt){console.warn(`Error setting feature state for key ${Re}:`,xt)}});let Nt;if(c==="boolean")Nt=["case",["==",["feature-state","value"],1],"#66827f","#f3f3f3"];else{const Mt=Array.from(ct.joinMap.values()).filter(Re=>typeof Re=="number").map(Re=>Re);if(Mt.length===0)console.warn("No hay valores numéricos para clasificación Jenks"),Nt=["case",["!=",["feature-state","value"],null],"#66827f","#f3f3f3"];else{const Re=op(Mt,ot),xt=Re.length-1,rt=lp("#f3f3f3","#66827f",xt),nt=["step",["feature-state","value"],rt[0]];for(let We=1;We<xt;We++)nt.push(Re[We]),nt.push(rt[We]);Nt=nt}}const Zt=Ne?Array.isArray(Ne)?Ne:[Ne]:[];let $t;Zt.length>0&&($t=["in",["get",D],["literal",Zt]]),zt?et.addLayer({id:lh,type:"fill",source:el,"source-layer":C,paint:{"fill-color":Nt,"fill-opacity":["case",["!=",["feature-state","value"],null],.75,0]},filter:$t}):et.addLayer({id:lh,type:"fill",source:el,"source-layer":C,paint:{"fill-color":Nt,"fill-opacity":.75},filter:$t}),et.addLayer({id:`${lh}-outline`,type:"line",source:el,"source-layer":C,paint:{"line-color":"#2c3e50","line-width":zt?1.5:.5},filter:$t});let ut=null;if(Zt.length>0){const Re=(await Promise.all(Zt.map(xt=>Lg(F,C,xt,Ke,D)))).filter(xt=>xt!==null&&xt.bbox);if(Re.length>0){let xt=1/0,rt=1/0,nt=-1/0,We=-1/0;Re.forEach(Et=>{Et&&Et.bbox&&(xt=Math.min(xt,Et.bbox[0]),rt=Math.min(rt,Et.bbox[1]),nt=Math.max(nt,Et.bbox[2]),We=Math.max(We,Et.bbox[3]))}),ut=[[xt,rt],[nt,We]],et.fitBounds(ut,{padding:50,duration:0})}else console.warn(`No se pudieron encontrar bboxes para los IDs: ${Zt.join(", ")}`)}if(zt&&Zt.length>0){console.log("[GEO-UI DEBUG] Iniciando capa de municipios"),console.log("[GEO-UI DEBUG] fitIdsArray:",Zt),console.log("[GEO-UI DEBUG] MUNICIPIOS_URL:",pp),et.addSource(js,{type:"vector",url:`pmtiles://${pp}`,promoteId:uh});const Mt=["in",["slice",["to-string",["get","CVEGEO"]],0,2],["literal",Zt]];if(console.log("[GEO-UI DEBUG] Filtro de municipios:",JSON.stringify(Mt,null,2)),et.addLayer({id:"debug-municipios-temp",type:"line",source:js,"source-layer":ja,paint:{"line-color":"transparent","line-width":0}}),console.log("[GEO-UI DEBUG] Esperando a que el mapa cargue tiles..."),et.once("idle",()=>{console.log("[GEO-UI DEBUG] Mapa idle - esperando 500ms adicionales..."),setTimeout(()=>{var xt,rt,nt,We,Et,ft;console.log("[GEO-UI DEBUG] Consultando features de municipios...");const Re=et.querySourceFeatures(js,{sourceLayer:ja});if(console.log("[GEO-UI DEBUG] Total features sin filtro:",Re.length),Re.length>0){console.log("[GEO-UI DEBUG] Primeras 3 features de municipios:");for(let Wt=0;Wt<Math.min(3,Re.length);Wt++){const at=Re[Wt];console.log(` Feature ${Wt+1}:`,{id:at.id,properties:at.properties,CVEGEO:(xt=at.properties)==null?void 0:xt.CVEGEO,CVE_ENT:(rt=at.properties)==null?void 0:rt.CVE_ENT,cvegeo:(nt=at.properties)==null?void 0:nt.cvegeo,cve_ent:(We=at.properties)==null?void 0:We.cve_ent})}const It=Re.filter(Wt=>{var Tt;return String(((Tt=Wt.properties)==null?void 0:Tt.CVEGEO)||"").startsWith("09")});console.log('[GEO-UI DEBUG] Municipios que empiezan con "09":',It.length),It.length>0&&console.log("[GEO-UI DEBUG] Ejemplo de municipio 09:",{id:It[0].id,CVEGEO:(Et=It[0].properties)==null?void 0:Et.CVEGEO,CVE_ENT:(ft=It[0].properties)==null?void 0:ft.CVE_ENT})}else console.warn("[GEO-UI DEBUG] No se encontraron features de municipios!");et.getLayer("debug-municipios-temp")&&et.removeLayer("debug-municipios-temp")},500)}),Qe||ge){const Re=ge?await ap(ge,uh,ti):await sp(Qe,uh,ti);Re.joinMap.forEach((rt,nt)=>{try{et.setFeatureState({source:js,sourceLayer:ja,id:nt},{value:rt})}catch(We){console.warn(`Error setting municipio feature state for key ${nt}:`,We)}});let xt;if(c==="boolean")xt=["case",["==",["feature-state","value"],1],"#66827f","#f3f3f3"];else{const rt=Array.from(Re.joinMap.values()).filter(nt=>typeof nt=="number").map(nt=>nt);if(rt.length>0){const nt=op(rt,ot),We=nt.length-1,Et=lp("#f3f3f3","#66827f",We),ft=["step",["feature-state","value"],Et[0]];for(let It=1;It<We;It++)ft.push(nt[It]),ft.push(Et[It]);xt=ft}else xt=["case",["!=",["feature-state","value"],null],"#66827f","#f3f3f3"]}et.addLayer({id:ch,type:"fill",source:js,"source-layer":ja,paint:{"fill-color":xt,"fill-opacity":.75},filter:Mt})}else et.addLayer({id:ch,type:"line",source:js,"source-layer":ja,paint:{"line-color":"#2c3e50","line-width":.5},filter:Mt});et.addLayer({id:`${ch}-outline`,type:"line",source:js,"source-layer":ja,paint:{"line-color":"#2c3e50","line-width":.5},filter:Mt})}}catch(Ue){console.error("Error cargando datos en el mapa:",Ue),pi(`Error cargando datos: ${Ue instanceof Error?Ue.message:String(Ue)}`)}}),et.on("error",Ue=>{var ct;console.error("Error del mapa:",Ue),pi(`Error del mapa: ${((ct=Ue.error)==null?void 0:ct.message)||"Error desconocido"}`)})}catch(he){console.error("Error inicializando mapa:",he),pi(`Error inicializando: ${he instanceof Error?he.message:String(he)}`)}})(),()=>{ht.current&&(ht.current.remove(),ht.current=null),Od.removeProtocol("pmtiles")}},[F,C,D,$,Q,ue,P,c,ot,Ne,Ke,Oe,zt,Qe,ge,ti]);const Mi={width:typeof le=="number"?`${le}px`:le,height:typeof Pe=="number"?`${Pe}px`:Pe,position:"relative"};return Ar.jsxs("div",{style:Mi,children:[Ar.jsx("div",{ref:Rt,style:{width:"100%",height:"100%"}}),ni&&Ar.jsx("div",{style:{position:"absolute",top:10,left:10,right:10,background:"rgba(231, 76, 60, 0.9)",color:"white",padding:"10px",borderRadius:"4px",fontSize:"12px",zIndex:1e3},children:ni})]})};Br.MapaPMTiles=Ng,Object.defineProperty(Br,Symbol.toStringTag,{value:"Module"})}));
|
|
823
823
|
//# sourceMappingURL=geo-ui.umd.cjs.map
|