qy-vue-plugins 0.1.20 → 0.1.22

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.
Files changed (46) hide show
  1. package/dist/chunks/{CreateData.vue_vue_type_script_setup_true_lang-BWZeS3T7.js → CreateData.vue_vue_type_script_setup_true_lang-D-eyHIr6.js} +1 -1
  2. package/dist/chunks/CreateData.vue_vue_type_script_setup_true_lang-XAwFLbts.js +1 -0
  3. package/dist/chunks/EventKeys-Cy8iJb0N.js +8 -0
  4. package/dist/chunks/EventKeys-D78tN5KT.js +1 -0
  5. package/dist/chunks/{MapView-4Ia2fnc2.js → MapView-CPtBXPNN.js} +6 -4
  6. package/dist/chunks/{MapView-BLrz0T_c.js → MapView-_PQa8Dp3.js} +2 -2
  7. package/dist/chunks/RenderFormItem.vue_vue_type_style_index_0_lang-CGxnSN-x.js +1 -0
  8. package/dist/chunks/RenderFormItem.vue_vue_type_style_index_0_lang-LijDQik_.js +472 -0
  9. package/dist/chunks/{lerc-SznfXVIf.js → lerc-C6hy7wwt.js} +1 -1
  10. package/dist/chunks/{lerc-Fn4yeamX.js → lerc-DUe7LuVV.js} +1 -1
  11. package/dist/manageTable/Block.cjs +5 -1
  12. package/dist/manageTable/Block.mjs +152 -3
  13. package/dist/manageTable/CreateData.cjs +1 -1
  14. package/dist/manageTable/CreateData.mjs +1 -1
  15. package/dist/manageTable/FilterItem.cjs +1 -1
  16. package/dist/manageTable/FilterItem.mjs +71 -70
  17. package/dist/manageTable/RenderFormItem.cjs +1 -1
  18. package/dist/manageTable/RenderFormItem.mjs +1 -1
  19. package/dist/manageTable/SortItem.cjs +1 -1
  20. package/dist/manageTable/SortItem.mjs +44 -43
  21. package/dist/manageTable/index.cjs +1 -1
  22. package/dist/manageTable/index.mjs +10 -9
  23. package/dist/manageTable/manageTable.cjs +1 -1
  24. package/dist/manageTable/manageTable.mjs +251 -232
  25. package/dist/mapbox/MapView.cjs +1 -1
  26. package/dist/mapbox/MapView.mjs +1 -1
  27. package/dist/mapbox/widgets/ShapeDialog.cjs +1 -1
  28. package/dist/mapbox/widgets/ShapeDialog.mjs +1 -1
  29. package/dist/mapbox.cjs +1 -1
  30. package/dist/mapbox.mjs +1 -1
  31. package/dist/qy-vue-plugins.css +1 -1
  32. package/dist/types/manageTable/EventKeys.d.ts +4 -0
  33. package/dist/types/manageTable/ProvideKeys.d.ts +0 -1
  34. package/dist/types/manageTable/index.d.ts +6 -13
  35. package/dist/types/manageTable.d.ts +5 -0
  36. package/dist/types/types/manageTable.d.ts +1 -1
  37. package/package/manageTable/EventKeys.ts +9 -0
  38. package/package/manageTable/ProvideKeys.ts +1 -1
  39. package/package/manageTable/index.ts +4 -6
  40. package/package/mapbox/useTif.ts +4 -2
  41. package/package.json +1 -1
  42. package/dist/chunks/Block-BB_2FvxH.js +0 -5
  43. package/dist/chunks/Block-jNvIBxNw.js +0 -155
  44. package/dist/chunks/CreateData.vue_vue_type_script_setup_true_lang-Daox4dFj.js +0 -1
  45. package/dist/chunks/RenderFormItem.vue_vue_type_style_index_0_lang-BLbHqWaq.js +0 -1
  46. package/dist/chunks/RenderFormItem.vue_vue_type_style_index_0_lang-BcsgINsW.js +0 -511
@@ -1,6 +1,6 @@
1
1
  import { defineComponent as T, inject as y, ref as i, reactive as z, createBlock as c, openBlock as u, unref as o, withCtx as r, createVNode as d, createCommentVNode as D, createElementBlock as x, Fragment as E, renderList as N, createElementVNode as k, toDisplayString as O, createTextVNode as S, toRaw as L } from "vue";
2
2
  import { ElDialog as M, ElForm as G, ElFormItem as h, ElSelect as H, ElOption as J, ElInputNumber as Q, ElInput as W, ElButton as A, ElMessage as s, dayjs as X } from "element-plus";
3
- import { B as Y } from "./Block-jNvIBxNw.js";
3
+ import Y from "../manageTable/Block.mjs";
4
4
  import { a as Z, q as ee, p as ae, r as le } from "./ProvideKeys-jhgDnhL_.js";
5
5
  const te = { style: { float: "left" } }, oe = { style: { float: "right", color: "var(--el-text-color-secondary)", "font-size": "13px" } }, re = { key: 1 }, ce = /* @__PURE__ */ T({
6
6
  __name: "CreateData",
@@ -0,0 +1 @@
1
+ "use strict";const e=require("vue"),a=require("element-plus"),D=require("../manageTable/Block.cjs"),c=require("./ProvideKeys-BPenLFlD.js"),I={style:{float:"left"}},_={style:{float:"right",color:"var(--el-text-color-secondary)","font-size":"13px"}},R={key:1},O=e.defineComponent({__name:"CreateData",emits:["closed"],setup(S,{expose:k,emit:x}){const v=e.inject(c.apiRowDataOptionsKey),h=e.inject(c.queryResearchDataOptionsKey),C=e.inject(c.projectIdKey),V=e.inject(c.researchStandardKey),u=e.ref(!1),i=e.ref([]),r=e.reactive({researchId:void 0,addCount:1,layerName:"",tableIndex:"0",blockId:null,type:"1",projectId:C}),s=e.ref([]),y=["forestResearchPlot","shrubResearchPlot","grassResearchPlot","wetlandResearchPlot"],f=["plantResearchCollect","fungusResearchCollect","speciesDistribution","waterResearchCollect","soilResearchCollect","humanActivity","naturalDisaster"],p=e.ref(!1),E=x,o=e.ref(),w=async()=>{if(o.value&&f.indexOf(o.value)==-1&&r.researchId==null){a.ElMessage.error("请选择样地或样线数据");return}if(o.value&&y.indexOf(o.value)>-1&&r.blockId==null){a.ElMessage.error("请选择样方号");return}if(r.addCount==null){a.ElMessage.error("请选择单次增加条数");return}if(r.addCount<1){a.ElMessage.error("单次增加条数不能小于1");return}if(r.addCount>100){a.ElMessage.error("单次增加条数不能大于100");return}if(!o.value){a.ElMessage.error("请选择调查类型");return}if(v){p.value=!0;try{var n=[];for(let t=0;t<r.addCount;t++){var l={createDate:a.dayjs().unix(),...e.toRaw(r)};o.value=="speciesDistribution"&&(l.speciesName="待鉴定",l.speciesType="plant"),["humanActivity","naturalDisaster"].includes(o.value)&&(console.log(s.value[t]),l.title=s.value[t]),n.push(l)}await v(n),a.ElMessage.success("添加成功")}catch(t){console.log(t)}E("closed"),p.value=!1}else a.ElMessage.warning("该调查不支持添加");u.value=!1},b=async(n,l)=>{if(o.value=n,u.value=!0,i.value=[],r.researchId=void 0,r.addCount=1,d.value={id:null},l){let[m,g]=l.split(",");r.layerName=m,g&&(r.tableIndex=`0-${g}`)}if(["naturalDisaster","humanActivity","speciesDistribution"].indexOf(o.value)!=-1&&(r.type=o.value),f.indexOf(n)==-1&&h){var t=await h({pageSize:99999,pageNum:1,projectId:C,researchStandard:V});i.value=t.data.list}},d=e.ref({id:null}),N=n=>{d.value=i.value.find(l=>l.id==n)},B=n=>{r.blockId=n};return k({showDialog:b}),(n,l)=>(e.openBlock(),e.createBlock(e.unref(a.ElDialog),{center:"",title:"添加数据",modelValue:u.value,"onUpdate:modelValue":l[4]||(l[4]=t=>u.value=t),width:"800px"},{footer:e.withCtx(()=>[e.createElementVNode("span",null,[e.createVNode(e.unref(a.ElButton),{onClick:l[3]||(l[3]=t=>u.value=!1)},{default:e.withCtx(()=>l[5]||(l[5]=[e.createTextVNode("取消")])),_:1,__:[5]}),e.createVNode(e.unref(a.ElButton),{type:"primary",onClick:w,loading:p.value,plain:""},{default:e.withCtx(()=>l[6]||(l[6]=[e.createTextVNode("创建")])),_:1,__:[6]},8,["loading"])])]),default:e.withCtx(()=>[e.createVNode(e.unref(a.ElForm),{model:r,ref:"form","label-width":"auto",inline:!1},{default:e.withCtx(()=>[o.value&&f.indexOf(o.value)==-1?(e.openBlock(),e.createBlock(e.unref(a.ElFormItem),{key:0,label:"样地或样线数据:"},{default:e.withCtx(()=>[e.createVNode(e.unref(a.ElSelect),{modelValue:r.researchId,"onUpdate:modelValue":l[0]||(l[0]=t=>r.researchId=t),"value-key":"",placeholder:"选择样地或样线数据",filterable:"",onChange:N},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,t=>(e.openBlock(),e.createBlock(e.unref(a.ElOption),{key:t.id,label:t.serialNumberAndCode,value:t.id},{default:e.withCtx(()=>[e.createElementVNode("span",I,e.toDisplayString(t.serialNumberAndCode),1),e.createElementVNode("span",_,e.toDisplayString(t.researchArea),1)]),_:2},1032,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1})):e.createCommentVNode("",!0),o.value&&y.indexOf(o.value)>-1&&d.value.id?(e.openBlock(),e.createBlock(e.unref(a.ElFormItem),{key:1,label:"选择样方号:"},{default:e.withCtx(()=>[d.value.id?(e.openBlock(),e.createBlock(D.default,{key:0,data:d.value,"show-code":!1,"select-mode":!0,onSelected:B},null,8,["data"])):(e.openBlock(),e.createElementBlock("div",R,"尚未选择样地数据"))]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(a.ElFormItem),{label:"单次增加条数:"},{default:e.withCtx(()=>[e.createVNode(e.unref(a.ElInputNumber),{modelValue:r.addCount,"onUpdate:modelValue":l[1]||(l[1]=t=>r.addCount=t),min:1,max:100,step:2,onChange:l[2]||(l[2]=t=>s.value.length=r.addCount)},null,8,["modelValue"])]),_:1}),o.value&&["humanActivity","naturalDisaster"].includes(o.value)?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:2},e.renderList(r.addCount,t=>(e.openBlock(),e.createBlock(e.unref(a.ElFormItem),{label:"标题:"},{default:e.withCtx(()=>[e.createVNode(e.unref(a.ElInput),{modelValue:s.value[t-1],"onUpdate:modelValue":m=>s.value[t-1]=m,placeholder:"请输入标题"},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1024))),256)):e.createCommentVNode("",!0)]),_:1},8,["model"])]),_:1},8,["modelValue"]))}});exports._sfc_main=O;
@@ -0,0 +1,8 @@
1
+ import { useEventBus as t } from "@vueuse/core";
2
+ const e = Symbol("upload-file");
3
+ t(e);
4
+ const o = Symbol("sort-event"), l = t(o), s = Symbol("filter-event"), r = t(s);
5
+ export {
6
+ r as f,
7
+ l as s
8
+ };
@@ -0,0 +1 @@
1
+ "use strict";const e=require("@vueuse/core"),t=Symbol("upload-file");e.useEventBus(t);const s=Symbol("sort-event"),n=e.useEventBus(s),o=Symbol("filter-event"),u=e.useEventBus(o);exports.filterEventBus=u;exports.sortEventBus=n;
@@ -521,7 +521,7 @@ le([8, 32946], () => import("./deflate-DbhbvOaP.js").then((t) => t.default));
521
521
  le(32773, () => import("./packbits-BuzK6gM3.js").then((t) => t.default));
522
522
  le(
523
523
  34887,
524
- () => import("./lerc-Fn4yeamX.js").then(async (t) => (await t.zstd.init(), t)).then((t) => t.default)
524
+ () => import("./lerc-DUe7LuVV.js").then(async (t) => (await t.zstd.init(), t)).then((t) => t.default)
525
525
  );
526
526
  le(50001, () => import("./webimage--SJddlky.js").then((t) => t.default));
527
527
  function Ge(t, e, r, n = 1) {
@@ -1864,8 +1864,10 @@ function mr(t) {
1864
1864
  }
1865
1865
  async function i(l, h = ["#000000", "#FFFFFF"], y = "geotiff-layer") {
1866
1866
  var R;
1867
- const g = await (await yr(l)).getImage(), d = g.getWidth(), I = g.getHeight(), p = g.fileDirectory || {}, b = parseInt(p.GDAL_NODATA) || parseInt(p.NODATA_value) || null;
1868
- console.log(typeof b, b);
1867
+ const g = await (await yr(l)).getImage(), d = g.getWidth(), I = g.getHeight(), p = g.fileDirectory || {};
1868
+ console.log("fileDirectory", p);
1869
+ const b = parseInt(p.GDAL_NODATA);
1870
+ console.log("GDAL_NODATA", typeof b, b);
1869
1871
  const T = Zt(g), v = await g.readRasters();
1870
1872
  r = { image: g, data: v, width: d, height: I }, console.log("GeoTIFF data loaded:", r);
1871
1873
  const O = Array.isArray(v) ? v : [v];
@@ -1878,7 +1880,7 @@ function mr(t) {
1878
1880
  max: U,
1879
1881
  originalMin: F,
1880
1882
  originalMax: U
1881
- };
1883
+ }, console.log("Data range calculated:", n);
1882
1884
  const X = f(v, d, I, h, b);
1883
1885
  if (!X) {
1884
1886
  console.error("Failed to create image data from GeoTIFF.");
@@ -1,5 +1,5 @@
1
1
  "use strict";const U=require("vue"),ge=require("mapbox-gl"),Pt=require("./mapStore-Dir9bFfQ.js"),Lt=require("./map-CAu4wyVU.js"),N=require("./utils-7p2Zpotx.js"),le=require("./EventKeys-BLmCVdTJ.js"),Le=require("./constant-Bc8XErtI.js"),Dt=require("@turf/turf"),De=require("./ProvideKeys-jy8dfV9u.js"),ut=require("./_commonjsHelpers-DwGv2jUC.js"),Ct=require("./_plugin-vue_export-helper-BHFhmbuH.js");function Et(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const i in t)if(i!=="default"){const n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:()=>t[i]})}}return e.default=t,Object.freeze(e)}const Ce=Et(Dt);function X(t){return(e,...i)=>At(t,e,i)}function pe(t,e){return X(ft(t,e).get)}const{apply:At,getOwnPropertyDescriptor:ft,getPrototypeOf:Ve,ownKeys:Mt}=Reflect,{iterator:Te,toStringTag:Ot}=Symbol,Nt=Object,{create:je,defineProperty:Rt}=Nt,Ft=Array,Bt=Ft.prototype,dt=Bt[Te],Gt=X(dt),ht=ArrayBuffer,kt=ht.prototype;pe(kt,"byteLength");const it=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:null;it&&pe(it.prototype,"byteLength");const gt=Ve(Uint8Array);gt.from;const W=gt.prototype;W[Te];X(W.keys);X(W.values);X(W.entries);X(W.set);X(W.reverse);X(W.fill);X(W.copyWithin);X(W.sort);X(W.slice);X(W.subarray);pe(W,"buffer");pe(W,"byteOffset");pe(W,"length");pe(W,Ot);const Ut=Uint8Array,yt=Uint16Array,qe=Uint32Array,Kt=Float32Array,Se=Ve([][Te]()),mt=X(Se.next),Vt=X(function*(){}().next),jt=Ve(Se),qt=DataView.prototype,zt=X(qt.getUint16),ze=WeakMap,pt=ze.prototype,xt=X(pt.get),Yt=X(pt.set),It=new ze,$t=je(null,{next:{value:function(){const e=xt(It,this);return mt(e)}},[Te]:{value:function(){return this}}});function Zt(t){if(t[Te]===dt&&Se.next===mt)return t;const e=je($t);return Yt(It,e,Gt(t)),e}const Xt=new ze,Jt=je(jt,{next:{value:function(){const e=xt(Xt,this);return Vt(e)},writable:!0,configurable:!0}});for(const t of Mt(Se))t!=="next"&&Rt(Jt,t,ft(Se,t));const wt=new ht(4),Ht=new Kt(wt),Qt=new qe(wt),oe=new yt(512),ne=new Ut(512);for(let t=0;t<256;++t){const e=t-127;e<-24?(oe[t]=0,oe[t|256]=32768,ne[t]=24,ne[t|256]=24):e<-14?(oe[t]=1024>>-e-14,oe[t|256]=1024>>-e-14|32768,ne[t]=-e-1,ne[t|256]=-e-1):e<=15?(oe[t]=e+15<<10,oe[t|256]=e+15<<10|32768,ne[t]=13,ne[t|256]=13):e<128?(oe[t]=31744,oe[t|256]=64512,ne[t]=24,ne[t|256]=24):(oe[t]=31744,oe[t|256]=64512,ne[t]=13,ne[t|256]=13)}const Ye=new qe(2048);for(let t=1;t<1024;++t){let e=t<<13,i=0;for(;(e&8388608)===0;)e<<=1,i-=8388608;e&=-8388609,i+=947912704,Ye[t]=e|i}for(let t=1024;t<2048;++t)Ye[t]=939524096+(t-1024<<13);const xe=new qe(64);for(let t=1;t<31;++t)xe[t]=t<<23;xe[31]=1199570944;xe[32]=2147483648;for(let t=33;t<63;++t)xe[t]=2147483648+(t-32<<23);xe[63]=3347054592;const vt=new yt(64);for(let t=1;t<64;++t)t!==32&&(vt[t]=1024);function Wt(t){const e=t>>10;return Qt[0]=Ye[vt[e]+(t&1023)]+xe[e],Ht[0]}function St(t,e,...i){return Wt(zt(t,e,...Zt(i)))}var Ee={exports:{}},ot;function _t(){if(ot)return Ee.exports;ot=1;function t(e,i,n){const o=n&&n.debug||!1;o&&console.log("[xml-utils] getting "+i+" in "+e);const r=typeof e=="object"?e.outer:e,c=r.slice(0,r.indexOf(">")+1),s=['"',"'"];for(let u=0;u<s.length;u++){const l=s[u],h=i+"\\="+l+"([^"+l+"]*)"+l;o&&console.log("[xml-utils] pattern:",h);const m=new RegExp(h).exec(c);if(o&&console.log("[xml-utils] match:",m),m)return m[1]}}return Ee.exports=t,Ee.exports.default=t,Ee.exports}var er=_t();const Ge=ut.getDefaultExportFromCjs(er);var Ae={exports:{}},Me={exports:{}},Oe={exports:{}},nt;function tr(){if(nt)return Oe.exports;nt=1;function t(e,i,n){const r=new RegExp(i).exec(e.slice(n));return r?n+r.index:-1}return Oe.exports=t,Oe.exports.default=t,Oe.exports}var Ne={exports:{}},at;function rr(){if(at)return Ne.exports;at=1;function t(e,i,n){const r=new RegExp(i).exec(e.slice(n));return r?n+r.index+r[0].length-1:-1}return Ne.exports=t,Ne.exports.default=t,Ne.exports}var Re={exports:{}},st;function ir(){if(st)return Re.exports;st=1;function t(e,i){const n=new RegExp(i,"g"),o=e.match(n);return o?o.length:0}return Re.exports=t,Re.exports.default=t,Re.exports}var lt;function or(){if(lt)return Me.exports;lt=1;const t=tr(),e=rr(),i=ir();function n(o,r,c){const s=c&&c.debug||!1,u=!(c&&typeof c.nested===!1),l=c&&c.startIndex||0;s&&console.log("[xml-utils] starting findTagByName with",r," and ",c);const h=t(o,`<${r}[
2
2
  >/]`,l);if(s&&console.log("[xml-utils] start:",h),h===-1)return;const y=o.slice(h+r.length);let m=e(y,"^[^<]*[ /]>",0);const g=m!==-1&&y[m-1]==="/";if(s&&console.log("[xml-utils] selfClosing:",g),g===!1)if(u){let b=0,T=1,v=0;for(;(m=e(y,"[ /]"+r+">",b))!==-1;){const R=y.substring(b,m+1);if(T+=i(R,"<"+r+`[
3
- >]`),v+=i(R,"</"+r+">"),v>=T)break;b=m}}else m=e(y,"[ /]"+r+">",0);const d=h+r.length+m+1;if(s&&console.log("[xml-utils] end:",d),d===-1)return;const w=o.slice(h,d);let p;return g?p=null:p=w.slice(w.indexOf(">")+1,w.lastIndexOf("<")),{inner:p,outer:w,start:h,end:d}}return Me.exports=n,Me.exports.default=n,Me.exports}var ct;function nr(){if(ct)return Ae.exports;ct=1;const t=or();function e(i,n,o){const r=[],c=o&&o.debug||!1,s=o&&typeof o.nested=="boolean"?o.nested:!0;let u=o&&o.startIndex||0,l;for(;l=t(i,n,{debug:c,startIndex:u});)s?u=l.start+1+n.length:u=l.end,r.push(l);return c&&console.log("findTagsByName found",r.length,"tags"),r}return Ae.exports=e,Ae.exports.default=e,Ae.exports}var ar=nr();const sr=ut.getDefaultExportFromCjs(ar),ve={315:"Artist",258:"BitsPerSample",265:"CellLength",264:"CellWidth",320:"ColorMap",259:"Compression",33432:"Copyright",306:"DateTime",338:"ExtraSamples",266:"FillOrder",289:"FreeByteCounts",288:"FreeOffsets",291:"GrayResponseCurve",290:"GrayResponseUnit",316:"HostComputer",270:"ImageDescription",257:"ImageLength",256:"ImageWidth",271:"Make",281:"MaxSampleValue",280:"MinSampleValue",272:"Model",254:"NewSubfileType",274:"Orientation",262:"PhotometricInterpretation",284:"PlanarConfiguration",296:"ResolutionUnit",278:"RowsPerStrip",277:"SamplesPerPixel",305:"Software",279:"StripByteCounts",273:"StripOffsets",255:"SubfileType",263:"Threshholding",282:"XResolution",283:"YResolution",326:"BadFaxLines",327:"CleanFaxData",343:"ClipPath",328:"ConsecutiveBadFaxLines",433:"Decode",434:"DefaultImageColor",269:"DocumentName",336:"DotRange",321:"HalftoneHints",346:"Indexed",347:"JPEGTables",285:"PageName",297:"PageNumber",317:"Predictor",319:"PrimaryChromaticities",532:"ReferenceBlackWhite",339:"SampleFormat",340:"SMinSampleValue",341:"SMaxSampleValue",559:"StripRowCounts",330:"SubIFDs",292:"T4Options",293:"T6Options",325:"TileByteCounts",323:"TileLength",324:"TileOffsets",322:"TileWidth",301:"TransferFunction",318:"WhitePoint",344:"XClipPathUnits",286:"XPosition",529:"YCbCrCoefficients",531:"YCbCrPositioning",530:"YCbCrSubSampling",345:"YClipPathUnits",287:"YPosition",37378:"ApertureValue",40961:"ColorSpace",36868:"DateTimeDigitized",36867:"DateTimeOriginal",34665:"Exif IFD",36864:"ExifVersion",33434:"ExposureTime",41728:"FileSource",37385:"Flash",40960:"FlashpixVersion",33437:"FNumber",42016:"ImageUniqueID",37384:"LightSource",37500:"MakerNote",37377:"ShutterSpeedValue",37510:"UserComment",33723:"IPTC",34675:"ICC Profile",700:"XMP",42112:"GDAL_METADATA",42113:"GDAL_NODATA",34377:"Photoshop",33550:"ModelPixelScale",33922:"ModelTiepoint",34264:"ModelTransformation",34735:"GeoKeyDirectory",34736:"GeoDoubleParams",34737:"GeoAsciiParams",50674:"LercParameters"},ae={};for(const t in ve)ve.hasOwnProperty(t)&&(ae[ve[t]]=parseInt(t,10));const lr=[ae.BitsPerSample,ae.ExtraSamples,ae.SampleFormat,ae.StripByteCounts,ae.StripOffsets,ae.StripRowCounts,ae.TileByteCounts,ae.TileOffsets,ae.SubIFDs],ke={1:"BYTE",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",6:"SBYTE",7:"UNDEFINED",8:"SSHORT",9:"SLONG",10:"SRATIONAL",11:"FLOAT",12:"DOUBLE",13:"IFD",16:"LONG8",17:"SLONG8",18:"IFD8"},F={};for(const t in ke)ke.hasOwnProperty(t)&&(F[ke[t]]=parseInt(t,10));const ee={WhiteIsZero:0,BlackIsZero:1,RGB:2,Palette:3,CMYK:5,YCbCr:6,CIELab:8},cr={Unspecified:0},ur={AddCompression:1},fr={None:0,Deflate:1,Zstandard:2},dr={1024:"GTModelTypeGeoKey",1025:"GTRasterTypeGeoKey",1026:"GTCitationGeoKey",2048:"GeographicTypeGeoKey",2049:"GeogCitationGeoKey",2050:"GeogGeodeticDatumGeoKey",2051:"GeogPrimeMeridianGeoKey",2052:"GeogLinearUnitsGeoKey",2053:"GeogLinearUnitSizeGeoKey",2054:"GeogAngularUnitsGeoKey",2055:"GeogAngularUnitSizeGeoKey",2056:"GeogEllipsoidGeoKey",2057:"GeogSemiMajorAxisGeoKey",2058:"GeogSemiMinorAxisGeoKey",2059:"GeogInvFlatteningGeoKey",2060:"GeogAzimuthUnitsGeoKey",2061:"GeogPrimeMeridianLongGeoKey",2062:"GeogTOWGS84GeoKey",3072:"ProjectedCSTypeGeoKey",3073:"PCSCitationGeoKey",3074:"ProjectionGeoKey",3075:"ProjCoordTransGeoKey",3076:"ProjLinearUnitsGeoKey",3077:"ProjLinearUnitSizeGeoKey",3078:"ProjStdParallel1GeoKey",3079:"ProjStdParallel2GeoKey",3080:"ProjNatOriginLongGeoKey",3081:"ProjNatOriginLatGeoKey",3082:"ProjFalseEastingGeoKey",3083:"ProjFalseNorthingGeoKey",3084:"ProjFalseOriginLongGeoKey",3085:"ProjFalseOriginLatGeoKey",3086:"ProjFalseOriginEastingGeoKey",3087:"ProjFalseOriginNorthingGeoKey",3088:"ProjCenterLongGeoKey",3089:"ProjCenterLatGeoKey",3090:"ProjCenterEastingGeoKey",3091:"ProjCenterNorthingGeoKey",3092:"ProjScaleAtNatOriginGeoKey",3093:"ProjScaleAtCenterGeoKey",3094:"ProjAzimuthAngleGeoKey",3095:"ProjStraightVertPoleLongGeoKey",3096:"ProjRectifiedGridAngleGeoKey",4096:"VerticalCSTypeGeoKey",4097:"VerticalCitationGeoKey",4098:"VerticalDatumGeoKey",4099:"VerticalUnitsGeoKey"};function hr(t,e){const{width:i,height:n}=t,o=new Uint8Array(i*n*3);let r;for(let c=0,s=0;c<t.length;++c,s+=3)r=256-t[c]/e*256,o[s]=r,o[s+1]=r,o[s+2]=r;return o}function gr(t,e){const{width:i,height:n}=t,o=new Uint8Array(i*n*3);let r;for(let c=0,s=0;c<t.length;++c,s+=3)r=t[c]/e*256,o[s]=r,o[s+1]=r,o[s+2]=r;return o}function yr(t,e){const{width:i,height:n}=t,o=new Uint8Array(i*n*3),r=e.length/3,c=e.length/3*2;for(let s=0,u=0;s<t.length;++s,u+=3){const l=t[s];o[u]=e[l]/65536*256,o[u+1]=e[l+r]/65536*256,o[u+2]=e[l+c]/65536*256}return o}function mr(t){const{width:e,height:i}=t,n=new Uint8Array(e*i*3);for(let o=0,r=0;o<t.length;o+=4,r+=3){const c=t[o],s=t[o+1],u=t[o+2],l=t[o+3];n[r]=255*((255-c)/256)*((255-l)/256),n[r+1]=255*((255-s)/256)*((255-l)/256),n[r+2]=255*((255-u)/256)*((255-l)/256)}return n}function pr(t){const{width:e,height:i}=t,n=new Uint8ClampedArray(e*i*3);for(let o=0,r=0;o<t.length;o+=3,r+=3){const c=t[o],s=t[o+1],u=t[o+2];n[r]=c+1.402*(u-128),n[r+1]=c-.34414*(s-128)-.71414*(u-128),n[r+2]=c+1.772*(s-128)}return n}const xr=.95047,Ir=1,wr=1.08883;function vr(t){const{width:e,height:i}=t,n=new Uint8Array(e*i*3);for(let o=0,r=0;o<t.length;o+=3,r+=3){const c=t[o+0],s=t[o+1]<<24>>24,u=t[o+2]<<24>>24;let l=(c+16)/116,h=s/500+l,y=l-u/200,m,g,d;h=xr*(h*h*h>.008856?h*h*h:(h-16/116)/7.787),l=Ir*(l*l*l>.008856?l*l*l:(l-16/116)/7.787),y=wr*(y*y*y>.008856?y*y*y:(y-16/116)/7.787),m=h*3.2406+l*-1.5372+y*-.4986,g=h*-.9689+l*1.8758+y*.0415,d=h*.0557+l*-.204+y*1.057,m=m>.0031308?1.055*m**(1/2.4)-.055:12.92*m,g=g>.0031308?1.055*g**(1/2.4)-.055:12.92*g,d=d>.0031308?1.055*d**(1/2.4)-.055:12.92*d,n[r]=Math.max(0,Math.min(1,m))*255,n[r+1]=Math.max(0,Math.min(1,g))*255,n[r+2]=Math.max(0,Math.min(1,d))*255}return n}const Tt=new Map;function ce(t,e){Array.isArray(t)||(t=[t]),t.forEach(i=>Tt.set(i,e))}async function Sr(t){const e=Tt.get(t.Compression);if(!e)throw new Error(`Unknown compression method identifier: ${t.Compression}`);const i=await e();return new i(t)}ce([void 0,1],()=>Promise.resolve().then(()=>require("./raw-Cm78EGPL.js")).then(t=>t.default));ce(5,()=>Promise.resolve().then(()=>require("./lzw-Cbi9AOTI.js")).then(t=>t.default));ce(6,()=>{throw new Error("old style JPEG compression is not supported.")});ce(7,()=>Promise.resolve().then(()=>require("./jpeg-ClJ__b4h.js")).then(t=>t.default));ce([8,32946],()=>Promise.resolve().then(()=>require("./deflate-DEFE2aFp.js")).then(t=>t.default));ce(32773,()=>Promise.resolve().then(()=>require("./packbits-BXw9Z-3g.js")).then(t=>t.default));ce(34887,()=>Promise.resolve().then(()=>require("./lerc-SznfXVIf.js")).then(async t=>(await t.zstd.init(),t)).then(t=>t.default));ce(50001,()=>Promise.resolve().then(()=>require("./webimage-CCSZWcNO.js")).then(t=>t.default));function Be(t,e,i,n=1){return new(Object.getPrototypeOf(t)).constructor(e*i*n)}function Tr(t,e,i,n,o){const r=e/n,c=i/o;return t.map(s=>{const u=Be(s,n,o);for(let l=0;l<o;++l){const h=Math.min(Math.round(c*l),i-1);for(let y=0;y<n;++y){const m=Math.min(Math.round(r*y),e-1),g=s[h*e+m];u[l*n+y]=g}}return u})}function me(t,e,i){return(1-i)*t+i*e}function br(t,e,i,n,o){const r=e/n,c=i/o;return t.map(s=>{const u=Be(s,n,o);for(let l=0;l<o;++l){const h=c*l,y=Math.floor(h),m=Math.min(Math.ceil(h),i-1);for(let g=0;g<n;++g){const d=r*g,w=d%1,p=Math.floor(d),b=Math.min(Math.ceil(d),e-1),T=s[y*e+p],v=s[y*e+b],R=s[m*e+p],B=s[m*e+b],V=me(me(T,v,w),me(R,B,w),h%1);u[l*n+g]=V}}return u})}function Pr(t,e,i,n,o,r="nearest"){switch(r.toLowerCase()){case"nearest":return Tr(t,e,i,n,o);case"bilinear":case"linear":return br(t,e,i,n,o);default:throw new Error(`Unsupported resampling method: '${r}'`)}}function Lr(t,e,i,n,o,r){const c=e/n,s=i/o,u=Be(t,n,o,r);for(let l=0;l<o;++l){const h=Math.min(Math.round(s*l),i-1);for(let y=0;y<n;++y){const m=Math.min(Math.round(c*y),e-1);for(let g=0;g<r;++g){const d=t[h*e*r+m*r+g];u[l*n*r+y*r+g]=d}}}return u}function Dr(t,e,i,n,o,r){const c=e/n,s=i/o,u=Be(t,n,o,r);for(let l=0;l<o;++l){const h=s*l,y=Math.floor(h),m=Math.min(Math.ceil(h),i-1);for(let g=0;g<n;++g){const d=c*g,w=d%1,p=Math.floor(d),b=Math.min(Math.ceil(d),e-1);for(let T=0;T<r;++T){const v=t[y*e*r+p*r+T],R=t[y*e*r+b*r+T],B=t[m*e*r+p*r+T],V=t[m*e*r+b*r+T],J=me(me(v,R,w),me(B,V,w),h%1);u[l*n*r+g*r+T]=J}}}return u}function Cr(t,e,i,n,o,r,c="nearest"){switch(c.toLowerCase()){case"nearest":return Lr(t,e,i,n,o,r);case"bilinear":case"linear":return Dr(t,e,i,n,o,r);default:throw new Error(`Unsupported resampling method: '${c}'`)}}function Er(t,e,i){let n=0;for(let o=e;o<i;++o)n+=t[o];return n}function Ue(t,e,i){switch(t){case 1:if(e<=8)return new Uint8Array(i);if(e<=16)return new Uint16Array(i);if(e<=32)return new Uint32Array(i);break;case 2:if(e===8)return new Int8Array(i);if(e===16)return new Int16Array(i);if(e===32)return new Int32Array(i);break;case 3:switch(e){case 16:case 32:return new Float32Array(i);case 64:return new Float64Array(i)}break}throw Error("Unsupported data format/bitsPerSample")}function Ar(t,e){return(t===1||t===2)&&e<=32&&e%8===0?!1:!(t===3&&(e===16||e===32||e===64))}function Mr(t,e,i,n,o,r,c){const s=new DataView(t),u=i===2?c*r:c*r*n,l=i===2?1:n,h=Ue(e,o,u),y=parseInt("1".repeat(o),2);if(e===1){let m;i===1?m=n*o:m=o;let g=r*m;(g&7)!==0&&(g=g+7&-8);for(let d=0;d<c;++d){const w=d*g;for(let p=0;p<r;++p){const b=w+p*l*o;for(let T=0;T<l;++T){const v=b+T*o,R=(d*r+p)*l+T,B=Math.floor(v/8),V=v%8;if(V+o<=8)h[R]=s.getUint8(B)>>8-o-V&y;else if(V+o<=16)h[R]=s.getUint16(B)>>16-o-V&y;else if(V+o<=24){const J=s.getUint16(B)<<8|s.getUint8(B+2);h[R]=J>>24-o-V&y}else h[R]=s.getUint32(B)>>32-o-V&y}}}}return h.buffer}class Or{constructor(e,i,n,o,r,c){this.fileDirectory=e,this.geoKeys=i,this.dataView=n,this.littleEndian=o,this.tiles=r?{}:null,this.isTiled=!e.StripOffsets;const s=e.PlanarConfiguration;if(this.planarConfiguration=typeof s>"u"?1:s,this.planarConfiguration!==1&&this.planarConfiguration!==2)throw new Error("Invalid planar configuration.");this.source=c}getFileDirectory(){return this.fileDirectory}getGeoKeys(){return this.geoKeys}getWidth(){return this.fileDirectory.ImageWidth}getHeight(){return this.fileDirectory.ImageLength}getSamplesPerPixel(){return typeof this.fileDirectory.SamplesPerPixel<"u"?this.fileDirectory.SamplesPerPixel:1}getTileWidth(){return this.isTiled?this.fileDirectory.TileWidth:this.getWidth()}getTileHeight(){return this.isTiled?this.fileDirectory.TileLength:typeof this.fileDirectory.RowsPerStrip<"u"?Math.min(this.fileDirectory.RowsPerStrip,this.getHeight()):this.getHeight()}getBlockWidth(){return this.getTileWidth()}getBlockHeight(e){return this.isTiled||(e+1)*this.getTileHeight()<=this.getHeight()?this.getTileHeight():this.getHeight()-e*this.getTileHeight()}getBytesPerPixel(){let e=0;for(let i=0;i<this.fileDirectory.BitsPerSample.length;++i)e+=this.getSampleByteSize(i);return e}getSampleByteSize(e){if(e>=this.fileDirectory.BitsPerSample.length)throw new RangeError(`Sample index ${e} is out of range.`);return Math.ceil(this.fileDirectory.BitsPerSample[e]/8)}getReaderForSample(e){const i=this.fileDirectory.SampleFormat?this.fileDirectory.SampleFormat[e]:1,n=this.fileDirectory.BitsPerSample[e];switch(i){case 1:if(n<=8)return DataView.prototype.getUint8;if(n<=16)return DataView.prototype.getUint16;if(n<=32)return DataView.prototype.getUint32;break;case 2:if(n<=8)return DataView.prototype.getInt8;if(n<=16)return DataView.prototype.getInt16;if(n<=32)return DataView.prototype.getInt32;break;case 3:switch(n){case 16:return function(o,r){return St(this,o,r)};case 32:return DataView.prototype.getFloat32;case 64:return DataView.prototype.getFloat64}break}throw Error("Unsupported data format/bitsPerSample")}getSampleFormat(e=0){return this.fileDirectory.SampleFormat?this.fileDirectory.SampleFormat[e]:1}getBitsPerSample(e=0){return this.fileDirectory.BitsPerSample[e]}getArrayForSample(e,i){const n=this.getSampleFormat(e),o=this.getBitsPerSample(e);return Ue(n,o,i)}async getTileOrStrip(e,i,n,o,r){const c=Math.ceil(this.getWidth()/this.getTileWidth()),s=Math.ceil(this.getHeight()/this.getTileHeight());let u;const{tiles:l}=this;this.planarConfiguration===1?u=i*c+e:this.planarConfiguration===2&&(u=n*c*s+i*c+e);let h,y;this.isTiled?(h=this.fileDirectory.TileOffsets[u],y=this.fileDirectory.TileByteCounts[u]):(h=this.fileDirectory.StripOffsets[u],y=this.fileDirectory.StripByteCounts[u]);const m=(await this.source.fetch([{offset:h,length:y}],r))[0];let g;return l===null||!l[u]?(g=(async()=>{let d=await o.decode(this.fileDirectory,m);const w=this.getSampleFormat(),p=this.getBitsPerSample();return Ar(w,p)&&(d=Mr(d,w,this.planarConfiguration,this.getSamplesPerPixel(),p,this.getTileWidth(),this.getBlockHeight(i))),d})(),l!==null&&(l[u]=g)):g=l[u],{x:e,y:i,sample:n,data:await g}}async _readRaster(e,i,n,o,r,c,s,u,l){const h=this.getTileWidth(),y=this.getTileHeight(),m=this.getWidth(),g=this.getHeight(),d=Math.max(Math.floor(e[0]/h),0),w=Math.min(Math.ceil(e[2]/h),Math.ceil(m/h)),p=Math.max(Math.floor(e[1]/y),0),b=Math.min(Math.ceil(e[3]/y),Math.ceil(g/y)),T=e[2]-e[0];let v=this.getBytesPerPixel();const R=[],B=[];for(let O=0;O<i.length;++O)this.planarConfiguration===1?R.push(Er(this.fileDirectory.BitsPerSample,0,i[O])/8):R.push(0),B.push(this.getReaderForSample(i[O]));const V=[],{littleEndian:J}=this;for(let O=p;O<b;++O)for(let Y=d;Y<w;++Y){let q;this.planarConfiguration===1&&(q=this.getTileOrStrip(Y,O,0,r,l));for(let $=0;$<i.length;++$){const z=$,te=i[$];this.planarConfiguration===2&&(v=this.getSampleByteSize(te),q=this.getTileOrStrip(Y,O,te,r,l));const re=q.then(_=>{const ue=_.data,Ie=new DataView(ue),fe=this.getBlockHeight(_.y),se=_.y*y,de=_.x*h,be=se+fe,a=(_.x+1)*h,f=B[z],I=Math.min(fe,fe-(be-e[3]),g-se),D=Math.min(h,h-(a-e[2]),m-de);for(let S=Math.max(0,e[1]-se);S<I;++S)for(let x=Math.max(0,e[0]-de);x<D;++x){const A=(S*h+x)*v,C=f.call(Ie,A+R[z],J);let k;o?(k=(S+se-e[1])*T*i.length+(x+de-e[0])*i.length+z,n[k]=C):(k=(S+se-e[1])*T+x+de-e[0],n[z][k]=C)}});V.push(re)}}if(await Promise.all(V),c&&e[2]-e[0]!==c||s&&e[3]-e[1]!==s){let O;return o?O=Cr(n,e[2]-e[0],e[3]-e[1],c,s,i.length,u):O=Pr(n,e[2]-e[0],e[3]-e[1],c,s,u),O.width=c,O.height=s,O}return n.width=c||e[2]-e[0],n.height=s||e[3]-e[1],n}async readRasters({window:e,samples:i=[],interleave:n,pool:o=null,width:r,height:c,resampleMethod:s,fillValue:u,signal:l}={}){const h=e||[0,0,this.getWidth(),this.getHeight()];if(h[0]>h[2]||h[1]>h[3])throw new Error("Invalid subsets");const y=h[2]-h[0],m=h[3]-h[1],g=y*m,d=this.getSamplesPerPixel();if(!i||!i.length)for(let T=0;T<d;++T)i.push(T);else for(let T=0;T<i.length;++T)if(i[T]>=d)return Promise.reject(new RangeError(`Invalid sample index '${i[T]}'.`));let w;if(n){const T=this.fileDirectory.SampleFormat?Math.max.apply(null,this.fileDirectory.SampleFormat):1,v=Math.max.apply(null,this.fileDirectory.BitsPerSample);w=Ue(T,v,g*i.length),u&&w.fill(u)}else{w=[];for(let T=0;T<i.length;++T){const v=this.getArrayForSample(i[T],g);Array.isArray(u)&&T<u.length?v.fill(u[T]):u&&!Array.isArray(u)&&v.fill(u),w.push(v)}}const p=o||await Sr(this.fileDirectory);return await this._readRaster(h,i,w,n,p,r,c,s,l)}async readRGB({window:e,interleave:i=!0,pool:n=null,width:o,height:r,resampleMethod:c,enableAlpha:s=!1,signal:u}={}){const l=e||[0,0,this.getWidth(),this.getHeight()];if(l[0]>l[2]||l[1]>l[3])throw new Error("Invalid subsets");const h=this.fileDirectory.PhotometricInterpretation;if(h===ee.RGB){let b=[0,1,2];if(this.fileDirectory.ExtraSamples!==cr.Unspecified&&s){b=[];for(let T=0;T<this.fileDirectory.BitsPerSample.length;T+=1)b.push(T)}return this.readRasters({window:e,interleave:i,samples:b,pool:n,width:o,height:r,resampleMethod:c,signal:u})}let y;switch(h){case ee.WhiteIsZero:case ee.BlackIsZero:case ee.Palette:y=[0];break;case ee.CMYK:y=[0,1,2,3];break;case ee.YCbCr:case ee.CIELab:y=[0,1,2];break;default:throw new Error("Invalid or unsupported photometric interpretation.")}const m={window:l,interleave:!0,samples:y,pool:n,width:o,height:r,resampleMethod:c,signal:u},{fileDirectory:g}=this,d=await this.readRasters(m),w=2**this.fileDirectory.BitsPerSample[0];let p;switch(h){case ee.WhiteIsZero:p=hr(d,w);break;case ee.BlackIsZero:p=gr(d,w);break;case ee.Palette:p=yr(d,g.ColorMap);break;case ee.CMYK:p=mr(d);break;case ee.YCbCr:p=pr(d);break;case ee.CIELab:p=vr(d);break;default:throw new Error("Unsupported photometric interpretation.")}if(!i){const b=new Uint8Array(p.length/3),T=new Uint8Array(p.length/3),v=new Uint8Array(p.length/3);for(let R=0,B=0;R<p.length;R+=3,++B)b[B]=p[R],T[B]=p[R+1],v[B]=p[R+2];p=[b,T,v]}return p.width=d.width,p.height=d.height,p}getTiePoints(){if(!this.fileDirectory.ModelTiepoint)return[];const e=[];for(let i=0;i<this.fileDirectory.ModelTiepoint.length;i+=6)e.push({i:this.fileDirectory.ModelTiepoint[i],j:this.fileDirectory.ModelTiepoint[i+1],k:this.fileDirectory.ModelTiepoint[i+2],x:this.fileDirectory.ModelTiepoint[i+3],y:this.fileDirectory.ModelTiepoint[i+4],z:this.fileDirectory.ModelTiepoint[i+5]});return e}getGDALMetadata(e=null){const i={};if(!this.fileDirectory.GDAL_METADATA)return null;const n=this.fileDirectory.GDAL_METADATA;let o=sr(n,"Item");e===null?o=o.filter(r=>Ge(r,"sample")===void 0):o=o.filter(r=>Number(Ge(r,"sample"))===e);for(let r=0;r<o.length;++r){const c=o[r];i[Ge(c,"name")]=c.inner}return i}getGDALNoData(){if(!this.fileDirectory.GDAL_NODATA)return null;const e=this.fileDirectory.GDAL_NODATA;return Number(e.substring(0,e.length-1))}getOrigin(){const e=this.fileDirectory.ModelTiepoint,i=this.fileDirectory.ModelTransformation;if(e&&e.length===6)return[e[3],e[4],e[5]];if(i)return[i[3],i[7],i[11]];throw new Error("The image does not have an affine transformation.")}getResolution(e=null){const i=this.fileDirectory.ModelPixelScale,n=this.fileDirectory.ModelTransformation;if(i)return[i[0],-i[1],i[2]];if(n)return n[1]===0&&n[4]===0?[n[0],-n[5],n[10]]:[Math.sqrt(n[0]*n[0]+n[4]*n[4]),-Math.sqrt(n[1]*n[1]+n[5]*n[5]),n[10]];if(e){const[o,r,c]=e.getResolution();return[o*e.getWidth()/this.getWidth(),r*e.getHeight()/this.getHeight(),c*e.getWidth()/this.getWidth()]}throw new Error("The image does not have an affine transformation.")}pixelIsArea(){return this.geoKeys.GTRasterTypeGeoKey===1}getBoundingBox(e=!1){const i=this.getHeight(),n=this.getWidth();if(this.fileDirectory.ModelTransformation&&!e){const[o,r,c,s,u,l,h,y]=this.fileDirectory.ModelTransformation,g=[[0,0],[0,i],[n,0],[n,i]].map(([p,b])=>[s+o*p+r*b,y+u*p+l*b]),d=g.map(p=>p[0]),w=g.map(p=>p[1]);return[Math.min(...d),Math.min(...w),Math.max(...d),Math.max(...w)]}else{const o=this.getOrigin(),r=this.getResolution(),c=o[0],s=o[1],u=c+r[0]*n,l=s+r[1]*i;return[Math.min(c,u),Math.min(s,l),Math.max(c,u),Math.max(s,l)]}}}class Nr{constructor(e){this._dataView=new DataView(e)}get buffer(){return this._dataView.buffer}getUint64(e,i){const n=this.getUint32(e,i),o=this.getUint32(e+4,i);let r;if(i){if(r=n+2**32*o,!Number.isSafeInteger(r))throw new Error(`${r} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return r}if(r=2**32*n+o,!Number.isSafeInteger(r))throw new Error(`${r} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return r}getInt64(e,i){let n=0;const o=(this._dataView.getUint8(e+(i?7:0))&128)>0;let r=!0;for(let c=0;c<8;c++){let s=this._dataView.getUint8(e+(i?c:7-c));o&&(r?s!==0&&(s=~(s-1)&255,r=!1):s=~s&255),n+=s*256**c}return o&&(n=-n),n}getUint8(e,i){return this._dataView.getUint8(e,i)}getInt8(e,i){return this._dataView.getInt8(e,i)}getUint16(e,i){return this._dataView.getUint16(e,i)}getInt16(e,i){return this._dataView.getInt16(e,i)}getUint32(e,i){return this._dataView.getUint32(e,i)}getInt32(e,i){return this._dataView.getInt32(e,i)}getFloat16(e,i){return St(this._dataView,e,i)}getFloat32(e,i){return this._dataView.getFloat32(e,i)}getFloat64(e,i){return this._dataView.getFloat64(e,i)}}class Rr{constructor(e,i,n,o){this._dataView=new DataView(e),this._sliceOffset=i,this._littleEndian=n,this._bigTiff=o}get sliceOffset(){return this._sliceOffset}get sliceTop(){return this._sliceOffset+this.buffer.byteLength}get littleEndian(){return this._littleEndian}get bigTiff(){return this._bigTiff}get buffer(){return this._dataView.buffer}covers(e,i){return this.sliceOffset<=e&&this.sliceTop>=e+i}readUint8(e){return this._dataView.getUint8(e-this._sliceOffset,this._littleEndian)}readInt8(e){return this._dataView.getInt8(e-this._sliceOffset,this._littleEndian)}readUint16(e){return this._dataView.getUint16(e-this._sliceOffset,this._littleEndian)}readInt16(e){return this._dataView.getInt16(e-this._sliceOffset,this._littleEndian)}readUint32(e){return this._dataView.getUint32(e-this._sliceOffset,this._littleEndian)}readInt32(e){return this._dataView.getInt32(e-this._sliceOffset,this._littleEndian)}readFloat32(e){return this._dataView.getFloat32(e-this._sliceOffset,this._littleEndian)}readFloat64(e){return this._dataView.getFloat64(e-this._sliceOffset,this._littleEndian)}readUint64(e){const i=this.readUint32(e),n=this.readUint32(e+4);let o;if(this._littleEndian){if(o=i+2**32*n,!Number.isSafeInteger(o))throw new Error(`${o} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return o}if(o=2**32*i+n,!Number.isSafeInteger(o))throw new Error(`${o} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return o}readInt64(e){let i=0;const n=(this._dataView.getUint8(e+(this._littleEndian?7:0))&128)>0;let o=!0;for(let r=0;r<8;r++){let c=this._dataView.getUint8(e+(this._littleEndian?r:7-r));n&&(o?c!==0&&(c=~(c-1)&255,o=!1):c=~c&255),i+=c*256**r}return n&&(i=-i),i}readOffset(e){return this._bigTiff?this.readUint64(e):this.readUint32(e)}}class Fr{async fetch(e,i=void 0){return Promise.all(e.map(n=>this.fetchSlice(n,i)))}async fetchSlice(e){throw new Error(`fetching of slice ${e} not possible, not implemented`)}get fileSize(){return null}async close(){}}class $e extends Error{constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,$e),this.name="AbortError"}}class Br extends Fr{constructor(e){super(),this.arrayBuffer=e}fetchSlice(e,i){if(i&&i.aborted)throw new $e("Request aborted");return this.arrayBuffer.slice(e.offset,e.offset+e.length)}}function Gr(t){return new Br(t)}function Ke(t){switch(t){case F.BYTE:case F.ASCII:case F.SBYTE:case F.UNDEFINED:return 1;case F.SHORT:case F.SSHORT:return 2;case F.LONG:case F.SLONG:case F.FLOAT:case F.IFD:return 4;case F.RATIONAL:case F.SRATIONAL:case F.DOUBLE:case F.LONG8:case F.SLONG8:case F.IFD8:return 8;default:throw new RangeError(`Invalid field type: ${t}`)}}function kr(t){const e=t.GeoKeyDirectory;if(!e)return null;const i={};for(let n=4;n<=e[3]*4;n+=4){const o=dr[e[n]],r=e[n+1]?ve[e[n+1]]:null,c=e[n+2],s=e[n+3];let u=null;if(!r)u=s;else{if(u=t[r],typeof u>"u"||u===null)throw new Error(`Could not get value of geoKey '${o}'.`);typeof u=="string"?u=u.substring(s,s+c-1):u.subarray&&(u=u.subarray(s,s+c),c===1&&(u=u[0]))}i[o]=u}return i}function ye(t,e,i,n){let o=null,r=null;const c=Ke(e);switch(e){case F.BYTE:case F.ASCII:case F.UNDEFINED:o=new Uint8Array(i),r=t.readUint8;break;case F.SBYTE:o=new Int8Array(i),r=t.readInt8;break;case F.SHORT:o=new Uint16Array(i),r=t.readUint16;break;case F.SSHORT:o=new Int16Array(i),r=t.readInt16;break;case F.LONG:case F.IFD:o=new Uint32Array(i),r=t.readUint32;break;case F.SLONG:o=new Int32Array(i),r=t.readInt32;break;case F.LONG8:case F.IFD8:o=new Array(i),r=t.readUint64;break;case F.SLONG8:o=new Array(i),r=t.readInt64;break;case F.RATIONAL:o=new Uint32Array(i*2),r=t.readUint32;break;case F.SRATIONAL:o=new Int32Array(i*2),r=t.readInt32;break;case F.FLOAT:o=new Float32Array(i),r=t.readFloat32;break;case F.DOUBLE:o=new Float64Array(i),r=t.readFloat64;break;default:throw new RangeError(`Invalid field type: ${e}`)}if(e===F.RATIONAL||e===F.SRATIONAL)for(let s=0;s<i;s+=2)o[s]=r.call(t,n+s*c),o[s+1]=r.call(t,n+(s*c+4));else for(let s=0;s<i;++s)o[s]=r.call(t,n+s*c);return e===F.ASCII?new TextDecoder("utf-8").decode(o):o}class Ur{constructor(e,i,n){this.fileDirectory=e,this.geoKeyDirectory=i,this.nextIFDByteOffset=n}}class Fe extends Error{constructor(e){super(`No image at index ${e}`),this.index=e}}class Kr{async readRasters(e={}){const{window:i,width:n,height:o}=e;let{resX:r,resY:c,bbox:s}=e;const u=await this.getImage();let l=u;const h=await this.getImageCount(),y=u.getBoundingBox();if(i&&s)throw new Error('Both "bbox" and "window" passed.');if(n||o){if(i){const[d,w]=u.getOrigin(),[p,b]=u.getResolution();s=[d+i[0]*p,w+i[1]*b,d+i[2]*p,w+i[3]*b]}const g=s||y;if(n){if(r)throw new Error("Both width and resX passed");r=(g[2]-g[0])/n}if(o){if(c)throw new Error("Both width and resY passed");c=(g[3]-g[1])/o}}if(r||c){const g=[];for(let d=0;d<h;++d){const w=await this.getImage(d),{SubfileType:p,NewSubfileType:b}=w.fileDirectory;(d===0||p===2||b&1)&&g.push(w)}g.sort((d,w)=>d.getWidth()-w.getWidth());for(let d=0;d<g.length;++d){const w=g[d],p=(y[2]-y[0])/w.getWidth(),b=(y[3]-y[1])/w.getHeight();if(l=w,r&&r>p||c&&c>b)break}}let m=i;if(s){const[g,d]=u.getOrigin(),[w,p]=l.getResolution(u);m=[Math.round((s[0]-g)/w),Math.round((s[1]-d)/p),Math.round((s[2]-g)/w),Math.round((s[3]-d)/p)],m=[Math.min(m[0],m[2]),Math.min(m[1],m[3]),Math.max(m[0],m[2]),Math.max(m[1],m[3])]}return l.readRasters({...e,window:m})}}class Ze extends Kr{constructor(e,i,n,o,r={}){super(),this.source=e,this.littleEndian=i,this.bigTiff=n,this.firstIFDOffset=o,this.cache=r.cache||!1,this.ifdRequests=[],this.ghostValues=null}async getSlice(e,i){const n=this.bigTiff?4048:1024;return new Rr((await this.source.fetch([{offset:e,length:typeof i<"u"?i:n}]))[0],e,this.littleEndian,this.bigTiff)}async parseFileDirectoryAt(e){const i=this.bigTiff?20:12,n=this.bigTiff?8:2;let o=await this.getSlice(e);const r=this.bigTiff?o.readUint64(e):o.readUint16(e),c=r*i+(this.bigTiff?16:6);o.covers(e,c)||(o=await this.getSlice(e,c));const s={};let u=e+(this.bigTiff?8:2);for(let y=0;y<r;u+=i,++y){const m=o.readUint16(u),g=o.readUint16(u+2),d=this.bigTiff?o.readUint64(u+4):o.readUint32(u+4);let w,p;const b=Ke(g),T=u+(this.bigTiff?12:8);if(b*d<=(this.bigTiff?8:4))w=ye(o,g,d,T);else{const v=o.readOffset(T),R=Ke(g)*d;if(o.covers(v,R))w=ye(o,g,d,v);else{const B=await this.getSlice(v,R);w=ye(B,g,d,v)}}d===1&&lr.indexOf(m)===-1&&!(g===F.RATIONAL||g===F.SRATIONAL)?p=w[0]:p=w,s[ve[m]]=p}const l=kr(s),h=o.readOffset(e+n+i*r);return new Ur(s,l,h)}async requestIFD(e){if(this.ifdRequests[e])return this.ifdRequests[e];if(e===0)return this.ifdRequests[e]=this.parseFileDirectoryAt(this.firstIFDOffset),this.ifdRequests[e];if(!this.ifdRequests[e-1])try{this.ifdRequests[e-1]=this.requestIFD(e-1)}catch(i){throw i instanceof Fe?new Fe(e):i}return this.ifdRequests[e]=(async()=>{const i=await this.ifdRequests[e-1];if(i.nextIFDByteOffset===0)throw new Fe(e);return this.parseFileDirectoryAt(i.nextIFDByteOffset)})(),this.ifdRequests[e]}async getImage(e=0){const i=await this.requestIFD(e);return new Or(i.fileDirectory,i.geoKeyDirectory,this.dataView,this.littleEndian,this.cache,this.source)}async getImageCount(){let e=0,i=!0;for(;i;)try{await this.requestIFD(e),++e}catch(n){if(n instanceof Fe)i=!1;else throw n}return e}async getGhostValues(){const e=this.bigTiff?16:8;if(this.ghostValues)return this.ghostValues;const i="GDAL_STRUCTURAL_METADATA_SIZE=",n=i.length+100;let o=await this.getSlice(e,n);if(i===ye(o,F.ASCII,i.length,e)){const c=ye(o,F.ASCII,n,e).split(`
3
+ >]`),v+=i(R,"</"+r+">"),v>=T)break;b=m}}else m=e(y,"[ /]"+r+">",0);const d=h+r.length+m+1;if(s&&console.log("[xml-utils] end:",d),d===-1)return;const w=o.slice(h,d);let p;return g?p=null:p=w.slice(w.indexOf(">")+1,w.lastIndexOf("<")),{inner:p,outer:w,start:h,end:d}}return Me.exports=n,Me.exports.default=n,Me.exports}var ct;function nr(){if(ct)return Ae.exports;ct=1;const t=or();function e(i,n,o){const r=[],c=o&&o.debug||!1,s=o&&typeof o.nested=="boolean"?o.nested:!0;let u=o&&o.startIndex||0,l;for(;l=t(i,n,{debug:c,startIndex:u});)s?u=l.start+1+n.length:u=l.end,r.push(l);return c&&console.log("findTagsByName found",r.length,"tags"),r}return Ae.exports=e,Ae.exports.default=e,Ae.exports}var ar=nr();const sr=ut.getDefaultExportFromCjs(ar),ve={315:"Artist",258:"BitsPerSample",265:"CellLength",264:"CellWidth",320:"ColorMap",259:"Compression",33432:"Copyright",306:"DateTime",338:"ExtraSamples",266:"FillOrder",289:"FreeByteCounts",288:"FreeOffsets",291:"GrayResponseCurve",290:"GrayResponseUnit",316:"HostComputer",270:"ImageDescription",257:"ImageLength",256:"ImageWidth",271:"Make",281:"MaxSampleValue",280:"MinSampleValue",272:"Model",254:"NewSubfileType",274:"Orientation",262:"PhotometricInterpretation",284:"PlanarConfiguration",296:"ResolutionUnit",278:"RowsPerStrip",277:"SamplesPerPixel",305:"Software",279:"StripByteCounts",273:"StripOffsets",255:"SubfileType",263:"Threshholding",282:"XResolution",283:"YResolution",326:"BadFaxLines",327:"CleanFaxData",343:"ClipPath",328:"ConsecutiveBadFaxLines",433:"Decode",434:"DefaultImageColor",269:"DocumentName",336:"DotRange",321:"HalftoneHints",346:"Indexed",347:"JPEGTables",285:"PageName",297:"PageNumber",317:"Predictor",319:"PrimaryChromaticities",532:"ReferenceBlackWhite",339:"SampleFormat",340:"SMinSampleValue",341:"SMaxSampleValue",559:"StripRowCounts",330:"SubIFDs",292:"T4Options",293:"T6Options",325:"TileByteCounts",323:"TileLength",324:"TileOffsets",322:"TileWidth",301:"TransferFunction",318:"WhitePoint",344:"XClipPathUnits",286:"XPosition",529:"YCbCrCoefficients",531:"YCbCrPositioning",530:"YCbCrSubSampling",345:"YClipPathUnits",287:"YPosition",37378:"ApertureValue",40961:"ColorSpace",36868:"DateTimeDigitized",36867:"DateTimeOriginal",34665:"Exif IFD",36864:"ExifVersion",33434:"ExposureTime",41728:"FileSource",37385:"Flash",40960:"FlashpixVersion",33437:"FNumber",42016:"ImageUniqueID",37384:"LightSource",37500:"MakerNote",37377:"ShutterSpeedValue",37510:"UserComment",33723:"IPTC",34675:"ICC Profile",700:"XMP",42112:"GDAL_METADATA",42113:"GDAL_NODATA",34377:"Photoshop",33550:"ModelPixelScale",33922:"ModelTiepoint",34264:"ModelTransformation",34735:"GeoKeyDirectory",34736:"GeoDoubleParams",34737:"GeoAsciiParams",50674:"LercParameters"},ae={};for(const t in ve)ve.hasOwnProperty(t)&&(ae[ve[t]]=parseInt(t,10));const lr=[ae.BitsPerSample,ae.ExtraSamples,ae.SampleFormat,ae.StripByteCounts,ae.StripOffsets,ae.StripRowCounts,ae.TileByteCounts,ae.TileOffsets,ae.SubIFDs],ke={1:"BYTE",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",6:"SBYTE",7:"UNDEFINED",8:"SSHORT",9:"SLONG",10:"SRATIONAL",11:"FLOAT",12:"DOUBLE",13:"IFD",16:"LONG8",17:"SLONG8",18:"IFD8"},F={};for(const t in ke)ke.hasOwnProperty(t)&&(F[ke[t]]=parseInt(t,10));const ee={WhiteIsZero:0,BlackIsZero:1,RGB:2,Palette:3,CMYK:5,YCbCr:6,CIELab:8},cr={Unspecified:0},ur={AddCompression:1},fr={None:0,Deflate:1,Zstandard:2},dr={1024:"GTModelTypeGeoKey",1025:"GTRasterTypeGeoKey",1026:"GTCitationGeoKey",2048:"GeographicTypeGeoKey",2049:"GeogCitationGeoKey",2050:"GeogGeodeticDatumGeoKey",2051:"GeogPrimeMeridianGeoKey",2052:"GeogLinearUnitsGeoKey",2053:"GeogLinearUnitSizeGeoKey",2054:"GeogAngularUnitsGeoKey",2055:"GeogAngularUnitSizeGeoKey",2056:"GeogEllipsoidGeoKey",2057:"GeogSemiMajorAxisGeoKey",2058:"GeogSemiMinorAxisGeoKey",2059:"GeogInvFlatteningGeoKey",2060:"GeogAzimuthUnitsGeoKey",2061:"GeogPrimeMeridianLongGeoKey",2062:"GeogTOWGS84GeoKey",3072:"ProjectedCSTypeGeoKey",3073:"PCSCitationGeoKey",3074:"ProjectionGeoKey",3075:"ProjCoordTransGeoKey",3076:"ProjLinearUnitsGeoKey",3077:"ProjLinearUnitSizeGeoKey",3078:"ProjStdParallel1GeoKey",3079:"ProjStdParallel2GeoKey",3080:"ProjNatOriginLongGeoKey",3081:"ProjNatOriginLatGeoKey",3082:"ProjFalseEastingGeoKey",3083:"ProjFalseNorthingGeoKey",3084:"ProjFalseOriginLongGeoKey",3085:"ProjFalseOriginLatGeoKey",3086:"ProjFalseOriginEastingGeoKey",3087:"ProjFalseOriginNorthingGeoKey",3088:"ProjCenterLongGeoKey",3089:"ProjCenterLatGeoKey",3090:"ProjCenterEastingGeoKey",3091:"ProjCenterNorthingGeoKey",3092:"ProjScaleAtNatOriginGeoKey",3093:"ProjScaleAtCenterGeoKey",3094:"ProjAzimuthAngleGeoKey",3095:"ProjStraightVertPoleLongGeoKey",3096:"ProjRectifiedGridAngleGeoKey",4096:"VerticalCSTypeGeoKey",4097:"VerticalCitationGeoKey",4098:"VerticalDatumGeoKey",4099:"VerticalUnitsGeoKey"};function hr(t,e){const{width:i,height:n}=t,o=new Uint8Array(i*n*3);let r;for(let c=0,s=0;c<t.length;++c,s+=3)r=256-t[c]/e*256,o[s]=r,o[s+1]=r,o[s+2]=r;return o}function gr(t,e){const{width:i,height:n}=t,o=new Uint8Array(i*n*3);let r;for(let c=0,s=0;c<t.length;++c,s+=3)r=t[c]/e*256,o[s]=r,o[s+1]=r,o[s+2]=r;return o}function yr(t,e){const{width:i,height:n}=t,o=new Uint8Array(i*n*3),r=e.length/3,c=e.length/3*2;for(let s=0,u=0;s<t.length;++s,u+=3){const l=t[s];o[u]=e[l]/65536*256,o[u+1]=e[l+r]/65536*256,o[u+2]=e[l+c]/65536*256}return o}function mr(t){const{width:e,height:i}=t,n=new Uint8Array(e*i*3);for(let o=0,r=0;o<t.length;o+=4,r+=3){const c=t[o],s=t[o+1],u=t[o+2],l=t[o+3];n[r]=255*((255-c)/256)*((255-l)/256),n[r+1]=255*((255-s)/256)*((255-l)/256),n[r+2]=255*((255-u)/256)*((255-l)/256)}return n}function pr(t){const{width:e,height:i}=t,n=new Uint8ClampedArray(e*i*3);for(let o=0,r=0;o<t.length;o+=3,r+=3){const c=t[o],s=t[o+1],u=t[o+2];n[r]=c+1.402*(u-128),n[r+1]=c-.34414*(s-128)-.71414*(u-128),n[r+2]=c+1.772*(s-128)}return n}const xr=.95047,Ir=1,wr=1.08883;function vr(t){const{width:e,height:i}=t,n=new Uint8Array(e*i*3);for(let o=0,r=0;o<t.length;o+=3,r+=3){const c=t[o+0],s=t[o+1]<<24>>24,u=t[o+2]<<24>>24;let l=(c+16)/116,h=s/500+l,y=l-u/200,m,g,d;h=xr*(h*h*h>.008856?h*h*h:(h-16/116)/7.787),l=Ir*(l*l*l>.008856?l*l*l:(l-16/116)/7.787),y=wr*(y*y*y>.008856?y*y*y:(y-16/116)/7.787),m=h*3.2406+l*-1.5372+y*-.4986,g=h*-.9689+l*1.8758+y*.0415,d=h*.0557+l*-.204+y*1.057,m=m>.0031308?1.055*m**(1/2.4)-.055:12.92*m,g=g>.0031308?1.055*g**(1/2.4)-.055:12.92*g,d=d>.0031308?1.055*d**(1/2.4)-.055:12.92*d,n[r]=Math.max(0,Math.min(1,m))*255,n[r+1]=Math.max(0,Math.min(1,g))*255,n[r+2]=Math.max(0,Math.min(1,d))*255}return n}const Tt=new Map;function ce(t,e){Array.isArray(t)||(t=[t]),t.forEach(i=>Tt.set(i,e))}async function Sr(t){const e=Tt.get(t.Compression);if(!e)throw new Error(`Unknown compression method identifier: ${t.Compression}`);const i=await e();return new i(t)}ce([void 0,1],()=>Promise.resolve().then(()=>require("./raw-Cm78EGPL.js")).then(t=>t.default));ce(5,()=>Promise.resolve().then(()=>require("./lzw-Cbi9AOTI.js")).then(t=>t.default));ce(6,()=>{throw new Error("old style JPEG compression is not supported.")});ce(7,()=>Promise.resolve().then(()=>require("./jpeg-ClJ__b4h.js")).then(t=>t.default));ce([8,32946],()=>Promise.resolve().then(()=>require("./deflate-DEFE2aFp.js")).then(t=>t.default));ce(32773,()=>Promise.resolve().then(()=>require("./packbits-BXw9Z-3g.js")).then(t=>t.default));ce(34887,()=>Promise.resolve().then(()=>require("./lerc-C6hy7wwt.js")).then(async t=>(await t.zstd.init(),t)).then(t=>t.default));ce(50001,()=>Promise.resolve().then(()=>require("./webimage-CCSZWcNO.js")).then(t=>t.default));function Be(t,e,i,n=1){return new(Object.getPrototypeOf(t)).constructor(e*i*n)}function Tr(t,e,i,n,o){const r=e/n,c=i/o;return t.map(s=>{const u=Be(s,n,o);for(let l=0;l<o;++l){const h=Math.min(Math.round(c*l),i-1);for(let y=0;y<n;++y){const m=Math.min(Math.round(r*y),e-1),g=s[h*e+m];u[l*n+y]=g}}return u})}function me(t,e,i){return(1-i)*t+i*e}function br(t,e,i,n,o){const r=e/n,c=i/o;return t.map(s=>{const u=Be(s,n,o);for(let l=0;l<o;++l){const h=c*l,y=Math.floor(h),m=Math.min(Math.ceil(h),i-1);for(let g=0;g<n;++g){const d=r*g,w=d%1,p=Math.floor(d),b=Math.min(Math.ceil(d),e-1),T=s[y*e+p],v=s[y*e+b],R=s[m*e+p],B=s[m*e+b],V=me(me(T,v,w),me(R,B,w),h%1);u[l*n+g]=V}}return u})}function Pr(t,e,i,n,o,r="nearest"){switch(r.toLowerCase()){case"nearest":return Tr(t,e,i,n,o);case"bilinear":case"linear":return br(t,e,i,n,o);default:throw new Error(`Unsupported resampling method: '${r}'`)}}function Lr(t,e,i,n,o,r){const c=e/n,s=i/o,u=Be(t,n,o,r);for(let l=0;l<o;++l){const h=Math.min(Math.round(s*l),i-1);for(let y=0;y<n;++y){const m=Math.min(Math.round(c*y),e-1);for(let g=0;g<r;++g){const d=t[h*e*r+m*r+g];u[l*n*r+y*r+g]=d}}}return u}function Dr(t,e,i,n,o,r){const c=e/n,s=i/o,u=Be(t,n,o,r);for(let l=0;l<o;++l){const h=s*l,y=Math.floor(h),m=Math.min(Math.ceil(h),i-1);for(let g=0;g<n;++g){const d=c*g,w=d%1,p=Math.floor(d),b=Math.min(Math.ceil(d),e-1);for(let T=0;T<r;++T){const v=t[y*e*r+p*r+T],R=t[y*e*r+b*r+T],B=t[m*e*r+p*r+T],V=t[m*e*r+b*r+T],J=me(me(v,R,w),me(B,V,w),h%1);u[l*n*r+g*r+T]=J}}}return u}function Cr(t,e,i,n,o,r,c="nearest"){switch(c.toLowerCase()){case"nearest":return Lr(t,e,i,n,o,r);case"bilinear":case"linear":return Dr(t,e,i,n,o,r);default:throw new Error(`Unsupported resampling method: '${c}'`)}}function Er(t,e,i){let n=0;for(let o=e;o<i;++o)n+=t[o];return n}function Ue(t,e,i){switch(t){case 1:if(e<=8)return new Uint8Array(i);if(e<=16)return new Uint16Array(i);if(e<=32)return new Uint32Array(i);break;case 2:if(e===8)return new Int8Array(i);if(e===16)return new Int16Array(i);if(e===32)return new Int32Array(i);break;case 3:switch(e){case 16:case 32:return new Float32Array(i);case 64:return new Float64Array(i)}break}throw Error("Unsupported data format/bitsPerSample")}function Ar(t,e){return(t===1||t===2)&&e<=32&&e%8===0?!1:!(t===3&&(e===16||e===32||e===64))}function Mr(t,e,i,n,o,r,c){const s=new DataView(t),u=i===2?c*r:c*r*n,l=i===2?1:n,h=Ue(e,o,u),y=parseInt("1".repeat(o),2);if(e===1){let m;i===1?m=n*o:m=o;let g=r*m;(g&7)!==0&&(g=g+7&-8);for(let d=0;d<c;++d){const w=d*g;for(let p=0;p<r;++p){const b=w+p*l*o;for(let T=0;T<l;++T){const v=b+T*o,R=(d*r+p)*l+T,B=Math.floor(v/8),V=v%8;if(V+o<=8)h[R]=s.getUint8(B)>>8-o-V&y;else if(V+o<=16)h[R]=s.getUint16(B)>>16-o-V&y;else if(V+o<=24){const J=s.getUint16(B)<<8|s.getUint8(B+2);h[R]=J>>24-o-V&y}else h[R]=s.getUint32(B)>>32-o-V&y}}}}return h.buffer}class Or{constructor(e,i,n,o,r,c){this.fileDirectory=e,this.geoKeys=i,this.dataView=n,this.littleEndian=o,this.tiles=r?{}:null,this.isTiled=!e.StripOffsets;const s=e.PlanarConfiguration;if(this.planarConfiguration=typeof s>"u"?1:s,this.planarConfiguration!==1&&this.planarConfiguration!==2)throw new Error("Invalid planar configuration.");this.source=c}getFileDirectory(){return this.fileDirectory}getGeoKeys(){return this.geoKeys}getWidth(){return this.fileDirectory.ImageWidth}getHeight(){return this.fileDirectory.ImageLength}getSamplesPerPixel(){return typeof this.fileDirectory.SamplesPerPixel<"u"?this.fileDirectory.SamplesPerPixel:1}getTileWidth(){return this.isTiled?this.fileDirectory.TileWidth:this.getWidth()}getTileHeight(){return this.isTiled?this.fileDirectory.TileLength:typeof this.fileDirectory.RowsPerStrip<"u"?Math.min(this.fileDirectory.RowsPerStrip,this.getHeight()):this.getHeight()}getBlockWidth(){return this.getTileWidth()}getBlockHeight(e){return this.isTiled||(e+1)*this.getTileHeight()<=this.getHeight()?this.getTileHeight():this.getHeight()-e*this.getTileHeight()}getBytesPerPixel(){let e=0;for(let i=0;i<this.fileDirectory.BitsPerSample.length;++i)e+=this.getSampleByteSize(i);return e}getSampleByteSize(e){if(e>=this.fileDirectory.BitsPerSample.length)throw new RangeError(`Sample index ${e} is out of range.`);return Math.ceil(this.fileDirectory.BitsPerSample[e]/8)}getReaderForSample(e){const i=this.fileDirectory.SampleFormat?this.fileDirectory.SampleFormat[e]:1,n=this.fileDirectory.BitsPerSample[e];switch(i){case 1:if(n<=8)return DataView.prototype.getUint8;if(n<=16)return DataView.prototype.getUint16;if(n<=32)return DataView.prototype.getUint32;break;case 2:if(n<=8)return DataView.prototype.getInt8;if(n<=16)return DataView.prototype.getInt16;if(n<=32)return DataView.prototype.getInt32;break;case 3:switch(n){case 16:return function(o,r){return St(this,o,r)};case 32:return DataView.prototype.getFloat32;case 64:return DataView.prototype.getFloat64}break}throw Error("Unsupported data format/bitsPerSample")}getSampleFormat(e=0){return this.fileDirectory.SampleFormat?this.fileDirectory.SampleFormat[e]:1}getBitsPerSample(e=0){return this.fileDirectory.BitsPerSample[e]}getArrayForSample(e,i){const n=this.getSampleFormat(e),o=this.getBitsPerSample(e);return Ue(n,o,i)}async getTileOrStrip(e,i,n,o,r){const c=Math.ceil(this.getWidth()/this.getTileWidth()),s=Math.ceil(this.getHeight()/this.getTileHeight());let u;const{tiles:l}=this;this.planarConfiguration===1?u=i*c+e:this.planarConfiguration===2&&(u=n*c*s+i*c+e);let h,y;this.isTiled?(h=this.fileDirectory.TileOffsets[u],y=this.fileDirectory.TileByteCounts[u]):(h=this.fileDirectory.StripOffsets[u],y=this.fileDirectory.StripByteCounts[u]);const m=(await this.source.fetch([{offset:h,length:y}],r))[0];let g;return l===null||!l[u]?(g=(async()=>{let d=await o.decode(this.fileDirectory,m);const w=this.getSampleFormat(),p=this.getBitsPerSample();return Ar(w,p)&&(d=Mr(d,w,this.planarConfiguration,this.getSamplesPerPixel(),p,this.getTileWidth(),this.getBlockHeight(i))),d})(),l!==null&&(l[u]=g)):g=l[u],{x:e,y:i,sample:n,data:await g}}async _readRaster(e,i,n,o,r,c,s,u,l){const h=this.getTileWidth(),y=this.getTileHeight(),m=this.getWidth(),g=this.getHeight(),d=Math.max(Math.floor(e[0]/h),0),w=Math.min(Math.ceil(e[2]/h),Math.ceil(m/h)),p=Math.max(Math.floor(e[1]/y),0),b=Math.min(Math.ceil(e[3]/y),Math.ceil(g/y)),T=e[2]-e[0];let v=this.getBytesPerPixel();const R=[],B=[];for(let O=0;O<i.length;++O)this.planarConfiguration===1?R.push(Er(this.fileDirectory.BitsPerSample,0,i[O])/8):R.push(0),B.push(this.getReaderForSample(i[O]));const V=[],{littleEndian:J}=this;for(let O=p;O<b;++O)for(let Y=d;Y<w;++Y){let q;this.planarConfiguration===1&&(q=this.getTileOrStrip(Y,O,0,r,l));for(let $=0;$<i.length;++$){const z=$,te=i[$];this.planarConfiguration===2&&(v=this.getSampleByteSize(te),q=this.getTileOrStrip(Y,O,te,r,l));const re=q.then(_=>{const ue=_.data,Ie=new DataView(ue),fe=this.getBlockHeight(_.y),se=_.y*y,de=_.x*h,be=se+fe,a=(_.x+1)*h,f=B[z],I=Math.min(fe,fe-(be-e[3]),g-se),D=Math.min(h,h-(a-e[2]),m-de);for(let S=Math.max(0,e[1]-se);S<I;++S)for(let x=Math.max(0,e[0]-de);x<D;++x){const A=(S*h+x)*v,C=f.call(Ie,A+R[z],J);let k;o?(k=(S+se-e[1])*T*i.length+(x+de-e[0])*i.length+z,n[k]=C):(k=(S+se-e[1])*T+x+de-e[0],n[z][k]=C)}});V.push(re)}}if(await Promise.all(V),c&&e[2]-e[0]!==c||s&&e[3]-e[1]!==s){let O;return o?O=Cr(n,e[2]-e[0],e[3]-e[1],c,s,i.length,u):O=Pr(n,e[2]-e[0],e[3]-e[1],c,s,u),O.width=c,O.height=s,O}return n.width=c||e[2]-e[0],n.height=s||e[3]-e[1],n}async readRasters({window:e,samples:i=[],interleave:n,pool:o=null,width:r,height:c,resampleMethod:s,fillValue:u,signal:l}={}){const h=e||[0,0,this.getWidth(),this.getHeight()];if(h[0]>h[2]||h[1]>h[3])throw new Error("Invalid subsets");const y=h[2]-h[0],m=h[3]-h[1],g=y*m,d=this.getSamplesPerPixel();if(!i||!i.length)for(let T=0;T<d;++T)i.push(T);else for(let T=0;T<i.length;++T)if(i[T]>=d)return Promise.reject(new RangeError(`Invalid sample index '${i[T]}'.`));let w;if(n){const T=this.fileDirectory.SampleFormat?Math.max.apply(null,this.fileDirectory.SampleFormat):1,v=Math.max.apply(null,this.fileDirectory.BitsPerSample);w=Ue(T,v,g*i.length),u&&w.fill(u)}else{w=[];for(let T=0;T<i.length;++T){const v=this.getArrayForSample(i[T],g);Array.isArray(u)&&T<u.length?v.fill(u[T]):u&&!Array.isArray(u)&&v.fill(u),w.push(v)}}const p=o||await Sr(this.fileDirectory);return await this._readRaster(h,i,w,n,p,r,c,s,l)}async readRGB({window:e,interleave:i=!0,pool:n=null,width:o,height:r,resampleMethod:c,enableAlpha:s=!1,signal:u}={}){const l=e||[0,0,this.getWidth(),this.getHeight()];if(l[0]>l[2]||l[1]>l[3])throw new Error("Invalid subsets");const h=this.fileDirectory.PhotometricInterpretation;if(h===ee.RGB){let b=[0,1,2];if(this.fileDirectory.ExtraSamples!==cr.Unspecified&&s){b=[];for(let T=0;T<this.fileDirectory.BitsPerSample.length;T+=1)b.push(T)}return this.readRasters({window:e,interleave:i,samples:b,pool:n,width:o,height:r,resampleMethod:c,signal:u})}let y;switch(h){case ee.WhiteIsZero:case ee.BlackIsZero:case ee.Palette:y=[0];break;case ee.CMYK:y=[0,1,2,3];break;case ee.YCbCr:case ee.CIELab:y=[0,1,2];break;default:throw new Error("Invalid or unsupported photometric interpretation.")}const m={window:l,interleave:!0,samples:y,pool:n,width:o,height:r,resampleMethod:c,signal:u},{fileDirectory:g}=this,d=await this.readRasters(m),w=2**this.fileDirectory.BitsPerSample[0];let p;switch(h){case ee.WhiteIsZero:p=hr(d,w);break;case ee.BlackIsZero:p=gr(d,w);break;case ee.Palette:p=yr(d,g.ColorMap);break;case ee.CMYK:p=mr(d);break;case ee.YCbCr:p=pr(d);break;case ee.CIELab:p=vr(d);break;default:throw new Error("Unsupported photometric interpretation.")}if(!i){const b=new Uint8Array(p.length/3),T=new Uint8Array(p.length/3),v=new Uint8Array(p.length/3);for(let R=0,B=0;R<p.length;R+=3,++B)b[B]=p[R],T[B]=p[R+1],v[B]=p[R+2];p=[b,T,v]}return p.width=d.width,p.height=d.height,p}getTiePoints(){if(!this.fileDirectory.ModelTiepoint)return[];const e=[];for(let i=0;i<this.fileDirectory.ModelTiepoint.length;i+=6)e.push({i:this.fileDirectory.ModelTiepoint[i],j:this.fileDirectory.ModelTiepoint[i+1],k:this.fileDirectory.ModelTiepoint[i+2],x:this.fileDirectory.ModelTiepoint[i+3],y:this.fileDirectory.ModelTiepoint[i+4],z:this.fileDirectory.ModelTiepoint[i+5]});return e}getGDALMetadata(e=null){const i={};if(!this.fileDirectory.GDAL_METADATA)return null;const n=this.fileDirectory.GDAL_METADATA;let o=sr(n,"Item");e===null?o=o.filter(r=>Ge(r,"sample")===void 0):o=o.filter(r=>Number(Ge(r,"sample"))===e);for(let r=0;r<o.length;++r){const c=o[r];i[Ge(c,"name")]=c.inner}return i}getGDALNoData(){if(!this.fileDirectory.GDAL_NODATA)return null;const e=this.fileDirectory.GDAL_NODATA;return Number(e.substring(0,e.length-1))}getOrigin(){const e=this.fileDirectory.ModelTiepoint,i=this.fileDirectory.ModelTransformation;if(e&&e.length===6)return[e[3],e[4],e[5]];if(i)return[i[3],i[7],i[11]];throw new Error("The image does not have an affine transformation.")}getResolution(e=null){const i=this.fileDirectory.ModelPixelScale,n=this.fileDirectory.ModelTransformation;if(i)return[i[0],-i[1],i[2]];if(n)return n[1]===0&&n[4]===0?[n[0],-n[5],n[10]]:[Math.sqrt(n[0]*n[0]+n[4]*n[4]),-Math.sqrt(n[1]*n[1]+n[5]*n[5]),n[10]];if(e){const[o,r,c]=e.getResolution();return[o*e.getWidth()/this.getWidth(),r*e.getHeight()/this.getHeight(),c*e.getWidth()/this.getWidth()]}throw new Error("The image does not have an affine transformation.")}pixelIsArea(){return this.geoKeys.GTRasterTypeGeoKey===1}getBoundingBox(e=!1){const i=this.getHeight(),n=this.getWidth();if(this.fileDirectory.ModelTransformation&&!e){const[o,r,c,s,u,l,h,y]=this.fileDirectory.ModelTransformation,g=[[0,0],[0,i],[n,0],[n,i]].map(([p,b])=>[s+o*p+r*b,y+u*p+l*b]),d=g.map(p=>p[0]),w=g.map(p=>p[1]);return[Math.min(...d),Math.min(...w),Math.max(...d),Math.max(...w)]}else{const o=this.getOrigin(),r=this.getResolution(),c=o[0],s=o[1],u=c+r[0]*n,l=s+r[1]*i;return[Math.min(c,u),Math.min(s,l),Math.max(c,u),Math.max(s,l)]}}}class Nr{constructor(e){this._dataView=new DataView(e)}get buffer(){return this._dataView.buffer}getUint64(e,i){const n=this.getUint32(e,i),o=this.getUint32(e+4,i);let r;if(i){if(r=n+2**32*o,!Number.isSafeInteger(r))throw new Error(`${r} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return r}if(r=2**32*n+o,!Number.isSafeInteger(r))throw new Error(`${r} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return r}getInt64(e,i){let n=0;const o=(this._dataView.getUint8(e+(i?7:0))&128)>0;let r=!0;for(let c=0;c<8;c++){let s=this._dataView.getUint8(e+(i?c:7-c));o&&(r?s!==0&&(s=~(s-1)&255,r=!1):s=~s&255),n+=s*256**c}return o&&(n=-n),n}getUint8(e,i){return this._dataView.getUint8(e,i)}getInt8(e,i){return this._dataView.getInt8(e,i)}getUint16(e,i){return this._dataView.getUint16(e,i)}getInt16(e,i){return this._dataView.getInt16(e,i)}getUint32(e,i){return this._dataView.getUint32(e,i)}getInt32(e,i){return this._dataView.getInt32(e,i)}getFloat16(e,i){return St(this._dataView,e,i)}getFloat32(e,i){return this._dataView.getFloat32(e,i)}getFloat64(e,i){return this._dataView.getFloat64(e,i)}}class Rr{constructor(e,i,n,o){this._dataView=new DataView(e),this._sliceOffset=i,this._littleEndian=n,this._bigTiff=o}get sliceOffset(){return this._sliceOffset}get sliceTop(){return this._sliceOffset+this.buffer.byteLength}get littleEndian(){return this._littleEndian}get bigTiff(){return this._bigTiff}get buffer(){return this._dataView.buffer}covers(e,i){return this.sliceOffset<=e&&this.sliceTop>=e+i}readUint8(e){return this._dataView.getUint8(e-this._sliceOffset,this._littleEndian)}readInt8(e){return this._dataView.getInt8(e-this._sliceOffset,this._littleEndian)}readUint16(e){return this._dataView.getUint16(e-this._sliceOffset,this._littleEndian)}readInt16(e){return this._dataView.getInt16(e-this._sliceOffset,this._littleEndian)}readUint32(e){return this._dataView.getUint32(e-this._sliceOffset,this._littleEndian)}readInt32(e){return this._dataView.getInt32(e-this._sliceOffset,this._littleEndian)}readFloat32(e){return this._dataView.getFloat32(e-this._sliceOffset,this._littleEndian)}readFloat64(e){return this._dataView.getFloat64(e-this._sliceOffset,this._littleEndian)}readUint64(e){const i=this.readUint32(e),n=this.readUint32(e+4);let o;if(this._littleEndian){if(o=i+2**32*n,!Number.isSafeInteger(o))throw new Error(`${o} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return o}if(o=2**32*i+n,!Number.isSafeInteger(o))throw new Error(`${o} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return o}readInt64(e){let i=0;const n=(this._dataView.getUint8(e+(this._littleEndian?7:0))&128)>0;let o=!0;for(let r=0;r<8;r++){let c=this._dataView.getUint8(e+(this._littleEndian?r:7-r));n&&(o?c!==0&&(c=~(c-1)&255,o=!1):c=~c&255),i+=c*256**r}return n&&(i=-i),i}readOffset(e){return this._bigTiff?this.readUint64(e):this.readUint32(e)}}class Fr{async fetch(e,i=void 0){return Promise.all(e.map(n=>this.fetchSlice(n,i)))}async fetchSlice(e){throw new Error(`fetching of slice ${e} not possible, not implemented`)}get fileSize(){return null}async close(){}}class $e extends Error{constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,$e),this.name="AbortError"}}class Br extends Fr{constructor(e){super(),this.arrayBuffer=e}fetchSlice(e,i){if(i&&i.aborted)throw new $e("Request aborted");return this.arrayBuffer.slice(e.offset,e.offset+e.length)}}function Gr(t){return new Br(t)}function Ke(t){switch(t){case F.BYTE:case F.ASCII:case F.SBYTE:case F.UNDEFINED:return 1;case F.SHORT:case F.SSHORT:return 2;case F.LONG:case F.SLONG:case F.FLOAT:case F.IFD:return 4;case F.RATIONAL:case F.SRATIONAL:case F.DOUBLE:case F.LONG8:case F.SLONG8:case F.IFD8:return 8;default:throw new RangeError(`Invalid field type: ${t}`)}}function kr(t){const e=t.GeoKeyDirectory;if(!e)return null;const i={};for(let n=4;n<=e[3]*4;n+=4){const o=dr[e[n]],r=e[n+1]?ve[e[n+1]]:null,c=e[n+2],s=e[n+3];let u=null;if(!r)u=s;else{if(u=t[r],typeof u>"u"||u===null)throw new Error(`Could not get value of geoKey '${o}'.`);typeof u=="string"?u=u.substring(s,s+c-1):u.subarray&&(u=u.subarray(s,s+c),c===1&&(u=u[0]))}i[o]=u}return i}function ye(t,e,i,n){let o=null,r=null;const c=Ke(e);switch(e){case F.BYTE:case F.ASCII:case F.UNDEFINED:o=new Uint8Array(i),r=t.readUint8;break;case F.SBYTE:o=new Int8Array(i),r=t.readInt8;break;case F.SHORT:o=new Uint16Array(i),r=t.readUint16;break;case F.SSHORT:o=new Int16Array(i),r=t.readInt16;break;case F.LONG:case F.IFD:o=new Uint32Array(i),r=t.readUint32;break;case F.SLONG:o=new Int32Array(i),r=t.readInt32;break;case F.LONG8:case F.IFD8:o=new Array(i),r=t.readUint64;break;case F.SLONG8:o=new Array(i),r=t.readInt64;break;case F.RATIONAL:o=new Uint32Array(i*2),r=t.readUint32;break;case F.SRATIONAL:o=new Int32Array(i*2),r=t.readInt32;break;case F.FLOAT:o=new Float32Array(i),r=t.readFloat32;break;case F.DOUBLE:o=new Float64Array(i),r=t.readFloat64;break;default:throw new RangeError(`Invalid field type: ${e}`)}if(e===F.RATIONAL||e===F.SRATIONAL)for(let s=0;s<i;s+=2)o[s]=r.call(t,n+s*c),o[s+1]=r.call(t,n+(s*c+4));else for(let s=0;s<i;++s)o[s]=r.call(t,n+s*c);return e===F.ASCII?new TextDecoder("utf-8").decode(o):o}class Ur{constructor(e,i,n){this.fileDirectory=e,this.geoKeyDirectory=i,this.nextIFDByteOffset=n}}class Fe extends Error{constructor(e){super(`No image at index ${e}`),this.index=e}}class Kr{async readRasters(e={}){const{window:i,width:n,height:o}=e;let{resX:r,resY:c,bbox:s}=e;const u=await this.getImage();let l=u;const h=await this.getImageCount(),y=u.getBoundingBox();if(i&&s)throw new Error('Both "bbox" and "window" passed.');if(n||o){if(i){const[d,w]=u.getOrigin(),[p,b]=u.getResolution();s=[d+i[0]*p,w+i[1]*b,d+i[2]*p,w+i[3]*b]}const g=s||y;if(n){if(r)throw new Error("Both width and resX passed");r=(g[2]-g[0])/n}if(o){if(c)throw new Error("Both width and resY passed");c=(g[3]-g[1])/o}}if(r||c){const g=[];for(let d=0;d<h;++d){const w=await this.getImage(d),{SubfileType:p,NewSubfileType:b}=w.fileDirectory;(d===0||p===2||b&1)&&g.push(w)}g.sort((d,w)=>d.getWidth()-w.getWidth());for(let d=0;d<g.length;++d){const w=g[d],p=(y[2]-y[0])/w.getWidth(),b=(y[3]-y[1])/w.getHeight();if(l=w,r&&r>p||c&&c>b)break}}let m=i;if(s){const[g,d]=u.getOrigin(),[w,p]=l.getResolution(u);m=[Math.round((s[0]-g)/w),Math.round((s[1]-d)/p),Math.round((s[2]-g)/w),Math.round((s[3]-d)/p)],m=[Math.min(m[0],m[2]),Math.min(m[1],m[3]),Math.max(m[0],m[2]),Math.max(m[1],m[3])]}return l.readRasters({...e,window:m})}}class Ze extends Kr{constructor(e,i,n,o,r={}){super(),this.source=e,this.littleEndian=i,this.bigTiff=n,this.firstIFDOffset=o,this.cache=r.cache||!1,this.ifdRequests=[],this.ghostValues=null}async getSlice(e,i){const n=this.bigTiff?4048:1024;return new Rr((await this.source.fetch([{offset:e,length:typeof i<"u"?i:n}]))[0],e,this.littleEndian,this.bigTiff)}async parseFileDirectoryAt(e){const i=this.bigTiff?20:12,n=this.bigTiff?8:2;let o=await this.getSlice(e);const r=this.bigTiff?o.readUint64(e):o.readUint16(e),c=r*i+(this.bigTiff?16:6);o.covers(e,c)||(o=await this.getSlice(e,c));const s={};let u=e+(this.bigTiff?8:2);for(let y=0;y<r;u+=i,++y){const m=o.readUint16(u),g=o.readUint16(u+2),d=this.bigTiff?o.readUint64(u+4):o.readUint32(u+4);let w,p;const b=Ke(g),T=u+(this.bigTiff?12:8);if(b*d<=(this.bigTiff?8:4))w=ye(o,g,d,T);else{const v=o.readOffset(T),R=Ke(g)*d;if(o.covers(v,R))w=ye(o,g,d,v);else{const B=await this.getSlice(v,R);w=ye(B,g,d,v)}}d===1&&lr.indexOf(m)===-1&&!(g===F.RATIONAL||g===F.SRATIONAL)?p=w[0]:p=w,s[ve[m]]=p}const l=kr(s),h=o.readOffset(e+n+i*r);return new Ur(s,l,h)}async requestIFD(e){if(this.ifdRequests[e])return this.ifdRequests[e];if(e===0)return this.ifdRequests[e]=this.parseFileDirectoryAt(this.firstIFDOffset),this.ifdRequests[e];if(!this.ifdRequests[e-1])try{this.ifdRequests[e-1]=this.requestIFD(e-1)}catch(i){throw i instanceof Fe?new Fe(e):i}return this.ifdRequests[e]=(async()=>{const i=await this.ifdRequests[e-1];if(i.nextIFDByteOffset===0)throw new Fe(e);return this.parseFileDirectoryAt(i.nextIFDByteOffset)})(),this.ifdRequests[e]}async getImage(e=0){const i=await this.requestIFD(e);return new Or(i.fileDirectory,i.geoKeyDirectory,this.dataView,this.littleEndian,this.cache,this.source)}async getImageCount(){let e=0,i=!0;for(;i;)try{await this.requestIFD(e),++e}catch(n){if(n instanceof Fe)i=!1;else throw n}return e}async getGhostValues(){const e=this.bigTiff?16:8;if(this.ghostValues)return this.ghostValues;const i="GDAL_STRUCTURAL_METADATA_SIZE=",n=i.length+100;let o=await this.getSlice(e,n);if(i===ye(o,F.ASCII,i.length,e)){const c=ye(o,F.ASCII,n,e).split(`
4
4
  `)[0],s=Number(c.split("=")[1].split(" ")[0])+c.length;s>n&&(o=await this.getSlice(e,s));const u=ye(o,F.ASCII,s,e);this.ghostValues={},u.split(`
5
- `).filter(l=>l.length>0).map(l=>l.split("=")).forEach(([l,h])=>{this.ghostValues[l]=h})}return this.ghostValues}static async fromSource(e,i,n){const o=(await e.fetch([{offset:0,length:1024}],n))[0],r=new Nr(o),c=r.getUint16(0,0);let s;if(c===18761)s=!0;else if(c===19789)s=!1;else throw new TypeError("Invalid byte order value.");const u=r.getUint16(2,s);let l;if(u===42)l=!1;else if(u===43){if(l=!0,r.getUint16(4,s)!==8)throw new Error("Unsupported offset byte-size.")}else throw new TypeError("Invalid magic number.");const h=l?r.getUint64(8,s):r.getUint32(4,s);return new Ze(e,s,l,h,i)}close(){return typeof this.source.close=="function"?this.source.close():!1}}async function Vr(t,e){return Ze.fromSource(Gr(t),e)}function jr(t){const e=U.ref([]);let i=null,n={min:null,max:null,originalMin:null,originalMax:null};async function o(l,h=["#000000","#FFFFFF"]){console.log("Adding TIF layer with URL/File:",l,h);const y=`tif-layer-${new Date().getTime()}`;if(l instanceof File){const m=await N.readFileAsArrayBuffer(l);await r(m,h,y),e.value.push(y)}else if(typeof l=="string"){const g=await(await fetch(l)).arrayBuffer();await r(g,h,y),e.value.push(y)}return{tifId:y,dataRange:n}}async function r(l,h=["#000000","#FFFFFF"],y="geotiff-layer"){var O;const g=await(await Vr(l)).getImage(),d=g.getWidth(),w=g.getHeight(),p=g.fileDirectory||{},b=parseInt(p.GDAL_NODATA)||parseInt(p.NODATA_value)||null;console.log(typeof b,b);const T=N.calculateBounds(g),v=await g.readRasters();i={image:g,data:v,width:d,height:w},console.log("GeoTIFF data loaded:",i);const R=Array.isArray(v)?v:[v];let B=1/0,V=-1/0;for(const Y of R)for(const q of Y)q>-1e10&&q!=b&&(B=Math.min(B,q),V=Math.max(V,q));(!isFinite(B)||!isFinite(V)||B>=V)&&(console.warn("无效的数据范围,使用默认值"),B=0,V=255),n={min:B,max:V,originalMin:B,originalMax:V};const J=u(v,d,w,h,b);if(!J){console.error("Failed to create image data from GeoTIFF.");return}c(J,d,w,T,y),(O=t.value)==null||O.fitBounds([[T[0],T[1]],[T[2],T[3]]],{padding:50})}function c(l,h,y,m,g="geotiff-layer"){var v,R,B,V;const d=g,w=g+"-source";(v=t.value)!=null&&v.getLayer(d)&&t.value.removeLayer(d),(R=t.value)!=null&&R.getSource(w)&&t.value.removeSource(w);const p=document.createElement("canvas");p.width=h,p.height=y;const b=p.getContext("2d");b==null||b.putImageData(l,0,0);const T=p.toDataURL("image/png");(B=t.value)==null||B.addSource(w,{type:"image",url:T,coordinates:[[m[0],m[3]],[m[2],m[3]],[m[2],m[1]],[m[0],m[1]]]}),(V=t.value)==null||V.addLayer({id:d,type:"raster",source:w,paint:{"raster-opacity":.8}})}function s(l){var g,d;const h=l,y=l+"-source";(g=t.value)!=null&&g.getLayer(h)&&t.value.removeLayer(h),(d=t.value)!=null&&d.getSource(y)&&t.value.removeSource(y);const m=e.value.indexOf(l);m!==-1&&e.value.splice(m,1)}function u(l,h,y,m,g=null){const d=document.createElement("canvas");d.width=h,d.height=y;const w=d.getContext("2d"),p=w==null?void 0:w.createImageData(h,y),b=Array.isArray(l)?l:[l],T=h*y;let v=n.min,R=n.max;(v===null||R===null)&&(v=0,R=255);const B=m.map(N.hexToRgb),V=B.length;function J(O){if(V===1||O<=0)return B[0];if(O>=1)return B[V-1];const Y=1/(V-1),q=Math.floor(O/Y),$=(O-q*Y)/Y,z=B[q],te=B[Math.min(q+1,V-1)];return[Math.round(z[0]+(te[0]-z[0])*$),Math.round(z[1]+(te[1]-z[1])*$),Math.round(z[2]+(te[2]-z[2])*$)]}for(let O=0;O<T;O++){let Y,q,$,z;const te=b[0][O];if(g!==null&&te===g)Y=q=$=0,z=0;else if(b.length>=3)g!==null&&(b[0][O]===g||b[1][O]===g||b[2][O]===g)?(Y=q=$=0,z=0):(Y=Math.floor(255*N.clamp((b[0][O]-v)/(R-v),0,1)),q=Math.floor(255*N.clamp((b[1][O]-v)/(R-v),0,1)),$=Math.floor(255*N.clamp((b[2][O]-v)/(R-v),0,1)),z=255);else if(b.length===1){const re=b[0][O];if(re<v)z=0,Y=q=$=0;else if(re>R)Y=255,q=$=0,z=255;else{const _=(re-v)/(R-v),ue=.15,Ie=(_-ue)/(1-ue);[Y,q,$]=J(Ie),z=255}}else{const _=(b[0][O]-v)/(R-v);_<.15?(Y=q=$=0,z=0):(Y=q=$=Math.floor(255*(_-.15)/.85),z=255)}p.data[O*4]=Y,p.data[O*4+1]=q,p.data[O*4+2]=$,p.data[O*4+3]=z}return w==null||w.putImageData(p,0,0),p}return{addTifLayer:o,processGeoTIFF:r,removeTifLayer:s}}const qr=["id"],zr={class:"left-bar"},Yr={class:"right-bar"},$r={class:"bottom-bar"},Zr=U.defineComponent({name:"MapView",__name:"MapView",props:{mapRootId:{default:"mapbox-map"},tdtToken:{},mapBoxToken:{},maxZoom:{default:17},minZoom:{default:3},zoom:{default:10},pitch:{default:60},hasScale:{type:Boolean,default:!0},scalePosition:{default:"bottom-right"},center:{},dbfDataRequest:{type:Function},researchDataRequest:{type:Function},dialogConfig:{default:()=>({center:!1,top:"50px",customClass:"hiper-map-dialog"})},loadIcon:{type:Boolean,default:!0}},emits:["mapReady"],setup(t,{expose:e,emit:i}){const n=U.useTemplateRef("mapRoot"),o=Pt.useMapStore();t.dialogConfig&&o.setDialogConfig(t.dialogConfig);const r=U.ref(),{addTifLayer:c,processGeoTIFF:s,removeTifLayer:u}=jr(r),l=i,h=()=>{var f;ge.accessToken=t.mapBoxToken;const a=o.mapInstances[t.mapRootId];if(r.value=new ge.Map({container:t.mapRootId,style:o.getCurrentMapStyle(t.mapRootId),center:a.center,zoom:a.zoom,pitch:a.pitch,bearing:0,antialias:!0,maxZoom:a.maxZoom,minZoom:a.minZoom,attributionControl:!1}),r.value.on("load",()=>{r.value&&($(),l("mapReady",r.value)),le.mapLoadedBus.emit({mapRootId:t.mapRootId})}),r.value.on("zoomend",()=>{var I;o.setZoom(t.mapRootId,((I=r.value)==null?void 0:I.getZoom())||0)}),t.hasScale){const I=new ge.ScaleControl({maxWidth:80,unit:"metric"});(f=r.value)==null||f.addControl(I,t.scalePosition)}r.value.on("load",()=>{})},y=()=>{var a,f;(a=r.value)==null||a.setStyle(o.getCurrentMapStyle(t.mapRootId)),(f=r.value)==null||f.once("styledata",()=>{console.log("地图样式更新完成,重新加载图层"),d.value.forEach(I=>{w(I)}),le.mapStyleChangedBus.emit({mapRootId:t.mapRootId})})},m=U.ref(!1),g=()=>{if(r.value){const a=o.mapInstances[t.mapRootId];m.value=!0,r.value.flyTo({center:a.center,zoom:a.zoom,bearing:0,pitch:a.threeDPitch,duration:2e3}),a.is3DMode=a.threeDPitch>0,a.pitch=a.threeDPitch,setTimeout(()=>{m.value=!1},2e3)}},d=U.ref([]),w=a=>{var I;if(!r.value){console.warn("地图实例未初始化,无法添加图层");return}const f=d.value.find(D=>D.id===a.id);if(f?Object.assign(f,a):d.value.push(a),a.geoJSON)console.log("渲染geoJSON---->"),b(a);else{const D=N.getLayerId(a);((I=r.value)==null?void 0:I.getLayer(D))==null?(console.log("首次渲染---->"),T(a)):(console.log("非首次渲染---->更新图层"),p(a,JSON.parse(a.layerPaintConfig)))}};function p(a,f){var k,P,M,G,E,L,j,Z,Q,H,ie,we,he,Xe,Je,He,Qe,We;f.fillColorList&&f.fillColorList.length&&(f.fillColorList=f.fillColorList.filter(K=>K.key&&K.value||K.type=="default"));const I=N.getLayerType(a);console.log("currentLayerType--->",I);const D=JSON.parse(JSON.stringify(f));console.log("newStyleConfig---->",D);const S=N.getFillStyle(D);console.log("newFillColorConfig---->",S);const x=N.getOutLineStyle(D);if(console.log("outlineStyle---->",x),I=="fill"&&S&&x)(k=r.value)==null||k.setPaintProperty(N.getLayerId(a),"fill-color",S["fill-color"]),(P=r.value)==null||P.setPaintProperty(N.getLayerId(a),"fill-opacity",S["fill-opacity"]),(M=r.value)==null||M.setPaintProperty(N.getLayerId(a),"fill-outline-color",S["fill-outline-color"]),x&&x["line-color"]&&((G=r.value)==null||G.setPaintProperty(N.getLayerId(a)+"-outline","line-color",x["line-color"])),x&&x["line-opacity"],x&&x["line-width"]&&((E=r.value)==null||E.setPaintProperty(N.getLayerId(a)+"-outline","line-width",x["line-width"])),(L=r.value)==null||L.setPaintProperty(N.getLayerId(a)+"-outline","line-dasharray",[]),x&&x["line-dasharray"]&&(console.log("outlineStyle['line-dasharray']----->",x["line-dasharray"]),(j=r.value)==null||j.setPaintProperty(N.getLayerId(a)+"-outline","line-dasharray",x["line-dasharray"]));else if(I=="line")x&&x["line-color"]&&((Z=r.value)==null||Z.setPaintProperty(N.getLayerId(a),"line-color",x["line-color"])),x&&x["line-opacity"]&&((Q=r.value)==null||Q.setPaintProperty(N.getLayerId(a),"line-opacity",x["line-opacity"])),x&&x["line-width"]&&((H=r.value)==null||H.setPaintProperty(N.getLayerId(a),"line-width",x["line-width"])),(ie=r.value)==null||ie.setPaintProperty(N.getLayerId(a),"line-dasharray",[]),x&&x["line-dasharray"]&&((we=r.value)==null||we.setPaintProperty(N.getLayerId(a),"line-dasharray",x["line-dasharray"]));else if(I=="circle"){const K=N.getCircleStyle(D);K&&K["circle-color"]&&((he=r.value)==null||he.setPaintProperty(N.getLayerId(a),"circle-color",K["circle-color"])),K&&K["circle-opacity"]&&((Xe=r.value)==null||Xe.setPaintProperty(N.getLayerId(a),"circle-opacity",K["circle-opacity"])),K&&K["circle-radius"]&&((Je=r.value)==null||Je.setPaintProperty(N.getLayerId(a),"circle-radius",K["circle-radius"])),K&&K["circle-stroke-color"]&&((He=r.value)==null||He.setPaintProperty(N.getLayerId(a),"circle-stroke-color",K["circle-stroke-color"])),K&&K["circle-stroke-width"]&&((Qe=r.value)==null||Qe.setPaintProperty(N.getLayerId(a),"circle-stroke-width",K["circle-stroke-width"]))}else if(I=="symbol"){const K=N.getCircleStyle(D);K&&K["icon-image"]&&((We=r.value)==null||We.setLayoutProperty(N.getLayerId(a),"icon-image",K["icon-image"]))}const A=[];let{symbolConfigList:C}=D;C=C.filter(K=>K.fontSize&&K.field&&K.textColor),C.forEach((K,Jr)=>{var _e,et,tt,rt;const Pe="points-symbol-"+a.id+K.field,bt=N.getSourceId(a);((_e=r.value)==null?void 0:_e.getLayer(Pe))?((tt=r.value)==null||tt.setLayoutProperty(Pe,"text-size",K.fontSize),(rt=r.value)==null||rt.setPaintProperty(Pe,"text-color",K.textColor)):((et=r.value)==null||et.addLayer({id:Pe,type:"symbol",source:bt,layout:{visibility:"visible","text-field":["get",K.field],"text-size":K.fontSize,"symbol-avoid-edges":!0,"icon-image":"circle-11","text-ignore-placement":!1,"text-max-angle":38},paint:{"text-color":K.textColor}}),A.push(K.field))})}function b(a){var x,A,C,k,P,M,G,E,L,j;if(!a.customLayerConfig||!a.geoJSON){console.warn("图层配置缺失,无法渲染图层");return}const f=JSON.parse(a.customLayerConfig),I=N.getLayerId(a);((x=r.value)==null?void 0:x.getLayer(I))!==void 0&&(console.warn(`图层 ${I} 已存在,无法重复添加`),(A=r.value)==null||A.removeLayer(I),(C=r.value)==null||C.removeSource(I));const S=JSON.parse(a.geoJSON);switch(a.layerType){case"symbol":const Z={id:I,type:"symbol",source:{type:"geojson",data:{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:S.features[0].geometry.coordinates},properties:{title:a.layerName||f.iconName,icon:`${f.iconName}`}}]}},layout:{"icon-image":"{icon}","icon-size":.1,"icon-anchor":"center","text-field":"{title}","text-font":["Open Sans Semibold","Arial Unicode MS Bold"],"text-offset":[0,1.8],"text-anchor":"center","text-size":12,"text-allow-overlap":!0,"text-optional":!0},paint:{"text-color":f.textColor,"text-halo-color":"rgba(0,0,0,0.32)","text-halo-width":1,"text-halo-blur":2,"text-translate":[0,0]}};(k=r.value)==null||k.addLayer(Z);break;case"line":const Q={id:I,type:"line",source:{type:"geojson",data:S},layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":f.lineColor,"line-width":Number(f.lineWidth)}};f.lineStyle=="dotted"&&(Q.paint["line-dasharray"]=[5.2,5.2]),(P=r.value)==null||P.addLayer(Q);break;case"shape":let H=I+"-outline";const ie={id:H,type:"line",source:{type:"geojson",data:JSON.parse(a.geoJSON)},layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":f.fillColor,"line-width":Number(f.lineWidth)}};((M=r.value)==null?void 0:M.getLayer(H))!==void 0&&((G=r.value)==null||G.removeLayer(H),(E=r.value)==null||E.removeSource(H)),(L=r.value)==null||L.addLayer(ie);const he={id:I,type:"fill",source:{type:"geojson",data:S},layout:{},paint:{"fill-color":f.fillColor,"fill-opacity":.32}};(j=r.value)==null||j.addLayer(he);break}}function T(a){var C,k,P,M,G;console.log("加载图层---->",a);const f=N.getLayerId(a),I=N.getSourceId(a);console.log("sourceId--->",I);const D=N.parseStyleConfig(a);console.log("styleConfig",D);const S=N.getLayerType(a);((C=r.value)==null?void 0:C.getSource(I))||(P=r.value)==null||P.addSource(I,{type:"geojson",data:(k=a.url)==null?void 0:k.replace("bjhweb","bjh")}),console.log("layerType--->",S);const A={id:f,source:I,name:f,layout:{visibility:"visible"},type:S};if(S!="symbol")A.paint=N.getLayerStyle(a);else{const E=N.getLayerStyle(a);A.layout={visibility:"visible","symbol-placement":"line","symbol-spacing":10,"icon-size":.1,"icon-keep-upright":!0,"icon-rotate":0,"icon-allow-overlap":!0,...E}}if(console.log("layerConfig--->",A),(M=r.value)==null||M.addLayer(A),S=="fill"){const E=N.getOutLineStyle(D);(G=r.value)==null||G.addLayer({id:f+"-outline",source:I,name:f+"-outline",layout:{visibility:"visible","line-join":"round","line-cap":"round"},type:"line",paint:{"line-color":E["line-color"],"line-width":E["line-width"],"line-dasharray":E["line-dasharray"]||[]}})}}const v=U.ref([]);function R(a){if(!r.value){console.warn("地图实例未初始化,无法添加调查数据图层");return}q(a);const f=a.pointInfo?a.pointInfo:JSON.parse(a.rowDataInstance??"{}");let I=null;if(f.latitude&&f.longitude&&(I=[parseFloat(f.longitude),parseFloat(f.latitude)]),f.latitudeStart&&f.longitudeStart&&(I=[parseFloat(f.longitudeStart),parseFloat(f.latitudeStart)]),a.layerType=="line"){const D={outlineColor:"#02d2e0",outlineWidth:3};let S=a.layerPaintConfig?JSON.parse(a.layerPaintConfig):D;if(!a.lineInfo){console.error("调查数据缺失,无法添加线图层");return}const x=a.lineInfo;let A=[];I&&I.length&&A.push(I),x.forEach(L=>{A.push([Number(L.longitude),Number(L.latitude)])});const k={type:"geojson",data:{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"LineString",coordinates:A}}]}},P=`${a.id}-geo-line-source`,M=r.value.getSource(P),G=`${a.id}-geo-line-layer`,E=r.value.getLayer(G);if(A.length>0){M||r.value.addSource(P,k),E&&r.value.removeLayer(G);let L={"line-color":S.outlineColor,"line-width":S.outlineWidth,"line-opacity":1};switch(S.outlineStyle){case"simple-dash":L["line-dasharray"]=[2,2];break;case"dot-dash":L["line-dasharray"]=[1,2,3,2];break;case"long-dash":L["line-dasharray"]=[4,2];break;case"dot-line":L["line-dasharray"]=[.1,2];break;case"complex-pattern":L["line-dasharray"]=[2,2,1,2];break}r.value.addLayer({id:G,type:"line",source:P,paint:L})}r.value.easeTo({zoom:17,center:A[0]})}else{const D={pointTintColor:"#02d2e0",pointRenderType:"points"};let S=a.layerPaintConfig?JSON.parse(a.layerPaintConfig):D;if(console.log("走这里---->",a),!a.lineInfo){console.error("调查数据缺失,无法添加点图层");return}if(!r.value){console.warn("地图实例未初始化,无法添加点图层");return}a.lineInfo.forEach(x=>{var E;let A=[0,0];x.latitude&&x.longitude&&(A=[Number(x.longitude),Number(x.latitude)]),x.latitudeStart&&x.longitudeStart&&(A=[Number(x.longitudeStart),Number(x.latitudeStart)]),console.log("layerPaintConfig.pointRenderType ",S);const C=document.createElement("div");if(S.pointRenderType=="icons"){C.className="research-location-icon-el";const L=document.createElement("img");L.className="research-location-img-el",L.src=Le.mapIconBaseUrl+S.currentMapIconName,C.appendChild(L)}else{C.className="research-location-point";const L=document.createElement("div");L.className="research-location-point-content",C.appendChild(L);const j=document.createElement("div");j.className="research-location-point-content-inner",j.style.backgroundColor=S.pointTintColor?S.pointTintColor:"#02d2e0",L.appendChild(j);const Z=document.createElement("div");Z.className="research-location-point-line",C.appendChild(Z)}C.onclick=L=>{Y(L,JSON.parse(a.rowDataInstance??"{}"))};const k=`${a.id}-research-point`,P=v.value.find(L=>L.id==k);P&&P.marker&&((E=P.marker)==null||E.remove());let M=new ge.Marker(C).setLngLat(A).setOffset([0,-22]).addTo(r.value),G=-1;v.value.forEach((L,j)=>{L.id==k&&(G=j)}),G>-1?v.value[G].marker=M:v.value.push({id:k,marker:M})})}J()}const B=U.ref(),V=U.ref();function J(){B.value&&B.value.hidePopup(),V.value&&V.value.hidePopup(),O.value&&O.value.hidePopup()}const O=U.ref();function Y(a,f){const{clientX:I,clientY:D}=a,S=I+28,x=D-60;O.value.showPopup(S,x,f)}function q(a){const f=d.value.find(I=>I.id===a.id);f?Object.assign(f,a):d.value.push(a)}function $(){if(!t.loadIcon)return Promise.resolve(!0);if(!r.value)return Promise.reject(new Error("地图实例未初始化,无法加载图标资源"));const a=Le.mapIconNameList.map(f=>new Promise((I,D)=>{var S;(S=r.value)==null||S.loadImage(Le.mapIconBaseUrl+f.fileName,(x,A)=>{var C;x?D(x):(A&&((C=r.value)==null||C.addImage(f.fileName,A)),I(!0))})}));return Promise.all(a)}function z(a){var x,A,C,k,P,M,G,E;console.log("removeThirdPartyLayer---->",a);const f=N.getLayerId(a),I=N.getLayerType(a),D=(x=r.value)==null?void 0:x.getLayer(f);console.log("currentLayerType---->",I,D);let S=-1;if(d.value.forEach((L,j)=>{L.id==a.id&&(S=j)}),S>-1&&d.value.splice(S,1),D){const L=(A=r.value)==null?void 0:A.getLayer(f);if(L){const j=L.source;(C=r.value)==null||C.removeLayer(f),a.geoJSON&&j&&((k=r.value)==null||k.removeSource(j))}}if(I=="fill"){console.log("移除边框----->");const L=f+"-outline",j=(P=r.value)==null?void 0:P.getLayer(L),Z=(M=r.value)==null?void 0:M.getLayer(L);if(Z){const Q=Z.source;j&&((G=r.value)==null||G.removeLayer(L)),a.geoJSON&&Q&&((E=r.value)==null||E.removeSource(Q))}}J()}U.watch(()=>{var a;return(a=o.mapInstances[t.mapRootId])==null?void 0:a.activeMapLayer},()=>{r.value&&y()},{immediate:!0}),U.watch(()=>{var a;return(a=o.mapInstances[t.mapRootId])==null?void 0:a.zoom},()=>{r.value&&!m.value&&r.value.flyTo({zoom:o.mapInstances[t.mapRootId].zoom,duration:500})},{immediate:!0}),U.watch(()=>{var a;return(a=o.mapInstances[t.mapRootId])==null?void 0:a.pitch},()=>{r.value&&!m.value&&(o.isDragging?r.value.setPitch(o.mapInstances[t.mapRootId].pitch):r.value.flyTo({pitch:o.mapInstances[t.mapRootId].pitch,duration:1e3}))},{immediate:!0}),U.watch(()=>{var a;return(a=o.mapInstances[t.mapRootId])==null?void 0:a.bearing},()=>{r.value&&!m.value&&(o.isDragging?r.value.setBearing(o.mapInstances[t.mapRootId].bearing):r.value.flyTo({bearing:o.mapInstances[t.mapRootId].bearing,duration:1e3}))},{immediate:!0});const te=a=>{r.value&&(r.value.flyTo({zoom:4,duration:400}),setTimeout(async()=>{var S,x,A,C,k;if(!a)return;let f=N.getSourceId(a);if(a.geoJSON&&(f=N.getLayerId(a)),a.url&&!a.geoJSON)try{const P=a.url.replace("bjhweb","bjh"),G=await(await fetch(P)).json();if(G&&G.features&&G.features.length>0){const E=Ce.bbox(G);if(E&&!re(E)){(S=r.value)==null||S.fitBounds([[E[0],E[1]],[E[2],E[3]]],{padding:{top:50,bottom:50,left:50,right:50}});return}}}catch(P){console.warn("从URL获取GeoJSON数据失败,尝试其他方法",P)}const I=(x=r.value)==null?void 0:x.getSource(f);if(I&&I._data&&I._data.features){const P=I._data,M=Ce.bbox(P);if(!re(M)){(A=r.value)==null||A.fitBounds([[M[0],M[1]],[M[2],M[3]]],{padding:{top:50,bottom:50,left:50,right:50}});return}}const D=(C=r.value)==null?void 0:C.querySourceFeatures(f);if(D&&D.length>0){const P=Ce.featureCollection(D),M=Ce.bbox(P);re(M)?console.warn("获取的边界框无效"):(k=r.value)==null||k.fitBounds([[M[0],M[1]],[M[2],M[3]]],{padding:{top:50,bottom:50,left:50,right:50}})}else console.warn("没有查询到图层数据")},500))};function re(a){return a[0]===1/0||a[1]===1/0||a[2]===-1/0||a[3]===-1/0||isNaN(a[0])||isNaN(a[1])||isNaN(a[2])||isNaN(a[3])}U.provide("resetMapView",g),U.provide("mapRootId",t.mapRootId),t.dbfDataRequest&&U.provide(De.dbfDataRequestKey,t.dbfDataRequest),t.researchDataRequest&&U.provide(De.researchDataRequestKey,t.researchDataRequest),U.provide(De.mapInstanceKey,r),U.provide(De.thirdPartyLayersKey,d);const _=({mapRootId:a,layer:f})=>{a===a&&(console.log("接收到渲染地理数据事件",f),f.layerDataType=="research"&&w(f))};le.renderGeographicDataKeyBus.on(_),e({mapInstance:r,initMap:h,handleSetMapStyle:y,resetMapView:g,addThirdPartyLayer:w,addResearchMapLayer:R,addTifLayer:c,processGeoTIFF:s,removeTifLayer:u}),U.onBeforeMount(()=>{o.mapInstances[t.mapRootId]={maxZoom:t.maxZoom,minZoom:t.minZoom,zoom:t.zoom,pitch:t.pitch,threeDPitch:t.pitch,center:t.center||[120.1551,30.2741],bearing:0,is3DMode:t.pitch>0,activeMapLayer:Lt.MapLayerType.SATELLITE,mapHeight:600,mapWidth:600,mapX:0,mapY:0}});function ue(a){var D,S,x,A;q(a);const f={outlineColor:"#02d2e0",outlineWidth:3,outlineOpacity:.72,pointTintColor:"#02d2e0"};let I=a.layerPaintConfig?JSON.parse(a.layerPaintConfig):f;if(console.log("layerPaintConfig--->",I),I.pointRenderType&&I.pointRenderType=="heatMap"){let C=a.id+"-source",k=a.id+"-layer",P=[];a.children&&a.children.forEach(M=>{let G=[0,0];const E=JSON.parse(M.rowDataInstance);E.latitude&&E.longitude&&(G=[Number(E.longitude),Number(E.latitude)]),E.latitudeStart&&E.longitudeStart&&(G=[Number(E.longitudeStart),Number(E.latitudeStart)]),P.push({type:"Feature",properties:{},geometry:{type:"Point",coordinates:G}})}),(D=r.value)==null||D.addSource(C,{type:"geojson",data:{type:"FeatureCollection",features:P}}),(S=r.value)==null||S.addLayer({id:k,type:"heatmap",source:C,maxzoom:9,paint:{"heatmap-weight":1,"heatmap-intensity":["interpolate",["linear"],["zoom"],0,1,9,3],"heatmap-color":["interpolate",["linear"],["heatmap-density"],0,"rgba(33,102,172,0)",.2,"blue",.4,"cyan",.6,"lime",.8,"yellow",1,"red"],"heatmap-radius":["interpolate",["linear"],["zoom"],0,2,9,20],"heatmap-opacity":["interpolate",["linear"],["zoom"],7,1,9,0]}})}else I.pointRenderType&&I.pointRenderType=="icons"?(console.log("走这里----->, icons",v.value),console.log("mapLayer.children",a.children),(x=a.children)==null||x.forEach(C=>{var j;let k=[0,0];const P=JSON.parse(C.rowDataInstance);P.latitude&&P.longitude&&(k=[Number(P.longitude),Number(P.latitude)]),P.latitudeStart&&P.longitudeStart&&(k=[Number(P.longitudeStart),Number(P.latitudeStart)]);const M=document.createElement("div");M.className="research-location-icon-el";const G=document.createElement("img");G.className="research-location-img-el",G.src=Le.mapIconBaseUrl+I.currentMapIconName,M.appendChild(G);const E=`${C.id}-research-point`,L=v.value.find(Z=>Z.id==E);if(L&&L.marker&&((j=L.marker)==null||j.remove()),r.value){let Z=new ge.Marker(M).setLngLat(k).setOffset([0,-22]).addTo(r.value),Q=-1;v.value.forEach((H,ie)=>{H.id==E&&(Q=ie)}),Q>-1?v.value[Q].marker=Z:v.value.push({id:E,marker:Z})}})):(A=a.children)==null||A.forEach(C=>{var Q;let k=[0,0];const P=JSON.parse(C.rowDataInstance);P.latitude&&P.longitude&&(k=[Number(P.longitude),Number(P.latitude)]),P.latitudeStart&&P.longitudeStart&&(k=[Number(P.longitudeStart),Number(P.latitudeStart)]);const M=document.createElement("div");M.className="research-location-point";const G=document.createElement("div");G.className="research-location-point-content",M.appendChild(G);const E=document.createElement("div");E.className="research-location-point-content-inner",E.style.backgroundColor=I.pointTintColor?I.pointTintColor:"#02d2e0",G.appendChild(E);const L=document.createElement("div");L.className="research-location-point-line",M.appendChild(L),M.onclick=H=>{console.log(H)};const j=`${C.id}-research-point`,Z=v.value.find(H=>H.id==j);if(Z&&Z.marker&&((Q=Z.marker)==null||Q.remove()),r.value){let H=new ge.Marker(M).setLngLat(k).setOffset([0,-22]).addTo(r.value),ie=-1;v.value.forEach((we,he)=>{we.id==j&&(ie=he)}),ie>-1?v.value[ie].marker=H:v.value.push({id:j,marker:H})}});J()}function Ie(a){var x,A,C;se(a);const f=`${a.id}-geo-line-layer`,I=`${a.id}-research-point`;((x=r.value)==null?void 0:x.getLayer(f))&&((A=r.value)==null||A.removeLayer(f));let S=-1;v.value.forEach((k,P)=>{k.id==I&&(S=P)}),S>-1&&(v.value[S].marker&&((C=v.value[S].marker)==null||C.remove()),v.value.splice(S,1)),J()}const fe=async({mapRootId:a,topic:f,visible:I,delLayer:D})=>{var S;if(console.log("接收到图层切换事件",t.mapRootId,a,f),a===t.mapRootId&&r.value)if(I)if(console.log("delLayer",D),D&&(console.log("mmb: 删除图层",f),z(f)),f.layerType=="species-group")ue(f);else if(f.layerDataType=="research"){if(f.layerType=="line"||f.layerType=="symbol"){if(!f.lineInfo){const x=await((S=t.researchDataRequest)==null?void 0:S.call(t,f));if(x){const{lineInfo:A,pointInfo:C}=x;f.lineInfo=A,f.pointInfo=C}}R(f)}}else w(f);else f.layerType=="species-group"?de(f):f.layerDataType=="research"?Ie(f):z(f)};function se(a){let f=-1;d.value.forEach((I,D)=>{I.id==a.id&&(f=D)}),f>-1&&d.value.splice(f,1)}function de(a){var f,I,D;if(se(a),a.layerPaintConfig){const S=JSON.parse(a.layerPaintConfig);if(S&&S.pointRenderType=="heatMap"){let x=a.id+"-source",A=a.id+"-layer";(f=r.value)==null||f.removeLayer(A),(I=r.value)==null||I.removeSource(x)}else(D=a.children)==null||D.forEach(x=>{var M,G,E;const A=`${x.id}-geo-line-layer`,C=`${x.id}-research-point`;((M=r.value)==null?void 0:M.getLayer(A))&&((G=r.value)==null||G.removeLayer(A));let P=-1;v.value.forEach((L,j)=>{L.id==C&&(P=j)}),P>-1&&(v.value[P].marker&&((E=v.value[P].marker)==null||E.remove()),v.value.splice(P,1))})}J()}const be=({mapRootId:a,layer:f})=>{a===t.mapRootId&&(console.log("接收到定位到图层中心事件",f),r.value&&te(f))};return U.onMounted(()=>{var a,f,I,D;o.setMapBoxToken(t.mapBoxToken),o.setTdtToken(t.tdtToken),o.setMaxZoom(t.mapRootId,t.maxZoom),o.setMinZoom(t.mapRootId,t.minZoom),o.setZoom(t.mapRootId,t.zoom),o.setPitch(t.mapRootId,t.pitch),o.setThreeDPitch(t.mapRootId,t.pitch),t.center&&Array.isArray(t.center)&&t.center.length>0?(o.setCenter(t.mapRootId,t.center),h()):navigator.geolocation.getCurrentPosition(S=>{const{latitude:x,longitude:A}=S.coords;o.setCenter(t.mapRootId,[A,x]),h()},()=>{o.setCenter(t.mapRootId,[104.1954,35.8617]),o.setZoom(t.mapRootId,4),h()}),o.mapInstances[t.mapRootId]&&(o.mapInstances[t.mapRootId].mapHeight=((a=n.value)==null?void 0:a.clientHeight)??600,o.mapInstances[t.mapRootId].mapWidth=((f=n.value)==null?void 0:f.clientWidth)??600,o.mapInstances[t.mapRootId].mapX=((I=n.value)==null?void 0:I.getBoundingClientRect().left)??600,o.mapInstances[t.mapRootId].mapY=((D=n.value)==null?void 0:D.getBoundingClientRect().top)??600),console.log("mapStore.mapInstances[mapRootId]--->",t.mapRootId),le.toggleGeographicLayerKeyBus.on(fe),le.locateToLayerCenterKeyBus.on(be)}),U.onUnmounted(()=>{console.log("组件卸载,清理事件监听"),le.renderGeographicDataKeyBus.off(_),le.toggleGeographicLayerKeyBus.off(fe),le.locateToLayerCenterKeyBus.off(be)}),(a,f)=>(U.openBlock(),U.createElementBlock("div",{class:"qy-map",ref_key:"mapRoot",ref:n},[U.createElementVNode("div",{class:"hiper-map-warper",id:a.mapRootId},[U.createElementVNode("div",zr,[U.renderSlot(a.$slots,"leftBar",{},void 0,!0)]),U.createElementVNode("div",Yr,[U.renderSlot(a.$slots,"rightBar",{},void 0,!0)]),U.createElementVNode("div",{class:"top-bar",style:U.normalizeStyle({left:U.unref(o).topicVisible?U.unref(o).topicWidth+50+"px":"70px"})},[U.renderSlot(a.$slots,"topBar",{},void 0,!0)],4),U.createElementVNode("div",$r,[U.renderSlot(a.$slots,"bottomBar",{},void 0,!0)]),U.renderSlot(a.$slots,"default",{},void 0,!0)],8,qr)],512))}}),Xr=Ct._export_sfc(Zr,[["__scopeId","data-v-e8cac047"]]);exports.LercAddCompression=fr;exports.LercParameters=ur;exports.MapView=Xr;
5
+ `).filter(l=>l.length>0).map(l=>l.split("=")).forEach(([l,h])=>{this.ghostValues[l]=h})}return this.ghostValues}static async fromSource(e,i,n){const o=(await e.fetch([{offset:0,length:1024}],n))[0],r=new Nr(o),c=r.getUint16(0,0);let s;if(c===18761)s=!0;else if(c===19789)s=!1;else throw new TypeError("Invalid byte order value.");const u=r.getUint16(2,s);let l;if(u===42)l=!1;else if(u===43){if(l=!0,r.getUint16(4,s)!==8)throw new Error("Unsupported offset byte-size.")}else throw new TypeError("Invalid magic number.");const h=l?r.getUint64(8,s):r.getUint32(4,s);return new Ze(e,s,l,h,i)}close(){return typeof this.source.close=="function"?this.source.close():!1}}async function Vr(t,e){return Ze.fromSource(Gr(t),e)}function jr(t){const e=U.ref([]);let i=null,n={min:null,max:null,originalMin:null,originalMax:null};async function o(l,h=["#000000","#FFFFFF"]){console.log("Adding TIF layer with URL/File:",l,h);const y=`tif-layer-${new Date().getTime()}`;if(l instanceof File){const m=await N.readFileAsArrayBuffer(l);await r(m,h,y),e.value.push(y)}else if(typeof l=="string"){const g=await(await fetch(l)).arrayBuffer();await r(g,h,y),e.value.push(y)}return{tifId:y,dataRange:n}}async function r(l,h=["#000000","#FFFFFF"],y="geotiff-layer"){var O;const g=await(await Vr(l)).getImage(),d=g.getWidth(),w=g.getHeight(),p=g.fileDirectory||{};console.log("fileDirectory",p);const b=parseInt(p.GDAL_NODATA);console.log("GDAL_NODATA",typeof b,b);const T=N.calculateBounds(g),v=await g.readRasters();i={image:g,data:v,width:d,height:w},console.log("GeoTIFF data loaded:",i);const R=Array.isArray(v)?v:[v];let B=1/0,V=-1/0;for(const Y of R)for(const q of Y)q>-1e10&&q!=b&&(B=Math.min(B,q),V=Math.max(V,q));(!isFinite(B)||!isFinite(V)||B>=V)&&(console.warn("无效的数据范围,使用默认值"),B=0,V=255),n={min:B,max:V,originalMin:B,originalMax:V},console.log("Data range calculated:",n);const J=u(v,d,w,h,b);if(!J){console.error("Failed to create image data from GeoTIFF.");return}c(J,d,w,T,y),(O=t.value)==null||O.fitBounds([[T[0],T[1]],[T[2],T[3]]],{padding:50})}function c(l,h,y,m,g="geotiff-layer"){var v,R,B,V;const d=g,w=g+"-source";(v=t.value)!=null&&v.getLayer(d)&&t.value.removeLayer(d),(R=t.value)!=null&&R.getSource(w)&&t.value.removeSource(w);const p=document.createElement("canvas");p.width=h,p.height=y;const b=p.getContext("2d");b==null||b.putImageData(l,0,0);const T=p.toDataURL("image/png");(B=t.value)==null||B.addSource(w,{type:"image",url:T,coordinates:[[m[0],m[3]],[m[2],m[3]],[m[2],m[1]],[m[0],m[1]]]}),(V=t.value)==null||V.addLayer({id:d,type:"raster",source:w,paint:{"raster-opacity":.8}})}function s(l){var g,d;const h=l,y=l+"-source";(g=t.value)!=null&&g.getLayer(h)&&t.value.removeLayer(h),(d=t.value)!=null&&d.getSource(y)&&t.value.removeSource(y);const m=e.value.indexOf(l);m!==-1&&e.value.splice(m,1)}function u(l,h,y,m,g=null){const d=document.createElement("canvas");d.width=h,d.height=y;const w=d.getContext("2d"),p=w==null?void 0:w.createImageData(h,y),b=Array.isArray(l)?l:[l],T=h*y;let v=n.min,R=n.max;(v===null||R===null)&&(v=0,R=255);const B=m.map(N.hexToRgb),V=B.length;function J(O){if(V===1||O<=0)return B[0];if(O>=1)return B[V-1];const Y=1/(V-1),q=Math.floor(O/Y),$=(O-q*Y)/Y,z=B[q],te=B[Math.min(q+1,V-1)];return[Math.round(z[0]+(te[0]-z[0])*$),Math.round(z[1]+(te[1]-z[1])*$),Math.round(z[2]+(te[2]-z[2])*$)]}for(let O=0;O<T;O++){let Y,q,$,z;const te=b[0][O];if(g!==null&&te===g)Y=q=$=0,z=0;else if(b.length>=3)g!==null&&(b[0][O]===g||b[1][O]===g||b[2][O]===g)?(Y=q=$=0,z=0):(Y=Math.floor(255*N.clamp((b[0][O]-v)/(R-v),0,1)),q=Math.floor(255*N.clamp((b[1][O]-v)/(R-v),0,1)),$=Math.floor(255*N.clamp((b[2][O]-v)/(R-v),0,1)),z=255);else if(b.length===1){const re=b[0][O];if(re<v)z=0,Y=q=$=0;else if(re>R)Y=255,q=$=0,z=255;else{const _=(re-v)/(R-v),ue=.15,Ie=(_-ue)/(1-ue);[Y,q,$]=J(Ie),z=255}}else{const _=(b[0][O]-v)/(R-v);_<.15?(Y=q=$=0,z=0):(Y=q=$=Math.floor(255*(_-.15)/.85),z=255)}p.data[O*4]=Y,p.data[O*4+1]=q,p.data[O*4+2]=$,p.data[O*4+3]=z}return w==null||w.putImageData(p,0,0),p}return{addTifLayer:o,processGeoTIFF:r,removeTifLayer:s}}const qr=["id"],zr={class:"left-bar"},Yr={class:"right-bar"},$r={class:"bottom-bar"},Zr=U.defineComponent({name:"MapView",__name:"MapView",props:{mapRootId:{default:"mapbox-map"},tdtToken:{},mapBoxToken:{},maxZoom:{default:17},minZoom:{default:3},zoom:{default:10},pitch:{default:60},hasScale:{type:Boolean,default:!0},scalePosition:{default:"bottom-right"},center:{},dbfDataRequest:{type:Function},researchDataRequest:{type:Function},dialogConfig:{default:()=>({center:!1,top:"50px",customClass:"hiper-map-dialog"})},loadIcon:{type:Boolean,default:!0}},emits:["mapReady"],setup(t,{expose:e,emit:i}){const n=U.useTemplateRef("mapRoot"),o=Pt.useMapStore();t.dialogConfig&&o.setDialogConfig(t.dialogConfig);const r=U.ref(),{addTifLayer:c,processGeoTIFF:s,removeTifLayer:u}=jr(r),l=i,h=()=>{var f;ge.accessToken=t.mapBoxToken;const a=o.mapInstances[t.mapRootId];if(r.value=new ge.Map({container:t.mapRootId,style:o.getCurrentMapStyle(t.mapRootId),center:a.center,zoom:a.zoom,pitch:a.pitch,bearing:0,antialias:!0,maxZoom:a.maxZoom,minZoom:a.minZoom,attributionControl:!1}),r.value.on("load",()=>{r.value&&($(),l("mapReady",r.value)),le.mapLoadedBus.emit({mapRootId:t.mapRootId})}),r.value.on("zoomend",()=>{var I;o.setZoom(t.mapRootId,((I=r.value)==null?void 0:I.getZoom())||0)}),t.hasScale){const I=new ge.ScaleControl({maxWidth:80,unit:"metric"});(f=r.value)==null||f.addControl(I,t.scalePosition)}r.value.on("load",()=>{})},y=()=>{var a,f;(a=r.value)==null||a.setStyle(o.getCurrentMapStyle(t.mapRootId)),(f=r.value)==null||f.once("styledata",()=>{console.log("地图样式更新完成,重新加载图层"),d.value.forEach(I=>{w(I)}),le.mapStyleChangedBus.emit({mapRootId:t.mapRootId})})},m=U.ref(!1),g=()=>{if(r.value){const a=o.mapInstances[t.mapRootId];m.value=!0,r.value.flyTo({center:a.center,zoom:a.zoom,bearing:0,pitch:a.threeDPitch,duration:2e3}),a.is3DMode=a.threeDPitch>0,a.pitch=a.threeDPitch,setTimeout(()=>{m.value=!1},2e3)}},d=U.ref([]),w=a=>{var I;if(!r.value){console.warn("地图实例未初始化,无法添加图层");return}const f=d.value.find(D=>D.id===a.id);if(f?Object.assign(f,a):d.value.push(a),a.geoJSON)console.log("渲染geoJSON---->"),b(a);else{const D=N.getLayerId(a);((I=r.value)==null?void 0:I.getLayer(D))==null?(console.log("首次渲染---->"),T(a)):(console.log("非首次渲染---->更新图层"),p(a,JSON.parse(a.layerPaintConfig)))}};function p(a,f){var k,P,M,G,E,L,j,Z,Q,H,ie,we,he,Xe,Je,He,Qe,We;f.fillColorList&&f.fillColorList.length&&(f.fillColorList=f.fillColorList.filter(K=>K.key&&K.value||K.type=="default"));const I=N.getLayerType(a);console.log("currentLayerType--->",I);const D=JSON.parse(JSON.stringify(f));console.log("newStyleConfig---->",D);const S=N.getFillStyle(D);console.log("newFillColorConfig---->",S);const x=N.getOutLineStyle(D);if(console.log("outlineStyle---->",x),I=="fill"&&S&&x)(k=r.value)==null||k.setPaintProperty(N.getLayerId(a),"fill-color",S["fill-color"]),(P=r.value)==null||P.setPaintProperty(N.getLayerId(a),"fill-opacity",S["fill-opacity"]),(M=r.value)==null||M.setPaintProperty(N.getLayerId(a),"fill-outline-color",S["fill-outline-color"]),x&&x["line-color"]&&((G=r.value)==null||G.setPaintProperty(N.getLayerId(a)+"-outline","line-color",x["line-color"])),x&&x["line-opacity"],x&&x["line-width"]&&((E=r.value)==null||E.setPaintProperty(N.getLayerId(a)+"-outline","line-width",x["line-width"])),(L=r.value)==null||L.setPaintProperty(N.getLayerId(a)+"-outline","line-dasharray",[]),x&&x["line-dasharray"]&&(console.log("outlineStyle['line-dasharray']----->",x["line-dasharray"]),(j=r.value)==null||j.setPaintProperty(N.getLayerId(a)+"-outline","line-dasharray",x["line-dasharray"]));else if(I=="line")x&&x["line-color"]&&((Z=r.value)==null||Z.setPaintProperty(N.getLayerId(a),"line-color",x["line-color"])),x&&x["line-opacity"]&&((Q=r.value)==null||Q.setPaintProperty(N.getLayerId(a),"line-opacity",x["line-opacity"])),x&&x["line-width"]&&((H=r.value)==null||H.setPaintProperty(N.getLayerId(a),"line-width",x["line-width"])),(ie=r.value)==null||ie.setPaintProperty(N.getLayerId(a),"line-dasharray",[]),x&&x["line-dasharray"]&&((we=r.value)==null||we.setPaintProperty(N.getLayerId(a),"line-dasharray",x["line-dasharray"]));else if(I=="circle"){const K=N.getCircleStyle(D);K&&K["circle-color"]&&((he=r.value)==null||he.setPaintProperty(N.getLayerId(a),"circle-color",K["circle-color"])),K&&K["circle-opacity"]&&((Xe=r.value)==null||Xe.setPaintProperty(N.getLayerId(a),"circle-opacity",K["circle-opacity"])),K&&K["circle-radius"]&&((Je=r.value)==null||Je.setPaintProperty(N.getLayerId(a),"circle-radius",K["circle-radius"])),K&&K["circle-stroke-color"]&&((He=r.value)==null||He.setPaintProperty(N.getLayerId(a),"circle-stroke-color",K["circle-stroke-color"])),K&&K["circle-stroke-width"]&&((Qe=r.value)==null||Qe.setPaintProperty(N.getLayerId(a),"circle-stroke-width",K["circle-stroke-width"]))}else if(I=="symbol"){const K=N.getCircleStyle(D);K&&K["icon-image"]&&((We=r.value)==null||We.setLayoutProperty(N.getLayerId(a),"icon-image",K["icon-image"]))}const A=[];let{symbolConfigList:C}=D;C=C.filter(K=>K.fontSize&&K.field&&K.textColor),C.forEach((K,Jr)=>{var _e,et,tt,rt;const Pe="points-symbol-"+a.id+K.field,bt=N.getSourceId(a);((_e=r.value)==null?void 0:_e.getLayer(Pe))?((tt=r.value)==null||tt.setLayoutProperty(Pe,"text-size",K.fontSize),(rt=r.value)==null||rt.setPaintProperty(Pe,"text-color",K.textColor)):((et=r.value)==null||et.addLayer({id:Pe,type:"symbol",source:bt,layout:{visibility:"visible","text-field":["get",K.field],"text-size":K.fontSize,"symbol-avoid-edges":!0,"icon-image":"circle-11","text-ignore-placement":!1,"text-max-angle":38},paint:{"text-color":K.textColor}}),A.push(K.field))})}function b(a){var x,A,C,k,P,M,G,E,L,j;if(!a.customLayerConfig||!a.geoJSON){console.warn("图层配置缺失,无法渲染图层");return}const f=JSON.parse(a.customLayerConfig),I=N.getLayerId(a);((x=r.value)==null?void 0:x.getLayer(I))!==void 0&&(console.warn(`图层 ${I} 已存在,无法重复添加`),(A=r.value)==null||A.removeLayer(I),(C=r.value)==null||C.removeSource(I));const S=JSON.parse(a.geoJSON);switch(a.layerType){case"symbol":const Z={id:I,type:"symbol",source:{type:"geojson",data:{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:S.features[0].geometry.coordinates},properties:{title:a.layerName||f.iconName,icon:`${f.iconName}`}}]}},layout:{"icon-image":"{icon}","icon-size":.1,"icon-anchor":"center","text-field":"{title}","text-font":["Open Sans Semibold","Arial Unicode MS Bold"],"text-offset":[0,1.8],"text-anchor":"center","text-size":12,"text-allow-overlap":!0,"text-optional":!0},paint:{"text-color":f.textColor,"text-halo-color":"rgba(0,0,0,0.32)","text-halo-width":1,"text-halo-blur":2,"text-translate":[0,0]}};(k=r.value)==null||k.addLayer(Z);break;case"line":const Q={id:I,type:"line",source:{type:"geojson",data:S},layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":f.lineColor,"line-width":Number(f.lineWidth)}};f.lineStyle=="dotted"&&(Q.paint["line-dasharray"]=[5.2,5.2]),(P=r.value)==null||P.addLayer(Q);break;case"shape":let H=I+"-outline";const ie={id:H,type:"line",source:{type:"geojson",data:JSON.parse(a.geoJSON)},layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":f.fillColor,"line-width":Number(f.lineWidth)}};((M=r.value)==null?void 0:M.getLayer(H))!==void 0&&((G=r.value)==null||G.removeLayer(H),(E=r.value)==null||E.removeSource(H)),(L=r.value)==null||L.addLayer(ie);const he={id:I,type:"fill",source:{type:"geojson",data:S},layout:{},paint:{"fill-color":f.fillColor,"fill-opacity":.32}};(j=r.value)==null||j.addLayer(he);break}}function T(a){var C,k,P,M,G;console.log("加载图层---->",a);const f=N.getLayerId(a),I=N.getSourceId(a);console.log("sourceId--->",I);const D=N.parseStyleConfig(a);console.log("styleConfig",D);const S=N.getLayerType(a);((C=r.value)==null?void 0:C.getSource(I))||(P=r.value)==null||P.addSource(I,{type:"geojson",data:(k=a.url)==null?void 0:k.replace("bjhweb","bjh")}),console.log("layerType--->",S);const A={id:f,source:I,name:f,layout:{visibility:"visible"},type:S};if(S!="symbol")A.paint=N.getLayerStyle(a);else{const E=N.getLayerStyle(a);A.layout={visibility:"visible","symbol-placement":"line","symbol-spacing":10,"icon-size":.1,"icon-keep-upright":!0,"icon-rotate":0,"icon-allow-overlap":!0,...E}}if(console.log("layerConfig--->",A),(M=r.value)==null||M.addLayer(A),S=="fill"){const E=N.getOutLineStyle(D);(G=r.value)==null||G.addLayer({id:f+"-outline",source:I,name:f+"-outline",layout:{visibility:"visible","line-join":"round","line-cap":"round"},type:"line",paint:{"line-color":E["line-color"],"line-width":E["line-width"],"line-dasharray":E["line-dasharray"]||[]}})}}const v=U.ref([]);function R(a){if(!r.value){console.warn("地图实例未初始化,无法添加调查数据图层");return}q(a);const f=a.pointInfo?a.pointInfo:JSON.parse(a.rowDataInstance??"{}");let I=null;if(f.latitude&&f.longitude&&(I=[parseFloat(f.longitude),parseFloat(f.latitude)]),f.latitudeStart&&f.longitudeStart&&(I=[parseFloat(f.longitudeStart),parseFloat(f.latitudeStart)]),a.layerType=="line"){const D={outlineColor:"#02d2e0",outlineWidth:3};let S=a.layerPaintConfig?JSON.parse(a.layerPaintConfig):D;if(!a.lineInfo){console.error("调查数据缺失,无法添加线图层");return}const x=a.lineInfo;let A=[];I&&I.length&&A.push(I),x.forEach(L=>{A.push([Number(L.longitude),Number(L.latitude)])});const k={type:"geojson",data:{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"LineString",coordinates:A}}]}},P=`${a.id}-geo-line-source`,M=r.value.getSource(P),G=`${a.id}-geo-line-layer`,E=r.value.getLayer(G);if(A.length>0){M||r.value.addSource(P,k),E&&r.value.removeLayer(G);let L={"line-color":S.outlineColor,"line-width":S.outlineWidth,"line-opacity":1};switch(S.outlineStyle){case"simple-dash":L["line-dasharray"]=[2,2];break;case"dot-dash":L["line-dasharray"]=[1,2,3,2];break;case"long-dash":L["line-dasharray"]=[4,2];break;case"dot-line":L["line-dasharray"]=[.1,2];break;case"complex-pattern":L["line-dasharray"]=[2,2,1,2];break}r.value.addLayer({id:G,type:"line",source:P,paint:L})}r.value.easeTo({zoom:17,center:A[0]})}else{const D={pointTintColor:"#02d2e0",pointRenderType:"points"};let S=a.layerPaintConfig?JSON.parse(a.layerPaintConfig):D;if(console.log("走这里---->",a),!a.lineInfo){console.error("调查数据缺失,无法添加点图层");return}if(!r.value){console.warn("地图实例未初始化,无法添加点图层");return}a.lineInfo.forEach(x=>{var E;let A=[0,0];x.latitude&&x.longitude&&(A=[Number(x.longitude),Number(x.latitude)]),x.latitudeStart&&x.longitudeStart&&(A=[Number(x.longitudeStart),Number(x.latitudeStart)]),console.log("layerPaintConfig.pointRenderType ",S);const C=document.createElement("div");if(S.pointRenderType=="icons"){C.className="research-location-icon-el";const L=document.createElement("img");L.className="research-location-img-el",L.src=Le.mapIconBaseUrl+S.currentMapIconName,C.appendChild(L)}else{C.className="research-location-point";const L=document.createElement("div");L.className="research-location-point-content",C.appendChild(L);const j=document.createElement("div");j.className="research-location-point-content-inner",j.style.backgroundColor=S.pointTintColor?S.pointTintColor:"#02d2e0",L.appendChild(j);const Z=document.createElement("div");Z.className="research-location-point-line",C.appendChild(Z)}C.onclick=L=>{Y(L,JSON.parse(a.rowDataInstance??"{}"))};const k=`${a.id}-research-point`,P=v.value.find(L=>L.id==k);P&&P.marker&&((E=P.marker)==null||E.remove());let M=new ge.Marker(C).setLngLat(A).setOffset([0,-22]).addTo(r.value),G=-1;v.value.forEach((L,j)=>{L.id==k&&(G=j)}),G>-1?v.value[G].marker=M:v.value.push({id:k,marker:M})})}J()}const B=U.ref(),V=U.ref();function J(){B.value&&B.value.hidePopup(),V.value&&V.value.hidePopup(),O.value&&O.value.hidePopup()}const O=U.ref();function Y(a,f){const{clientX:I,clientY:D}=a,S=I+28,x=D-60;O.value.showPopup(S,x,f)}function q(a){const f=d.value.find(I=>I.id===a.id);f?Object.assign(f,a):d.value.push(a)}function $(){if(!t.loadIcon)return Promise.resolve(!0);if(!r.value)return Promise.reject(new Error("地图实例未初始化,无法加载图标资源"));const a=Le.mapIconNameList.map(f=>new Promise((I,D)=>{var S;(S=r.value)==null||S.loadImage(Le.mapIconBaseUrl+f.fileName,(x,A)=>{var C;x?D(x):(A&&((C=r.value)==null||C.addImage(f.fileName,A)),I(!0))})}));return Promise.all(a)}function z(a){var x,A,C,k,P,M,G,E;console.log("removeThirdPartyLayer---->",a);const f=N.getLayerId(a),I=N.getLayerType(a),D=(x=r.value)==null?void 0:x.getLayer(f);console.log("currentLayerType---->",I,D);let S=-1;if(d.value.forEach((L,j)=>{L.id==a.id&&(S=j)}),S>-1&&d.value.splice(S,1),D){const L=(A=r.value)==null?void 0:A.getLayer(f);if(L){const j=L.source;(C=r.value)==null||C.removeLayer(f),a.geoJSON&&j&&((k=r.value)==null||k.removeSource(j))}}if(I=="fill"){console.log("移除边框----->");const L=f+"-outline",j=(P=r.value)==null?void 0:P.getLayer(L),Z=(M=r.value)==null?void 0:M.getLayer(L);if(Z){const Q=Z.source;j&&((G=r.value)==null||G.removeLayer(L)),a.geoJSON&&Q&&((E=r.value)==null||E.removeSource(Q))}}J()}U.watch(()=>{var a;return(a=o.mapInstances[t.mapRootId])==null?void 0:a.activeMapLayer},()=>{r.value&&y()},{immediate:!0}),U.watch(()=>{var a;return(a=o.mapInstances[t.mapRootId])==null?void 0:a.zoom},()=>{r.value&&!m.value&&r.value.flyTo({zoom:o.mapInstances[t.mapRootId].zoom,duration:500})},{immediate:!0}),U.watch(()=>{var a;return(a=o.mapInstances[t.mapRootId])==null?void 0:a.pitch},()=>{r.value&&!m.value&&(o.isDragging?r.value.setPitch(o.mapInstances[t.mapRootId].pitch):r.value.flyTo({pitch:o.mapInstances[t.mapRootId].pitch,duration:1e3}))},{immediate:!0}),U.watch(()=>{var a;return(a=o.mapInstances[t.mapRootId])==null?void 0:a.bearing},()=>{r.value&&!m.value&&(o.isDragging?r.value.setBearing(o.mapInstances[t.mapRootId].bearing):r.value.flyTo({bearing:o.mapInstances[t.mapRootId].bearing,duration:1e3}))},{immediate:!0});const te=a=>{r.value&&(r.value.flyTo({zoom:4,duration:400}),setTimeout(async()=>{var S,x,A,C,k;if(!a)return;let f=N.getSourceId(a);if(a.geoJSON&&(f=N.getLayerId(a)),a.url&&!a.geoJSON)try{const P=a.url.replace("bjhweb","bjh"),G=await(await fetch(P)).json();if(G&&G.features&&G.features.length>0){const E=Ce.bbox(G);if(E&&!re(E)){(S=r.value)==null||S.fitBounds([[E[0],E[1]],[E[2],E[3]]],{padding:{top:50,bottom:50,left:50,right:50}});return}}}catch(P){console.warn("从URL获取GeoJSON数据失败,尝试其他方法",P)}const I=(x=r.value)==null?void 0:x.getSource(f);if(I&&I._data&&I._data.features){const P=I._data,M=Ce.bbox(P);if(!re(M)){(A=r.value)==null||A.fitBounds([[M[0],M[1]],[M[2],M[3]]],{padding:{top:50,bottom:50,left:50,right:50}});return}}const D=(C=r.value)==null?void 0:C.querySourceFeatures(f);if(D&&D.length>0){const P=Ce.featureCollection(D),M=Ce.bbox(P);re(M)?console.warn("获取的边界框无效"):(k=r.value)==null||k.fitBounds([[M[0],M[1]],[M[2],M[3]]],{padding:{top:50,bottom:50,left:50,right:50}})}else console.warn("没有查询到图层数据")},500))};function re(a){return a[0]===1/0||a[1]===1/0||a[2]===-1/0||a[3]===-1/0||isNaN(a[0])||isNaN(a[1])||isNaN(a[2])||isNaN(a[3])}U.provide("resetMapView",g),U.provide("mapRootId",t.mapRootId),t.dbfDataRequest&&U.provide(De.dbfDataRequestKey,t.dbfDataRequest),t.researchDataRequest&&U.provide(De.researchDataRequestKey,t.researchDataRequest),U.provide(De.mapInstanceKey,r),U.provide(De.thirdPartyLayersKey,d);const _=({mapRootId:a,layer:f})=>{a===a&&(console.log("接收到渲染地理数据事件",f),f.layerDataType=="research"&&w(f))};le.renderGeographicDataKeyBus.on(_),e({mapInstance:r,initMap:h,handleSetMapStyle:y,resetMapView:g,addThirdPartyLayer:w,addResearchMapLayer:R,addTifLayer:c,processGeoTIFF:s,removeTifLayer:u}),U.onBeforeMount(()=>{o.mapInstances[t.mapRootId]={maxZoom:t.maxZoom,minZoom:t.minZoom,zoom:t.zoom,pitch:t.pitch,threeDPitch:t.pitch,center:t.center||[120.1551,30.2741],bearing:0,is3DMode:t.pitch>0,activeMapLayer:Lt.MapLayerType.SATELLITE,mapHeight:600,mapWidth:600,mapX:0,mapY:0}});function ue(a){var D,S,x,A;q(a);const f={outlineColor:"#02d2e0",outlineWidth:3,outlineOpacity:.72,pointTintColor:"#02d2e0"};let I=a.layerPaintConfig?JSON.parse(a.layerPaintConfig):f;if(console.log("layerPaintConfig--->",I),I.pointRenderType&&I.pointRenderType=="heatMap"){let C=a.id+"-source",k=a.id+"-layer",P=[];a.children&&a.children.forEach(M=>{let G=[0,0];const E=JSON.parse(M.rowDataInstance);E.latitude&&E.longitude&&(G=[Number(E.longitude),Number(E.latitude)]),E.latitudeStart&&E.longitudeStart&&(G=[Number(E.longitudeStart),Number(E.latitudeStart)]),P.push({type:"Feature",properties:{},geometry:{type:"Point",coordinates:G}})}),(D=r.value)==null||D.addSource(C,{type:"geojson",data:{type:"FeatureCollection",features:P}}),(S=r.value)==null||S.addLayer({id:k,type:"heatmap",source:C,maxzoom:9,paint:{"heatmap-weight":1,"heatmap-intensity":["interpolate",["linear"],["zoom"],0,1,9,3],"heatmap-color":["interpolate",["linear"],["heatmap-density"],0,"rgba(33,102,172,0)",.2,"blue",.4,"cyan",.6,"lime",.8,"yellow",1,"red"],"heatmap-radius":["interpolate",["linear"],["zoom"],0,2,9,20],"heatmap-opacity":["interpolate",["linear"],["zoom"],7,1,9,0]}})}else I.pointRenderType&&I.pointRenderType=="icons"?(console.log("走这里----->, icons",v.value),console.log("mapLayer.children",a.children),(x=a.children)==null||x.forEach(C=>{var j;let k=[0,0];const P=JSON.parse(C.rowDataInstance);P.latitude&&P.longitude&&(k=[Number(P.longitude),Number(P.latitude)]),P.latitudeStart&&P.longitudeStart&&(k=[Number(P.longitudeStart),Number(P.latitudeStart)]);const M=document.createElement("div");M.className="research-location-icon-el";const G=document.createElement("img");G.className="research-location-img-el",G.src=Le.mapIconBaseUrl+I.currentMapIconName,M.appendChild(G);const E=`${C.id}-research-point`,L=v.value.find(Z=>Z.id==E);if(L&&L.marker&&((j=L.marker)==null||j.remove()),r.value){let Z=new ge.Marker(M).setLngLat(k).setOffset([0,-22]).addTo(r.value),Q=-1;v.value.forEach((H,ie)=>{H.id==E&&(Q=ie)}),Q>-1?v.value[Q].marker=Z:v.value.push({id:E,marker:Z})}})):(A=a.children)==null||A.forEach(C=>{var Q;let k=[0,0];const P=JSON.parse(C.rowDataInstance);P.latitude&&P.longitude&&(k=[Number(P.longitude),Number(P.latitude)]),P.latitudeStart&&P.longitudeStart&&(k=[Number(P.longitudeStart),Number(P.latitudeStart)]);const M=document.createElement("div");M.className="research-location-point";const G=document.createElement("div");G.className="research-location-point-content",M.appendChild(G);const E=document.createElement("div");E.className="research-location-point-content-inner",E.style.backgroundColor=I.pointTintColor?I.pointTintColor:"#02d2e0",G.appendChild(E);const L=document.createElement("div");L.className="research-location-point-line",M.appendChild(L),M.onclick=H=>{console.log(H)};const j=`${C.id}-research-point`,Z=v.value.find(H=>H.id==j);if(Z&&Z.marker&&((Q=Z.marker)==null||Q.remove()),r.value){let H=new ge.Marker(M).setLngLat(k).setOffset([0,-22]).addTo(r.value),ie=-1;v.value.forEach((we,he)=>{we.id==j&&(ie=he)}),ie>-1?v.value[ie].marker=H:v.value.push({id:j,marker:H})}});J()}function Ie(a){var x,A,C;se(a);const f=`${a.id}-geo-line-layer`,I=`${a.id}-research-point`;((x=r.value)==null?void 0:x.getLayer(f))&&((A=r.value)==null||A.removeLayer(f));let S=-1;v.value.forEach((k,P)=>{k.id==I&&(S=P)}),S>-1&&(v.value[S].marker&&((C=v.value[S].marker)==null||C.remove()),v.value.splice(S,1)),J()}const fe=async({mapRootId:a,topic:f,visible:I,delLayer:D})=>{var S;if(console.log("接收到图层切换事件",t.mapRootId,a,f),a===t.mapRootId&&r.value)if(I)if(console.log("delLayer",D),D&&(console.log("mmb: 删除图层",f),z(f)),f.layerType=="species-group")ue(f);else if(f.layerDataType=="research"){if(f.layerType=="line"||f.layerType=="symbol"){if(!f.lineInfo){const x=await((S=t.researchDataRequest)==null?void 0:S.call(t,f));if(x){const{lineInfo:A,pointInfo:C}=x;f.lineInfo=A,f.pointInfo=C}}R(f)}}else w(f);else f.layerType=="species-group"?de(f):f.layerDataType=="research"?Ie(f):z(f)};function se(a){let f=-1;d.value.forEach((I,D)=>{I.id==a.id&&(f=D)}),f>-1&&d.value.splice(f,1)}function de(a){var f,I,D;if(se(a),a.layerPaintConfig){const S=JSON.parse(a.layerPaintConfig);if(S&&S.pointRenderType=="heatMap"){let x=a.id+"-source",A=a.id+"-layer";(f=r.value)==null||f.removeLayer(A),(I=r.value)==null||I.removeSource(x)}else(D=a.children)==null||D.forEach(x=>{var M,G,E;const A=`${x.id}-geo-line-layer`,C=`${x.id}-research-point`;((M=r.value)==null?void 0:M.getLayer(A))&&((G=r.value)==null||G.removeLayer(A));let P=-1;v.value.forEach((L,j)=>{L.id==C&&(P=j)}),P>-1&&(v.value[P].marker&&((E=v.value[P].marker)==null||E.remove()),v.value.splice(P,1))})}J()}const be=({mapRootId:a,layer:f})=>{a===t.mapRootId&&(console.log("接收到定位到图层中心事件",f),r.value&&te(f))};return U.onMounted(()=>{var a,f,I,D;o.setMapBoxToken(t.mapBoxToken),o.setTdtToken(t.tdtToken),o.setMaxZoom(t.mapRootId,t.maxZoom),o.setMinZoom(t.mapRootId,t.minZoom),o.setZoom(t.mapRootId,t.zoom),o.setPitch(t.mapRootId,t.pitch),o.setThreeDPitch(t.mapRootId,t.pitch),t.center&&Array.isArray(t.center)&&t.center.length>0?(o.setCenter(t.mapRootId,t.center),h()):navigator.geolocation.getCurrentPosition(S=>{const{latitude:x,longitude:A}=S.coords;o.setCenter(t.mapRootId,[A,x]),h()},()=>{o.setCenter(t.mapRootId,[104.1954,35.8617]),o.setZoom(t.mapRootId,4),h()}),o.mapInstances[t.mapRootId]&&(o.mapInstances[t.mapRootId].mapHeight=((a=n.value)==null?void 0:a.clientHeight)??600,o.mapInstances[t.mapRootId].mapWidth=((f=n.value)==null?void 0:f.clientWidth)??600,o.mapInstances[t.mapRootId].mapX=((I=n.value)==null?void 0:I.getBoundingClientRect().left)??600,o.mapInstances[t.mapRootId].mapY=((D=n.value)==null?void 0:D.getBoundingClientRect().top)??600),console.log("mapStore.mapInstances[mapRootId]--->",t.mapRootId),le.toggleGeographicLayerKeyBus.on(fe),le.locateToLayerCenterKeyBus.on(be)}),U.onUnmounted(()=>{console.log("组件卸载,清理事件监听"),le.renderGeographicDataKeyBus.off(_),le.toggleGeographicLayerKeyBus.off(fe),le.locateToLayerCenterKeyBus.off(be)}),(a,f)=>(U.openBlock(),U.createElementBlock("div",{class:"qy-map",ref_key:"mapRoot",ref:n},[U.createElementVNode("div",{class:"hiper-map-warper",id:a.mapRootId},[U.createElementVNode("div",zr,[U.renderSlot(a.$slots,"leftBar",{},void 0,!0)]),U.createElementVNode("div",Yr,[U.renderSlot(a.$slots,"rightBar",{},void 0,!0)]),U.createElementVNode("div",{class:"top-bar",style:U.normalizeStyle({left:U.unref(o).topicVisible?U.unref(o).topicWidth+50+"px":"70px"})},[U.renderSlot(a.$slots,"topBar",{},void 0,!0)],4),U.createElementVNode("div",$r,[U.renderSlot(a.$slots,"bottomBar",{},void 0,!0)]),U.renderSlot(a.$slots,"default",{},void 0,!0)],8,qr)],512))}}),Xr=Ct._export_sfc(Zr,[["__scopeId","data-v-e8cac047"]]);exports.LercAddCompression=fr;exports.LercParameters=ur;exports.MapView=Xr;
@@ -0,0 +1 @@
1
+ "use strict";const e=require("vue"),O=require("@element-plus/icons-vue"),re=require("../manageTable/Block.cjs"),n=require("element-plus"),F=require("./ProvideKeys-BPenLFlD.js"),v=require("./utils-rH1yoZOz.js"),d=[];for(let o=0;o<256;++o)d.push((o+256).toString(16).slice(1));function ne(o,i=0){return(d[o[i+0]]+d[o[i+1]]+d[o[i+2]]+d[o[i+3]]+"-"+d[o[i+4]]+d[o[i+5]]+"-"+d[o[i+6]]+d[o[i+7]]+"-"+d[o[i+8]]+d[o[i+9]]+"-"+d[o[i+10]]+d[o[i+11]]+d[o[i+12]]+d[o[i+13]]+d[o[i+14]]+d[o[i+15]]).toLowerCase()}let U;const ie=new Uint8Array(16);function de(){if(!U){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");U=crypto.getRandomValues.bind(crypto)}return U(ie)}const se=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),q={randomUUID:se};function I(o,i,y){var u;if(q.randomUUID&&!o)return q.randomUUID();o=o||{};const p=o.random??((u=o.rng)==null?void 0:u.call(o))??de();if(p.length<16)throw new Error("Random bytes length must be >= 16");return p[6]=p[6]&15|64,p[8]=p[8]&63|128,ne(p)}const ce={class:"fromItem_style"},pe={class:"value"},fe={class:"link"},me={class:"voice-list",style:{"margin-top":"20px"}},ve=["src"],ye={style:{display:"flex","justify-content":"center",width:"auto"}},ke=["src"],Ve=e.defineComponent({__name:"RenderFormItem",props:{field:{type:Object,required:!0},data:null},emits:["change"],setup(o,{emit:i}){const y=e.inject(F.uploadFileKey),p=e.inject(F.speciesNameQueryKey);console.log("speciesList",p);const u=o,w=e.ref(!1),k=e.ref(!1),T=e.ref(),a=e.ref(null),P=e.computed(()=>u.field.layoutType=="singleSelect"),j=e.computed(()=>u.field.layoutType=="input"),M=e.computed(()=>u.field.layoutType=="number"),R=e.computed(()=>u.field.layoutType=="selectGroup"),E=e.computed(()=>u.field.layoutType=="multipleSelect"),A=e.computed(()=>u.field.layoutType=="textArea"),z=e.computed(()=>u.field.layoutType=="imageList"),J=e.computed(()=>u.field.layoutType=="voiceList"),$=e.computed(()=>u.field.layoutType=="cascader"),C=e.computed(()=>u.field.layoutType=="datePicker"||u.field.layout=="datePicker"),G=e.computed(()=>u.field.layoutType=="dateTimePicker"),Y=e.computed(()=>u.field.layoutType=="quadratChart"),D=e.computed(()=>(console.log("props.field.layoutType",u.field.layoutType),u.field.layoutType=="switch"));if(u.field.property)if(u.field.type=="custom"){if(a.value="",u.data.extra&&Object.keys(JSON.parse(u.data.extra)).length>0)if(a.value=JSON.parse(u.data.extra)[u.field.property],E.value)try{a.value=a.value!=""?a.value.split(/[,,、]/):[]}catch{a.value=[]}else C.value&&(a.value=a.value?n.dayjs(a.value).unix():n.dayjs().unix())}else if(D.value)a.value=u.data[u.field.property]==1;else if(E.value)try{let r=u.data[u.field.property];a.value=r!=""?r.split(/[,,、]/):[]}catch{a.value=[]}else a.value=u.data[u.field.property];if(u.field.propertyGroup){var S=[];u.field.propertyGroup.forEach(r=>{S.push(u.data[r])}),a.value=S}const V=i,c=()=>{u.field.type=="custom"&&C.value?V("change",n.dayjs(a.value*1e3).format("YYYY-MM-DD")):u.field.property=="speciesName"?V("change",{speciesName:a.value,latinName:b.value.canorical_me}):V("change",E.value?a.value.join("、"):a.value)},f=e.ref([]);if(u.field.layoutType=="imageList"&&(k.value=!0,a.value)){a.value=v.html_entity_decode(a.value);var x=JSON.parse(v.html_entity_decode(a.value));x.forEach(r=>{f.value.push({name:r.name,url:v.buildOriginUrl(r.url),imagePath:r.imagePath||"",id:r.id||"pc-"+I(),title:r.title||null,remark:r.remark||null,disabled:r.disabled||null})})}const K=r=>{T.value=r.url,w.value=!0},Q=()=>{a.value=JSON.stringify(f.value.map(r=>({...r,url:v.clearOssUrl(r.url)}))),c()},X=(r,t)=>{var l=new FormData;return l.append("file",r.file),l.append("type",t),y?y(l).then(s=>{f.value.forEach(m=>{m.uid==r.file.uid&&(console.log(m.uid,r.file.uid),m.url=s.info.url)})}).catch(s=>{n.ElMessage.error(s)}):Promise.reject(new Error("uploadFile function is not provided"))},g=e.ref(!1),h=e.ref([]);if(u.field.layoutType=="voiceList"&&(g.value=!0,a.value)){a.value=v.html_entity_decode(a.value);var x=JSON.parse(v.html_entity_decode(a.value));x.forEach(t=>{h.value.push(t)})}const H=(r,t)=>{var l=new FormData;l.append("file",r.file),l.append("type",t);const s=new FileReader;var m=0;return s.onload=function(B){const oe=new Blob([B.target.result]),ue=URL.createObjectURL(oe),L=new Audio(ue);L.addEventListener("loadedmetadata",function(){m=Math.round(L.duration/1e3)})},s.readAsArrayBuffer(r.file),y?y(l).then(B=>{h.value.push({name:r.file.name,url:B.info.url,id:"pc-"+I(),duration:m})}).catch(B=>{n.ElMessage.error(B.msg)}):Promise.reject(new Error("uploadFile function is not provided"))},W=()=>{a.value=JSON.stringify(h.value),c()},N=e.ref(!1);u.field.layoutType=="quadratChart"&&(N.value=!0);const Z=r=>{var t;(t=u.field.propertyGroup)==null||t.forEach((l,s)=>{a.value[l]=r[s]}),c()},_=()=>{c()};e.watch(()=>u.field,()=>{}),e.watch(f,()=>{});const ee=()=>{V("change",a.value?1:0)},le=async r=>{if(!p)throw new Error("speciesList is not provided");return(await p({species_name:r,page_size:100})).data},te=(r,t)=>{le(r).then(l=>{t(l)})},b=e.ref({}),ae=r=>{a.value=r.speciesC,b.value=r,V("change",{speciesName:a.value,latinName:b.value.canoricalMe})};return(r,t)=>(e.openBlock(),e.createElementBlock("div",ce,[j.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[u.field.property=="speciesName"?(e.openBlock(),e.createBlock(e.unref(n.ElAutocomplete),{key:0,modelValue:a.value,"onUpdate:modelValue":t[0]||(t[0]=l=>a.value=l),"fetch-suggestions":te,"popper-class":"my-autocomplete",placeholder:o.field.placeholder,debounce:500,onBlur:c,onSelect:ae},{default:e.withCtx(({item:l})=>[e.createElementVNode("div",pe,e.toDisplayString(l.speciesC),1),e.createElementVNode("span",fe,e.toDisplayString(l.canoricalMe),1)]),_:1},8,["modelValue","placeholder"])):(e.openBlock(),e.createBlock(e.unref(n.ElInput),{key:1,modelValue:a.value,"onUpdate:modelValue":t[1]||(t[1]=l=>a.value=l),placeholder:o.field.placeholder,onBlur:c,class:e.normalizeClass({"input-latin-name":u.field.property=="latinName"})},null,8,["modelValue","placeholder","class"]))],64)):P.value?(e.openBlock(),e.createBlock(e.unref(n.ElSelect),{key:1,modelValue:a.value,"onUpdate:modelValue":t[2]||(t[2]=l=>a.value=l),placeholder:o.field.placeholder,onBlur:c},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.field.selectOptions,l=>(e.openBlock(),e.createBlock(e.unref(n.ElOption),{key:l.label,label:l.label,value:l.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])):M.value?(e.openBlock(),e.createBlock(e.unref(n.ElInput),{key:2,modelValue:a.value,"onUpdate:modelValue":t[3]||(t[3]=l=>a.value=l),type:"number",placeholder:o.field.placeholder,onBlur:c},null,8,["modelValue","placeholder"])):R.value?(e.openBlock(),e.createBlock(e.unref(n.ElSelect),{key:3,modelValue:a.value,"onUpdate:modelValue":t[4]||(t[4]=l=>a.value=l),placeholder:o.field.placeholder,onBlur:c},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.field.selectOptions,l=>(e.openBlock(),e.createBlock(e.unref(n.ElOptionGroup),{key:l.label,label:l.label},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.children,s=>(e.openBlock(),e.createBlock(e.unref(n.ElOption),{key:s.label,label:s.label,value:s.value},null,8,["label","value"]))),128))]),_:2},1032,["label"]))),128))]),_:1},8,["modelValue","placeholder"])):E.value?(e.openBlock(),e.createBlock(e.unref(n.ElSelect),{key:4,modelValue:a.value,"onUpdate:modelValue":t[5]||(t[5]=l=>a.value=l),placeholder:o.field.placeholder,multiple:"","collapse-tags":"","collapse-tags-tooltip":"",onBlur:c},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.field.selectOptions,l=>(e.openBlock(),e.createBlock(e.unref(n.ElOption),{key:l.label,label:l.label,value:l.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])):A.value?(e.openBlock(),e.createBlock(e.unref(n.ElInput),{key:5,type:"textarea",modelValue:a.value,"onUpdate:modelValue":t[6]||(t[6]=l=>a.value=l),placeholder:o.field.placeholder,onBlur:c},null,8,["modelValue","placeholder"])):z.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:6},[t[22]||(t[22]=e.createTextVNode(" 编辑中 ")),e.createVNode(e.unref(n.ElDialog),{center:"",modelValue:k.value,"onUpdate:modelValue":t[10]||(t[10]=l=>k.value=l),title:"图片管理","append-to-body":"",onClose:Q},{footer:e.withCtx(()=>[e.createVNode(e.unref(n.ElButton),{onClick:t[8]||(t[8]=l=>k.value=!1)},{default:e.withCtx(()=>t[20]||(t[20]=[e.createTextVNode("取 消")])),_:1,__:[20]}),e.createVNode(e.unref(n.ElButton),{type:"primary",onClick:t[9]||(t[9]=l=>k.value=!1)},{default:e.withCtx(()=>t[21]||(t[21]=[e.createTextVNode("确 定")])),_:1,__:[21]})]),default:e.withCtx(()=>[e.createVNode(e.unref(n.ElUpload),{"on-preview":K,style:{margin:"10px 0 0 0"},"file-list":f.value,"onUpdate:fileList":t[7]||(t[7]=l=>f.value=l),action:"","http-request":l=>X(l,"1"),accept:"image/*","list-type":"picture-card"},{default:e.withCtx(()=>[e.createVNode(e.unref(n.ElIcon),null,{default:e.withCtx(()=>[e.createVNode(e.unref(O.Plus))]),_:1})]),_:1},8,["file-list","http-request"])]),_:1},8,["modelValue"])],64)):J.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:7},[t[26]||(t[26]=e.createTextVNode(" 编辑中 ")),e.createVNode(e.unref(n.ElDialog),{center:"",modelValue:g.value,"onUpdate:modelValue":t[13]||(t[13]=l=>g.value=l),title:"声音管理","append-to-body":"",onClose:W},{footer:e.withCtx(()=>[e.createVNode(e.unref(n.ElButton),{onClick:t[11]||(t[11]=l=>g.value=!1)},{default:e.withCtx(()=>t[24]||(t[24]=[e.createTextVNode("取 消")])),_:1,__:[24]}),e.createVNode(e.unref(n.ElButton),{type:"primary",onClick:t[12]||(t[12]=l=>g.value=!1)},{default:e.withCtx(()=>t[25]||(t[25]=[e.createTextVNode("确 定")])),_:1,__:[25]})]),default:e.withCtx(()=>[e.createElementVNode("div",me,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,(l,s)=>(e.openBlock(),e.createElementBlock("div",{key:s},[e.createElementVNode("audio",{src:l.url,controls:""},null,8,ve)]))),128)),h.value.length==0?(e.openBlock(),e.createBlock(e.unref(n.ElEmpty),{key:0,description:"没有声音文件"})):e.createCommentVNode("",!0)]),e.createVNode(e.unref(n.ElUpload),{action:"","http-request":l=>H(l,"2"),"show-file-list":!1,accept:"audio/mpeg,audio/wav,audio/ogg,audio/flac,audio/mp3"},{default:e.withCtx(()=>[e.createVNode(e.unref(n.ElButton),{type:"primary",style:{"margin-top":"10px"},size:"default"},{default:e.withCtx(()=>t[23]||(t[23]=[e.createTextVNode("上传声音文件")])),_:1,__:[23]})]),_:1},8,["http-request"])]),_:1},8,["modelValue"])],64)):C.value?(e.openBlock(),e.createBlock(e.unref(n.ElDatePicker),{key:8,modelValue:a.value,"onUpdate:modelValue":t[14]||(t[14]=l=>a.value=l),type:"date",placeholder:o.field.placeholder,"value-format":"X",onBlur:c},null,8,["modelValue","placeholder"])):G.value?(e.openBlock(),e.createBlock(e.unref(n.ElDatePicker),{key:9,modelValue:a.value,"onUpdate:modelValue":t[15]||(t[15]=l=>a.value=l),type:"datetime",placeholder:o.field.placeholder,"value-format":"X",onBlur:c},null,8,["modelValue","placeholder"])):$.value?(e.openBlock(),e.createBlock(e.unref(n.ElCascader),{key:10,modelValue:a.value,"onUpdate:modelValue":t[16]||(t[16]=l=>a.value=l),options:o.field.selectOptions,placeholder:o.field.placeholder,onChange:Z},null,8,["modelValue","options","placeholder"])):Y.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:11},[e.createVNode(e.unref(n.ElIcon),{size:"20"},{default:e.withCtx(()=>[e.createVNode(e.unref(O.Calendar))]),_:1}),e.createVNode(e.unref(n.ElDialog),{center:"",modelValue:N.value,"onUpdate:modelValue":t[17]||(t[17]=l=>N.value=l),title:"查看完成度","append-to-body":"",width:"650px",onClose:_},{default:e.withCtx(()=>[e.createVNode(re.default,{data:o.data},null,8,["data"])]),_:1},8,["modelValue"])],64)):D.value?(e.openBlock(),e.createBlock(e.unref(n.ElSwitch),{key:12,modelValue:a.value,"onUpdate:modelValue":t[18]||(t[18]=l=>a.value=l),onChange:ee},null,8,["modelValue"])):e.createCommentVNode("",!0),e.createVNode(e.unref(n.ElDialog),{center:"",modelValue:w.value,"onUpdate:modelValue":t[19]||(t[19]=l=>w.value=l),"append-to-body":"","close-icon":"true"},{default:e.withCtx(()=>[e.createElementVNode("div",ye,[e.createElementVNode("img",{src:T.value,alt:"",style:{height:"700px","object-fit":"contain"}},null,8,ke)])]),_:1},8,["modelValue"])]))}});exports._sfc_main=Ve;