@signalk/freeboard-sk 3.2.0-beta.6 → 3.2.0

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.
@@ -1 +1 @@
1
- import{Ta as a}from"./chunk-ZXYQTYUX.js";import"./chunk-RRYFRHFP.js";import"./chunk-4UBQTQSK.js";import"./chunk-5SYZI253.js";import"./chunk-BJKB23AZ.js";import"./chunk-D4A5NW5G.js";import"./chunk-GBMW6IJP.js";import"./chunk-BNCDJR4Z.js";import"./chunk-XZM7Q5WP.js";import"./chunk-USYMWMPO.js";import"./chunk-BCS6VHKX.js";import"./chunk-NCEQPEJE.js";export{a as Trail2RouteDialog};
1
+ import{Ta as a}from"./chunk-GFDZNVNU.js";import"./chunk-RRYFRHFP.js";import"./chunk-4UBQTQSK.js";import"./chunk-5SYZI253.js";import"./chunk-BJKB23AZ.js";import"./chunk-D4A5NW5G.js";import"./chunk-GBMW6IJP.js";import"./chunk-BNCDJR4Z.js";import"./chunk-XZM7Q5WP.js";import"./chunk-USYMWMPO.js";import"./chunk-BCS6VHKX.js";import"./chunk-NCEQPEJE.js";export{a as Trail2RouteDialog};
@@ -1,2 +1,2 @@
1
- import{a as pe}from"./chunk-VQDXDSU7.js";import{L as oe,Ua as re,V as se,W as le,i as q,j as J,k as Q,l as Y,m as Z,q as ne,r as ae}from"./chunk-ZXYQTYUX.js";import{a as ee,b as te,c as ie}from"./chunk-RRYFRHFP.js";import{j as A,k as L,l as B}from"./chunk-4UBQTQSK.js";import"./chunk-5SYZI253.js";import{a as z}from"./chunk-BJKB23AZ.js";import"./chunk-D4A5NW5G.js";import{j as H,o as j}from"./chunk-GBMW6IJP.js";import{a as N,b as U}from"./chunk-BNCDJR4Z.js";import"./chunk-XZM7Q5WP.js";import"./chunk-USYMWMPO.js";import{Ea as f,Ed as E,Fa as x,Fd as G,Ha as b,Ia as v,Id as R,Ja as T,Ka as u,Kd as X,La as a,Ma as o,Md as O,Na as C,Nd as W,P as y,R as d,S as m,Ua as _,Vd as V,Wa as h,Xd as F,Ya as p,_d as K,gb as w,ja as l,lb as r,mb as P,nb as M,oa as D,ob as S,qe as $,ra as I}from"./chunk-BCS6VHKX.js";import{g as k}from"./chunk-NCEQPEJE.js";function de(s,t){if(s&1){let e=_();a(0,"button",11),h("click",function(){d(e);let i=p();return m(i.load())}),a(1,"mat-icon"),r(2,"file_upload"),o(),r(3," \xA0Load "),o()}if(s&2){let e=p();u("disabled",!e.display.loadRoutesOK&&!e.display.loadWaypointsOK&&!e.display.loadTracksOK)}}function me(s,t){s&1&&(a(0,"div",10)(1,"div")(2,"b"),r(3,"Invalid GPX Data:"),o(),C(4,"br")(5,"br"),a(6,"i"),r(7,"Selected file does not contain GPX data or"),C(8,"br"),r(9," does not correctly implement namespaced <extensions> attributes."),o()()())}function ue(s,t){s&1&&C(0,"mat-progress-bar",12)}function he(s,t){if(s&1){let e=_();a(0,"div",23)(1,"div",24),r(2),o(),a(3,"div",25)(4,"mat-checkbox",26,0),h("change",function(){let i=d(e).$index,c=w(5),g=p(4);return m(g.checkWpt(c.checked,i))}),o()()()}if(s&2){let e=t.$implicit,n=t.$index,i=p(4);l(2),P(e.name),l(2),u("checked",i.selWaypoints[n])}}function _e(s,t){if(s&1){let e=_();a(0,"div",13)(1,"mat-expansion-panel",16),h("opened",function(){d(e);let i=p(3);return m(i.display.expand.waypoints=!0)})("closed",function(){d(e);let i=p(3);return m(i.display.expand.waypoints=!1)}),a(2,"mat-expansion-panel-header",17)(3,"mat-panel-title")(4,"mat-icon",18),r(5,"place"),o(),r(6," \xA0\xA0 "),a(7,"b"),r(8,"Waypoints:"),o()(),a(9,"mat-panel-description")(10,"div",5)(11,"span",19),r(12),o(),a(13,"span",20)(14,"mat-checkbox",21),h("change",function(i){d(e);let c=p(3);return m(c.checkWpt(i.checked,-1))})("click",function(i){return i.cancelBubble=!0}),o()()()()(),a(15,"div",22),v(16,he,6,2,"div",23,b),o()()()}if(s&2){let e=p(3);l(),u("expanded",e.display.expand.waypoints),l(11),S(" (",e.display.selCount.waypoints," of ",e.gpxData==null?null:e.gpxData.waypoints.length,") "),l(2),u("indeterminate",e.display.someWptChecked)("checked",e.display.allWaypointsChecked)("disabled",e.gpxData.waypoints.length===0),l(2),T(e.gpxData.waypoints)}}function fe(s,t){if(s&1){let e=_();a(0,"div",23)(1,"div",24),r(2),o(),a(3,"div",25)(4,"mat-checkbox",29,1),h("change",function(){let i=d(e).$index,c=w(5),g=p(4);return m(g.checkRte(c.checked,i))}),o()()()}if(s&2){let e=t.$implicit,n=t.$index,i=p(4);l(2),P(e.name),l(2),u("checked",i.selRoutes[n])}}function xe(s,t){if(s&1){let e=_();a(0,"div",13)(1,"mat-expansion-panel",16),h("opened",function(){d(e);let i=p(3);return m(i.display.expand.routes=!0)})("closed",function(){d(e);let i=p(3);return m(i.display.expand.routes=!1)}),a(2,"mat-expansion-panel-header",17)(3,"mat-panel-title")(4,"mat-icon",27),r(5,"directions"),o(),r(6," \xA0\xA0 "),a(7,"b"),r(8,"Routes:"),o()(),a(9,"mat-panel-description")(10,"div",5)(11,"span",19),r(12),o(),a(13,"span",20)(14,"mat-checkbox",28),h("change",function(i){d(e);let c=p(3);return m(c.checkRte(i.checked,-1))})("click",function(i){return i.cancelBubble=!0}),o()()()()(),a(15,"div",22),v(16,fe,6,2,"div",23,b),o()()()}if(s&2){let e=p(3);l(),u("expanded",e.display.expand.routes),l(11),S(" (",e.display.selCount.routes," of ",e.gpxData==null?null:e.gpxData.routes.length,") "),l(2),u("indeterminate",e.display.someRteChecked)("checked",e.display.allRoutesChecked)("disabled",e.gpxData.routes.length==0),l(2),T(e.gpxData.routes)}}function ye(s,t){if(s&1){let e=_();a(0,"div",23)(1,"div",24),r(2),o(),a(3,"div",25)(4,"mat-checkbox",32,2),h("change",function(){let i=d(e).$index,c=w(5),g=p(4);return m(g.checkTrk(c.checked,i))}),o()()()}if(s&2){let e=t.$implicit,n=t.$index,i=p(4);l(2),P(e.name),l(2),u("checked",i.selTracks[n])}}function ge(s,t){if(s&1){let e=_();a(0,"div",13)(1,"mat-expansion-panel",16),h("opened",function(){d(e);let i=p(3);return m(i.display.expand.tracks=!0)})("closed",function(){d(e);let i=p(3);return m(i.display.expand.tracks=!1)}),a(2,"mat-expansion-panel-header",17)(3,"mat-panel-title")(4,"mat-icon",30),r(5,"show_chart"),o(),r(6," \xA0\xA0 "),a(7,"b"),r(8,"Tracks:"),o()(),a(9,"mat-panel-description")(10,"div",5)(11,"span",19),r(12),o(),a(13,"span",20)(14,"mat-checkbox",31),h("change",function(i){d(e);let c=p(3);return m(c.checkTrk(i.checked,-1))})("click",function(i){return i.cancelBubble=!0}),o()()()()(),a(15,"div",22),v(16,ye,6,2,"div",23,b),o()()()}if(s&2){let e=p(3);l(),u("expanded",e.display.expand.tracks),l(11),S(" (",e.display.selCount.tracks," of ",e.gpxData==null?null:e.gpxData.tracks.length,") "),l(2),u("indeterminate",e.display.someTrkChecked)("checked",e.display.allTracksChecked)("disabled",e.gpxData.tracks.length==0),l(2),T(e.gpxData.tracks)}}function Ce(s,t){if(s&1&&(a(0,"div",13)(1,"div",14)(2,"div"),r(3,"File:"),o(),a(4,"div",15),r(5),o()(),C(6,"mat-divider"),o(),f(7,_e,18,6,"div",13),f(8,xe,18,6,"div",13),f(9,ge,18,6,"div",13)),s&2){let e=p(2);l(5),M(" ",e.data.fileName," "),l(2),x(e.gpxData.waypoints.length!=0?7:-1),l(),x(e.gpxData.routes.length!=0?8:-1),l(),x(e.gpxData.tracks.length!=0&&e.app.featureFlags().resourceTracks?9:-1)}}function ke(s,t){if(s&1&&(a(0,"div",10),f(1,ue,1,0,"mat-progress-bar",12)(2,Ce,10,4),o()),s&2){let e=p();l(),x(e.app.sIsFetching()?1:2)}}var ce=class s{constructor(t){this.data=t}data;gpxData={name:"",routes:[],waypoints:[],tracks:[]};selRoutes=[];selectedRoute=null;selWaypoints=[];selTracks=[];display={notValid:!1,allRoutesChecked:!1,allWaypointsChecked:!1,allTracksChecked:!1,someWptChecked:!1,someRteChecked:!1,someTrkChecked:!1,loadRoutesOK:!1,loadWaypointsOK:!1,loadTracksOK:!1,routeViewer:!1,selCount:{routes:0,waypoints:0,tracks:0},expand:{routes:!1,waypoints:!1,tracks:!1}};errorCount=0;subCount=0;gpx;app=y(re);dialogRef=y(E);skres=y(oe);signalk=y(ne);symbols=y(ae);ngOnInit(){this.data.fileData=this.data.fileData||null,this.parseGPXData(this.data.fileData)}ngOnDestroy(){this.clear()}load(){this.uploadToServer({rte:{selected:this.selRoutes},wpt:{selected:this.selWaypoints},trk:{selected:this.selTracks}})}parseGPXData(t){return k(this,null,function*(){if(this.display.allRoutesChecked=!1,this.display.loadRoutesOK=!1,this.selRoutes=[],this.display.allWaypointsChecked=!1,this.display.loadWaypointsOK=!1,this.selWaypoints=[],this.display.allTracksChecked=!1,this.display.loadTracksOK=!1,this.selTracks=[],this.display.selCount={routes:0,waypoints:0,tracks:0},this.display.expand={routes:!1,waypoints:!1,tracks:!1},this.display.notValid=!1,this.gpxData=yield this.parseFileData(t),!this.gpxData){console.warn(`Selected file does not contain GPX data or
1
+ import{a as pe}from"./chunk-VQDXDSU7.js";import{L as oe,Ua as re,V as se,W as le,i as q,j as J,k as Q,l as Y,m as Z,q as ne,r as ae}from"./chunk-GFDZNVNU.js";import{a as ee,b as te,c as ie}from"./chunk-RRYFRHFP.js";import{j as A,k as L,l as B}from"./chunk-4UBQTQSK.js";import"./chunk-5SYZI253.js";import{a as z}from"./chunk-BJKB23AZ.js";import"./chunk-D4A5NW5G.js";import{j as H,o as j}from"./chunk-GBMW6IJP.js";import{a as N,b as U}from"./chunk-BNCDJR4Z.js";import"./chunk-XZM7Q5WP.js";import"./chunk-USYMWMPO.js";import{Ea as f,Ed as E,Fa as x,Fd as G,Ha as b,Ia as v,Id as R,Ja as T,Ka as u,Kd as X,La as a,Ma as o,Md as O,Na as C,Nd as W,P as y,R as d,S as m,Ua as _,Vd as V,Wa as h,Xd as F,Ya as p,_d as K,gb as w,ja as l,lb as r,mb as P,nb as M,oa as D,ob as S,qe as $,ra as I}from"./chunk-BCS6VHKX.js";import{g as k}from"./chunk-NCEQPEJE.js";function de(s,t){if(s&1){let e=_();a(0,"button",11),h("click",function(){d(e);let i=p();return m(i.load())}),a(1,"mat-icon"),r(2,"file_upload"),o(),r(3," \xA0Load "),o()}if(s&2){let e=p();u("disabled",!e.display.loadRoutesOK&&!e.display.loadWaypointsOK&&!e.display.loadTracksOK)}}function me(s,t){s&1&&(a(0,"div",10)(1,"div")(2,"b"),r(3,"Invalid GPX Data:"),o(),C(4,"br")(5,"br"),a(6,"i"),r(7,"Selected file does not contain GPX data or"),C(8,"br"),r(9," does not correctly implement namespaced <extensions> attributes."),o()()())}function ue(s,t){s&1&&C(0,"mat-progress-bar",12)}function he(s,t){if(s&1){let e=_();a(0,"div",23)(1,"div",24),r(2),o(),a(3,"div",25)(4,"mat-checkbox",26,0),h("change",function(){let i=d(e).$index,c=w(5),g=p(4);return m(g.checkWpt(c.checked,i))}),o()()()}if(s&2){let e=t.$implicit,n=t.$index,i=p(4);l(2),P(e.name),l(2),u("checked",i.selWaypoints[n])}}function _e(s,t){if(s&1){let e=_();a(0,"div",13)(1,"mat-expansion-panel",16),h("opened",function(){d(e);let i=p(3);return m(i.display.expand.waypoints=!0)})("closed",function(){d(e);let i=p(3);return m(i.display.expand.waypoints=!1)}),a(2,"mat-expansion-panel-header",17)(3,"mat-panel-title")(4,"mat-icon",18),r(5,"place"),o(),r(6," \xA0\xA0 "),a(7,"b"),r(8,"Waypoints:"),o()(),a(9,"mat-panel-description")(10,"div",5)(11,"span",19),r(12),o(),a(13,"span",20)(14,"mat-checkbox",21),h("change",function(i){d(e);let c=p(3);return m(c.checkWpt(i.checked,-1))})("click",function(i){return i.cancelBubble=!0}),o()()()()(),a(15,"div",22),v(16,he,6,2,"div",23,b),o()()()}if(s&2){let e=p(3);l(),u("expanded",e.display.expand.waypoints),l(11),S(" (",e.display.selCount.waypoints," of ",e.gpxData==null?null:e.gpxData.waypoints.length,") "),l(2),u("indeterminate",e.display.someWptChecked)("checked",e.display.allWaypointsChecked)("disabled",e.gpxData.waypoints.length===0),l(2),T(e.gpxData.waypoints)}}function fe(s,t){if(s&1){let e=_();a(0,"div",23)(1,"div",24),r(2),o(),a(3,"div",25)(4,"mat-checkbox",29,1),h("change",function(){let i=d(e).$index,c=w(5),g=p(4);return m(g.checkRte(c.checked,i))}),o()()()}if(s&2){let e=t.$implicit,n=t.$index,i=p(4);l(2),P(e.name),l(2),u("checked",i.selRoutes[n])}}function xe(s,t){if(s&1){let e=_();a(0,"div",13)(1,"mat-expansion-panel",16),h("opened",function(){d(e);let i=p(3);return m(i.display.expand.routes=!0)})("closed",function(){d(e);let i=p(3);return m(i.display.expand.routes=!1)}),a(2,"mat-expansion-panel-header",17)(3,"mat-panel-title")(4,"mat-icon",27),r(5,"directions"),o(),r(6," \xA0\xA0 "),a(7,"b"),r(8,"Routes:"),o()(),a(9,"mat-panel-description")(10,"div",5)(11,"span",19),r(12),o(),a(13,"span",20)(14,"mat-checkbox",28),h("change",function(i){d(e);let c=p(3);return m(c.checkRte(i.checked,-1))})("click",function(i){return i.cancelBubble=!0}),o()()()()(),a(15,"div",22),v(16,fe,6,2,"div",23,b),o()()()}if(s&2){let e=p(3);l(),u("expanded",e.display.expand.routes),l(11),S(" (",e.display.selCount.routes," of ",e.gpxData==null?null:e.gpxData.routes.length,") "),l(2),u("indeterminate",e.display.someRteChecked)("checked",e.display.allRoutesChecked)("disabled",e.gpxData.routes.length==0),l(2),T(e.gpxData.routes)}}function ye(s,t){if(s&1){let e=_();a(0,"div",23)(1,"div",24),r(2),o(),a(3,"div",25)(4,"mat-checkbox",32,2),h("change",function(){let i=d(e).$index,c=w(5),g=p(4);return m(g.checkTrk(c.checked,i))}),o()()()}if(s&2){let e=t.$implicit,n=t.$index,i=p(4);l(2),P(e.name),l(2),u("checked",i.selTracks[n])}}function ge(s,t){if(s&1){let e=_();a(0,"div",13)(1,"mat-expansion-panel",16),h("opened",function(){d(e);let i=p(3);return m(i.display.expand.tracks=!0)})("closed",function(){d(e);let i=p(3);return m(i.display.expand.tracks=!1)}),a(2,"mat-expansion-panel-header",17)(3,"mat-panel-title")(4,"mat-icon",30),r(5,"show_chart"),o(),r(6," \xA0\xA0 "),a(7,"b"),r(8,"Tracks:"),o()(),a(9,"mat-panel-description")(10,"div",5)(11,"span",19),r(12),o(),a(13,"span",20)(14,"mat-checkbox",31),h("change",function(i){d(e);let c=p(3);return m(c.checkTrk(i.checked,-1))})("click",function(i){return i.cancelBubble=!0}),o()()()()(),a(15,"div",22),v(16,ye,6,2,"div",23,b),o()()()}if(s&2){let e=p(3);l(),u("expanded",e.display.expand.tracks),l(11),S(" (",e.display.selCount.tracks," of ",e.gpxData==null?null:e.gpxData.tracks.length,") "),l(2),u("indeterminate",e.display.someTrkChecked)("checked",e.display.allTracksChecked)("disabled",e.gpxData.tracks.length==0),l(2),T(e.gpxData.tracks)}}function Ce(s,t){if(s&1&&(a(0,"div",13)(1,"div",14)(2,"div"),r(3,"File:"),o(),a(4,"div",15),r(5),o()(),C(6,"mat-divider"),o(),f(7,_e,18,6,"div",13),f(8,xe,18,6,"div",13),f(9,ge,18,6,"div",13)),s&2){let e=p(2);l(5),M(" ",e.data.fileName," "),l(2),x(e.gpxData.waypoints.length!=0?7:-1),l(),x(e.gpxData.routes.length!=0?8:-1),l(),x(e.gpxData.tracks.length!=0&&e.app.featureFlags().resourceTracks?9:-1)}}function ke(s,t){if(s&1&&(a(0,"div",10),f(1,ue,1,0,"mat-progress-bar",12)(2,Ce,10,4),o()),s&2){let e=p();l(),x(e.app.sIsFetching()?1:2)}}var ce=class s{constructor(t){this.data=t}data;gpxData={name:"",routes:[],waypoints:[],tracks:[]};selRoutes=[];selectedRoute=null;selWaypoints=[];selTracks=[];display={notValid:!1,allRoutesChecked:!1,allWaypointsChecked:!1,allTracksChecked:!1,someWptChecked:!1,someRteChecked:!1,someTrkChecked:!1,loadRoutesOK:!1,loadWaypointsOK:!1,loadTracksOK:!1,routeViewer:!1,selCount:{routes:0,waypoints:0,tracks:0},expand:{routes:!1,waypoints:!1,tracks:!1}};errorCount=0;subCount=0;gpx;app=y(re);dialogRef=y(E);skres=y(oe);signalk=y(ne);symbols=y(ae);ngOnInit(){this.data.fileData=this.data.fileData||null,this.parseGPXData(this.data.fileData)}ngOnDestroy(){this.clear()}load(){this.uploadToServer({rte:{selected:this.selRoutes},wpt:{selected:this.selWaypoints},trk:{selected:this.selTracks}})}parseGPXData(t){return k(this,null,function*(){if(this.display.allRoutesChecked=!1,this.display.loadRoutesOK=!1,this.selRoutes=[],this.display.allWaypointsChecked=!1,this.display.loadWaypointsOK=!1,this.selWaypoints=[],this.display.allTracksChecked=!1,this.display.loadTracksOK=!1,this.selTracks=[],this.display.selCount={routes:0,waypoints:0,tracks:0},this.display.expand={routes:!1,waypoints:!1,tracks:!1},this.display.notValid=!1,this.gpxData=yield this.parseFileData(t),!this.gpxData){console.warn(`Selected file does not contain GPX data or
2
2
  does not correctly implement namespaced <extensions> attributes`,"Invalid GPX Data:"),this.display.notValid=!0;return}this.gpxData.routes.forEach(()=>{this.selRoutes.push(!1)}),this.selRoutes.length===1&&(this.selRoutes[0]=!0,this.display.allRoutesChecked=!0,this.display.expand.routes=!0,this.display.loadRoutesOK=!0,this.display.selCount.routes=1),this.gpxData.waypoints.forEach(()=>{this.selWaypoints.push(!1)}),this.selWaypoints.length===1&&(this.selWaypoints[0]=!0,this.display.allWaypointsChecked=!0,this.display.expand.waypoints=!0,this.display.loadWaypointsOK=!0,this.display.selCount.waypoints=1),this.gpxData.tracks.forEach(()=>{this.selTracks.push(!1)}),this.selTracks.length===1&&(this.selTracks[0]=!0,this.display.allTracksChecked=!0,this.display.expand.tracks=!0,this.display.loadTracksOK=!0,this.display.selCount.tracks=1)})}checkRte(t,e=-1){let n=0;if(e!==-1){this.selRoutes[e]=t,this.display.loadRoutesOK=t;for(let i of this.selRoutes)i&&n++;this.display.loadRoutesOK=n!==0,this.display.selCount.routes=n,this.display.allRoutesChecked=n===this.selRoutes.length}else{for(let i=0;i<this.selRoutes.length;i++)this.selRoutes[i]=t,this.display.loadRoutesOK=t,this.display.allRoutesChecked=t;this.display.selCount.routes=t?this.selRoutes.length:0}this.display.someRteChecked=!(this.display.allRoutesChecked||n===0)}checkWpt(t,e=-1){let n=0;if(e!==-1){this.selWaypoints[e]=t,this.display.loadWaypointsOK=t;for(let i of this.selWaypoints)i&&n++;this.display.loadWaypointsOK=n!==0,this.display.selCount.waypoints=n,this.display.allWaypointsChecked=n===this.selWaypoints.length}else{for(let i=0;i<this.selWaypoints.length;i++)this.selWaypoints[i]=t,this.display.loadWaypointsOK=t,this.display.allWaypointsChecked=t;this.display.selCount.waypoints=t?this.selWaypoints.length:0}this.display.someWptChecked=!(this.display.allWaypointsChecked||n===0)}checkTrk(t,e=-1){let n=0;if(e!==-1){this.selTracks[e]=t,this.display.loadTracksOK=t;for(let i of this.selTracks)i&&n++;this.display.loadTracksOK=n!==0,this.display.selCount.tracks=n,this.display.allTracksChecked=n===this.selTracks.length}else{for(let i=0;i<this.selTracks.length;i++)this.selTracks[i]=t,this.display.loadTracksOK=t,this.display.allTracksChecked=t;this.display.selCount.tracks=t?this.selTracks.length:0}this.display.someTrkChecked=!(this.display.allTracksChecked||n===0)}clear(){this.gpx=null}parseFileData(t){return k(this,null,function*(){let e={name:"",routes:[],waypoints:[],tracks:[]};if(this.gpx=new pe,this.app.sIsFetching.set(!0),!(yield this.gpx.parse(t)))return this.app.sIsFetching.set(!1),null;let n=1;return this.gpx.rte.forEach(i=>{e.routes.push({name:i.name!==""?i.name:`Rte: ${n}`,description:i.desc?i.desc:i.cmt?i.cmt:"",wptcount:i.rtept.length}),n++}),n=1,this.gpx.wpt.forEach(i=>{e.waypoints.push({name:i.name?i.name:`Wpt: ${n}`,description:i.desc?i.desc:i.cmt?i.cmt:""}),n++}),n=1,this.gpx.trk.forEach(i=>{e.tracks.push({name:i.name?i.name:`Trk: ${n}`,description:i.desc?i.desc:i.cmt?i.cmt:""}),n++}),this.app.sIsFetching.set(!1),e})}uploadToServer(t){return k(this,null,function*(){this.app.sIsFetching.set(!0),this.errorCount=0,this.subCount=0;for(let n=0;n<t.rte.selected.length;n++)t.rte.selected[n]&&this.transformRoute(this.gpx.rte[n]);for(let n=0;n<t.wpt.selected.length;n++)t.wpt.selected[n]&&this.transformWaypoint(this.gpx.wpt[n]);let e=[];for(let n=0;n<t.trk.selected.length;n++)if(t.trk.selected[n]){let i=this.transformTrack(this.gpx.trk[n]);this.subCount++;try{let c=yield this.skres.postToServer("tracks",i);this.subCount--,Math.floor(c.statusCode/100)===2?(e.push(c.id),this.app.debug("SUCCESS: Track added.")):this.errorCount++,this.checkComplete()}catch(c){this.errorCount++,this.subCount--,this.logError(c),this.checkComplete()}}e.length!==0&&this.skres.trackAddFromServer(e)})}errorList=[];logError(t){let e=t.error?t.error.message:t.message;this.errorList.push({status:t.status,message:e})}checkComplete(){this.subCount===0&&(this.app.sIsFetching.set(!1),this.app.saveConfig(),this.dialogRef.close({errCount:this.errorCount,errList:this.errorList}),this.app.debug(`GPXLoad: complete: ${this.errorCount}`))}transformRoute(t){let e=this.skres.buildRoute(t.rtept.map(i=>[i.lon,i.lat])),n=e[1];n.name=t.name??"",n.description=t.desc??"",t.cmt&&(n.feature.properties.cmt=t.cmt),t.src&&(n.feature.properties.src=t.src),t.number&&(n.feature.properties.number=t.number),t.type&&(n.feature.properties.type=t.type),n.feature.properties.coordinatesMeta=[],n.feature.properties.coordinatesMeta=t.rtept.map(i=>{let c={name:i.name??""};return i.cmt&&(c.description=i.cmt),c}),this.subCount++,this.signalk.api.put(this.app.skApiVersion,`/resources/routes/${e[0]}`,e[1]).subscribe(i=>{this.subCount--,Math.floor(i.statusCode/100)===2?(this.app.debug("SUCCESS: Route added."),this.skres.selectionAdd("routes",e[0])):this.errorCount++,this.checkComplete()},i=>{this.errorCount++,this.subCount--,this.logError(i),this.checkComplete()})}transformWaypoint(t){let e=this.skres.buildWaypoint([t.lon,t.lat]),n=e[1];if(t.ele&&n.feature.geometry.coordinates.push(t.ele),t.name&&t.name.length!==0&&(n.name=t.name),t.desc&&t.desc.length!==0&&(n.description=t.desc),t.type&&(n.type=t.type,n.feature.properties.type=t.type),t.cmt&&(n.feature.properties.cmt=t.cmt),t.src&&(n.feature.properties.src=t.src),t.sym){n.feature.properties.sym=t.sym;let i=this.symbols.resolveGpxSym(t.sym);i&&(n.type="waypoint",n.feature.properties.skIcon=i)}this.subCount++,this.signalk.api.put(this.app.skApiVersion,`/resources/waypoints/${e[0]}`,e[1]).subscribe(i=>{this.subCount--,Math.floor(i.statusCode/100)===2?(this.app.debug("SUCCESS: Waypoint added."),this.skres.selectionAdd("waypoints",e[0])):this.errorCount++,this.checkComplete()},i=>{this.errorCount++,this.subCount--,this.logError(i),this.checkComplete()})}transformTrack(t){let e={feature:{type:"Feature",geometry:{type:"MultiLineString",coordinates:[]},properties:{},id:""}};return t.trkseg&&t.trkseg.forEach(n=>{let i=[];n.trkpt.forEach(c=>{i.push([c.lon,c.lat])}),e.feature.geometry.coordinates.push(i)}),t.name&&t.name.length!==0?e.feature.properties.name=t.name:e.feature.properties.name=`gpxtrk #${Math.random().toString().slice(-5)}`,t.desc&&t.desc.length!==0&&(e.feature.properties.description=t.desc),t.cmt&&(e.feature.properties.cmt=t.cmt),t.src&&(e.feature.properties.src=t.src),t.type&&(e.feature.properties.type=t.type),e}static \u0275fac=function(e){return new(e||s)(D(G))};static \u0275cmp=I({type:s,selectors:[["gpxload-dialog"]],decls:13,vars:3,consts:[["wval",""],["rval",""],["tval",""],[1,"gpxload-dialog"],[2,"background-color","transparent"],[2,"display","flex","width","100%"],["mat-raised-button","","matTooltip","Load selected resources","matTooltipPosition","right",2,"width","85px",3,"disabled"],[2,"flex","1 1 auto","text-align","center"],[2,"text-align","right"],["mat-icon-button","",3,"click","disabled"],["mat-dialog-content",""],["mat-raised-button","","matTooltip","Load selected resources","matTooltipPosition","right",2,"width","85px",3,"click","disabled"],["mode","indeterminate"],[1,"card-group"],[2,"display","flex"],[2,"flex","1 1 auto","padding-left","10px","overflow","hidden","display","-webkit-box","-webkit-box-orient","vertical","-webkit-line-clamp","1","line-clamp","1","text-overflow","ellipsis"],[3,"opened","closed","expanded"],[2,"padding","0 12px"],[1,"icon-waypoint"],[1,"pnlSelectedItems"],[1,"pnlSelect"],["matTooltip","Select all Waypoints","matTooltipPosition","before",3,"change","click","indeterminate","checked","disabled"],[1,"list-container-scrollable"],[1,"item-row"],[1,"name"],[1,"check"],["matTooltip","Select Waypoint","matTooltipPosition","below",3,"change","checked"],[1,"icon-route"],["matTooltip","Select all Routes","matTooltipPosition","before",3,"change","click","indeterminate","checked","disabled"],["matTooltip","Select this Route","matTooltipPosition","below",3,"change","checked"],[1,"icon-track"],["matTooltip","Select all Tracks","matTooltipPosition","before",3,"change","click","indeterminate","checked","disabled"],["matTooltip","Select this Track","matTooltipPosition","below",3,"change","checked"]],template:function(e,n){e&1&&(a(0,"div",3)(1,"mat-toolbar",4)(2,"div",5)(3,"div"),f(4,de,4,1,"button",6),o(),a(5,"div",7),r(6,"Import GPX"),o(),a(7,"div",8)(8,"button",9),h("click",function(){return n.dialogRef.close(-1)}),a(9,"mat-icon"),r(10,"close"),o()()()()(),f(11,me,10,0,"div",10)(12,ke,3,1,"div",10),o()),e&2&&(l(4),x(n.app.sIsFetching()?-1:4),l(4),u("disabled",n.app.sIsFetching()),l(3),x(n.display.notValid?11:12))},dependencies:[te,ee,le,se,X,R,W,O,K,F,V,A,H,j,U,N,Z,q,J,Y,Q,B,L,ie,z,$],styles:[".gpxload-dialog[_ngcontent-%COMP%]{font-family:roboto;position:relative}.mat-expansion-panel-body[_ngcontent-%COMP%]{padding:0 12px 6px}.card-group-title[_ngcontent-%COMP%]{font-weight:700;font-size:10pt;font-family:Arial,Helvetica,sans-serif;padding:10px 0}.item-row[_ngcontent-%COMP%]{display:flex;width:100%;padding:2px 0}.item-row[_ngcontent-%COMP%] .name[_ngcontent-%COMP%]{flex:1 1 auto;overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;text-overflow:ellipsis;line-height:2.5em}.item-row[_ngcontent-%COMP%] .check[_ngcontent-%COMP%]{text-align:right;padding-right:15px}.pnlSelectedItems[_ngcontent-%COMP%]{display:none;line-height:2.9em}.pnlSelect[_ngcontent-%COMP%]{flex:1 1 auto;padding-left:3px;padding-right:3px;text-align:right}.txtSelect[_ngcontent-%COMP%]{display:none}button[_ngcontent-%COMP%]{min-width:unset;padding:unset}@media only screen and (min-width:400px){.pnlSelectedItems[_ngcontent-%COMP%]{display:inline}}@media only screen and (min-width:475px){.pnlSelectedItems[_ngcontent-%COMP%]{display:inline;line-height:2.9em}.txtSelect[_ngcontent-%COMP%]{display:inline}.pnlSelect[_ngcontent-%COMP%]{flex:1 1 auto;padding-left:20px;padding-right:15px;text-align:right}button[_ngcontent-%COMP%]{min-width:inherit;padding:inherit}}"]})};export{ce as GPXImportDialog};
@@ -1 +1 @@
1
- import{a as Ie,b as O,c as Ae,d as Ke,e as Be}from"./chunk-VQDXDSU7.js";import{Ga as Re,Ha as Oe,Ia as Ge,Ja as Fe,Ka as Xe,L as Se,La as We,Ua as Ve,V as Pe,W as Me,X as De,d as ee,i as _e,j as ye,k as ke,l as Ce,m as ve,p as Ee,q as R}from"./chunk-ZXYQTYUX.js";import{a as be,b as Te,c as we}from"./chunk-RRYFRHFP.js";import{j as oe,k as re,l as se}from"./chunk-4UBQTQSK.js";import{a as he,b as ge,d as xe}from"./chunk-5SYZI253.js";import{a as fe}from"./chunk-BJKB23AZ.js";import"./chunk-D4A5NW5G.js";import{b as le,i as ce,j as pe,n as de,o as me}from"./chunk-GBMW6IJP.js";import{b as ue}from"./chunk-BNCDJR4Z.js";import"./chunk-XZM7Q5WP.js";import"./chunk-USYMWMPO.js";import{Ea as f,Ed as j,Fa as _,Fd as N,Ha as V,Ia as T,Id as U,Ja as w,Ka as g,Kd as z,L as B,La as r,Ma as s,Md as q,Na as L,Nd as Q,P as b,R as m,S as u,Ua as y,Vd as Y,Wa as h,Xd as J,Ya as d,_d as Z,ae as te,c as A,fe as ie,gb as E,ie as ae,ja as c,k as K,lb as l,mb as H,nb as S,oa as C,pb as P,qb as M,qe as ne,ra as $,rb as D}from"./chunk-BCS6VHKX.js";import{g as v}from"./chunk-NCEQPEJE.js";var G=class{gpx;constructor(){this.init()}init(){this.gpx=new Ie,this.gpx.metadata.name="Signal K Resource Export",this.gpx.metadata.desc="Freeboard export of Signal K resources"}toXML(){return this.gpx.toXML()}setRoutes(i,e){if(e)e.forEach(t=>{i[t]&&this.gpx.rte.push(this.packageRoute(t,i[t]))});else for(let t in i)this.gpx.rte.push(this.packageRoute(t,i[t]))}packageRoute(i,e){let t=new Ae;t.extensions=t.extensions??{},t.extensions.signalk={},t.extensions.signalk.uuid=i,e.distance&&(t.extensions.signalk.distance=e.distance),t.name=e.name||null,t.desc=e.description||null,t.cmt=e.feature.properties.cmt||null,t.src=e.feature.properties.src||null,t.number=e.feature.properties.number||null,t.type=e.feature.properties.type||null;for(let a of e.feature.geometry.coordinates){let n=new O;n.lon=a[0],n.lat=a[1],n.ele=a[2]||null,t.rtept.push(n),this.gpx.updateBounds(n)}return t}setWaypoints(i,e){if(e)e.forEach(t=>{i[t]&&this.gpx.wpt.push(this.packageWaypoint(t,i[t]))});else for(let t in i)this.gpx.wpt.push(this.packageWaypoint(t,i[t]))}packageWaypoint(i,e){let t=new O;if(t.extensions=t.extensions||{},t.extensions.signalk={},t.extensions.signalk.uuid=i,t.name=e.name||"",t.desc=e.description||"",t.cmt=e.feature.properties.cmt||null,t.geoidHeight=e.feature.properties.geoidHeight||null,t.src=e.feature.properties.src||null,t.sym=e.feature.properties.sym||null,t.type=e.feature.properties.type||null,e.type==="waypoint"){let a=Ee(e.feature.properties.skIcon);a?.gpxType&&(t.type=a.gpxType),a?.gpxSym&&(t.sym=a.gpxSym)}return t.fix=e.feature.properties.fix||null,t.sat=e.feature.properties.sat||null,t.hdop=e.feature.properties.hdop||null,t.vdop=e.feature.properties.vdop||null,t.pdop=e.feature.properties.pdop||null,t.ageOfGpsData=e.feature.properties.ageOfGpsData||null,t.dgpsid=e.feature.properties.dgpsid||null,t.lat=e.feature.geometry.coordinates[1],t.lon=e.feature.geometry.coordinates[0],t.ele=e.feature.geometry.coordinates[2]||null,this.gpx.updateBounds(t),t}setTracks(i,e){if(e)e.forEach(t=>{i[t]&&this.gpx.trk.push(this.packageTrack(t,i[t]))});else for(let t in i)this.gpx.trk.push(this.packageTrack(t,i[t]))}packageTrack(i,e){let t=new Ke;t.extensions=t.extensions||{},t.extensions.signalk={},t.extensions.signalk.uuid=i,t.name=e.feature.properties.name||null,t.desc=e.feature.properties.description||null,t.cmt=e.feature.properties.cmt||null,t.src=e.feature.properties.src||null,t.number=e.feature.properties.number||null,t.type=e.feature.properties.type||null;let a=e.feature.properties.coordTimes;return e.feature.geometry.coordinates.forEach((n,p)=>{let x=new Be;n.forEach((W,He)=>{let k=new O;k.lon=W[0],k.lat=W[1],k.ele=W[2]||null;let I=a?.[p]?.[He];I&&(k.datetime=new Date(I)),x.trkpt.push(k),this.gpx.updateBounds(k)}),t.trkseg.push(x)}),t}};var F=class o{resultSource;result$;sk2gpx;hasFSA;signalk=b(R);constructor(){this.resultSource=new A,this.result$=this.resultSource.asObservable(),this.hasFSA="showOpenFilePicker"in window}clear(){this.sk2gpx=null}prepData(i){let e={routes:[],waypoints:[],tracks:[]},t=1;return e.routes=i.routes.map(a=>{let n=a[1];return n.feature.id=a[0],n}),t=1,e.waypoints=i.waypoints.map(a=>{let n=a[1];return n.feature.id=a[0],n.name=n.name??`Wpt: ${t}`,t++,n}),e.tracks=i.tracks,e}saveToFile(i,e){this.sk2gpx=new G;let t={},a={},n={};for(let p=0;p<e.rte.selected.length;p++)e.rte.selected[p]&&(t[i.routes[p].feature.id]=i.routes[p]);this.sk2gpx.setRoutes(t);for(let p=0;p<e.wpt.selected.length;p++)e.wpt.selected[p]&&(a[i.waypoints[p].feature.id]=i.waypoints[p]);this.sk2gpx.setWaypoints(a),(e.trk.tracks??[]).forEach(p=>{let x=this.signalk.uuid;n[x]=We(x,p)}),this.sk2gpx.setTracks(n),this.hasFSA?this.fsaSaveFile():this.legacySaveToFile()}legacySaveToFile(){let i=new Blob([this.sk2gpx.toXML()],{type:"text/xml"}),e=document.createElement("a");e.href=URL.createObjectURL(i),e.download="fb_export.gpx",e.click(),URL.revokeObjectURL(e.href),e.remove(),this.resultSource.next(-1)}fsaSaveFile(){window.showSaveFilePicker({types:[{description:"GPX file",accept:{"text/xml":[".gpx"]}}]}).then(i=>{i.createWritable().then(e=>{let t=new Blob([this.sk2gpx.toXML()]);e.write(t).then(()=>{e.close(),this.resultSource.next(0)})}).catch(e=>{console.warn(e),this.resultSource.next(1)})}).catch(i=>{i?.name==="SecurityError"?this.legacySaveToFile():this.resultSource.next(-1)})}static \u0275fac=function(e){return new(e||o)};static \u0275prov=B({token:o,factory:o.\u0275fac,providedIn:"root"})};var Ue=(o,i)=>i.context;function ze(o,i){o&1&&L(0,"mat-progress-bar",10)}function qe(o,i){if(o&1){let e=y();r(0,"div",19)(1,"div",20),l(2),s(),r(3,"div",21)(4,"mat-checkbox",22,0),h("change",function(){let a=m(e).$index,n=E(5),p=d(2);return u(p.checkWpt(n.checked,a))}),s()()()}if(o&2){let e=i.$implicit,t=i.$index,a=d(2);c(2),H(e.name),c(2),g("checked",a.selWaypoints[t])}}function Qe(o,i){if(o&1){let e=y();r(0,"div",12)(1,"mat-expansion-panel",13),h("opened",function(){m(e);let a=d();return u(a.display.expand.waypoints=!0)})("closed",function(){m(e);let a=d();return u(a.display.expand.waypoints=!1)}),r(2,"mat-expansion-panel-header",14)(3,"mat-panel-title")(4,"mat-icon",15),l(5,"place"),s(),l(6," \xA0"),r(7,"b"),l(8,"Waypoints:"),s()(),r(9,"mat-panel-description")(10,"div",16)(11,"mat-checkbox",17),h("change",function(a){m(e);let n=d();return u(n.checkWpt(a.checked,-1))})("click",function(a){return a.cancelBubble=!0}),s()()()(),r(12,"div",18),T(13,qe,6,2,"div",19,V),s()()()}if(o&2){let e=d();c(),g("expanded",e.display.expand.waypoints),c(10),g("indeterminate",e.display.someWptChecked)("checked",e.display.allWaypointsChecked)("disabled",e.resData.waypoints.length===0),c(2),w(e.resData.waypoints)}}function Ye(o,i){if(o&1){let e=y();r(0,"div",19)(1,"div",20)(2,"mat-icon",23),l(3,"directions"),s(),l(4),s(),r(5,"div",21)(6,"mat-checkbox",25,1),h("change",function(){let a=m(e).$index,n=E(7),p=d(2);return u(p.checkRte(n.checked,a))}),s()()()}if(o&2){let e=i.$implicit,t=i.$index,a=d(2);c(4),S(" ",e.name," "),c(2),g("checked",a.selRoutes[t])}}function Je(o,i){if(o&1){let e=y();r(0,"div",12)(1,"mat-expansion-panel",13),h("opened",function(){m(e);let a=d();return u(a.display.expand.routes=!0)})("closed",function(){m(e);let a=d();return u(a.display.expand.routes=!1)}),r(2,"mat-expansion-panel-header",14)(3,"mat-panel-title")(4,"mat-icon",23),l(5,"directions"),s(),l(6," \xA0"),r(7,"b"),l(8,"Routes:"),s()(),r(9,"mat-panel-description")(10,"div",16)(11,"mat-checkbox",24),h("change",function(a){m(e);let n=d();return u(n.checkRte(a.checked,-1))})("click",function(a){return a.cancelBubble=!0}),s()()()(),r(12,"div",18),T(13,Ye,8,2,"div",19,V),s()()()}if(o&2){let e=d();c(),g("expanded",e.display.expand.routes),c(10),g("indeterminate",e.display.someRteChecked)("checked",e.display.allRoutesChecked)("disabled",e.resData.routes.length==0),c(2),w(e.resData.routes)}}function Ze(o,i){o&1&&(r(0,"div",30),l(1," Only the positions gathered while Freeboard was open: the server has no recorded track for this vessel. "),s())}function et(o,i){if(o&1){let e=y();r(0,"div",19)(1,"div",20)(2,"mat-icon",26),l(3,"directions_boat"),s(),l(4),s(),r(5,"div",21)(6,"mat-checkbox",29,2),h("change",function(){let a=m(e).$index,n=E(7),p=d(2);return u(p.checkTrk(n.checked,a))}),s()()(),f(8,Ze,2,0,"div",30)}if(o&2){let e=i.$implicit,t=i.$index,a=d(2);c(4),S(" ",e.label," "),c(2),g("checked",a.selTracks[t]),c(2),_(e.tailOnly&&a.trackChoice==="displayed"?8:-1)}}function tt(o,i){o&1&&(r(0,"mat-option",37),l(1,"Track history range"),s())}function it(o,i){o&1&&(r(0,"div",30),l(1,"Choose a From time before the To time."),s())}function at(o,i){if(o&1){let e=y();r(0,"div",39)(1,"mat-form-field")(2,"mat-label"),l(3,"From"),s(),r(4,"input",40),D("ngModelChange",function(a){m(e);let n=d(3);return M(n.customFrom,a)||(n.customFrom=a),u(a)}),s()(),r(5,"mat-form-field")(6,"mat-label"),l(7,"To"),s(),r(8,"input",40),D("ngModelChange",function(a){m(e);let n=d(3);return M(n.customTo,a)||(n.customTo=a),u(a)}),s()()(),f(9,it,2,0,"div",30)}if(o&2){let e=d(3);c(4),P("ngModel",e.customFrom),c(4),P("ngModel",e.customTo),c(),_(e.customInvalid?9:-1)}}function nt(o,i){o&1&&(r(0,"div",30),l(1," Fetched from the server when you save, in the most detail it provides. "),s())}function ot(o,i){if(o&1){let e=y();r(0,"div",28)(1,"mat-form-field",31)(2,"mat-label"),l(3,"Track to export"),s(),r(4,"mat-select",32),D("ngModelChange",function(a){m(e);let n=d(2);return M(n.trackChoice,a)||(n.trackChoice=a),u(a)}),r(5,"mat-option",33),l(6,"As displayed"),s(),r(7,"mat-option",34),l(8,"Last 7 days"),s(),r(9,"mat-option",35),l(10,"Last 30 days"),s(),r(11,"mat-option",36),l(12,"All recorded"),s(),f(13,tt,2,0,"mat-option",37),r(14,"mat-option",38),l(15,"Custom range"),s()()(),f(16,at,10,3)(17,nt,2,0,"div",30),s()}if(o&2){let e=d(2);c(4),P("ngModel",e.trackChoice),c(9),_(e.historyRange?13:-1),c(3),_(e.trackChoice==="custom"?16:e.trackChoice!=="displayed"?17:-1)}}function rt(o,i){if(o&1){let e=y();r(0,"div",12)(1,"mat-expansion-panel",13),h("opened",function(){m(e);let a=d();return u(a.display.expand.tracks=!0)})("closed",function(){m(e);let a=d();return u(a.display.expand.tracks=!1)}),r(2,"mat-expansion-panel-header",14)(3,"mat-panel-title")(4,"mat-icon",26),l(5,"show_chart"),s(),l(6," \xA0"),r(7,"b"),l(8,"Tracks:"),s()(),r(9,"mat-panel-description")(10,"div",16)(11,"mat-checkbox",27),h("change",function(a){m(e);let n=d();return u(n.checkTrk(a.checked,-1))})("click",function(a){return a.cancelBubble=!0}),s()()()(),r(12,"div",18),T(13,et,9,3,null,null,Ue),s(),f(15,ot,18,3,"div",28),s()()}if(o&2){let e=d();c(),g("expanded",e.display.expand.tracks),c(10),g("indeterminate",e.display.someTrkChecked)("checked",e.display.allTracksChecked)("disabled",e.resData.tracks.length==0),c(2),w(e.resData.tracks),c(2),_(e.rangeAvailable?15:-1)}}var st=36e5;function $e(o){let i=new Date(o),e=t=>String(t).padStart(2,"0");return`${i.getFullYear()}-${e(i.getMonth()+1)}-${e(i.getDate())}T${e(i.getHours())}:${e(i.getMinutes())}`}function X(o){let i=o?new Date(o).getTime():NaN;return Number.isFinite(i)?i:null}var Le=class o{constructor(i,e,t,a,n){this.app=i;this.skres=e;this.facade=t;this.dialogRef=a;this.data=n}app;skres;facade;dialogRef;data;resData={routes:[],waypoints:[],tracks:[]};trackChoice="displayed";customFrom="";customTo="";fetching=!1;closed=!1;signalk=b(R);trackHistory=b(De);selRoutes=[];selectedRoute=null;selWaypoints=[];selTracks=[];display={notValid:!1,allRoutesChecked:!1,allWaypointsChecked:!1,allTracksChecked:!1,someWptChecked:!1,someRteChecked:!1,someTrkChecked:!1,saveRoutesOK:!1,saveWaypointsOK:!1,saveTracksOK:!1,routeViewer:!1,selCount:{routes:0,waypoints:0,tracks:0},expand:{routes:!1,waypoints:!1,tracks:!1}};unsubscribe=[];ngOnInit(){let i=Date.now();this.customFrom=$e(i-24*st),this.customTo=$e(i),this.loadResources(),this.data.initialChoice&&this.rangeAvailable&&(this.data.initialChoice!=="history"||this.historyRange)&&(this.trackChoice=this.data.initialChoice),this.unsubscribe.push(this.facade.result$.subscribe(e=>{this.dialogRef.close(e)}))}ngOnDestroy(){this.closed=!0,this.unsubscribe.forEach(i=>i.unsubscribe()),this.facade.clear()}loadResources(){return v(this,null,function*(){if(this.data.tracksOnly){this.data.waypoints=[],this.parseResourceData();return}this.data.routes.sort((i,e)=>i[1].name.localeCompare(e[1].name));try{this.app.sIsFetching.set(!0);let i=yield this.skres.listFromServer("waypoints");i.sort((e,t)=>e[1].name.localeCompare(t[1].name)),this.data.waypoints=i,this.app.sIsFetching.set(!1)}catch(i){this.app.sIsFetching.set(!1),this.resData.waypoints=[]}this.parseResourceData()})}get rangeAvailable(){return!!this.app.featureFlags().tracksApi}get historyRange(){return this.resData.tracks.some(i=>this.trackHistory.isShown(i.context))?this.trackHistory.range():void 0}chosenRange(){return Re(this.trackChoice,Date.now(),{history:this.historyRange,custom:{from:X(this.customFrom),to:X(this.customTo)}})}get customInvalid(){return this.trackChoice==="custom"&&!Oe({from:X(this.customFrom),to:X(this.customTo)})}get rangeUnusable(){return this.rangeAvailable&&this.trackChoice!=="displayed"&&this.chosenRange()===null}get canSave(){return!this.fetching&&!(this.display.saveTracksOK&&this.rangeUnusable)&&(this.display.saveRoutesOK||this.display.saveWaypointsOK||this.display.saveTracksOK)}save(){return v(this,null,function*(){let i;try{i=yield this.selectedTracks()}catch(e){if(this.closed)return;this.app.showAlert("GPX Save","Unable to fetch the recorded track from the server.");return}i===null||this.closed||this.facade.saveToFile(this.resData,{rte:{selected:this.selRoutes},wpt:{selected:this.selWaypoints},trk:{tracks:i}})})}selectedTracks(){return v(this,null,function*(){let i=this.resData.tracks.filter((n,p)=>this.selTracks[p]);if(i.length===0)return[];let e=this.rangeAvailable?this.chosenRange():null,t=Date.now(),a=[];this.fetching=!0;try{for(let n of i){let p=e===null?n.displayed:yield this.fetchTrack(n.context,e),x=Xe(n.label,p,t);if(!x)return this.app.showAlert("GPX Save",e===null?`There is no track to save for ${n.label}.`:`No track is recorded for ${n.label} in the selected range.`),null;a.push(x)}}finally{this.fetching=!1}return a})}fetchTrack(i,e){return v(this,null,function*(){let t=this.app.trackSource()?.provider,a=this.signalk.api.get(2,`/tracks?${Ge(i,e,t)}`);if(!a)throw new Error("Not connected");let n=yield K(a),p=ee(i,n,t);return{lines:p?.lines??[],times:p?.times??(p?.lines??[]).map(x=>x.map(()=>{}))}})}parseResourceData(){this.display.allRoutesChecked=!1,this.display.saveRoutesOK=!1,this.selRoutes=[],this.display.allWaypointsChecked=!1,this.display.saveWaypointsOK=!1,this.selWaypoints=[],this.display.allTracksChecked=!1,this.display.saveTracksOK=!1,this.selTracks=[],this.display.selCount={routes:0,waypoints:0,tracks:0},this.display.expand={routes:!1,waypoints:!1,tracks:!1},this.display.notValid=!1,this.resData=this.facade.prepData(this.data),this.resData.tracks=this.resData.tracks.filter(i=>this.rangeAvailable||Fe(i.displayed?.lines)),this.resData.routes.forEach(()=>{this.selRoutes.push(!1)}),this.selRoutes.length===1&&(this.selRoutes[0]=!0,this.display.allRoutesChecked=!0,this.display.expand.routes=!0,this.display.saveRoutesOK=!0),this.resData.waypoints.forEach(()=>{this.selWaypoints.push(!1)}),this.resData.tracks.forEach(()=>{this.selTracks.push(!1)}),this.data.tracksOnly&&this.selTracks.length!==0&&(this.checkTrk(!0,-1),this.display.expand.tracks=!0)}checkRte(i,e=-1){let t=0;if(e!==-1){this.selRoutes[e]=i,this.display.saveRoutesOK=i;for(let a of this.selRoutes)a&&t++;this.display.saveRoutesOK=t!==0,this.display.selCount.routes=t,this.display.allRoutesChecked=t===this.selRoutes.length}else{for(let a=0;a<this.selRoutes.length;a++)this.selRoutes[a]=i,this.display.saveRoutesOK=i,this.display.allRoutesChecked=i;this.display.selCount.routes=i?this.selRoutes.length:0}this.display.someRteChecked=!(this.display.allRoutesChecked||t===0)}checkWpt(i,e=-1){let t=0;if(e!==-1){this.selWaypoints[e]=i,this.display.saveWaypointsOK=i;for(let a of this.selWaypoints)a&&t++;this.display.saveWaypointsOK=t!==0,this.display.selCount.waypoints=t,this.display.allWaypointsChecked=t===this.selWaypoints.length}else{for(let a=0;a<this.selWaypoints.length;a++)this.selWaypoints[a]=i,this.display.saveWaypointsOK=i,this.display.allWaypointsChecked=i;this.display.selCount.waypoints=i?this.selWaypoints.length:0}this.display.someWptChecked=!(this.display.allWaypointsChecked||t===0)}checkTrk(i,e=-1){let t=0;if(e!==-1){this.selTracks[e]=i,this.display.saveTracksOK=i;for(let a of this.selTracks)a&&t++;this.display.saveTracksOK=t!==0,this.display.selCount.tracks=t,this.display.allTracksChecked=t===this.selTracks.length}else{for(let a=0;a<this.selTracks.length;a++)this.selTracks[a]=i,this.display.saveTracksOK=i,this.display.allTracksChecked=i;this.display.selCount.tracks=i?this.selTracks.length:0}this.display.someTrkChecked=!(this.display.allTracksChecked||t===0)}static \u0275fac=function(e){return new(e||o)(C(Ve),C(Se),C(F),C(j),C(N))};static \u0275cmp=$({type:o,selectors:[["gpxsave-dialog"]],decls:19,vars:6,consts:[["wval",""],["rval",""],["tval",""],[1,"gpxsave-dialog"],[2,"background-color","transparent"],[2,"display","flex","width","100%"],["mat-raised-button","","matTooltip","Save selected resources","matTooltipPosition","right",2,"width","85px",3,"click","disabled"],[2,"flex","1 1 auto","text-align","center"],[2,"text-align","right"],["mat-icon-button","",3,"click"],["mode","indeterminate"],["mat-dialog-content","",2,"padding","2px"],[1,"card-group"],[3,"opened","closed","expanded"],[1,"panel-header"],[1,"icon-waypoint"],[1,"panel-description"],["matTooltip","Select all Waypoints","matTooltipPosition","before",3,"change","click","indeterminate","checked","disabled"],[1,"list-container-scrollable"],[1,"item-row"],[1,"name"],[1,"check"],["matTooltip","Select Waypoint","matTooltipPosition","below",3,"change","checked"],[1,"icon-route"],["matTooltip","Select all Routes","matTooltipPosition","before",3,"change","click","indeterminate","checked","disabled"],["matTooltip","Select this Route","matTooltipPosition","below",3,"change","checked"],[1,"icon-track"],["matTooltip","Select all Tracks","matTooltipPosition","before",3,"change","click","indeterminate","checked","disabled"],[1,"track-range"],["matTooltip","Select this Track","matTooltipPosition","below",3,"change","checked"],[1,"track-note"],[1,"track-range-select"],[3,"ngModelChange","ngModel"],["value","displayed"],["value","7d"],["value","30d"],["value","all"],["value","history"],["value","custom"],[1,"track-range-custom"],["matInput","","type","datetime-local",3,"ngModelChange","ngModel"]],template:function(e,t){e&1&&(r(0,"div",3)(1,"mat-toolbar",4)(2,"div",5)(3,"div")(4,"button",6),h("click",function(){return t.save()}),r(5,"mat-icon"),l(6,"save"),s(),l(7,"\xA0Save\xA0 "),s()(),r(8,"div",7),l(9),s(),r(10,"div",8)(11,"button",9),h("click",function(){return t.dialogRef.close(-1)}),r(12,"mat-icon"),l(13,"close"),s()()()()(),f(14,ze,1,0,"mat-progress-bar",10),r(15,"div",11),f(16,Qe,15,4,"div",12),f(17,Je,15,4,"div",12),f(18,rt,16,5,"div",12),s()()),e&2&&(c(4),g("disabled",!t.canSave),c(5),S(" ",t.data.tracksOnly?"Export track to GPX":"Export to GPX"," "),c(5),_(t.fetching?14:-1),c(2),_(t.resData.waypoints.length!==0?16:-1),c(),_(t.resData.routes.length!==0?17:-1),c(),_(t.resData.tracks.length!==0?18:-1))},dependencies:[Te,be,Me,Pe,z,U,Q,q,Z,J,Y,oe,pe,ce,le,me,de,ue,ve,_e,ye,Ce,ke,se,re,we,fe,xe,ge,he,ne,te,ie,ae],styles:[".gpxsave-dialog[_ngcontent-%COMP%]{font-family:roboto;position:relative}.dialog-content[_ngcontent-%COMP%]{position:relative;min-height:300px;max-height:400px;width:100%;min-width:240px;overflow-y:auto}.dialog-icon[_ngcontent-%COMP%]{display:none}.card-group[_ngcontent-%COMP%]{padding:5px 5%}.card-group[_ngcontent-%COMP%] .panel-header[_ngcontent-%COMP%]{padding:0 5px}.card-group[_ngcontent-%COMP%] .panel-description[_ngcontent-%COMP%]{text-align:right;width:100%;padding-right:10px}.card-group-title[_ngcontent-%COMP%]{font-weight:700;font-size:10pt;font-family:Arial,Helvetica,sans-serif;padding:10px 0}button[_ngcontent-%COMP%]{min-width:unset;padding:unset}.item-row[_ngcontent-%COMP%]{display:flex;width:100%;padding:2px 0}.item-row[_ngcontent-%COMP%] .name[_ngcontent-%COMP%]{flex:1 1 auto;overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;text-overflow:ellipsis;line-height:2.5em}.item-row[_ngcontent-%COMP%] .check[_ngcontent-%COMP%]{text-align:right;padding-right:15px}.track-note[_ngcontent-%COMP%]{font-size:.85em;opacity:.8;padding:0 15px 4px 30px}.track-range[_ngcontent-%COMP%]{padding:8px 5px 0}.track-range-select[_ngcontent-%COMP%]{width:100%}.track-range-custom[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;gap:0 8px}.track-range-custom[_ngcontent-%COMP%] mat-form-field[_ngcontent-%COMP%]{flex:1 1 220px}@media only screen and (min-width:475px){button[_ngcontent-%COMP%]{min-width:inherit;padding:inherit}.dialog-content[_ngcontent-%COMP%]{min-width:400px}.dialog-icon[_ngcontent-%COMP%]{display:inline}}@media only screen and (min-width:800px){.card-group[_ngcontent-%COMP%]{padding:5px 5%}}"]})};export{Le as GPXExportDialog,X as fromLocalInput,$e as toLocalInput};
1
+ import{a as Ie,b as O,c as Ae,d as Ke,e as Be}from"./chunk-VQDXDSU7.js";import{Ga as Re,Ha as Oe,Ia as Ge,Ja as Fe,Ka as Xe,L as Se,La as We,Ua as Ve,V as Pe,W as Me,X as De,d as ee,i as _e,j as ye,k as ke,l as Ce,m as ve,p as Ee,q as R}from"./chunk-GFDZNVNU.js";import{a as be,b as Te,c as we}from"./chunk-RRYFRHFP.js";import{j as oe,k as re,l as se}from"./chunk-4UBQTQSK.js";import{a as he,b as ge,d as xe}from"./chunk-5SYZI253.js";import{a as fe}from"./chunk-BJKB23AZ.js";import"./chunk-D4A5NW5G.js";import{b as le,i as ce,j as pe,n as de,o as me}from"./chunk-GBMW6IJP.js";import{b as ue}from"./chunk-BNCDJR4Z.js";import"./chunk-XZM7Q5WP.js";import"./chunk-USYMWMPO.js";import{Ea as f,Ed as j,Fa as _,Fd as N,Ha as V,Ia as T,Id as U,Ja as w,Ka as g,Kd as z,L as B,La as r,Ma as s,Md as q,Na as L,Nd as Q,P as b,R as m,S as u,Ua as y,Vd as Y,Wa as h,Xd as J,Ya as d,_d as Z,ae as te,c as A,fe as ie,gb as E,ie as ae,ja as c,k as K,lb as l,mb as H,nb as S,oa as C,pb as P,qb as M,qe as ne,ra as $,rb as D}from"./chunk-BCS6VHKX.js";import{g as v}from"./chunk-NCEQPEJE.js";var G=class{gpx;constructor(){this.init()}init(){this.gpx=new Ie,this.gpx.metadata.name="Signal K Resource Export",this.gpx.metadata.desc="Freeboard export of Signal K resources"}toXML(){return this.gpx.toXML()}setRoutes(i,e){if(e)e.forEach(t=>{i[t]&&this.gpx.rte.push(this.packageRoute(t,i[t]))});else for(let t in i)this.gpx.rte.push(this.packageRoute(t,i[t]))}packageRoute(i,e){let t=new Ae;t.extensions=t.extensions??{},t.extensions.signalk={},t.extensions.signalk.uuid=i,e.distance&&(t.extensions.signalk.distance=e.distance),t.name=e.name||null,t.desc=e.description||null,t.cmt=e.feature.properties.cmt||null,t.src=e.feature.properties.src||null,t.number=e.feature.properties.number||null,t.type=e.feature.properties.type||null;for(let a of e.feature.geometry.coordinates){let n=new O;n.lon=a[0],n.lat=a[1],n.ele=a[2]||null,t.rtept.push(n),this.gpx.updateBounds(n)}return t}setWaypoints(i,e){if(e)e.forEach(t=>{i[t]&&this.gpx.wpt.push(this.packageWaypoint(t,i[t]))});else for(let t in i)this.gpx.wpt.push(this.packageWaypoint(t,i[t]))}packageWaypoint(i,e){let t=new O;if(t.extensions=t.extensions||{},t.extensions.signalk={},t.extensions.signalk.uuid=i,t.name=e.name||"",t.desc=e.description||"",t.cmt=e.feature.properties.cmt||null,t.geoidHeight=e.feature.properties.geoidHeight||null,t.src=e.feature.properties.src||null,t.sym=e.feature.properties.sym||null,t.type=e.feature.properties.type||null,e.type==="waypoint"){let a=Ee(e.feature.properties.skIcon);a?.gpxType&&(t.type=a.gpxType),a?.gpxSym&&(t.sym=a.gpxSym)}return t.fix=e.feature.properties.fix||null,t.sat=e.feature.properties.sat||null,t.hdop=e.feature.properties.hdop||null,t.vdop=e.feature.properties.vdop||null,t.pdop=e.feature.properties.pdop||null,t.ageOfGpsData=e.feature.properties.ageOfGpsData||null,t.dgpsid=e.feature.properties.dgpsid||null,t.lat=e.feature.geometry.coordinates[1],t.lon=e.feature.geometry.coordinates[0],t.ele=e.feature.geometry.coordinates[2]||null,this.gpx.updateBounds(t),t}setTracks(i,e){if(e)e.forEach(t=>{i[t]&&this.gpx.trk.push(this.packageTrack(t,i[t]))});else for(let t in i)this.gpx.trk.push(this.packageTrack(t,i[t]))}packageTrack(i,e){let t=new Ke;t.extensions=t.extensions||{},t.extensions.signalk={},t.extensions.signalk.uuid=i,t.name=e.feature.properties.name||null,t.desc=e.feature.properties.description||null,t.cmt=e.feature.properties.cmt||null,t.src=e.feature.properties.src||null,t.number=e.feature.properties.number||null,t.type=e.feature.properties.type||null;let a=e.feature.properties.coordTimes;return e.feature.geometry.coordinates.forEach((n,p)=>{let x=new Be;n.forEach((W,He)=>{let k=new O;k.lon=W[0],k.lat=W[1],k.ele=W[2]||null;let I=a?.[p]?.[He];I&&(k.datetime=new Date(I)),x.trkpt.push(k),this.gpx.updateBounds(k)}),t.trkseg.push(x)}),t}};var F=class o{resultSource;result$;sk2gpx;hasFSA;signalk=b(R);constructor(){this.resultSource=new A,this.result$=this.resultSource.asObservable(),this.hasFSA="showOpenFilePicker"in window}clear(){this.sk2gpx=null}prepData(i){let e={routes:[],waypoints:[],tracks:[]},t=1;return e.routes=i.routes.map(a=>{let n=a[1];return n.feature.id=a[0],n}),t=1,e.waypoints=i.waypoints.map(a=>{let n=a[1];return n.feature.id=a[0],n.name=n.name??`Wpt: ${t}`,t++,n}),e.tracks=i.tracks,e}saveToFile(i,e){this.sk2gpx=new G;let t={},a={},n={};for(let p=0;p<e.rte.selected.length;p++)e.rte.selected[p]&&(t[i.routes[p].feature.id]=i.routes[p]);this.sk2gpx.setRoutes(t);for(let p=0;p<e.wpt.selected.length;p++)e.wpt.selected[p]&&(a[i.waypoints[p].feature.id]=i.waypoints[p]);this.sk2gpx.setWaypoints(a),(e.trk.tracks??[]).forEach(p=>{let x=this.signalk.uuid;n[x]=We(x,p)}),this.sk2gpx.setTracks(n),this.hasFSA?this.fsaSaveFile():this.legacySaveToFile()}legacySaveToFile(){let i=new Blob([this.sk2gpx.toXML()],{type:"text/xml"}),e=document.createElement("a");e.href=URL.createObjectURL(i),e.download="fb_export.gpx",e.click(),URL.revokeObjectURL(e.href),e.remove(),this.resultSource.next(-1)}fsaSaveFile(){window.showSaveFilePicker({types:[{description:"GPX file",accept:{"text/xml":[".gpx"]}}]}).then(i=>{i.createWritable().then(e=>{let t=new Blob([this.sk2gpx.toXML()]);e.write(t).then(()=>{e.close(),this.resultSource.next(0)})}).catch(e=>{console.warn(e),this.resultSource.next(1)})}).catch(i=>{i?.name==="SecurityError"?this.legacySaveToFile():this.resultSource.next(-1)})}static \u0275fac=function(e){return new(e||o)};static \u0275prov=B({token:o,factory:o.\u0275fac,providedIn:"root"})};var Ue=(o,i)=>i.context;function ze(o,i){o&1&&L(0,"mat-progress-bar",10)}function qe(o,i){if(o&1){let e=y();r(0,"div",19)(1,"div",20),l(2),s(),r(3,"div",21)(4,"mat-checkbox",22,0),h("change",function(){let a=m(e).$index,n=E(5),p=d(2);return u(p.checkWpt(n.checked,a))}),s()()()}if(o&2){let e=i.$implicit,t=i.$index,a=d(2);c(2),H(e.name),c(2),g("checked",a.selWaypoints[t])}}function Qe(o,i){if(o&1){let e=y();r(0,"div",12)(1,"mat-expansion-panel",13),h("opened",function(){m(e);let a=d();return u(a.display.expand.waypoints=!0)})("closed",function(){m(e);let a=d();return u(a.display.expand.waypoints=!1)}),r(2,"mat-expansion-panel-header",14)(3,"mat-panel-title")(4,"mat-icon",15),l(5,"place"),s(),l(6," \xA0"),r(7,"b"),l(8,"Waypoints:"),s()(),r(9,"mat-panel-description")(10,"div",16)(11,"mat-checkbox",17),h("change",function(a){m(e);let n=d();return u(n.checkWpt(a.checked,-1))})("click",function(a){return a.cancelBubble=!0}),s()()()(),r(12,"div",18),T(13,qe,6,2,"div",19,V),s()()()}if(o&2){let e=d();c(),g("expanded",e.display.expand.waypoints),c(10),g("indeterminate",e.display.someWptChecked)("checked",e.display.allWaypointsChecked)("disabled",e.resData.waypoints.length===0),c(2),w(e.resData.waypoints)}}function Ye(o,i){if(o&1){let e=y();r(0,"div",19)(1,"div",20)(2,"mat-icon",23),l(3,"directions"),s(),l(4),s(),r(5,"div",21)(6,"mat-checkbox",25,1),h("change",function(){let a=m(e).$index,n=E(7),p=d(2);return u(p.checkRte(n.checked,a))}),s()()()}if(o&2){let e=i.$implicit,t=i.$index,a=d(2);c(4),S(" ",e.name," "),c(2),g("checked",a.selRoutes[t])}}function Je(o,i){if(o&1){let e=y();r(0,"div",12)(1,"mat-expansion-panel",13),h("opened",function(){m(e);let a=d();return u(a.display.expand.routes=!0)})("closed",function(){m(e);let a=d();return u(a.display.expand.routes=!1)}),r(2,"mat-expansion-panel-header",14)(3,"mat-panel-title")(4,"mat-icon",23),l(5,"directions"),s(),l(6," \xA0"),r(7,"b"),l(8,"Routes:"),s()(),r(9,"mat-panel-description")(10,"div",16)(11,"mat-checkbox",24),h("change",function(a){m(e);let n=d();return u(n.checkRte(a.checked,-1))})("click",function(a){return a.cancelBubble=!0}),s()()()(),r(12,"div",18),T(13,Ye,8,2,"div",19,V),s()()()}if(o&2){let e=d();c(),g("expanded",e.display.expand.routes),c(10),g("indeterminate",e.display.someRteChecked)("checked",e.display.allRoutesChecked)("disabled",e.resData.routes.length==0),c(2),w(e.resData.routes)}}function Ze(o,i){o&1&&(r(0,"div",30),l(1," Only the positions gathered while Freeboard was open: the server has no recorded track for this vessel. "),s())}function et(o,i){if(o&1){let e=y();r(0,"div",19)(1,"div",20)(2,"mat-icon",26),l(3,"directions_boat"),s(),l(4),s(),r(5,"div",21)(6,"mat-checkbox",29,2),h("change",function(){let a=m(e).$index,n=E(7),p=d(2);return u(p.checkTrk(n.checked,a))}),s()()(),f(8,Ze,2,0,"div",30)}if(o&2){let e=i.$implicit,t=i.$index,a=d(2);c(4),S(" ",e.label," "),c(2),g("checked",a.selTracks[t]),c(2),_(e.tailOnly&&a.trackChoice==="displayed"?8:-1)}}function tt(o,i){o&1&&(r(0,"mat-option",37),l(1,"Track history range"),s())}function it(o,i){o&1&&(r(0,"div",30),l(1,"Choose a From time before the To time."),s())}function at(o,i){if(o&1){let e=y();r(0,"div",39)(1,"mat-form-field")(2,"mat-label"),l(3,"From"),s(),r(4,"input",40),D("ngModelChange",function(a){m(e);let n=d(3);return M(n.customFrom,a)||(n.customFrom=a),u(a)}),s()(),r(5,"mat-form-field")(6,"mat-label"),l(7,"To"),s(),r(8,"input",40),D("ngModelChange",function(a){m(e);let n=d(3);return M(n.customTo,a)||(n.customTo=a),u(a)}),s()()(),f(9,it,2,0,"div",30)}if(o&2){let e=d(3);c(4),P("ngModel",e.customFrom),c(4),P("ngModel",e.customTo),c(),_(e.customInvalid?9:-1)}}function nt(o,i){o&1&&(r(0,"div",30),l(1," Fetched from the server when you save, in the most detail it provides. "),s())}function ot(o,i){if(o&1){let e=y();r(0,"div",28)(1,"mat-form-field",31)(2,"mat-label"),l(3,"Track to export"),s(),r(4,"mat-select",32),D("ngModelChange",function(a){m(e);let n=d(2);return M(n.trackChoice,a)||(n.trackChoice=a),u(a)}),r(5,"mat-option",33),l(6,"As displayed"),s(),r(7,"mat-option",34),l(8,"Last 7 days"),s(),r(9,"mat-option",35),l(10,"Last 30 days"),s(),r(11,"mat-option",36),l(12,"All recorded"),s(),f(13,tt,2,0,"mat-option",37),r(14,"mat-option",38),l(15,"Custom range"),s()()(),f(16,at,10,3)(17,nt,2,0,"div",30),s()}if(o&2){let e=d(2);c(4),P("ngModel",e.trackChoice),c(9),_(e.historyRange?13:-1),c(3),_(e.trackChoice==="custom"?16:e.trackChoice!=="displayed"?17:-1)}}function rt(o,i){if(o&1){let e=y();r(0,"div",12)(1,"mat-expansion-panel",13),h("opened",function(){m(e);let a=d();return u(a.display.expand.tracks=!0)})("closed",function(){m(e);let a=d();return u(a.display.expand.tracks=!1)}),r(2,"mat-expansion-panel-header",14)(3,"mat-panel-title")(4,"mat-icon",26),l(5,"show_chart"),s(),l(6," \xA0"),r(7,"b"),l(8,"Tracks:"),s()(),r(9,"mat-panel-description")(10,"div",16)(11,"mat-checkbox",27),h("change",function(a){m(e);let n=d();return u(n.checkTrk(a.checked,-1))})("click",function(a){return a.cancelBubble=!0}),s()()()(),r(12,"div",18),T(13,et,9,3,null,null,Ue),s(),f(15,ot,18,3,"div",28),s()()}if(o&2){let e=d();c(),g("expanded",e.display.expand.tracks),c(10),g("indeterminate",e.display.someTrkChecked)("checked",e.display.allTracksChecked)("disabled",e.resData.tracks.length==0),c(2),w(e.resData.tracks),c(2),_(e.rangeAvailable?15:-1)}}var st=36e5;function $e(o){let i=new Date(o),e=t=>String(t).padStart(2,"0");return`${i.getFullYear()}-${e(i.getMonth()+1)}-${e(i.getDate())}T${e(i.getHours())}:${e(i.getMinutes())}`}function X(o){let i=o?new Date(o).getTime():NaN;return Number.isFinite(i)?i:null}var Le=class o{constructor(i,e,t,a,n){this.app=i;this.skres=e;this.facade=t;this.dialogRef=a;this.data=n}app;skres;facade;dialogRef;data;resData={routes:[],waypoints:[],tracks:[]};trackChoice="displayed";customFrom="";customTo="";fetching=!1;closed=!1;signalk=b(R);trackHistory=b(De);selRoutes=[];selectedRoute=null;selWaypoints=[];selTracks=[];display={notValid:!1,allRoutesChecked:!1,allWaypointsChecked:!1,allTracksChecked:!1,someWptChecked:!1,someRteChecked:!1,someTrkChecked:!1,saveRoutesOK:!1,saveWaypointsOK:!1,saveTracksOK:!1,routeViewer:!1,selCount:{routes:0,waypoints:0,tracks:0},expand:{routes:!1,waypoints:!1,tracks:!1}};unsubscribe=[];ngOnInit(){let i=Date.now();this.customFrom=$e(i-24*st),this.customTo=$e(i),this.loadResources(),this.data.initialChoice&&this.rangeAvailable&&(this.data.initialChoice!=="history"||this.historyRange)&&(this.trackChoice=this.data.initialChoice),this.unsubscribe.push(this.facade.result$.subscribe(e=>{this.dialogRef.close(e)}))}ngOnDestroy(){this.closed=!0,this.unsubscribe.forEach(i=>i.unsubscribe()),this.facade.clear()}loadResources(){return v(this,null,function*(){if(this.data.tracksOnly){this.data.waypoints=[],this.parseResourceData();return}this.data.routes.sort((i,e)=>i[1].name.localeCompare(e[1].name));try{this.app.sIsFetching.set(!0);let i=yield this.skres.listFromServer("waypoints");i.sort((e,t)=>e[1].name.localeCompare(t[1].name)),this.data.waypoints=i,this.app.sIsFetching.set(!1)}catch(i){this.app.sIsFetching.set(!1),this.resData.waypoints=[]}this.parseResourceData()})}get rangeAvailable(){return!!this.app.featureFlags().tracksApi}get historyRange(){return this.resData.tracks.some(i=>this.trackHistory.isShown(i.context))?this.trackHistory.range():void 0}chosenRange(){return Re(this.trackChoice,Date.now(),{history:this.historyRange,custom:{from:X(this.customFrom),to:X(this.customTo)}})}get customInvalid(){return this.trackChoice==="custom"&&!Oe({from:X(this.customFrom),to:X(this.customTo)})}get rangeUnusable(){return this.rangeAvailable&&this.trackChoice!=="displayed"&&this.chosenRange()===null}get canSave(){return!this.fetching&&!(this.display.saveTracksOK&&this.rangeUnusable)&&(this.display.saveRoutesOK||this.display.saveWaypointsOK||this.display.saveTracksOK)}save(){return v(this,null,function*(){let i;try{i=yield this.selectedTracks()}catch(e){if(this.closed)return;this.app.showAlert("GPX Save","Unable to fetch the recorded track from the server.");return}i===null||this.closed||this.facade.saveToFile(this.resData,{rte:{selected:this.selRoutes},wpt:{selected:this.selWaypoints},trk:{tracks:i}})})}selectedTracks(){return v(this,null,function*(){let i=this.resData.tracks.filter((n,p)=>this.selTracks[p]);if(i.length===0)return[];let e=this.rangeAvailable?this.chosenRange():null,t=Date.now(),a=[];this.fetching=!0;try{for(let n of i){let p=e===null?n.displayed:yield this.fetchTrack(n.context,e),x=Xe(n.label,p,t);if(!x)return this.app.showAlert("GPX Save",e===null?`There is no track to save for ${n.label}.`:`No track is recorded for ${n.label} in the selected range.`),null;a.push(x)}}finally{this.fetching=!1}return a})}fetchTrack(i,e){return v(this,null,function*(){let t=this.app.trackSource()?.provider,a=this.signalk.api.get(2,`/tracks?${Ge(i,e,t)}`);if(!a)throw new Error("Not connected");let n=yield K(a),p=ee(i,n,t);return{lines:p?.lines??[],times:p?.times??(p?.lines??[]).map(x=>x.map(()=>{}))}})}parseResourceData(){this.display.allRoutesChecked=!1,this.display.saveRoutesOK=!1,this.selRoutes=[],this.display.allWaypointsChecked=!1,this.display.saveWaypointsOK=!1,this.selWaypoints=[],this.display.allTracksChecked=!1,this.display.saveTracksOK=!1,this.selTracks=[],this.display.selCount={routes:0,waypoints:0,tracks:0},this.display.expand={routes:!1,waypoints:!1,tracks:!1},this.display.notValid=!1,this.resData=this.facade.prepData(this.data),this.resData.tracks=this.resData.tracks.filter(i=>this.rangeAvailable||Fe(i.displayed?.lines)),this.resData.routes.forEach(()=>{this.selRoutes.push(!1)}),this.selRoutes.length===1&&(this.selRoutes[0]=!0,this.display.allRoutesChecked=!0,this.display.expand.routes=!0,this.display.saveRoutesOK=!0),this.resData.waypoints.forEach(()=>{this.selWaypoints.push(!1)}),this.resData.tracks.forEach(()=>{this.selTracks.push(!1)}),this.data.tracksOnly&&this.selTracks.length!==0&&(this.checkTrk(!0,-1),this.display.expand.tracks=!0)}checkRte(i,e=-1){let t=0;if(e!==-1){this.selRoutes[e]=i,this.display.saveRoutesOK=i;for(let a of this.selRoutes)a&&t++;this.display.saveRoutesOK=t!==0,this.display.selCount.routes=t,this.display.allRoutesChecked=t===this.selRoutes.length}else{for(let a=0;a<this.selRoutes.length;a++)this.selRoutes[a]=i,this.display.saveRoutesOK=i,this.display.allRoutesChecked=i;this.display.selCount.routes=i?this.selRoutes.length:0}this.display.someRteChecked=!(this.display.allRoutesChecked||t===0)}checkWpt(i,e=-1){let t=0;if(e!==-1){this.selWaypoints[e]=i,this.display.saveWaypointsOK=i;for(let a of this.selWaypoints)a&&t++;this.display.saveWaypointsOK=t!==0,this.display.selCount.waypoints=t,this.display.allWaypointsChecked=t===this.selWaypoints.length}else{for(let a=0;a<this.selWaypoints.length;a++)this.selWaypoints[a]=i,this.display.saveWaypointsOK=i,this.display.allWaypointsChecked=i;this.display.selCount.waypoints=i?this.selWaypoints.length:0}this.display.someWptChecked=!(this.display.allWaypointsChecked||t===0)}checkTrk(i,e=-1){let t=0;if(e!==-1){this.selTracks[e]=i,this.display.saveTracksOK=i;for(let a of this.selTracks)a&&t++;this.display.saveTracksOK=t!==0,this.display.selCount.tracks=t,this.display.allTracksChecked=t===this.selTracks.length}else{for(let a=0;a<this.selTracks.length;a++)this.selTracks[a]=i,this.display.saveTracksOK=i,this.display.allTracksChecked=i;this.display.selCount.tracks=i?this.selTracks.length:0}this.display.someTrkChecked=!(this.display.allTracksChecked||t===0)}static \u0275fac=function(e){return new(e||o)(C(Ve),C(Se),C(F),C(j),C(N))};static \u0275cmp=$({type:o,selectors:[["gpxsave-dialog"]],decls:19,vars:6,consts:[["wval",""],["rval",""],["tval",""],[1,"gpxsave-dialog"],[2,"background-color","transparent"],[2,"display","flex","width","100%"],["mat-raised-button","","matTooltip","Save selected resources","matTooltipPosition","right",2,"width","85px",3,"click","disabled"],[2,"flex","1 1 auto","text-align","center"],[2,"text-align","right"],["mat-icon-button","",3,"click"],["mode","indeterminate"],["mat-dialog-content","",2,"padding","2px"],[1,"card-group"],[3,"opened","closed","expanded"],[1,"panel-header"],[1,"icon-waypoint"],[1,"panel-description"],["matTooltip","Select all Waypoints","matTooltipPosition","before",3,"change","click","indeterminate","checked","disabled"],[1,"list-container-scrollable"],[1,"item-row"],[1,"name"],[1,"check"],["matTooltip","Select Waypoint","matTooltipPosition","below",3,"change","checked"],[1,"icon-route"],["matTooltip","Select all Routes","matTooltipPosition","before",3,"change","click","indeterminate","checked","disabled"],["matTooltip","Select this Route","matTooltipPosition","below",3,"change","checked"],[1,"icon-track"],["matTooltip","Select all Tracks","matTooltipPosition","before",3,"change","click","indeterminate","checked","disabled"],[1,"track-range"],["matTooltip","Select this Track","matTooltipPosition","below",3,"change","checked"],[1,"track-note"],[1,"track-range-select"],[3,"ngModelChange","ngModel"],["value","displayed"],["value","7d"],["value","30d"],["value","all"],["value","history"],["value","custom"],[1,"track-range-custom"],["matInput","","type","datetime-local",3,"ngModelChange","ngModel"]],template:function(e,t){e&1&&(r(0,"div",3)(1,"mat-toolbar",4)(2,"div",5)(3,"div")(4,"button",6),h("click",function(){return t.save()}),r(5,"mat-icon"),l(6,"save"),s(),l(7,"\xA0Save\xA0 "),s()(),r(8,"div",7),l(9),s(),r(10,"div",8)(11,"button",9),h("click",function(){return t.dialogRef.close(-1)}),r(12,"mat-icon"),l(13,"close"),s()()()()(),f(14,ze,1,0,"mat-progress-bar",10),r(15,"div",11),f(16,Qe,15,4,"div",12),f(17,Je,15,4,"div",12),f(18,rt,16,5,"div",12),s()()),e&2&&(c(4),g("disabled",!t.canSave),c(5),S(" ",t.data.tracksOnly?"Export track to GPX":"Export to GPX"," "),c(5),_(t.fetching?14:-1),c(2),_(t.resData.waypoints.length!==0?16:-1),c(),_(t.resData.routes.length!==0?17:-1),c(),_(t.resData.tracks.length!==0?18:-1))},dependencies:[Te,be,Me,Pe,z,U,Q,q,Z,J,Y,oe,pe,ce,le,me,de,ue,ve,_e,ye,Ce,ke,se,re,we,fe,xe,ge,he,ne,te,ie,ae],styles:[".gpxsave-dialog[_ngcontent-%COMP%]{font-family:roboto;position:relative}.dialog-content[_ngcontent-%COMP%]{position:relative;min-height:300px;max-height:400px;width:100%;min-width:240px;overflow-y:auto}.dialog-icon[_ngcontent-%COMP%]{display:none}.card-group[_ngcontent-%COMP%]{padding:5px 5%}.card-group[_ngcontent-%COMP%] .panel-header[_ngcontent-%COMP%]{padding:0 5px}.card-group[_ngcontent-%COMP%] .panel-description[_ngcontent-%COMP%]{text-align:right;width:100%;padding-right:10px}.card-group-title[_ngcontent-%COMP%]{font-weight:700;font-size:10pt;font-family:Arial,Helvetica,sans-serif;padding:10px 0}button[_ngcontent-%COMP%]{min-width:unset;padding:unset}.item-row[_ngcontent-%COMP%]{display:flex;width:100%;padding:2px 0}.item-row[_ngcontent-%COMP%] .name[_ngcontent-%COMP%]{flex:1 1 auto;overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;text-overflow:ellipsis;line-height:2.5em}.item-row[_ngcontent-%COMP%] .check[_ngcontent-%COMP%]{text-align:right;padding-right:15px}.track-note[_ngcontent-%COMP%]{font-size:.85em;opacity:.8;padding:0 15px 4px 30px}.track-range[_ngcontent-%COMP%]{padding:8px 5px 0}.track-range-select[_ngcontent-%COMP%]{width:100%}.track-range-custom[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;gap:0 8px}.track-range-custom[_ngcontent-%COMP%] mat-form-field[_ngcontent-%COMP%]{flex:1 1 220px}@media only screen and (min-width:475px){button[_ngcontent-%COMP%]{min-width:inherit;padding:inherit}.dialog-content[_ngcontent-%COMP%]{min-width:400px}.dialog-icon[_ngcontent-%COMP%]{display:inline}}@media only screen and (min-width:800px){.card-group[_ngcontent-%COMP%]{padding:5px 5%}}"]})};export{Le as GPXExportDialog,X as fromLocalInput,$e as toLocalInput};