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-5ec89bde-178437865139...

116 lines
261 KiB

var Tl=Object.defineProperty,Sl=Object.defineProperties;var Ml=Object.getOwnPropertyDescriptors;var Ka=Object.getOwnPropertySymbols;var hr=Object.prototype.hasOwnProperty,pr=Object.prototype.propertyIsEnumerable;var pa=Math.pow,dr=(b,e,t)=>e in b?Tl(b,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):b[e]=t,I=(b,e)=>{for(var t in e||(e={}))hr.call(e,t)&&dr(b,t,e[t]);if(Ka)for(var t of Ka(e))pr.call(e,t)&&dr(b,t,e[t]);return b},V=(b,e)=>Sl(b,Ml(e));var fr=(b,e)=>{var t={};for(var a in b)hr.call(b,a)&&e.indexOf(a)<0&&(t[a]=b[a]);if(b!=null&&Ka)for(var a of Ka(b))e.indexOf(a)<0&&pr.call(b,a)&&(t[a]=b[a]);return t};var he=(b,e,t)=>new Promise((a,i)=>{var s=d=>{try{u(t.next(d))}catch(h){i(h)}},o=d=>{try{u(t.throw(d))}catch(h){i(h)}},u=d=>d.done?a(d.value):Promise.resolve(d.value).then(s,o);u((t=t.apply(b,e)).next())});import{q as Qr,h as es,w as qt,o as x,c as A,a as f,d as $,L as kl,A as jt,g as k,M as $e,s as tt,v as Pl,C as Za,u as Y,j as Le,n as Ve,t as P,F as te,y as pe,b as j,x as se,K as Ct,B as Wt,e as Xa,H as Jt,f as Ja,O as fa}from"./index-1784378651390.js";import{H as Pe}from"./index.esm.min-6b4ee6a0-1784378651390.js";import{_ as oe}from"./index-8193533d-1784378651390.js";import{t as Jn,S as ra,u as ln,v as La,w as Cl,V as ie,F as Fl,C as vt,G as Te,c as xl,d as Nl,f as Rl,g as jn,L as Qt,D as Ie,a as be,h as Qa,R as ot,A as Ge,N as mr,b as qe,P as At,o as ea,n as ta,x as Il,T as Gl,B as _l,i as Al,j as Bl,k as El,l as $l,m as Vl,y as Ol,z as ma,E as gr,H as yr,I as Dl,J as br,q as vr,r as zl,s as wr,K as ga,U as Hn,W as Lr,M as Wl}from"./screen2Standard-f85af2d3-1784378651390.js";import{g as Ht,M as Yl,h as jl,L as Hl,B as ya,a as aa,E as Tr,G as en,D as ql,b as Ul,l as Kl,P as Sr,c as Mr,d as Zl,m as Xl,t as Jl,k as lt,n as Ql,o as kr,p as eu,q as tu,r as qn,s as ba,u as Pr,v as Cr,f as Bt,w as Fr,x as au,e as nu,i as iu,j as ru,y as su}from"./data-b6eb78ac-1784378651390.js";import{g as na}from"./index-e9f36657-1784378651390.js";import{h as ou,a as ts,S as lu,W as Et,H as q,j as Un,k as uu,l as cu,m as du}from"./townshipBoundaries-a3a8b9c1-1784378651390.js";import{b as hu,g as xr,a as Nr,c as pu}from"./geoserver-b3bc784b-1784378651390.js";import{_ as fu}from"./TopicSwitcher-c2a18053-1784378651390.js";import{_ as mu}from"./LayerPanel-e35ca392-1784378651390.js";import{A as gu}from"./assets-a26a4c41-1784378651390.js";import{M as yu}from"./index-ae8926ff-1784378651390.js";import{a as bu,b as vu,c as wu,d as Lu,g as Rr,e as Ir,f as Tu,h as Kn,i as Su,j as Mu,k as ku}from"./yakApi-788472d8-1784378651390.js";import{y as Pu}from"./livestockData-36ec0ae2-1784378651390.js";import"./index-bb11a8b6-1784378651390.js";const Cu=ou.map(b=>I({},b)),Gr=ts.map(b=>I({},b)),Fu=ts.map(b=>{var e,t;return{name:b.name,value:b.value,lng:(e=b.center)==null?void 0:e[0],lat:(t=b.center)==null?void 0:t[1]}}),xu=[{name:"邛溪镇",level:"县城驻地",value:895.94,lng:102.60242339873115,lat:32.83022561372293},{name:"瓦切镇",level:"北部牧区",value:991,lng:102.71535664604494,lat:33.12869670968013},{name:"刷经寺镇",level:"南部通道",value:986.44,lng:102.55651980382184,lat:32.204097908180216},{name:"色地镇",level:"东部片区",value:1199.06,lng:103.12540730227074,lat:33.010462261362875}],sa=256,Qn="https://qkl-map.oss-cn-chengdu.aliyuncs.com/hy-result/{z}/{x}/{y}.png",Nu=900,Ru=10,Ut=new Map,oa={west:101.852492,south:31.851389,east:103.347518,north:33.319796};function Zn(b,e,t){const a=pa(2,t),i=Math.sin(e*Math.PI/180);return{x:(b+180)/360*a,y:(.5-Math.log((1+i)/(1-i))/(4*Math.PI))*a}}function _r(b,e,t){const a=pa(2,t),i=b/a*360-180,s=Math.PI-2*Math.PI*e/a,o=180/Math.PI*Math.atan(.5*(Math.exp(s)-Math.exp(-s)));return[i,o]}function tn(b,e,t){return Math.max(e,Math.min(t,b))}function as(b,e,{centerLngLat:t,maxCols:a,maxRows:i}={}){const s=Zn(b.west,b.north,e),o=Zn(b.east,b.south,e),u=Math.floor(s.x),d=Math.floor(o.x),h=Math.floor(s.y),g=Math.floor(o.y);let m=u,L=d,S=h,C=g,F=Math.floor((u+d)/2),E=Math.floor((h+g)/2);if(t&&Number.isFinite(a)&&Number.isFinite(i)){const D=tn(Number(t[0]),b.west,b.east),J=tn(Number(t[1]),b.south,b.north),re=Zn(D,J,e);F=Math.floor(re.x),E=Math.floor(re.y);const K=Math.max(1,Math.min(Math.floor(a),d-u+1)),G=Math.max(1,Math.min(Math.floor(i),g-h+1));m=tn(F-Math.floor(K/2),u,d-K+1),S=tn(E-Math.floor(G/2),h,g-G+1),L=m+K-1,C=S+G-1}return{zoom:e,minX:m,maxX:L,minY:S,maxY:C,centerX:F,centerY:E,cols:L-m+1,rows:C-S+1}}function Iu({zoom:b=11,centerLngLat:e,maxCols:t,maxRows:a,bounds:i=oa}={}){return as(i,b,{centerLngLat:e,maxCols:t,maxRows:a})}function Gu(b,e){const[t,a]=_r(b.minX,b.minY,b.zoom),[i,s]=_r(b.maxX+1,b.maxY+1,b.zoom),[o]=e([t,oa.south]),[u]=e([i,oa.south]),[,d]=e([oa.west,a]),[,h]=e([oa.west,s]);return{left:o,right:u,bottom:-h,top:-d}}function _u(b,e){const{width:t,height:a}=e;b.save(),b.globalCompositeOperation="multiply",b.fillStyle="rgba(5, 24, 34, 0.22)",b.fillRect(0,0,t,a),b.globalCompositeOperation="screen";const i=b.createRadialGradient(t*.5,a*.48,t*.1,t*.5,a*.5,t*.72);i.addColorStop(0,"rgba(80, 230, 255, 0.16)"),i.addColorStop(1,"rgba(0, 18, 36, 0.03)"),b.fillStyle=i,b.fillRect(0,0,t,a),b.restore()}function Au(b,e){const t=b.createLinearGradient(0,0,e.width,e.height);t.addColorStop(0,"#061927"),t.addColorStop(.5,"#0b2c3c"),t.addColorStop(1,"#07131f"),b.fillStyle=t,b.fillRect(0,0,e.width,e.height)}function Bu(b){const e=Ut.get(b);return e||new Promise(t=>{const a=new Image;a.crossOrigin="anonymous",a.onload=()=>t(a),a.onerror=()=>{Ut.delete(b),t(null)},a.src=b})}function Eu(b){const e=Ut.get(b);if(e)return e;const t=Bu(b);for(Ut.set(b,t);Ut.size>Nu;){const a=Ut.keys().next().value;if(!a)break;Ut.delete(a)}return t}function $u(b,e,t,a=Qn){return String(a||Qn).replace(/\{x\}/g,b).replace(/\{y\}/g,e).replace(/\{z\}/g,t)}function Vu(u,d,h,g){return he(this,arguments,function*(b,e,t,a,{tileUrlTemplate:i,onTileStatus:s,applyTone:o=!0}={}){const m=[],L=a.cols*a.rows;let S=0,C=0;s==null||s({type:"loading",text:`正在加载${a.zoom}级影像底图`,loaded:S,failed:C,total:L,zoom:a.zoom,tileRange:a,tileUrlTemplate:i}),b.save(),b.filter="brightness(0.92) contrast(1.22) saturate(1.06)";for(let K=a.minX;K<=a.maxX;K+=1)for(let G=a.minY;G<=a.maxY;G+=1)m.push({x:K,y:G});m.sort((K,G)=>Math.abs(K.x-a.centerX)+Math.abs(K.y-a.centerY)-(Math.abs(G.x-a.centerX)+Math.abs(G.y-a.centerY)));let F=0;function E(){return he(this,null,function*(){for(;F<m.length;){const K=m[F];F+=1;const G=yield Eu($u(K.x,K.y,a.zoom,i));G?(S+=1,b.drawImage(G,(K.x-a.minX)*sa,(K.y-a.minY)*sa,sa,sa),t.needsUpdate=!0):C+=1,s==null||s({type:"loading",text:`正在加载${a.zoom}级影像底图`,loaded:S,failed:C,total:L,zoom:a.zoom,tileRange:a,tileUrlTemplate:i})}})}yield Promise.all(Array.from({length:Math.min(Ru,m.length)},E)),b.restore(),o&&_u(b,e),t.needsUpdate=!0;const D=L>0?S/L:0,J=S===0?"error":D>=.75?"success":"warning",re=S===L?`${a.zoom}级影像底图已加载`:S>0?`${a.zoom}级影像底图已加载(${S}/${L}张有效瓦片)`:`${a.zoom}级影像底图加载失败`;s==null||s({type:J,text:re,loaded:S,failed:C,total:L,zoom:a.zoom,tileRange:a,tileUrlTemplate:i})})}function Ar({geoProjectionCenter:b,geoProjectionScale:e,zoom:t=11,tileUrlTemplate:a=Qn,onTileStatus:i,centerLngLat:s,maxCols:o,maxRows:u,transparentBackground:d=!1,applyTone:h=!0}={}){const g=as(oa,t,{centerLngLat:s,maxCols:o,maxRows:u}),m=document.createElement("canvas");m.width=g.cols*sa,m.height=g.rows*sa;const L=m.getContext("2d");d?L.clearRect(0,0,m.width,m.height):Au(L,m);const S=new Jn(m);S.colorSpace=ra,S.wrapS=ln,S.wrapT=ln,S.minFilter=La,S.magFilter=La,S.needsUpdate=!0;const C=Ht().center(b).scale(e).translate([0,0]),F=Gu(g,C);return Vu(L,m,S,g,{tileUrlTemplate:a,onTileStatus:i,applyTone:h}).catch(E=>{console.warn("load satellite tiles failed:",E),i==null||i({type:"error",text:`${g.zoom}级影像底图加载失败`,loaded:0,failed:g.cols*g.rows,total:g.cols*g.rows,zoom:g.zoom,tileRange:g,tileUrlTemplate:a})}),{texture:S,uvBounds:F,tileRange:g}}function Br(b,e){const t=e.right-e.left,a=e.top-e.bottom;b.mapGroup.traverse(i=>{var u,d;const s=(d=(u=i.geometry)==null?void 0:u.attributes)==null?void 0:d.position;if(!i.isMesh||!s)return;const o=new Float32Array(s.count*2);for(let h=0;h<s.count;h+=1){const g=s.getX(h),m=s.getY(h);o[h*2]=(g-e.left)/t,o[h*2+1]=(m-e.bottom)/a}i.geometry.setAttribute("uv",new Cl(o,2)),i.geometry.attributes.uv.needsUpdate=!0})}const Ou=new ie(-.17427287762525134,13.678992786206543,20.688611202093714),Du=new ie(0,0,0),zu=new ie(-13.767695123014105,12.990152163077308,39.28228164159694),an=21,Wu=9,Yu=260,ju=12,Hu=700,ia=new Map,Er="#30DCFF",qu="#F2FFFF",Uu="#8BF7FF",$r=3202303,Ku=15925247,Vr=9172991,Or={"family-pasture":"pasture","artificial-grassland":"grass","scale-breeding":"breeding","forage-storage":"storage","slaughter-processing":"processing","farm-equipment":"equipment","social-service":"service"};function Dr(b){return b.sort((e,t)=>t.value-e.value),b}function ut(b){return String(b||"").replace(/\s+/g,"").trim()}function le(b,e=0){const t=Number(b);return Number.isFinite(t)?t:e}function Yt(b,e,t){const a=Number(b);return Number.isFinite(a)?Math.max(e,Math.min(t,a)):e}function Se(b){return String(b!=null?b:"").replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e])}function zr(b){return(b==null?void 0:b.scope)==="village"||(b==null?void 0:b.labelMode)==="village"}function Wr(b){return(b==null?void 0:b.scope)==="trade-flow"||(b==null?void 0:b.labelMode)==="trade-flow"}function Zu(b){return(b==null?void 0:b.showFlowLines)!==!1}function Yr(b){return!!(b!=null&&b.hideTownNames||(b==null?void 0:b.showTownNames)===!1)}function va(b){return!!(b!=null&&b.hideMapLabels||(b==null?void 0:b.showMapLabels)===!1)}function Xu(b){return(b==null?void 0:b.displayMode)==="callout"||(b==null?void 0:b.labelMode)==="callout"}function nn(b){return["wkt-api","geojson","wfs"].includes(String((b==null?void 0:b.sourceType)||"").toLowerCase())}function Ju(b){return(b==null?void 0:b.interactive)===!1||(b==null?void 0:b.key)==="yak-recognition-layer"}function jr(b){return String((b==null?void 0:b.sourceType)||"").toLowerCase()==="wmts"}function Hr(b,e,t){const a=pa(2,t),i=Math.sin(e*Math.PI/180);return{x:(b+180)/360*a,y:(.5-Math.log((1+i)/(1-i))/(4*Math.PI))*a}}function qr(b,e,t){const a=pa(2,t),i=b/a*360-180,s=Math.PI-2*Math.PI*e/a,o=180/Math.PI*Math.atan(.5*(Math.exp(s)-Math.exp(-s)));return[i,o]}function Qu(b,e){const t=Hr(b.west,b.north,e),a=Hr(b.east,b.south,e);return{minX:Math.floor(t.x),maxX:Math.floor(a.x),minY:Math.floor(t.y),maxY:Math.floor(a.y)}}function ec(b,e,t,a){const[i,s]=qr(b,e,t),[o,u]=qr(b+1,e+1,t),d=q.east-q.west,h=q.north-q.south;return{x:(i-q.west)/d*a.width,y:(q.north-s)/h*a.height,width:(o-i)/d*a.width,height:(s-u)/h*a.height}}function tc(b){const e=ia.get(b);if(e)return e;const t=new Promise(a=>{const i=new Image;i.crossOrigin="anonymous",i.onload=()=>a(i),i.onerror=()=>{ia.delete(b),a(null)},i.src=b});for(ia.set(b,t);ia.size>Hu;){const a=ia.keys().next().value;if(!a)break;ia.delete(a)}return t}function Ur(b){return b?/^https?:\/\//.test(b)||b.startsWith("/")?b:`./${b}`:""}function ac(b){if(!b)return null;if(typeof b=="string")try{return JSON.parse(b)}catch(e){return console.warn("地图 GeoJSON 解析失败",e),null}return b}function wa(b){const e=ac(b);return e!=null&&e.features&&e.features.forEach(t=>{var a;((a=t.geometry)==null?void 0:a.type)==="Polygon"&&(t.geometry.coordinates=[t.geometry.coordinates])}),e}function Kr(b){var e,t,a;return b!=null&&b.coordinates?b.type==="Polygon"?Array.isArray((a=(t=(e=b.coordinates)==null?void 0:e[0])==null?void 0:t[0])==null?void 0:a[0])?b.coordinates:[b.coordinates]:b.type==="MultiPolygon"?b.coordinates:[]:[]}class nc extends Yl{constructor(e,t,a={}){var u,d,h,g;super(e),this.geoProjectionCenter=[102.6305459723107,32.72169252326339],this.geoProjectionScale=650,this.tradeGeoProjectionCenter=[104,36],this.tradeGeoProjectionScale=11.4,this.tradeNationalDepth=.24,this.depth=.5,this.clicked=!1,this.scene.fog=new Fl(466735,1,50),this.scene.background=new vt(466735),this.camera.instance.position.copy(zu),this.camera.instance.near=1,this.camera.instance.far=1e4,this.camera.instance.updateProjectionMatrix(),this.defaultMapCameraPosition=Ou.clone(),this.defaultMapTarget=Du.clone(),this.camera.controls.target.copy(this.defaultMapTarget),this.camera.controls.update(),this.activeMapViewTweens=[],this.sceneTweens=[],this.sceneTimers=[],this.interactionManager=new jl(this.renderer.instance,this.camera.instance,this.canvas),this.assets=t,this.callbacks=a,this.useSatelliteBase=a.useSatelliteBase!==!1,this.showNationalBackdrop=a.showNationalBackdrop===!0,this.topicLayerPresentation=a.topicLayerPresentation||"default",this.hideTownLabelStatsByDefault=a.hideTownLabelStats===!0,this.tileUrlTemplate=a.tileUrlTemplate||"",this.usesCustomSatelliteTiles=this.useSatelliteBase&&!!this.tileUrlTemplate;const i=Math.round(Number(a.satelliteTextureZoom));this.satelliteTextureZoom=Number.isFinite(i)&&i>0?Math.min(an,i):lu;const s=Math.round(Number(a.satelliteMaxZoom)),o=Number.isFinite(s)&&s>0?Math.min(an,Math.max(this.satelliteTextureZoom,s)):an;this.adminBoundaryLineScale=this.normalizeAdminBoundaryLineScale(a.adminBoundaryLineScale),this.mapBoundaryEmphasisMaterial=null,this.dynamicSatelliteMaxZoom=o,this.dynamicSatelliteTileWindow=Wu,this.dynamicSatelliteOverlay=null,this.dynamicSatelliteMaterial=null,this.dynamicSatelliteTexture=null,this.dynamicSatelliteCurrentKey="",this.dynamicSatelliteLoadingKey="",this.dynamicSatelliteRequestId=0,this.dynamicSatelliteLastCheck=0,this.topicLayerLoadId=0,this.visibleTopicLayers=[],this.mapAnimationComplete=!1,this.showTownRankingBars=!1,this.showTownRankingPointMarkers=!1,this.currentTownRanking=null,this.villageRankingGroup=null,this.villageRankingLabels=[],this.tradeFlowGroup=null,this.tradeFlowMeshGroup=null,this.tradeFlowLabelGroup=null,this.tradeFlowLabels=[],this.tradeFlowMaterials=[],this.tradeFlowPulseSprites=[],this.isTradeNationalMapActive=!1,this.selectedFeatureGroup=null,this.selectedVectorFeatures=[],this.analysisBoundaryFeature=null,this.analysisMatchedFeatures=[],this.boundaryDrawingEnabled=!1,this.boundaryDrawPoints=[],this.lastBoundaryDrawPoint=null,this.currentVectorFeatures=[],this.yakIndustryPointLabelGroup=null,this.yakIndustryPointLabels=[],this.yakIndustryPointMarkerGroup=null,this.yakIndustryPointMarkers=[],this.yakIndustryMarkerMaterialCache=new Map,this.hongyuanBoundaryPolygons=[],this.townMetaByName=new Map(Gr.map(m=>[ut(m.name),m])),this.staticMapData={china:wa(this.assets.instance.getResource("china")),mapJson:wa(this.assets.instance.getResource("mapJson")),mapStroke:wa(this.assets.instance.getResource("mapStroke"))},this.handleCanvasBoundaryPointerDown=this.handleCanvasBoundaryPointerDown.bind(this),this.handleCanvasBoundaryDoubleClick=this.handleCanvasBoundaryDoubleClick.bind(this),(d=(u=this.canvas)==null?void 0:u.addEventListener)==null||d.call(u,"pointerdown",this.handleCanvasBoundaryPointerDown,!0),(g=(h=this.canvas)==null?void 0:h.addEventListener)==null||g.call(h,"dblclick",this.handleCanvasBoundaryDoubleClick,!0),this.initEnvironment(),this.init()}init(){this.labelGroup=new Te,this.label3d=new Hl(this),this.labelGroup.rotation.x=-Math.PI/2,this.scene.add(this.labelGroup),this.flyLineFocusGroup=new Te,this.flyLineFocusGroup.visible=!1,this.flyLineFocusGroup.rotation.x=-Math.PI/2,this.scene.add(this.flyLineFocusGroup),this.eventElement=[],this.defaultMaterial=null,this.defaultLightMaterial=null,this.createBottomBg(),this.createChinaBlurLine(),this.createGrid(),this.createRotateBorder(),this.createLabel(),this.createMap(),this.createEvent(),this.createFlyLine(),this.createFocus(),this.createParticles(),this.createScatter(),this.createInfoPoint(),this.createStorke();let e=na.timeline({onComplete:()=>{if(this.mapAnimationComplete=!0,this.applyLayerMapView(this.currentTopicLayer,{force:!0}),this.setTradeNationalMapVisible(!1),this.updateYakIndustryPointMarkers(this.currentTopicLayer,this.currentVectorFeatures),this.updateYakIndustryPointLabels(this.currentTopicLayer,this.currentVectorFeatures),va(this.currentTownRanking)){this.hideAllMapStatisticLabels();return}this.updateVillageRankingLabels(this.currentTownRanking),this.updateTradeFlowLayer(this.currentTownRanking),this.updateInfoPointStats()}});e.pause(),this.animateTl=e,e.addLabel("focusMap",1.5),e.addLabel("focusMapOpacity",2),e.addLabel("bar",3),e.to(this.camera.instance.position,{duration:2,x:this.defaultMapCameraPosition.x,y:this.defaultMapCameraPosition.y,z:this.defaultMapCameraPosition.z,ease:"circ.out",onStart:()=>{this.flyLineFocusGroup.visible=!1}}),e.to(this.focusMapGroup.position,{duration:1,x:0,y:0,z:0},"focusMap"),e.to(this.focusMapGroup.scale,{duration:1,x:1,y:1,z:1,ease:"circ.out",onComplete:()=>{if(this.flyLineGroup.visible=!0,this.scatterGroup.visible=!0,this.InfoPointGroup.visible=!va(this.currentTownRanking)&&this.showTownRankingPointMarkers&&this.hasTownRankingRows(),this.setTradeNationalMapVisible(!1),this.updateYakIndustryPointMarkers(this.currentTopicLayer,this.currentVectorFeatures),this.updateYakIndustryPointLabels(this.currentTopicLayer,this.currentVectorFeatures),va(this.currentTownRanking)){this.hideAllMapStatisticLabels();return}this.updateVillageRankingLabels(this.currentTownRanking),this.updateTradeFlowLayer(this.currentTownRanking),this.updateInfoPointStats()}},"focusMap"),e.to(this.focusMapTopMaterial,{duration:1,opacity:this.getFocusMapTopOpacity(),ease:"circ.out"},"focusMapOpacity"),e.to(this.focusMapSideMaterial,{duration:1,opacity:1,ease:"circ.out",onComplete:()=>{this.focusMapSideMaterial.transparent=!1}},"focusMapOpacity"),this.otherLabel.map((a,i)=>{let s=a.element.querySelector(".other-label");e.to(s,{duration:1,delay:.1*i,translateY:0,opacity:1,ease:"circ.out"},"focusMapOpacity")}),e.to(this.mapLineMaterial,{duration:.5,delay:.3,opacity:1},"focusMapOpacity"),this.mapBoundaryEmphasisMaterial&&e.to(this.mapBoundaryEmphasisMaterial,{duration:.5,delay:.3,opacity:this.getAdminBoundaryEmphasisOpacity()},"focusMapOpacity"),e.to(this.rotateBorder1.scale,{delay:.3,duration:1,x:1,y:1,z:1,ease:"circ.out"},"focusMapOpacity"),e.to(this.rotateBorder2.scale,{duration:1,delay:.5,x:1,y:1,z:1,ease:"circ.out",onComplete:()=>{var a,i;this.flyLineFocusGroup.visible=!0,(i=(a=this.callbacks).onPlayComplete)==null||i.call(a)}},"focusMapOpacity"),this.showTownRankingBars&&(this.allBar.map((a,i)=>{e.to(a.scale,{duration:1,delay:.1*i,x:1,y:1,z:1,ease:"circ.out"},"bar")}),this.allBarMaterial.map((a,i)=>{e.to(a,{duration:1,delay:.1*i,opacity:1,ease:"circ.out"},"bar")}));const t=this;this.allProvinceLabel.map((a,i)=>{let s=a.element.querySelector(".provinces-label-wrap"),o=a.element.querySelector(".number .value"),u={progress:0};e.to(s,{duration:1,delay:.2*i,translateY:0,opacity:1,ease:"circ.out"},"bar"),e.to(u,{duration:1,delay:.2*i,progress:1,onStart:()=>{u.progress=0},onUpdate:d},"bar");function d(){var g,m;const h=le((m=(g=a.userData)==null?void 0:g.targetValue)!=null?m:o.dataset.targetValue);o.innerText=t.formatMapRankingValue(h*u.progress)}}),this.showTownRankingBars&&this.allGuangquan.map((a,i)=>{e.to(a.children[0].scale,{duration:1,delay:.1*i,x:1,y:1,z:1,ease:"circ.out"},"bar"),e.to(a.children[1].scale,{duration:1,delay:.1*i,x:1,y:1,z:1,ease:"circ.out"},"bar")})}initEnvironment(){let e=new xl(13171711,4.2);this.scene.add(e);let t=new Nl(14679295,5.8);t.position.set(-30,6,-8),t.castShadow=!0,t.shadow.radius=20,t.shadow.mapSize.width=1024,t.shadow.mapSize.height=1024,this.scene.add(t),this.createPointLight({color:"#1fd6df",intensity:680,distance:1e4,x:-9,y:3,z:-3}),this.createPointLight({color:"#2af0c6",intensity:260,distance:1e4,x:0,y:2,z:5})}createPointLight(e){const t=new Rl(1924702,e.intensity,e.distance);t.position.set(e.x,e.y,e.z),this.scene.add(t)}createMap(){let e=new Te,t=new Te;this.mapGroup=e,this.focusMapGroup=t;let{china:a,chinaTopLine:i}=this.createChina(),{map:s,mapTop:o,mapLine:u,mapBoundaryEmphasis:d}=this.createProvince();this.createNationalBackdrop(),a.setParent(e),i.setParent(e),this.createDiffuse(),s.setParent(t),o.setParent(t),u.setParent(t),d==null||d.setParent(t),t.position.set(0,0,-.01),t.scale.set(1,1,0),e.add(t),this.createTopicLayer(),e.rotation.x=-Math.PI/2,e.position.set(0,.2,0),this.scene.add(e),this.createBar()}createChina(){let e={chinaBgMaterialColor:"#0d3349",lineColor:"#39c7ef"},t=this.staticMapData.china,a=new jn({color:new vt(e.chinaBgMaterialColor),transparent:!0,opacity:.72}),i=new ya(this,{data:t,geoProjectionCenter:this.geoProjectionCenter,geoProjectionScale:this.geoProjectionScale,merge:!0,material:a,renderOrder:2}),s=new Qt({color:e.lineColor,transparent:!0,opacity:.58}),o=new aa(this,{data:t,geoProjectionCenter:this.geoProjectionCenter,geoProjectionScale:this.geoProjectionScale,material:s,renderOrder:3});return o.lineGroup.position.z+=.01,{china:i,chinaTopLine:o}}createNationalBackdrop(){var h;if(!this.showNationalBackdrop||this.nationalBackdropGroup)return!1;let e=null;try{e=wa(this.assets.instance.getResource("chinaMap"))}catch(g){return console.warn("首页全国底图资源未加载",g),!1}if(!((h=e==null?void 0:e.features)!=null&&h.length))return!1;const t=this.geoProjectionCenter,a=120,i=new ie(0,0,-.08),s=new jn({color:new vt("#152c47"),transparent:!0,opacity:.72,depthWrite:!1,fog:!1,side:Ie}),o=new ya(this,{data:e,geoProjectionCenter:t,geoProjectionScale:a,merge:!0,position:i,material:s,renderOrder:0});o.mapGroup.name="home-national-backdrop-fill",o.setParent(this.mapGroup);const u=new Qt({color:new vt("#3f82cd"),transparent:!0,opacity:.46,depthWrite:!1,fog:!1}),d=new aa(this,{data:e,geoProjectionCenter:t,geoProjectionScale:a,position:new ie(i.x,i.y,i.z+.01),material:u,renderOrder:1});return d.lineGroup.name="home-national-backdrop-line",d.setParent(this.mapGroup),this.nationalBackdropGroup=o.mapGroup,this.nationalBackdropLineGroup=d.lineGroup,!0}createTradeNationalMap(){var m;if(this.tradeNationalMapGroup)return!0;let e=null;try{e=wa(this.assets.instance.getResource("chinaMap"))}catch(L){return console.warn("牦牛交易全国地图资源未加载",L),!1}const t=e;if(!e||!((m=t==null?void 0:t.features)!=null&&m.length))return!1;const a=new Te;a.name="trade-national-map",a.visible=!1,a.rotation.x=-Math.PI/2,a.position.set(0,.04,0);const i=new be({color:403001,transparent:!0,opacity:.14,side:Ie,depthWrite:!1,fog:!1});new ya(this,{data:e,geoProjectionCenter:this.tradeGeoProjectionCenter,geoProjectionScale:this.tradeGeoProjectionScale,position:new ie(.05,-.05,-.03),material:i,renderOrder:17}).setParent(a);const{topMaterial:o,sideMaterial:u}=this.createTradeNationalMaterials(),d=new Tr(this,{data:e,geoProjectionCenter:this.tradeGeoProjectionCenter,geoProjectionScale:this.tradeGeoProjectionScale,position:new ie(0,0,0),depth:this.tradeNationalDepth,topFaceMaterial:o,sideMaterial:u,renderOrder:20,bevelThickness:.024,bevelSegments:1});d.mapGroup.traverse(L=>{L.isMesh&&(L.renderOrder=20)}),d.setParent(a);const h=new Qt({color:4777983,transparent:!0,opacity:.52,fog:!1,depthTest:!1}),g=new aa(this,{data:e,geoProjectionCenter:this.tradeGeoProjectionCenter,geoProjectionScale:this.tradeGeoProjectionScale,material:h,renderOrder:21});return g.lineGroup.position.z+=this.tradeNationalDepth+.055,g.setParent(a),this.scene.add(a),this.tradeNationalMapGroup=a,this.createTradeNationalLabels(t),!0}createTradeNationalMaterials(){const e=new Qa({color:16777215,transparent:!0,opacity:.54,roughness:.84,metalness:.08,side:Ie,fog:!1});new en(e,{uColor1:827317,uColor2:403515,size:6.8,dir:"x"});const t=this.assets.instance.getResource("side").clone();t.wrapS=ot,t.wrapT=ot,t.repeat.set(1,1.2),t.needsUpdate=!0;const a=new Qa({color:1485501,map:t,transparent:!0,opacity:.58,roughness:.78,metalness:.04,side:Ie,fog:!1});return new en(a,{uColor1:1354174,uColor2:134940,size:Math.max(this.tradeNationalDepth,.1),dir:"y"}),this.time.on("tick",()=>{t.offset.y+=.004}),{topMaterial:e,sideMaterial:a}}createTradeNationalLabels(e){this.tradeNationalLabelGroup=new Te,this.tradeNationalLabelGroup.name="trade-national-label",this.tradeNationalLabelGroup.rotation.x=-Math.PI/2,this.tradeNationalLabelGroup.visible=!1,this.scene.add(this.tradeNationalLabelGroup),this.tradeNationalLabels=[];const t=new Set(["四川","青海","甘肃","陕西","重庆","云南","西藏","新疆"]);(e.features||[]).forEach(a=>{var d;const i=((d=a.properties)==null?void 0:d.name)||"",s=this.normalizeTradeProvinceName(i);if(!t.has(s))return;const o=this.getFeatureCenterLngLat(a);if(!o)return;const u=this.label3d.create("","trade-national-label",!0);u.init(`<div class="trade-national-name">${Se(s)}</div>`,this.getTradeLocalPoint(o.lng,o.lat,.82)),this.label3d.setLabelStyle(u,.012,"x"),u.setParent(this.tradeNationalLabelGroup),u.visible=!0,this.tradeNationalLabels.push(u)})}normalizeTradeProvinceName(e=""){return String(e).replace(/省|市|自治区|壮族|回族|维吾尔|特别行政区/g,"").trim()}getFeatureCenterLngLat(e){var s,o,u;const t=((s=e==null?void 0:e.properties)==null?void 0:s.cp)||((o=e==null?void 0:e.properties)==null?void 0:o.centroid)||((u=e==null?void 0:e.properties)==null?void 0:u.center);if(Array.isArray(t)&&Number.isFinite(Number(t[0]))&&Number.isFinite(Number(t[1])))return{lng:Number(t[0]),lat:Number(t[1])};const a=this.getGeometryCoordinateList(e==null?void 0:e.geometry);if(!a.length)return null;const i=a.reduce((d,h)=>({minLng:Math.min(d.minLng,Number(h[0])),maxLng:Math.max(d.maxLng,Number(h[0])),minLat:Math.min(d.minLat,Number(h[1])),maxLat:Math.max(d.maxLat,Number(h[1]))}),{minLng:1/0,maxLng:-1/0,minLat:1/0,maxLat:-1/0});return{lng:(i.minLng+i.maxLng)/2,lat:(i.minLat+i.maxLat)/2}}isHomeTopicPresentation(){return this.topicLayerPresentation==="home"}createProvince(){let e=this.staticMapData.mapJson;this.mapJsonData=e;const t=this.useSatelliteBase?Ar({geoProjectionCenter:this.geoProjectionCenter,geoProjectionScale:this.geoProjectionScale,zoom:this.satelliteTextureZoom,tileUrlTemplate:this.tileUrlTemplate,onTileStatus:m=>{var L,S;return(S=(L=this.callbacks).onTileStatus)==null?void 0:S.call(L,m)}}):null;t!=null&&t.texture&&this.enhanceTexture(t.texture);let[a,i]=this.createProvinceMaterial();this.focusMapTopMaterial=a,this.focusMapSideMaterial=i;let s=new Tr(this,{geoProjectionCenter:this.geoProjectionCenter,geoProjectionScale:this.geoProjectionScale,position:new ie(0,0,.11),data:e,depth:this.depth,topFaceMaterial:a,sideMaterial:i,renderOrder:9}),o=new Qa({color:this.useSatelliteBase?16777215:13172735,map:(t==null?void 0:t.texture)||null,transparent:!0,opacity:this.useSatelliteBase?this.usesCustomSatelliteTiles?1:.94:this.isHomeTopicPresentation()?.58:.88,roughness:this.useSatelliteBase?this.usesCustomSatelliteTiles?.7:.82:.66,metalness:this.useSatelliteBase?0:.08});this.usesCustomSatelliteTiles||new en(o,{uColor1:this.useSatelliteBase?1629410:this.isHomeTopicPresentation()?683906:1227744,uColor2:this.useSatelliteBase?757673:this.isHomeTopicPresentation()?406090:38069,size:this.useSatelliteBase?15:8.6}),this.defaultMaterial=o,this.defaultLightMaterial=this.defaultMaterial.clone(),this.defaultLightMaterial.color=new vt("rgba(128,244,255,1)"),this.defaultLightMaterial.opacity=.9;let u=new ya(this,{geoProjectionCenter:this.geoProjectionCenter,geoProjectionScale:this.geoProjectionScale,position:new ie(0,0,this.depth+.22),data:e,material:o,renderOrder:this.usesCustomSatelliteTiles?14:8});this.satelliteMapTop=u,this.satelliteMaterial=o,t!=null&&t.uvBounds&&Br(u,t.uvBounds),u.mapGroup.children.map(m=>{m.children.map(L=>{L.type==="Mesh"&&this.eventElement.push(L)})}),this.mapLineMaterial=new Qt({color:12254463,opacity:0,transparent:!0,linewidth:this.adminBoundaryLineScale,fog:!1});let d=new aa(this,{geoProjectionCenter:this.geoProjectionCenter,geoProjectionScale:this.geoProjectionScale,data:e,material:this.mapLineMaterial,renderOrder:this.isHomeTopicPresentation()?34:26});d.lineGroup.position.z+=this.depth+(this.isHomeTopicPresentation()?.315:.285);let h=null;const g=this.getAdminBoundaryEmphasisRadius();return g>0&&(this.mapBoundaryEmphasisMaterial=new be({color:9632767,transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1,blending:Ge}),h=new aa(this,{geoProjectionCenter:this.geoProjectionCenter,geoProjectionScale:this.geoProjectionScale,data:e,material:this.mapBoundaryEmphasisMaterial,renderOrder:this.usesCustomSatelliteTiles?24:18,type:"Line3",tubeRadius:g}),h.lineGroup.position.z+=this.depth+.255),{map:s,mapTop:u,mapLine:d,mapBoundaryEmphasis:h}}normalizeAdminBoundaryLineScale(e){const t=Number(e);return Number.isFinite(t)?Math.min(4,Math.max(1,t)):1}getAdminBoundaryEmphasisRadius(){return this.adminBoundaryLineScale<=1?0:Math.min(.04,.011*this.adminBoundaryLineScale)}getAdminBoundaryEmphasisOpacity(){return this.adminBoundaryLineScale<=1?0:Math.min(.5,.2+this.adminBoundaryLineScale*.08)}createTopicLayer(){if(!this.mapJsonData)return;this.initHongyuanBoundaryPolygons();const e=document.createElement("canvas");e.width=Et.width,e.height=Et.height;const t=e.getContext("2d");t.clearRect(0,0,e.width,e.height);const a=new Jn(e);a.colorSpace=ra,a.wrapS=ln,a.wrapT=ln,a.minFilter=La,a.magFilter=La,this.enhanceTexture(a),a.needsUpdate=!0;const i=new be({map:a,transparent:!0,opacity:0,depthWrite:!1,depthTest:!this.isHomeTopicPresentation(),side:Ie,fog:!1}),s=this.createLayerUvBounds(),o=new ya(this,{geoProjectionCenter:this.geoProjectionCenter,geoProjectionScale:this.geoProjectionScale,position:new ie(0,0,this.depth+(this.isHomeTopicPresentation()?.272:.255)),data:this.mapJsonData,material:i,renderOrder:this.isHomeTopicPresentation()?24:18});Br(o,s),o.setParent(this.focusMapGroup),this.topicLayerUvBounds=s,this.topicLayerCanvas=e,this.topicLayerContext=t,this.topicLayerTexture=a,this.topicLayerMaterial=i,this.topicLayerMap=o}initHongyuanBoundaryPolygons(){var t,a,i;if((t=this.hongyuanBoundaryPolygons)!=null&&t.length)return;const e=this.staticMapData.mapStroke;this.hongyuanBoundaryPolygons=Kr((i=(a=e==null?void 0:e.features)==null?void 0:a[0])==null?void 0:i.geometry)}createSelectedFeatureGroup(){var e;this.selectedFeatureGroup||(this.selectedFeatureGroup=new Te,this.selectedFeatureGroup.name="selected-feature-highlight",this.selectedFeatureGroup.position.z=this.depth+.31,(e=this.focusMapGroup)==null||e.add(this.selectedFeatureGroup))}createLayerUvBounds(){const e=Ht().center(this.geoProjectionCenter).scale(this.geoProjectionScale).translate([0,0]),[t]=e([q.west,q.south]),[a]=e([q.east,q.south]),[,i]=e([q.west,q.north]),[,s]=e([q.west,q.south]);return{left:t,right:a,bottom:-s,top:-i}}setTopicLayer(e){var a,i;if(!e||!this.topicLayerContext||!this.topicLayerTexture)return;this.currentTopicLayer=e,this.visibleTopicLayers=[e],this.clearSelectedFeature(),this.applyLayerMapView(e);const t=++this.topicLayerLoadId;if(this.currentVectorFeatures=[],this.clearYakIndustryPointMarkers(),this.clearYakIndustryPointLabels(),this.topicLayerContext.clearRect(0,0,this.topicLayerCanvas.width,this.topicLayerCanvas.height),this.topicLayerTexture.needsUpdate=!0,this.topicLayerMaterial.opacity=0,(i=(a=this.callbacks).onLayerStatus)==null||i.call(a,{type:"loading",text:`正在加载 ${e.name}`}),nn(e)){this.loadVectorTopicLayer(e,t);return}this.loadTopicLayerImage(e).then(s=>{var o,u,d,h;if(t===this.topicLayerLoadId){if(!(s!=null&&s.image)){this.topicLayerContext.clearRect(0,0,this.topicLayerCanvas.width,this.topicLayerCanvas.height),this.topicLayerTexture.needsUpdate=!0,this.topicLayerMaterial.opacity=0,(u=(o=this.callbacks).onLayerStatus)==null||u.call(o,{type:"error",text:"GeoServer 图层加载失败"});return}this.topicLayerContext.clearRect(0,0,this.topicLayerCanvas.width,this.topicLayerCanvas.height),this.drawTopicRasterImage(s.image,s.layer||e),this.topicLayerTexture.needsUpdate=!0,this.updateTopicLayerTextureSampling(e),this.topicLayerMaterial.opacity=this.getTopicLayerMaterialOpacity(e,.84),(h=(d=this.callbacks).onLayerStatus)==null||h.call(d,{type:"success",text:"GeoServer 图层已加载"})}}).catch(()=>{var s,o;t===this.topicLayerLoadId&&(this.topicLayerContext.clearRect(0,0,this.topicLayerCanvas.width,this.topicLayerCanvas.height),this.topicLayerTexture.needsUpdate=!0,this.topicLayerMaterial.opacity=0,(o=(s=this.callbacks).onLayerStatus)==null||o.call(s,{type:"error",text:"GeoServer 图层加载失败"}))})}setTopicLayers(e=[],t=e[0]){var s,o,u,d;if(!this.topicLayerContext||!this.topicLayerTexture)return;const a=e.filter(Boolean);if(!a.length){this.topicLayerLoadId+=1,this.visibleTopicLayers=[],this.currentTopicLayer=null,this.currentVectorFeatures=[],this.clearYakIndustryPointMarkers(),this.clearYakIndustryPointLabels(),this.clearSelectedFeature(),this.applyLayerMapView(null),this.topicLayerContext.clearRect(0,0,this.topicLayerCanvas.width,this.topicLayerCanvas.height),this.topicLayerTexture.needsUpdate=!0,this.topicLayerMaterial.opacity=0,(o=(s=this.callbacks).onLayerStatus)==null||o.call(s,{type:"success",text:"图层已关闭"});return}if(a.length===1){this.setTopicLayer(I(I({},a[0]),(t==null?void 0:t.key)===a[0].key?t:{}));return}this.currentTopicLayer=t||a[a.length-1],this.visibleTopicLayers=a,this.clearSelectedFeature(),this.clearYakIndustryPointMarkers(),this.clearYakIndustryPointLabels(),this.applyLayerMapView(this.currentTopicLayer);const i=++this.topicLayerLoadId;this.currentVectorFeatures=[],this.topicLayerContext.clearRect(0,0,this.topicLayerCanvas.width,this.topicLayerCanvas.height),this.topicLayerTexture.needsUpdate=!0,this.topicLayerMaterial.opacity=0,(d=(u=this.callbacks).onLayerStatus)==null||d.call(u,{type:"loading",text:`正在加载 ${a.length} 个地图图层`}),Promise.all(a.map(h=>this.loadCompositeTopicLayerItem(h))).then(h=>{var L,S,C;if(i!==this.topicLayerLoadId)return;const g=h.filter(Boolean),m=g.find(F=>{var E,D;return F.type==="vector"&&((E=F.layer)==null?void 0:E.key)===((D=this.currentTopicLayer)==null?void 0:D.key)});this.currentVectorFeatures=((L=m==null?void 0:m.geojson)==null?void 0:L.features)||[],this.topicLayerContext.clearRect(0,0,this.topicLayerCanvas.width,this.topicLayerCanvas.height),g.forEach((F,E)=>{var D,J;if(F.type==="image"){this.topicLayerContext.save();const re=E===g.length-1?Math.max(.78,(D=F.layer.opacity)!=null?D:.9):Math.min(.52,(J=F.layer.opacity)!=null?J:.52);this.topicLayerContext.globalAlpha=Math.min(1,Math.max(.28,re)),this.drawTopicRasterImage(F.image,F.layer),this.topicLayerContext.restore();return}this.drawVectorTopicLayer(F.layer,F.geojson.features||[],{clear:!1})}),this.updateYakIndustryPointMarkers(this.currentTopicLayer,this.currentVectorFeatures),this.updateYakIndustryPointLabels(this.currentTopicLayer,this.currentVectorFeatures),this.topicLayerTexture.needsUpdate=!0,this.updateTopicLayerTextureSampling(this.currentTopicLayer),this.topicLayerMaterial.opacity=g.length?this.getTopicLayerMaterialOpacity(this.currentTopicLayer,1):0,(C=(S=this.callbacks).onLayerStatus)==null||C.call(S,{type:g.length?"success":"error",text:g.length?`已加载 ${g.length} 个地图图层`:"地图图层加载失败"})})}loadCompositeTopicLayerItem(e){return he(this,null,function*(){if(nn(e))try{const t=yield this.fetchVectorLayerGeojson(e);return{type:"vector",layer:e,geojson:t}}catch(t){return null}return this.loadTopicLayerImage(e).then(t=>t?I({type:"image"},t):null)})}loadTopicLayerImage(e){return jr(e)?this.loadWmtsTopicLayerImage(e):new Promise(t=>{const a=new Image;a.crossOrigin="anonymous",a.onload=()=>t({image:a,layer:e}),a.onerror=()=>t(null),a.src=hu(e)})}loadWmtsTopicLayerImage(e){return he(this,null,function*(){const t=document.createElement("canvas");t.width=Et.width,t.height=Et.height;const a=t.getContext("2d");if(!a)return null;a.clearRect(0,0,t.width,t.height);const i=this.getWmtsTopicZoom(e),s=Qu(q,i),o=[];for(let g=s.minX;g<=s.maxX;g+=1)for(let m=s.minY;m<=s.maxY;m+=1)o.push({x:g,y:m});let u=0,d=0;const h=()=>he(this,null,function*(){for(;d<o.length;){const g=o[d];d+=1;const m=yield tc(pu(e,{x:g.x,y:g.y,z:i}));if(!m)continue;const L=ec(g.x,g.y,i,t);a.drawImage(m,L.x,L.y,L.width,L.height),u+=1}});return yield Promise.all(Array.from({length:Math.min(ju,o.length)},h)),u?(this.enhanceWmtsTopicCanvas(t,e),{image:t,layer:e,loaded:u}):null})}enhanceWmtsTopicCanvas(e,t={}){var d,h;if(t.homeWmtsEnhance===!1)return;const a=e.getContext("2d");if(!a)return;const i=document.createElement("canvas");i.width=e.width,i.height=e.height;const s=i.getContext("2d");if(!s)return;s.drawImage(e,0,0);const o=Yt((d=t.homeWmtsPointSpread)!=null?d:0,0,4),u=Yt((h=t.homeWmtsGlowRadius)!=null?h:0,0,6);if(a.clearRect(0,0,e.width,e.height),u>0&&(a.save(),a.globalAlpha=.58,a.filter=`blur(${u}px)`,a.drawImage(i,0,0),a.restore()),o>0){const g=[[-o,0],[o,0],[0,-o],[0,o],[-o,-o],[o,-o],[-o,o],[o,o]];a.save(),a.globalAlpha=.72,g.forEach(([m,L])=>a.drawImage(i,m,L)),a.restore()}a.drawImage(i,0,0)}getWmtsTopicZoom(e={}){var o,u,d;const t=Math.round(Number(e.maximumLevel)),a=Number.isFinite(t)&&t>0?t:21,i=Number((d=(u=(o=e.homeWmtsZoom)!=null?o:e.wmtsZoom)!=null?u:e.tileZoom)!=null?d:this.satelliteTextureZoom),s=Number.isFinite(i)&&i>0?Math.round(i):11;return Yt(s,3,Math.min(a,an))}updateTopicLayerTextureSampling(e={}){if(!this.topicLayerTexture)return;const t=jr(e)?mr:La;this.topicLayerTexture.minFilter=t,this.topicLayerTexture.magFilter=t,this.topicLayerTexture.needsUpdate=!0}drawTopicRasterImage(e,t={}){const a=this.topicLayerCanvas,i=this.topicLayerContext;if(!a||!i)return;if(!t.softMask){this.drawHomeTopicRasterGlow(e,t),i.drawImage(e,0,0,a.width,a.height);return}const s=Math.min(1,Math.max(.08,Number(t.softMaskScale)||.18)),o=document.createElement("canvas");o.width=Math.max(96,Math.round(a.width*s)),o.height=Math.max(96,Math.round(a.height*s));const u=o.getContext("2d");if(!u){i.drawImage(e,0,0,a.width,a.height);return}u.clearRect(0,0,o.width,o.height),u.imageSmoothingEnabled=!0,u.imageSmoothingQuality="high",u.drawImage(e,0,0,o.width,o.height),i.save(),i.imageSmoothingEnabled=!0,i.imageSmoothingQuality="high",i.drawImage(o,0,0,a.width,a.height),i.restore()}drawHomeTopicRasterGlow(e,t={}){var d,h;if(!this.isHomeTopicPresentation())return;const a=this.topicLayerCanvas,i=this.topicLayerContext;if(!a||!i)return;const s=Yt((d=t.homeGlowOpacity)!=null?d:0,0,.8),o=Yt((h=t.homeGlowBlur)!=null?h:0,0,32);if(!s||!o)return;const u=t.homeGlowColor||"#E5FCFF";i.save(),i.globalAlpha=s,i.filter=`drop-shadow(0 0 ${o}px ${u})`,i.drawImage(e,0,0,a.width,a.height),i.restore()}applyLayerMapView(e,t={}){var d,h;if(!((d=this.camera)!=null&&d.instance)||!((h=this.camera)!=null&&h.controls)||!this.mapAnimationComplete&&!t.force)return;const a=e?null:this.currentTownRanking,i=(e==null?void 0:e.mapView)||(e!=null&&e.cameraPosition?{cameraPosition:e.cameraPosition}:null)||(a==null?void 0:a.mapView)||(a!=null&&a.cameraPosition?{cameraPosition:a.cameraPosition}:null),s=i?this.getLayerMapViewTarget(i):this.defaultMapTarget.clone(),o=i?this.getLayerMapViewCameraPosition(i,s):this.defaultMapCameraPosition.clone(),u=i&&Number.isFinite(i.duration)?i.duration:.75;this.animateMapCamera(o,s,u)}getFocusMapTopOpacity(){return this.useSatelliteBase?this.usesCustomSatelliteTiles?.16:1:.78}getTopicLayerMaterialOpacity(e,t=.84){const a=Number(e==null?void 0:e.opacity),i=Number.isFinite(a)?a:t;if(!this.isHomeTopicPresentation())return i;const s=Number(e==null?void 0:e.homePresentationMaxOpacity),o=Number.isFinite(s)?s:.56;return Yt(i,0,o)}getDynamicSatelliteZoom(e){return this.usesCustomSatelliteTiles?e<=4.2?Math.min(this.dynamicSatelliteMaxZoom,21):e<=6.4?Math.min(this.dynamicSatelliteMaxZoom,19):e<=8.4?Math.min(this.dynamicSatelliteMaxZoom,17):e<=11?Math.min(this.dynamicSatelliteMaxZoom,15):e<=14.5?Math.min(this.dynamicSatelliteMaxZoom,13):e<=18?Math.min(this.dynamicSatelliteMaxZoom,11):this.satelliteTextureZoom:this.satelliteTextureZoom}getCameraTargetLngLat(){var s,o,u,d,h,g,m;const e=(d=(u=(o=(s=this.camera)==null?void 0:s.controls)==null?void 0:o.target)==null?void 0:u.clone)==null?void 0:d.call(u);if(!e)return[102.58,32.72];(g=(h=this.focusMapGroup)==null?void 0:h.updateWorldMatrix)==null||g.call(h,!0,!1);const t=this.focusMapGroup?this.focusMapGroup.worldToLocal(e):e,a=Ht().center(this.geoProjectionCenter).scale(this.geoProjectionScale).translate([0,0]),i=((m=a.invert)==null?void 0:m.call(a,[t.x,-t.y]))||[102.58,32.72];return[Math.max(q.west,Math.min(q.east,Number(i[0])||102.58)),Math.max(q.south,Math.min(q.north,Number(i[1])||32.72))]}getDynamicSatelliteTileWindow(e){return e>=21?3:e>=19?5:e>=17?7:e>=15?this.dynamicSatelliteTileWindow:e>=13?Math.min(11,this.dynamicSatelliteTileWindow+2):Math.min(11,this.dynamicSatelliteTileWindow+2)}getDynamicSatelliteKey(e,t){return t?`${e}:${t.minX}-${t.maxX}:${t.minY}-${t.maxY}`:""}updateDynamicSatelliteTiles(e=!1){if(!this.usesCustomSatelliteTiles||!this.mapAnimationComplete)return;const t=Date.now();if(!e&&t-this.dynamicSatelliteLastCheck<Yu)return;this.dynamicSatelliteLastCheck=t;const a=this.camera.instance.position.distanceTo(this.camera.controls.target),i=this.getDynamicSatelliteZoom(a);if(i<=this.satelliteTextureZoom){this.hideDynamicSatelliteOverlay();return}const s=this.getCameraTargetLngLat(),o=this.getDynamicSatelliteTileWindow(i),u=Iu({zoom:i,centerLngLat:s,maxCols:o,maxRows:o}),d=this.getDynamicSatelliteKey(i,u);!d||d===this.dynamicSatelliteCurrentKey||d===this.dynamicSatelliteLoadingKey||this.loadDynamicSatelliteOverlay({zoom:i,centerLngLat:s,maxTiles:o,key:d})}loadDynamicSatelliteOverlay({zoom:e,centerLngLat:t,maxTiles:a,key:i}){const s=++this.dynamicSatelliteRequestId;this.dynamicSatelliteLoadingKey=i;let o;o=Ar({geoProjectionCenter:this.geoProjectionCenter,geoProjectionScale:this.geoProjectionScale,zoom:e,centerLngLat:t,maxCols:a,maxRows:a,tileUrlTemplate:this.tileUrlTemplate,transparentBackground:!0,applyTone:!1,onTileStatus:u=>{var d,h,g,m,L;if((g=(h=this.callbacks).onTileStatus)==null||g.call(h,V(I({},u),{text:((d=u.text)==null?void 0:d.replace("影像底图","高清影像底图"))||u.text})),u.type!=="loading"){if(s!==this.dynamicSatelliteRequestId){(L=(m=o==null?void 0:o.texture)==null?void 0:m.dispose)==null||L.call(m);return}if(this.dynamicSatelliteLoadingKey="",Number(u.loaded||0)<=0){this.dynamicSatelliteCurrentKey===i&&this.hideDynamicSatelliteOverlay();return}this.applyDynamicSatelliteOverlay(o,i)}}}),this.applyDynamicSatelliteOverlay(o,i)}ensureDynamicSatelliteOverlay(){var a;if(this.dynamicSatelliteOverlay)return;const e=new be({transparent:!0,opacity:0,depthWrite:!1,depthTest:!0,side:Ie,fog:!1}),t=new qe(new At(1,1),e);t.name="dynamic-satellite-overlay",t.renderOrder=15,t.visible=!1,t.position.z=this.depth+.248,(a=this.focusMapGroup)==null||a.add(t),this.dynamicSatelliteOverlay=t,this.dynamicSatelliteMaterial=e}applyDynamicSatelliteOverlay(e,t){var o,u;if(!(e!=null&&e.texture)||!(e!=null&&e.uvBounds))return;this.ensureDynamicSatelliteOverlay();const a=e.uvBounds,i=Math.max(1e-4,a.right-a.left),s=Math.max(1e-4,a.top-a.bottom);this.dynamicSatelliteOverlay.position.set((a.left+a.right)/2,(a.bottom+a.top)/2,this.depth+.248),this.dynamicSatelliteOverlay.scale.set(i,s,1),this.dynamicSatelliteOverlay.visible=!0,this.dynamicSatelliteTexture&&this.dynamicSatelliteTexture!==e.texture&&((u=(o=this.dynamicSatelliteTexture).dispose)==null||u.call(o)),this.dynamicSatelliteTexture=e.texture,this.dynamicSatelliteMaterial.map=e.texture,this.dynamicSatelliteMaterial.opacity=1,this.dynamicSatelliteMaterial.needsUpdate=!0,this.dynamicSatelliteCurrentKey=t}hideDynamicSatelliteOverlay(){this.dynamicSatelliteOverlay&&(this.dynamicSatelliteOverlay.visible=!1),this.dynamicSatelliteLoadingKey&&(this.dynamicSatelliteRequestId+=1,this.dynamicSatelliteLoadingKey=""),this.dynamicSatelliteCurrentKey=""}ensureMapRevealed(){var e,t,a,i;if(!this.mapAnimationComplete){if((t=(e=this.animateTl)==null?void 0:e.progress)==null||t.call(e,1,!1),(i=(a=this.animateTl)==null?void 0:a.pause)==null||i.call(a),this.mapAnimationComplete=!0,this.focusMapGroup&&(this.focusMapGroup.position.set(0,0,0),this.focusMapGroup.scale.set(1,1,1)),this.focusMapTopMaterial&&(this.focusMapTopMaterial.opacity=this.getFocusMapTopOpacity()),this.focusMapSideMaterial&&(this.focusMapSideMaterial.opacity=1,this.focusMapSideMaterial.transparent=!1),this.mapGroup&&(this.mapGroup.visible=!0),this.labelGroup&&(this.labelGroup.visible=!0),this.flyLineGroup&&(this.flyLineGroup.visible=!0),this.flyLineFocusGroup&&(this.flyLineFocusGroup.visible=!0),this.scatterGroup&&(this.scatterGroup.visible=!0),this.InfoPointGroup&&(this.InfoPointGroup.visible=this.showTownRankingPointMarkers&&this.hasTownRankingRows()),this.applyLayerMapView(this.currentTopicLayer,{force:!0}),this.updateDynamicSatelliteTiles(!0),this.updateYakIndustryPointMarkers(this.currentTopicLayer,this.currentVectorFeatures),this.updateYakIndustryPointLabels(this.currentTopicLayer,this.currentVectorFeatures),va(this.currentTownRanking)){this.hideAllMapStatisticLabels();return}this.updateVillageRankingLabels(this.currentTownRanking),this.updateTradeFlowLayer(this.currentTownRanking),this.updateInfoPointStats()}}getLayerMapViewTarget(e){var t;return e!=null&&e.targetLngLat?this.lngLatToWorldPoint(e.targetLngLat,(t=e.targetLocalZ)!=null?t:.72):e!=null&&e.target?this.toVector3(e.target,this.defaultMapTarget):this.defaultMapTarget.clone()}getLayerMapViewCameraPosition(e,t){if(e!=null&&e.cameraPosition)return this.toVector3(e.cameraPosition,this.defaultMapCameraPosition);const a=Number.isFinite(e==null?void 0:e.distanceScale)?e.distanceScale:1,i=this.defaultMapCameraPosition.clone().sub(this.defaultMapTarget).multiplyScalar(a),s=t.clone().add(i);return e!=null&&e.cameraOffset&&s.add(this.toVector3(e.cameraOffset,new ie(0,0,0))),s}lngLatToWorldPoint(e,t=0){const a=Array.isArray(e)?e:[e==null?void 0:e.lng,e==null?void 0:e.lat],i=Number(a==null?void 0:a[0]),s=Number(a==null?void 0:a[1]);if(!Number.isFinite(i)||!Number.isFinite(s))return this.defaultMapTarget.clone();const[o,u]=this.geoProjection([i,s]),d=new ie(o,-u,Number(t)||0);return this.focusMapGroup?this.focusMapGroup.localToWorld(d):d}toVector3(e,t){if(Array.isArray(e)){const[o,u,d]=e.map(Number);return[o,u,d].every(Number.isFinite)?new ie(o,u,d):t.clone()}const a=Number(e==null?void 0:e.x),i=Number(e==null?void 0:e.y),s=Number(e==null?void 0:e.z);return[a,i,s].every(Number.isFinite)?new ie(a,i,s):t.clone()}animateMapCamera(e,t,a=.75){this.activeMapViewTweens.forEach(o=>{var u;return(u=o==null?void 0:o.kill)==null?void 0:u.call(o)}),this.activeMapViewTweens=[];const i=this.camera.controls,s=()=>i.update();this.activeMapViewTweens.push(na.to(this.camera.instance.position,{duration:a,x:e.x,y:e.y,z:e.z,ease:"power2.out",onUpdate:s}),na.to(i.target,{duration:a,x:t.x,y:t.y,z:t.z,ease:"power2.out",onUpdate:s}))}addSceneTween(e){var t;return e&&(this.sceneTweens.push(e),this.scenePaused&&((t=e.pause)==null||t.call(e)),e)}addSceneTimer(e){return e&&this.sceneTimers.push(e),e}focusTownByName(e,t={}){var u,d,h;const a=this.townMetaByName.get(ut(e)),i=t.select?this.selectTownFeatureByName(e,t):!1;if(t.preserveCamera)return i||!!(a!=null&&a.center);if(!(a!=null&&a.center))return i;const s=this.lngLatToWorldPoint(a.center,(u=t.targetLocalZ)!=null?u:.82),o=this.getLayerMapViewCameraPosition({distanceScale:(d=t.distanceScale)!=null?d:.82,cameraOffset:t.cameraOffset||{x:0,y:1.2,z:0}},s);return this.animateMapCamera(o,s,(h=t.duration)!=null?h:.75),!0}isNationalParkTownSelectionActive(){var e;return((e=this.currentTopicLayer)==null?void 0:e.key)==="national-park-zoning"&&this.getTownRankingMeta().onlyRankedTownLabels}getTownNameFromMapEvent(e){var a,i,s,o,u,d,h,g,m,L;return[(s=(i=(a=e==null?void 0:e.target)==null?void 0:a.parent)==null?void 0:i.userData)==null?void 0:s.name,(u=(o=e==null?void 0:e.target)==null?void 0:o.userData)==null?void 0:u.name,(g=(h=(d=e==null?void 0:e.target)==null?void 0:d.parent)==null?void 0:h.userData)==null?void 0:g.townName,(L=(m=e==null?void 0:e.target)==null?void 0:m.userData)==null?void 0:L.townName].find(S=>String(S||"").trim())||""}findTownFeatureByName(e){var i,s,o,u;const t=ut(e);if(!t)return null;const a=(((i=this.mapJsonData)==null?void 0:i.features)||((o=(s=this.staticMapData)==null?void 0:s.mapJson)==null?void 0:o.features)||[]).find(d=>{const h=(d==null?void 0:d.properties)||{};return[h.name,h.fullName,h.full_name,h.townName].some(m=>ut(m)===t)});return a!=null&&a.geometry?{type:"Feature",properties:V(I({},a.properties||{}),{name:((u=a.properties)==null?void 0:u.name)||e,feature_role:"乡镇范围"}),geometry:a.geometry}:null}selectTownFeatureByName(e,t={}){var i,s,o,u,d;const a=this.findTownFeatureByName(e);return a?(this.showSelectedFeature(a,{mode:"town"}),t.silentStatus!==!0&&((d=(u=this.callbacks).onLayerStatus)==null||d.call(u,{type:"success",text:t.statusText||`已选中${((o=a.properties)==null?void 0:o.name)||e}`})),!0):(t.showMissingStatus!==!1&&((s=(i=this.callbacks).onLayerStatus)==null||s.call(i,{type:"warning",text:"未找到对应乡镇边界"})),!1)}handleTownRankingSelect(e,t={}){var u,d;if(!this.isNationalParkTownSelectionActive())return!1;const a=ut(e);if(!a||!this.getTownRankingRows(this.currentTownRanking,Number.POSITIVE_INFINITY,!1).some(h=>ut(h.name)===a))return!1;const o=this.focusTownByName(e,I({select:!0,preserveCamera:!0,statusText:`已选中${e}`},t));return o&&((d=(u=this.callbacks).onFeatureInfo)==null||d.call(u,{feature:null})),o}focusYakIndustryPoint(e={}){var s,o;const t=this.getYakIndustryPayloadCoordinate(e);if(!t)return(o=(s=this.callbacks).onLayerStatus)==null||o.call(s,{type:"warning",text:"当前主体暂无可定位坐标"}),{focused:!1,screen:null};const a=this.findYakIndustryPointFeature(e,t);return a?this.setSelectedVectorFeatures([a]):this.clearSelectedFeature(),{focused:this.flyToLngLat(t,{span:.035,duration:.72,statusText:"已定位产业主体"}),screen:this.getYakIndustryPointScreen(e),feature:a}}focusVectorFeature(e={}){var h,g;const t=this.getVisibleVectorFeatures(this.currentTopicLayer,this.currentVectorFeatures||[]),a=String(e.id||e.key||""),i=String(e.fullName||e.name||"").trim(),s=t.find(m=>{const L=(m==null?void 0:m.properties)||{};return a&&String(L.id||"")===a||i&&String(L.name||L.plot_name||"").trim()===i});if(!s)return(g=(h=this.callbacks).onLayerStatus)==null||g.call(h,{type:"warning",text:"当前图斑尚未加载"}),{focused:!1,screen:null,feature:null};this.setSelectedVectorFeatures([s]);const o=this.getGeometryLngLatBounds(s.geometry);if(!o)return{focused:!1,screen:null,feature:s};const u=[(o.minLng+o.maxLng)/2,(o.minLat+o.maxLat)/2];return{focused:this.flyToLngLat(u,{span:Math.max(o.maxLng-o.minLng,o.maxLat-o.minLat),duration:.75,statusText:"已定位种草图斑"}),screen:this.getVectorFeatureScreen(s),feature:s}}getVectorFeatureScreen(e={}){let t=(e==null?void 0:e.feature)||e;if(!(t!=null&&t.geometry)){const s=this.getVisibleVectorFeatures(this.currentTopicLayer,this.currentVectorFeatures||[]),o=String((e==null?void 0:e.id)||(e==null?void 0:e.key)||"");t=s.find(u=>{var d;return String(((d=u==null?void 0:u.properties)==null?void 0:d.id)||"")===o})||null}const a=this.getGeometryLngLatBounds(t==null?void 0:t.geometry);if(!a)return null;const i=[(a.minLng+a.maxLng)/2,(a.minLat+a.maxLat)/2];return this.lngLatToLayerScreenPoint(i,this.depth+.34)||this.lngLatToScreenPoint(i,this.depth+.32)}getYakIndustryPointScreen(e={}){const t=this.getYakIndustryPayloadCoordinate(e);return t?this.lngLatToLayerScreenPoint(t,this.depth+.36)||this.lngLatToScreenPoint(t,this.depth+.32):null}getYakIndustryPayloadCoordinate(e={}){var s,o,u,d,h;const t=((s=e.geometry)==null?void 0:s.coordinates)||e.coordinates,a=Number((u=(o=e.longitude)!=null?o:e.lng)!=null?u:t==null?void 0:t[0]),i=Number((h=(d=e.latitude)!=null?d:e.lat)!=null?h:t==null?void 0:t[1]);return!Number.isFinite(a)||!Number.isFinite(i)?null:[a,i]}findYakIndustryPointFeature(e={},t=this.getYakIndustryPayloadCoordinate(e)){const a=this.getVisibleVectorFeatures(this.currentTopicLayer,this.currentVectorFeatures||[]),i=String(e.id||e.key||""),s=String(e.fullName||e.name||"").trim(),o=String(e.stageKey||""),u=t&&a.find(h=>{var m;if(((m=h==null?void 0:h.geometry)==null?void 0:m.type)!=="Point")return!1;const g=h.properties||{};return o&&String(g.stageKey||"")!==o?!1:this.getCoordinateDistance(h.geometry.coordinates,t)<=8e-4})||null;if(e.preferCoordinateMatch)return u;const d=a.find(h=>{const g=(h==null?void 0:h.properties)||{};return!!(i&&String(g.id||"")===i||s&&String(g.name||g.fullName||"").trim()===s)});return d||u}loadVectorTopicLayer(e,t){return he(this,null,function*(){var a,i,s,o;try{const u=yield this.fetchVectorLayerGeojson(e);if(t!==this.topicLayerLoadId)return;this.currentVectorFeatures=u.features||[],this.drawVectorTopicLayer(e,this.currentVectorFeatures),this.updateYakIndustryPointMarkers(e,this.currentVectorFeatures),this.updateYakIndustryPointLabels(e,this.currentVectorFeatures),this.topicLayerTexture.needsUpdate=!0,this.topicLayerMaterial.opacity=this.getTopicLayerMaterialOpacity(e,.9),(i=(a=this.callbacks).onLayerStatus)==null||i.call(a,{type:"success",text:"真实矢量图层已加载"})}catch(u){if(t!==this.topicLayerLoadId)return;this.currentVectorFeatures=[],this.clearYakIndustryPointMarkers(),this.clearYakIndustryPointLabels(),this.topicLayerContext.clearRect(0,0,this.topicLayerCanvas.width,this.topicLayerCanvas.height),this.topicLayerTexture.needsUpdate=!0,this.topicLayerMaterial.opacity=0,(o=(s=this.callbacks).onLayerStatus)==null||o.call(s,{type:"error",text:"真实矢量图层加载失败"})}})}fetchVectorLayerGeojson(e){return he(this,null,function*(){var s,o;if(e.sourceType==="geojson"){if(((s=e.geojsonData)==null?void 0:s.type)==="FeatureCollection")return e.geojsonData;const u=yield fetch(Ur(e.dataPath),{credentials:"include"});if(!u.ok)throw new Error(`HTTP ${u.status}`);return yield u.json()}if(e.sourceType==="wfs"){const u=yield xr(e.layerName,{cqlFilter:e.cqlFilter,maxFeatures:e.maxFeatures||1200,timeout:e.timeout||18e3});return(u==null?void 0:u.type)==="FeatureCollection"?u:{type:"FeatureCollection",features:(u==null?void 0:u.features)||[]}}let t=[],a=null;try{const u=yield fetch(e.apiUrl,{credentials:"include"});if(!u.ok)throw new Error(`HTTP ${u.status}`);const d=yield u.json();t=Array.isArray(d==null?void 0:d.data)?d.data:Array.isArray((o=d==null?void 0:d.data)==null?void 0:o.rows)?d.data.rows:[]}catch(u){a=u}let i=this.buildWktLayerFeatures(t);if((!t.length||!i.length)&&e.fallbackPath){const u=yield fetch(Ur(e.fallbackPath),{credentials:"include"});if(!u.ok)throw a||new Error(`HTTP ${u.status}`);const d=yield u.json();t=Array.isArray(d==null?void 0:d.rows)?d.rows:[],i=this.buildWktLayerFeatures(t)}return{type:"FeatureCollection",features:i}})}buildWktLayerFeatures(e=[]){return(e||[]).map(t=>({type:"Feature",properties:{id:t.id,type:t.type,totalAcreage:t.totalAcreage,cdAcreage:t.cdAcreage,sdAcreage:t.sdAcreage,cdScl:t.cdScl,sdScl:t.sdScl},geometry:this.parseWktGeometry(this.pickWktValue(t))})).filter(t=>t.geometry)}pickWktValue(e={}){return e.wkt||e.WKT||e.geom||e.geometry||e.the_geom||e.theGeom||e.shape||e.Shape}drawVectorTopicLayer(e,t,a={}){const i=this.topicLayerContext;a.clear!==!1&&i.clearRect(0,0,this.topicLayerCanvas.width,this.topicLayerCanvas.height),i.save(),i.lineJoin="round",i.lineCap="round",this.clipVectorLayerContext(i,e);const o=this.getVisibleVectorFeatures(e,t).filter(u=>{var d;return!(e!=null&&e.hidePointFeatures)||((d=u==null?void 0:u.geometry)==null?void 0:d.type)!=="Point"}).sort((u,d)=>{var m,L;const h=this.getGeometryDrawRank((m=u.geometry)==null?void 0:m.type),g=this.getGeometryDrawRank((L=d.geometry)==null?void 0:L.type);return h-g});o.forEach(u=>{const d=this.getVectorFeatureStyle(e,u);this.drawVectorFeature(i,u.geometry,d)}),this.drawNationalParkBoundaryOverlay(i,e,o),this.drawSelectedVectorOverlay(i),i.restore()}drawNationalParkBoundaryOverlay(e,t,a=[]){(t==null?void 0:t.key)!=="national-park-zoning"||!a.length||a.forEach(i=>{const s=this.getVectorFeatureStyle(t,i);this.drawVectorFeature(e,i.geometry,V(I({},s),{fill:"#071A20",stroke:"#071A20",polygonAlpha:0,lineAlpha:.34,lineWidth:7,glow:!0})),this.drawVectorFeature(e,i.geometry,V(I({},s),{fill:"#E7FFF6",stroke:"#E7FFF6",polygonAlpha:0,lineAlpha:.68,lineWidth:2.1,glow:!1})),this.drawVectorFeature(e,i.geometry,V(I({},s),{fill:s.stroke,stroke:s.stroke,polygonAlpha:0,lineAlpha:.86,lineWidth:1.2,glow:!1}))})}drawSelectedVectorOverlay(e){const t=this.selectedVectorFeatures||[],a=this.analysisMatchedFeatures||[],i=this.analysisBoundaryFeature,s=this.boundaryDrawPoints||[];if(!t.length&&!a.length&&!i&&!s.length)return;const o=this.isEcologicalProjectLayer(this.currentTopicLayer),u={fill:Er,stroke:Uu,polygonAlpha:o?.2:.28,lineAlpha:o?.78:.98,lineWidth:o?6:12,pointRadius:11,glow:!o,halo:!o},d={fill:Er,stroke:qu,polygonAlpha:o?.34:.52,lineAlpha:o?.94:1,lineWidth:o?3.2:5,pointRadius:6.5,glow:!1,halo:!1};if(e.save(),t.forEach(h=>{var m;const g=(h==null?void 0:h.geometry)||((m=h==null?void 0:h.feature)==null?void 0:m.geometry);this.drawVectorFeature(e,g,u),this.drawVectorFeature(e,g,d)}),a.forEach(h=>{var m;const g=(h==null?void 0:h.geometry)||((m=h==null?void 0:h.feature)==null?void 0:m.geometry);this.drawVectorFeature(e,g,{fill:"#30DCFF",stroke:"#C9FBFF",polygonAlpha:o?.22:.28,lineAlpha:o?.88:.98,lineWidth:o?2.8:5,pointRadius:6,glow:!o})}),i!=null&&i.geometry&&this.drawVectorFeature(e,i.geometry,{fill:"#24F6C4",stroke:"#FFFFFF",polygonAlpha:o?.12:.18,lineAlpha:o?.92:1,lineWidth:o?3:4,pointRadius:6,glow:!o}),s.length){const h=s.map(m=>[m.lng,m.lat]),g={type:"LineString",coordinates:this.boundaryDrawingEnabled?h:[...h,h[0]].filter(Boolean)};this.drawVectorFeature(e,g,{fill:"#24F6C4",stroke:"#24F6C4",polygonAlpha:o?.08:.12,lineAlpha:1,lineWidth:o?3:4,pointRadius:6,glow:!o}),h.forEach(m=>{this.drawVectorFeature(e,{type:"Point",coordinates:m},{fill:"#FFFFFF",stroke:"#24F6C4",polygonAlpha:.2,lineAlpha:1,lineWidth:o?2.4:3,pointRadius:5.5,glow:!o})})}e.restore()}redrawVectorTopicLayer(){!this.topicLayerContext||!this.topicLayerTexture||!this.currentTopicLayer||!nn(this.currentTopicLayer)||(this.drawVectorTopicLayer(this.currentTopicLayer,this.currentVectorFeatures||[]),this.updateYakIndustryPointMarkers(this.currentTopicLayer,this.currentVectorFeatures),this.topicLayerTexture.needsUpdate=!0)}featureMatchesLegend(e={},t={}){var s;const a=Array.isArray(t==null?void 0:t.matches)?t.matches.filter(o=>o==null?void 0:o.field):[];if(a.length)return a.some(o=>{var u;return String((u=e[o.field])!=null?u:"")===String(o.value)});const i=t==null?void 0:t.match;return i!=null&&i.field?String((s=e[i.field])!=null?s:"")===String(i.value):!0}getVisibleVectorFeatures(e,t){var u,d;const a=Array.isArray(e==null?void 0:e.activeLegends)?e.activeLegends.filter(h=>{var g,m;return((g=h==null?void 0:h.matches)==null?void 0:g.length)||((m=h==null?void 0:h.match)==null?void 0:m.field)}):[];if(a.length)return(t||[]).filter(h=>a.some(g=>this.featureMatchesLegend((h==null?void 0:h.properties)||{},g)));const i=e==null?void 0:e.activeLegend;if((u=i==null?void 0:i.matches)!=null&&u.length||(d=i==null?void 0:i.match)!=null&&d.field)return(t||[]).filter(h=>this.featureMatchesLegend((h==null?void 0:h.properties)||{},i));const o=String((e==null?void 0:e.cqlFilter)||"").trim().match(/^([a-zA-Z0-9_]+)\s*=\s*'((?:''|[^'])*)'$/);if(o){const[,h,g]=o,m=g.replace(/''/g,"'");return(t||[]).filter(L=>{var S,C;return String((C=(S=L==null?void 0:L.properties)==null?void 0:S[h])!=null?C:"")===m})}return[...t||[]]}updateYakIndustryPointLabels(e=this.currentTopicLayer,t=this.currentVectorFeatures){if(this.clearYakIndustryPointLabels(),(e==null?void 0:e.showPointLabels)===!1||e!=null&&e.hidePointFeatures||(e==null?void 0:e.key)!=="yak-industry-points"||!this.label3d)return;const a=this.getYakIndustryLabelFeatures(e,t);a.length&&(this.ensureYakIndustryPointLabelGroup(),a.forEach((i,s)=>{var u;let o=this.yakIndustryPointLabels[s];o||(o=this.label3d.create("","yak-industry-point-label",!0),this.label3d.setLabelStyle(o,.012,"x"),o.setParent(this.yakIndustryPointLabelGroup),this.yakIndustryPointLabels.push(o)),o.element.className="yak-industry-point-label",o.init(this.getYakIndustryPointLabelHtml(i),this.getYakIndustryPointLabelPosition(i,s)),o.visible=!0,(u=o.show)==null||u.call(o),o.userData={feature:i}}),this.yakIndustryPointLabels.slice(a.length).forEach(i=>{var s;i.visible=!1,(s=i.hide)==null||s.call(i),i.userData=null}),this.yakIndustryPointLabelGroup.visible=!!this.mapAnimationComplete)}updateYakIndustryPointMarkers(e=this.currentTopicLayer,t=this.currentVectorFeatures){if(this.clearYakIndustryPointMarkers(),(e==null?void 0:e.key)!=="yak-industry-points"||e!=null&&e.hidePointMarkers)return;const a=this.getVisibleVectorFeatures(e,t).filter(i=>{var s;return((s=i==null?void 0:i.geometry)==null?void 0:s.type)==="Point"});a.length&&(this.ensureYakIndustryPointMarkerGroup(),a.forEach((i,s)=>{let o=this.yakIndustryPointMarkers[s];const u=this.getVectorFeatureStyle(e,i),d=this.getYakIndustryMarkerMaterial(u,i),h=this.lngLatToLayerLocalPoint(i.geometry.coordinates,this.depth+.36),g=Number(e==null?void 0:e.pointSpriteScale)||.34,m=this.getYakIndustryMarkerType(i);o||(o=new ea(d),o.name="yak-industry-point-marker",o.renderOrder=42,this.bindYakIndustryPointMarkerEvents(o),this.interactionManager.add(o),this.yakIndustryPointMarkerGroup.add(o),this.yakIndustryPointMarkers.push(o)),o.material=d,o.center.set(.5,.5),o.position.copy(h),o.scale.set(g*.88,g*.88,1),o.visible=!0,o.userData={feature:i,layer:e,index:s,markerType:m}}),this.yakIndustryPointMarkers.slice(a.length).forEach(i=>{i.visible=!1,i.userData=null}),this.yakIndustryPointMarkerGroup.visible=!!this.mapAnimationComplete)}ensureYakIndustryPointMarkerGroup(){var e;this.yakIndustryPointMarkerGroup||(this.yakIndustryPointMarkerGroup=new Te,this.yakIndustryPointMarkerGroup.name="yak-industry-point-markers",this.yakIndustryPointMarkerGroup.visible=!1,(e=this.focusMapGroup)==null||e.add(this.yakIndustryPointMarkerGroup))}clearYakIndustryPointMarkers(){var e;this.yakIndustryPointMarkerGroup&&(this.yakIndustryPointMarkerGroup.visible=!1),(e=this.yakIndustryPointMarkers)==null||e.forEach(t=>{t.visible=!1})}bindYakIndustryPointMarkerEvents(e){e.addEventListener("mousedown",t=>{var s,o,u,d,h,g,m,L,S;if(this.clicked||!((s=this.yakIndustryPointMarkerGroup)!=null&&s.visible))return!1;const a=(u=(o=t.target)==null?void 0:o.userData)==null?void 0:u.feature;if(!a)return!1;this.clicked=!0;const i=((d=a.geometry)==null?void 0:d.coordinates)||[];this.setSelectedVectorFeatures([a]),(S=(L=this.callbacks).onFeatureInfo)==null||S.call(L,{feature:{id:((h=a.properties)==null?void 0:h.id)||((g=a.properties)==null?void 0:g.feature_id)||((m=a.properties)==null?void 0:m.project_name),properties:a.properties||{},feature:a,layer:this.currentTopicLayer,lngLat:{lng:Number(i[0]),lat:Number(i[1])}},screen:this.getPointFeatureScreenPoint(a)})}),e.addEventListener("mouseup",()=>{this.clicked=!1}),e.addEventListener("mouseover",()=>{e.visible&&(document.body.style.cursor="pointer")}),e.addEventListener("mouseout",()=>{document.body.style.cursor="default"})}getYakIndustryMarkerMaterial(e,t){const a=e.markerType||this.getYakIndustryMarkerType(t),i=`${e.fill||"#24F6C4"}-${e.stroke||"#B7FFF2"}-${a}`,s=this.yakIndustryMarkerMaterialCache.get(i);if(s)return s;const o=this.createYakIndustryMarkerTexture(e.fill,e.stroke,a),u=new ta({map:o,transparent:!0,depthTest:!1,depthWrite:!1,fog:!1});return this.yakIndustryMarkerMaterialCache.set(i,u),u}getYakIndustryMarkerType(e={}){var a;const t=String(((a=e==null?void 0:e.properties)==null?void 0:a.stageKey)||"");return Or[t]||"point"}createYakIndustryMarkerTexture(e="#24F6C4",t="#B7FFF2",a="point"){const i=document.createElement("canvas");i.width=112,i.height=112;const s=i.getContext("2d"),o=56,u=56;s.clearRect(0,0,i.width,i.height),s.beginPath(),s.arc(o,u,42,0,Math.PI*2),s.fillStyle=this.hexToRgba(e,.18),s.shadowColor=e,s.shadowBlur=20,s.fill(),this.drawYakIndustryMarkerFrame(s,a,o,u,e,t||e),s.save(),s.shadowBlur=0,s.beginPath(),s.arc(o,u,19,0,Math.PI*2),s.fillStyle="rgba(3, 23, 34, 0.64)",s.fill(),s.strokeStyle=this.hexToRgba("#FFFFFF",.32),s.lineWidth=2,s.stroke(),s.restore(),this.drawYakIndustryMarkerGlyph(s,a,o,u,"#FFFFFF");const d=new Jn(i);return d.colorSpace=ra,d.needsUpdate=!0,d}drawYakIndustryMarkerFrame(e,t,a,i,s="#24F6C4",o="#B7FFF2"){if(e.save(),e.translate(a,i),e.fillStyle=this.hexToRgba(s,.92),e.strokeStyle=this.hexToRgba(o||s,.98),e.lineWidth=4,e.shadowColor=o||s,e.shadowBlur=14,t==="pasture")e.beginPath(),e.moveTo(-34,-9),e.lineTo(0,-38),e.lineTo(34,-9),e.lineTo(28,-9),e.lineTo(28,24),e.quadraticCurveTo(28,31,21,31),e.lineTo(-21,31),e.quadraticCurveTo(-28,31,-28,24),e.lineTo(-28,-9),e.closePath();else if(t==="grass")e.beginPath(),e.moveTo(0,-38),e.bezierCurveTo(31,-22,34,18,0,38),e.bezierCurveTo(-34,18,-31,-22,0,-38),e.closePath();else if(t==="breeding"){e.beginPath();for(let u=0;u<6;u+=1){const d=-Math.PI/2+Math.PI*2*u/6,h=Math.cos(d)*35,g=Math.sin(d)*35;u===0?e.moveTo(h,g):e.lineTo(h,g)}e.closePath()}else if(t==="storage")e.beginPath(),e.moveTo(-34,-25),e.lineTo(25,-25),e.lineTo(35,-13),e.lineTo(35,27),e.lineTo(-25,27),e.lineTo(-35,15),e.lineTo(-35,-25),e.closePath();else if(t==="processing"){e.beginPath();for(let u=0;u<10;u+=1){const d=-Math.PI/2+Math.PI*2*u/10,h=u%2===0?38:30,g=Math.cos(d)*h,m=Math.sin(d)*h;u===0?e.moveTo(g,m):e.lineTo(g,m)}e.closePath()}else if(t==="equipment"){e.beginPath();for(let u=0;u<16;u+=1){const d=-Math.PI/2+Math.PI*2*u/16,h=u%2===0?38:30,g=Math.cos(d)*h,m=Math.sin(d)*h;u===0?e.moveTo(g,m):e.lineTo(g,m)}e.closePath()}else t==="service"?(e.beginPath(),e.moveTo(0,-39),e.lineTo(31,-24),e.lineTo(25,14),e.quadraticCurveTo(0,39,-25,14),e.lineTo(-31,-24),e.closePath()):(e.beginPath(),e.arc(0,0,34,0,Math.PI*2));e.fill(),e.stroke(),e.restore()}drawYakIndustryMarkerGlyph(e,t,a,i,s="#24F6C4"){if(e.save(),e.translate(a,i),e.lineCap="round",e.lineJoin="round",e.shadowBlur=0,e.fillStyle=this.hexToRgba(s,.98),e.strokeStyle=this.hexToRgba(s,.98),e.lineWidth=3,t==="pasture")e.beginPath(),e.moveTo(-12,-2),e.lineTo(0,-11),e.lineTo(12,-2),e.stroke(),e.fillRect(-9,-2,18,12),e.clearRect(-3,2,6,8);else if(t==="grass")e.beginPath(),e.moveTo(0,10),e.quadraticCurveTo(-10,1,-7,-10),e.moveTo(0,10),e.quadraticCurveTo(10,1,7,-10),e.moveTo(0,10),e.quadraticCurveTo(0,0,1,-12),e.stroke();else if(t==="breeding")e.beginPath(),e.moveTo(-8,-5),e.quadraticCurveTo(-15,-12,-18,-4),e.moveTo(8,-5),e.quadraticCurveTo(15,-12,18,-4),e.stroke(),e.beginPath(),e.ellipse(0,1,11,12,0,0,Math.PI*2),e.fill(),e.fillStyle=this.hexToRgba("#08202D",.85),e.fillRect(-5,-2,3,3),e.fillRect(2,-2,3,3);else if(t==="storage")e.beginPath(),e.moveTo(-13,-3),e.lineTo(0,-11),e.lineTo(13,-3),e.lineTo(13,9),e.lineTo(-13,9),e.closePath(),e.fill(),e.strokeStyle=this.hexToRgba("#08202D",.72),e.lineWidth=2,e.beginPath(),e.moveTo(-8,0),e.lineTo(8,0),e.moveTo(-8,5),e.lineTo(8,5),e.stroke();else if(t==="processing")e.beginPath(),e.moveTo(-13,8),e.lineTo(-13,-1),e.lineTo(-5,-6),e.lineTo(-5,-1),e.lineTo(3,-6),e.lineTo(3,-1),e.lineTo(12,-6),e.lineTo(12,8),e.closePath(),e.fill(),e.fillRect(-13,-11,5,7),e.fillStyle=this.hexToRgba("#08202D",.72),e.fillRect(-8,2,4,3),e.fillRect(0,2,4,3),e.fillRect(7,2,4,3);else if(t==="equipment"){for(let o=0;o<8;o+=1)e.save(),e.rotate(Math.PI*2*o/8),e.fillRect(8,-2,5,4),e.restore();e.beginPath(),e.arc(0,0,9,0,Math.PI*2),e.fill(),e.fillStyle=this.hexToRgba("#FFFFFF",.98),e.beginPath(),e.arc(0,0,4,0,Math.PI*2),e.fill()}else t==="service"?(e.beginPath(),e.moveTo(0,-13),e.lineTo(12,-7),e.lineTo(9,6),e.quadraticCurveTo(0,14,-9,6),e.lineTo(-12,-7),e.closePath(),e.fill(),e.strokeStyle=this.hexToRgba("#FFFFFF",.94),e.lineWidth=2.4,e.beginPath(),e.moveTo(0,-7),e.lineTo(0,6),e.moveTo(-6,-1),e.lineTo(6,-1),e.stroke()):(e.beginPath(),e.arc(0,0,7,0,Math.PI*2),e.fill());e.restore()}ensureYakIndustryPointLabelGroup(){this.yakIndustryPointLabelGroup||(this.yakIndustryPointLabelGroup=new Te,this.yakIndustryPointLabelGroup.name="yak-industry-point-labels",this.yakIndustryPointLabelGroup.rotation.x=-Math.PI/2,this.yakIndustryPointLabelGroup.visible=!1,this.scene.add(this.yakIndustryPointLabelGroup))}clearYakIndustryPointLabels(){var e;this.yakIndustryPointLabelGroup&&(this.yakIndustryPointLabelGroup.visible=!1),(e=this.yakIndustryPointLabels)==null||e.forEach(t=>{var a;t.visible=!1,(a=t.hide)==null||a.call(t)})}getYakIndustryLabelFeatures(e,t){const a=this.getVisibleVectorFeatures(e,t).filter(d=>{var h;return((h=d==null?void 0:d.geometry)==null?void 0:h.type)==="Point"}),i=Number(e==null?void 0:e.pointLabelLimit)||(a.length>36?12:Math.min(a.length,16)),s=a.map(d=>{var h;return{feature:d,score:this.getYakIndustryFeatureScore(d),town:ut((h=d.properties)==null?void 0:h.town)}}).sort((d,h)=>{var g,m;return h.score-d.score||String(((g=d.feature.properties)==null?void 0:g.name)||"").localeCompare(String(((m=h.feature.properties)==null?void 0:m.name)||""),"zh-CN")}),o=[],u=new Set;return s.forEach(d=>{o.length>=i||!d.town||u.has(d.town)||(o.push(d.feature),u.add(d.town))}),s.forEach(d=>{o.length>=i||o.includes(d.feature)||o.push(d.feature)}),o}getYakIndustryFeatureScore(e){const t=(e==null?void 0:e.properties)||{},a=[t.outputValue,t.capacity,t.value,t.count,t["年产值 (万元)"],t["年总产值 (万元)"],t["设计存栏量 (头)"],t["总库容 (吨)"]].map(i=>this.parseMapMetricNumber(i));return Math.max(...a,0)}parseMapMetricNumber(e){if(typeof e=="number")return Number.isFinite(e)?e:0;const t=String(e!=null?e:"").replace(/,/g,"").match(/-?\d+(?:\.\d+)?/);return t&&Number(t[0])||0}getYakIndustryPointLabelPosition(e,t=0){var i;const a=this.lngLatToLayerLocalPoint((i=e==null?void 0:e.geometry)==null?void 0:i.coordinates,this.depth+.42+Math.min(t,5)*.01);return a.x+=(t%3-1)*.08,a.y+=t%2===0?.07:-.06,a}getYakIndustryPointLabelHtml(e){const t=(e==null?void 0:e.properties)||{},a=this.compactYakIndustryLabelName(t.name||t.fullName||"产业主体"),i=this.formatYakIndustryLabelText(t.categoryName||t.stageName||"产业主体"),s=t.town||t.village||"红原县",o=this.getYakIndustryPointMetricText(t),u=this.getYakIndustryLabelColor(t);return`<div class="yak-industry-point-label-wrap" style="--yak-point-color:${Se(u)}">
<div class="yak-industry-point-label-head"><i></i><span>${Se(i)}</span></div>
<div class="yak-industry-point-label-name">${Se(a)}</div>
<div class="yak-industry-point-label-meta">
<span>${Se(s)}</span>
${o?`<strong>${Se(o)}</strong>`:""}
</div>
</div>`}compactYakIndustryLabelName(e=""){const t=String(e).replace(/^四川红原/,"").replace(/^红原县/,"").replace(/有限责任公司$/,"").replace(/农民专业合作社$/,"合作社").replace(/\s+/g," ").trim();return t.length>16?`${t.slice(0,15)}`:t}formatYakIndustryLabelText(e=""){return String(e).replace(/\bcxpt[-_./\s]*/gi,"").replace(/^cxpt/i,"").replace(/\s+/g," ").trim()}getYakIndustryPointMetricText(e={}){return e.capacity!==void 0&&e.capacity!==null&&e.capacity!==""&&this.parseMapMetricNumber(e.capacity)>0?this.formatYakIndustryMetricText(e.capacity,e.capacityUnit):this.parseMapMetricNumber(e.outputValue)>0?`${this.formatMapRankingValue(e.outputValue)}万元`:this.isMeaningfulMapText(e.locationType)?e.locationType:this.isMeaningfulMapText(e.status)?e.status:""}isMeaningfulMapText(e){const t=String(e!=null?e:"").trim();return!!(t&&t!=="0"&&t!=="无"&&t!=="待完善")}formatYakIndustryMetricText(e,t=""){const a=String(e!=null?e:"").trim();return!a||a==="0"?"":typeof e=="string"&&/[^\d.,\s-]/.test(a)?a:`${this.formatMapRankingValue(e)}${t||""}`}getYakIndustryLabelColor(e={}){var i,s,o,u,d,h;const t=String(e.stageKey||""),a=(((i=this.currentTopicLayer)==null?void 0:i.legends)||[]).find(g=>{var m;return String(((m=g.match)==null?void 0:m.value)||"")===t})||(String(((u=(o=(s=this.currentTopicLayer)==null?void 0:s.activeLegend)==null?void 0:o.match)==null?void 0:u.value)||"")===t?this.currentTopicLayer.activeLegend:null);return(a==null?void 0:a.fillColor)||((h=(d=this.currentTopicLayer)==null?void 0:d.activeLegend)==null?void 0:h.fillColor)||"#24F6C4"}clipVectorLayerContext(e,t){if(this.shouldClipLayerToHongyuanBoundary(t)&&this.clipContextToHongyuanBoundary(e),!this.shouldClipLayerToLayerBounds(t))return;const a=this.getLayerClipBounds(t);if(!a)return;const i=this.lngLatToLayerCanvasPoint([a.west,a.north]),s=this.lngLatToLayerCanvasPoint([a.east,a.south]),o=Math.min(i.x,s.x),u=Math.min(i.y,s.y),d=Math.abs(s.x-i.x),h=Math.abs(s.y-i.y);!d||!h||(e.beginPath(),e.rect(o,u,d,h),e.clip())}clipContextToHongyuanBoundary(e){const t=this.hongyuanBoundaryPolygons||[];t.length&&(e.beginPath(),t.forEach(a=>{a.forEach(i=>{i.forEach((s,o)=>{const u=this.lngLatToLayerCanvasPoint(s);o===0?e.moveTo(u.x,u.y):e.lineTo(u.x,u.y)}),e.closePath()})}),e.clip("evenodd"))}shouldClipLayerToHongyuanBoundary(e=this.currentTopicLayer){if(!e||e.clipToHongyuanBoundary===!1)return!1;if(e.clipToHongyuanBoundary===!0)return!0;const t=String((e==null?void 0:e.key)||"");return!!(t==="national-park-zoning"||t.startsWith("yak-"))}shouldClipLayerToLayerBounds(e=this.currentTopicLayer){return!!(e!=null&&e.clipBounds&&(e==null?void 0:e.clipToLayerBounds)!==!1)}isLngLatInHongyuanBoundary(e){const t=this.hongyuanBoundaryPolygons||[];return t.length?t.some(a=>this.isLngLatInPolygon(e,a)):!0}isLngLatInLayerClipBounds(e,t=this.currentTopicLayer){const a=this.getLayerClipBounds(t);return a?e.lng>=a.west&&e.lng<=a.east&&e.lat>=a.south&&e.lat<=a.north:!0}getLayerClipBounds(e){const t=e==null?void 0:e.clipBounds;if(!t)return null;const a=Math.max(Number(t.west),q.west),i=Math.max(Number(t.south),q.south),s=Math.min(Number(t.east),q.east),o=Math.min(Number(t.north),q.north);return![a,i,s,o].every(Number.isFinite)||a>=s||i>=o?null:{west:a,south:i,east:s,north:o}}getGeometryDrawRank(e){return String(e).includes("Polygon")?1:String(e).includes("LineString")?2:3}isEcologicalProjectLayer(e=this.currentTopicLayer){return["restoration-projects","engineering-analysis-projects"].includes(e==null?void 0:e.key)}getVectorFeatureStyle(e,t){var d,h,g;const a=t.properties||{},s=(e.legends||[]).find(m=>{var L,S;return(((L=m==null?void 0:m.matches)==null?void 0:L.length)||((S=m==null?void 0:m.match)==null?void 0:S.field))&&this.featureMatchesLegend(a,m)})||e.activeLegend||((d=e.legends)==null?void 0:d[0])||{},o=String(((h=t.geometry)==null?void 0:h.type)||"").includes("LineString"),u=((g=t.geometry)==null?void 0:g.type)==="Point";if(this.isEcologicalProjectLayer(e)){const m=o||String(a.feature_role||"")==="线性设施";return{fill:m||u?s.strokeColor||s.fillColor||"#D2EA78":s.fillColor||"#75AD49",stroke:s.strokeColor||s.fillColor||"#D2EA78",polygonAlpha:m?.08:.22,lineAlpha:m?.9:.82,lineWidth:m?3:1.85,pointRadius:u?3.8:4,glow:!1}}return(e==null?void 0:e.key)==="yak-epidemic-village-boundary"?{fill:s.fillColor||"#24F6C4",stroke:s.strokeColor||"#C9FBFF",polygonAlpha:.16,lineAlpha:1,lineWidth:3.2,pointRadius:4.5,glow:!0}:(e==null?void 0:e.key)==="artificial-grassland-plots"?{fill:s.fillColor||"#24F6C4",stroke:s.strokeColor||"#A7F8FF",polygonAlpha:.2,lineAlpha:.94,lineWidth:1.6,pointRadius:4.5,glow:!0}:(e==null?void 0:e.key)==="yak-industry-points"?{fill:s.fillColor||"#24F6C4",stroke:s.strokeColor||s.fillColor||"#B7FFF2",polygonAlpha:.36,lineAlpha:.82,lineWidth:1.6,pointRadius:this.getVectorPointRadius(e,t),glow:!0,halo:!0,marker:!0,markerType:Or[String(a.stageKey||"")]||"point"}:(e==null?void 0:e.key)==="national-park-zoning"?{fill:s.fillColor||"#30DCFF",stroke:s.strokeColor||"#F2FFFF",polygonAlpha:.38,lineAlpha:.96,lineWidth:2.7,pointRadius:4.5,glow:!1}:e!=null&&e.boundaryOnly?{fill:s.fillColor||"#24F6C4",stroke:s.strokeColor||s.fillColor||"#18F8FF",polygonAlpha:.04,lineAlpha:.96,lineWidth:10,pointRadius:4.5,glow:!0}:{fill:o||u?s.strokeColor||s.fillColor||"#30DCFF":s.fillColor||"#30DCFF",stroke:s.strokeColor||s.fillColor||"#30DCFF",polygonAlpha:.36,lineAlpha:o?.92:.9,lineWidth:o?5:2.4,pointRadius:u?this.getVectorPointRadius(e,t):4.5,glow:!0}}getVectorPointRadius(e,t){var i,s;const a=Number(((i=t==null?void 0:t.properties)==null?void 0:i.count)||((s=t==null?void 0:t.properties)==null?void 0:s.value)||0);return(e==null?void 0:e.key)==="yak-recognition-layer"?Math.max(3.8,Math.min(8.6,3.6+Math.sqrt(a)/68)):(e==null?void 0:e.key)==="yak-industry-points"?10.4:4.5}drawVectorFeature(e,t,a){if(t!=null&&t.coordinates){if(t.type==="Polygon"){this.drawPolygonPath(e,t.coordinates,a);return}if(t.type==="MultiPolygon"){t.coordinates.forEach(i=>this.drawPolygonPath(e,i,a));return}if(t.type==="LineString"){this.drawLinePath(e,t.coordinates,a);return}if(t.type==="MultiLineString"){t.coordinates.forEach(i=>this.drawLinePath(e,i,a));return}t.type==="Point"&&this.drawPointPath(e,t.coordinates,a)}}drawPolygonPath(e,t,a){Array.isArray(t==null?void 0:t[0])&&(e.save(),e.beginPath(),t.forEach(i=>{i.forEach((s,o)=>{const u=this.lngLatToLayerCanvasPoint(s);o===0?e.moveTo(u.x,u.y):e.lineTo(u.x,u.y)}),e.closePath()}),e.fillStyle=this.hexToRgba(a.fill,a.polygonAlpha),e.strokeStyle=this.hexToRgba(a.stroke,a.lineAlpha),e.lineWidth=a.lineWidth,a.glow&&(e.shadowColor=a.stroke,e.shadowBlur=14),e.fill("evenodd"),e.stroke(),e.restore())}drawLinePath(e,t,a){!Array.isArray(t)||t.length<2||(e.save(),e.beginPath(),t.forEach((i,s)=>{const o=this.lngLatToLayerCanvasPoint(i);s===0?e.moveTo(o.x,o.y):e.lineTo(o.x,o.y)}),e.strokeStyle=this.hexToRgba(a.stroke,a.lineAlpha),e.lineWidth=a.lineWidth,e.shadowColor=a.stroke,e.shadowBlur=12,e.stroke(),e.restore())}drawPointPath(e,t,a){var s;if(a.marker){this.drawMarkerPointPath(e,t,a);return}const i=this.lngLatToLayerCanvasPoint(t);e.save(),a.halo&&(e.beginPath(),e.arc(i.x,i.y,a.pointRadius*2.35,0,Math.PI*2),e.fillStyle=this.hexToRgba(a.fill,.18),e.shadowColor=a.fill,e.shadowBlur=18,e.fill()),e.beginPath(),e.arc(i.x,i.y,a.pointRadius,0,Math.PI*2),e.fillStyle=this.hexToRgba(a.fill,.96),e.shadowColor=a.stroke,e.shadowBlur=a.halo?8:12,e.fill(),a.lineWidth&&(e.lineWidth=a.lineWidth,e.strokeStyle=this.hexToRgba(a.stroke,(s=a.lineAlpha)!=null?s:.9),e.stroke()),e.restore()}drawMarkerPointPath(e,t,a){const i=this.lngLatToLayerCanvasPoint(t),s=a.pointRadius||6;e.save(),e.beginPath(),e.arc(i.x,i.y+s*.22,s*2.55,0,Math.PI*2),e.fillStyle=this.hexToRgba(a.fill,.16),e.shadowColor=a.fill,e.shadowBlur=24,e.fill(),e.beginPath(),e.moveTo(i.x,i.y+s*2.05),e.bezierCurveTo(i.x+s*1.46,i.y+s*.62,i.x+s*1.34,i.y-s*1.34,i.x,i.y-s*1.62),e.bezierCurveTo(i.x-s*1.34,i.y-s*1.34,i.x-s*1.46,i.y+s*.62,i.x,i.y+s*2.05),e.closePath(),e.fillStyle=this.hexToRgba(a.fill,.94),e.strokeStyle=this.hexToRgba(a.stroke,.98),e.lineWidth=Math.max(2,a.lineWidth||2),e.shadowColor=a.stroke,e.shadowBlur=14,e.fill(),e.stroke(),e.beginPath(),e.arc(i.x,i.y-s*.34,s*.52,0,Math.PI*2),e.fillStyle=this.hexToRgba("#FFFFFF",.96),e.shadowBlur=0,e.fill(),e.beginPath(),e.arc(i.x,i.y-s*.34,s*.82,0,Math.PI*2),e.lineWidth=Math.max(1.2,s*.14),e.strokeStyle=this.hexToRgba("#FFFFFF",.42),e.stroke(),e.restore()}lngLatToLayerCanvasPoint(e){const t=Number(e==null?void 0:e[0]),a=Number(e==null?void 0:e[1]);return{x:(t-q.west)/(q.east-q.west)*this.topicLayerCanvas.width,y:(q.north-a)/(q.north-q.south)*this.topicLayerCanvas.height}}hexToRgba(e,t=1){const a=String(e||"#30DCFF").replace("#",""),i=a.length===3?a.split("").map(h=>h+h).join(""):a,s=Number.parseInt(i,16);if(!Number.isFinite(s))return`rgba(48, 220, 255, ${t})`;const o=s>>16&255,u=s>>8&255,d=s&255;return`rgba(${o}, ${u}, ${d}, ${t})`}parseWktGeometry(e){var o;const t=String(e||"").trim();if(!t)return null;const a=t.match(/^([A-Z]+)(?:\s+[A-Z]+)?\s*\(/i),i=(o=a==null?void 0:a[1])==null?void 0:o.toUpperCase();if(!i)return null;const s=t.slice(t.indexOf("("));return i==="POLYGON"?{type:"Polygon",coordinates:this.parseWktPolygonBody(s)}:i==="MULTIPOLYGON"?{type:"MultiPolygon",coordinates:this.parseWktMultiPolygonBody(s)}:i==="POINT"?{type:"Point",coordinates:this.parseWktPoint(s)}:i==="MULTIPOINT"?{type:"MultiPoint",coordinates:this.getWktChildGroups(s).map(u=>this.parseWktPoint(u)).filter(Boolean)}:i==="LINESTRING"?{type:"LineString",coordinates:this.parseWktRing(s)}:i==="MULTILINESTRING"?{type:"MultiLineString",coordinates:this.getWktChildGroups(s).map(u=>this.parseWktRing(u)).filter(u=>u.length)}:null}parseWktMultiPolygonBody(e){return this.getWktChildGroups(e).map(t=>this.parseWktPolygonBody(t)).filter(t=>t.length)}parseWktPolygonBody(e){return this.getWktChildGroups(e).map(t=>this.parseWktRing(t)).filter(t=>t.length>=3)}getWktChildGroups(e){const t=String(e||"").trim(),a=t.startsWith("(")&&t.endsWith(")")?t.slice(1,-1):t,i=[];let s=0,o=-1;for(let u=0;u<a.length;u+=1){const d=a[u];d==="("?(s===0&&(o=u),s+=1):d===")"&&(s-=1,s===0&&o>=0&&(i.push(a.slice(o,u+1)),o=-1))}return i.length?i:[a]}parseWktRing(e){return String(e||"").replace(/^\(+|\)+$/g,"").split(",").map(a=>a.trim().split(/\s+/).slice(0,2).map(Number)).filter(([a,i])=>Number.isFinite(a)&&Number.isFinite(i))}parseWktPoint(e){const t=String(e||"").replace(/^\(+|\)+$/g,"").trim().split(/\s+/).slice(0,2).map(Number);return t.length>=2&&Number.isFinite(t[0])&&Number.isFinite(t[1])?[t[0],t[1]]:null}createProvinceMaterial(){const e=!this.useSatelliteBase;let t=new jn({color:16777215,transparent:!0,opacity:0,depthWrite:!this.usesCustomSatelliteTiles,fog:!1,side:Ie});t.onBeforeCompile=s=>{s.uniforms=V(I({},s.uniforms),{uColor1:{value:new vt(e?2780818:2152676)},uColor2:{value:new vt(e?1058614:475482)}}),s.vertexShader=s.vertexShader.replace("void main() {",`
attribute float alpha;
varying vec3 vPosition;
varying float vAlpha;
void main() {
vAlpha = alpha;
vPosition = position;
`),s.fragmentShader=s.fragmentShader.replace("void main() {",`
varying vec3 vPosition;
varying float vAlpha;
uniform vec3 uColor1;
uniform vec3 uColor2;
void main() {
`),s.fragmentShader=s.fragmentShader.replace("#include <opaque_fragment>",`
#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= transmissionAlpha + 0.1;
#endif
vec3 gradient = mix(uColor1, uColor2, vPosition.x/15.78);
${e?`outgoingLight = outgoingLight * gradient;
float topAlpha = 0.56;`:`outgoingLight = mix(outgoingLight * vec3(1.18), outgoingLight * gradient, 0.32);
float topAlpha = 0.92;`}
if(vPosition.z>0.3){
diffuseColor.a *= topAlpha;
}
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
`)};let a=this.assets.instance.getResource("side");a.wrapS=ot,a.wrapT=ot,a.repeat.set(1,1.8),a.offset.y+=.065;let i=new Qa({color:2148829,map:a,fog:!1,opacity:0,side:Ie,roughness:.58,metalness:.08});return this.time.on("tick",()=>{a.offset.y+=.005}),i.onBeforeCompile=s=>{s.uniforms=V(I({},s.uniforms),{uColor1:{value:new vt(1629410)},uColor2:{value:new vt(205365)}}),s.vertexShader=s.vertexShader.replace("void main() {",`
attribute float alpha;
varying vec3 vPosition;
varying float vAlpha;
void main() {
vAlpha = alpha;
vPosition = position;
`),s.fragmentShader=s.fragmentShader.replace("void main() {",`
varying vec3 vPosition;
varying float vAlpha;
uniform vec3 uColor1;
uniform vec3 uColor2;
void main() {
`),s.fragmentShader=s.fragmentShader.replace("#include <opaque_fragment>",`
#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= transmissionAlpha + 0.1;
#endif
vec3 gradient = mix(uColor1, uColor2, vPosition.z/1.2);
outgoingLight = outgoingLight*gradient*vec3(1.12);
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
`)},[t,i]}getDefaultTownRanking(){return{title:"乡镇统计加载中",unit:"",rows:Gr.map(e=>({name:e.name,value:0,unit:""}))}}getTownRankingMeta(e=this.currentTownRanking){var i,s,o,u;const t=this.getDefaultTownRanking(),a=Xu(e);return{title:(e==null?void 0:e.title)||t.title,unit:(e==null?void 0:e.unit)||t.unit,metricLabel:(e==null?void 0:e.metricLabel)||(e==null?void 0:e.legendName)||"",note:(e==null?void 0:e.note)||"",hideTownNames:Yr(e),hideMapLabels:va(e),hideTownLabelStats:(i=e==null?void 0:e.hideTownLabelStats)!=null?i:this.hideTownLabelStatsByDefault,calloutMode:a,showBars:(s=e==null?void 0:e.showBars)!=null?s:!1,showPointMarkers:(o=e==null?void 0:e.showPointMarkers)!=null?o:a,onlyRankedTownLabels:(u=e==null?void 0:e.onlyRankedTownLabels)!=null?u:!1,showMissingTownStats:(e==null?void 0:e.showMissingTownStats)===!0}}getTownRankingRows(e=this.currentTownRanking,t=7,a=!0){var d;const i=this.getDefaultTownRanking(),s=(d=e==null?void 0:e.rows)!=null&&d.length?e.rows:a?i.rows:[],o=this.getTownRankingMeta(e),u=s.map(h=>{const g=this.townMetaByName.get(ut(h.name));return g?V(I(I({},g),h),{name:g.name,enName:g.enName,center:g.center,centroid:g.centroid,value:le(h.value),unit:h.unit||o.unit,metricTitle:o.title}):null}).filter(Boolean).sort((h,g)=>g.value-h.value).map((h,g)=>V(I({},h),{rank:g+1}));return Number.isFinite(t)?u.slice(0,t):u}getVillageRankingRows(e=this.currentTownRanking){const t=this.getTownRankingMeta(e);return((e==null?void 0:e.rows)||[]).map((a,i)=>{var h,g,m,L,S,C,F,E;const s=le((h=a.lng)!=null?h:a.longitude,NaN),o=le((g=a.lat)!=null?g:a.latitude,NaN);if(!Number.isFinite(s)||!Number.isFinite(o))return null;const u=le((m=a.displayValue)!=null?m:a.value),d=le((C=(S=(L=a.rawValue)!=null?L:a.earTagCount)!=null?S:a.ear_tag_count)!=null?C:a.value);return V(I({},a),{key:a.key||`${a.town||""}-${a.village||a.name||i}`,name:a.name||a.village||`${i+1}`,town:a.town||"",lng:s,lat:o,value:u,rawValue:d,recordCount:le((F=a.recordCount)!=null?F:a.record_count,0),imageRate:le((E=a.imageRate)!=null?E:a.image_rate,0),unit:a.displayUnit||a.unit||t.unit,metricTitle:t.title,metricLabel:a.metricLabel||t.metricLabel||""})}).filter(Boolean).sort((a,i)=>i.rawValue-a.rawValue).map((a,i)=>V(I({},a),{rank:i+1}))}getVillageRankingHtml(e,t){const a=t.hideTownNames?"":`<span>${Se(e.town||"红原县")}</span>`;return e.displayMode==="park-village"||t.displayMode==="park-village"?`<div class="epidemic-village-card is-park-village ${e.rank>8?"is-small":""}">
<div class="village-card-head">
<strong>${Se(e.name)}</strong>
${a}
</div>
<div class="village-card-body">
<span class="metric">${Se(e.metricLabel||t.metricLabel||"")}</span>
<span class="number">${this.formatMapRankingValue(e.value)}</span>
<span class="unit">${Se(e.unit||t.unit||"")}</span>
</div>
</div>`:`<div class="epidemic-village-card ${e.rank>8?"is-small":""}">
<div class="village-card-head">
<strong>${Se(e.name)}</strong>
${a}
</div>
<div class="village-card-body">
<span class="metric">${Se(e.metricLabel||"防疫")}</span>
<span class="number">${this.formatMapRankingValue(e.value)}</span>
<span class="unit">${Se(e.unit||t.unit||"")}</span>
</div>
<div class="village-card-foot">
<span>台账 ${this.formatMapCompactValue(e.recordCount)}条</span>
<span>耳标 ${this.formatMapCompactValue(e.rawValue)}头</span>
</div>
</div>`}ensureVillageRankingGroup(){this.villageRankingGroup||(this.villageRankingGroup=new Te,this.villageRankingGroup.rotation.x=-Math.PI/2,this.villageRankingGroup.visible=!1,this.scene.add(this.villageRankingGroup),this.villageRankingLabels=[])}hideVillageRankingLabels(){var e;this.villageRankingGroup&&(this.villageRankingGroup.visible=!1),(e=this.villageRankingLabels)==null||e.forEach(t=>{t.visible=!1})}hideAllMapStatisticLabels(){var e,t,a,i;this.updateTownNameLabelStats(null),this.setTownNameLabelsVisible(!1),this.hideVillageRankingLabels(),this.hideTradeFlowLayer(),this.clearInfoPointStats(),(e=this.allProvinceLabel)==null||e.forEach(s=>{s.visible=!1}),(t=this.allBar)==null||t.forEach(s=>{s.visible=!1,s.scale.set(1,1,0)}),(a=this.allBarMaterial)==null||a.forEach(s=>{s.opacity=0}),(i=this.allGuangquan)==null||i.forEach(s=>{s.visible=!1})}setTownNameLabelsVisible(e=!0){var t;(t=this.townNameLabels)==null||t.forEach(a=>{a.visible=e})}updateVillageRankingLabels(e=this.currentTownRanking){if(this.ensureVillageRankingGroup(),!zr(e)){this.hideVillageRankingLabels();return}const t=this.getVillageRankingRows(e),a=this.getTownRankingMeta(e);if(!t.length){this.hideVillageRankingLabels();return}this.villageRankingGroup.visible=this.mapAnimationComplete,t.forEach((i,s)=>{let o=this.villageRankingLabels[s];o||(o=this.label3d.create("","epidemic-village-label",!0),this.label3d.setLabelStyle(o,.0135,"x"),o.setParent(this.villageRankingGroup),this.villageRankingLabels.push(o));const[u,d]=this.geoProjection([i.lng,i.lat]),h=(s%3-1)*.06,g=Math.floor(s/3)%2*.04;o.init(this.getVillageRankingHtml(i,a),new ie(u+h,-d+g,this.depth+1.55+Math.min(s,6)*.015)),o.visible=!0,o.userData=I({},i)}),this.villageRankingLabels.slice(t.length).forEach(i=>{i.visible=!1})}ensureTradeFlowGroup(){this.tradeFlowGroup||(this.tradeFlowGroup=new Te,this.tradeFlowGroup.name="yak-trade-flow",this.tradeFlowGroup.visible=!1,this.tradeFlowMeshGroup=new Te,this.tradeFlowMeshGroup.name="yak-trade-flow-mesh",this.tradeFlowMeshGroup.rotation.x=-Math.PI/2,this.tradeFlowLabelGroup=new Te,this.tradeFlowLabelGroup.name="yak-trade-flow-label",this.tradeFlowLabelGroup.rotation.x=-Math.PI/2,this.tradeFlowGroup.add(this.tradeFlowMeshGroup,this.tradeFlowLabelGroup),this.scene.add(this.tradeFlowGroup))}hideTradeFlowLayer(){var e,t;this.tradeFlowGroup&&(this.tradeFlowGroup.visible=!1),(e=this.tradeFlowLabels)==null||e.forEach(a=>{a.visible=!1}),(t=this.tradeFlowPulseSprites)==null||t.forEach(a=>{a.visible=!1})}clearTradeFlowLayer(){this.tradeFlowMeshGroup&&(this.tradeFlowMeshGroup.children.forEach(e=>{var t;(t=e.traverse)==null||t.call(e,a=>this.disposeObject3D(a))}),this.tradeFlowMeshGroup.clear(),this.tradeFlowMaterials=[],this.tradeFlowPulseSprites=[])}getTradeFlowSource(e=this.currentTownRanking){var s,o,u,d;const t=(e==null?void 0:e.source)||{},a=le((s=t.lng)!=null?s:t.longitude,NaN),i=le((o=t.lat)!=null?o:t.latitude,NaN);return!Number.isFinite(a)||!Number.isFinite(i)?null:{name:t.name||"红原牦牛交易市场",lng:a,lat:i,total:le((d=(u=t.total)!=null?u:t.headCount)!=null?d:t.value,NaN)}}getTradeFlowRows(e=this.currentTownRanking){const t=this.getTownRankingMeta(e);return((e==null?void 0:e.rows)||[]).map((a,i)=>{var L,S,C,F,E,D;const s=le((L=a.lng)!=null?L:a.longitude,NaN),o=le((S=a.lat)!=null?S:a.latitude,NaN),u=le((E=(F=(C=a.headCount)!=null?C:a.head_count)!=null?F:a.rawValue)!=null?E:a.value),d=a.displayName||a.display_name||a.name,h=a.mapTownName||a.map_town_name||a.town||a.startTown||a.start_town||d,g=this.townMetaByName.get(ut(h)),m=Number.isFinite(s)&&Number.isFinite(o)?{lng:s,lat:o}:g!=null&&g.center?{lng:g.center[0],lat:g.center[1]}:null;return!m||!Number.isFinite(u)?null:V(I(I({},a),g),{key:a.key||`${(g==null?void 0:g.name)||d||h||"trade-source"}-${i}`,name:d||h||(g==null?void 0:g.name)||`来源${i+1}`,townName:(g==null?void 0:g.name)||h,lng:m.lng,lat:m.lat,labelSide:a.labelSide||a.label_side||this.getTradeSourceLabelSide(g,i),value:u,headCount:u,recordCount:le((D=a.recordCount)!=null?D:a.record_count,0),unit:a.unit||t.unit||"头"})}).filter(Boolean).sort((a,i)=>i.value-a.value).map((a,i)=>V(I({},a),{rank:i+1}))}getTradeMarketHtml(e,t){const a=Number.isFinite(e.total)?e.total:t.reduce((i,s)=>i+le(s.value),0);return`<div class="trade-market-card">
<div class="market-title">${Se(e.name)}</div>
<div class="market-total"><span>${this.formatMapIntegerValue(a)}</span><em>头</em></div>
</div>`}getTradeFlowDisplayName(e=""){const t=String(e||"").replace(/^.*红原县/,"").replace(/\s+/g,"");return t.length>7?`${t.slice(0,7)}`:t||"来源区域"}getTradeFlowLabelHtml(e){return`<div class="trade-flow-card${e.labelSide?` is-${String(e.labelSide).replace(/[^a-z0-9-]/gi,"")}`:""}">
<div class="flow-head"><span>${String(e.rank).padStart(2,"0")}</span><strong>${Se(this.getTradeFlowDisplayName(e.name))}</strong></div>
<div class="flow-body"><em>${this.formatMapIntegerValue(e.value)}</em><b>${Se(e.unit||"头")}</b></div>
</div>`}getTradeFlowLabelOffset(e,t){return new ie(0,0,0)}getTradeSourceLabelSide(e,t=0){var s,o;const a=Number((s=e==null?void 0:e.center)==null?void 0:s[0]),i=Number((o=e==null?void 0:e.center)==null?void 0:o[1]);return Number.isFinite(a)&&a<this.geoProjectionCenter[0]-.18?"left":Number.isFinite(a)&&a>this.geoProjectionCenter[0]+.2?"right":Number.isFinite(i)&&i>this.geoProjectionCenter[1]+.22?"top":Number.isFinite(i)&&i<this.geoProjectionCenter[1]-.26?"bottom":["right","left","top","bottom"][t%4]}getTradeLocalPoint(e,t,a=0){const[i,s]=this.geoProjection([e,t]);return new ie(i,-s,this.depth+a)}getTradeFlowPoint(e,t=0){return this.getTradeLocalPoint(e.lng,e.lat,t)}getLocalTradeFlowCurve(e,t,a){const i=this.getTradeFlowPoint(e,.76),s=this.getTradeLocalPoint(t.lng,t.lat,.86),o=i.clone().lerp(s,.5),u=i.distanceTo(s);o.z+=Math.max(.32,Math.min(.82,u*.22+a*.012));const d=new ie(-(s.y-i.y),s.x-i.x,0);return d.lengthSq()>0&&(d.normalize().multiplyScalar((a%2===0?1:-1)*Math.min(.18,.05+u*.02)),o.add(d)),new Il([i,o,s])}tradeGeoProjection(e){return Ht().center(this.tradeGeoProjectionCenter).scale(this.tradeGeoProjectionScale).translate([0,0])(e)}setTradeNationalMapVisible(e){const t=!!e;if(!(!t&&!this.isTradeNationalMapActive&&!this.tradeNationalMapGroup&&!this.tradeFlowGroup)){if(t&&!this.createTradeNationalMap()){this.isTradeNationalMapActive=!1;return}this.isTradeNationalMapActive=t,this.tradeNationalMapGroup&&(this.tradeNationalMapGroup.visible=t&&this.mapAnimationComplete),this.tradeNationalLabelGroup&&(this.tradeNationalLabelGroup.visible=t&&this.mapAnimationComplete),this.mapGroup&&(this.mapGroup.visible=!t),this.labelGroup&&(this.labelGroup.visible=!t),this.flyLineGroup&&(this.flyLineGroup.visible=!t&&this.mapAnimationComplete),this.flyLineFocusGroup&&(this.flyLineFocusGroup.visible=!t&&this.mapAnimationComplete),this.scatterGroup&&(this.scatterGroup.visible=!t&&this.mapAnimationComplete),this.topicLayerMaterial&&t&&(this.topicLayerMaterial.opacity=0),t&&this.mapAnimationComplete?this.animateMapCamera(new ie(0,11.4,16.2),new ie(0,-.05,0),.65):!t&&this.mapAnimationComplete&&this.applyLayerMapView(this.currentTopicLayer,{force:!0})}}createTradeSourceMarker(e,t,a,i,s=!0){const o=new vt(t%3===1?16766828:t%3===2?2617536:3202303),u=this.getTradeFlowPoint(e,.72);if(i&&s){const F=this.getLocalTradeFlowCurve(e,i,t),E=new be({color:o,transparent:!0,opacity:.42,depthWrite:!1,depthTest:!1,fog:!1,blending:Ge}),D=.012+Math.min(.012,le(e.value)/Math.max(a,1)*.01),J=new qe(new Gl(F,48,D,8,!1),E);J.renderOrder=31,this.tradeFlowMeshGroup.add(J),this.tradeFlowMaterials.push(E);const re=new ta({map:this.assets.instance.getResource("point"),color:o,transparent:!0,opacity:.92,depthWrite:!1,depthTest:!1,fog:!1,blending:Ge}),K=new ea(re),G=.12+Math.min(.08,le(e.value)/Math.max(a,1)*.06);K.renderOrder=36,K.scale.set(G,G,G),K.userData={curve:F,phase:t*.13%1,speed:.16+Math.min(.16,le(e.value)/Math.max(a,1)*.12)},K.position.copy(F.getPointAt(K.userData.phase)),this.tradeFlowPulseSprites.push(K),this.tradeFlowMeshGroup.add(K)}const d=new ta({map:this.assets.instance.getResource("point"),color:o,transparent:!0,opacity:.95,depthWrite:!1,depthTest:!1,fog:!1,blending:Ge}),h=new ea(d),g=.22+Math.min(.34,le(e.value)/Math.max(a,1)*.28);h.renderOrder=34,h.scale.set(g,g,g),h.position.copy(u),this.tradeFlowMeshGroup.add(h);const m=this.assets.instance.getResource("guangquan1"),L=new be({map:m,alphaMap:m,color:o,transparent:!0,opacity:.52,depthWrite:!1,depthTest:!1,fog:!1,blending:Ge,side:Ie}),S=.38+Math.min(.36,le(e.value)/Math.max(a,1)*.28),C=new qe(new At(S,S),L);C.renderOrder=29,C.position.copy(this.getTradeFlowPoint(e,.5)),this.tradeFlowMeshGroup.add(C)}createTradeMarketMarker(e){const t=this.assets.instance.getResource("point"),a=this.assets.instance.getResource("guangquan1"),i=this.getTradeLocalPoint(e.lng,e.lat,.82),s=new ta({map:t,color:16773997,transparent:!0,opacity:1,depthWrite:!1,depthTest:!1,fog:!1,blending:Ge}),o=new ea(s);o.renderOrder=35,o.scale.set(.34,.34,.34),o.position.copy(i),this.tradeFlowMeshGroup.add(o);const u=new be({map:a,alphaMap:a,color:16773997,transparent:!0,opacity:.72,depthWrite:!1,depthTest:!1,fog:!1,blending:Ge,side:Ie}),d=new qe(new At(.58,.58),u);d.renderOrder=29,d.position.copy(this.getTradeLocalPoint(e.lng,e.lat,.58)),this.tradeFlowMeshGroup.add(d)}disposeObject3D(e){var t,a,i,s;(a=(t=e.geometry)==null?void 0:t.dispose)==null||a.call(t),Array.isArray(e.material)?e.material.forEach(o=>{var u;return(u=o==null?void 0:o.dispose)==null?void 0:u.call(o)}):(s=(i=e.material)==null?void 0:i.dispose)==null||s.call(i)}updateTradeFlowPulses(e=.016){var t,a;!((t=this.tradeFlowGroup)!=null&&t.visible)||!((a=this.tradeFlowPulseSprites)!=null&&a.length)||this.tradeFlowPulseSprites.forEach(i=>{var u;const s=(u=i.userData)==null?void 0:u.curve;if(!s)return;const o=(le(i.userData.phase)+le(i.userData.speed,.16)*e)%1;i.userData.phase=o,i.position.copy(s.getPointAt(o))})}updateTradeFlowLayer(e=this.currentTownRanking){if(!Wr(e)){this.hideTradeFlowLayer();return}this.ensureTradeFlowGroup();const t=this.getTradeFlowSource(e),a=this.getTradeFlowRows(e);if(!t||!a.length){this.clearTradeFlowLayer(),this.hideTradeFlowLayer();return}this.clearTradeFlowLayer(),this.tradeFlowGroup.visible=this.mapAnimationComplete;const i=Zu(e);this.createTradeMarketMarker(t);const s=Math.max(...a.map(d=>d.value),1);a.forEach((d,h)=>{this.createTradeSourceMarker(d,h,s,t,i)});const o=a.length+1;for(let d=this.tradeFlowLabels.length;d<o;d+=1){const h=this.label3d.create("",d===0?"trade-market-label":"trade-flow-label",!0);this.label3d.setLabelStyle(h,d===0?.014:.0125,"x"),h.setParent(this.tradeFlowLabelGroup),this.tradeFlowLabels.push(h)}const u=this.tradeFlowLabels[0];u.element.className="trade-market-label",u.init(this.getTradeMarketHtml(t,a),this.getTradeLocalPoint(t.lng,t.lat,.9)),u.visible=!0,u.userData=V(I({},t),{rows:a.length}),a.forEach((d,h)=>{const g=this.tradeFlowLabels[h+1];g.element.className="trade-flow-label",g.init(this.getTradeFlowLabelHtml(d),this.getTradeFlowPoint(d,.78).add(this.getTradeFlowLabelOffset(d,h))),g.visible=!0,g.userData=I({},d)}),this.tradeFlowLabels.slice(o).forEach(d=>{d.visible=!1})}hasTownRankingRows(e=this.currentTownRanking){return this.getTownRankingRows(e,Number.POSITIVE_INFINITY,!1).length>0}formatMapRankingValue(e){const t=le(e);return Math.abs(t)>=100?String(Math.round(t)):Math.abs(t)>=10?String(Number(t.toFixed(1))):String(Number(t.toFixed(2)))}formatMapCompactValue(e){const t=le(e);return Math.abs(t)>=1e4?`${Number((t/1e4).toFixed(Math.abs(t)>=1e5?1:2))}`:Math.abs(t)>=1e3?`${Number((t/1e3).toFixed(1))}`:this.formatMapRankingValue(t)}formatMapIntegerValue(e){const t=le(e);return Math.round(t).toLocaleString("zh-CN")}getBarHeight(e,t){return t?Math.max(2.8*.12,2.8*(le(e)/t)):2.8*.25}createBarGeometry(e){const a=new _l(.06999999999999999,.06999999999999999,e);return a.translate(0,0,e/2),a}getProvinceLabelHtml(e,t,a){return`<div class="provinces-label ${t>4?"yellow":""}">
<div class="provinces-label-wrap">
<div class="label-main">
<div class="label-title">${a.title}</div>
<div class="number"><span class="value" data-target-value="${e.value}">${this.formatMapRankingValue(e.value)}</span><span class="unit">${e.unit||a.unit}</span></div>
<div class="name">${e.name}</div>
</div>
<div class="no">${t+1}</div>
</div>
</div>`}updateBarItem(e,t,a,i,s=!0){var h,g;const o=this.getBarHeight(t.value,i),[u,d]=this.geoProjection(t.centroid);return e.visible=!0,(g=(h=e.geometry)==null?void 0:h.dispose)==null||g.call(h),e.geometry=this.createBarGeometry(o),e.position.set(u,-d,this.depth+.45),e.userData=V(I({},t),{targetValue:t.value,geoHeight:o}),e.children.forEach(m=>{var L,S,C,F;(S=(L=m.geometry)==null?void 0:L.dispose)==null||S.call(L),Array.isArray(m.material)?m.material.forEach(E=>{var D;return(D=E==null?void 0:E.dispose)==null?void 0:D.call(E)}):(F=(C=m.material)==null?void 0:C.dispose)==null||F.call(C)}),e.clear(),e.add(...this.createHUIGUANG(o,a>3?16776948:7863285)),s?na.to(e.scale,{duration:.45,x:1,y:1,z:1,ease:"power2.out"}):this.mapAnimationComplete&&e.scale.set(1,1,1),{x:u,y:d,geoHeight:o}}updateProvinceLabel(e,t,a,i,s,o=!0){var C;const u=le((C=e.userData)==null?void 0:C.targetValue,t.value);e.visible=!0,e.userData=V(I({},t),{targetValue:t.value}),e.position.copy(i);const d=e.element.querySelector(".label-title"),h=e.element.querySelector(".number .value"),g=e.element.querySelector(".number .unit"),m=e.element.querySelector(".name"),L=e.element.querySelector(".no");!d||!h||!g||!m||!L?e.element.innerHTML=this.getProvinceLabelHtml(t,a,s):(d.innerText=s.title,h.dataset.targetValue=String(t.value),h.innerText=this.formatMapRankingValue(t.value),g.innerText=t.unit||s.unit,m.innerText=t.name,L.innerText=a+1);const S=e.element.querySelector(".provinces-label-wrap");if(this.mapAnimationComplete&&(S.style.opacity="1",S.style.transform="translate(50%, 0)"),o&&this.mapAnimationComplete){const F=e.element.querySelector(".number .value"),D={value:u};na.to(D,{value:t.value,duration:.45,ease:"power2.out",onUpdate:()=>{F.innerText=this.formatMapRankingValue(D.value)},onComplete:()=>{F.dataset.previousValue=String(t.value),F.innerText=this.formatMapRankingValue(t.value)}})}}clearTownNameLabelStat(e){const t=e.element.querySelector(".town-stat-label"),a=e.element.querySelector(".town-stat-value"),i=e.element.querySelector(".town-stat-unit"),s=e.element.querySelector(".town-rank"),o=e.element.querySelector(".town-stat-metric");t==null||t.classList.remove("has-stat"),e.element.style.pointerEvents="none",e.element.style.cursor="",a&&(a.innerText=""),i&&(i.innerText=""),s&&(s.innerText=""),o&&(o.innerText="")}updateTownNameLabelStats(e=this.currentTownRanking){var o;if(!((o=this.townNameLabels)!=null&&o.length))return;const t=this.getTownRankingRows(e,Number.POSITIVE_INFINITY,!1),a=this.getTownRankingMeta(e);if(a.hideTownLabelStats){this.townNameLabels.forEach(u=>{var g,m;const d=((g=u.userData)==null?void 0:g.townName)||((m=u.userData)==null?void 0:m.name),h=u.element.querySelector(".town-name");h&&(h.innerText=d||""),this.clearTownNameLabelStat(u),u.visible=!a.hideTownNames});return}const i=new Map(t.map(u=>[ut(u.name),u])),s=!!(a.showMissingTownStats&&e&&t.length&&(a.metricLabel||a.unit||a.title));this.townNameLabels.forEach(u=>{var J,re;const d=((J=u.userData)==null?void 0:J.townName)||((re=u.userData)==null?void 0:re.name),h=i.get(ut(d));if(a.onlyRankedTownLabels&&!h){this.clearTownNameLabelStat(u),u.element.style.pointerEvents="none",u.element.style.cursor="",u.visible=!1;return}const g=h||(s?{name:d,value:0,unit:a.unit,metricLabel:a.metricLabel,rank:null}:null);if(!g){this.clearTownNameLabelStat(u),u.element.style.pointerEvents="none",u.element.style.cursor="";return}const m=u.element.querySelector(".town-stat-label"),L=u.element.querySelector(".town-name"),S=u.element.querySelector(".town-stat-value"),C=u.element.querySelector(".town-stat-unit"),F=u.element.querySelector(".town-rank"),E=u.element.querySelector(".town-stat-metric");m==null||m.classList.add("has-stat"),L&&(L.innerText=d),E&&(E.innerText=g.metricLabel||a.metricLabel||""),S&&(S.innerText=this.formatMapRankingValue(g.value)),C&&(C.innerText=g.unit||a.unit||""),F&&(F.innerText=g.rank?`${g.rank}`:"");const D=this.isNationalParkTownSelectionActive()&&!!h;u.element.style.pointerEvents=D?"auto":"none",u.element.style.cursor=D?"pointer":"",u.userData=V(I(I({},u.userData),g),{townName:d,targetValue:g.value})})}getInfoPointHtml(e,t=this.getTownRankingMeta()){const a=String(e.metricLabel||t.metricLabel||t.title||"统计指标").replace(/排行$/,""),i=Number(e.rank),s=Number.isFinite(i)?String(i).padStart(2,"0"):"--";return`<div class="info-point-wrap ${i<=3?"is-prime":""}">
<div class="info-point-wrap-inner">
<div class="info-point-head">
<span class="rank">${s}</span>
<strong>${Se(e.name||"红原县")}</strong>
</div>
<div class="info-point-metric">${Se(a)}</div>
<div class="info-point-value">
<span>${this.formatMapRankingValue(e.value)}</span>
<em>${Se(e.unit||t.unit||"")}</em>
</div>
</div>
</div>`}updateInfoPointStats(){var o,u;if(!((o=this.infoPointSprites)!=null&&o.length)||!((u=this.infoLabelElement)!=null&&u.length))return;if(!this.showTownRankingPointMarkers){this.clearInfoPointStats();return}const e=this.getTownRankingRows(this.currentTownRanking,Number.POSITIVE_INFINITY,!1);if(!e.length){this.clearInfoPointStats();return}const t=this.getTownRankingMeta(),a=e.slice(0,this.infoPointSprites.length),i=Math.max(...a.map(d=>d.value),1);this.infoPointSprites.forEach((d,h)=>{const g=a[h],m=this.infoLabelElement[h];if(!g){d.visible=!1,d.scale.set(0,0,0),m&&(m.visible=!1);return}const[L,S]=this.geoProjection(g.centroid||g.center),C=[L,-S,this.depth+.72];d.userData=V(I(I({},d.userData),g),{position:C,value:g.value,unit:g.unit||t.unit,rank:g.rank,metricTitle:t.title,index:h}),d.position.set(...C),d.visible=this.showTownRankingPointMarkers;const F=.78+g.value/i*.44;if(d.scale.set(F,F,F),m){const E=(h%2===0?.22:-.18)+(h===0?.12:0),D=h%3===0?.08:-.04;m.position.set(L+E,-S+D,this.depth+1.88+Math.min(h,4)*.03),m.userData=V(I({},g),{index:h}),m.element.innerHTML=this.getInfoPointHtml(g,t)}});const s=this.infoLabelElement[this.infoPointIndex];s&&this.showTownRankingPointMarkers&&this.mapAnimationComplete&&(s.visible=!0),this.showTownRankingPointMarkers&&this.mapAnimationComplete&&!this.infoPointLabelTime&&this.createInfoPointLabelLoop()}clearInfoPointStats(){var e,t;clearInterval(this.infoPointLabelTime),this.infoPointLabelTime=null,this.infoPointIndex=0,this.InfoPointGroup&&(this.InfoPointGroup.visible=!1),(e=this.infoLabelElement)==null||e.forEach(a=>{a.visible=!1}),(t=this.infoPointSprites)==null||t.forEach(a=>{a.visible=!1,a.scale.set(0,0,0)})}createBar(){const e=this.getTownRankingRows();this.getTownRankingMeta();const t=new Te;this.barGroup=t;const a=Math.max(...e.map(i=>i.value),1);this.allBar=[],this.allBarMaterial=[],this.allGuangquan=[],this.allProvinceLabel=[],e.map((i,s)=>{const o=this.getBarHeight(i.value,a),u=new be({color:16777215,transparent:!0,opacity:0,depthTest:!1,fog:!1});new en(u,{uColor1:s>3?16506760:5291006,uColor2:s>3?16776948:7863285,size:o,dir:"y"});const d=new qe(this.createBarGeometry(o),u);d.renderOrder=5;const[h,g]=this.geoProjection(i.centroid);d.position.set(h,-g,this.depth+.45),d.scale.set(1,1,0),d.userData=V(I({},i),{targetValue:i.value,geoHeight:o});const m=this.createQuan(new ie(h,this.depth+.44,g),s);d.add(...this.createHUIGUANG(o,s>3?16776948:7863285)),t.add(d),t.rotation.x=-Math.PI/2,this.allBar.push(d),this.allBarMaterial.push(u),this.allGuangquan.push(m)}),this.scene.add(t),this.updateTownNameLabelStats(this.currentTownRanking)}setTownRanking(e){var s,o,u,d,h,g,m,L,S,C,F,E,D,J,re,K;this.currentTownRanking=e;const t=this.getTownRankingMeta(e);if(this.showTownRankingBars=!!t.showBars,this.showTownRankingPointMarkers=!!t.showPointMarkers,t.hideMapLabels){this.hideAllMapStatisticLabels(),this.mapGroup&&(this.mapGroup.visible=!0),this.labelGroup&&(this.labelGroup.visible=!0),this.flyLineGroup&&(this.flyLineGroup.visible=this.mapAnimationComplete),this.flyLineFocusGroup&&(this.flyLineFocusGroup.visible=this.mapAnimationComplete),this.scatterGroup&&(this.scatterGroup.visible=this.mapAnimationComplete);return}if(Wr(e)){this.setTradeNationalMapVisible(!1),this.updateTownNameLabelStats(null),this.setTownNameLabelsVisible(!1),this.hideVillageRankingLabels(),this.clearInfoPointStats(),this.mapGroup&&(this.mapGroup.visible=!0),this.labelGroup&&(this.labelGroup.visible=!1),this.flyLineGroup&&(this.flyLineGroup.visible=!1),this.flyLineFocusGroup&&(this.flyLineFocusGroup.visible=!1),this.scatterGroup&&(this.scatterGroup.visible=!1),(s=this.allBar)!=null&&s.length&&(this.allBar.forEach(G=>{G.visible=!1,G.scale.set(1,1,0)}),(o=this.allBarMaterial)==null||o.forEach(G=>{G.opacity=0}),(u=this.allProvinceLabel)==null||u.forEach(G=>{G.visible=!1}),(d=this.allGuangquan)==null||d.forEach(G=>{G.visible=!1})),this.updateTradeFlowLayer(e),(e!=null&&e.mapView||e!=null&&e.cameraPosition)&&this.applyLayerMapView(null);return}if(this.setTradeNationalMapVisible(!1),this.hideTradeFlowLayer(),this.mapGroup&&(this.mapGroup.visible=!0),this.labelGroup&&(this.labelGroup.visible=!0),this.flyLineGroup&&(this.flyLineGroup.visible=this.mapAnimationComplete),this.flyLineFocusGroup&&(this.flyLineFocusGroup.visible=this.mapAnimationComplete),this.scatterGroup&&(this.scatterGroup.visible=this.mapAnimationComplete),zr(e)){this.updateTownNameLabelStats(null),this.setTownNameLabelsVisible(!Yr(e)),this.clearInfoPointStats(),this.updateVillageRankingLabels(e),(h=this.allBar)!=null&&h.length&&(this.allBar.forEach(G=>{G.visible=!1,G.scale.set(1,1,0)}),(g=this.allBarMaterial)==null||g.forEach(G=>{G.opacity=0}),(m=this.allProvinceLabel)==null||m.forEach(G=>{G.visible=!1}),(L=this.allGuangquan)==null||L.forEach(G=>{G.visible=!1}));return}if(this.setTownNameLabelsVisible(!t.calloutMode&&!t.hideTownNames),this.hideVillageRankingLabels(),t.calloutMode?this.updateTownNameLabelStats(null):this.updateTownNameLabelStats(e),!((S=this.allBar)!=null&&S.length))return;if(!this.showTownRankingBars){this.allBar.forEach(G=>{G.visible=!1,G.scale.set(1,1,0)}),(C=this.allBarMaterial)==null||C.forEach(G=>{G.opacity=0}),(F=this.allProvinceLabel)==null||F.forEach(G=>{G.visible=!1}),(E=this.allGuangquan)==null||E.forEach(G=>{G.visible=!1}),this.showTownRankingPointMarkers?(this.InfoPointGroup&&(this.InfoPointGroup.visible=this.mapAnimationComplete&&this.hasTownRankingRows(e)),this.updateInfoPointStats()):this.clearInfoPointStats();return}const a=this.getTownRankingRows(e,7,!1);if(!a.length){this.allBar.forEach(G=>{G.visible=!1,G.scale.set(1,1,0)}),(D=this.allProvinceLabel)==null||D.forEach(G=>{G.visible=!1}),(J=this.allGuangquan)==null||J.forEach(G=>{G.visible=!1}),this.clearInfoPointStats();return}this.InfoPointGroup&&(this.InfoPointGroup.visible=this.showTownRankingPointMarkers&&this.mapAnimationComplete),(re=this.infoPointSprites)==null||re.forEach(G=>{G.visible=this.showTownRankingPointMarkers});const i=Math.max(...a.map(G=>G.value),1);this.allBar.forEach((G,Ce)=>{const Ue=Ce<a.length;G.visible=Ue,Ue||G.scale.set(1,1,0)}),(K=this.allProvinceLabel)==null||K.forEach(G=>{G.visible=!1}),this.allGuangquan.forEach((G,Ce)=>{G.visible=Ce<a.length}),a.forEach((G,Ce)=>{const Ue=this.allBar[Ce],at=this.allGuangquan[Ce];if(!Ue)return;const{x:wt,y:z}=this.updateBarItem(Ue,G,Ce,i,this.mapAnimationComplete);at&&(at.visible=!0,at.position.set(0,0,0),at.children.forEach(je=>{je.position.set(wt,this.depth+.44,z),this.mapAnimationComplete&&je.scale.set(1,1,1)}))}),this.updateInfoPointStats()}createEvent(){let e=[];const t=i=>{i.traverse(s=>{s.isMesh&&(s.material=this.defaultMaterial)})},a=i=>{i.traverse(s=>{s.isMesh&&(s.material=this.defaultLightMaterial)})};this.eventElement.map(i=>{this.interactionManager.add(i),i.addEventListener("mousedown",s=>{this.handleMapClick(s)}),i.addEventListener("mouseover",s=>{e.includes(s.target.parent)||e.push(s.target.parent),document.body.style.cursor="pointer",a(s.target.parent)}),i.addEventListener("mouseout",s=>{e=e.filter(o=>o.userData.name!==s.target.parent.userData.name),e.length>0&&e[e.length-1],t(s.target.parent),document.body.style.cursor="default"})})}createHUIGUANG(e,t){let a=new At(.35,e);a.translate(0,e/2,0);const i=this.assets.instance.getResource("huiguang");i.colorSpace=ra,i.wrapS=ot,i.wrapT=ot;let s=new be({color:t,map:i,transparent:!0,opacity:.4,depthWrite:!1,side:Ie,blending:Ge}),o=new qe(a,s);o.renderOrder=10,o.rotateX(Math.PI/2);let u=o.clone(),d=o.clone();return u.rotateY(Math.PI/180*60),d.rotateY(Math.PI/180*120),[o,u,d]}createQuan(e,t){const a=this.assets.instance.getResource("guangquan1"),i=this.assets.instance.getResource("guangquan2");let s=new At(.5,.5),o=new be({color:16777215,map:a,alphaMap:a,opacity:1,transparent:!0,depthTest:!1,fog:!1,blending:Ge}),u=new be({color:16777215,map:i,alphaMap:i,opacity:1,transparent:!0,depthTest:!1,fog:!1,blending:Ge}),d=new qe(s,o),h=new qe(s,u);return d.renderOrder=6,h.renderOrder=6,d.rotateX(-Math.PI/2),h.rotateX(-Math.PI/2),d.position.copy(e),h.position.copy(e),h.position.y-=.001,d.scale.set(0,0,0),h.scale.set(0,0,0),this.quanGroup=new Te,this.quanGroup.add(d,h),this.scene.add(this.quanGroup),this.time.on("tick",()=>{d.rotation.z+=.05}),this.quanGroup}createDiffuse(){let e=new At(200,200),t=new be({color:0,depthWrite:!1,transparent:!0,blending:Al});t.blendEquation=Bl,t.blendSrc=El,t.blendDst=$l,new ql({material:t,time:this.time,size:60,diffuseSpeed:8,diffuseColor:7442830,diffuseWidth:2,callback:i=>{const s=setTimeout(()=>{this.addSceneTween(na.to(i.uniforms.uTime,{value:4,repeat:-1,duration:6,ease:"power1.easeIn"}))},3);this.addSceneTimer(s)}});let a=new qe(e,t);a.renderOrder=3,a.rotation.x=-Math.PI/2,a.position.set(0,.21,0),this.scene.add(a)}createGrid(){new Ul(this,{gridSize:54,gridDivision:24,gridColor:1990543,shapeSize:.55,shapeColor:3309487,pointSize:.085,pointColor:1993891,pointBlending:Ge})}createBottomBg(){let e=new At(24,24);const t=this.assets.instance.getResource("ocean");t.colorSpace=ra,t.wrapS=ot,t.wrapT=ot,t.repeat.set(1,1);let a=new be({map:t,opacity:.92,fog:!1}),i=new qe(e,a);i.rotation.x=-Math.PI/2,i.position.set(0,-.7,0),this.scene.add(i)}createChinaBlurLine(){let e=new At(154,154);const t=this.assets.instance.getResource("chinaBlurLine");t.colorSpace=ra,t.wrapS=ot,t.wrapT=ot,t.generateMipmaps=!1,t.minFilter=mr,t.repeat.set(1,1);let a=new be({color:4162253,alphaMap:t,transparent:!0,opacity:.62}),i=new qe(e,a);i.rotateX(-Math.PI/2),i.position.set(-19.3,-.5,-19.7),this.scene.add(i)}createLabel(){let e=this,t=this.labelGroup,a=this.label3d,i=[],s=[];Cu.map(u=>{if(u.hide==!0)return!1;let d=o(u,a,t);i.push(d),s.push(d)}),this.otherLabel=i,this.townNameLabels=s;function o(u,d,h){let g=d.create("",`china-label ${u.blur?" blur":""}`,!0);const[m,L]=e.geoProjection(u.center);return g.init(`<div class="other-label town-stat-label">
<div class="town-name-row"><img class="label-icon" src="${Kl}"><span class="town-name">${u.name}</span><span class="town-rank"></span></div>
<div class="town-stat-row"><span class="town-stat-metric"></span><span class="town-stat-value"></span><span class="town-stat-unit"></span></div>
</div>`,new ie(m,-L,e.depth+.85)),d.setLabelStyle(g,.018,"x"),g.setParent(h),g.userData=V(I({},u),{labelType:"town-label",baseScale:.018,townName:u.name}),g.element.addEventListener("pointerdown",S=>{e.handleTownRankingSelect(u.name,{preserveCamera:!0,statusText:`已选中${u.name}`})&&(S.preventDefault(),S.stopPropagation())}),g}}createRotateBorder(){let e=13.2,t=this.assets.instance.getResource("rotationBorder1"),a=this.assets.instance.getResource("rotationBorder2"),i=new Sr(this,{width:e*1.178,needRotate:!0,rotateSpeed:.001,material:new be({map:t,color:4763647,transparent:!0,opacity:.26,side:Ie,depthWrite:!1,blending:Ge}),position:new ie(0,.31,0)});i.instance.rotation.x=-Math.PI/2,i.instance.renderOrder=6,i.instance.scale.set(0,0,0),i.setParent(this.scene);let s=new Sr(this,{width:e*1.116,needRotate:!0,rotateSpeed:-.004,material:new be({map:a,color:4763647,transparent:!0,opacity:.5,side:Ie,depthWrite:!1,blending:Ge}),position:new ie(0,.33,0)});s.instance.rotation.x=-Math.PI/2,s.instance.renderOrder=6,s.instance.scale.set(0,0,0),s.setParent(this.scene),this.rotateBorder1=i.instance,this.rotateBorder2=s.instance}createFlyLine(){this.flyLineGroup=new Te,this.flyLineGroup.visible=!1,this.scene.add(this.flyLineGroup)}createFocus(){this.flyLineFocusGroup.clear()}createParticles(){this.particles=new Mr(this,{num:10,range:30,dir:"up",speed:.05,material:new Vl({map:Mr.createTexture(),size:1,color:61166,transparent:!0,opacity:1,depthTest:!1,depthWrite:!1,vertexColors:!0,blending:Ge,sizeAttenuation:!0})}),this.particleGroup=new Te,this.scene.add(this.particleGroup),this.particleGroup.rotation.x=-Math.PI/2,this.particles.setParent(this.particleGroup),this.particles.enable=!0,this.particleGroup.visible=!0}createScatter(){this.scatterGroup=new Te,this.scatterGroup.visible=!1,this.scatterGroup.rotation.x=-Math.PI/2,this.scene.add(this.scatterGroup);const e=this.assets.instance.getResource("arrow"),t=new ta({map:e,color:16776948,fog:!1,transparent:!0,depthTest:!1});let a=Dr(Fu),i=a[0].value;a.map(s=>{const o=new ea(t);o.renderOrder=23;let u=.1+s.value/i*.2;o.scale.set(u,u,u);let[d,h]=this.geoProjection([s.lng,s.lat]);o.position.set(d,-h,this.depth+.45),o.userData.position=[d,-h,this.depth+.45],this.scatterGroup.add(o)})}createInfoPoint(){let e=this;this.InfoPointGroup=new Te,this.scene.add(this.InfoPointGroup),this.InfoPointGroup.visible=!1,this.InfoPointGroup.rotation.x=-Math.PI/2,this.infoPointIndex=0,this.infoPointLabelTime=null,this.infoLabelElement=[],this.infoPointSprites=[];let t=this.label3d;const a=this.assets.instance.getResource("point");let i=[16776948,7863285],s=Dr(xu),o=s[0].value;s.map((d,h)=>{const g=new ta({map:a,color:i[h%i.length],fog:!1,transparent:!0,depthTest:!1}),m=new ea(g);m.renderOrder=23;let L=.7+d.value/o*.4;m.scale.set(L,L,L);let[S,C]=this.geoProjection([d.lng,d.lat]),F=[S,-C,this.depth+.7];m.position.set(...F),m.userData.position=[...F],m.userData={position:[S,-C,this.depth+.7],name:d.name,value:d.value,level:d.level,index:h},this.InfoPointGroup.add(m);let E=u(d,t,this.InfoPointGroup,h);this.infoLabelElement.push(E),this.infoPointSprites.push(m),this.interactionManager.add(m),m.addEventListener("mousedown",D=>{var J,re;if(this.clicked||!this.InfoPointGroup.visible)return!1;this.clicked=!0,this.infoPointIndex=D.target.userData.index,this.infoLabelElement.map(K=>{K.visible=!1}),E.visible=!0,this.handleTownRankingSelect(((J=D.target.userData)==null?void 0:J.name)||((re=D.target.userData)==null?void 0:re.townName)),this.createInfoPointLabelLoop()}),m.addEventListener("mouseup",D=>{this.clicked=!1}),m.addEventListener("mouseover",D=>{document.body.style.cursor="pointer"}),m.addEventListener("mouseout",D=>{document.body.style.cursor="default"})});function u(d,h,g,m){let L=h.create("","info-point",!0);const[S,C]=e.geoProjection([d.lng,d.lat]);return L.init(e.getInfoPointHtml(V(I({},d),{value:0,rank:m+1,unit:""}),e.getTownRankingMeta()),new ie(S,-C,e.depth+1.9)),h.setLabelStyle(L,.015,"x"),L.setParent(g),L.visible=!1,L}}createInfoPointLabelLoop(){var e;this.scenePaused||!((e=this.infoLabelElement)!=null&&e.length)||(clearInterval(this.infoPointLabelTime),this.infoPointLabelTime=setInterval(()=>{this.infoPointIndex++,this.infoPointIndex>=this.infoLabelElement.length&&(this.infoPointIndex=0),this.infoLabelElement.map((t,a)=>{this.infoPointIndex===a?t.visible=!0:t.visible=!1})},3e3))}createStorke(){const e=this.staticMapData.mapStroke,t=this.assets.instance.getResource("pathLine3");t.wrapS=t.wrapT=ot,t.repeat.set(2,1);let a=new aa(this,{geoProjectionCenter:this.geoProjectionCenter,geoProjectionScale:this.geoProjectionScale,position:new ie(0,0,this.depth+.24),data:e,material:new be({color:2868444,map:t,alphaMap:t,fog:!1,transparent:!0,opacity:1,blending:Ge}),type:"Line3",renderOrder:22,tubeRadius:.03});this.focusMapGroup.add(a.lineGroup),this.time.on("tick",()=>{t.offset.x+=.005})}handleMapClick(e){return he(this,null,function*(){var s,o,u,d,h,g,m,L,S,C,F,E,D,J,re,K,G,Ce,Ue,at,wt,z,je,nt,Ft,ct,xt,Kt,dt,ht,Oe,Fe,ge,xe,pt,Lt,De,Ke,ve,ft,M;if(!this.currentTopicLayer)return;const t=this.getScreenPointFromEvent(e),a=this.getLngLatFromEvent(e);if(!a){this.clearSelectedFeature(),(o=(s=this.callbacks).onFeatureInfo)==null||o.call(s,{feature:null});return}if(this.boundaryDrawingEnabled){const w=((u=e==null?void 0:e.data)==null?void 0:u.originalEvent)||(e==null?void 0:e.originalEvent)||e;if(w!=null&&w.__analysisBoundaryHandled)return;this.addBoundaryDrawPoint(a);return}if(this.shouldClipLayerToHongyuanBoundary(this.currentTopicLayer)&&!this.isLngLatInHongyuanBoundary(a)){this.clearSelectedFeature(),(h=(d=this.callbacks).onFeatureInfo)==null||h.call(d,{feature:null}),(m=(g=this.callbacks).onLayerStatus)==null||m.call(g,{type:"success",text:"当前点击位置不在红原县边界内"});return}if(this.shouldClipLayerToLayerBounds(this.currentTopicLayer)&&!this.isLngLatInLayerClipBounds(a,this.currentTopicLayer)){this.clearSelectedFeature(),(S=(L=this.callbacks).onFeatureInfo)==null||S.call(L,{feature:null}),(F=(C=this.callbacks).onLayerStatus)==null||F.call(C,{type:"success",text:"当前点击位置不在图层显示范围内"});return}if(Ju(this.currentTopicLayer)){this.clearSelectedFeature(),(D=(E=this.callbacks).onFeatureInfo)==null||D.call(E,{feature:null});return}if(nn(this.currentTopicLayer)){const w=this.pickVectorFeatureAtPoint(a,t),N=(w==null?void 0:w.feature)||w;let O=(w==null?void 0:w.screen)||t;if(N)this.shouldClipLayerToHongyuanBoundary(this.currentTopicLayer)?(this.clearSelectedGeometryGroup(),this.setSelectedVectorFeatures([N])):this.showSelectedFeature(N),((J=this.currentTopicLayer)==null?void 0:J.key)==="yak-industry-points"&&(this.setSelectedVectorFeatures([N]),O=this.getPointFeatureScreenPoint(N)||O),(Ue=(Ce=this.callbacks).onFeatureInfo)==null||Ue.call(Ce,{feature:{id:((re=N.properties)==null?void 0:re.id)||((K=N.properties)==null?void 0:K.feature_id)||((G=N.properties)==null?void 0:G.project_name),properties:N.properties||{},feature:N,layer:this.currentTopicLayer,lngLat:a},screen:O}),(wt=(at=this.callbacks).onLayerStatus)==null||wt.call(at,{type:"success",text:"真实矢量要素已选中"});else{const H=this.getTownNameFromMapEvent(e);if(this.handleTownRankingSelect(H))return;this.clearSelectedFeature(),(je=(z=this.callbacks).onFeatureInfo)==null||je.call(z,{feature:null}),(Ft=(nt=this.callbacks).onLayerStatus)==null||Ft.call(nt,{type:"success",text:"当前点击位置无生态保护要素"})}return}const i=this.lngLatToWmsPixel(a);(xt=(ct=this.callbacks).onFeatureInfo)==null||xt.call(ct,{feature:null}),(dt=(Kt=this.callbacks).onFeatureLoading)==null||dt.call(Kt,!0);try{const w=yield Nr(this.currentTopicLayer,i,{size:Et,buffer:10}),N=this.normalizeFeatureInfoAtPoint(w,a),O=N?null:yield this.queryFallbackFeatureInfo(a),H=N||(O==null?void 0:O.feature);if(H){const ne=yield this.enrichFeatureInfo(H,i,a);this.showSelectedFeature(ne.feature||ne),(Oe=(ht=this.callbacks).onFeatureInfo)==null||Oe.call(ht,{feature:V(I({},ne),{layer:(O==null?void 0:O.layer)||this.currentTopicLayer,lngLat:a}),screen:t})}else this.clearSelectedFeature(),(ge=(Fe=this.callbacks).onFeatureInfo)==null||ge.call(Fe,{feature:null});H||(pt=(xe=this.callbacks).onLayerStatus)==null||pt.call(xe,{type:"success",text:"当前点击位置无图斑"})}catch(w){this.clearSelectedFeature(),(De=(Lt=this.callbacks).onFeatureInfo)==null||De.call(Lt,{feature:null}),(ve=(Ke=this.callbacks).onLayerStatus)==null||ve.call(Ke,{type:"error",text:"图斑信息查询失败"})}finally{(M=(ft=this.callbacks).onFeatureLoading)==null||M.call(ft,!1)}})}handleCanvasBoundaryPointerDown(e){var a,i;if(!this.boundaryDrawingEnabled)return;const t=this.getLngLatFromCanvasEvent(e);t&&this.addBoundaryDrawPoint(t)&&(e.__analysisBoundaryHandled=!0),(a=e.preventDefault)==null||a.call(e),(i=e.stopPropagation)==null||i.call(e)}handleCanvasBoundaryDoubleClick(e){var a,i;if(!this.boundaryDrawingEnabled)return;const t=this.getLngLatFromCanvasEvent(e);(this.boundaryDrawPoints||[]).length<3&&t&&this.addBoundaryDrawPoint(t),(this.boundaryDrawPoints||[]).length>=3&&(this.finishBoundaryDrawing(),e.__analysisBoundaryHandled=!0),(a=e.preventDefault)==null||a.call(e),(i=e.stopPropagation)==null||i.call(e)}getLngLatFromCanvasEvent(e){var L,S,C;if(!((L=this.camera)!=null&&L.instance)||!this.focusMapGroup||!this.canvas)return null;const t=this.canvas.getBoundingClientRect();if(!t.width||!t.height)return null;const a=(S=this.interactionManager)==null?void 0:S.raycaster;if(!(a!=null&&a.setFromCamera))return null;const i={x:(e.clientX-t.left)/t.width*2-1,y:-((e.clientY-t.top)/t.height)*2+1};a.setFromCamera(i,this.camera.instance);const o=((C=a.intersectObjects(this.eventElement||[],!0)[0])==null?void 0:C.point)||this.getRayMapPlaneIntersection(a.ray);if(!o)return null;const u=this.focusMapGroup.worldToLocal(o.clone()),h=Ht().center(this.geoProjectionCenter).scale(this.geoProjectionScale).translate([0,0]).invert([u.x,-u.y]);if(!h)return null;const g=Number(h[0]),m=Number(h[1]);return!Number.isFinite(g)||!Number.isFinite(m)?null:g<q.west-.03||g>q.east+.03||m<q.south-.03||m>q.north+.03?this.getFallbackLngLatFromPointer(e,t):{lng:g,lat:m}}getFallbackLngLatFromPointer(e,t=(i=>(i=(a=>(a=this.canvas)==null?void 0:a.getBoundingClientRect)())==null?void 0:i.call(a))()){if(!(t!=null&&t.width)||!(t!=null&&t.height))return null;const s=Math.min(1,Math.max(0,(e.clientX-t.left)/t.width)),o=Math.min(1,Math.max(0,(e.clientY-t.top)/t.height)),u=q.west+(q.east-q.west)*s,d=q.north-(q.north-q.south)*o;return{lng:u,lat:d}}getRayMapPlaneIntersection(e){if(!(e!=null&&e.origin)||!(e!=null&&e.direction)||!this.focusMapGroup)return null;const t=this.focusMapGroup.worldToLocal(e.origin.clone()),i=this.focusMapGroup.worldToLocal(e.origin.clone().add(e.direction.clone())).sub(t),s=this.depth+.22;if(Math.abs(i.z)<1e-8)return null;const o=(s-t.z)/i.z;if(!Number.isFinite(o)||o<0)return null;const u=t.add(i.multiplyScalar(o));return this.focusMapGroup.localToWorld(u)}enrichFeatureInfo(e,t,a){return he(this,null,function*(){const i=this.getLayerTopicKey(this.currentTopicLayer);if(!["grassland","wetland","woodland"].includes(i))return e;const o=(Un[i]||[]).find(m=>m.key===`${i}-distribution`),u=(this.visibleTopicLayers||[]).filter(m=>this.getLayerTopicKey(m)===i).slice(0,5),d=[o,this.currentTopicLayer,...u].filter(m=>m==null?void 0:m.layerName).filter((m,L,S)=>S.findIndex(C=>this.getLayerQueryKey(C)===this.getLayerQueryKey(m))===L);if(!d.length)return e;const h=yield Promise.allSettled([...d.filter(m=>this.getLayerQueryKey(m)!==this.getLayerQueryKey(this.currentTopicLayer)).map(m=>he(this,null,function*(){const L=yield Nr(m,t,{size:Et,buffer:10}),S=this.normalizeFeatureInfoAtPoint(L,a);return S?{layer:m,feature:S,source:"wms"}:null})),...d.map(m=>he(this,null,function*(){const L=yield this.queryLayerFeatureByPoint(m,a);return L?{layer:m,feature:L,source:"wfs"}:null}))]),g=I({},e.properties||{});return h.forEach(m=>{var L,S;m.status!=="fulfilled"||!((S=(L=m.value)==null?void 0:L.feature)!=null&&S.properties)||this.mergeBusinessProperties(g,m.value.feature.properties,m.value.layer)}),V(I({},e),{properties:g,relatedFeatures:h.filter(m=>{var L;return m.status==="fulfilled"&&((L=m.value)==null?void 0:L.feature)}).map(m=>m.value),feature:V(I({},e.feature||{}),{properties:g})})})}queryFallbackFeatureInfo(e){return he(this,null,function*(){const t=this.getLayerTopicKey(this.currentTopicLayer);if(!["grassland","wetland","woodland"].includes(t))return null;const i=[(Un[t]||[]).find(s=>s.key===`${t}-distribution`),this.currentTopicLayer,...(this.visibleTopicLayers||[]).filter(s=>this.getLayerTopicKey(s)===t)].filter((s,o,u)=>(s==null?void 0:s.layerName)&&u.findIndex(d=>this.getLayerQueryKey(d)===this.getLayerQueryKey(s))===o);for(const s of i){const o=yield this.queryLayerFeatureByPoint(s,e,{requireContainment:!0});if(o)return{layer:s,feature:o}}return null})}normalizeFeatureInfoAtPoint(e,t){const a=Array.isArray(e==null?void 0:e.features)?e.features:[];if(!a.length)return null;const i=this.pickFeatureAtPoint(a,t,{requireContainment:!0});if(!i)return null;const s=i.properties||{};return{id:i.id||s.gid||s.objectid||s.OBJECTID,properties:s,feature:i}}queryLayerFeatureByPoint(i,s){return he(this,arguments,function*(e,t,a={}){var C,F,E;if(!(e!=null&&e.layerName)||!Number.isFinite(t==null?void 0:t.lng)||!Number.isFinite(t==null?void 0:t.lat))return null;const o=e.pointQueryTolerance||.0015,u=e.geometryField||"geom",d=t.lng-o,h=t.lat-o,g=t.lng+o,m=t.lat+o,L=yield xr(e.layerName,{cqlFilter:`BBOX(${u},${d},${h},${g},${m})`,maxFeatures:8,timeout:12e3}),S=this.pickFeatureAtPoint((L==null?void 0:L.features)||[],t,a);return S?{id:S.id||((C=S.properties)==null?void 0:C.gid)||((F=S.properties)==null?void 0:F.objectid)||((E=S.properties)==null?void 0:E.OBJECTID),properties:S.properties||{},feature:S}:null})}pickFeatureAtPoint(e,t,a={}){var s;if(!Array.isArray(e)||!e.length)return null;const i=e.filter(o=>this.isLngLatInGeometry(t,o.geometry)).sort((o,u)=>this.getGeometryAreaScore(o.geometry)-this.getGeometryAreaScore(u.geometry));return i.length?i[0]:a.requireContainment?null:((s=e.map(o=>({feature:o,distance:this.getGeometryDistanceScore(o.geometry,t)})).sort((o,u)=>o.distance-u.distance)[0])==null?void 0:s.feature)||null}isLngLatInGeometry(e,t){return!e||!(t!=null&&t.coordinates)?!1:t.type==="Polygon"?this.isLngLatInPolygon(e,t.coordinates):t.type==="MultiPolygon"?t.coordinates.some(a=>this.isLngLatInPolygon(e,a)):!1}isLngLatInPolygon(e,t=[]){return!t.length||!this.isLngLatInRing(e,t[0])?!1:!t.slice(1).some(i=>this.isLngLatInRing(e,i))}isLngLatInRing(e,t=[]){if(t.length<3)return!1;let a=!1;const i=e.lng,s=e.lat;for(let o=0,u=t.length-1;o<t.length;u=o++){const d=t[o],h=t[u],g=Number(d==null?void 0:d[0]),m=Number(d==null?void 0:d[1]),L=Number(h==null?void 0:h[0]),S=Number(h==null?void 0:h[1]);if(this.isPointOnSegment(i,s,g,m,L,S))return!0;m>s!=S>s&&i<(L-g)*(s-m)/(S-m)+g&&(a=!a)}return a}isPointOnSegment(e,t,a,i,s,o){const u=(e-a)*(o-i)-(t-i)*(s-a);return Math.abs(u)>1e-10?!1:(e-a)*(e-s)+(t-i)*(t-o)<=1e-10}getGeometryAreaScore(e){return e!=null&&e.coordinates?e.type==="Polygon"?this.getLngLatPolygonAreaScore(e.coordinates):e.type==="MultiPolygon"?e.coordinates.reduce((t,a)=>t+this.getLngLatPolygonAreaScore(a),0):Number.POSITIVE_INFINITY:Number.POSITIVE_INFINITY}getLngLatPolygonAreaScore(e=[]){const t=e[0]||[];if(t.length<3)return Number.POSITIVE_INFINITY;let a=0;for(let i=0;i<t.length;i++){const s=t[i],o=t[(i+1)%t.length];a+=Number((s==null?void 0:s[0])||0)*Number((o==null?void 0:o[1])||0)-Number((o==null?void 0:o[0])||0)*Number((s==null?void 0:s[1])||0)}return Math.abs(a)}getGeometryDistanceScore(e,t){const a=this.getGeometryLngLatBounds(e);if(!a)return Number.POSITIVE_INFINITY;const i=(a.minLng+a.maxLng)/2,s=(a.minLat+a.maxLat)/2;return Math.hypot(i-t.lng,s-t.lat)}getGeometryLngLatBounds(e){const t=this.getGeometryCoordinateList(e);return t.length?t.reduce((a,i)=>({minLng:Math.min(a.minLng,Number((i==null?void 0:i[0])||0)),minLat:Math.min(a.minLat,Number((i==null?void 0:i[1])||0)),maxLng:Math.max(a.maxLng,Number((i==null?void 0:i[0])||0)),maxLat:Math.max(a.maxLat,Number((i==null?void 0:i[1])||0))}),{minLng:Number.POSITIVE_INFINITY,minLat:Number.POSITIVE_INFINITY,maxLng:Number.NEGATIVE_INFINITY,maxLat:Number.NEGATIVE_INFINITY}):null}getGeometryCoordinateList(e){const t=[],a=i=>{if(Array.isArray(i)){if(typeof i[0]=="number"&&typeof i[1]=="number"){t.push(i);return}i.forEach(a)}};return a(e==null?void 0:e.coordinates),t}pickVectorFeatureAtPoint(e,t){var o;const a=this.getVisibleVectorFeatures(this.currentTopicLayer,this.currentVectorFeatures||[]);if(((o=this.currentTopicLayer)==null?void 0:o.key)==="yak-industry-points"){const u=this.pickPointFeatureAtScreenPoint(a,t);if(u)return u}const i=a.filter(u=>this.isLngLatInGeometry(e,u.geometry)).sort((u,d)=>this.getGeometryAreaScore(u.geometry)-this.getGeometryAreaScore(d.geometry));if(i.length)return i[0];const s=a.find(u=>this.isPointOrLineNearLngLat(u.geometry,e));return s||null}pickPointFeatureAtScreenPoint(e,t){var s;if(!t||!((s=this.camera)!=null&&s.instance)||!this.focusMapGroup||!this.canvas)return null;const i=(e||[]).filter(o=>{var u;return((u=o==null?void 0:o.geometry)==null?void 0:u.type)==="Point"}).map(o=>{const u=this.getPointFeatureScreenPoint(o);return u?{feature:o,screen:u,distance:Math.hypot(u.x-t.x,u.y-t.y)}:null}).filter(Boolean).sort((o,u)=>o.distance-u.distance)[0];return(i==null?void 0:i.distance)<=22?{feature:i.feature,screen:i.screen}:null}getPointFeatureScreenPoint(e){var a,i;const t=(e==null?void 0:e.geometry)||((a=e==null?void 0:e.feature)==null?void 0:a.geometry);return(t==null?void 0:t.type)!=="Point"?null:((i=this.currentTopicLayer)==null?void 0:i.key)==="yak-industry-points"?this.lngLatToLayerScreenPoint(t.coordinates,this.depth+.36):this.lngLatToScreenPoint(t.coordinates,this.depth+.32)}lngLatToLayerLocalPoint(e,t=0){const a=()=>{const h=Number(e==null?void 0:e[0]),g=Number(e==null?void 0:e[1]);if(!Number.isFinite(h)||!Number.isFinite(g))return new ie(0,0,Number(t)||0);const[m,L]=this.geoProjection([h,g]);return new ie(m,-L,Number(t)||0)},i=this.topicLayerUvBounds;if(!i)return a();const s=this.lngLatToLayerCanvasPoint(e),o=this.topicLayerCanvas;if(!(o!=null&&o.width)||!(o!=null&&o.height))return a();const u=i.left+s.x/o.width*(i.right-i.left),d=i.bottom+(o.height-s.y)/o.height*(i.top-i.bottom);return new ie(u,d,Number(t)||0)}lngLatToLayerScreenPoint(e,t=0){return this.localMapPointToScreenPoint(this.lngLatToLayerLocalPoint(e,t))}lngLatToScreenPoint(e,t=0){const a=Number(e==null?void 0:e[0]),i=Number(e==null?void 0:e[1]);if(!Number.isFinite(a)||!Number.isFinite(i))return null;const s=this.lngLatToWorldPoint([a,i],t);return this.worldPointToScreenPoint(s)}localMapPointToScreenPoint(e){const t=this.focusMapGroup?this.focusMapGroup.localToWorld(e):e;return this.worldPointToScreenPoint(t)}worldPointToScreenPoint(e){var i;if(!((i=this.camera)!=null&&i.instance)||!this.canvas||!e)return null;const t=this.canvas.getBoundingClientRect();if(!t.width||!t.height)return null;const a=e.clone().project(this.camera.instance);return!Number.isFinite(a.x)||!Number.isFinite(a.y)?null:{x:t.left+(a.x+1)/2*t.width,y:t.top+(1-a.y)/2*t.height}}focusProject(e){var L,S,C,F;const t=String(e||"").trim();if(!t)return!1;const a=(this.currentVectorFeatures||[]).filter(E=>{var D;return String(((D=E==null?void 0:E.properties)==null?void 0:D.project_name)||"").trim()===t});if(!a.length)return(S=(L=this.callbacks).onLayerStatus)==null||S.call(L,{type:"success",text:"当前项目图斑尚未加载"}),!1;const i=this.getFeatureListLngLatBounds(a);if(!i)return!1;const s=this.getProjectHighlightFeatures(a);s.length?(this.showSelectedFeatures(s),this.setSelectedVectorFeatures(s)):this.clearSelectedFeature();const o=[(i.minLng+i.maxLng)/2,(i.minLat+i.maxLat)/2],u=Math.max(i.maxLng-i.minLng,i.maxLat-i.minLat),d=Math.max(.22,Math.min(.55,u*1.25)),h=this.lngLatToWorldPoint(o,.72),g=this.defaultMapCameraPosition.clone().sub(this.defaultMapTarget).multiplyScalar(d),m=h.clone().add(g);return this.animateMapCamera(m,h,.75),(F=(C=this.callbacks).onLayerStatus)==null||F.call(C,{type:"success",text:"已定位项目"}),!0}setBoundaryDrawing(e){var t,a,i,s;this.boundaryDrawingEnabled=!!e,this.boundaryDrawingEnabled?(this.boundaryDrawPoints=[],this.lastBoundaryDrawPoint=null,this.analysisBoundaryFeature=null,this.analysisMatchedFeatures=[],this.clearSelectedFeature(),(a=(t=this.callbacks).onLayerStatus)==null||a.call(t,{type:"success",text:"请在地图上依次点击绘制分析边界"})):(s=(i=this.callbacks).onLayerStatus)==null||s.call(i,{type:"success",text:"已退出边界绘制"}),this.redrawVectorTopicLayer()}addBoundaryDrawPoint(e){var s,o,u,d;if(!Number.isFinite(e==null?void 0:e.lng)||!Number.isFinite(e==null?void 0:e.lat))return!1;const t=Date.now(),a=this.lastBoundaryDrawPoint;return a&&t-a.time<350&&Math.hypot(e.lng-a.lng,e.lat-a.lat)<8e-4?!1:(this.lastBoundaryDrawPoint={lng:e.lng,lat:e.lat,time:t},this.boundaryDrawPoints=[...this.boundaryDrawPoints||[],{lng:e.lng,lat:e.lat}],(o=(s=this.callbacks).onDrawBoundary)==null||o.call(s,{status:"drawing",points:this.boundaryDrawPoints,pointCount:this.boundaryDrawPoints.length}),(d=(u=this.callbacks).onLayerStatus)==null||d.call(u,{type:"success",text:`已添加边界点 ${this.boundaryDrawPoints.length}`}),this.redrawVectorTopicLayer(),!0)}undoBoundaryPoint(){var e,t,a;return(e=this.boundaryDrawPoints)!=null&&e.length?(this.boundaryDrawPoints=this.boundaryDrawPoints.slice(0,-1),(a=(t=this.callbacks).onDrawBoundary)==null||a.call(t,{status:"drawing",points:this.boundaryDrawPoints,pointCount:this.boundaryDrawPoints.length}),this.redrawVectorTopicLayer(),!0):!1}finishBoundaryDrawing(){var o,u,d,h,g,m;const e=this.boundaryDrawPoints||[];if(e.length<3)return(u=(o=this.callbacks).onLayerStatus)==null||u.call(o,{type:"error",text:"至少需要 3 个点才能形成分析边界"}),null;const t=e.map(L=>[L.lng,L.lat]),a=t[0],i=t[t.length-1];(a[0]!==i[0]||a[1]!==i[1])&&t.push([...a]);const s={type:"Feature",properties:{source:"draw",pointCount:e.length},geometry:{type:"Polygon",coordinates:[t]}};return this.boundaryDrawingEnabled=!1,this.boundaryDrawPoints=[],this.lastBoundaryDrawPoint=null,this.analysisBoundaryFeature=s,(h=(d=this.callbacks).onDrawBoundary)==null||h.call(d,{status:"complete",feature:s,points:e,pointCount:e.length}),(m=(g=this.callbacks).onLayerStatus)==null||m.call(g,{type:"success",text:"分析边界已生成"}),this.redrawVectorTopicLayer(),s}clearAnalysisBoundary(){var e,t;return this.boundaryDrawingEnabled=!1,this.boundaryDrawPoints=[],this.lastBoundaryDrawPoint=null,this.analysisBoundaryFeature=null,this.analysisMatchedFeatures=[],this.redrawVectorTopicLayer(),(t=(e=this.callbacks).onDrawBoundary)==null||t.call(e,{status:"clear",points:[],pointCount:0}),!0}showAnalysisResult(e={}){var s;const t=Object.prototype.hasOwnProperty.call(e,"boundary")||Object.prototype.hasOwnProperty.call(e,"boundaryFeature")||Object.prototype.hasOwnProperty.call(e,"feature"),a=e.boundary||e.boundaryFeature||e.feature||null,i=Array.isArray(e.matches)?e.matches:[];return t&&(this.analysisBoundaryFeature=(a==null?void 0:a.type)==="Feature"?a:a!=null&&a.geometry?{type:"Feature",properties:a.properties||{},geometry:a.geometry}:null),this.analysisMatchedFeatures=i.map(o=>(o==null?void 0:o.feature)||o).filter(o=>o==null?void 0:o.geometry),e.preserveView||(!t&&this.analysisMatchedFeatures.length?this.focusAnalysisFeatures(this.analysisMatchedFeatures):(s=this.analysisBoundaryFeature)!=null&&s.geometry&&this.focusAnalysisGeometry(this.analysisBoundaryFeature.geometry)),this.redrawVectorTopicLayer(),!0}focusAnalysisFeatures(e=[]){const t=this.getFeatureListLngLatBounds(e);if(!t)return!1;const a=[(t.minLng+t.maxLng)/2,(t.minLat+t.maxLat)/2];return this.flyToLngLat(a,{span:Math.max(t.maxLng-t.minLng,t.maxLat-t.minLat),statusText:"已定位命中项目"})}focusAnalysisGeometry(e){const t=this.getGeometryLngLatBounds(e);if(!t)return!1;const a=[(t.minLng+t.maxLng)/2,(t.minLat+t.maxLat)/2];return this.flyToLngLat(a,{span:Math.max(t.maxLng-t.minLng,t.maxLat-t.minLat),statusText:"已定位分析边界"})}focusPasture(e={}){var i,s;const a=[...this.normalizePastureGrasslandRows(e==null?void 0:e.grasslands),...this.normalizePastureGrasslandRows(e==null?void 0:e.wkt)].map((o,u)=>{const d=this.normalizePastureGrasslandGeometry(o);if(!d)return null;const h=this.normalizePastureGrasslandProperties(o);return{type:"Feature",properties:V(I({},h),{id:h.id||h.gid||`${(e==null?void 0:e.name)||"pasture"}-${u}`,pasture_name:(e==null?void 0:e.name)||h.pastureName||h.name}),geometry:d}}).filter(Boolean);if(a.length){const o=this.getFeatureListLngLatBounds(a);if(!o)return!1;this.showSelectedFeatures(a,{mode:"pasture"}),this.setSelectedVectorFeatures(a);const u=[(o.minLng+o.maxLng)/2,(o.minLat+o.maxLat)/2];return this.flyToLngLat(u,{span:Math.max(o.maxLng-o.minLng,o.maxLat-o.minLat),statusText:"已定位具体草场"}),!0}return(s=(i=this.callbacks).onLayerStatus)==null||s.call(i,{type:"warning",text:"当前牧户暂无可定位数据"}),!1}normalizePastureGrasslandRows(e){return e?typeof e=="string"?[e]:Array.isArray(e)?e:(e==null?void 0:e.type)==="FeatureCollection"&&Array.isArray(e.features)?e.features:(e==null?void 0:e.type)==="Feature"||this.isGeoJsonGeometry(e)?[e]:Array.isArray(e==null?void 0:e.rows)?e.rows:Array.isArray(e==null?void 0:e.data)?e.data:e!=null&&e.data?this.normalizePastureGrasslandRows(e.data):Array.isArray(e==null?void 0:e.list)?e.list:Array.isArray(e==null?void 0:e.features)?e.features:e!=null&&e.wkt||e!=null&&e.geo||e!=null&&e.geom||e!=null&&e.geometryWkt||e!=null&&e.geometry_wkt||e!=null&&e.shape||e!=null&&e.location||e!=null&&e.geometry?[e]:[]:[]}normalizePastureGrasslandGeometry(e){var t;return typeof e=="string"?this.parseGeometryText(e):(e==null?void 0:e.type)==="Feature"?this.normalizePastureGrasslandGeometry(e.geometry):this.isGeoJsonGeometry(e)?e:typeof(e==null?void 0:e.geometry)=="string"?this.parseGeometryText(e.geometry):((t=e==null?void 0:e.geometry)==null?void 0:t.type)==="Feature"?this.normalizePastureGrasslandGeometry(e.geometry.geometry):this.isGeoJsonGeometry(e==null?void 0:e.geometry)?e.geometry:this.parseGeometryText((e==null?void 0:e.wkt)||(e==null?void 0:e.geo)||(e==null?void 0:e.geom)||(e==null?void 0:e.geometryWkt)||(e==null?void 0:e.geometry_wkt)||(e==null?void 0:e.shape)||(e==null?void 0:e.location))}normalizePastureGrasslandProperties(e){return!e||typeof e!="object"||Array.isArray(e)?{wkt:e}:e.type==="Feature"?e.properties||{}:e}parseGeometryText(e){const t=String(e||"").trim();if(!t)return null;if(t.startsWith("{")||t.startsWith("["))try{const a=JSON.parse(t);if((a==null?void 0:a.type)==="Feature")return this.normalizePastureGrasslandGeometry(a);if(this.isGeoJsonGeometry(a))return a}catch(a){return null}return this.parseWktGeometry(t)}isGeoJsonGeometry(e){return!!(e&&["Polygon","MultiPolygon","LineString","MultiLineString","Point"].includes(e.type)&&e.coordinates)}flyToLngLat(e,t={}){var m,L;const a=Array.isArray(e)?e:[e==null?void 0:e.lng,e==null?void 0:e.lat],i=Number(a==null?void 0:a[0]),s=Number(a==null?void 0:a[1]);if(!Number.isFinite(i)||!Number.isFinite(s))return!1;const o=Number(t.span),u=Number.isFinite(o)?Math.max(.2,Math.min(.55,o*1.25)):.32,d=this.lngLatToWorldPoint([i,s],.72),h=this.defaultMapCameraPosition.clone().sub(this.defaultMapTarget).multiplyScalar(u),g=d.clone().add(h);return this.animateMapCamera(g,d,t.duration||.75),(L=(m=this.callbacks).onLayerStatus)==null||L.call(m,{type:"success",text:t.statusText||"已定位"}),!0}getProjectHighlightFeatures(e){const t=e.filter(i=>{var o;const s=String(((o=i==null?void 0:i.geometry)==null?void 0:o.type)||"");return s.includes("Polygon")||s.includes("LineString")}),a=t.filter(i=>{var s;return((s=i==null?void 0:i.properties)==null?void 0:s.feature_role)==="工程范围"});return a.length?a:t}getFeatureListLngLatBounds(e){return e.reduce((t,a)=>{const i=this.getGeometryLngLatBounds(a.geometry);return i?t?{minLng:Math.min(t.minLng,i.minLng),minLat:Math.min(t.minLat,i.minLat),maxLng:Math.max(t.maxLng,i.maxLng),maxLat:Math.max(t.maxLat,i.maxLat)}:I({},i):t},null)}isPointOrLineNearLngLat(e,t){return e!=null&&e.coordinates?e.type==="Point"?this.getCoordinateDistance(e.coordinates,[t.lng,t.lat])<=.02:e.type==="LineString"?this.isCoordinateNearLine(e.coordinates,t,.004):e.type==="MultiLineString"?e.coordinates.some(a=>this.isCoordinateNearLine(a,t,.004)):!1:!1}isCoordinateNearLine(e,t,a){if(!Array.isArray(e)||e.length<2)return!1;const i=[t.lng,t.lat];for(let s=1;s<e.length;s+=1)if(this.getCoordinateSegmentDistance(i,e[s-1],e[s])<=a)return!0;return!1}getCoordinateDistance(e,t){return Math.hypot(Number(e==null?void 0:e[0])-Number(t==null?void 0:t[0]),Number(e==null?void 0:e[1])-Number(t==null?void 0:t[1]))}getCoordinateSegmentDistance(e,t,a){const i=Number(t==null?void 0:t[0]),s=Number(t==null?void 0:t[1]),o=Number(a==null?void 0:a[0])-i,u=Number(a==null?void 0:a[1])-s;if(!Number.isFinite(o)||!Number.isFinite(u))return Number.POSITIVE_INFINITY;if(!o&&!u)return this.getCoordinateDistance(e,t);const d=Math.max(0,Math.min(1,((e[0]-i)*o+(e[1]-s)*u)/(o*o+u*u)));return this.getCoordinateDistance(e,[i+d*o,s+d*u])}getLayerTopicKey(e){const t=e==null?void 0:e.layerName,a=e==null?void 0:e.key,i=Object.entries(I(I({},Un),uu)).find(([,s])=>s.some(o=>o.key===a||o.layerName===t));return(i==null?void 0:i[0])||""}getLayerQueryKey(e){return[(e==null?void 0:e.layerName)||"",(e==null?void 0:e.styles)||"",(e==null?void 0:e.cqlFilter)||"",(e==null?void 0:e.key)||""].join("|")}mergeBusinessProperties(e,t,a){const i=(a==null?void 0:a.key)||"";if(Object.entries(t||{}).forEach(([s,o])=>{o==null||o===""||(e[s]===void 0||e[s]===null||e[s]==="")&&(e[s]=o)}),i==="basic-grassland"){const s=(t==null?void 0:t.basic_type_name)||(t==null?void 0:t.grassland_category_name)||(t==null?void 0:t.land_class_name)||(t==null?void 0:t.land_use_name)||(t==null?void 0:t.base_grass);s!=null&&s!==""&&(e.basic_type_name=s)}if(i==="grassland-level"){const s=(t==null?void 0:t.grassland_level)||(t==null?void 0:t.level)||(t==null?void 0:t.grassland_level_name)||(t==null?void 0:t.level_name);s!=null&&s!==""&&(e.grassland_level=s)}if(i==="grassland-type"||i==="wetland-type"){const s=(t==null?void 0:t.grass_min_type)||(t==null?void 0:t.grass_type)||(t==null?void 0:t.grassland_type)||(t==null?void 0:t.type_name)||(t==null?void 0:t.type);s!=null&&s!==""&&(e.grass_min_type=s)}if(i==="grassland-yield"||i==="wetland-yield"){const s=(t==null?void 0:t.yield)||(t==null?void 0:t.xc_yield)||(t==null?void 0:t.xb_xc_yield)||(t==null?void 0:t.fresh_grass_yield)||(t==null?void 0:t.value),o=(t==null?void 0:t.mu_yield)||(t==null?void 0:t.xc_mu_yield)||(t==null?void 0:t.xb_xc_mu_yield)||(t==null?void 0:t.yield_per_mu);s!=null&&s!==""&&(e.fresh_grass_yield=s),o!=null&&o!==""&&(e.mu_yield=o)}if(i==="grassland-health"){const s=(t==null?void 0:t.health_level)||(t==null?void 0:t.health_level_name)||(t==null?void 0:t.ndvi_level)||(t==null?void 0:t.level)||(t==null?void 0:t.level_name),o=(t==null?void 0:t.ndvi)||(t==null?void 0:t.NDVI)||(t==null?void 0:t.value);s!=null&&s!==""&&(e.health_level=s),o!=null&&o!==""&&(e.ndvi=o);const u=(t==null?void 0:t.degradation_level)||(t==null?void 0:t.degradation_level_name)||(t==null?void 0:t.level)||(t==null?void 0:t.level_name);u!=null&&u!==""&&(e.degradation_level=u)}}getScreenPointFromEvent(e){var a;const t=((a=e==null?void 0:e.data)==null?void 0:a.originalEvent)||(e==null?void 0:e.originalEvent)||e;return(t==null?void 0:t.clientX)!==void 0&&(t==null?void 0:t.clientY)!==void 0?{x:t.clientX,y:t.clientY}:null}getLngLatFromEvent(e){var u,d,h;const a=(h=(((d=(u=this.interactionManager)==null?void 0:u.raycaster)==null?void 0:d.intersectObject(e.target,!1))||[])[0])==null?void 0:h.point;if(!a)return null;const i=this.focusMapGroup.worldToLocal(a.clone()),o=Ht().center(this.geoProjectionCenter).scale(this.geoProjectionScale).translate([0,0]).invert([i.x,-i.y]);return o?{lng:o[0],lat:o[1]}:null}lngLatToWmsPixel({lng:e,lat:t}){const a=(e-q.west)/(q.east-q.west)*Et.width,i=(q.north-t)/(q.north-q.south)*Et.height;return{x:a,y:i}}showSelectedFeature(e,t={}){var i;const a=(e==null?void 0:e.geometry)||((i=e==null?void 0:e.feature)==null?void 0:i.geometry);this.clearSelectedFeature(),this.createSelectedFeatureGroup(),this.addSelectedGeometry(a,t),this.selectedFeatureGroup.children.length||this.clearSelectedFeature()}showSelectedFeatures(e=[],t={}){this.clearSelectedFeature(),this.createSelectedFeatureGroup(),e.forEach(a=>{var s;const i=(a==null?void 0:a.geometry)||((s=a==null?void 0:a.feature)==null?void 0:s.geometry);this.addSelectedGeometry(i,t)}),this.selectedFeatureGroup.children.length||this.clearSelectedFeature()}setSelectedVectorFeatures(e=[]){this.selectedVectorFeatures=[...e],this.redrawVectorTopicLayer()}getSelectedFeatureStyle(e={}){const t=e.mode==="pasture",a=e.mode==="town";return{fillColor:$r,fillOpacity:t?.46:a?.24:.54,lineColor:Ku,lineOpacity:.98,glowColor:Vr,glowOpacity:t?.92:.96,renderOrderBase:t?42:a?40:35,boundary:t||a,boundaryColor:$r,boundaryGlowColor:Vr,boundaryWidth:a?.012:.018,boundaryGlowWidth:a?.045:.06,boundaryOpacity:.95,boundaryGlowOpacity:a?.34:.42}}addSelectedGeometry(e,t={}){if(!(e!=null&&e.coordinates)||!this.selectedFeatureGroup)return;const a=this.getSelectedFeatureStyle(t),i=this.getDisplayFeaturePolygons(e),s=new be({color:a.fillColor,transparent:!0,opacity:a.fillOpacity,side:Ie,depthWrite:!1,fog:!1}),o=new Qt({color:a.lineColor,transparent:!0,opacity:a.lineOpacity,linewidth:2,depthTest:!1,depthWrite:!1,fog:!1}),u=new Qt({color:a.glowColor,transparent:!0,opacity:a.glowOpacity,linewidth:3,depthTest:!1,depthWrite:!1,fog:!1}),d=a.boundary?new be({color:a.boundaryColor,transparent:!0,opacity:a.boundaryOpacity,side:Ie,depthTest:!1,depthWrite:!1,fog:!1}):null,h=a.boundary?new be({color:a.boundaryGlowColor,transparent:!0,opacity:a.boundaryGlowOpacity,side:Ie,depthTest:!1,depthWrite:!1,fog:!1,blending:Ge}):null;i.length&&i.forEach(m=>{const L=this.createProjectedShape(m);if(!L)return;const S=new Ol(L),C=new qe(S,s);C.renderOrder=a.renderOrderBase,this.selectedFeatureGroup.add(C),m.forEach(F=>{const E=this.createProjectedRingPoints(F);if(E.length<3)return;a.boundary&&(this.addSelectedBoundaryBand(E,h,a.boundaryGlowWidth,a.renderOrderBase+1,!0),this.addSelectedBoundaryBand(E,d,a.boundaryWidth,a.renderOrderBase+4,!0));const D=new ma().setFromPoints(E),J=new gr(D,o);J.renderOrder=a.renderOrderBase+5,this.selectedFeatureGroup.add(J);const re=new ma().setFromPoints(E),K=new gr(re,u);K.renderOrder=a.renderOrderBase+3,K.scale.set(1.004,1.004,1),this.selectedFeatureGroup.add(K)})});const g=this.normalizeFeatureLineStrings(e);g.length&&g.forEach(m=>{const L=this.createProjectedRingPoints(m);if(L.length<2)return;a.boundary&&(this.addSelectedBoundaryBand(L,h,a.boundaryGlowWidth,a.renderOrderBase+1,!1),this.addSelectedBoundaryBand(L,d,a.boundaryWidth,a.renderOrderBase+4,!1));const S=new ma().setFromPoints(L),C=new yr(S,u);C.renderOrder=a.renderOrderBase+3,C.scale.set(1.004,1.004,1),this.selectedFeatureGroup.add(C);const F=new ma().setFromPoints(L),E=new yr(F,o);E.renderOrder=a.renderOrderBase+5,this.selectedFeatureGroup.add(E)})}addSelectedBoundaryBand(e,t,a,i,s=!0){if(!t||!this.selectedFeatureGroup)return;const o=this.createPathBandGeometry(e,a,s);if(!o)return;const u=new qe(o,t);u.renderOrder=i,this.selectedFeatureGroup.add(u)}createPathBandGeometry(e,t,a=!0){const i=this.normalizePathBandPoints(e,a);if(i.length<(a?3:2))return null;const s=Math.max(Number(t)||0,0)/2;if(!s)return null;const o=[],u=a?i.length:i.length-1;for(let h=0;h<u;h+=1){const g=i[h],m=i[(h+1)%i.length],L=m.x-g.x,S=m.y-g.y,C=Math.hypot(L,S);if(!C)continue;const F=-S/C*s,E=L/C*s,D=[g.x+F,g.y+E,.006],J=[g.x-F,g.y-E,.006],re=[m.x+F,m.y+E,.006],K=[m.x-F,m.y-E,.006];o.push(...D,...J,...re,...re,...J,...K)}if(!o.length)return null;const d=new ma;return d.setAttribute("position",new Dl(o,3)),d.computeVertexNormals(),d}normalizePathBandPoints(e,t){const a=(e||[]).filter(i=>Number.isFinite(i==null?void 0:i.x)&&Number.isFinite(i==null?void 0:i.y)).map(i=>i.clone());if(t&&a.length>2){const i=a[0],s=a[a.length-1];i.distanceToSquared(s)<1e-10&&a.pop()}return a}clearSelectedFeature(){var t;const e=!!((t=this.selectedVectorFeatures)!=null&&t.length);this.selectedVectorFeatures=[],e&&this.redrawVectorTopicLayer(),this.clearSelectedGeometryGroup()}clearSelectedGeometryGroup(){var t,a;if(!this.selectedFeatureGroup)return;const e=new Set;for(;this.selectedFeatureGroup.children.length;){const i=this.selectedFeatureGroup.children.pop();(a=(t=i.geometry)==null?void 0:t.dispose)==null||a.call(t),Array.isArray(i.material)?i.material.forEach(s=>e.add(s)):e.add(i.material)}e.forEach(i=>{var s;return(s=i==null?void 0:i.dispose)==null?void 0:s.call(i)})}normalizeFeaturePolygons(e){return Kr(e)}normalizeFeatureLineStrings(e){return e!=null&&e.coordinates?e.type==="LineString"?[e.coordinates]:e.type==="MultiLineString"?e.coordinates:[]:[]}getDisplayFeaturePolygons(e){const t=this.normalizeFeaturePolygons(e),a=this.getLayerClipBounds(this.currentTopicLayer);return a?t.map(i=>{const s=this.clipRingToBounds(i==null?void 0:i[0],a);if(s.length<3)return null;const o=i.slice(1).map(u=>this.clipRingToBounds(u,a)).filter(u=>u.length>=3);return[s,...o]}).filter(Boolean):t}clipRingToBounds(e=[],t){let a=e.map(s=>[Number(s==null?void 0:s[0]),Number(s==null?void 0:s[1])]).filter(([s,o])=>Number.isFinite(s)&&Number.isFinite(o));return[{inside:([s])=>s>=t.west,intersect:(s,o)=>this.getLngLatLineIntersection(s,o,"lng",t.west)},{inside:([s])=>s<=t.east,intersect:(s,o)=>this.getLngLatLineIntersection(s,o,"lng",t.east)},{inside:([,s])=>s>=t.south,intersect:(s,o)=>this.getLngLatLineIntersection(s,o,"lat",t.south)},{inside:([,s])=>s<=t.north,intersect:(s,o)=>this.getLngLatLineIntersection(s,o,"lat",t.north)}].forEach(s=>{const o=a;a=[],o.length&&o.forEach((u,d)=>{const h=o[(d+o.length-1)%o.length],g=s.inside(u),m=s.inside(h);g?(m||a.push(s.intersect(h,u)),a.push(u)):m&&a.push(s.intersect(h,u))})}),a}getLngLatLineIntersection(e,t,a,i){const s=a==="lng"?0:1,o=a==="lng"?1:0,u=t[s]-e[s];if(!u)return[...e];const d=(i-e[s])/u,h=[...e];return h[s]=i,h[o]=e[o]+(t[o]-e[o])*d,h}createProjectedShape(e){const t=e==null?void 0:e[0];if(!Array.isArray(t)||t.length<3)return null;const a=new br;return this.createProjectedRingPoints(t).forEach((s,o)=>{o===0?a.moveTo(s.x,s.y):a.lineTo(s.x,s.y)}),e.slice(1).forEach(s=>{const o=this.createProjectedRingPoints(s);if(o.length<3)return;const u=new br;o.forEach((d,h)=>{h===0?u.moveTo(d.x,d.y):u.lineTo(d.x,d.y)}),a.holes.push(u)}),a}createProjectedRingPoints(e){if(!Array.isArray(e))return[];const t=[];return e.forEach(a=>{if(!Array.isArray(a)||a.length<2)return;const i=Number(a[0]),s=Number(a[1]);if(!Number.isFinite(i)||!Number.isFinite(s))return;const[o,u]=this.geoProjection([i,s]);t.push(new ie(o,-u,0))}),t}enhanceTexture(e){var a,i,s;const t=(i=(a=this.renderer)==null?void 0:a.instance)==null?void 0:i.capabilities;e.anisotropy=((s=t==null?void 0:t.getMaxAnisotropy)==null?void 0:s.call(t))||1,e.needsUpdate=!0}geoProjection(e){return Ht().center(this.geoProjectionCenter).scale(this.geoProjectionScale).translate([0,0])(e)}updateTownLabelScale(){var u,d,h;const e=this.townNameLabels||this.otherLabel||[],t=(u=this.camera)==null?void 0:u.instance,a=(h=(d=this.camera)==null?void 0:d.controls)==null?void 0:h.target;if(!e.length||!t||!a)return;const i=t.position.distanceTo(a),s=Yt(i*72e-5,.011,.026),o=i>45?"0.76":i<22?"0.94":"1";e.forEach(g=>{var L,S,C;if(((L=g==null?void 0:g.userData)==null?void 0:L.labelType)!=="town-label")return;g.scale.set(s,s,s);const m=(C=(S=g.element)==null?void 0:S.querySelector)==null?void 0:C.call(S,".other-label");m&&(m.style.opacity=o)})}update(e){super.update(e),this.updateDynamicSatelliteTiles(),this.updateTownLabelScale(),this.updateTradeFlowPulses(e),this.interactionManager&&this.interactionManager.update()}pauseScene(){var e,t;this.scenePaused=!0,(t=(e=this.time)==null?void 0:e.pause)==null||t.call(e),this.sceneTweens.forEach(a=>{var i;return(i=a==null?void 0:a.pause)==null?void 0:i.call(a)}),clearInterval(this.infoPointLabelTime),this.infoPointLabelTime=null}resumeScene(){var e,t;this.scenePaused=!1,(t=(e=this.time)==null?void 0:e.resume)==null||t.call(e),this.sceneTweens.forEach(a=>{var i;return(i=a==null?void 0:a.resume)==null?void 0:i.call(a)}),this.showTownRankingPointMarkers&&this.mapAnimationComplete&&!this.infoPointLabelTime&&this.createInfoPointLabelLoop()}destroy(){var e,t,a,i;this.pauseScene(),this.sceneTimers.forEach(s=>clearTimeout(s)),this.sceneTimers=[],this.sceneTweens.forEach(s=>{var o;return(o=s==null?void 0:s.kill)==null?void 0:o.call(s)}),this.sceneTweens=[],this.callbacks={},(t=(e=this.canvas)==null?void 0:e.removeEventListener)==null||t.call(e,"pointerdown",this.handleCanvasBoundaryPointerDown,!0),(i=(a=this.canvas)==null?void 0:a.removeEventListener)==null||i.call(a,"dblclick",this.handleCanvasBoundaryDoubleClick,!0),this.clearTradeFlowLayer(),this.clearSelectedFeature(),super.destroy(),this.label3d&&this.label3d.destroy()}}const ic={class:"map"},rc={__name:"map",props:{activeLayer:{type:Object,default:null},mapRanking:{type:Object,default:null},tileUrlTemplate:{type:String,default:""},satelliteTextureZoom:{type:Number,default:0},satelliteMaxZoom:{type:Number,default:21},adminBoundaryLineScale:{type:Number,default:1},useSatelliteBase:{type:Boolean,default:!0},showNationalBackdrop:{type:Boolean,default:!1},topicLayerPresentation:{type:String,default:"default"},hideTownLabelStats:{type:Boolean,default:!1}},emits:["feature-loading","feature-info","layer-status","tile-status","draw-boundary","scene-mounted"],setup(b,{expose:e,emit:t}){const a=b,i=t,s=$(null),o=kl(null);let u=null,d=null,h=null,g=null,m=null,L="",S="",C=!1;Qr(()=>{i("scene-mounted")}),es(()=>{dt()});function F(M){return o.value?!0:s.value?(o.value=new nc(s.value,M,{onFeatureLoading:w=>i("feature-loading",w),onFeatureInfo:w=>i("feature-info",w),onLayerStatus:w=>i("layer-status",w),onTileStatus:w=>i("tile-status",w),onDrawBoundary:w=>i("draw-boundary",w),tileUrlTemplate:a.tileUrlTemplate,satelliteTextureZoom:a.satelliteTextureZoom,satelliteMaxZoom:a.satelliteMaxZoom,adminBoundaryLineScale:a.adminBoundaryLineScale,useSatelliteBase:a.useSatelliteBase,showNationalBackdrop:a.showNationalBackdrop,topicLayerPresentation:a.topicLayerPresentation,hideTownLabelStats:a.hideTownLabelStats}),o.value.time.pause(),L=Ke(a.activeLayer),S=ft(a.mapRanking),o.value.setTopicLayers(ve(a.activeLayer),a.activeLayer),o.value.setTownRanking(a.mapRanking),ge(),Fe(),!0):!1}function E(){return!!o.value}function D(){return he(this,null,function*(){var M,w,N,O,H,ne;if(o.value&&(J(),!o.value.mapAnimationComplete)){if(C){(w=(M=o.value.animateTl)==null?void 0:M.play)==null||w.call(M),ht();return}C=!0,(O=(N=o.value.animateTl)==null?void 0:N.timeScale)==null||O.call(N,1),(ne=(H=o.value.animateTl)==null?void 0:H.play)==null||ne.call(H),ht()}})}function J(){var M,w;o.value&&(ge(),Fe(),window.requestAnimationFrame(()=>{var N,O,H,ne,ue,_e;(H=(O=(N=o.value)==null?void 0:N.label3d)==null?void 0:O.resize)==null||H.call(O),(_e=(ue=(ne=o.value)==null?void 0:ne.label3d)==null?void 0:ue.update)==null||_e.call(ue)}),(w=(M=o.value).resumeScene)==null||w.call(M),o.value.resumeScene||o.value.time.resume())}function re(){var M,w,N,O,H,ne;o.value&&(Oe(),(w=(M=o.value.animateTl)==null?void 0:M.pause)==null||w.call(M),(O=(N=o.value).pauseScene)==null||O.call(N),o.value.pauseScene||(ne=(H=o.value.time)==null?void 0:H.pause)==null||ne.call(H),pt())}function K(){var M,w;(w=(M=o.value)==null?void 0:M.clearSelectedFeature)==null||w.call(M)}function G(M){var w,N;(N=(w=o.value)==null?void 0:w.focusProject)==null||N.call(w,M)}function Ce(M){var w,N;(N=(w=o.value)==null?void 0:w.focusPasture)==null||N.call(w,M)}function Ue(M,w){var N,O;return(O=(N=o.value)==null?void 0:N.focusTownByName)==null?void 0:O.call(N,M,w)}function at(M){var w,N;return(N=(w=o.value)==null?void 0:w.focusYakIndustryPoint)==null?void 0:N.call(w,M)}function wt(M){var w,N;return(N=(w=o.value)==null?void 0:w.focusVectorFeature)==null?void 0:N.call(w,M)}function z(M){var w,N;return(N=(w=o.value)==null?void 0:w.getVectorFeatureScreen)==null?void 0:N.call(w,M)}function je(M){var w,N;return(N=(w=o.value)==null?void 0:w.getYakIndustryPointScreen)==null?void 0:N.call(w,M)}function nt(M){var w,N;(N=(w=o.value)==null?void 0:w.setBoundaryDrawing)==null||N.call(w,M)}function Ft(){var M,w;return(w=(M=o.value)==null?void 0:M.finishBoundaryDrawing)==null?void 0:w.call(M)}function ct(){var M,w;(w=(M=o.value)==null?void 0:M.undoBoundaryPoint)==null||w.call(M)}function xt(){var M,w;(w=(M=o.value)==null?void 0:M.clearAnalysisBoundary)==null||w.call(M)}function Kt(M){var w,N;(N=(w=o.value)==null?void 0:w.showAnalysisResult)==null||N.call(w,M)}function dt(){var M,w;Oe(),pt(),(w=(M=o.value)==null?void 0:M.destroy)==null||w.call(M),o.value=null}function ht(){Oe(),m=window.setTimeout(()=>{var M,w;m=null,(w=(M=o.value)==null?void 0:M.ensureMapRevealed)==null||w.call(M)},5200)}function Oe(){m&&(window.clearTimeout(m),m=null)}function Fe(){d&&window.cancelAnimationFrame(d),d=window.requestAnimationFrame(()=>{var M,w,N,O,H;d=null,(N=(w=(M=o.value)==null?void 0:M.sizes)==null?void 0:w.init)==null||N.call(w),(H=(O=o.value)==null?void 0:O.resize)==null||H.call(O)}),h&&window.clearTimeout(h),h=window.setTimeout(()=>{var M,w,N,O,H;h=null,(N=(w=(M=o.value)==null?void 0:M.sizes)==null?void 0:w.init)==null||N.call(w),(H=(O=o.value)==null?void 0:O.resize)==null||H.call(O)},180)}function ge(){var w;pt();const M=(w=s.value)==null?void 0:w.parentNode;M&&window.ResizeObserver&&(u=new ResizeObserver(()=>Fe()),u.observe(M)),g=window.setInterval(xe,1e3),jt(Fe)}function xe(){var ue;if(!o.value||!s.value)return;const M=s.value.parentNode,w=(M==null?void 0:M.offsetWidth)||window.innerWidth||1,N=(M==null?void 0:M.offsetHeight)||window.innerHeight||1,O=((ue=o.value.sizes)==null?void 0:ue.pixelRatio)||1,H=Math.floor(w*O),ne=Math.floor(N*O);(s.value.width!==H||s.value.height!==ne)&&Fe()}function pt(){u&&(u.disconnect(),u=null),d&&(window.cancelAnimationFrame(d),d=null),h&&(window.clearTimeout(h),h=null),g&&(window.clearInterval(g),g=null)}function Lt(){if(!o.value)return;ge();const M=()=>{var w,N,O,H,ne,ue,_e,ze,Ae,Be,Ee,Ze,it,fe,me,Q,rt,mt,Me,Tt,St;o.value&&((N=(w=o.value)==null?void 0:w.resumeScene)==null||N.call(w),o.value.resumeScene||(H=(O=o.value.time)==null?void 0:O.resume)==null||H.call(O),(_e=(ue=(ne=o.value)==null?void 0:ne.sizes)==null?void 0:ue.init)==null||_e.call(ue),(Ae=(ze=o.value)==null?void 0:ze.resize)==null||Ae.call(ze),(Ze=(Ee=(Be=o.value)==null?void 0:Be.label3d)==null?void 0:Ee.resize)==null||Ze.call(Ee),(me=(fe=(it=o.value)==null?void 0:it.label3d)==null?void 0:fe.update)==null||me.call(fe),(rt=(Q=o.value)==null?void 0:Q.setTopicLayers)==null||rt.call(Q,ve(a.activeLayer),a.activeLayer),(Me=(mt=o.value)==null?void 0:mt.setTownRanking)==null||Me.call(mt,a.mapRanking),(St=(Tt=o.value)==null?void 0:Tt.ensureMapRevealed)==null||St.call(Tt))};Fe(),window.requestAnimationFrame(M),window.setTimeout(()=>{M()},80),window.setTimeout(()=>{M()},220)}function De(){if(!o.value)return;ge();const M=()=>{var N,O,H,ne,ue,_e,ze,Ae,Be,Ee,Ze,it,fe,me,Q,rt;const w=o.value;w&&((N=w.resumeScene)==null||N.call(w),w.resumeScene||(H=(O=w.time)==null?void 0:O.resume)==null||H.call(O),(ue=(ne=w.sizes)==null?void 0:ne.init)==null||ue.call(ne),(_e=w.resize)==null||_e.call(w),(ze=w.ensureMapRevealed)==null||ze.call(w),(Ae=w.setTradeNationalMapVisible)==null||Ae.call(w,!1),(Be=w.setTopicLayers)==null||Be.call(w,ve(a.activeLayer),a.activeLayer),(Ee=w.setTownRanking)==null||Ee.call(w,a.mapRanking),(Ze=w.applyLayerMapView)==null||Ze.call(w,w.currentTopicLayer||a.activeLayer||null,{force:!0}),(fe=(it=w.label3d)==null?void 0:it.resize)==null||fe.call(it),(Q=(me=w.label3d)==null?void 0:me.update)==null||Q.call(me),(rt=w.updateDynamicSatelliteTiles)==null||rt.call(w,!0))};Fe(),window.requestAnimationFrame(M),window.setTimeout(M,100),window.setTimeout(M,260)}qt(()=>a.activeLayer,M=>{const w=Ke(M);w!==L&&(L=w,o.value&&o.value.setTopicLayers(ve(M),M))},{deep:!0}),qt(()=>a.mapRanking,M=>{const w=ft(M);w!==S&&(S=w,o.value&&o.value.setTownRanking(M))},{deep:!0}),e({loadMap:F,hasMap:E,play:D,resume:J,pause:re,clearSelectedFeature:K,focusProject:G,focusPasture:Ce,focusTown:Ue,focusYakIndustryPoint:at,focusVectorFeature:wt,getVectorFeatureScreen:z,getYakIndustryPointScreen:je,setBoundaryDrawing:nt,finishBoundaryDrawing:Ft,undoBoundaryPoint:ct,clearAnalysisBoundary:xt,showAnalysisResult:Kt,refreshView:Lt,resetView:De,destroyMap:dt,canvasMap:o});function Ke(M){return M?ve(M).map(w=>{var N,O;return[w.key||"",w.layerName||"",w.styles||"",w.sldBody||"",w.cqlFilter||"",((N=w.activeLegend)==null?void 0:N.key)||"",Array.isArray(w.activeLegends)?w.activeLegends.map(H=>(H==null?void 0:H.key)||"").join(","):"",w.timelineDate||"",((O=w.timelineItem)==null?void 0:O.key)||"",w.sourceType||"",w.dataPath||"",w.fallbackPath||""].join("|")}).join("||"):""}function ve(M){if(!M)return[];const w=Array.isArray(M.overlayLayers)?M.overlayLayers.filter(Boolean):[];return[M,...w]}function ft(M){var w,N,O,H,ne,ue,_e,ze,Ae,Be;return M?[M.status||"",M.topicKey||"",M.layerKey||"",M.title||"",M.metricLabel||"",M.scope||"",M.displayMode||"",(w=M.showPointMarkers)!=null?w:"",(N=M.showBars)!=null?N:"",(O=M.showTownNames)!=null?O:"",(H=M.showMapLabels)!=null?H:"",(ne=M.hideTownLabelStats)!=null?ne:"",(ue=M.showFlowLines)!=null?ue:"",(_e=M.onlyRankedTownLabels)!=null?_e:"",(ze=M.showMissingTownStats)!=null?ze:"",((Ae=M.rows)==null?void 0:Ae.length)||0,((Be=M.rows)==null?void 0:Be.map(Ee=>{var Ze;return`${Ee.key||Ee.name||""}:${(Ze=Ee.value)!=null?Ze:""}`}).join(","))||""].join("|"):""}return(M,w)=>(x(),A("div",ic,[f("canvas",{ref_key:"canvasRef",ref:s},null,512)]))}};const sc={class:"yak-management"},oc={key:0},lc={class:"yak-management-ui"},uc={key:0,class:"trade-year-switcher","aria-label":"交易年份切换"},cc=["onClick"],dc={key:1,class:"epidemic-year-switcher","aria-label":"防疫年份切换"},hc=["onClick"],pc={key:2,class:"forecast-year-switcher","aria-label":"预测年份切换"},fc=["onClick"],mc={class:"yak-left"},gc={class:"yak-side-stack is-left"},yc={class:"breeding-health-card"},bc={class:"breeding-health-head"},vc={class:"breeding-health-grid"},wc={class:"structure-chart-card"},Lc={class:"structure-ratio-card"},Tc={class:"structure-ratio-chart"},Sc={viewBox:"0 0 150 150",preserveAspectRatio:"xMidYMid meet","aria-hidden":"true"},Mc={class:"structure-rose-segments"},kc=["d","fill","stroke"],Pc={class:"structure-ratio-list"},Cc={key:0,class:"yak-data-status"},Fc={key:1,class:"yak-data-status is-warning"},xc={class:"forecast-waterfall-card"},Nc={class:"forecast-waterfall-head"},Rc={class:"forecast-waterfall-list"},Ic={class:"forecast-trend-card"},Gc={class:"forecast-density-switcher","aria-label":"预测粒度切换"},_c=["onClick"],Ac={key:0,class:"epidemic-three-pie-card"},Bc={class:"epidemic-three-pie-visual"},Ec={class:"epidemic-three-pie-center"},$c={class:"epidemic-three-pie-legend"},Vc={key:1,class:"epidemic-empty"},Oc={class:"trade-risk-card"},Dc={class:"trade-risk-head"},zc={class:"trade-risk-list"},Wc={class:"yak-right"},Yc={class:"yak-side-stack is-right"},jc={class:"structure-chart-card"},Hc={class:"structure-summary-card"},qc={key:0,class:"yak-data-status"},Uc={key:1,class:"yak-data-status is-warning"},Kc={class:"forecast-heat-list"},Zc=["title"],Xc={class:"epidemic-record-table is-full"},Jc={class:"epidemic-record-toolbar"},Qc={class:"epidemic-record-rows"},ed=["onClick"],td={key:0,class:"epidemic-empty"},ad={class:"epidemic-record-pager"},nd=["disabled"],id=["disabled"],rd={class:"trade-cert-card"},sd={class:"trade-cert-main"},od={class:"trade-dest-list"},ld={key:0,class:"epidemic-empty"},ud={class:"trade-ledger-table"},cd={class:"trade-ledger-toolbar"},dd={class:"trade-ledger-rows"},hd=["onClick"],pd={key:0,class:"epidemic-empty"},fd={class:"trade-ledger-pager"},md=["disabled"],gd=["disabled"],yd={class:"yak-bottom-topic"},bd={key:3,class:"yak-map-layer-tools"},vd={class:"epidemic-ledger-dialog"},wd={class:"epidemic-ledger-dialog-head"},Ld={class:"epidemic-ledger-filters"},Td=["value"],Sd=["value"],Md={class:"epidemic-ledger-workspace"},kd={class:"epidemic-ledger-list"},Pd=["onClick"],Cd={key:0,class:"epidemic-empty"},Fd={class:"epidemic-ledger-detail trade-ledger-detail epidemic-ledger-record-detail"},xd={class:"epidemic-detail-head trade-detail-head"},Nd={class:"epidemic-detail-grid is-modal trade-detail-grid epidemic-detail-flat-grid"},Rd={key:0,class:"epidemic-detail-photos"},Id={class:"epidemic-modal-photo-strip"},Gd=["onClick"],_d=["src"],Ad={class:"epidemic-ledger-pager"},Bd=["disabled"],Ed=["disabled"],$d={class:"epidemic-ledger-dialog trade-ledger-dialog"},Vd={class:"epidemic-ledger-dialog-head"},Od={class:"epidemic-ledger-filters trade-ledger-filters"},Dd=["value"],zd=["value"],Wd=["value"],Yd={class:"epidemic-ledger-workspace trade-ledger-workspace"},jd={class:"epidemic-ledger-list trade-ledger-modal-list"},Hd=["onClick"],qd={key:0,class:"epidemic-empty"},Ud={class:"epidemic-ledger-detail trade-ledger-detail"},Kd={class:"epidemic-detail-head trade-detail-head"},Zd={class:"epidemic-detail-grid is-modal trade-detail-grid"},Xd={class:"is-wide"},Jd={class:"is-wide"},Qd={class:"is-wide"},eh={class:"is-wide"},th=["disabled"],ah={class:"epidemic-ledger-pager"},nh=["disabled"],ih=["disabled"],rh={class:"epidemic-image-preview-dialog"},sh={class:"epidemic-image-preview-head"},oh={class:"epidemic-image-preview-body"},lh={class:"epidemic-image-preview-frame"},uh=["src"],ch="https://qkl-hy.oss-cn-chengdu.aliyuncs.com/yak-vaccine-images",dh="https://qkl-map.oss-cn-chengdu.aliyuncs.com/hy-result/{z}/{x}/{y}.png",hh=9,ph="oss-satellite-dynamic-zoom21-v5",rn="#43d9e8",sn=8,Zr=14,Xn=8,Xr=14,fh=5e3,on=6,mh=4200,Jr="#FFE600",Ih={__name:"index",props:{active:{type:Boolean,default:!0},viewKey:{type:String,default:"structure"}},emits:["module-stats","view-change"],setup(b,{expose:e,emit:t}){const a=b,i=t,s=vr.sideCardWidth;vr.sideCardGap;const o=$(typeof window=="undefined"?1080:window.innerHeight),u=k(()=>zl(o.value)),d=k(()=>wr(u.value,2)),h=k(()=>u.value),g=k(()=>wr(u.value,2)),m=ga.textPrimary,L=ga.textStrong,S=ga.textSecondary,C=ga.textMuted,F=ga.chartGridLine,E=cu,D=E,J=E,re=du,K={targetLngLat:[102.6,32.59],targetLocalZ:.72,distanceScale:1.05,duration:.75},G=["#30dcff","#8bf7ff","#58d9ff","#28e8d6","#7bdfff","#9efcff"],Ce=["#30dcff","#8bf7ff","#58d9ff","#28e8d6","#7bdfff","#9efcff"],Ue=["#30dcff","#8bf7ff","#58d9ff","#28e8d6","#7bdfff","#9efcff","#48cfff"],at={name:"红原牦牛交易市场",lng:102.562157,lat:32.820484},wt=[{key:"structure",name:"畜群结构",color:"#30dcff"},{key:"forecast",name:"畜群预测",color:"#8bf7ff"},{key:"epidemic",name:"牦牛防疫",color:"#8bf7ff"},{key:"trade",name:"牦牛交易",color:"#63d7ff"}],z=$(Yn(a.viewKey)),je=$([]),nt=$("2027"),Ft=$("month"),ct=$(0),xt=$([]),Kt=$([]),dt=$([]),ht=$(!1),Oe=$(""),Fe=[2025,2026],ge=$(2026),xe=$({metrics:{}}),pt=$({rows:[],year:null}),Lt=$({rows:[]}),De=$([]),Ke=$(0),ve=$(1),ft=$(""),M=$(""),w=$(!1),N=$(""),O=$(!1),H=$([]),ne=$(0),ue=$(1),_e=$(!1),ze=$(""),Ae=$(null),Be=$(null),Ee=$(!1),Ze=$(!1),it=$(""),fe=$(Da()),me=$({years:[],latestYear:null}),Q=$({metrics:{},hasData:!1}),rt=$([]),mt=$(0),Me=$(null),Tt=$(!1),St=$(""),Mt=$(1),Ta=$(""),un=$(""),cn=$(!1),$t=$([]),Sa=$(0),Vt=$(1),dn=$(!1),hn=$(""),Ma=$(null),gt=$({keyword:"",startTown:"",usageType:"",certType:""}),Ne=$(null),la=$(null),Zt=$(!1),ua=$(!1),He=$(!1),ei=$(0),ti=$(0),ka=$({type:"idle",text:""}),Pa=$({type:"idle",text:""});let pn=null,Ca=!1,ai=!1,Nt=!1,kt=null,ca=!1,Fa=null,xa=null,Na=0,ni=!1,ii=!1,ri=!1;const fn=[{key:"day",label:"日",unit:"日",stepDays:1},{key:"week",label:"周",unit:"周",stepDays:7},{key:"month",label:"月",unit:"月",stepDays:30}],Xe=k(()=>Zl(nt.value)),ns=new Set(["epidemic","trade"]),mn=k(()=>!ns.has(z.value)),si=k(()=>mn.value?dh:""),is=k(()=>mn.value?"oss-satellite":"solid-3d"),rs=k(()=>`yak-management-map-${is.value}-${ph}-${ei.value}`),ss=k(()=>Xl+Jl),gn=k(()=>Xe.value.stock-lt),os=k(()=>wl(Xe.value)),Ra=k(()=>cl(dt.value,ba)),ls=k(()=>Ra.value.reduce((n,r)=>n+Number(r.count||0),0));k(()=>{const n=ls.value||1;return Ra.value.map((r,l)=>{const c=Number(r.count||0),p=Number(r.ratio);return V(I({},r),{count:c,color:G[l%G.length],percent:Number.isFinite(p)?p:c/n*100})})});const us=k(()=>or(Ra.value,ba)),Ia=k(()=>us.value),oi=k(()=>ml(Ia.value)),li=k(()=>gl(Ra.value,ba)),ui=k(()=>bl(li.value)),cs=k(()=>Math.max(...oi.value.map(n=>Number(n.count||0)),1)),yn=k(()=>Ia.value.length?0:-1),ds=k(()=>{const n=Ia.value,r=n.length;if(!r)return[];const l=Math.max(...n.map(y=>Number(y.count||0)),1),c=360/r,p=Math.min(8,c*.16);return n.map((y,v)=>{const T=Number(y.count||0),R=v===yn.value,B=36+Math.sqrt(T/l)*31+(R?5:0),_=17,W=-90+v*c+p/2,Z=-90+(v+1)*c-p/2,X=(W+Z)/2,ce=zt(75,75,B+3,X),Re=zt(75,75,B+15,X),st=zt(75,75,B+20,X);return{key:y.key||y.name||v,index:v,item:y,color:y.color||G[v%G.length],path:fl(75,75,_,B,W,Z),lineStart:ce,lineEnd:Re,label:st,anchor:Math.cos(X*Math.PI/180)>=0?"start":"end"}})}),ci=k(()=>rr(["fertileCow","overageCow"])),di=k(()=>rr(["femaleCalf","maleCalf"])),Rt=k(()=>Ql(Mo(xt.value.length?xt.value:kr,kr),lt)),bn=k(()=>Pu),vn=k(()=>eu(Xe.value)),hs=k(()=>tu(Xe.value)),wn=k(()=>{var n;return((n=xe.value)==null?void 0:n.metrics)||{}}),Ln=k(()=>{var n;return Pt((n=xe.value)==null?void 0:n.dateTrend).sort(Go)}),Ga=k(()=>{var n;return Pt((n=xe.value)==null?void 0:n.medicineCounts)}),_a=k(()=>Ga.value.filter(n=>n.value>0).map((n,r)=>V(I({},n),{key:n.key||`${n.name}-${r}`,unit:"条"}))),ps=k(()=>_a.value.map(n=>`${n.name}:${n.value}`).join("|")||"epidemic-medicine-empty"),fs=k(()=>{var n;return Pt((n=xe.value)==null?void 0:n.ownerRanks).slice(0,8)}),It=k(()=>Mi(xe.value)),ms=k(()=>{var n;return((n=Ga.value.find(r=>r.name&&r.name!=="未填写"))==null?void 0:n.name)||"-"}),yt=k(()=>Wa(wn.value,["total","vaccine"]));k(()=>Wa(wn.value,["owners"]));const gs=k(()=>Number(ge.value)===2026?10:Wa(wn.value,["villages"])),Tn=k(()=>Ot.value.length),ys=k(()=>{var n;return((n=Ot.value[0])==null?void 0:n.name)||"-"}),hi=k(()=>{const n=De.value.map(r=>r.operateTime).filter(Boolean).sort();return n.length?_t(n[n.length-1]):"-"}),Sn=k(()=>{const n=Math.max(...Ga.value.map(r=>Number(r.value||0)),0);return n>0?n:Math.round(yt.value/It.value)}),Mn=k(()=>{var r;const n=Co((r=pt.value)==null?void 0:r.rows);return n.length?n:Ot.value.map(l=>({name:l.name,recordCount:Number(l.recordCount||0),earTagCount:Number(l.earTagCount||0),ratio:l.ratio,source:"ledger"}))}),pi=k(()=>{var r;const n=new Set;return $n((r=Lt.value)==null?void 0:r.rows).filter(l=>Number.isFinite(l.lng)&&Number.isFinite(l.lat)).map((l,c)=>{const p=`${l.lng.toFixed(4)},${l.lat.toFixed(4)}`,y=n.has(p)?(c%3-1)*.012:0;return n.add(p),V(I({},l),{name:l.village,value:l.earTagCount,unit:"万头",lng:l.lng+y,lat:l.lat-y*.65,displayValue:Number((l.earTagCount/1e4).toFixed(2)),displayUnit:"万头",rankLabel:`${c+1}`})})}),Ot=k(()=>{var r;const n=new Map;return Pt((r=xe.value)==null?void 0:r.townCounts).forEach(l=>{const c=Qe(l.name);c&&n.set(c,Number(n.get(c)||0)+Number(l.value||0))}),[...n.entries()].map(([l,c])=>{const p=Math.round(c/It.value),y=yt.value?c/yt.value*100:0;return{name:l,recordCount:c,earTagCount:p,ratio:y}}).sort((l,c)=>Number(c.recordCount||0)-Number(l.recordCount||0))}),bs=k(()=>Math.max(Rt.value.length,Tn.value)),vs=k(()=>new Set(Ot.value.map(n=>Qe(n.name)).filter(Boolean))),Gt=k(()=>{const n=vs.value;return Rt.value.map(r=>Qe(r.name)).filter(r=>r&&!n.has(r))}),ws=k(()=>{const n=bs.value||Tn.value||1;return Tn.value/n*100});k(()=>Sn.value/lt*100);const Aa=k(()=>Ao());k(()=>yt.value?Gt.value.length?Gt.value.length:Aa.value.name&&Aa.value.name!=="暂无"?1:0:0);const Ls=k(()=>Bo()),Ts=k(()=>Eo()),Ss=k(()=>$o());k(()=>Vo());const Ms=k(()=>Oo());k(()=>Ms.value.slice(0,3)),k(()=>yt.value?Gt.value.length?"年度免疫进度需核查":Aa.value.desc:"年度计划待核查");const kn=k(()=>Math.max(Math.ceil(Ke.value/sn),1)),ks=k(()=>De.value.slice(0,sn)),fi=k(()=>Math.max(Math.ceil(ne.value/Zr),1)),Dt=k(()=>Be.value||Ae.value||{}),mi=k(()=>On(Dt.value)),Ps=k(()=>{const n=Dt.value||{};return[ke("台账编号",n.epidemicId,{wide:!0}),ke("养殖户",n.owner,{wide:!0}),ke("联系电话",Gi(n.phone)),ke("证件类型",n.idType),ke("证件号码",Yo(n.idNo)),ke("镇/乡",n.town),ke("村",n.village),ke("详细地址",n.location,{wide:!0}),ke("畜种",n.livestockType),ke("性别",n.sex),ke("畜龄",n.age),ke("体重",jo(n.weight)),ke("疫苗/药品",n.medicine),ke("防疫类型",n.preventionType),ke("免疫方式",n.method),ke("剂量",Ho(n.dose)),ke("免疫时间",_t(n.operateTime)),ke("操作员",n.operator)].filter(Boolean)}),Cs=k(()=>{var n;return Pt((n=xe.value)==null?void 0:n.townCounts).map(r=>r.name)}),Fs=k(()=>Ga.value.map(n=>n.name).filter(n=>n&&n!=="未填写")),gi=k(()=>{var n;return((n=Q.value)==null?void 0:n.metrics)||{}}),yi=k(()=>{var n,r,l,c,p,y,v,T;return ki((n=me.value)==null?void 0:n.years,(r=Q.value)==null?void 0:r.availableYears,(l=Q.value)==null?void 0:l.available_years,(c=Q.value)==null?void 0:c.yearSummary,(p=Q.value)==null?void 0:p.year_summary,(y=Q.value)==null?void 0:y.latestYear,(v=Q.value)==null?void 0:v.latest_year,(T=Q.value)==null?void 0:T.year)}),xs=k(()=>{var n,r;return za(((n=Q.value)==null?void 0:n.monthTrend)||((r=Q.value)==null?void 0:r.month_trend),"name")});k(()=>{var n,r;return ko(((n=Q.value)==null?void 0:n.yearSummary)||((r=Q.value)==null?void 0:r.year_summary))});const Ba=k(()=>{var n,r;return za(((n=Q.value)==null?void 0:n.startTownCounts)||((r=Q.value)==null?void 0:r.start_town_counts),"name")}),Pn=k(()=>{var n,r;return za(((n=Q.value)==null?void 0:n.usageCounts)||((r=Q.value)==null?void 0:r.usage_counts),"name")}),Ns=k(()=>{var n,r,l,c,p,y;return za(((n=Q.value)==null?void 0:n.transportNumberCounts)||((r=Q.value)==null?void 0:r.transport_number_counts)||((l=Q.value)==null?void 0:l.vehicleCounts)||((c=Q.value)==null?void 0:c.vehicle_counts)||((p=Q.value)==null?void 0:p.transportCounts)||((y=Q.value)==null?void 0:y.transport_counts),"transportNumber")}),Ea=k(()=>{const n=Ba.value.map(l=>{const c=String(l.name||"").trim(),p=Qe(c),y=Gn(p||c);return V(I({},l),{rawName:c,name:y,displayName:y,town:p,mapTownName:p})}).filter(l=>l.name&&l.name!=="未填写").slice(0,10),r=Math.max(...n.map(l=>l.headCount),1);return n.map((l,c)=>V(I({},l),{key:l.key||`${l.mapTownName||l.name}-${c}`,value:l.headCount,unit:"头",ratio:Math.max(8,Math.round(l.headCount/r*100))}))}),bi=k(()=>rt.value.slice(0,Xn)),Cn=k(()=>Math.max(Math.ceil(mt.value/Xn),1)),Fn=k(()=>Math.max(Math.ceil(Sa.value/Xr),1)),ye=k(()=>Ma.value||{}),Rs=k(()=>ye.value.certId||ye.value.factoryCode||""),Is=k(()=>{var r,l;const n=Bn(((r=me.value)==null?void 0:r.startTowns)||((l=me.value)==null?void 0:l.start_towns));return n.length?n:En(Ba.value.map(c=>c.name))}),Gs=k(()=>{var r,l;const n=Bn(((r=me.value)==null?void 0:r.usageTypes)||((l=me.value)==null?void 0:l.usage_types));return n.length?n:En(Pn.value.map(c=>c.name))}),_s=k(()=>{var r,l,c,p;const n=Po(((r=me.value)==null?void 0:r.certTypeOptions)||((l=me.value)==null?void 0:l.cert_type_options));return n.length?n:Bn(((c=me.value)==null?void 0:c.certTypes)||((p=me.value)==null?void 0:p.cert_types)).map(y=>({value:y,label:y}))}),As=k(()=>Ea.value.map((n,r)=>({key:n.key||`${n.name}-${r}`,name:n.displayName||n.name,displayName:n.displayName||n.name,rawName:n.rawName,town:n.mapTownName||n.town||Qe(n.name),mapTownName:n.mapTownName||n.town||Qe(n.name),value:n.headCount,headCount:n.headCount,recordCount:n.recordCount,ratio:n.ratio,unit:"头"}))),vi=k(()=>Do()),Bs=k(()=>{const n=vi.value.filter(r=>r.level==="high");return n.length>=2?`${n.length}项重点`:n.length===1?`重点:${n[0].name}`:"整体平稳"}),Es=k(()=>Rt.value.map(n=>V(I({},n),{breedingCowRatio:ci.value,calfRatio:di.value,breedingCow:Math.round(n.count*ci.value/100),calf:Math.round(n.count*di.value/100)}))),$a=k(()=>{const n=Es.value,r=n.length,l=Math.max(Math.ceil(r/on),1),c=ct.value%l,p=c*on,y=Math.min(p+on,r);return{page:c,pageCount:l,start:p,end:y,total:r,rows:n.slice(p,y)}}),$s=k(()=>z.value==="forecast"?vn.value:Rt.value),Vs=k(()=>z.value==="forecast"?"forecast":"count"),Os=k(()=>ol($s.value,Vs.value)),da=k(()=>({key:"yak-marks-layer",sourceType:"wmts",layerName:"ne:daping_yak_marks",style:"ne:yak_marks",styles:"ne:yak_marks",format:"image/png",tileMatrixSetID:"EPSG:900913",maximumLevel:21,url:"/geoserver/gwc/service/wmts",cqlFilter:"gov_show = true",name:"牦牛识别",opacity:.92,queryBuffer:10,geometryField:"geom",fillColor:"rgba(255, 230, 0, 0)",strokeColor:Jr,glowColor:"rgba(255, 230, 0, 0.42)",lineWidth:1.4,mapView:{targetLngLat:E,distanceScale:.82,targetLocalZ:.76,duration:.85},legends:[{key:"yak-marks",name:"牦牛",fillColor:Jr,strokeColor:"#FFF58A",selectable:!1}]})),Ds=k(()=>[da.value]),zs=k(()=>{const n=Array.isArray(je.value)?je.value:[je.value];return new Set(n.map(String).filter(Boolean))}),xn=k(()=>zs.value.has(da.value.key)),Ws=k(()=>xn.value?da.value.legends||[]:[]),Ys=k(()=>xn.value?202:172),js=k(()=>{var l;const r=$n((l=Lt.value)==null?void 0:l.rows).map(c=>No(c.town,c.village)).filter(Boolean);return{key:"yak-epidemic-village-boundary",sourceType:"wfs",layerName:"ne:t_pastures_map",styles:"牧场样式",name:"防疫村边界",opacity:.86,queryBuffer:8,cqlFilter:r.length?r.join(" OR "):"EXCLUDE",legends:[{key:"yak-epidemic-village-boundary",name:"防疫村边界",fillColor:"#30DCFF",strokeColor:"#C9FBFF",selectable:!1}]}}),wi=k(()=>z.value==="epidemic"?js.value:z.value==="trade"?null:Je.value?xn.value?da.value:null:da.value),Je=k(()=>z.value==="structure"||z.value==="forecast"),Hs=k(()=>z.value==="forecast"?J:D),qs=k(()=>Je.value?null:wi.value),Us=k(()=>Je.value?null:Xs.value),Ks=k(()=>Je.value?!ua.value:!Zt.value),Zs=k(()=>Je.value?"地图加载中":"3D 地图加载中"),Xs=k(()=>z.value==="trade"?{scope:"trade-flow",title:`${Me.value||""}出栏来源`,metricLabel:"来源",unit:"头",source:V(I({},at),{total:We("headCount")}),rows:As.value,showFlowLines:!1,mapView:K}:{scope:z.value==="epidemic"?"village":"town",hideTownNames:z.value==="epidemic",title:z.value==="forecast"?`${Xe.value.shortLabel}预测存栏`:z.value==="epidemic"?`${ge.value}年村级防疫信息`:"乡镇估算存栏",metricLabel:z.value==="forecast"?"预测":z.value==="epidemic"?"防疫":"存栏",unit:"万头",rows:z.value==="epidemic"?pi.value:Os.value.map(n=>({name:n.name,value:Number((n.value/1e4).toFixed(2)),unit:"万头"}))}),Js=k(()=>({color:["#8bf7ff","#30dcff"],tooltip:V(I({},we()),{trigger:"axis",axisPointer:{type:"shadow"},formatter(n){const r=n.map(l=>`${l.marker}${l.seriesName}${U(Math.abs(l.value))}`);return`${n[0].name}<br/>${r.join("<br/>")}`}}),legend:{top:4,right:12,itemWidth:12,itemHeight:8,textStyle:{color:S,fontSize:11}},grid:{left:22,right:22,top:32,bottom:12,containLabel:!0},xAxis:{type:"value",axisLabel:{color:C,fontSize:10,formatter:n=>ae(Math.abs(n))},splitLine:{lineStyle:{color:F,type:"dashed"}},axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"category",data:qn.map(n=>n.age),axisLabel:{color:m,fontSize:11,fontWeight:700},axisLine:{show:!1},axisTick:{show:!1}},series:[{name:"母牛",type:"bar",stack:"gender",barWidth:12,data:qn.map(n=>-n.cow),itemStyle:{borderRadius:[7,0,0,7]}},{name:"公牛",type:"bar",stack:"gender",barWidth:12,data:qn.map(n=>n.bull),itemStyle:{borderRadius:[0,7,7,0]}}]})),Qs=k(()=>{const n=Rt.value,r=n.map(l=>l.count);return{color:G,tooltip:V(I({},we()),{trigger:"axis",axisPointer:{type:"shadow"},formatter(l){const c=l.map(p=>`${p.marker}${p.seriesName}${U(p.value)}`);return`${l[0].name}<br/>${c.join("<br/>")}<br/>估算存栏:${U(r[l[0].dataIndex])}头<br/>结构依据:畜群结构比例表`}}),legend:{top:-2,right:0,itemWidth:8,itemHeight:6,itemGap:6,textStyle:{color:S,fontSize:10}},grid:{left:54,right:30,top:22,bottom:8},xAxis:{type:"value",axisLabel:{color:C,fontSize:10,formatter:ae},splitLine:{lineStyle:{color:F,type:"dashed"}},axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"category",inverse:!0,data:n.map(l=>l.name),axisLabel:{color:m,fontSize:10,fontWeight:700,interval:0},axisLine:{show:!1},axisTick:{show:!1}},series:ba.map(l=>({name:l.name,type:"bar",stack:"town",barWidth:n.length>8?6:11,data:n.map(c=>Math.round(c.count*l.ratio/100))}))}}),eo=k(()=>Wn(Rt.value,"count","头",{style:"ladder",tooltipFormatter(n){const r=Rt.value[n.dataIndex];return`${r.name}<br/>估算存栏:${U(r.count)}头<br/>来源:无人机识别`}})),to=k(()=>{const n=$a.value,r=n.rows,l=Math.max(...r.map(c=>c.breedingCow+c.calf),1);return{color:["#30dcff","#8bf7ff"],animationDurationUpdate:700,animationEasingUpdate:"cubicOut",tooltip:V(I({},we()),{trigger:"axis",axisPointer:{type:"shadow"},formatter(c){const p=r[c[0].dataIndex],y=c.filter(v=>["能繁母牛","犊牛合计"].includes(v.seriesName)).map(v=>`${v.marker}${v.seriesName}${U(v.value)}`);return`${p.name}<br/>母犊合计:${U(p.breedingCow+p.calf)}头<br/>${y.join("<br/>")}<br/>依据:无人机识别 + 畜群结构比例表`}}),legend:{data:["能繁母牛","犊牛合计"],top:2,left:2,itemWidth:10,itemHeight:7,itemGap:9,textStyle:{color:S,fontSize:10}},graphic:n.total>on?{type:"text",right:4,top:3,silent:!0,style:{text:`${n.start+1}-${n.end} / ${n.total}`,fill:C,fontSize:10,fontWeight:600}}:void 0,grid:{left:18,right:18,top:42,bottom:44,containLabel:!1},xAxis:{type:"category",data:r.map(c=>c.name),axisLabel:{color:C,fontSize:10,lineHeight:12,interval:0,margin:8,formatter:Io},axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"value",max:Math.ceil(l*1.28),axisLabel:{show:!1},axisLine:{show:!1},axisTick:{show:!1},splitLine:{lineStyle:{color:F,type:"dashed"}}},series:[{name:"基础群规模",type:"bar",barWidth:15,barGap:"-100%",data:r.map(c=>c.breedingCow+c.calf),tooltip:{show:!1},itemStyle:{borderRadius:[8,8,1,1],color:"rgba(48, 220, 255, 0.07)"},silent:!0},{name:"能繁母牛",type:"bar",stack:"foundation",barWidth:15,data:r.map(c=>c.breedingCow),itemStyle:{borderRadius:[1,1,0,0],color:new $e(0,0,0,1,[{offset:0,color:"rgba(48, 220, 255, 0.34)"},{offset:1,color:"#30dcff"}])}},{name:"犊牛合计",type:"bar",stack:"foundation",barWidth:15,data:r.map(c=>c.calf),itemStyle:{borderRadius:[8,8,1,1],color:new $e(0,0,0,1,[{offset:0,color:"#8bf7ff"},{offset:1,color:"rgba(139, 247, 255, 0.2)"}])},label:{show:!0,position:"top",formatter:({dataIndex:c})=>ae(r[c].breedingCow+r[c].calf),color:"#ffffff",fontSize:10,fontWeight:700}}]}}),ao=k(()=>{const n=Pr.slice().sort((c,p)=>p.value-c.value),r=Pr.reduce((c,p)=>c+p.value,0),l=n.map(c=>c.yoy||0);return{color:[rn,"#8bf7ff"],tooltip:V(I({},we()),{trigger:"axis",axisPointer:{type:"shadow"},formatter(c){const p=n[c[0].dataIndex];return`${p.label}<br/>数量:${U(p.value)}头<br/>占比:${et(p.value/r*100)}<br/>同比:${p.yoy>0?"+":""}${p.yoy}%`}}),grid:{left:36,right:30,top:20,bottom:34},xAxis:{type:"category",data:n.map(c=>c.label),axisLabel:{color:m,fontSize:10,fontWeight:700,interval:0,margin:10},axisLine:{lineStyle:{color:"rgba(48, 220, 255, 0.24)"}},axisTick:{show:!1}},yAxis:[{type:"value",axisLabel:{color:C,fontSize:10,formatter:ae},splitLine:{lineStyle:{color:F,type:"dashed"}}},{type:"value",min:Math.min(-2,Math.floor(Math.min(...l)-1)),max:Math.max(8,Math.ceil(Math.max(...l)+1)),axisLabel:{color:S,fontSize:10,formatter:"{value}%"},splitLine:{show:!1},axisLine:{show:!1},axisTick:{show:!1}}],series:[{name:"数量",type:"bar",barWidth:16,data:n.map(c=>({value:c.value,itemStyle:{borderRadius:[2,2,1,1],color:new $e(0,0,0,1,[{offset:0,color:rn},{offset:.58,color:"rgba(67, 217, 232, 0.72)"},{offset:1,color:"rgba(67, 217, 232, 0.16)"}]),shadowBlur:2,shadowColor:"rgba(48, 220, 255, 0.16)"},label:{show:!0,position:"top",color:L,fontSize:10,fontFamily:Hn.number,fontWeight:700,formatter:({value:p})=>ae(p)}}))},{name:"同比",type:"line",yAxisIndex:1,smooth:!0,symbol:"circle",symbolSize:6,data:l,lineStyle:{width:2,color:"#8bf7ff"},itemStyle:{color:"#8bf7ff",borderColor:"rgba(3, 18, 28, 0.9)",borderWidth:2},label:{show:!0,position:"top",color:"#8bf7ff",fontSize:10,formatter:({value:c})=>`${c>0?"+":""}${c}%`}}]}}),no=k(()=>{const n=al(Ft.value),r=nl(Xe.value,n.key),l=sl(r),c=il(l.length,n.key);return{color:["#30dcff","#8bf7ff","#48cfff"],tooltip:V(I({},we()),{trigger:"axis",triggerOn:"mousemove|click",axisPointer:{type:"cross",crossStyle:{color:"rgba(126, 251, 246, 0.42)"},label:{color:"#eaffff",backgroundColor:"rgba(5, 31, 51, 0.96)"}},formatter(p){var B,_,W;const y=Array.isArray(p)?p:[p],v=y.find(Z=>Z.seriesType==="candlestick"),T=(v==null?void 0:v.data)||l[(W=(_=v==null?void 0:v.dataIndex)!=null?_:(B=y[0])==null?void 0:B.dataIndex)!=null?W:0];if(!T)return"";const R=T.close-T.open;return[`${T.label}${n.unit}度预测`,`预测存栏:${U(T.close)}`,`较上期:${Ua(R)}`,`新生牛犊:${U(T.birth)}`,`出栏扣减:${U(T.outflow)}`].join("<br/>")}}),legend:{top:4,right:8,data:["预测存栏","新生牛犊","出栏扣减"],itemWidth:12,itemHeight:8,textStyle:{color:S,fontSize:10}},grid:{left:44,right:40,top:34,bottom:28},xAxis:{type:"category",boundaryGap:!0,data:r.labels,axisLabel:{color:C,fontSize:10,interval:c},axisLine:{lineStyle:{color:"rgba(48, 220, 255, 0.28)"}},axisTick:{show:!1}},yAxis:[{type:"value",scale:!0,axisLabel:{color:C,fontSize:10,formatter:ae},splitLine:{lineStyle:{color:F,type:"dashed"}}},{type:"value",axisLabel:{color:S,fontSize:10,formatter:ae},splitLine:{show:!1}}],series:[{name:"预测存栏",type:"candlestick",yAxisIndex:0,barWidth:rl(l.length,n.key),data:l,itemStyle:{color:"rgba(48, 220, 255, 0.82)",color0:"rgba(72, 207, 255, 0.82)",borderColor:"#30dcff",borderColor0:"#48cfff",borderWidth:1.4}},{name:"预测存栏线",type:"line",yAxisIndex:0,smooth:!0,symbol:"circle",symbolSize:4,data:l.map(p=>p.close),lineStyle:{width:1.8,color:"rgba(48, 220, 255, 0.86)"},itemStyle:{color:"#30dcff",borderColor:"rgba(3, 18, 28, 0.9)",borderWidth:1},tooltip:{show:!1}},nr("新生牛犊",r.births,"#8bf7ff",1),nr("出栏扣减",r.outflow,"#48cfff",1)]}}),io=k(()=>({color:["#30dcff","#8bf7ff"],tooltip:V(I({},we()),{trigger:"axis"}),legend:{top:4,right:12,itemWidth:12,itemHeight:8,textStyle:{color:S,fontSize:10}},grid:{left:52,right:42,top:34,bottom:28},xAxis:{type:"category",data:bn.value.map(n=>n.month||n.name),axisLabel:{color:C,fontSize:10,interval:1},axisLine:{lineStyle:{color:"rgba(48, 220, 255, 0.26)"}},axisTick:{show:!1}},yAxis:[{type:"value",axisLabel:{color:C,fontSize:10,formatter:n=>{const r=Number(n);return Number.isFinite(r)?Math.abs(r)>=1e4?`${Number((r/1e4).toFixed(1))}`:`${r}`:n}},splitLine:{lineStyle:{color:F,type:"dashed"}}},{type:"value",axisLabel:{color:S,fontSize:10},splitLine:{show:!1}}],series:[{name:"数量",type:"bar",barWidth:12,data:bn.value.map(n=>n.count||n.value),itemStyle:{borderRadius:[8,8,0,0],color:new $e(0,0,0,1,[{offset:0,color:"#30dcff"},{offset:1,color:"rgba(48, 220, 255, 0.08)"}])}},{name:"增速",type:"line",yAxisIndex:1,smooth:!0,symbolSize:5,data:bn.value.map(n=>n.speed||n.growthRate||0),lineStyle:{width:2.4,color:"#8bf7ff"},itemStyle:{color:"#8bf7ff"}}]})),ro=k(()=>({tooltip:we(),radar:{center:["50%","54%"],radius:"68%",splitNumber:4,indicator:Cr.map(n=>({name:n.name,max:100})),axisName:{color:"rgba(223, 250, 255, 0.76)",fontSize:11},splitLine:{lineStyle:{color:"rgba(48, 220, 255, 0.22)"}},splitArea:{areaStyle:{color:["rgba(48, 220, 255, 0.04)","rgba(139, 247, 255, 0.018)"]}},axisLine:{lineStyle:{color:"rgba(48, 220, 255, 0.18)"}}},series:[{type:"radar",data:[{name:"预测因子",value:Cr.map(n=>n.value),areaStyle:{color:"rgba(48, 220, 255, 0.22)"},lineStyle:{color:"#30dcff",width:2},itemStyle:{color:"#8bf7ff"}}]}]})),so=k(()=>Wn(vn.value,"forecast","头")),oo=k(()=>{const n=hs.value,r=n.reduce((l,c,p)=>{const y=c.color||G[p%G.length];return l[`name${p}`]={color:y,fontSize:10,fontWeight:800},l[`percent${p}`]={color:y,fontSize:10,fontFamily:"D-DIN, Arial, sans-serif",fontWeight:800},l},{});return{color:G,tooltip:we(l=>{var p;const c=n.find(y=>y.name===l.name);return`${l.name}<br/>预测占比:${et((p=c==null?void 0:c.ratio)!=null?p:l.percent)}<br/>预测数量:${U((c==null?void 0:c.count)||0)}`}),legend:{orient:"vertical",right:4,top:"middle",itemWidth:8,itemHeight:8,itemGap:6,formatter(l){const c=n.findIndex(y=>y.name===l),p=n[c];return p?`{name${c}|${l}} {percent${c}|${et(p.ratio)}}`:l},textStyle:{color:S,fontSize:10,rich:r}},series:[{name:"期末结构预测",type:"pie",radius:["38%","66%"],center:["32%","54%"],startAngle:118,avoidLabelOverlap:!1,label:{show:!1},labelLine:{show:!1},itemStyle:{borderColor:"rgba(3, 18, 31, 0.92)",borderWidth:3},data:n.map(l=>({name:l.name,value:l.count}))}]}}),lo=k(()=>({color:["#8bf7ff","#48cfff","#48cfff"],tooltip:V(I({},we()),{trigger:"axis",axisPointer:{type:"shadow"}}),legend:{top:4,right:8,itemWidth:12,itemHeight:8,textStyle:{color:S,fontSize:10}},grid:{left:44,right:26,top:34,bottom:28},xAxis:{type:"category",data:Bt.map(n=>n.shortLabel),axisLabel:{color:m,fontSize:11,fontWeight:700},axisLine:{lineStyle:{color:"rgba(48, 220, 255, 0.26)"}},axisTick:{show:!1}},yAxis:{type:"value",axisLabel:{color:C,fontSize:10,formatter:n=>qa(n,1)},splitLine:{lineStyle:{color:F,type:"dashed"}}},series:[{name:"新生牛犊",type:"bar",barWidth:12,data:Bt.map(n=>n.births),itemStyle:{borderRadius:[7,7,0,0]}},{name:"出栏流出",type:"bar",barWidth:12,data:Bt.map(n=>-n.outflow),itemStyle:{borderRadius:[0,0,7,7]}},{name:"稳态校正",type:"line",smooth:!0,symbolSize:6,data:Bt.map(n=>n.correction),lineStyle:{width:2.4}}]})),uo=k(()=>{const n=vn.value,r=Math.max(...n.map(l=>Math.abs(l.change)),1);return n.map(l=>V(I({},l),{width:Math.max(8,Math.round(Math.abs(l.change)/r*100))}))});function co(n){const r=Number((n==null?void 0:n.change)||0)>=0;return{"--heat-width":`${n.width}%`,"--heat-color":r?"#30dcff":"#8bf7ff","--heat-color-soft":r?"rgba(48, 220, 255, 0.24)":"rgba(139, 247, 255, 0.22)","--heat-color-dim":r?"rgba(48, 220, 255, 0.07)":"rgba(139, 247, 255, 0.07)"}}function ho(n){return`${n.name}${Ua(n.change)}`}const po=k(()=>{const n=Ln.value,r=n.map(c=>c.value),l=Math.max(...r,1);return{color:["#30dcff","#8bf7ff"],tooltip:V(I({},we()),{trigger:"axis",axisPointer:{type:"line",lineStyle:{color:"rgba(48, 220, 255, 0.28)"}},formatter(c){const p=c[0];return`${p.name}<br/>防疫记录:${U(p.value)}`}}),grid:{left:42,right:24,top:20,bottom:28},xAxis:{type:"category",data:n.map(c=>c.name),axisLabel:{color:C,fontSize:10,interval:Math.max(Math.floor(n.length/7),0)},axisLine:{lineStyle:{color:"rgba(48, 220, 255, 0.22)"}},axisTick:{show:!1}},yAxis:{type:"value",axisLabel:{color:C,fontSize:10,formatter:ae},splitLine:{lineStyle:{color:F,type:"dashed"}}},series:[{name:"防疫记录",type:"bar",barMaxWidth:12,data:r,itemStyle:{borderRadius:[7,7,0,0],color:new $e(0,0,0,1,[{offset:0,color:"#8bf7ff"},{offset:.45,color:"#30dcff"},{offset:1,color:"rgba(48, 220, 255, 0.08)"}])},label:{show:!0,position:"top",color:"rgba(230, 255, 249, 0.92)",fontSize:10,formatter:({value:c})=>c>=l*.42?ae(c):""}},{name:"作业趋势",type:"line",smooth:!0,showSymbol:!1,data:r,lineStyle:{width:2.4,color:"#8bf7ff"}}]}});k(()=>{const n=Ln.value.length?Ln.value.slice(-6):[{name:"待开展",value:0}],r=n.map(v=>Number(v.value||0)),l=Ls.value,c=l.map(v=>Number(v.value||0)),p=Math.max(...r,1),y=v=>String(v||"").replace(/(镇|乡|村)$/,"");return{color:["#30dcff","#8bf7ff"],title:[{text:"作业节奏",left:4,top:0,textStyle:{color:"rgba(226, 252, 255, 0.82)",fontSize:11,fontWeight:800}},{text:"补免关注",left:"55%",top:0,textStyle:{color:"rgba(226, 252, 255, 0.82)",fontSize:11,fontWeight:800}}],tooltip:V(I({},we()),{trigger:"axis",formatter(v){const T=Array.isArray(v)?v[0]:v;if((T==null?void 0:T.axisIndex)===1){const B=l[T.dataIndex]||{};return`${B.name}<br/>补免关注:${B.label||T.value}`}const R=n[T.dataIndex]||{};return`${R.name}<br/>防疫记录:${U(R.value)}`}}),grid:[{left:6,right:"52%",top:26,bottom:15},{left:"56%",right:12,top:26,bottom:15}],xAxis:[{type:"category",gridIndex:0,data:n.map(v=>v.name),axisLabel:{color:"rgba(226, 252, 255, 0.56)",fontSize:9,interval:0,formatter:v=>String(v||"").replace(/^(\d{1,2})\D+(\d{1,2}).*$/,"$1/$2")},axisLine:{lineStyle:{color:"rgba(48, 220, 255, 0.22)"}},axisTick:{show:!1}},{type:"value",gridIndex:1,min:0,max:Math.max(...c,100),show:!1}],yAxis:[{type:"value",gridIndex:0,show:!1},{type:"category",gridIndex:1,inverse:!0,data:l.map(v=>v.name),axisLabel:{color:"rgba(226, 252, 255, 0.68)",fontSize:9,formatter:v=>y(v)},axisLine:{show:!1},axisTick:{show:!1}}],series:[{name:"防疫记录",type:"bar",xAxisIndex:0,yAxisIndex:0,barMaxWidth:9,data:r,itemStyle:{borderRadius:[6,6,0,0],color:new $e(0,0,0,1,[{offset:0,color:"#8bf7ff"},{offset:.45,color:"#30dcff"},{offset:1,color:"rgba(48, 220, 255, 0.1)"}])},label:{show:!0,position:"top",color:"rgba(230, 255, 249, 0.86)",fontSize:8,formatter:({value:v})=>v>=p*.55?ae(v):""}},{name:"节奏线",type:"line",xAxisIndex:0,yAxisIndex:0,smooth:!0,showSymbol:!1,data:r,lineStyle:{width:1.8,color:"#8bf7ff"},tooltip:{show:!1}},{name:"补免关注",type:"bar",xAxisIndex:1,yAxisIndex:1,barWidth:8,data:c,itemStyle:{borderRadius:[0,7,7,0],color:new $e(0,0,1,0,[{offset:0,color:"rgba(139, 247, 255, 0.24)"},{offset:1,color:"#8bf7ff"}])},label:{show:!0,position:"right",color:"rgba(201, 251, 255, 0.9)",fontSize:8,formatter:({dataIndex:v})=>{var T;return((T=l[v])==null?void 0:T.label)||""}}}]}}),k(()=>{const n=Ts.value,r=n.map(y=>Number(y.value||0)),l=Math.max(...r,1),c=r.filter(Boolean).reduce((y,v)=>y+v,0)/Math.max(r.filter(Boolean).length,1),p=Math.ceil(l*1.18);return{color:["#30dcff","#8bf7ff"],tooltip:V(I({},we()),{trigger:"axis",axisPointer:{type:"shadow"},formatter(y){var T;const v=n[(T=y[0])==null?void 0:T.dataIndex]||{};return v.isMissing?`${v.name}<br/>年度防疫:待补强`:`${v.name}<br/>覆盖量:${U(v.value)}头<br/>防疫记录:${U(v.recordCount)}`}}),grid:{left:56,right:46,top:16,bottom:12},xAxis:{type:"value",min:0,max:p,show:!1},yAxis:{type:"category",inverse:!0,data:n.map(y=>y.name),axisLabel:{color:"rgba(226, 252, 255, 0.82)",fontSize:11,interval:0,formatter:y=>String(y||"").replace(/(镇|乡)$/,"")},axisLine:{show:!1},axisTick:{show:!1}},series:[{name:"均衡参照",type:"bar",barWidth:11,silent:!0,barGap:"-100%",data:n.map(()=>p),itemStyle:{borderRadius:[0,8,8,0],borderColor:"rgba(48, 220, 255, 0.12)",borderWidth:1,color:"rgba(48, 220, 255, 0.045)"}},{name:"覆盖量",type:"bar",barWidth:11,barGap:"-100%",z:3,data:n.map(y=>{const v=Number(y.value||0);return{value:v>0?v:Math.max(p*.035,1),rawValue:v,itemStyle:{borderRadius:[0,8,8,0],color:new $e(0,0,1,0,[{offset:0,color:y.isMissing?"rgba(72, 207, 255, 0.2)":"rgba(48, 220, 255, 0.14)"},{offset:.72,color:y.isMissing?"#48cfff":"#30dcff"},{offset:1,color:y.isMissing?"#8bf7ff":"#9efcff"}]),shadowBlur:y.isMissing?4:5,shadowColor:y.isMissing?"rgba(72, 207, 255, 0.18)":"rgba(48, 220, 255, 0.16)"}}}),label:{show:!0,position:"right",color:"rgba(239, 255, 255, 0.92)",fontSize:11,fontWeight:800,formatter:({dataIndex:y})=>{const v=n[y]||{};return v.isMissing?"待补强":`${ae(v.value)}`}},markLine:c>0?{symbol:"none",silent:!0,lineStyle:{color:"rgba(139, 247, 255, 0.46)",type:"dashed",width:1},label:{color:"rgba(201, 251, 255, 0.8)",fontSize:10,formatter:"均衡线"},data:[{xAxis:c}]}:void 0}]}}),k(()=>{const n=Ss.value,r=["#30dcff","#8bf7ff","#58d9ff","#28e8d6","#7bdfff","#9efcff","#48cfff","#40b8ff","#8bf7ff"],l=n.length?n.map((c,p)=>({name:String(c.name||"").replace(/(村|社区|牧委会)$/,""),value:Math.max(Number(c.value||0),1),rawValue:Number(c.value||0),town:c.town||"",itemStyle:{color:new $e(0,0,1,1,[{offset:0,color:r[p%r.length]},{offset:1,color:"rgba(17, 70, 92, 0.38)"}])}})):[{name:"待形成",value:1,rawValue:0,town:"",itemStyle:{color:"rgba(48, 220, 255, 0.14)"}}];return{tooltip:V(I({},we()),{formatter(c){const p=c.data||{};return p.rawValue?`${p.town?`${p.town} `:""}${p.name}<br/>覆盖量:${U(p.rawValue)}`:`${p.name}<br/>暂无村级覆盖量`}}),series:[{type:"treemap",roam:!1,nodeClick:!1,breadcrumb:{show:!1},left:6,right:6,top:7,bottom:5,visibleMin:1,data:l,label:{show:!0,color:"rgba(235, 254, 255, 0.9)",fontSize:10,fontWeight:800,lineHeight:14,formatter(c){var y;const p=Number(((y=c.data)==null?void 0:y.rawValue)||0);return p?`${c.name}
${ae(p)}`:c.name}},upperLabel:{show:!1},itemStyle:{borderColor:"rgba(4, 24, 36, 0.88)",borderWidth:2,gapWidth:2},emphasis:{label:{color:"#ffffff"},itemStyle:{shadowBlur:6,shadowColor:"rgba(48, 220, 255, 0.18)"}},levels:[{itemStyle:{borderColor:"rgba(14, 75, 98, 0.72)",borderWidth:1,gapWidth:2}}]}]}});const fo=k(()=>{const n=Mn.value,r=n.length>8?10:12,l=r+8,c=n.map(B=>Number(B.recordCount||0)),p=n.map(B=>Number(B.earTagCount||0)),y=Math.max(...c,1),v=n.map(()=>Math.ceil(y*1.08)),T=new $e(0,0,0,1,[{offset:0,color:"rgba(48, 220, 255, 0.18)"},{offset:.48,color:"rgba(48, 220, 255, 0.06)"},{offset:1,color:"rgba(48, 220, 255, 0.02)"}]),R=new $e(0,0,0,1,[{offset:0,color:"#31f7ff"},{offset:.36,color:"#1cbcff"},{offset:1,color:"#266dff"}]);return{color:["#31f7ff","#8bf7ff"],title:{text:`台账总量:{value|${ae(yt.value)}条}`,right:0,top:0,textStyle:{color:"#fff",fontSize:12,fontWeight:500,rich:{value:{color:"#22f1ff",borderColor:"#14bdf4",borderWidth:1,borderRadius:2,padding:[2,6,3,6],fontSize:12,fontWeight:700}}}},tooltip:V(I({},we()),{trigger:"axis",axisPointer:{type:"shadow"},formatter(B){const _=n[B[0].dataIndex];return[`${_.name}`,`防疫记录:${U(_.recordCount)}`,`耳标数量:${U(_.earTagCount)}`,"数据来源:防疫台账"].join("<br/>")}}),legend:[{data:["防疫记录"],top:0,left:0,itemWidth:10,itemHeight:10,icon:"circle",textStyle:{color:m,fontSize:11},selectedMode:!1},{data:["耳标数"],top:0,left:82,itemWidth:10,itemHeight:10,icon:"circle",textStyle:{color:m,fontSize:11},selectedMode:!1}],grid:{left:42,right:12,top:46,bottom:68},xAxis:{type:"category",data:n.map(B=>B.name),axisLabel:{color:m,fontSize:10,interval:0,lineHeight:11,margin:8,formatter:Ro},axisLine:{show:!1},axisTick:{show:!1},splitLine:{show:!1}},yAxis:{type:"value",name:"数量/条",max:Math.ceil(y*1.2),nameTextStyle:{color:C,fontSize:10,align:"left"},axisLabel:{color:C,fontSize:10,formatter:ae},axisLine:{show:!1},axisTick:{show:!1},splitLine:{lineStyle:{color:F,type:"dashed"}}},series:[{name:"统计底柱",type:"bar",barWidth:l,barGap:"-100%",data:v,tooltip:{show:!1},silent:!0,z:1,itemStyle:{borderRadius:[8,8,1,1],borderColor:"rgba(48, 220, 255, 0.22)",borderWidth:1,color:T}},{name:"防疫记录",type:"bar",barGap:"-100%",barWidth:r,barMinHeight:2,z:3,data:c.map(B=>({value:B,itemStyle:{borderRadius:[8,8,1,1],borderColor:"rgba(200, 252, 255, 0.22)",borderWidth:1,color:R,shadowBlur:10,shadowColor:"rgba(49, 247, 255, 0.28)"}}))},{name:"耳标数",type:"line",smooth:!0,showSymbol:!1,z:9,data:p,lineStyle:{width:1.6,color:"#8bf7ff",shadowBlur:0,shadowColor:"transparent"},itemStyle:{color:"#8bf7ff"}}]}}),mo=k(()=>{const n=fs.value;return{tooltip:V(I({},we()),{trigger:"axis",axisPointer:{type:"shadow"},formatter(r){const l=n[r[0].dataIndex];return`${l.name}<br/>防疫记录:${U(l.value)}`}}),grid:{left:74,right:42,top:12,bottom:8},xAxis:{type:"value",axisLabel:{color:C,fontSize:10,formatter:ae},axisLine:{show:!1},axisTick:{show:!1},splitLine:{lineStyle:{color:F,type:"dashed"}}},yAxis:{type:"category",inverse:!0,data:n.map(r=>r.name),axisLabel:{color:m,fontSize:10,fontWeight:700,interval:0},axisLine:{show:!1},axisTick:{show:!1}},series:[{name:"记录",type:"bar",barWidth:9,data:n.map(r=>({value:r.value,itemStyle:{borderRadius:[1,2,2,1],color:new $e(0,0,1,0,[{offset:0,color:"rgba(67, 217, 232, 0.14)"},{offset:.58,color:"rgba(67, 217, 232, 0.7)"},{offset:1,color:rn}])}})),label:{show:!0,position:"right",color:"#eaffff",fontSize:10,formatter:({value:r})=>ae(r)}}]}}),go=k(()=>{const n=xs.value;return{color:["#30dcff","#8bf7ff"],tooltip:V(I({},we()),{trigger:"axis",axisPointer:{type:"shadow"},formatter(r){const l=r.find(p=>p.seriesName==="流通头数"),c=r.find(p=>p.seriesName==="出证记录");return`${(l==null?void 0:l.axisValue)||""}<br/>流通头数:${U((l==null?void 0:l.value)||0)}头<br/>出证记录:${U((c==null?void 0:c.value)||0)}`}}),legend:{top:4,right:10,itemWidth:12,itemHeight:8,textStyle:{color:S,fontSize:10}},grid:{left:42,right:38,top:34,bottom:28},xAxis:{type:"category",data:n.map(r=>r.name),axisLabel:{color:C,fontSize:10,interval:1},axisLine:{lineStyle:{color:"rgba(48, 220, 255, 0.24)"}},axisTick:{show:!1}},yAxis:[{type:"value",axisLabel:{color:C,fontSize:10,formatter:ae},splitLine:{lineStyle:{color:F,type:"dashed"}}},{type:"value",axisLabel:{color:S,fontSize:10,formatter:ae},splitLine:{show:!1}}],series:[{name:"流通头数",type:"bar",barMaxWidth:13,data:n.map(r=>r.headCount),itemStyle:{borderRadius:[7,7,0,0],color:new $e(0,0,0,1,[{offset:0,color:"#30dcff"},{offset:1,color:"rgba(48, 220, 255, 0.08)"}])}},{name:"出证记录",type:"line",yAxisIndex:1,smooth:!0,symbolSize:5,data:n.map(r=>r.recordCount),lineStyle:{width:2.2,color:"#8bf7ff"},itemStyle:{color:"#8bf7ff",borderColor:"rgba(3, 18, 28, 0.9)",borderWidth:2}}]}}),yo=k(()=>Wn(Ba.value.slice(0,10),"headCount","头",{style:"ladder",axisTextColor:"rgba(255, 255, 255, 0.88)",dimAxisTextColor:"rgba(255, 255, 255, 0.74)",tooltipFormatter(n){const r=Ba.value[n.dataIndex];return`${r.name}<br/>流通头数:${U(r.headCount)}头<br/>出证记录:${U(r.recordCount)}`}})),bo=k(()=>{const n=Pn.value;return{color:Ue,tooltip:we(r=>{const l=n.find(c=>c.name===r.name);return`${r.name}<br/>占比:${r.percent}%<br/>流通头数:${U(r.value)}头<br/>出证记录:${U((l==null?void 0:l.recordCount)||0)}`}),legend:{orient:"vertical",right:4,top:"middle",itemWidth:8,itemHeight:8,itemGap:6,textStyle:{color:S,fontSize:10},formatter(r){const l=n.find(c=>c.name===r);return l?`${r} ${ae(l.headCount)}`:r}},series:[{name:"用途结构",type:"pie",radius:["38%","64%"],center:["32%","54%"],startAngle:110,label:{show:!1},labelLine:{show:!1},itemStyle:{borderColor:"rgba(3, 18, 31, 0.92)",borderWidth:3},data:n.map(r=>({name:r.name,value:r.headCount}))}]}}),vo=k(()=>{const n=[{name:"省外A证",value:We("outProvinceHeads","aCertHeads")},{name:"省内B证",value:We("inProvinceHeads","bCertHeads")}];return{color:["#8bf7ff","#30dcff"],tooltip:we(r=>`${r.name}<br/>流通头数:${U(r.value)}头<br/>占比:${r.percent}%`),series:[{type:"pie",radius:["48%","72%"],center:["50%","52%"],label:{show:!1},labelLine:{show:!1},itemStyle:{borderColor:"rgba(3, 18, 31, 0.92)",borderWidth:3},data:n}]}});function Nn(){o.value=typeof window=="undefined"?1080:window.innerHeight}function Li(){var n,r,l,c,p,y;if(Je.value){(r=(n=la.value)==null?void 0:n.refreshView)==null||r.call(n);return}(c=(l=Ne.value)==null?void 0:l.resume)==null||c.call(l),(y=(p=Ne.value)==null?void 0:p.refreshView)==null||y.call(p)}function Ti(){kt&&(window.clearTimeout(kt),kt=null)}function Si(){var n,r,l,c,p,y;if(He.value=!1,ka.value={type:"loading",text:"地图正在复位"},Pa.value={type:"idle",text:""},Je.value){(r=(n=la.value)==null?void 0:n.hasMap)!=null&&r.call(n)?(ua.value=!0,(c=(l=la.value)==null?void 0:l.resetView)==null||c.call(l)):(ua.value=!1,ti.value+=1,jt(()=>{window.setTimeout(()=>{var v,T;return(T=(v=la.value)==null?void 0:v.refreshView)==null?void 0:T.call(v)},160)}));return}if((y=(p=Ne.value)==null?void 0:p.hasMap)!=null&&y.call(p)){Zt.value=!0,Li();return}Ti(),Zt.value=!1,Nt=!1,ei.value+=1,jt(()=>{Ha()})}function wo(){He.value=!1,Si()}e({refreshMapView:Li,resetMap:Si,setActiveView(n){z.value=Yn(n)}}),Qr(()=>{Nn(),window.addEventListener("resize",Nn),Ji(),Qi(z.value),Va(),Oa()}),es(()=>{var n,r;ca=!0,window.removeEventListener("resize",Nn),kt&&window.clearTimeout(kt),Rn(),In(),(r=(n=Ne.value)==null?void 0:n.destroyMap)==null||r.call(n)}),qt([z,Xe,Rt,Sn,yt,ge,Me,gi],()=>{el()},{immediate:!0}),qt(z,(n,r)=>{i("view-change",n),Qi(n);const l=n==="structure"||n==="forecast",c=r==="structure"||r==="forecast",p=!l&&!c&&(n==="trade"||r==="trade");l&&!c&&(He.value=!1,ua.value=!1,ka.value={type:"idle",text:""},Pa.value={type:"idle",text:""}),!l&&c&&(Ji(),Ti(),He.value=!1,Zt.value=!1,Nt=!1,ka.value={type:"idle",text:""},Pa.value={type:"idle",text:""},jt(()=>{var y,v,T,R;Ha(),(v=(y=Ne.value)==null?void 0:y.resume)==null||v.call(y),(R=(T=Ne.value)==null?void 0:T.refreshView)==null||R.call(T),window.setTimeout(()=>{var B,_;return(_=(B=Ne.value)==null?void 0:B.refreshView)==null?void 0:_.call(B)},180)})),p&&jt(()=>{var y,v,T,R;(v=(y=Ne.value)==null?void 0:y.resume)==null||v.call(y),(R=(T=Ne.value)==null?void 0:T.refreshView)==null||R.call(T)}),Va(),Oa()}),qt(()=>a.viewKey,n=>{const r=Yn(n);r!==z.value&&(z.value=r)}),qt(()=>a.active,n=>{var r,l,c,p;n?(Ha(),(l=(r=Ne.value)==null?void 0:r.resume)==null||l.call(r),Va(),Oa()):((p=(c=Ne.value)==null?void 0:c.pause)==null||p.call(c),Rn(),In())}),qt($a,n=>{ct.value>=n.pageCount&&(ct.value=0),Oa()});function Lo(n){n!==nt.value&&(nt.value=n,Va())}function Va(){Rn(),!(!a.active||z.value!=="forecast"||ca)&&(Fa=window.setInterval(To,fh))}function To(){const n=Bt.findIndex(l=>l.key===nt.value),r=n>=0?(n+1)%Bt.length:0;nt.value=Bt[r].key}function Rn(){Fa&&(window.clearInterval(Fa),Fa=null)}function Oa(){In(),!(!a.active||z.value!=="structure"||ca||$a.value.pageCount<=1)&&(xa=window.setInterval(So,mh))}function So(){const n=$a.value.pageCount;n<=1||(ct.value=(ct.value+1)%n)}function In(){xa&&(window.clearInterval(xa),xa=null)}function Mo(n=[],r=[]){const l=new Map;return r.forEach(c=>{const p=Gn(c.name);p&&l.set(p,V(I({},c),{name:p,count:Number(c.count||0)}))}),n.forEach(c=>{const p=Gn(c.name);if(!p)return;const y=l.get(p)||{};l.set(p,V(I(I({},y),c),{name:p,count:Number.isFinite(Number(c.count))?Number(c.count):Number(y.count||0)}))}),[...l.values()].sort((c,p)=>Number(p.count||0)-Number(c.count||0))}function Gn(n){return Fr(n||"")}function Qe(n){return String(n||"").trim()}function _n(n){const r=Number(n);return Number.isFinite(r)&&Fe.includes(r)?r:Fe[Fe.length-1]}function An(n=ge.value){const r=_n(n);return{startDate:`${r}-01-01`,endDate:`${r}-12-31`}}function Da(){return{keyword:"",town:"",medicine:"",startDate:"",endDate:""}}function Pt(n=[]){return Array.isArray(n)?n.map((r,l)=>{var c,p,y;return{key:r.key||r.id||`${r.name||r.label||"item"}-${l}`,name:String(r.name||r.label||r.town||r.village||"未填写"),value:Number((y=(p=(c=r.value)!=null?c:r.count)!=null?p:r.total)!=null?y:0)}}).filter(r=>r.name&&Number.isFinite(r.value)):[]}function Mi(n={}){const r=Pt(n==null?void 0:n.medicineCounts);return Math.max(r.filter(l=>l.name!=="未填写").length,1)}function ki(...n){const r=n.flatMap(l=>Array.isArray(l)?l:[l]).map(l=>{var c,p,y;return l&&typeof l=="object"?(y=(p=(c=l.year)!=null?c:l.value)!=null?p:l.latestYear)!=null?y:l.latest_year:l}).map(Number).filter(l=>Number.isFinite(l)&&l>0);return[...new Set(r)].sort((l,c)=>l-c)}function za(n=[],r="name"){return Array.isArray(n)?n.map((l,c)=>{var p,y,v,T,R,B,_,W,Z,X,ce,Re,st,Xt,de,Ye,ha;return{key:l.key||l.id||`${l[r]||l.name||l.label||"trade"}-${c}`,name:String(l[r]||l.name||l.label||l.town||"未填写"),recordCount:Number((v=(y=(p=l.recordCount)!=null?p:l.record_count)!=null?y:l.count)!=null?v:0),headCount:Number((_=(B=(R=(T=l.headCount)!=null?T:l.head_count)!=null?R:l.amount)!=null?B:l.value)!=null?_:0),lng:bt((Re=(ce=(X=(Z=(W=l.lng)!=null?W:l.longitude)!=null?Z:l.destLng)!=null?X:l.dest_lng)!=null?ce:l.destLongitude)!=null?Re:l.dest_longitude),lat:bt((ha=(Ye=(de=(Xt=(st=l.lat)!=null?st:l.latitude)!=null?Xt:l.destLat)!=null?de:l.dest_lat)!=null?Ye:l.destLatitude)!=null?ha:l.dest_latitude)}}).filter(l=>l.name&&Number.isFinite(l.headCount)):[]}function ko(n=[]){return Array.isArray(n)?n.map(r=>{var l,c,p,y,v,T;return{year:Number(r.year),recordCount:Number((c=(l=r.recordCount)!=null?l:r.record_count)!=null?c:0),headCount:Number((T=(v=(y=(p=r.headCount)!=null?p:r.head_count)!=null?y:r.amount)!=null?v:r.value)!=null?T:0)}}).filter(r=>Number.isFinite(r.year)&&Number.isFinite(r.headCount)):[]}function Bn(n=[]){return Array.isArray(n)?En(n.map(r=>{var l,c,p;return r&&typeof r=="object"?(p=(c=(l=r.value)!=null?l:r.label)!=null?c:r.name)!=null?p:"":r})):[]}function Po(n=[]){return Array.isArray(n)?n.map(r=>{var l,c,p,y,v,T;if(r&&typeof r=="object"){const R=(p=(c=(l=r.value)!=null?l:r.name)!=null?c:r.label)!=null?p:"",B=(T=(v=(y=r.label)!=null?y:r.name)!=null?v:r.value)!=null?T:R;return R?{value:String(R),label:String(B||R)}:null}return r?{value:String(r),label:String(r)}:null}).filter(Boolean):[]}function En(n=[]){return[...new Set(n.map(r=>String(r||"").trim()).filter(Boolean))]}function Co(n=[]){if(!Array.isArray(n))return[];const r=new Map;n.forEach((c,p)=>{var B,_,W,Z,X,ce;const y=Qe(c.name||c.areaName||c.area_name||c.town||c.label||"");if(!y)return;const v=bt((W=(_=(B=c.value)!=null?B:c.number)!=null?_:c.count)!=null?W:c.total);if(!Number.isFinite(v))return;const T=r.get(y)||{key:c.areaCode||c.area_code||`${y}-${p}`,name:y,recordCount:0,earTagCount:0,source:"stats"};T.recordCount+=v;const R=bt((ce=(X=(Z=c.earTagCount)!=null?Z:c.ear_tag_count)!=null?X:c.headCount)!=null?ce:c.head_count);T.earTagCount+=Number.isFinite(R)?R:0,r.set(y,T)});const l=[...r.values()].reduce((c,p)=>c+Number(p.recordCount||0),0);return[...r.values()].map(c=>V(I({},c),{earTagCount:c.earTagCount||Math.round(Number(c.recordCount||0)/It.value),ratio:l?Number(c.recordCount||0)/l*100:0})).sort((c,p)=>Number(p.recordCount||0)-Number(c.recordCount||0))}function Fo(n={}){var p,y;const r=Array.isArray(n)?{rows:n}:n||{},l=r.result||{};return{rows:r.rows||r.data||r.list||r.records||[],year:(y=(p=r.year)!=null?p:l.year)!=null?y:null}}function $n(n=[]){return Array.isArray(n)?n.map((r,l)=>{var W,Z,X,ce,Re,st,Xt,de,Ye,ha,ur,cr;const c=Qe(r.town||r.townName||r.town_name||""),p=String(r.village||r.villageName||r.village_name||r.name||"").trim(),y=bt((X=(Z=(W=r.recordCount)!=null?W:r.record_count)!=null?Z:r.records)!=null?X:r.total),v=bt((Xt=(st=(Re=(ce=r.earTagCount)!=null?ce:r.ear_tag_count)!=null?Re:r.headCount)!=null?st:r.head_count)!=null?Xt:r.value),T=bt((Ye=(de=r.imageCount)!=null?de:r.image_count)!=null?Ye:r.images),R=bt((ha=r.imageRate)!=null?ha:r.image_rate),B=bt((ur=r.lng)!=null?ur:r.longitude),_=bt((cr=r.lat)!=null?cr:r.latitude);return{key:r.key||r.id||`${c}-${p}-${l}`,town:c,village:p,recordCount:Number.isFinite(y)?y:0,earTagCount:Number.isFinite(v)?v:0,imageCount:Number.isFinite(T)?T:0,imageRate:Number.isFinite(R)?R:0,lng:B,lat:_}}).filter(r=>r.town&&r.village&&Number.isFinite(r.earTagCount)).sort((r,l)=>Number(l.earTagCount||0)-Number(r.earTagCount||0)):[]}function xo(n={},r={}){const l=Array.isArray(r)?{rows:r}:r||{},c=l.result||{},p=$n(l.rows||l.data||l.list||l.records||c.rows||[]),y=new Map;p.forEach(_=>{Pi(_.village).forEach(W=>{y.has(W)||y.set(W,_)})});const v=Pt(n==null?void 0:n.townCounts),T=v.length===1?Qe(v[0].name):"",R=Mi(n),B=Pt(n==null?void 0:n.villageCounts).map((_,W)=>{const Z=String(_.name||"").trim(),X=Pi(Z).map(Re=>y.get(Re)).find(Boolean)||{},ce=Number(_.value||0);return{key:X.key||`${X.town||T||"防疫"}-${Z}-${W}`,town:X.town||T,village:Z,recordCount:ce,earTagCount:Math.round(ce/R),imageCount:X.imageCount||0,imageRate:X.imageRate||0,lng:X.lng,lat:X.lat}}).filter(_=>_.village&&_.recordCount>0);return V(I({},l),{rows:B})}function Pi(n){const r=String(n||"").trim(),l=r.replace(/(村|社区|牧委会)$/,"");return[...new Set([r,l].filter(Boolean))]}function bt(n){if(n==null||n==="")return NaN;const r=Number(String(n).replace(/,/g,"").replace(/%/g,""));return Number.isFinite(r)?r:NaN}function Ci(n){return String(n||"").replace(/'/g,"''").replace(/%/g,"\\%").replace(/_/g,"\\_")}function No(n,r){const l=Qe(n),c=String(r||"").trim();if(!l||!c)return"";const p=`${l}${c}`,y=Ci(p),v=Ci(c);return`(full_name LIKE '%${y}%' OR name = '${y}' OR name = '${v}')`}function Ro(n){const r=String(n||"").trim().replace(/\s+/g,"");return r?Array.from(r).join(`
`):""}function Io(n){const r=String(n||"").trim();if(!r)return"";const l=r.match(/^(.+)(镇|乡|村)$/);return l?`${l[1]}
${l[2]}`:r}function Go(n,r){return Fi(n.name)-Fi(r.name)}function Fi(n){const r=String(n||"").match(/(\d{1,2})\D+(\d{1,2})/);return r?Number(r[1])*100+Number(r[2]):Number.MAX_SAFE_INTEGER}function Vn(n=[]){return Array.isArray(n)?n.map(xi).filter(Boolean):[]}function xi(n){return n?{epidemicId:n.epidemicId||n.epidemic_id||n.id||"",earTag:n.earTag||n.ear_tag||"",owner:n.owner||"",idType:n.idType||n.id_type||"",idNo:n.idNo||n.id_no||"",phone:n.phone||"",town:n.town||"",village:n.village||"",location:n.location||"",livestockType:n.livestockType||n.livestock_type||"",age:n.age||"",sex:n.sex||"",weight:n.weight||n.weightKg||n.weight_kg||"",preventionType:n.preventionType||n.prevention_type||"",method:n.method||"",medicine:n.medicine||"",dose:n.dose||"",operator:n.operator||"",operateTime:n.operateTime||n.operate_time||"",imagePaths:n.imagePaths||n.image_paths||""}:null}function Ni(n=[]){return Array.isArray(n)?n.map(_o).filter(Boolean):[]}function _o(n){var r,l,c,p;return n?{certId:n.certId||n.cert_id||n.id||"",certType:n.certType||n.cert_type||"",certScopeName:n.certScopeName||n.cert_scope_name||"",factoryCode:n.factoryCode||n.factory_code||"",ownerName:n.ownerName||n.owner_name||"",ownerPhone:n.ownerPhone||n.owner_phone||"",transportNumber:n.transportNumber||n.transport_number||"",amount:Number((p=(c=(l=(r=n.amount)!=null?r:n.headCount)!=null?l:n.head_count)!=null?c:n.value)!=null?p:0),unitName:n.unitName||n.unit_name||"头",animalTypeName:n.animalTypeName||n.animal_type_name||"",usageTypeName:n.usageTypeName||n.usage_type_name||"",startTown:n.startTown||n.start_town||"",startRegionFullName:n.startRegionFullName||n.start_region_full_name||"",destProvince:n.destProvince||n.dest_province||"",destRegionFullName:n.destRegionFullName||n.dest_region_full_name||"",quarantineOfficerName:n.quarantineOfficerName||n.quarantine_officer_name||"",issueTime:n.issueTime||n.issue_time||"",statusName:n.statusName||n.status_name||""}:null}function Wa(n,r){for(const l of r){const c=Number(n==null?void 0:n[l]);if(Number.isFinite(c))return c}return 0}function We(...n){return Wa(gi.value,n)}function Ri(n=[],r=2){const l=[...new Set(n.map(c=>String(c||"").trim()).filter(Boolean))];return l.length?l.length<=r?l.join("、"):`${l.slice(0,r).join("、")}${l.length}个乡镇`:"暂无"}function Ao(){const n=Gt.value;if(n.length)return{name:Ri(n,1),desc:"年度防疫覆盖需补强",level:"watch"};const r=Ot.value.filter(c=>Number(c.earTagCount||c.recordCount||0)>0).sort((c,p)=>Number(c.earTagCount||c.recordCount||0)-Number(p.earTagCount||p.recordCount||0)),l=r[0];return l?{name:l.name,desc:`${ae(l.earTagCount||l.recordCount)}头,建议补免回访`,level:r.length>=2?"watch":"normal"}:{name:"暂无",desc:"等待年度防疫记录形成",level:"normal"}}function Bo(){const n=Gt.value;if(n.length)return n.slice(0,4).map((c,p)=>({key:`missing-${c}`,name:c,value:Math.max(25,100-p*12),label:"待补免",level:"watch"}));const r=Ot.value.filter(c=>Number(c.earTagCount||c.recordCount||0)>0);if(!r.length)return[{key:"empty",name:"暂无",value:0,label:"待开展",level:"watch"}];const l=r.reduce((c,p)=>c+Number(p.earTagCount||0),0)/r.length||1;return[...r].sort((c,p)=>Number(c.earTagCount||0)-Number(p.earTagCount||0)).slice(0,4).map(c=>{const p=Number(c.earTagCount||c.recordCount||0),y=Math.max(8,Math.round((l-p)/l*100));return{key:`weak-${c.name}`,name:c.name,value:Math.min(100,y),label:`${ae(p)}`,level:y>=35?"watch":"normal"}})}function Eo(){const r=(Mn.value.length?Mn.value:Ot.value).map((p,y)=>{const v=Qe(p.name),T=Number(p.earTagCount||0),R=Number(p.recordCount||p.value||0),B=T||Math.round(R/It.value);return{key:p.key||`${v}-${y}`,name:v,value:B,recordCount:R,isMissing:!1}}).filter(p=>p.name&&Number.isFinite(p.value)),c=[...Gt.value.map((p,y)=>({key:`missing-${p}-${y}`,name:p,value:0,recordCount:0,isMissing:!0})),...r];return c.length?c.sort((p,y)=>p.isMissing!==y.isMissing?p.isMissing?-1:1:Number(p.value||0)-Number(y.value||0)).slice(0,7):[{key:"empty",name:"待开展",value:0,recordCount:0,isMissing:!0}]}function $o(){var r;const n=pi.value.map((l,c)=>({key:l.key||`${l.town}-${l.village}-${c}`,name:l.village||l.name,town:l.town,value:Number(l.earTagCount||l.value||0)})).filter(l=>l.name&&Number.isFinite(l.value)&&l.value>0);return n.length?n.sort((l,c)=>c.value-l.value).slice(0,9):Pt((r=xe.value)==null?void 0:r.villageCounts).map((l,c)=>({key:l.key||`${l.name}-${c}`,name:l.name,town:"",value:Math.round(Number(l.value||0)/It.value)})).filter(l=>l.name&&Number.isFinite(l.value)&&l.value>0).sort((l,c)=>c.value-l.value).slice(0,9)}function Vo(){if(!yt.value)return{level:"watch",title:"年度待开展",desc:"年度免疫记录暂未形成",advice:"建议先核查年度免疫计划与乡镇推进节奏。"};const n=ws.value,r=Aa.value;return Gt.value.length?{level:"watch",title:"补免待核查",desc:`乡镇覆盖${et(n)}${r.name}需补强`,advice:`优先核查${Ri(Gt.value,1)}免疫进度。`}:n>=90&&It.value>=4?{level:"stable",title:"运行平稳",desc:`乡镇覆盖${et(n)},疫苗谱较完整`,advice:"建议保持当前免疫节奏,持续跟踪补免回访。"}:{level:"normal",title:"均衡回访",desc:`${r.name}相对偏低,适合继续跟进`,advice:`关注${r.name}补免回访,保持覆盖均衡。`}}function Oo(){return[{key:"latest",name:"最近免疫",value:hi.value,desc:"最后作业时间",level:hi.value==="-"?"watch":"stable",color:"#8bf7ff"},{key:"top-town",name:"高频乡镇",value:ys.value,desc:"年度作业集中区",level:"normal",color:"#30dcff"},{key:"vaccine",name:"主用疫苗",value:ms.value,desc:`${It.value}类疫苗`,level:"normal",color:"#8bf7ff"}]}function Do(){const n=We("headCount","totalHeads","total_heads"),r=Ea.value,l=r.reduce((de,Ye)=>de+Number(Ye.headCount||0),0)||n||1,c=r[0],p=c?Number(c.headCount||0)/l*100:0,y=Pn.value.filter(de=>de.name&&de.name!=="未填写").sort((de,Ye)=>Number(Ye.headCount||0)-Number(de.headCount||0)),v=y.reduce((de,Ye)=>de+Number(Ye.headCount||0),0)||n||1,T=y[0],R=T?Number(T.headCount||0)/v*100:0,_=Ns.value.filter(de=>de.name&&de.name!=="未填写").sort((de,Ye)=>Number(Ye.headCount||Ye.recordCount||0)-Number(de.headCount||de.recordCount||0))[0],W=We("vehicleCount","vehicle_count","transportVehicleCount","transport_vehicle_count"),Z=W>0?n/W:0,X=We("outProvinceHeads","out_province_heads","aCertHeads","a_cert_heads"),ce=We("inProvinceHeads","in_province_heads","bCertHeads","b_cert_heads"),Re=X+ce||n||1,st=X?X/Re*100:0;return[{key:"town",name:"高频出栏乡镇",value:(c==null?void 0:c.displayName)||(c==null?void 0:c.name)||"暂无",desc:c?`${ae(c.headCount)}头,占${et(p)}`:"等待来源乡镇数据",level:p>=35?"high":p>=24?"watch":"normal",color:"#63d7ff"},{key:"usage",name:"交易用途集中度",value:(T==null?void 0:T.name)||"暂无",desc:T?`${et(R)}`:"等待用途结构数据",level:R>=60?"high":R>=45?"watch":"normal",color:"#30dcff"},{key:"vehicle",name:_?"运输车辆高频":"车辆周转强度",value:_?`${ae(_.headCount||_.recordCount)}${_.headCount?"头":"条"}`:W?`车均${U(Z)}`:"--",desc:_?"已接入车辆聚合,明细在台账核查":W?`${U(W)}辆参与流通`:"等待车辆聚合数据",level:_||Z>=260?"watch":"normal",color:"#48cfff"},{key:"cert-dest",name:"证照/去向线索",value:X?et(st):"--",desc:X?`省外流通${ae(X)}`:"等待证照去向数据",level:st>=55?"high":st>=35?"watch":"normal",color:"#48cfff"}].map(de=>V(I({},de),{badge:de.level==="high"?"重点":de.level==="watch"?"关注":"平稳"}))}function On(n={}){return String(n.imagePaths||"").split(";").map(r=>r.trim()).filter(Boolean)}function Ii(n){const l=String(n||"").replace(/^images\//,"").split("/").map(encodeURIComponent).join("/");return`${ch}/${l}`}function zo(n){it.value=Ii(n),Ze.value=!0}function Dn(){Ze.value=!1,it.value=""}function ee(n){return n==null||n===""?"-":n}function Wo(n){const r=String(n!=null?n:"").trim();return!!(r&&r!=="-")}function ke(n,r,l={}){return Wo(r)?I({label:n,value:r},l):null}function _t(n){return n?String(n).slice(0,10):"-"}function Gi(n){const r=String(n||"").trim();return r?r.length<7?r:`${r.slice(0,3)}****${r.slice(-4)}`:"-"}function Yo(n){const r=String(n||"").trim();return r?r.length<=4?r:`****${r.slice(-4)}`:"-"}function jo(n){const r=String(n!=null?n:"").trim();if(!r)return"-";if(/kg|公斤|千克/i.test(r))return r;const l=Number(r);return Number.isFinite(l)?`${U(l)}kg`:r}function Ho(n){return String(n!=null?n:"").trim()||"-"}function _i(n={}){return n.certScopeName||n.certType||"-"}function qo(){return he(this,null,function*(){var c,p;ht.value=!0,Oe.value="";const[n,r,l]=yield Promise.allSettled([bu(),vu(),wu()]);n.status==="fulfilled"&&((c=n.value)!=null&&c.length)&&(xt.value=su(n.value.map(y=>({name:Fr(y.name),count:Number(y.value)})).filter(y=>y.name&&Number.isFinite(y.count)))),r.status==="fulfilled"&&((p=r.value)!=null&&p.length)&&(Kt.value=r.value.map(y=>({month:y.name,count:Number(y.value),speed:pl(y.extra)})).filter(y=>y.month&&Number.isFinite(y.count))),l.status==="fulfilled"?(dt.value=ul(l.value),dt.value.length||(Oe.value="结构数据暂无数据")):(Oe.value=hl(l.reason,"结构数据异常"),dt.value=[]),ht.value=!1})}function Ai(){return he(this,arguments,function*(n=Me.value){var r,l,c,p,y,v;Tt.value=!0,St.value="";try{(l=(r=me.value)==null?void 0:r.years)!=null&&l.length||(me.value=yield Lu());const T=ki((c=me.value)==null?void 0:c.years),R=Number(((p=me.value)==null?void 0:p.latestYear)||((y=me.value)==null?void 0:y.latest_year)||T[T.length-1]),B=Number(n||Me.value||R||T[T.length-1]);Me.value=B;let _=yield Rr({year:B});const W=(v=_==null?void 0:_.hasData)!=null?v:_==null?void 0:_.has_data,Z=Number((_==null?void 0:_.latestYear)||(_==null?void 0:_.latest_year)||R);W===!1&&Z&&Z!==B&&(Me.value=Z,_=yield Rr({year:Z})),Q.value=_||{metrics:{},hasData:!1},yield zn(1)}catch(T){St.value="交易数据接口异常",Q.value={metrics:{},hasData:!1},rt.value=[],mt.value=0}finally{Tt.value=!1}})}function zn(){return he(this,arguments,function*(n=Mt.value){var l,c;if(!Me.value)return;const r={year:Me.value,page:n,pageSize:Xn,keyword:un.value};try{const p=yield Ir(r);rt.value=Ni(p.rows),mt.value=Number(((l=p.page)==null?void 0:l.totalCount)||p.totalCount||rt.value.length||0),Mt.value=Number(((c=p.page)==null?void 0:c.page)||n||1)}catch(p){St.value=St.value||"交易台账接口异常",rt.value=[],mt.value=0}})}function Uo(n){const r=Number(n);!Number.isFinite(r)||r===Number(Me.value)||(Me.value=r,Mt.value=1,Ta.value="",un.value="",Ai(r))}function Ko(n){const r=_n(n);r!==Number(ge.value)&&(ge.value=r,ve.value=1,ft.value="",M.value="",ue.value=1,fe.value=Da(),Wi(r))}function Bi(){un.value=Ta.value.trim(),zn(1)}function Ei(n){const r=Math.min(Math.max(Number(n)||1,1),Cn.value);zn(r)}function $i(n=null){cn.value=!0,n&&(Ma.value=n),Ya(n?Mt.value:1,n)}function Vi(){cn.value=!1}function Oi(){Ya(1)}function Zo(){gt.value={keyword:"",startTown:"",usageType:"",certType:""},Ya(1)}function Di(n){const r=Math.min(Math.max(Number(n)||1,1),Fn.value);Ya(r)}function Ya(){return he(this,arguments,function*(n=Vt.value,r=null){var p,y;if(!Me.value)return;dn.value=!0,hn.value="";const l=gt.value,c={year:Me.value,page:n,pageSize:Xr,keyword:l.keyword.trim(),startTown:l.startTown,usageType:l.usageType,certType:l.certType};try{const v=yield Ir(c);$t.value=Ni(v.rows),Sa.value=Number(((p=v.page)==null?void 0:p.totalCount)||v.totalCount||$t.value.length||0),Vt.value=Number(((y=v.page)==null?void 0:y.page)||n||1);const T=r?r.certId||r.factoryCode:"",R=T?$t.value.find(B=>(B.certId||B.factoryCode)===T)||r:$t.value[0]||null;zi(R)}catch(v){hn.value="交易台账接口异常",$t.value=[],Sa.value=0,Ma.value=null}finally{dn.value=!1}})}function zi(n){Ma.value=n||null}function Xo(n){n!=null&&n.startTown&&(z.value="trade",jt(()=>{var r,l,c,p,y,v;(l=(r=Ne.value)==null?void 0:r.resume)==null||l.call(r),(p=(c=Ne.value)==null?void 0:c.refreshView)==null||p.call(c),(v=(y=Ne.value)==null?void 0:y.focusTown)==null||v.call(y,Qe(n.startTown),{distanceScale:.78,duration:.8})}))}function Wi(){return he(this,arguments,function*(n=ge.value){var T;const r=_n(n),l=An(r);ge.value=r,w.value=!0,N.value="";const[c,p,y,v]=yield Promise.allSettled([Tu(l),Kn(I({page:ve.value,pageSize:sn,keyword:M.value},l)),Su({year:r}),Mu()]);if(c.status==="fulfilled"?xe.value=c.value||{metrics:{}}:(N.value="防疫统计接口异常",xe.value={metrics:{}}),p.status==="fulfilled"){const R=p.value||{};De.value=Vn(R.rows),Ke.value=Number(((T=R.page)==null?void 0:T.totalCount)||R.totalCount||De.value.length||0)}else N.value=N.value||"防疫台账接口异常",De.value=[],Ke.value=0;y.status==="fulfilled"?pt.value=Fo(y.value):pt.value={rows:[],year:null},v.status==="fulfilled"?Lt.value=xo(xe.value,v.value):Lt.value={rows:[]},w.value=!1})}function Yi(){return he(this,arguments,function*(n=ve.value){var c,p;w.value=!0,N.value="";const r=Math.min(Math.max(Number(n)||1,1),kn.value),l=An(ge.value);try{const y=yield Kn(I({page:r,pageSize:sn,keyword:M.value},l));De.value=Vn(y.rows),Ke.value=Number(((c=y.page)==null?void 0:c.totalCount)||y.totalCount||De.value.length||0),ve.value=Number(((p=y.page)==null?void 0:p.page)||r||1)}catch(y){N.value="防疫台账接口异常",De.value=[],Ke.value=0,ve.value=1}finally{w.value=!1}})}function ji(){M.value=ft.value.trim(),fe.value=V(I({},Da()),{keyword:M.value}),Yi(1)}function Hi(n){Yi(n)}function qi(n=null){O.value=!0,n&&(Ae.value=n,Be.value=null),ja(1,n)}function Ui(){O.value=!1,Dn()}function Ki(){ja(1)}function Jo(){fe.value=Da(),ja(1)}function Zi(n){ja(n)}function ja(){return he(this,arguments,function*(n=ue.value,r=null){var y,v;_e.value=!0,ze.value="";const l=fe.value,c=An(ge.value),p={keyword:l.keyword.trim(),town:l.town,medicine:l.medicine,startDate:l.startDate||c.startDate,endDate:l.endDate||c.endDate,page:n,pageSize:Zr};try{const T=yield Kn(p);H.value=Vn(T.rows),ne.value=Number(((y=T.page)==null?void 0:y.totalCount)||T.totalCount||H.value.length||0),ue.value=Number(((v=T.page)==null?void 0:v.page)||n||1);const R=r||H.value[0]||null;R?Xi(R):(Ae.value=null,Be.value=null)}catch(T){ze.value="台账接口异常",H.value=[],ne.value=0}finally{_e.value=!1}})}function Xi(n){return he(this,null,function*(){if(Ae.value=n,Be.value=null,!(n!=null&&n.earTag)&&!(n!=null&&n.epidemicId))return;const r=++Na;Ee.value=!0;try{const l=yield ku(n.earTag||n.epidemicId);r===Na&&(Be.value=xi(l)||n)}catch(l){r===Na&&(Be.value=n)}finally{r===Na&&(Ee.value=!1)}})}function Ji(){var n;ai||Ca||(ai=!0,pn=new gu,Ca=!1,(n=pn.ready)==null||n.then(()=>{Ca=!0,He.value=!1,Ha()}).catch(r=>{console.warn("[yakManagement] map assets unavailable",r),Zt.value=!1,He.value=!0}))}function Qi(n){(n==="structure"||n==="forecast")&&!ni&&(ni=!0,qo()),n==="epidemic"&&!ii&&(ii=!0,Wi()),n==="trade"&&!ri&&(ri=!0,Ai())}function Ha(){ca||!a.active||!Ca||Nt||(He.value=!1,Nt=!0,kt&&window.clearTimeout(kt),kt=window.setTimeout(()=>{kt=null,er()},600))}function er(n=0){return he(this,null,function*(){var l,c;if(ca)return;if(!a.active){Nt=!1;return}if(yield jt(),!a.active){Nt=!1;return}const r=Ne.value;if((l=r==null?void 0:r.loadMap)==null||l.call(r,pn),r!=null&&r.canvasMap){Nt=!1,Zt.value=!0,He.value=!1,(c=r.play)==null||c.call(r);return}if(n<24){window.setTimeout(()=>er(n+1),120);return}Nt=!1,He.value=!0})}function tr(n={}){Pa.value={type:n.type||"idle",text:n.text||""}}function Qo(){ua.value=!0,He.value=!1}function ar(n={}){ka.value={type:n.type||"idle",text:n.text||"",loaded:n.loaded,failed:n.failed,total:n.total,zoom:n.zoom,tileUrlTemplate:n.tileUrlTemplate}}function el(){if(z.value==="epidemic"){i("module-stats",{moduleKey:"yak-management",items:[{zh:"防疫记录",value:yt.value,unit:"条"},{zh:"防疫耳标",value:Sn.value,unit:"头"},{zh:"疫苗类型",value:It.value,unit:"类"},{zh:"涉及村数",value:gs.value,unit:"个"}]});return}if(z.value==="forecast"){const n=Xe.value.stock-lt;i("module-stats",{moduleKey:"yak-management",items:[{zh:"预测期末存栏",value:Xe.value.stock,unit:"头"},{zh:"新生牛犊",value:Xe.value.births,unit:"头"},{zh:"出栏流出",value:Xe.value.outflow,unit:"头"},{zh:"预测净变化",value:n,unit:"头"}]});return}if(z.value==="trade"){i("module-stats",{moduleKey:"yak-management",items:[{zh:"流通总量",value:We("headCount"),unit:"头"},{zh:"出证记录",value:We("recordCount"),unit:"条"},{zh:"运输车辆",value:We("vehicleCount"),unit:"辆"}]});return}i("module-stats",{moduleKey:"yak-management",items:[{zh:"图像识别总数",value:au,unit:"头"},{zh:"模型修正总数",value:ss.value,unit:"头"},{zh:"当前存栏数量",value:lt,unit:"头"}]})}function Wn(n,r,l,c={}){const p=c.labelKey||"name",y=n.length>8,v=c.style==="ladder",T=y?v?7:6:n.length>6?11:13,R=c.axisTextColor||m,B=c.dimAxisTextColor||C;return{tooltip:V(I({},we()),{trigger:"axis",axisPointer:{type:"shadow"},formatter(_){if(c.tooltipFormatter)return c.tooltipFormatter(_[0]);const W=n[_[0].dataIndex];return`${W[p]}<br/>数值:${U(W[r])}${l}`}}),grid:{left:y?58:74,right:y?54:58,top:y?6:16,bottom:y?8:14},xAxis:{type:"value",axisLabel:{color:B,fontSize:10,formatter:l==="%"?"{value}%":ae},axisLine:{show:!1},axisTick:{show:!1},splitLine:{lineStyle:{color:F,type:"dashed"}}},yAxis:{type:"category",inverse:!0,data:n.map(_=>_[p]),axisLabel:{color:R,fontSize:y?10:11,fontWeight:700,interval:0},axisLine:{show:!1},axisTick:{show:!1}},series:[{type:"bar",barWidth:T,barGap:"-100%",data:n.map(_=>({value:_[r],itemStyle:{borderRadius:[1,2,2,1],color:tl(rn),shadowBlur:2,shadowColor:"rgba(48, 220, 255, 0.12)"}})),showBackground:!0,backgroundStyle:{color:v?"rgba(48, 220, 255, 0.05)":"rgba(48, 220, 255, 0.07)",borderRadius:[1,2,2,1]},label:{show:!0,position:"right",color:L,fontFamily:Hn.number,fontSize:y?10:Lr.chartLabel,fontWeight:700,formatter:({value:_})=>`${l==="%"?et(_):ae(_)}`}}]}}function tl(n){return new $e(0,0,1,0,[{offset:0,color:"rgba(67, 217, 232, 0.14)"},{offset:.58,color:"rgba(67, 217, 232, 0.7)"},{offset:1,color:n}])}function nr(n,r,l,c=0,p=!1){return{name:n,type:"line",yAxisIndex:c,smooth:!0,symbolSize:5,data:r,lineStyle:{width:2.5,color:l},itemStyle:{color:l},areaStyle:p?{color:new $e(0,0,0,1,[{offset:0,color:`${l}44`},{offset:1,color:`${l}05`}])}:void 0}}function al(n){return fn.find(r=>r.key===n)||fn[2]}function nl(n,r="month"){if(r==="month")return nu(n);const l=iu(n),c=Math.max(1,Math.round(Math.max(1,l-1)*30)),p=r==="week"?7:1,y=Math.ceil(c/p)+1,v=Array.from({length:y},(_,W)=>{const Z=Math.min(c,W*p);return ru(Z)}),T=v.map((_,W)=>{const X=Math.min(c,W*p)/c,ce=Math.sin(W/(r==="week"?1.8:8.5))*Math.sin(Math.PI*X)*Math.min(360,n.months*18);return Math.round(lt+(n.stock-lt)*X+ce)}),R=v.map((_,W)=>{const Z=Math.min(c,W*p)/c;return Math.round(n.births*Z)}),B=v.map((_,W)=>{const Z=Math.min(c,W*p)/c;return Math.round(n.outflow*Z)});return{labels:v,stock:T,births:R,outflow:B}}function il(n,r){return r==="day"?Math.max(10,Math.ceil(n/6)):r==="week"?Math.max(2,Math.ceil(n/7)):n>24?4:n>14?2:1}function rl(n,r){return r==="day"?n>700?2:n>360?3:4:r==="week"?n>110?4:6:n>24?7:10}function sl(n){return(n.labels||[]).map((r,l)=>{var _,W,Z,X,ce,Re;const c=Number(((_=n.stock)==null?void 0:_[Math.max(l-1,0)])||0),p=Number(((W=n.stock)==null?void 0:W[l])||c),y=Math.max(0,Number(((Z=n.births)==null?void 0:Z[l])||0)-Number(((X=n.births)==null?void 0:X[Math.max(l-1,0)])||0)),v=Math.max(0,Number(((ce=n.outflow)==null?void 0:ce[l])||0)-Number(((Re=n.outflow)==null?void 0:Re[Math.max(l-1,0)])||0)),T=Math.max(120,Math.round((y+v)*.18)),R=Math.max(c,p)+Math.max(T,Math.round(y*.32)),B=Math.max(0,Math.min(c,p)-Math.max(T,Math.round(v*.32)));return{label:r,open:c,close:p,low:B,high:R,birth:y,outflow:v,value:[c,p,B,R]}})}function ol(n,r){const l=new Map;return n.forEach(c=>{const p=ll(c.name);if(!p)return;const y=l.get(p)||{name:p,value:0};y.value+=Number(c[r]||0),l.set(p,y)}),[...l.values()].sort((c,p)=>p.value-c.value)}function ll(n){return{色地镇:"色地镇",瓦切镇:"瓦切镇",安曲镇:"安曲镇",龙日镇:"龙日镇",邛溪镇:"邛溪镇",刷经寺镇:"刷经寺镇",阿木乡:"阿木乡",查尔玛乡:"查尔玛乡",江茸乡:"江茸乡",麦洼乡:"麦洼乡"}[n]||""}function we(n){return{trigger:"item",backgroundColor:"rgba(5, 31, 51, 0.96)",borderColor:"rgba(0, 210, 255, 0.54)",borderWidth:1,padding:[7,10],textStyle:{color:m,fontFamily:Hn.ui,fontSize:Lr.tooltip,lineHeight:18},extraCssText:"box-shadow:0 0 10px rgba(0,210,255,.12);",formatter:n}}function Yn(n){return wt.some(r=>r.key===n)?n:"structure"}function ul(n=[]){return n.map((r,l)=>{var y,v,T,R;const c=String(r.name||r.label||r.type||`结构${l+1}`).trim(),p=ir((v=(y=r.value)!=null?y:r.count)!=null?v:r.number);return{key:r.key||r.id||`${c}-${l}`,name:c,count:p,ratio:Number((R=(T=r.ratio)!=null?T:r.percent)!=null?R:0),source:r.source||"结构统计"}}).filter(r=>r.name&&r.count>0)}function cl(n=[],r=[]){const l=n.some(p=>lr(p))?n:r,c=or(l,r).map((p,y)=>{var R,B;const v=String(p.name||p.label||`结构${y+1}`).trim(),T=ir((B=(R=p.count)!=null?R:p.value)!=null?B:p.number);return V(I({},p),{key:p.key||`${v}-${y}`,name:v,count:T})}).filter(p=>p.name&&p.count>0);return dl(c,lt)}function dl(n=[],r=lt){const l=n.reduce((y,v)=>y+Number(v.count||0),0);if(!l||!r)return n;const c=n.map((y,v)=>{const T=Number.isFinite(Number(y.ratio))&&Number(y.ratio)>0?Number(y.ratio):Number(y.count||0)/l*100,R=r*T/100;return V(I({},y),{index:v,ratio:T,count:Math.floor(R),remainder:R-Math.floor(R)})});let p=r-c.reduce((y,v)=>y+v.count,0);return c.slice().sort((y,v)=>v.remainder-y.remainder||y.index-v.index).forEach(y=>{p<=0||(y.count+=1,p-=1)}),c.map(R=>{var B=R,{index:y,remainder:v}=B,T=fr(B,["index","remainder"]);return V(I({},T),{ratio:Number(T.ratio.toFixed(1))})})}function ir(n){const r=Number(String(n!=null?n:"").replace(/,/g,"").replace(/%/g,""));return Number.isFinite(r)&&r>0?Math.round(r):0}function hl(n,r){const l=String((n==null?void 0:n.message)||n||"");return/未登录|401|HTTP_401/.test(l)?"结构数据未就绪":/超时|timeout/i.test(l)?"结构数据加载超时":r}function pl(n){const r=String(n||"").match(/-?\d+(?:\.\d+)?/);return r?Number(r[0]):0}function U(n){const r=Number(n);return Number.isFinite(r)?r.toLocaleString("zh-CN",{maximumFractionDigits:Number.isInteger(r)?0:2}):"--"}function ae(n){const r=Number(n);return Number.isFinite(r)?Math.abs(r)>=1e4?`${(r/1e4).toFixed(Math.abs(r)>=1e5?0:1)}`:Math.round(r).toLocaleString("zh-CN"):"--"}function qa(n,r=2){const l=Number(n);return Number.isFinite(l)?`${(l/1e4).toFixed(r)}`:"--"}function et(n){const r=Number(n);return Number.isFinite(r)?`${Number.isInteger(r)?r:r.toFixed(1)}%`:"--"}function zt(n,r,l,c){const p=c*Math.PI/180;return{x:Number((n+l*Math.cos(p)).toFixed(2)),y:Number((r+l*Math.sin(p)).toFixed(2))}}function fl(n,r,l,c,p,y){const v=zt(n,r,c,p),T=zt(n,r,c,y),R=zt(n,r,l,y),B=zt(n,r,l,p),_=y-p>180?1:0;return[`M ${v.x} ${v.y}`,`A ${c} ${c} 0 ${_} 1 ${T.x} ${T.y}`,`L ${R.x} ${R.y}`,`A ${l} ${l} 0 ${_} 0 ${B.x} ${B.y}`,"Z"].join(" ")}function rr(n=[]){return n.reduce((r,l)=>{const c=ba.find(p=>p.key===l);return r+Number((c==null?void 0:c.ratio)||0)},0)}function sr(){return[{key:"fertileCow",name:"适龄能繁母牛",color:"#3ed9e7",matcher:(n,r)=>n==="fertileCow"||r.includes("适龄能繁母牛")},{key:"meatBull",name:"麦洼公牦牛",color:"#5b8ff9",matcher:(n,r)=>n==="meatBull"||r.includes("肉公牛")||r.includes("麦洼公牦牛")},{key:"breedingBull",name:"种公牛",color:"#f6bd16",matcher:(n,r)=>n==="breedingBull"||r.includes("种公牛")},{key:"femaleCalf",name:"母犊牛",color:"#5ad8a6",matcher:(n,r)=>n==="femaleCalf"||r.includes("母犊牛")},{key:"maleCalf",name:"公犊牛",color:"#9270ca",matcher:(n,r)=>n==="maleCalf"||r.includes("公犊牛")},{key:"overageCow",name:"过龄能繁母牛",color:"#e8684a",matcher:(n,r)=>n==="overageCow"||r.includes("过龄能繁母牛")}]}function ml(n=[]){const r=n.reduce((c,p)=>c+Number(p.count||0),0)||1;return[{key:"female",group:"性别",name:"母牛合计",color:"#8bf7ff",matcher:(c,p)=>["fertileCow","femaleCalf","overageCow"].includes(c)||p.includes("母")},{key:"male",group:"性别",name:"公牛合计",color:"#30dcff",matcher:(c,p)=>["meatBull","breedingBull","maleCalf"].includes(c)||p.includes("公")||p.includes("肉牛")},{key:"calf",group:"阶段",name:"犊牛合计",color:"#8bf7ff",matcher:(c,p)=>["femaleCalf","maleCalf"].includes(c)||p.includes("犊牛")},{key:"breeding-cow",group:"阶段",name:"能繁母牛",color:"#48cfff",matcher:(c,p)=>["fertileCow","overageCow"].includes(c)||p.includes("能繁母牛")}].map(c=>{const p=n.filter(y=>c.matcher(String(y.key||""),String(y.name||""))).reduce((y,v)=>y+Number(v.count||0),0);return{key:c.key,group:c.group,name:c.name,color:c.color,count:p,percent:p/r*100}})}function or(n=[],r=[]){const c=n.some(v=>lr(v))?n:r,p=c.reduce((v,T)=>v+Number(T.count||0),0)||lt||1;return sr().map(v=>{const T=c.filter(_=>v.matcher(String(_.key||""),String(_.name||""))),R=T.reduce((_,W)=>_+Number(W.count||0),0),B=T.length===1?Number(T[0].ratio):Number.NaN;return{key:v.key,name:v.name,color:v.color,count:R,percent:Number.isFinite(B)&&B>0?B:R/p*100}}).filter(v=>v.count>0||v.percent>0)}function lr(n={}){const r=String(n.key||""),l=String(n.name||"");return sr().some(c=>c.matcher(r,l))}function gl(n=[],r=[]){const c=n.some(v=>yl(v))?n:r,p=c.reduce((v,T)=>v+Number(T.count||0),0)||1,y=(v,T,R,B,_)=>{const W=c.filter(ce=>B(String(ce.key||""),String(ce.name||""))),Z=W.reduce((ce,Re)=>ce+Number(Re.count||0),0),X=W.length===1?Number(W[0].ratio):Number.NaN;return{key:v,name:T,color:R,count:Z,percent:Number.isFinite(X)&&X>0?X:Z/p*100,desc:_}};return[y("fertile-cow","适龄能繁母牛","#30dcff",(v,T)=>v==="fertileCow"||T.includes("适龄能繁母牛"),"繁殖基础"),y("calf","犊牛合计","#8bf7ff",(v,T)=>["femaleCalf","maleCalf"].includes(v)||T.includes("犊牛"),"新生补充"),y("overage-cow","过龄能繁母牛","#30dcff",(v,T)=>v==="overageCow"||T.includes("过龄能繁母牛"),"更新压力"),y("breeding-bull","种公牛配比","#48cfff",(v,T)=>v==="breedingBull"||T.includes("种公牛"),"配种支撑")]}function yl(n={}){const r=String(n.key||""),l=String(n.name||"");return["fertileCow","femaleCalf","maleCalf","overageCow","breedingBull"].includes(r)||l.includes("适龄能繁母牛")||l.includes("犊牛")||l.includes("过龄能繁母牛")||l.includes("种公牛")}function bl(n=[]){const r=v=>{var T;return Number(((T=n.find(R=>R.key===v))==null?void 0:T.percent)||0)},l=r("fertile-cow"),c=r("calf"),p=r("overage-cow"),y=r("breeding-bull");return l>=40&&c>=25&&y>=2&&y<=5&&p<=10?{label:"结构健康",title:"繁殖基础稳定",summary:"适龄母牛足,犊牛补充稳",note:"保持适龄能繁母牛、犊牛补充与种公牛配置稳定。"}:c<25?{label:"结构健康",title:"犊牛补充需关注",summary:"繁殖基础稳定,补充端可优化",note:"关注犊牛成活和季节性补栏,保持生产连续性。"}:y<2?{label:"结构健康",title:"繁殖基础总体稳定",summary:"适龄母牛基础较稳",note:"结合实际配种需求,平稳优化公牛配置。"}:{label:"结构健康",title:"生产阶段较均衡",summary:"繁殖群和犊牛补充连续支撑",note:"延续结构管理,优先保障适龄母牛与犊牛质量。"}}function vl(n){const r=Number((n==null?void 0:n.count)||0);return Math.max(8,Math.min(100,r/cs.value*100))}function wl(n={}){const r=lt,l=[{key:"births",name:"新生牛犊",delta:Number(n.births||0),color:"#30dcff"},{key:"outflow",name:"出栏流出",delta:-Number(n.outflow||0),color:"#48cfff"},{key:"correction",name:"修正损耗",delta:Number(n.correction||0),color:"#8bf7ff"}];let c=r;const p=[{key:"current",name:"当前存栏",type:"anchor",value:r,magnitude:r,from:r,to:r,color:"#30dcff",display:`${qa(r,2)}`}];l.forEach(T=>{const R=c,B=c+T.delta;c=B,p.push(V(I({},T),{name:`${T.delta>=0?"+":"-"}${T.name}`,type:"delta",from:R,to:B,value:T.delta,magnitude:Math.abs(T.delta),display:`${Ll(T.delta)}`}))});const y=Number(n.stock||c);p.push({key:"final",name:"=期末预测",type:"final",value:y,magnitude:y,from:y,to:y,color:"#48cfff",display:`${qa(y,2)}`});const v=Math.max(...p.map(T=>Number(T.magnitude)||0),1);return p.map(T=>{const R=(Number(T.magnitude)||0)/v*100;return V(I({},T),{left:0,width:Math.max(T.type==="delta"?5:10,Math.min(100,R))})})}function Ua(n){const r=Number(n);return Number.isFinite(r)?`${r>=0?"+":"-"}${U(Math.abs(r))}`:"--"}function Ll(n){const r=Number(n);return Number.isFinite(r)?`${r>=0?"+":"-"}${qa(Math.abs(r))}`:"--"}return(n,r)=>(x(),A("div",sc,[tt((x(),Za(rc,{key:rs.value,ref_key:"mapSceneRef",ref:Ne,class:"yak-map-scene","active-layer":qs.value,"map-ranking":Us.value,"tile-url-template":si.value,"use-satellite-base":mn.value,"satellite-max-zoom":21,"admin-boundary-line-scale":1.35,onLayerStatus:tr,onTileStatus:ar},null,8,["active-layer","map-ranking","tile-url-template","use-satellite-base"])),[[Pl,!Je.value]]),Je.value?(x(),Za(yu,{key:ti.value,ref_key:"yakOlMapRef",ref:la,class:"yak-ol-map-layer",active:a.active&&Je.value,"tile-url-template":si.value,center:Hs.value,"initial-zoom":hh,"minimum-zoom-distance":1,"county-view-target-offset":Y(re),"admin-boundary-line-scale":1.65,"auto-apply-layer-map-view":!1,"max-zoom":21,"overlay-layer":wi.value,onReady:Qo,onLayerStatus:tr,onTileStatus:ar},null,8,["active","tile-url-template","center","county-view-target-offset","overlay-layer"])):Le("",!0),f("div",{class:Ve(["yak-map-scrim",{"is-ol-map":Je.value}])},null,2),Ks.value?(x(),A("div",{key:1,class:Ve(["yak-map-loading",{"is-timeout":He.value}]),role:"status","aria-live":"polite"},[f("strong",null,P(He.value?"地图暂未加载完成":Zs.value),1),He.value?(x(),A(te,{key:1},[r[24]||(r[24]=f("span",null,"其余业务数据仍可查看,您可以重新加载地图。",-1)),f("button",{type:"button",onClick:wo},"重新加载地图")],64)):(x(),A("span",oc,"正在准备地图资源,请稍候"))],2)):Le("",!0),f("div",lc,[z.value==="trade"&&yi.value.length?(x(),A("div",uc,[r[25]||(r[25]=f("span",null,"交易年份",-1)),(x(!0),A(te,null,pe(yi.value,l=>(x(),A("button",{key:l,type:"button",class:Ve({active:Number(l)===Number(Me.value)}),onClick:c=>Uo(l)},P(l),11,cc))),128))])):Le("",!0),z.value==="epidemic"&&Fe.length?(x(),A("div",dc,[r[26]||(r[26]=f("span",null,"防疫年份",-1)),(x(),A(te,null,pe(Fe,l=>f("button",{key:l,type:"button",class:Ve({active:Number(l)===Number(ge.value)}),onClick:c=>Ko(l)},P(l),11,hc)),64))])):Le("",!0),z.value==="forecast"?(x(),A("div",pc,[r[27]||(r[27]=f("span",null,"预测年份",-1)),(x(!0),A(te,null,pe(Y(Bt),l=>(x(),A("button",{key:l.key,type:"button",class:Ve({active:l.key===nt.value}),onClick:c=>Lo(l.key)},P(l.shortLabel),11,fc))),128))])):Le("",!0),f("div",mc,[f("div",gc,[z.value==="structure"?(x(),A(te,{key:0},[j(oe,{class:"yak-side-card left-card",title:"繁殖基础评估",width:Y(s),height:u.value},{default:se(()=>[f("div",yc,[f("div",bc,[f("strong",null,P(ui.value.title)+","+P(ui.value.summary),1)]),f("div",vc,[(x(!0),A(te,null,pe(li.value,l=>(x(),A("div",{key:l.key,class:"breeding-health-item",style:Ct({"--health-color":l.color,"--health-width":`${Math.max(5,Math.min(100,l.percent))}%`})},[f("span",null,P(l.name),1),f("strong",null,P(et(l.percent)),1),r[28]||(r[28]=f("i",null,[f("b")],-1)),f("em",null,P(l.desc),1)],4))),128))])])]),_:1},8,["width","height"]),j(oe,{class:"yak-side-card left-card",title:"畜群结构占比",width:Y(s),height:u.value},{default:se(()=>[f("div",wc,[f("div",Lc,[f("div",Tc,[(x(),A("svg",Sc,[f("g",Mc,[(x(!0),A(te,null,pe(ds.value,l=>(x(),A("path",{key:l.key,class:Ve(["structure-rose-segment",{"is-active":l.index===yn.value}]),d:l.path,fill:l.color,stroke:l.color},null,10,kc))),128))]),r[29]||(r[29]=f("circle",{class:"structure-rose-glow",cx:"75",cy:"75",r:"24"},null,-1)),r[30]||(r[30]=f("circle",{class:"structure-rose-hole",cx:"75",cy:"75",r:"16"},null,-1)),r[31]||(r[31]=f("text",{class:"structure-rose-center",x:"75",y:"72","text-anchor":"middle"},"结构",-1)),r[32]||(r[32]=f("text",{class:"structure-rose-center is-sub",x:"75",y:"83","text-anchor":"middle"},"占比",-1))]))]),f("div",Pc,[(x(!0),A(te,null,pe(Ia.value,(l,c)=>(x(),A("div",{key:l.key||l.name,class:Ve(["structure-ratio-row",{"is-active":c===yn.value}]),style:Ct({"--row-color":l.color,"--row-percent":`${Math.max(4,l.percent)}%`})},[f("i",{style:Ct({background:l.color,color:l.color})},null,4),f("span",null,[Wt(P(l.name),1),f("small",null,P(et(l.percent)),1)]),f("strong",null,P(ae(l.count)),1),r[33]||(r[33]=f("em",null,"头",-1))],6))),128))])]),ht.value?(x(),A("div",Cc,"结构数据加载中")):Oe.value?(x(),A("div",Fc,P(Oe.value),1)):Le("",!0)])]),_:1},8,["width","height"]),j(oe,{class:"yak-side-card left-card",title:"母牛/公牛年龄结构",width:Y(s),height:u.value},{default:se(()=>[j(Y(Pe),{class:"yak-chart",option:Js.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"]),j(oe,{class:"yak-side-card left-card",title:"牦牛乡镇分布",width:Y(s),height:u.value},{default:se(()=>[j(Y(Pe),{class:"yak-chart",option:Qs.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"])],64)):z.value==="forecast"?(x(),A(te,{key:1},[j(oe,{class:"yak-side-card left-card",title:"存栏变化拆解",width:Y(s),height:u.value},{default:se(()=>[f("div",xc,[f("div",Nc,[f("span",null,P(Xe.value.label)+"变化路径",1),f("strong",{class:Ve({positive:gn.value>0,negative:gn.value<0})},[Wt(" 净变化 "+P(Ua(gn.value)),1),r[34]||(r[34]=f("em",null,"头",-1))],2)]),f("div",Rc,[(x(!0),A(te,null,pe(os.value,l=>(x(),A("div",{key:l.key,class:Ve(["forecast-waterfall-row",[`is-${l.type}`,{positive:l.delta>0,negative:l.delta<0}]]),style:Ct({"--waterfall-left":`${l.left}%`,"--waterfall-width":`${l.width}%`,"--waterfall-color":l.color})},[f("span",null,P(l.name),1),r[35]||(r[35]=f("i",null,[f("b")],-1)),f("strong",null,P(l.display),1)],6))),128))])])]),_:1},8,["width","height"]),j(oe,{class:"yak-side-card left-card",title:"未来存栏趋势",width:Y(s),height:u.value},{default:se(()=>[f("div",Ic,[f("div",Gc,[(x(),A(te,null,pe(fn,l=>f("button",{key:l.key,type:"button",class:Ve({active:l.key===Ft.value}),onClick:c=>Ft.value=l.key},P(l.label),11,_c)),64))]),j(Y(Pe),{class:"yak-chart forecast-kline-chart",option:no.value,autoresize:!0},null,8,["option"])])]),_:1},8,["width","height"]),j(oe,{class:"yak-side-card left-card",title:"月度数量预测",width:Y(s),height:u.value},{default:se(()=>[j(Y(Pe),{class:"yak-chart",option:io.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"]),j(oe,{class:"yak-side-card left-card",title:"预测因子雷达",width:Y(s),height:u.value},{default:se(()=>[j(Y(Pe),{class:"yak-chart",option:ro.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"])],64)):z.value==="epidemic"?(x(),A(te,{key:2},[j(oe,{class:"yak-side-card left-card",title:"防疫统计",width:Y(s),height:u.value},{default:se(()=>[j(Y(Pe),{class:"yak-chart",option:fo.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"]),j(oe,{class:"yak-side-card left-card",title:"养殖户防疫排行",width:Y(s),height:u.value},{default:se(()=>[j(Y(Pe),{class:"yak-chart",option:mo.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"]),j(oe,{class:"yak-side-card left-card",title:"防疫作业趋势",width:Y(s),height:u.value},{default:se(()=>[j(Y(Pe),{class:"yak-chart",option:po.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"]),j(oe,{class:"yak-side-card left-card",title:"疫苗类型分布",width:Y(s),height:u.value},{default:se(()=>[_a.value.length?(x(),A("div",Ac,[f("div",Bc,[(x(),Za(Wl,{key:ps.value,data:_a.value,delay:3e3,colors:Ce,opacity:.62,class:"epidemic-three-pie"},{default:se(({data:l})=>[f("div",Ec,[f("strong",null,P(ae((l==null?void 0:l.count)||yt.value)),1),f("span",null,P((l==null?void 0:l.name)||"疫苗类型"),1)])]),_:1},8,["data"]))]),f("div",$c,[(x(!0),A(te,null,pe(_a.value,(l,c)=>(x(),A("div",{key:l.key||l.name,class:"epidemic-three-pie-row"},[f("i",{style:Ct({borderColor:Ce[c%Ce.length]})},null,4),f("span",null,P(l.name),1),f("strong",null,P(ae(l.value)),1),f("em",null,P(l.unit),1)]))),128))])])):(x(),A("div",Vc,"暂无疫苗类型数据"))]),_:1},8,["width","height"])],64)):z.value==="trade"?(x(),A(te,{key:3},[j(oe,{class:"yak-side-card left-card",title:"交易异常关注",width:Y(s),height:u.value},{default:se(()=>[f("div",Oc,[f("div",Dc,[f("span",null,P(Me.value)+"年流通监管线索",1),f("strong",null,P(Bs.value),1)]),f("div",zc,[(x(!0),A(te,null,pe(vi.value,l=>(x(),A("div",{key:l.key,class:Ve(["trade-risk-row",`is-${l.level}`]),style:Ct({"--risk-color":l.color})},[r[36]||(r[36]=f("i",null,null,-1)),f("span",null,[f("em",null,[f("b",null,P(l.badge),1),Wt(P(l.name),1)]),f("small",null,P(l.value)+"|"+P(l.desc),1)])],6))),128))])])]),_:1},8,["width","height"]),j(oe,{class:"yak-side-card left-card",title:"交易流通趋势",width:Y(s),height:u.value},{default:se(()=>[j(Y(Pe),{class:"yak-chart",option:go.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"]),j(oe,{class:"yak-side-card left-card",title:"来源乡镇分布",width:Y(s),height:u.value},{default:se(()=>[j(Y(Pe),{class:"yak-chart",option:yo.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"]),j(oe,{class:"yak-side-card left-card",title:"用途结构统计",width:Y(s),height:u.value},{default:se(()=>[j(Y(Pe),{class:"yak-chart",option:bo.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"])],64)):Le("",!0)])]),f("div",Wc,[f("div",Yc,[z.value==="structure"?(x(),A(te,{key:0},[j(oe,{class:"yak-side-card right-card",title:"乡镇存栏排行",width:Y(s),height:u.value},{default:se(()=>[j(Y(Pe),{class:"yak-chart",option:eo.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"]),j(oe,{class:"yak-side-card right-card",title:"能繁母牛与犊牛分布",width:Y(s),height:u.value},{default:se(()=>[j(Y(Pe),{class:"yak-chart",option:to.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"]),j(oe,{class:"yak-side-card right-card",title:"出栏/交易影响",width:Y(s),height:u.value},{default:se(()=>[j(Y(Pe),{class:"yak-chart",option:ao.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"]),j(oe,{class:"yak-side-card right-card",title:"性别与生产阶段汇总",width:Y(s),height:u.value},{default:se(()=>[f("div",jc,[f("div",Hc,[(x(!0),A(te,null,pe(oi.value,l=>(x(),A("div",{key:l.key||l.name,class:"structure-summary-row",style:Ct({"--structure-color":l.color,"--structure-width":`${vl(l)}%`})},[f("span",null,[r[37]||(r[37]=f("i",null,null,-1)),Wt(P(l.name),1)]),r[39]||(r[39]=f("b",null,[f("em")],-1)),f("strong",null,[Wt(P(ae(l.count)),1),r[38]||(r[38]=f("em",null,"头",-1))]),f("small",null,P(et(l.percent)),1)],4))),128))]),ht.value?(x(),A("div",qc,"结构数据加载中")):Oe.value?(x(),A("div",Uc,P(Oe.value),1)):Le("",!0)])]),_:1},8,["width","height"])],64)):z.value==="forecast"?(x(),A(te,{key:1},[j(oe,{class:"yak-side-card right-card",title:"乡镇预测排行",width:Y(s),height:u.value},{default:se(()=>[j(Y(Pe),{class:"yak-chart",option:so.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"]),j(oe,{class:"yak-side-card right-card",title:"期末结构预测",width:Y(s),height:u.value},{default:se(()=>[j(Y(Pe),{class:"yak-chart",option:oo.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"]),j(oe,{class:"yak-side-card right-card",title:"补充/流出对比",width:Y(s),height:u.value},{default:se(()=>[j(Y(Pe),{class:"yak-chart",option:lo.value,autoresize:!0},null,8,["option"])]),_:1},8,["width","height"]),j(oe,{class:"yak-side-card right-card",title:"预测变化热力",width:Y(s),height:u.value},{default:se(()=>[f("div",Kc,[(x(!0),A(te,null,pe(uo.value,l=>(x(),A("div",{key:l.name,class:Ve(["heat-row",{"is-negative":l.change<0}]),style:Ct(co(l)),title:ho(l)},[f("span",null,P(l.name),1),r[40]||(r[40]=f("b",null,[f("i")],-1)),f("strong",null,P(Ua(l.change)),1)],14,Zc))),128))])]),_:1},8,["width","height"])],64)):z.value==="epidemic"?(x(),Za(oe,{key:2,class:"yak-side-card right-card epidemic-ledger-card",title:"防疫记录台账",width:Y(s),height:d.value},{default:se(()=>[f("div",Xc,[f("div",Jc,[f("span",null,P(ge.value)+"年 共 "+P(U(Ke.value))+" 条",1),f("div",null,[tt(f("input",{"onUpdate:modelValue":r[0]||(r[0]=l=>ft.value=l),type:"search",placeholder:"耳标/养殖户/疫苗",onKeyup:Xa(ji,["enter"])},null,544),[[Jt,ft.value]]),f("button",{type:"button",onClick:ji},"搜索"),f("button",{type:"button",class:"is-more",onClick:r[1]||(r[1]=l=>qi())},"查看更多")])]),r[41]||(r[41]=f("div",{class:"epidemic-record-header"},[f("span",null,"电子耳标"),f("span",null,"养殖户"),f("span",null,"镇/乡"),f("span",null,"疫苗"),f("span",null,"时间")],-1)),f("div",Qc,[(x(!0),A(te,null,pe(ks.value,l=>(x(),A("button",{key:l.epidemicId||l.earTag,type:"button",onClick:c=>qi(l)},[f("span",null,P(ee(l.earTag)),1),f("span",null,P(ee(l.owner)),1),f("span",null,P(ee(l.town)),1),f("strong",null,P(ee(l.medicine)),1),f("span",null,P(_t(l.operateTime)),1)],8,ed))),128)),De.value.length?Le("",!0):(x(),A("div",td,P(w.value?"防疫台账读取中":N.value||"暂无防疫记录"),1))]),f("div",ad,[f("span",null,"第 "+P(ve.value)+" / "+P(kn.value)+" 页",1),f("button",{type:"button",disabled:ve.value<=1,onClick:r[2]||(r[2]=l=>Hi(ve.value-1))},"上一页",8,nd),f("button",{type:"button",disabled:ve.value>=kn.value,onClick:r[3]||(r[3]=l=>Hi(ve.value+1))},"下一页",8,id)])])]),_:1},8,["width","height"])):z.value==="trade"?(x(),A(te,{key:3},[j(oe,{class:"yak-side-card right-card",title:"出证结构统计",width:Y(s),height:u.value},{default:se(()=>[f("div",rd,[f("div",sd,[f("span",null,[r[43]||(r[43]=f("em",null,"省外流通 A证",-1)),f("strong",null,[Wt(P(U(We("outProvinceHeads","aCertHeads"))),1),r[42]||(r[42]=f("b",null,"头",-1))]),f("small",null,P(U(We("outProvinceCount","aCertCount")))+"条记录",1)]),f("span",null,[r[45]||(r[45]=f("em",null,"省内流通 B证",-1)),f("strong",null,[Wt(P(U(We("inProvinceHeads","bCertHeads"))),1),r[44]||(r[44]=f("b",null,"头",-1))]),f("small",null,P(U(We("inProvinceCount","bCertCount")))+"条记录",1)])]),j(Y(Pe),{class:"trade-cert-chart",option:vo.value,autoresize:!0},null,8,["option"])])]),_:1},8,["width","height"]),j(oe,{class:"yak-side-card right-card trade-source-card",title:"出栏来源排行",width:Y(s),height:h.value},{default:se(()=>[f("div",od,[(x(!0),A(te,null,pe(Ea.value,(l,c)=>(x(),A("div",{key:l.name,class:"trade-dest-row",style:Ct({"--trade-ratio":`${l.ratio}%`})},[f("span",null,P(c+1),1),f("strong",null,P(l.name),1),f("em",null,P(ae(l.headCount))+"头",1)],4))),128)),Ea.value.length?Le("",!0):(x(),A("div",ld,P(Tt.value?"交易数据读取中":St.value||"暂无出栏来源数据"),1))])]),_:1},8,["width","height"]),j(oe,{class:"yak-side-card right-card trade-ledger-card",title:"交易出证台账",width:Y(s),height:g.value},{default:se(()=>[f("div",ud,[f("div",cd,[f("span",null,"共 "+P(U(mt.value))+" 条",1),f("div",null,[tt(f("input",{"onUpdate:modelValue":r[4]||(r[4]=l=>Ta.value=l),type:"search",placeholder:"货主/车辆/检疫号/地区",onKeyup:Xa(Bi,["enter"])},null,544),[[Jt,Ta.value]]),f("button",{type:"button",onClick:Bi},"搜索"),f("button",{type:"button",class:"is-more",onClick:r[5]||(r[5]=l=>$i())},"查看更多")])]),r[46]||(r[46]=f("div",{class:"trade-ledger-header"},[f("span",null,"货主"),f("span",null,"车牌"),f("span",null,"数量"),f("span",null,"来源"),f("span",null,"用途"),f("span",null,"时间")],-1)),f("div",dd,[(x(!0),A(te,null,pe(bi.value,l=>(x(),A("button",{key:l.certId,type:"button",onClick:c=>$i(l)},[f("span",null,P(ee(l.ownerName)),1),f("span",null,P(ee(l.transportNumber)),1),f("strong",null,P(U(l.amount))+"头",1),f("span",null,P(ee(l.startTown)),1),f("span",null,P(ee(l.usageTypeName)),1),f("span",null,P(_t(l.issueTime)),1)],8,hd))),128)),bi.value.length?Le("",!0):(x(),A("div",pd,P(Tt.value?"交易台账读取中":St.value||"暂无交易记录"),1))]),f("div",fd,[f("span",null,"第 "+P(Mt.value)+" / "+P(Cn.value)+" 页",1),f("button",{type:"button",disabled:Mt.value<=1,onClick:r[6]||(r[6]=l=>Ei(Mt.value-1))},"上一页",8,md),f("button",{type:"button",disabled:Mt.value>=Cn.value,onClick:r[7]||(r[7]=l=>Ei(Mt.value+1))},"下一页",8,gd)])])]),_:1},8,["width","height"])],64)):Le("",!0)])]),f("div",yd,[j(fu,{"model-value":z.value,topics:wt,"onUpdate:modelValue":r[8]||(r[8]=l=>z.value=l)},null,8,["model-value"])]),Je.value?(x(),A("div",bd,[j(mu,{modelValue:je.value,"onUpdate:modelValue":r[9]||(r[9]=l=>je.value=l),"topic-key":"yak-management",layers:Ds.value,legends:Ws.value,multiple:"",compact:"",width:248,height:Ys.value},null,8,["modelValue","layers","legends","height"])])):Le("",!0)]),O.value?(x(),A("div",{key:2,class:"epidemic-ledger-modal",onClick:Ja(Ui,["self"])},[f("div",vd,[f("div",wd,[f("div",null,[r[47]||(r[47]=f("span",null,"牦牛防疫台账",-1)),f("strong",null,P(ge.value)+"年 "+P(U(ne.value))+" 条记录",1)]),f("button",{type:"button",onClick:Ui},"关闭")]),f("div",Ld,[tt(f("input",{"onUpdate:modelValue":r[10]||(r[10]=l=>fe.value.keyword=l),type:"search",placeholder:"耳标 / 养殖户 / 药品","aria-label":"耳标 / 养殖户 / 药品",onKeyup:Xa(Ki,["enter"])},null,544),[[Jt,fe.value.keyword]]),tt(f("select",{"onUpdate:modelValue":r[11]||(r[11]=l=>fe.value.town=l)},[r[48]||(r[48]=f("option",{value:""},"全部镇/乡",-1)),(x(!0),A(te,null,pe(Cs.value,l=>(x(),A("option",{key:l,value:l},P(l),9,Td))),128))],512),[[fa,fe.value.town]]),tt(f("select",{"onUpdate:modelValue":r[12]||(r[12]=l=>fe.value.medicine=l)},[r[49]||(r[49]=f("option",{value:""},"全部疫苗",-1)),(x(!0),A(te,null,pe(Fs.value,l=>(x(),A("option",{key:l,value:l},P(l),9,Sd))),128))],512),[[fa,fe.value.medicine]]),tt(f("input",{"onUpdate:modelValue":r[13]||(r[13]=l=>fe.value.startDate=l),type:"date"},null,512),[[Jt,fe.value.startDate]]),tt(f("input",{"onUpdate:modelValue":r[14]||(r[14]=l=>fe.value.endDate=l),type:"date"},null,512),[[Jt,fe.value.endDate]]),f("button",{type:"button",onClick:Ki},"检索"),f("button",{type:"button",class:"is-ghost",onClick:Jo},"重置")]),f("div",Md,[f("div",kd,[r[50]||(r[50]=f("div",{class:"epidemic-ledger-table-head"},[f("span",null,"电子耳标"),f("span",null,"养殖户"),f("span",null,"镇/乡"),f("span",null,"村"),f("span",null,"疫苗"),f("span",null,"免疫时间"),f("span",null,"图片")],-1)),(x(!0),A(te,null,pe(H.value,l=>{var c,p;return x(),A("button",{key:l.epidemicId||l.earTag,type:"button",class:Ve({active:(((c=Ae.value)==null?void 0:c.epidemicId)||((p=Ae.value)==null?void 0:p.earTag))===(l.epidemicId||l.earTag)}),onClick:y=>Xi(l)},[f("span",null,P(ee(l.earTag)),1),f("span",null,P(ee(l.owner)),1),f("span",null,P(ee(l.town)),1),f("span",null,P(ee(l.village)),1),f("strong",null,P(ee(l.medicine)),1),f("span",null,P(_t(l.operateTime)),1),f("span",null,P(On(l).length?`${On(l).length}`:"无"),1)],10,Pd)}),128)),H.value.length?Le("",!0):(x(),A("div",Cd,P(_e.value?"台账读取中":ze.value||"暂无匹配记录"),1))]),f("div",Fd,[f("div",xd,[f("div",null,[f("span",null,P(ee(Dt.value.earTag)),1),f("em",null,P(ee(Dt.value.medicine||Dt.value.preventionType)),1)]),f("strong",null,P(Ee.value?"加载中":_t(Dt.value.operateTime)),1)]),f("div",Nd,[(x(!0),A(te,null,pe(Ps.value,l=>(x(),A("span",{key:l.label,class:Ve({"is-wide":l.wide})},[f("em",null,P(l.label),1),f("strong",null,P(l.value),1)],2))),128))]),mi.value.length?(x(),A("div",Rd,[r[51]||(r[51]=f("div",{class:"epidemic-detail-photo-title"},"现场照片",-1)),f("div",Id,[(x(!0),A(te,null,pe(mi.value.slice(0,6),l=>(x(),A("button",{key:l,type:"button",class:"epidemic-modal-photo-thumb",onClick:Ja(c=>zo(l),["stop"])},[f("img",{src:Ii(l),alt:"防疫照片"},null,8,_d)],8,Gd))),128))])])):Le("",!0)])]),f("div",Ad,[f("span",null,"第 "+P(ue.value)+" / "+P(fi.value)+" 页",1),f("button",{type:"button",disabled:ue.value<=1,onClick:r[15]||(r[15]=l=>Zi(ue.value-1))},"上一页",8,Bd),f("button",{type:"button",disabled:ue.value>=fi.value,onClick:r[16]||(r[16]=l=>Zi(ue.value+1))},"下一页",8,Ed)])])])):Le("",!0),cn.value?(x(),A("div",{key:3,class:"epidemic-ledger-modal trade-ledger-modal",onClick:Ja(Vi,["self"])},[f("div",$d,[f("div",Vd,[f("div",null,[r[52]||(r[52]=f("span",null,"牦牛交易出证台账",-1)),f("strong",null,P(Me.value)+"年 "+P(U(Sa.value))+" 条记录",1)]),f("button",{type:"button",onClick:Vi},"关闭")]),f("div",Od,[tt(f("input",{"onUpdate:modelValue":r[17]||(r[17]=l=>gt.value.keyword=l),type:"search",placeholder:"货主 / 车辆 / 检疫号 / 地区",onKeyup:Xa(Oi,["enter"])},null,544),[[Jt,gt.value.keyword]]),tt(f("select",{"onUpdate:modelValue":r[18]||(r[18]=l=>gt.value.startTown=l)},[r[53]||(r[53]=f("option",{value:""},"全部来源乡镇",-1)),(x(!0),A(te,null,pe(Is.value,l=>(x(),A("option",{key:l,value:l},P(l),9,Dd))),128))],512),[[fa,gt.value.startTown]]),tt(f("select",{"onUpdate:modelValue":r[19]||(r[19]=l=>gt.value.usageType=l)},[r[54]||(r[54]=f("option",{value:""},"全部用途",-1)),(x(!0),A(te,null,pe(Gs.value,l=>(x(),A("option",{key:l,value:l},P(l),9,zd))),128))],512),[[fa,gt.value.usageType]]),tt(f("select",{"onUpdate:modelValue":r[20]||(r[20]=l=>gt.value.certType=l)},[r[55]||(r[55]=f("option",{value:""},"全部证书",-1)),(x(!0),A(te,null,pe(_s.value,l=>(x(),A("option",{key:l.value,value:l.value},P(l.label),9,Wd))),128))],512),[[fa,gt.value.certType]]),f("button",{type:"button",onClick:Oi},"检索"),f("button",{type:"button",class:"is-ghost",onClick:Zo},"重置")]),f("div",Yd,[f("div",jd,[r[56]||(r[56]=f("div",{class:"trade-ledger-modal-table-head"},[f("span",null,"货主"),f("span",null,"证书"),f("span",null,"车牌号"),f("span",null,"数量"),f("span",null,"来源"),f("span",null,"用途"),f("span",null,"出证时间"),f("span",null,"状态")],-1)),(x(!0),A(te,null,pe($t.value,l=>(x(),A("button",{key:l.certId||l.factoryCode,type:"button",class:Ve({active:Rs.value===(l.certId||l.factoryCode)}),onClick:c=>zi(l)},[f("span",null,P(ee(l.ownerName)),1),f("span",null,P(ee(l.certType||l.certScopeName)),1),f("span",null,P(ee(l.transportNumber)),1),f("strong",null,P(U(l.amount))+"头",1),f("span",null,P(ee(l.startTown)),1),f("span",null,P(ee(l.usageTypeName)),1),f("span",null,P(_t(l.issueTime)),1),f("span",null,P(ee(l.statusName)),1)],10,Hd))),128)),$t.value.length?Le("",!0):(x(),A("div",qd,P(dn.value?"交易台账读取中":hn.value||"暂无匹配记录"),1))]),f("div",Ud,[f("div",Kd,[f("div",null,[f("span",null,P(ee(ye.value.factoryCode||ye.value.certId)),1),f("em",null,P(_i(ye.value)),1)]),f("strong",null,P(_t(ye.value.issueTime)),1)]),f("div",Zd,[f("span",Xd,[r[57]||(r[57]=f("em",null,"货主",-1)),f("strong",null,P(ee(ye.value.ownerName)),1)]),f("span",null,[r[58]||(r[58]=f("em",null,"联系方式",-1)),f("strong",null,P(Gi(ye.value.ownerPhone)),1)]),f("span",null,[r[59]||(r[59]=f("em",null,"证书类型",-1)),f("strong",null,P(_i(ye.value)),1)]),f("span",null,[r[60]||(r[60]=f("em",null,"车牌号",-1)),f("strong",null,P(ee(ye.value.transportNumber)),1)]),f("span",null,[r[61]||(r[61]=f("em",null,"牦牛数量",-1)),f("strong",null,P(U(ye.value.amount))+"头",1)]),f("span",null,[r[62]||(r[62]=f("em",null,"用途",-1)),f("strong",null,P(ee(ye.value.usageTypeName)),1)]),f("span",null,[r[63]||(r[63]=f("em",null,"来源乡镇",-1)),f("strong",null,P(ee(ye.value.startTown)),1)]),f("span",null,[r[64]||(r[64]=f("em",null,"目的省份",-1)),f("strong",null,P(ee(ye.value.destProvince)),1)]),f("span",null,[r[65]||(r[65]=f("em",null,"检疫员",-1)),f("strong",null,P(ee(ye.value.quarantineOfficerName)),1)]),f("span",Jd,[r[66]||(r[66]=f("em",null,"状态",-1)),f("strong",null,P(ee(ye.value.statusName)),1)]),f("span",Qd,[r[67]||(r[67]=f("em",null,"来源地区",-1)),f("strong",null,P(ee(ye.value.startRegionFullName)),1)]),f("span",eh,[r[68]||(r[68]=f("em",null,"目的地",-1)),f("strong",null,P(ee(ye.value.destRegionFullName)),1)])]),f("button",{type:"button",class:"trade-detail-locate",disabled:!ye.value.startTown,onClick:r[21]||(r[21]=l=>Xo(ye.value))}," 查看乡镇位置 ",8,th)])]),f("div",ah,[f("span",null,"第 "+P(Vt.value)+" / "+P(Fn.value)+" 页",1),f("button",{type:"button",disabled:Vt.value<=1,onClick:r[22]||(r[22]=l=>Di(Vt.value-1))},"上一页",8,nh),f("button",{type:"button",disabled:Vt.value>=Fn.value,onClick:r[23]||(r[23]=l=>Di(Vt.value+1))},"下一页",8,ih)])])])):Le("",!0),Ze.value?(x(),A("div",{key:4,class:"epidemic-image-preview-modal",onClick:Ja(Dn,["self"])},[f("div",rh,[f("div",sh,[f("div",null,[r[69]||(r[69]=f("span",null,"防疫照片",-1)),f("strong",null,P(ee(Dt.value.earTag)),1)]),f("button",{type:"button",onClick:Dn},"关闭")]),f("div",oh,[f("div",lh,[f("img",{src:it.value,alt:"防疫照片预览"},null,8,uh)])])])])):Le("",!0)]))}};export{Ih as default};