You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
hy-screen-2.0/docs/assets/index-0060e718-178404366447...

2 lines
79 KiB

var or=Object.defineProperty,sr=Object.defineProperties;var lr=Object.getOwnPropertyDescriptors;var wn=Object.getOwnPropertySymbols;var ar=Object.prototype.hasOwnProperty,ur=Object.prototype.propertyIsEnumerable;var Sn=(m,n,r)=>n in m?or(m,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):m[n]=r,lt=(m,n)=>{for(var r in n||(n={}))ar.call(n,r)&&Sn(m,r,n[r]);if(wn)for(var r of wn(n))ur.call(n,r)&&Sn(m,r,n[r]);return m},Lt=(m,n)=>sr(m,lr(n));var ft=(m,n,r)=>new Promise((u,h)=>{var c=y=>{try{d(r.next(y))}catch(w){h(w)}},p=y=>{try{d(r.throw(y))}catch(w){h(w)}},d=y=>y.done?u(y.value):Promise.resolve(y.value).then(c,p);d((r=r.apply(m,n)).next())});import{H as G,n as xe,h as bn}from"./townshipBoundaries-1b068bef-1784043664472.js";import{_ as cr,g as hr,q as fr,h as mr,w as Kt,A as _n,o as pr,c as dr,a as gr,d as Nn,K as yr}from"./index-1784043664472.js";class gt{constructor(n,r){this.next=null,this.key=n,this.data=r,this.left=null,this.right=null}}function xr(m,n){return m>n?1:m<n?-1:0}function mt(m,n,r){const u=new gt(null,null);let h=u,c=u;for(;;){const p=r(m,n.key);if(p<0){if(n.left===null)break;if(r(m,n.left.key)<0){const d=n.left;if(n.left=d.right,d.right=n,n=d,n.left===null)break}c.left=n,c=n,n=n.left}else if(p>0){if(n.right===null)break;if(r(m,n.right.key)>0){const d=n.right;if(n.right=d.left,d.left=n,n=d,n.right===null)break}h.right=n,h=n,n=n.right}else break}return h.right=n.left,c.left=n.right,n.left=u.right,n.right=u.left,n}function we(m,n,r,u){const h=new gt(m,n);if(r===null)return h.left=h.right=null,h;r=mt(m,r,u);const c=u(m,r.key);return c<0?(h.left=r.left,h.right=r,r.left=null):c>=0&&(h.right=r.right,h.left=r,r.right=null),h}function Cn(m,n,r){let u=null,h=null;if(n){n=mt(m,n,r);const c=r(n.key,m);c===0?(u=n.left,h=n.right):c<0?(h=n.right,n.right=null,u=n):(u=n.left,n.left=null,h=n)}return{left:u,right:h}}function wr(m,n,r){return n===null?m:(m===null||(n=mt(m.key,n,r),n.left=m),n)}function _e(m,n,r,u,h){if(m){u(`${n}${r?"└── ":"├── "}${h(m)}
`);const c=n+(r?" ":"│ ");m.left&&_e(m.left,c,!1,u,h),m.right&&_e(m.right,c,!0,u,h)}}class Pe{constructor(n=xr){this._root=null,this._size=0,this._comparator=n}insert(n,r){return this._size++,this._root=we(n,r,this._root,this._comparator)}add(n,r){const u=new gt(n,r);this._root===null&&(u.left=u.right=null,this._size++,this._root=u);const h=this._comparator,c=mt(n,this._root,h),p=h(n,c.key);return p===0?this._root=c:(p<0?(u.left=c.left,u.right=c,c.left=null):p>0&&(u.right=c.right,u.left=c,c.right=null),this._size++,this._root=u),this._root}remove(n){this._root=this._remove(n,this._root,this._comparator)}_remove(n,r,u){let h;return r===null?null:(r=mt(n,r,u),u(n,r.key)===0?(r.left===null?h=r.right:(h=mt(n,r.left,u),h.right=r.right),this._size--,h):r)}pop(){let n=this._root;if(n){for(;n.left;)n=n.left;return this._root=mt(n.key,this._root,this._comparator),this._root=this._remove(n.key,this._root,this._comparator),{key:n.key,data:n.data}}return null}findStatic(n){let r=this._root;const u=this._comparator;for(;r;){const h=u(n,r.key);if(h===0)return r;h<0?r=r.left:r=r.right}return null}find(n){return this._root&&(this._root=mt(n,this._root,this._comparator),this._comparator(n,this._root.key)!==0)?null:this._root}contains(n){let r=this._root;const u=this._comparator;for(;r;){const h=u(n,r.key);if(h===0)return!0;h<0?r=r.left:r=r.right}return!1}forEach(n,r){let u=this._root;const h=[];let c=!1;for(;!c;)u!==null?(h.push(u),u=u.left):h.length!==0?(u=h.pop(),n.call(r,u),u=u.right):c=!0;return this}range(n,r,u,h){const c=[],p=this._comparator;let d=this._root,y;for(;c.length!==0||d;)if(d)c.push(d),d=d.left;else{if(d=c.pop(),y=p(d.key,r),y>0)break;if(p(d.key,n)>=0&&u.call(h,d))return this;d=d.right}return this}keys(){const n=[];return this.forEach(({key:r})=>{n.push(r)}),n}values(){const n=[];return this.forEach(({data:r})=>{n.push(r)}),n}min(){return this._root?this.minNode(this._root).key:null}max(){return this._root?this.maxNode(this._root).key:null}minNode(n=this._root){if(n)for(;n.left;)n=n.left;return n}maxNode(n=this._root){if(n)for(;n.right;)n=n.right;return n}at(n){let r=this._root,u=!1,h=0;const c=[];for(;!u;)if(r)c.push(r),r=r.left;else if(c.length>0){if(r=c.pop(),h===n)return r;h++,r=r.right}else u=!0;return null}next(n){let r=this._root,u=null;if(n.right){for(u=n.right;u.left;)u=u.left;return u}const h=this._comparator;for(;r;){const c=h(n.key,r.key);if(c===0)break;c<0?(u=r,r=r.left):r=r.right}return u}prev(n){let r=this._root,u=null;if(n.left!==null){for(u=n.left;u.right;)u=u.right;return u}const h=this._comparator;for(;r;){const c=h(n.key,r.key);if(c===0)break;c<0?r=r.left:(u=r,r=r.right)}return u}clear(){return this._root=null,this._size=0,this}toList(){return br(this._root)}load(n,r=[],u=!1){let h=n.length;const c=this._comparator;if(u&&Ee(n,r,0,h-1,c),this._root===null)this._root=Ne(n,r,0,h),this._size=h;else{const p=_r(this.toList(),Sr(n,r),c);h=this._size+h,this._root=Ce({head:p},0,h)}return this}isEmpty(){return this._root===null}get size(){return this._size}get root(){return this._root}toString(n=r=>String(r.key)){const r=[];return _e(this._root,"",!0,u=>r.push(u),n),r.join("")}update(n,r,u){const h=this._comparator;let{left:c,right:p}=Cn(n,this._root,h);h(n,r)<0?p=we(r,u,p,h):c=we(r,u,c,h),this._root=wr(c,p,h)}split(n){return Cn(n,this._root,this._comparator)}*[Symbol.iterator](){let n=this._root;const r=[];let u=!1;for(;!u;)n!==null?(r.push(n),n=n.left):r.length!==0?(n=r.pop(),yield n,n=n.right):u=!0}}function Ne(m,n,r,u){const h=u-r;if(h>0){const c=r+Math.floor(h/2),p=m[c],d=n[c],y=new gt(p,d);return y.left=Ne(m,n,r,c),y.right=Ne(m,n,c+1,u),y}return null}function Sr(m,n){const r=new gt(null,null);let u=r;for(let h=0;h<m.length;h++)u=u.next=new gt(m[h],n[h]);return u.next=null,r.next}function br(m){let n=m;const r=[];let u=!1;const h=new gt(null,null);let c=h;for(;!u;)n?(r.push(n),n=n.left):r.length>0?(n=c=c.next=r.pop(),n=n.right):u=!0;return c.next=null,h.next}function Ce(m,n,r){const u=r-n;if(u>0){const h=n+Math.floor(u/2),c=Ce(m,n,h),p=m.head;return p.left=c,m.head=m.head.next,p.right=Ce(m,h+1,r),p}return null}function _r(m,n,r){const u=new gt(null,null);let h=u,c=m,p=n;for(;c!==null&&p!==null;)r(c.key,p.key)<0?(h.next=c,c=c.next):(h.next=p,p=p.next),h=h.next;return c!==null?h.next=c:p!==null&&(h.next=p),u.next}function Ee(m,n,r,u,h){if(r>=u)return;const c=m[r+u>>1];let p=r-1,d=u+1;for(;;){do p++;while(h(m[p],c)<0);do d--;while(h(m[d],c)>0);if(p>=d)break;let y=m[p];m[p]=m[d],m[d]=y,y=n[p],n[p]=n[d],n[d]=y}Ee(m,n,r,d,h),Ee(m,n,d+1,u,h)}const at=11102230246251565e-32,J=134217729,Nr=(3+8*at)*at;function Se(m,n,r,u,h){let c,p,d,y,w=n[0],N=u[0],o=0,x=0;N>w==N>-w?(c=w,w=n[++o]):(c=N,N=u[++x]);let b=0;if(o<m&&x<r)for(N>w==N>-w?(p=w+c,d=c-(p-w),w=n[++o]):(p=N+c,d=c-(p-N),N=u[++x]),c=p,d!==0&&(h[b++]=d);o<m&&x<r;)N>w==N>-w?(p=c+w,y=p-c,d=c-(p-y)+(w-y),w=n[++o]):(p=c+N,y=p-c,d=c-(p-y)+(N-y),N=u[++x]),c=p,d!==0&&(h[b++]=d);for(;o<m;)p=c+w,y=p-c,d=c-(p-y)+(w-y),w=n[++o],c=p,d!==0&&(h[b++]=d);for(;x<r;)p=c+N,y=p-c,d=c-(p-y)+(N-y),N=u[++x],c=p,d!==0&&(h[b++]=d);return(c!==0||b===0)&&(h[b++]=c),b}function Cr(m,n){let r=n[0];for(let u=1;u<m;u++)r+=n[u];return r}function Bt(m){return new Float64Array(m)}const Er=(3+16*at)*at,Fr=(2+12*at)*at,Pr=(9+64*at)*at*at,Ct=Bt(4),En=Bt(8),Fn=Bt(12),Pn=Bt(16),K=Bt(4);function Tr(m,n,r,u,h,c,p){let d,y,w,N,o,x,b,P,E,R,I,M,O,k,v,B,$,D;const q=m-h,z=r-h,Z=n-c,W=u-c;k=q*W,x=J*q,b=x-(x-q),P=q-b,x=J*W,E=x-(x-W),R=W-E,v=P*R-(k-b*E-P*E-b*R),B=Z*z,x=J*Z,b=x-(x-Z),P=Z-b,x=J*z,E=x-(x-z),R=z-E,$=P*R-(B-b*E-P*E-b*R),I=v-$,o=v-I,Ct[0]=v-(I+o)+(o-$),M=k+I,o=M-k,O=k-(M-o)+(I-o),I=O-B,o=O-I,Ct[1]=O-(I+o)+(o-B),D=M+I,o=D-M,Ct[2]=M-(D-o)+(I-o),Ct[3]=D;let U=Cr(4,Ct),it=Fr*p;if(U>=it||-U>=it||(o=m-q,d=m-(q+o)+(o-h),o=r-z,w=r-(z+o)+(o-h),o=n-Z,y=n-(Z+o)+(o-c),o=u-W,N=u-(W+o)+(o-c),d===0&&y===0&&w===0&&N===0)||(it=Pr*p+Nr*Math.abs(U),U+=q*N+W*d-(Z*w+z*y),U>=it||-U>=it))return U;k=d*W,x=J*d,b=x-(x-d),P=d-b,x=J*W,E=x-(x-W),R=W-E,v=P*R-(k-b*E-P*E-b*R),B=y*z,x=J*y,b=x-(x-y),P=y-b,x=J*z,E=x-(x-z),R=z-E,$=P*R-(B-b*E-P*E-b*R),I=v-$,o=v-I,K[0]=v-(I+o)+(o-$),M=k+I,o=M-k,O=k-(M-o)+(I-o),I=O-B,o=O-I,K[1]=O-(I+o)+(o-B),D=M+I,o=D-M,K[2]=M-(D-o)+(I-o),K[3]=D;const ut=Se(4,Ct,4,K,En);k=q*N,x=J*q,b=x-(x-q),P=q-b,x=J*N,E=x-(x-N),R=N-E,v=P*R-(k-b*E-P*E-b*R),B=Z*w,x=J*Z,b=x-(x-Z),P=Z-b,x=J*w,E=x-(x-w),R=w-E,$=P*R-(B-b*E-P*E-b*R),I=v-$,o=v-I,K[0]=v-(I+o)+(o-$),M=k+I,o=M-k,O=k-(M-o)+(I-o),I=O-B,o=O-I,K[1]=O-(I+o)+(o-B),D=M+I,o=D-M,K[2]=M-(D-o)+(I-o),K[3]=D;const ie=Se(ut,En,4,K,Fn);k=d*N,x=J*d,b=x-(x-d),P=d-b,x=J*N,E=x-(x-N),R=N-E,v=P*R-(k-b*E-P*E-b*R),B=y*w,x=J*y,b=x-(x-y),P=y-b,x=J*w,E=x-(x-w),R=w-E,$=P*R-(B-b*E-P*E-b*R),I=v-$,o=v-I,K[0]=v-(I+o)+(o-$),M=k+I,o=M-k,O=k-(M-o)+(I-o),I=O-B,o=O-I,K[1]=O-(I+o)+(o-B),D=M+I,o=D-M,K[2]=M-(D-o)+(I-o),K[3]=D;const Et=Se(ie,Fn,4,K,Pn);return Pn[Et-1]}function Ir(m,n,r,u,h,c){const p=(n-c)*(r-h),d=(m-h)*(u-c),y=p-d,w=Math.abs(p+d);return Math.abs(y)>=Er*w?y:-Tr(m,n,r,u,h,c,w)}const At=(m,n)=>m.ll.x<=n.x&&n.x<=m.ur.x&&m.ll.y<=n.y&&n.y<=m.ur.y,Fe=(m,n)=>{if(n.ur.x<m.ll.x||m.ur.x<n.ll.x||n.ur.y<m.ll.y||m.ur.y<n.ll.y)return null;const r=m.ll.x<n.ll.x?n.ll.x:m.ll.x,u=m.ur.x<n.ur.x?m.ur.x:n.ur.x,h=m.ll.y<n.ll.y?n.ll.y:m.ll.y,c=m.ur.y<n.ur.y?m.ur.y:n.ur.y;return{ll:{x:r,y:h},ur:{x:u,y:c}}};let pt=Number.EPSILON;pt===void 0&&(pt=Math.pow(2,-52));const Mr=pt*pt,Tn=(m,n)=>{if(-pt<m&&m<pt&&-pt<n&&n<pt)return 0;const r=m-n;return r*r<Mr*m*n?0:m<n?-1:1};class Rr{constructor(){this.reset()}reset(){this.xRounder=new In,this.yRounder=new In}round(n,r){return{x:this.xRounder.round(n),y:this.yRounder.round(r)}}}class In{constructor(){this.tree=new Pe,this.round(0)}round(n){const r=this.tree.add(n),u=this.tree.prev(r);if(u!==null&&Tn(r.key,u.key)===0)return this.tree.remove(n),u.key;const h=this.tree.next(r);return h!==null&&Tn(r.key,h.key)===0?(this.tree.remove(n),h.key):n}}const vt=new Rr,te=(m,n)=>m.x*n.y-m.y*n.x,Gn=(m,n)=>m.x*n.x+m.y*n.y,Mn=(m,n,r)=>{const u=Ir(m.x,m.y,n.x,n.y,r.x,r.y);return u>0?-1:u<0?1:0},ee=m=>Math.sqrt(Gn(m,m)),kr=(m,n,r)=>{const u={x:n.x-m.x,y:n.y-m.y},h={x:r.x-m.x,y:r.y-m.y};return te(h,u)/ee(h)/ee(u)},Lr=(m,n,r)=>{const u={x:n.x-m.x,y:n.y-m.y},h={x:r.x-m.x,y:r.y-m.y};return Gn(h,u)/ee(h)/ee(u)},Rn=(m,n,r)=>n.y===0?null:{x:m.x+n.x/n.y*(r-m.y),y:r},kn=(m,n,r)=>n.x===0?null:{x:r,y:m.y+n.y/n.x*(r-m.x)},Ar=(m,n,r,u)=>{if(n.x===0)return kn(r,u,m.x);if(u.x===0)return kn(m,n,r.x);if(n.y===0)return Rn(r,u,m.y);if(u.y===0)return Rn(m,n,r.y);const h=te(n,u);if(h==0)return null;const c={x:r.x-m.x,y:r.y-m.y},p=te(c,n)/h,d=te(c,u)/h,y=m.x+d*n.x,w=r.x+p*u.x,N=m.y+d*n.y,o=r.y+p*u.y,x=(y+w)/2,b=(N+o)/2;return{x,y:b}};class nt{static compare(n,r){const u=nt.comparePoints(n.point,r.point);return u!==0?u:(n.point!==r.point&&n.link(r),n.isLeft!==r.isLeft?n.isLeft?1:-1:dt.compare(n.segment,r.segment))}static comparePoints(n,r){return n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0}constructor(n,r){n.events===void 0?n.events=[this]:n.events.push(this),this.point=n,this.isLeft=r}link(n){if(n.point===this.point)throw new Error("Tried to link already linked events");const r=n.point.events;for(let u=0,h=r.length;u<h;u++){const c=r[u];this.point.events.push(c),c.point=this.point}this.checkForConsuming()}checkForConsuming(){const n=this.point.events.length;for(let r=0;r<n;r++){const u=this.point.events[r];if(u.segment.consumedBy===void 0)for(let h=r+1;h<n;h++){const c=this.point.events[h];c.consumedBy===void 0&&u.otherSE.point.events===c.otherSE.point.events&&u.segment.consume(c.segment)}}}getAvailableLinkedEvents(){const n=[];for(let r=0,u=this.point.events.length;r<u;r++){const h=this.point.events[r];h!==this&&!h.segment.ringOut&&h.segment.isInResult()&&n.push(h)}return n}getLeftmostComparator(n){const r=new Map,u=h=>{const c=h.otherSE;r.set(h,{sine:kr(this.point,n.point,c.point),cosine:Lr(this.point,n.point,c.point)})};return(h,c)=>{r.has(h)||u(h),r.has(c)||u(c);const{sine:p,cosine:d}=r.get(h),{sine:y,cosine:w}=r.get(c);return p>=0&&y>=0?d<w?1:d>w?-1:0:p<0&&y<0?d<w?-1:d>w?1:0:y<p?-1:y>p?1:0}}}let vr=0;class dt{static compare(n,r){const u=n.leftSE.point.x,h=r.leftSE.point.x,c=n.rightSE.point.x,p=r.rightSE.point.x;if(p<u)return 1;if(c<h)return-1;const d=n.leftSE.point.y,y=r.leftSE.point.y,w=n.rightSE.point.y,N=r.rightSE.point.y;if(u<h){if(y<d&&y<w)return 1;if(y>d&&y>w)return-1;const o=n.comparePoint(r.leftSE.point);if(o<0)return 1;if(o>0)return-1;const x=r.comparePoint(n.rightSE.point);return x!==0?x:-1}if(u>h){if(d<y&&d<N)return-1;if(d>y&&d>N)return 1;const o=r.comparePoint(n.leftSE.point);if(o!==0)return o;const x=n.comparePoint(r.rightSE.point);return x<0?1:x>0?-1:1}if(d<y)return-1;if(d>y)return 1;if(c<p){const o=r.comparePoint(n.rightSE.point);if(o!==0)return o}if(c>p){const o=n.comparePoint(r.rightSE.point);if(o<0)return 1;if(o>0)return-1}if(c!==p){const o=w-d,x=c-u,b=N-y,P=p-h;if(o>x&&b<P)return 1;if(o<x&&b>P)return-1}return c>p?1:c<p||w<N?-1:w>N?1:n.id<r.id?-1:n.id>r.id?1:0}constructor(n,r,u,h){this.id=++vr,this.leftSE=n,n.segment=this,n.otherSE=r,this.rightSE=r,r.segment=this,r.otherSE=n,this.rings=u,this.windings=h}static fromRing(n,r,u){let h,c,p;const d=nt.comparePoints(n,r);if(d<0)h=n,c=r,p=1;else if(d>0)h=r,c=n,p=-1;else throw new Error(`Tried to create degenerate segment at [${n.x}, ${n.y}]`);const y=new nt(h,!0),w=new nt(c,!1);return new dt(y,w,[u],[p])}replaceRightSE(n){this.rightSE=n,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){const n=this.leftSE.point.y,r=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:n<r?n:r},ur:{x:this.rightSE.point.x,y:n>r?n:r}}}vector(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}isAnEndpoint(n){return n.x===this.leftSE.point.x&&n.y===this.leftSE.point.y||n.x===this.rightSE.point.x&&n.y===this.rightSE.point.y}comparePoint(n){if(this.isAnEndpoint(n))return 0;const r=this.leftSE.point,u=this.rightSE.point,h=this.vector();if(r.x===u.x)return n.x===r.x?0:n.x<r.x?1:-1;const c=(n.y-r.y)/h.y,p=r.x+c*h.x;if(n.x===p)return 0;const d=(n.x-r.x)/h.x,y=r.y+d*h.y;return n.y===y?0:n.y<y?-1:1}getIntersection(n){const r=this.bbox(),u=n.bbox(),h=Fe(r,u);if(h===null)return null;const c=this.leftSE.point,p=this.rightSE.point,d=n.leftSE.point,y=n.rightSE.point,w=At(r,d)&&this.comparePoint(d)===0,N=At(u,c)&&n.comparePoint(c)===0,o=At(r,y)&&this.comparePoint(y)===0,x=At(u,p)&&n.comparePoint(p)===0;if(N&&w)return x&&!o?p:!x&&o?y:null;if(N)return o&&c.x===y.x&&c.y===y.y?null:c;if(w)return x&&p.x===d.x&&p.y===d.y?null:d;if(x&&o)return null;if(x)return p;if(o)return y;const b=Ar(c,this.vector(),d,n.vector());return b===null||!At(h,b)?null:vt.round(b.x,b.y)}split(n){const r=[],u=n.events!==void 0,h=new nt(n,!0),c=new nt(n,!1),p=this.rightSE;this.replaceRightSE(c),r.push(c),r.push(h);const d=new dt(h,p,this.rings.slice(),this.windings.slice());return nt.comparePoints(d.leftSE.point,d.rightSE.point)>0&&d.swapEvents(),nt.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),u&&(h.checkForConsuming(),c.checkForConsuming()),r}swapEvents(){const n=this.rightSE;this.rightSE=this.leftSE,this.leftSE=n,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let r=0,u=this.windings.length;r<u;r++)this.windings[r]*=-1}consume(n){let r=this,u=n;for(;r.consumedBy;)r=r.consumedBy;for(;u.consumedBy;)u=u.consumedBy;const h=dt.compare(r,u);if(h!==0){if(h>0){const c=r;r=u,u=c}if(r.prev===u){const c=r;r=u,u=c}for(let c=0,p=u.rings.length;c<p;c++){const d=u.rings[c],y=u.windings[c],w=r.rings.indexOf(d);w===-1?(r.rings.push(d),r.windings.push(y)):r.windings[w]+=y}u.rings=null,u.windings=null,u.consumedBy=r,u.leftSE.consumedBy=r.leftSE,u.rightSE.consumedBy=r.rightSE}}prevInResult(){return this._prevInResult!==void 0?this._prevInResult:(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null,this._prevInResult)}beforeState(){if(this._beforeState!==void 0)return this._beforeState;if(!this.prev)this._beforeState={rings:[],windings:[],multiPolys:[]};else{const n=this.prev.consumedBy||this.prev;this._beforeState=n.afterState()}return this._beforeState}afterState(){if(this._afterState!==void 0)return this._afterState;const n=this.beforeState();this._afterState={rings:n.rings.slice(0),windings:n.windings.slice(0),multiPolys:[]};const r=this._afterState.rings,u=this._afterState.windings,h=this._afterState.multiPolys;for(let d=0,y=this.rings.length;d<y;d++){const w=this.rings[d],N=this.windings[d],o=r.indexOf(w);o===-1?(r.push(w),u.push(N)):u[o]+=N}const c=[],p=[];for(let d=0,y=r.length;d<y;d++){if(u[d]===0)continue;const w=r[d],N=w.poly;if(p.indexOf(N)===-1)if(w.isExterior)c.push(N);else{p.indexOf(N)===-1&&p.push(N);const o=c.indexOf(w.poly);o!==-1&&c.splice(o,1)}}for(let d=0,y=c.length;d<y;d++){const w=c[d].multiPoly;h.indexOf(w)===-1&&h.push(w)}return this._afterState}isInResult(){if(this.consumedBy)return!1;if(this._isInResult!==void 0)return this._isInResult;const n=this.beforeState().multiPolys,r=this.afterState().multiPolys;switch(ot.type){case"union":{const u=n.length===0,h=r.length===0;this._isInResult=u!==h;break}case"intersection":{let u,h;n.length<r.length?(u=n.length,h=r.length):(u=r.length,h=n.length),this._isInResult=h===ot.numMultiPolys&&u<h;break}case"xor":{const u=Math.abs(n.length-r.length);this._isInResult=u%2===1;break}case"difference":{const u=h=>h.length===1&&h[0].isSubject;this._isInResult=u(n)!==u(r);break}default:throw new Error(`Unrecognized operation type found ${ot.type}`)}return this._isInResult}}class Ln{constructor(n,r,u){if(!Array.isArray(n)||n.length===0)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=r,this.isExterior=u,this.segments=[],typeof n[0][0]!="number"||typeof n[0][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const h=vt.round(n[0][0],n[0][1]);this.bbox={ll:{x:h.x,y:h.y},ur:{x:h.x,y:h.y}};let c=h;for(let p=1,d=n.length;p<d;p++){if(typeof n[p][0]!="number"||typeof n[p][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");let y=vt.round(n[p][0],n[p][1]);y.x===c.x&&y.y===c.y||(this.segments.push(dt.fromRing(c,y,this)),y.x<this.bbox.ll.x&&(this.bbox.ll.x=y.x),y.y<this.bbox.ll.y&&(this.bbox.ll.y=y.y),y.x>this.bbox.ur.x&&(this.bbox.ur.x=y.x),y.y>this.bbox.ur.y&&(this.bbox.ur.y=y.y),c=y)}(h.x!==c.x||h.y!==c.y)&&this.segments.push(dt.fromRing(c,h,this))}getSweepEvents(){const n=[];for(let r=0,u=this.segments.length;r<u;r++){const h=this.segments[r];n.push(h.leftSE),n.push(h.rightSE)}return n}}class Br{constructor(n,r){if(!Array.isArray(n))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new Ln(n[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(let u=1,h=n.length;u<h;u++){const c=new Ln(n[u],this,!1);c.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=c.bbox.ll.x),c.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=c.bbox.ll.y),c.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=c.bbox.ur.x),c.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=c.bbox.ur.y),this.interiorRings.push(c)}this.multiPoly=r}getSweepEvents(){const n=this.exteriorRing.getSweepEvents();for(let r=0,u=this.interiorRings.length;r<u;r++){const h=this.interiorRings[r].getSweepEvents();for(let c=0,p=h.length;c<p;c++)n.push(h[c])}return n}}class An{constructor(n,r){if(!Array.isArray(n))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{typeof n[0][0][0]=="number"&&(n=[n])}catch(u){}this.polys=[],this.bbox={ll:{x:Number.POSITIVE_INFINITY,y:Number.POSITIVE_INFINITY},ur:{x:Number.NEGATIVE_INFINITY,y:Number.NEGATIVE_INFINITY}};for(let u=0,h=n.length;u<h;u++){const c=new Br(n[u],this);c.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=c.bbox.ll.x),c.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=c.bbox.ll.y),c.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=c.bbox.ur.x),c.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=c.bbox.ur.y),this.polys.push(c)}this.isSubject=r}getSweepEvents(){const n=[];for(let r=0,u=this.polys.length;r<u;r++){const h=this.polys[r].getSweepEvents();for(let c=0,p=h.length;c<p;c++)n.push(h[c])}return n}}class ne{static factory(n){const r=[];for(let u=0,h=n.length;u<h;u++){const c=n[u];if(!c.isInResult()||c.ringOut)continue;let p=null,d=c.leftSE,y=c.rightSE;const w=[d],N=d.point,o=[];for(;p=d,d=y,w.push(d),d.point!==N;)for(;;){const x=d.getAvailableLinkedEvents();if(x.length===0){const E=w[0].point,R=w[w.length-1].point;throw new Error(`Unable to complete output ring starting at [${E.x}, ${E.y}]. Last matching segment found ends at [${R.x}, ${R.y}].`)}if(x.length===1){y=x[0].otherSE;break}let b=null;for(let E=0,R=o.length;E<R;E++)if(o[E].point===d.point){b=E;break}if(b!==null){const E=o.splice(b)[0],R=w.splice(E.index);R.unshift(R[0].otherSE),r.push(new ne(R.reverse()));continue}o.push({index:w.length,point:d.point});const P=d.getLeftmostComparator(p);y=x.sort(P)[0].otherSE;break}r.push(new ne(w))}return r}constructor(n){this.events=n;for(let r=0,u=n.length;r<u;r++)n[r].segment.ringOut=this;this.poly=null}getGeom(){let n=this.events[0].point;const r=[n];for(let w=1,N=this.events.length-1;w<N;w++){const o=this.events[w].point,x=this.events[w+1].point;Mn(o,n,x)!==0&&(r.push(o),n=o)}if(r.length===1)return null;const u=r[0],h=r[1];Mn(u,n,h)===0&&r.shift(),r.push(r[0]);const c=this.isExteriorRing()?1:-1,p=this.isExteriorRing()?0:r.length-1,d=this.isExteriorRing()?r.length:-1,y=[];for(let w=p;w!=d;w+=c)y.push([r[w].x,r[w].y]);return y}isExteriorRing(){if(this._isExteriorRing===void 0){const n=this.enclosingRing();this._isExteriorRing=n?!n.isExteriorRing():!0}return this._isExteriorRing}enclosingRing(){return this._enclosingRing===void 0&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}_calcEnclosingRing(){let n=this.events[0];for(let h=1,c=this.events.length;h<c;h++){const p=this.events[h];nt.compare(n,p)>0&&(n=p)}let r=n.segment.prevInResult(),u=r?r.prevInResult():null;for(;;){if(!r)return null;if(!u)return r.ringOut;if(u.ringOut!==r.ringOut)return u.ringOut.enclosingRing()!==r.ringOut?r.ringOut:r.ringOut.enclosingRing();r=u.prevInResult(),u=r?r.prevInResult():null}}}class vn{constructor(n){this.exteriorRing=n,n.poly=this,this.interiorRings=[]}addInterior(n){this.interiorRings.push(n),n.poly=this}getGeom(){const n=[this.exteriorRing.getGeom()];if(n[0]===null)return null;for(let r=0,u=this.interiorRings.length;r<u;r++){const h=this.interiorRings[r].getGeom();h!==null&&n.push(h)}return n}}class Or{constructor(n){this.rings=n,this.polys=this._composePolys(n)}getGeom(){const n=[];for(let r=0,u=this.polys.length;r<u;r++){const h=this.polys[r].getGeom();h!==null&&n.push(h)}return n}_composePolys(n){const r=[];for(let u=0,h=n.length;u<h;u++){const c=n[u];if(!c.poly)if(c.isExteriorRing())r.push(new vn(c));else{const p=c.enclosingRing();p.poly||r.push(new vn(p)),p.poly.addInterior(c)}}return r}}class Dr{constructor(n){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:dt.compare;this.queue=n,this.tree=new Pe(r),this.segments=[]}process(n){const r=n.segment,u=[];if(n.consumedBy)return n.isLeft?this.queue.remove(n.otherSE):this.tree.remove(r),u;const h=n.isLeft?this.tree.add(r):this.tree.find(r);if(!h)throw new Error(`Unable to find segment #${r.id} [${r.leftSE.point.x}, ${r.leftSE.point.y}] -> [${r.rightSE.point.x}, ${r.rightSE.point.y}] in SweepLine tree.`);let c=h,p=h,d,y;for(;d===void 0;)c=this.tree.prev(c),c===null?d=null:c.key.consumedBy===void 0&&(d=c.key);for(;y===void 0;)p=this.tree.next(p),p===null?y=null:p.key.consumedBy===void 0&&(y=p.key);if(n.isLeft){let w=null;if(d){const o=d.getIntersection(r);if(o!==null&&(r.isAnEndpoint(o)||(w=o),!d.isAnEndpoint(o))){const x=this._splitSafely(d,o);for(let b=0,P=x.length;b<P;b++)u.push(x[b])}}let N=null;if(y){const o=y.getIntersection(r);if(o!==null&&(r.isAnEndpoint(o)||(N=o),!y.isAnEndpoint(o))){const x=this._splitSafely(y,o);for(let b=0,P=x.length;b<P;b++)u.push(x[b])}}if(w!==null||N!==null){let o=null;w===null?o=N:N===null?o=w:o=nt.comparePoints(w,N)<=0?w:N,this.queue.remove(r.rightSE),u.push(r.rightSE);const x=r.split(o);for(let b=0,P=x.length;b<P;b++)u.push(x[b])}u.length>0?(this.tree.remove(r),u.push(n)):(this.segments.push(r),r.prev=d)}else{if(d&&y){const w=d.getIntersection(y);if(w!==null){if(!d.isAnEndpoint(w)){const N=this._splitSafely(d,w);for(let o=0,x=N.length;o<x;o++)u.push(N[o])}if(!y.isAnEndpoint(w)){const N=this._splitSafely(y,w);for(let o=0,x=N.length;o<x;o++)u.push(N[o])}}}this.tree.remove(r)}return u}_splitSafely(n,r){this.tree.remove(n);const u=n.rightSE;this.queue.remove(u);const h=n.split(r);return h.push(u),n.consumedBy===void 0&&this.tree.add(n),h}}const Bn=typeof process!="undefined"&&{}.POLYGON_CLIPPING_MAX_QUEUE_SIZE||1e6,Wr=typeof process!="undefined"&&{}.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS||1e6;class Hr{run(n,r,u){ot.type=n,vt.reset();const h=[new An(r,!0)];for(let o=0,x=u.length;o<x;o++)h.push(new An(u[o],!1));if(ot.numMultiPolys=h.length,ot.type==="difference"){const o=h[0];let x=1;for(;x<h.length;)Fe(h[x].bbox,o.bbox)!==null?x++:h.splice(x,1)}if(ot.type==="intersection")for(let o=0,x=h.length;o<x;o++){const b=h[o];for(let P=o+1,E=h.length;P<E;P++)if(Fe(b.bbox,h[P].bbox)===null)return[]}const c=new Pe(nt.compare);for(let o=0,x=h.length;o<x;o++){const b=h[o].getSweepEvents();for(let P=0,E=b.length;P<E;P++)if(c.insert(b[P]),c.size>Bn)throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big).")}const p=new Dr(c);let d=c.size,y=c.pop();for(;y;){const o=y.key;if(c.size===d){const b=o.segment;throw new Error(`Unable to pop() ${o.isLeft?"left":"right"} SweepEvent [${o.point.x}, ${o.point.y}] from segment #${b.id} [${b.leftSE.point.x}, ${b.leftSE.point.y}] -> [${b.rightSE.point.x}, ${b.rightSE.point.y}] from queue.`)}if(c.size>Bn)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big).");if(p.segments.length>Wr)throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments).");const x=p.process(o);for(let b=0,P=x.length;b<P;b++){const E=x[b];E.consumedBy===void 0&&c.insert(E)}d=c.size,y=c.pop()}vt.reset();const w=ne.factory(p.segments);return new Or(w).getGeom()}}const ot=new Hr,Gr=function(m){for(var n=arguments.length,r=new Array(n>1?n-1:0),u=1;u<n;u++)r[u-1]=arguments[u];return ot.run("union",m,r)},zr=function(m){for(var n=arguments.length,r=new Array(n>1?n-1:0),u=1;u<n;u++)r[u-1]=arguments[u];return ot.run("intersection",m,r)},jr=function(m){for(var n=arguments.length,r=new Array(n>1?n-1:0),u=1;u<n;u++)r[u-1]=arguments[u];return ot.run("xor",m,r)},Yr=function(m){for(var n=arguments.length,r=new Array(n>1?n-1:0),u=1;u<n;u++)r[u-1]=arguments[u];return ot.run("difference",m,r)};var Qt={union:Gr,intersection:zr,xor:jr,difference:Yr};const io="datas/geojsons/hongyuan-townships-screen.geojson",Vr="assets/json/hongyuan-county-outline.json",ro="assets/json/中华人民共和国.json";function $r(m){return`./${m}`}const Ur=21,qr=-18,Zr=-50,Xr=.045,On=-18,Dn=-58,Wn=4.2,Hn=3.2,be=4700,Jr=4620,Kr={__name:"index",props:{active:{type:Boolean,default:!0},activeLayer:{type:Object,default:null},mapRanking:{type:Object,default:null},overlayLayer:{type:Object,default:null},overlayLayers:{type:Array,default:()=>[]},tileUrlTemplate:{type:String,default:"https://qkl-map.oss-cn-chengdu.aliyuncs.com/hy-result/{z}/{x}/{y}.png"},referenceTileUrlTemplate:{type:String,default:"https://map.shuxitech.com/vt/lyrs=s&hl=zh-CN&x={x}&y={y}&z={z}"},terrainUrl:{type:String,default:"/terrain"},center:{type:Array,default:()=>[102.600005,32.585593]},initialZoom:{type:Number,default:9},minimumZoomDistance:{type:Number,default:350},countyViewTargetOffset:{type:Object,default:null},autoApplyLayerMapView:{type:Boolean,default:!0},maxZoom:{type:Number,default:21},adminBoundaryLineScale:{type:Number,default:1},showNationalBackdrop:{type:Boolean,default:!0},enableImageryFeaturePick:{type:Boolean,default:!0},enableTownPolygonPick:{type:Boolean,default:!0},hideTownLabelStats:{type:Boolean,default:!1}},emits:["ready","scene-mounted","feature-loading","feature-info","layer-status","tile-status","map-click","draw-boundary","view-change"],setup(m,{expose:n,emit:r}){let u=[],h=null;const c=m,p=r,d=Nn(null),y=Nn(null),w=yr(null),N=hr(()=>c.activeLayer?[c.activeLayer,...Array.isArray(c.activeLayer.overlayLayers)?c.activeLayer.overlayLayers:[]].filter(Boolean):c.overlayLayers.length?c.overlayLayers.filter(Boolean):c.overlayLayer?[c.overlayLayer]:[]);let o=null,x=null,b=null,P=null,E=null,R=!1,I=0,M=null,O=!1,k=[],v=null,B=[],$=[],D=[],q=[],z=[],Z=[],W=null,U=[],it=[],ut=[],ie=[];const Et=new Map;fr(()=>{p("scene-mounted"),c.active&&Ot()}),mr(()=>It()),Kt(N,()=>Be(),{deep:!0}),Kt(()=>c.mapRanking,()=>oe(),{deep:!0}),Kt(()=>c.hideTownLabelStats,()=>oe()),Kt(()=>c.active,t=>ft(this,null,function*(){if(!t){It();return}yield _n(),Ot()}));function Ot(){var S,_,F,C;if(o||!y.value)return!!o;const t=window.Cesium;if(!t)return p("layer-status",{type:"error",text:"Cesium 运行资源加载失败"}),!1;R=!1;const e=zn(t),i=Ie(c.tileUrlTemplate),l=Ie(c.referenceTileUrlTemplate),a=jn(i),s=l&&l!==i?Te(t,l,{maximumLevel:c.maxZoom}):null,f=i?Te(t,i,{maximumLevel:a?Math.min(c.maxZoom,Ur):c.maxZoom,rectangle:a?Yn(t):null}):null;if(o=new t.Viewer(y.value,{animation:!1,baseLayerPicker:!1,fullscreenButton:!1,geocoder:!1,homeButton:!1,infoBox:!1,navigationHelpButton:!1,sceneModePicker:!1,selectionIndicator:!1,timeline:!1,scene3DOnly:!0,imageryProvider:!1,terrainProvider:e,useBrowserRecommendedResolution:!1,requestRenderMode:!0,maximumRenderTimeChange:1/0,contextOptions:{webgl:{alpha:!0,antialias:!0}}}),Ae(!1),s){const T=o.imageryLayers.addImageryProvider(s);T.alpha=1,T.brightness=.68,T.contrast=1.08,T.saturation=.48,T.gamma=.9}f&&(v=o.imageryLayers.addImageryProvider(f),v.alpha=a?.88:1,v.brightness=a?.96:.9,v.contrast=a?1.12:1.1,v.saturation=a?1.08:1.05,v.gamma=a?.98:.96),o.scene.globe.terrainExaggeration=1.5,o.scene.globe.depthTestAgainstTerrain=!1,o.scene.globe.baseColor=t.Color.fromCssColorString("#061821"),o.scene.backgroundColor=t.Color.fromCssColorString("#020b12"),o.scene.skyAtmosphere.show=!1,o.scene.skyBox&&(o.scene.skyBox.show=!1),o.scene.fog.enabled=!0,o.scene.fog.density=18e-5,o.resolutionScale=Math.min(Math.max(window.devicePixelRatio||1,1),1.5),o.scene.fxaa=!1,o.scene.postProcessStages.fxaa.enabled=!1,o.scene.screenSpaceCameraController.enableCollisionDetection=!0,o.scene.screenSpaceCameraController.minimumZoomDistance=Math.max(1,Number(c.minimumZoomDistance)||1),o.scene.screenSpaceCameraController.maximumZoomDistance=56e4,(S=o.cesiumWidget)!=null&&S.creditContainer&&(o.cesiumWidget.creditContainer.style.display="none"),(_=o._cesiumWidget)!=null&&_._creditContainer&&(o._cesiumWidget._creditContainer.style.display="none"),qn(e,t),Me().then(()=>{var T;!o||(T=o.isDestroyed)!=null&&T.call(o)||(Fi(),re())}).catch(T=>{console.warn("[cesium-map] county outline load failed",T),p("layer-status",{type:"error",text:"红原县边界加载失败"})}),_i(),ki(),ni(),ii(),ri(),re(),Be(),oe();const g={viewer:o,clearSelectedFeature:tt,focusProject:tn,focusPasture:on,focusTownByName:Qe,focusYakIndustryPoint:en,focusVectorFeature:nn,getVectorFeatureAnchorScreen:rn,getVectorFeaturesAnchorScreen:Vt,getVectorFeatureScreen:Pt,getYakIndustryPointScreen:ce,destroy:It};return w.value=g,(C=(F=f==null?void 0:f.errorEvent)==null?void 0:F.addEventListener)==null||C.call(F,()=>{p("tile-status",{type:"warning",text:"牧场影像底图部分瓦片加载失败"})}),p("tile-status",{type:"success",text:"牧场影像底图已加载"}),window.setTimeout(()=>{var T;o&&!((T=o.isDestroyed)!=null&&T.call(o))&&p("ready")},0),_n(Dt),!0}function zn(t){if(!c.terrainUrl)return new t.EllipsoidTerrainProvider;try{return new t.CesiumTerrainProvider({url:c.terrainUrl,requestVertexNormals:!0,requestWaterMask:!1})}catch(e){return R=!0,new t.EllipsoidTerrainProvider}}function Te(t,e,i={}){return e?new t.UrlTemplateImageryProvider({url:e,minimumLevel:i.minimumLevel||3,maximumLevel:i.maximumLevel||c.maxZoom,rectangle:i.rectangle||void 0,tilingScheme:new t.WebMercatorTilingScheme,credit:""}):null}function Ie(t){return String(t||"").trim()}function jn(t){return/hy-result|qkl-map/i.test(String(t||""))}function Yn(t){return t.Rectangle.fromDegrees(G.west-.035,G.south-.035,G.east+.035,G.north+.035)}function Vn(t,e="feature"){const i=[];if(((t==null?void 0:t.features)||[]).forEach(l=>{const a=j(l==null?void 0:l.geometry);ze(a).forEach(s=>{const f=$n(s);f&&i.push(f)})}),!i.length)return[];try{return Qt.union(...i)}catch(l){return console.warn(`[cesium-map] ${e} union boundary failed`,l),i.map(a=>a)}}function Me(){return ft(this,null,function*(){return u.length?u:(h||(h=Ht(Vr).then(t=>{const e=Vn(t,"county outline");return u=e,e}).catch(t=>{throw h=null,t})),h)})}function $n(t){if(!Array.isArray(t))return null;const e=t.map(i=>Un((i||[]).map(Y).filter(Boolean))).filter(i=>i.length>=4);return e.length?e:null}function Un(t=[]){if(!t.length)return[];const e=t[0],i=t[t.length-1];return je(e,i)?t:[...t,e]}function qn(t,e){var l,a,s,f;const i=()=>{!o||R||(R=!0,o.terrainProvider=new e.EllipsoidTerrainProvider,o.scene.globe.terrainExaggeration=1,o.scene.requestRender(),p("layer-status",{type:"warning",text:"CXPT 地形服务暂不可用,已保留三维影像地图"}))};(a=(l=t==null?void 0:t.errorEvent)==null?void 0:l.addEventListener)==null||a.call(l,i),(f=(s=t==null?void 0:t.readyPromise)==null?void 0:s.catch)==null||f.call(s,i)}function Zn(){return Ot()}function Xn(){var t;return!!(o&&!((t=o.isDestroyed)!=null&&t.call(o)))}function Jn(){Re()}function Re(){if(!o){Ot();return}o.useDefaultRenderLoop=!0,Dt()}function Kn(){It()}function Dt(){var t;!o||(t=o.isDestroyed)!=null&&t.call(o)||(o.resize(),o.scene.requestRender())}function ke(){if(!(o!=null&&o.camera)||!window.Cesium)return null;const t=window.Cesium,e=o.camera;return{position:t.Cartesian3.clone(e.positionWC||e.position),direction:t.Cartesian3.clone(e.directionWC||e.direction),up:t.Cartesian3.clone(e.upWC||e.up)}}function Wt(t){var i,l,a,s,f,g;if(!(o!=null&&o.camera)||!t||!window.Cesium)return;const e=window.Cesium;(l=(i=o.camera).cancelFlight)==null||l.call(i),(s=(a=o.camera).lookAtTransform)==null||s.call(a,e.Matrix4.IDENTITY),o.camera.setView({destination:e.Cartesian3.clone(t.position),orientation:{direction:e.Cartesian3.clone(t.direction),up:e.Cartesian3.clone(t.up)}}),(g=(f=o.scene)==null?void 0:f.requestRender)==null||g.call(f)}function Le(t){var e,i;!t||typeof window=="undefined"||((e=window.requestAnimationFrame)==null||e.call(window,()=>Wt(t)),(i=window.setTimeout)==null||i.call(window,()=>Wt(t),80))}function Qn(){tt(),Ae(!0)}function Ae(t=!0){if(!o)return;const e=window.Cesium,i=ei(),l=ve(c.initialZoom),a=ti(),s=e.Cartesian3.fromDegrees(i[0]+a.lng,i[1]+a.lat,2200),f=new e.HeadingPitchRange(e.Math.toRadians(qr),e.Math.toRadians(Zr),l);t?o.camera.flyToBoundingSphere(new e.BoundingSphere(s,1),{offset:f,duration:.9}):(o.camera.lookAt(s,f),o.camera.lookAtTransform(e.Matrix4.IDENTITY)),o.scene.requestRender()}function ti(){var l,a;const t=c.countyViewTargetOffset,e=Number((l=t==null?void 0:t.lng)!=null?l:t==null?void 0:t[0]),i=Number((a=t==null?void 0:t.lat)!=null?a:t==null?void 0:t[1]);return{lng:Number.isFinite(e)?e:0,lat:Number.isFinite(i)?i:-Xr}}function ve(t){const e=Number.isFinite(Number(t))?Number(t):9;return Math.max(9e3,Math.min(58e4,365e3/Math.pow(1.62,e-9)))}function ei(){const t=Y(c.center);return t||[(G.west+G.east)/2,(G.south+G.north)/2]}function ni(){!d.value||!window.ResizeObserver||(b=new ResizeObserver(()=>Dt()),b.observe(d.value))}function ii(){!o||P||(P=o.camera.moveEnd.addEventListener(re))}function ri(){!o||E||(E=o.scene.postRender.addEventListener(()=>{p("view-change")}))}function re(){var l,a;if(!o||(l=o.isDestroyed)!=null&&l.call(o))return;const t=Number((a=o.camera.positionCartographic)==null?void 0:a.height)||32e4,e=Math.max(0,Math.min(1,(36e4-t)/3e5)),i={township:1.1+e*.35,countyOutline:1.9+e*.35,countyHalo:4.2+e*.65};$.forEach(s=>{s!=null&&s.polyline&&s.__hyBoundaryRole==="township"&&(s.polyline.width=i.township)}),ut.forEach(s=>{s!=null&&s.polyline&&s.__hyBoundaryRole==="county-outline"&&(s.polyline.width=i.countyOutline),s!=null&&s.polyline&&s.__hyBoundaryRole==="county-halo"&&(s.polyline.width=i.countyHalo)}),o.scene.requestRender()}function Be(){return ft(this,null,function*(){var i,l;if(!o)return;const t=++I;yn();const e=N.value;if(!e.length){p("layer-status",{type:"idle",text:"未选择专题图层"}),o.scene.requestRender();return}p("layer-status",{type:"loading",text:"正在加载三维专题图层"});try{if(yield Me(),t!==I||!o)return;for(const a of e){if(t!==I)return;yield oi(a,t)}if(t!==I)return;c.autoApplyLayerMapView&&Vi(e.find(a=>(a==null?void 0:a.mapView)||(a==null?void 0:a.cameraPosition))),p("layer-status",{type:"success",text:`${e.map(a=>a.name).filter(Boolean).join("、")}已加载`})}catch(a){if(t!==I)return;console.warn("[cesium-map] topic layer failed",a),p("layer-status",{type:"error",text:"三维专题图层加载失败"})}finally{(l=(i=o==null?void 0:o.scene)==null?void 0:i.requestRender)==null||l.call(i)}})}function oi(t,e){return ft(this,null,function*(){const i=String((t==null?void 0:t.sourceType)||"wms").toLowerCase();if(["geojson","wkt-api","wfs"].includes(i)){const l=yield ui(t);if(e!==I||!l)return;mi(l,t,D);return}if(i==="wmts"){si(t);return}ai(t)})}function si(t){const e=window.Cesium,i=t.tileMatrixSetID||t.tileMatrixSet||"EPSG:900913",l=Number.isFinite(Number(t.maximumLevel))?Number(t.maximumLevel):21,a=new e.WebMapTileServiceImageryProvider({url:t.url||"/geoserver/gwc/service/wmts",layer:t.layerName,style:t.style||t.styles||"",format:t.format||"image/png",tileMatrixSetID:i,tileMatrixLabels:t.tileMatrixLabels||li(i,l),tilingScheme:/4326/i.test(i)?new e.GeographicTilingScheme:new e.WebMercatorTilingScheme,maximumLevel:l,credit:t.credit||""}),s=o.imageryLayers.addImageryProvider(a),f=String(t.layerName||"").includes("daping_yak_marks");s.alpha=f?St(t.opacity,.94):St(t.opacity,.86),f&&Oe(s,t),s.__hyLayer=t,B.push(s)}function li(t,e=21){return Array.from({length:e+1},(i,l)=>`${t}:${l}`)}function ai(t){const e=window.Cesium,i={service:"WMS",transparent:!0,format:"image/png",version:"1.1.1",styles:t.styles||""};t.cqlFilter&&(i.cql_filter=t.cqlFilter),t.sldBody&&(i.sld_body=t.sldBody);const l=new e.WebMapServiceImageryProvider({url:t.url||"/geoserver/ne/wms",layers:t.layerName,parameters:i,getFeatureInfoParameters:Lt(lt({},i),{info_format:"application/json",feature_count:10})}),a=o.imageryLayers.addImageryProvider(l),s=String(t.layerName||"").includes("daping_yak_marks");a.alpha=s?St(t.opacity,.94):St(t.opacity,.86),s&&Oe(a,t),a.__hyLayer=t,B.push(a)}function Oe(t,e={}){t.brightness=Number.isFinite(Number(e.brightness))?Number(e.brightness):1.08,t.contrast=Number.isFinite(Number(e.contrast))?Number(e.contrast):1.18,t.saturation=Number.isFinite(Number(e.saturation))?Number(e.saturation):1.42,t.gamma=Number.isFinite(Number(e.gamma))?Number(e.gamma):.95}function ui(t){return ft(this,null,function*(){if(t.sourceType==="wkt-api")try{const e=yield fetch(t.apiUrl,{credentials:"same-origin"});if(!e.ok)throw new Error(`HTTP ${e.status}`);return fi(yield e.json())}catch(e){if(!t.fallbackPath)throw e;return Ht(t.fallbackPath)}if(t.sourceType==="wfs"){const e=ci(t);return Ht(e)}return Ht(t.dataPath||t.fallbackPath)})}function Ht(t){return ft(this,null,function*(){if(!t)return null;const e=/^(https?:)?\/\//.test(t)||t.startsWith("/")?t:$r(t),i=yield fetch(e,{credentials:"same-origin"});if(!i.ok)throw new Error(`HTTP ${i.status}`);return i.json()})}function ci(t){const e=new URLSearchParams({service:"WFS",version:"1.1.0",request:"GetFeature",typeName:t.layerName,outputFormat:"application/json",srsName:"EPSG:4326"});return t.cqlFilter&&e.set("cql_filter",t.cqlFilter),t.maxFeatures&&e.set("maxFeatures",String(t.maxFeatures)),Array.isArray(t.propertyName)&&t.propertyName.length?e.set("propertyName",t.propertyName.join(",")):t.propertyName&&e.set("propertyName",t.propertyName),`${t.url||"/geoserver/ne/wfs"}?${e.toString()}`}function hi(t,e={},i=null,l=null){var S,_,F;const a=((S=t==null?void 0:t.data)==null?void 0:S.type)==="Feature"?t.data:((F=(_=t==null?void 0:t.data)==null?void 0:_.features)==null?void 0:F[0])||(t==null?void 0:t.feature)||null,s=(a==null?void 0:a.properties)||e||{},f=j((a==null?void 0:a.geometry)||s.geometry||s.geom||s.the_geom||s.theGeom||s.wkt||s.shape),g=(a==null?void 0:a.id)||s.id||s.gid||s.objectid||s.OBJECTID||(t==null?void 0:t.name);return{type:"Feature",id:g,properties:s,feature:{type:"Feature",id:g,properties:s,geometry:f},geometry:f,layer:i,lngLat:l}}function fi(t){var l;const e=(l=t==null?void 0:t.data)!=null?l:t;return{type:"FeatureCollection",features:(Array.isArray(e)?e:(e==null?void 0:e.rows)||(e==null?void 0:e.list)||(e==null?void 0:e.records)||(e==null?void 0:e.data)||[]).map((a,s)=>{var f;return{type:"Feature",id:(f=a==null?void 0:a.id)!=null?f:s,properties:lt({},a),geometry:j(a==null?void 0:a.geometry)||me(De(a))}}).filter(a=>a.geometry)}}function De(t={}){return t.wkt||t.WKT||t.geom||t.the_geom||t.theGeom||t.shape||t.Shape}function mi(t,e,i){((t==null?void 0:t.type)==="FeatureCollection"?t.features:(t==null?void 0:t.type)==="Feature"?[t]:[]).filter(a=>a==null?void 0:a.geometry).filter(a=>bi(a.properties||{},e)).map(a=>pi(a,e)).filter(Boolean).forEach(a=>yt(a,e,i))}function pi(t,e){const i=j(t==null?void 0:t.geometry),l=(e==null?void 0:e.clipToHongyuanBoundary)===!0,a=di(e);if(!i||!["Polygon","MultiPolygon"].includes(i.type)||!l&&!a)return t;let s=i.type==="Polygon"?[i.coordinates]:i.coordinates;try{l&&u.length&&(s=Qt.intersection(s,u)),a&&s.length&&(s=Qt.intersection(s,[gi(a)]))}catch(f){return console.warn("[cesium-map] vector layer clipping failed",e==null?void 0:e.key,f),t}return s.length?Lt(lt({},t),{geometry:{type:"MultiPolygon",coordinates:s}}):null}function di(t){if(!(t!=null&&t.clipBounds)||t.clipToLayerBounds===!1)return null;const e=t.clipBounds,i=Math.max(Number(e.west),G.west),l=Math.max(Number(e.south),G.south),a=Math.min(Number(e.east),G.east),s=Math.min(Number(e.north),G.north);return![i,l,a,s].every(Number.isFinite)||i>=a||l>=s?null:{west:i,south:l,east:a,north:s}}function gi(t){return[[[t.west,t.south],[t.east,t.south],[t.east,t.north],[t.west,t.north],[t.west,t.south]]]}function yt(t,e,i,l={}){const a=j(t.geometry);if(!a)return[];const s=wi(e,t.properties||{},l),f=Gt(a,t,e,s);return i.push(...f),f}function Gt(t,e,i,l){const a=window.Cesium,s=[],f=g=>{const S=o.entities.add(g);return S.__hyFeature=e,S.__hyLayer=i,s.push(S),S};if(t.type==="Point"){const g=Y(t.coordinates);return!g||i.hidePointFeatures||i.hidePointMarkers||f({position:a.Cartesian3.fromDegrees(g[0],g[1],8),point:{pixelSize:l.pointSize,color:l.fill,outlineColor:l.stroke,outlineWidth:2,heightReference:a.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY},label:i.showPointLabels?xi(e):void 0}),s}if(t.type==="MultiPoint")return t.coordinates.forEach(g=>s.push(...Gt({type:"Point",coordinates:g},e,i,l))),s;if(t.type==="LineString"){const g=_t(t.coordinates);return g.length<2||f({polyline:{positions:g,width:l.lineWidth,material:new a.PolylineGlowMaterialProperty({glowPower:.16,color:l.stroke}),clampToGround:!0}}),s}if(t.type==="MultiLineString")return t.coordinates.forEach(g=>s.push(...Gt({type:"LineString",coordinates:g},e,i,l))),s;if(t.type==="Polygon"){const g=zt(t.coordinates);return g&&(f({polygon:{hierarchy:g,height:0,heightReference:a.HeightReference.CLAMP_TO_GROUND,perPositionHeight:!1,material:l.fill,outline:!1,classificationType:a.ClassificationType.BOTH}}),yi(t.coordinates,e,i,l,s)),s}return t.type==="MultiPolygon"&&t.coordinates.forEach(g=>s.push(...Gt({type:"Polygon",coordinates:g},e,i,l))),s}function yi(t,e,i,l,a){t.forEach(s=>{const f=_t(s);if(f.length<2)return;const g=o.entities.add({polyline:{positions:f,width:l.lineWidth,material:l.stroke,depthFailMaterial:l.stroke,clampToGround:!0}});g.__hyFeature=e,g.__hyLayer=i,a.push(g)})}function zt(t=[]){const e=window.Cesium,i=_t(t[0]||[]);if(i.length<3)return null;const l=t.slice(1).map(a=>{const s=_t(a);return s.length>=3?new e.PolygonHierarchy(s):null}).filter(Boolean);return new e.PolygonHierarchy(i,l)}function xi(t,e){const i=window.Cesium,l=t.properties||{},a=l.name||l.project_name||l.title||"";if(a)return{text:String(a),font:"600 14px PingFang SC, Microsoft YaHei, sans-serif",fillColor:i.Color.WHITE,outlineColor:i.Color.fromCssColorString("#03121e"),outlineWidth:3,style:i.LabelStyle.FILL_AND_OUTLINE,pixelOffset:new i.Cartesian2(0,-22),heightReference:i.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY,distanceDisplayCondition:new i.DistanceDisplayCondition(0,15e4)}}function wi(t,e,i={}){var C,T,L,H,A,Q,st,et,ht;const l=window.Cesium,a=Si(t,e),s=St(t.opacity,.84),f=i.fillColor||(a==null?void 0:a.fillColor)||t.fillColor||t.color||"#24F6C4",g=i.strokeColor||(a==null?void 0:a.strokeColor)||t.strokeColor||t.color||"#B7FFF2",S=(L=(T=(C=i.fillAlpha)!=null?C:a==null?void 0:a.fillAlpha)!=null?T:t.fillAlpha)!=null?L:Math.min(.34,s*.34),_=(Q=(A=(H=i.strokeAlpha)!=null?H:a==null?void 0:a.strokeAlpha)!=null?A:t.strokeAlpha)!=null?Q:Math.max(.72,s),F=(ht=(et=(st=i.lineWidth)!=null?st:a==null?void 0:a.lineWidth)!=null?et:t.lineWidth)!=null?ht:Math.max(1.6,1.8*Number(c.adminBoundaryLineScale||1));return{fill:We(l,f,S),stroke:We(l,g,_),lineWidth:F,pointSize:i.pointSize||12}}function We(t,e,i){try{return t.Color.fromCssColorString(String(e||"#24F6C4")).withAlpha(St(i,1))}catch(l){return t.Color.CYAN.withAlpha(St(i,1))}}function Si(t,e){var i;return t!=null&&t.activeLegend?t.activeLegend:((t==null?void 0:t.legends)||[]).find(l=>He(e,l))||((i=t==null?void 0:t.legends)==null?void 0:i[0])}function bi(t,e){const i=e==null?void 0:e.activeLegend;return i?He(t,i):!0}function He(t,e={}){return e.match?Ge(t,e.match):Array.isArray(e.matches)?e.matches.some(i=>Ge(t,i)):!0}function Ge(t,e={}){var i,l;return String((i=t==null?void 0:t[e.field])!=null?i:"")===String((l=e.value)!=null?l:"")}function _i(){if(!o)return;V($);const t=window.Cesium,e={stroke:t.Color.fromCssColorString("#B8FFF8").withAlpha(.82),fill:t.Color.TRANSPARENT,lineWidth:1.2,pointSize:0};Ni(xe.features||[]).forEach(i=>{var s;const l=ge(i.points,Jr);if(l.length<2)return;const a=o.entities.add({polyline:{positions:l,width:e.lineWidth,material:e.stroke,depthFailMaterial:e.stroke,clampToGround:!1}});a.__hyBoundaryRole="township",a.__hyTownName=((s=i.townNames)==null?void 0:s[0])||"",$.push(a)}),o.scene.requestRender()}function Ni(t=[]){const e=new Map;t.forEach(l=>{var f;const a=String(((f=l==null?void 0:l.properties)==null?void 0:f.name)||"").trim(),s=j(l==null?void 0:l.geometry);ze(s).forEach(g=>{const S=((g==null?void 0:g[0])||[]).map(Y).filter(Boolean);for(let _=0;_<S.length-1;_+=1){const F=S[_],C=S[_+1];if(!F||!C||je(F,C))continue;const T=Ci(F,C),L=e.get(T)||{points:[F,C],count:0,townNames:new Set};L.count+=1,a&&L.townNames.add(a),e.set(T,L)}})});const i=Array.from(e.values()).map(l=>Lt(lt({},l),{townNames:Array.from(l.townNames)})).filter(l=>l.count>1&&l.townNames.length>1);return Ei(i)}function ze(t){return t!=null&&t.coordinates?t.type==="Polygon"?[t.coordinates]:t.type==="MultiPolygon"?t.coordinates:[]:[]}function Ci(t,e){const i=Ft(t),l=Ft(e);return i<l?`${i}|${l}`:`${l}|${i}`}function Ft(t){return`${Number(t[0]).toFixed(5)},${Number(t[1]).toFixed(5)}`}function je(t,e){return Math.abs(Number(t[0])-Number(e[0]))<1e-10&&Math.abs(Number(t[1])-Number(e[1]))<1e-10}function Ei(t=[]){const e=new Map;t.forEach((a,s)=>{a.points.forEach(f=>{const g=Ft(f),S=e.get(g)||[];S.push(s),e.set(g,S)})});const i=new Set,l=[];return t.forEach((a,s)=>{if(i.has(s))return;i.add(s);const f=[a.points[0],a.points[1]];Ye(f,e,t,i,!0),Ye(f,e,t,i,!1),l.push({points:f,townNames:a.townNames})}),l}function Ye(t,e,i,l,a){for(;t.length;){const s=a?t[0]:t[t.length-1],f=Ft(s),g=(e.get(f)||[]).filter(L=>!l.has(L));if(g.length!==1)return;const S=g[0],_=i[S];l.add(S);const[F,C]=_.points,T=Ft(F)===f?C:F;a?t.unshift(T):t.push(T)}}function Fi(){if(!o||!u.length)return;V(ut);const t=window.Cesium;Pi(t),u.forEach(e=>{const l=(Array.isArray(e==null?void 0:e[0])?e[0]:[]).map(Y).filter(Boolean);if(l.length<3)return;const a=zt(e);if(a){const g=o.entities.add({polygon:{hierarchy:a,material:t.Color.fromCssColorString("#20EAF2").withAlpha(.026),outline:!1,classificationType:t.ClassificationType.BOTH}});ut.push(g)}const s=o.entities.add({polyline:{positions:ge(l,be),width:4.8,material:new t.PolylineGlowMaterialProperty({glowPower:.16,color:t.Color.fromCssColorString("#78FFF7").withAlpha(.48)}),depthFailMaterial:t.Color.fromCssColorString("#78FFF7").withAlpha(.32),clampToGround:!1,zIndex:8}});s.__hyBoundaryRole="county-halo";const f=o.entities.add({polyline:{positions:ge(l,be+80),width:1.9,material:t.Color.fromCssColorString("#F2FFFB").withAlpha(.98),depthFailMaterial:t.Color.fromCssColorString("#F2FFFB").withAlpha(.9),clampToGround:!1,zIndex:9}});f.__hyBoundaryRole="county-outline",ut.push(s,f)}),o.scene.requestRender()}function Pi(t){const e=Ti();let i=[];try{i=Qt.difference([e],u)}catch(l){console.warn("[cesium-map] county outside mask failed",l),i=[e]}i.forEach(l=>{const a=zt(l);if(!a)return;const s=o.entities.add({polygon:{hierarchy:a,material:t.Color.fromCssColorString("#020A10").withAlpha(.52),outline:!1,perPositionHeight:!1,heightReference:t.HeightReference.CLAMP_TO_GROUND,classificationType:t.ClassificationType.BOTH,zIndex:1}});ut.push(s)})}function Ti(){const t=G.west-Wn,e=G.south-Hn,i=G.east+Wn,l=G.north+Hn;return[[[t,e],[i,e],[i,l],[t,l],[t,e]]]}function Ii(t,e=!1){const i=(Array.isArray(t)?t:[t]).map(Rt=>String(Rt||"").trim()).filter(Boolean).slice(0,2),l=`v15-centered-map-badge:${e?"h":"n"}:${i.join("|")}`;if(Et.has(l))return Et.get(l);const a=document.createElement("canvas"),s=a.getContext("2d");if(!s)return{image:"",width:1,height:1};const f=Math.min(4,Math.max(3,window.devicePixelRatio||2)),g="700 14px Microsoft YaHei, PingFang SC, sans-serif",S="700 9px Microsoft YaHei, PingFang SC, sans-serif",_="800 14px Microsoft YaHei, PingFang SC, sans-serif",F="600 9px Microsoft YaHei, PingFang SC, sans-serif",C=Ri(i[1]);s.font=g;const T=Math.ceil(s.measureText(i[0]||"").width);let L=0;C&&(s.font=S,L+=Math.ceil(s.measureText(C.metric).width),s.font=_,L+=Math.ceil(s.measureText(C.value).width),s.font=F,L+=Math.ceil(s.measureText(C.unit).width),L+=C.metric?5:0,L+=C.unit?4:0);const H=Math.min(118,Math.max(C?96:62,T+20,L+20)),A=C?40:25,Q=C?5:0,st=6,et=H+st*2,ht=A+Q+st*2;a.width=Math.ceil(et*f),a.height=Math.ceil(ht*f),a.style.width=`${et}px`,a.style.height=`${ht}px`,s.scale(f,f),s.clearRect(0,0,et,ht);const X=st,rt=st,Nt=rt+A,bt=s.createLinearGradient(X,rt,X,Nt);bt.addColorStop(0,e?"rgba(8, 58, 70, 0.9)":"rgba(6, 45, 57, 0.78)"),bt.addColorStop(.55,e?"rgba(4, 34, 46, 0.88)":"rgba(3, 29, 41, 0.76)"),bt.addColorStop(1,e?"rgba(2, 22, 32, 0.88)":"rgba(2, 18, 29, 0.78)"),s.save(),s.shadowColor="rgba(48, 220, 255, 0.13)",s.shadowBlur=6,s.fillStyle=bt,Ve(s,X,rt,H,A),s.fill(),s.restore(),s.save(),s.globalCompositeOperation="lighter";const Jt=s.createLinearGradient(X,rt,X+H,rt);Jt.addColorStop(0,"rgba(42, 210, 255, 0)"),Jt.addColorStop(.5,e?"rgba(98, 246, 255, 0.34)":"rgba(98, 246, 255, 0.26)"),Jt.addColorStop(1,"rgba(42, 210, 255, 0)"),s.strokeStyle=Jt,s.lineWidth=1,s.beginPath(),s.moveTo(X+10,rt+2),s.lineTo(X+H-10,rt+2),s.stroke(),s.restore(),s.save(),s.strokeStyle=e?"rgba(126, 251, 246, 0.58)":"rgba(126, 251, 246, 0.46)",s.lineWidth=.9,Ve(s,X+.5,rt+.5,H-1,A-1),s.stroke(),s.restore();const Mt=X+H/2;Q>0&&(s.save(),s.shadowColor="rgba(48, 220, 255, 0.2)",s.shadowBlur=5,s.beginPath(),s.moveTo(Mt-5,Nt-1),s.lineTo(Mt+5,Nt-1),s.lineTo(Mt,Nt+Q),s.closePath(),s.fillStyle=e?"rgba(4, 42, 52, 0.98)":"rgba(3, 31, 43, 0.96)",s.fill(),s.strokeStyle=e?"rgba(126, 251, 246, 0.48)":"rgba(126, 251, 246, 0.34)",s.lineWidth=.8,s.stroke(),s.restore()),s.save(),s.textAlign="center",s.textBaseline="alphabetic",s.fillStyle="rgba(255, 255, 255, 0.98)",s.strokeStyle="rgba(0, 8, 14, 0.98)",s.lineJoin="round",s.shadowColor="rgba(0, 8, 14, 0.72)",s.shadowBlur=0,s.font=g,s.lineWidth=1.6;const rr=rt+(C?12.5:A/2);if(jt(s,i[0]||"",Mt,rr),C){const Rt=rt+29.5;let kt=Mt-L/2;s.textAlign="left",s.shadowBlur=0,s.font=S,s.lineWidth=1.2,s.fillStyle="rgba(126, 251, 246, 0.9)",C.metric&&(jt(s,C.metric,kt,Rt,{stroke:!1}),s.font=S,kt+=Math.ceil(s.measureText(C.metric).width)+5),s.font=_,s.lineWidth=1.4,s.fillStyle="#FFFFFF",s.shadowColor="rgba(0, 8, 14, 0.72)",s.shadowBlur=0,jt(s,C.value,kt,Rt),s.shadowBlur=0,kt+=Math.ceil(s.measureText(C.value).width)+(C.unit?4:0),C.unit&&(s.font=F,s.fillStyle="rgba(232, 252, 255, 0.76)",jt(s,C.unit,kt,Rt+1,{stroke:!1}))}s.restore();const xn={image:a.toDataURL("image/png"),width:et,height:ht};return Et.set(l,xn),xn}function jt(t,e,i,l,a={}){const s=t.measureText(e),f=Mi(t.font),g=Number(s.actualBoundingBoxAscent)||f*.74,S=Number(s.actualBoundingBoxDescent)||f*.18,_=l+(g-S)/2;a.stroke!==!1&&t.lineWidth>0&&t.strokeText(e,i,_),t.fillText(e,i,_)}function Mi(t){const e=String(t||"").match(/(\d+(?:\.\d+)?)px/);return e?Number(e[1]):14}function Ri(t){const e=String(t||"").trim();if(!e)return null;const i=e.match(/^(.+?)\s+([+-]?\d[\d,.]*)(.*)$/u);if(i)return{metric:i[1].trim(),value:i[2].trim(),unit:i[3].trim()};const l=e.match(/^(.*?)([+-]?\d[\d,.]*)([\u4e00-\u9fa5A-Za-z/%]+)?$/u);return l?{metric:l[1].trim(),value:l[2].trim(),unit:(l[3]||"").trim()}:{metric:"",value:e,unit:""}}function Ve(t,e,i,l,a){const s=Math.min(7,l*.12,a*.34);t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+l-s,i),t.lineTo(e+l,i+s),t.lineTo(e+l,i+a-s),t.lineTo(e+l-s,i+a),t.lineTo(e+s,i+a),t.lineTo(e,i+a-s),t.lineTo(e,i+s),t.closePath()}function oe(){var f;if(!o)return;V(q);const t=window.Cesium,e=c.mapRanking||{},i=Array.isArray(e.rows)?e.rows:[],l=new Map(i.map(g=>[ct(g.name),g])),a=e.showTownNames!==!1&&e.hideTownNames!==!0,s=(f=e.hideTownLabelStats)!=null?f:c.hideTownLabelStats;a&&bn.forEach(g=>{const S=l.get(ct(g.name)),_=[g.name];if(!s&&S&&e.showMapLabels!==!1){const H=e.metricLabel?`${e.metricLabel} `:"";_.push(`${H}${ir(S.value)}${S.unit||e.unit||""}`)}const F=Y(g.center);if(!F)return;const C=Ii(_,!!S),T=!!(s||_.length===1),L=o.entities.add({position:t.Cartesian3.fromDegrees(F[0],F[1],18),billboard:{image:C.image,width:C.width,height:C.height,scale:1,verticalOrigin:T?t.VerticalOrigin.CENTER:t.VerticalOrigin.BOTTOM,horizontalOrigin:t.HorizontalOrigin.CENTER,pixelOffset:T?new t.Cartesian2(0,0):new t.Cartesian2(0,-4),heightReference:t.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY,scaleByDistance:new t.NearFarScalar(2e4,.94,36e4,.8),distanceDisplayCondition:new t.DistanceDisplayCondition(0,42e4)}});L.__hyTownName=g.name,L.__hyRankingRow=S||null,q.push(L)}),i.filter(g=>wt(g)).forEach(g=>{const S=wt(g),_=o.entities.add({position:t.Cartesian3.fromDegrees(S[0],S[1],16),point:{pixelSize:9,color:t.Color.fromCssColorString("#35F3FF"),outlineColor:t.Color.WHITE,outlineWidth:2,heightReference:t.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY},label:e.showPointMarkers===!1?void 0:{text:String(g.name||""),font:"600 12px PingFang SC, Microsoft YaHei, sans-serif",fillColor:t.Color.WHITE,outlineColor:t.Color.fromCssColorString("#03121e"),outlineWidth:3,style:t.LabelStyle.FILL_AND_OUTLINE,pixelOffset:new t.Cartesian2(0,-18),heightReference:t.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY}});_.__hyTownName=g.name,_.__hyRankingRow=g,q.push(_)}),o.scene.requestRender()}function ki(){if(!o)return;const t=window.Cesium;x=new t.ScreenSpaceEventHandler(o.scene.canvas),x.setInputAction(e=>ft(this,null,function*(){var F,C,T;const i=Li(e.position),l=Ai(i);if(!l)return;const a=t.Cartographic.fromCartesian(l),s={lng:t.Math.toDegrees(a.longitude),lat:t.Math.toDegrees(a.latitude),height:a.height},f=$e(i);if(O){Hi(s);return}p("map-click",{lngLat:s,screen:f,overlayLayer:N.value[0]||null});const g=o.scene.pick(i),S=g==null?void 0:g.id;if(c.enableTownPolygonPick&&(S!=null&&S.__hyTownName)&&ue(S.__hyTownName))return;if(c.enableTownPolygonPick){const L=Oi(s);if(L&&ue((F=L.properties)==null?void 0:F.name))return}const _=Ui(s,f)||S;if(_!=null&&_.__hyFeature){se(_),p("feature-info",{feature:{id:_.__hyFeature.id,properties:_.__hyFeature.properties||{},feature:_.__hyFeature,geometry:_.__hyFeature.geometry||null,layer:_.__hyLayer,lngLat:s},screen:f});return}if(c.enableImageryFeaturePick&&B.length){p("feature-loading",!0);try{const L=o.camera.getPickRay(i),H=yield o.imageryLayers.pickImageryLayerFeatures(L,o.scene),A=H==null?void 0:H[0];if(A){const Q=B.find(Nt=>{var bt;return Nt.imageryProvider===((bt=A.imageryLayer)==null?void 0:bt.imageryProvider)})||B[B.length-1],st=(Q==null?void 0:Q.__hyLayer)||N.value[0],et=A.properties||((C=A.data)==null?void 0:C.properties)||A.data||{},X=hi(A,et,st,s);Je(X)||tt(),p("feature-info",{feature:{id:X.id||et.id||et.fid||A.name,properties:X.properties||et,feature:X.feature||A,geometry:X.geometry||((T=X.feature)==null?void 0:T.geometry)||null,layer:st,lngLat:s},screen:f})}else tt(),p("feature-info",{feature:null,screen:f})}catch(L){tt(),p("feature-info",{feature:null,screen:f})}finally{p("feature-loading",!1)}}}),t.ScreenSpaceEventType.LEFT_CLICK)}function Li(t){var T,L,H,A;if(!t||!((T=o==null?void 0:o.scene)!=null&&T.canvas))return t;const e=window.Cesium,i=o.scene.canvas,l=(L=i.getBoundingClientRect)==null?void 0:L.call(i),a=Number(l==null?void 0:l.width)||0,s=Number(l==null?void 0:l.height)||0,f=Number(i.clientWidth||((H=d.value)==null?void 0:H.clientWidth))||a||1,g=Number(i.clientHeight||((A=d.value)==null?void 0:A.clientHeight))||s||1,S=Number(t.x),_=Number(t.y);if(!Number.isFinite(S)||!Number.isFinite(_)||!a||!s)return t;const F=f/a,C=g/s;return Math.abs(F-1)<.001&&Math.abs(C-1)<.001?t:new e.Cartesian2(S*F,_*C)}function $e(t){var _,F,C,T;if(!t||!((_=o==null?void 0:o.scene)!=null&&_.canvas))return null;const e=o.scene.canvas,i=(F=e.getBoundingClientRect)==null?void 0:F.call(e),l=Number(i==null?void 0:i.width)||0,a=Number(i==null?void 0:i.height)||0,s=Number(e.clientWidth||((C=d.value)==null?void 0:C.clientWidth))||l||1,f=Number(e.clientHeight||((T=d.value)==null?void 0:T.clientHeight))||a||1,g=Number(t.x),S=Number(t.y);return!Number.isFinite(g)||!Number.isFinite(S)||!i?null:{x:(Number(i.left)||0)+g*(l/s),y:(Number(i.top)||0)+S*(a/f)}}function Ai(t){if(!o)return null;const e=o.camera.getPickRay(t);return e?o.scene.globe.pick(e,o.scene):null}function se(t){var e,i,l,a,s;tt(),M=t,t.point&&(t.__hyOriginalPointSize=t.point.pixelSize,t.point.pixelSize=18),(e=t.__hyFeature)!=null&&e.geometry&&["Polygon","MultiPolygon","LineString","MultiLineString"].includes(t.__hyFeature.geometry.type)&&Yt(t.__hyFeature,{townName:t.__hyTownName||((l=(i=t.__hyFeature)==null?void 0:i.properties)==null?void 0:l.name),mode:"feature"}),(s=(a=o==null?void 0:o.scene)==null?void 0:a.requestRender)==null||s.call(a)}function tt(){var t,e;M!=null&&M.point&&M.__hyOriginalPointSize&&(M.point.pixelSize=M.__hyOriginalPointSize),M=null,V(Z),Ue(),(e=(t=o==null?void 0:o.scene)==null?void 0:t.requestRender)==null||e.call(t)}function Yt(t,e={}){var C,T,L,H;if(!o||!(t!=null&&t.geometry))return[];const i=vi({append:e.append===!0});if(!i)return[];const l=window.Cesium,a=e.mode==="town",s=e.highlightTone==="white"||e.mode==="white",f=e.highlightTone==="v21",g=a?"#30DCFF":s?"#FFFFFF":f?"#FFD166":"#FF2D2D",S=a?"#F2FFFF":s?"#FFFFFF":f?"#FFF1B8":"#FF2D2D",_={fill:l.Color.fromCssColorString(g).withAlpha((C=e.fillAlpha)!=null?C:a?.16:s?.035:f?.2:.16),stroke:l.Color.fromCssColorString(S).withAlpha((T=e.strokeAlpha)!=null?T:s?.9:.98),lineWidth:(L=e.lineWidth)!=null?L:a?4.2:s?3.8:f?4.4:5.2,pointSize:a?0:(H=e.pointSize)!=null?H:14},F=Ze(t.geometry,t,i.entities,_);return F.forEach(A=>{var Q;A.__hyFeature=null,A.__hyLayer=null,A.__hyTownName=e.townName||((Q=t.properties)==null?void 0:Q.name)||"",A.__hySelectedOverlay=!0}),Z.push(...F),qe(i),F}function vi(t={}){return!o||!window.Cesium?null:(t.append&&W||(Ue(),W=new window.Cesium.CustomDataSource("selected-feature-overlay"),o.dataSources.add(W),qe(W)),W)}function Ue(){var e,i;if(!(o!=null&&o.dataSources)){W=null;return}Array.from(new Set([W,...((i=(e=o.dataSources).getByName)==null?void 0:i.call(e,"selected-feature-overlay"))||[]].filter(Boolean))).forEach(l=>{try{o.dataSources.remove(l,!0)}catch(a){console.warn("[cesium-map] remove selected overlay failed",a)}}),W=null,Z=[]}function qe(t){var e,i;if(!(!(o!=null&&o.dataSources)||!t))try{if(o.dataSources.raiseToTop){o.dataSources.raiseToTop(t);return}for(;((i=(e=o.dataSources).indexOf)==null?void 0:i.call(e,t))<o.dataSources.length-1;)o.dataSources.raise(t)}catch(l){console.warn("[cesium-map] raise selected overlay failed",l)}}function Ze(t,e,i,l){const a=window.Cesium,s=[];if(!t||!i)return s;const f=g=>{const S=i.add(g);return S.__hyFeature=e,s.push(S),S};if(t.type==="Point"){const g=Y(t.coordinates);return!g||l.pointSize<=0||f({position:a.Cartesian3.fromDegrees(g[0],g[1]),point:{show:!0,color:l.fill,pixelSize:l.pointSize,outlineColor:l.stroke,outlineWidth:3,heightReference:a.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),s}return t.type==="MultiPoint"?(t.coordinates.forEach(g=>{s.push(...Ze({type:"Point",coordinates:g},e,i,l))}),s):t.type==="LineString"?(le(t.coordinates,e,i,l,s),s):t.type==="MultiLineString"?(t.coordinates.forEach(g=>{le(g,e,i,l,s)}),s):t.type==="Polygon"?(Xe(t.coordinates,e,i,l,s),s):(t.type==="MultiPolygon"&&t.coordinates.forEach(g=>{Xe(g,e,i,l,s)}),s)}function Xe(t,e,i,l,a){const s=window.Cesium,f=zt(t);if(!f)return;const g=i.add({polygon:{hierarchy:f,height:0,heightReference:s.HeightReference.CLAMP_TO_GROUND,perPositionHeight:!1,clampToGround:!0,material:l.fill,outline:!1,classificationType:s.ClassificationType.BOTH,zIndex:999}});g.__hyFeature=e,a.push(g),t.forEach(S=>le(S,e,i,l,a))}function le(t,e,i,l,a){const s=window.Cesium,f=_t(t);if(f.length<2)return;const g=i.add({polyline:{positions:f,width:l.lineWidth,material:l.stroke,depthFailMaterial:l.stroke,heightReference:s.HeightReference.CLAMP_TO_GROUND,clampToGround:!0,classificationType:s.ClassificationType.BOTH,zIndex:1e3}});g.__hyFeature=e,a.push(g)}function Je(t,e={}){var s,f,g,S,_;if(!o||!t)return!1;const i=t.properties||((s=t.feature)==null?void 0:s.properties)||(typeof t=="object"?t:{}),l=j(t.geometry||((f=t.feature)==null?void 0:f.geometry)||i.geometry||i.geom||i.wkt||t);if(!l)return!1;tt();const a={type:"Feature",id:t.id||((g=t.feature)==null?void 0:g.id)||i.id,properties:i,geometry:l};return Yt(a,lt({mode:"feature"},e)),(_=(S=o==null?void 0:o.scene)==null?void 0:S.requestRender)==null||_.call(S),Z.length>0}function Bi(t){const e=ct(t);return e&&(xe.features||[]).find(i=>{var l;return ct((l=i==null?void 0:i.properties)==null?void 0:l.name)===e})||null}function ae(){var t,e;return((t=c.mapRanking)==null?void 0:t.scope)==="town"&&Array.isArray((e=c.mapRanking)==null?void 0:e.rows)&&c.mapRanking.rows.length>0}function Ke(t){var i;if(!ae())return!1;const e=ct(t);return(((i=c.mapRanking)==null?void 0:i.rows)||[]).some(l=>ct(l.name)===e)}function Oi(t){return ae()&&(xe.features||[]).find(e=>{var l;const i=(l=e==null?void 0:e.properties)==null?void 0:l.name;return Ke(i)&&cn(t,j(e==null?void 0:e.geometry))})||null}function ue(t,e={}){var l,a,s,f;if(!ae()||!Ke(t))return!1;const i=Bi(t);return i?(tt(),Yt(i,{mode:"town",townName:((l=i.properties)==null?void 0:l.name)||t}),e.emitFeatureInfo!==!1&&p("feature-info",{feature:null}),e.emitStatus!==!1&&p("layer-status",{type:"success",text:`已选中${((a=i.properties)==null?void 0:a.name)||t}`}),(f=(s=o==null?void 0:o.scene)==null?void 0:s.requestRender)==null||f.call(s),!0):!1}function Qe(t,e={}){const i=bn.find(a=>ct(a.name)===ct(t)),l=Y(i==null?void 0:i.center);return l?(e.select&&ue(t,{emitFeatureInfo:!1,emitStatus:!1}),ln(l,42e3),{screen:xt(l)}):null}function tn(t={}){var f,g;const e=qi(t),i=$i(S=>Zi(S,e));if(!i.length)return null;const l=Xi(i),a=Ji(l);tt(),M=i[0],M!=null&&M.point&&(M.__hyOriginalPointSize=M.point.pixelSize,M.point.pixelSize=18),a.forEach((S,_)=>{Yt(S,{mode:"feature",highlightTone:e.highlightTone,append:_>0})});const s=ye(l);return s?$t(s,.9):o.flyTo(i[0],{duration:.9,offset:Tt(18e3)}),(g=(f=o==null?void 0:o.scene)==null?void 0:f.requestRender)==null||g.call(f),{entity:i[0],entities:i,feature:l[0]||i[0].__hyFeature,features:l,highlightFeatures:a,screen:Vt(a.length?a:l)}}function en(t={}){const e=wt(t);let i=fe(l=>Ut(l,t));return i?(se(i),o.flyTo(i,{duration:.9,offset:Tt(16e3)})):e&&ln(e,16e3),{feature:(i==null?void 0:i.__hyFeature)||null,screen:ce(t)}}function nn(t={}){const e=fe(i=>Ut(i,t));return e?(se(e),o.flyTo(e,{duration:.9,offset:Tt(18e3)}),{feature:e.__hyFeature,screen:Pt(e.__hyFeature)}):null}function Pt(t){var i;const e=nr(j((t==null?void 0:t.geometry)||((i=t==null?void 0:t.feature)==null?void 0:i.geometry)));return e?xt(e):null}function rn(t){return Vt([t])||Pt(t)}function Vt(t=[]){const e=[];if((Array.isArray(t)?t:[t]).forEach(a=>{var S,_;const s=(a==null?void 0:a.properties)||((S=a==null?void 0:a.feature)==null?void 0:S.properties)||{},f=j((a==null?void 0:a.geometry)||((_=a==null?void 0:a.feature)==null?void 0:_.geometry)||s.geometry||s.geom||s.wkt||s.geo||s.the_geom||s.geometryWkt||s.geometry_wkt||s.shape);if(!f){const F=Pt(a);F&&e.push(F);return}const g=[];Xt(f.coordinates,g),e.push(...g.map(xt).filter(Boolean))}),!e.length)return null;const i=e.map(a=>Number(a.x)).filter(Number.isFinite),l=e.map(a=>Number(a.y)).filter(Number.isFinite);return!i.length||!l.length?null:{x:(Math.min(...i)+Math.max(...i))/2,y:Math.min(...l)}}function ce(t={}){var a,s;const e=wt(t);if(e)return xt(e);const i=fe(f=>Ut(f,t)),l=(s=(a=i==null?void 0:i.position)==null?void 0:a.getValue)==null?void 0:s.call(a,window.Cesium.JulianDate.now());return l?toLogicalScreen(window.Cesium.SceneTransforms.wgs84ToWindowCoordinates(o.scene,l)):null}function on(t={}){var f,g;sn();const e=Ki(t.grasslands||t),i=t.highlightTone==="white",l=i?null:{fillColor:"#FF3B30",strokeColor:"#FF3B30",fillAlpha:.1,strokeAlpha:.68,lineWidth:12},a=i?{fillColor:"#F7FFFF",strokeColor:"#F7FFFF",fillAlpha:.025,strokeAlpha:.9,lineWidth:3.8}:{fillColor:"#FF2D2D",strokeColor:"#FFE1E1",fillAlpha:.3,strokeAlpha:1,lineWidth:6.2};t.locateOnly||(e.forEach(S=>{l&&yt(S,{key:"pasture-focus-glow",name:t.name||"牧场高亮"},z,l),yt(S,{key:"pasture-focus",name:t.name||"牧场高亮"},z,a)}),(Array.isArray(t.yakMarks)?t.yakMarks:[]).forEach((S,_)=>{const F=wt(S);F&&yt({type:"Feature",id:S.id||_,properties:lt({},S),geometry:{type:"Point",coordinates:F}},{key:"pasture-focus-yak",name:"牦牛识别"},z,{fillColor:"#FFCB45",strokeColor:"#FFF4B8",pointSize:11})}));const s=ye(e);return s&&$t(s,.9),(g=(f=o==null?void 0:o.scene)==null?void 0:f.requestRender)==null||g.call(f),!!e.length}function sn(){var t,e;V(z),(e=(t=o==null?void 0:o.scene)==null?void 0:t.requestRender)==null||e.call(t)}function Di(){tt()}function Wi(t){O=!!t,O||(k=[]),he(),p("draw-boundary",{status:O?"drawing":"clear",pointCount:k.length,points:k})}function Hi(t){k.push([t.lng,t.lat]),he(),p("draw-boundary",{status:"drawing",pointCount:k.length,points:k})}function Gi(){k.pop(),he(),p("draw-boundary",{status:"drawing",pointCount:k.length,points:k})}function zi(){if(k.length<3)return null;const t=ke(),e=[...k,k[0]],i={type:"Feature",properties:{source:"drawn"},geometry:{type:"Polygon",coordinates:[e]}};return O=!1,k=[],V(U),yt(i,{key:"analysis-boundary",name:"分析边界"},U,{fillColor:"#24F6C4",strokeColor:"#B7FFF2",fillAlpha:.12,strokeAlpha:1,lineWidth:3}),p("draw-boundary",{status:"complete",pointCount:0,points:[],feature:i}),Wt(t),Le(t),i}function ji(){var t,e;O=!1,k=[],V(U),V(it),p("draw-boundary",{status:"clear",pointCount:0,points:[]}),(e=(t=o==null?void 0:o.scene)==null?void 0:t.requestRender)==null||e.call(t)}function he(){if(!o)return;const t=window.Cesium;V(U),k.forEach(e=>{U.push(o.entities.add({position:t.Cartesian3.fromDegrees(e[0],e[1],12),point:{pixelSize:10,color:t.Color.fromCssColorString("#24F6C4"),outlineColor:t.Color.WHITE,outlineWidth:2,heightReference:t.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY}}))}),k.length>1&&U.push(o.entities.add({polyline:{positions:_t(k),width:3,material:t.Color.fromCssColorString("#24F6C4"),clampToGround:!0}})),o.scene.requestRender()}function Yi(t={}){var a,s,f,g,S,_,F;const e=((a=t.boundary)==null?void 0:a.type)==="Feature"||(s=t.boundary)!=null&&s.geometry?t.boundary:null,i=t.preserveView===!0||((f=e==null?void 0:e.properties)==null?void 0:f.source)==="drawn",l=i?ke():null;if(i&&((S=(g=o==null?void 0:o.camera)==null?void 0:g.cancelFlight)==null||S.call(g)),V(it),e&&yt(e,{key:"analysis-result-boundary"},it,{fillColor:"#24F6C4",strokeColor:"#B7FFF2",fillAlpha:.1,lineWidth:3}),(Array.isArray(t.matches)?t.matches:[]).forEach(C=>{const T=(C==null?void 0:C.type)==="Feature"?C:(C==null?void 0:C.feature)||null;T&&yt(T,{key:"analysis-result-feature"},it,{fillColor:"#30DCFF",strokeColor:"#C9FBFF",fillAlpha:.1,lineWidth:2.6})}),i)Wt(l),Le(l);else{const C=[e,...t.matches||[]].filter(Boolean),T=ye(C);T&&$t(T,.9)}(F=(_=o==null?void 0:o.scene)==null?void 0:_.requestRender)==null||F.call(_)}function ln(t,e=22e3,i=.9){if(!o||!t)return;const l=window.Cesium,a=l.Cartesian3.fromDegrees(t[0],t[1],3600);o.camera.flyToBoundingSphere(new l.BoundingSphere(a,1),{offset:Tt(e),duration:i})}function $t(t,e=.9){if(!o||!t)return;const i=window.Cesium,l=[(Number(t.west)+Number(t.east))/2,(Number(t.south)+Number(t.north))/2];if(!l.every(Number.isFinite))return;const a=Math.max(Math.abs(Number(t.east)-Number(t.west)),Math.abs(Number(t.north)-Number(t.south))),s=Math.max(18e3,Math.min(16e4,a*135e3)),f=i.Cartesian3.fromDegrees(l[0],l[1],2600);o.camera.flyToBoundingSphere(new i.BoundingSphere(f,1),{offset:Tt(s),duration:e})}function Vi(t){if(!o||!t)return;const e=t.mapView||(t.cameraPosition?{cameraPosition:t.cameraPosition}:null);if(!e)return;const i=window.Cesium,l=Number.isFinite(Number(e.duration))?Number(e.duration):.9,a=Y(e.targetLngLat);if(a){const s=ve(c.initialZoom),f=Number.isFinite(Number(e.distanceScale))?Number(e.distanceScale):1,g=Math.max(18e3,Math.min(56e4,s*f)),S=Number.isFinite(Number(e.targetHeight))?Number(e.targetHeight):2600,_=Number.isFinite(Number(e.heading))?Number(e.heading):On,F=Number.isFinite(Number(e.pitch))?Number(e.pitch):Dn,C=i.Cartesian3.fromDegrees(a[0],a[1],S);o.camera.flyToBoundingSphere(new i.BoundingSphere(C,1),{offset:new i.HeadingPitchRange(i.Math.toRadians(_),i.Math.toRadians(F),g),duration:l});return}e.bounds&&$t(e.bounds,l)}function Tt(t){const e=window.Cesium;return new e.HeadingPitchRange(e.Math.toRadians(On),e.Math.toRadians(Dn),t)}function xt(t){if(!o||!t)return null;const e=window.Cesium,i=e.Cartesian3.fromDegrees(t[0],t[1],16);return $e(e.SceneTransforms.wgs84ToWindowCoordinates(o.scene,i))}function fe(t){return[...D,...z].find(e=>e.__hyFeature&&t(e.__hyFeature))||null}function $i(t){return[...D,...z].filter(e=>e.__hyFeature&&t(e.__hyFeature))}function Ui(t,e){if(!Number.isFinite(t==null?void 0:t.lng)||!Number.isFinite(t==null?void 0:t.lat))return null;const i=an(D),l=i.map(s=>{var f;return{entity:s,geometry:j((f=s.__hyFeature)==null?void 0:f.geometry)}}).filter(s=>s.geometry&&cn(t,s.geometry)).sort((s,f)=>hn(s.geometry)-hn(f.geometry));if(l.length)return l[0].entity;const a=i.map(s=>{var f;return{entity:s,distance:Qi(j((f=s.__hyFeature)==null?void 0:f.geometry),e)}}).filter(s=>Number.isFinite(s.distance)).sort((s,f)=>s.distance-f.distance)[0];return(a==null?void 0:a.distance)<=18?a.entity:null}function Ut(t,e={}){const i=(t==null?void 0:t.properties)||{},l=[e.id,e.key,e.featureId,e.projectId].filter(_=>_!=null&&_!=="").map(String),a=[t.id,i.id,i.key,i.feature_id,i.project_id].filter(_=>_!=null&&_!=="").map(String);if(l.some(_=>a.includes(_)))return!0;const s=[e.name,e.fullName,e.projectName].filter(Boolean).map(String),f=[i.name,i.fullName,i.project_name,i.projectName].filter(Boolean).map(String);if(s.some(_=>f.includes(_)))return!0;const g=wt(e),S=wt(Lt(lt({},i),{geometry:t.geometry}));return!!(g&&S&&Math.abs(g[0]-S[0])<2e-5&&Math.abs(g[1]-S[1])<2e-5)}function qi(t={}){return t&&typeof t=="object"?t:{name:t,projectName:t,project_name:t}}function Zi(t,e={}){if(Ut(t,e))return!0;const i=(t==null?void 0:t.properties)||{},l=qt([e.id,e.key,e.featureId,e.projectId,e.project_id]),a=qt([t==null?void 0:t.id,i.id,i.key,i.feature_id,i.project_id,i.gid]);if(l.some(g=>a.includes(g)))return!0;const s=qt([e.name,e.fullName,e.projectName,e.project_name,e.title]),f=qt([i.name,i.fullName,i.project_name,i.projectName,i.title]);return s.some(g=>f.includes(g))}function qt(t=[]){const e=[];return t.forEach(i=>{if(i==null||i==="")return;const l=String(i).trim();if(!l)return;e.push(l);const a=l.replace(/\s+/g,"");a&&a!==l&&e.push(a)}),Array.from(new Set(e))}function an(t=[]){const e=new Set;return t.filter(i=>{const l=i==null?void 0:i.__hyFeature;return!l||e.has(l)?!1:(e.add(l),!0)})}function Xi(t=[]){return an(t).map(e=>e.__hyFeature).filter(Boolean)}function Ji(t=[]){const e=t.filter(l=>{var s;const a=String(((s=j(l==null?void 0:l.geometry))==null?void 0:s.type)||"");return a.includes("Polygon")||a.includes("LineString")}),i=e.filter(l=>{var a;return((a=l==null?void 0:l.properties)==null?void 0:a.feature_role)==="工程范围"});return i.length?i:e}function Ki(t){return(Array.isArray(t)?t:(t==null?void 0:t.grasslands)||(t==null?void 0:t.features)||(t==null?void 0:t.rows)||(t==null?void 0:t.list)||(t?[t]:[])).map((i,l)=>{var s,f;if((i==null?void 0:i.type)==="Feature")return i;const a=j(i==null?void 0:i.geometry)||me(De(i));return a?{type:"Feature",id:(f=(s=i==null?void 0:i.id)!=null?s:i==null?void 0:i.grasslandId)!=null?f:l,properties:lt({},i),geometry:a}:null}).filter(Boolean)}function j(t){if(!t)return null;if(t.type==="Feature")return j(t.geometry);if(t.type&&Array.isArray(t.coordinates))return t;if(typeof t=="string"){const e=t.trim();if(!e)return null;if(e.startsWith("{")||e.startsWith("["))try{return j(JSON.parse(e))}catch(i){return null}return me(e)}return null}function me(t){const i=String(t||"").trim().replace(/^SRID=\d+;/i,"").match(/^([A-Z]+)(?:\s+[A-Z]+)?\s*(\(.+\))$/i);if(!i)return null;const l=i[1].toUpperCase(),a=i[2];return l==="POINT"?{type:"Point",coordinates:pe(a)}:l==="MULTIPOINT"?{type:"MultiPoint",coordinates:Zt(a).map(pe).filter(Boolean)}:l==="LINESTRING"?{type:"LineString",coordinates:de(a)}:l==="MULTILINESTRING"?{type:"MultiLineString",coordinates:Zt(a).map(de).filter(s=>s.length)}:l==="POLYGON"?{type:"Polygon",coordinates:un(a)}:l==="MULTIPOLYGON"?{type:"MultiPolygon",coordinates:Zt(a).map(un).filter(s=>s.length)}:null}function pe(t){const e=String(t||"").replace(/^\(+|\)+$/g,"").trim().split(/\s+/).slice(0,2).map(Number);return e.length===2&&e.every(Number.isFinite)?e:null}function de(t){return String(t||"").replace(/^\(+|\)+$/g,"").split(",").map(pe).filter(Boolean)}function un(t){return Zt(t).map(de).filter(e=>e.length>=3)}function Zt(t){const e=String(t||"").trim(),i=e.startsWith("(")&&e.endsWith(")")?e.slice(1,-1):e,l=[];let a=0,s=-1;return Array.from(i).forEach((f,g)=>{f==="("?(a===0&&(s=g),a+=1):f===")"&&(a-=1,a===0&&s>=0&&(l.push(i.slice(s,g+1)),s=-1))}),l.length?l:[i]}function _t(t=[]){const e=window.Cesium;return t.map(Y).filter(Boolean).map(i=>e.Cartesian3.fromDegrees(i[0],i[1],8))}function ge(t=[],e=be){const i=window.Cesium;return t.map(Y).filter(Boolean).map(l=>i.Cartesian3.fromDegrees(l[0],l[1],e))}function Y(t){if(!Array.isArray(t)||t.length<2)return null;const e=Number(t[0]),i=Number(t[1]);return Number.isFinite(e)&&Number.isFinite(i)?[e,i]:null}function wt(t={}){const e=j(t.geometry);return(e==null?void 0:e.type)==="Point"?Y(e.coordinates):[[t.longitude,t.latitude],[t.lng,t.lat],[t.lon,t.lat],[t.x,t.y],t.point,t.center,t.centroid,t.coordinates].map(Y).find(Boolean)||null}function cn(t,e){return!t||!(e!=null&&e.coordinates)?!1:e.type==="Polygon"?dn(t,e.coordinates):e.type==="MultiPolygon"?e.coordinates.some(i=>dn(t,i)):!1}function hn(t){return t!=null&&t.coordinates?t.type==="Polygon"?fn(t.coordinates):t.type==="MultiPolygon"?t.coordinates.reduce((e,i)=>e+fn(i),0):Number.POSITIVE_INFINITY:Number.POSITIVE_INFINITY}function fn(t=[]){const e=t[0]||[];if(e.length<3)return Number.POSITIVE_INFINITY;let i=0;for(let l=0;l<e.length;l+=1){const a=e[l],s=e[(l+1)%e.length];i+=Number((a==null?void 0:a[0])||0)*Number((s==null?void 0:s[1])||0)-Number((s==null?void 0:s[0])||0)*Number((a==null?void 0:a[1])||0)}return Math.abs(i)}function Qi(t,e){return!(t!=null&&t.coordinates)||!e?Number.POSITIVE_INFINITY:t.type==="Point"?mn(t.coordinates,e):t.type==="MultiPoint"?Math.min(...t.coordinates.map(i=>mn(i,e))):t.type==="LineString"?pn(t.coordinates,e):t.type==="MultiLineString"?Math.min(...t.coordinates.map(i=>pn(i,e))):Number.POSITIVE_INFINITY}function mn(t,e){const i=xt(Y(t));return i?Math.hypot(Number(i.x)-Number(e.x),Number(i.y)-Number(e.y)):Number.POSITIVE_INFINITY}function pn(t=[],e){if(!Array.isArray(t)||t.length<2)return Number.POSITIVE_INFINITY;let i=Number.POSITIVE_INFINITY;for(let l=1;l<t.length;l+=1){const a=xt(Y(t[l-1])),s=xt(Y(t[l]));!a||!s||(i=Math.min(i,tr(e,a,s)))}return i}function tr(t,e,i){const l=Number(e.x),a=Number(e.y),s=Number(i.x)-l,f=Number(i.y)-a;if(![l,a,s,f].every(Number.isFinite))return Number.POSITIVE_INFINITY;if(!s&&!f)return Math.hypot(Number(t.x)-l,Number(t.y)-a);const g=Math.max(0,Math.min(1,((Number(t.x)-l)*s+(Number(t.y)-a)*f)/(s*s+f*f)));return Math.hypot(Number(t.x)-(l+g*s),Number(t.y)-(a+g*f))}function dn(t,e=[]){return!e.length||!gn(t,e[0])?!1:!e.slice(1).some(i=>gn(t,i))}function gn(t,e=[]){if(e.length<3)return!1;const i=Number(t.lng),l=Number(t.lat);if(!Number.isFinite(i)||!Number.isFinite(l))return!1;let a=!1;for(let s=0,f=e.length-1;s<e.length;f=s++){const g=e[s],S=e[f],_=Number(g==null?void 0:g[0]),F=Number(g==null?void 0:g[1]),C=Number(S==null?void 0:S[0]),T=Number(S==null?void 0:S[1]);if(![_,F,C,T].every(Number.isFinite))continue;if(er(i,l,_,F,C,T))return!0;F>l!=T>l&&i<(C-_)*(l-F)/(T-F)+_&&(a=!a)}return a}function er(t,e,i,l,a,s){const f=(t-i)*(s-l)-(e-l)*(a-i);return Math.abs(f)>1e-10?!1:(t-i)*(t-a)+(e-l)*(e-s)<=1e-10}function nr(t){if(!t)return null;if(t.type==="Point")return Y(t.coordinates);const e=[];return Xt(t.coordinates,e),e.length?[e.reduce((i,l)=>i+l[0],0)/e.length,e.reduce((i,l)=>i+l[1],0)/e.length]:null}function Xt(t,e){const i=Y(t);if(i&&!Array.isArray(t[0])){e.push(i);return}Array.isArray(t)&&t.forEach(l=>Xt(l,e))}function ye(t=[]){const e=[];if(t.forEach(f=>{var S;const g=j((f==null?void 0:f.geometry)||((S=f==null?void 0:f.feature)==null?void 0:S.geometry)||f);g&&Xt(g.coordinates,e)}),!e.length)return null;const i=e.map(f=>f[0]),l=e.map(f=>f[1]),a=Math.max(.006,(Math.max(...i)-Math.min(...i))*.18),s=Math.max(.006,(Math.max(...l)-Math.min(...l))*.18);return{west:Math.max(G.west,Math.min(...i)-a),south:Math.max(G.south,Math.min(...l)-s),east:Math.min(G.east,Math.max(...i)+a),north:Math.min(G.north,Math.max(...l)+s)}}function V(t){if(!o){t.length=0;return}t.splice(0).forEach(e=>o.entities.remove(e))}function yn(){B.splice(0).forEach(t=>{var e,i;return(i=(e=o==null?void 0:o.imageryLayers)==null?void 0:e.remove)==null?void 0:i.call(e,t,!0)}),V(D),tt()}function It(){var t,e,i;I+=1,(t=b==null?void 0:b.disconnect)==null||t.call(b),b=null,P==null||P(),P=null,E==null||E(),E=null,(e=x==null?void 0:x.destroy)==null||e.call(x),x=null,yn(),V(ie),V(ut),V($),V(q),V(z),V(U),V(it),o&&!((i=o.isDestroyed)!=null&&i.call(o))&&o.destroy(),o=null,v=null,w.value=null,y.value&&y.value.replaceChildren()}function St(t,e=1){const i=Number(t);return Number.isFinite(i)?Math.max(0,Math.min(1,i)):e}function ct(t){return String(t||"").trim().replace(/(镇|乡)$/,"")}function ir(t){const e=Number(t);return Number.isFinite(e)?Number.isInteger(e)?String(e):String(Number(e.toFixed(2))):"--"}return n({loadMap:Zn,hasMap:Xn,play:Jn,resume:Re,pause:Kn,refreshView:Dt,resetView:Qn,destroyMap:It,highlightFeature:Je,clearSelectedFeature:tt,clearFloatingOverlays:Di,focusProject:tn,focusPasture:on,clearPastureFocus:sn,focusTown:Qe,focusYakIndustryPoint:en,focusVectorFeature:nn,getVectorFeatureAnchorScreen:rn,getVectorFeaturesAnchorScreen:Vt,getVectorFeatureScreen:Pt,getYakIndustryPointScreen:ce,setBoundaryDrawing:Wi,finishBoundaryDrawing:zi,undoBoundaryPoint:Gi,clearAnalysisBoundary:ji,showAnalysisResult:Yi,canvasMap:w}),(t,e)=>(pr(),dr("div",{ref_key:"containerRef",ref:d,class:"cesium-map"},[gr("div",{ref_key:"viewerRef",ref:y,class:"cesium-map__viewer"},null,512)],512))}},oo=cr(Kr,[["__scopeId","data-v-8d7881df"]]);export{ro as C,io as H,oo as M,Vr as a,$r as g};