2 lines
9.2 KiB
JavaScript
2 lines
9.2 KiB
JavaScript
"use strict";(self.webpackChunkelement_web=self.webpackChunkelement_web||[]).push([[395,4006,8227],{"./node_modules/@vector-im/compound-design-tokens/assets/web/icons/minus.js":(e,t,o)=>{o.d(t,{A:()=>a});var n=o("./node_modules/react/index.js"),r=o("./node_modules/react/jsx-runtime.js");function s(e,t){return(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor",viewBox:"0 0 24 24",ref:t,...e,children:(0,r.jsx)("path",{d:"M6 13a.97.97 0 0 1-.713-.287A.97.97 0 0 1 5 12q0-.424.287-.713A.97.97 0 0 1 6 11h12q.424 0 .712.287.288.288.288.713 0 .424-.288.713A.97.97 0 0 1 18 13z"})})}s.displayName="MinusIcon";const a=(0,n.forwardRef)(s)},"./node_modules/@vector-im/compound-design-tokens/assets/web/icons/plus.js":(e,t,o)=>{o.d(t,{A:()=>a});var n=o("./node_modules/react/index.js"),r=o("./node_modules/react/jsx-runtime.js");function s(e,t){return(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor",viewBox:"0 0 24 24",ref:t,...e,children:(0,r.jsx)("path",{d:"M11 13H6a.97.97 0 0 1-.713-.287A.97.97 0 0 1 5 12q0-.424.287-.713A.97.97 0 0 1 6 11h5V6q0-.424.287-.713A.97.97 0 0 1 12 5q.424 0 .713.287Q13 5.576 13 6v5h5q.424 0 .712.287.288.288.288.713 0 .424-.288.713A.97.97 0 0 1 18 13h-5v5q0 .424-.287.712A.97.97 0 0 1 12 19a.97.97 0 0 1-.713-.288A.97.97 0 0 1 11 18z"})})}s.displayName="PlusIcon";const a=(0,n.forwardRef)(s)},"./src/components/views/location/LocationViewDialog.tsx":(e,t,o)=>{o.r(t),o.d(t,{default:()=>d});var n=o("./node_modules/@babel/runtime/helpers/esm/defineProperty.js"),r=o("./node_modules/react/index.js"),s=o("./src/components/views/dialogs/BaseDialog.tsx"),a=o("./src/utils/location/index.ts"),i=o("./src/components/views/location/Map.tsx"),l=o("./src/components/views/location/SmartMarker.tsx"),c=o("./src/components/views/location/ZoomButtons.tsx");class d extends r.Component{constructor(e){super(e),(0,n.A)(this,"getBodyId",()=>`mx_LocationViewDialog_${this.props.mxEvent.getId()}`),(0,n.A)(this,"onError",e=>{this.setState({error:e})}),this.state={error:void 0}}render(){const{mxEvent:e}=this.props,t=(0,a.qy)(e.getContent())&&e.sender||void 0,o=(0,a.jm)(e);return r.createElement(s.A,{className:"mx_LocationViewDialog",onFinished:this.props.onFinished,fixedWidth:!1},r.createElement(i.default,{id:this.getBodyId(),centerGeoUri:o,onError:this.onError,interactive:!0,className:"mx_LocationViewDialog_map",allowGeolocate:!0},({map:e})=>r.createElement(r.Fragment,null,r.createElement(l.default,{map:e,id:`${this.getBodyId()}-marker`,geoUri:o,roomMember:t}),r.createElement(c.A,{map:e}))))}}},"./src/components/views/location/Map.tsx":(e,t,o)=>{o.r(t),o.d(t,{default:()=>h});var n=o("./node_modules/react/index.js"),r=o("./node_modules/classnames/index.js"),s=o.n(r),a=o("./node_modules/maplibre-gl/dist/maplibre-gl.js"),i=o("./node_modules/matrix-js-sdk/src/matrix.ts"),l=o("./node_modules/matrix-js-sdk/src/logger.ts"),c=o("./src/contexts/MatrixClientContext.tsx"),d=o("./src/hooks/useEventEmitter.ts"),m=o("./src/utils/location/index.ts"),u=o("./src/utils/WellKnownUtils.ts"),p=o("./src/utils/location/map.ts");var _=o("./src/Modal.tsx"),v=o("./src/components/views/dialogs/ErrorDialog.tsx"),g=o("./src/languageHandler.tsx");const x=({id:e,centerGeoUri:t,onError:o,interactive:r,bounds:s,allowGeolocate:_})=>{const v=`mx_Map_${e}`,g=(0,n.useContext)(c.Ay),x=(0,d.dF)(g,i.ClientEvent.ClientWellKnown,e=>{var t;return null===(t=(0,u.XP)(e))||void 0===t?void 0:t.map_style_url}),h=(({interactive:e,bodyId:t,onError:o})=>{const r=(0,c.nH)(),[s,a]=(0,n.useState)();return(0,n.useEffect)(()=>{let n;try{n=(0,p.p)(r,!!e,t,o),a(n)}catch(e){console.error("Error encountered in useMap",e),e instanceof Error&&(null==o||o(e))}return()=>{n&&(n.remove(),a(void 0))}},[r,e,t,o]),s})({interactive:r,bodyId:v,onError:o});(0,n.useEffect)(()=>{x&&h&&h.setStyle(x)},[x,h]),(0,n.useEffect)(()=>{if(h&&t)try{const e=(0,m.XB)(t);if(!e)throw new Error("Invalid geo URI");h.setCenter({lon:e.longitude,lat:e.latitude})}catch(e){l.vF.error("Could not set map center",e)}},[h,t]),(0,n.useEffect)(()=>{if(h&&s)try{const e=new a.LngLatBounds([s.west,s.south],[s.east,s.north]);h.fitBounds(e,{padding:100,maxZoom:15})}catch(e){l.vF.error("Invalid map bounds",e)}},[h,s]);const[w,b]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(h){if(_&&!w){const e=new a.GeolocateControl({positionOptions:{enableHighAccuracy:!0},trackUserLocation:!1});b(e),h.addControl(e)}!_&&w&&(h.removeControl(w),b(null))}},[h,w,_]),(0,n.useEffect)(()=>{if(w)return w.on("error",f),()=>{w.off("error",f)}},[w]),{map:h,bodyId:v}},f=e=>{var t;l.vF.error("Could not fetch location",e),_.Ay.createDialog(v.A,{title:(0,g._t)("location_sharing|error_fetch_location"),description:null!==(t=(0,m.Ff)(e.code))&&void 0!==t?t:""})},h=({bounds:e,centerGeoUri:t,children:o,className:r,allowGeolocate:a,id:i,interactive:l,onError:c,onClick:d})=>{const{map:m,bodyId:u}=x({centerGeoUri:t,onError:c,id:i,interactive:l,bounds:e,allowGeolocate:a});return n.createElement("div",{className:s()("mx_Map",r),id:u,onClick:e=>{e.target.classList.contains("maplibregl-ctrl-attrib-button")||null==d||d()}},!!o&&!!m&&o({map:m}))}},"./src/components/views/location/Marker.tsx":(e,t,o)=>{o.d(t,{A:()=>d});var n=o("./node_modules/react/index.js"),r=o("./node_modules/classnames/index.js"),s=o.n(r),a=o("./node_modules/@vector-im/compound-design-tokens/assets/web/icons/location-pin-solid.js"),i=o("./src/utils/FormattingUtils.ts"),l=o("./src/components/views/avatars/MemberAvatar.tsx");const c=({tooltip:e,children:t})=>{const[o,r]=(0,n.useState)(!1);if(!e)return n.createElement(n.Fragment,null,t);return n.createElement("div",{onMouseEnter:()=>r(!0),onClick:e=>{e.stopPropagation(),r(!o)},onMouseLeave:()=>r(!1)},t,o&&e)},d=({id:e,roomMember:t,useMemberColor:o,tooltip:r,ref:d})=>{const m=o&&t?(0,i.yJ)(t.userId):"";return n.createElement("div",{ref:d,id:e,className:s()("mx_Marker",m,{mx_Marker_defaultColor:!m})},n.createElement(c,{tooltip:r},n.createElement("div",{className:"mx_Marker_border"},t?n.createElement(l.A,{member:t,size:"36px",viewUserOnClick:!1,hideTitle:!!r}):n.createElement(a.A,{className:"mx_Marker_icon"}))))}},"./src/components/views/location/SmartMarker.tsx":(e,t,o)=>{o.r(t),o.d(t,{default:()=>i});var n=o("./node_modules/react/index.js"),r=o("./src/utils/location/index.ts"),s=o("./src/utils/location/map.ts"),a=o("./src/components/views/location/Marker.tsx");const i=({id:e,map:t,geoUri:o,roomMember:i,useMemberColor:l,tooltip:c})=>{const{onElementRef:d}=((e,t)=>{const[o,a]=(0,n.useState)(),i=(0,n.useCallback)(n=>{if(o||!n)return;const i=(0,r.XB)(t);if(i){const t=(0,s.h)(i,n);t.addTo(e),a(t)}},[o,t,e]);return(0,n.useEffect)(()=>{if(o){const e=(0,r.XB)(t);e&&o.setLngLat({lon:e.longitude,lat:e.latitude})}},[o,t]),(0,n.useEffect)(()=>()=>{o&&o.remove()},[o]),{marker:o,onElementRef:i}})(t,o);return n.createElement("span",null,n.createElement(a.A,{ref:d,id:e,roomMember:i,useMemberColor:l,tooltip:c}))}},"./src/components/views/location/ZoomButtons.tsx":(e,t,o)=>{o.d(t,{A:()=>l});var n=o("./node_modules/react/index.js"),r=o("./node_modules/@vector-im/compound-design-tokens/assets/web/icons/minus.js"),s=o("./node_modules/@vector-im/compound-design-tokens/assets/web/icons/plus.js"),a=o("./src/languageHandler.tsx"),i=o("./src/components/views/elements/AccessibleButton.tsx");const l=({map:e})=>n.createElement("div",{className:"mx_ZoomButtons"},n.createElement(i.A,{onClick:()=>{e.zoomIn()},title:(0,a._t)("action|zoom_in"),className:"mx_ZoomButtons_button"},n.createElement(s.A,{className:"mx_ZoomButtons_icon"})),n.createElement(i.A,{onClick:()=>{e.zoomOut()},title:(0,a._t)("action|zoom_out"),className:"mx_ZoomButtons_button"},n.createElement(r.A,{className:"mx_ZoomButtons_icon"})))},"./src/utils/location/map.ts":(e,t,o)=>{o.d(t,{h:()=>c,p:()=>l});var n=o("./node_modules/maplibre-gl/dist/maplibre-gl.js"),r=o("./node_modules/matrix-js-sdk/src/logger.ts"),s=o("./src/languageHandler.tsx"),a=o("./src/utils/location/findMapStyleUrl.ts"),i=o("./src/utils/location/LocationShareErrors.ts");const l=(e,t,o,l)=>{try{const c=(0,a.M)(e),d=new n.Map({container:o,style:c,zoom:15,interactive:t,attributionControl:!1,locale:{"AttributionControl.ToggleAttribution":(0,s._t)("location_sharing|toggle_attribution"),"AttributionControl.MapFeedback":(0,s._t)("location_sharing|map_feedback"),"FullscreenControl.Enter":(0,s._t)("action|enter_fullscreen"),"FullscreenControl.Exit":(0,s._t)("action|exit_fullscreeen"),"GeolocateControl.FindMyLocation":(0,s._t)("location_sharing|find_my_location"),"GeolocateControl.LocationNotAvailable":(0,s._t)("location_sharing|location_not_available"),"LogoControl.Title":(0,s._t)("location_sharing|mapbox_logo"),"NavigationControl.ResetBearing":(0,s._t)("location_sharing|reset_bearing"),"NavigationControl.ZoomIn":(0,s._t)("action|zoom_in"),"NavigationControl.ZoomOut":(0,s._t)("action|zoom_out")}});return d.addControl(new n.AttributionControl,"top-right"),d.on("error",e=>{r.vF.error("Failed to load map: check map_style_url in config.json has a valid URL and API key",e.error),null==l||l(new Error(i.$.MapStyleUrlNotReachable))}),d}catch(e){r.vF.error("Failed to render map",e);if((null==e?void 0:e.message).includes("Failed to initialize WebGL"))throw new Error(i.$.WebGLNotEnabled);throw e}},c=(e,t)=>new n.Marker({element:t,anchor:"bottom",offset:[0,-1]}).setLngLat({lon:e.longitude,lat:e.latitude})}}]);
|
|
//# sourceMappingURL=4006.js.map
|