"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("react/jsx-runtime"),p=require("react"),y=require("react-dom/client"),g=require("d3"),m=require("./Tooltip.js"),T=require("./Utils.js");function b(s){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const e in s)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(s,e);Object.defineProperty(t,e,o.get?o:{enumerable:!0,get:()=>s[e]})}}return t.default=s,Object.freeze(t)}const i=b(g);let w=class extends p.Component{constructor(){super(),this.loadJSON=this.loadJSON.bind(this),this.create=this.create.bind(this),this.createLayer=this.createLayer.bind(this),this.loadJSON=this.loadJSON.bind(this),this.showToolTip=this.showToolTip.bind(this),this.moveToolTip=this.moveToolTip.bind(this),this.gRef=p.createRef(),this.state={json:null}}loadJSON(t){return T.loadJSON(t)}createLayer(t){alert("please implement createLayer")}applyInitialTransform(){const{editing:t,initialPosition:e,width:o,height:a}=this.props;if(e&&e.width){const{x:r,y:l,k:n,width:h,height:d}=e,u=r+(o-h)/2*(1-n),f=l+(a-d)/2*(1-n);i.select(this.gRef.current).attr("transform",`translate(${u},${f}) scale(${n})`)}else i.select(this.gRef.current).attr("transform",`translate(${e.x},${e.y}) scale(${e.k})`)}create(){const{file:t}=this.props;this.state.json?this.createLayer(this.state.json):this.loadJSON(t).then(e=>{this.setState({json:e}),this.createLayer(e)})}showToolTip(t,e,o,a){if(e){const r=i.select("body").append("div").attr("class","d3MapTooltip").style("position","absolute").html("").style("left",window.event.pageX+15+"px").style("top",window.event.pageY-50+"px");y.createRoot(r._groups[0][0]).render(c.jsx(m.default,{intl:this.props.intl,tooltip:t,data:e,tooltipEnableMarkdown:!1}))}}moveToolTip(t){i.select(".d3MapTooltip").style("left",window.event.pageX+15+"px").style("top",window.event.pageY-50+"px")}hiddenToolTip(t){i.selectAll(".d3MapTooltip").remove()}componentDidMount(){this.props.zoom&&this.gRef.current&&this.applyInitialTransform(),this.create()}render(){const{name:t,height:e,width:o}=this.props;return c.jsx("g",{className:"layer",ref:this.gRef})}};exports.default=w;
