@idmwx/idmui-gl3 4.6.6 → 4.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -56,7 +56,7 @@ const I = (z, M) => {
56
56
  default: void 0
57
57
  }
58
58
  },
59
- emits: ["weather", "other", "toggleWindParticle", "toggleWindFeather", "toggleCurrentParticle", "toggleCurrentIsoband", "coordinate", "measure", "point", "3d", "layerToggle", "handleToggleVersion"],
59
+ emits: ["weather", "other", "toggleWindParticle", "toggleWindFeather", "toggleCurrentParticle", "toggleCurrentIsoband", "coordinate", "measure", "point", "3d", "layerToggle", "handleToggleVersion", "login"],
60
60
  data() {
61
61
  return {
62
62
  autoActive: !0,
@@ -175,7 +175,7 @@ const I = (z, M) => {
175
175
  this.showCoord = !this.showCoord, this.$emit("coordinate", this.showCoord);
176
176
  },
177
177
  handlePointToggle() {
178
- this.isLogin ? (this.showPoint = !this.showPoint, this.$emit("point", this.showPoint)) : this.$emit("handleToggleVersion");
178
+ this.isLogin ? (this.showPoint = !this.showPoint, this.$emit("point", this.showPoint)) : this.$emit("login");
179
179
  },
180
180
  handleMeasureToggle() {
181
181
  this.showMeasure = !this.showMeasure, this.$emit("measure", this.showMeasure);
@@ -1,4 +1,4 @@
1
- (function(k,U){typeof exports=="object"&&typeof module<"u"?U(exports,require("@idm-plugin/tag"),require("vue"),require("@turf/turf"),require("@mapbox/sphericalmercator"),require("moment"),require("mapbox-gl"),require("@idm-plugin/geo"),require("@idm-plugin/meteo"),require("axios")):typeof define=="function"&&define.amd?define(["exports","@idm-plugin/tag","vue","@turf/turf","@mapbox/sphericalmercator","moment","mapbox-gl","@idm-plugin/geo","@idm-plugin/meteo","axios"],U):(k=typeof globalThis<"u"?globalThis:k||self,U(k["idm-gl"]={},k["@idm-plugin/tag"],k.Vue,k["@turf/turf"],k["@mapbox/sphericalmercator"],k.moment,k["mapbox-gl"],k["@idm-plugin/geo"],k["@idm-plugin/meteo"],k.axios))})(this,function(k,U,b,T0,w0,D,c0,C,u0,e0){"use strict";var Bb=Object.defineProperty;var gb=(k,U,b)=>U in k?Bb(k,U,{enumerable:!0,configurable:!0,writable:!0,value:b}):k[U]=b;var V=(k,U,b)=>(gb(k,typeof U!="symbol"?U+"":U,b),b);function C0(p){const M=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(p){for(const z in p)if(z!=="default"){const o=Object.getOwnPropertyDescriptor(p,z);Object.defineProperty(M,z,o.get?o:{enumerable:!0,get:()=>p[z]})}}return M.default=p,Object.freeze(M)}const y=C0(T0),yb="",Xb="",S=(p,M)=>{const z=p.__vccOpts||p;for(const[o,O]of M)z[o]=O;return z},E0={name:"IdmGlLayer",props:{map:{type:Object},mapProjection:{type:String},top:{type:Number,default:60},layerToggle:{type:Boolean,default:!1},toggleVersion:{type:Number},isLogin:{type:Boolean,default:void 0},showWindFeather:{type:Boolean,default:void 0},showWindParticle:{type:Boolean,default:void 0},showCurrentIsoband:{type:Boolean,default:void 0},showCurrentParticle:{type:Boolean,default:void 0}},emits:["weather","other","toggleWindParticle","toggleWindFeather","toggleCurrentParticle","toggleCurrentIsoband","coordinate","measure","point","3d","layerToggle","handleToggleVersion"],data(){return{autoActive:!0,layers:{weather:[...U.LayerHelper.WEATHER_LAYERS.filter(p=>!["swell-height","swell-direction","current-direction","current-speed"].includes(p.key))],other:[...U.LayerHelper.OTHER_LAYERS.filter(p=>p.key!=="world12nm"&&p.enabled)]},activeWeatherLayers:[],activeOtherLayers:[],autoActiveCache:"autoActiveCache",activeWeatherLayersCache:"activeWeatherLayersCache",activeOtherLayersCache:"activeOtherLayersCache",collectedLayerCache:"collectedLayerCache",sourceCache:"defaultSourceCache",windFeatherCache:"windFeatherCache",currentIsobandCache:"currentIsobandCache",showCoord:!1,showMeasure:!1,showPoint:!1,show3d:!1,version:{v:"0.0.7",k:"glCacheVersion"},source:"",right:10,rampColorLayers:["visibility","precip3h","temp","water-temp","arctic"]}},computed:{computeLayerClass(){return function(p,M){var o;let z="layer flex-between";return M.some(O=>O.key===p.key)&&(z=z+" active"),(!p.enabled||(o=this.layers.weather)!=null&&o.some(O=>O.key===p.key)&&!this.autoActive||this.rampColorLayers.includes(p.key)&&this.mapProjection==="globe")&&(z=z+" disabled"),z}},hasCollectedLayers(){var p;return((p=this.layers.weather.filter(M=>M.collected))==null?void 0:p.length)>0}},watch:{toggleVersion:{handler(){this.$nextTick(()=>{var p;this.right=(((p=document.getElementsByClassName("right-bar")[0])==null?void 0:p.clientWidth)||0)+10})}},source:{handler(p,M){p&&M&&p!==M&&this.handleConfirm()}}},mounted(){this.fetchCache(),this.handleConfirm()},methods:{fetchCache(){const p=localStorage.getItem(this.version.k);this.version.v!==p&&(localStorage.removeItem(this.activeWeatherLayersCache),localStorage.removeItem(this.collectedLayerCache),localStorage.removeItem(this.activeOtherLayersCache),localStorage.removeItem(this.windFeatherCache),localStorage.removeItem(this.currentIsobandCache),localStorage.setItem(this.version.k,this.version.v));let M=localStorage.getItem(this.autoActiveCache);this.autoActive=M!=="false",M=localStorage.getItem(this.collectedLayerCache);let z=JSON.parse(M||'[{"weight": 16, "name": "Sig Waves", "key": "sig-wave-height", "collected": true},{"weight": 1, "name": "Wind", "key": "wind", "h5": true, "collected": true},{"weight": 96, "name": "Current", "key": "current", "collected": true},{"weight": 6, "name": "Swell", "key": "swell", "collected": true}]');this.layers.weather.forEach(o=>{o.collected=!!z.some(O=>O.key===o.key&&O.collected)}),M=localStorage.getItem(this.activeWeatherLayersCache),M||localStorage.setItem(this.activeWeatherLayersCache,JSON.stringify([{weight:1,name:"Wind",key:"wind",enabled:!0,type:"json",particle:!0},{weight:4096,name:"Pressure",key:"prmsl",enabled:!0,type:"json"},{weight:256,name:"Tropicals",key:"tropicals",enabled:!0,type:"json"}])),M=localStorage.getItem(this.activeWeatherLayersCache),z=JSON.parse(M),this.autoActive&&(this.activeWeatherLayers=[...z]),z.some(o=>o.key==="wind"&&o.particle)&&this.$emit("toggleWindParticle",!0),localStorage.getItem(this.windFeatherCache)==="true"&&this.$emit("toggleWindFeather",!0),z.some(o=>o.key==="current"&&o.particle)&&this.$emit("toggleCurrentParticle",!0),localStorage.getItem(this.currentIsobandCache)==="true"&&this.$emit("toggleCurrentIsoband",!0),M=localStorage.getItem(this.activeOtherLayersCache),z=JSON.parse(M||'[{"weight":4,"name":"ECA Zones","key":"eca-zones","enabled":true,"type":"json"}]'),this.activeOtherLayers=z,M=localStorage.getItem(this.sourceCache),this.source=M||"GFS"},handleConfirm(){this.$emit("weather",this.activeWeatherLayers,this.source),this.$emit("other",this.activeOtherLayers),localStorage.setItem(this.autoActiveCache,this.autoActive),localStorage.setItem(this.sourceCache,this.source)},handleWeatherLayerPick(p){if(this.activeWeatherLayers=JSON.parse(localStorage.getItem(this.activeWeatherLayersCache)),this.rampColorLayers.includes(p.key)&&this.mapProjection==="globe"||!this.autoActive)return!1;(p.key==="wind"&&!this.showWindFeather||p.key==="current"&&!this.showCurrentIsoband)&&(p.particle=!0),this.activeWeatherLayers.some(M=>M.key===p.key)?this.activeWeatherLayers=this.activeWeatherLayers.filter(M=>M.key!==p.key):this.activeWeatherLayers.length<6&&p.enabled&&(["png","jpg"].includes(p.type)?this.activeWeatherLayers.forEach(M=>{(M.key==="wind"&&this.showWindFeather||p.key==="current"&&this.showCurrentIsoband)&&(M.particle=!1)}):p.key==="wind"?this.activeWeatherLayers.forEach(M=>{M.key==="current"&&this.showCurrentIsoband&&(M.particle=!1)}):p.key==="current"&&this.activeWeatherLayers.forEach(M=>{M.key==="wind"&&this.showWindFeather&&(M.particle=!1)}),this.activeWeatherLayers=this.activeWeatherLayers.filter(M=>M.type==="json"&&!(["wind","current"].includes(M.key)&&M.particle)),this.activeWeatherLayers.push(p)),this.$emit("weather",this.activeWeatherLayers,this.source),localStorage.setItem(this.activeWeatherLayersCache,JSON.stringify(this.activeWeatherLayers))},handleWeatherLayerCollect(p){var M;!p.collected&&((M=this.layers.weather.filter(z=>z.collected))==null?void 0:M.length)>=6&&(this.layers.weather.filter(z=>z.collected)[0].collected=!1),p.collected=!p.collected,localStorage.setItem(this.collectedLayerCache,JSON.stringify(this.layers.weather)),this.$emit("handleToggleVersion")},handleToggleWindParticle(){!this.showWindFeather&&this.showWindParticle?this.handleWeatherLayerPick({weight:1,name:"Wind",key:"wind",enabled:!0,type:"json",particle:!0}):(this.showCurrentParticle&&(this.$emit("toggleCurrentParticle",!1),this.showCurrentIsoband||(this.activeWeatherLayers=this.activeWeatherLayers.filter(p=>p.key!=="current"),localStorage.setItem(this.activeWeatherLayersCache,JSON.stringify(this.activeWeatherLayers)))),this.$emit("toggleWindParticle",!this.showWindParticle))},handleToggleWindFeather(){this.showWindFeather&&!this.showWindParticle&&this.handleWeatherLayerPick({weight:1,name:"Wind",key:"wind",enabled:!0,type:"json",particle:!0}),this.$emit("toggleWindFeather",!this.showWindFeather),localStorage.setItem(this.windFeatherCache,!this.showWindFeather)},handleToggleCurrentParticle(){!this.showCurrentIsoband&&this.showCurrentParticle?this.handleWeatherLayerPick({weight:96,name:"Current",key:"current",vendor:"cmems",merge:!0,h5:!0,enabled:!0}):(this.showWindParticle&&(this.$emit("toggleWindParticle",!1),this.showWindFeather||(this.activeWeatherLayers=this.activeWeatherLayers.filter(p=>p.key!=="wind"),localStorage.setItem(this.activeWeatherLayersCache,JSON.stringify(this.activeWeatherLayers)))),this.$emit("toggleCurrentParticle",!this.showCurrentParticle))},handleToggleCurrentIsoband(){this.showCurrentIsoband&&!this.showCurrentParticle&&this.handleWeatherLayerPick({weight:96,name:"Current",key:"current",vendor:"cmems",merge:!0,h5:!0,enabled:!0}),this.$emit("toggleCurrentIsoband",!this.showCurrentIsoband),localStorage.setItem(this.currentIsobandCache,!this.showCurrentIsoband)},handleOtherLayerPick(p){this.activeOtherLayers.some(M=>M.key===p.key)?this.activeOtherLayers=this.activeOtherLayers.filter(M=>M.key!==p.key):p.enabled&&this.activeOtherLayers.push(p),localStorage.setItem(this.activeOtherLayersCache,JSON.stringify(this.activeOtherLayers)),this.$emit("other",this.activeOtherLayers)},handleMenuToggle(){this.$emit("layerToggle",!this.layerToggle)},toggleAutoActive(){this.autoActive=!this.autoActive,localStorage.setItem(this.autoActiveCache,this.autoActive),this.autoActive?this.$emit("weather",this.activeWeatherLayers,this.source):this.$emit("weather",[],this.source)},handleCoordToggle(){this.showCoord=!this.showCoord,this.$emit("coordinate",this.showCoord)},handlePointToggle(){this.isLogin?(this.showPoint=!this.showPoint,this.$emit("point",this.showPoint)):this.$emit("handleToggleVersion")},handleMeasureToggle(){this.showMeasure=!this.showMeasure,this.$emit("measure",this.showMeasure)},handle3DToggle(){this.show3d=!this.show3d,this.$emit("3d",this.show3d)}}},_0={class:"idm-gl3-layer"},S0={class:"bar-item layer-bars"},x0={class:"bar-item tool-bars"},v0={class:"flex-between"},k0={key:0,class:"iconfont active"},P0={key:1,class:"iconfont"},D0=["onClick"],I0=["onClick"],V0={key:0,class:"flex-start"},j0={key:1,class:"flex-start"},F0={class:"header-box flex-between"},H0={class:"weather-layers card-bg"},U0={class:"layers-title flex-between"},G0={key:0,class:"iconfont active"},K0={key:1,class:"iconfont"},J0={class:"layers-body"},Q0={class:"flex-start"},Z0=["onClick"],$0=["onClick"],Y0={key:0,class:"flex-start"},M1={key:1,class:"flex-start"},b1=["onClick"],z1={key:0,class:"iconfont bookmark-icon active"},p1={key:1,class:"iconfont bookmark-icon inactive"},O1={class:"other-layers card-bg"},o1={class:"layers-body"},c1=["onClick"],e1={class:"flex-start"},A1={class:"switch flex-center"},t1={key:0,class:"iconfont active"},a1={key:1,class:"iconfont"},q1={class:"source-layers card-bg"},i1={class:"layers-body"};function r1(p,M,z,o,O,c){const e=b.resolveComponent("ElTooltip"),t=b.resolveComponent("ElRadio"),q=b.resolveComponent("ElRadioGroup"),r=b.resolveComponent("ElScrollbar");return b.openBlock(),b.createElementBlock("div",_0,[b.createElementVNode("div",{class:"menu-bar-box",style:b.normalizeStyle({top:z.top+10+"px",right:O.right+"px"})},[b.createElementVNode("div",S0,[b.createVNode(e,{placement:"left",effect:"light",content:"Menu","show-after":1e3},{default:b.withCtx(()=>[b.createElementVNode("div",{class:b.normalizeClass(z.layerToggle?"menu-icon active":"menu-icon"),onClick:M[0]||(M[0]=(...a)=>c.handleMenuToggle&&c.handleMenuToggle(...a))},M[17]||(M[17]=[b.createElementVNode("span",{class:"iconfont"},"",-1)]),2)]),_:1})])],4),b.createElementVNode("div",{class:"menu-bar-box",style:b.normalizeStyle({top:z.top+160+"px",right:O.right+"px"})},[b.createElementVNode("div",x0,[b.createVNode(e,{placement:"left",effect:"light",content:"Measure","show-after":1e3},{default:b.withCtx(()=>[b.createElementVNode("div",{class:b.normalizeClass(O.showMeasure?"menu-icon active":"menu-icon"),onClick:M[1]||(M[1]=(...a)=>c.handleMeasureToggle&&c.handleMeasureToggle(...a))},M[18]||(M[18]=[b.createElementVNode("span",{class:"iconfont"},"",-1)]),2)]),_:1}),b.createVNode(e,{placement:"left",effect:"light",content:"Point Meteo","show-after":1e3},{default:b.withCtx(()=>[b.createElementVNode("div",{class:b.normalizeClass(O.showPoint?"menu-icon active":"menu-icon"),onClick:M[2]||(M[2]=(...a)=>c.handlePointToggle&&c.handlePointToggle(...a))},M[19]||(M[19]=[b.createElementVNode("span",{class:"iconfont"},"",-1)]),2)]),_:1}),b.createVNode(e,{placement:"left",effect:"light",content:"Grid","show-after":1e3},{default:b.withCtx(()=>[b.createElementVNode("div",{class:b.normalizeClass(O.showCoord?"menu-icon active":"menu-icon"),onClick:M[3]||(M[3]=(...a)=>c.handleCoordToggle&&c.handleCoordToggle(...a))},M[20]||(M[20]=[b.createElementVNode("span",{class:"iconfont"},"",-1)]),2)]),_:1}),b.createVNode(e,{placement:"left",effect:"light",content:"3D","show-after":1e3},{default:b.withCtx(()=>[b.createElementVNode("div",{class:b.normalizeClass(O.show3d?"menu-icon active":"menu-icon"),onClick:M[4]||(M[4]=(...a)=>c.handle3DToggle&&c.handle3DToggle(...a))},M[21]||(M[21]=[b.createElementVNode("span",{class:"iconfont"},"",-1)]),2)]),_:1})])],4),c.hasCollectedLayers?(b.openBlock(),b.createElementBlock("div",{key:0,class:"active-layers",style:b.normalizeStyle({right:O.right+"px",bottom:"100px"})},[b.createElementVNode("div",v0,[M[22]||(M[22]=b.createElementVNode("div",{style:{margin:"2px 5px"}},"My Favorites",-1)),b.createElementVNode("div",{class:"switch flex-center",style:{"font-size":"28px","margin-right":"0"},onClick:M[5]||(M[5]=(...a)=>c.toggleAutoActive&&c.toggleAutoActive(...a))},[O.autoActive?(b.openBlock(),b.createElementBlock("i",k0,"")):(b.openBlock(),b.createElementBlock("i",P0,""))])]),(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(O.layers.weather.filter(a=>a.collected),a=>(b.openBlock(),b.createElementBlock("div",{key:a.key,class:b.normalizeClass(c.computeLayerClass(a,O.activeWeatherLayers))},[b.createElementVNode("div",{class:"checkbox",onClick:i=>c.handleWeatherLayerPick(a)},null,8,D0),b.createElementVNode("span",{class:"name",onClick:i=>c.handleWeatherLayerPick(a)},b.toDisplayString(a.name),9,I0),a.key==="wind"&&O.activeWeatherLayers.some(i=>i.key===a.key)?(b.openBlock(),b.createElementBlock("div",V0,[b.createElementVNode("i",{class:b.normalizeClass(["iconfont sub-layer-icon",z.showWindParticle?"active":""]),onClick:M[6]||(M[6]=i=>c.handleToggleWindParticle())},"",2),b.createElementVNode("i",{class:b.normalizeClass(["iconfont sub-layer-icon",z.showWindFeather?"active":""]),onClick:M[7]||(M[7]=i=>c.handleToggleWindFeather())},"",2)])):b.createCommentVNode("",!0),a.key==="current"&&O.activeWeatherLayers.some(i=>i.key===a.key)?(b.openBlock(),b.createElementBlock("div",j0,[b.createElementVNode("i",{class:b.normalizeClass(["iconfont sub-layer-icon",z.showCurrentParticle?"active":""]),onClick:M[8]||(M[8]=i=>c.handleToggleCurrentParticle())},"",2),b.createElementVNode("i",{class:b.normalizeClass(["iconfont sub-layer-icon",z.showCurrentIsoband?"active":""]),onClick:M[9]||(M[9]=i=>c.handleToggleCurrentIsoband())},"",2)])):b.createCommentVNode("",!0)],2))),128))],4)):b.createCommentVNode("",!0),b.createElementVNode("div",{class:"available-layers flex-center",style:b.normalizeStyle({top:z.top+"px",right:z.layerToggle?"0px":"-240px"})},[b.createElementVNode("div",{class:b.normalizeClass(["list-box",z.layerToggle?"right-bar":""])},[b.createElementVNode("div",F0,[M[23]||(M[23]=b.createElementVNode("div",null,"Layers",-1)),b.createElementVNode("div",{class:"iconfont close-btn",onClick:M[10]||(M[10]=(...a)=>c.handleMenuToggle&&c.handleMenuToggle(...a))},"")]),b.createVNode(r,{style:{flex:"1"}},{default:b.withCtx(()=>[b.createElementVNode("div",H0,[b.createElementVNode("div",U0,[M[24]||(M[24]=b.createElementVNode("div",null,"Weather Layers",-1)),b.createElementVNode("div",{class:"switch flex-center",style:{"margin-right":"0"},onClick:M[11]||(M[11]=(...a)=>c.toggleAutoActive&&c.toggleAutoActive(...a))},[O.autoActive?(b.openBlock(),b.createElementBlock("i",G0,"")):(b.openBlock(),b.createElementBlock("i",K0,""))])]),b.createElementVNode("div",J0,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(O.layers.weather,a=>(b.openBlock(),b.createElementBlock(b.Fragment,{key:a.key},[a.hide?b.createCommentVNode("",!0):(b.openBlock(),b.createElementBlock("div",{key:0,class:b.normalizeClass(c.computeLayerClass(a,O.activeWeatherLayers))},[b.createElementVNode("div",Q0,[b.createElementVNode("div",{class:"checkbox",onClick:i=>c.handleWeatherLayerPick(a)},null,8,Z0),b.createElementVNode("span",{class:"name",onClick:i=>c.handleWeatherLayerPick(a)},b.toDisplayString(a.name),9,$0),a.key==="wind"&&O.activeWeatherLayers.some(i=>i.key===a.key)?(b.openBlock(),b.createElementBlock("div",Y0,[b.createElementVNode("i",{class:b.normalizeClass(["iconfont sub-layer-icon",z.showWindParticle?"active":""]),onClick:M[12]||(M[12]=i=>c.handleToggleWindParticle())},"",2),b.createElementVNode("i",{class:b.normalizeClass(["iconfont sub-layer-icon",z.showWindFeather?"active":""]),onClick:M[13]||(M[13]=i=>c.handleToggleWindFeather())},"",2)])):b.createCommentVNode("",!0),a.key==="current"&&O.activeWeatherLayers.some(i=>i.key===a.key)?(b.openBlock(),b.createElementBlock("div",M1,[b.createElementVNode("i",{class:b.normalizeClass(["iconfont sub-layer-icon",z.showCurrentParticle?"active":""]),onClick:M[14]||(M[14]=i=>c.handleToggleCurrentParticle())},"",2),b.createElementVNode("i",{class:b.normalizeClass(["iconfont sub-layer-icon",z.showCurrentIsoband?"active":""]),onClick:M[15]||(M[15]=i=>c.handleToggleCurrentIsoband())},"",2)])):b.createCommentVNode("",!0)]),b.createElementVNode("div",{onClick:i=>c.handleWeatherLayerCollect(a)},[a.collected?(b.openBlock(),b.createElementBlock("i",z1,"")):(b.openBlock(),b.createElementBlock("i",p1,""))],8,b1)],2))],64))),128)),M[25]||(M[25]=b.createElementVNode("div",{class:"tip flex-start"},[b.createElementVNode("i",{class:"iconfont bookmark-icon",style:{"align-self":"flex-start",padding:"5px 5px 0 0"}},""),b.createElementVNode("div",null,"You can add the layers to your favorites. (Max 6)")],-1))])]),b.createElementVNode("div",O1,[M[26]||(M[26]=b.createElementVNode("div",{class:"layers-title"},"Other Layers",-1)),b.createElementVNode("div",o1,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(O.layers.other,a=>{var i;return b.openBlock(),b.createElementBlock("div",{key:a.key,class:b.normalizeClass(["layer flex-between",c.computeLayerClass(a,O.activeOtherLayers)]),onClick:f=>c.handleOtherLayerPick(a)},[b.createElementVNode("div",e1,[b.createElementVNode("div",A1,[(i=c.computeLayerClass(a,O.activeOtherLayers))!=null&&i.includes("active")?(b.openBlock(),b.createElementBlock("i",t1,"")):(b.openBlock(),b.createElementBlock("i",a1,""))]),b.createElementVNode("span",null,b.toDisplayString(a.name),1)])],10,c1)}),128))])]),b.createElementVNode("div",q1,[M[29]||(M[29]=b.createElementVNode("span",{class:"layers-title"},"Forecast Model",-1)),b.createElementVNode("div",i1,[b.createVNode(q,{modelValue:O.source,"onUpdate:modelValue":M[16]||(M[16]=a=>O.source=a),class:"layer-radio flex-col-center-start"},{default:b.withCtx(()=>[b.createVNode(t,{value:"GFS"},{default:b.withCtx(()=>M[27]||(M[27]=[b.createTextVNode("GFS")])),_:1}),b.createVNode(t,{value:"CMEMS"},{default:b.withCtx(()=>M[28]||(M[28]=[b.createTextVNode("CMEMS")])),_:1})]),_:1},8,["modelValue"])])])]),_:1})],2)],4)])}const n1=S(E0,[["render",r1]]),Tb="",d1={name:"IdmWindBarb",props:{map:{type:Object},wind:{type:Object},current:{type:Object},beforeLayer:{type:String},mapProjection:{type:String},showWindFeather:{type:Boolean,default:!1},showWindParticle:{type:Boolean,default:!1},toggleVersion:{type:Number}},emits:["particle","showWindFeather"],data(){return{source:"wind-barb-source",barbs:[0,2,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105],empty:y.featureCollection([]),right:10,bottom:125,windBarbLoaded:!1}},watch:{"wind.version":{handler(){var p;(p=this.wind)!=null&&p.active&&this.showWindFeather?this.handleRender():this.handleClear()},deep:!0},showWindParticle:{handler(){this.handleParticle()}},showWindFeather:{handler(){this.handleToggle()}}},methods:{handleParticle(){this.$emit("particle",{particle:this.showWindParticle,key:"wind",weight:1})},handleRender(){var p,M,z,o;if(!this.map)setTimeout(()=>{this.handleRender()},500);else if(this.wind){const O=new Date().valueOf();let c=0,e=0,t=this.empty;if((p=this.wind)!=null&&p.active&&(t=(M=this.wind)==null?void 0:M.data),(z=this.map)!=null&&z.getSource(this.source))(o=this.map)==null||o.getSource(this.source).setData(t),e=new Date().valueOf()-(O+c),console.log("[wind] update elapsed: ",e,", total: ",c+=e);else{this.map.addSource(this.source,{type:"geojson",data:t});for(let q=0;q<(this.barbs??[]).length-1;q++){const r=(this.barbs??[])[q]||0,a=(this.barbs??[])[q+1]||0,i=r<10?`00${r}kts`:r<100?`0${r}kts`:`${r}kts`;this.map.addLayer({id:i,type:"symbol",filter:["all",[">=","spd",r],["<","spd",a]],source:this.source,layout:{"symbol-placement":"point","icon-image":i,"icon-size":.14,"icon-offset":[0,-20],"icon-allow-overlap":!0,"icon-rotation-alignment":"map","icon-rotate":{property:"val",stops:[[0,0],[360,360]]}},paint:{"icon-opacity":1,"text-color":"#222"}},this.beforeLayer)}this.windBarbLoaded=!0,e=new Date().valueOf()-(O+c),console.log("[wind] add elapsed: ",e,", total: ",c+=e)}}},handleToggle(){if(!this.windBarbLoaded)this.handleRender();else for(const p of this.barbs??[]){const M=p<10?`00${p}kts`:p<100?`0${p}kts`:`${p}kts`;this.map.getLayer(M)&&this.map.setLayoutProperty(M,"visibility",this.showWindFeather?"visible":"none")}},handleClear(){for(const p of this.barbs??[]){const M=p<10?`00${p}kts`:p<100?`0${p}kts`:`${p}kts`;this.map.getLayer(M)&&this.map.removeLayer(M)}this.map.getSource(this.source)&&this.map.removeSource(this.source),this.windBarbLoaded=!1}}},s1={key:0};function W1(p,M,z,o,O,c){var e;return(e=z.wind)!=null&&e.active?(b.openBlock(),b.createElementBlock("div",s1)):b.createCommentVNode("",!0)}const l1=S(d1,[["render",W1]]);class l0{constructor(M){V(this,"map");V(this,"mercator");V(this,"rampColorLayer");V(this,"rampColorSource");V(this,"particleLayer");V(this,"particleSource");V(this,"rampColorCanvas");V(this,"particleCanvas");V(this,"ratio");this.map=M,this.mercator=new w0,this.rampColorLayer="ramp-color-layer",this.rampColorSource="ramp-color-source",this.particleLayer="particle-layer",this.particleSource="particle-source",this.rampColorCanvas=document.createElement("canvas"),this.particleCanvas=document.createElement("canvas"),this.ratio=window.devicePixelRatio}convertNLng(M,z=0){return M>180?this.convertNLng(M-360,z+1):M<-180?this.convertNLng(M+360,z+1):[M,z]}getBoundLngLat(){const M=this.map.getBounds();return[[M._sw.lng,M._ne.lat],[M._ne.lng,M._ne.lat],[M._ne.lng,M._sw.lat],[M._sw.lng,M._sw.lat]]}getBoundPixel(){const M=this.map.getBounds(),z=this.map.getZoom()+1,o=[M._ne.lng,M._ne.lat],O=[M._sw.lng,M._sw.lat],[c,e]=this.convertNLng(o[0]),[t,q]=this.convertNLng(O[0]),[r,a]=this.mercator.px([c,o[1]],z),[i,f]=this.mercator.px([t,O[1]],z),n=Math.round(this.mercator.size*Math.pow(2,z)*(e+q));return[i,f,r+n,a]}getBoundRange(){const M=this.map.getZoom()+1,z=this.mercator.size*Math.pow(2,M),o=this.getBoundPixel();return[o[0]/z,o[2]/z,o[3]/z,o[1]/z]}getWorldCopy(M,z){const o=2**z,[O,c,e,t]=M.map(a=>~~(a/(o*256))),q=[];for(let a=t;a<=c;a++)for(let i=O;i<=e;i++)q.push([i,a]);return q.map(a=>{const i=2**z*256;return[a[0]*i,a[1]*i,i]})}resize(){let M=this.map.getSource(this.rampColorSource);M.setCoordinates(this.getBoundLngLat()),M=this.map.getSource(this.particleSource),M.setCoordinates(this.getBoundLngLat()),this.rampColorCanvas.width=this.map._canvas.clientWidth,this.rampColorCanvas.height=this.map._canvas.clientHeight,this.particleCanvas.width=this.map._canvas.clientWidth,this.particleCanvas.height=this.map._canvas.clientHeight}toggle(M){const z=this.map.getLayoutProperty(this.rampColorLayer,"visibility"),o=M?"visible":"none";z!==o&&this.map.setLayoutProperty(this.rampColorLayer,"visibility",o)}toggleParticle(M){const z=this.map.getLayoutProperty(this.particleLayer,"visibility"),o=M?"visible":"none";z!==o&&this.map.setLayoutProperty(this.particleLayer,"visibility",o)}}class r0{createShader(M,z,o){const O=M.createShader(z);if(O&&(M.shaderSource(O,o),M.compileShader(O),!M.getShaderParameter(O,M.COMPILE_STATUS)))throw new Error(M.getShaderInfoLog(O)||"error happened while create shader...");return O}createTexture(M,z,o,O,c,e,t){const q=M.createTexture();return M.bindTexture(M.TEXTURE_2D,q),M.texParameteri(M.TEXTURE_2D,M.TEXTURE_MIN_FILTER,z),M.texParameteri(M.TEXTURE_2D,M.TEXTURE_MAG_FILTER,o),M.texParameteri(M.TEXTURE_2D,M.TEXTURE_WRAP_S,O),M.texParameteri(M.TEXTURE_2D,M.TEXTURE_WRAP_T,O),c instanceof Uint8Array?M.texImage2D(M.TEXTURE_2D,0,M.RGBA,e,t,0,M.RGBA,M.UNSIGNED_BYTE,c):M.texImage2D(M.TEXTURE_2D,0,M.RGBA,M.RGBA,M.UNSIGNED_BYTE,c),M.bindTexture(M.TEXTURE_2D,null),q}createDataBuffer(M,z,o){if(M){const O=M.createBuffer();return z==="array"?(M.bindBuffer(M.ARRAY_BUFFER,O),o&&M.bufferData(M.ARRAY_BUFFER,o,M.STATIC_DRAW)):z==="element"&&(M.bindBuffer(M.ELEMENT_ARRAY_BUFFER,O),o&&M.bufferData(M.ELEMENT_ARRAY_BUFFER,o,M.STATIC_DRAW)),O}return null}createProgram(M,z,o){const O=M.createProgram(),c=this.createShader(M,M.VERTEX_SHADER,z),e=this.createShader(M,M.FRAGMENT_SHADER,o);if(O&&c&&e&&(M.attachShader(O,c),M.attachShader(O,e),M.linkProgram(O),!M.getProgramParameter(O,M.LINK_STATUS)))throw new Error(M.getProgramInfoLog(O)||"error happened while creating ramp color program");return O}createProgramWrapper(M,z,o){const O=this.createProgram(M,z,o);if(O){const c={program:O},e=M.getProgramParameter(O,M.ACTIVE_ATTRIBUTES);for(let q=0;q<e;q++){const r=M.getActiveAttrib(O,q);c[r.name]=M.getAttribLocation(O,r.name)}const t=M.getProgramParameter(O,M.ACTIVE_UNIFORMS);for(let q=0;q<t;q++){const r=M.getActiveUniform(O,q);c[r.name]=M.getUniformLocation(O,r.name)}return c}}setup(M,z,o=!1,O,c){const e=document.createElement("canvas");e.width=256,e.height=1;const t=e.getContext("2d");if(t&&M){const q=t==null?void 0:t.createLinearGradient(0,0,256,0);return z.forEach(([r,a])=>{q.addColorStop(r,a)}),t.fillStyle=q,t.fillRect(0,0,256,1),{canvas:e,texture:this.createTexture(M,M.LINEAR,M.LINEAR,M.CLAMP_TO_EDGE,o?new Uint8Array(t.getImageData(0,0,256,1).data):e,O,c)}}}setupParticle(M,z=1e3){const o=Math.ceil(Math.sqrt(z)),O=o*o,c=new Uint8Array(O*4);for(let a=0;a<c.length;a++)c[a]=Math.floor(Math.random()*256);const e=this.createTexture(M,M.NEAREST,M.NEAREST,M.CLAMP_TO_EDGE,c,o,o),t=this.createTexture(M,M.NEAREST,M.NEAREST,M.CLAMP_TO_EDGE,c,o,o),q=new Float32Array(O);for(let a=0;a<O;a++)q[a]=a;const r=this.createDataBuffer(M,"array",q);return{resolution:o,total:O,texture0:e,texture1:t,indexBuffer:r}}bind(M,z,o){const O=this.createProgram(M,z,o);if(O){const c=this.createDataBuffer(M,"array",void 0),e=M.getAttribLocation(O,"a_position");M.enableVertexAttribArray(e),M.vertexAttribPointer(e,2,M.FLOAT,!1,0,0);const t=new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]);this.createDataBuffer(M,"array",t);const q=M.getAttribLocation(O,"a_texCoord");return M.enableVertexAttribArray(q),M.vertexAttribPointer(q,2,M.FLOAT,!1,0,0),{program:O,aPositionBuffer:c}}return{}}bindParticle(M,z,o,O,c,e){const t=this.createProgramWrapper(M,z,o),q=this.createProgramWrapper(M,O,c),r=this.createProgramWrapper(M,O,e),a=this.createDataBuffer(M,"array",new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1])),i=M.createFramebuffer();return{particle:t,screen:q,update:r,quadBuffer:a,frameBuffer:i}}draw(M,z,o,O,c,e,t){var q,r;if(z&&o){M.resize(),z==null||z.viewport(0,0,(q=z==null?void 0:z.canvas)==null?void 0:q.width,(r=z==null?void 0:z.canvas)==null?void 0:r.height),z.clearColor(0,0,0,0),z.clear(z.COLOR_BUFFER_BIT|z.DEPTH_BUFFER_BIT);try{const a=z.getUniformLocation(o,"u_resolution"),i=z.getUniformLocation(o,"u_image"),f=z.getUniformLocation(o,"u_color");if(z.useProgram(o),z.uniform2f(a,z.canvas.width*M.ratio,z.canvas.height*M.ratio),z.activeTexture(z.TEXTURE0),z.bindTexture(z.TEXTURE_2D,O),z.uniform1i(i,0),z.activeTexture(z.TEXTURE1),z.bindTexture(z.TEXTURE_2D,c),z.uniform1i(f,1),t!=null&&t.uvRange&&(t!=null&&t.sRange)){const d=z.getUniformLocation(o,"u_range_u_v"),h=z.getUniformLocation(o,"u_range_s");z.uniform2f(d,t.uvRange[0],t.uvRange[1]),z.uniform2f(h,t.sRange[0],t.sRange[1])}const n=M.getBoundPixel(),R=M.map.getZoom()+1,l=M.getWorldCopy(n,R);for(const d of l){const h=(d[0]-n[0])*M.ratio,L=(d[1]-n[3])*M.ratio,B=d[2]*M.ratio,[T,N,P,m]=[h,B+h,L,B+L],X=new Float32Array([T,P,N,P,T,m,T,m,N,P,N,m]);z.bindBuffer(z.ARRAY_BUFFER,e),z.bufferData(z.ARRAY_BUFFER,X,z.STATIC_DRAW),z.drawArrays(z.TRIANGLES,0,6)}}catch(a){console.log(`render failed...${a}`)}}}drawParticle(M,z,o,O,c){var e,t;z&&(z==null||z.viewport(0,0,(e=z==null?void 0:z.canvas)==null?void 0:e.width,(t=z==null?void 0:z.canvas)==null?void 0:t.height),z.disable(z.DEPTH_TEST),z.disable(z.STENCIL_TEST),z.activeTexture(z.TEXTURE0),z.bindTexture(z.TEXTURE_2D,o),z.activeTexture(z.TEXTURE1),z.bindTexture(z.TEXTURE_2D,O.texture0),this.renderScreen(M,z,O,c),this.updateParticles(M,z,O,c))}renderScreen(M,z,o,O){z.bindFramebuffer(z.FRAMEBUFFER,o.frameBuffer),z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,o.screenTexture,0),z.viewport(0,0,z.canvas.width,z.canvas.height),this.renderScreenTexture(z,o.backgroundTexture,o.screen,o.quadBuffer,.95),this.renderParticles(M,z,o,O),z.bindFramebuffer(z.FRAMEBUFFER,null),this.renderScreenTexture(z,o.screenTexture,o.screen,o.quadBuffer,1);const c=o.backgroundTexture;o.backgroundTexture=o.screenTexture,o.screenTexture=c}renderScreenTexture(M,z,o,O,c){M&&(M.useProgram(o.program),M.bindBuffer(M.ARRAY_BUFFER,O),M.enableVertexAttribArray(o.a_pos),M.vertexAttribPointer(o.a_pos,2,M.FLOAT,!1,0,0),M.activeTexture(M.TEXTURE2),M.bindTexture(M.TEXTURE_2D,z),M.uniform1i(o.u_screen,2),M.uniform1f(o.u_opacity,c),M.drawArrays(M.TRIANGLES,0,6))}renderParticles(M,z,o,O){if(z){z.useProgram(o.particle.program),z.bindBuffer(z.ARRAY_BUFFER,o.indexBuffer),z.enableVertexAttribArray(o.particle.a_index),z.vertexAttribPointer(o.particle.a_index,1,z.FLOAT,!1,0,0),z.activeTexture(z.TEXTURE2),z.bindTexture(z.TEXTURE_2D,o.color.texture),z.uniform1i(o.particle.u_factor,0),z.uniform1i(o.particle.u_particles,1),z.uniform1i(o.particle.u_color_ramp,2),z.uniform1f(o.particle.u_particles_resolution,o.resolution*M.ratio),z.uniform1f(o.particle.u_point,M.ratio);const c=M.getBoundRange();z.uniform4f(o.particle.u_viewport,c[0],c[1],c[2],c[3]),z.uniform2f(o.particle.u_factor_min,O.uvRange[0],O.uvRange[0]),z.uniform2f(o.particle.u_factor_max,O.uvRange[1],O.uvRange[1]),z.drawArrays(z.POINTS,0,o.total)}}updateParticles(M,z,o,O){var e,t;if(z){z.bindFramebuffer(z.FRAMEBUFFER,o.frameBuffer),z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,o.texture1,0),z.viewport(0,0,o.resolution,o.resolution),z.useProgram(o.update.program),z.bindBuffer(z.ARRAY_BUFFER,o.quadBuffer),z.enableVertexAttribArray(o.update.a_pos),z.vertexAttribPointer(o.update.a_pos,2,z.FLOAT,!1,0,0),z.uniform1i(o.update.u_factor,0),z.uniform1i(o.update.u_particles,1);const q=M.getBoundRange();z.uniform4f(o.update.u_viewport,q[0],q[1],q[2],q[3]),z.uniform1f(o.update.u_rand_seed,Math.random()),z.uniform2f(o.update.u_factor_res,(e=o==null?void 0:o.image)==null?void 0:e.width,(t=o==null?void 0:o.image)==null?void 0:t.height),z.uniform2f(o.update.u_factor_min,O.uvRange[0],O.uvRange[0]),z.uniform2f(o.update.u_factor_max,O.uvRange[1],O.uvRange[1]),z.uniform1f(o.update.u_speed_factor,O.speedFactor*M.ratio),z.uniform1f(o.update.u_drop_rate,O.dropRate),z.uniform1f(o.update.u_drop_rate_bump,O.dropRateBump),z.drawArrays(z.TRIANGLES,0,6)}const c=o.texture0;o.texture0=o.texture1,o.texture1=c}resize(M,z){M.resize();const o=new Uint8Array(z.canvas.width*z.canvas.height*4).fill(0,0,z.canvas.width*z.canvas.height*4),O=this.createTexture(z,z.NEAREST,z.NEAREST,z.CLAMP_TO_EDGE,o,z.canvas.width,z.canvas.height),c=this.createTexture(z,z.NEAREST,z.NEAREST,z.CLAMP_TO_EDGE,o,z.canvas.width,z.canvas.height);return{screenTexture:O,backgroundTexture:c}}async loadImg(M){return new Promise(z=>{const o=new Blob([M],{type:M.type}),O=URL.createObjectURL(o),c=new Image;c.crossOrigin="anonymous",c.src=O,c.onload=()=>z(c)})}}class G{}V(G,"vertexSchema",`
1
+ (function(k,U){typeof exports=="object"&&typeof module<"u"?U(exports,require("@idm-plugin/tag"),require("vue"),require("@turf/turf"),require("@mapbox/sphericalmercator"),require("moment"),require("mapbox-gl"),require("@idm-plugin/geo"),require("@idm-plugin/meteo"),require("axios")):typeof define=="function"&&define.amd?define(["exports","@idm-plugin/tag","vue","@turf/turf","@mapbox/sphericalmercator","moment","mapbox-gl","@idm-plugin/geo","@idm-plugin/meteo","axios"],U):(k=typeof globalThis<"u"?globalThis:k||self,U(k["idm-gl"]={},k["@idm-plugin/tag"],k.Vue,k["@turf/turf"],k["@mapbox/sphericalmercator"],k.moment,k["mapbox-gl"],k["@idm-plugin/geo"],k["@idm-plugin/meteo"],k.axios))})(this,function(k,U,b,T0,w0,D,c0,C,u0,e0){"use strict";var Bb=Object.defineProperty;var gb=(k,U,b)=>U in k?Bb(k,U,{enumerable:!0,configurable:!0,writable:!0,value:b}):k[U]=b;var V=(k,U,b)=>(gb(k,typeof U!="symbol"?U+"":U,b),b);function C0(p){const M=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(p){for(const z in p)if(z!=="default"){const o=Object.getOwnPropertyDescriptor(p,z);Object.defineProperty(M,z,o.get?o:{enumerable:!0,get:()=>p[z]})}}return M.default=p,Object.freeze(M)}const y=C0(T0),yb="",Xb="",S=(p,M)=>{const z=p.__vccOpts||p;for(const[o,O]of M)z[o]=O;return z},E0={name:"IdmGlLayer",props:{map:{type:Object},mapProjection:{type:String},top:{type:Number,default:60},layerToggle:{type:Boolean,default:!1},toggleVersion:{type:Number},isLogin:{type:Boolean,default:void 0},showWindFeather:{type:Boolean,default:void 0},showWindParticle:{type:Boolean,default:void 0},showCurrentIsoband:{type:Boolean,default:void 0},showCurrentParticle:{type:Boolean,default:void 0}},emits:["weather","other","toggleWindParticle","toggleWindFeather","toggleCurrentParticle","toggleCurrentIsoband","coordinate","measure","point","3d","layerToggle","handleToggleVersion","login"],data(){return{autoActive:!0,layers:{weather:[...U.LayerHelper.WEATHER_LAYERS.filter(p=>!["swell-height","swell-direction","current-direction","current-speed"].includes(p.key))],other:[...U.LayerHelper.OTHER_LAYERS.filter(p=>p.key!=="world12nm"&&p.enabled)]},activeWeatherLayers:[],activeOtherLayers:[],autoActiveCache:"autoActiveCache",activeWeatherLayersCache:"activeWeatherLayersCache",activeOtherLayersCache:"activeOtherLayersCache",collectedLayerCache:"collectedLayerCache",sourceCache:"defaultSourceCache",windFeatherCache:"windFeatherCache",currentIsobandCache:"currentIsobandCache",showCoord:!1,showMeasure:!1,showPoint:!1,show3d:!1,version:{v:"0.0.7",k:"glCacheVersion"},source:"",right:10,rampColorLayers:["visibility","precip3h","temp","water-temp","arctic"]}},computed:{computeLayerClass(){return function(p,M){var o;let z="layer flex-between";return M.some(O=>O.key===p.key)&&(z=z+" active"),(!p.enabled||(o=this.layers.weather)!=null&&o.some(O=>O.key===p.key)&&!this.autoActive||this.rampColorLayers.includes(p.key)&&this.mapProjection==="globe")&&(z=z+" disabled"),z}},hasCollectedLayers(){var p;return((p=this.layers.weather.filter(M=>M.collected))==null?void 0:p.length)>0}},watch:{toggleVersion:{handler(){this.$nextTick(()=>{var p;this.right=(((p=document.getElementsByClassName("right-bar")[0])==null?void 0:p.clientWidth)||0)+10})}},source:{handler(p,M){p&&M&&p!==M&&this.handleConfirm()}}},mounted(){this.fetchCache(),this.handleConfirm()},methods:{fetchCache(){const p=localStorage.getItem(this.version.k);this.version.v!==p&&(localStorage.removeItem(this.activeWeatherLayersCache),localStorage.removeItem(this.collectedLayerCache),localStorage.removeItem(this.activeOtherLayersCache),localStorage.removeItem(this.windFeatherCache),localStorage.removeItem(this.currentIsobandCache),localStorage.setItem(this.version.k,this.version.v));let M=localStorage.getItem(this.autoActiveCache);this.autoActive=M!=="false",M=localStorage.getItem(this.collectedLayerCache);let z=JSON.parse(M||'[{"weight": 16, "name": "Sig Waves", "key": "sig-wave-height", "collected": true},{"weight": 1, "name": "Wind", "key": "wind", "h5": true, "collected": true},{"weight": 96, "name": "Current", "key": "current", "collected": true},{"weight": 6, "name": "Swell", "key": "swell", "collected": true}]');this.layers.weather.forEach(o=>{o.collected=!!z.some(O=>O.key===o.key&&O.collected)}),M=localStorage.getItem(this.activeWeatherLayersCache),M||localStorage.setItem(this.activeWeatherLayersCache,JSON.stringify([{weight:1,name:"Wind",key:"wind",enabled:!0,type:"json",particle:!0},{weight:4096,name:"Pressure",key:"prmsl",enabled:!0,type:"json"},{weight:256,name:"Tropicals",key:"tropicals",enabled:!0,type:"json"}])),M=localStorage.getItem(this.activeWeatherLayersCache),z=JSON.parse(M),this.autoActive&&(this.activeWeatherLayers=[...z]),z.some(o=>o.key==="wind"&&o.particle)&&this.$emit("toggleWindParticle",!0),localStorage.getItem(this.windFeatherCache)==="true"&&this.$emit("toggleWindFeather",!0),z.some(o=>o.key==="current"&&o.particle)&&this.$emit("toggleCurrentParticle",!0),localStorage.getItem(this.currentIsobandCache)==="true"&&this.$emit("toggleCurrentIsoband",!0),M=localStorage.getItem(this.activeOtherLayersCache),z=JSON.parse(M||'[{"weight":4,"name":"ECA Zones","key":"eca-zones","enabled":true,"type":"json"}]'),this.activeOtherLayers=z,M=localStorage.getItem(this.sourceCache),this.source=M||"GFS"},handleConfirm(){this.$emit("weather",this.activeWeatherLayers,this.source),this.$emit("other",this.activeOtherLayers),localStorage.setItem(this.autoActiveCache,this.autoActive),localStorage.setItem(this.sourceCache,this.source)},handleWeatherLayerPick(p){if(this.activeWeatherLayers=JSON.parse(localStorage.getItem(this.activeWeatherLayersCache)),this.rampColorLayers.includes(p.key)&&this.mapProjection==="globe"||!this.autoActive)return!1;(p.key==="wind"&&!this.showWindFeather||p.key==="current"&&!this.showCurrentIsoband)&&(p.particle=!0),this.activeWeatherLayers.some(M=>M.key===p.key)?this.activeWeatherLayers=this.activeWeatherLayers.filter(M=>M.key!==p.key):this.activeWeatherLayers.length<6&&p.enabled&&(["png","jpg"].includes(p.type)?this.activeWeatherLayers.forEach(M=>{(M.key==="wind"&&this.showWindFeather||p.key==="current"&&this.showCurrentIsoband)&&(M.particle=!1)}):p.key==="wind"?this.activeWeatherLayers.forEach(M=>{M.key==="current"&&this.showCurrentIsoband&&(M.particle=!1)}):p.key==="current"&&this.activeWeatherLayers.forEach(M=>{M.key==="wind"&&this.showWindFeather&&(M.particle=!1)}),this.activeWeatherLayers=this.activeWeatherLayers.filter(M=>M.type==="json"&&!(["wind","current"].includes(M.key)&&M.particle)),this.activeWeatherLayers.push(p)),this.$emit("weather",this.activeWeatherLayers,this.source),localStorage.setItem(this.activeWeatherLayersCache,JSON.stringify(this.activeWeatherLayers))},handleWeatherLayerCollect(p){var M;!p.collected&&((M=this.layers.weather.filter(z=>z.collected))==null?void 0:M.length)>=6&&(this.layers.weather.filter(z=>z.collected)[0].collected=!1),p.collected=!p.collected,localStorage.setItem(this.collectedLayerCache,JSON.stringify(this.layers.weather)),this.$emit("handleToggleVersion")},handleToggleWindParticle(){!this.showWindFeather&&this.showWindParticle?this.handleWeatherLayerPick({weight:1,name:"Wind",key:"wind",enabled:!0,type:"json",particle:!0}):(this.showCurrentParticle&&(this.$emit("toggleCurrentParticle",!1),this.showCurrentIsoband||(this.activeWeatherLayers=this.activeWeatherLayers.filter(p=>p.key!=="current"),localStorage.setItem(this.activeWeatherLayersCache,JSON.stringify(this.activeWeatherLayers)))),this.$emit("toggleWindParticle",!this.showWindParticle))},handleToggleWindFeather(){this.showWindFeather&&!this.showWindParticle&&this.handleWeatherLayerPick({weight:1,name:"Wind",key:"wind",enabled:!0,type:"json",particle:!0}),this.$emit("toggleWindFeather",!this.showWindFeather),localStorage.setItem(this.windFeatherCache,!this.showWindFeather)},handleToggleCurrentParticle(){!this.showCurrentIsoband&&this.showCurrentParticle?this.handleWeatherLayerPick({weight:96,name:"Current",key:"current",vendor:"cmems",merge:!0,h5:!0,enabled:!0}):(this.showWindParticle&&(this.$emit("toggleWindParticle",!1),this.showWindFeather||(this.activeWeatherLayers=this.activeWeatherLayers.filter(p=>p.key!=="wind"),localStorage.setItem(this.activeWeatherLayersCache,JSON.stringify(this.activeWeatherLayers)))),this.$emit("toggleCurrentParticle",!this.showCurrentParticle))},handleToggleCurrentIsoband(){this.showCurrentIsoband&&!this.showCurrentParticle&&this.handleWeatherLayerPick({weight:96,name:"Current",key:"current",vendor:"cmems",merge:!0,h5:!0,enabled:!0}),this.$emit("toggleCurrentIsoband",!this.showCurrentIsoband),localStorage.setItem(this.currentIsobandCache,!this.showCurrentIsoband)},handleOtherLayerPick(p){this.activeOtherLayers.some(M=>M.key===p.key)?this.activeOtherLayers=this.activeOtherLayers.filter(M=>M.key!==p.key):p.enabled&&this.activeOtherLayers.push(p),localStorage.setItem(this.activeOtherLayersCache,JSON.stringify(this.activeOtherLayers)),this.$emit("other",this.activeOtherLayers)},handleMenuToggle(){this.$emit("layerToggle",!this.layerToggle)},toggleAutoActive(){this.autoActive=!this.autoActive,localStorage.setItem(this.autoActiveCache,this.autoActive),this.autoActive?this.$emit("weather",this.activeWeatherLayers,this.source):this.$emit("weather",[],this.source)},handleCoordToggle(){this.showCoord=!this.showCoord,this.$emit("coordinate",this.showCoord)},handlePointToggle(){this.isLogin?(this.showPoint=!this.showPoint,this.$emit("point",this.showPoint)):this.$emit("login")},handleMeasureToggle(){this.showMeasure=!this.showMeasure,this.$emit("measure",this.showMeasure)},handle3DToggle(){this.show3d=!this.show3d,this.$emit("3d",this.show3d)}}},_0={class:"idm-gl3-layer"},S0={class:"bar-item layer-bars"},x0={class:"bar-item tool-bars"},v0={class:"flex-between"},k0={key:0,class:"iconfont active"},P0={key:1,class:"iconfont"},D0=["onClick"],I0=["onClick"],V0={key:0,class:"flex-start"},j0={key:1,class:"flex-start"},F0={class:"header-box flex-between"},H0={class:"weather-layers card-bg"},U0={class:"layers-title flex-between"},G0={key:0,class:"iconfont active"},K0={key:1,class:"iconfont"},J0={class:"layers-body"},Q0={class:"flex-start"},Z0=["onClick"],$0=["onClick"],Y0={key:0,class:"flex-start"},M1={key:1,class:"flex-start"},b1=["onClick"],z1={key:0,class:"iconfont bookmark-icon active"},p1={key:1,class:"iconfont bookmark-icon inactive"},O1={class:"other-layers card-bg"},o1={class:"layers-body"},c1=["onClick"],e1={class:"flex-start"},A1={class:"switch flex-center"},t1={key:0,class:"iconfont active"},a1={key:1,class:"iconfont"},q1={class:"source-layers card-bg"},i1={class:"layers-body"};function r1(p,M,z,o,O,c){const e=b.resolveComponent("ElTooltip"),t=b.resolveComponent("ElRadio"),q=b.resolveComponent("ElRadioGroup"),r=b.resolveComponent("ElScrollbar");return b.openBlock(),b.createElementBlock("div",_0,[b.createElementVNode("div",{class:"menu-bar-box",style:b.normalizeStyle({top:z.top+10+"px",right:O.right+"px"})},[b.createElementVNode("div",S0,[b.createVNode(e,{placement:"left",effect:"light",content:"Menu","show-after":1e3},{default:b.withCtx(()=>[b.createElementVNode("div",{class:b.normalizeClass(z.layerToggle?"menu-icon active":"menu-icon"),onClick:M[0]||(M[0]=(...a)=>c.handleMenuToggle&&c.handleMenuToggle(...a))},M[17]||(M[17]=[b.createElementVNode("span",{class:"iconfont"},"",-1)]),2)]),_:1})])],4),b.createElementVNode("div",{class:"menu-bar-box",style:b.normalizeStyle({top:z.top+160+"px",right:O.right+"px"})},[b.createElementVNode("div",x0,[b.createVNode(e,{placement:"left",effect:"light",content:"Measure","show-after":1e3},{default:b.withCtx(()=>[b.createElementVNode("div",{class:b.normalizeClass(O.showMeasure?"menu-icon active":"menu-icon"),onClick:M[1]||(M[1]=(...a)=>c.handleMeasureToggle&&c.handleMeasureToggle(...a))},M[18]||(M[18]=[b.createElementVNode("span",{class:"iconfont"},"",-1)]),2)]),_:1}),b.createVNode(e,{placement:"left",effect:"light",content:"Point Meteo","show-after":1e3},{default:b.withCtx(()=>[b.createElementVNode("div",{class:b.normalizeClass(O.showPoint?"menu-icon active":"menu-icon"),onClick:M[2]||(M[2]=(...a)=>c.handlePointToggle&&c.handlePointToggle(...a))},M[19]||(M[19]=[b.createElementVNode("span",{class:"iconfont"},"",-1)]),2)]),_:1}),b.createVNode(e,{placement:"left",effect:"light",content:"Grid","show-after":1e3},{default:b.withCtx(()=>[b.createElementVNode("div",{class:b.normalizeClass(O.showCoord?"menu-icon active":"menu-icon"),onClick:M[3]||(M[3]=(...a)=>c.handleCoordToggle&&c.handleCoordToggle(...a))},M[20]||(M[20]=[b.createElementVNode("span",{class:"iconfont"},"",-1)]),2)]),_:1}),b.createVNode(e,{placement:"left",effect:"light",content:"3D","show-after":1e3},{default:b.withCtx(()=>[b.createElementVNode("div",{class:b.normalizeClass(O.show3d?"menu-icon active":"menu-icon"),onClick:M[4]||(M[4]=(...a)=>c.handle3DToggle&&c.handle3DToggle(...a))},M[21]||(M[21]=[b.createElementVNode("span",{class:"iconfont"},"",-1)]),2)]),_:1})])],4),c.hasCollectedLayers?(b.openBlock(),b.createElementBlock("div",{key:0,class:"active-layers",style:b.normalizeStyle({right:O.right+"px",bottom:"100px"})},[b.createElementVNode("div",v0,[M[22]||(M[22]=b.createElementVNode("div",{style:{margin:"2px 5px"}},"My Favorites",-1)),b.createElementVNode("div",{class:"switch flex-center",style:{"font-size":"28px","margin-right":"0"},onClick:M[5]||(M[5]=(...a)=>c.toggleAutoActive&&c.toggleAutoActive(...a))},[O.autoActive?(b.openBlock(),b.createElementBlock("i",k0,"")):(b.openBlock(),b.createElementBlock("i",P0,""))])]),(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(O.layers.weather.filter(a=>a.collected),a=>(b.openBlock(),b.createElementBlock("div",{key:a.key,class:b.normalizeClass(c.computeLayerClass(a,O.activeWeatherLayers))},[b.createElementVNode("div",{class:"checkbox",onClick:i=>c.handleWeatherLayerPick(a)},null,8,D0),b.createElementVNode("span",{class:"name",onClick:i=>c.handleWeatherLayerPick(a)},b.toDisplayString(a.name),9,I0),a.key==="wind"&&O.activeWeatherLayers.some(i=>i.key===a.key)?(b.openBlock(),b.createElementBlock("div",V0,[b.createElementVNode("i",{class:b.normalizeClass(["iconfont sub-layer-icon",z.showWindParticle?"active":""]),onClick:M[6]||(M[6]=i=>c.handleToggleWindParticle())},"",2),b.createElementVNode("i",{class:b.normalizeClass(["iconfont sub-layer-icon",z.showWindFeather?"active":""]),onClick:M[7]||(M[7]=i=>c.handleToggleWindFeather())},"",2)])):b.createCommentVNode("",!0),a.key==="current"&&O.activeWeatherLayers.some(i=>i.key===a.key)?(b.openBlock(),b.createElementBlock("div",j0,[b.createElementVNode("i",{class:b.normalizeClass(["iconfont sub-layer-icon",z.showCurrentParticle?"active":""]),onClick:M[8]||(M[8]=i=>c.handleToggleCurrentParticle())},"",2),b.createElementVNode("i",{class:b.normalizeClass(["iconfont sub-layer-icon",z.showCurrentIsoband?"active":""]),onClick:M[9]||(M[9]=i=>c.handleToggleCurrentIsoband())},"",2)])):b.createCommentVNode("",!0)],2))),128))],4)):b.createCommentVNode("",!0),b.createElementVNode("div",{class:"available-layers flex-center",style:b.normalizeStyle({top:z.top+"px",right:z.layerToggle?"0px":"-240px"})},[b.createElementVNode("div",{class:b.normalizeClass(["list-box",z.layerToggle?"right-bar":""])},[b.createElementVNode("div",F0,[M[23]||(M[23]=b.createElementVNode("div",null,"Layers",-1)),b.createElementVNode("div",{class:"iconfont close-btn",onClick:M[10]||(M[10]=(...a)=>c.handleMenuToggle&&c.handleMenuToggle(...a))},"")]),b.createVNode(r,{style:{flex:"1"}},{default:b.withCtx(()=>[b.createElementVNode("div",H0,[b.createElementVNode("div",U0,[M[24]||(M[24]=b.createElementVNode("div",null,"Weather Layers",-1)),b.createElementVNode("div",{class:"switch flex-center",style:{"margin-right":"0"},onClick:M[11]||(M[11]=(...a)=>c.toggleAutoActive&&c.toggleAutoActive(...a))},[O.autoActive?(b.openBlock(),b.createElementBlock("i",G0,"")):(b.openBlock(),b.createElementBlock("i",K0,""))])]),b.createElementVNode("div",J0,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(O.layers.weather,a=>(b.openBlock(),b.createElementBlock(b.Fragment,{key:a.key},[a.hide?b.createCommentVNode("",!0):(b.openBlock(),b.createElementBlock("div",{key:0,class:b.normalizeClass(c.computeLayerClass(a,O.activeWeatherLayers))},[b.createElementVNode("div",Q0,[b.createElementVNode("div",{class:"checkbox",onClick:i=>c.handleWeatherLayerPick(a)},null,8,Z0),b.createElementVNode("span",{class:"name",onClick:i=>c.handleWeatherLayerPick(a)},b.toDisplayString(a.name),9,$0),a.key==="wind"&&O.activeWeatherLayers.some(i=>i.key===a.key)?(b.openBlock(),b.createElementBlock("div",Y0,[b.createElementVNode("i",{class:b.normalizeClass(["iconfont sub-layer-icon",z.showWindParticle?"active":""]),onClick:M[12]||(M[12]=i=>c.handleToggleWindParticle())},"",2),b.createElementVNode("i",{class:b.normalizeClass(["iconfont sub-layer-icon",z.showWindFeather?"active":""]),onClick:M[13]||(M[13]=i=>c.handleToggleWindFeather())},"",2)])):b.createCommentVNode("",!0),a.key==="current"&&O.activeWeatherLayers.some(i=>i.key===a.key)?(b.openBlock(),b.createElementBlock("div",M1,[b.createElementVNode("i",{class:b.normalizeClass(["iconfont sub-layer-icon",z.showCurrentParticle?"active":""]),onClick:M[14]||(M[14]=i=>c.handleToggleCurrentParticle())},"",2),b.createElementVNode("i",{class:b.normalizeClass(["iconfont sub-layer-icon",z.showCurrentIsoband?"active":""]),onClick:M[15]||(M[15]=i=>c.handleToggleCurrentIsoband())},"",2)])):b.createCommentVNode("",!0)]),b.createElementVNode("div",{onClick:i=>c.handleWeatherLayerCollect(a)},[a.collected?(b.openBlock(),b.createElementBlock("i",z1,"")):(b.openBlock(),b.createElementBlock("i",p1,""))],8,b1)],2))],64))),128)),M[25]||(M[25]=b.createElementVNode("div",{class:"tip flex-start"},[b.createElementVNode("i",{class:"iconfont bookmark-icon",style:{"align-self":"flex-start",padding:"5px 5px 0 0"}},""),b.createElementVNode("div",null,"You can add the layers to your favorites. (Max 6)")],-1))])]),b.createElementVNode("div",O1,[M[26]||(M[26]=b.createElementVNode("div",{class:"layers-title"},"Other Layers",-1)),b.createElementVNode("div",o1,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(O.layers.other,a=>{var i;return b.openBlock(),b.createElementBlock("div",{key:a.key,class:b.normalizeClass(["layer flex-between",c.computeLayerClass(a,O.activeOtherLayers)]),onClick:f=>c.handleOtherLayerPick(a)},[b.createElementVNode("div",e1,[b.createElementVNode("div",A1,[(i=c.computeLayerClass(a,O.activeOtherLayers))!=null&&i.includes("active")?(b.openBlock(),b.createElementBlock("i",t1,"")):(b.openBlock(),b.createElementBlock("i",a1,""))]),b.createElementVNode("span",null,b.toDisplayString(a.name),1)])],10,c1)}),128))])]),b.createElementVNode("div",q1,[M[29]||(M[29]=b.createElementVNode("span",{class:"layers-title"},"Forecast Model",-1)),b.createElementVNode("div",i1,[b.createVNode(q,{modelValue:O.source,"onUpdate:modelValue":M[16]||(M[16]=a=>O.source=a),class:"layer-radio flex-col-center-start"},{default:b.withCtx(()=>[b.createVNode(t,{value:"GFS"},{default:b.withCtx(()=>M[27]||(M[27]=[b.createTextVNode("GFS")])),_:1}),b.createVNode(t,{value:"CMEMS"},{default:b.withCtx(()=>M[28]||(M[28]=[b.createTextVNode("CMEMS")])),_:1})]),_:1},8,["modelValue"])])])]),_:1})],2)],4)])}const n1=S(E0,[["render",r1]]),Tb="",d1={name:"IdmWindBarb",props:{map:{type:Object},wind:{type:Object},current:{type:Object},beforeLayer:{type:String},mapProjection:{type:String},showWindFeather:{type:Boolean,default:!1},showWindParticle:{type:Boolean,default:!1},toggleVersion:{type:Number}},emits:["particle","showWindFeather"],data(){return{source:"wind-barb-source",barbs:[0,2,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105],empty:y.featureCollection([]),right:10,bottom:125,windBarbLoaded:!1}},watch:{"wind.version":{handler(){var p;(p=this.wind)!=null&&p.active&&this.showWindFeather?this.handleRender():this.handleClear()},deep:!0},showWindParticle:{handler(){this.handleParticle()}},showWindFeather:{handler(){this.handleToggle()}}},methods:{handleParticle(){this.$emit("particle",{particle:this.showWindParticle,key:"wind",weight:1})},handleRender(){var p,M,z,o;if(!this.map)setTimeout(()=>{this.handleRender()},500);else if(this.wind){const O=new Date().valueOf();let c=0,e=0,t=this.empty;if((p=this.wind)!=null&&p.active&&(t=(M=this.wind)==null?void 0:M.data),(z=this.map)!=null&&z.getSource(this.source))(o=this.map)==null||o.getSource(this.source).setData(t),e=new Date().valueOf()-(O+c),console.log("[wind] update elapsed: ",e,", total: ",c+=e);else{this.map.addSource(this.source,{type:"geojson",data:t});for(let q=0;q<(this.barbs??[]).length-1;q++){const r=(this.barbs??[])[q]||0,a=(this.barbs??[])[q+1]||0,i=r<10?`00${r}kts`:r<100?`0${r}kts`:`${r}kts`;this.map.addLayer({id:i,type:"symbol",filter:["all",[">=","spd",r],["<","spd",a]],source:this.source,layout:{"symbol-placement":"point","icon-image":i,"icon-size":.14,"icon-offset":[0,-20],"icon-allow-overlap":!0,"icon-rotation-alignment":"map","icon-rotate":{property:"val",stops:[[0,0],[360,360]]}},paint:{"icon-opacity":1,"text-color":"#222"}},this.beforeLayer)}this.windBarbLoaded=!0,e=new Date().valueOf()-(O+c),console.log("[wind] add elapsed: ",e,", total: ",c+=e)}}},handleToggle(){if(!this.windBarbLoaded)this.handleRender();else for(const p of this.barbs??[]){const M=p<10?`00${p}kts`:p<100?`0${p}kts`:`${p}kts`;this.map.getLayer(M)&&this.map.setLayoutProperty(M,"visibility",this.showWindFeather?"visible":"none")}},handleClear(){for(const p of this.barbs??[]){const M=p<10?`00${p}kts`:p<100?`0${p}kts`:`${p}kts`;this.map.getLayer(M)&&this.map.removeLayer(M)}this.map.getSource(this.source)&&this.map.removeSource(this.source),this.windBarbLoaded=!1}}},s1={key:0};function W1(p,M,z,o,O,c){var e;return(e=z.wind)!=null&&e.active?(b.openBlock(),b.createElementBlock("div",s1)):b.createCommentVNode("",!0)}const l1=S(d1,[["render",W1]]);class l0{constructor(M){V(this,"map");V(this,"mercator");V(this,"rampColorLayer");V(this,"rampColorSource");V(this,"particleLayer");V(this,"particleSource");V(this,"rampColorCanvas");V(this,"particleCanvas");V(this,"ratio");this.map=M,this.mercator=new w0,this.rampColorLayer="ramp-color-layer",this.rampColorSource="ramp-color-source",this.particleLayer="particle-layer",this.particleSource="particle-source",this.rampColorCanvas=document.createElement("canvas"),this.particleCanvas=document.createElement("canvas"),this.ratio=window.devicePixelRatio}convertNLng(M,z=0){return M>180?this.convertNLng(M-360,z+1):M<-180?this.convertNLng(M+360,z+1):[M,z]}getBoundLngLat(){const M=this.map.getBounds();return[[M._sw.lng,M._ne.lat],[M._ne.lng,M._ne.lat],[M._ne.lng,M._sw.lat],[M._sw.lng,M._sw.lat]]}getBoundPixel(){const M=this.map.getBounds(),z=this.map.getZoom()+1,o=[M._ne.lng,M._ne.lat],O=[M._sw.lng,M._sw.lat],[c,e]=this.convertNLng(o[0]),[t,q]=this.convertNLng(O[0]),[r,a]=this.mercator.px([c,o[1]],z),[i,f]=this.mercator.px([t,O[1]],z),n=Math.round(this.mercator.size*Math.pow(2,z)*(e+q));return[i,f,r+n,a]}getBoundRange(){const M=this.map.getZoom()+1,z=this.mercator.size*Math.pow(2,M),o=this.getBoundPixel();return[o[0]/z,o[2]/z,o[3]/z,o[1]/z]}getWorldCopy(M,z){const o=2**z,[O,c,e,t]=M.map(a=>~~(a/(o*256))),q=[];for(let a=t;a<=c;a++)for(let i=O;i<=e;i++)q.push([i,a]);return q.map(a=>{const i=2**z*256;return[a[0]*i,a[1]*i,i]})}resize(){let M=this.map.getSource(this.rampColorSource);M.setCoordinates(this.getBoundLngLat()),M=this.map.getSource(this.particleSource),M.setCoordinates(this.getBoundLngLat()),this.rampColorCanvas.width=this.map._canvas.clientWidth,this.rampColorCanvas.height=this.map._canvas.clientHeight,this.particleCanvas.width=this.map._canvas.clientWidth,this.particleCanvas.height=this.map._canvas.clientHeight}toggle(M){const z=this.map.getLayoutProperty(this.rampColorLayer,"visibility"),o=M?"visible":"none";z!==o&&this.map.setLayoutProperty(this.rampColorLayer,"visibility",o)}toggleParticle(M){const z=this.map.getLayoutProperty(this.particleLayer,"visibility"),o=M?"visible":"none";z!==o&&this.map.setLayoutProperty(this.particleLayer,"visibility",o)}}class r0{createShader(M,z,o){const O=M.createShader(z);if(O&&(M.shaderSource(O,o),M.compileShader(O),!M.getShaderParameter(O,M.COMPILE_STATUS)))throw new Error(M.getShaderInfoLog(O)||"error happened while create shader...");return O}createTexture(M,z,o,O,c,e,t){const q=M.createTexture();return M.bindTexture(M.TEXTURE_2D,q),M.texParameteri(M.TEXTURE_2D,M.TEXTURE_MIN_FILTER,z),M.texParameteri(M.TEXTURE_2D,M.TEXTURE_MAG_FILTER,o),M.texParameteri(M.TEXTURE_2D,M.TEXTURE_WRAP_S,O),M.texParameteri(M.TEXTURE_2D,M.TEXTURE_WRAP_T,O),c instanceof Uint8Array?M.texImage2D(M.TEXTURE_2D,0,M.RGBA,e,t,0,M.RGBA,M.UNSIGNED_BYTE,c):M.texImage2D(M.TEXTURE_2D,0,M.RGBA,M.RGBA,M.UNSIGNED_BYTE,c),M.bindTexture(M.TEXTURE_2D,null),q}createDataBuffer(M,z,o){if(M){const O=M.createBuffer();return z==="array"?(M.bindBuffer(M.ARRAY_BUFFER,O),o&&M.bufferData(M.ARRAY_BUFFER,o,M.STATIC_DRAW)):z==="element"&&(M.bindBuffer(M.ELEMENT_ARRAY_BUFFER,O),o&&M.bufferData(M.ELEMENT_ARRAY_BUFFER,o,M.STATIC_DRAW)),O}return null}createProgram(M,z,o){const O=M.createProgram(),c=this.createShader(M,M.VERTEX_SHADER,z),e=this.createShader(M,M.FRAGMENT_SHADER,o);if(O&&c&&e&&(M.attachShader(O,c),M.attachShader(O,e),M.linkProgram(O),!M.getProgramParameter(O,M.LINK_STATUS)))throw new Error(M.getProgramInfoLog(O)||"error happened while creating ramp color program");return O}createProgramWrapper(M,z,o){const O=this.createProgram(M,z,o);if(O){const c={program:O},e=M.getProgramParameter(O,M.ACTIVE_ATTRIBUTES);for(let q=0;q<e;q++){const r=M.getActiveAttrib(O,q);c[r.name]=M.getAttribLocation(O,r.name)}const t=M.getProgramParameter(O,M.ACTIVE_UNIFORMS);for(let q=0;q<t;q++){const r=M.getActiveUniform(O,q);c[r.name]=M.getUniformLocation(O,r.name)}return c}}setup(M,z,o=!1,O,c){const e=document.createElement("canvas");e.width=256,e.height=1;const t=e.getContext("2d");if(t&&M){const q=t==null?void 0:t.createLinearGradient(0,0,256,0);return z.forEach(([r,a])=>{q.addColorStop(r,a)}),t.fillStyle=q,t.fillRect(0,0,256,1),{canvas:e,texture:this.createTexture(M,M.LINEAR,M.LINEAR,M.CLAMP_TO_EDGE,o?new Uint8Array(t.getImageData(0,0,256,1).data):e,O,c)}}}setupParticle(M,z=1e3){const o=Math.ceil(Math.sqrt(z)),O=o*o,c=new Uint8Array(O*4);for(let a=0;a<c.length;a++)c[a]=Math.floor(Math.random()*256);const e=this.createTexture(M,M.NEAREST,M.NEAREST,M.CLAMP_TO_EDGE,c,o,o),t=this.createTexture(M,M.NEAREST,M.NEAREST,M.CLAMP_TO_EDGE,c,o,o),q=new Float32Array(O);for(let a=0;a<O;a++)q[a]=a;const r=this.createDataBuffer(M,"array",q);return{resolution:o,total:O,texture0:e,texture1:t,indexBuffer:r}}bind(M,z,o){const O=this.createProgram(M,z,o);if(O){const c=this.createDataBuffer(M,"array",void 0),e=M.getAttribLocation(O,"a_position");M.enableVertexAttribArray(e),M.vertexAttribPointer(e,2,M.FLOAT,!1,0,0);const t=new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]);this.createDataBuffer(M,"array",t);const q=M.getAttribLocation(O,"a_texCoord");return M.enableVertexAttribArray(q),M.vertexAttribPointer(q,2,M.FLOAT,!1,0,0),{program:O,aPositionBuffer:c}}return{}}bindParticle(M,z,o,O,c,e){const t=this.createProgramWrapper(M,z,o),q=this.createProgramWrapper(M,O,c),r=this.createProgramWrapper(M,O,e),a=this.createDataBuffer(M,"array",new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1])),i=M.createFramebuffer();return{particle:t,screen:q,update:r,quadBuffer:a,frameBuffer:i}}draw(M,z,o,O,c,e,t){var q,r;if(z&&o){M.resize(),z==null||z.viewport(0,0,(q=z==null?void 0:z.canvas)==null?void 0:q.width,(r=z==null?void 0:z.canvas)==null?void 0:r.height),z.clearColor(0,0,0,0),z.clear(z.COLOR_BUFFER_BIT|z.DEPTH_BUFFER_BIT);try{const a=z.getUniformLocation(o,"u_resolution"),i=z.getUniformLocation(o,"u_image"),f=z.getUniformLocation(o,"u_color");if(z.useProgram(o),z.uniform2f(a,z.canvas.width*M.ratio,z.canvas.height*M.ratio),z.activeTexture(z.TEXTURE0),z.bindTexture(z.TEXTURE_2D,O),z.uniform1i(i,0),z.activeTexture(z.TEXTURE1),z.bindTexture(z.TEXTURE_2D,c),z.uniform1i(f,1),t!=null&&t.uvRange&&(t!=null&&t.sRange)){const d=z.getUniformLocation(o,"u_range_u_v"),h=z.getUniformLocation(o,"u_range_s");z.uniform2f(d,t.uvRange[0],t.uvRange[1]),z.uniform2f(h,t.sRange[0],t.sRange[1])}const n=M.getBoundPixel(),R=M.map.getZoom()+1,l=M.getWorldCopy(n,R);for(const d of l){const h=(d[0]-n[0])*M.ratio,L=(d[1]-n[3])*M.ratio,B=d[2]*M.ratio,[T,N,P,m]=[h,B+h,L,B+L],X=new Float32Array([T,P,N,P,T,m,T,m,N,P,N,m]);z.bindBuffer(z.ARRAY_BUFFER,e),z.bufferData(z.ARRAY_BUFFER,X,z.STATIC_DRAW),z.drawArrays(z.TRIANGLES,0,6)}}catch(a){console.log(`render failed...${a}`)}}}drawParticle(M,z,o,O,c){var e,t;z&&(z==null||z.viewport(0,0,(e=z==null?void 0:z.canvas)==null?void 0:e.width,(t=z==null?void 0:z.canvas)==null?void 0:t.height),z.disable(z.DEPTH_TEST),z.disable(z.STENCIL_TEST),z.activeTexture(z.TEXTURE0),z.bindTexture(z.TEXTURE_2D,o),z.activeTexture(z.TEXTURE1),z.bindTexture(z.TEXTURE_2D,O.texture0),this.renderScreen(M,z,O,c),this.updateParticles(M,z,O,c))}renderScreen(M,z,o,O){z.bindFramebuffer(z.FRAMEBUFFER,o.frameBuffer),z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,o.screenTexture,0),z.viewport(0,0,z.canvas.width,z.canvas.height),this.renderScreenTexture(z,o.backgroundTexture,o.screen,o.quadBuffer,.95),this.renderParticles(M,z,o,O),z.bindFramebuffer(z.FRAMEBUFFER,null),this.renderScreenTexture(z,o.screenTexture,o.screen,o.quadBuffer,1);const c=o.backgroundTexture;o.backgroundTexture=o.screenTexture,o.screenTexture=c}renderScreenTexture(M,z,o,O,c){M&&(M.useProgram(o.program),M.bindBuffer(M.ARRAY_BUFFER,O),M.enableVertexAttribArray(o.a_pos),M.vertexAttribPointer(o.a_pos,2,M.FLOAT,!1,0,0),M.activeTexture(M.TEXTURE2),M.bindTexture(M.TEXTURE_2D,z),M.uniform1i(o.u_screen,2),M.uniform1f(o.u_opacity,c),M.drawArrays(M.TRIANGLES,0,6))}renderParticles(M,z,o,O){if(z){z.useProgram(o.particle.program),z.bindBuffer(z.ARRAY_BUFFER,o.indexBuffer),z.enableVertexAttribArray(o.particle.a_index),z.vertexAttribPointer(o.particle.a_index,1,z.FLOAT,!1,0,0),z.activeTexture(z.TEXTURE2),z.bindTexture(z.TEXTURE_2D,o.color.texture),z.uniform1i(o.particle.u_factor,0),z.uniform1i(o.particle.u_particles,1),z.uniform1i(o.particle.u_color_ramp,2),z.uniform1f(o.particle.u_particles_resolution,o.resolution*M.ratio),z.uniform1f(o.particle.u_point,M.ratio);const c=M.getBoundRange();z.uniform4f(o.particle.u_viewport,c[0],c[1],c[2],c[3]),z.uniform2f(o.particle.u_factor_min,O.uvRange[0],O.uvRange[0]),z.uniform2f(o.particle.u_factor_max,O.uvRange[1],O.uvRange[1]),z.drawArrays(z.POINTS,0,o.total)}}updateParticles(M,z,o,O){var e,t;if(z){z.bindFramebuffer(z.FRAMEBUFFER,o.frameBuffer),z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,o.texture1,0),z.viewport(0,0,o.resolution,o.resolution),z.useProgram(o.update.program),z.bindBuffer(z.ARRAY_BUFFER,o.quadBuffer),z.enableVertexAttribArray(o.update.a_pos),z.vertexAttribPointer(o.update.a_pos,2,z.FLOAT,!1,0,0),z.uniform1i(o.update.u_factor,0),z.uniform1i(o.update.u_particles,1);const q=M.getBoundRange();z.uniform4f(o.update.u_viewport,q[0],q[1],q[2],q[3]),z.uniform1f(o.update.u_rand_seed,Math.random()),z.uniform2f(o.update.u_factor_res,(e=o==null?void 0:o.image)==null?void 0:e.width,(t=o==null?void 0:o.image)==null?void 0:t.height),z.uniform2f(o.update.u_factor_min,O.uvRange[0],O.uvRange[0]),z.uniform2f(o.update.u_factor_max,O.uvRange[1],O.uvRange[1]),z.uniform1f(o.update.u_speed_factor,O.speedFactor*M.ratio),z.uniform1f(o.update.u_drop_rate,O.dropRate),z.uniform1f(o.update.u_drop_rate_bump,O.dropRateBump),z.drawArrays(z.TRIANGLES,0,6)}const c=o.texture0;o.texture0=o.texture1,o.texture1=c}resize(M,z){M.resize();const o=new Uint8Array(z.canvas.width*z.canvas.height*4).fill(0,0,z.canvas.width*z.canvas.height*4),O=this.createTexture(z,z.NEAREST,z.NEAREST,z.CLAMP_TO_EDGE,o,z.canvas.width,z.canvas.height),c=this.createTexture(z,z.NEAREST,z.NEAREST,z.CLAMP_TO_EDGE,o,z.canvas.width,z.canvas.height);return{screenTexture:O,backgroundTexture:c}}async loadImg(M){return new Promise(z=>{const o=new Blob([M],{type:M.type}),O=URL.createObjectURL(o),c=new Image;c.crossOrigin="anonymous",c.src=O,c.onload=()=>z(c)})}}class G{}V(G,"vertexSchema",`
2
2
  //canvas 坐标系上的坐标 (x, y)
3
3
  attribute vec2 a_position; //像素坐标
4
4
  attribute vec2 a_texCoord; //纹理坐标
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@idmwx/idmui-gl3",
3
3
  "private": false,
4
- "version": "4.6.6",
4
+ "version": "4.6.7",
5
5
  "description": "idm webgl3",
6
6
  "type": "module",
7
7
  "keywords": [