// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define("exports ../../chunks/tslib.es6 ../../Color ../../core/Accessor ../../core/asyncUtils ../../core/colorUtils ../../core/handleUtils ../../core/has ../../core/mathUtils ../../core/promiseUtils ../../core/quantityFormatUtils ../../core/reactiveUtils ../../core/screenUtils ../../core/unitUtils ../../core/accessorSupport/decorators/property ../../core/Logger ../../core/RandomLCG ../../core/accessorSupport/decorators/subclass ../../core/libs/gl-matrix-2/math/vec2 ../../core/libs/gl-matrix-2/factories/vec2f64 ../../chunks/vec32 ../../geometry/support/coordsUtils ../../geometry/support/vectorStacks ../../intl/messages ../../support/elevationInfoUtils ../../support/getDefaultUnitForView ../overlay/TextOverlayItem ../support/automaticLengthMeasurementUtils".split(" "), function(h,m,L,M,N,B,O,ea,P,Q,R,C,F,G,p,fa,ha,S,r,H,T,U,I,V,x,W,X,Y){function Z(a,b,c,f,g){const d=[];b.data.components[g].iterateVertices(l=>{d.push(f.toXYZ(l.pos,I.sv3d.get()))});0===g&&null!=c&&d.push(f.toXYZ(c,I.sv3d.get()));if(2>d.length)return d;b=d[0];c=d[d.length-1];"polygon"===a.type&&2{const c=await V.fetchMessageBundle("esri/core/t9n/Units");Q.throwIfAborted(b);this._messagesUnits=c});this.addHandles([C.watch(()=>[null!=this.context&&this.getCameraOrExtent(this.context),this.visible,this._edgeDistancePixels,this.stagedVertex,this._messagesUnits],()=>this._update()),...["vertex-add","vertex-update","vertex-remove"].map(b=>C.on(()=>this.context?.editGeometryOperations, b,()=>this._update())),O.makeHandle(()=>a.abort()),C.watch(()=>this._colors,b=>this._updateStyle(b))])}destroy(){for(this._nextLabelIndex=0;this._labelInfos.length;)this._destroyLabel(this._labelInfos.pop())}get updating(){return null==this._messagesUnits}get test(){}get _edgeDistancePixels(){return aa[this.edgeDistance]}get _colors(){const a=this.context?.view.effectiveTheme.textColor??L.fromArray([255,255,255]),b=B.multiplyOpacity(B.getContrast(a,B.BrightnessThreshold.Low),.6);return{textColor:a, backgroundColor:b}}_update(){if(!this.destroyed){this._nextLabelIndex=0;var {context:a,stagedVertex:b}=this;if(!a)return this._destroyUnusedLabels();var {editGeometryOperations:c}=a,{components:f,geometry:g,coordinateHelper:d}=c.data;if(!g)return this._destroyUnusedLabels();var l=f.length;for(let D=0;Dt.length)){a:{e=t;var q=a.view,u=a.elevationInfo,n=d.spatialReference;if("2d"===q.type)e=!0;else{var y=G.getMetersPerUnit(n)??1,z=G.getMetersPerVerticalUnitForSR(n); for(let A=1;Aba){e=!1;break a}}e=!0}}e=!e}if(!e)for(e=1===l?!U.isClockwise(t):!1,q=ca,u=da,this.toScreenPointArray(a,t[0],q),n=1;nr.squaredDistance(c,g))l.visible=!1;else{var {spatialReference:e}=a.editGeometryOperations.data;b=Y.autoDistance2D(b,f,e);f=this._messagesUnits;a=W.getDefaultUnitForView(a.view);l.text=null!=f&&null!=b?R.formatLength(f,b,a):"";l.visible=!0;a=g[0]-c[0];b=g[1]-c[1];d?r.set(k, -b,a):r.set(k,b,-a);r.normalize(k,k);r.scale(k,k,this._edgeDistancePixels);r.lerp(w,c,g,.5);r.add(w,w,k);l.position=[w[0],w[1]];l.anchor=Math.abs(k[0])>Math.abs(k[1])?0-k[1]?"top":"bottom"}}_getOrCreateLabel(a){var b=this._labelInfos.length>this._nextLabelIndex;const {textColor:c,backgroundColor:f}=this._colors;if(b)return a=this._labelInfos[this._nextLabelIndex++],{label:b}=a,b.textColor=c,b.backgroundColor=f,a;b=new X({anchor:"center",fontSize:8,textColor:c,backgroundColor:f}); a.view.overlay?.items.add(b);a={label:b};this._labelInfos.push(a);this._nextLabelIndex=this._labelInfos.length;return a}_destroyUnusedLabels(){for(;this._labelInfos.length>this._nextLabelIndex;)this._destroyLabel(this._labelInfos.pop())}_destroyLabel({label:a}){this.context?.view.overlay?.items.remove(a);a.destroy()}};m.__decorate([p.property()],h.SegmentLabels.prototype,"context",void 0);m.__decorate([p.property()],h.SegmentLabels.prototype,"stagedVertex",void 0);m.__decorate([p.property()],h.SegmentLabels.prototype, "visible",void 0);m.__decorate([p.property()],h.SegmentLabels.prototype,"edgeDistance",void 0);m.__decorate([p.property()],h.SegmentLabels.prototype,"updating",null);m.__decorate([p.property()],h.SegmentLabels.prototype,"_messagesUnits",void 0);m.__decorate([p.property()],h.SegmentLabels.prototype,"_edgeDistancePixels",null);m.__decorate([p.property()],h.SegmentLabels.prototype,"_colors",null);h.SegmentLabels=m.__decorate([S.subclass("esri.views.interactive.SegmentLabels")],h.SegmentLabels);const ba= P.deg2rad(5),k=H.create(),w=H.create(),ca=F.createScreenPointArray(),da=F.createScreenPointArray();Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});