tilfluktsrom/pwa/dist/assets/index-Db4vftzp.js

13 lines
168 KiB
JavaScript
Raw Normal View History

(function(){const l=document.createElement("link").relList;if(l&&l.supports&&l.supports("modulepreload"))return;for(const d of document.querySelectorAll('link[rel="modulepreload"]'))_(d);new MutationObserver(d=>{for(const g of d)if(g.type==="childList")for(const p of g.addedNodes)p.tagName==="LINK"&&p.rel==="modulepreload"&&_(p)}).observe(document,{childList:!0,subtree:!0});function r(d){const g={};return d.integrity&&(g.integrity=d.integrity),d.referrerPolicy&&(g.referrerPolicy=d.referrerPolicy),d.crossOrigin==="use-credentials"?g.credentials="include":d.crossOrigin==="anonymous"?g.credentials="omit":g.credentials="same-origin",g}function _(d){if(d.ep)return;d.ep=!0;const g=r(d);fetch(d.href,g)}})();const _r={app_name:"Tilfluktsrom",status_ready:"Ready",status_loading:"Loading shelter data…",status_updating:"Updating…",status_offline:"Offline mode",status_shelters_loaded:"%d shelters loaded",status_no_location:"Waiting for GPS…",status_caching_map:"Caching map for offline use…",loading_shelters:"Downloading shelter data…",loading_map:"Caching map tiles…",loading_map_explanation:`Preparing offline map.
The map will scroll briefly to cache your surroundings.`,loading_first_time:"Setting up for first use…",shelter_capacity:"%d places",shelter_room_nr:"Room %d",nearest_shelter:"Nearest shelter",no_shelters:"No shelter data available",action_refresh:"Refresh data",action_toggle_view:"Toggle map/compass view",action_skip:"Skip",action_cache_ok:"Cache map",action_cache_now:"Cache now",warning_no_map_cache:"No offline map cached. Map requires internet.",permission_location_title:"Location permission required",permission_location_message:"This app needs your location to find the nearest shelter. Please grant location access.",permission_denied:"Location permission denied. The app cannot find nearby shelters without it.",error_download_failed:"Could not download shelter data. Check your internet connection.",error_no_data_offline:"No cached data available. Connect to the internet to download shelter data.",update_success:"Shelter data updated",update_failed:"Update failed — using cached data"},mr={app_name:"Tilfluktsrom",status_ready:"Klar",status_loading:"Laster tilfluktsromdata…",status_updating:"Oppdaterer…",status_offline:"Frakoblet modus",status_shelters_loaded:"%d tilfluktsrom lastet",status_no_location:"Venter på GPS…",status_caching_map:"Lagrer kart for frakoblet bruk…",loading_shelters:"Laster ned tilfluktsromdata…",loading_map:"Lagrer kartfliser…",loading_map_explanation:`Forbereder frakoblet kart.
Kartet vil rulle kort for å lagre omgivelsene dine.`,loading_first_time:"Gjør klar for første gangs bruk…",shelter_capacity:"%d plasser",shelter_room_nr:"Rom %d",nearest_shelter:"Nærmeste tilfluktsrom",no_shelters:"Ingen tilfluktsromdata tilgjengelig",action_refresh:"Oppdater data",action_toggle_view:"Bytt mellom kart og kompassvisning",action_skip:"Hopp over",action_cache_ok:"Lagre kart",action_cache_now:"Lagre nå",warning_no_map_cache:"Ingen frakoblet kart lagret. Kartet krever internett.",permission_location_title:"Posisjonstillatelse kreves",permission_location_message:"Denne appen trenger din posisjon for å finne nærmeste tilfluktsrom. Vennligst gi tilgang til posisjon.",permission_denied:"Posisjonstillatelse avslått. Appen kan ikke finne tilfluktsrom i nærheten uten den.",error_download_failed:"Kunne ikke laste ned tilfluktsromdata. Sjekk internettforbindelsen.",error_no_data_offline:"Ingen lagrede data tilgjengelig. Koble til internett for å laste ned tilfluktsromdata.",update_success:"Tilfluktsromdata oppdatert",update_failed:"Oppdatering mislyktes — bruker lagrede data"},pr={app_name:"Tilfluktsrom",status_ready:"Klar",status_loading:"Lastar tilfluktsromdata…",status_updating:"Oppdaterer…",status_offline:"Fråkopla modus",status_shelters_loaded:"%d tilfluktsrom lasta",status_no_location:"Ventar på GPS…",status_caching_map:"Lagrar kart for fråkopla bruk…",loading_shelters:"Lastar ned tilfluktsromdata…",loading_map:"Lagrar kartfliser…",loading_map_explanation:`Førebur fråkopla kart.
Kartet vil rulle kort for å lagre omgjevnadene dine.`,loading_first_time:"Gjer klar for fyrste gongs bruk…",shelter_capacity:"%d plassar",shelter_room_nr:"Rom %d",nearest_shelter:"Næraste tilfluktsrom",no_shelters:"Ingen tilfluktsromdata tilgjengeleg",action_refresh:"Oppdater data",action_toggle_view:"Byt mellom kart og kompassvising",action_skip:"Hopp over",action_cache_ok:"Lagre kart",action_cache_now:"Lagre no",warning_no_map_cache:"Ingen fråkopla kart lagra. Kartet krev internett.",permission_location_title:"Posisjonsløyve krevst",permission_location_message:"Denne appen treng posisjonen din for å finne næraste tilfluktsrom. Ver venleg og gje tilgang til posisjon.",permission_denied:"Posisjonsløyve avslått. Appen kan ikkje finne tilfluktsrom i nærleiken utan det.",error_download_failed:"Kunne ikkje laste ned tilfluktsromdata. Sjekk internettilkoplinga.",error_no_data_offline:"Ingen lagra data tilgjengeleg. Kopla til internett for å laste ned tilfluktsromdata.",update_success:"Tilfluktsromdata oppdatert",update_failed:"Oppdatering mislukkast — brukar lagra data"},Oi={en:_r,nb:mr,nn:pr};let Bi="en";function gr(){const a=navigator.languages??[navigator.language];for(const l of a){const r=l.toLowerCase().split("-")[0];if(r in Oi){Bi=r;return}if(r==="no"){Bi="nb";return}}}function O(a,...l){var _;let r=((_=Oi[Bi])==null?void 0:_[a])??Oi.en[a]??a;for(const d of l)r=r.replace(/%[ds]/,String(d));return r}const vr=6371e3;function Bt(a){return a*Math.PI/180}function yr(a){return a*180/Math.PI}function wr(a,l,r,_){const d=Bt(r-a),g=Bt(_-l),p=Math.sin(d/2)**2+Math.cos(Bt(a))*Math.cos(Bt(r))*Math.sin(g/2)**2;return vr*2*Math.atan2(Math.sqrt(p),Math.sqrt(1-p))}function xr(a,l,r,_){const d=Bt(a),g=Bt(r),p=Bt(_-l),S=Math.sin(p)*Math.cos(g),y=Math.cos(d)*Math.sin(g)-Math.sin(d)*Math.cos(g)*Math.cos(p);return(yr(Math.atan2(S,y))+360)%360}function Mo(a){return a<1e3?`${Math.round(a)} m`:`${(a/1e3).toFixed(1)} km`}function Lr(a,l,r,_=3){return a.map(d=>({shelter:d,distanceMeters:wr(l,r,d.latitude,d.longitude),bearingDegrees:xr(l,r,d.latitude,d.longitude)})).sort((d,g)=>d.distanceMeters-g.distanceMeters).slice(0,_)}const Zi=(a,l)=>l.some(r=>a instanceof r);let po,go;function Pr(){return po||(po=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function br(){return go||(go=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Ai=new WeakMap,Ci=new WeakMap,We=new WeakMap;function Tr(a){const l=new Promise((r,_)=>{const d=()=>{a.removeEventListener("success",g),a.removeEventListener("error",p)},g=()=>{r(Zt(a.result)),d()},p=()=>{_(a.error),d()};a.addEventListener("success",g),a.addEventListener("error",p)});return We.set(l,a),l}function Mr(a){if(Ai.has(a))return;const l=new Promise((r,_)=>{const d=()=>{a.removeEventListener("complete",g),a.removeEventListener("error",p),a.removeEventListener("abort",p)},g=()=>{r(),d()},p=()=>{_(a.error||new DOMException("AbortError","AbortError")),d()};a.addEventListener("complete",g),a.addEventListener("error",p),a.addEventListener("abort",p)});Ai.set(a,l)}let Di={get(a,l,r){if(a instanceof IDBTransaction){if(l==="done")return Ai.get(a);if(l==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return Zt(a[l])},set(a,l,r){return a[l]=r,!0},has(a,l){return a instanceof IDBTransaction&&(l==="done"||l==="store")?!0:l in a}};function ko(a){Di=a(Di)}function kr(a){return br().includes(a)?function(...l){return a.apply(Ni(this),l),Zt(this.request)}:function(...l){return Zt(a.apply(Ni(this),l))}}function Cr(a){return typeof a=="function"?kr(a):(a instanceof IDBTransaction&&Mr(a),Zi(a,Pr())?new Proxy(a,Di):a)}function Zt(a){if(a instanceof IDBRequest)return Tr(a);if(Ci.has(a))return Ci.get(a);const l=Cr(a);return l!==a&&(Ci.set(a,l),We.set(l,a)),l}const Ni=a=>We.get(a);function Sr(a,l,{blocked:r,upgrade:_,blocking:d,terminated:g}={}){const p=indexedDB.open(a,l),S=Zt(p);return _&&p.addEventListener("upgradeneeded",y=>{_(Zt(p.result),y.oldVersion,y.newVersion,Zt(p.transaction),y)}),r&&p.addEventListener("block
* Leaflet 1.9.4, a JS library for interactive maps. https://leafletjs.com
* (c) 2010-2023 Vladimir Agafonkin, (c) 2010-2011 CloudMade
*/(function(a,l){(function(r,_){_(l)})(Kr,function(r){var _="1.9.4";function d(t){var e,i,n,o;for(i=1,n=arguments.length;i<n;i++){o=arguments[i];for(e in o)t[e]=o[e]}return t}var g=Object.create||function(){function t(){}return function(e){return t.prototype=e,new t}}();function p(t,e){var i=Array.prototype.slice;if(t.bind)return t.bind.apply(t,i.call(arguments,1));var n=i.call(arguments,2);return function(){return t.apply(e,n.length?n.concat(i.call(arguments)):arguments)}}var S=0;function y(t){return"_leaflet_id"in t||(t._leaflet_id=++S),t._leaflet_id}function q(t,e,i){var n,o,s,h;return h=function(){n=!1,o&&(s.apply(i,o),o=!1)},s=function(){n?o=arguments:(t.apply(i,arguments),setTimeout(h,e),n=!0)},s}function pt(t,e,i){var n=e[1],o=e[0],s=n-o;return t===n&&i?t:((t-o)%s+s)%s+o}function Z(){return!1}function it(t,e){if(e===!1)return t;var i=Math.pow(10,e===void 0?6:e);return Math.round(t*i)/i}function Ve(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Ct(t){return Ve(t).split(/\s+/)}function B(t,e){Object.prototype.hasOwnProperty.call(t,"options")||(t.options=t.options?g(t.options):{});for(var i in e)t.options[i]=e[i];return t.options}function Qi(t,e,i){var n=[];for(var o in t)n.push(encodeURIComponent(i?o.toUpperCase():o)+"="+encodeURIComponent(t[o]));return(!e||e.indexOf("?")===-1?"?":"&")+n.join("&")}var Ho=/\{ *([\w_ -]+) *\}/g;function $i(t,e){return t.replace(Ho,function(i,n){var o=e[n];if(o===void 0)throw new Error("No value provided for variable "+i);return typeof o=="function"&&(o=o(e)),o})}var at=Array.isArray||function(t){return Object.prototype.toString.call(t)==="[object Array]"};function je(t,e){for(var i=0;i<t.length;i++)if(t[i]===e)return i;return-1}var fe="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";function Ge(t){return window["webkit"+t]||window["moz"+t]||window["ms"+t]}var tn=0;function en(t){var e=+new Date,i=Math.max(0,16-(e-tn));return tn=e+i,window.setTimeout(t,i)}var qe=window.requestAnimationFrame||Ge("RequestAnimationFrame")||en,nn=window.cancelAnimationFrame||Ge("CancelAnimationFrame")||Ge("CancelRequestAnimationFrame")||function(t){window.clearTimeout(t)};function K(t,e,i){if(i&&qe===en)t.call(e);else return qe.call(window,p(t,e))}function nt(t){t&&nn.call(window,t)}var Wo={__proto__:null,extend:d,create:g,bind:p,get lastId(){return S},stamp:y,throttle:q,wrapNum:pt,falseFn:Z,formatNum:it,trim:Ve,splitWords:Ct,setOptions:B,getParamString:Qi,template:$i,isArray:at,indexOf:je,emptyImageUrl:fe,requestFn:qe,cancelFn:nn,requestAnimFrame:K,cancelAnimFrame:nt};function gt(){}gt.extend=function(t){var e=function(){B(this),this.initialize&&this.initialize.apply(this,arguments),this.callInitHooks()},i=e.__super__=this.prototype,n=g(i);n.constructor=e,e.prototype=n;for(var o in this)Object.prototype.hasOwnProperty.call(this,o)&&o!=="prototype"&&o!=="__super__"&&(e[o]=this[o]);return t.statics&&d(e,t.statics),t.includes&&(Uo(t.includes),d.apply(null,[n].concat(t.includes))),d(n,t),delete n.statics,delete n.includes,n.options&&(n.options=i.options?g(i.options):{},d(n.options,t.options)),n._initHooks=[],n.callInitHooks=function(){if(!this._initHooksCalled){i.callInitHooks&&i.callInitHooks.call(this),this._initHooksCalled=!0;for(var s=0,h=n._initHooks.length;s<h;s++)n._initHooks[s].call(this)}},e},gt.include=function(t){var e=this.prototype.options;return d(this.prototype,t),t.options&&(this.prototype.options=e,this.mergeOptions(t.options)),this},gt.mergeOptions=function(t){return d(this.prototype.options,t),this},gt.addInitHook=function(t){var e=Array.prototype.slice.call(arguments,1),i=typeof t=="function"?t:function(){this[t].apply(this,e)};return this.prototype._initHooks=this.prototype._initHooks||[],this.prototype._initHooks.push(i),this};function Uo(t){if(!(typeof L>"u"||!L||!L.Mixin)){t=at(t)?t:[t];for(var e=0;e<t.length;e++)t[e]===L.Mixin.Events&&console.warn("Deprecated include of L.Mixin.Events: this property will be removed in future releases, please inherit from L.Evented instead.",new Error().stack)}}var $={on:function(t,e,i){if(typeof t=="object")for(var n in t)
<path d="M12 2L2 12h3v8h14v-8h3L12 2z" fill="#FF6B35" stroke="#fff" stroke-width="1.5"/>
<text x="12" y="17" text-anchor="middle" fill="#fff" font-size="8" font-weight="bold">T</text>
</svg>`,iconSize:[28,28],iconAnchor:[14,28],popupAnchor:[0,-28]}),Qr=et.divIcon({className:"shelter-marker selected",html:`<svg viewBox="0 0 24 24" width="36" height="36">
<path d="M12 2L2 12h3v8h14v-8h3L12 2z" fill="#FFC107" stroke="#fff" stroke-width="1.5"/>
<text x="12" y="17" text-anchor="middle" fill="#1A1A2E" font-size="8" font-weight="bold">T</text>
</svg>`,iconSize:[36,36],iconAnchor:[18,36],popupAnchor:[0,-36]});let V=null,Ii=null,Ze=[],Ae=null,He=!1,De=null;function $r(a,l){return De=l,V=et.map(a,{zoomControl:!0,attributionControl:!0}).setView(Xr,Ki),et.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',maxZoom:19}).addTo(V),V.on("dragstart",()=>{He=!0}),V.on("zoomstart",r=>{ce||(He=!0)}),V}let ce=!1;function ta(a){if(!V)return;const l=et.latLng(a.latitude,a.longitude);Ii?Ii.setLatLng(l):Ii=et.circleMarker(l,{radius:8,fillColor:"#4285F4",fillOpacity:1,color:"#fff",weight:3}).addTo(V)}function ji(a){if(V){for(const l of Ze)V.removeLayer(l);Ze=[],Ae=null;for(const l of a){const r=et.marker([l.latitude,l.longitude],{icon:Eo}).bindPopup(`<strong>${l.adresse}</strong><br>${O("shelter_capacity",l.plasser)} &middot; ${O("shelter_room_nr",l.romnr)}`).on("click",()=>{De==null||De(l)});r.addTo(V),r._shelterLokalId=l.lokalId,Ze.push(r)}}}function ea(a,l){if(V){for(const r of Ze){const _=r._shelterLokalId;_===a.shelter.lokalId?(r.setIcon(Qr),Ae=_):(_===Ae||Ae===null)&&r.setIcon(Eo)}He||Io(a,l)}}function Io(a,l){if(!V)return;ce=!0;const r=et.latLng(a.shelter.latitude,a.shelter.longitude);if(l){const _=et.latLng(l.latitude,l.longitude),d=et.latLngBounds([_,r]);V.fitBounds(d.pad(.3),{animate:!0})}else V.setView(r,Ki,{animate:!0});setTimeout(()=>{ce=!1},500)}function zo(a,l){He=!1,a?Io(a,l):l&&(ce=!0,V==null||V.setView(et.latLng(l.latitude,l.longitude),Ki,{animate:!0}),setTimeout(()=>{ce=!1},500))}function Gi(){return V}const ia="#FF6B35",na="#FFFFFF",oa=4;let tt=null,R=null,Oo=0,zi=0;function sa(a){tt=document.createElement("canvas"),tt.id="compass-canvas",tt.style.width="100%",tt.style.height="100%",a.prepend(tt),xo(),window.addEventListener("resize",xo)}function xo(){if(!tt)return;const a=tt.parentElement.getBoundingClientRect();tt.width=a.width*devicePixelRatio,tt.height=a.height*devicePixelRatio,Zo()}function Bo(a){Oo=a,zi&&cancelAnimationFrame(zi),zi=requestAnimationFrame(Zo)}function Zo(){if(!tt||(R=tt.getContext("2d"),!R))return;const a=tt.width,l=tt.height,r=a/2,_=l/2,d=Math.min(a,l)*.4;R.clearRect(0,0,a,l),R.save(),R.translate(r,_),R.rotate(Oo*Math.PI/180),R.beginPath(),R.moveTo(0,-d),R.lineTo(d*.5,d*.3),R.lineTo(d*.15,d*.1),R.lineTo(d*.15,d*.7),R.lineTo(-d*.15,d*.7),R.lineTo(-d*.15,d*.1),R.lineTo(-d*.5,d*.3),R.closePath(),R.fillStyle=ia,R.fill(),R.strokeStyle=na,R.lineWidth=oa,R.stroke(),R.restore()}let Gt=null,Ne=null,Lo=0;function ra(a,l){Gt=a,Ne=l}function Ao(a,l){if(Gt){for(Lo=l;Gt.firstChild;)Gt.removeChild(Gt.firstChild);a.forEach((r,_)=>{const d=document.createElement("button");d.className=`shelter-item${_===Lo?" selected":""}`;const g=document.createElement("span");g.className="shelter-item-address",g.textContent=r.shelter.adresse;const p=document.createElement("span");p.className="shelter-item-details",p.textContent=[Mo(r.distanceMeters),O("shelter_capacity",r.shelter.plasser),O("shelter_room_nr",r.shelter.romnr)].join(" · "),d.appendChild(g),d.appendChild(p),d.addEventListener("click",()=>{Ne==null||Ne(_)}),Gt.appendChild(d)})}}function Q(a){const l=document.getElementById("status-text");l&&(l.textContent=a)}function aa(a){const l=document.getElementById("refresh-btn");l&&l.addEventListener("click",a)}function Do(a,l=!0){const r=document.getElementById("loading-overlay"),_=document.getElementById("loading-text"),d=document.getElementById("loading-spinner"),g=document.getElementById("loading-button-row");_.textContent=a,d.style.display=l?"block":"none",g.style.display="none",r.style.display="flex"}function ha(a,l,r){const _=document.getElementById("loading-overlay"),d=document.getElementById("loading-text"),g=document.getElementById("loading-spinner"),p=document.getElementById("loading-button-row"),S=document.getElementById("loading-ok-btn"),y=document.getElementById("loading-skip-btn");d.textContent=a,g.style.display="none",p.style.display="flex",_.style.display="flex",S.onclick=()=>{de(),l()},y.onclick=()=>{de(),r()}}function la(a){const l=document.getE