(function(u,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("@turf/turf"),require("moment"),require("moment-timezone"),require("tz-lookup")):typeof define=="function"&&define.amd?define(["exports","@turf/turf","moment","moment-timezone","tz-lookup"],y):(u=typeof globalThis<"u"?globalThis:u||self,y(u["idm-base"]={},u["@turf/turf"],u.moment,u["moment-timezone"],u["tz-lookup"]))})(this,function(u,y,S,$e,X){"use strict";var Ae=Object.defineProperty;var Pe=(u,y,S)=>y in u?Ae(u,y,{enumerable:!0,configurable:!0,writable:!0,value:S}):u[y]=S;var A=(u,y,S)=>(Pe(u,typeof y!="symbol"?y+"":y,S),S);function Q(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const n in i)if(n!=="default"){const t=Object.getOwnPropertyDescriptor(i,n);Object.defineProperty(e,n,t.get?t:{enumerable:!0,get:()=>i[n]})}}return e.default=i,Object.freeze(e)}const p=Q(y);class d{static guessTimeZoneOffset(e,n){const t=X(n,e),l=S().tz(t).utcOffset();return this.roundPrecision(l/60,1)}static prettyTimeZoneOffset(e){let n=Math.floor(Math.abs(e)),t=Math.round((Math.abs(e)-n)*60);return t=t>9?t:`0${t}`,n=n>9?n:`0${n}`,e>0?`+${n}:${t}`:`-${n}:${t}`}static lng2pretty(e,n=6,t="H°M′"){e=d.convertToStdLng(e,n);let l="E";e<0&&(l="W"),e=Math.abs(e),t=t.toUpperCase();let a=e*3600,r,s,o,c,g,m;r=a%3600%60,t.indexOf("S")!==-1&&(a=a-r,s=d.num2format(r,2)),o=a/60%60,t.indexOf("M")!==-1&&(t.indexOf("S")!==-1?c=d.roundPrecision(o,n).toString().padStart(2,"0"):c=d.num2format(o,2),a=a-o*60),g=a/3600,t.indexOf("M")!==-1?m=d.roundPrecision(g,n).toString().padStart(3,"0"):m=d.num2format(g,3);const h=`${t.replace(/S+/gi,s).replace(/M+/gi,c).replace(/H+/gi,m)}${l}`;return{direction:l,degree:d.roundPrecision(g,n),minute:d.roundPrecision(o,n),second:d.roundPrecision(r,n),pretty:h}}static lat2pretty(e,n=6,t="H°M′"){e=e%180;let l="N";e<0&&(l="S"),e=Math.abs(e),t=t.toUpperCase();let a=e*3600,r,s,o,c,g,m;r=a%3600%60,t.indexOf("S")!==-1&&(a=a-r,s=d.num2format(r,2)),o=a/60%60,t.indexOf("M")!==-1&&(t.indexOf("S")!==-1?c=d.roundPrecision(o,n).toString().padStart(2,"0"):c=d.num2format(o,2),a=a-o*60),g=a/3600,t.indexOf("M")!==-1?m=d.roundPrecision(g,n).toString().padStart(2,"0"):m=d.num2format(g,2);const h=`${t.replace(/S+/gi,s).replace(/M+/gi,c).replace(/H+/gi,m)}${l}`;return{direction:l,degree:d.roundPrecision(g,n),minute:d.roundPrecision(o,n),second:d.roundPrecision(r,n),pretty:h}}static num2format(e,n=2){const t=Math.trunc(e).toString().padStart(n,"0");let l=Math.trunc(d.roundPrecision(e-Math.trunc(e),2)*100);return l=l.toString().padStart(2,"0"),`${t}.${l}`}static strReplace(e,n="LAT"){e=e.replace(/([0-9]+)\.([0-9]+\.[0-9]+)/g,"$1 $2").replace(/-/g," ").replace(/°/," ").replace(/'/g," ").replace(/′/g," ").replace(/"/g," ").replace(/∼/g," ").replace(/°/g," ").replace(/,/g,".").replace(/^ /g,"").replace(/ $/g,"").trim();const t=e[e.length-1].toUpperCase();if(!["N","S","E","W"].includes(t)){const l=e,a=Number(l.split(" ")[0]);if(isNaN(a))throw new Error(`invalid Lat/Lng: ${e}`);a>=90?e=`${l}E`:a<=-90?e=`${l}W`:["LAN","LNG"].includes(n==null?void 0:n.toUpperCase())?e=`${l}${a>0?"E":"W"}`:e=`${l}${a>0?"N":"S"}`}return e}static str2Lng(e,n=6){let t;if(isNaN(e)){e=d.strReplace(e,"LNG");const l=e[e.length-1].toUpperCase();e=e.substring(0,e.length-1).trim();const a=e.split(" ").filter(o=>o!=="").map(o=>Number(o));let[r,s]=a;if(s=s>60?s/Math.pow(10,String(s).length-2):s,r>360&&!s){const o=this.roundPrecision(r/100,0);s=r-o*100,r=o}t=r+(s??0)/60,l==="W"&&(t=t*-1)}else t=Number(e);return d.convertToStdLng(t,n)}static str2Lat(e,n=6){let t;if(isNaN(e)){e=d.strReplace(e,"LAT");const l=e[e.length-1].toUpperCase();e=e.substring(0,e.length-1).trim();const a=e.split(" ").filter(o=>o!=="").map(o=>Number(o));let[r,s]=a;if(s=s>60?s/Math.pow(10,String(s).length-2):s,r>90&&!s){const o=this.roundPrecision(r/100,0);s=r-o*100,r=o}t=r+(s??0)/60,l==="S"&&(t=t*-1)}else t=Number(e);return d.roundPrecision(t,n)}static str2LngOrLat(e,n=6,t="LAT"){e=d.strReplace(e,t);const l=e[e.length-1].toUpperCase();return["N","S"].includes(l)?{lat:d.str2Lat(e,n)}:{lng:d.str2Lng(e,n)}}static convertToStdLng(e,n=4){return e>180?(e=e%360,e=e>180?e-360:e):e<-180&&(e=e%360,e=e<-180?e+360:e),d.roundPrecision(e,n)}static roundPrecision(e,n=4){if(typeof e=="number"){const t=Number("1".padEnd(n+1,"0"));return Math.round(e*t)/t}return e}}function v(i,e=4){return d.convertToStdLng(i,e)}function W(i){for(let e=1;e180){const o=x([[l,i[r].lat],[a,i[r+1].lat]]);let c,g;e?(c=p.lineString(o),g=p.lineString([[s>0?180:-180,89],[s>0?180:-180,-89]])):(c=p.greatCircle(o[0],o[1]),g=p.greatCircle([s>0?180:-180,89],[s>0?180:-180,-89]));const m=p.lineIntersect(c,g);let h;if(m.features.length){const M=p.getCoord(m.features[0]);h=f(M[1],8)}else h=i[r].lat;s>0?(n.push([180-1e-6,h]),t.push([...n]),n=[],n.push([-(180-1e-6),h])):(n.push([-(180-1e-6),h]),t.push([...n]),n=[],n.push([180-1e-6,h]))}r===i.length-2&&n.push([a,i[r+1].lat])}return t.push(n),t}function K(i){const e=[];for(const n of i){const t=n.reduce((l,a)=>(l.findIndex(r=>r[0]===a[0]&&r[1]===a[1])===-1&&l.push(a),l),[]);e.push(t)}return e}function z(i){return i.reduce((e,n)=>(e.findIndex(t=>t.lat===n.lat&&t.lng===n.lng)===-1&&e.push(n),e),[])}function ee(i,e){i.lng=v(i.lng,8);for(const n of e)for(let t=n.length-1;t>=0;t--)f(n[t][0],8)===i.lng&&f(n[t][1],8)===f(i.lat,8)&&n.splice(t,1);return e}function te(i,e){i.lng=v(i.lng,8);for(let n=e.length-1;n>=0;n--)f(e[n].lng,8)===i.lng&&f(e[n].lat,8)===f(i.lat,8)&&e.splice(n,1);return e}function G(i,e){i.lng=v(i.lng,8);let n=Number.MAX_VALUE,t=0,l=0,a,r;return e.forEach((s,o)=>{for(let c=0;ch&&(n=h,l=c,t=o,a=b(g,i),r=b(m,i))}}),a!==0&&r!==0?e[t].splice(l+1,0,[i.lng,i.lat]):a===0?e[t].splice(l,1,[i.lng,i.lat]):r===0&&e[t].splice(l+1,1,[i.lng,i.lat]),e}function U(i,e){for(const n of i)e=G(n,e);return e}function j(i,e,n){const t=[];let l=0;return n.forEach(a=>{if(l===2)return;const r=[];for(const s of a){if(f(e.lng,8)===f(s[0],8)&&f(e.lat,8)===f(s[1],8)){r.push(s),l===0&&r.push([i.lng,i.lat]),l=2;break}l===1?r.push(s):f(i.lng,8)===f(s[0],8)&&f(i.lat,8)===f(s[1],8)&&(l=1,r.push(s))}r.length&&t.push(r)}),t}function ne(i,e,n,t=[]){const l=O(n,0),a=B([i,e,...t],l),r=a.findIndex(c=>f(i.lng,8)===f(c.lng,8)&&f(i.lat,8)===f(c.lat,8)),s=a.findIndex(c=>f(e.lng,8)===f(c.lng,8)&&f(e.lat,8)===f(c.lat,8));return a.filter((c,g)=>g>=r&&g<=s)}function _(i,e){let n=Number.MAX_VALUE,t=0,l=0;return e.forEach((a,r)=>{for(let s=0;sg&&(n=g,t=s,l=r)}}),{minDist:n,segIndex:l,minIndex:t}}function ie(i,e){const{segIndex:n,minIndex:t}=_({...i},e);i.lng=v(i.lng);const l=[];let a=!0;for(let r=n;rg>0);const o=R(i,r,s);n>o&&(n=o,t=a)}i.lng=v(i.lng);const l=[i];for(let a=t+1;a0?i.lng-360:i.lng+360,i.lat]),a,t);return d.roundPrecision(Math.min(r,s),6)}function re(i,e){e=U(i,e);for(let n=0;n=g&&(t=g,l=s,a=b(o,i,!1,6),r=b(c,i,!1,6))}return a!==0&&r!==0?a(s.lng=v(s.lng),s))}function se(i){const e=[];for(let n=1;np.point(c));t.push(...o)}const l=p.featureCollection(t),a=p.nearestPoint(n,l),r=p.getCoord(a);return{lng:r[0],lat:r[1]}}function ce(i,e,n,t="nauticalmiles"){var m;const l=i.speed||12,a=[];let r=[],s=!1,o=0,c=0,g;if(e&&n.length?(a.push(i),n.forEach((h,M)=>{if(s)r.push(h);else{const k=[];let P;for(let T=0;T1){const h={lng:r[0][1][0],lat:r[0][1][1]};g.bearing=$(g,h)}else g.bearing=0;return{coordinate:g,nextRoute:r,prevRoute:a}}function ue(i,e,n){const t=d.convertToStdLng(i.lng,6),l=p.point([t,i.lat]),a=d.convertToStdLng(e.lng,6),r=d.convertToStdLng(n.lng,6),s=p.lineString([[a,e.lat],[r,n.lat]]),o=p.nearestPointOnLine(s,l),c=p.getCoord(o),g=d.roundPrecision(c[0],6),m=d.roundPrecision(c[1],6);return{lng:g,lat:m,inline:!(g===a&&m===e.lat)&&!(g===r&&m===n.lat)}}function O(i,e=0){const n=[];let t,l;return i.forEach(a=>{a.forEach(r=>{const s={lng:r[0],lat:r[1]};if(!l)n.push(s),l=s;else if(l.bearing===void 0)l.bearing=$(l,s,!0);else{const o=b(t,s,!0);o&&o>=e&&(t.bearing=$(t,s,!0),n.push(t),l=t)}t=s})}),t&&n.push(t),n}function ge(i,e,n=1){let t=O(i,n);return t=Z(t,e),t}function Z(i,e){e.forEach(t=>{E(t,i)});for(let t=1;to.lng===l.lng&&o.lat===l.lat),s=i.findIndex(o=>o.lng===a.lng&&o.lat===a.lat);for(let o=s-1;o>r;o--)i.splice(o,1)}}let n=0;for(let t=1;t(t.lng=v(t.lng),t))}class N{static guessVendor(e){return w}static parseText(e){return N.guessVendor(e).parseText(e)}static parseJson(e){return N.guessVendor("").parseJson(e)}static parseNoon(e){return N.guessVendor(e).parseNoon(e)}static convert2Html(e){return e.replace(/^"+|"+$/g,"").replace(/(\\n){2,}/g,"

").replace(/(\\n>)+/g,"\\n").replace(/(\\n)+/g,"
")}static reviseAddress(e){var n,t,l,a;return(a=(l=(t=(n=e==null?void 0:e.replaceAll(/[\uff0c\uff1b。;]/g,","))==null?void 0:n.split(","))==null?void 0:t.map(r=>(r=r==null?void 0:r.trim(),r)))==null?void 0:l.filter(r=>r))==null?void 0:a.join(",")}static signature(e="ORM",n="Operation Dept."){return e==="OPI"||e==="2z1mtf3"?`
${n}
Ocean PI Technology Co., Ltd.
+86 0532 83618328
1006# Rong Hui Zhong Xin, Shandong road, Shibei district, Qingdao, China.
`:`
${n}
Ocean Right Marine Service Co., Ltd.
op@ormwx.com
Rm1805, B Technology Innovation Bldg, No.171 Shandong Road, Qingdao, China.
`}}class w extends N{static parseText(e){var a,r,s;const n={};if(!e)return n;const t=/(.+?)(?=\])/g;e=e==null?void 0:e.replaceAll(" : ",":").replaceAll(/\[?REPORT TYPE:/g,"[Type:").replaceAll(`\r `," ").replaceAll(` `," ").replaceAll("\\n"," ").replaceAll("\r"," ").replaceAll("\\r"," ").replaceAll(" "," ").replaceAll("\\t"," ").replaceAll("> > >","]").replaceAll("> >","]").replaceAll(">","").replaceAll(/(\d*)[·。](\d*)/g,"$1.$2").replaceAll(/(\d*)\/(\d*)/g,"$2").replaceAll(/(\d+)[,,](\d+)[,,.](\d*)/g,"$1$2.$3").replaceAll(/(\d+)[,,](\d*)/g,"$1.$2").replaceAll(/(\d+)(\s*\[)/g,"$1][").replaceAll(/[^\]](\s*\[)/g,"]$1").replaceAll(" "," ").replaceAll(":",":");const l=e==null?void 0:e.match(t);if(l)for(let o=0;o(i.DANGEROUS="DANGEROUS",i.SEVERE="SEVERE",i.HEAVY="HEAVY",i.DEVIATION="deviation",i.STOPPAGE="stoppage",i.DECELERATION="deceleration",i.NO_NOON="noNoon",i.NO_LANE="noLane",i.NO_CP="noCp",i.SEND_RPT="sendRpt",i.SEND_BPS="sendBps",i.SEND_PVAR="sendPvar",i.CHECKED="checked",i))(q||{});class C{}A(C,"WEATHER_TAG",[{weight:4,name:"Adverse Weather Dangerous",key:"DANGEROUS",positive:!0},{weight:2,name:"Adverse Weather Severe",key:"SEVERE",positive:!0},{weight:1,name:"Adverse Weather Heavy",key:"HEAVY",positive:!0}]),A(C,"SAILING_TAG",[{weight:2048,name:"Deviation",key:"deviation",positive:!0},{weight:4096,name:"Stoppage",key:"stoppage",positive:!0},{weight:8192,name:"Deceleration",key:"deceleration",positive:!0},{weight:16384,name:"No Lane",key:"noLane",positive:!0},{weight:32768,name:"No Noon",key:"noNoon",positive:!0}]),A(C,"OTHER_TAG",[{weight:2097152,name:"No CP",key:"noCp",positive:!0},{weight:4194304,name:"Send Rpt",key:"sendRpt",positive:!1},{weight:8388608,name:"Send Bps",key:"sendBps",positive:!1},{weight:16777216,name:"Send Pvar",key:"sendPvar",positive:!1},{weight:33554432,name:"Checked",key:"checked",positive:!1}]);class H{}A(H,"LEVEL",{Basic:1,Prime:2,Supper:1024});const ke="",fe=(i,e)=>{const n=i.__vccOpts||i;for(const[t,l]of e)n[t]=l;return n},me={name:"AssetIndex"};function ve(i,e,n,t,l,a){return null}const J=fe(me,[["render",ve]]),be={install(i){i.component("AssetIndex",J)}};u.AisHelper=de,u.AssetIndex=J,u.AssetPlugin=be,u.CompanyHelper=H,u.DNTerminatorHelper=he,u.EmailHelper=N,u.IDMEmailHelper=w,u.LayerHelper=I,u.LngLatHelper=d,u.Sample=pe,u.VoyageTagHelper=C,u.VoyageTagKey=q,u.calculateBearing=$,u.calculateCoordinate=D,u.calculateDistance=b,u.calculateMinDistanceToRoute=_,u.calculateNextCoordinateAlongRoute=ce,u.calculatePointToLineDistance=R,u.calculatePrevWaypoint=ae,u.calculateRangeRoute=j,u.calculateRangeWaypoints=ne,u.calculateRouteDistance=L,u.calculateSubRoute=ie,u.calculateSubWaypoints=le,u.calculateWaypointsPropInRoute=re,u.convertRouteToCoordinates=O,u.convertToMonotonicLng=W,u.convertToMonotonicLng2=x,u.convertToStandardLng=v,u.deduplicationCoordinates=z,u.deduplicationRoute=K,u.divideAccordingToLng=F,u.generateRouteAccordingToWaypoints=se,u.interpolateCoordinates=Y,u.mergeCoordinateToRoute=G,u.mergeCoordinateToWaypoints=E,u.mergeCoordinatesToWaypoints=B,u.mergeWaypointsToRoute=U,u.nearestCoordinateInLine=ue,u.nearestCoordinateInRoute=oe,u.removeCoordinateFromRoute=ee,u.removeCoordinateFromWaypoints=te,u.roundPrecision=f,u.simplifyGCCoordinates=Z,u.simplifyRouteToCoordinates=ge,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});