PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 All 504 releases
← All changes | _inc/blocks/map/view.js +1 -1 12.2.3 → 16.3-a.1 View file →
@@ -1 +1 @@
1 -(()=>{var t={90055:(t,e,i)=>{"use strict";function o(t,e){return{default:{details:"mapbox://styles/automattic/cjolkhmez0qdd2ro82dwog1in",no_details:"mapbox://styles/automattic/cjolkci3905d82soef4zlmkdo"},black_and_white:{details:"mapbox://styles/automattic/cjolkixvv0ty42spgt2k4j434",no_details:"mapbox://styles/automattic/cjolkgc540tvj2spgzzoq37k4"},satellite:{details:"mapbox://styles/mapbox/satellite-streets-v10",no_details:"mapbox://styles/mapbox/satellite-v9"},terrain:{details:"mapbox://styles/automattic/cjolkf8p405fh2soet2rdt96b",no_details:"mapbox://styles/automattic/cjolke6fz12ys2rpbpvgl12ha"}}[t][e?"details":"no_details"]}i.d(e,{h:()=>o})},84634:(t,e,i)=>{"use strict";i.d(e,{YB:()=>n,b2:()=>o,k:()=>s,xt:()=>a,zb:()=>r});const o=t=>t.hasOwnProperty("lat")&&t.hasOwnProperty("lng")?t:{lat:t.latitude||0,lng:t.longitude||0};function n(t,e){const i=new t.LngLatBounds;return e.forEach((t=>{i.extend([t.coordinates.longitude,t.coordinates.latitude])})),i}function s(t,e){t.fitBounds(e,{padding:{top:80,bottom:80,left:40,right:40}})}function r(t,e){t.innerHTML=`\n\t\t<?xml version="1.0" encoding="UTF-8"?>\n\t\t<svg version="1.1" viewBox="0 0 32 38" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">\n\t\t\t<g fill-rule="evenodd">\n\t\t\t\t<path id="d" d="m16 38s16-11.308 16-22-7.1634-16-16-16-16 5.3076-16 16 16 22 16 22z" fill="${e}"/>\n\t\t\t</g>\n\t\t</svg>\n\t`}function a(t){return new t.Popup({closeButton:!0,closeOnClick:!1,offset:{left:[0,0],top:[0,5],right:[0,0],bottom:[0,-40]}})}},96442:(t,e,i)=>{"use strict";i.d(e,{E0:()=>l,ot:()=>r,rZ:()=>a});var o=i(85007);const n=6371e3;function s(t){return Math.abs(n*Math.cos(t*Math.PI/180)*2*Math.PI/256)}function r(t,e){return 512/Math.pow(2,t)*.5*s(e)}function a(t,e){return new Promise((i=>{if(e.mapkitScriptIsLoading)(0,o.Dz)(e,"mapkit").then((t=>{i(t)}));else{e.mapkitScriptIsLoading=!0;const n=t.createElement("script");n.addEventListener("load",(async()=>{const t=await(0,o.Dz)(e,"mapkit");e.mapkitScriptIsLoading=!1,i(t)}),{once:!0}),n.src="https://cdn.apple-mapkit.com/mk/5.x.x/mapkit.js",n.crossOrigin="anonymous",t.head.appendChild(n)}}))}function l(t,e,i){return new Promise(((e,o)=>{i.mapkitIsInitialized?e():i.mapkitIsInitializing?function(t){return new Promise(((e,i)=>{const o=()=>{void 0===t.mapkitIsInitializing?i():!1===t.mapkitIsInitializing?e():t.requestAnimationFrame(o)};o()}))}(i).then((()=>{e()})):(i.mapkitIsInitializing=!0,i.mapkitIsInitialized=!1,t.init({authorizationCallback:async t=>{try{const n=await fetch("https://public-api.wordpress.com/wpcom/v2/mapkit");if(200===n.status){t((await n.json()).wpcom_mapkit_access_token)}else o();i.mapkitIsInitializing=!1,i.mapkitIsInitialized=!0,e()}catch(t){o()}}}))}))}},51321:(t,e,i)=>{"use strict";i.d(e,{Z:()=>o});const o=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(e)t.style.height=e+"px";else{const e=t.offsetWidth,i=window.location.search.indexOf("map-block-counter")>-1?window.innerHeight:.8*window.innerHeight,o=Math.min(e*(3/4),i);t.style.height=o+"px"}}},24795:(t,e,i)=>{"use strict";i.d(e,{G:()=>o.Z,k:()=>n.Z});var o=i(49735),n=i(75867)},49735:(t,e,i)=>{"use strict";i.d(e,{Z:()=>d});var o=i(90017),n=i.n(o),s=i(85007),r=i(24393),a=i(45388),l=i(90055),p=i(84634),c=i(51321);const d=class{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:()=>{};n()(this,"sizeMap",(()=>{(0,c.Z)(this.container,this.mapHeight),this.map.resize(),this.setBoundsByMarkers()})),n()(this,"closeInfoWindow",(()=>{this.activeMarker=null,this.infoWindow.remove()})),this.root=t;const{currentDoc:i,currentWindow:o}=(0,s.bL)(this.root);this.document=i,this.window=o,this.onError=e,this.mapStyle=this.root.getAttribute("data-map-style")||"default",this.mapDetails="true"===this.root.getAttribute("data-map-details"),this.apiKey=this.root.getAttribute("data-api-key")||null,this.scrollToZoom="true"===this.root.getAttribute("data-scroll-to-zoom"),this.showFullscreenButton="true"===this.root.getAttribute("data-show-fullscreen-button"),this.points=JSON.parse(this.root.getAttribute("data-points")||"[]"),this.mapCenter=JSON.parse(this.root.getAttribute("data-map-center")||"{}"),this.mapHeight=this.root.getAttribute("data-map-height")||null,this.markerColor=this.root.getAttribute("data-marker-color")||"red";const r=this.root.getAttribute("data-zoom");this.zoom=r&&r.length?parseInt(this.root.getAttribute("data-zoom"),10):13,this.activeMarker=null;const a=this.root.querySelector("ul");if(a&&(a.style.display="none"),!this.apiKey||!this.apiKey.length)throw new Error("API key missing")}initDOM(){this.root.innerHTML='<div class="wp-block-jetpack-map__gm-container"></div>',this.container=this.root.querySelector(".wp-block-jetpack-map__gm-container")}loadMapLibraries(){return new Promise((t=>{const e={"mapbox-gl-js":()=>{(0,s.Dz)(this.window,"mapboxgl").then((e=>{this.mapboxgl=e,e.accessToken=this.apiKey,t(e)}))}};(0,s.Pp)(a,e,this.root)}))}initMap(){try{this.map=new this.mapboxgl.Map({container:this.container,style:(0,l.h)(this.mapStyle,this.mapDetails),center:(0,p.b2)(this.mapCenter),zoom:this.zoom,pitchWithRotate:!1,attributionControl:!1,dragRotate:!1})}catch(t){return void this.onError("mapbox_error",t.message)}this.scrollToZoom||this.map.scrollZoom.disable(),this.showFullscreenButton&&this.map.addControl(new this.mapboxgl.FullscreenControl),this.map.on("error",(t=>{this.onError("mapbox_error",t.error.message)})),this.zoomControl=new this.mapboxgl.NavigationControl({showCompass:!1,showZoom:!0})}initInfoWindow(){this.infoWindowContent=this.document.createElement("div"),this.infoWindow=(0,p.xt)(this.mapboxgl),this.infoWindow.setDOMContent(this.infoWindowContent)}setBoundsByMarkers(){if(!this.map)return;if(this.map.dragPan.enable(),!this.points.length)return;if(this.activeMarker)return;const t=(0,p.YB)(this.mapboxgl,this.points);this.points.length>1?(0,p.k)(this.map,t):(this.map.setCenter(t.getCenter()),this.map.addControl(this.zoomControl))}initMapSize(){this.setBoundsByMarkers(),this.debouncedSizeMap=(0,r.D)(this.sizeMap,250),this.debouncedSizeMap()}initHandlers(){this.map.getCanvas().addEventListener("click",this.closeInfoWindow),window.addEventListener("resize",this.debouncedSizeMap)}showInfoWindow(t,e){const i=[e.coordinates.longitude,e.coordinates.latitude];this.activeMarker=t,this.infoWindowContent.innerHTML="<h3></h3><p></p>",this.infoWindowContent.querySelector("h3").textContent=e.title,this.infoWindowContent.querySelector("p").textContent=e.caption,this.infoWindow.setLngLat(i).addTo(this.map)}initMarkers(){this.points.forEach((t=>{const e=[t.coordinates.longitude,t.coordinates.latitude],i=this.document.createElement("div");i.className="wp-block-jetpack-map-marker";const o=new this.mapboxgl.Marker(i).setLngLat(e).setOffset([0,-19]).addTo(this.map);o.getElement().addEventListener("click",(()=>this.showInfoWindow(o,t))),(0,p.zb)(i,this.markerColor)}))}async init(){this.initDOM(),await this.loadMapLibraries(),this.initMap(),this.initInfoWindow(),this.initMapSize(),this.initHandlers(),this.initMarkers()}}},75867:(t,e,i)=>{"use strict";i.d(e,{Z:()=>l});var o=i(90017),n=i.n(o),s=i(24393),r=i(96442),a=i(51321);const l=class{constructor(t){n()(this,"sizeMap",(()=>{(0,a.Z)(this.container,this.mapHeight)})),this.root=t,this.blog_id=this.root.getAttribute("data-blog-id"),this.center=JSON.parse(this.root.getAttribute("data-map-center")),this.points=JSON.parse(this.root.getAttribute("data-points")||"[]"),this.color=this.root.getAttribute("data-marker-color")||"red",this.zoom=parseFloat(this.root.getAttribute("data-zoom"))||10,this.scrollToZoom="true"===this.root.getAttribute("data-scroll-to-zoom"),this.mapStyle=this.root.getAttribute("data-map-style")||"default",this.mapHeight=this.root.getAttribute("data-map-height")||null}async init(){this.initDOM(),await this.loadLibrary(),await this.fetchKey(),this.initMapSize(),this.initMap(),this.addPoints(),this.initHandlers()}initDOM(){this.root.innerHTML='<div class="wp-block-jetpack-map__mb-container"></div>',this.container=this.root.querySelector(".wp-block-jetpack-map__mb-container")}initMapSize(){this.debouncedSizeMap=(0,s.D)(this.sizeMap,250),this.sizeMap()}initHandlers(){window.addEventListener("resize",this.debouncedSizeMap)}loadLibrary(){return new Promise((t=>{(0,r.rZ)(document,window).then((e=>{this.mapkit=e,t()}))}))}fetchKey(){return(0,r.E0)(this.mapkit,this.blog_id,window)}initMap(){const t=new this.mapkit.Coordinate(this.center.lat,this.center.lng),e=(()=>{switch(this.mapStyle){case"satellite":return this.mapkit.Map.MapTypes.Satellite;case"black_and_white":return this.mapkit.Map.MapTypes.MutedStandard;case"hybrid":return this.mapkit.Map.MapTypes.Hybrid;default:return this.mapkit.Map.MapTypes.Standard}})();this.map=new this.mapkit.Map(this.container,{center:t,mapType:e,showsMapTypeControl:!1}),this.points.length<2&&this.zoom&&this.setZoom(),this.scrollToZoom&&(this.map._allowWheelToZoom=!0)}setZoom(){this.map.cameraDistance=(0,r.ot)(this.zoom,this.center.lat)}addPoints(){const t=this.points.map((t=>{const e=new this.mapkit.Coordinate(t.coordinates.latitude,t.coordinates.longitude);return new this.mapkit.MarkerAnnotation(e,{color:this.color,title:t.title,callout:{calloutContentForAnnotation:function(t){const e=document.createElement("div");e.style.width=t.element.parentElement.offsetWidth/2+"px";const i=e.appendChild(document.createElement("div"));i.style.fontSize="17px",i.style.fontWeight="600",i.style.lineHeight="19px",i.style.marginTop="8px",i.textContent=t.title;const o=e.appendChild(document.createElement("p"));return o.style.fontSize="14px",o.style.margin="0px 0px 4px 0px",o.textContent=t.data?.caption,e}},calloutEnabled:!0,data:{caption:t.caption}})}));this.map.showItems(t)}}},85007:(t,e,i)=>{"use strict";function o(t){const e=t.ownerDocument;return{currentDoc:e,currentWindow:e.defaultView||e.parentWindow}}function n(t,e,i){const n=`${window.Jetpack_Block_Assets_Base_Url.url}editor-assets`,{currentDoc:s}=o(i),r=s.getElementsByTagName("head")[0];t.forEach((t=>{const[i,o]=t.file.split("/").pop().split(".");if("css"===o){if(s.getElementById(t.id))return;const e=s.createElement("link");e.id=t.id,e.rel="stylesheet",e.href=`${n}/${i}-${t.version}.${o}`,r.appendChild(e)}if("js"===o){const a=e[t.id]?e[t.id]:null;if(s.getElementById(t.id))return a();const l=s.createElement("script");l.id=t.id,l.type="text/javascript",l.src=`${n}/${i}-${t.version}.${o}`,l.onload=a,r.appendChild(l)}}))}function s(t,e){return new Promise((i=>{const o=()=>{t[e]?i(t[e]):t.requestAnimationFrame(o)};o()}))}i.d(e,{Dz:()=>s,Pp:()=>n,bL:()=>o})},24393:(t,e,i)=>{"use strict";function o(t,e){let i;return function(){for(var o=arguments.length,n=new Array(o),s=0;s<o;s++)n[s]=arguments[s];clearTimeout(i),i=setTimeout((()=>t.apply(this,n)),e)}}i.d(e,{D:()=>o})},80425:(t,e,i)=>{"object"==typeof window&&window.Jetpack_Block_Assets_Base_Url&&window.Jetpack_Block_Assets_Base_Url.url&&(i.p=window.Jetpack_Block_Assets_Base_Url.url)},47701:t=>{"use strict";t.exports=window.wp.domReady},90017:(t,e,i)=>{var o=i(96930);t.exports=function(t,e,i){return(e=o(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t},t.exports.__esModule=!0,t.exports.default=t.exports},45061:(t,e,i)=>{var o=i(73522).default;t.exports=function(t,e){if("object"!==o(t)||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!==o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)},t.exports.__esModule=!0,t.exports.default=t.exports},96930:(t,e,i)=>{var o=i(73522).default,n=i(45061);t.exports=function(t){var e=n(t,"string");return"symbol"===o(e)?e:String(e)},t.exports.__esModule=!0,t.exports.default=t.exports},73522:t=>{function e(i){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(i)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports},45388:t=>{"use strict";t.exports=JSON.parse('[{"id":"mapbox-gl-js","file":"node_modules/mapbox-gl/dist/mapbox-gl.js","version":"1.13.0"},{"id":"mapbox-gl-css","file":"node_modules/mapbox-gl/dist/mapbox-gl.css","version":"1.13.0"}]')}},e={};function i(o){var n=e[o];if(void 0!==n)return n.exports;var s=e[o]={exports:{}};return t[o](s,s.exports,i),s.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var o in e)i.o(e,o)&&!i.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{var t;i.g.importScripts&&(t=i.g.location+"");var e=i.g.document;if(!t&&e&&(e.currentScript&&(t=e.currentScript.src),!t)){var o=e.getElementsByTagName("script");o.length&&(t=o[o.length-1].src)}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i.p=t+"../"})(),(()=>{"use strict";i(80425)})(),(()=>{"use strict";var t=i(47701),e=i.n(t),o=i(24795);e()((function(){Array.from(document.querySelectorAll(".wp-block-jetpack-map")).forEach((async t=>{try{if("mapkit"===t.getAttribute("data-map-provider")){new o.k(t).init()}else{new o.G(t).init()}}catch(t){}}))}))})()})();
1 +(()=>{var t={50221(){},64525(){},82063(t,e,i){"use strict";function o(t,e){return{default:{details:"mapbox://styles/automattic/cjolkhmez0qdd2ro82dwog1in",no_details:"mapbox://styles/automattic/cjolkci3905d82soef4zlmkdo"},black_and_white:{details:"mapbox://styles/automattic/cjolkixvv0ty42spgt2k4j434",no_details:"mapbox://styles/automattic/cjolkgc540tvj2spgzzoq37k4"},satellite:{details:"mapbox://styles/mapbox/satellite-streets-v10",no_details:"mapbox://styles/mapbox/satellite-v9"},terrain:{details:"mapbox://styles/automattic/cjolkf8p405fh2soet2rdt96b",no_details:"mapbox://styles/automattic/cjolke6fz12ys2rpbpvgl12ha"}}[t][e?"details":"no_details"]}i.d(e,{o:()=>o})},16815(t,e,i){"use strict";i.d(e,{BY:()=>r,ES:()=>s,_t:()=>n,iU:()=>a,jF:()=>o});const o=t=>Object.hasOwn(t,"lat")&&Object.hasOwn(t,"lng")?t:{lat:t.latitude||0,lng:t.longitude||0};function s(t,e){const i=new t.LngLatBounds;return e.forEach(t=>{i.extend([t.coordinates.longitude,t.coordinates.latitude])}),i}function n(t,e){t.fitBounds(e,{padding:{top:80,bottom:80,left:40,right:40}})}function a(t,e){t.innerHTML=`\n\t\t<?xml version="1.0" encoding="UTF-8"?>\n\t\t<svg version="1.1" viewBox="0 0 32 38" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">\n\t\t\t<g fill-rule="evenodd">\n\t\t\t\t<path id="d" d="m16 38s16-11.308 16-22-7.1634-16-16-16-16 5.3076-16 16 16 22 16 22z" fill="${e}"/>\n\t\t\t</g>\n\t\t</svg>\n\t`}function r(t){return new t.Popup({closeButton:!0,closeOnClick:!1,offset:{left:[0,0],top:[0,5],right:[0,0],bottom:[0,-40]}})}},42470(t,e,i){"use strict";i.d(e,{IR:()=>r,Yc:()=>a,c6:()=>n});var o=i(34377);function s(t){return Math.abs(6371e3*Math.cos(t*Math.PI/180)*2*Math.PI/256)}function n(t,e){return 512/Math.pow(2,t)*.5*s(e)}function a(t,e){return new Promise(i=>{if(e.mapkitScriptIsLoading)(0,o.Cu)(e,"mapkit").then(t=>{i(t)});else{e.mapkitScriptIsLoading=!0;const s=t.createElement("script");s.addEventListener("load",async()=>{const t=await(0,o.Cu)(e,"mapkit");e.mapkitScriptIsLoading=!1,i(t)},{once:!0}),s.src="https://cdn.apple-mapkit.com/mk/5.x.x/mapkit.js",s.crossOrigin="anonymous",t.head.appendChild(s)}})}function r(t,e,i){return new Promise((e,o)=>{i.mapkitIsInitialized?e():i.mapkitIsInitializing?function(t){return new Promise((e,i)=>{const o=()=>{void 0===t.mapkitIsInitializing?i():!1===t.mapkitIsInitializing?e():t.requestAnimationFrame(o)};o()})}(i).then(()=>{e()}):(i.mapkitIsInitializing=!0,i.mapkitIsInitialized=!1,t.init({authorizationCallback:async t=>{try{const s=await fetch("https://public-api.wordpress.com/wpcom/v2/mapkit");if(200===s.status){t((await s.json()).wpcom_mapkit_access_token)}else o();i.mapkitIsInitializing=!1,i.mapkitIsInitialized=!0,e()}catch{o()}}}))})}},91844(t,e,i){"use strict";i.d(e,{A:()=>o});const o=(t,e=null)=>{if(e)t.style.height=e+"px";else{const e=t.offsetWidth,i=window.location.search.indexOf("map-block-counter")>-1?window.innerHeight:.8*window.innerHeight,o=Math.min(e*(3/4),i);t.style.height=o+"px"}}},18109(t,e,i){"use strict";i.d(e,{i:()=>s.A,p:()=>o.A});var o=i(2370),s=i(56955)},2370(t,e,i){"use strict";i.d(e,{A:()=>c});var o=i(34377),s=i(71738),n=i(55740),a=i(82063),r=i(16815),l=i(91844);i(64525),i(50221);const c=class{constructor(t,e=()=>{}){this.root=t;const{currentDoc:i,currentWindow:s}=(0,o.sG)(this.root);this.document=i,this.window=s,this.onError=e;const n=this.root.getAttribute("data-map-id"),a=window.JetpackMapBlockData&&n?window.JetpackMapBlockData[n]:null;this.mapStyle=a?.mapStyle||this.root.getAttribute("data-map-style")||"default",this.mapDetails=a?.mapDetails??"true"===this.root.getAttribute("data-map-details"),this.apiKey=this.root.getAttribute("data-api-key")||null,this.scrollToZoom=a?.scrollToZoom??"true"===this.root.getAttribute("data-scroll-to-zoom"),this.showFullscreenButton=a?.showFullscreenButton??"true"===this.root.getAttribute("data-show-fullscreen-button"),this.points=a?.points||JSON.parse(this.root.getAttribute("data-points")||"[]"),this.mapCenter=a?.mapCenter||JSON.parse(this.root.getAttribute("data-map-center")||"{}"),this.mapHeight=a?.mapHeight||this.root.getAttribute("data-map-height")||null,this.markerColor=a?.markerColor||this.root.getAttribute("data-marker-color")||"red";const r=a?.zoom??this.root.getAttribute("data-zoom");this.zoom=null!=r?parseInt(r,10):13,this.activeMarker=null;const l=this.root.querySelector("ul");if(l&&(l.style.display="none"),!this.apiKey||!this.apiKey.length)throw new Error("API key missing")}initDOM(){this.root.innerHTML='<div class="wp-block-jetpack-map__gm-container"></div>',this.container=this.root.querySelector(".wp-block-jetpack-map__gm-container")}loadMapLibraries(){return new Promise(t=>{const e={"mapbox-gl-js":()=>{(0,o.Cu)(this.window,"mapboxgl").then(e=>{this.mapboxgl=e,e.accessToken=this.apiKey,t(e)})}};(0,o.a$)(n,e,this.root)})}initMap(){try{this.map=new this.mapboxgl.Map({container:this.container,style:(0,a.o)(this.mapStyle,this.mapDetails),center:(0,r.jF)(this.mapCenter),zoom:this.zoom,pitchWithRotate:!1,attributionControl:!1,dragRotate:!1})}catch(t){return void this.onError("mapbox_error",t.message)}this.scrollToZoom||this.map.scrollZoom.disable(),this.showFullscreenButton&&this.map.addControl(new this.mapboxgl.FullscreenControl),this.map.on("error",t=>{this.onError("mapbox_error",t.error.message)}),this.zoomControl=new this.mapboxgl.NavigationControl({showCompass:!1,showZoom:!0})}initInfoWindow(){this.infoWindowContent=this.document.createElement("div"),this.infoWindow=(0,r.BY)(this.mapboxgl),this.infoWindow.setDOMContent(this.infoWindowContent)}setBoundsByMarkers(){if(!this.map)return;if(this.map.dragPan.enable(),!this.points.length)return;if(this.activeMarker)return;const t=(0,r.ES)(this.mapboxgl,this.points);this.points.length>1?(0,r._t)(this.map,t):(this.map.setCenter(t.getCenter()),this.map.addControl(this.zoomControl))}sizeMap=()=>{(0,l.A)(this.container,this.mapHeight),this.map.resize(),this.setBoundsByMarkers()};initMapSize(){this.setBoundsByMarkers(),this.debouncedSizeMap=(0,s.s)(this.sizeMap,250),this.debouncedSizeMap()}closeInfoWindow=()=>{this.activeMarker=null,this.infoWindow.remove()};initHandlers(){this.map.getCanvas().addEventListener("click",this.closeInfoWindow),window.addEventListener("resize",this.debouncedSizeMap)}showInfoWindow(t,e){const i=[e.coordinates.longitude,e.coordinates.latitude];this.activeMarker=t,this.infoWindowContent.innerHTML="<h3></h3><p></p>",this.infoWindowContent.querySelector("h3").textContent=e.title,this.infoWindowContent.querySelector("p").textContent=e.caption,this.infoWindow.setLngLat(i).addTo(this.map)}initMarkers(){this.points.forEach(t=>{const e=[t.coordinates.longitude,t.coordinates.latitude],i=this.document.createElement("div");i.className="wp-block-jetpack-map-marker";const o=new this.mapboxgl.Marker(i).setLngLat(e).setOffset([0,-19]).addTo(this.map);o.getElement().addEventListener("click",()=>this.showInfoWindow(o,t)),(0,r.iU)(i,this.markerColor)})}async init(){this.initDOM(),await this.loadMapLibraries(),this.initMap(),this.initInfoWindow(),this.initMapSize(),this.initHandlers(),this.initMarkers()}}},56955(t,e,i){"use strict";i.d(e,{A:()=>a});var o=i(71738),s=i(42470),n=i(91844);const a=class{constructor(t){this.root=t;const e=this.root.getAttribute("data-map-id"),i=window.JetpackMapBlockData&&e?window.JetpackMapBlockData[e]:null;this.blog_id=this.root.getAttribute("data-blog-id"),this.center=i?.mapCenter||JSON.parse(this.root.getAttribute("data-map-center")||"{}"),this.points=i?.points||JSON.parse(this.root.getAttribute("data-points")||"[]"),this.color=i?.markerColor||this.root.getAttribute("data-marker-color")||"red",this.zoom=parseFloat(i?.zoom??this.root.getAttribute("data-zoom"))||10,this.scrollToZoom=i?.scrollToZoom??"true"===this.root.getAttribute("data-scroll-to-zoom"),this.mapStyle=i?.mapStyle||this.root.getAttribute("data-map-style")||"default",this.mapHeight=i?.mapHeight||this.root.getAttribute("data-map-height")||null,this.onError=()=>{}}async init(){this.initDOM(),await this.loadLibrary(),await this.fetchKey(),this.initMapSize(),this.initMap(),this.addPoints(),this.initHandlers()}initDOM(){this.root.innerHTML='<div class="wp-block-jetpack-map__mb-container"></div>',this.container=this.root.querySelector(".wp-block-jetpack-map__mb-container")}sizeMap=()=>{(0,n.A)(this.container,this.mapHeight)};initMapSize(){this.debouncedSizeMap=(0,o.s)(this.sizeMap,250),this.sizeMap()}initHandlers(){window.addEventListener("resize",this.debouncedSizeMap)}loadLibrary(){return new Promise(t=>{(0,s.Yc)(document,window).then(e=>{this.mapkit=e,this.mapkit.addEventListener("error",t=>{this.onError(t)}),t()})})}fetchKey(){return(0,s.IR)(this.mapkit,this.blog_id,window)}initMap(){const t=new this.mapkit.Coordinate(this.center.lat,this.center.lng),e=(()=>{switch(this.mapStyle){case"satellite":return this.mapkit.Map.MapTypes.Satellite;case"black_and_white":return this.mapkit.Map.MapTypes.MutedStandard;case"hybrid":return this.mapkit.Map.MapTypes.Hybrid;default:return this.mapkit.Map.MapTypes.Standard}})();this.map=new this.mapkit.Map(this.container,{center:t,mapType:e,showsMapTypeControl:!1}),this.points.length<2&&this.zoom&&this.setZoom(),this.scrollToZoom&&(this.map._allowWheelToZoom=!0)}setZoom(){this.map.cameraDistance=(0,s.c6)(this.zoom,this.center.lat)}addPoints(){const t=this.points.map(t=>{const e=new this.mapkit.Coordinate(t.coordinates.latitude,t.coordinates.longitude);return new this.mapkit.MarkerAnnotation(e,{color:this.color,title:t.title,callout:{calloutContentForAnnotation:function(t){const e=document.createElement("div");e.style.width=t.element.parentElement.offsetWidth/2+"px";const i=e.appendChild(document.createElement("div"));i.style.fontSize="17px",i.style.fontWeight="600",i.style.lineHeight="19px",i.style.marginTop="8px",i.textContent=t.title;const o=e.appendChild(document.createElement("p"));return o.style.fontSize="14px",o.style.margin="0px 0px 4px 0px",o.textContent=t.data?.caption,e}},calloutEnabled:!0,data:{caption:t.caption}})});this.map.showItems(t)}}},34377(t,e,i){"use strict";function o(t){const e=t.ownerDocument;return{currentDoc:e,currentWindow:e.defaultView||e.parentWindow}}function s(t,e,s){let n;try{n=new URL("editor-assets",i.p)}catch{return}const a=n.href,{currentDoc:r}=o(s),l=r.getElementsByTagName("head")[0];t.forEach(t=>{const[i,o]=t.file.split("/").pop().split(".");if("css"===o){if(r.getElementById(t.id))return;const e=r.createElement("link");e.id=t.id,e.rel="stylesheet",e.href=`${a}/${i}-${t.version}.${o}`,l.appendChild(e)}if("js"===o){const s=e[t.id]?e[t.id]:null;if(r.getElementById(t.id))return s();const n=r.createElement("script");n.id=t.id,n.type="text/javascript",n.src=`${a}/${i}-${t.version}.${o}`,n.onload=s,l.appendChild(n)}})}function n(t,e){return new Promise(i=>{const o=()=>{t[e]?i(t[e]):t.requestAnimationFrame(o)};o()})}i.d(e,{Cu:()=>n,a$:()=>s,sG:()=>o})},71738(t,e,i){"use strict";function o(t,e){let i;return function(...o){clearTimeout(i),i=setTimeout(()=>t.apply(this,o),e)}}i.d(e,{s:()=>o})},79366(t,e,i){"object"==typeof window&&window.Jetpack_Block_Assets_Base_Url&&(i.p=window.Jetpack_Block_Assets_Base_Url)},98490(t){"use strict";t.exports=window.wp.domReady},55740(t){"use strict";t.exports=JSON.parse('[{"id":"mapbox-gl-js","file":"node_modules/mapbox-gl/dist/mapbox-gl.js","version":"1.13.0"},{"id":"mapbox-gl-css","file":"node_modules/mapbox-gl/dist/mapbox-gl.css","version":"1.13.0"}]')}},e={};function i(o){var s=e[o];if(void 0!==s)return s.exports;var n=e[o]={exports:{}};return t[o](n,n.exports,i),n.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var o in e)i.o(e,o)&&!i.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{var t;globalThis.importScripts&&(t=globalThis.location+"");var e=globalThis.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var o=e.getElementsByTagName("script");if(o.length)for(var s=o.length-1;s>-1&&(!t||!/^http(s?):/.test(t));)t=o[s--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i.p=t+"../"})(),(()=>{"use strict";i(79366)})(),(()=>{"use strict";var t=i(98490),e=i.n(t),o=(i(64525),i(50221),i(18109));e()(function(){Array.from(document.querySelectorAll(".wp-block-jetpack-map")).forEach(async t=>{try{if("mapkit"===t.getAttribute("data-map-provider")){const e=new o.i(t);e.onError=()=>{t.innerHtml="";new o.p(t).init()},e.init()}else{new o.p(t).init()}}catch{}})})})()})();