"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[7545],{29709:function(e,t,n){var r=n(41376),o=n(54354),i=n(69039),a=n(77975),c=n(720),f=n(77138),u=n(64498),s=n(42365),m=n(61038),y=n(75469),g=n(3077),d=n(79847),l=n(95783),w=n(42010),v=n(41372),Z=n(86923),h=n(36104),p=new w.Z({source:new d.Z}),C=new l.Z,G=new i.ZP({geometry:function(e){var t=e.get("modifyGeometry");return t?t.geometry:e.getGeometry()},fill:new a.Z({color:"rgba(255, 255, 255, 0.2)"}),stroke:new c.Z({color:"#ffcc33",width:2}),image:new f.Z({radius:7,fill:new a.Z({color:"#ffcc33"})})});function E(e){var t,n,r,o,i=e.getType();if("Polygon"===i){var a=0,c=0,f=0;(n=e.getCoordinates()[0].slice(1)).forEach((function(e){a+=e[0],c+=e[1],f++})),t=[a/f,c/f]}else"LineString"===i?(t=e.getCoordinateAt(.5),n=e.getCoordinates()):t=(0,Z.qg)(e.getExtent());return n?(o=n.map((function(e){var n=e[0]-t[0],r=e[1]-t[1];return n*n+r*r})),r=Math.sqrt(Math.max.apply(Math,o))/3):r=Math.max((0,Z.dz)(e.getExtent()),(0,Z.Cr)(e.getExtent()))/3,{center:t,coordinates:n,minRadius:r,sqDistances:o}}var M,q=new v.Z({source:C,style:function(e){var t=[G],n=e.get("modifyGeometry"),r=E(n?n.geometry:e.getGeometry()),o=r.center;if(o){t.push(new i.ZP({geometry:new y.Z(o),image:new f.Z({radius:4,fill:new a.Z({color:"#ff3333"})})}));var c=r.coordinates;if(c){var u=r.minRadius,s=r.sqDistances,m=u*u,d=c.filter((function(e,t){return s[t]>m}));t.push(new i.ZP({geometry:new g.Z(d),image:new f.Z({radius:4,fill:new a.Z({color:"#33cc33"})})}))}}return t}}),x=new r.Z({layers:[p,q],target:"map",view:new o.ZP({center:[-11e6,46e5],zoom:4})}),P=new u.Z({source:C}).getOverlay().getStyleFunction(),k=new u.Z({source:C,condition:function(e){return(0,h.Xp)(e)&&!(0,h.QC)(e)},deleteCondition:h.Fi,insertVertexCondition:h.Fi,style:function(e){return e.get("features").forEach((function(t){var n=t.get("modifyGeometry");if(n){var r=e.getGeometry().getCoordinates(),o=n.point;if(!o){o=r,n.point=o,n.geometry0=n.geometry;var i=E(n.geometry0);n.center=i.center,n.minRadius=i.minRadius}var a,c,f=n.center,u=n.minRadius;a=o[0]-f[0],c=o[1]-f[1];var s=Math.sqrt(a*a+c*c);if(s>u){var m=Math.atan2(c,a);a=r[0]-f[0],c=r[1]-f[1];var y=Math.sqrt(a*a+c*c);if(y>0){var g=Math.atan2(c,a),d=n.geometry0.clone();d.scale(y/s,void 0,f),d.rotate(g-m,f),n.geometry=d}}}})),P(e)}});k.on("modifystart",(function(e){e.features.forEach((function(e){e.set("modifyGeometry",{geometry:e.getGeometry().clone()},!0)}))})),k.on("modifyend",(function(e){e.features.forEach((function(e){var t=e.get("modifyGeometry");t&&(e.setGeometry(t.geometry),e.unset("modifyGeometry",!0))}))})),x.addInteraction(k),x.addInteraction(new s.Z({condition:function(e){return(0,h.Xp)(e)&&(0,h.QC)(e)},layers:[q]}));var I=document.getElementById("type");function R(){M=new m.ZP({source:C,type:I.value}),x.addInteraction(M)}I.onchange=function(){x.removeInteraction(M),R()},R()}},function(e){var t=function(t){return e(e.s=t)};t(9877),t(29709)}]); //# sourceMappingURL=modify-scale-and-rotate.js.map