"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("react/jsx-runtime"),c=require("react"),u=require("d3");function f(n){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(t,e,o.get?o:{enumerable:!0,get:()=>n[e]})}}return t.default=n,Object.freeze(t)}const r=f(u);class m extends c.Component{constructor(t){super(t),this.svgRef=c.createRef(),this.dragged=this.dragged.bind(this)}componentDidUpdate(t,e,o){if(t.projection!==this.props.projection){const a=r.geoPath().projection(this.props.projection);this.setState({projection:this.props.projection,path:a})}const{rotationEnabled:i}=this.props,s=r.select(this.svgRef.current).datum({x:0,y:0});i?s.call(r.drag().on("drag",this.dragged)):s.on(".drag",null)}componentDidMount(){const{rotationEnabled:t}=this.props,e=r.select(this.svgRef.current).datum({x:0,y:0});t&&e.call(r.drag().on("drag",this.dragged))}dragged(t,e){const o={x:0,y:0},{projection:i,width:s,height:a}=this.props,d=r.scaleLinear().domain([-s,s]).range([-180,180]),h=r.scaleLinear().domain([-a,a]).range([90,-90]),p={x:d(e.x=t.x),y:h(e.y=t.y)};i.rotate([o.x+p.x,o.y+p.y]);const g=r.geoPath().projection(i);this.setState({projection:i,path:g})}render(){const{projection:t,width:e,height:o,path:i}=this.props;return l.jsx("svg",{viewBox:`0 0 ${e} ${o}`,className:"map",height:o,width:"100%",ref:this.svgRef,children:t&&this.props.children?this.props.children.map(s=>c.cloneElement(s,{...this.props,svg:this.svgRef.current,...this.state})):null})}}exports.default=m;
