@labelbee/lb-annotation 1.5.3 → 1.5.4-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/index.js +7 -7
- package/es/index.js +7 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
[English](./README_en-US.md) | 简体中文
|
|
2
|
+
|
|
1
3
|
# LB-Annotation
|
|
2
4
|
|
|
3
5
|
标注绘图框架,能快速提供检测、分割、分类等标注操作。
|
|
@@ -14,8 +16,6 @@ $ yarn add @labelbee/lb-annotation
|
|
|
14
16
|
|
|
15
17
|
## Quick Start
|
|
16
18
|
|
|
17
|
-
### 接口定义
|
|
18
|
-
|
|
19
19
|
```ts
|
|
20
20
|
import React, { useEffect } from 'react';
|
|
21
21
|
import { AnnotationEngine } from '@labelbee/lb-annotation';
|
|
@@ -107,6 +107,8 @@ const App = () => {
|
|
|
107
107
|
export default App;
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
+
### 接口定义
|
|
111
|
+
|
|
110
112
|
```js
|
|
111
113
|
interface IImageAttribute {
|
|
112
114
|
contrast: number;
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";/*!
|
|
2
|
-
* sense-annotation v1.5.
|
|
2
|
+
* sense-annotation v1.5.4-alpha.0
|
|
3
3
|
* (c) 2020-2021
|
|
4
|
-
* Released under the
|
|
5
|
-
*/Object.defineProperty(exports,"__esModule",{value:!0});var _=require("lodash"),rgba=require("color-rgba");function _interopDefaultLegacy(r){return r&&typeof r=="object"&&"default"in r?r:{default:r}}var ___default=_interopDefaultLegacy(_),rgba__default=_interopDefaultLegacy(rgba);const editStepWidth=320;var EPointCloudName;(function(r){r.PointCloud="pointCloudTool"})(EPointCloudName||(EPointCloudName={}));var EVideoToolName;(function(r){r.VideoTextTool="videoTextTool",r.VideoTagTool="videoTagTool",r.VideoClipTool="videoClipTool"})(EVideoToolName||(EVideoToolName={}));var EToolType;(function(r){r[r.Rect=0]="Rect",r[r.Tag=1]="Tag"})(EToolType||(EToolType={}));var EToolName;(function(r){r.Rect="rectTool",r.Tag="tagTool",r.Point="pointTool",r.PointMarker="pointMarkerTool",r.Segmentation="segmentationTool",r.Filter="filterTool",r.Text="textTool",r.Polygon="polygonTool",r.Line="lineTool",r.LineMarker="lineMarkerTool",r.Empty="emptyTool",r.FolderTag="folderTagTool",r.RectTrack="rectTrackTool",r.Face="faceTool",r.ClientAttribute="clientAttributeTool",r.OCRRelation="OCRRelationTool"})(EToolName||(EToolName={}));var ECheckModel;(function(r){r.Check="check"})(ECheckModel||(ECheckModel={}));var ERectPattern;(function(r){r[r.nothing=0]="nothing",r[r.RectBG=1]="RectBG",r[r.showOrder=2]="showOrder"})(ERectPattern||(ERectPattern={}));const TOOL_NAME={[EToolName.Rect]:"\u62C9\u6846",[EToolName.Tag]:"\u6807\u7B7E",[EToolName.Point]:"\u6807\u70B9",[EToolName.PointMarker]:"\u5217\u8868\u6807\u70B9",[EToolName.Segmentation]:"\u524D\u666F\u5206\u5272",[EToolName.Filter]:"\u7B5B\u9009",[EToolName.Text]:"\u6587\u672C",[EToolName.Polygon]:"\u591A\u8FB9\u5F62",[EToolName.Line]:"\u7EBF\u6761",[EToolName.LineMarker]:"\u5217\u8868\u7EBF\u6761",[EToolName.FolderTag]:"\u6587\u4EF6\u5939\u6807\u7B7E",[EToolName.RectTrack]:"\u62C9\u6846\u8DDF\u8E2A",[EToolName.Face]:"\u4EBA\u8138106\u5DE5\u5177",[EToolName.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[EToolName.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177",[EVideoToolName.VideoTextTool]:"\u89C6\u9891\u6587\u672C",[EVideoToolName.VideoTagTool]:"\u89C6\u9891\u6807\u7B7E",[EVideoToolName.VideoClipTool]:"\u89C6\u9891\u622A\u53D6",[EPointCloudName.PointCloud]:"\u70B9\u4E91"};var EDependPattern;(function(r){r[r.noDepend=1]="noDepend",r[r.dependOrigin=2]="dependOrigin",r[r.dependShape=3]="dependShape",r[r.dependLine=4]="dependLine",r[r.dependPolygon=5]="dependPolygon",r[r.dependPreShape=101]="dependPreShape",r[r.dependPreLine=102]="dependPreLine",r[r.dependPrePolygon=103]="dependPrePolygon"})(EDependPattern||(EDependPattern={}));var EFilterToolOperation;(function(r){r.lc="leftClick",r.rc="rightClick",r.clc="ctrlLeftClick",r.crc="ctrlRightClick"})(EFilterToolOperation||(EFilterToolOperation={}));const OPERATION_LIST={leftClick:"\u9F20\u6807\u5DE6\u952E",rightClick:"\u9F20\u6807\u53F3\u952E",ctrlLeftClick:"ctrl + \u9F20\u6807\u5DE6\u952E",ctrlRightClick:"ctrl + \u9F20\u6807\u53F3\u952E"};var EAnnotationMode;(function(r){r[r.Normal=1]="Normal",r[r.Modify=2]="Modify"})(EAnnotationMode||(EAnnotationMode={}));var ELineTypes;(function(r){r[r.Line=0]="Line",r[r.Curve=1]="Curve"})(ELineTypes||(ELineTypes={}));var ELineColor;(function(r){r[r.SingleColor=0]="SingleColor",r[r.MultiColor=1]="MultiColor"})(ELineColor||(ELineColor={}));var ESelectedType;(function(r){r[r.Form=1]="Form",r[r.Json=2]="Json"})(ESelectedType||(ESelectedType={}));var EDragTarget$1;(function(r){r[r.Point=0]="Point",r[r.Line=1]="Line",r[r.Plane=2]="Plane"})(EDragTarget$1||(EDragTarget$1={}));var EDrawPointPattern;(function(r){r[r.None=0]="None",r[r.Drawing=1]="Drawing",r[r.Edit=2]="Edit"})(EDrawPointPattern||(EDrawPointPattern={}));var EPageOperator$1;(function(r){r[r.Backward=0]="Backward",r[r.Forward=1]="Forward",r[r.JumpSkip=2]="JumpSkip",r[r.None=3]="None"})(EPageOperator$1||(EPageOperator$1={}));var EAuditStatus;(function(r){r[r.Wait=0]="Wait",r[r.Pass=1]="Pass",r[r.Fail=2]="Fail",r[r.Loading=3]="Loading"})(EAuditStatus||(EAuditStatus={}));var ETextType;(function(r){r[r.AnyString=0]="AnyString",r[r.Order=1]="Order",r[r.EnglishOnly=2]="EnglishOnly",r[r.NumberOnly=3]="NumberOnly",r[r.CustomFormat=4]="CustomFormat"})(ETextType||(ETextType={}));const TEXT_TYPE={0:"\u4EFB\u610F\u5B57\u7B26",1:"\u5E8F\u53F7",2:"\u4EC5\u82F1\u6587",3:"\u4EC5\u6570\u5B57"},TEXT_ATTRIBUTE_MAX_LENGTH=1e3,TEXT_ATTRIBUTE_LINE_HEIGHT=16;var EThumbnailOption;(function(r){r[r.ImgList=1e3]="ImgList",r[r.TrackPrediction=1001]="TrackPrediction",r[r.ImgSearch=1002]="ImgSearch"})(EThumbnailOption||(EThumbnailOption={}));const CLIENT_TOOL_HEAD_TYPE={[EPointCloudName.PointCloud]:"sensebeepc",[EToolName.ClientAttribute]:"sensebeepc-EnumAttributeTool",[EToolName.Face]:"sensebeepc-FacePointsLabellingTool",[EToolName.OCRRelation]:"sensebeepc-OCRRelationTool"},CLIENT_TOOL_NAME={[EPointCloudName.PointCloud]:"\u70B9\u4E91\u5BA2\u6237\u7AEF",[EToolName.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[EToolName.Face]:"\u4EBA\u8138106\u70B9\u5DE5\u5177",[EToolName.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177"},SEGMENT_NUMBER$2=16,edgeAdsorptionScope=10;var tool=Object.freeze({__proto__:null,editStepWidth,get EPointCloudName(){return EPointCloudName},get EVideoToolName(){return EVideoToolName},get EToolType(){return EToolType},get EToolName(){return EToolName},get ECheckModel(){return ECheckModel},get ERectPattern(){return ERectPattern},TOOL_NAME,get EDependPattern(){return EDependPattern},get EFilterToolOperation(){return EFilterToolOperation},OPERATION_LIST,get EAnnotationMode(){return EAnnotationMode},get ELineTypes(){return ELineTypes},get ELineColor(){return ELineColor},get ESelectedType(){return ESelectedType},get EDragTarget(){return EDragTarget$1},get EDrawPointPattern(){return EDrawPointPattern},get EPageOperator(){return EPageOperator$1},get EAuditStatus(){return EAuditStatus},get ETextType(){return ETextType},TEXT_TYPE,TEXT_ATTRIBUTE_MAX_LENGTH,TEXT_ATTRIBUTE_LINE_HEIGHT,get EThumbnailOption(){return EThumbnailOption},CLIENT_TOOL_HEAD_TYPE,CLIENT_TOOL_NAME,SEGMENT_NUMBER:SEGMENT_NUMBER$2,edgeAdsorptionScope}),__defProp$e=Object.defineProperty,__defProps$c=Object.defineProperties,__getOwnPropDescs$c=Object.getOwnPropertyDescriptors,__getOwnPropSymbols$e=Object.getOwnPropertySymbols,__hasOwnProp$e=Object.prototype.hasOwnProperty,__propIsEnum$e=Object.prototype.propertyIsEnumerable,__defNormalProp$e=(r,t,e)=>t in r?__defProp$e(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,__spreadValues$e=(r,t)=>{for(var e in t||(t={}))__hasOwnProp$e.call(t,e)&&__defNormalProp$e(r,e,t[e]);if(__getOwnPropSymbols$e)for(var e of __getOwnPropSymbols$e(t))__propIsEnum$e.call(t,e)&&__defNormalProp$e(r,e,t[e]);return r},__spreadProps$c=(r,t)=>__defProps$c(r,__getOwnPropDescs$c(t));function createSmoothCurvePoints(r,t=.5,e=!1,i=16){if(r.length<4)return r;const s=[],n=r.slice(0);let o,a,l,h,d,u,c,g,f,v,p,b,x;for(e?(n.unshift(r[r.length-1]),n.unshift(r[r.length-2]),n.unshift(r[r.length-1]),n.unshift(r[r.length-2]),n.push(r[0]),n.push(r[1])):(n.unshift(r[1]),n.unshift(r[0]),n.push(r[r.length-2]),n.push(r[r.length-1])),x=2;x<n.length-4;x+=2)for(l=(n[x+2]-n[x-2])*t,h=(n[x+4]-n[x-0])*t,d=(n[x+3]-n[x-1])*t,u=(n[x+5]-n[x+1])*t,b=0;b<=i;b++)p=b/i,c=2*Math.pow(p,3)-3*Math.pow(p,2)+1,g=-(2*Math.pow(p,3))+3*Math.pow(p,2),f=Math.pow(p,3)-2*Math.pow(p,2)+p,v=Math.pow(p,3)-Math.pow(p,2),o=c*n[x]+g*n[x+2]+f*l+v*h,a=c*n[x+1]+g*n[x+3]+f*d+v*u,s.push(o),s.push(a);const y=[];for(let I=0;I<s.length-1;I+=2)y.push({x:s[I],y:s[I+1]});if(e)for(let I=0;I<i+1;I++){const m=y.shift();y.push(m)}return y}const createSmoothCurvePointsFromPointList=(r,t=16)=>createSmoothCurvePoints(r.reduce((e,i)=>[...e,i.x,i.y],[]),.5,!1,t);function isInPolygon(r,t,e=ELineTypes.Line){let i=0,s,n,o,a;t=[...t],e===ELineTypes.Curve&&(t=createSmoothCurvePoints(t.reduce((h,d)=>[...h,d.x,d.y],[]),.5,!0,SEGMENT_NUMBER$2)),[o]=t;const l=t.length;for(s=1;s<=l;s++)a=t[s%l],r.x>Math.min(o.x,a.x)&&r.x<=Math.max(o.x,a.x)&&r.y<=Math.max(o.y,a.y)&&o.x!==a.x&&(n=(r.x-o.x)*(a.y-o.y)/(a.x-o.x)+o.y,(o.y===a.y||r.y<=n)&&i++),o=a;return i%2!=0}function getPolygonPointUnderZoom(r,t=1){return r.map(e=>__spreadProps$c(__spreadValues$e({},e),{x:e.x*t,y:e.y*t}))}const _MathUtils=class{static getRotate(r){return r+90>=360?r+90-360:r+90}static getLineLength(r,t){return Math.sqrt(Math.pow(t.y-r.y,2)+Math.pow(t.x-r.x,2))}};let MathUtils=_MathUtils;MathUtils.isInRange=(r,t)=>{const e=Math.min(...t),i=Math.max(...t),s=o=>o<=i&&o>=e;return(Array.isArray(r)?r:[r]).every(o=>s(o))},MathUtils.withinRange=(r,t)=>{const e=Math.min(...t),i=Math.max(...t);return r>i?i:r<e?e:r},MathUtils.calcViewportBoundaries=(r,t=!1,e=SEGMENT_NUMBER$2,i=1)=>{if(!r)return{top:0,bottom:0,left:0,right:0};const s=20/i,n=[],o=[];let a=r;t&&(a=createSmoothCurvePointsFromPointList(r,e)),a.forEach(({x:f,y:v})=>{n.push(f),o.push(v)});let l=Math.min(...n),h=Math.max(...n),d=Math.min(...o),u=Math.max(...o);const c=h-l,g=u-d;if(c<s){const f=(s-c)/2;l-=f,h+=f}if(g<s){const f=(s-g)/2;d-=f,u+=f}return{top:d,bottom:u,left:l,right:h}},MathUtils.getFootOfPerpendicular=(r,t,e,i=!1)=>{let s={x:0,y:0};const n=t.x-e.x,o=t.y-e.y;if(Math.abs(n)<1e-8&&Math.abs(o)<1e-8)return s=t,s;let a=(r.x-t.x)*(t.x-e.x)+(r.y-t.y)*(t.y-e.y);a/=n*n+o*o,s.x=t.x+a*n,s.y=t.y+a*o;const l=_MathUtils.getLineLength(r,s),h=2,d=Math.min(t.x,e.x),u=Math.max(t.x,e.x),c=Math.min(t.y,e.y),g=Math.max(t.y,e.y),f=!(_MathUtils.isInRange(r.x,[d,u])||_MathUtils.isInRange(r.y,[c,g])),v=r.x>u+h||r.x<d-h||r.y>g+h||r.y<c-h;return(i?f:v)?{footPoint:s,length:Infinity}:{footPoint:s,length:l}};const headerHeight=61,tipsHeight=40,footerHeight=40,sidebarWidth=240;var EStepType;(function(r){r[r.ANNOTATION=1]="ANNOTATION",r[r.QUALITY_INSPECTION=2]="QUALITY_INSPECTION",r[r.PRE_ANNOTATION=3]="PRE_ANNOTATION",r[r.MANUAL_CORRECTION=4]="MANUAL_CORRECTION"})(EStepType||(EStepType={}));const ANNOTATION_MAX_SIZE=1e3;var EPageOperator;(function(r){r[r.Backward=0]="Backward",r[r.Forward=1]="Forward",r[r.JumpSkip=2]="JumpSkip",r[r.None=3]="None"})(EPageOperator||(EPageOperator={}));var EDragStatus;(function(r){r[r.Start=0]="Start",r[r.Stop=1]="Stop",r[r.Wait=2]="Wait",r[r.Move=3]="Move"})(EDragStatus||(EDragStatus={}));var EDragTarget;(function(r){r[r.Point=0]="Point",r[r.Line=1]="Line",r[r.Plane=2]="Plane"})(EDragTarget||(EDragTarget={}));var ESortDirection;(function(r){r[r.ascend=0]="ascend",r[r.descend=1]="descend"})(ESortDirection||(ESortDirection={}));var EGrowthMode;(function(r){r[r.Intelligence=0]="Intelligence",r[r.Linear=1]="Linear"})(EGrowthMode||(EGrowthMode={}));var ELang;(function(r){r.Zh="zh_CN",r.US="en_US"})(ELang||(ELang={}));const DEFAULT_TEXT_OFFSET={offsetX:-10,offsetY:-10},DEFAULT_TEXT_SHADOW={shadowColor:"rgba(0,0,0,0.6)",shadowOffsetX:0,shadowOffsetY:2,shadowBlur:4};var annotation=Object.freeze({__proto__:null,headerHeight,tipsHeight,footerHeight,sidebarWidth,get EStepType(){return EStepType},ANNOTATION_MAX_SIZE,get EPageOperator(){return EPageOperator},get EDragStatus(){return EDragStatus},get EDragTarget(){return EDragTarget},get ESortDirection(){return ESortDirection},get EGrowthMode(){return EGrowthMode},get ELang(){return ELang},DEFAULT_TEXT_OFFSET,DEFAULT_TEXT_SHADOW}),__defProp$d=Object.defineProperty,__defProps$b=Object.defineProperties,__getOwnPropDescs$b=Object.getOwnPropertyDescriptors,__getOwnPropSymbols$d=Object.getOwnPropertySymbols,__hasOwnProp$d=Object.prototype.hasOwnProperty,__propIsEnum$d=Object.prototype.propertyIsEnumerable,__defNormalProp$d=(r,t,e)=>t in r?__defProp$d(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,__spreadValues$d=(r,t)=>{for(var e in t||(t={}))__hasOwnProp$d.call(t,e)&&__defNormalProp$d(r,e,t[e]);if(__getOwnPropSymbols$d)for(var e of __getOwnPropSymbols$d(t))__propIsEnum$d.call(t,e)&&__defNormalProp$d(r,e,t[e]);return r},__spreadProps$b=(r,t)=>__defProps$b(r,__getOwnPropDescs$b(t));class RectUtils{static composeResult(t,e,i,s,n){try{const o=JSON.parse(t),a=CommonToolUtils.getCurrentStepInfo(e,s),{dataSourceStep:l}=a,h=`step_${a.step}`;if(Object.assign(o,n),o[h]){const d=o[h];return d.result?(d.result=i,JSON.stringify(o)):JSON.stringify(__spreadProps$b(__spreadValues$d({},o),{[h]:__spreadProps$b(__spreadValues$d({},o[h]),{result:i})}))}return JSON.stringify(__spreadProps$b(__spreadValues$d({},o),{[h]:{dataSourceStep:l,toolName:a.tool,result:i}}))}catch(o){return t}}static changeCoordinateByRotate(t,e,i){const{x:s,y:n,width:o,height:a}=t,l=AxisUtils.changeCoordinateByRotate({x:s,y:n},e,i);switch(e%360){case 90:return __spreadProps$b(__spreadValues$d({},t),{x:l.x-a,y:l.y,width:a,height:o});case 180:return __spreadProps$b(__spreadValues$d({},t),{x:l.x-o,y:l.y-a});case 270:return __spreadProps$b(__spreadValues$d({},t),{x:l.x,y:l.y-o,width:a,height:o});default:return t}}static translateRect2Points(t){const{x:e,y:i,width:s,height:n}=t;return[{x:e,y:i},{x:e+s,y:i},{x:e+s,y:i+n},{x:e,y:i+n}]}static translatePoints2Rect(t,e){if(t.length!==4)return;const{x:i,y:s}=t[0],n=t[1].x-t[0].x,o=t[2].y-t[1].y;return __spreadProps$b(__spreadValues$d({},e),{x:i,y:s,width:n,height:o})}static getRectPointList(t,e=1){return[{x:t.x*e,y:t.y*e},{x:(t.x+t.width)*e,y:t.y*e},{x:(t.x+t.width)*e,y:(t.y+t.height)*e},{x:t.x*e,y:(t.y+t.height)*e}]}static getRectEdgeList(t,e=1){const i=this.getRectPointList(t,e),s=i.length;return i.map((n,o)=>({begin:n,end:i[(o+1)%s]}))}static isInRect(t,e,i=0,s=1){return t.x>=e.x*s-i&&t.x<=(e.x+e.width)*s+i&&t.y>=e.y*s-i&&t.y<=(e.y+e.height)*s+i}static getRectUnderZoom(t,e=1){const{x:i,y:s,width:n,height:o}=t;return __spreadProps$b(__spreadValues$d({},t),{x:i*e,y:s*e,width:n*e,height:o*e})}static isRectNotInPolygon(t,e){return this.getRectPointList(t).some(s=>!isInPolygon(s,e))}}function uuid(r=8,t=62){const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),i=[];let s;if(t=t||e.length,r)for(s=0;s<r;s++)i[s]=e[0|Math.random()*t];else{let n;for(i[8]=i[13]=i[18]=i[23]="-",i[14]="4",s=0;s<36;s++)i[s]||(n=0|Math.random()*16,i[s]=e[s===19?n&3|8:n])}return i.join("")}var __defProp$c=Object.defineProperty,__getOwnPropSymbols$c=Object.getOwnPropertySymbols,__hasOwnProp$c=Object.prototype.hasOwnProperty,__propIsEnum$c=Object.prototype.propertyIsEnumerable,__defNormalProp$c=(r,t,e)=>t in r?__defProp$c(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,__spreadValues$c=(r,t)=>{for(var e in t||(t={}))__hasOwnProp$c.call(t,e)&&__defNormalProp$c(r,e,t[e]);if(__getOwnPropSymbols$c)for(var e of __getOwnPropSymbols$c(t))__propIsEnum$c.call(t,e)&&__defNormalProp$c(r,e,t[e]);return r};class TagUtil{static getTagKeyName(t,e){var i,s;if(!!e)return(s=(i=e.find(n=>n.value===t))==null?void 0:i.key)!=null?s:""}static getTagName([t="",e=""],i){if(!!i){for(const s of i)if(s.value===t){if(!s.subSelected)return console.error("\u6807\u7B7E\u89E3\u6790\u9519\u8BEF",t,e),"";for(const n of s.subSelected)if(n.value===e)return n.key}}}static getTagNameList(t,e){return Object.keys(t).length<=0?[]:Object.entries(t).reduce((i,s)=>{const[n,o]=s;if(o&&o.length>0){const a=o.split(";"),l={keyName:this.getTagKeyName(n,e),value:a.map(h=>this.getTagName([n,h],e))};return[...i,l]}return i},[]).filter(i=>i)}static getTagnameListWithoutConfig(t){return Object.keys(t).length<=0?[]:Object.entries(t).reduce((e,i)=>{const[s,n]=i,o=n.split(";"),a={keyName:s,value:o};return[...e,a]},[]).filter(e=>e)}static judgeResultIsInInputList(t,e,i){return!t||!e||!i?!1:i.filter(n=>{if(n.value===t&&n.subSelected){const o=e==null?void 0:e.split(";");return(n==null?void 0:n.subSelected.filter(a=>o.indexOf(a.value)>-1).length)>0}return!1}).length>0}static getDefaultResultByConfig(t){return t.reduce((e,i)=>(i.subSelected&&i.subSelected.forEach(s=>{var n;if(s.isDefault){const o=(n=e[i.value])!=null?n:"";let a=[];o.length>0&&(a=o.split(";")),a.push(s.value),e[i.value]=a.join(";")}}),e),{})}static getDefaultTagResult(t,e){const i=this.getDefaultResultByConfig(t);return e.length>0?e.map(s=>({id:uuid(),sourceID:s.id,result:__spreadValues$c({},i)})):[{id:uuid(),sourceID:"",result:__spreadValues$c({},i)}]}}var canvasEdit0='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#ccc"/></g></g></svg>',canvasEdit1='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#ff2323"/></g></g></svg>',canvasEdit2='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#ffe232"/></g></g></svg>',canvasEdit3='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#01ff30"/></g></g></svg>',canvasEdit4='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#00ffea"/></g></g></svg>',canvasEdit5='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#0282fa"/></g></g></svg>',canvasEdit6='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#800cf9"/></g></g></svg>',canvasEdit7='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#ff88f7"/></g></g></svg>',canvasEdit8='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#994217"/></g></g></svg>',baseEditLan='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#1f0bf9"/></g></g></svg>',baseEditQing='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#3fe"/></g></g></svg>',baseEditLv='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#33fe33"/></g></g></svg>',baseEditHuang='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#fdff37"/></g></g></svg>',baseEditFen='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#f70efa"/></g></g></svg>',INVALID_ICON='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#f33"/></g></g></svg>';const NULL_ICON=canvasEdit0,HEADER_HEIGHT=61,TAB_HEIGHT=80,SEARCH_HEIGHT=62,PADDING=20,TABLE_ROW_HEIGHT=55,PAGINATION_HEIGHT=55,TIPS_HEIGHT=40,FOOTER_HEIGHT=80,SIDERBAR_WIDTH=240,EDIT_STEP_WIDTH=320,THEME_COLOR="rgba(102, 111, 255, 1)",COLORS_ARRAY=["rgba(128, 12, 249, 1)","rgba(0, 255, 48, 1)","rgba(255, 136, 247, 1)","rgba(255, 226, 50, 1)","rgba(153, 66, 23, 1)","rgba(2, 130, 250, 1)","rgba(255, 35, 35, 1)","rgba(0, 255, 234, 1)"],ICON_ARRAY=[canvasEdit0,canvasEdit6,canvasEdit3,canvasEdit7,canvasEdit2,canvasEdit8,canvasEdit5,canvasEdit1,canvasEdit4],BASE_ICON={1:baseEditLan,3:baseEditQing,5:baseEditLv,7:baseEditHuang,9:baseEditFen},INVALID_COLOR="rgba(255, 51, 51, 1)",NULL_COLOR="rgba(204, 204, 204, 1)",FILTER_TOOL_COLOR={[EFilterToolOperation.lc]:"rgba(153, 51, 255, 1)",[EFilterToolOperation.rc]:"rgba(51, 153, 255, 1)",[EFilterToolOperation.clc]:"rgba(46, 230, 46, 1)",[EFilterToolOperation.crc]:"rgba(255, 51, 51, 1)"};var style=Object.freeze({__proto__:null,HEADER_HEIGHT,TAB_HEIGHT,SEARCH_HEIGHT,PADDING,TABLE_ROW_HEIGHT,PAGINATION_HEIGHT,TIPS_HEIGHT,FOOTER_HEIGHT,SIDERBAR_WIDTH,EDIT_STEP_WIDTH,THEME_COLOR,COLORS_ARRAY,ICON_ARRAY,BASE_ICON,INVALID_COLOR,NULL_COLOR,NULL_ICON,INVALID_ICON,FILTER_TOOL_COLOR}),EMessage;(function(r){r.NoRotateNotice="noRotateNotice",r.RectErrorSizeNotice="rectErrorSizeNotice",r.TextCheckNumberErrorNotice="textCheckNumberErrorNotice",r.TextCheckEnglishErrorNotice="textCheckEnglishErrorNotice",r.TextCheckCustomErrorNotice="textCheckCustomErrorNotice",r.UpperLimitErrorNotice="UpperLimitErrorNotice",r.LowerLimitErrorNotice="LowerLimitErrorNotice",r.InvalidImage="InvalidImage",r.DisableDelete="DisableDelete",r.ClearPartialData="ClearPartialData",r.MarkerFinish="MarkerFinish",r.LowerLimitPoint="LowerLimitPoint",r.NoRotateInDependence="noRotateInDependence"})(EMessage||(EMessage={}));const message$1={[EMessage.NoRotateNotice]:"This Image contains data and cannot be rotated",[EMessage.RectErrorSizeNotice]:"The drawing frame size is smaller than the minimum drawing size",[EMessage.TextCheckNumberErrorNotice]:"Please enter in number-only format",[EMessage.TextCheckEnglishErrorNotice]:"Please enter in English only format",[EMessage.TextCheckCustomErrorNotice]:"Please enter in the required format",[EMessage.UpperLimitErrorNotice]:"The number of vertices is not more than",[EMessage.LowerLimitErrorNotice]:"The number of vertices is not less than",[EMessage.InvalidImage]:"Invalid image, please skip this image",[EMessage.DisableDelete]:"Disable delete",[EMessage.ClearPartialData]:"Clear partial data",[EMessage.MarkerFinish]:"ListAnnotation is finished",[EMessage.LowerLimitPoint]:"\u5DF2\u5230\u8FBE\u6807\u70B9\u6570\u91CF\u4E0A\u9650",[EMessage.NoRotateInDependence]:"Disallow rotation in dependent cases"},message={[EMessage.NoRotateNotice]:"\u672C\u56FE\u542B\u6709\u6570\u636E\uFF0C\u65E0\u6CD5\u8FDB\u884C\u65CB\u8F6C",[EMessage.RectErrorSizeNotice]:"\u7ED8\u5236\u6846\u5C3A\u5BF8\u5C0F\u4E8E\u6700\u5C0F\u7ED8\u5236\u5C3A\u5BF8",[EMessage.TextCheckNumberErrorNotice]:"\u8BF7\u6309\u4EC5\u6570\u5B57\u7684\u683C\u5F0F\u8F93\u5165",[EMessage.TextCheckEnglishErrorNotice]:"\u8BF7\u6309\u4EC5\u82F1\u6587\u7684\u683C\u5F0F\u8F93\u5165",[EMessage.TextCheckCustomErrorNotice]:"\u8BF7\u6309\u8981\u6C42\u7684\u683C\u5F0F\u8F93\u5165",[EMessage.UpperLimitErrorNotice]:"\u9876\u70B9\u6570\u4E0D\u591A\u4E8E",[EMessage.LowerLimitErrorNotice]:"\u9876\u70B9\u6570\u4E0D\u5C11\u4E8E",[EMessage.InvalidImage]:"\u65E0\u6548\u56FE\u7247\uFF0C\u8BF7\u8DF3\u8FC7\u6B64\u56FE",[EMessage.DisableDelete]:"\u8BE5\u6570\u636E\u7981\u6B62\u5220\u9664",[EMessage.ClearPartialData]:"\u5B58\u5728\u90E8\u5206\u6570\u636E\u65E0\u6CD5\u6E05\u9664",[EMessage.MarkerFinish]:"\u5217\u8868\u6807\u6CE8\u5DF2\u5B8C\u6210",[EMessage.LowerLimitPoint]:"\u5DF2\u5230\u8FBE\u6807\u70B9\u6570\u91CF\u4E0A\u9650",[EMessage.NoRotateInDependence]:"\u4F9D\u8D56\u60C5\u51B5\u4E0B\u65E0\u6CD5\u8FDB\u884C\u65CB\u8F6C"};class Locale{}Locale.getMessagesByLocale=(r,t)=>{switch(t){case ELang.US:return message$1[r];case ELang.Zh:default:return message[r]}};var __defProp$b=Object.defineProperty,__defProps$a=Object.defineProperties,__getOwnPropDescs$a=Object.getOwnPropertyDescriptors,__getOwnPropSymbols$b=Object.getOwnPropertySymbols,__hasOwnProp$b=Object.prototype.hasOwnProperty,__propIsEnum$b=Object.prototype.propertyIsEnumerable,__defNormalProp$b=(r,t,e)=>t in r?__defProp$b(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,__spreadValues$b=(r,t)=>{for(var e in t||(t={}))__hasOwnProp$b.call(t,e)&&__defNormalProp$b(r,e,t[e]);if(__getOwnPropSymbols$b)for(var e of __getOwnPropSymbols$b(t))__propIsEnum$b.call(t,e)&&__defNormalProp$b(r,e,t[e]);return r},__spreadProps$a=(r,t)=>__defProps$a(r,__getOwnPropDescs$a(t));const REGEXP_NUMBER="^[0-9]+$",REGEXP_ENGLISH="^[A-Za-z]+$";class AttributeUtils{static getAttributeIcon(t,e,i=!0){var s;const n=e.findIndex(l=>l.value===t);let o=(s=ICON_ARRAY[n%ICON_ARRAY.length])!=null?s:NULL_ICON;i||(o=INVALID_ICON),o="";const a=new Image;return a.src=o,a}static checkString(t,e){let i="";switch(t){case ETextType.Order:case ETextType.NumberOnly:i=REGEXP_NUMBER;break;case ETextType.EnglishOnly:i=REGEXP_ENGLISH;break;case ETextType.CustomFormat:i=e;break}return i}static checkTextAttibute(t,e){if(t===void 0||t==="")return!0;try{return new RegExp(e).test(t)}catch(i){return!1}}static getAttributeShowText(t,e=[]){var i,s;try{const n=e.findIndex(o=>o.value===t);return(s=(i=e[n])==null?void 0:i.key)!=null?s:t}catch(n){return t}}static getAttributeIndex(t,e){try{const i=e.findIndex(s=>s.value===t);return i>=8?i%8:i}catch(i){return-1}}static getAttributeColor(t,e){try{const i=this.getAttributeIndex(t,e);return i===-1?NULL_COLOR:COLORS_ARRAY[i%COLORS_ARRAY.length]}catch(i){return NULL_COLOR}}static getTextAttribute(t,e){try{if(e===ETextType.Order){const i=t.map(n=>parseInt(n.textAttribute,10)).filter(n=>_.isNumber(n)&&n<Number.MAX_SAFE_INTEGER&&n>=0);return i.sort((n,o)=>n-o),`${(i.pop()||0)+1}`}return""}catch(i){return""}}static textChange(t,e,i){return i.map(s=>s.id===e?__spreadProps$a(__spreadValues$b({},s),{textAttribute:t}):s)}static getErrorNotice(t,e){switch(t){case ETextType.Order:case ETextType.NumberOnly:return Locale.getMessagesByLocale(EMessage.TextCheckNumberErrorNotice,e);case ETextType.EnglishOnly:return Locale.getMessagesByLocale(EMessage.TextCheckEnglishErrorNotice,e);case ETextType.CustomFormat:return Locale.getMessagesByLocale(EMessage.TextCheckCustomErrorNotice,e);default:return""}}static textAttributeValidate(t,e,i){try{return new RegExp(this.checkString(t,e)).test(i)}catch(s){}}static checkTextAttribute(t,e,i,s){let n=!1;return i.forEach(o=>{(o==null?void 0:o.textAttribute)===void 0||(o==null?void 0:o.textAttribute)===""||(s?o.id===s:!0)&&!this.textAttributeValidate(t,e,o.textAttribute)&&(n=!0)}),!!n}static changeTextAttributeInLog(t,e){return t==null?void 0:t.map(i=>i==null?void 0:i.map(s=>{if((e==null?void 0:e.findIndex(n=>(n==null?void 0:n.id)===(s==null?void 0:s.id)))>-1){const n=e==null?void 0:e.find(o=>(o==null?void 0:o.id)===(s==null?void 0:s.id));return __spreadProps$a(__spreadValues$b({},s),{textAttribute:n==null?void 0:n.textAttribute})}return s}))}static getTextIconSvg(t="",e,i=!1,s){if(i===!0){const n=(e==null?void 0:e.findIndex(o=>(o==null?void 0:o.value)===t))%COLORS_ARRAY.length+1;return ICON_ARRAY[n]}return s}static getAttributeByKeycode(t,e){var i;let s;return MathUtils.isInRange(t,[48,57])&&(s=t-48),MathUtils.isInRange(t,[96,105])&&(s=t-96),s===0?"":s?(i=e[s-1])==null?void 0:i.value:void 0}}class UnitUtils{static deg2rad(t){return t*Math.PI/180}static rad2deg(t){return t*180/Math.PI}}const DEFAULT_ZOOM=1,DEFAULT_CURRENT_POS={x:0,y:0},DEFAULT_ROTATE=0,DEFAULT_COLOR="";class DrawUtils{static drawLine(t,e,i,s={}){const n=t.getContext("2d"),{color:o=DEFAULT_COLOR,thickness:a=1,lineCap:l="round"}=s;n.save(),n.strokeStyle=o,n.lineWidth=a,n.lineCap=l,n.beginPath(),n.moveTo(e.x,e.y),n.lineTo(i.x+1,i.y+1),n.stroke(),n.restore()}static drawRect(t,e,i={}){const s=t.getContext("2d"),{color:n=DEFAULT_COLOR,thickness:o=1,lineCap:a="round"}=i;s.save(),s.strokeStyle=n,s.lineWidth=o,s.lineCap=a,s.beginPath(),s.fillStyle=n,s.strokeRect(e.x,e.y,e.width,e.height);let l="";if(e.attribute&&(l=`${l} ${e.attribute}`),this.drawText(t,{x:e.x,y:e.y-5},l),e.textAttribute){const d=`${~~e.width} * ${~~e.height}`.length*7,u=0,c=Math.max(20,e.width-d);this.drawText(t,{x:e.x,y:e.y+e.height+20+u},e.textAttribute,{textMaxWidth:c})}s.restore()}static drawRectWithFill(t,e,i={}){const s=t.getContext("2d"),{color:n=DEFAULT_COLOR}=i;s.save(),s.beginPath(),s.fillStyle=n,s.fillRect(e.x,e.y,e.width,e.height),s.restore()}static drawTag(t,e){var i;const s=t==null?void 0:t.parentNode,n=window.self.document.getElementById("tagToolTag");if(n&&s&&s.contains(n)&&(s==null||s.removeChild(n)),!((e==null?void 0:e.length)>0))return;const o=document.createElement("div");o.innerHTML=(i=e.reduce((a,l)=>`${a}${l.keyName}: ${l.value.join(" \u3001 ")}
|
|
6
|
-
`,""))!=null?i:"",o.setAttribute("id","tagToolTag"),s==null||s.appendChild(o)}static drawLineWithPointList(t,e,i={}){if(e.length<2)return;const s=t.getContext("2d"),{color:n=DEFAULT_COLOR,thickness:o=1,lineCap:a="round",lineType:l=ELineTypes.Line,hoverEdgeIndex:h}=i;s.save(),s.strokeStyle=n,s.lineWidth=o,s.lineCap=a,s.beginPath(),l===ELineTypes.Curve?(h!==void 0&&h>-1&&e.push(e[0]),e=PolygonUtils.createSmoothCurvePointsFromPointList([...e],SEGMENT_NUMBER$2),h!==void 0&&h>-1&&(e=e.slice((SEGMENT_NUMBER$2+1)*h,(SEGMENT_NUMBER$2+1)*(h+1)))):h!==void 0&&h>-1&&(e=[...e,e[0]],e=e.slice(h,h+2));const[d,...u]=e;s.moveTo(d.x,d.y),u.forEach(c=>{s.lineTo(c.x,c.y)}),s.stroke(),s.restore()}static drawCircle(t,e,i,s={}){const n=t.getContext("2d"),{startAngleDeg:o=0,endAngleDeg:a=360,thickness:l=1,color:h=DEFAULT_COLOR,fill:d=DEFAULT_COLOR}=s,u=UnitUtils.deg2rad(o),c=UnitUtils.deg2rad(a);n.save(),n.beginPath(),n.strokeStyle=h,n.fillStyle=d,n.lineWidth=l,n.arc(e.x,e.y,i,u,c,!1),n.stroke(),n.fill(),n.closePath(),n.restore()}static drawCircleWithFill(t,e,i=3,s={}){const n=t.getContext("2d"),{color:o=DEFAULT_COLOR}=s;n.save();const a=UnitUtils.deg2rad(0),l=UnitUtils.deg2rad(360);n.fillStyle=o,n.beginPath(),n.arc(e.x,e.y,i,a,l,!1),n.fill(),n.restore()}static drawPolygon(t,e,i={}){const{isClose:s=!1,lineType:n=ELineTypes.Line}=i;s===!0&&(e=[...e,e[0]]),n===ELineTypes.Curve&&(e=PolygonUtils.createSmoothCurvePointsFromPointList([...e])),this.drawLineWithPointList(t,e,i)}static drawPolygonWithFill(t,e,i={}){if(e.length<2)return;const s=t.getContext("2d"),{color:n=DEFAULT_COLOR,lineType:o=ELineTypes.Line}=i;s.save(),s.fillStyle=n,s.beginPath(),o===ELineTypes.Curve&&(e=PolygonUtils.createSmoothCurvePointsFromPointList([...e,e[0]]));const[a,...l]=e;s.moveTo(a.x,a.y),l.forEach(h=>{s.lineTo(h.x,h.y)}),s.fill(),s.restore()}static drawPolygonWithFillAndLine(t,e,i={}){const{strokeColor:s,fillColor:n,thickness:o,lineCap:a,isClose:l,lineType:h}=i;this.drawPolygon(t,e,{color:s,thickness:o,lineCap:a,isClose:l,lineType:h}),this.drawPolygonWithFill(t,e,{color:n,lineType:h})}static drawSelectedPolygonWithFillAndLine(t,e,i={}){const{pointColor:s="white",strokeColor:n}=i;this.drawPolygonWithFillAndLine(t,e,i),[...e].forEach(a=>{this.drawCircleWithFill(t,a,4,{color:n}),this.drawCircleWithFill(t,a,3,{color:s})})}static drawText(t,e,i,s={}){if(!i)return;const n=t.getContext("2d"),{color:o=DEFAULT_COLOR,font:a="normal normal 500 14px Arial",shadowColor:l="",shadowBlur:h=0,shadowOffsetX:d=0,shadowOffsetY:u=0,textMaxWidth:c=164,offsetX:g=0,offsetY:f=0,textAlign:v="start"}=s;n.save(),n.textAlign=v,n.fillStyle=o!=null?o:"white",n.font=a,n.shadowColor=l,n.shadowOffsetX=d,n.shadowOffsetY=u,n.shadowBlur=h,this.wrapText(t,`${i}`,e.x+g,e.y+f,c),n.restore()}static wrapText(t,e,i,s,n,o){if(typeof e!="string"||typeof i!="number"||typeof s!="number")return;const
|
|
7
|
-
`);for(let
|
|
4
|
+
* Released under the Apache-2.0 License.
|
|
5
|
+
*/Object.defineProperty(exports,"__esModule",{value:!0});var _=require("lodash"),rgba=require("color-rgba");function _interopDefaultLegacy(r){return r&&typeof r=="object"&&"default"in r?r:{default:r}}var ___default=_interopDefaultLegacy(_),rgba__default=_interopDefaultLegacy(rgba);const editStepWidth=320;var EPointCloudName;(function(r){r.PointCloud="pointCloudTool"})(EPointCloudName||(EPointCloudName={}));var EVideoToolName;(function(r){r.VideoTextTool="videoTextTool",r.VideoTagTool="videoTagTool",r.VideoClipTool="videoClipTool"})(EVideoToolName||(EVideoToolName={}));var EToolType;(function(r){r[r.Rect=0]="Rect",r[r.Tag=1]="Tag"})(EToolType||(EToolType={}));var EToolName;(function(r){r.Rect="rectTool",r.Tag="tagTool",r.Point="pointTool",r.PointMarker="pointMarkerTool",r.Segmentation="segmentationTool",r.Filter="filterTool",r.Text="textTool",r.Polygon="polygonTool",r.Line="lineTool",r.LineMarker="lineMarkerTool",r.Empty="emptyTool",r.FolderTag="folderTagTool",r.RectTrack="rectTrackTool",r.Face="faceTool",r.ClientAttribute="clientAttributeTool",r.OCRRelation="OCRRelationTool"})(EToolName||(EToolName={}));var ECheckModel;(function(r){r.Check="check"})(ECheckModel||(ECheckModel={}));var ERectPattern;(function(r){r[r.nothing=0]="nothing",r[r.RectBG=1]="RectBG",r[r.showOrder=2]="showOrder"})(ERectPattern||(ERectPattern={}));const TOOL_NAME={[EToolName.Rect]:"\u62C9\u6846",[EToolName.Tag]:"\u6807\u7B7E",[EToolName.Point]:"\u6807\u70B9",[EToolName.PointMarker]:"\u5217\u8868\u6807\u70B9",[EToolName.Segmentation]:"\u524D\u666F\u5206\u5272",[EToolName.Filter]:"\u7B5B\u9009",[EToolName.Text]:"\u6587\u672C",[EToolName.Polygon]:"\u591A\u8FB9\u5F62",[EToolName.Line]:"\u7EBF\u6761",[EToolName.LineMarker]:"\u5217\u8868\u7EBF\u6761",[EToolName.FolderTag]:"\u6587\u4EF6\u5939\u6807\u7B7E",[EToolName.RectTrack]:"\u62C9\u6846\u8DDF\u8E2A",[EToolName.Face]:"\u4EBA\u8138106\u5DE5\u5177",[EToolName.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[EToolName.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177",[EVideoToolName.VideoTextTool]:"\u89C6\u9891\u6587\u672C",[EVideoToolName.VideoTagTool]:"\u89C6\u9891\u6807\u7B7E",[EVideoToolName.VideoClipTool]:"\u89C6\u9891\u622A\u53D6",[EPointCloudName.PointCloud]:"\u70B9\u4E91"};var EDependPattern;(function(r){r[r.noDepend=1]="noDepend",r[r.dependOrigin=2]="dependOrigin",r[r.dependShape=3]="dependShape",r[r.dependLine=4]="dependLine",r[r.dependPolygon=5]="dependPolygon",r[r.dependPreShape=101]="dependPreShape",r[r.dependPreLine=102]="dependPreLine",r[r.dependPrePolygon=103]="dependPrePolygon"})(EDependPattern||(EDependPattern={}));var EFilterToolOperation;(function(r){r.lc="leftClick",r.rc="rightClick",r.clc="ctrlLeftClick",r.crc="ctrlRightClick"})(EFilterToolOperation||(EFilterToolOperation={}));const OPERATION_LIST={leftClick:"\u9F20\u6807\u5DE6\u952E",rightClick:"\u9F20\u6807\u53F3\u952E",ctrlLeftClick:"ctrl + \u9F20\u6807\u5DE6\u952E",ctrlRightClick:"ctrl + \u9F20\u6807\u53F3\u952E"};var EAnnotationMode;(function(r){r[r.Normal=1]="Normal",r[r.Modify=2]="Modify"})(EAnnotationMode||(EAnnotationMode={}));var ELineTypes;(function(r){r[r.Line=0]="Line",r[r.Curve=1]="Curve"})(ELineTypes||(ELineTypes={}));var ELineColor;(function(r){r[r.SingleColor=0]="SingleColor",r[r.MultiColor=1]="MultiColor"})(ELineColor||(ELineColor={}));var ESelectedType;(function(r){r[r.Form=1]="Form",r[r.Json=2]="Json"})(ESelectedType||(ESelectedType={}));var EDragTarget$1;(function(r){r[r.Point=0]="Point",r[r.Line=1]="Line",r[r.Plane=2]="Plane"})(EDragTarget$1||(EDragTarget$1={}));var EDrawPointPattern;(function(r){r[r.None=0]="None",r[r.Drawing=1]="Drawing",r[r.Edit=2]="Edit"})(EDrawPointPattern||(EDrawPointPattern={}));var EPageOperator$1;(function(r){r[r.Backward=0]="Backward",r[r.Forward=1]="Forward",r[r.JumpSkip=2]="JumpSkip",r[r.None=3]="None"})(EPageOperator$1||(EPageOperator$1={}));var EAuditStatus;(function(r){r[r.Wait=0]="Wait",r[r.Pass=1]="Pass",r[r.Fail=2]="Fail",r[r.Loading=3]="Loading"})(EAuditStatus||(EAuditStatus={}));var ETextType;(function(r){r[r.AnyString=0]="AnyString",r[r.Order=1]="Order",r[r.EnglishOnly=2]="EnglishOnly",r[r.NumberOnly=3]="NumberOnly",r[r.CustomFormat=4]="CustomFormat"})(ETextType||(ETextType={}));const TEXT_TYPE={0:"\u4EFB\u610F\u5B57\u7B26",1:"\u5E8F\u53F7",2:"\u4EC5\u82F1\u6587",3:"\u4EC5\u6570\u5B57"},TEXT_ATTRIBUTE_MAX_LENGTH=1e3,TEXT_ATTRIBUTE_LINE_HEIGHT=16;var EThumbnailOption;(function(r){r[r.ImgList=1e3]="ImgList",r[r.TrackPrediction=1001]="TrackPrediction",r[r.ImgSearch=1002]="ImgSearch"})(EThumbnailOption||(EThumbnailOption={}));const CLIENT_TOOL_HEAD_TYPE={[EPointCloudName.PointCloud]:"sensebeepc",[EToolName.ClientAttribute]:"sensebeepc-EnumAttributeTool",[EToolName.Face]:"sensebeepc-FacePointsLabellingTool",[EToolName.OCRRelation]:"sensebeepc-OCRRelationTool"},CLIENT_TOOL_NAME={[EPointCloudName.PointCloud]:"\u70B9\u4E91\u5BA2\u6237\u7AEF",[EToolName.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[EToolName.Face]:"\u4EBA\u8138106\u70B9\u5DE5\u5177",[EToolName.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177"},SEGMENT_NUMBER$2=16,edgeAdsorptionScope=10;var tool=Object.freeze({__proto__:null,editStepWidth,get EPointCloudName(){return EPointCloudName},get EVideoToolName(){return EVideoToolName},get EToolType(){return EToolType},get EToolName(){return EToolName},get ECheckModel(){return ECheckModel},get ERectPattern(){return ERectPattern},TOOL_NAME,get EDependPattern(){return EDependPattern},get EFilterToolOperation(){return EFilterToolOperation},OPERATION_LIST,get EAnnotationMode(){return EAnnotationMode},get ELineTypes(){return ELineTypes},get ELineColor(){return ELineColor},get ESelectedType(){return ESelectedType},get EDragTarget(){return EDragTarget$1},get EDrawPointPattern(){return EDrawPointPattern},get EPageOperator(){return EPageOperator$1},get EAuditStatus(){return EAuditStatus},get ETextType(){return ETextType},TEXT_TYPE,TEXT_ATTRIBUTE_MAX_LENGTH,TEXT_ATTRIBUTE_LINE_HEIGHT,get EThumbnailOption(){return EThumbnailOption},CLIENT_TOOL_HEAD_TYPE,CLIENT_TOOL_NAME,SEGMENT_NUMBER:SEGMENT_NUMBER$2,edgeAdsorptionScope}),__defProp$e=Object.defineProperty,__defProps$c=Object.defineProperties,__getOwnPropDescs$c=Object.getOwnPropertyDescriptors,__getOwnPropSymbols$e=Object.getOwnPropertySymbols,__hasOwnProp$e=Object.prototype.hasOwnProperty,__propIsEnum$e=Object.prototype.propertyIsEnumerable,__defNormalProp$e=(r,t,e)=>t in r?__defProp$e(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,__spreadValues$e=(r,t)=>{for(var e in t||(t={}))__hasOwnProp$e.call(t,e)&&__defNormalProp$e(r,e,t[e]);if(__getOwnPropSymbols$e)for(var e of __getOwnPropSymbols$e(t))__propIsEnum$e.call(t,e)&&__defNormalProp$e(r,e,t[e]);return r},__spreadProps$c=(r,t)=>__defProps$c(r,__getOwnPropDescs$c(t));function createSmoothCurvePoints(r,t=.5,e=!1,i=16){if(r.length<4)return r;const s=[],n=r.slice(0);let o,a,l,h,d,u,c,g,f,v,p,b,x;for(e?(n.unshift(r[r.length-1]),n.unshift(r[r.length-2]),n.unshift(r[r.length-1]),n.unshift(r[r.length-2]),n.push(r[0]),n.push(r[1])):(n.unshift(r[1]),n.unshift(r[0]),n.push(r[r.length-2]),n.push(r[r.length-1])),x=2;x<n.length-4;x+=2)for(l=(n[x+2]-n[x-2])*t,h=(n[x+4]-n[x-0])*t,d=(n[x+3]-n[x-1])*t,u=(n[x+5]-n[x+1])*t,b=0;b<=i;b++)p=b/i,c=2*Math.pow(p,3)-3*Math.pow(p,2)+1,g=-(2*Math.pow(p,3))+3*Math.pow(p,2),f=Math.pow(p,3)-2*Math.pow(p,2)+p,v=Math.pow(p,3)-Math.pow(p,2),o=c*n[x]+g*n[x+2]+f*l+v*h,a=c*n[x+1]+g*n[x+3]+f*d+v*u,s.push(o),s.push(a);const y=[];for(let I=0;I<s.length-1;I+=2)y.push({x:s[I],y:s[I+1]});if(e)for(let I=0;I<i+1;I++){const m=y.shift();y.push(m)}return y}const createSmoothCurvePointsFromPointList=(r,t=16)=>createSmoothCurvePoints(r.reduce((e,i)=>[...e,i.x,i.y],[]),.5,!1,t);function isInPolygon(r,t,e=ELineTypes.Line){let i=0,s,n,o,a;t=[...t],e===ELineTypes.Curve&&(t=createSmoothCurvePoints(t.reduce((h,d)=>[...h,d.x,d.y],[]),.5,!0,SEGMENT_NUMBER$2)),[o]=t;const l=t.length;for(s=1;s<=l;s++)a=t[s%l],r.x>Math.min(o.x,a.x)&&r.x<=Math.max(o.x,a.x)&&r.y<=Math.max(o.y,a.y)&&o.x!==a.x&&(n=(r.x-o.x)*(a.y-o.y)/(a.x-o.x)+o.y,(o.y===a.y||r.y<=n)&&i++),o=a;return i%2!=0}function getPolygonPointUnderZoom(r,t=1){return r.map(e=>__spreadProps$c(__spreadValues$e({},e),{x:e.x*t,y:e.y*t}))}const _MathUtils=class{static getRotate(r){return r+90>=360?r+90-360:r+90}static getLineLength(r,t){return Math.sqrt(Math.pow(t.y-r.y,2)+Math.pow(t.x-r.x,2))}};let MathUtils=_MathUtils;MathUtils.isInRange=(r,t)=>{const e=Math.min(...t),i=Math.max(...t),s=o=>o<=i&&o>=e;return(Array.isArray(r)?r:[r]).every(o=>s(o))},MathUtils.withinRange=(r,t)=>{const e=Math.min(...t),i=Math.max(...t);return r>i?i:r<e?e:r},MathUtils.calcViewportBoundaries=(r,t=!1,e=SEGMENT_NUMBER$2,i=1)=>{if(!r)return{top:0,bottom:0,left:0,right:0};const s=20/i,n=[],o=[];let a=r;t&&(a=createSmoothCurvePointsFromPointList(r,e)),a.forEach(({x:f,y:v})=>{n.push(f),o.push(v)});let l=Math.min(...n),h=Math.max(...n),d=Math.min(...o),u=Math.max(...o);const c=h-l,g=u-d;if(c<s){const f=(s-c)/2;l-=f,h+=f}if(g<s){const f=(s-g)/2;d-=f,u+=f}return{top:d,bottom:u,left:l,right:h}},MathUtils.getFootOfPerpendicular=(r,t,e,i=!1)=>{let s={x:0,y:0};const n=t.x-e.x,o=t.y-e.y;if(Math.abs(n)<1e-8&&Math.abs(o)<1e-8)return s=t,s;let a=(r.x-t.x)*(t.x-e.x)+(r.y-t.y)*(t.y-e.y);a/=n*n+o*o,s.x=t.x+a*n,s.y=t.y+a*o;const l=_MathUtils.getLineLength(r,s),h=2,d=Math.min(t.x,e.x),u=Math.max(t.x,e.x),c=Math.min(t.y,e.y),g=Math.max(t.y,e.y),f=!(_MathUtils.isInRange(r.x,[d,u])||_MathUtils.isInRange(r.y,[c,g])),v=r.x>u+h||r.x<d-h||r.y>g+h||r.y<c-h;return(i?f:v)?{footPoint:s,length:Infinity}:{footPoint:s,length:l}};const headerHeight=61,tipsHeight=40,footerHeight=40,sidebarWidth=240;var EStepType;(function(r){r[r.ANNOTATION=1]="ANNOTATION",r[r.QUALITY_INSPECTION=2]="QUALITY_INSPECTION",r[r.PRE_ANNOTATION=3]="PRE_ANNOTATION",r[r.MANUAL_CORRECTION=4]="MANUAL_CORRECTION"})(EStepType||(EStepType={}));const ANNOTATION_MAX_SIZE=1e3;var EPageOperator;(function(r){r[r.Backward=0]="Backward",r[r.Forward=1]="Forward",r[r.JumpSkip=2]="JumpSkip",r[r.None=3]="None"})(EPageOperator||(EPageOperator={}));var EDragStatus;(function(r){r[r.Start=0]="Start",r[r.Stop=1]="Stop",r[r.Wait=2]="Wait",r[r.Move=3]="Move"})(EDragStatus||(EDragStatus={}));var EDragTarget;(function(r){r[r.Point=0]="Point",r[r.Line=1]="Line",r[r.Plane=2]="Plane"})(EDragTarget||(EDragTarget={}));var ESortDirection;(function(r){r[r.ascend=0]="ascend",r[r.descend=1]="descend"})(ESortDirection||(ESortDirection={}));var EGrowthMode;(function(r){r[r.Intelligence=0]="Intelligence",r[r.Linear=1]="Linear"})(EGrowthMode||(EGrowthMode={}));var ELang;(function(r){r.Zh="zh_CN",r.US="en_US"})(ELang||(ELang={}));const DEFAULT_TEXT_OFFSET={offsetX:-10,offsetY:-10},DEFAULT_TEXT_SHADOW={shadowColor:"rgba(0,0,0,0.6)",shadowOffsetX:0,shadowOffsetY:2,shadowBlur:4};var annotation=Object.freeze({__proto__:null,headerHeight,tipsHeight,footerHeight,sidebarWidth,get EStepType(){return EStepType},ANNOTATION_MAX_SIZE,get EPageOperator(){return EPageOperator},get EDragStatus(){return EDragStatus},get EDragTarget(){return EDragTarget},get ESortDirection(){return ESortDirection},get EGrowthMode(){return EGrowthMode},get ELang(){return ELang},DEFAULT_TEXT_OFFSET,DEFAULT_TEXT_SHADOW}),__defProp$d=Object.defineProperty,__defProps$b=Object.defineProperties,__getOwnPropDescs$b=Object.getOwnPropertyDescriptors,__getOwnPropSymbols$d=Object.getOwnPropertySymbols,__hasOwnProp$d=Object.prototype.hasOwnProperty,__propIsEnum$d=Object.prototype.propertyIsEnumerable,__defNormalProp$d=(r,t,e)=>t in r?__defProp$d(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,__spreadValues$d=(r,t)=>{for(var e in t||(t={}))__hasOwnProp$d.call(t,e)&&__defNormalProp$d(r,e,t[e]);if(__getOwnPropSymbols$d)for(var e of __getOwnPropSymbols$d(t))__propIsEnum$d.call(t,e)&&__defNormalProp$d(r,e,t[e]);return r},__spreadProps$b=(r,t)=>__defProps$b(r,__getOwnPropDescs$b(t));class RectUtils{static composeResult(t,e,i,s,n){try{const o=JSON.parse(t),a=CommonToolUtils.getCurrentStepInfo(e,s),{dataSourceStep:l}=a,h=`step_${a.step}`;if(Object.assign(o,n),o[h]){const d=o[h];return d.result?(d.result=i,JSON.stringify(o)):JSON.stringify(__spreadProps$b(__spreadValues$d({},o),{[h]:__spreadProps$b(__spreadValues$d({},o[h]),{result:i})}))}return JSON.stringify(__spreadProps$b(__spreadValues$d({},o),{[h]:{dataSourceStep:l,toolName:a.tool,result:i}}))}catch(o){return t}}static changeCoordinateByRotate(t,e,i){const{x:s,y:n,width:o,height:a}=t,l=AxisUtils.changeCoordinateByRotate({x:s,y:n},e,i);switch(e%360){case 90:return __spreadProps$b(__spreadValues$d({},t),{x:l.x-a,y:l.y,width:a,height:o});case 180:return __spreadProps$b(__spreadValues$d({},t),{x:l.x-o,y:l.y-a});case 270:return __spreadProps$b(__spreadValues$d({},t),{x:l.x,y:l.y-o,width:a,height:o});default:return t}}static translateRect2Points(t){const{x:e,y:i,width:s,height:n}=t;return[{x:e,y:i},{x:e+s,y:i},{x:e+s,y:i+n},{x:e,y:i+n}]}static translatePoints2Rect(t,e){if(t.length!==4)return;const{x:i,y:s}=t[0],n=t[1].x-t[0].x,o=t[2].y-t[1].y;return __spreadProps$b(__spreadValues$d({},e),{x:i,y:s,width:n,height:o})}static getRectPointList(t,e=1){return[{x:t.x*e,y:t.y*e},{x:(t.x+t.width)*e,y:t.y*e},{x:(t.x+t.width)*e,y:(t.y+t.height)*e},{x:t.x*e,y:(t.y+t.height)*e}]}static getRectEdgeList(t,e=1){const i=this.getRectPointList(t,e),s=i.length;return i.map((n,o)=>({begin:n,end:i[(o+1)%s]}))}static isInRect(t,e,i=0,s=1){return t.x>=e.x*s-i&&t.x<=(e.x+e.width)*s+i&&t.y>=e.y*s-i&&t.y<=(e.y+e.height)*s+i}static getRectUnderZoom(t,e=1){const{x:i,y:s,width:n,height:o}=t;return __spreadProps$b(__spreadValues$d({},t),{x:i*e,y:s*e,width:n*e,height:o*e})}static isRectNotInPolygon(t,e){return this.getRectPointList(t).some(s=>!isInPolygon(s,e))}}function uuid(r=8,t=62){const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),i=[];let s;if(t=t||e.length,r)for(s=0;s<r;s++)i[s]=e[0|Math.random()*t];else{let n;for(i[8]=i[13]=i[18]=i[23]="-",i[14]="4",s=0;s<36;s++)i[s]||(n=0|Math.random()*16,i[s]=e[s===19?n&3|8:n])}return i.join("")}var __defProp$c=Object.defineProperty,__getOwnPropSymbols$c=Object.getOwnPropertySymbols,__hasOwnProp$c=Object.prototype.hasOwnProperty,__propIsEnum$c=Object.prototype.propertyIsEnumerable,__defNormalProp$c=(r,t,e)=>t in r?__defProp$c(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,__spreadValues$c=(r,t)=>{for(var e in t||(t={}))__hasOwnProp$c.call(t,e)&&__defNormalProp$c(r,e,t[e]);if(__getOwnPropSymbols$c)for(var e of __getOwnPropSymbols$c(t))__propIsEnum$c.call(t,e)&&__defNormalProp$c(r,e,t[e]);return r};class TagUtil{static getTagKeyName(t,e){var i,s;if(!!e)return(s=(i=e.find(n=>n.value===t))==null?void 0:i.key)!=null?s:""}static getTagName([t="",e=""],i){if(!!i){for(const s of i)if(s.value===t){if(!s.subSelected)return console.error("\u6807\u7B7E\u89E3\u6790\u9519\u8BEF",t,e),"";for(const n of s.subSelected)if(n.value===e)return n.key}}}static getTagNameList(t,e){return Object.keys(t).length<=0?[]:Object.entries(t).reduce((i,s)=>{const[n,o]=s;if(o&&o.length>0){const a=o.split(";"),l={keyName:this.getTagKeyName(n,e),value:a.map(h=>this.getTagName([n,h],e))};return[...i,l]}return i},[]).filter(i=>i)}static getTagnameListWithoutConfig(t){return Object.keys(t).length<=0?[]:Object.entries(t).reduce((e,i)=>{const[s,n]=i,o=n.split(";"),a={keyName:s,value:o};return[...e,a]},[]).filter(e=>e)}static judgeResultIsInInputList(t,e,i){return!t||!e||!i?!1:i.filter(n=>{if(n.value===t&&n.subSelected){const o=e==null?void 0:e.split(";");return(n==null?void 0:n.subSelected.filter(a=>o.indexOf(a.value)>-1).length)>0}return!1}).length>0}static getDefaultResultByConfig(t){return t.reduce((e,i)=>(i.subSelected&&i.subSelected.forEach(s=>{var n;if(s.isDefault){const o=(n=e[i.value])!=null?n:"";let a=[];o.length>0&&(a=o.split(";")),a.push(s.value),e[i.value]=a.join(";")}}),e),{})}static getDefaultTagResult(t,e){const i=this.getDefaultResultByConfig(t);return e.length>0?e.map(s=>({id:uuid(),sourceID:s.id,result:__spreadValues$c({},i)})):[{id:uuid(),sourceID:"",result:__spreadValues$c({},i)}]}}var canvasEdit0='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#ccc"/></g></g></svg>',canvasEdit1='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#ff2323"/></g></g></svg>',canvasEdit2='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#ffe232"/></g></g></svg>',canvasEdit3='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#01ff30"/></g></g></svg>',canvasEdit4='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#00ffea"/></g></g></svg>',canvasEdit5='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#0282fa"/></g></g></svg>',canvasEdit6='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#800cf9"/></g></g></svg>',canvasEdit7='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#ff88f7"/></g></g></svg>',canvasEdit8='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#994217"/></g></g></svg>',baseEditLan='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#1f0bf9"/></g></g></svg>',baseEditQing='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#3fe"/></g></g></svg>',baseEditLv='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#33fe33"/></g></g></svg>',baseEditHuang='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#fdff37"/></g></g></svg>',baseEditFen='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#f70efa"/></g></g></svg>',INVALID_ICON='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#f33"/></g></g></svg>';const NULL_ICON=canvasEdit0,HEADER_HEIGHT=61,TAB_HEIGHT=80,SEARCH_HEIGHT=62,PADDING=20,TABLE_ROW_HEIGHT=55,PAGINATION_HEIGHT=55,TIPS_HEIGHT=40,FOOTER_HEIGHT=80,SIDERBAR_WIDTH=240,EDIT_STEP_WIDTH=320,THEME_COLOR="rgba(102, 111, 255, 1)",COLORS_ARRAY=["rgba(128, 12, 249, 1)","rgba(0, 255, 48, 1)","rgba(255, 136, 247, 1)","rgba(255, 226, 50, 1)","rgba(153, 66, 23, 1)","rgba(2, 130, 250, 1)","rgba(255, 35, 35, 1)","rgba(0, 255, 234, 1)"],ICON_ARRAY=[canvasEdit0,canvasEdit6,canvasEdit3,canvasEdit7,canvasEdit2,canvasEdit8,canvasEdit5,canvasEdit1,canvasEdit4],BASE_ICON={1:baseEditLan,3:baseEditQing,5:baseEditLv,7:baseEditHuang,9:baseEditFen},INVALID_COLOR="rgba(255, 51, 51, 1)",NULL_COLOR="rgba(204, 204, 204, 1)",FILTER_TOOL_COLOR={[EFilterToolOperation.lc]:"rgba(153, 51, 255, 1)",[EFilterToolOperation.rc]:"rgba(51, 153, 255, 1)",[EFilterToolOperation.clc]:"rgba(46, 230, 46, 1)",[EFilterToolOperation.crc]:"rgba(255, 51, 51, 1)"};var style=Object.freeze({__proto__:null,HEADER_HEIGHT,TAB_HEIGHT,SEARCH_HEIGHT,PADDING,TABLE_ROW_HEIGHT,PAGINATION_HEIGHT,TIPS_HEIGHT,FOOTER_HEIGHT,SIDERBAR_WIDTH,EDIT_STEP_WIDTH,THEME_COLOR,COLORS_ARRAY,ICON_ARRAY,BASE_ICON,INVALID_COLOR,NULL_COLOR,NULL_ICON,INVALID_ICON,FILTER_TOOL_COLOR}),EMessage;(function(r){r.NoRotateNotice="noRotateNotice",r.RectErrorSizeNotice="rectErrorSizeNotice",r.TextCheckNumberErrorNotice="textCheckNumberErrorNotice",r.TextCheckEnglishErrorNotice="textCheckEnglishErrorNotice",r.TextCheckCustomErrorNotice="textCheckCustomErrorNotice",r.UpperLimitErrorNotice="UpperLimitErrorNotice",r.LowerLimitErrorNotice="LowerLimitErrorNotice",r.InvalidImage="InvalidImage",r.DisableDelete="DisableDelete",r.ClearPartialData="ClearPartialData",r.MarkerFinish="MarkerFinish",r.LowerLimitPoint="LowerLimitPoint",r.NoRotateInDependence="noRotateInDependence"})(EMessage||(EMessage={}));const message$1={[EMessage.NoRotateNotice]:"This Image contains data and cannot be rotated",[EMessage.RectErrorSizeNotice]:"The drawing frame size is smaller than the minimum drawing size",[EMessage.TextCheckNumberErrorNotice]:"Please enter in number-only format",[EMessage.TextCheckEnglishErrorNotice]:"Please enter in English only format",[EMessage.TextCheckCustomErrorNotice]:"Please enter in the required format",[EMessage.UpperLimitErrorNotice]:"The number of vertices is not more than",[EMessage.LowerLimitErrorNotice]:"The number of vertices is not less than",[EMessage.InvalidImage]:"Invalid image, please skip this image",[EMessage.DisableDelete]:"Disable delete",[EMessage.ClearPartialData]:"Clear partial data",[EMessage.MarkerFinish]:"ListAnnotation is finished",[EMessage.LowerLimitPoint]:"\u5DF2\u5230\u8FBE\u6807\u70B9\u6570\u91CF\u4E0A\u9650",[EMessage.NoRotateInDependence]:"Disallow rotation in dependent cases"},message={[EMessage.NoRotateNotice]:"\u672C\u56FE\u542B\u6709\u6570\u636E\uFF0C\u65E0\u6CD5\u8FDB\u884C\u65CB\u8F6C",[EMessage.RectErrorSizeNotice]:"\u7ED8\u5236\u6846\u5C3A\u5BF8\u5C0F\u4E8E\u6700\u5C0F\u7ED8\u5236\u5C3A\u5BF8",[EMessage.TextCheckNumberErrorNotice]:"\u8BF7\u6309\u4EC5\u6570\u5B57\u7684\u683C\u5F0F\u8F93\u5165",[EMessage.TextCheckEnglishErrorNotice]:"\u8BF7\u6309\u4EC5\u82F1\u6587\u7684\u683C\u5F0F\u8F93\u5165",[EMessage.TextCheckCustomErrorNotice]:"\u8BF7\u6309\u8981\u6C42\u7684\u683C\u5F0F\u8F93\u5165",[EMessage.UpperLimitErrorNotice]:"\u9876\u70B9\u6570\u4E0D\u591A\u4E8E",[EMessage.LowerLimitErrorNotice]:"\u9876\u70B9\u6570\u4E0D\u5C11\u4E8E",[EMessage.InvalidImage]:"\u65E0\u6548\u56FE\u7247\uFF0C\u8BF7\u8DF3\u8FC7\u6B64\u56FE",[EMessage.DisableDelete]:"\u8BE5\u6570\u636E\u7981\u6B62\u5220\u9664",[EMessage.ClearPartialData]:"\u5B58\u5728\u90E8\u5206\u6570\u636E\u65E0\u6CD5\u6E05\u9664",[EMessage.MarkerFinish]:"\u5217\u8868\u6807\u6CE8\u5DF2\u5B8C\u6210",[EMessage.LowerLimitPoint]:"\u5DF2\u5230\u8FBE\u6807\u70B9\u6570\u91CF\u4E0A\u9650",[EMessage.NoRotateInDependence]:"\u4F9D\u8D56\u60C5\u51B5\u4E0B\u65E0\u6CD5\u8FDB\u884C\u65CB\u8F6C"};class Locale{}Locale.getMessagesByLocale=(r,t)=>{switch(t){case ELang.US:return message$1[r];case ELang.Zh:default:return message[r]}};var __defProp$b=Object.defineProperty,__defProps$a=Object.defineProperties,__getOwnPropDescs$a=Object.getOwnPropertyDescriptors,__getOwnPropSymbols$b=Object.getOwnPropertySymbols,__hasOwnProp$b=Object.prototype.hasOwnProperty,__propIsEnum$b=Object.prototype.propertyIsEnumerable,__defNormalProp$b=(r,t,e)=>t in r?__defProp$b(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,__spreadValues$b=(r,t)=>{for(var e in t||(t={}))__hasOwnProp$b.call(t,e)&&__defNormalProp$b(r,e,t[e]);if(__getOwnPropSymbols$b)for(var e of __getOwnPropSymbols$b(t))__propIsEnum$b.call(t,e)&&__defNormalProp$b(r,e,t[e]);return r},__spreadProps$a=(r,t)=>__defProps$a(r,__getOwnPropDescs$a(t));const REGEXP_NUMBER="^[0-9]+$",REGEXP_ENGLISH="^[A-Za-z]+$";class AttributeUtils{static getAttributeIcon(t,e,i=!0){var s;const n=e.findIndex(l=>l.value===t);let o=(s=ICON_ARRAY[n%ICON_ARRAY.length])!=null?s:NULL_ICON;i||(o=INVALID_ICON),o="";const a=new Image;return a.src=o,a}static checkString(t,e){let i="";switch(t){case ETextType.Order:case ETextType.NumberOnly:i=REGEXP_NUMBER;break;case ETextType.EnglishOnly:i=REGEXP_ENGLISH;break;case ETextType.CustomFormat:i=e;break}return i}static checkTextAttibute(t,e){if(t===void 0||t==="")return!0;try{return new RegExp(e).test(t)}catch(i){return!1}}static getAttributeShowText(t,e=[]){var i,s;try{const n=e.findIndex(o=>o.value===t);return(s=(i=e[n])==null?void 0:i.key)!=null?s:t}catch(n){return t}}static getAttributeIndex(t,e){try{const i=e.findIndex(s=>s.value===t);return i>=8?i%8:i}catch(i){return-1}}static getAttributeColor(t,e){try{const i=this.getAttributeIndex(t,e);return i===-1?NULL_COLOR:COLORS_ARRAY[i%COLORS_ARRAY.length]}catch(i){return NULL_COLOR}}static getTextAttribute(t,e){try{if(e===ETextType.Order){const i=t.map(n=>parseInt(n.textAttribute,10)).filter(n=>_.isNumber(n)&&n<Number.MAX_SAFE_INTEGER&&n>=0);return i.sort((n,o)=>n-o),`${(i.pop()||0)+1}`}return""}catch(i){return""}}static textChange(t,e,i){return i.map(s=>s.id===e?__spreadProps$a(__spreadValues$b({},s),{textAttribute:t}):s)}static getErrorNotice(t,e){switch(t){case ETextType.Order:case ETextType.NumberOnly:return Locale.getMessagesByLocale(EMessage.TextCheckNumberErrorNotice,e);case ETextType.EnglishOnly:return Locale.getMessagesByLocale(EMessage.TextCheckEnglishErrorNotice,e);case ETextType.CustomFormat:return Locale.getMessagesByLocale(EMessage.TextCheckCustomErrorNotice,e);default:return""}}static textAttributeValidate(t,e,i){try{return new RegExp(this.checkString(t,e)).test(i)}catch(s){}}static checkTextAttribute(t,e,i,s){let n=!1;return i.forEach(o=>{(o==null?void 0:o.textAttribute)===void 0||(o==null?void 0:o.textAttribute)===""||(s?o.id===s:!0)&&!this.textAttributeValidate(t,e,o.textAttribute)&&(n=!0)}),!!n}static changeTextAttributeInLog(t,e){return t==null?void 0:t.map(i=>i==null?void 0:i.map(s=>{if((e==null?void 0:e.findIndex(n=>(n==null?void 0:n.id)===(s==null?void 0:s.id)))>-1){const n=e==null?void 0:e.find(o=>(o==null?void 0:o.id)===(s==null?void 0:s.id));return __spreadProps$a(__spreadValues$b({},s),{textAttribute:n==null?void 0:n.textAttribute})}return s}))}static getTextIconSvg(t="",e,i=!1,s){if(i===!0){const n=(e==null?void 0:e.findIndex(o=>(o==null?void 0:o.value)===t))%COLORS_ARRAY.length+1;return ICON_ARRAY[n]}return s}static getAttributeByKeycode(t,e){var i;let s;return MathUtils.isInRange(t,[48,57])&&(s=t-48),MathUtils.isInRange(t,[96,105])&&(s=t-96),s===0?"":s?(i=e[s-1])==null?void 0:i.value:void 0}}class UnitUtils{static deg2rad(t){return t*Math.PI/180}static rad2deg(t){return t*180/Math.PI}}const DEFAULT_ZOOM=1,DEFAULT_CURRENT_POS={x:0,y:0},DEFAULT_ROTATE=0,DEFAULT_COLOR="";class DrawUtils{static drawLine(t,e,i,s={}){const n=t.getContext("2d"),{color:o=DEFAULT_COLOR,thickness:a=1,lineCap:l="round"}=s;n.save(),n.strokeStyle=o,n.lineWidth=a,n.lineCap=l,n.beginPath(),n.moveTo(e.x,e.y),n.lineTo(i.x+1,i.y+1),n.stroke(),n.restore()}static drawRect(t,e,i={}){const s=t.getContext("2d"),{color:n=DEFAULT_COLOR,thickness:o=1,lineCap:a="round"}=i;s.save(),s.strokeStyle=n,s.lineWidth=o,s.lineCap=a,s.beginPath(),s.fillStyle=n,s.strokeRect(e.x,e.y,e.width,e.height);let l="";if(e.attribute&&(l=`${l} ${e.attribute}`),this.drawText(t,{x:e.x,y:e.y-5},l),e.textAttribute){const d=`${~~e.width} * ${~~e.height}`.length*7,u=0,c=Math.max(20,e.width-d);this.drawText(t,{x:e.x,y:e.y+e.height+20+u},e.textAttribute,{textMaxWidth:c})}s.restore()}static drawRectWithFill(t,e,i={}){const s=t.getContext("2d"),{color:n=DEFAULT_COLOR}=i;s.save(),s.beginPath(),s.fillStyle=n,s.fillRect(e.x,e.y,e.width,e.height),s.restore()}static drawTag(t,e){var i;const s=t==null?void 0:t.parentNode,n=window==null?void 0:window.self.document.getElementById("tagToolTag");if(n&&s&&s.contains(n)&&(s==null||s.removeChild(n)),!((e==null?void 0:e.length)>0))return;const o=document.createElement("div");o.innerHTML=(i=e.reduce((a,l)=>`${a}${l.keyName}: ${l.value.join(" \u3001 ")}
|
|
6
|
+
`,""))!=null?i:"",o.setAttribute("id","tagToolTag"),s==null||s.appendChild(o)}static drawLineWithPointList(t,e,i={}){if(e.length<2)return;const s=t.getContext("2d"),{color:n=DEFAULT_COLOR,thickness:o=1,lineCap:a="round",lineType:l=ELineTypes.Line,hoverEdgeIndex:h}=i;s.save(),s.strokeStyle=n,s.lineWidth=o,s.lineCap=a,s.beginPath(),l===ELineTypes.Curve?(h!==void 0&&h>-1&&e.push(e[0]),e=PolygonUtils.createSmoothCurvePointsFromPointList([...e],SEGMENT_NUMBER$2),h!==void 0&&h>-1&&(e=e.slice((SEGMENT_NUMBER$2+1)*h,(SEGMENT_NUMBER$2+1)*(h+1)))):h!==void 0&&h>-1&&(e=[...e,e[0]],e=e.slice(h,h+2));const[d,...u]=e;s.moveTo(d.x,d.y),u.forEach(c=>{s.lineTo(c.x,c.y)}),s.stroke(),s.restore()}static drawCircle(t,e,i,s={}){const n=t.getContext("2d"),{startAngleDeg:o=0,endAngleDeg:a=360,thickness:l=1,color:h=DEFAULT_COLOR,fill:d=DEFAULT_COLOR}=s,u=UnitUtils.deg2rad(o),c=UnitUtils.deg2rad(a);n.save(),n.beginPath(),n.strokeStyle=h,n.fillStyle=d,n.lineWidth=l,n.arc(e.x,e.y,i,u,c,!1),n.stroke(),n.fill(),n.closePath(),n.restore()}static drawCircleWithFill(t,e,i=3,s={}){const n=t.getContext("2d"),{color:o=DEFAULT_COLOR}=s;n.save();const a=UnitUtils.deg2rad(0),l=UnitUtils.deg2rad(360);n.fillStyle=o,n.beginPath(),n.arc(e.x,e.y,i,a,l,!1),n.fill(),n.restore()}static drawPolygon(t,e,i={}){const{isClose:s=!1,lineType:n=ELineTypes.Line}=i;s===!0&&(e=[...e,e[0]]),n===ELineTypes.Curve&&(e=PolygonUtils.createSmoothCurvePointsFromPointList([...e])),this.drawLineWithPointList(t,e,i)}static drawPolygonWithFill(t,e,i={}){if(e.length<2)return;const s=t.getContext("2d"),{color:n=DEFAULT_COLOR,lineType:o=ELineTypes.Line}=i;s.save(),s.fillStyle=n,s.beginPath(),o===ELineTypes.Curve&&(e=PolygonUtils.createSmoothCurvePointsFromPointList([...e,e[0]]));const[a,...l]=e;s.moveTo(a.x,a.y),l.forEach(h=>{s.lineTo(h.x,h.y)}),s.fill(),s.restore()}static drawPolygonWithFillAndLine(t,e,i={}){const{strokeColor:s,fillColor:n,thickness:o,lineCap:a,isClose:l,lineType:h}=i;this.drawPolygon(t,e,{color:s,thickness:o,lineCap:a,isClose:l,lineType:h}),this.drawPolygonWithFill(t,e,{color:n,lineType:h})}static drawSelectedPolygonWithFillAndLine(t,e,i={}){const{pointColor:s="white",strokeColor:n}=i;this.drawPolygonWithFillAndLine(t,e,i),[...e].forEach(a=>{this.drawCircleWithFill(t,a,4,{color:n}),this.drawCircleWithFill(t,a,3,{color:s})})}static drawText(t,e,i,s={}){if(!i)return;const n=t.getContext("2d"),{color:o=DEFAULT_COLOR,font:a="normal normal 500 14px Arial",shadowColor:l="",shadowBlur:h=0,shadowOffsetX:d=0,shadowOffsetY:u=0,textMaxWidth:c=164,offsetX:g=0,offsetY:f=0,textAlign:v="start"}=s;n.save(),n.textAlign=v,n.fillStyle=o!=null?o:"white",n.font=a,n.shadowColor=l,n.shadowOffsetX=d,n.shadowOffsetY=u,n.shadowBlur=h,this.wrapText(t,`${i}`,e.x+g,e.y+f,c),n.restore()}static wrapText(t,e,i,s,n,o){var a,l;if(typeof e!="string"||typeof i!="number"||typeof s!="number")return;const h=t.getContext("2d");typeof n=="undefined"&&(n=t&&t.width||300),typeof o=="undefined"&&(o=((a=t&&parseInt(window==null?void 0:window.getComputedStyle(t).lineHeight,10))!=null?a:0)||parseInt((l=window==null?void 0:window.getComputedStyle(document.body).lineHeight)!=null?l:0,10));const d=e.split(`
|
|
7
|
+
`);for(let u=0;u<d.length;u++){const c=d[u].split("");let g="";for(let f=0;f<c.length;f++){const v=g+c[f],b=h.measureText(v).width;n||(n=300),b>n&&f>0?(h.fillText(g,i,s),g=c[f],s+=o):g=v}h.fillText(g,i,s),s+=o}}static drawArrow(t,e,i,s={}){const{color:n=DEFAULT_COLOR,thickness:o=1,lineCap:a="round",theta:l=30,headLen:h=10}=s,d=Math.atan2(e.y-i.y,e.x-i.x)*180/Math.PI,u=(d+l)*Math.PI/180,c=(d-l)*Math.PI/180,g=h*Math.cos(u),f=h*Math.sin(u),v=h*Math.cos(c),p=h*Math.sin(c);t.save(),t.strokeStyle=n,t.lineWidth=o,t.lineCap=a,t.beginPath(),t.moveTo(i.x+g,i.y+f),t.lineTo(i.x,i.y),t.lineTo(i.x+v,i.y+p),t.stroke(),t.restore()}}DrawUtils.drawImg=(r,t,e={})=>{const i=r.getContext("2d"),{zoom:s=DEFAULT_ZOOM,currentPos:n=DEFAULT_CURRENT_POS,rotate:o=DEFAULT_ROTATE,imgAttribute:a}=e;switch(i.save(),o){case 0:i.translate(n.x,n.y);break;case 90:i.translate(n.x+t.height*s,n.y),i.rotate(90*Math.PI/180);break;case 180:i.translate(n.x+t.width*s,n.y+t.height*s),i.rotate(Math.PI);break;case 270:i.translate(n.x,n.y+t.width*s),i.rotate(270*Math.PI/180);break;default:i.translate(n.x,n.y);break}if(a){const{contrast:l,saturation:h,brightness:d}=a;i.filter=`saturate(${h+100}%) contrast(${l+100}%) brightness(${d+100}%)`}i.drawImage(t,0,0,t.width*s,t.height*s),i.restore()};class StyleUtils{static getStrokeAndFill(t,e=!0,i={}){const{isSelected:s=!1,isHover:n=!1}=i;return s?{stroke:e?t.validSelected.stroke:t.invalidSelected.stroke,fill:e?t.validSelected.fill:t.invalidSelected.fill}:n?{stroke:e?t.validHover.stroke:t.invalidHover.stroke,fill:e?t.validHover.fill:t.invalidHover.fill}:{stroke:e?t.valid.stroke:t.invalid.stroke,fill:e?t.valid.fill:t.invalid.fill}}}var EKeyCode;(function(r){r[r.A=65]="A",r[r.B=66]="B",r[r.C=67]="C",r[r.D=68]="D",r[r.E=69]="E",r[r.F=70]="F",r[r.G=71]="G",r[r.H=72]="H",r[r.L=76]="L",r[r.R=82]="R",r[r.Z=90]="Z",r[r.W=87]="W",r[r.X=88]="X",r[r.Y=89]="Y",r[r.S=83]="S",r[r.Q=81]="Q",r[r.Delete=46]="Delete",r[r.F11=122]="F11",r[r.Space=32]="Space",r[r.Esc=27]="Esc",r[r.Left=37]="Left",r[r.Up=38]="Up",r[r.Right=39]="Right",r[r.Down=40]="Down",r[r.Enter=13]="Enter",r[r.Ctrl=17]="Ctrl",r[r.Alt=18]="Alt",r[r.Shift=16]="Shift",r[r.Tab=9]="Tab"})(EKeyCode||(EKeyCode={}));var EKeyCode$1=EKeyCode,keyCode=Object.freeze({__proto__:null,default:EKeyCode$1});class ActionsHistory{constructor(t){this.record=[],this.recordIndex=-1,this.minRecordIndex=-1,this.emitHistoryChanged=()=>{this.historyChanged&&(this.constructor.name==="ActionsHistory"?!0:this.record.length>0)&&this.historyChanged(this.undoEnabled,this.redoEnabled)},this.historyChanged=t}get undoEnabled(){return this.recordIndex>this.minRecordIndex}get redoEnabled(){return this.recordIndex<this.record.length-1}pushHistory(t){if(this.recordIndex!==this.record.length-1){const e=this.record.slice(0,Math.min(this.recordIndex+1,this.record.length));this.record=e}this.record.push(___default.default.cloneDeepWith(t)),this.recordIndex+=1,this.emitHistoryChanged()}updateHistory(t){this.record[this.recordIndex]=___default.default.cloneDeep(t)}applyAttribute(t,e,i){t&&this.record.forEach(s=>{const n=s.find(o=>o.id===t);n&&(n[e]=i)})}undo(){if(this.undoEnabled)return this.recordIndex-=1,this.emitHistoryChanged(),___default.default.cloneDeep(this.record[this.recordIndex])||[]}redo(){if(this.redoEnabled)return this.recordIndex+=1,this.emitHistoryChanged(),___default.default.cloneDeep(this.record[this.recordIndex])}init(){this.record=[[]],this.recordIndex=0,this.emitHistoryChanged()}empty(){this.record=[],this.recordIndex=-1,this.emitHistoryChanged()}initRecord(t,e=!1){const i=t.length>0||e;this.record=i?[___default.default.cloneDeep(t)]:[],this.minRecordIndex=i?0:-1,this.recordIndex=0}}class DblClickEventListener{constructor(t,e){this.rcTime=0,this.mouseDownTime=0,this.onMouseDown=()=>{this.mouseDownTime=new Date().getTime()},this.dom=t,this.isDoubleClick=!1,this.delay=e}getRcTime(){return this.rcTime}getCoord(t){return{x:t.clientX,y:t.clientY}}removeEvent(){!this.dom||(this.dom.removeEventListener("mouseup",this.mouseUp),this.dom.removeEventListener("mousemove",this.mouseMove),this.dom.removeEventListener("dblclick",this.dblclick),this.dom.removeEventListener("mousedown",this.onMouseDown))}addEvent(t,e,i,s){!this.dom||(this.removeEvent(),this.mouseUp=n=>{const o=new Date().getTime(),a=s?s(n):!0;if(o-this.mouseDownTime>this.delay||a!==!0){t(n);return}if(n.button===2)if(this.rcTime===0)setTimeout(()=>{this.rcTime=0},this.delay),this.rcTime=o;else{o-this.rcTime<this.delay&&(i(n),clearTimeout(this.setTimeFun),this.cacheFunction=void 0),this.rcTime=0;return}this.setTimeFun&&clearTimeout(this.setTimeFun),this.clickCoord=this.getCoord(n),this.cacheFunction=()=>t(n),this.setTimeFun=setTimeout(()=>{if(this.isDoubleClick){this.isDoubleClick=!1;return}this.cacheFunction(),this.clickCoord=void 0},this.delay)},this.mouseMove=n=>{const o=this.getCoord(n);this.clickCoord&&!AxisUtils.getIsInScope(o,this.clickCoord,10)&&(this.cacheFunction&&this.cacheFunction(),this.clickCoord=void 0,this.cacheFunction=null,clearTimeout(this.setTimeFun))},this.dblclick=n=>{this.isDoubleClick=!0,this.clickCoord=void 0,e(n)},this.dom.addEventListener("mouseup",this.mouseUp),this.dom.addEventListener("mousemove",this.mouseMove),this.dom.addEventListener("dblclick",this.dblclick),this.dom.addEventListener("mousedown",this.onMouseDown))}clearRightDblClick(){this.rcTime=0}}class ImgPosUtils{static getInitImgPos(t,e,i=0,s=1,n=!1){(i===90||i===270)&&(e={width:e.height,height:e.width});const o=t.width*s/e.width,a=t.height*s/e.height;let l=n?1:Math.min(o,a);const h={x:(t.width-e.width*l)/2,y:(t.height-e.height*l)/2},d=e.width*l,u=e.height*l;return n&&(l=1),{zoom:l,currentPos:h,imgInfo:{width:d,height:u}}}static getBasicRecPos(t,e,i,s=.9,n=1,o=!1){if(e&&t){const{x:a,y:l,height:h,width:d}=e;let u=i.height/h;d/h>i.width/i.height&&(u=i.width/d);const c=o?1:u*s*n,g={x:i.width/2,y:i.height/2},f={x:(a+d/2)*c,y:(l+h/2)*c};return{currentPos:{x:g.x-f.x,y:g.y-f.y},innerZoom:c}}return!1}}class RenderDomUtils{static renderInvalidPage(t,e,i){const s=document.createElement("div");return s.setAttribute("style",`
|
|
8
8
|
position: absolute;
|
|
9
9
|
left: 0px;
|
|
10
10
|
top: 0px;
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
font-size: 30px;
|
|
20
20
|
opacity: 0.7;
|
|
21
21
|
z-index: 30;
|
|
22
|
-
`),s.innerHTML=Locale.getMessagesByLocale(EMessage.InvalidImage,i),e.appendChild(s),s}}const ZOOM_LEVEL=[1,5,10,20,30,50,80,100].concat(Array.from({length:9}).map((r,t)=>(t+2)*100));class ZoomUtils{}ZoomUtils.zoomChanged=(r,t,e=EGrowthMode.Linear)=>{switch(e){case EGrowthMode.Intelligence:{const i=Math.max(...ZOOM_LEVEL),s=Math.min(...ZOOM_LEVEL),n=ZOOM_LEVEL.slice(0,ZOOM_LEVEL.length).findIndex((a,l)=>r>=a&&(r<ZOOM_LEVEL[l+1]||a===i));let o;if(n===-1)r>=s&&r<=i?o=t?i:s:o=t?s:r;else{const a=t?n+1:n-(ZOOM_LEVEL.includes(r)?1:0);o=ZOOM_LEVEL[MathUtils.withinRange(a,[0,ZOOM_LEVEL.length-1])]}return o}default:{const i=t?2:1/2;return r*i}}},ZoomUtils.wheelChangePos=(r,t,e,i,s={})=>{const{zoom:n=1,innerZoom:o=1,basicZoom:a=1,zoomMax:l=1e3,rotate:h=0}=s,{x:d,y:u}=i,c=parseFloat((n+1/10).toFixed(1))/5;if(r&&t){let{width:g,height:f}=r;[90,270].includes(h)&&(g=r.height,f=r.width);const v=g*o,p=f*o,b=t.x-d,x=t.y-u,y=b/v,I=x/p;let m=n+e*c;m=MathUtils.withinRange(m,[a,l]);const L=g*m*y,w=f*m*I,C=d+(b-L),P=u+(x-w);return{zoom:m,currentPos:{x:C,y:P},imgInfo:{width:g*m,height:f*m},ratio:c}}return null};class EventListener{constructor(){this._events=new Map}on(t,e){const i=this._events.get(t)||[];i.some(s=>s===e)||this._events.set(t,i.concat(e))}singleOn(t,e){this._events.set(t,[e])}emit(t,...e){const i=this._events.get(t);i&&i.forEach(s=>{s&&s(...e)})}unbind(t,e){const i=this._events.get(t);i&&this._events.set(t,i.filter(s=>s!==e))}unbindAll(t){this._events.delete(t)}}const rectToolConfig={showConfirm:!1,skipWhileNoDependencies:!1,drawOutsideTarget:!1,copyBackwardResult:!1,minWidth:1,minHeight:1,isShowOrder:!1,filterData:["valid","invalid"],attributeConfigurable:!1,attributeList:[],textConfigurable:!1,textCheckType:0,customFormat:""},tagToolConfig={showConfirm:!1,skipWhileNoDependencies:!1,inputList:[{key:"\u7C7B\u522B1",value:"class1",isMulti:!1,subSelected:[{key:"\u9009\u98791",value:"option1",isDefault:!1},{key:"\u9009\u98792",value:"option1-2",isDefault:!1}]},{key:"\u7C7B\u522B2",value:"class-AH",isMulti:!0,subSelected:[{key:"\u9009\u98792-1",value:"option2-1",isDefault:!1},{key:"\u9009\u98792-2",value:"option2-2",isDefault:!1},{key:"\u9009\u98792-3",value:"option2-3",isDefault:!1}]},{key:"\u7C7B\u522B3",value:"class-0P",isMulti:!1,subSelected:[{key:"\u9009\u98793-1",value:"option3-1",isMulti:!1},{key:"\u9009\u98793-2",value:"option3-2",isDefault:!1},{key:"\u9009\u98793-3",value:"option3-3",isDefault:!1}]}]},lineToolConfig={lineType:0,lineColor:0,edgeAdsorption:!1,outOfTarget:!0,copyBackwardResult:!1,isShowOrder:!1,attributeConfigurable:!1,attributeList:[{key:"\u7C7B\u522B1",value:"\u7C7B\u522B1"},{key:"\u7C7B\u522Bao",value:"class-ao"},{key:"\u7C7B\u522BM1",value:"class-M1"},{key:"\u7C7B\u522BCm",value:"class-Cm"},{key:"\u7C7B\u522Bc3",value:"class-c3"},{key:"\u7C7B\u522Ba0",value:"class-a0"},{key:"\u7C7B\u522Bu7",value:"class-u7"},{key:"\u7C7B\u522BZb",value:"class-Zb"},{key:"\u7C7B\u522Bzi",value:"class-zi"}],textConfigurable:!1,textCheckType:2,customFormat:"",showConfirm:!1,lowerLimitPointNum:2,upperLimitPointNum:"",preReferenceStep:0,skipWhileNoDependencies:!1,filterData:["valid","invalid"]},textToolConfig={showConfirm:!1,skipWhileNoDependencies:!1,enableTextRecognition:!1,recognitionMode:"general",configList:[{label:"\u6587\u672C",key:"text",required:!1,default:"",maxLength:1e3}],filterData:["valid","invalid"]},polygonConfig={lineType:0,lineColor:0,lowerLimitPointNum:3,edgeAdsorption:!1,drawOutsideTarget:!1,copyBackwardResult:!1,isShowOrder:!1,attributeConfigurable:!1,attributeList:[],textConfigurable:!0,textCheckType:0,customFormat:""},getConfig=r=>r==="lineTool"?lineToolConfig:r==="rectTool"?rectToolConfig:r==="tagTool"?tagToolConfig:r==="textTool"?textToolConfig:r==="polygonTool"?polygonConfig:rectToolConfig,styleDefaultConfig={toolColor:{1:{valid:{stroke:"rgba(0,0,255,0.50)",fill:"rgba(0,0,255,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.80)"},validSelected:{stroke:"rgba(0,15,255,1.00)",fill:"rgba(0,15,255,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,0.60)",fill:"rgba(255,0,0,0.24)"},validHover:{stroke:"rgba(0,15,255,0.80)",fill:"rgba(0,15,255,0.64)"},invalidHover:{stroke:"rgba(255,0,0,0.50)",fill:"rgba(255,0,0,0.40)"}},3:{valid:{stroke:"rgba(0,255,255,0.50)",fill:"rgba(0,255,255,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.80)"},validSelected:{stroke:"rgba(0,212,255,1.00)",fill:"rgba(0,212,255,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,0.60)",fill:"rgba(255,0,0,0.24)"},validHover:{stroke:"rgba(0,212,255,0.80)",fill:"rgba(0,212,255,0.64)"},invalidHover:{stroke:"rgba(255,0,0,0.50)",fill:"rgba(255,0,0,0.40)"}},5:{valid:{stroke:"rgba(0,255,0,0.50)",fill:"rgba(0,255,0,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.80)"},validSelected:{stroke:"rgba(149,255,1.00)",fill:"rgba(149,255,0,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,0.60)",fill:"rgba(255,0,0,0.24)"},validHover:{stroke:"rgba(149,255,0,0.80)",fill:"rgba(149,255,0,0.64)"},invalidHover:{stroke:"rgba(255,0,0,0.50)",fill:"rgba(255,0,0,0.40)"}},7:{valid:{stroke:"rgba(255,255,0,0.50)",fill:"rgba(255,255,0,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.80)"},validSelected:{stroke:"rgba(255,230,102,1.00)",fill:"rgba(255,213,0,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,0.60)",fill:"rgba(255,0,0,0.24)"},validHover:{stroke:"rgba(255,230,102,0.80)",fill:"rgba(255,230,102,0.64)"},invalidHover:{stroke:"rgba(255,0,0,0.50)",fill:"rgba(255,0,0,0.40)"}},9:{valid:{stroke:"rgba(255,0,255,0.50)",fill:"rgba(255,0,255,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.80)"},validSelected:{stroke:"rgba(230,102,255,1.00)",fill:"rgba(213,0,255,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,0.60)",fill:"rgba(255,0,0,0.24)"},validHover:{stroke:"rgba(230,102,255,0.80)",fill:"rgba(230,102,255,0.64)"},invalidHover:{stroke:"rgba(255,0,0,0.50)",fill:"rgba(255,0,0,0.40)"}}},attributeColor:[{valid:{stroke:"rgba(204,204,204,1.00)",fill:"rgba(204,204,204,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(204,204,204,1.00)",fill:"rgba(204,204,204,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(204,204,204,1.00)",fill:"rgba(204,204,204,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(153,51,255,1.00)",fill:"rgba(153,51,255,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(153,51,255,1.00)",fill:"rgba(153,51,255,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(153,51,255,1.00)",fill:"rgba(153,51,255,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(51,254,51,1.00)",fill:"rgba(51,254,51,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(51,254,51,1.00)",fill:"rgba(51,254,51,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(51,254,51,1.00)",fill:"rgba(51,254,51,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(255,51,255,1.00)",fill:"rgba(255,51,255,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(255,51,255,1.00)",fill:"rgba(255,51,255,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(255,51,255,1.00)",fill:"rgba(255,51,255,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(204,255,51,1.00)",fill:"rgba(204,255,51,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(204,255,51,1.00)",fill:"rgba(204,255,51,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(204,255,51,1.00)",fill:"rgba(204,255,51,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(51,153,255,1.00)",fill:"rgba(51,153,255,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(51,153,255,1.00)",fill:"rgba(51,153,255,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(51,153,255,1.00)",fill:"rgba(51,153,255,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(255,153,51,1.00)",fill:"rgba(255,153,51,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(255,153,51,1.00)",fill:"rgba(255,153,51,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(255,153,51,1.00)",fill:"rgba(255,153,51,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(51,255,238,1.00)",fill:"rgba(51,255,238,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(51,255,238,1.00)",fill:"rgba(51,255,238,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(51,255,238,1.00)",fill:"rgba(51,255,238,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(255,221,51,1.00)",fill:"rgba(255,221,51,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(255,221,51,1.00)",fill:"rgba(255,221,51,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(255,221,51,1.00)",fill:"rgba(255,221,51,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}}],lineColor:{1:"rgba(102, 111, 255, 1 )",3:"rgba(102, 230, 255, 1)",5:"rgba(191, 255, 102, 1)",7:"rgba(255, 230, 102, 1)",9:"rgba(230, 102, 255, 1)"},attributeLineColor:["rgba(204, 204, 204, 1)","rgba(153, 51, 255, 1)","rgba(51, 254, 51, 1)","rgba(255, 51, 255, 1)","rgba(204, 255, 51, 1)","rgba(51, 153, 255, 1)","rgba(255, 153, 51, 1)","rgba(51, 255, 238, 1)","rgba(255, 221, 51, 1)"],color:1,width:2,opacity:9};var __defProp$a=Object.defineProperty,__defProps$9=Object.defineProperties,__getOwnPropDescs$9=Object.getOwnPropertyDescriptors,__getOwnPropSymbols$a=Object.getOwnPropertySymbols,__hasOwnProp$a=Object.prototype.hasOwnProperty,__propIsEnum$a=Object.prototype.propertyIsEnumerable,__defNormalProp$a=(r,t,e)=>t in r?__defProp$a(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,__spreadValues$a=(r,t)=>{for(var e in t||(t={}))__hasOwnProp$a.call(t,e)&&__defNormalProp$a(r,e,t[e]);if(__getOwnPropSymbols$a)for(var e of __getOwnPropSymbols$a(t))__propIsEnum$a.call(t,e)&&__defNormalProp$a(r,e,t[e]);return r},__spreadProps$9=(r,t)=>__defProps$9(r,__getOwnPropDescs$9(t)),EStatus$1;(function(r){r[r.Create=0]="Create",r[r.Active=1]="Active",r[r.Edit=1]="Edit",r[r.None=2]="None"})(EStatus$1||(EStatus$1={}));var EColor;(function(r){r.ActiveArea="#B3B8FF"})(EColor||(EColor={}));const SEGMENT_NUMBER$1=16,POINT_RADIUS$1=3,_LineToolUtils=class{static isInLine(r,t,e,i=3){const{length:s}=MathUtils.getFootOfPerpendicular(r,t,e);return s<i}};let LineToolUtils=_LineToolUtils;LineToolUtils.setSpecialEdgeStyle=r=>{r.lineCap="butt",r.setLineDash([10,10])},LineToolUtils.setReferenceCtx=r=>{r.lineCap="butt",r.setLineDash([6])},LineToolUtils.calcOptimalIntersection=(r,t,e,i,s)=>{let n,o=Infinity,a;if(r.find((h,d)=>{if(d===0)return;const u=_LineToolUtils.isInLine(t.pointA,h,r[d-1]),c=_LineToolUtils.isInLine(t.pointB,h,r[d-1]);return u&&c}))return{point:e};if(r.forEach((h,d)=>{if(d===0)return;const u={pointA:r[d-1],pointB:h},c=_LineToolUtils.lineIntersection(t,u);if(c&&t){const{onLine2:g,onLine1:f,x:v,y:p}=c,b=_LineToolUtils.calcDistance(e,c);if(_LineToolUtils.isOnLine(t.pointB.x,t.pointB.y,h.x,h.y,r[d-1].x,r[d-1].y)){if(_LineToolUtils.calcDistance(e,c)<i/s){const I=t.pointB,{footPoint:m,length:L}=MathUtils.getFootOfPerpendicular(I,u.pointA,u.pointB,!0);if(L!==void 0){const w=_LineToolUtils.calcDistance(u.pointA,m),C=_LineToolUtils.calcDistance(u.pointB,m);a={point:m,minDistance:L},L===Infinity&&(a.point=w>C?u.pointB:u.pointA)}}return}b<o&&g&&f&&(o=b,n={x:v,y:p})}}),n)return{point:n,minDistance:o};if(a)return a},LineToolUtils.lineIntersection=(r,t)=>{let e=!1,i=!1;const s=_LineToolUtils.getAxisDiff(r),n=_LineToolUtils.getAxisDiff(t),o=n.y*s.x-n.x*s.y;if(o===0)return!1;let a=r.pointA.y-t.pointA.y,l=r.pointA.x-t.pointA.x;const h=(t.pointB.x-t.pointA.x)*a-(t.pointB.y-t.pointA.y)*l,d=(r.pointB.x-r.pointA.x)*a-(r.pointB.y-r.pointA.y)*l;a=h/o,l=d/o,a>0&&a<1&&(e=!0),l>0&&l<1&&(i=!0);const u=r.pointA.x+a*(r.pointB.x-r.pointA.x),c=r.pointA.y+a*(r.pointB.y-r.pointA.y);return{x:u,y:c,onLine1:e,onLine2:i}},LineToolUtils.getAxisDiff=r=>({x:r.pointB.x-r.pointA.x,y:r.pointB.y-r.pointA.y}),LineToolUtils.calcDistance=(r,t)=>Math.sqrt(Math.pow(Math.abs(r.x-t.x),2)+Math.pow(Math.abs(r.y-t.y),2)),LineToolUtils.drawCurveLine=(r,t,e,i=!0,s=!1,n)=>{const o=createSmoothCurvePointsFromPointList(t,SEGMENT_NUMBER$1);r.save(),r.lineCap="round",r.lineJoin="round",r.strokeStyle=e.color,i&&(r.lineWidth=e.lineWidth),s&&_LineToolUtils.setReferenceCtx(r),t.forEach((a,l)=>{const h=a==null?void 0:a.specialEdge,d=o.splice(0,SEGMENT_NUMBER$1+1);r.save(),r.beginPath(),n===l&&(r.lineWidth=4),d.forEach(({x:u,y:c},g)=>{const f=g>0?"lineTo":"moveTo";h&&_LineToolUtils.setSpecialEdgeStyle(r),r[f](u,c)}),r.stroke(),r.restore()}),r.restore()},LineToolUtils.calcTwoPointDistance=(r,t)=>Math.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2)),LineToolUtils.pointOverTarget=(r,t,e,i,s,n,o,a,l,h)=>{const d=r;if(!t)return r;if(e===EToolName.Polygon){const u=_LineToolUtils.getPolygonPointList(i,s);if(u.length===0||PolygonUtils.isInPolygon(r,u))return d;const g=u.concat(u[0]).map(x=>l(x)),f=l(t),v=l(r),p={pointA:f,pointB:v},b=_LineToolUtils.calcOptimalIntersection(g,p,f,o,a);if(b){const x=h(b==null?void 0:b.point);d.x=x.x,d.y=x.y}else return t;return d}if(e===EToolName.Rect){const{x:u,y:c,width:g,height:f}=i;return d.x=MathUtils.withinRange(d.x,[u,u+g]),d.y=MathUtils.withinRange(d.y,[c,c+f]),d}return d.x=MathUtils.withinRange(d.x,[0,n.width]),d.y=MathUtils.withinRange(d.y,[0,n.height]),d},LineToolUtils.getPolygonPointList=(r,t)=>{const{pointList:e}=r,{lineType:i}=t;return i===ELineTypes.Line?e:PolygonUtils.createSmoothCurvePoints(e.reduce((s,n)=>[...s,n.x,n.y],[]),.5,!0,20)},LineToolUtils.isOnLine=(r,t,e,i,s,n)=>Math.abs((a=>(i-t)/(e-r)*(a-r)+t)(s)-n)<1e-6&&s>=r&&s<=e,LineToolUtils.inArea=({top:r,left:t,right:e,bottom:i},{x:s,y:n})=>n>=r&&n<=i&&s>=t&&s<=e,LineToolUtils.getVHPoint=(r,t,e,i)=>{const s=_LineToolUtils.getAngle(r,e);return Math.abs(s)<45?__spreadProps$9(__spreadValues$a({},t),{y:i.y}):__spreadProps$9(__spreadValues$a({},t),{x:i.x})},LineToolUtils.getAngle=(r,t)=>{const e=t.x-r.x,i=t.y-r.y;return 360*Math.atan(i/e)/(2*Math.PI)};var __defProp$9=Object.defineProperty,__defProps$8=Object.defineProperties,__getOwnPropDescs$8=Object.getOwnPropertyDescriptors,__getOwnPropSymbols$9=Object.getOwnPropertySymbols,__hasOwnProp$9=Object.prototype.hasOwnProperty,__propIsEnum$9=Object.prototype.propertyIsEnumerable,__defNormalProp$9=(r,t,e)=>t in r?__defProp$9(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,__spreadValues$9=(r,t)=>{for(var e in t||(t={}))__hasOwnProp$9.call(t,e)&&__defNormalProp$9(r,e,t[e]);if(__getOwnPropSymbols$9)for(var e of __getOwnPropSymbols$9(t))__propIsEnum$9.call(t,e)&&__defNormalProp$9(r,e,t[e]);return r},__spreadProps$8=(r,t)=>__defProps$8(r,__getOwnPropDescs$8(t)),__async$1=(r,t,e)=>new Promise((i,s)=>{var n=l=>{try{a(e.next(l))}catch(h){s(h)}},o=l=>{try{a(e.throw(l))}catch(h){s(h)}},a=l=>l.done?i(l.value):Promise.resolve(l.value).then(n,o);a((e=e.apply(r,t)).next())});const zoomInfo={min:.2,max:1e3,ratio:.4};class BasicToolOperation extends EventListener{constructor(t){super();this.isDrag=!1,this.isSpaceKey=!1,this.innerZoom=1,this.basicZoom=.01,this.isSpaceClick=!1,this.isDragStart=!1,this.startTime=0,this.initImgPos=()=>__async$1(this,null,function*(){var d,u;if(!this.imgNode)return;const c=(d=this._imgAttribute)==null?void 0:d.zoomRatio,g=(u=this._imgAttribute)==null?void 0:u.isOriginalSize,{currentPos:f,imgInfo:v,zoom:p}=ImgPosUtils.getInitImgPos(this.size,{width:this.imgNode.width,height:this.imgNode.height},this.rotate,c,g);this.setCurrentPos(f),this.currentPosStorage=f,this.imgInfo=v,this.setZoom(p),this.innerZoom=p,this.render(),this.renderBasicCanvas(),this.emit("dependRender"),this.emit("renderZoom",p)}),this.getCurrentPos=d=>{const{_firstClickCoordinate:u,currentPosStorage:c}=this;try{let g;return u&&c?g={y:c.y+d.y-u.y,x:c.x+d.x-u.x}:g={x:0,y:0},g}catch(g){return console.error(g),{x:0,y:0}}},this.wheelChangePos=(d,u,c)=>{const{currentPos:g,imgNode:f}=this;if(!f){console.error("unable to load image");return}if(this.zoom===this.basicZoom&&u===-1)return;const v=ZoomUtils.wheelChangePos(f,d,u,g,{zoom:c||this.zoom,innerZoom:this.innerZoom,basicZoom:this.basicZoom,zoomMax:zoomInfo.max,rotate:this.rotate});if(!v)return;const{currentPos:p,ratio:b,zoom:x,imgInfo:y}=v;this.innerZoom=x,this.setZoom(x),this.setCurrentPos(p),this.currentPosStorage=p,this.imgInfo=y,zoomInfo.ratio=b,this.emit("renderZoom",x)},this.zoomChanged=(d,u=EGrowthMode.Linear)=>{const c=ZoomUtils.zoomChanged(this.zoom,d,u);this.wheelChangePos(this.getGetCenterCoordinate(),c>this.zoom?1:-1,c),this.render(),this.renderBasicCanvas()},this.drawImg=()=>{!this.imgNode||DrawUtils.drawImg(this.basicCanvas,this.imgNode,{zoom:this.zoom,currentPos:this.currentPos,rotate:this.rotate,imgAttribute:this._imgAttribute})};var e,i,s,n,o,a,l,h;this.container=t.container,this.showDefaultCursor=t.showDefaultCursor||!1,this.destroyCanvas(),this.createCanvas(t.size),this.imgNode=t.imgNode,this.isImgError=!t.imgNode,this.basicImgInfo={width:(i=(e=t.imgNode)==null?void 0:e.width)!=null?i:0,height:(n=(s=t.imgNode)==null?void 0:s.height)!=null?n:0,valid:!0,rotate:0},this.forbidOperation=(o=t.forbidOperation)!=null?o:!1,this.size=t.size,this.currentPos={x:0,y:0},this.zoom=1,this.coord={x:-1,y:-1},this.currentPosStorage={x:0,y:0},this.isShowCursor=!1,this.style={strokeColor:COLORS_ARRAY[4],fillColor:COLORS_ARRAY[4],strokeWidth:2,opacity:1},this.attributeLockList=[],this.history=new ActionsHistory,this.style=(a=t.style)!=null?a:{},this._imgAttribute=(l=t.imgAttribute)!=null?l:{},this.isHidden=!1,this.dragStatus=EDragStatus.Wait,this.defaultAttribute=(h=t==null?void 0:t.defaultAttribute)!=null?h:"",this.forbidCursorLine=!!t.forbidCursorLine,this.lang=ELang.Zh,this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.onWheel=this.onWheel.bind(this),this.onLeftDblClick=this.onLeftDblClick.bind(this),this.onRightDblClick=this.onRightDblClick.bind(this),this.onClick=this.onClick.bind(this),this.clearImgDrag=this.clearImgDrag.bind(this),this.dblClickListener=new DblClickEventListener(this.container,200),this.coordUtils=new CoordinateUtils(this),this.coordUtils.setBasicImgInfo(this.basicImgInfo)}onContextmenu(t){t.preventDefault()}get ctx(){var t;return this._ctx||((t=this.canvas)==null?void 0:t.getContext("2d"))}get basicCtx(){var t;return(t=this.basicCanvas)==null?void 0:t.getContext("2d")}get rotate(){var t,e;return(e=(t=this.basicImgInfo)==null?void 0:t.rotate)!=null?e:0}get valid(){var t,e;return(e=(t=this.basicImgInfo)==null?void 0:t.valid)!=null?e:!0}get baseIcon(){return BASE_ICON[this.style.color]}get defaultCursor(){return this.showDefaultCursor?"default":"none"}get dataList(){return[]}setZoom(t){this.zoom=t,this.coordUtils.setZoomAndCurrentPos(this.zoom,this.currentPos)}setCurrentPos(t){this.currentPos=t,this.coordUtils.setZoomAndCurrentPos(this.zoom,this.currentPos)}updatePosition(t){const{zoom:e,currentPos:i}=t;this.setZoom(e),this.setCurrentPos(i),this.currentPosStorage=i,this.innerZoom=e,this.renderBasicCanvas(),this.render()}setLang(t){this.lang=t}setShowDefaultCursor(t){this.showDefaultCursor=t,this.container.style.cursor=this.defaultCursor}get forbidMouseOperation(){return this.forbidOperation||this.valid===!1}init(){this.eventUnbinding(),this.initPosition(),this.eventBinding(),this.render(),this.renderBasicCanvas()}destroy(){this.destroyCanvas(),this.eventUnbinding()}createCanvas(t){const e=document.createElement("canvas");e.setAttribute("width",`${t.width}`),e.setAttribute("height",`${t.height}`),e.style.position="absolute",e.style.left="0",e.style.top="0",e.style.zIndex="0",this.container.appendChild(e),this.basicCanvas=e;const i=document.createElement("canvas");i.setAttribute("width",`${t.width}`),i.setAttribute("height",`${t.height}`),i.style.position="absolute",i.style.left="0",i.style.top="0",i.style.zIndex="10",this.container.appendChild(i),this.canvas=i,this.container.style.cursor=this.defaultCursor}destroyCanvas(){this.canvas&&this.container.contains(this.canvas)&&this.container.removeChild(this.canvas),this.basicCanvas&&this.container.contains(this.basicCanvas)&&this.container.removeChild(this.basicCanvas),this.clearInvalidPage(),this.clearImgDrag()}setStyle(t){this.style=t,this.render()}setImgNode(t,e={}){this.imgNode=t,this.setBasicImgInfo(__spreadValues$9({width:t.width,height:t.height,valid:!0,rotate:0},e)),this.isImgError===!0&&(this.isImgError=!1,this.emit("changeAnnotationShow")),typeof e.valid=="boolean"&&this.setValid(e.valid),this.initImgPos(),this.render(),this.renderBasicCanvas()}setErrorImg(){const t=this.isImgError;this.isImgError=!0,this.imgNode=void 0,this.setBasicImgInfo({width:0,height:0,valid:!0,rotate:0}),t===!1&&this.emit("changeAnnotationShow")}setBasicImgInfo(t){this.basicImgInfo=t,this.coordUtils.setBasicImgInfo(t)}setForbidOperation(t){this.forbidOperation=t,this.render()}setForbidCursorLine(t){this.forbidCursorLine=t,this.render()}setIsHidden(t){this.isHidden=t,this.emit("hiddenChange")}setIsShowOrder(t){this.config.isShowOrder=t,this.render()}getCoordinate(t){const e=this.canvas.getBoundingClientRect();return{x:t.clientX-e.left,y:t.clientY-e.top}}getCoordinateUnderZoom(t){const e=this.canvas.getBoundingClientRect();return{x:t.clientX-e.left-this.currentPos.x,y:t.clientY-e.top-this.currentPos.y}}getGetCenterCoordinate(){return{x:this.size.width/2,y:this.size.height/2}}initPosition(){if(this.basicResult&&this.imgInfo){const{basicResult:t,size:e,imgNode:i,_imgAttribute:s,imgInfo:n,dependToolName:o}=this;if(t&&i&&o){let a=t;switch(o){case EToolName.Polygon:case EToolName.Line:{if(t.pointList){const h=MathUtils.calcViewportBoundaries(t.pointList);a={x:h.left,y:h.top,width:h.right-h.left,height:h.bottom-h.top}}break}}const l=ImgPosUtils.getBasicRecPos(i,a,e,void 0,s==null?void 0:s.zoomRatio,s==null?void 0:s.isOriginalSize);l&&(this.setCurrentPos(l.currentPos),this.currentPosStorage=this.currentPos,this.imgInfo=__spreadProps$8(__spreadValues$9({},n),{width:n.width/this.innerZoom*l.innerZoom,height:n.height/this.innerZoom*l.innerZoom}),this.innerZoom=l.innerZoom,this.setZoom(l.innerZoom),this.render(),this.renderBasicCanvas())}}else this.initImgPos()}undo(){this.history.undo()}redo(){this.history.redo()}clearCanvas(){var t;(t=this.ctx)==null||t.clearRect(0,0,this.size.width,this.size.height)}clearBasicCanvas(){var t;(t=this.basicCtx)==null||t.clearRect(0,0,this.size.width,this.size.height)}eventBinding(){this.dblClickListener.addEvent(()=>{},this.onLeftDblClick,this.onRightDblClick),this.container.addEventListener("mousedown",this.onMouseDown),this.container.addEventListener("mousemove",this.onMouseMove),this.container.addEventListener("mouseup",this.onMouseUp),this.container.addEventListener("mouseleave",this.onMouseLeave),this.container.addEventListener("click",this.onClick),this.container.addEventListener("wheel",this.onWheel),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.onKeyUp),window.parent.document.addEventListener("contextmenu",this.onContextmenu,!1)}eventUnbinding(){this.container.removeEventListener("mousedown",this.onMouseDown),this.container.removeEventListener("mousemove",this.onMouseMove),this.container.removeEventListener("mouseup",this.onMouseUp),this.container.removeEventListener("mouseleave",this.onMouseLeave),this.container.removeEventListener("wheel",this.onWheel),this.container.removeEventListener("click",this.onClick),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),window.parent.document.removeEventListener("contextmenu",this.onContextmenu,!1),this.dblClickListener.removeEvent()}clearImgDrag(){this.isDrag=!1,this.isDragStart=!1,this.isSpaceClick=!1,this.startTime=0,this.container.style.cursor=this.defaultCursor,this.forbidCursorLine=!1}onMouseDown(t){if(!this.canvas||this.isImgError)return!0;const e=this.getCoordinate(t);(this.isSpaceKey&&t.button===0||t.button===2)&&(t.stopPropagation(),this._firstClickCoordinate=e,this.currentPosStorage=this.currentPos,this.isSpaceClick=!0,this.isDragStart=!0,this.startTime=new Date().getTime())}onMouseMove(t){if(!this.canvas||this.isImgError)return!0;const e=this.getCoordinate(t);this.isShowCursor&&(this.coord=e,this.render());try{if(!e||!_.isNumber(e==null?void 0:e.x)||!_.isNumber(e==null?void 0:e.y))throw new Error("coord error");if(this.coord=e,(this.isSpaceClick||this.isDragStart)&&this._firstClickCoordinate){const i=this.getCurrentPos(e);this.setCurrentPos(i),this.isDrag=!0,this.container.style.cursor="grabbing",this.forbidCursorLine=!0,this.renderBasicCanvas(),this.emit("dependRender")}this.render()}catch(i){console.error(i)}}onMouseUp(t){if(!this.canvas||this.isImgError)return!0;if(this.container.style.cursor=this.defaultCursor,this.forbidCursorLine=!1,this.isDrag=!1,this.isDragStart=!1,this.isSpaceClick=!1,this.startTime!==0&&this._firstClickCoordinate){const e=new Date().getTime(),i=this.getCoordinate(t);if(e-this.startTime>1e3||this.isSpaceKey===!0||LineToolUtils.calcTwoPointDistance(i,this._firstClickCoordinate)>10)return t.stopPropagation(),this.startTime=0,this.render(),!0}this.startTime=0,this.render()}onMouseLeave(){this.clearImgDrag()}onClick(t){}onLeftDblClick(t){}onRightDblClick(t){this.clearImgDrag()}onKeyDown(t){switch(t.keyCode===EKeyCode$1.Alt&&t.preventDefault(),t.keyCode){case EKeyCode$1.Space:this.isSpaceKey=!0;break;case EKeyCode$1.Z:if(t.ctrlKey)return t.shiftKey?this.redo():this.undo(),!1;break}return!0}onKeyUp(t){switch(t.keyCode){case EKeyCode$1.Space:this.isSpaceKey=!1;break}}onWheel(t,e=!0){if(!this.imgNode||!this.coord)return;t.preventDefault(),t.stopPropagation();const i=this.getCoordinate(t),s=t.deltaY||t.wheelDelta;let n=0;s>0&&this.zoom>zoomInfo.min&&(n=-1),s<0&&this.zoom<zoomInfo.max&&(n=1),this.wheelChangePos(i,n),this.emit("dependRender"),e&&this.render(),this.renderBasicCanvas()}renderCursorLine(t=(e=>(e=this.style.lineColor[0])!=null?e:"")()){if(!this.ctx||this.forbidCursorLine)return;const{x:e,y:i}=this.coord;DrawUtils.drawLine(this.canvas,{x:0,y:i},{x:1e4,y:i},{color:t}),DrawUtils.drawLine(this.canvas,{x:e,y:0},{x:e,y:1e4},{color:t}),DrawUtils.drawCircleWithFill(this.canvas,{x:e,y:i},1,{color:"white"})}setSize(t){this.size=t,this.container.contains(this.canvas)&&(this.destroyCanvas(),this.createCanvas(t),this.eventUnbinding(),this.init())}setImgAttribute(t){const e=this._imgAttribute;if(this._imgAttribute=t,(e==null?void 0:e.zoomRatio)!==t.zoomRatio||e.isOriginalSize!==t.isOriginalSize){this.initImgPos();return}this.renderBasicCanvas(),this.render()}clearResult(t){}setValid(t){this.basicImgInfo.valid=t,t===!1?(this.renderInvalidPage(),this.clearResult(!1)):this.clearInvalidPage()}setRotate(t){this.basicImgInfo.rotate=t}setBasicResult(t){this.basicResult=t,this.coordUtils.setBasicResult(t),this.initPosition(),this.emit("dependRender")}setDependName(t,e){this.dependToolName=t,this.coordUtils.setDependInfo(t,e)}setAttributeLockList(t){this.attributeLockList=t,this.render()}setConfig(t){this.config=CommonToolUtils.jsonParser(t)}updateRotate(){if(this.dependToolName)return this.emit("messageInfo",Locale.getMessagesByLocale(EMessage.NoRotateInDependence,this.lang)),!1;if(this.dataList.length>0)return this.emit("messageInfo",Locale.getMessagesByLocale(EMessage.NoRotateNotice,this.lang)),!1;const t=MathUtils.getRotate(this.basicImgInfo.rotate);this.basicImgInfo.rotate=t,this.initImgPos(),this.emit("updateResult")}getColor(t="",e=this.config){var i;if((e==null?void 0:e.attributeConfigurable)===!0&&this.style.attributeColor){const o=AttributeUtils.getAttributeIndex(t,(i=e.attributeList)!=null?i:[])+1;return this.style.attributeColor[o]}const{color:s,toolColor:n}=this.style;return n?n[s]:styleDefaultConfig.toolColor["1"]}getLineColor(t=""){var e,i,s;if(((e=this.config)==null?void 0:e.attributeConfigurable)===!0){const a=AttributeUtils.getAttributeIndex(t,(s=(i=this.config)==null?void 0:i.attributeList)!=null?s:[])+1;return this.style.attributeLineColor?this.style.attributeLineColor[a]:""}const{color:n,lineColor:o}=this.style;return n&&o?o[n]:""}clearInvalidPage(){this._invalidDOM&&this.container&&this.container.contains(this._invalidDOM)&&(this.container.removeChild(this._invalidDOM),this._invalidDOM=void 0)}renderInvalidPage(){!this.container||this._invalidDOM||(this._invalidDOM=RenderDomUtils.renderInvalidPage(this.canvas,this.container,this.lang))}renderBasicCanvas(){if(!this.basicCanvas)return;this.clearBasicCanvas(),this.drawImg();const t=3;if(this.basicResult&&this.dependToolName)switch(this.dependToolName){case EToolName.Rect:{DrawUtils.drawRect(this.basicCanvas,AxisUtils.changeRectByZoom(this.basicResult,this.zoom,this.currentPos),{color:"rgba(204,204,204,1.00)",thickness:t});break}case EToolName.Polygon:{DrawUtils.drawPolygonWithFillAndLine(this.basicCanvas,AxisUtils.changePointListByZoom(this.basicResult.pointList,this.zoom,this.currentPos),{fillColor:"transparent",strokeColor:"rgba(204,204,204,1.00)",isClose:!0,thickness:t});break}case EToolName.Line:{DrawUtils.drawLineWithPointList(this.basicCanvas,AxisUtils.changePointListByZoom(this.basicResult.pointList,this.zoom,this.currentPos),{color:"rgba(204,204,204,1.00)",thickness:t});break}}}render(){!this.canvas||!this.ctx||!this.imgNode||this.clearCanvas()}changeStyle(t=this.defaultAttribute){this.emit("changeStyle",{attribute:t})}}var __defProp$8=Object.defineProperty,__getOwnPropSymbols$8=Object.getOwnPropertySymbols,__hasOwnProp$8=Object.prototype.hasOwnProperty,__propIsEnum$8=Object.prototype.propertyIsEnumerable,__defNormalProp$8=(r,t,e)=>t in r?__defProp$8(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,__spreadValues$8=(r,t)=>{for(var e in t||(t={}))__hasOwnProp$8.call(t,e)&&__defNormalProp$8(r,e,t[e]);if(__getOwnPropSymbols$8)for(var e of __getOwnPropSymbols$8(t))__propIsEnum$8.call(t,e)&&__defNormalProp$8(r,e,t[e]);return r};const TEXT_ATTRIBUTE_OFFSET$1={x:8,y:26},newScope$1=2;class CheckOperation extends BasicToolOperation{constructor(t){super(t);this.getHoverRectID=e=>{var i,s;const n=this.getCoordinateUnderZoom(e),o=(s=(i=this.resultList.find(a=>a.toolName===EToolName.Rect))==null?void 0:i.result)!=null?s:[];if(o.length>0){const a=o.filter(l=>RectUtils.isInRect(n,l,newScope$1,this.zoom));if(a.length===0)return"";if(a.length===1)return a[0].id;if(a.length>1)return a.map(h=>({size:h.width*h.height,id:h.id})).sort((h,d)=>h.size-d.size)[0].id}return""},this.resultList=[],this.hoverID=[],this.fillID=[],this.render=this.render.bind(this),this.drawPolygon=this.drawPolygon.bind(this),this.drawRect=this.drawRect.bind(this),this.drawTag=this.drawTag.bind(this),this.setShowDefaultCursor(!0),this.forbidOperation=!0}onMouseDown(t){var e,i;if(super.onMouseDown(t)||this.forbidMouseOperation||!this.imgInfo)return!0;const s=this.mouseHoverID,n=(i=(e=this.resultList.find(o=>o.toolName===EToolName.Rect))==null?void 0:e.result)!=null?i:[];if(t.button===0){let o=[s],a=!0;s&&n.find(l=>l.id===s&&(l==null?void 0:l.isSelected))&&(a=!1),s||(o=n.map(l=>l.id),a=!1),this.emit("setSelectedID",o,a),this.render()}}updateRotate(){}onMouseMove(t){if(super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo)return;const e=this.mouseHoverID,i=this.getHoverRectID(t);if(e!==i){this.mouseHoverID=i;let s=[i];i||(s=[]),this.emit("setHoverID",s),this.render()}}setResult(t){this.resultList=_.cloneDeep(t),this.render()}drawPolygon(t,e){t==null||t.forEach(i=>{var s,n,o,a,l;const h=this.getColor(i.attribute,e),d=StyleUtils.getStrokeAndFill(h,i.valid);let u=(n=(s=this.style)==null?void 0:s.width)!=null?n:2;this.hoverID.includes(i.id)?(u=4,DrawUtils.drawPolygonWithFillAndLine(this.canvas,AxisUtils.changePointListByZoom(i.pointList,this.zoom,this.currentPos),{fillColor:d.fill,strokeColor:d.stroke,pointColor:"white",thickness:u,lineCap:"round",isClose:!0,lineType:e==null?void 0:e.lineType})):DrawUtils.drawPolygon(this.canvas,AxisUtils.changePointListByZoom(i.pointList,this.zoom,this.currentPos),{color:d.fill,lineType:(o=this.config)==null?void 0:o.lineType,thickness:u,isClose:!0}),DrawUtils.drawText(this.canvas,AxisUtils.changePointByZoom(i.pointList[0],this.zoom,this.currentPos),(l=AttributeUtils.getAttributeShowText(i.attribute,(a=e==null?void 0:e.attributeList)!=null?a:[]))!=null?l:"",__spreadValues$8({color:d.stroke},DEFAULT_TEXT_OFFSET));const c=AxisUtils.changePointListByZoom(i.pointList||[],this.zoom,this.currentPos),g=c[c.length-1];DrawUtils.drawText(this.canvas,{x:g.x+TEXT_ATTRIBUTE_OFFSET$1.x,y:g.y+TEXT_ATTRIBUTE_OFFSET$1.y},i==null?void 0:i.textAttribute,__spreadValues$8({color:d.stroke},DEFAULT_TEXT_OFFSET))})}drawRect(t,e){t==null||t.forEach(i=>{let s=1;this.hoverID.includes(i.id)&&(s=3);const n=this.getColor(i.attribute,e),o=AxisUtils.changeRectByZoom(i,this.zoom,this.currentPos);DrawUtils.drawRect(this.canvas,o,{color:(i==null?void 0:i.valid)?n.valid.stroke:n.invalid.stroke,thickness:s}),this.fillID.includes(i.id)&&DrawUtils.drawRectWithFill(this.canvas,o,{color:(i==null?void 0:i.valid)?n.valid.fill:n.invalid.fill})})}drawTag(t,e){const i=t.reduce((s,n)=>[...s,...(e==null?void 0:e.inputList)?TagUtil.getTagNameList(n.result,e.inputList):TagUtil.getTagnameListWithoutConfig(n.result)],[]);DrawUtils.drawTag(this.canvas,i)}setHoverID(t){this.hoverID=t,this.render()}setFillID(t){this.fillID=t,this.render()}render(){var t;super.render(),(t=this.resultList)==null||t.forEach(e=>{switch(e==null?void 0:e.toolName){case EToolName.Rect:this.drawRect(e.result,CommonToolUtils.jsonParser(e.config));break;case EToolName.Polygon:this.drawPolygon(e.result,CommonToolUtils.jsonParser(e.config));break;case EToolName.Tag:this.drawTag(e.result,CommonToolUtils.jsonParser(e.config));break}})}exportData(){return[[],{}]}}class CanvasUtils{static getMousePositionOnCanvasFromEvent(t,e){if(e&&t){const i=e.getBoundingClientRect();return{x:t.clientX-i.left,y:t.clientY-i.top}}return null}static getClientRect(t){if(t){const e=t.getBoundingClientRect();return{x:e.left,y:e.top,width:e.width,height:e.height}}return null}static getSize(t){if(t){const e=t.getBoundingClientRect();return{width:e.width,height:e.height}}return null}static inViewPort(t,e){return t?MathUtils.isInRange(t.x,[e.left,e.right])&&MathUtils.isInRange(t.y,[e.top,e.bottom]):!1}}CanvasUtils.getViewPort=(r,t,e)=>{const{width:i,height:s}=r,{x:n,y:o}=t,a=(0-o)/e,l=(0-n)/e,h=a+s/e,d=l+i/e;return{top:a,bottom:h,left:l,right:d}};const defaultWidth=30,DEFAULT_TEXT_WIDTH=164;class TextAttributeClass{constructor(t){this.textKeyDown=l=>{switch(l.stopPropagation(),l.keyCode){case EKeyCode$1.Enter:this.submitTextarea(),this.appendToContainer();break}};const{container:e,icon:i,color:s,getCurrentSelectedData:n,updateSelectedTextAttribute:o}=t,a=t.width||DEFAULT_TEXT_WIDTH;this.container=e,this.getCurrentSelectedData=n,this.updateSelectedTextAttribute=o,this._textAttributeDOM=this.initTextAttributeDOM(),this._iconDOM=this.initIconDOM(i),this._textDOM=this.initTextDOM(a,TEXT_ATTRIBUTE_LINE_HEIGHT),this._textareaDOM=this.initTextareaDOM(a,s),this.appendToContainer()}get isExit(){return this._textAttributeDOM?this.container.contains(this._textAttributeDOM):!1}get isExitTextareaDOM(){return this._textareaDOM?this.container.contains(this._textareaDOM):!1}updateIcon(t){this._iconDOM&&(this._iconDOM.innerHTML=t)}appendToContainer(){!this._textAttributeDOM||!this._textDOM||!this._iconDOM||(this.container.appendChild(this._textAttributeDOM),this._textAttributeDOM.appendChild(this._textDOM),this._textAttributeDOM.appendChild(this._iconDOM))}initTextAttributeDOM(){const t=document.createElement("div");return t.setAttribute("id","textArea"),t}initTextDOM(t,e){const i=document.createElement("span");return i.setAttribute("style",`
|
|
22
|
+
`),s.innerHTML=Locale.getMessagesByLocale(EMessage.InvalidImage,i),e.appendChild(s),s}}const ZOOM_LEVEL=[1,5,10,20,30,50,80,100].concat(Array.from({length:9}).map((r,t)=>(t+2)*100));class ZoomUtils{}ZoomUtils.zoomChanged=(r,t,e=EGrowthMode.Linear)=>{switch(e){case EGrowthMode.Intelligence:{const i=Math.max(...ZOOM_LEVEL),s=Math.min(...ZOOM_LEVEL),n=ZOOM_LEVEL.slice(0,ZOOM_LEVEL.length).findIndex((a,l)=>r>=a&&(r<ZOOM_LEVEL[l+1]||a===i));let o;if(n===-1)r>=s&&r<=i?o=t?i:s:o=t?s:r;else{const a=t?n+1:n-(ZOOM_LEVEL.includes(r)?1:0);o=ZOOM_LEVEL[MathUtils.withinRange(a,[0,ZOOM_LEVEL.length-1])]}return o}default:{const i=t?2:1/2;return r*i}}},ZoomUtils.wheelChangePos=(r,t,e,i,s={})=>{const{zoom:n=1,innerZoom:o=1,basicZoom:a=1,zoomMax:l=1e3,rotate:h=0}=s,{x:d,y:u}=i,c=parseFloat((n+1/10).toFixed(1))/5;if(r&&t){let{width:g,height:f}=r;[90,270].includes(h)&&(g=r.height,f=r.width);const v=g*o,p=f*o,b=t.x-d,x=t.y-u,y=b/v,I=x/p;let m=n+e*c;m=MathUtils.withinRange(m,[a,l]);const L=g*m*y,w=f*m*I,C=d+(b-L),P=u+(x-w);return{zoom:m,currentPos:{x:C,y:P},imgInfo:{width:g*m,height:f*m},ratio:c}}return null};class EventListener{constructor(){this._events=new Map}on(t,e){const i=this._events.get(t)||[];i.some(s=>s===e)||this._events.set(t,i.concat(e))}singleOn(t,e){this._events.set(t,[e])}emit(t,...e){const i=this._events.get(t);i&&i.forEach(s=>{s&&s(...e)})}unbind(t,e){const i=this._events.get(t);i&&this._events.set(t,i.filter(s=>s!==e))}unbindAll(t){this._events.delete(t)}}const rectToolConfig={showConfirm:!1,skipWhileNoDependencies:!1,drawOutsideTarget:!1,copyBackwardResult:!1,minWidth:1,minHeight:1,isShowOrder:!1,filterData:["valid","invalid"],attributeConfigurable:!1,attributeList:[],textConfigurable:!1,textCheckType:0,customFormat:""},tagToolConfig={showConfirm:!1,skipWhileNoDependencies:!1,inputList:[{key:"\u7C7B\u522B1",value:"class1",isMulti:!1,subSelected:[{key:"\u9009\u98791",value:"option1",isDefault:!1},{key:"\u9009\u98792",value:"option1-2",isDefault:!1}]},{key:"\u7C7B\u522B2",value:"class-AH",isMulti:!0,subSelected:[{key:"\u9009\u98792-1",value:"option2-1",isDefault:!1},{key:"\u9009\u98792-2",value:"option2-2",isDefault:!1},{key:"\u9009\u98792-3",value:"option2-3",isDefault:!1}]},{key:"\u7C7B\u522B3",value:"class-0P",isMulti:!1,subSelected:[{key:"\u9009\u98793-1",value:"option3-1",isMulti:!1},{key:"\u9009\u98793-2",value:"option3-2",isDefault:!1},{key:"\u9009\u98793-3",value:"option3-3",isDefault:!1}]}]},lineToolConfig={lineType:0,lineColor:0,edgeAdsorption:!1,outOfTarget:!0,copyBackwardResult:!1,isShowOrder:!1,attributeConfigurable:!1,attributeList:[{key:"\u7C7B\u522B1",value:"\u7C7B\u522B1"},{key:"\u7C7B\u522Bao",value:"class-ao"},{key:"\u7C7B\u522BM1",value:"class-M1"},{key:"\u7C7B\u522BCm",value:"class-Cm"},{key:"\u7C7B\u522Bc3",value:"class-c3"},{key:"\u7C7B\u522Ba0",value:"class-a0"},{key:"\u7C7B\u522Bu7",value:"class-u7"},{key:"\u7C7B\u522BZb",value:"class-Zb"},{key:"\u7C7B\u522Bzi",value:"class-zi"}],textConfigurable:!1,textCheckType:2,customFormat:"",showConfirm:!1,lowerLimitPointNum:2,upperLimitPointNum:"",preReferenceStep:0,skipWhileNoDependencies:!1,filterData:["valid","invalid"]},textToolConfig={showConfirm:!1,skipWhileNoDependencies:!1,enableTextRecognition:!1,recognitionMode:"general",configList:[{label:"\u6587\u672C",key:"text",required:!1,default:"",maxLength:1e3}],filterData:["valid","invalid"]},polygonConfig={lineType:0,lineColor:0,lowerLimitPointNum:3,edgeAdsorption:!1,drawOutsideTarget:!1,copyBackwardResult:!1,isShowOrder:!1,attributeConfigurable:!1,attributeList:[],textConfigurable:!0,textCheckType:0,customFormat:""},getConfig=r=>r==="lineTool"?lineToolConfig:r==="rectTool"?rectToolConfig:r==="tagTool"?tagToolConfig:r==="textTool"?textToolConfig:r==="polygonTool"?polygonConfig:rectToolConfig,styleDefaultConfig={toolColor:{1:{valid:{stroke:"rgba(0,0,255,0.50)",fill:"rgba(0,0,255,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.80)"},validSelected:{stroke:"rgba(0,15,255,1.00)",fill:"rgba(0,15,255,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,0.60)",fill:"rgba(255,0,0,0.24)"},validHover:{stroke:"rgba(0,15,255,0.80)",fill:"rgba(0,15,255,0.64)"},invalidHover:{stroke:"rgba(255,0,0,0.50)",fill:"rgba(255,0,0,0.40)"}},3:{valid:{stroke:"rgba(0,255,255,0.50)",fill:"rgba(0,255,255,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.80)"},validSelected:{stroke:"rgba(0,212,255,1.00)",fill:"rgba(0,212,255,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,0.60)",fill:"rgba(255,0,0,0.24)"},validHover:{stroke:"rgba(0,212,255,0.80)",fill:"rgba(0,212,255,0.64)"},invalidHover:{stroke:"rgba(255,0,0,0.50)",fill:"rgba(255,0,0,0.40)"}},5:{valid:{stroke:"rgba(0,255,0,0.50)",fill:"rgba(0,255,0,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.80)"},validSelected:{stroke:"rgba(149,255,1.00)",fill:"rgba(149,255,0,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,0.60)",fill:"rgba(255,0,0,0.24)"},validHover:{stroke:"rgba(149,255,0,0.80)",fill:"rgba(149,255,0,0.64)"},invalidHover:{stroke:"rgba(255,0,0,0.50)",fill:"rgba(255,0,0,0.40)"}},7:{valid:{stroke:"rgba(255,255,0,0.50)",fill:"rgba(255,255,0,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.80)"},validSelected:{stroke:"rgba(255,230,102,1.00)",fill:"rgba(255,213,0,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,0.60)",fill:"rgba(255,0,0,0.24)"},validHover:{stroke:"rgba(255,230,102,0.80)",fill:"rgba(255,230,102,0.64)"},invalidHover:{stroke:"rgba(255,0,0,0.50)",fill:"rgba(255,0,0,0.40)"}},9:{valid:{stroke:"rgba(255,0,255,0.50)",fill:"rgba(255,0,255,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.80)"},validSelected:{stroke:"rgba(230,102,255,1.00)",fill:"rgba(213,0,255,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,0.60)",fill:"rgba(255,0,0,0.24)"},validHover:{stroke:"rgba(230,102,255,0.80)",fill:"rgba(230,102,255,0.64)"},invalidHover:{stroke:"rgba(255,0,0,0.50)",fill:"rgba(255,0,0,0.40)"}}},attributeColor:[{valid:{stroke:"rgba(204,204,204,1.00)",fill:"rgba(204,204,204,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(204,204,204,1.00)",fill:"rgba(204,204,204,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(204,204,204,1.00)",fill:"rgba(204,204,204,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(153,51,255,1.00)",fill:"rgba(153,51,255,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(153,51,255,1.00)",fill:"rgba(153,51,255,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(153,51,255,1.00)",fill:"rgba(153,51,255,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(51,254,51,1.00)",fill:"rgba(51,254,51,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(51,254,51,1.00)",fill:"rgba(51,254,51,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(51,254,51,1.00)",fill:"rgba(51,254,51,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(255,51,255,1.00)",fill:"rgba(255,51,255,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(255,51,255,1.00)",fill:"rgba(255,51,255,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(255,51,255,1.00)",fill:"rgba(255,51,255,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(204,255,51,1.00)",fill:"rgba(204,255,51,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(204,255,51,1.00)",fill:"rgba(204,255,51,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(204,255,51,1.00)",fill:"rgba(204,255,51,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(51,153,255,1.00)",fill:"rgba(51,153,255,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(51,153,255,1.00)",fill:"rgba(51,153,255,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(51,153,255,1.00)",fill:"rgba(51,153,255,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(255,153,51,1.00)",fill:"rgba(255,153,51,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(255,153,51,1.00)",fill:"rgba(255,153,51,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(255,153,51,1.00)",fill:"rgba(255,153,51,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(51,255,238,1.00)",fill:"rgba(51,255,238,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(51,255,238,1.00)",fill:"rgba(51,255,238,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(51,255,238,1.00)",fill:"rgba(51,255,238,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(255,221,51,1.00)",fill:"rgba(255,221,51,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(255,221,51,1.00)",fill:"rgba(255,221,51,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(255,221,51,1.00)",fill:"rgba(255,221,51,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}}],lineColor:{1:"rgba(102, 111, 255, 1 )",3:"rgba(102, 230, 255, 1)",5:"rgba(191, 255, 102, 1)",7:"rgba(255, 230, 102, 1)",9:"rgba(230, 102, 255, 1)"},attributeLineColor:["rgba(204, 204, 204, 1)","rgba(153, 51, 255, 1)","rgba(51, 254, 51, 1)","rgba(255, 51, 255, 1)","rgba(204, 255, 51, 1)","rgba(51, 153, 255, 1)","rgba(255, 153, 51, 1)","rgba(51, 255, 238, 1)","rgba(255, 221, 51, 1)"],color:1,width:2,opacity:9};var __defProp$a=Object.defineProperty,__defProps$9=Object.defineProperties,__getOwnPropDescs$9=Object.getOwnPropertyDescriptors,__getOwnPropSymbols$a=Object.getOwnPropertySymbols,__hasOwnProp$a=Object.prototype.hasOwnProperty,__propIsEnum$a=Object.prototype.propertyIsEnumerable,__defNormalProp$a=(r,t,e)=>t in r?__defProp$a(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,__spreadValues$a=(r,t)=>{for(var e in t||(t={}))__hasOwnProp$a.call(t,e)&&__defNormalProp$a(r,e,t[e]);if(__getOwnPropSymbols$a)for(var e of __getOwnPropSymbols$a(t))__propIsEnum$a.call(t,e)&&__defNormalProp$a(r,e,t[e]);return r},__spreadProps$9=(r,t)=>__defProps$9(r,__getOwnPropDescs$9(t)),EStatus$1;(function(r){r[r.Create=0]="Create",r[r.Active=1]="Active",r[r.Edit=1]="Edit",r[r.None=2]="None"})(EStatus$1||(EStatus$1={}));var EColor;(function(r){r.ActiveArea="#B3B8FF"})(EColor||(EColor={}));const SEGMENT_NUMBER$1=16,POINT_RADIUS$1=3,_LineToolUtils=class{static isInLine(r,t,e,i=3){const{length:s}=MathUtils.getFootOfPerpendicular(r,t,e);return s<i}};let LineToolUtils=_LineToolUtils;LineToolUtils.setSpecialEdgeStyle=r=>{r.lineCap="butt",r.setLineDash([10,10])},LineToolUtils.setReferenceCtx=r=>{r.lineCap="butt",r.setLineDash([6])},LineToolUtils.calcOptimalIntersection=(r,t,e,i,s)=>{let n,o=Infinity,a;if(r.find((h,d)=>{if(d===0)return;const u=_LineToolUtils.isInLine(t.pointA,h,r[d-1]),c=_LineToolUtils.isInLine(t.pointB,h,r[d-1]);return u&&c}))return{point:e};if(r.forEach((h,d)=>{if(d===0)return;const u={pointA:r[d-1],pointB:h},c=_LineToolUtils.lineIntersection(t,u);if(c&&t){const{onLine2:g,onLine1:f,x:v,y:p}=c,b=_LineToolUtils.calcDistance(e,c);if(_LineToolUtils.isOnLine(t.pointB.x,t.pointB.y,h.x,h.y,r[d-1].x,r[d-1].y)){if(_LineToolUtils.calcDistance(e,c)<i/s){const I=t.pointB,{footPoint:m,length:L}=MathUtils.getFootOfPerpendicular(I,u.pointA,u.pointB,!0);if(L!==void 0){const w=_LineToolUtils.calcDistance(u.pointA,m),C=_LineToolUtils.calcDistance(u.pointB,m);a={point:m,minDistance:L},L===Infinity&&(a.point=w>C?u.pointB:u.pointA)}}return}b<o&&g&&f&&(o=b,n={x:v,y:p})}}),n)return{point:n,minDistance:o};if(a)return a},LineToolUtils.lineIntersection=(r,t)=>{let e=!1,i=!1;const s=_LineToolUtils.getAxisDiff(r),n=_LineToolUtils.getAxisDiff(t),o=n.y*s.x-n.x*s.y;if(o===0)return!1;let a=r.pointA.y-t.pointA.y,l=r.pointA.x-t.pointA.x;const h=(t.pointB.x-t.pointA.x)*a-(t.pointB.y-t.pointA.y)*l,d=(r.pointB.x-r.pointA.x)*a-(r.pointB.y-r.pointA.y)*l;a=h/o,l=d/o,a>0&&a<1&&(e=!0),l>0&&l<1&&(i=!0);const u=r.pointA.x+a*(r.pointB.x-r.pointA.x),c=r.pointA.y+a*(r.pointB.y-r.pointA.y);return{x:u,y:c,onLine1:e,onLine2:i}},LineToolUtils.getAxisDiff=r=>({x:r.pointB.x-r.pointA.x,y:r.pointB.y-r.pointA.y}),LineToolUtils.calcDistance=(r,t)=>Math.sqrt(Math.pow(Math.abs(r.x-t.x),2)+Math.pow(Math.abs(r.y-t.y),2)),LineToolUtils.drawCurveLine=(r,t,e,i=!0,s=!1,n)=>{const o=createSmoothCurvePointsFromPointList(t,SEGMENT_NUMBER$1);r.save(),r.lineCap="round",r.lineJoin="round",r.strokeStyle=e.color,i&&(r.lineWidth=e.lineWidth),s&&_LineToolUtils.setReferenceCtx(r),t.forEach((a,l)=>{const h=a==null?void 0:a.specialEdge,d=o.splice(0,SEGMENT_NUMBER$1+1);r.save(),r.beginPath(),n===l&&(r.lineWidth=4),d.forEach(({x:u,y:c},g)=>{const f=g>0?"lineTo":"moveTo";h&&_LineToolUtils.setSpecialEdgeStyle(r),r[f](u,c)}),r.stroke(),r.restore()}),r.restore()},LineToolUtils.calcTwoPointDistance=(r,t)=>Math.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2)),LineToolUtils.pointOverTarget=(r,t,e,i,s,n,o,a,l,h)=>{const d=r;if(!t)return r;if(e===EToolName.Polygon){const u=_LineToolUtils.getPolygonPointList(i,s);if(u.length===0||PolygonUtils.isInPolygon(r,u))return d;const g=u.concat(u[0]).map(x=>l(x)),f=l(t),v=l(r),p={pointA:f,pointB:v},b=_LineToolUtils.calcOptimalIntersection(g,p,f,o,a);if(b){const x=h(b==null?void 0:b.point);d.x=x.x,d.y=x.y}else return t;return d}if(e===EToolName.Rect){const{x:u,y:c,width:g,height:f}=i;return d.x=MathUtils.withinRange(d.x,[u,u+g]),d.y=MathUtils.withinRange(d.y,[c,c+f]),d}return d.x=MathUtils.withinRange(d.x,[0,n.width]),d.y=MathUtils.withinRange(d.y,[0,n.height]),d},LineToolUtils.getPolygonPointList=(r,t)=>{const{pointList:e}=r,{lineType:i}=t;return i===ELineTypes.Line?e:PolygonUtils.createSmoothCurvePoints(e.reduce((s,n)=>[...s,n.x,n.y],[]),.5,!0,20)},LineToolUtils.isOnLine=(r,t,e,i,s,n)=>Math.abs((a=>(i-t)/(e-r)*(a-r)+t)(s)-n)<1e-6&&s>=r&&s<=e,LineToolUtils.inArea=({top:r,left:t,right:e,bottom:i},{x:s,y:n})=>n>=r&&n<=i&&s>=t&&s<=e,LineToolUtils.getVHPoint=(r,t,e,i)=>{const s=_LineToolUtils.getAngle(r,e);return Math.abs(s)<45?__spreadProps$9(__spreadValues$a({},t),{y:i.y}):__spreadProps$9(__spreadValues$a({},t),{x:i.x})},LineToolUtils.getAngle=(r,t)=>{const e=t.x-r.x,i=t.y-r.y;return 360*Math.atan(i/e)/(2*Math.PI)};var __defProp$9=Object.defineProperty,__defProps$8=Object.defineProperties,__getOwnPropDescs$8=Object.getOwnPropertyDescriptors,__getOwnPropSymbols$9=Object.getOwnPropertySymbols,__hasOwnProp$9=Object.prototype.hasOwnProperty,__propIsEnum$9=Object.prototype.propertyIsEnumerable,__defNormalProp$9=(r,t,e)=>t in r?__defProp$9(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,__spreadValues$9=(r,t)=>{for(var e in t||(t={}))__hasOwnProp$9.call(t,e)&&__defNormalProp$9(r,e,t[e]);if(__getOwnPropSymbols$9)for(var e of __getOwnPropSymbols$9(t))__propIsEnum$9.call(t,e)&&__defNormalProp$9(r,e,t[e]);return r},__spreadProps$8=(r,t)=>__defProps$8(r,__getOwnPropDescs$8(t)),__async$1=(r,t,e)=>new Promise((i,s)=>{var n=l=>{try{a(e.next(l))}catch(h){s(h)}},o=l=>{try{a(e.throw(l))}catch(h){s(h)}},a=l=>l.done?i(l.value):Promise.resolve(l.value).then(n,o);a((e=e.apply(r,t)).next())});const zoomInfo={min:.2,max:1e3,ratio:.4};class BasicToolOperation extends EventListener{constructor(t){super();this.isDrag=!1,this.isSpaceKey=!1,this.innerZoom=1,this.basicZoom=.01,this.isSpaceClick=!1,this.isDragStart=!1,this.startTime=0,this.initImgPos=()=>__async$1(this,null,function*(){var d,u;if(!this.imgNode)return;const c=(d=this._imgAttribute)==null?void 0:d.zoomRatio,g=(u=this._imgAttribute)==null?void 0:u.isOriginalSize,{currentPos:f,imgInfo:v,zoom:p}=ImgPosUtils.getInitImgPos(this.size,{width:this.imgNode.width,height:this.imgNode.height},this.rotate,c,g);this.setCurrentPos(f),this.currentPosStorage=f,this.imgInfo=v,this.setZoom(p),this.innerZoom=p,this.render(),this.renderBasicCanvas(),this.emit("dependRender"),this.emit("renderZoom",p)}),this.getCurrentPos=d=>{const{_firstClickCoordinate:u,currentPosStorage:c}=this;try{let g;return u&&c?g={y:c.y+d.y-u.y,x:c.x+d.x-u.x}:g={x:0,y:0},g}catch(g){return console.error(g),{x:0,y:0}}},this.wheelChangePos=(d,u,c)=>{const{currentPos:g,imgNode:f}=this;if(!f){console.error("unable to load image");return}if(this.zoom===this.basicZoom&&u===-1)return;const v=ZoomUtils.wheelChangePos(f,d,u,g,{zoom:c||this.zoom,innerZoom:this.innerZoom,basicZoom:this.basicZoom,zoomMax:zoomInfo.max,rotate:this.rotate});if(!v)return;const{currentPos:p,ratio:b,zoom:x,imgInfo:y}=v;this.innerZoom=x,this.setZoom(x),this.setCurrentPos(p),this.currentPosStorage=p,this.imgInfo=y,zoomInfo.ratio=b,this.emit("renderZoom",x)},this.zoomChanged=(d,u=EGrowthMode.Linear)=>{const c=ZoomUtils.zoomChanged(this.zoom,d,u);this.wheelChangePos(this.getGetCenterCoordinate(),c>this.zoom?1:-1,c),this.render(),this.renderBasicCanvas()},this.drawImg=()=>{!this.imgNode||DrawUtils.drawImg(this.basicCanvas,this.imgNode,{zoom:this.zoom,currentPos:this.currentPos,rotate:this.rotate,imgAttribute:this._imgAttribute})};var e,i,s,n,o,a,l,h;this.container=t.container,this.showDefaultCursor=t.showDefaultCursor||!1,this.destroyCanvas(),this.createCanvas(t.size),this.imgNode=t.imgNode,this.isImgError=!t.imgNode,this.basicImgInfo={width:(i=(e=t.imgNode)==null?void 0:e.width)!=null?i:0,height:(n=(s=t.imgNode)==null?void 0:s.height)!=null?n:0,valid:!0,rotate:0},this.forbidOperation=(o=t.forbidOperation)!=null?o:!1,this.size=t.size,this.currentPos={x:0,y:0},this.zoom=1,this.coord={x:-1,y:-1},this.currentPosStorage={x:0,y:0},this.isShowCursor=!1,this.style={strokeColor:COLORS_ARRAY[4],fillColor:COLORS_ARRAY[4],strokeWidth:2,opacity:1},this.attributeLockList=[],this.history=new ActionsHistory,this.style=(a=t.style)!=null?a:{},this._imgAttribute=(l=t.imgAttribute)!=null?l:{},this.isHidden=!1,this.dragStatus=EDragStatus.Wait,this.defaultAttribute=(h=t==null?void 0:t.defaultAttribute)!=null?h:"",this.forbidCursorLine=!!t.forbidCursorLine,this.lang=ELang.Zh,this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.onWheel=this.onWheel.bind(this),this.onLeftDblClick=this.onLeftDblClick.bind(this),this.onRightDblClick=this.onRightDblClick.bind(this),this.onClick=this.onClick.bind(this),this.clearImgDrag=this.clearImgDrag.bind(this),this.dblClickListener=new DblClickEventListener(this.container,200),this.coordUtils=new CoordinateUtils(this),this.coordUtils.setBasicImgInfo(this.basicImgInfo)}onContextmenu(t){t.preventDefault()}get ctx(){var t;return this._ctx||((t=this.canvas)==null?void 0:t.getContext("2d"))}get basicCtx(){var t;return(t=this.basicCanvas)==null?void 0:t.getContext("2d")}get rotate(){var t,e;return(e=(t=this.basicImgInfo)==null?void 0:t.rotate)!=null?e:0}get valid(){var t,e;return(e=(t=this.basicImgInfo)==null?void 0:t.valid)!=null?e:!0}get baseIcon(){return BASE_ICON[this.style.color]}get defaultCursor(){return this.showDefaultCursor?"default":"none"}get dataList(){return[]}setZoom(t){this.zoom=t,this.coordUtils.setZoomAndCurrentPos(this.zoom,this.currentPos)}setCurrentPos(t){this.currentPos=t,this.coordUtils.setZoomAndCurrentPos(this.zoom,this.currentPos)}updatePosition(t){const{zoom:e,currentPos:i}=t;this.setZoom(e),this.setCurrentPos(i),this.currentPosStorage=i,this.innerZoom=e,this.renderBasicCanvas(),this.render()}setLang(t){this.lang=t}setShowDefaultCursor(t){this.showDefaultCursor=t,this.container.style.cursor=this.defaultCursor}get forbidMouseOperation(){return this.forbidOperation||this.valid===!1}init(){this.eventUnbinding(),this.initPosition(),this.eventBinding(),this.render(),this.renderBasicCanvas()}destroy(){this.destroyCanvas(),this.eventUnbinding()}createCanvas(t){const e=document.createElement("canvas");e.setAttribute("width",`${t.width}`),e.setAttribute("height",`${t.height}`),e.style.position="absolute",e.style.left="0",e.style.top="0",e.style.zIndex="0",this.container.appendChild(e),this.basicCanvas=e;const i=document.createElement("canvas");i.setAttribute("width",`${t.width}`),i.setAttribute("height",`${t.height}`),i.style.position="absolute",i.style.left="0",i.style.top="0",i.style.zIndex="10",this.container.appendChild(i),this.canvas=i,this.container.style.cursor=this.defaultCursor}destroyCanvas(){this.canvas&&this.container.contains(this.canvas)&&this.container.removeChild(this.canvas),this.basicCanvas&&this.container.contains(this.basicCanvas)&&this.container.removeChild(this.basicCanvas),this.clearInvalidPage(),this.clearImgDrag()}setStyle(t){this.style=t,this.render()}setImgNode(t,e={}){this.imgNode=t,this.setBasicImgInfo(__spreadValues$9({width:t.width,height:t.height,valid:!0,rotate:0},e)),this.isImgError===!0&&(this.isImgError=!1,this.emit("changeAnnotationShow")),typeof e.valid=="boolean"&&this.setValid(e.valid),this.initImgPos(),this.render(),this.renderBasicCanvas()}setErrorImg(){const t=this.isImgError;this.isImgError=!0,this.imgNode=void 0,this.setBasicImgInfo({width:0,height:0,valid:!0,rotate:0}),t===!1&&this.emit("changeAnnotationShow")}setBasicImgInfo(t){this.basicImgInfo=t,this.coordUtils.setBasicImgInfo(t)}setForbidOperation(t){this.forbidOperation=t,this.render()}setForbidCursorLine(t){this.forbidCursorLine=t,this.render()}setIsHidden(t){this.isHidden=t,this.emit("hiddenChange")}setIsShowOrder(t){this.config.isShowOrder=t,this.render()}getCoordinate(t){const e=this.canvas.getBoundingClientRect();return{x:t.clientX-e.left,y:t.clientY-e.top}}getCoordinateUnderZoom(t){const e=this.canvas.getBoundingClientRect();return{x:t.clientX-e.left-this.currentPos.x,y:t.clientY-e.top-this.currentPos.y}}getGetCenterCoordinate(){return{x:this.size.width/2,y:this.size.height/2}}initPosition(){if(this.basicResult&&this.imgInfo){const{basicResult:t,size:e,imgNode:i,_imgAttribute:s,imgInfo:n,dependToolName:o}=this;if(t&&i&&o){let a=t;switch(o){case EToolName.Polygon:case EToolName.Line:{if(t.pointList){const h=MathUtils.calcViewportBoundaries(t.pointList);a={x:h.left,y:h.top,width:h.right-h.left,height:h.bottom-h.top}}break}}const l=ImgPosUtils.getBasicRecPos(i,a,e,void 0,s==null?void 0:s.zoomRatio,s==null?void 0:s.isOriginalSize);l&&(this.setCurrentPos(l.currentPos),this.currentPosStorage=this.currentPos,this.imgInfo=__spreadProps$8(__spreadValues$9({},n),{width:n.width/this.innerZoom*l.innerZoom,height:n.height/this.innerZoom*l.innerZoom}),this.innerZoom=l.innerZoom,this.setZoom(l.innerZoom),this.render(),this.renderBasicCanvas())}}else this.initImgPos()}undo(){this.history.undo()}redo(){this.history.redo()}clearCanvas(){var t;(t=this.ctx)==null||t.clearRect(0,0,this.size.width,this.size.height)}clearBasicCanvas(){var t;(t=this.basicCtx)==null||t.clearRect(0,0,this.size.width,this.size.height)}eventBinding(){this.dblClickListener.addEvent(()=>{},this.onLeftDblClick,this.onRightDblClick),this.container.addEventListener("mousedown",this.onMouseDown),this.container.addEventListener("mousemove",this.onMouseMove),this.container.addEventListener("mouseup",this.onMouseUp),this.container.addEventListener("mouseleave",this.onMouseLeave),this.container.addEventListener("click",this.onClick),this.container.addEventListener("wheel",this.onWheel),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.onKeyUp),window==null||window.parent.document.addEventListener("contextmenu",this.onContextmenu,!1)}eventUnbinding(){this.container.removeEventListener("mousedown",this.onMouseDown),this.container.removeEventListener("mousemove",this.onMouseMove),this.container.removeEventListener("mouseup",this.onMouseUp),this.container.removeEventListener("mouseleave",this.onMouseLeave),this.container.removeEventListener("wheel",this.onWheel),this.container.removeEventListener("click",this.onClick),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),window==null||window.parent.document.removeEventListener("contextmenu",this.onContextmenu,!1),this.dblClickListener.removeEvent()}clearImgDrag(){this.isDrag=!1,this.isDragStart=!1,this.isSpaceClick=!1,this.startTime=0,this.container.style.cursor=this.defaultCursor,this.forbidCursorLine=!1}onMouseDown(t){if(!this.canvas||this.isImgError)return!0;const e=this.getCoordinate(t);(this.isSpaceKey&&t.button===0||t.button===2)&&(t.stopPropagation(),this._firstClickCoordinate=e,this.currentPosStorage=this.currentPos,this.isSpaceClick=!0,this.isDragStart=!0,this.startTime=new Date().getTime())}onMouseMove(t){if(!this.canvas||this.isImgError)return!0;const e=this.getCoordinate(t);this.isShowCursor&&(this.coord=e,this.render());try{if(!e||!_.isNumber(e==null?void 0:e.x)||!_.isNumber(e==null?void 0:e.y))throw new Error("coord error");if(this.coord=e,(this.isSpaceClick||this.isDragStart)&&this._firstClickCoordinate){const i=this.getCurrentPos(e);this.setCurrentPos(i),this.isDrag=!0,this.container.style.cursor="grabbing",this.forbidCursorLine=!0,this.renderBasicCanvas(),this.emit("dependRender")}this.render()}catch(i){console.error(i)}}onMouseUp(t){if(!this.canvas||this.isImgError)return!0;if(this.container.style.cursor=this.defaultCursor,this.forbidCursorLine=!1,this.isDrag=!1,this.isDragStart=!1,this.isSpaceClick=!1,this.startTime!==0&&this._firstClickCoordinate){const e=new Date().getTime(),i=this.getCoordinate(t);if(e-this.startTime>1e3||this.isSpaceKey===!0||LineToolUtils.calcTwoPointDistance(i,this._firstClickCoordinate)>10)return t.stopPropagation(),this.startTime=0,this.render(),!0}this.startTime=0,this.render()}onMouseLeave(){this.clearImgDrag()}onClick(t){}onLeftDblClick(t){}onRightDblClick(t){this.clearImgDrag()}onKeyDown(t){switch(t.keyCode===EKeyCode$1.Alt&&t.preventDefault(),t.keyCode){case EKeyCode$1.Space:this.isSpaceKey=!0;break;case EKeyCode$1.Z:if(t.ctrlKey)return t.shiftKey?this.redo():this.undo(),!1;break}return!0}onKeyUp(t){switch(t.keyCode){case EKeyCode$1.Space:this.isSpaceKey=!1;break}}onWheel(t,e=!0){if(!this.imgNode||!this.coord)return;t.preventDefault(),t.stopPropagation();const i=this.getCoordinate(t),s=t.deltaY||t.wheelDelta;let n=0;s>0&&this.zoom>zoomInfo.min&&(n=-1),s<0&&this.zoom<zoomInfo.max&&(n=1),this.wheelChangePos(i,n),this.emit("dependRender"),e&&this.render(),this.renderBasicCanvas()}renderCursorLine(t=(e=>(e=this.style.lineColor[0])!=null?e:"")()){if(!this.ctx||this.forbidCursorLine)return;const{x:e,y:i}=this.coord;DrawUtils.drawLine(this.canvas,{x:0,y:i},{x:1e4,y:i},{color:t}),DrawUtils.drawLine(this.canvas,{x:e,y:0},{x:e,y:1e4},{color:t}),DrawUtils.drawCircleWithFill(this.canvas,{x:e,y:i},1,{color:"white"})}setSize(t){this.size=t,this.container.contains(this.canvas)&&(this.destroyCanvas(),this.createCanvas(t),this.eventUnbinding(),this.init())}setImgAttribute(t){const e=this._imgAttribute;if(this._imgAttribute=t,(e==null?void 0:e.zoomRatio)!==t.zoomRatio||e.isOriginalSize!==t.isOriginalSize){this.initImgPos();return}this.renderBasicCanvas(),this.render()}clearResult(t){}setValid(t){this.basicImgInfo.valid=t,t===!1?(this.renderInvalidPage(),this.clearResult(!1)):this.clearInvalidPage()}setRotate(t){this.basicImgInfo.rotate=t}setBasicResult(t){this.basicResult=t,this.coordUtils.setBasicResult(t),this.initPosition(),this.emit("dependRender")}setDependName(t,e){this.dependToolName=t,this.coordUtils.setDependInfo(t,e)}setAttributeLockList(t){this.attributeLockList=t,this.render()}setConfig(t){this.config=CommonToolUtils.jsonParser(t)}updateRotate(){if(this.dependToolName)return this.emit("messageInfo",Locale.getMessagesByLocale(EMessage.NoRotateInDependence,this.lang)),!1;if(this.dataList.length>0)return this.emit("messageInfo",Locale.getMessagesByLocale(EMessage.NoRotateNotice,this.lang)),!1;const t=MathUtils.getRotate(this.basicImgInfo.rotate);this.basicImgInfo.rotate=t,this.initImgPos(),this.emit("updateResult")}getColor(t="",e=this.config){var i;if((e==null?void 0:e.attributeConfigurable)===!0&&this.style.attributeColor){const o=AttributeUtils.getAttributeIndex(t,(i=e.attributeList)!=null?i:[])+1;return this.style.attributeColor[o]}const{color:s,toolColor:n}=this.style;return n?n[s]:styleDefaultConfig.toolColor["1"]}getLineColor(t=""){var e,i,s;if(((e=this.config)==null?void 0:e.attributeConfigurable)===!0){const a=AttributeUtils.getAttributeIndex(t,(s=(i=this.config)==null?void 0:i.attributeList)!=null?s:[])+1;return this.style.attributeLineColor?this.style.attributeLineColor[a]:""}const{color:n,lineColor:o}=this.style;return n&&o?o[n]:""}clearInvalidPage(){this._invalidDOM&&this.container&&this.container.contains(this._invalidDOM)&&(this.container.removeChild(this._invalidDOM),this._invalidDOM=void 0)}renderInvalidPage(){!this.container||this._invalidDOM||(this._invalidDOM=RenderDomUtils.renderInvalidPage(this.canvas,this.container,this.lang))}renderBasicCanvas(){if(!this.basicCanvas)return;this.clearBasicCanvas(),this.drawImg();const t=3;if(this.basicResult&&this.dependToolName)switch(this.dependToolName){case EToolName.Rect:{DrawUtils.drawRect(this.basicCanvas,AxisUtils.changeRectByZoom(this.basicResult,this.zoom,this.currentPos),{color:"rgba(204,204,204,1.00)",thickness:t});break}case EToolName.Polygon:{DrawUtils.drawPolygonWithFillAndLine(this.basicCanvas,AxisUtils.changePointListByZoom(this.basicResult.pointList,this.zoom,this.currentPos),{fillColor:"transparent",strokeColor:"rgba(204,204,204,1.00)",isClose:!0,thickness:t});break}case EToolName.Line:{DrawUtils.drawLineWithPointList(this.basicCanvas,AxisUtils.changePointListByZoom(this.basicResult.pointList,this.zoom,this.currentPos),{color:"rgba(204,204,204,1.00)",thickness:t});break}}}render(){!this.canvas||!this.ctx||!this.imgNode||this.clearCanvas()}changeStyle(t=this.defaultAttribute){this.emit("changeStyle",{attribute:t})}}var __defProp$8=Object.defineProperty,__getOwnPropSymbols$8=Object.getOwnPropertySymbols,__hasOwnProp$8=Object.prototype.hasOwnProperty,__propIsEnum$8=Object.prototype.propertyIsEnumerable,__defNormalProp$8=(r,t,e)=>t in r?__defProp$8(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,__spreadValues$8=(r,t)=>{for(var e in t||(t={}))__hasOwnProp$8.call(t,e)&&__defNormalProp$8(r,e,t[e]);if(__getOwnPropSymbols$8)for(var e of __getOwnPropSymbols$8(t))__propIsEnum$8.call(t,e)&&__defNormalProp$8(r,e,t[e]);return r};const TEXT_ATTRIBUTE_OFFSET$1={x:8,y:26},newScope$1=2;class CheckOperation extends BasicToolOperation{constructor(t){super(t);this.getHoverRectID=e=>{var i,s;const n=this.getCoordinateUnderZoom(e),o=(s=(i=this.resultList.find(a=>a.toolName===EToolName.Rect))==null?void 0:i.result)!=null?s:[];if(o.length>0){const a=o.filter(l=>RectUtils.isInRect(n,l,newScope$1,this.zoom));if(a.length===0)return"";if(a.length===1)return a[0].id;if(a.length>1)return a.map(h=>({size:h.width*h.height,id:h.id})).sort((h,d)=>h.size-d.size)[0].id}return""},this.resultList=[],this.hoverID=[],this.fillID=[],this.render=this.render.bind(this),this.drawPolygon=this.drawPolygon.bind(this),this.drawRect=this.drawRect.bind(this),this.drawTag=this.drawTag.bind(this),this.setShowDefaultCursor(!0),this.forbidOperation=!0}onMouseDown(t){var e,i;if(super.onMouseDown(t)||this.forbidMouseOperation||!this.imgInfo)return!0;const s=this.mouseHoverID,n=(i=(e=this.resultList.find(o=>o.toolName===EToolName.Rect))==null?void 0:e.result)!=null?i:[];if(t.button===0){let o=[s],a=!0;s&&n.find(l=>l.id===s&&(l==null?void 0:l.isSelected))&&(a=!1),s||(o=n.map(l=>l.id),a=!1),this.emit("setSelectedID",o,a),this.render()}}updateRotate(){}onMouseMove(t){if(super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo)return;const e=this.mouseHoverID,i=this.getHoverRectID(t);if(e!==i){this.mouseHoverID=i;let s=[i];i||(s=[]),this.emit("setHoverID",s),this.render()}}setResult(t){this.resultList=_.cloneDeep(t),this.render()}drawPolygon(t,e){t==null||t.forEach(i=>{var s,n,o,a,l;const h=this.getColor(i.attribute,e),d=StyleUtils.getStrokeAndFill(h,i.valid);let u=(n=(s=this.style)==null?void 0:s.width)!=null?n:2;this.hoverID.includes(i.id)?(u=4,DrawUtils.drawPolygonWithFillAndLine(this.canvas,AxisUtils.changePointListByZoom(i.pointList,this.zoom,this.currentPos),{fillColor:d.fill,strokeColor:d.stroke,pointColor:"white",thickness:u,lineCap:"round",isClose:!0,lineType:e==null?void 0:e.lineType})):DrawUtils.drawPolygon(this.canvas,AxisUtils.changePointListByZoom(i.pointList,this.zoom,this.currentPos),{color:d.fill,lineType:(o=this.config)==null?void 0:o.lineType,thickness:u,isClose:!0}),DrawUtils.drawText(this.canvas,AxisUtils.changePointByZoom(i.pointList[0],this.zoom,this.currentPos),(l=AttributeUtils.getAttributeShowText(i.attribute,(a=e==null?void 0:e.attributeList)!=null?a:[]))!=null?l:"",__spreadValues$8({color:d.stroke},DEFAULT_TEXT_OFFSET));const c=AxisUtils.changePointListByZoom(i.pointList||[],this.zoom,this.currentPos),g=c[c.length-1];DrawUtils.drawText(this.canvas,{x:g.x+TEXT_ATTRIBUTE_OFFSET$1.x,y:g.y+TEXT_ATTRIBUTE_OFFSET$1.y},i==null?void 0:i.textAttribute,__spreadValues$8({color:d.stroke},DEFAULT_TEXT_OFFSET))})}drawRect(t,e){t==null||t.forEach(i=>{let s=1;this.hoverID.includes(i.id)&&(s=3);const n=this.getColor(i.attribute,e),o=AxisUtils.changeRectByZoom(i,this.zoom,this.currentPos);DrawUtils.drawRect(this.canvas,o,{color:(i==null?void 0:i.valid)?n.valid.stroke:n.invalid.stroke,thickness:s}),this.fillID.includes(i.id)&&DrawUtils.drawRectWithFill(this.canvas,o,{color:(i==null?void 0:i.valid)?n.valid.fill:n.invalid.fill})})}drawTag(t,e){const i=t.reduce((s,n)=>[...s,...(e==null?void 0:e.inputList)?TagUtil.getTagNameList(n.result,e.inputList):TagUtil.getTagnameListWithoutConfig(n.result)],[]);DrawUtils.drawTag(this.canvas,i)}setHoverID(t){this.hoverID=t,this.render()}setFillID(t){this.fillID=t,this.render()}render(){var t;super.render(),(t=this.resultList)==null||t.forEach(e=>{switch(e==null?void 0:e.toolName){case EToolName.Rect:this.drawRect(e.result,CommonToolUtils.jsonParser(e.config));break;case EToolName.Polygon:this.drawPolygon(e.result,CommonToolUtils.jsonParser(e.config));break;case EToolName.Tag:this.drawTag(e.result,CommonToolUtils.jsonParser(e.config));break}})}exportData(){return[[],{}]}}class CanvasUtils{static getMousePositionOnCanvasFromEvent(t,e){if(e&&t){const i=e.getBoundingClientRect();return{x:t.clientX-i.left,y:t.clientY-i.top}}return null}static getClientRect(t){if(t){const e=t.getBoundingClientRect();return{x:e.left,y:e.top,width:e.width,height:e.height}}return null}static getSize(t){if(t){const e=t.getBoundingClientRect();return{width:e.width,height:e.height}}return null}static inViewPort(t,e){return t?MathUtils.isInRange(t.x,[e.left,e.right])&&MathUtils.isInRange(t.y,[e.top,e.bottom]):!1}}CanvasUtils.getViewPort=(r,t,e)=>{const{width:i,height:s}=r,{x:n,y:o}=t,a=(0-o)/e,l=(0-n)/e,h=a+s/e,d=l+i/e;return{top:a,bottom:h,left:l,right:d}};const defaultWidth=30,DEFAULT_TEXT_WIDTH=164;class TextAttributeClass{constructor(t){this.textKeyDown=l=>{switch(l.stopPropagation(),l.keyCode){case EKeyCode$1.Enter:this.submitTextarea(),this.appendToContainer();break}};const{container:e,icon:i,color:s,getCurrentSelectedData:n,updateSelectedTextAttribute:o}=t,a=t.width||DEFAULT_TEXT_WIDTH;this.container=e,this.getCurrentSelectedData=n,this.updateSelectedTextAttribute=o,this._textAttributeDOM=this.initTextAttributeDOM(),this._iconDOM=this.initIconDOM(i),this._textDOM=this.initTextDOM(a,TEXT_ATTRIBUTE_LINE_HEIGHT),this._textareaDOM=this.initTextareaDOM(a,s),this.appendToContainer()}get isExit(){return this._textAttributeDOM?this.container.contains(this._textAttributeDOM):!1}get isExitTextareaDOM(){return this._textareaDOM?this.container.contains(this._textareaDOM):!1}updateIcon(t){this._iconDOM&&(this._iconDOM.innerHTML=t)}appendToContainer(){!this._textAttributeDOM||!this._textDOM||!this._iconDOM||(this.container.appendChild(this._textAttributeDOM),this._textAttributeDOM.appendChild(this._textDOM),this._textAttributeDOM.appendChild(this._iconDOM))}initTextAttributeDOM(){const t=document.createElement("div");return t.setAttribute("id","textArea"),t}initTextDOM(t,e){const i=document.createElement("span");return i.setAttribute("style",`
|
|
23
23
|
width: ${Math.max(t,defaultWidth)}px;
|
|
24
24
|
line-height: ${e}px;
|
|
25
25
|
word-break: break-all;
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
left:${s}px;
|
|
56
56
|
top: ${n}px;
|
|
57
57
|
color: ${o};
|
|
58
|
-
`),this._textDOM&&(this._textDOM.innerHTML=`${t}`),this._textareaDOM&&(this._textareaDOM.style.width=`${l}px`,this._textareaDOM.style.borderColor=`${o}`)}changeSelected(){this.isExitTextareaDOM&&this.submitTextarea()}}var __defProp$7=Object.defineProperty,__defProps$7=Object.defineProperties,__getOwnPropDescs$7=Object.getOwnPropertyDescriptors,__getOwnPropSymbols$7=Object.getOwnPropertySymbols,__hasOwnProp$7=Object.prototype.hasOwnProperty,__propIsEnum$7=Object.prototype.propertyIsEnumerable,__defNormalProp$7=(r,t,e)=>t in r?__defProp$7(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,__spreadValues$7=(r,t)=>{for(var e in t||(t={}))__hasOwnProp$7.call(t,e)&&__defNormalProp$7(r,e,t[e]);if(__getOwnPropSymbols$7)for(var e of __getOwnPropSymbols$7(t))__propIsEnum$7.call(t,e)&&__defNormalProp$7(r,e,t[e]);return r},__spreadProps$7=(r,t)=>__defProps$7(r,__getOwnPropDescs$7(t));const TEXT_MAX_WIDTH=164,TEXT_ATTRIBUTE_OFFSET={x:8,y:26};class PolygonOperation extends BasicToolOperation{constructor(t){super(t);this.isAllowDouble=e=>{const{selectedID:i}=this,s=this.getHoverID(e);return!!(i&&i===s)},this.textChange=e=>{this.config.textConfigurable===!1||!this.selectedID||(this.setPolygonList(AttributeUtils.textChange(e,this.selectedID,this.polygonList)),this.emit("selectedChange"),this.render())},this.config=CommonToolUtils.jsonParser(t.config),this.drawingPointList=[],this.polygonList=[],this.hoverPointIndex=-1,this.hoverEdgeIndex=-1,this.drawingHistory=new ActionsHistory,this.isCtrl=!1,this.isAlt=!1,this.getCurrentSelectedData=this.getCurrentSelectedData.bind(this),this.updateSelectedTextAttribute=this.updateSelectedTextAttribute.bind(this)}eventBinding(){super.eventBinding(),this.container.removeEventListener("mouseup",this.onMouseUp),this.container.addEventListener("mouseup",this.dragMouseUp),this.dblClickListener.addEvent(this.onMouseUp,this.onLeftDblClick,this.onRightDblClick,this.isAllowDouble)}eventUnbinding(){super.eventUnbinding(),this.container.removeEventListener("mouseup",this.dragMouseUp)}destroy(){super.destroy(),this._textAttributInstance&&this._textAttributInstance.clearTextAttribute()}get selectedPolygon(){return PolygonUtils.getPolygonByID(this.polygonList,this.selectedID)}get polygonListUnderZoom(){return this.polygonList.map(t=>__spreadProps$7(__spreadValues$7({},t),{pointList:AxisUtils.changePointListByZoom(t.pointList,this.zoom)}))}get selectedText(){var t;return(t=this.selectedPolygon)==null?void 0:t.textAttribute}get dataList(){return this.polygonList}get currentShowList(){let t=[];const[e,i]=CommonToolUtils.getRenderResultList(this.polygonList,CommonToolUtils.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);return t=e,this.isHidden&&(t=[]),i&&t.push(i),t}get currentPageResult(){const[t]=CommonToolUtils.getRenderResultList(this.polygonList,CommonToolUtils.getSourceID(this.basicResult),[]);return t}setResult(t){this.clearActiveStatus(),this.setPolygonList(t),this.render()}setPolygonDataByID(t,e){return this.polygonList.map(i=>i.id===e?__spreadValues$7(__spreadValues$7({},i),t):i)}addPointInDrawing(t){if(!this.imgInfo)return;const{upperLimitPointNum:e,edgeAdsorption:i}=this.config;if(e&&this.drawingPointList.length>=e){this.emit("messageInfo",`${Locale.getMessagesByLocale(EMessage.UpperLimitErrorNotice,this.lang)}${e}`);return}this.setSelectedID("");const s=this.getCoordinateUnderZoom(t),n=AxisUtils.changeDrawOutsideTarget(s,{x:0,y:0},this.imgInfo,this.config.drawOutsideTarget,this.basicResult,this.zoom);if(AxisUtils.returnClosePointIndex(n,AxisUtils.changePointListByZoom(this.drawingPointList,this.zoom))===0){this.addDrawingPointToPolygonList();return}const{dropFoot:a}=PolygonUtils.getClosestPoint(n,this.polygonListUnderZoom,this.config.lineType,edgeAdsorptionScope),l=AxisUtils.changePointByZoom(a&&t.altKey===!1&&i?a:n,1/this.zoom);this.drawingPointList.push(l),this.drawingPointList.length===1?this.drawingHistory.initRecord(this.drawingPointList):this.drawingHistory.pushHistory(this.drawingPointList)}clearResult(){this.setPolygonList([]),this.setSelectedID(void 0),this.render()}clearPolygonDrag(){this.drawingPointList=[],this.dragInfo=void 0,this.dragInfo=void 0,this.dragStatus=EDragStatus.Wait,this.hoverEdgeIndex=-1,this.hoverPointIndex=-1,this.hoverID=""}clearActiveStatus(){this.clearPolygonDrag(),this.setSelectedID(void 0)}setPolygonList(t){const e=this.polygonList.length;this.polygonList=t,e!==t.length&&this.emit("updatePageNumber")}setSelectedID(t){var e,i;const s=this.selectedID;t!==s&&s&&((e=this._textAttributInstance)==null||e.changeSelected()),t||(i=this._textAttributInstance)==null||i.clearTextAttribute(),this.selectedID=t,this.render(),this.emit("selectedChange")}setDefaultAttribute(t=""){const e=this.defaultAttribute;if(this.defaultAttribute=t,e!==t){this.changeStyle(t),this.emit("changeAttributeSidebar");const{selectedID:i}=this;if(i&&(this.selectedPolygon&&(this.selectedPolygon.attribute=t),this.history.pushHistory(this.polygonList),this.render()),this._textAttributInstance){if(this.attributeLockList.length>0&&!this.attributeLockList.includes(t)){this._textAttributInstance.clearTextAttribute();return}this._textAttributInstance.updateIcon(this.getTextIconSvg(t))}}}setStyle(t){var e;super.setStyle(t),this._textAttributInstance&&this.config.attributeConfigurable===!1&&((e=this._textAttributInstance)==null||e.updateIcon(this.getTextIconSvg()))}setPolygonValidAndRender(t){if(!t)return;const e=this.polygonList.map(i=>i.id===t?__spreadProps$7(__spreadValues$7({},i),{valid:!i.valid}):i);this.setPolygonList(e),this.history.pushHistory(this.polygonList),this.render(),this.emit("updateResult")}addDrawingPointToPolygonList(){let{lowerLimitPointNum:t=3}=this.config;if(t<3&&(t=3),this.drawingPointList.length<t){this.drawingPointList=[],this.editPolygonID="";return}const e=CommonToolUtils.getSourceID(this.basicResult),i=[...this.polygonList];if(this.editPolygonID){const s=i.find(n=>n.id===this.editPolygonID);if(!s)return;s.pointList=this.drawingPointList,this.editPolygonID=""}else{const s=uuid(8,62);let n={id:s,sourceID:e,valid:!this.isCtrl,textAttribute:"",pointList:this.drawingPointList,attribute:this.defaultAttribute,order:CommonToolUtils.getMaxOrder(i.filter(o=>CommonToolUtils.isSameSourceID(o.sourceID,e)))+1};if(this.config.textConfigurable){let o="";o=AttributeUtils.getTextAttribute(this.polygonList.filter(a=>CommonToolUtils.isSameSourceID(a.sourceID,e)),this.config.textCheckType),n=__spreadProps$7(__spreadValues$7({},n),{textAttribute:o})}i.push(n),this.setSelectedIdAfterAddingDrawing(s)}this.setPolygonList(i),this.isCtrl=!1,this.drawingPointList=[],this.history.pushHistory(i)}setSelectedIdAfterAddingDrawing(t){this.drawingPointList.length!==0&&(this.config.textConfigurable?this.setSelectedID(t):this.setSelectedID())}getHoverID(t){var e;const i=this.getCoordinateUnderZoom(t),s=this.currentShowList.map(n=>__spreadProps$7(__spreadValues$7({},n),{pointList:AxisUtils.changePointListByZoom(n.pointList,this.zoom)}));return PolygonUtils.getHoverPolygonID(i,s,10,(e=this.config)==null?void 0:e.lineType)}getHoverEdgeIndex(t){var e;if(!this.selectedID)return-1;const i=this.selectedPolygon;if(!i)return-1;const s=this.getCoordinateUnderZoom(t),n=AxisUtils.changePointListByZoom(i.pointList,this.zoom);return PolygonUtils.getHoverEdgeIndex(s,n,(e=this.config)==null?void 0:e.lineType)}getHoverPointIndex(t){if(!this.selectedID)return-1;const e=this.selectedPolygon;if(!e)return-1;const i=this.getCoordinateUnderZoom(t),s=AxisUtils.changePointListByZoom(e.pointList,this.zoom);return AxisUtils.returnClosePointIndex(i,s)}deletePolygon(t){var e;!t||(this.setPolygonList(this.polygonList.filter(i=>i.id!==t)),this.history.pushHistory(this.polygonList),(e=this._textAttributInstance)==null||e.clearTextAttribute(),this.emit("selectedChange"),this.render())}deletePolygonPoint(t){if(!this.selectedID)return;const{selectedPolygon:e}=this;if(!e)return;let{lowerLimitPointNum:i}=this.config;if(i<3&&(i=3),e.pointList.length<=i){this.emit("messageInfo",`${Locale.getMessagesByLocale(EMessage.LowerLimitErrorNotice,this.lang)}${i}`);return}e==null||e.pointList.splice(t,1),this.history.pushHistory(this.polygonList),this.render()}spaceKeydown(){var t,e;this.selectedID&&(this.editPolygonID=this.selectedID,this.drawingPointList=(e=(t=this.selectedPolygon)==null?void 0:t.pointList)!=null?e:[],this.drawingHistory.empty(),this.drawingHistory.initRecord(this.drawingPointList),this.hoverID="",this.setSelectedID(""),this.render())}onTabKeyDown(t){if(t.preventDefault(),this.drawingPointList.length>0)return;let e=ESortDirection.ascend;t.shiftKey&&(e=ESortDirection.descend);const[i,s]=CommonToolUtils.getRenderResultList(this.polygonList,CommonToolUtils.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);let n=[...i];s&&(n=[...n,s]);const o=CanvasUtils.getViewPort(this.canvas,this.currentPos,this.zoom),a=n.map(h=>{var d,u,c,g;return __spreadProps$7(__spreadValues$7({},h),{x:(u=(d=h.pointList[0])==null?void 0:d.x)!=null?u:0,y:(g=(c=h.pointList[0])==null?void 0:c.y)!=null?g:0})}).filter(h=>CanvasUtils.inViewPort({x:h.x,y:h.y},o)),l=CommonToolUtils.getNextSelectedRectID(a,e,this.selectedID);if(l){this.setSelectedID(l.id);const{selectedPolygon:h}=this;h&&this.setDefaultAttribute(h.attribute)}this.render()}onKeyDown(t){if(!CommonToolUtils.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;const{keyCode:e}=t;switch(e){case EKeyCode$1.Space:this.spaceKeydown();break;case EKeyCode$1.Esc:this.drawingPointList=[],this.editPolygonID="";break;case EKeyCode$1.F:this.selectedID&&this.setPolygonValidAndRender(this.selectedID);break;case EKeyCode$1.Z:this.setIsHidden(!this.isHidden),this.render();break;case EKeyCode$1.Delete:this.deletePolygon(this.selectedID),this.render();break;case EKeyCode$1.Ctrl:this.isCtrl=!0;break;case EKeyCode$1.Alt:this.isAlt===!1&&(t.preventDefault(),this.isAlt=!0,this.render());break;case EKeyCode$1.Tab:{this.onTabKeyDown(t);break}default:{if(this.config.attributeConfigurable){const i=AttributeUtils.getAttributeByKeycode(e,this.config.attributeList);i!==void 0&&this.setDefaultAttribute(i)}break}}}onKeyUp(t){switch(super.onKeyUp(t),t.keyCode){case EKeyCode$1.Ctrl:this.isCtrl=!1;break;case EKeyCode$1.Alt:{const e=this.isAlt;this.isAlt=!1,e===!0&&this.render();break}}}rightMouseUp(){if(this.drawingPointList.length>0){this.addDrawingPointToPolygonList();return}this.setSelectedID(this.hoverID);const{selectedPolygon:t}=this;t&&this.setDefaultAttribute(t.attribute)}onLeftDblClick(t){if(this.hoverEdgeIndex>-1){const e=this.getCoordinateUnderZoom(t),{selectedPolygon:i}=this;if(!i)return;const{dropFoot:s}=PolygonUtils.getClosestPoint(e,this.polygonListUnderZoom,this.config.lineType,edgeAdsorptionScope);if(!s)return;const{upperLimitPointNum:n}=this.config;if(n&&i.pointList.length>=n){this.emit("messageInfo",`${Locale.getMessagesByLocale(EMessage.UpperLimitErrorNotice,this.lang)}${n}`),this.clearPolygonDrag();return}i==null||i.pointList.splice(this.hoverEdgeIndex+1,0,AxisUtils.changePointByZoom(s,1/this.zoom)),this.setPolygonDataByID(i,this.selectedID),this.history.pushHistory(this.polygonList),this.hoverPointIndex=-1,this.hoverEdgeIndex=-1,this.render()}this.dragInfo=void 0}onRightDblClick(t){this.dragInfo=void 0,this.clearImgDrag();const e=this.getHoverID(t),i=this.getHoverPointIndex(t);if(this.hoverPointIndex>-1&&this.hoverPointIndex===i){this.deletePolygonPoint(i),this.dragInfo=void 0,this.hoverPointIndex=-1,this.render();return}this.hoverID===this.selectedID&&this.deletePolygon(e),this.render()}onMouseDown(t){if(super.onMouseDown(t)||this.forbidMouseOperation||t.ctrlKey===!0)return;const e=this.selectedPolygon;if(!e||t.button!==0||this.getHoverID(t)!==this.selectedID)return;const s=e.pointList,n=this.getCoordinateUnderZoom(t);let o=[0],a=EDragTarget.Plane;this.dragStatus=EDragStatus.Start;const l=this.getHoverPointIndex(t),h=this.getHoverEdgeIndex(t);return l>-1?(a=EDragTarget.Point,o=[l]):h>-1&&this.hoverEdgeIndex>-1&&(a=EDragTarget.Line,o=[h,(h+1)%s.length]),this.dragInfo={dragStartCoord:n,dragTarget:a,initPointList:s,changePointIndex:o},!0}onDragMove(t){var e;if(!this.dragInfo||!this.selectedID)return;let i=(e=this.selectedPolygon)==null?void 0:e.pointList;if(!i)return;const{initPointList:s,dragStartCoord:n,dragTarget:o,changePointIndex:a}=this.dragInfo,l=this.getCoordinateUnderZoom(t),h={x:(l.x-n.x)/this.zoom,y:(l.y-n.y)/this.zoom};switch(this.dragStatus=EDragStatus.Move,o){case EDragTarget.Plane:i=i.map((u,c)=>__spreadProps$7(__spreadValues$7({},u),{x:s[c].x+h.x,y:s[c].y+h.y}));break;case EDragTarget.Point:case EDragTarget.Line:i=i.map((u,c)=>a&&a.includes(c)?__spreadProps$7(__spreadValues$7({},u),{x:s[c].x+h.x,y:s[c].y+h.y}):u);break}if(this.config.drawOutsideTarget===!1&&this.imgInfo){if(this.dependToolName&&this.basicCanvas&&this.basicResult){let p=!1;switch(this.dependToolName){case EToolName.Rect:{p=i.filter(b=>!RectUtils.isInRect(b,this.basicResult)).length>0;break}case EToolName.Polygon:{p=PolygonUtils.isPointListOutSidePolygon(i,this.basicResult.pointList,this.config.lineType);break}}if(p)return}const{left:u,top:c,right:g,bottom:f}=MathUtils.calcViewportBoundaries(AxisUtils.changePointListByZoom(i,this.zoom)),v=1e-5;if(u<0||c<0||g>this.imgInfo.width+v||f>this.imgInfo.height+v)return}const d=this.polygonList.map(u=>u.id===this.selectedID?__spreadProps$7(__spreadValues$7({},u),{pointList:i}):u);this.setPolygonList(d),this.render()}onMouseMove(t){if(super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo)return;if(this.selectedID&&this.dragInfo){this.onDragMove(t);return}let e=-1,i=-1;const{selectedID:s}=this;if(s&&(this.hoverEdgeIndex=-1,this.hoverPointIndex=-1,e=this.getHoverPointIndex(t),e>-1?this.hoverPointIndex=e:(i=this.getHoverEdgeIndex(t),this.hoverEdgeIndex=i)),this.drawingPointList.length>0)return;const n=this.getHoverID(t);this.hoverID!==n&&(this.hoverID=n,this.render())}leftMouseUp(t){const e=this.getHoverID(t);if(this.drawingPointList.length===0&&t.ctrlKey===!0&&e){this.setPolygonValidAndRender(e);return}this.addPointInDrawing(t)}onMouseUp(t){if(!(super.onMouseUp(t)||this.forbidMouseOperation||!this.imgInfo)){if(this.dragInfo&&this.dragStatus===EDragStatus.Move){this.dragInfo=void 0,this.dragStatus=EDragStatus.Wait,this.history.pushHistory(this.polygonList),this.emit("updateResult");return}switch(t.button){case 0:{this.leftMouseUp(t);break}case 2:{this.rightMouseUp();break}}this.render()}}dragMouseUp(){this.dragStatus===EDragStatus.Start&&(this.dragInfo=void 0,this.dragStatus=EDragStatus.Wait)}exportData(){const{polygonList:t}=this;return[t,this.basicImgInfo]}getTextIconSvg(t=""){return AttributeUtils.getTextIconSvg(t,this.config.attributeList,this.config.attributeConfigurable,this.baseIcon)}getCurrentSelectedData(){const{selectedPolygon:t}=this;if(!t)return;const e=this.getColor(t.attribute),i=t.valid?e==null?void 0:e.valid.stroke:e==null?void 0:e.invalid.stroke;return{width:TEXT_MAX_WIDTH,textAttribute:t.textAttribute,color:i}}updateSelectedTextAttribute(t){if(this._textAttributInstance&&t&&this.selectedID){let e=t;AttributeUtils.textAttributeValidate(this.config.textCheckType,"",e)===!1&&(this.emit("messageError",AttributeUtils.getErrorNotice(this.config.textCheckType,this.lang)),e=""),this.setPolygonList(AttributeUtils.textChange(e,this.selectedID,this.polygonList)),this.emit("updateTextAttribute"),this.render()}}renderTextAttribute(){var t;const{selectedPolygon:e}=this;if(!this.ctx||this.config.textConfigurable===!1||!e)return;const{pointList:i,attribute:s,valid:n,textAttribute:o}=e,{x:a,y:l}=i[i.length-1],h=TEXT_MAX_WIDTH,d=AxisUtils.getOffsetCoordinate({x:a,y:l},this.currentPos,this.zoom),u=this.getColor(s),c=n?u==null?void 0:u.valid.stroke:u==null?void 0:u.invalid.stroke;this._textAttributInstance||(this._textAttributInstance=new TextAttributeClass({width:h,container:this.container,icon:this.getTextIconSvg(s),color:c,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedTextAttribute})),this._textAttributInstance&&!((t=this._textAttributInstance)==null?void 0:t.isExit)&&this._textAttributInstance.appendToContainer(),this._textAttributInstance.update(`${o}`,{left:d.x,top:d.y,color:c,width:h})}renderPolygon(){var t,e,i,s,n,o,a,l,h;if(this.isHidden===!1&&((t=this.polygonList)==null||t.forEach(c=>{var g,f,v,p,b;if([this.selectedID,this.editPolygonID].includes(c.id))return;const{textAttribute:x,attribute:y}=c,I=this.getColor(y),m=StyleUtils.getStrokeAndFill(I,c.valid),L=AxisUtils.changePointListByZoom(c.pointList||[],this.zoom,this.currentPos);DrawUtils.drawPolygonWithFillAndLine(this.canvas,L,{fillColor:m.fill,strokeColor:m.stroke,pointColor:"white",thickness:(f=(g=this.style)==null?void 0:g.width)!=null?f:2,lineCap:"round",isClose:!0,lineType:(v=this.config)==null?void 0:v.lineType});let w=`${(p=AttributeUtils.getAttributeShowText(y,this.config.attributeList))!=null?p:""}`;((b=this.config)==null?void 0:b.isShowOrder)&&(c==null?void 0:c.order)>0&&(w=`${c.order} ${w}`),DrawUtils.drawText(this.canvas,L[0],w,__spreadValues$7({color:m.stroke},DEFAULT_TEXT_OFFSET));const C=L[L.length-1];DrawUtils.drawText(this.canvas,{x:C.x+TEXT_ATTRIBUTE_OFFSET.x,y:C.y+TEXT_ATTRIBUTE_OFFSET.y},x,__spreadValues$7({color:m.stroke},DEFAULT_TEXT_OFFSET))})),this.hoverID&&this.hoverID!==this.editPolygonID){const c=this.polygonList.find(g=>g.id===this.hoverID&&g.id!==this.selectedID);if(c){let g="";const f=this.getColor(c.attribute);c.valid?g=f.validHover.fill:g=StyleUtils.getStrokeAndFill(f,!1,{isHover:!0}).fill,DrawUtils.drawPolygonWithFill(this.canvas,AxisUtils.changePointListByZoom(c.pointList,this.zoom,this.currentPos),{color:g,lineType:(e=this.config)==null?void 0:e.lineType})}}if(this.selectedID){const c=this.selectedPolygon;if(c){const g=this.getColor(c.attribute),f=StyleUtils.getStrokeAndFill(g,c.valid,{isSelected:!0});DrawUtils.drawSelectedPolygonWithFillAndLine(this.canvas,AxisUtils.changePointListByZoom(c.pointList,this.zoom,this.currentPos),{fillColor:f.fill,strokeColor:f.stroke,pointColor:"white",thickness:2,lineCap:"round",isClose:!0,lineType:(i=this.config)==null?void 0:i.lineType});let v=`${(s=AttributeUtils.getAttributeShowText(c.attribute,this.config.attributeList))!=null?s:""}`;((n=this.config)==null?void 0:n.isShowOrder)&&(c==null?void 0:c.order)>0&&(v=`${c.order} ${v}`),DrawUtils.drawText(this.canvas,AxisUtils.changePointByZoom(c.pointList[0],this.zoom,this.currentPos),v,__spreadValues$7({color:f.stroke},DEFAULT_TEXT_OFFSET)),this.renderTextAttribute()}}const d=this.getColor(this.defaultAttribute),u=StyleUtils.getStrokeAndFill(d,!this.isCtrl);if(((o=this.drawingPointList)==null?void 0:o.length)>0){const c=[...this.drawingPointList];let g=AxisUtils.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);if(((a=this.config)==null?void 0:a.edgeAdsorption)&&this.isAlt===!1){const{dropFoot:f}=PolygonUtils.getClosestPoint(g,this.polygonList,(l=this.config)==null?void 0:l.lineType,edgeAdsorptionScope/this.zoom);f&&(g=f)}c.push(g),DrawUtils.drawSelectedPolygonWithFillAndLine(this.canvas,AxisUtils.changePointListByZoom(c,this.zoom,this.currentPos),{fillColor:u.fill,strokeColor:u.stroke,pointColor:"white",thickness:2,lineCap:"round",isClose:!1,lineType:this.config.lineType})}if(this.hoverPointIndex>-1&&this.selectedID){const c=this.selectedPolygon;if(!c)return;const g=StyleUtils.getStrokeAndFill(d,c.valid,{isSelected:!0}),f=c==null?void 0:c.pointList[this.hoverPointIndex];if(f){const{x:v,y:p}=AxisUtils.changePointByZoom(f,this.zoom,this.currentPos);DrawUtils.drawCircleWithFill(this.canvas,{x:v,y:p},5,{color:g.fill})}}if(this.hoverEdgeIndex>-1&&this.selectedID){const c=this.selectedPolygon;if(!c)return;const g=StyleUtils.getStrokeAndFill(d,c.valid,{isSelected:!0});DrawUtils.drawLineWithPointList(this.canvas,AxisUtils.changePointListByZoom(c.pointList,this.zoom,this.currentPos),{color:g.stroke,thickness:10,hoverEdgeIndex:this.hoverEdgeIndex,lineType:(h=this.config)==null?void 0:h.lineType})}}render(){!this.ctx||(super.render(),this.renderCursorLine(this.getLineColor(this.defaultAttribute)),this.renderPolygon())}undo(){if(this.drawingPointList.length>0){const e=this.drawingHistory.undo();if(!e)return;this.drawingPointList=e,this.render();return}const t=this.history.undo();t&&(t.length!==this.polygonList.length&&this.setSelectedID(""),this.setPolygonList(t),this.render())}redo(){if(this.drawingPointList.length>0){const e=this.drawingHistory.redo();if(!e)return;this.drawingPointList=e,this.render();return}const t=this.history.redo();t&&(t.length!==this.polygonList.length&&this.setSelectedID(""),this.setPolygonList(t),this.render())}}class TagOperation extends BasicToolOperation{constructor(t){super(t);this.getInitResultList=(e,i)=>!(e===0||e===void 0)&&i.length===0?[]:TagUtil.getDefaultTagResult(this.config.inputList,i),this.setLabel=(e,i)=>{var s,n;if(this.isImgError||!this.basicResult&&this.dependToolName)return;const o=this.config.inputList;if(!o[e])return;const{subSelected:a}=o[e];if(e<o.length&&o[e].subSelected&&a&&i<a.length){const l=o[e].value;let h=(s=a[i])==null?void 0:s.value;const d=(n=o[e])==null?void 0:n.isMulti,u=this.tagResult.filter(c=>{const g=`${c.sourceID}`;return CommonToolUtils.isSameSourceID(g,this.sourceID)})[0];if(u){let c=0;const{result:g}=u;u.sourceID===0&&(u.sourceID="0");for(const f in u.result)if(f===o[e].value){if(c++,d===!0){const v=g[f].split(";").filter(b=>b!==""),p=v.indexOf(h);p===-1?v.push(h):v.splice(p,1),h=v.join(";")}h===""?Object.keys(g).length===1?this.tagResult=this.tagResult.filter(v=>{const p=`${v.sourceID}`;return CommonToolUtils.isDifferSourceID(p,this.sourceID)}):Object.keys(g).length>1&&delete g[f]:g[f]=h}c===0&&Object.assign(u.result,{[l]:h})}else this.tagResult=[{sourceID:this.sourceID,id:uuid(8,62),result:{[l]:h}}];this.render()}},this.clearResult=(e=!0,i)=>{i?this.tagResult=this.tagResult.map(s=>((s==null?void 0:s.result[i])&&delete s.result[i],s)):this.tagResult=[],this.render()},this.config=CommonToolUtils.jsonParser(t.config),this.tagResult=[],this.labelSelectedList=[],this.setShowDefaultCursor(!0)}destroy(){this.clearTag(),super.destroy()}setResult(t){this.tagResult=t,this.render()}get currentPageResult(){return[this.currentTagResult]}get currentTagResult(){var t;return(t=this.tagResult.filter(e=>{const i=`${e.sourceID}`;return CommonToolUtils.isSameSourceID(i,this.sourceID)})[0])!=null?t:{}}get sourceID(){return CommonToolUtils.getSourceID(this.basicResult)}onKeyDown(t){if(!CommonToolUtils.hotkeyFilter(t))return;let{keyCode:e}=t;if(e&&(e<=57&&e>=49||e<=105&&e>=97)){if(e>57?e-=97:e-=49,this.config.inputList.length===1){this.labelSelectedList=[0,e],this.setLabel(0,e),setTimeout(()=>{this.labelSelectedList=[],this.render()},500);return}this.labelSelectedList.length===1?(this.labelSelectedList=[this.labelSelectedList[0],e],this.setLabel(this.labelSelectedList[0],e),setTimeout(()=>{this.labelSelectedList=[],this.render()},500)):(this.labelSelectedList=[e],this.emit("expend"))}}clearTag(){var t;const e=(t=this.canvas)==null?void 0:t.parentNode,i=window.self.document.getElementById("tagToolTag");i&&e&&e.contains(i)&&(e==null||e.removeChild(i))}renderTag(){var t,e,i,s,n,o;if(this.clearTag(),!(((t=this.tagResult)==null?void 0:t.length)>0))return;const a=document.createElement("div"),l=TagUtil.getTagNameList((i=(e=this.currentTagResult)==null?void 0:e.result)!=null?i:{},this.config.inputList);a.innerHTML=(s=l.reduce((h,d)=>`${h}${d.keyName}: ${d.value.join(" \u3001 ")}
|
|
58
|
+
`),this._textDOM&&(this._textDOM.innerHTML=`${t}`),this._textareaDOM&&(this._textareaDOM.style.width=`${l}px`,this._textareaDOM.style.borderColor=`${o}`)}changeSelected(){this.isExitTextareaDOM&&this.submitTextarea()}}var __defProp$7=Object.defineProperty,__defProps$7=Object.defineProperties,__getOwnPropDescs$7=Object.getOwnPropertyDescriptors,__getOwnPropSymbols$7=Object.getOwnPropertySymbols,__hasOwnProp$7=Object.prototype.hasOwnProperty,__propIsEnum$7=Object.prototype.propertyIsEnumerable,__defNormalProp$7=(r,t,e)=>t in r?__defProp$7(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,__spreadValues$7=(r,t)=>{for(var e in t||(t={}))__hasOwnProp$7.call(t,e)&&__defNormalProp$7(r,e,t[e]);if(__getOwnPropSymbols$7)for(var e of __getOwnPropSymbols$7(t))__propIsEnum$7.call(t,e)&&__defNormalProp$7(r,e,t[e]);return r},__spreadProps$7=(r,t)=>__defProps$7(r,__getOwnPropDescs$7(t));const TEXT_MAX_WIDTH=164,TEXT_ATTRIBUTE_OFFSET={x:8,y:26};class PolygonOperation extends BasicToolOperation{constructor(t){super(t);this.isAllowDouble=e=>{const{selectedID:i}=this,s=this.getHoverID(e);return!!(i&&i===s)},this.textChange=e=>{this.config.textConfigurable===!1||!this.selectedID||(this.setPolygonList(AttributeUtils.textChange(e,this.selectedID,this.polygonList)),this.emit("selectedChange"),this.render())},this.config=CommonToolUtils.jsonParser(t.config),this.drawingPointList=[],this.polygonList=[],this.hoverPointIndex=-1,this.hoverEdgeIndex=-1,this.drawingHistory=new ActionsHistory,this.isCtrl=!1,this.isAlt=!1,this.getCurrentSelectedData=this.getCurrentSelectedData.bind(this),this.updateSelectedTextAttribute=this.updateSelectedTextAttribute.bind(this)}eventBinding(){super.eventBinding(),this.container.removeEventListener("mouseup",this.onMouseUp),this.container.addEventListener("mouseup",this.dragMouseUp),this.dblClickListener.addEvent(this.onMouseUp,this.onLeftDblClick,this.onRightDblClick,this.isAllowDouble)}eventUnbinding(){super.eventUnbinding(),this.container.removeEventListener("mouseup",this.dragMouseUp)}destroy(){super.destroy(),this._textAttributInstance&&this._textAttributInstance.clearTextAttribute()}get selectedPolygon(){return PolygonUtils.getPolygonByID(this.polygonList,this.selectedID)}get polygonListUnderZoom(){return this.polygonList.map(t=>__spreadProps$7(__spreadValues$7({},t),{pointList:AxisUtils.changePointListByZoom(t.pointList,this.zoom)}))}get selectedText(){var t;return(t=this.selectedPolygon)==null?void 0:t.textAttribute}get dataList(){return this.polygonList}get currentShowList(){let t=[];const[e,i]=CommonToolUtils.getRenderResultList(this.polygonList,CommonToolUtils.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);return t=e,this.isHidden&&(t=[]),i&&t.push(i),t}get currentPageResult(){const[t]=CommonToolUtils.getRenderResultList(this.polygonList,CommonToolUtils.getSourceID(this.basicResult),[]);return t}setResult(t){this.clearActiveStatus(),this.setPolygonList(t),this.render()}setPolygonDataByID(t,e){return this.polygonList.map(i=>i.id===e?__spreadValues$7(__spreadValues$7({},i),t):i)}addPointInDrawing(t){if(!this.imgInfo)return;const{upperLimitPointNum:e,edgeAdsorption:i}=this.config;if(e&&this.drawingPointList.length>=e){this.emit("messageInfo",`${Locale.getMessagesByLocale(EMessage.UpperLimitErrorNotice,this.lang)}${e}`);return}this.setSelectedID("");const s=this.getCoordinateUnderZoom(t),n=AxisUtils.changeDrawOutsideTarget(s,{x:0,y:0},this.imgInfo,this.config.drawOutsideTarget,this.basicResult,this.zoom);if(AxisUtils.returnClosePointIndex(n,AxisUtils.changePointListByZoom(this.drawingPointList,this.zoom))===0){this.addDrawingPointToPolygonList();return}const{dropFoot:a}=PolygonUtils.getClosestPoint(n,this.polygonListUnderZoom,this.config.lineType,edgeAdsorptionScope),l=AxisUtils.changePointByZoom(a&&t.altKey===!1&&i?a:n,1/this.zoom);this.drawingPointList.push(l),this.drawingPointList.length===1?this.drawingHistory.initRecord(this.drawingPointList):this.drawingHistory.pushHistory(this.drawingPointList)}clearResult(){this.setPolygonList([]),this.setSelectedID(void 0),this.render()}clearPolygonDrag(){this.drawingPointList=[],this.dragInfo=void 0,this.dragInfo=void 0,this.dragStatus=EDragStatus.Wait,this.hoverEdgeIndex=-1,this.hoverPointIndex=-1,this.hoverID=""}clearActiveStatus(){this.clearPolygonDrag(),this.setSelectedID(void 0)}setPolygonList(t){const e=this.polygonList.length;this.polygonList=t,e!==t.length&&this.emit("updatePageNumber")}setSelectedID(t){var e,i;const s=this.selectedID;t!==s&&s&&((e=this._textAttributInstance)==null||e.changeSelected()),t||(i=this._textAttributInstance)==null||i.clearTextAttribute(),this.selectedID=t,this.render(),this.emit("selectedChange")}setDefaultAttribute(t=""){const e=this.defaultAttribute;if(this.defaultAttribute=t,e!==t){this.changeStyle(t),this.emit("changeAttributeSidebar");const{selectedID:i}=this;if(i&&(this.selectedPolygon&&(this.selectedPolygon.attribute=t),this.history.pushHistory(this.polygonList),this.render()),this._textAttributInstance){if(this.attributeLockList.length>0&&!this.attributeLockList.includes(t)){this._textAttributInstance.clearTextAttribute();return}this._textAttributInstance.updateIcon(this.getTextIconSvg(t))}}}setStyle(t){var e;super.setStyle(t),this._textAttributInstance&&this.config.attributeConfigurable===!1&&((e=this._textAttributInstance)==null||e.updateIcon(this.getTextIconSvg()))}setPolygonValidAndRender(t){if(!t)return;const e=this.polygonList.map(i=>i.id===t?__spreadProps$7(__spreadValues$7({},i),{valid:!i.valid}):i);this.setPolygonList(e),this.history.pushHistory(this.polygonList),this.render(),this.emit("updateResult")}addDrawingPointToPolygonList(){let{lowerLimitPointNum:t=3}=this.config;if(t<3&&(t=3),this.drawingPointList.length<t){this.drawingPointList=[],this.editPolygonID="";return}const e=CommonToolUtils.getSourceID(this.basicResult),i=[...this.polygonList];if(this.editPolygonID){const s=i.find(n=>n.id===this.editPolygonID);if(!s)return;s.pointList=this.drawingPointList,this.editPolygonID=""}else{const s=uuid(8,62);let n={id:s,sourceID:e,valid:!this.isCtrl,textAttribute:"",pointList:this.drawingPointList,attribute:this.defaultAttribute,order:CommonToolUtils.getMaxOrder(i.filter(o=>CommonToolUtils.isSameSourceID(o.sourceID,e)))+1};if(this.config.textConfigurable){let o="";o=AttributeUtils.getTextAttribute(this.polygonList.filter(a=>CommonToolUtils.isSameSourceID(a.sourceID,e)),this.config.textCheckType),n=__spreadProps$7(__spreadValues$7({},n),{textAttribute:o})}i.push(n),this.setSelectedIdAfterAddingDrawing(s)}this.setPolygonList(i),this.isCtrl=!1,this.drawingPointList=[],this.history.pushHistory(i)}setSelectedIdAfterAddingDrawing(t){this.drawingPointList.length!==0&&(this.config.textConfigurable?this.setSelectedID(t):this.setSelectedID())}getHoverID(t){var e;const i=this.getCoordinateUnderZoom(t),s=this.currentShowList.map(n=>__spreadProps$7(__spreadValues$7({},n),{pointList:AxisUtils.changePointListByZoom(n.pointList,this.zoom)}));return PolygonUtils.getHoverPolygonID(i,s,10,(e=this.config)==null?void 0:e.lineType)}getHoverEdgeIndex(t){var e;if(!this.selectedID)return-1;const i=this.selectedPolygon;if(!i)return-1;const s=this.getCoordinateUnderZoom(t),n=AxisUtils.changePointListByZoom(i.pointList,this.zoom);return PolygonUtils.getHoverEdgeIndex(s,n,(e=this.config)==null?void 0:e.lineType)}getHoverPointIndex(t){if(!this.selectedID)return-1;const e=this.selectedPolygon;if(!e)return-1;const i=this.getCoordinateUnderZoom(t),s=AxisUtils.changePointListByZoom(e.pointList,this.zoom);return AxisUtils.returnClosePointIndex(i,s)}deletePolygon(t){var e;!t||(this.setPolygonList(this.polygonList.filter(i=>i.id!==t)),this.history.pushHistory(this.polygonList),(e=this._textAttributInstance)==null||e.clearTextAttribute(),this.emit("selectedChange"),this.render())}deletePolygonPoint(t){if(!this.selectedID)return;const{selectedPolygon:e}=this;if(!e)return;let{lowerLimitPointNum:i}=this.config;if(i<3&&(i=3),e.pointList.length<=i){this.emit("messageInfo",`${Locale.getMessagesByLocale(EMessage.LowerLimitErrorNotice,this.lang)}${i}`);return}e==null||e.pointList.splice(t,1),this.history.pushHistory(this.polygonList),this.render()}spaceKeydown(){var t,e;this.selectedID&&(this.editPolygonID=this.selectedID,this.drawingPointList=(e=(t=this.selectedPolygon)==null?void 0:t.pointList)!=null?e:[],this.drawingHistory.empty(),this.drawingHistory.initRecord(this.drawingPointList),this.hoverID="",this.setSelectedID(""),this.render())}onTabKeyDown(t){if(t.preventDefault(),this.drawingPointList.length>0)return;let e=ESortDirection.ascend;t.shiftKey&&(e=ESortDirection.descend);const[i,s]=CommonToolUtils.getRenderResultList(this.polygonList,CommonToolUtils.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);let n=[...i];s&&(n=[...n,s]);const o=CanvasUtils.getViewPort(this.canvas,this.currentPos,this.zoom),a=n.map(h=>{var d,u,c,g;return __spreadProps$7(__spreadValues$7({},h),{x:(u=(d=h.pointList[0])==null?void 0:d.x)!=null?u:0,y:(g=(c=h.pointList[0])==null?void 0:c.y)!=null?g:0})}).filter(h=>CanvasUtils.inViewPort({x:h.x,y:h.y},o)),l=CommonToolUtils.getNextSelectedRectID(a,e,this.selectedID);if(l){this.setSelectedID(l.id);const{selectedPolygon:h}=this;h&&this.setDefaultAttribute(h.attribute)}this.render()}onKeyDown(t){if(!CommonToolUtils.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;const{keyCode:e}=t;switch(e){case EKeyCode$1.Space:this.spaceKeydown();break;case EKeyCode$1.Esc:this.drawingPointList=[],this.editPolygonID="";break;case EKeyCode$1.F:this.selectedID&&this.setPolygonValidAndRender(this.selectedID);break;case EKeyCode$1.Z:this.setIsHidden(!this.isHidden),this.render();break;case EKeyCode$1.Delete:this.deletePolygon(this.selectedID),this.render();break;case EKeyCode$1.Ctrl:this.isCtrl=!0;break;case EKeyCode$1.Alt:this.isAlt===!1&&(t.preventDefault(),this.isAlt=!0,this.render());break;case EKeyCode$1.Tab:{this.onTabKeyDown(t);break}default:{if(this.config.attributeConfigurable){const i=AttributeUtils.getAttributeByKeycode(e,this.config.attributeList);i!==void 0&&this.setDefaultAttribute(i)}break}}}onKeyUp(t){switch(super.onKeyUp(t),t.keyCode){case EKeyCode$1.Ctrl:this.isCtrl=!1;break;case EKeyCode$1.Alt:{const e=this.isAlt;this.isAlt=!1,e===!0&&this.render();break}}}rightMouseUp(){if(this.drawingPointList.length>0){this.addDrawingPointToPolygonList();return}this.setSelectedID(this.hoverID);const{selectedPolygon:t}=this;t&&this.setDefaultAttribute(t.attribute)}onLeftDblClick(t){if(this.hoverEdgeIndex>-1){const e=this.getCoordinateUnderZoom(t),{selectedPolygon:i}=this;if(!i)return;const{dropFoot:s}=PolygonUtils.getClosestPoint(e,this.polygonListUnderZoom,this.config.lineType,edgeAdsorptionScope);if(!s)return;const{upperLimitPointNum:n}=this.config;if(n&&i.pointList.length>=n){this.emit("messageInfo",`${Locale.getMessagesByLocale(EMessage.UpperLimitErrorNotice,this.lang)}${n}`),this.clearPolygonDrag();return}i==null||i.pointList.splice(this.hoverEdgeIndex+1,0,AxisUtils.changePointByZoom(s,1/this.zoom)),this.setPolygonDataByID(i,this.selectedID),this.history.pushHistory(this.polygonList),this.hoverPointIndex=-1,this.hoverEdgeIndex=-1,this.render()}this.dragInfo=void 0}onRightDblClick(t){this.dragInfo=void 0,this.clearImgDrag();const e=this.getHoverID(t),i=this.getHoverPointIndex(t);if(this.hoverPointIndex>-1&&this.hoverPointIndex===i){this.deletePolygonPoint(i),this.dragInfo=void 0,this.hoverPointIndex=-1,this.render();return}this.hoverID===this.selectedID&&this.deletePolygon(e),this.render()}onMouseDown(t){if(super.onMouseDown(t)||this.forbidMouseOperation||t.ctrlKey===!0)return;const e=this.selectedPolygon;if(!e||t.button!==0||this.getHoverID(t)!==this.selectedID)return;const s=e.pointList,n=this.getCoordinateUnderZoom(t);let o=[0],a=EDragTarget.Plane;this.dragStatus=EDragStatus.Start;const l=this.getHoverPointIndex(t),h=this.getHoverEdgeIndex(t);return l>-1?(a=EDragTarget.Point,o=[l]):h>-1&&this.hoverEdgeIndex>-1&&(a=EDragTarget.Line,o=[h,(h+1)%s.length]),this.dragInfo={dragStartCoord:n,dragTarget:a,initPointList:s,changePointIndex:o},!0}onDragMove(t){var e;if(!this.dragInfo||!this.selectedID)return;let i=(e=this.selectedPolygon)==null?void 0:e.pointList;if(!i)return;const{initPointList:s,dragStartCoord:n,dragTarget:o,changePointIndex:a}=this.dragInfo,l=this.getCoordinateUnderZoom(t),h={x:(l.x-n.x)/this.zoom,y:(l.y-n.y)/this.zoom};switch(this.dragStatus=EDragStatus.Move,o){case EDragTarget.Plane:i=i.map((u,c)=>__spreadProps$7(__spreadValues$7({},u),{x:s[c].x+h.x,y:s[c].y+h.y}));break;case EDragTarget.Point:case EDragTarget.Line:i=i.map((u,c)=>a&&a.includes(c)?__spreadProps$7(__spreadValues$7({},u),{x:s[c].x+h.x,y:s[c].y+h.y}):u);break}if(this.config.drawOutsideTarget===!1&&this.imgInfo){if(this.dependToolName&&this.basicCanvas&&this.basicResult){let p=!1;switch(this.dependToolName){case EToolName.Rect:{p=i.filter(b=>!RectUtils.isInRect(b,this.basicResult)).length>0;break}case EToolName.Polygon:{p=PolygonUtils.isPointListOutSidePolygon(i,this.basicResult.pointList,this.config.lineType);break}}if(p)return}const{left:u,top:c,right:g,bottom:f}=MathUtils.calcViewportBoundaries(AxisUtils.changePointListByZoom(i,this.zoom)),v=1e-5;if(u<0||c<0||g>this.imgInfo.width+v||f>this.imgInfo.height+v)return}const d=this.polygonList.map(u=>u.id===this.selectedID?__spreadProps$7(__spreadValues$7({},u),{pointList:i}):u);this.setPolygonList(d),this.render()}onMouseMove(t){if(super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo)return;if(this.selectedID&&this.dragInfo){this.onDragMove(t);return}let e=-1,i=-1;const{selectedID:s}=this;if(s&&(this.hoverEdgeIndex=-1,this.hoverPointIndex=-1,e=this.getHoverPointIndex(t),e>-1?this.hoverPointIndex=e:(i=this.getHoverEdgeIndex(t),this.hoverEdgeIndex=i)),this.drawingPointList.length>0)return;const n=this.getHoverID(t);this.hoverID!==n&&(this.hoverID=n,this.render())}leftMouseUp(t){const e=this.getHoverID(t);if(this.drawingPointList.length===0&&t.ctrlKey===!0&&e){this.setPolygonValidAndRender(e);return}this.addPointInDrawing(t)}onMouseUp(t){if(!(super.onMouseUp(t)||this.forbidMouseOperation||!this.imgInfo)){if(this.dragInfo&&this.dragStatus===EDragStatus.Move){this.dragInfo=void 0,this.dragStatus=EDragStatus.Wait,this.history.pushHistory(this.polygonList),this.emit("updateResult");return}switch(t.button){case 0:{this.leftMouseUp(t);break}case 2:{this.rightMouseUp();break}}this.render()}}dragMouseUp(){this.dragStatus===EDragStatus.Start&&(this.dragInfo=void 0,this.dragStatus=EDragStatus.Wait)}exportData(){const{polygonList:t}=this;return[t,this.basicImgInfo]}getTextIconSvg(t=""){return AttributeUtils.getTextIconSvg(t,this.config.attributeList,this.config.attributeConfigurable,this.baseIcon)}getCurrentSelectedData(){const{selectedPolygon:t}=this;if(!t)return;const e=this.getColor(t.attribute),i=t.valid?e==null?void 0:e.valid.stroke:e==null?void 0:e.invalid.stroke;return{width:TEXT_MAX_WIDTH,textAttribute:t.textAttribute,color:i}}updateSelectedTextAttribute(t){if(this._textAttributInstance&&t&&this.selectedID){let e=t;AttributeUtils.textAttributeValidate(this.config.textCheckType,"",e)===!1&&(this.emit("messageError",AttributeUtils.getErrorNotice(this.config.textCheckType,this.lang)),e=""),this.setPolygonList(AttributeUtils.textChange(e,this.selectedID,this.polygonList)),this.emit("updateTextAttribute"),this.render()}}renderTextAttribute(){var t;const{selectedPolygon:e}=this;if(!this.ctx||this.config.textConfigurable===!1||!e)return;const{pointList:i,attribute:s,valid:n,textAttribute:o}=e,{x:a,y:l}=i[i.length-1],h=TEXT_MAX_WIDTH,d=AxisUtils.getOffsetCoordinate({x:a,y:l},this.currentPos,this.zoom),u=this.getColor(s),c=n?u==null?void 0:u.valid.stroke:u==null?void 0:u.invalid.stroke;this._textAttributInstance||(this._textAttributInstance=new TextAttributeClass({width:h,container:this.container,icon:this.getTextIconSvg(s),color:c,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedTextAttribute})),this._textAttributInstance&&!((t=this._textAttributInstance)==null?void 0:t.isExit)&&this._textAttributInstance.appendToContainer(),this._textAttributInstance.update(`${o}`,{left:d.x,top:d.y,color:c,width:h})}renderPolygon(){var t,e,i,s,n,o,a,l,h;if(this.isHidden===!1&&((t=this.polygonList)==null||t.forEach(c=>{var g,f,v,p,b;if([this.selectedID,this.editPolygonID].includes(c.id))return;const{textAttribute:x,attribute:y}=c,I=this.getColor(y),m=StyleUtils.getStrokeAndFill(I,c.valid),L=AxisUtils.changePointListByZoom(c.pointList||[],this.zoom,this.currentPos);DrawUtils.drawPolygonWithFillAndLine(this.canvas,L,{fillColor:m.fill,strokeColor:m.stroke,pointColor:"white",thickness:(f=(g=this.style)==null?void 0:g.width)!=null?f:2,lineCap:"round",isClose:!0,lineType:(v=this.config)==null?void 0:v.lineType});let w=`${(p=AttributeUtils.getAttributeShowText(y,this.config.attributeList))!=null?p:""}`;((b=this.config)==null?void 0:b.isShowOrder)&&(c==null?void 0:c.order)>0&&(w=`${c.order} ${w}`),DrawUtils.drawText(this.canvas,L[0],w,__spreadValues$7({color:m.stroke},DEFAULT_TEXT_OFFSET));const C=L[L.length-1];DrawUtils.drawText(this.canvas,{x:C.x+TEXT_ATTRIBUTE_OFFSET.x,y:C.y+TEXT_ATTRIBUTE_OFFSET.y},x,__spreadValues$7({color:m.stroke},DEFAULT_TEXT_OFFSET))})),this.hoverID&&this.hoverID!==this.editPolygonID){const c=this.polygonList.find(g=>g.id===this.hoverID&&g.id!==this.selectedID);if(c){let g="";const f=this.getColor(c.attribute);c.valid?g=f.validHover.fill:g=StyleUtils.getStrokeAndFill(f,!1,{isHover:!0}).fill,DrawUtils.drawPolygonWithFill(this.canvas,AxisUtils.changePointListByZoom(c.pointList,this.zoom,this.currentPos),{color:g,lineType:(e=this.config)==null?void 0:e.lineType})}}if(this.selectedID){const c=this.selectedPolygon;if(c){const g=this.getColor(c.attribute),f=StyleUtils.getStrokeAndFill(g,c.valid,{isSelected:!0});DrawUtils.drawSelectedPolygonWithFillAndLine(this.canvas,AxisUtils.changePointListByZoom(c.pointList,this.zoom,this.currentPos),{fillColor:f.fill,strokeColor:f.stroke,pointColor:"white",thickness:2,lineCap:"round",isClose:!0,lineType:(i=this.config)==null?void 0:i.lineType});let v=`${(s=AttributeUtils.getAttributeShowText(c.attribute,this.config.attributeList))!=null?s:""}`;((n=this.config)==null?void 0:n.isShowOrder)&&(c==null?void 0:c.order)>0&&(v=`${c.order} ${v}`),DrawUtils.drawText(this.canvas,AxisUtils.changePointByZoom(c.pointList[0],this.zoom,this.currentPos),v,__spreadValues$7({color:f.stroke},DEFAULT_TEXT_OFFSET)),this.renderTextAttribute()}}const d=this.getColor(this.defaultAttribute),u=StyleUtils.getStrokeAndFill(d,!this.isCtrl);if(((o=this.drawingPointList)==null?void 0:o.length)>0){const c=[...this.drawingPointList];let g=AxisUtils.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);if(((a=this.config)==null?void 0:a.edgeAdsorption)&&this.isAlt===!1){const{dropFoot:f}=PolygonUtils.getClosestPoint(g,this.polygonList,(l=this.config)==null?void 0:l.lineType,edgeAdsorptionScope/this.zoom);f&&(g=f)}c.push(g),DrawUtils.drawSelectedPolygonWithFillAndLine(this.canvas,AxisUtils.changePointListByZoom(c,this.zoom,this.currentPos),{fillColor:u.fill,strokeColor:u.stroke,pointColor:"white",thickness:2,lineCap:"round",isClose:!1,lineType:this.config.lineType})}if(this.hoverPointIndex>-1&&this.selectedID){const c=this.selectedPolygon;if(!c)return;const g=StyleUtils.getStrokeAndFill(d,c.valid,{isSelected:!0}),f=c==null?void 0:c.pointList[this.hoverPointIndex];if(f){const{x:v,y:p}=AxisUtils.changePointByZoom(f,this.zoom,this.currentPos);DrawUtils.drawCircleWithFill(this.canvas,{x:v,y:p},5,{color:g.fill})}}if(this.hoverEdgeIndex>-1&&this.selectedID){const c=this.selectedPolygon;if(!c)return;const g=StyleUtils.getStrokeAndFill(d,c.valid,{isSelected:!0});DrawUtils.drawLineWithPointList(this.canvas,AxisUtils.changePointListByZoom(c.pointList,this.zoom,this.currentPos),{color:g.stroke,thickness:10,hoverEdgeIndex:this.hoverEdgeIndex,lineType:(h=this.config)==null?void 0:h.lineType})}}render(){!this.ctx||(super.render(),this.renderCursorLine(this.getLineColor(this.defaultAttribute)),this.renderPolygon())}undo(){if(this.drawingPointList.length>0){const e=this.drawingHistory.undo();if(!e)return;this.drawingPointList=e,this.render();return}const t=this.history.undo();t&&(t.length!==this.polygonList.length&&this.setSelectedID(""),this.setPolygonList(t),this.render())}redo(){if(this.drawingPointList.length>0){const e=this.drawingHistory.redo();if(!e)return;this.drawingPointList=e,this.render();return}const t=this.history.redo();t&&(t.length!==this.polygonList.length&&this.setSelectedID(""),this.setPolygonList(t),this.render())}}class TagOperation extends BasicToolOperation{constructor(t){super(t);this.getInitResultList=(e,i)=>!(e===0||e===void 0)&&i.length===0?[]:TagUtil.getDefaultTagResult(this.config.inputList,i),this.setLabel=(e,i)=>{var s,n;if(this.isImgError||!this.basicResult&&this.dependToolName)return;const o=this.config.inputList;if(!o[e])return;const{subSelected:a}=o[e];if(e<o.length&&o[e].subSelected&&a&&i<a.length){const l=o[e].value;let h=(s=a[i])==null?void 0:s.value;const d=(n=o[e])==null?void 0:n.isMulti,u=this.tagResult.filter(c=>{const g=`${c.sourceID}`;return CommonToolUtils.isSameSourceID(g,this.sourceID)})[0];if(u){let c=0;const{result:g}=u;u.sourceID===0&&(u.sourceID="0");for(const f in u.result)if(f===o[e].value){if(c++,d===!0){const v=g[f].split(";").filter(b=>b!==""),p=v.indexOf(h);p===-1?v.push(h):v.splice(p,1),h=v.join(";")}h===""?Object.keys(g).length===1?this.tagResult=this.tagResult.filter(v=>{const p=`${v.sourceID}`;return CommonToolUtils.isDifferSourceID(p,this.sourceID)}):Object.keys(g).length>1&&delete g[f]:g[f]=h}c===0&&Object.assign(u.result,{[l]:h})}else this.tagResult=[{sourceID:this.sourceID,id:uuid(8,62),result:{[l]:h}}];this.render()}},this.clearResult=(e=!0,i)=>{i?this.tagResult=this.tagResult.map(s=>((s==null?void 0:s.result[i])&&delete s.result[i],s)):this.tagResult=[],this.render()},this.config=CommonToolUtils.jsonParser(t.config),this.tagResult=[],this.labelSelectedList=[],this.setShowDefaultCursor(!0)}destroy(){this.clearTag(),super.destroy()}setResult(t){this.tagResult=t,this.render()}get currentPageResult(){return[this.currentTagResult]}get currentTagResult(){var t;return(t=this.tagResult.filter(e=>{const i=`${e.sourceID}`;return CommonToolUtils.isSameSourceID(i,this.sourceID)})[0])!=null?t:{}}get sourceID(){return CommonToolUtils.getSourceID(this.basicResult)}onKeyDown(t){if(!CommonToolUtils.hotkeyFilter(t))return;let{keyCode:e}=t;if(e&&(e<=57&&e>=49||e<=105&&e>=97)){if(e>57?e-=97:e-=49,this.config.inputList.length===1){this.labelSelectedList=[0,e],this.setLabel(0,e),setTimeout(()=>{this.labelSelectedList=[],this.render()},500);return}this.labelSelectedList.length===1?(this.labelSelectedList=[this.labelSelectedList[0],e],this.setLabel(this.labelSelectedList[0],e),setTimeout(()=>{this.labelSelectedList=[],this.render()},500)):(this.labelSelectedList=[e],this.emit("expend"))}}clearTag(){var t;const e=(t=this.canvas)==null?void 0:t.parentNode,i=window==null?void 0:window.self.document.getElementById("tagToolTag");i&&e&&e.contains(i)&&(e==null||e.removeChild(i))}renderTag(){var t,e,i,s,n,o;if(this.clearTag(),!(((t=this.tagResult)==null?void 0:t.length)>0))return;const a=document.createElement("div"),l=TagUtil.getTagNameList((i=(e=this.currentTagResult)==null?void 0:e.result)!=null?i:{},this.config.inputList);a.innerHTML=(s=l.reduce((h,d)=>`${h}${d.keyName}: ${d.value.join(" \u3001 ")}
|
|
59
59
|
`,""))!=null?s:"",a.setAttribute("id","tagToolTag"),a.setAttribute("style",`
|
|
60
60
|
position: absolute;
|
|
61
61
|
top: 0;
|
package/es/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* sense-annotation v1.5.
|
|
2
|
+
* sense-annotation v1.5.4-alpha.0
|
|
3
3
|
* (c) 2020-2021
|
|
4
|
-
* Released under the
|
|
5
|
-
*/import E,{isNumber as Rt,cloneDeep as pi,isObject as bi}from"lodash";import ee from"color-rgba";const xi=320;var lt;(function(r){r.PointCloud="pointCloudTool"})(lt||(lt={}));var ht;(function(r){r.VideoTextTool="videoTextTool",r.VideoTagTool="videoTagTool",r.VideoClipTool="videoClipTool"})(ht||(ht={}));var St;(function(r){r[r.Rect=0]="Rect",r[r.Tag=1]="Tag"})(St||(St={}));var m;(function(r){r.Rect="rectTool",r.Tag="tagTool",r.Point="pointTool",r.PointMarker="pointMarkerTool",r.Segmentation="segmentationTool",r.Filter="filterTool",r.Text="textTool",r.Polygon="polygonTool",r.Line="lineTool",r.LineMarker="lineMarkerTool",r.Empty="emptyTool",r.FolderTag="folderTagTool",r.RectTrack="rectTrackTool",r.Face="faceTool",r.ClientAttribute="clientAttributeTool",r.OCRRelation="OCRRelationTool"})(m||(m={}));var vt;(function(r){r.Check="check"})(vt||(vt={}));var Tt;(function(r){r[r.nothing=0]="nothing",r[r.RectBG=1]="RectBG",r[r.showOrder=2]="showOrder"})(Tt||(Tt={}));const yi={[m.Rect]:"\u62C9\u6846",[m.Tag]:"\u6807\u7B7E",[m.Point]:"\u6807\u70B9",[m.PointMarker]:"\u5217\u8868\u6807\u70B9",[m.Segmentation]:"\u524D\u666F\u5206\u5272",[m.Filter]:"\u7B5B\u9009",[m.Text]:"\u6587\u672C",[m.Polygon]:"\u591A\u8FB9\u5F62",[m.Line]:"\u7EBF\u6761",[m.LineMarker]:"\u5217\u8868\u7EBF\u6761",[m.FolderTag]:"\u6587\u4EF6\u5939\u6807\u7B7E",[m.RectTrack]:"\u62C9\u6846\u8DDF\u8E2A",[m.Face]:"\u4EBA\u8138106\u5DE5\u5177",[m.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[m.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177",[ht.VideoTextTool]:"\u89C6\u9891\u6587\u672C",[ht.VideoTagTool]:"\u89C6\u9891\u6807\u7B7E",[ht.VideoClipTool]:"\u89C6\u9891\u622A\u53D6",[lt.PointCloud]:"\u70B9\u4E91"};var kt;(function(r){r[r.noDepend=1]="noDepend",r[r.dependOrigin=2]="dependOrigin",r[r.dependShape=3]="dependShape",r[r.dependLine=4]="dependLine",r[r.dependPolygon=5]="dependPolygon",r[r.dependPreShape=101]="dependPreShape",r[r.dependPreLine=102]="dependPreLine",r[r.dependPrePolygon=103]="dependPrePolygon"})(kt||(kt={}));var rt;(function(r){r.lc="leftClick",r.rc="rightClick",r.clc="ctrlLeftClick",r.crc="ctrlRightClick"})(rt||(rt={}));const mi={leftClick:"\u9F20\u6807\u5DE6\u952E",rightClick:"\u9F20\u6807\u53F3\u952E",ctrlLeftClick:"ctrl + \u9F20\u6807\u5DE6\u952E",ctrlRightClick:"ctrl + \u9F20\u6807\u53F3\u952E"};var Ot;(function(r){r[r.Normal=1]="Normal",r[r.Modify=2]="Modify"})(Ot||(Ot={}));var T;(function(r){r[r.Line=0]="Line",r[r.Curve=1]="Curve"})(T||(T={}));var pt;(function(r){r[r.SingleColor=0]="SingleColor",r[r.MultiColor=1]="MultiColor"})(pt||(pt={}));var Mt;(function(r){r[r.Form=1]="Form",r[r.Json=2]="Json"})(Mt||(Mt={}));var F;(function(r){r[r.Point=0]="Point",r[r.Line=1]="Line",r[r.Plane=2]="Plane"})(F||(F={}));var Et;(function(r){r[r.None=0]="None",r[r.Drawing=1]="Drawing",r[r.Edit=2]="Edit"})(Et||(Et={}));var Ht;(function(r){r[r.Backward=0]="Backward",r[r.Forward=1]="Forward",r[r.JumpSkip=2]="JumpSkip",r[r.None=3]="None"})(Ht||(Ht={}));var Nt;(function(r){r[r.Wait=0]="Wait",r[r.Pass=1]="Pass",r[r.Fail=2]="Fail",r[r.Loading=3]="Loading"})(Nt||(Nt={}));var U;(function(r){r[r.AnyString=0]="AnyString",r[r.Order=1]="Order",r[r.EnglishOnly=2]="EnglishOnly",r[r.NumberOnly=3]="NumberOnly",r[r.CustomFormat=4]="CustomFormat"})(U||(U={}));const Ii={0:"\u4EFB\u610F\u5B57\u7B26",1:"\u5E8F\u53F7",2:"\u4EC5\u82F1\u6587",3:"\u4EC5\u6570\u5B57"},Bt=1e3,ie=16;var Ft;(function(r){r[r.ImgList=1e3]="ImgList",r[r.TrackPrediction=1001]="TrackPrediction",r[r.ImgSearch=1002]="ImgSearch"})(Ft||(Ft={}));const Li={[lt.PointCloud]:"sensebeepc",[m.ClientAttribute]:"sensebeepc-EnumAttributeTool",[m.Face]:"sensebeepc-FacePointsLabellingTool",[m.OCRRelation]:"sensebeepc-OCRRelationTool"},wi={[lt.PointCloud]:"\u70B9\u4E91\u5BA2\u6237\u7AEF",[m.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[m.Face]:"\u4EBA\u8138106\u70B9\u5DE5\u5177",[m.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177"},j=16,bt=10;var Ci=Object.freeze({__proto__:null,editStepWidth:xi,get EPointCloudName(){return lt},get EVideoToolName(){return ht},get EToolType(){return St},get EToolName(){return m},get ECheckModel(){return vt},get ERectPattern(){return Tt},TOOL_NAME:yi,get EDependPattern(){return kt},get EFilterToolOperation(){return rt},OPERATION_LIST:mi,get EAnnotationMode(){return Ot},get ELineTypes(){return T},get ELineColor(){return pt},get ESelectedType(){return Mt},get EDragTarget(){return F},get EDrawPointPattern(){return Et},get EPageOperator(){return Ht},get EAuditStatus(){return Nt},get ETextType(){return U},TEXT_TYPE:Ii,TEXT_ATTRIBUTE_MAX_LENGTH:Bt,TEXT_ATTRIBUTE_LINE_HEIGHT:ie,get EThumbnailOption(){return Ft},CLIENT_TOOL_HEAD_TYPE:Li,CLIENT_TOOL_NAME:wi,SEGMENT_NUMBER:j,edgeAdsorptionScope:bt}),Pi=Object.defineProperty,Di=Object.defineProperties,_i=Object.getOwnPropertyDescriptors,se=Object.getOwnPropertySymbols,Ai=Object.prototype.hasOwnProperty,Ri=Object.prototype.propertyIsEnumerable,re=(r,t,e)=>t in r?Pi(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Si=(r,t)=>{for(var e in t||(t={}))Ai.call(t,e)&&re(r,e,t[e]);if(se)for(var e of se(t))Ri.call(t,e)&&re(r,e,t[e]);return r},Ti=(r,t)=>Di(r,_i(t));function $t(r,t=.5,e=!1,i=16){if(r.length<4)return r;const s=[],n=r.slice(0);let o,a,l,h,d,u,c,g,f,v,p,x,y;for(e?(n.unshift(r[r.length-1]),n.unshift(r[r.length-2]),n.unshift(r[r.length-1]),n.unshift(r[r.length-2]),n.push(r[0]),n.push(r[1])):(n.unshift(r[1]),n.unshift(r[0]),n.push(r[r.length-2]),n.push(r[r.length-1])),y=2;y<n.length-4;y+=2)for(l=(n[y+2]-n[y-2])*t,h=(n[y+4]-n[y-0])*t,d=(n[y+3]-n[y-1])*t,u=(n[y+5]-n[y+1])*t,x=0;x<=i;x++)p=x/i,c=2*Math.pow(p,3)-3*Math.pow(p,2)+1,g=-(2*Math.pow(p,3))+3*Math.pow(p,2),f=Math.pow(p,3)-2*Math.pow(p,2)+p,v=Math.pow(p,3)-Math.pow(p,2),o=c*n[y]+g*n[y+2]+f*l+v*h,a=c*n[y+1]+g*n[y+3]+f*d+v*u,s.push(o),s.push(a);const A=[];for(let k=0;k<s.length-1;k+=2)A.push({x:s[k],y:s[k+1]});if(e)for(let k=0;k<i+1;k++){const S=A.shift();A.push(S)}return A}const xt=(r,t=16)=>$t(r.reduce((e,i)=>[...e,i.x,i.y],[]),.5,!1,t);function ne(r,t,e=T.Line){let i=0,s,n,o,a;t=[...t],e===T.Curve&&(t=$t(t.reduce((h,d)=>[...h,d.x,d.y],[]),.5,!0,j)),[o]=t;const l=t.length;for(s=1;s<=l;s++)a=t[s%l],r.x>Math.min(o.x,a.x)&&r.x<=Math.max(o.x,a.x)&&r.y<=Math.max(o.y,a.y)&&o.x!==a.x&&(n=(r.x-o.x)*(a.y-o.y)/(a.x-o.x)+o.y,(o.y===a.y||r.y<=n)&&i++),o=a;return i%2!=0}function oe(r,t=1){return r.map(e=>Ti(Si({},e),{x:e.x*t,y:e.y*t}))}const yt=class{static getRotate(r){return r+90>=360?r+90-360:r+90}static getLineLength(r,t){return Math.sqrt(Math.pow(t.y-r.y,2)+Math.pow(t.x-r.x,2))}};let w=yt;w.isInRange=(r,t)=>{const e=Math.min(...t),i=Math.max(...t),s=o=>o<=i&&o>=e;return(Array.isArray(r)?r:[r]).every(o=>s(o))},w.withinRange=(r,t)=>{const e=Math.min(...t),i=Math.max(...t);return r>i?i:r<e?e:r},w.calcViewportBoundaries=(r,t=!1,e=j,i=1)=>{if(!r)return{top:0,bottom:0,left:0,right:0};const s=20/i,n=[],o=[];let a=r;t&&(a=xt(r,e)),a.forEach(({x:f,y:v})=>{n.push(f),o.push(v)});let l=Math.min(...n),h=Math.max(...n),d=Math.min(...o),u=Math.max(...o);const c=h-l,g=u-d;if(c<s){const f=(s-c)/2;l-=f,h+=f}if(g<s){const f=(s-g)/2;d-=f,u+=f}return{top:d,bottom:u,left:l,right:h}},w.getFootOfPerpendicular=(r,t,e,i=!1)=>{let s={x:0,y:0};const n=t.x-e.x,o=t.y-e.y;if(Math.abs(n)<1e-8&&Math.abs(o)<1e-8)return s=t,s;let a=(r.x-t.x)*(t.x-e.x)+(r.y-t.y)*(t.y-e.y);a/=n*n+o*o,s.x=t.x+a*n,s.y=t.y+a*o;const l=yt.getLineLength(r,s),h=2,d=Math.min(t.x,e.x),u=Math.max(t.x,e.x),c=Math.min(t.y,e.y),g=Math.max(t.y,e.y),f=!(yt.isInRange(r.x,[d,u])||yt.isInRange(r.y,[c,g])),v=r.x>u+h||r.x<d-h||r.y>g+h||r.y<c-h;return(i?f:v)?{footPoint:s,length:Infinity}:{footPoint:s,length:l}};const ki=61,Oi=40,Mi=40,Ei=240;var ut;(function(r){r[r.ANNOTATION=1]="ANNOTATION",r[r.QUALITY_INSPECTION=2]="QUALITY_INSPECTION",r[r.PRE_ANNOTATION=3]="PRE_ANNOTATION",r[r.MANUAL_CORRECTION=4]="MANUAL_CORRECTION"})(ut||(ut={}));const Hi=1e3;var Zt;(function(r){r[r.Backward=0]="Backward",r[r.Forward=1]="Forward",r[r.JumpSkip=2]="JumpSkip",r[r.None=3]="None"})(Zt||(Zt={}));var _;(function(r){r[r.Start=0]="Start",r[r.Stop=1]="Stop",r[r.Wait=2]="Wait",r[r.Move=3]="Move"})(_||(_={}));var Y;(function(r){r[r.Point=0]="Point",r[r.Line=1]="Line",r[r.Plane=2]="Plane"})(Y||(Y={}));var z;(function(r){r[r.ascend=0]="ascend",r[r.descend=1]="descend"})(z||(z={}));var ct;(function(r){r[r.Intelligence=0]="Intelligence",r[r.Linear=1]="Linear"})(ct||(ct={}));var q;(function(r){r.Zh="zh_CN",r.US="en_US"})(q||(q={}));const nt={offsetX:-10,offsetY:-10},mt={shadowColor:"rgba(0,0,0,0.6)",shadowOffsetX:0,shadowOffsetY:2,shadowBlur:4};var Ni=Object.freeze({__proto__:null,headerHeight:ki,tipsHeight:Oi,footerHeight:Mi,sidebarWidth:Ei,get EStepType(){return ut},ANNOTATION_MAX_SIZE:Hi,get EPageOperator(){return Zt},get EDragStatus(){return _},get EDragTarget(){return Y},get ESortDirection(){return z},get EGrowthMode(){return ct},get ELang(){return q},DEFAULT_TEXT_OFFSET:nt,DEFAULT_TEXT_SHADOW:mt}),Bi=Object.defineProperty,Fi=Object.defineProperties,$i=Object.getOwnPropertyDescriptors,ae=Object.getOwnPropertySymbols,Zi=Object.prototype.hasOwnProperty,Ui=Object.prototype.propertyIsEnumerable,le=(r,t,e)=>t in r?Bi(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Q=(r,t)=>{for(var e in t||(t={}))Zi.call(t,e)&&le(r,e,t[e]);if(ae)for(var e of ae(t))Ui.call(t,e)&&le(r,e,t[e]);return r},tt=(r,t)=>Fi(r,$i(t));class H{static composeResult(t,e,i,s,n){try{const o=JSON.parse(t),a=b.getCurrentStepInfo(e,s),{dataSourceStep:l}=a,h=`step_${a.step}`;if(Object.assign(o,n),o[h]){const d=o[h];return d.result?(d.result=i,JSON.stringify(o)):JSON.stringify(tt(Q({},o),{[h]:tt(Q({},o[h]),{result:i})}))}return JSON.stringify(tt(Q({},o),{[h]:{dataSourceStep:l,toolName:a.tool,result:i}}))}catch(o){return t}}static changeCoordinateByRotate(t,e,i){const{x:s,y:n,width:o,height:a}=t,l=I.changeCoordinateByRotate({x:s,y:n},e,i);switch(e%360){case 90:return tt(Q({},t),{x:l.x-a,y:l.y,width:a,height:o});case 180:return tt(Q({},t),{x:l.x-o,y:l.y-a});case 270:return tt(Q({},t),{x:l.x,y:l.y-o,width:a,height:o});default:return t}}static translateRect2Points(t){const{x:e,y:i,width:s,height:n}=t;return[{x:e,y:i},{x:e+s,y:i},{x:e+s,y:i+n},{x:e,y:i+n}]}static translatePoints2Rect(t,e){if(t.length!==4)return;const{x:i,y:s}=t[0],n=t[1].x-t[0].x,o=t[2].y-t[1].y;return tt(Q({},e),{x:i,y:s,width:n,height:o})}static getRectPointList(t,e=1){return[{x:t.x*e,y:t.y*e},{x:(t.x+t.width)*e,y:t.y*e},{x:(t.x+t.width)*e,y:(t.y+t.height)*e},{x:t.x*e,y:(t.y+t.height)*e}]}static getRectEdgeList(t,e=1){const i=this.getRectPointList(t,e),s=i.length;return i.map((n,o)=>({begin:n,end:i[(o+1)%s]}))}static isInRect(t,e,i=0,s=1){return t.x>=e.x*s-i&&t.x<=(e.x+e.width)*s+i&&t.y>=e.y*s-i&&t.y<=(e.y+e.height)*s+i}static getRectUnderZoom(t,e=1){const{x:i,y:s,width:n,height:o}=t;return tt(Q({},t),{x:i*e,y:s*e,width:n*e,height:o*e})}static isRectNotInPolygon(t,e){return this.getRectPointList(t).some(s=>!ne(s,e))}}function W(r=8,t=62){const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),i=[];let s;if(t=t||e.length,r)for(s=0;s<r;s++)i[s]=e[0|Math.random()*t];else{let n;for(i[8]=i[13]=i[18]=i[23]="-",i[14]="4",s=0;s<36;s++)i[s]||(n=0|Math.random()*16,i[s]=e[s===19?n&3|8:n])}return i.join("")}var zi=Object.defineProperty,he=Object.getOwnPropertySymbols,Vi=Object.prototype.hasOwnProperty,Wi=Object.prototype.propertyIsEnumerable,ce=(r,t,e)=>t in r?zi(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,de=(r,t)=>{for(var e in t||(t={}))Vi.call(t,e)&&ce(r,e,t[e]);if(he)for(var e of he(t))Wi.call(t,e)&&ce(r,e,t[e]);return r};class gt{static getTagKeyName(t,e){var i,s;if(!!e)return(s=(i=e.find(n=>n.value===t))==null?void 0:i.key)!=null?s:""}static getTagName([t="",e=""],i){if(!!i){for(const s of i)if(s.value===t){if(!s.subSelected)return console.error("\u6807\u7B7E\u89E3\u6790\u9519\u8BEF",t,e),"";for(const n of s.subSelected)if(n.value===e)return n.key}}}static getTagNameList(t,e){return Object.keys(t).length<=0?[]:Object.entries(t).reduce((i,s)=>{const[n,o]=s;if(o&&o.length>0){const a=o.split(";"),l={keyName:this.getTagKeyName(n,e),value:a.map(h=>this.getTagName([n,h],e))};return[...i,l]}return i},[]).filter(i=>i)}static getTagnameListWithoutConfig(t){return Object.keys(t).length<=0?[]:Object.entries(t).reduce((e,i)=>{const[s,n]=i,o=n.split(";"),a={keyName:s,value:o};return[...e,a]},[]).filter(e=>e)}static judgeResultIsInInputList(t,e,i){return!t||!e||!i?!1:i.filter(n=>{if(n.value===t&&n.subSelected){const o=e==null?void 0:e.split(";");return(n==null?void 0:n.subSelected.filter(a=>o.indexOf(a.value)>-1).length)>0}return!1}).length>0}static getDefaultResultByConfig(t){return t.reduce((e,i)=>(i.subSelected&&i.subSelected.forEach(s=>{var n;if(s.isDefault){const o=(n=e[i.value])!=null?n:"";let a=[];o.length>0&&(a=o.split(";")),a.push(s.value),e[i.value]=a.join(";")}}),e),{})}static getDefaultTagResult(t,e){const i=this.getDefaultResultByConfig(t);return e.length>0?e.map(s=>({id:W(),sourceID:s.id,result:de({},i)})):[{id:W(),sourceID:"",result:de({},i)}]}}var ue='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#ccc"/></g></g></svg>',ji='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#ff2323"/></g></g></svg>',Xi='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#ffe232"/></g></g></svg>',Yi='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#01ff30"/></g></g></svg>',Gi='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#00ffea"/></g></g></svg>',Ki='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#0282fa"/></g></g></svg>',Ji='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#800cf9"/></g></g></svg>',qi='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#ff88f7"/></g></g></svg>',Qi='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#994217"/></g></g></svg>',ts='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#1f0bf9"/></g></g></svg>',es='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#3fe"/></g></g></svg>',is='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#33fe33"/></g></g></svg>',ss='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#fdff37"/></g></g></svg>',rs='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#f70efa"/></g></g></svg>',ge='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#f33"/></g></g></svg>';const fe=ue,ns=61,os=80,as=62,ls=20,hs=55,cs=55,ds=40,us=80,gs=240,fs=320,vs="rgba(102, 111, 255, 1)",dt=["rgba(128, 12, 249, 1)","rgba(0, 255, 48, 1)","rgba(255, 136, 247, 1)","rgba(255, 226, 50, 1)","rgba(153, 66, 23, 1)","rgba(2, 130, 250, 1)","rgba(255, 35, 35, 1)","rgba(0, 255, 234, 1)"],It=[ue,Ji,Yi,qi,Xi,Qi,Ki,ji,Gi],ve={1:ts,3:es,5:is,7:ss,9:rs},ps="rgba(255, 51, 51, 1)",Ut="rgba(204, 204, 204, 1)",bs={[rt.lc]:"rgba(153, 51, 255, 1)",[rt.rc]:"rgba(51, 153, 255, 1)",[rt.clc]:"rgba(46, 230, 46, 1)",[rt.crc]:"rgba(255, 51, 51, 1)"};var xs=Object.freeze({__proto__:null,HEADER_HEIGHT:ns,TAB_HEIGHT:os,SEARCH_HEIGHT:as,PADDING:ls,TABLE_ROW_HEIGHT:hs,PAGINATION_HEIGHT:cs,TIPS_HEIGHT:ds,FOOTER_HEIGHT:us,SIDERBAR_WIDTH:gs,EDIT_STEP_WIDTH:fs,THEME_COLOR:vs,COLORS_ARRAY:dt,ICON_ARRAY:It,BASE_ICON:ve,INVALID_COLOR:ps,NULL_COLOR:Ut,NULL_ICON:fe,INVALID_ICON:ge,FILTER_TOOL_COLOR:bs}),L;(function(r){r.NoRotateNotice="noRotateNotice",r.RectErrorSizeNotice="rectErrorSizeNotice",r.TextCheckNumberErrorNotice="textCheckNumberErrorNotice",r.TextCheckEnglishErrorNotice="textCheckEnglishErrorNotice",r.TextCheckCustomErrorNotice="textCheckCustomErrorNotice",r.UpperLimitErrorNotice="UpperLimitErrorNotice",r.LowerLimitErrorNotice="LowerLimitErrorNotice",r.InvalidImage="InvalidImage",r.DisableDelete="DisableDelete",r.ClearPartialData="ClearPartialData",r.MarkerFinish="MarkerFinish",r.LowerLimitPoint="LowerLimitPoint",r.NoRotateInDependence="noRotateInDependence"})(L||(L={}));const ys={[L.NoRotateNotice]:"This Image contains data and cannot be rotated",[L.RectErrorSizeNotice]:"The drawing frame size is smaller than the minimum drawing size",[L.TextCheckNumberErrorNotice]:"Please enter in number-only format",[L.TextCheckEnglishErrorNotice]:"Please enter in English only format",[L.TextCheckCustomErrorNotice]:"Please enter in the required format",[L.UpperLimitErrorNotice]:"The number of vertices is not more than",[L.LowerLimitErrorNotice]:"The number of vertices is not less than",[L.InvalidImage]:"Invalid image, please skip this image",[L.DisableDelete]:"Disable delete",[L.ClearPartialData]:"Clear partial data",[L.MarkerFinish]:"ListAnnotation is finished",[L.LowerLimitPoint]:"\u5DF2\u5230\u8FBE\u6807\u70B9\u6570\u91CF\u4E0A\u9650",[L.NoRotateInDependence]:"Disallow rotation in dependent cases"},ms={[L.NoRotateNotice]:"\u672C\u56FE\u542B\u6709\u6570\u636E\uFF0C\u65E0\u6CD5\u8FDB\u884C\u65CB\u8F6C",[L.RectErrorSizeNotice]:"\u7ED8\u5236\u6846\u5C3A\u5BF8\u5C0F\u4E8E\u6700\u5C0F\u7ED8\u5236\u5C3A\u5BF8",[L.TextCheckNumberErrorNotice]:"\u8BF7\u6309\u4EC5\u6570\u5B57\u7684\u683C\u5F0F\u8F93\u5165",[L.TextCheckEnglishErrorNotice]:"\u8BF7\u6309\u4EC5\u82F1\u6587\u7684\u683C\u5F0F\u8F93\u5165",[L.TextCheckCustomErrorNotice]:"\u8BF7\u6309\u8981\u6C42\u7684\u683C\u5F0F\u8F93\u5165",[L.UpperLimitErrorNotice]:"\u9876\u70B9\u6570\u4E0D\u591A\u4E8E",[L.LowerLimitErrorNotice]:"\u9876\u70B9\u6570\u4E0D\u5C11\u4E8E",[L.InvalidImage]:"\u65E0\u6548\u56FE\u7247\uFF0C\u8BF7\u8DF3\u8FC7\u6B64\u56FE",[L.DisableDelete]:"\u8BE5\u6570\u636E\u7981\u6B62\u5220\u9664",[L.ClearPartialData]:"\u5B58\u5728\u90E8\u5206\u6570\u636E\u65E0\u6CD5\u6E05\u9664",[L.MarkerFinish]:"\u5217\u8868\u6807\u6CE8\u5DF2\u5B8C\u6210",[L.LowerLimitPoint]:"\u5DF2\u5230\u8FBE\u6807\u70B9\u6570\u91CF\u4E0A\u9650",[L.NoRotateInDependence]:"\u4F9D\u8D56\u60C5\u51B5\u4E0B\u65E0\u6CD5\u8FDB\u884C\u65CB\u8F6C"};class ${}$.getMessagesByLocale=(r,t)=>{switch(t){case q.US:return ys[r];case q.Zh:default:return ms[r]}};var Is=Object.defineProperty,Ls=Object.defineProperties,ws=Object.getOwnPropertyDescriptors,pe=Object.getOwnPropertySymbols,Cs=Object.prototype.hasOwnProperty,Ps=Object.prototype.propertyIsEnumerable,be=(r,t,e)=>t in r?Is(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,xe=(r,t)=>{for(var e in t||(t={}))Cs.call(t,e)&&be(r,e,t[e]);if(pe)for(var e of pe(t))Ps.call(t,e)&&be(r,e,t[e]);return r},ye=(r,t)=>Ls(r,ws(t));const Ds="^[0-9]+$",_s="^[A-Za-z]+$";class D{static getAttributeIcon(t,e,i=!0){var s;const n=e.findIndex(l=>l.value===t);let o=(s=It[n%It.length])!=null?s:fe;i||(o=ge),o="";const a=new Image;return a.src=o,a}static checkString(t,e){let i="";switch(t){case U.Order:case U.NumberOnly:i=Ds;break;case U.EnglishOnly:i=_s;break;case U.CustomFormat:i=e;break}return i}static checkTextAttibute(t,e){if(t===void 0||t==="")return!0;try{return new RegExp(e).test(t)}catch(i){return!1}}static getAttributeShowText(t,e=[]){var i,s;try{const n=e.findIndex(o=>o.value===t);return(s=(i=e[n])==null?void 0:i.key)!=null?s:t}catch(n){return t}}static getAttributeIndex(t,e){try{const i=e.findIndex(s=>s.value===t);return i>=8?i%8:i}catch(i){return-1}}static getAttributeColor(t,e){try{const i=this.getAttributeIndex(t,e);return i===-1?Ut:dt[i%dt.length]}catch(i){return Ut}}static getTextAttribute(t,e){try{if(e===U.Order){const i=t.map(n=>parseInt(n.textAttribute,10)).filter(n=>Rt(n)&&n<Number.MAX_SAFE_INTEGER&&n>=0);return i.sort((n,o)=>n-o),`${(i.pop()||0)+1}`}return""}catch(i){return""}}static textChange(t,e,i){return i.map(s=>s.id===e?ye(xe({},s),{textAttribute:t}):s)}static getErrorNotice(t,e){switch(t){case U.Order:case U.NumberOnly:return $.getMessagesByLocale(L.TextCheckNumberErrorNotice,e);case U.EnglishOnly:return $.getMessagesByLocale(L.TextCheckEnglishErrorNotice,e);case U.CustomFormat:return $.getMessagesByLocale(L.TextCheckCustomErrorNotice,e);default:return""}}static textAttributeValidate(t,e,i){try{return new RegExp(this.checkString(t,e)).test(i)}catch(s){}}static checkTextAttribute(t,e,i,s){let n=!1;return i.forEach(o=>{(o==null?void 0:o.textAttribute)===void 0||(o==null?void 0:o.textAttribute)===""||(s?o.id===s:!0)&&!this.textAttributeValidate(t,e,o.textAttribute)&&(n=!0)}),!!n}static changeTextAttributeInLog(t,e){return t==null?void 0:t.map(i=>i==null?void 0:i.map(s=>{if((e==null?void 0:e.findIndex(n=>(n==null?void 0:n.id)===(s==null?void 0:s.id)))>-1){const n=e==null?void 0:e.find(o=>(o==null?void 0:o.id)===(s==null?void 0:s.id));return ye(xe({},s),{textAttribute:n==null?void 0:n.textAttribute})}return s}))}static getTextIconSvg(t="",e,i=!1,s){if(i===!0){const n=(e==null?void 0:e.findIndex(o=>(o==null?void 0:o.value)===t))%dt.length+1;return It[n]}return s}static getAttributeByKeycode(t,e){var i;let s;return w.isInRange(t,[48,57])&&(s=t-48),w.isInRange(t,[96,105])&&(s=t-96),s===0?"":s?(i=e[s-1])==null?void 0:i.value:void 0}}class Lt{static deg2rad(t){return t*Math.PI/180}static rad2deg(t){return t*180/Math.PI}}const As=1,Rs={x:0,y:0},Ss=0,X="";class C{static drawLine(t,e,i,s={}){const n=t.getContext("2d"),{color:o=X,thickness:a=1,lineCap:l="round"}=s;n.save(),n.strokeStyle=o,n.lineWidth=a,n.lineCap=l,n.beginPath(),n.moveTo(e.x,e.y),n.lineTo(i.x+1,i.y+1),n.stroke(),n.restore()}static drawRect(t,e,i={}){const s=t.getContext("2d"),{color:n=X,thickness:o=1,lineCap:a="round"}=i;s.save(),s.strokeStyle=n,s.lineWidth=o,s.lineCap=a,s.beginPath(),s.fillStyle=n,s.strokeRect(e.x,e.y,e.width,e.height);let l="";if(e.attribute&&(l=`${l} ${e.attribute}`),this.drawText(t,{x:e.x,y:e.y-5},l),e.textAttribute){const d=`${~~e.width} * ${~~e.height}`.length*7,u=0,c=Math.max(20,e.width-d);this.drawText(t,{x:e.x,y:e.y+e.height+20+u},e.textAttribute,{textMaxWidth:c})}s.restore()}static drawRectWithFill(t,e,i={}){const s=t.getContext("2d"),{color:n=X}=i;s.save(),s.beginPath(),s.fillStyle=n,s.fillRect(e.x,e.y,e.width,e.height),s.restore()}static drawTag(t,e){var i;const s=t==null?void 0:t.parentNode,n=window.self.document.getElementById("tagToolTag");if(n&&s&&s.contains(n)&&(s==null||s.removeChild(n)),!((e==null?void 0:e.length)>0))return;const o=document.createElement("div");o.innerHTML=(i=e.reduce((a,l)=>`${a}${l.keyName}: ${l.value.join(" \u3001 ")}
|
|
6
|
-
`,""))!=null?i:"",o.setAttribute("id","tagToolTag"),s==null||s.appendChild(o)}static drawLineWithPointList(t,e,i={}){if(e.length<2)return;const s=t.getContext("2d"),{color:n=X,thickness:o=1,lineCap:a="round",lineType:l=T.Line,hoverEdgeIndex:h}=i;s.save(),s.strokeStyle=n,s.lineWidth=o,s.lineCap=a,s.beginPath(),l===T.Curve?(h!==void 0&&h>-1&&e.push(e[0]),e=M.createSmoothCurvePointsFromPointList([...e],j),h!==void 0&&h>-1&&(e=e.slice((j+1)*h,(j+1)*(h+1)))):h!==void 0&&h>-1&&(e=[...e,e[0]],e=e.slice(h,h+2));const[d,...u]=e;s.moveTo(d.x,d.y),u.forEach(c=>{s.lineTo(c.x,c.y)}),s.stroke(),s.restore()}static drawCircle(t,e,i,s={}){const n=t.getContext("2d"),{startAngleDeg:o=0,endAngleDeg:a=360,thickness:l=1,color:h=X,fill:d=X}=s,u=Lt.deg2rad(o),c=Lt.deg2rad(a);n.save(),n.beginPath(),n.strokeStyle=h,n.fillStyle=d,n.lineWidth=l,n.arc(e.x,e.y,i,u,c,!1),n.stroke(),n.fill(),n.closePath(),n.restore()}static drawCircleWithFill(t,e,i=3,s={}){const n=t.getContext("2d"),{color:o=X}=s;n.save();const a=Lt.deg2rad(0),l=Lt.deg2rad(360);n.fillStyle=o,n.beginPath(),n.arc(e.x,e.y,i,a,l,!1),n.fill(),n.restore()}static drawPolygon(t,e,i={}){const{isClose:s=!1,lineType:n=T.Line}=i;s===!0&&(e=[...e,e[0]]),n===T.Curve&&(e=M.createSmoothCurvePointsFromPointList([...e])),this.drawLineWithPointList(t,e,i)}static drawPolygonWithFill(t,e,i={}){if(e.length<2)return;const s=t.getContext("2d"),{color:n=X,lineType:o=T.Line}=i;s.save(),s.fillStyle=n,s.beginPath(),o===T.Curve&&(e=M.createSmoothCurvePointsFromPointList([...e,e[0]]));const[a,...l]=e;s.moveTo(a.x,a.y),l.forEach(h=>{s.lineTo(h.x,h.y)}),s.fill(),s.restore()}static drawPolygonWithFillAndLine(t,e,i={}){const{strokeColor:s,fillColor:n,thickness:o,lineCap:a,isClose:l,lineType:h}=i;this.drawPolygon(t,e,{color:s,thickness:o,lineCap:a,isClose:l,lineType:h}),this.drawPolygonWithFill(t,e,{color:n,lineType:h})}static drawSelectedPolygonWithFillAndLine(t,e,i={}){const{pointColor:s="white",strokeColor:n}=i;this.drawPolygonWithFillAndLine(t,e,i),[...e].forEach(a=>{this.drawCircleWithFill(t,a,4,{color:n}),this.drawCircleWithFill(t,a,3,{color:s})})}static drawText(t,e,i,s={}){if(!i)return;const n=t.getContext("2d"),{color:o=X,font:a="normal normal 500 14px Arial",shadowColor:l="",shadowBlur:h=0,shadowOffsetX:d=0,shadowOffsetY:u=0,textMaxWidth:c=164,offsetX:g=0,offsetY:f=0,textAlign:v="start"}=s;n.save(),n.textAlign=v,n.fillStyle=o!=null?o:"white",n.font=a,n.shadowColor=l,n.shadowOffsetX=d,n.shadowOffsetY=u,n.shadowBlur=h,this.wrapText(t,`${i}`,e.x+g,e.y+f,c),n.restore()}static wrapText(t,e,i,s,n,o){if(typeof e!="string"||typeof i!="number"||typeof s!="number")return;const
|
|
7
|
-
`);for(let
|
|
4
|
+
* Released under the Apache-2.0 License.
|
|
5
|
+
*/import E,{isNumber as Rt,cloneDeep as pi,isObject as bi}from"lodash";import ee from"color-rgba";const xi=320;var lt;(function(r){r.PointCloud="pointCloudTool"})(lt||(lt={}));var ht;(function(r){r.VideoTextTool="videoTextTool",r.VideoTagTool="videoTagTool",r.VideoClipTool="videoClipTool"})(ht||(ht={}));var St;(function(r){r[r.Rect=0]="Rect",r[r.Tag=1]="Tag"})(St||(St={}));var m;(function(r){r.Rect="rectTool",r.Tag="tagTool",r.Point="pointTool",r.PointMarker="pointMarkerTool",r.Segmentation="segmentationTool",r.Filter="filterTool",r.Text="textTool",r.Polygon="polygonTool",r.Line="lineTool",r.LineMarker="lineMarkerTool",r.Empty="emptyTool",r.FolderTag="folderTagTool",r.RectTrack="rectTrackTool",r.Face="faceTool",r.ClientAttribute="clientAttributeTool",r.OCRRelation="OCRRelationTool"})(m||(m={}));var vt;(function(r){r.Check="check"})(vt||(vt={}));var Tt;(function(r){r[r.nothing=0]="nothing",r[r.RectBG=1]="RectBG",r[r.showOrder=2]="showOrder"})(Tt||(Tt={}));const yi={[m.Rect]:"\u62C9\u6846",[m.Tag]:"\u6807\u7B7E",[m.Point]:"\u6807\u70B9",[m.PointMarker]:"\u5217\u8868\u6807\u70B9",[m.Segmentation]:"\u524D\u666F\u5206\u5272",[m.Filter]:"\u7B5B\u9009",[m.Text]:"\u6587\u672C",[m.Polygon]:"\u591A\u8FB9\u5F62",[m.Line]:"\u7EBF\u6761",[m.LineMarker]:"\u5217\u8868\u7EBF\u6761",[m.FolderTag]:"\u6587\u4EF6\u5939\u6807\u7B7E",[m.RectTrack]:"\u62C9\u6846\u8DDF\u8E2A",[m.Face]:"\u4EBA\u8138106\u5DE5\u5177",[m.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[m.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177",[ht.VideoTextTool]:"\u89C6\u9891\u6587\u672C",[ht.VideoTagTool]:"\u89C6\u9891\u6807\u7B7E",[ht.VideoClipTool]:"\u89C6\u9891\u622A\u53D6",[lt.PointCloud]:"\u70B9\u4E91"};var kt;(function(r){r[r.noDepend=1]="noDepend",r[r.dependOrigin=2]="dependOrigin",r[r.dependShape=3]="dependShape",r[r.dependLine=4]="dependLine",r[r.dependPolygon=5]="dependPolygon",r[r.dependPreShape=101]="dependPreShape",r[r.dependPreLine=102]="dependPreLine",r[r.dependPrePolygon=103]="dependPrePolygon"})(kt||(kt={}));var rt;(function(r){r.lc="leftClick",r.rc="rightClick",r.clc="ctrlLeftClick",r.crc="ctrlRightClick"})(rt||(rt={}));const mi={leftClick:"\u9F20\u6807\u5DE6\u952E",rightClick:"\u9F20\u6807\u53F3\u952E",ctrlLeftClick:"ctrl + \u9F20\u6807\u5DE6\u952E",ctrlRightClick:"ctrl + \u9F20\u6807\u53F3\u952E"};var Ot;(function(r){r[r.Normal=1]="Normal",r[r.Modify=2]="Modify"})(Ot||(Ot={}));var T;(function(r){r[r.Line=0]="Line",r[r.Curve=1]="Curve"})(T||(T={}));var pt;(function(r){r[r.SingleColor=0]="SingleColor",r[r.MultiColor=1]="MultiColor"})(pt||(pt={}));var Mt;(function(r){r[r.Form=1]="Form",r[r.Json=2]="Json"})(Mt||(Mt={}));var F;(function(r){r[r.Point=0]="Point",r[r.Line=1]="Line",r[r.Plane=2]="Plane"})(F||(F={}));var Et;(function(r){r[r.None=0]="None",r[r.Drawing=1]="Drawing",r[r.Edit=2]="Edit"})(Et||(Et={}));var Ht;(function(r){r[r.Backward=0]="Backward",r[r.Forward=1]="Forward",r[r.JumpSkip=2]="JumpSkip",r[r.None=3]="None"})(Ht||(Ht={}));var Nt;(function(r){r[r.Wait=0]="Wait",r[r.Pass=1]="Pass",r[r.Fail=2]="Fail",r[r.Loading=3]="Loading"})(Nt||(Nt={}));var U;(function(r){r[r.AnyString=0]="AnyString",r[r.Order=1]="Order",r[r.EnglishOnly=2]="EnglishOnly",r[r.NumberOnly=3]="NumberOnly",r[r.CustomFormat=4]="CustomFormat"})(U||(U={}));const Ii={0:"\u4EFB\u610F\u5B57\u7B26",1:"\u5E8F\u53F7",2:"\u4EC5\u82F1\u6587",3:"\u4EC5\u6570\u5B57"},Bt=1e3,ie=16;var Ft;(function(r){r[r.ImgList=1e3]="ImgList",r[r.TrackPrediction=1001]="TrackPrediction",r[r.ImgSearch=1002]="ImgSearch"})(Ft||(Ft={}));const Li={[lt.PointCloud]:"sensebeepc",[m.ClientAttribute]:"sensebeepc-EnumAttributeTool",[m.Face]:"sensebeepc-FacePointsLabellingTool",[m.OCRRelation]:"sensebeepc-OCRRelationTool"},wi={[lt.PointCloud]:"\u70B9\u4E91\u5BA2\u6237\u7AEF",[m.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[m.Face]:"\u4EBA\u8138106\u70B9\u5DE5\u5177",[m.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177"},j=16,bt=10;var Ci=Object.freeze({__proto__:null,editStepWidth:xi,get EPointCloudName(){return lt},get EVideoToolName(){return ht},get EToolType(){return St},get EToolName(){return m},get ECheckModel(){return vt},get ERectPattern(){return Tt},TOOL_NAME:yi,get EDependPattern(){return kt},get EFilterToolOperation(){return rt},OPERATION_LIST:mi,get EAnnotationMode(){return Ot},get ELineTypes(){return T},get ELineColor(){return pt},get ESelectedType(){return Mt},get EDragTarget(){return F},get EDrawPointPattern(){return Et},get EPageOperator(){return Ht},get EAuditStatus(){return Nt},get ETextType(){return U},TEXT_TYPE:Ii,TEXT_ATTRIBUTE_MAX_LENGTH:Bt,TEXT_ATTRIBUTE_LINE_HEIGHT:ie,get EThumbnailOption(){return Ft},CLIENT_TOOL_HEAD_TYPE:Li,CLIENT_TOOL_NAME:wi,SEGMENT_NUMBER:j,edgeAdsorptionScope:bt}),Pi=Object.defineProperty,Di=Object.defineProperties,_i=Object.getOwnPropertyDescriptors,se=Object.getOwnPropertySymbols,Ai=Object.prototype.hasOwnProperty,Ri=Object.prototype.propertyIsEnumerable,re=(r,t,e)=>t in r?Pi(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Si=(r,t)=>{for(var e in t||(t={}))Ai.call(t,e)&&re(r,e,t[e]);if(se)for(var e of se(t))Ri.call(t,e)&&re(r,e,t[e]);return r},Ti=(r,t)=>Di(r,_i(t));function $t(r,t=.5,e=!1,i=16){if(r.length<4)return r;const s=[],n=r.slice(0);let o,a,l,h,d,u,c,g,f,v,p,x,y;for(e?(n.unshift(r[r.length-1]),n.unshift(r[r.length-2]),n.unshift(r[r.length-1]),n.unshift(r[r.length-2]),n.push(r[0]),n.push(r[1])):(n.unshift(r[1]),n.unshift(r[0]),n.push(r[r.length-2]),n.push(r[r.length-1])),y=2;y<n.length-4;y+=2)for(l=(n[y+2]-n[y-2])*t,h=(n[y+4]-n[y-0])*t,d=(n[y+3]-n[y-1])*t,u=(n[y+5]-n[y+1])*t,x=0;x<=i;x++)p=x/i,c=2*Math.pow(p,3)-3*Math.pow(p,2)+1,g=-(2*Math.pow(p,3))+3*Math.pow(p,2),f=Math.pow(p,3)-2*Math.pow(p,2)+p,v=Math.pow(p,3)-Math.pow(p,2),o=c*n[y]+g*n[y+2]+f*l+v*h,a=c*n[y+1]+g*n[y+3]+f*d+v*u,s.push(o),s.push(a);const A=[];for(let k=0;k<s.length-1;k+=2)A.push({x:s[k],y:s[k+1]});if(e)for(let k=0;k<i+1;k++){const S=A.shift();A.push(S)}return A}const xt=(r,t=16)=>$t(r.reduce((e,i)=>[...e,i.x,i.y],[]),.5,!1,t);function ne(r,t,e=T.Line){let i=0,s,n,o,a;t=[...t],e===T.Curve&&(t=$t(t.reduce((h,d)=>[...h,d.x,d.y],[]),.5,!0,j)),[o]=t;const l=t.length;for(s=1;s<=l;s++)a=t[s%l],r.x>Math.min(o.x,a.x)&&r.x<=Math.max(o.x,a.x)&&r.y<=Math.max(o.y,a.y)&&o.x!==a.x&&(n=(r.x-o.x)*(a.y-o.y)/(a.x-o.x)+o.y,(o.y===a.y||r.y<=n)&&i++),o=a;return i%2!=0}function oe(r,t=1){return r.map(e=>Ti(Si({},e),{x:e.x*t,y:e.y*t}))}const yt=class{static getRotate(r){return r+90>=360?r+90-360:r+90}static getLineLength(r,t){return Math.sqrt(Math.pow(t.y-r.y,2)+Math.pow(t.x-r.x,2))}};let w=yt;w.isInRange=(r,t)=>{const e=Math.min(...t),i=Math.max(...t),s=o=>o<=i&&o>=e;return(Array.isArray(r)?r:[r]).every(o=>s(o))},w.withinRange=(r,t)=>{const e=Math.min(...t),i=Math.max(...t);return r>i?i:r<e?e:r},w.calcViewportBoundaries=(r,t=!1,e=j,i=1)=>{if(!r)return{top:0,bottom:0,left:0,right:0};const s=20/i,n=[],o=[];let a=r;t&&(a=xt(r,e)),a.forEach(({x:f,y:v})=>{n.push(f),o.push(v)});let l=Math.min(...n),h=Math.max(...n),d=Math.min(...o),u=Math.max(...o);const c=h-l,g=u-d;if(c<s){const f=(s-c)/2;l-=f,h+=f}if(g<s){const f=(s-g)/2;d-=f,u+=f}return{top:d,bottom:u,left:l,right:h}},w.getFootOfPerpendicular=(r,t,e,i=!1)=>{let s={x:0,y:0};const n=t.x-e.x,o=t.y-e.y;if(Math.abs(n)<1e-8&&Math.abs(o)<1e-8)return s=t,s;let a=(r.x-t.x)*(t.x-e.x)+(r.y-t.y)*(t.y-e.y);a/=n*n+o*o,s.x=t.x+a*n,s.y=t.y+a*o;const l=yt.getLineLength(r,s),h=2,d=Math.min(t.x,e.x),u=Math.max(t.x,e.x),c=Math.min(t.y,e.y),g=Math.max(t.y,e.y),f=!(yt.isInRange(r.x,[d,u])||yt.isInRange(r.y,[c,g])),v=r.x>u+h||r.x<d-h||r.y>g+h||r.y<c-h;return(i?f:v)?{footPoint:s,length:Infinity}:{footPoint:s,length:l}};const ki=61,Oi=40,Mi=40,Ei=240;var ut;(function(r){r[r.ANNOTATION=1]="ANNOTATION",r[r.QUALITY_INSPECTION=2]="QUALITY_INSPECTION",r[r.PRE_ANNOTATION=3]="PRE_ANNOTATION",r[r.MANUAL_CORRECTION=4]="MANUAL_CORRECTION"})(ut||(ut={}));const Hi=1e3;var Zt;(function(r){r[r.Backward=0]="Backward",r[r.Forward=1]="Forward",r[r.JumpSkip=2]="JumpSkip",r[r.None=3]="None"})(Zt||(Zt={}));var _;(function(r){r[r.Start=0]="Start",r[r.Stop=1]="Stop",r[r.Wait=2]="Wait",r[r.Move=3]="Move"})(_||(_={}));var Y;(function(r){r[r.Point=0]="Point",r[r.Line=1]="Line",r[r.Plane=2]="Plane"})(Y||(Y={}));var z;(function(r){r[r.ascend=0]="ascend",r[r.descend=1]="descend"})(z||(z={}));var ct;(function(r){r[r.Intelligence=0]="Intelligence",r[r.Linear=1]="Linear"})(ct||(ct={}));var q;(function(r){r.Zh="zh_CN",r.US="en_US"})(q||(q={}));const nt={offsetX:-10,offsetY:-10},mt={shadowColor:"rgba(0,0,0,0.6)",shadowOffsetX:0,shadowOffsetY:2,shadowBlur:4};var Ni=Object.freeze({__proto__:null,headerHeight:ki,tipsHeight:Oi,footerHeight:Mi,sidebarWidth:Ei,get EStepType(){return ut},ANNOTATION_MAX_SIZE:Hi,get EPageOperator(){return Zt},get EDragStatus(){return _},get EDragTarget(){return Y},get ESortDirection(){return z},get EGrowthMode(){return ct},get ELang(){return q},DEFAULT_TEXT_OFFSET:nt,DEFAULT_TEXT_SHADOW:mt}),Bi=Object.defineProperty,Fi=Object.defineProperties,$i=Object.getOwnPropertyDescriptors,ae=Object.getOwnPropertySymbols,Zi=Object.prototype.hasOwnProperty,Ui=Object.prototype.propertyIsEnumerable,le=(r,t,e)=>t in r?Bi(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Q=(r,t)=>{for(var e in t||(t={}))Zi.call(t,e)&&le(r,e,t[e]);if(ae)for(var e of ae(t))Ui.call(t,e)&&le(r,e,t[e]);return r},tt=(r,t)=>Fi(r,$i(t));class H{static composeResult(t,e,i,s,n){try{const o=JSON.parse(t),a=b.getCurrentStepInfo(e,s),{dataSourceStep:l}=a,h=`step_${a.step}`;if(Object.assign(o,n),o[h]){const d=o[h];return d.result?(d.result=i,JSON.stringify(o)):JSON.stringify(tt(Q({},o),{[h]:tt(Q({},o[h]),{result:i})}))}return JSON.stringify(tt(Q({},o),{[h]:{dataSourceStep:l,toolName:a.tool,result:i}}))}catch(o){return t}}static changeCoordinateByRotate(t,e,i){const{x:s,y:n,width:o,height:a}=t,l=I.changeCoordinateByRotate({x:s,y:n},e,i);switch(e%360){case 90:return tt(Q({},t),{x:l.x-a,y:l.y,width:a,height:o});case 180:return tt(Q({},t),{x:l.x-o,y:l.y-a});case 270:return tt(Q({},t),{x:l.x,y:l.y-o,width:a,height:o});default:return t}}static translateRect2Points(t){const{x:e,y:i,width:s,height:n}=t;return[{x:e,y:i},{x:e+s,y:i},{x:e+s,y:i+n},{x:e,y:i+n}]}static translatePoints2Rect(t,e){if(t.length!==4)return;const{x:i,y:s}=t[0],n=t[1].x-t[0].x,o=t[2].y-t[1].y;return tt(Q({},e),{x:i,y:s,width:n,height:o})}static getRectPointList(t,e=1){return[{x:t.x*e,y:t.y*e},{x:(t.x+t.width)*e,y:t.y*e},{x:(t.x+t.width)*e,y:(t.y+t.height)*e},{x:t.x*e,y:(t.y+t.height)*e}]}static getRectEdgeList(t,e=1){const i=this.getRectPointList(t,e),s=i.length;return i.map((n,o)=>({begin:n,end:i[(o+1)%s]}))}static isInRect(t,e,i=0,s=1){return t.x>=e.x*s-i&&t.x<=(e.x+e.width)*s+i&&t.y>=e.y*s-i&&t.y<=(e.y+e.height)*s+i}static getRectUnderZoom(t,e=1){const{x:i,y:s,width:n,height:o}=t;return tt(Q({},t),{x:i*e,y:s*e,width:n*e,height:o*e})}static isRectNotInPolygon(t,e){return this.getRectPointList(t).some(s=>!ne(s,e))}}function W(r=8,t=62){const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),i=[];let s;if(t=t||e.length,r)for(s=0;s<r;s++)i[s]=e[0|Math.random()*t];else{let n;for(i[8]=i[13]=i[18]=i[23]="-",i[14]="4",s=0;s<36;s++)i[s]||(n=0|Math.random()*16,i[s]=e[s===19?n&3|8:n])}return i.join("")}var zi=Object.defineProperty,he=Object.getOwnPropertySymbols,Vi=Object.prototype.hasOwnProperty,Wi=Object.prototype.propertyIsEnumerable,ce=(r,t,e)=>t in r?zi(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,de=(r,t)=>{for(var e in t||(t={}))Vi.call(t,e)&&ce(r,e,t[e]);if(he)for(var e of he(t))Wi.call(t,e)&&ce(r,e,t[e]);return r};class gt{static getTagKeyName(t,e){var i,s;if(!!e)return(s=(i=e.find(n=>n.value===t))==null?void 0:i.key)!=null?s:""}static getTagName([t="",e=""],i){if(!!i){for(const s of i)if(s.value===t){if(!s.subSelected)return console.error("\u6807\u7B7E\u89E3\u6790\u9519\u8BEF",t,e),"";for(const n of s.subSelected)if(n.value===e)return n.key}}}static getTagNameList(t,e){return Object.keys(t).length<=0?[]:Object.entries(t).reduce((i,s)=>{const[n,o]=s;if(o&&o.length>0){const a=o.split(";"),l={keyName:this.getTagKeyName(n,e),value:a.map(h=>this.getTagName([n,h],e))};return[...i,l]}return i},[]).filter(i=>i)}static getTagnameListWithoutConfig(t){return Object.keys(t).length<=0?[]:Object.entries(t).reduce((e,i)=>{const[s,n]=i,o=n.split(";"),a={keyName:s,value:o};return[...e,a]},[]).filter(e=>e)}static judgeResultIsInInputList(t,e,i){return!t||!e||!i?!1:i.filter(n=>{if(n.value===t&&n.subSelected){const o=e==null?void 0:e.split(";");return(n==null?void 0:n.subSelected.filter(a=>o.indexOf(a.value)>-1).length)>0}return!1}).length>0}static getDefaultResultByConfig(t){return t.reduce((e,i)=>(i.subSelected&&i.subSelected.forEach(s=>{var n;if(s.isDefault){const o=(n=e[i.value])!=null?n:"";let a=[];o.length>0&&(a=o.split(";")),a.push(s.value),e[i.value]=a.join(";")}}),e),{})}static getDefaultTagResult(t,e){const i=this.getDefaultResultByConfig(t);return e.length>0?e.map(s=>({id:W(),sourceID:s.id,result:de({},i)})):[{id:W(),sourceID:"",result:de({},i)}]}}var ue='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#ccc"/></g></g></svg>',ji='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#ff2323"/></g></g></svg>',Xi='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#ffe232"/></g></g></svg>',Yi='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#01ff30"/></g></g></svg>',Gi='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#00ffea"/></g></g></svg>',Ki='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#0282fa"/></g></g></svg>',Ji='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#800cf9"/></g></g></svg>',qi='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#ff88f7"/></g></g></svg>',Qi='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#994217"/></g></g></svg>',ts='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#1f0bf9"/></g></g></svg>',es='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#3fe"/></g></g></svg>',is='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#33fe33"/></g></g></svg>',ss='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#fdff37"/></g></g></svg>',rs='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#f70efa"/></g></g></svg>',ge='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill="#f33"/></g></g></svg>';const fe=ue,ns=61,os=80,as=62,ls=20,hs=55,cs=55,ds=40,us=80,gs=240,fs=320,vs="rgba(102, 111, 255, 1)",dt=["rgba(128, 12, 249, 1)","rgba(0, 255, 48, 1)","rgba(255, 136, 247, 1)","rgba(255, 226, 50, 1)","rgba(153, 66, 23, 1)","rgba(2, 130, 250, 1)","rgba(255, 35, 35, 1)","rgba(0, 255, 234, 1)"],It=[ue,Ji,Yi,qi,Xi,Qi,Ki,ji,Gi],ve={1:ts,3:es,5:is,7:ss,9:rs},ps="rgba(255, 51, 51, 1)",Ut="rgba(204, 204, 204, 1)",bs={[rt.lc]:"rgba(153, 51, 255, 1)",[rt.rc]:"rgba(51, 153, 255, 1)",[rt.clc]:"rgba(46, 230, 46, 1)",[rt.crc]:"rgba(255, 51, 51, 1)"};var xs=Object.freeze({__proto__:null,HEADER_HEIGHT:ns,TAB_HEIGHT:os,SEARCH_HEIGHT:as,PADDING:ls,TABLE_ROW_HEIGHT:hs,PAGINATION_HEIGHT:cs,TIPS_HEIGHT:ds,FOOTER_HEIGHT:us,SIDERBAR_WIDTH:gs,EDIT_STEP_WIDTH:fs,THEME_COLOR:vs,COLORS_ARRAY:dt,ICON_ARRAY:It,BASE_ICON:ve,INVALID_COLOR:ps,NULL_COLOR:Ut,NULL_ICON:fe,INVALID_ICON:ge,FILTER_TOOL_COLOR:bs}),L;(function(r){r.NoRotateNotice="noRotateNotice",r.RectErrorSizeNotice="rectErrorSizeNotice",r.TextCheckNumberErrorNotice="textCheckNumberErrorNotice",r.TextCheckEnglishErrorNotice="textCheckEnglishErrorNotice",r.TextCheckCustomErrorNotice="textCheckCustomErrorNotice",r.UpperLimitErrorNotice="UpperLimitErrorNotice",r.LowerLimitErrorNotice="LowerLimitErrorNotice",r.InvalidImage="InvalidImage",r.DisableDelete="DisableDelete",r.ClearPartialData="ClearPartialData",r.MarkerFinish="MarkerFinish",r.LowerLimitPoint="LowerLimitPoint",r.NoRotateInDependence="noRotateInDependence"})(L||(L={}));const ys={[L.NoRotateNotice]:"This Image contains data and cannot be rotated",[L.RectErrorSizeNotice]:"The drawing frame size is smaller than the minimum drawing size",[L.TextCheckNumberErrorNotice]:"Please enter in number-only format",[L.TextCheckEnglishErrorNotice]:"Please enter in English only format",[L.TextCheckCustomErrorNotice]:"Please enter in the required format",[L.UpperLimitErrorNotice]:"The number of vertices is not more than",[L.LowerLimitErrorNotice]:"The number of vertices is not less than",[L.InvalidImage]:"Invalid image, please skip this image",[L.DisableDelete]:"Disable delete",[L.ClearPartialData]:"Clear partial data",[L.MarkerFinish]:"ListAnnotation is finished",[L.LowerLimitPoint]:"\u5DF2\u5230\u8FBE\u6807\u70B9\u6570\u91CF\u4E0A\u9650",[L.NoRotateInDependence]:"Disallow rotation in dependent cases"},ms={[L.NoRotateNotice]:"\u672C\u56FE\u542B\u6709\u6570\u636E\uFF0C\u65E0\u6CD5\u8FDB\u884C\u65CB\u8F6C",[L.RectErrorSizeNotice]:"\u7ED8\u5236\u6846\u5C3A\u5BF8\u5C0F\u4E8E\u6700\u5C0F\u7ED8\u5236\u5C3A\u5BF8",[L.TextCheckNumberErrorNotice]:"\u8BF7\u6309\u4EC5\u6570\u5B57\u7684\u683C\u5F0F\u8F93\u5165",[L.TextCheckEnglishErrorNotice]:"\u8BF7\u6309\u4EC5\u82F1\u6587\u7684\u683C\u5F0F\u8F93\u5165",[L.TextCheckCustomErrorNotice]:"\u8BF7\u6309\u8981\u6C42\u7684\u683C\u5F0F\u8F93\u5165",[L.UpperLimitErrorNotice]:"\u9876\u70B9\u6570\u4E0D\u591A\u4E8E",[L.LowerLimitErrorNotice]:"\u9876\u70B9\u6570\u4E0D\u5C11\u4E8E",[L.InvalidImage]:"\u65E0\u6548\u56FE\u7247\uFF0C\u8BF7\u8DF3\u8FC7\u6B64\u56FE",[L.DisableDelete]:"\u8BE5\u6570\u636E\u7981\u6B62\u5220\u9664",[L.ClearPartialData]:"\u5B58\u5728\u90E8\u5206\u6570\u636E\u65E0\u6CD5\u6E05\u9664",[L.MarkerFinish]:"\u5217\u8868\u6807\u6CE8\u5DF2\u5B8C\u6210",[L.LowerLimitPoint]:"\u5DF2\u5230\u8FBE\u6807\u70B9\u6570\u91CF\u4E0A\u9650",[L.NoRotateInDependence]:"\u4F9D\u8D56\u60C5\u51B5\u4E0B\u65E0\u6CD5\u8FDB\u884C\u65CB\u8F6C"};class ${}$.getMessagesByLocale=(r,t)=>{switch(t){case q.US:return ys[r];case q.Zh:default:return ms[r]}};var Is=Object.defineProperty,Ls=Object.defineProperties,ws=Object.getOwnPropertyDescriptors,pe=Object.getOwnPropertySymbols,Cs=Object.prototype.hasOwnProperty,Ps=Object.prototype.propertyIsEnumerable,be=(r,t,e)=>t in r?Is(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,xe=(r,t)=>{for(var e in t||(t={}))Cs.call(t,e)&&be(r,e,t[e]);if(pe)for(var e of pe(t))Ps.call(t,e)&&be(r,e,t[e]);return r},ye=(r,t)=>Ls(r,ws(t));const Ds="^[0-9]+$",_s="^[A-Za-z]+$";class D{static getAttributeIcon(t,e,i=!0){var s;const n=e.findIndex(l=>l.value===t);let o=(s=It[n%It.length])!=null?s:fe;i||(o=ge),o="";const a=new Image;return a.src=o,a}static checkString(t,e){let i="";switch(t){case U.Order:case U.NumberOnly:i=Ds;break;case U.EnglishOnly:i=_s;break;case U.CustomFormat:i=e;break}return i}static checkTextAttibute(t,e){if(t===void 0||t==="")return!0;try{return new RegExp(e).test(t)}catch(i){return!1}}static getAttributeShowText(t,e=[]){var i,s;try{const n=e.findIndex(o=>o.value===t);return(s=(i=e[n])==null?void 0:i.key)!=null?s:t}catch(n){return t}}static getAttributeIndex(t,e){try{const i=e.findIndex(s=>s.value===t);return i>=8?i%8:i}catch(i){return-1}}static getAttributeColor(t,e){try{const i=this.getAttributeIndex(t,e);return i===-1?Ut:dt[i%dt.length]}catch(i){return Ut}}static getTextAttribute(t,e){try{if(e===U.Order){const i=t.map(n=>parseInt(n.textAttribute,10)).filter(n=>Rt(n)&&n<Number.MAX_SAFE_INTEGER&&n>=0);return i.sort((n,o)=>n-o),`${(i.pop()||0)+1}`}return""}catch(i){return""}}static textChange(t,e,i){return i.map(s=>s.id===e?ye(xe({},s),{textAttribute:t}):s)}static getErrorNotice(t,e){switch(t){case U.Order:case U.NumberOnly:return $.getMessagesByLocale(L.TextCheckNumberErrorNotice,e);case U.EnglishOnly:return $.getMessagesByLocale(L.TextCheckEnglishErrorNotice,e);case U.CustomFormat:return $.getMessagesByLocale(L.TextCheckCustomErrorNotice,e);default:return""}}static textAttributeValidate(t,e,i){try{return new RegExp(this.checkString(t,e)).test(i)}catch(s){}}static checkTextAttribute(t,e,i,s){let n=!1;return i.forEach(o=>{(o==null?void 0:o.textAttribute)===void 0||(o==null?void 0:o.textAttribute)===""||(s?o.id===s:!0)&&!this.textAttributeValidate(t,e,o.textAttribute)&&(n=!0)}),!!n}static changeTextAttributeInLog(t,e){return t==null?void 0:t.map(i=>i==null?void 0:i.map(s=>{if((e==null?void 0:e.findIndex(n=>(n==null?void 0:n.id)===(s==null?void 0:s.id)))>-1){const n=e==null?void 0:e.find(o=>(o==null?void 0:o.id)===(s==null?void 0:s.id));return ye(xe({},s),{textAttribute:n==null?void 0:n.textAttribute})}return s}))}static getTextIconSvg(t="",e,i=!1,s){if(i===!0){const n=(e==null?void 0:e.findIndex(o=>(o==null?void 0:o.value)===t))%dt.length+1;return It[n]}return s}static getAttributeByKeycode(t,e){var i;let s;return w.isInRange(t,[48,57])&&(s=t-48),w.isInRange(t,[96,105])&&(s=t-96),s===0?"":s?(i=e[s-1])==null?void 0:i.value:void 0}}class Lt{static deg2rad(t){return t*Math.PI/180}static rad2deg(t){return t*180/Math.PI}}const As=1,Rs={x:0,y:0},Ss=0,X="";class C{static drawLine(t,e,i,s={}){const n=t.getContext("2d"),{color:o=X,thickness:a=1,lineCap:l="round"}=s;n.save(),n.strokeStyle=o,n.lineWidth=a,n.lineCap=l,n.beginPath(),n.moveTo(e.x,e.y),n.lineTo(i.x+1,i.y+1),n.stroke(),n.restore()}static drawRect(t,e,i={}){const s=t.getContext("2d"),{color:n=X,thickness:o=1,lineCap:a="round"}=i;s.save(),s.strokeStyle=n,s.lineWidth=o,s.lineCap=a,s.beginPath(),s.fillStyle=n,s.strokeRect(e.x,e.y,e.width,e.height);let l="";if(e.attribute&&(l=`${l} ${e.attribute}`),this.drawText(t,{x:e.x,y:e.y-5},l),e.textAttribute){const d=`${~~e.width} * ${~~e.height}`.length*7,u=0,c=Math.max(20,e.width-d);this.drawText(t,{x:e.x,y:e.y+e.height+20+u},e.textAttribute,{textMaxWidth:c})}s.restore()}static drawRectWithFill(t,e,i={}){const s=t.getContext("2d"),{color:n=X}=i;s.save(),s.beginPath(),s.fillStyle=n,s.fillRect(e.x,e.y,e.width,e.height),s.restore()}static drawTag(t,e){var i;const s=t==null?void 0:t.parentNode,n=window==null?void 0:window.self.document.getElementById("tagToolTag");if(n&&s&&s.contains(n)&&(s==null||s.removeChild(n)),!((e==null?void 0:e.length)>0))return;const o=document.createElement("div");o.innerHTML=(i=e.reduce((a,l)=>`${a}${l.keyName}: ${l.value.join(" \u3001 ")}
|
|
6
|
+
`,""))!=null?i:"",o.setAttribute("id","tagToolTag"),s==null||s.appendChild(o)}static drawLineWithPointList(t,e,i={}){if(e.length<2)return;const s=t.getContext("2d"),{color:n=X,thickness:o=1,lineCap:a="round",lineType:l=T.Line,hoverEdgeIndex:h}=i;s.save(),s.strokeStyle=n,s.lineWidth=o,s.lineCap=a,s.beginPath(),l===T.Curve?(h!==void 0&&h>-1&&e.push(e[0]),e=M.createSmoothCurvePointsFromPointList([...e],j),h!==void 0&&h>-1&&(e=e.slice((j+1)*h,(j+1)*(h+1)))):h!==void 0&&h>-1&&(e=[...e,e[0]],e=e.slice(h,h+2));const[d,...u]=e;s.moveTo(d.x,d.y),u.forEach(c=>{s.lineTo(c.x,c.y)}),s.stroke(),s.restore()}static drawCircle(t,e,i,s={}){const n=t.getContext("2d"),{startAngleDeg:o=0,endAngleDeg:a=360,thickness:l=1,color:h=X,fill:d=X}=s,u=Lt.deg2rad(o),c=Lt.deg2rad(a);n.save(),n.beginPath(),n.strokeStyle=h,n.fillStyle=d,n.lineWidth=l,n.arc(e.x,e.y,i,u,c,!1),n.stroke(),n.fill(),n.closePath(),n.restore()}static drawCircleWithFill(t,e,i=3,s={}){const n=t.getContext("2d"),{color:o=X}=s;n.save();const a=Lt.deg2rad(0),l=Lt.deg2rad(360);n.fillStyle=o,n.beginPath(),n.arc(e.x,e.y,i,a,l,!1),n.fill(),n.restore()}static drawPolygon(t,e,i={}){const{isClose:s=!1,lineType:n=T.Line}=i;s===!0&&(e=[...e,e[0]]),n===T.Curve&&(e=M.createSmoothCurvePointsFromPointList([...e])),this.drawLineWithPointList(t,e,i)}static drawPolygonWithFill(t,e,i={}){if(e.length<2)return;const s=t.getContext("2d"),{color:n=X,lineType:o=T.Line}=i;s.save(),s.fillStyle=n,s.beginPath(),o===T.Curve&&(e=M.createSmoothCurvePointsFromPointList([...e,e[0]]));const[a,...l]=e;s.moveTo(a.x,a.y),l.forEach(h=>{s.lineTo(h.x,h.y)}),s.fill(),s.restore()}static drawPolygonWithFillAndLine(t,e,i={}){const{strokeColor:s,fillColor:n,thickness:o,lineCap:a,isClose:l,lineType:h}=i;this.drawPolygon(t,e,{color:s,thickness:o,lineCap:a,isClose:l,lineType:h}),this.drawPolygonWithFill(t,e,{color:n,lineType:h})}static drawSelectedPolygonWithFillAndLine(t,e,i={}){const{pointColor:s="white",strokeColor:n}=i;this.drawPolygonWithFillAndLine(t,e,i),[...e].forEach(a=>{this.drawCircleWithFill(t,a,4,{color:n}),this.drawCircleWithFill(t,a,3,{color:s})})}static drawText(t,e,i,s={}){if(!i)return;const n=t.getContext("2d"),{color:o=X,font:a="normal normal 500 14px Arial",shadowColor:l="",shadowBlur:h=0,shadowOffsetX:d=0,shadowOffsetY:u=0,textMaxWidth:c=164,offsetX:g=0,offsetY:f=0,textAlign:v="start"}=s;n.save(),n.textAlign=v,n.fillStyle=o!=null?o:"white",n.font=a,n.shadowColor=l,n.shadowOffsetX=d,n.shadowOffsetY=u,n.shadowBlur=h,this.wrapText(t,`${i}`,e.x+g,e.y+f,c),n.restore()}static wrapText(t,e,i,s,n,o){var a,l;if(typeof e!="string"||typeof i!="number"||typeof s!="number")return;const h=t.getContext("2d");typeof n=="undefined"&&(n=t&&t.width||300),typeof o=="undefined"&&(o=((a=t&&parseInt(window==null?void 0:window.getComputedStyle(t).lineHeight,10))!=null?a:0)||parseInt((l=window==null?void 0:window.getComputedStyle(document.body).lineHeight)!=null?l:0,10));const d=e.split(`
|
|
7
|
+
`);for(let u=0;u<d.length;u++){const c=d[u].split("");let g="";for(let f=0;f<c.length;f++){const v=g+c[f],x=h.measureText(v).width;n||(n=300),x>n&&f>0?(h.fillText(g,i,s),g=c[f],s+=o):g=v}h.fillText(g,i,s),s+=o}}static drawArrow(t,e,i,s={}){const{color:n=X,thickness:o=1,lineCap:a="round",theta:l=30,headLen:h=10}=s,d=Math.atan2(e.y-i.y,e.x-i.x)*180/Math.PI,u=(d+l)*Math.PI/180,c=(d-l)*Math.PI/180,g=h*Math.cos(u),f=h*Math.sin(u),v=h*Math.cos(c),p=h*Math.sin(c);t.save(),t.strokeStyle=n,t.lineWidth=o,t.lineCap=a,t.beginPath(),t.moveTo(i.x+g,i.y+f),t.lineTo(i.x,i.y),t.lineTo(i.x+v,i.y+p),t.stroke(),t.restore()}}C.drawImg=(r,t,e={})=>{const i=r.getContext("2d"),{zoom:s=As,currentPos:n=Rs,rotate:o=Ss,imgAttribute:a}=e;switch(i.save(),o){case 0:i.translate(n.x,n.y);break;case 90:i.translate(n.x+t.height*s,n.y),i.rotate(90*Math.PI/180);break;case 180:i.translate(n.x+t.width*s,n.y+t.height*s),i.rotate(Math.PI);break;case 270:i.translate(n.x,n.y+t.width*s),i.rotate(270*Math.PI/180);break;default:i.translate(n.x,n.y);break}if(a){const{contrast:l,saturation:h,brightness:d}=a;i.filter=`saturate(${h+100}%) contrast(${l+100}%) brightness(${d+100}%)`}i.drawImage(t,0,0,t.width*s,t.height*s),i.restore()};class G{static getStrokeAndFill(t,e=!0,i={}){const{isSelected:s=!1,isHover:n=!1}=i;return s?{stroke:e?t.validSelected.stroke:t.invalidSelected.stroke,fill:e?t.validSelected.fill:t.invalidSelected.fill}:n?{stroke:e?t.validHover.stroke:t.invalidHover.stroke,fill:e?t.validHover.fill:t.invalidHover.fill}:{stroke:e?t.valid.stroke:t.invalid.stroke,fill:e?t.valid.fill:t.invalid.fill}}}var zt;(function(r){r[r.A=65]="A",r[r.B=66]="B",r[r.C=67]="C",r[r.D=68]="D",r[r.E=69]="E",r[r.F=70]="F",r[r.G=71]="G",r[r.H=72]="H",r[r.L=76]="L",r[r.R=82]="R",r[r.Z=90]="Z",r[r.W=87]="W",r[r.X=88]="X",r[r.Y=89]="Y",r[r.S=83]="S",r[r.Q=81]="Q",r[r.Delete=46]="Delete",r[r.F11=122]="F11",r[r.Space=32]="Space",r[r.Esc=27]="Esc",r[r.Left=37]="Left",r[r.Up=38]="Up",r[r.Right=39]="Right",r[r.Down=40]="Down",r[r.Enter=13]="Enter",r[r.Ctrl=17]="Ctrl",r[r.Alt=18]="Alt",r[r.Shift=16]="Shift",r[r.Tab=9]="Tab"})(zt||(zt={}));var P=zt,Ts=Object.freeze({__proto__:null,default:P});class Vt{constructor(t){this.record=[],this.recordIndex=-1,this.minRecordIndex=-1,this.emitHistoryChanged=()=>{this.historyChanged&&(this.constructor.name==="ActionsHistory"?!0:this.record.length>0)&&this.historyChanged(this.undoEnabled,this.redoEnabled)},this.historyChanged=t}get undoEnabled(){return this.recordIndex>this.minRecordIndex}get redoEnabled(){return this.recordIndex<this.record.length-1}pushHistory(t){if(this.recordIndex!==this.record.length-1){const e=this.record.slice(0,Math.min(this.recordIndex+1,this.record.length));this.record=e}this.record.push(E.cloneDeepWith(t)),this.recordIndex+=1,this.emitHistoryChanged()}updateHistory(t){this.record[this.recordIndex]=E.cloneDeep(t)}applyAttribute(t,e,i){t&&this.record.forEach(s=>{const n=s.find(o=>o.id===t);n&&(n[e]=i)})}undo(){if(this.undoEnabled)return this.recordIndex-=1,this.emitHistoryChanged(),E.cloneDeep(this.record[this.recordIndex])||[]}redo(){if(this.redoEnabled)return this.recordIndex+=1,this.emitHistoryChanged(),E.cloneDeep(this.record[this.recordIndex])}init(){this.record=[[]],this.recordIndex=0,this.emitHistoryChanged()}empty(){this.record=[],this.recordIndex=-1,this.emitHistoryChanged()}initRecord(t,e=!1){const i=t.length>0||e;this.record=i?[E.cloneDeep(t)]:[],this.minRecordIndex=i?0:-1,this.recordIndex=0}}class me{constructor(t,e){this.rcTime=0,this.mouseDownTime=0,this.onMouseDown=()=>{this.mouseDownTime=new Date().getTime()},this.dom=t,this.isDoubleClick=!1,this.delay=e}getRcTime(){return this.rcTime}getCoord(t){return{x:t.clientX,y:t.clientY}}removeEvent(){!this.dom||(this.dom.removeEventListener("mouseup",this.mouseUp),this.dom.removeEventListener("mousemove",this.mouseMove),this.dom.removeEventListener("dblclick",this.dblclick),this.dom.removeEventListener("mousedown",this.onMouseDown))}addEvent(t,e,i,s){!this.dom||(this.removeEvent(),this.mouseUp=n=>{const o=new Date().getTime(),a=s?s(n):!0;if(o-this.mouseDownTime>this.delay||a!==!0){t(n);return}if(n.button===2)if(this.rcTime===0)setTimeout(()=>{this.rcTime=0},this.delay),this.rcTime=o;else{o-this.rcTime<this.delay&&(i(n),clearTimeout(this.setTimeFun),this.cacheFunction=void 0),this.rcTime=0;return}this.setTimeFun&&clearTimeout(this.setTimeFun),this.clickCoord=this.getCoord(n),this.cacheFunction=()=>t(n),this.setTimeFun=setTimeout(()=>{if(this.isDoubleClick){this.isDoubleClick=!1;return}this.cacheFunction(),this.clickCoord=void 0},this.delay)},this.mouseMove=n=>{const o=this.getCoord(n);this.clickCoord&&!I.getIsInScope(o,this.clickCoord,10)&&(this.cacheFunction&&this.cacheFunction(),this.clickCoord=void 0,this.cacheFunction=null,clearTimeout(this.setTimeFun))},this.dblclick=n=>{this.isDoubleClick=!0,this.clickCoord=void 0,e(n)},this.dom.addEventListener("mouseup",this.mouseUp),this.dom.addEventListener("mousemove",this.mouseMove),this.dom.addEventListener("dblclick",this.dblclick),this.dom.addEventListener("mousedown",this.onMouseDown))}clearRightDblClick(){this.rcTime=0}}class Ie{static getInitImgPos(t,e,i=0,s=1,n=!1){(i===90||i===270)&&(e={width:e.height,height:e.width});const o=t.width*s/e.width,a=t.height*s/e.height;let l=n?1:Math.min(o,a);const h={x:(t.width-e.width*l)/2,y:(t.height-e.height*l)/2},d=e.width*l,u=e.height*l;return n&&(l=1),{zoom:l,currentPos:h,imgInfo:{width:d,height:u}}}static getBasicRecPos(t,e,i,s=.9,n=1,o=!1){if(e&&t){const{x:a,y:l,height:h,width:d}=e;let u=i.height/h;d/h>i.width/i.height&&(u=i.width/d);const c=o?1:u*s*n,g={x:i.width/2,y:i.height/2},f={x:(a+d/2)*c,y:(l+h/2)*c};return{currentPos:{x:g.x-f.x,y:g.y-f.y},innerZoom:c}}return!1}}class ks{static renderInvalidPage(t,e,i){const s=document.createElement("div");return s.setAttribute("style",`
|
|
8
8
|
position: absolute;
|
|
9
9
|
left: 0px;
|
|
10
10
|
top: 0px;
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
font-size: 30px;
|
|
20
20
|
opacity: 0.7;
|
|
21
21
|
z-index: 30;
|
|
22
|
-
`),s.innerHTML=$.getMessagesByLocale(L.InvalidImage,i),e.appendChild(s),s}}const et=[1,5,10,20,30,50,80,100].concat(Array.from({length:9}).map((r,t)=>(t+2)*100));class wt{}wt.zoomChanged=(r,t,e=ct.Linear)=>{switch(e){case ct.Intelligence:{const i=Math.max(...et),s=Math.min(...et),n=et.slice(0,et.length).findIndex((a,l)=>r>=a&&(r<et[l+1]||a===i));let o;if(n===-1)r>=s&&r<=i?o=t?i:s:o=t?s:r;else{const a=t?n+1:n-(et.includes(r)?1:0);o=et[w.withinRange(a,[0,et.length-1])]}return o}default:{const i=t?2:1/2;return r*i}}},wt.wheelChangePos=(r,t,e,i,s={})=>{const{zoom:n=1,innerZoom:o=1,basicZoom:a=1,zoomMax:l=1e3,rotate:h=0}=s,{x:d,y:u}=i,c=parseFloat((n+1/10).toFixed(1))/5;if(r&&t){let{width:g,height:f}=r;[90,270].includes(h)&&(g=r.height,f=r.width);const v=g*o,p=f*o,x=t.x-d,y=t.y-u,A=x/v,k=y/p;let S=n+e*c;S=w.withinRange(S,[a,l]);const Z=g*S*A,st=f*S*k,at=d+(x-Z),vi=u+(y-st);return{zoom:S,currentPos:{x:at,y:vi},imgInfo:{width:g*S,height:f*S},ratio:c}}return null};class Os{constructor(){this._events=new Map}on(t,e){const i=this._events.get(t)||[];i.some(s=>s===e)||this._events.set(t,i.concat(e))}singleOn(t,e){this._events.set(t,[e])}emit(t,...e){const i=this._events.get(t);i&&i.forEach(s=>{s&&s(...e)})}unbind(t,e){const i=this._events.get(t);i&&this._events.set(t,i.filter(s=>s!==e))}unbindAll(t){this._events.delete(t)}}const Le={showConfirm:!1,skipWhileNoDependencies:!1,drawOutsideTarget:!1,copyBackwardResult:!1,minWidth:1,minHeight:1,isShowOrder:!1,filterData:["valid","invalid"],attributeConfigurable:!1,attributeList:[],textConfigurable:!1,textCheckType:0,customFormat:""},Ms={showConfirm:!1,skipWhileNoDependencies:!1,inputList:[{key:"\u7C7B\u522B1",value:"class1",isMulti:!1,subSelected:[{key:"\u9009\u98791",value:"option1",isDefault:!1},{key:"\u9009\u98792",value:"option1-2",isDefault:!1}]},{key:"\u7C7B\u522B2",value:"class-AH",isMulti:!0,subSelected:[{key:"\u9009\u98792-1",value:"option2-1",isDefault:!1},{key:"\u9009\u98792-2",value:"option2-2",isDefault:!1},{key:"\u9009\u98792-3",value:"option2-3",isDefault:!1}]},{key:"\u7C7B\u522B3",value:"class-0P",isMulti:!1,subSelected:[{key:"\u9009\u98793-1",value:"option3-1",isMulti:!1},{key:"\u9009\u98793-2",value:"option3-2",isDefault:!1},{key:"\u9009\u98793-3",value:"option3-3",isDefault:!1}]}]},Es={lineType:0,lineColor:0,edgeAdsorption:!1,outOfTarget:!0,copyBackwardResult:!1,isShowOrder:!1,attributeConfigurable:!1,attributeList:[{key:"\u7C7B\u522B1",value:"\u7C7B\u522B1"},{key:"\u7C7B\u522Bao",value:"class-ao"},{key:"\u7C7B\u522BM1",value:"class-M1"},{key:"\u7C7B\u522BCm",value:"class-Cm"},{key:"\u7C7B\u522Bc3",value:"class-c3"},{key:"\u7C7B\u522Ba0",value:"class-a0"},{key:"\u7C7B\u522Bu7",value:"class-u7"},{key:"\u7C7B\u522BZb",value:"class-Zb"},{key:"\u7C7B\u522Bzi",value:"class-zi"}],textConfigurable:!1,textCheckType:2,customFormat:"",showConfirm:!1,lowerLimitPointNum:2,upperLimitPointNum:"",preReferenceStep:0,skipWhileNoDependencies:!1,filterData:["valid","invalid"]},Hs={showConfirm:!1,skipWhileNoDependencies:!1,enableTextRecognition:!1,recognitionMode:"general",configList:[{label:"\u6587\u672C",key:"text",required:!1,default:"",maxLength:1e3}],filterData:["valid","invalid"]},Ns={lineType:0,lineColor:0,lowerLimitPointNum:3,edgeAdsorption:!1,drawOutsideTarget:!1,copyBackwardResult:!1,isShowOrder:!1,attributeConfigurable:!1,attributeList:[],textConfigurable:!0,textCheckType:0,customFormat:""},we=r=>r==="lineTool"?Es:r==="rectTool"?Le:r==="tagTool"?Ms:r==="textTool"?Hs:r==="polygonTool"?Ns:Le,Ce={toolColor:{1:{valid:{stroke:"rgba(0,0,255,0.50)",fill:"rgba(0,0,255,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.80)"},validSelected:{stroke:"rgba(0,15,255,1.00)",fill:"rgba(0,15,255,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,0.60)",fill:"rgba(255,0,0,0.24)"},validHover:{stroke:"rgba(0,15,255,0.80)",fill:"rgba(0,15,255,0.64)"},invalidHover:{stroke:"rgba(255,0,0,0.50)",fill:"rgba(255,0,0,0.40)"}},3:{valid:{stroke:"rgba(0,255,255,0.50)",fill:"rgba(0,255,255,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.80)"},validSelected:{stroke:"rgba(0,212,255,1.00)",fill:"rgba(0,212,255,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,0.60)",fill:"rgba(255,0,0,0.24)"},validHover:{stroke:"rgba(0,212,255,0.80)",fill:"rgba(0,212,255,0.64)"},invalidHover:{stroke:"rgba(255,0,0,0.50)",fill:"rgba(255,0,0,0.40)"}},5:{valid:{stroke:"rgba(0,255,0,0.50)",fill:"rgba(0,255,0,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.80)"},validSelected:{stroke:"rgba(149,255,1.00)",fill:"rgba(149,255,0,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,0.60)",fill:"rgba(255,0,0,0.24)"},validHover:{stroke:"rgba(149,255,0,0.80)",fill:"rgba(149,255,0,0.64)"},invalidHover:{stroke:"rgba(255,0,0,0.50)",fill:"rgba(255,0,0,0.40)"}},7:{valid:{stroke:"rgba(255,255,0,0.50)",fill:"rgba(255,255,0,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.80)"},validSelected:{stroke:"rgba(255,230,102,1.00)",fill:"rgba(255,213,0,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,0.60)",fill:"rgba(255,0,0,0.24)"},validHover:{stroke:"rgba(255,230,102,0.80)",fill:"rgba(255,230,102,0.64)"},invalidHover:{stroke:"rgba(255,0,0,0.50)",fill:"rgba(255,0,0,0.40)"}},9:{valid:{stroke:"rgba(255,0,255,0.50)",fill:"rgba(255,0,255,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.80)"},validSelected:{stroke:"rgba(230,102,255,1.00)",fill:"rgba(213,0,255,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,0.60)",fill:"rgba(255,0,0,0.24)"},validHover:{stroke:"rgba(230,102,255,0.80)",fill:"rgba(230,102,255,0.64)"},invalidHover:{stroke:"rgba(255,0,0,0.50)",fill:"rgba(255,0,0,0.40)"}}},attributeColor:[{valid:{stroke:"rgba(204,204,204,1.00)",fill:"rgba(204,204,204,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(204,204,204,1.00)",fill:"rgba(204,204,204,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(204,204,204,1.00)",fill:"rgba(204,204,204,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(153,51,255,1.00)",fill:"rgba(153,51,255,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(153,51,255,1.00)",fill:"rgba(153,51,255,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(153,51,255,1.00)",fill:"rgba(153,51,255,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(51,254,51,1.00)",fill:"rgba(51,254,51,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(51,254,51,1.00)",fill:"rgba(51,254,51,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(51,254,51,1.00)",fill:"rgba(51,254,51,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(255,51,255,1.00)",fill:"rgba(255,51,255,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(255,51,255,1.00)",fill:"rgba(255,51,255,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(255,51,255,1.00)",fill:"rgba(255,51,255,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(204,255,51,1.00)",fill:"rgba(204,255,51,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(204,255,51,1.00)",fill:"rgba(204,255,51,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(204,255,51,1.00)",fill:"rgba(204,255,51,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(51,153,255,1.00)",fill:"rgba(51,153,255,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(51,153,255,1.00)",fill:"rgba(51,153,255,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(51,153,255,1.00)",fill:"rgba(51,153,255,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(255,153,51,1.00)",fill:"rgba(255,153,51,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(255,153,51,1.00)",fill:"rgba(255,153,51,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(255,153,51,1.00)",fill:"rgba(255,153,51,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(51,255,238,1.00)",fill:"rgba(51,255,238,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(51,255,238,1.00)",fill:"rgba(51,255,238,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(51,255,238,1.00)",fill:"rgba(51,255,238,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(255,221,51,1.00)",fill:"rgba(255,221,51,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(255,221,51,1.00)",fill:"rgba(255,221,51,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(255,221,51,1.00)",fill:"rgba(255,221,51,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}}],lineColor:{1:"rgba(102, 111, 255, 1 )",3:"rgba(102, 230, 255, 1)",5:"rgba(191, 255, 102, 1)",7:"rgba(255, 230, 102, 1)",9:"rgba(230, 102, 255, 1)"},attributeLineColor:["rgba(204, 204, 204, 1)","rgba(153, 51, 255, 1)","rgba(51, 254, 51, 1)","rgba(255, 51, 255, 1)","rgba(204, 255, 51, 1)","rgba(51, 153, 255, 1)","rgba(255, 153, 51, 1)","rgba(51, 255, 238, 1)","rgba(255, 221, 51, 1)"],color:1,width:2,opacity:9};var Bs=Object.defineProperty,Fs=Object.defineProperties,$s=Object.getOwnPropertyDescriptors,Pe=Object.getOwnPropertySymbols,Zs=Object.prototype.hasOwnProperty,Us=Object.prototype.propertyIsEnumerable,De=(r,t,e)=>t in r?Bs(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_e=(r,t)=>{for(var e in t||(t={}))Zs.call(t,e)&&De(r,e,t[e]);if(Pe)for(var e of Pe(t))Us.call(t,e)&&De(r,e,t[e]);return r},Ae=(r,t)=>Fs(r,$s(t)),Re;(function(r){r[r.Create=0]="Create",r[r.Active=1]="Active",r[r.Edit=1]="Edit",r[r.None=2]="None"})(Re||(Re={}));var Se;(function(r){r.ActiveArea="#B3B8FF"})(Se||(Se={}));const Te=16,zs=3,N=class{static isInLine(r,t,e,i=3){const{length:s}=w.getFootOfPerpendicular(r,t,e);return s<i}};let R=N;R.setSpecialEdgeStyle=r=>{r.lineCap="butt",r.setLineDash([10,10])},R.setReferenceCtx=r=>{r.lineCap="butt",r.setLineDash([6])},R.calcOptimalIntersection=(r,t,e,i,s)=>{let n,o=Infinity,a;if(r.find((h,d)=>{if(d===0)return;const u=N.isInLine(t.pointA,h,r[d-1]),c=N.isInLine(t.pointB,h,r[d-1]);return u&&c}))return{point:e};if(r.forEach((h,d)=>{if(d===0)return;const u={pointA:r[d-1],pointB:h},c=N.lineIntersection(t,u);if(c&&t){const{onLine2:g,onLine1:f,x:v,y:p}=c,x=N.calcDistance(e,c);if(N.isOnLine(t.pointB.x,t.pointB.y,h.x,h.y,r[d-1].x,r[d-1].y)){if(N.calcDistance(e,c)<i/s){const k=t.pointB,{footPoint:S,length:Z}=w.getFootOfPerpendicular(k,u.pointA,u.pointB,!0);if(Z!==void 0){const st=N.calcDistance(u.pointA,S),at=N.calcDistance(u.pointB,S);a={point:S,minDistance:Z},Z===Infinity&&(a.point=st>at?u.pointB:u.pointA)}}return}x<o&&g&&f&&(o=x,n={x:v,y:p})}}),n)return{point:n,minDistance:o};if(a)return a},R.lineIntersection=(r,t)=>{let e=!1,i=!1;const s=N.getAxisDiff(r),n=N.getAxisDiff(t),o=n.y*s.x-n.x*s.y;if(o===0)return!1;let a=r.pointA.y-t.pointA.y,l=r.pointA.x-t.pointA.x;const h=(t.pointB.x-t.pointA.x)*a-(t.pointB.y-t.pointA.y)*l,d=(r.pointB.x-r.pointA.x)*a-(r.pointB.y-r.pointA.y)*l;a=h/o,l=d/o,a>0&&a<1&&(e=!0),l>0&&l<1&&(i=!0);const u=r.pointA.x+a*(r.pointB.x-r.pointA.x),c=r.pointA.y+a*(r.pointB.y-r.pointA.y);return{x:u,y:c,onLine1:e,onLine2:i}},R.getAxisDiff=r=>({x:r.pointB.x-r.pointA.x,y:r.pointB.y-r.pointA.y}),R.calcDistance=(r,t)=>Math.sqrt(Math.pow(Math.abs(r.x-t.x),2)+Math.pow(Math.abs(r.y-t.y),2)),R.drawCurveLine=(r,t,e,i=!0,s=!1,n)=>{const o=xt(t,Te);r.save(),r.lineCap="round",r.lineJoin="round",r.strokeStyle=e.color,i&&(r.lineWidth=e.lineWidth),s&&N.setReferenceCtx(r),t.forEach((a,l)=>{const h=a==null?void 0:a.specialEdge,d=o.splice(0,Te+1);r.save(),r.beginPath(),n===l&&(r.lineWidth=4),d.forEach(({x:u,y:c},g)=>{const f=g>0?"lineTo":"moveTo";h&&N.setSpecialEdgeStyle(r),r[f](u,c)}),r.stroke(),r.restore()}),r.restore()},R.calcTwoPointDistance=(r,t)=>Math.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2)),R.pointOverTarget=(r,t,e,i,s,n,o,a,l,h)=>{const d=r;if(!t)return r;if(e===m.Polygon){const u=N.getPolygonPointList(i,s);if(u.length===0||M.isInPolygon(r,u))return d;const g=u.concat(u[0]).map(y=>l(y)),f=l(t),v=l(r),p={pointA:f,pointB:v},x=N.calcOptimalIntersection(g,p,f,o,a);if(x){const y=h(x==null?void 0:x.point);d.x=y.x,d.y=y.y}else return t;return d}if(e===m.Rect){const{x:u,y:c,width:g,height:f}=i;return d.x=w.withinRange(d.x,[u,u+g]),d.y=w.withinRange(d.y,[c,c+f]),d}return d.x=w.withinRange(d.x,[0,n.width]),d.y=w.withinRange(d.y,[0,n.height]),d},R.getPolygonPointList=(r,t)=>{const{pointList:e}=r,{lineType:i}=t;return i===T.Line?e:M.createSmoothCurvePoints(e.reduce((s,n)=>[...s,n.x,n.y],[]),.5,!0,20)},R.isOnLine=(r,t,e,i,s,n)=>Math.abs((a=>(i-t)/(e-r)*(a-r)+t)(s)-n)<1e-6&&s>=r&&s<=e,R.inArea=({top:r,left:t,right:e,bottom:i},{x:s,y:n})=>n>=r&&n<=i&&s>=t&&s<=e,R.getVHPoint=(r,t,e,i)=>{const s=N.getAngle(r,e);return Math.abs(s)<45?Ae(_e({},t),{y:i.y}):Ae(_e({},t),{x:i.x})},R.getAngle=(r,t)=>{const e=t.x-r.x,i=t.y-r.y;return 360*Math.atan(i/e)/(2*Math.PI)};var Vs=Object.defineProperty,Ws=Object.defineProperties,js=Object.getOwnPropertyDescriptors,ke=Object.getOwnPropertySymbols,Xs=Object.prototype.hasOwnProperty,Ys=Object.prototype.propertyIsEnumerable,Oe=(r,t,e)=>t in r?Vs(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Me=(r,t)=>{for(var e in t||(t={}))Xs.call(t,e)&&Oe(r,e,t[e]);if(ke)for(var e of ke(t))Ys.call(t,e)&&Oe(r,e,t[e]);return r},Gs=(r,t)=>Ws(r,js(t)),Ks=(r,t,e)=>new Promise((i,s)=>{var n=l=>{try{a(e.next(l))}catch(h){s(h)}},o=l=>{try{a(e.throw(l))}catch(h){s(h)}},a=l=>l.done?i(l.value):Promise.resolve(l.value).then(n,o);a((e=e.apply(r,t)).next())});const Ct={min:.2,max:1e3,ratio:.4};class K extends Os{constructor(t){super();this.isDrag=!1,this.isSpaceKey=!1,this.innerZoom=1,this.basicZoom=.01,this.isSpaceClick=!1,this.isDragStart=!1,this.startTime=0,this.initImgPos=()=>Ks(this,null,function*(){var d,u;if(!this.imgNode)return;const c=(d=this._imgAttribute)==null?void 0:d.zoomRatio,g=(u=this._imgAttribute)==null?void 0:u.isOriginalSize,{currentPos:f,imgInfo:v,zoom:p}=Ie.getInitImgPos(this.size,{width:this.imgNode.width,height:this.imgNode.height},this.rotate,c,g);this.setCurrentPos(f),this.currentPosStorage=f,this.imgInfo=v,this.setZoom(p),this.innerZoom=p,this.render(),this.renderBasicCanvas(),this.emit("dependRender"),this.emit("renderZoom",p)}),this.getCurrentPos=d=>{const{_firstClickCoordinate:u,currentPosStorage:c}=this;try{let g;return u&&c?g={y:c.y+d.y-u.y,x:c.x+d.x-u.x}:g={x:0,y:0},g}catch(g){return console.error(g),{x:0,y:0}}},this.wheelChangePos=(d,u,c)=>{const{currentPos:g,imgNode:f}=this;if(!f){console.error("unable to load image");return}if(this.zoom===this.basicZoom&&u===-1)return;const v=wt.wheelChangePos(f,d,u,g,{zoom:c||this.zoom,innerZoom:this.innerZoom,basicZoom:this.basicZoom,zoomMax:Ct.max,rotate:this.rotate});if(!v)return;const{currentPos:p,ratio:x,zoom:y,imgInfo:A}=v;this.innerZoom=y,this.setZoom(y),this.setCurrentPos(p),this.currentPosStorage=p,this.imgInfo=A,Ct.ratio=x,this.emit("renderZoom",y)},this.zoomChanged=(d,u=ct.Linear)=>{const c=wt.zoomChanged(this.zoom,d,u);this.wheelChangePos(this.getGetCenterCoordinate(),c>this.zoom?1:-1,c),this.render(),this.renderBasicCanvas()},this.drawImg=()=>{!this.imgNode||C.drawImg(this.basicCanvas,this.imgNode,{zoom:this.zoom,currentPos:this.currentPos,rotate:this.rotate,imgAttribute:this._imgAttribute})};var e,i,s,n,o,a,l,h;this.container=t.container,this.showDefaultCursor=t.showDefaultCursor||!1,this.destroyCanvas(),this.createCanvas(t.size),this.imgNode=t.imgNode,this.isImgError=!t.imgNode,this.basicImgInfo={width:(i=(e=t.imgNode)==null?void 0:e.width)!=null?i:0,height:(n=(s=t.imgNode)==null?void 0:s.height)!=null?n:0,valid:!0,rotate:0},this.forbidOperation=(o=t.forbidOperation)!=null?o:!1,this.size=t.size,this.currentPos={x:0,y:0},this.zoom=1,this.coord={x:-1,y:-1},this.currentPosStorage={x:0,y:0},this.isShowCursor=!1,this.style={strokeColor:dt[4],fillColor:dt[4],strokeWidth:2,opacity:1},this.attributeLockList=[],this.history=new Vt,this.style=(a=t.style)!=null?a:{},this._imgAttribute=(l=t.imgAttribute)!=null?l:{},this.isHidden=!1,this.dragStatus=_.Wait,this.defaultAttribute=(h=t==null?void 0:t.defaultAttribute)!=null?h:"",this.forbidCursorLine=!!t.forbidCursorLine,this.lang=q.Zh,this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.onWheel=this.onWheel.bind(this),this.onLeftDblClick=this.onLeftDblClick.bind(this),this.onRightDblClick=this.onRightDblClick.bind(this),this.onClick=this.onClick.bind(this),this.clearImgDrag=this.clearImgDrag.bind(this),this.dblClickListener=new me(this.container,200),this.coordUtils=new Rr(this),this.coordUtils.setBasicImgInfo(this.basicImgInfo)}onContextmenu(t){t.preventDefault()}get ctx(){var t;return this._ctx||((t=this.canvas)==null?void 0:t.getContext("2d"))}get basicCtx(){var t;return(t=this.basicCanvas)==null?void 0:t.getContext("2d")}get rotate(){var t,e;return(e=(t=this.basicImgInfo)==null?void 0:t.rotate)!=null?e:0}get valid(){var t,e;return(e=(t=this.basicImgInfo)==null?void 0:t.valid)!=null?e:!0}get baseIcon(){return ve[this.style.color]}get defaultCursor(){return this.showDefaultCursor?"default":"none"}get dataList(){return[]}setZoom(t){this.zoom=t,this.coordUtils.setZoomAndCurrentPos(this.zoom,this.currentPos)}setCurrentPos(t){this.currentPos=t,this.coordUtils.setZoomAndCurrentPos(this.zoom,this.currentPos)}updatePosition(t){const{zoom:e,currentPos:i}=t;this.setZoom(e),this.setCurrentPos(i),this.currentPosStorage=i,this.innerZoom=e,this.renderBasicCanvas(),this.render()}setLang(t){this.lang=t}setShowDefaultCursor(t){this.showDefaultCursor=t,this.container.style.cursor=this.defaultCursor}get forbidMouseOperation(){return this.forbidOperation||this.valid===!1}init(){this.eventUnbinding(),this.initPosition(),this.eventBinding(),this.render(),this.renderBasicCanvas()}destroy(){this.destroyCanvas(),this.eventUnbinding()}createCanvas(t){const e=document.createElement("canvas");e.setAttribute("width",`${t.width}`),e.setAttribute("height",`${t.height}`),e.style.position="absolute",e.style.left="0",e.style.top="0",e.style.zIndex="0",this.container.appendChild(e),this.basicCanvas=e;const i=document.createElement("canvas");i.setAttribute("width",`${t.width}`),i.setAttribute("height",`${t.height}`),i.style.position="absolute",i.style.left="0",i.style.top="0",i.style.zIndex="10",this.container.appendChild(i),this.canvas=i,this.container.style.cursor=this.defaultCursor}destroyCanvas(){this.canvas&&this.container.contains(this.canvas)&&this.container.removeChild(this.canvas),this.basicCanvas&&this.container.contains(this.basicCanvas)&&this.container.removeChild(this.basicCanvas),this.clearInvalidPage(),this.clearImgDrag()}setStyle(t){this.style=t,this.render()}setImgNode(t,e={}){this.imgNode=t,this.setBasicImgInfo(Me({width:t.width,height:t.height,valid:!0,rotate:0},e)),this.isImgError===!0&&(this.isImgError=!1,this.emit("changeAnnotationShow")),typeof e.valid=="boolean"&&this.setValid(e.valid),this.initImgPos(),this.render(),this.renderBasicCanvas()}setErrorImg(){const t=this.isImgError;this.isImgError=!0,this.imgNode=void 0,this.setBasicImgInfo({width:0,height:0,valid:!0,rotate:0}),t===!1&&this.emit("changeAnnotationShow")}setBasicImgInfo(t){this.basicImgInfo=t,this.coordUtils.setBasicImgInfo(t)}setForbidOperation(t){this.forbidOperation=t,this.render()}setForbidCursorLine(t){this.forbidCursorLine=t,this.render()}setIsHidden(t){this.isHidden=t,this.emit("hiddenChange")}setIsShowOrder(t){this.config.isShowOrder=t,this.render()}getCoordinate(t){const e=this.canvas.getBoundingClientRect();return{x:t.clientX-e.left,y:t.clientY-e.top}}getCoordinateUnderZoom(t){const e=this.canvas.getBoundingClientRect();return{x:t.clientX-e.left-this.currentPos.x,y:t.clientY-e.top-this.currentPos.y}}getGetCenterCoordinate(){return{x:this.size.width/2,y:this.size.height/2}}initPosition(){if(this.basicResult&&this.imgInfo){const{basicResult:t,size:e,imgNode:i,_imgAttribute:s,imgInfo:n,dependToolName:o}=this;if(t&&i&&o){let a=t;switch(o){case m.Polygon:case m.Line:{if(t.pointList){const h=w.calcViewportBoundaries(t.pointList);a={x:h.left,y:h.top,width:h.right-h.left,height:h.bottom-h.top}}break}}const l=Ie.getBasicRecPos(i,a,e,void 0,s==null?void 0:s.zoomRatio,s==null?void 0:s.isOriginalSize);l&&(this.setCurrentPos(l.currentPos),this.currentPosStorage=this.currentPos,this.imgInfo=Gs(Me({},n),{width:n.width/this.innerZoom*l.innerZoom,height:n.height/this.innerZoom*l.innerZoom}),this.innerZoom=l.innerZoom,this.setZoom(l.innerZoom),this.render(),this.renderBasicCanvas())}}else this.initImgPos()}undo(){this.history.undo()}redo(){this.history.redo()}clearCanvas(){var t;(t=this.ctx)==null||t.clearRect(0,0,this.size.width,this.size.height)}clearBasicCanvas(){var t;(t=this.basicCtx)==null||t.clearRect(0,0,this.size.width,this.size.height)}eventBinding(){this.dblClickListener.addEvent(()=>{},this.onLeftDblClick,this.onRightDblClick),this.container.addEventListener("mousedown",this.onMouseDown),this.container.addEventListener("mousemove",this.onMouseMove),this.container.addEventListener("mouseup",this.onMouseUp),this.container.addEventListener("mouseleave",this.onMouseLeave),this.container.addEventListener("click",this.onClick),this.container.addEventListener("wheel",this.onWheel),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.onKeyUp),window.parent.document.addEventListener("contextmenu",this.onContextmenu,!1)}eventUnbinding(){this.container.removeEventListener("mousedown",this.onMouseDown),this.container.removeEventListener("mousemove",this.onMouseMove),this.container.removeEventListener("mouseup",this.onMouseUp),this.container.removeEventListener("mouseleave",this.onMouseLeave),this.container.removeEventListener("wheel",this.onWheel),this.container.removeEventListener("click",this.onClick),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),window.parent.document.removeEventListener("contextmenu",this.onContextmenu,!1),this.dblClickListener.removeEvent()}clearImgDrag(){this.isDrag=!1,this.isDragStart=!1,this.isSpaceClick=!1,this.startTime=0,this.container.style.cursor=this.defaultCursor,this.forbidCursorLine=!1}onMouseDown(t){if(!this.canvas||this.isImgError)return!0;const e=this.getCoordinate(t);(this.isSpaceKey&&t.button===0||t.button===2)&&(t.stopPropagation(),this._firstClickCoordinate=e,this.currentPosStorage=this.currentPos,this.isSpaceClick=!0,this.isDragStart=!0,this.startTime=new Date().getTime())}onMouseMove(t){if(!this.canvas||this.isImgError)return!0;const e=this.getCoordinate(t);this.isShowCursor&&(this.coord=e,this.render());try{if(!e||!Rt(e==null?void 0:e.x)||!Rt(e==null?void 0:e.y))throw new Error("coord error");if(this.coord=e,(this.isSpaceClick||this.isDragStart)&&this._firstClickCoordinate){const i=this.getCurrentPos(e);this.setCurrentPos(i),this.isDrag=!0,this.container.style.cursor="grabbing",this.forbidCursorLine=!0,this.renderBasicCanvas(),this.emit("dependRender")}this.render()}catch(i){console.error(i)}}onMouseUp(t){if(!this.canvas||this.isImgError)return!0;if(this.container.style.cursor=this.defaultCursor,this.forbidCursorLine=!1,this.isDrag=!1,this.isDragStart=!1,this.isSpaceClick=!1,this.startTime!==0&&this._firstClickCoordinate){const e=new Date().getTime(),i=this.getCoordinate(t);if(e-this.startTime>1e3||this.isSpaceKey===!0||R.calcTwoPointDistance(i,this._firstClickCoordinate)>10)return t.stopPropagation(),this.startTime=0,this.render(),!0}this.startTime=0,this.render()}onMouseLeave(){this.clearImgDrag()}onClick(t){}onLeftDblClick(t){}onRightDblClick(t){this.clearImgDrag()}onKeyDown(t){switch(t.keyCode===P.Alt&&t.preventDefault(),t.keyCode){case P.Space:this.isSpaceKey=!0;break;case P.Z:if(t.ctrlKey)return t.shiftKey?this.redo():this.undo(),!1;break}return!0}onKeyUp(t){switch(t.keyCode){case P.Space:this.isSpaceKey=!1;break}}onWheel(t,e=!0){if(!this.imgNode||!this.coord)return;t.preventDefault(),t.stopPropagation();const i=this.getCoordinate(t),s=t.deltaY||t.wheelDelta;let n=0;s>0&&this.zoom>Ct.min&&(n=-1),s<0&&this.zoom<Ct.max&&(n=1),this.wheelChangePos(i,n),this.emit("dependRender"),e&&this.render(),this.renderBasicCanvas()}renderCursorLine(t=(e=>(e=this.style.lineColor[0])!=null?e:"")()){if(!this.ctx||this.forbidCursorLine)return;const{x:e,y:i}=this.coord;C.drawLine(this.canvas,{x:0,y:i},{x:1e4,y:i},{color:t}),C.drawLine(this.canvas,{x:e,y:0},{x:e,y:1e4},{color:t}),C.drawCircleWithFill(this.canvas,{x:e,y:i},1,{color:"white"})}setSize(t){this.size=t,this.container.contains(this.canvas)&&(this.destroyCanvas(),this.createCanvas(t),this.eventUnbinding(),this.init())}setImgAttribute(t){const e=this._imgAttribute;if(this._imgAttribute=t,(e==null?void 0:e.zoomRatio)!==t.zoomRatio||e.isOriginalSize!==t.isOriginalSize){this.initImgPos();return}this.renderBasicCanvas(),this.render()}clearResult(t){}setValid(t){this.basicImgInfo.valid=t,t===!1?(this.renderInvalidPage(),this.clearResult(!1)):this.clearInvalidPage()}setRotate(t){this.basicImgInfo.rotate=t}setBasicResult(t){this.basicResult=t,this.coordUtils.setBasicResult(t),this.initPosition(),this.emit("dependRender")}setDependName(t,e){this.dependToolName=t,this.coordUtils.setDependInfo(t,e)}setAttributeLockList(t){this.attributeLockList=t,this.render()}setConfig(t){this.config=b.jsonParser(t)}updateRotate(){if(this.dependToolName)return this.emit("messageInfo",$.getMessagesByLocale(L.NoRotateInDependence,this.lang)),!1;if(this.dataList.length>0)return this.emit("messageInfo",$.getMessagesByLocale(L.NoRotateNotice,this.lang)),!1;const t=w.getRotate(this.basicImgInfo.rotate);this.basicImgInfo.rotate=t,this.initImgPos(),this.emit("updateResult")}getColor(t="",e=this.config){var i;if((e==null?void 0:e.attributeConfigurable)===!0&&this.style.attributeColor){const o=D.getAttributeIndex(t,(i=e.attributeList)!=null?i:[])+1;return this.style.attributeColor[o]}const{color:s,toolColor:n}=this.style;return n?n[s]:Ce.toolColor["1"]}getLineColor(t=""){var e,i,s;if(((e=this.config)==null?void 0:e.attributeConfigurable)===!0){const a=D.getAttributeIndex(t,(s=(i=this.config)==null?void 0:i.attributeList)!=null?s:[])+1;return this.style.attributeLineColor?this.style.attributeLineColor[a]:""}const{color:n,lineColor:o}=this.style;return n&&o?o[n]:""}clearInvalidPage(){this._invalidDOM&&this.container&&this.container.contains(this._invalidDOM)&&(this.container.removeChild(this._invalidDOM),this._invalidDOM=void 0)}renderInvalidPage(){!this.container||this._invalidDOM||(this._invalidDOM=ks.renderInvalidPage(this.canvas,this.container,this.lang))}renderBasicCanvas(){if(!this.basicCanvas)return;this.clearBasicCanvas(),this.drawImg();const t=3;if(this.basicResult&&this.dependToolName)switch(this.dependToolName){case m.Rect:{C.drawRect(this.basicCanvas,I.changeRectByZoom(this.basicResult,this.zoom,this.currentPos),{color:"rgba(204,204,204,1.00)",thickness:t});break}case m.Polygon:{C.drawPolygonWithFillAndLine(this.basicCanvas,I.changePointListByZoom(this.basicResult.pointList,this.zoom,this.currentPos),{fillColor:"transparent",strokeColor:"rgba(204,204,204,1.00)",isClose:!0,thickness:t});break}case m.Line:{C.drawLineWithPointList(this.basicCanvas,I.changePointListByZoom(this.basicResult.pointList,this.zoom,this.currentPos),{color:"rgba(204,204,204,1.00)",thickness:t});break}}}render(){!this.canvas||!this.ctx||!this.imgNode||this.clearCanvas()}changeStyle(t=this.defaultAttribute){this.emit("changeStyle",{attribute:t})}}var Js=Object.defineProperty,Ee=Object.getOwnPropertySymbols,qs=Object.prototype.hasOwnProperty,Qs=Object.prototype.propertyIsEnumerable,He=(r,t,e)=>t in r?Js(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ne=(r,t)=>{for(var e in t||(t={}))qs.call(t,e)&&He(r,e,t[e]);if(Ee)for(var e of Ee(t))Qs.call(t,e)&&He(r,e,t[e]);return r};const Be={x:8,y:26},tr=2;class er extends K{constructor(t){super(t);this.getHoverRectID=e=>{var i,s;const n=this.getCoordinateUnderZoom(e),o=(s=(i=this.resultList.find(a=>a.toolName===m.Rect))==null?void 0:i.result)!=null?s:[];if(o.length>0){const a=o.filter(l=>H.isInRect(n,l,tr,this.zoom));if(a.length===0)return"";if(a.length===1)return a[0].id;if(a.length>1)return a.map(h=>({size:h.width*h.height,id:h.id})).sort((h,d)=>h.size-d.size)[0].id}return""},this.resultList=[],this.hoverID=[],this.fillID=[],this.render=this.render.bind(this),this.drawPolygon=this.drawPolygon.bind(this),this.drawRect=this.drawRect.bind(this),this.drawTag=this.drawTag.bind(this),this.setShowDefaultCursor(!0),this.forbidOperation=!0}onMouseDown(t){var e,i;if(super.onMouseDown(t)||this.forbidMouseOperation||!this.imgInfo)return!0;const s=this.mouseHoverID,n=(i=(e=this.resultList.find(o=>o.toolName===m.Rect))==null?void 0:e.result)!=null?i:[];if(t.button===0){let o=[s],a=!0;s&&n.find(l=>l.id===s&&(l==null?void 0:l.isSelected))&&(a=!1),s||(o=n.map(l=>l.id),a=!1),this.emit("setSelectedID",o,a),this.render()}}updateRotate(){}onMouseMove(t){if(super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo)return;const e=this.mouseHoverID,i=this.getHoverRectID(t);if(e!==i){this.mouseHoverID=i;let s=[i];i||(s=[]),this.emit("setHoverID",s),this.render()}}setResult(t){this.resultList=pi(t),this.render()}drawPolygon(t,e){t==null||t.forEach(i=>{var s,n,o,a,l;const h=this.getColor(i.attribute,e),d=G.getStrokeAndFill(h,i.valid);let u=(n=(s=this.style)==null?void 0:s.width)!=null?n:2;this.hoverID.includes(i.id)?(u=4,C.drawPolygonWithFillAndLine(this.canvas,I.changePointListByZoom(i.pointList,this.zoom,this.currentPos),{fillColor:d.fill,strokeColor:d.stroke,pointColor:"white",thickness:u,lineCap:"round",isClose:!0,lineType:e==null?void 0:e.lineType})):C.drawPolygon(this.canvas,I.changePointListByZoom(i.pointList,this.zoom,this.currentPos),{color:d.fill,lineType:(o=this.config)==null?void 0:o.lineType,thickness:u,isClose:!0}),C.drawText(this.canvas,I.changePointByZoom(i.pointList[0],this.zoom,this.currentPos),(l=D.getAttributeShowText(i.attribute,(a=e==null?void 0:e.attributeList)!=null?a:[]))!=null?l:"",Ne({color:d.stroke},nt));const c=I.changePointListByZoom(i.pointList||[],this.zoom,this.currentPos),g=c[c.length-1];C.drawText(this.canvas,{x:g.x+Be.x,y:g.y+Be.y},i==null?void 0:i.textAttribute,Ne({color:d.stroke},nt))})}drawRect(t,e){t==null||t.forEach(i=>{let s=1;this.hoverID.includes(i.id)&&(s=3);const n=this.getColor(i.attribute,e),o=I.changeRectByZoom(i,this.zoom,this.currentPos);C.drawRect(this.canvas,o,{color:(i==null?void 0:i.valid)?n.valid.stroke:n.invalid.stroke,thickness:s}),this.fillID.includes(i.id)&&C.drawRectWithFill(this.canvas,o,{color:(i==null?void 0:i.valid)?n.valid.fill:n.invalid.fill})})}drawTag(t,e){const i=t.reduce((s,n)=>[...s,...(e==null?void 0:e.inputList)?gt.getTagNameList(n.result,e.inputList):gt.getTagnameListWithoutConfig(n.result)],[]);C.drawTag(this.canvas,i)}setHoverID(t){this.hoverID=t,this.render()}setFillID(t){this.fillID=t,this.render()}render(){var t;super.render(),(t=this.resultList)==null||t.forEach(e=>{switch(e==null?void 0:e.toolName){case m.Rect:this.drawRect(e.result,b.jsonParser(e.config));break;case m.Polygon:this.drawPolygon(e.result,b.jsonParser(e.config));break;case m.Tag:this.drawTag(e.result,b.jsonParser(e.config));break}})}exportData(){return[[],{}]}}class ot{static getMousePositionOnCanvasFromEvent(t,e){if(e&&t){const i=e.getBoundingClientRect();return{x:t.clientX-i.left,y:t.clientY-i.top}}return null}static getClientRect(t){if(t){const e=t.getBoundingClientRect();return{x:e.left,y:e.top,width:e.width,height:e.height}}return null}static getSize(t){if(t){const e=t.getBoundingClientRect();return{width:e.width,height:e.height}}return null}static inViewPort(t,e){return t?w.isInRange(t.x,[e.left,e.right])&&w.isInRange(t.y,[e.top,e.bottom]):!1}}ot.getViewPort=(r,t,e)=>{const{width:i,height:s}=r,{x:n,y:o}=t,a=(0-o)/e,l=(0-n)/e,h=a+s/e,d=l+i/e;return{top:a,bottom:h,left:l,right:d}};const Wt=30,jt=164;class Pt{constructor(t){this.textKeyDown=l=>{switch(l.stopPropagation(),l.keyCode){case P.Enter:this.submitTextarea(),this.appendToContainer();break}};const{container:e,icon:i,color:s,getCurrentSelectedData:n,updateSelectedTextAttribute:o}=t,a=t.width||jt;this.container=e,this.getCurrentSelectedData=n,this.updateSelectedTextAttribute=o,this._textAttributeDOM=this.initTextAttributeDOM(),this._iconDOM=this.initIconDOM(i),this._textDOM=this.initTextDOM(a,ie),this._textareaDOM=this.initTextareaDOM(a,s),this.appendToContainer()}get isExit(){return this._textAttributeDOM?this.container.contains(this._textAttributeDOM):!1}get isExitTextareaDOM(){return this._textareaDOM?this.container.contains(this._textareaDOM):!1}updateIcon(t){this._iconDOM&&(this._iconDOM.innerHTML=t)}appendToContainer(){!this._textAttributeDOM||!this._textDOM||!this._iconDOM||(this.container.appendChild(this._textAttributeDOM),this._textAttributeDOM.appendChild(this._textDOM),this._textAttributeDOM.appendChild(this._iconDOM))}initTextAttributeDOM(){const t=document.createElement("div");return t.setAttribute("id","textArea"),t}initTextDOM(t,e){const i=document.createElement("span");return i.setAttribute("style",`
|
|
22
|
+
`),s.innerHTML=$.getMessagesByLocale(L.InvalidImage,i),e.appendChild(s),s}}const et=[1,5,10,20,30,50,80,100].concat(Array.from({length:9}).map((r,t)=>(t+2)*100));class wt{}wt.zoomChanged=(r,t,e=ct.Linear)=>{switch(e){case ct.Intelligence:{const i=Math.max(...et),s=Math.min(...et),n=et.slice(0,et.length).findIndex((a,l)=>r>=a&&(r<et[l+1]||a===i));let o;if(n===-1)r>=s&&r<=i?o=t?i:s:o=t?s:r;else{const a=t?n+1:n-(et.includes(r)?1:0);o=et[w.withinRange(a,[0,et.length-1])]}return o}default:{const i=t?2:1/2;return r*i}}},wt.wheelChangePos=(r,t,e,i,s={})=>{const{zoom:n=1,innerZoom:o=1,basicZoom:a=1,zoomMax:l=1e3,rotate:h=0}=s,{x:d,y:u}=i,c=parseFloat((n+1/10).toFixed(1))/5;if(r&&t){let{width:g,height:f}=r;[90,270].includes(h)&&(g=r.height,f=r.width);const v=g*o,p=f*o,x=t.x-d,y=t.y-u,A=x/v,k=y/p;let S=n+e*c;S=w.withinRange(S,[a,l]);const Z=g*S*A,st=f*S*k,at=d+(x-Z),vi=u+(y-st);return{zoom:S,currentPos:{x:at,y:vi},imgInfo:{width:g*S,height:f*S},ratio:c}}return null};class Os{constructor(){this._events=new Map}on(t,e){const i=this._events.get(t)||[];i.some(s=>s===e)||this._events.set(t,i.concat(e))}singleOn(t,e){this._events.set(t,[e])}emit(t,...e){const i=this._events.get(t);i&&i.forEach(s=>{s&&s(...e)})}unbind(t,e){const i=this._events.get(t);i&&this._events.set(t,i.filter(s=>s!==e))}unbindAll(t){this._events.delete(t)}}const Le={showConfirm:!1,skipWhileNoDependencies:!1,drawOutsideTarget:!1,copyBackwardResult:!1,minWidth:1,minHeight:1,isShowOrder:!1,filterData:["valid","invalid"],attributeConfigurable:!1,attributeList:[],textConfigurable:!1,textCheckType:0,customFormat:""},Ms={showConfirm:!1,skipWhileNoDependencies:!1,inputList:[{key:"\u7C7B\u522B1",value:"class1",isMulti:!1,subSelected:[{key:"\u9009\u98791",value:"option1",isDefault:!1},{key:"\u9009\u98792",value:"option1-2",isDefault:!1}]},{key:"\u7C7B\u522B2",value:"class-AH",isMulti:!0,subSelected:[{key:"\u9009\u98792-1",value:"option2-1",isDefault:!1},{key:"\u9009\u98792-2",value:"option2-2",isDefault:!1},{key:"\u9009\u98792-3",value:"option2-3",isDefault:!1}]},{key:"\u7C7B\u522B3",value:"class-0P",isMulti:!1,subSelected:[{key:"\u9009\u98793-1",value:"option3-1",isMulti:!1},{key:"\u9009\u98793-2",value:"option3-2",isDefault:!1},{key:"\u9009\u98793-3",value:"option3-3",isDefault:!1}]}]},Es={lineType:0,lineColor:0,edgeAdsorption:!1,outOfTarget:!0,copyBackwardResult:!1,isShowOrder:!1,attributeConfigurable:!1,attributeList:[{key:"\u7C7B\u522B1",value:"\u7C7B\u522B1"},{key:"\u7C7B\u522Bao",value:"class-ao"},{key:"\u7C7B\u522BM1",value:"class-M1"},{key:"\u7C7B\u522BCm",value:"class-Cm"},{key:"\u7C7B\u522Bc3",value:"class-c3"},{key:"\u7C7B\u522Ba0",value:"class-a0"},{key:"\u7C7B\u522Bu7",value:"class-u7"},{key:"\u7C7B\u522BZb",value:"class-Zb"},{key:"\u7C7B\u522Bzi",value:"class-zi"}],textConfigurable:!1,textCheckType:2,customFormat:"",showConfirm:!1,lowerLimitPointNum:2,upperLimitPointNum:"",preReferenceStep:0,skipWhileNoDependencies:!1,filterData:["valid","invalid"]},Hs={showConfirm:!1,skipWhileNoDependencies:!1,enableTextRecognition:!1,recognitionMode:"general",configList:[{label:"\u6587\u672C",key:"text",required:!1,default:"",maxLength:1e3}],filterData:["valid","invalid"]},Ns={lineType:0,lineColor:0,lowerLimitPointNum:3,edgeAdsorption:!1,drawOutsideTarget:!1,copyBackwardResult:!1,isShowOrder:!1,attributeConfigurable:!1,attributeList:[],textConfigurable:!0,textCheckType:0,customFormat:""},we=r=>r==="lineTool"?Es:r==="rectTool"?Le:r==="tagTool"?Ms:r==="textTool"?Hs:r==="polygonTool"?Ns:Le,Ce={toolColor:{1:{valid:{stroke:"rgba(0,0,255,0.50)",fill:"rgba(0,0,255,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.80)"},validSelected:{stroke:"rgba(0,15,255,1.00)",fill:"rgba(0,15,255,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,0.60)",fill:"rgba(255,0,0,0.24)"},validHover:{stroke:"rgba(0,15,255,0.80)",fill:"rgba(0,15,255,0.64)"},invalidHover:{stroke:"rgba(255,0,0,0.50)",fill:"rgba(255,0,0,0.40)"}},3:{valid:{stroke:"rgba(0,255,255,0.50)",fill:"rgba(0,255,255,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.80)"},validSelected:{stroke:"rgba(0,212,255,1.00)",fill:"rgba(0,212,255,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,0.60)",fill:"rgba(255,0,0,0.24)"},validHover:{stroke:"rgba(0,212,255,0.80)",fill:"rgba(0,212,255,0.64)"},invalidHover:{stroke:"rgba(255,0,0,0.50)",fill:"rgba(255,0,0,0.40)"}},5:{valid:{stroke:"rgba(0,255,0,0.50)",fill:"rgba(0,255,0,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.80)"},validSelected:{stroke:"rgba(149,255,1.00)",fill:"rgba(149,255,0,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,0.60)",fill:"rgba(255,0,0,0.24)"},validHover:{stroke:"rgba(149,255,0,0.80)",fill:"rgba(149,255,0,0.64)"},invalidHover:{stroke:"rgba(255,0,0,0.50)",fill:"rgba(255,0,0,0.40)"}},7:{valid:{stroke:"rgba(255,255,0,0.50)",fill:"rgba(255,255,0,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.80)"},validSelected:{stroke:"rgba(255,230,102,1.00)",fill:"rgba(255,213,0,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,0.60)",fill:"rgba(255,0,0,0.24)"},validHover:{stroke:"rgba(255,230,102,0.80)",fill:"rgba(255,230,102,0.64)"},invalidHover:{stroke:"rgba(255,0,0,0.50)",fill:"rgba(255,0,0,0.40)"}},9:{valid:{stroke:"rgba(255,0,255,0.50)",fill:"rgba(255,0,255,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.80)"},validSelected:{stroke:"rgba(230,102,255,1.00)",fill:"rgba(213,0,255,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,0.60)",fill:"rgba(255,0,0,0.24)"},validHover:{stroke:"rgba(230,102,255,0.80)",fill:"rgba(230,102,255,0.64)"},invalidHover:{stroke:"rgba(255,0,0,0.50)",fill:"rgba(255,0,0,0.40)"}}},attributeColor:[{valid:{stroke:"rgba(204,204,204,1.00)",fill:"rgba(204,204,204,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(204,204,204,1.00)",fill:"rgba(204,204,204,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(204,204,204,1.00)",fill:"rgba(204,204,204,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(153,51,255,1.00)",fill:"rgba(153,51,255,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(153,51,255,1.00)",fill:"rgba(153,51,255,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(153,51,255,1.00)",fill:"rgba(153,51,255,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(51,254,51,1.00)",fill:"rgba(51,254,51,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(51,254,51,1.00)",fill:"rgba(51,254,51,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(51,254,51,1.00)",fill:"rgba(51,254,51,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(255,51,255,1.00)",fill:"rgba(255,51,255,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(255,51,255,1.00)",fill:"rgba(255,51,255,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(255,51,255,1.00)",fill:"rgba(255,51,255,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(204,255,51,1.00)",fill:"rgba(204,255,51,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(204,255,51,1.00)",fill:"rgba(204,255,51,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(204,255,51,1.00)",fill:"rgba(204,255,51,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(51,153,255,1.00)",fill:"rgba(51,153,255,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(51,153,255,1.00)",fill:"rgba(51,153,255,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(51,153,255,1.00)",fill:"rgba(51,153,255,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(255,153,51,1.00)",fill:"rgba(255,153,51,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(255,153,51,1.00)",fill:"rgba(255,153,51,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(255,153,51,1.00)",fill:"rgba(255,153,51,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(51,255,238,1.00)",fill:"rgba(51,255,238,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(51,255,238,1.00)",fill:"rgba(51,255,238,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(51,255,238,1.00)",fill:"rgba(51,255,238,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}},{valid:{stroke:"rgba(255,221,51,1.00)",fill:"rgba(255,221,51,0.40)"},invalid:{stroke:"rgba(255,153,102,1.00)",fill:"rgba(255,153,102,0.40)"},validSelected:{stroke:"rgba(255,221,51,1.00)",fill:"rgba(255,221,51,0.80)"},invalidSelected:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"},validHover:{stroke:"rgba(255,221,51,1.00)",fill:"rgba(255,221,51,0.80)"},invalidHover:{stroke:"rgba(255,0,0,1.00)",fill:"rgba(255,0,0,0.80)"}}],lineColor:{1:"rgba(102, 111, 255, 1 )",3:"rgba(102, 230, 255, 1)",5:"rgba(191, 255, 102, 1)",7:"rgba(255, 230, 102, 1)",9:"rgba(230, 102, 255, 1)"},attributeLineColor:["rgba(204, 204, 204, 1)","rgba(153, 51, 255, 1)","rgba(51, 254, 51, 1)","rgba(255, 51, 255, 1)","rgba(204, 255, 51, 1)","rgba(51, 153, 255, 1)","rgba(255, 153, 51, 1)","rgba(51, 255, 238, 1)","rgba(255, 221, 51, 1)"],color:1,width:2,opacity:9};var Bs=Object.defineProperty,Fs=Object.defineProperties,$s=Object.getOwnPropertyDescriptors,Pe=Object.getOwnPropertySymbols,Zs=Object.prototype.hasOwnProperty,Us=Object.prototype.propertyIsEnumerable,De=(r,t,e)=>t in r?Bs(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_e=(r,t)=>{for(var e in t||(t={}))Zs.call(t,e)&&De(r,e,t[e]);if(Pe)for(var e of Pe(t))Us.call(t,e)&&De(r,e,t[e]);return r},Ae=(r,t)=>Fs(r,$s(t)),Re;(function(r){r[r.Create=0]="Create",r[r.Active=1]="Active",r[r.Edit=1]="Edit",r[r.None=2]="None"})(Re||(Re={}));var Se;(function(r){r.ActiveArea="#B3B8FF"})(Se||(Se={}));const Te=16,zs=3,N=class{static isInLine(r,t,e,i=3){const{length:s}=w.getFootOfPerpendicular(r,t,e);return s<i}};let R=N;R.setSpecialEdgeStyle=r=>{r.lineCap="butt",r.setLineDash([10,10])},R.setReferenceCtx=r=>{r.lineCap="butt",r.setLineDash([6])},R.calcOptimalIntersection=(r,t,e,i,s)=>{let n,o=Infinity,a;if(r.find((h,d)=>{if(d===0)return;const u=N.isInLine(t.pointA,h,r[d-1]),c=N.isInLine(t.pointB,h,r[d-1]);return u&&c}))return{point:e};if(r.forEach((h,d)=>{if(d===0)return;const u={pointA:r[d-1],pointB:h},c=N.lineIntersection(t,u);if(c&&t){const{onLine2:g,onLine1:f,x:v,y:p}=c,x=N.calcDistance(e,c);if(N.isOnLine(t.pointB.x,t.pointB.y,h.x,h.y,r[d-1].x,r[d-1].y)){if(N.calcDistance(e,c)<i/s){const k=t.pointB,{footPoint:S,length:Z}=w.getFootOfPerpendicular(k,u.pointA,u.pointB,!0);if(Z!==void 0){const st=N.calcDistance(u.pointA,S),at=N.calcDistance(u.pointB,S);a={point:S,minDistance:Z},Z===Infinity&&(a.point=st>at?u.pointB:u.pointA)}}return}x<o&&g&&f&&(o=x,n={x:v,y:p})}}),n)return{point:n,minDistance:o};if(a)return a},R.lineIntersection=(r,t)=>{let e=!1,i=!1;const s=N.getAxisDiff(r),n=N.getAxisDiff(t),o=n.y*s.x-n.x*s.y;if(o===0)return!1;let a=r.pointA.y-t.pointA.y,l=r.pointA.x-t.pointA.x;const h=(t.pointB.x-t.pointA.x)*a-(t.pointB.y-t.pointA.y)*l,d=(r.pointB.x-r.pointA.x)*a-(r.pointB.y-r.pointA.y)*l;a=h/o,l=d/o,a>0&&a<1&&(e=!0),l>0&&l<1&&(i=!0);const u=r.pointA.x+a*(r.pointB.x-r.pointA.x),c=r.pointA.y+a*(r.pointB.y-r.pointA.y);return{x:u,y:c,onLine1:e,onLine2:i}},R.getAxisDiff=r=>({x:r.pointB.x-r.pointA.x,y:r.pointB.y-r.pointA.y}),R.calcDistance=(r,t)=>Math.sqrt(Math.pow(Math.abs(r.x-t.x),2)+Math.pow(Math.abs(r.y-t.y),2)),R.drawCurveLine=(r,t,e,i=!0,s=!1,n)=>{const o=xt(t,Te);r.save(),r.lineCap="round",r.lineJoin="round",r.strokeStyle=e.color,i&&(r.lineWidth=e.lineWidth),s&&N.setReferenceCtx(r),t.forEach((a,l)=>{const h=a==null?void 0:a.specialEdge,d=o.splice(0,Te+1);r.save(),r.beginPath(),n===l&&(r.lineWidth=4),d.forEach(({x:u,y:c},g)=>{const f=g>0?"lineTo":"moveTo";h&&N.setSpecialEdgeStyle(r),r[f](u,c)}),r.stroke(),r.restore()}),r.restore()},R.calcTwoPointDistance=(r,t)=>Math.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2)),R.pointOverTarget=(r,t,e,i,s,n,o,a,l,h)=>{const d=r;if(!t)return r;if(e===m.Polygon){const u=N.getPolygonPointList(i,s);if(u.length===0||M.isInPolygon(r,u))return d;const g=u.concat(u[0]).map(y=>l(y)),f=l(t),v=l(r),p={pointA:f,pointB:v},x=N.calcOptimalIntersection(g,p,f,o,a);if(x){const y=h(x==null?void 0:x.point);d.x=y.x,d.y=y.y}else return t;return d}if(e===m.Rect){const{x:u,y:c,width:g,height:f}=i;return d.x=w.withinRange(d.x,[u,u+g]),d.y=w.withinRange(d.y,[c,c+f]),d}return d.x=w.withinRange(d.x,[0,n.width]),d.y=w.withinRange(d.y,[0,n.height]),d},R.getPolygonPointList=(r,t)=>{const{pointList:e}=r,{lineType:i}=t;return i===T.Line?e:M.createSmoothCurvePoints(e.reduce((s,n)=>[...s,n.x,n.y],[]),.5,!0,20)},R.isOnLine=(r,t,e,i,s,n)=>Math.abs((a=>(i-t)/(e-r)*(a-r)+t)(s)-n)<1e-6&&s>=r&&s<=e,R.inArea=({top:r,left:t,right:e,bottom:i},{x:s,y:n})=>n>=r&&n<=i&&s>=t&&s<=e,R.getVHPoint=(r,t,e,i)=>{const s=N.getAngle(r,e);return Math.abs(s)<45?Ae(_e({},t),{y:i.y}):Ae(_e({},t),{x:i.x})},R.getAngle=(r,t)=>{const e=t.x-r.x,i=t.y-r.y;return 360*Math.atan(i/e)/(2*Math.PI)};var Vs=Object.defineProperty,Ws=Object.defineProperties,js=Object.getOwnPropertyDescriptors,ke=Object.getOwnPropertySymbols,Xs=Object.prototype.hasOwnProperty,Ys=Object.prototype.propertyIsEnumerable,Oe=(r,t,e)=>t in r?Vs(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Me=(r,t)=>{for(var e in t||(t={}))Xs.call(t,e)&&Oe(r,e,t[e]);if(ke)for(var e of ke(t))Ys.call(t,e)&&Oe(r,e,t[e]);return r},Gs=(r,t)=>Ws(r,js(t)),Ks=(r,t,e)=>new Promise((i,s)=>{var n=l=>{try{a(e.next(l))}catch(h){s(h)}},o=l=>{try{a(e.throw(l))}catch(h){s(h)}},a=l=>l.done?i(l.value):Promise.resolve(l.value).then(n,o);a((e=e.apply(r,t)).next())});const Ct={min:.2,max:1e3,ratio:.4};class K extends Os{constructor(t){super();this.isDrag=!1,this.isSpaceKey=!1,this.innerZoom=1,this.basicZoom=.01,this.isSpaceClick=!1,this.isDragStart=!1,this.startTime=0,this.initImgPos=()=>Ks(this,null,function*(){var d,u;if(!this.imgNode)return;const c=(d=this._imgAttribute)==null?void 0:d.zoomRatio,g=(u=this._imgAttribute)==null?void 0:u.isOriginalSize,{currentPos:f,imgInfo:v,zoom:p}=Ie.getInitImgPos(this.size,{width:this.imgNode.width,height:this.imgNode.height},this.rotate,c,g);this.setCurrentPos(f),this.currentPosStorage=f,this.imgInfo=v,this.setZoom(p),this.innerZoom=p,this.render(),this.renderBasicCanvas(),this.emit("dependRender"),this.emit("renderZoom",p)}),this.getCurrentPos=d=>{const{_firstClickCoordinate:u,currentPosStorage:c}=this;try{let g;return u&&c?g={y:c.y+d.y-u.y,x:c.x+d.x-u.x}:g={x:0,y:0},g}catch(g){return console.error(g),{x:0,y:0}}},this.wheelChangePos=(d,u,c)=>{const{currentPos:g,imgNode:f}=this;if(!f){console.error("unable to load image");return}if(this.zoom===this.basicZoom&&u===-1)return;const v=wt.wheelChangePos(f,d,u,g,{zoom:c||this.zoom,innerZoom:this.innerZoom,basicZoom:this.basicZoom,zoomMax:Ct.max,rotate:this.rotate});if(!v)return;const{currentPos:p,ratio:x,zoom:y,imgInfo:A}=v;this.innerZoom=y,this.setZoom(y),this.setCurrentPos(p),this.currentPosStorage=p,this.imgInfo=A,Ct.ratio=x,this.emit("renderZoom",y)},this.zoomChanged=(d,u=ct.Linear)=>{const c=wt.zoomChanged(this.zoom,d,u);this.wheelChangePos(this.getGetCenterCoordinate(),c>this.zoom?1:-1,c),this.render(),this.renderBasicCanvas()},this.drawImg=()=>{!this.imgNode||C.drawImg(this.basicCanvas,this.imgNode,{zoom:this.zoom,currentPos:this.currentPos,rotate:this.rotate,imgAttribute:this._imgAttribute})};var e,i,s,n,o,a,l,h;this.container=t.container,this.showDefaultCursor=t.showDefaultCursor||!1,this.destroyCanvas(),this.createCanvas(t.size),this.imgNode=t.imgNode,this.isImgError=!t.imgNode,this.basicImgInfo={width:(i=(e=t.imgNode)==null?void 0:e.width)!=null?i:0,height:(n=(s=t.imgNode)==null?void 0:s.height)!=null?n:0,valid:!0,rotate:0},this.forbidOperation=(o=t.forbidOperation)!=null?o:!1,this.size=t.size,this.currentPos={x:0,y:0},this.zoom=1,this.coord={x:-1,y:-1},this.currentPosStorage={x:0,y:0},this.isShowCursor=!1,this.style={strokeColor:dt[4],fillColor:dt[4],strokeWidth:2,opacity:1},this.attributeLockList=[],this.history=new Vt,this.style=(a=t.style)!=null?a:{},this._imgAttribute=(l=t.imgAttribute)!=null?l:{},this.isHidden=!1,this.dragStatus=_.Wait,this.defaultAttribute=(h=t==null?void 0:t.defaultAttribute)!=null?h:"",this.forbidCursorLine=!!t.forbidCursorLine,this.lang=q.Zh,this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.onWheel=this.onWheel.bind(this),this.onLeftDblClick=this.onLeftDblClick.bind(this),this.onRightDblClick=this.onRightDblClick.bind(this),this.onClick=this.onClick.bind(this),this.clearImgDrag=this.clearImgDrag.bind(this),this.dblClickListener=new me(this.container,200),this.coordUtils=new Rr(this),this.coordUtils.setBasicImgInfo(this.basicImgInfo)}onContextmenu(t){t.preventDefault()}get ctx(){var t;return this._ctx||((t=this.canvas)==null?void 0:t.getContext("2d"))}get basicCtx(){var t;return(t=this.basicCanvas)==null?void 0:t.getContext("2d")}get rotate(){var t,e;return(e=(t=this.basicImgInfo)==null?void 0:t.rotate)!=null?e:0}get valid(){var t,e;return(e=(t=this.basicImgInfo)==null?void 0:t.valid)!=null?e:!0}get baseIcon(){return ve[this.style.color]}get defaultCursor(){return this.showDefaultCursor?"default":"none"}get dataList(){return[]}setZoom(t){this.zoom=t,this.coordUtils.setZoomAndCurrentPos(this.zoom,this.currentPos)}setCurrentPos(t){this.currentPos=t,this.coordUtils.setZoomAndCurrentPos(this.zoom,this.currentPos)}updatePosition(t){const{zoom:e,currentPos:i}=t;this.setZoom(e),this.setCurrentPos(i),this.currentPosStorage=i,this.innerZoom=e,this.renderBasicCanvas(),this.render()}setLang(t){this.lang=t}setShowDefaultCursor(t){this.showDefaultCursor=t,this.container.style.cursor=this.defaultCursor}get forbidMouseOperation(){return this.forbidOperation||this.valid===!1}init(){this.eventUnbinding(),this.initPosition(),this.eventBinding(),this.render(),this.renderBasicCanvas()}destroy(){this.destroyCanvas(),this.eventUnbinding()}createCanvas(t){const e=document.createElement("canvas");e.setAttribute("width",`${t.width}`),e.setAttribute("height",`${t.height}`),e.style.position="absolute",e.style.left="0",e.style.top="0",e.style.zIndex="0",this.container.appendChild(e),this.basicCanvas=e;const i=document.createElement("canvas");i.setAttribute("width",`${t.width}`),i.setAttribute("height",`${t.height}`),i.style.position="absolute",i.style.left="0",i.style.top="0",i.style.zIndex="10",this.container.appendChild(i),this.canvas=i,this.container.style.cursor=this.defaultCursor}destroyCanvas(){this.canvas&&this.container.contains(this.canvas)&&this.container.removeChild(this.canvas),this.basicCanvas&&this.container.contains(this.basicCanvas)&&this.container.removeChild(this.basicCanvas),this.clearInvalidPage(),this.clearImgDrag()}setStyle(t){this.style=t,this.render()}setImgNode(t,e={}){this.imgNode=t,this.setBasicImgInfo(Me({width:t.width,height:t.height,valid:!0,rotate:0},e)),this.isImgError===!0&&(this.isImgError=!1,this.emit("changeAnnotationShow")),typeof e.valid=="boolean"&&this.setValid(e.valid),this.initImgPos(),this.render(),this.renderBasicCanvas()}setErrorImg(){const t=this.isImgError;this.isImgError=!0,this.imgNode=void 0,this.setBasicImgInfo({width:0,height:0,valid:!0,rotate:0}),t===!1&&this.emit("changeAnnotationShow")}setBasicImgInfo(t){this.basicImgInfo=t,this.coordUtils.setBasicImgInfo(t)}setForbidOperation(t){this.forbidOperation=t,this.render()}setForbidCursorLine(t){this.forbidCursorLine=t,this.render()}setIsHidden(t){this.isHidden=t,this.emit("hiddenChange")}setIsShowOrder(t){this.config.isShowOrder=t,this.render()}getCoordinate(t){const e=this.canvas.getBoundingClientRect();return{x:t.clientX-e.left,y:t.clientY-e.top}}getCoordinateUnderZoom(t){const e=this.canvas.getBoundingClientRect();return{x:t.clientX-e.left-this.currentPos.x,y:t.clientY-e.top-this.currentPos.y}}getGetCenterCoordinate(){return{x:this.size.width/2,y:this.size.height/2}}initPosition(){if(this.basicResult&&this.imgInfo){const{basicResult:t,size:e,imgNode:i,_imgAttribute:s,imgInfo:n,dependToolName:o}=this;if(t&&i&&o){let a=t;switch(o){case m.Polygon:case m.Line:{if(t.pointList){const h=w.calcViewportBoundaries(t.pointList);a={x:h.left,y:h.top,width:h.right-h.left,height:h.bottom-h.top}}break}}const l=Ie.getBasicRecPos(i,a,e,void 0,s==null?void 0:s.zoomRatio,s==null?void 0:s.isOriginalSize);l&&(this.setCurrentPos(l.currentPos),this.currentPosStorage=this.currentPos,this.imgInfo=Gs(Me({},n),{width:n.width/this.innerZoom*l.innerZoom,height:n.height/this.innerZoom*l.innerZoom}),this.innerZoom=l.innerZoom,this.setZoom(l.innerZoom),this.render(),this.renderBasicCanvas())}}else this.initImgPos()}undo(){this.history.undo()}redo(){this.history.redo()}clearCanvas(){var t;(t=this.ctx)==null||t.clearRect(0,0,this.size.width,this.size.height)}clearBasicCanvas(){var t;(t=this.basicCtx)==null||t.clearRect(0,0,this.size.width,this.size.height)}eventBinding(){this.dblClickListener.addEvent(()=>{},this.onLeftDblClick,this.onRightDblClick),this.container.addEventListener("mousedown",this.onMouseDown),this.container.addEventListener("mousemove",this.onMouseMove),this.container.addEventListener("mouseup",this.onMouseUp),this.container.addEventListener("mouseleave",this.onMouseLeave),this.container.addEventListener("click",this.onClick),this.container.addEventListener("wheel",this.onWheel),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.onKeyUp),window==null||window.parent.document.addEventListener("contextmenu",this.onContextmenu,!1)}eventUnbinding(){this.container.removeEventListener("mousedown",this.onMouseDown),this.container.removeEventListener("mousemove",this.onMouseMove),this.container.removeEventListener("mouseup",this.onMouseUp),this.container.removeEventListener("mouseleave",this.onMouseLeave),this.container.removeEventListener("wheel",this.onWheel),this.container.removeEventListener("click",this.onClick),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),window==null||window.parent.document.removeEventListener("contextmenu",this.onContextmenu,!1),this.dblClickListener.removeEvent()}clearImgDrag(){this.isDrag=!1,this.isDragStart=!1,this.isSpaceClick=!1,this.startTime=0,this.container.style.cursor=this.defaultCursor,this.forbidCursorLine=!1}onMouseDown(t){if(!this.canvas||this.isImgError)return!0;const e=this.getCoordinate(t);(this.isSpaceKey&&t.button===0||t.button===2)&&(t.stopPropagation(),this._firstClickCoordinate=e,this.currentPosStorage=this.currentPos,this.isSpaceClick=!0,this.isDragStart=!0,this.startTime=new Date().getTime())}onMouseMove(t){if(!this.canvas||this.isImgError)return!0;const e=this.getCoordinate(t);this.isShowCursor&&(this.coord=e,this.render());try{if(!e||!Rt(e==null?void 0:e.x)||!Rt(e==null?void 0:e.y))throw new Error("coord error");if(this.coord=e,(this.isSpaceClick||this.isDragStart)&&this._firstClickCoordinate){const i=this.getCurrentPos(e);this.setCurrentPos(i),this.isDrag=!0,this.container.style.cursor="grabbing",this.forbidCursorLine=!0,this.renderBasicCanvas(),this.emit("dependRender")}this.render()}catch(i){console.error(i)}}onMouseUp(t){if(!this.canvas||this.isImgError)return!0;if(this.container.style.cursor=this.defaultCursor,this.forbidCursorLine=!1,this.isDrag=!1,this.isDragStart=!1,this.isSpaceClick=!1,this.startTime!==0&&this._firstClickCoordinate){const e=new Date().getTime(),i=this.getCoordinate(t);if(e-this.startTime>1e3||this.isSpaceKey===!0||R.calcTwoPointDistance(i,this._firstClickCoordinate)>10)return t.stopPropagation(),this.startTime=0,this.render(),!0}this.startTime=0,this.render()}onMouseLeave(){this.clearImgDrag()}onClick(t){}onLeftDblClick(t){}onRightDblClick(t){this.clearImgDrag()}onKeyDown(t){switch(t.keyCode===P.Alt&&t.preventDefault(),t.keyCode){case P.Space:this.isSpaceKey=!0;break;case P.Z:if(t.ctrlKey)return t.shiftKey?this.redo():this.undo(),!1;break}return!0}onKeyUp(t){switch(t.keyCode){case P.Space:this.isSpaceKey=!1;break}}onWheel(t,e=!0){if(!this.imgNode||!this.coord)return;t.preventDefault(),t.stopPropagation();const i=this.getCoordinate(t),s=t.deltaY||t.wheelDelta;let n=0;s>0&&this.zoom>Ct.min&&(n=-1),s<0&&this.zoom<Ct.max&&(n=1),this.wheelChangePos(i,n),this.emit("dependRender"),e&&this.render(),this.renderBasicCanvas()}renderCursorLine(t=(e=>(e=this.style.lineColor[0])!=null?e:"")()){if(!this.ctx||this.forbidCursorLine)return;const{x:e,y:i}=this.coord;C.drawLine(this.canvas,{x:0,y:i},{x:1e4,y:i},{color:t}),C.drawLine(this.canvas,{x:e,y:0},{x:e,y:1e4},{color:t}),C.drawCircleWithFill(this.canvas,{x:e,y:i},1,{color:"white"})}setSize(t){this.size=t,this.container.contains(this.canvas)&&(this.destroyCanvas(),this.createCanvas(t),this.eventUnbinding(),this.init())}setImgAttribute(t){const e=this._imgAttribute;if(this._imgAttribute=t,(e==null?void 0:e.zoomRatio)!==t.zoomRatio||e.isOriginalSize!==t.isOriginalSize){this.initImgPos();return}this.renderBasicCanvas(),this.render()}clearResult(t){}setValid(t){this.basicImgInfo.valid=t,t===!1?(this.renderInvalidPage(),this.clearResult(!1)):this.clearInvalidPage()}setRotate(t){this.basicImgInfo.rotate=t}setBasicResult(t){this.basicResult=t,this.coordUtils.setBasicResult(t),this.initPosition(),this.emit("dependRender")}setDependName(t,e){this.dependToolName=t,this.coordUtils.setDependInfo(t,e)}setAttributeLockList(t){this.attributeLockList=t,this.render()}setConfig(t){this.config=b.jsonParser(t)}updateRotate(){if(this.dependToolName)return this.emit("messageInfo",$.getMessagesByLocale(L.NoRotateInDependence,this.lang)),!1;if(this.dataList.length>0)return this.emit("messageInfo",$.getMessagesByLocale(L.NoRotateNotice,this.lang)),!1;const t=w.getRotate(this.basicImgInfo.rotate);this.basicImgInfo.rotate=t,this.initImgPos(),this.emit("updateResult")}getColor(t="",e=this.config){var i;if((e==null?void 0:e.attributeConfigurable)===!0&&this.style.attributeColor){const o=D.getAttributeIndex(t,(i=e.attributeList)!=null?i:[])+1;return this.style.attributeColor[o]}const{color:s,toolColor:n}=this.style;return n?n[s]:Ce.toolColor["1"]}getLineColor(t=""){var e,i,s;if(((e=this.config)==null?void 0:e.attributeConfigurable)===!0){const a=D.getAttributeIndex(t,(s=(i=this.config)==null?void 0:i.attributeList)!=null?s:[])+1;return this.style.attributeLineColor?this.style.attributeLineColor[a]:""}const{color:n,lineColor:o}=this.style;return n&&o?o[n]:""}clearInvalidPage(){this._invalidDOM&&this.container&&this.container.contains(this._invalidDOM)&&(this.container.removeChild(this._invalidDOM),this._invalidDOM=void 0)}renderInvalidPage(){!this.container||this._invalidDOM||(this._invalidDOM=ks.renderInvalidPage(this.canvas,this.container,this.lang))}renderBasicCanvas(){if(!this.basicCanvas)return;this.clearBasicCanvas(),this.drawImg();const t=3;if(this.basicResult&&this.dependToolName)switch(this.dependToolName){case m.Rect:{C.drawRect(this.basicCanvas,I.changeRectByZoom(this.basicResult,this.zoom,this.currentPos),{color:"rgba(204,204,204,1.00)",thickness:t});break}case m.Polygon:{C.drawPolygonWithFillAndLine(this.basicCanvas,I.changePointListByZoom(this.basicResult.pointList,this.zoom,this.currentPos),{fillColor:"transparent",strokeColor:"rgba(204,204,204,1.00)",isClose:!0,thickness:t});break}case m.Line:{C.drawLineWithPointList(this.basicCanvas,I.changePointListByZoom(this.basicResult.pointList,this.zoom,this.currentPos),{color:"rgba(204,204,204,1.00)",thickness:t});break}}}render(){!this.canvas||!this.ctx||!this.imgNode||this.clearCanvas()}changeStyle(t=this.defaultAttribute){this.emit("changeStyle",{attribute:t})}}var Js=Object.defineProperty,Ee=Object.getOwnPropertySymbols,qs=Object.prototype.hasOwnProperty,Qs=Object.prototype.propertyIsEnumerable,He=(r,t,e)=>t in r?Js(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ne=(r,t)=>{for(var e in t||(t={}))qs.call(t,e)&&He(r,e,t[e]);if(Ee)for(var e of Ee(t))Qs.call(t,e)&&He(r,e,t[e]);return r};const Be={x:8,y:26},tr=2;class er extends K{constructor(t){super(t);this.getHoverRectID=e=>{var i,s;const n=this.getCoordinateUnderZoom(e),o=(s=(i=this.resultList.find(a=>a.toolName===m.Rect))==null?void 0:i.result)!=null?s:[];if(o.length>0){const a=o.filter(l=>H.isInRect(n,l,tr,this.zoom));if(a.length===0)return"";if(a.length===1)return a[0].id;if(a.length>1)return a.map(h=>({size:h.width*h.height,id:h.id})).sort((h,d)=>h.size-d.size)[0].id}return""},this.resultList=[],this.hoverID=[],this.fillID=[],this.render=this.render.bind(this),this.drawPolygon=this.drawPolygon.bind(this),this.drawRect=this.drawRect.bind(this),this.drawTag=this.drawTag.bind(this),this.setShowDefaultCursor(!0),this.forbidOperation=!0}onMouseDown(t){var e,i;if(super.onMouseDown(t)||this.forbidMouseOperation||!this.imgInfo)return!0;const s=this.mouseHoverID,n=(i=(e=this.resultList.find(o=>o.toolName===m.Rect))==null?void 0:e.result)!=null?i:[];if(t.button===0){let o=[s],a=!0;s&&n.find(l=>l.id===s&&(l==null?void 0:l.isSelected))&&(a=!1),s||(o=n.map(l=>l.id),a=!1),this.emit("setSelectedID",o,a),this.render()}}updateRotate(){}onMouseMove(t){if(super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo)return;const e=this.mouseHoverID,i=this.getHoverRectID(t);if(e!==i){this.mouseHoverID=i;let s=[i];i||(s=[]),this.emit("setHoverID",s),this.render()}}setResult(t){this.resultList=pi(t),this.render()}drawPolygon(t,e){t==null||t.forEach(i=>{var s,n,o,a,l;const h=this.getColor(i.attribute,e),d=G.getStrokeAndFill(h,i.valid);let u=(n=(s=this.style)==null?void 0:s.width)!=null?n:2;this.hoverID.includes(i.id)?(u=4,C.drawPolygonWithFillAndLine(this.canvas,I.changePointListByZoom(i.pointList,this.zoom,this.currentPos),{fillColor:d.fill,strokeColor:d.stroke,pointColor:"white",thickness:u,lineCap:"round",isClose:!0,lineType:e==null?void 0:e.lineType})):C.drawPolygon(this.canvas,I.changePointListByZoom(i.pointList,this.zoom,this.currentPos),{color:d.fill,lineType:(o=this.config)==null?void 0:o.lineType,thickness:u,isClose:!0}),C.drawText(this.canvas,I.changePointByZoom(i.pointList[0],this.zoom,this.currentPos),(l=D.getAttributeShowText(i.attribute,(a=e==null?void 0:e.attributeList)!=null?a:[]))!=null?l:"",Ne({color:d.stroke},nt));const c=I.changePointListByZoom(i.pointList||[],this.zoom,this.currentPos),g=c[c.length-1];C.drawText(this.canvas,{x:g.x+Be.x,y:g.y+Be.y},i==null?void 0:i.textAttribute,Ne({color:d.stroke},nt))})}drawRect(t,e){t==null||t.forEach(i=>{let s=1;this.hoverID.includes(i.id)&&(s=3);const n=this.getColor(i.attribute,e),o=I.changeRectByZoom(i,this.zoom,this.currentPos);C.drawRect(this.canvas,o,{color:(i==null?void 0:i.valid)?n.valid.stroke:n.invalid.stroke,thickness:s}),this.fillID.includes(i.id)&&C.drawRectWithFill(this.canvas,o,{color:(i==null?void 0:i.valid)?n.valid.fill:n.invalid.fill})})}drawTag(t,e){const i=t.reduce((s,n)=>[...s,...(e==null?void 0:e.inputList)?gt.getTagNameList(n.result,e.inputList):gt.getTagnameListWithoutConfig(n.result)],[]);C.drawTag(this.canvas,i)}setHoverID(t){this.hoverID=t,this.render()}setFillID(t){this.fillID=t,this.render()}render(){var t;super.render(),(t=this.resultList)==null||t.forEach(e=>{switch(e==null?void 0:e.toolName){case m.Rect:this.drawRect(e.result,b.jsonParser(e.config));break;case m.Polygon:this.drawPolygon(e.result,b.jsonParser(e.config));break;case m.Tag:this.drawTag(e.result,b.jsonParser(e.config));break}})}exportData(){return[[],{}]}}class ot{static getMousePositionOnCanvasFromEvent(t,e){if(e&&t){const i=e.getBoundingClientRect();return{x:t.clientX-i.left,y:t.clientY-i.top}}return null}static getClientRect(t){if(t){const e=t.getBoundingClientRect();return{x:e.left,y:e.top,width:e.width,height:e.height}}return null}static getSize(t){if(t){const e=t.getBoundingClientRect();return{width:e.width,height:e.height}}return null}static inViewPort(t,e){return t?w.isInRange(t.x,[e.left,e.right])&&w.isInRange(t.y,[e.top,e.bottom]):!1}}ot.getViewPort=(r,t,e)=>{const{width:i,height:s}=r,{x:n,y:o}=t,a=(0-o)/e,l=(0-n)/e,h=a+s/e,d=l+i/e;return{top:a,bottom:h,left:l,right:d}};const Wt=30,jt=164;class Pt{constructor(t){this.textKeyDown=l=>{switch(l.stopPropagation(),l.keyCode){case P.Enter:this.submitTextarea(),this.appendToContainer();break}};const{container:e,icon:i,color:s,getCurrentSelectedData:n,updateSelectedTextAttribute:o}=t,a=t.width||jt;this.container=e,this.getCurrentSelectedData=n,this.updateSelectedTextAttribute=o,this._textAttributeDOM=this.initTextAttributeDOM(),this._iconDOM=this.initIconDOM(i),this._textDOM=this.initTextDOM(a,ie),this._textareaDOM=this.initTextareaDOM(a,s),this.appendToContainer()}get isExit(){return this._textAttributeDOM?this.container.contains(this._textAttributeDOM):!1}get isExitTextareaDOM(){return this._textareaDOM?this.container.contains(this._textareaDOM):!1}updateIcon(t){this._iconDOM&&(this._iconDOM.innerHTML=t)}appendToContainer(){!this._textAttributeDOM||!this._textDOM||!this._iconDOM||(this.container.appendChild(this._textAttributeDOM),this._textAttributeDOM.appendChild(this._textDOM),this._textAttributeDOM.appendChild(this._iconDOM))}initTextAttributeDOM(){const t=document.createElement("div");return t.setAttribute("id","textArea"),t}initTextDOM(t,e){const i=document.createElement("span");return i.setAttribute("style",`
|
|
23
23
|
width: ${Math.max(t,Wt)}px;
|
|
24
24
|
line-height: ${e}px;
|
|
25
25
|
word-break: break-all;
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
left:${s}px;
|
|
56
56
|
top: ${n}px;
|
|
57
57
|
color: ${o};
|
|
58
|
-
`),this._textDOM&&(this._textDOM.innerHTML=`${t}`),this._textareaDOM&&(this._textareaDOM.style.width=`${l}px`,this._textareaDOM.style.borderColor=`${o}`)}changeSelected(){this.isExitTextareaDOM&&this.submitTextarea()}}var ir=Object.defineProperty,sr=Object.defineProperties,rr=Object.getOwnPropertyDescriptors,Fe=Object.getOwnPropertySymbols,nr=Object.prototype.hasOwnProperty,or=Object.prototype.propertyIsEnumerable,$e=(r,t,e)=>t in r?ir(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,V=(r,t)=>{for(var e in t||(t={}))nr.call(t,e)&&$e(r,e,t[e]);if(Fe)for(var e of Fe(t))or.call(t,e)&&$e(r,e,t[e]);return r},it=(r,t)=>sr(r,rr(t));const Ze=164,Ue={x:8,y:26};class ze extends K{constructor(t){super(t);this.isAllowDouble=e=>{const{selectedID:i}=this,s=this.getHoverID(e);return!!(i&&i===s)},this.textChange=e=>{this.config.textConfigurable===!1||!this.selectedID||(this.setPolygonList(D.textChange(e,this.selectedID,this.polygonList)),this.emit("selectedChange"),this.render())},this.config=b.jsonParser(t.config),this.drawingPointList=[],this.polygonList=[],this.hoverPointIndex=-1,this.hoverEdgeIndex=-1,this.drawingHistory=new Vt,this.isCtrl=!1,this.isAlt=!1,this.getCurrentSelectedData=this.getCurrentSelectedData.bind(this),this.updateSelectedTextAttribute=this.updateSelectedTextAttribute.bind(this)}eventBinding(){super.eventBinding(),this.container.removeEventListener("mouseup",this.onMouseUp),this.container.addEventListener("mouseup",this.dragMouseUp),this.dblClickListener.addEvent(this.onMouseUp,this.onLeftDblClick,this.onRightDblClick,this.isAllowDouble)}eventUnbinding(){super.eventUnbinding(),this.container.removeEventListener("mouseup",this.dragMouseUp)}destroy(){super.destroy(),this._textAttributInstance&&this._textAttributInstance.clearTextAttribute()}get selectedPolygon(){return M.getPolygonByID(this.polygonList,this.selectedID)}get polygonListUnderZoom(){return this.polygonList.map(t=>it(V({},t),{pointList:I.changePointListByZoom(t.pointList,this.zoom)}))}get selectedText(){var t;return(t=this.selectedPolygon)==null?void 0:t.textAttribute}get dataList(){return this.polygonList}get currentShowList(){let t=[];const[e,i]=b.getRenderResultList(this.polygonList,b.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);return t=e,this.isHidden&&(t=[]),i&&t.push(i),t}get currentPageResult(){const[t]=b.getRenderResultList(this.polygonList,b.getSourceID(this.basicResult),[]);return t}setResult(t){this.clearActiveStatus(),this.setPolygonList(t),this.render()}setPolygonDataByID(t,e){return this.polygonList.map(i=>i.id===e?V(V({},i),t):i)}addPointInDrawing(t){if(!this.imgInfo)return;const{upperLimitPointNum:e,edgeAdsorption:i}=this.config;if(e&&this.drawingPointList.length>=e){this.emit("messageInfo",`${$.getMessagesByLocale(L.UpperLimitErrorNotice,this.lang)}${e}`);return}this.setSelectedID("");const s=this.getCoordinateUnderZoom(t),n=I.changeDrawOutsideTarget(s,{x:0,y:0},this.imgInfo,this.config.drawOutsideTarget,this.basicResult,this.zoom);if(I.returnClosePointIndex(n,I.changePointListByZoom(this.drawingPointList,this.zoom))===0){this.addDrawingPointToPolygonList();return}const{dropFoot:a}=M.getClosestPoint(n,this.polygonListUnderZoom,this.config.lineType,bt),l=I.changePointByZoom(a&&t.altKey===!1&&i?a:n,1/this.zoom);this.drawingPointList.push(l),this.drawingPointList.length===1?this.drawingHistory.initRecord(this.drawingPointList):this.drawingHistory.pushHistory(this.drawingPointList)}clearResult(){this.setPolygonList([]),this.setSelectedID(void 0),this.render()}clearPolygonDrag(){this.drawingPointList=[],this.dragInfo=void 0,this.dragInfo=void 0,this.dragStatus=_.Wait,this.hoverEdgeIndex=-1,this.hoverPointIndex=-1,this.hoverID=""}clearActiveStatus(){this.clearPolygonDrag(),this.setSelectedID(void 0)}setPolygonList(t){const e=this.polygonList.length;this.polygonList=t,e!==t.length&&this.emit("updatePageNumber")}setSelectedID(t){var e,i;const s=this.selectedID;t!==s&&s&&((e=this._textAttributInstance)==null||e.changeSelected()),t||(i=this._textAttributInstance)==null||i.clearTextAttribute(),this.selectedID=t,this.render(),this.emit("selectedChange")}setDefaultAttribute(t=""){const e=this.defaultAttribute;if(this.defaultAttribute=t,e!==t){this.changeStyle(t),this.emit("changeAttributeSidebar");const{selectedID:i}=this;if(i&&(this.selectedPolygon&&(this.selectedPolygon.attribute=t),this.history.pushHistory(this.polygonList),this.render()),this._textAttributInstance){if(this.attributeLockList.length>0&&!this.attributeLockList.includes(t)){this._textAttributInstance.clearTextAttribute();return}this._textAttributInstance.updateIcon(this.getTextIconSvg(t))}}}setStyle(t){var e;super.setStyle(t),this._textAttributInstance&&this.config.attributeConfigurable===!1&&((e=this._textAttributInstance)==null||e.updateIcon(this.getTextIconSvg()))}setPolygonValidAndRender(t){if(!t)return;const e=this.polygonList.map(i=>i.id===t?it(V({},i),{valid:!i.valid}):i);this.setPolygonList(e),this.history.pushHistory(this.polygonList),this.render(),this.emit("updateResult")}addDrawingPointToPolygonList(){let{lowerLimitPointNum:t=3}=this.config;if(t<3&&(t=3),this.drawingPointList.length<t){this.drawingPointList=[],this.editPolygonID="";return}const e=b.getSourceID(this.basicResult),i=[...this.polygonList];if(this.editPolygonID){const s=i.find(n=>n.id===this.editPolygonID);if(!s)return;s.pointList=this.drawingPointList,this.editPolygonID=""}else{const s=W(8,62);let n={id:s,sourceID:e,valid:!this.isCtrl,textAttribute:"",pointList:this.drawingPointList,attribute:this.defaultAttribute,order:b.getMaxOrder(i.filter(o=>b.isSameSourceID(o.sourceID,e)))+1};if(this.config.textConfigurable){let o="";o=D.getTextAttribute(this.polygonList.filter(a=>b.isSameSourceID(a.sourceID,e)),this.config.textCheckType),n=it(V({},n),{textAttribute:o})}i.push(n),this.setSelectedIdAfterAddingDrawing(s)}this.setPolygonList(i),this.isCtrl=!1,this.drawingPointList=[],this.history.pushHistory(i)}setSelectedIdAfterAddingDrawing(t){this.drawingPointList.length!==0&&(this.config.textConfigurable?this.setSelectedID(t):this.setSelectedID())}getHoverID(t){var e;const i=this.getCoordinateUnderZoom(t),s=this.currentShowList.map(n=>it(V({},n),{pointList:I.changePointListByZoom(n.pointList,this.zoom)}));return M.getHoverPolygonID(i,s,10,(e=this.config)==null?void 0:e.lineType)}getHoverEdgeIndex(t){var e;if(!this.selectedID)return-1;const i=this.selectedPolygon;if(!i)return-1;const s=this.getCoordinateUnderZoom(t),n=I.changePointListByZoom(i.pointList,this.zoom);return M.getHoverEdgeIndex(s,n,(e=this.config)==null?void 0:e.lineType)}getHoverPointIndex(t){if(!this.selectedID)return-1;const e=this.selectedPolygon;if(!e)return-1;const i=this.getCoordinateUnderZoom(t),s=I.changePointListByZoom(e.pointList,this.zoom);return I.returnClosePointIndex(i,s)}deletePolygon(t){var e;!t||(this.setPolygonList(this.polygonList.filter(i=>i.id!==t)),this.history.pushHistory(this.polygonList),(e=this._textAttributInstance)==null||e.clearTextAttribute(),this.emit("selectedChange"),this.render())}deletePolygonPoint(t){if(!this.selectedID)return;const{selectedPolygon:e}=this;if(!e)return;let{lowerLimitPointNum:i}=this.config;if(i<3&&(i=3),e.pointList.length<=i){this.emit("messageInfo",`${$.getMessagesByLocale(L.LowerLimitErrorNotice,this.lang)}${i}`);return}e==null||e.pointList.splice(t,1),this.history.pushHistory(this.polygonList),this.render()}spaceKeydown(){var t,e;this.selectedID&&(this.editPolygonID=this.selectedID,this.drawingPointList=(e=(t=this.selectedPolygon)==null?void 0:t.pointList)!=null?e:[],this.drawingHistory.empty(),this.drawingHistory.initRecord(this.drawingPointList),this.hoverID="",this.setSelectedID(""),this.render())}onTabKeyDown(t){if(t.preventDefault(),this.drawingPointList.length>0)return;let e=z.ascend;t.shiftKey&&(e=z.descend);const[i,s]=b.getRenderResultList(this.polygonList,b.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);let n=[...i];s&&(n=[...n,s]);const o=ot.getViewPort(this.canvas,this.currentPos,this.zoom),a=n.map(h=>{var d,u,c,g;return it(V({},h),{x:(u=(d=h.pointList[0])==null?void 0:d.x)!=null?u:0,y:(g=(c=h.pointList[0])==null?void 0:c.y)!=null?g:0})}).filter(h=>ot.inViewPort({x:h.x,y:h.y},o)),l=b.getNextSelectedRectID(a,e,this.selectedID);if(l){this.setSelectedID(l.id);const{selectedPolygon:h}=this;h&&this.setDefaultAttribute(h.attribute)}this.render()}onKeyDown(t){if(!b.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;const{keyCode:e}=t;switch(e){case P.Space:this.spaceKeydown();break;case P.Esc:this.drawingPointList=[],this.editPolygonID="";break;case P.F:this.selectedID&&this.setPolygonValidAndRender(this.selectedID);break;case P.Z:this.setIsHidden(!this.isHidden),this.render();break;case P.Delete:this.deletePolygon(this.selectedID),this.render();break;case P.Ctrl:this.isCtrl=!0;break;case P.Alt:this.isAlt===!1&&(t.preventDefault(),this.isAlt=!0,this.render());break;case P.Tab:{this.onTabKeyDown(t);break}default:{if(this.config.attributeConfigurable){const i=D.getAttributeByKeycode(e,this.config.attributeList);i!==void 0&&this.setDefaultAttribute(i)}break}}}onKeyUp(t){switch(super.onKeyUp(t),t.keyCode){case P.Ctrl:this.isCtrl=!1;break;case P.Alt:{const e=this.isAlt;this.isAlt=!1,e===!0&&this.render();break}}}rightMouseUp(){if(this.drawingPointList.length>0){this.addDrawingPointToPolygonList();return}this.setSelectedID(this.hoverID);const{selectedPolygon:t}=this;t&&this.setDefaultAttribute(t.attribute)}onLeftDblClick(t){if(this.hoverEdgeIndex>-1){const e=this.getCoordinateUnderZoom(t),{selectedPolygon:i}=this;if(!i)return;const{dropFoot:s}=M.getClosestPoint(e,this.polygonListUnderZoom,this.config.lineType,bt);if(!s)return;const{upperLimitPointNum:n}=this.config;if(n&&i.pointList.length>=n){this.emit("messageInfo",`${$.getMessagesByLocale(L.UpperLimitErrorNotice,this.lang)}${n}`),this.clearPolygonDrag();return}i==null||i.pointList.splice(this.hoverEdgeIndex+1,0,I.changePointByZoom(s,1/this.zoom)),this.setPolygonDataByID(i,this.selectedID),this.history.pushHistory(this.polygonList),this.hoverPointIndex=-1,this.hoverEdgeIndex=-1,this.render()}this.dragInfo=void 0}onRightDblClick(t){this.dragInfo=void 0,this.clearImgDrag();const e=this.getHoverID(t),i=this.getHoverPointIndex(t);if(this.hoverPointIndex>-1&&this.hoverPointIndex===i){this.deletePolygonPoint(i),this.dragInfo=void 0,this.hoverPointIndex=-1,this.render();return}this.hoverID===this.selectedID&&this.deletePolygon(e),this.render()}onMouseDown(t){if(super.onMouseDown(t)||this.forbidMouseOperation||t.ctrlKey===!0)return;const e=this.selectedPolygon;if(!e||t.button!==0||this.getHoverID(t)!==this.selectedID)return;const s=e.pointList,n=this.getCoordinateUnderZoom(t);let o=[0],a=Y.Plane;this.dragStatus=_.Start;const l=this.getHoverPointIndex(t),h=this.getHoverEdgeIndex(t);return l>-1?(a=Y.Point,o=[l]):h>-1&&this.hoverEdgeIndex>-1&&(a=Y.Line,o=[h,(h+1)%s.length]),this.dragInfo={dragStartCoord:n,dragTarget:a,initPointList:s,changePointIndex:o},!0}onDragMove(t){var e;if(!this.dragInfo||!this.selectedID)return;let i=(e=this.selectedPolygon)==null?void 0:e.pointList;if(!i)return;const{initPointList:s,dragStartCoord:n,dragTarget:o,changePointIndex:a}=this.dragInfo,l=this.getCoordinateUnderZoom(t),h={x:(l.x-n.x)/this.zoom,y:(l.y-n.y)/this.zoom};switch(this.dragStatus=_.Move,o){case Y.Plane:i=i.map((u,c)=>it(V({},u),{x:s[c].x+h.x,y:s[c].y+h.y}));break;case Y.Point:case Y.Line:i=i.map((u,c)=>a&&a.includes(c)?it(V({},u),{x:s[c].x+h.x,y:s[c].y+h.y}):u);break}if(this.config.drawOutsideTarget===!1&&this.imgInfo){if(this.dependToolName&&this.basicCanvas&&this.basicResult){let p=!1;switch(this.dependToolName){case m.Rect:{p=i.filter(x=>!H.isInRect(x,this.basicResult)).length>0;break}case m.Polygon:{p=M.isPointListOutSidePolygon(i,this.basicResult.pointList,this.config.lineType);break}}if(p)return}const{left:u,top:c,right:g,bottom:f}=w.calcViewportBoundaries(I.changePointListByZoom(i,this.zoom)),v=1e-5;if(u<0||c<0||g>this.imgInfo.width+v||f>this.imgInfo.height+v)return}const d=this.polygonList.map(u=>u.id===this.selectedID?it(V({},u),{pointList:i}):u);this.setPolygonList(d),this.render()}onMouseMove(t){if(super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo)return;if(this.selectedID&&this.dragInfo){this.onDragMove(t);return}let e=-1,i=-1;const{selectedID:s}=this;if(s&&(this.hoverEdgeIndex=-1,this.hoverPointIndex=-1,e=this.getHoverPointIndex(t),e>-1?this.hoverPointIndex=e:(i=this.getHoverEdgeIndex(t),this.hoverEdgeIndex=i)),this.drawingPointList.length>0)return;const n=this.getHoverID(t);this.hoverID!==n&&(this.hoverID=n,this.render())}leftMouseUp(t){const e=this.getHoverID(t);if(this.drawingPointList.length===0&&t.ctrlKey===!0&&e){this.setPolygonValidAndRender(e);return}this.addPointInDrawing(t)}onMouseUp(t){if(!(super.onMouseUp(t)||this.forbidMouseOperation||!this.imgInfo)){if(this.dragInfo&&this.dragStatus===_.Move){this.dragInfo=void 0,this.dragStatus=_.Wait,this.history.pushHistory(this.polygonList),this.emit("updateResult");return}switch(t.button){case 0:{this.leftMouseUp(t);break}case 2:{this.rightMouseUp();break}}this.render()}}dragMouseUp(){this.dragStatus===_.Start&&(this.dragInfo=void 0,this.dragStatus=_.Wait)}exportData(){const{polygonList:t}=this;return[t,this.basicImgInfo]}getTextIconSvg(t=""){return D.getTextIconSvg(t,this.config.attributeList,this.config.attributeConfigurable,this.baseIcon)}getCurrentSelectedData(){const{selectedPolygon:t}=this;if(!t)return;const e=this.getColor(t.attribute),i=t.valid?e==null?void 0:e.valid.stroke:e==null?void 0:e.invalid.stroke;return{width:Ze,textAttribute:t.textAttribute,color:i}}updateSelectedTextAttribute(t){if(this._textAttributInstance&&t&&this.selectedID){let e=t;D.textAttributeValidate(this.config.textCheckType,"",e)===!1&&(this.emit("messageError",D.getErrorNotice(this.config.textCheckType,this.lang)),e=""),this.setPolygonList(D.textChange(e,this.selectedID,this.polygonList)),this.emit("updateTextAttribute"),this.render()}}renderTextAttribute(){var t;const{selectedPolygon:e}=this;if(!this.ctx||this.config.textConfigurable===!1||!e)return;const{pointList:i,attribute:s,valid:n,textAttribute:o}=e,{x:a,y:l}=i[i.length-1],h=Ze,d=I.getOffsetCoordinate({x:a,y:l},this.currentPos,this.zoom),u=this.getColor(s),c=n?u==null?void 0:u.valid.stroke:u==null?void 0:u.invalid.stroke;this._textAttributInstance||(this._textAttributInstance=new Pt({width:h,container:this.container,icon:this.getTextIconSvg(s),color:c,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedTextAttribute})),this._textAttributInstance&&!((t=this._textAttributInstance)==null?void 0:t.isExit)&&this._textAttributInstance.appendToContainer(),this._textAttributInstance.update(`${o}`,{left:d.x,top:d.y,color:c,width:h})}renderPolygon(){var t,e,i,s,n,o,a,l,h;if(this.isHidden===!1&&((t=this.polygonList)==null||t.forEach(c=>{var g,f,v,p,x;if([this.selectedID,this.editPolygonID].includes(c.id))return;const{textAttribute:y,attribute:A}=c,k=this.getColor(A),S=G.getStrokeAndFill(k,c.valid),Z=I.changePointListByZoom(c.pointList||[],this.zoom,this.currentPos);C.drawPolygonWithFillAndLine(this.canvas,Z,{fillColor:S.fill,strokeColor:S.stroke,pointColor:"white",thickness:(f=(g=this.style)==null?void 0:g.width)!=null?f:2,lineCap:"round",isClose:!0,lineType:(v=this.config)==null?void 0:v.lineType});let st=`${(p=D.getAttributeShowText(A,this.config.attributeList))!=null?p:""}`;((x=this.config)==null?void 0:x.isShowOrder)&&(c==null?void 0:c.order)>0&&(st=`${c.order} ${st}`),C.drawText(this.canvas,Z[0],st,V({color:S.stroke},nt));const at=Z[Z.length-1];C.drawText(this.canvas,{x:at.x+Ue.x,y:at.y+Ue.y},y,V({color:S.stroke},nt))})),this.hoverID&&this.hoverID!==this.editPolygonID){const c=this.polygonList.find(g=>g.id===this.hoverID&&g.id!==this.selectedID);if(c){let g="";const f=this.getColor(c.attribute);c.valid?g=f.validHover.fill:g=G.getStrokeAndFill(f,!1,{isHover:!0}).fill,C.drawPolygonWithFill(this.canvas,I.changePointListByZoom(c.pointList,this.zoom,this.currentPos),{color:g,lineType:(e=this.config)==null?void 0:e.lineType})}}if(this.selectedID){const c=this.selectedPolygon;if(c){const g=this.getColor(c.attribute),f=G.getStrokeAndFill(g,c.valid,{isSelected:!0});C.drawSelectedPolygonWithFillAndLine(this.canvas,I.changePointListByZoom(c.pointList,this.zoom,this.currentPos),{fillColor:f.fill,strokeColor:f.stroke,pointColor:"white",thickness:2,lineCap:"round",isClose:!0,lineType:(i=this.config)==null?void 0:i.lineType});let v=`${(s=D.getAttributeShowText(c.attribute,this.config.attributeList))!=null?s:""}`;((n=this.config)==null?void 0:n.isShowOrder)&&(c==null?void 0:c.order)>0&&(v=`${c.order} ${v}`),C.drawText(this.canvas,I.changePointByZoom(c.pointList[0],this.zoom,this.currentPos),v,V({color:f.stroke},nt)),this.renderTextAttribute()}}const d=this.getColor(this.defaultAttribute),u=G.getStrokeAndFill(d,!this.isCtrl);if(((o=this.drawingPointList)==null?void 0:o.length)>0){const c=[...this.drawingPointList];let g=I.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);if(((a=this.config)==null?void 0:a.edgeAdsorption)&&this.isAlt===!1){const{dropFoot:f}=M.getClosestPoint(g,this.polygonList,(l=this.config)==null?void 0:l.lineType,bt/this.zoom);f&&(g=f)}c.push(g),C.drawSelectedPolygonWithFillAndLine(this.canvas,I.changePointListByZoom(c,this.zoom,this.currentPos),{fillColor:u.fill,strokeColor:u.stroke,pointColor:"white",thickness:2,lineCap:"round",isClose:!1,lineType:this.config.lineType})}if(this.hoverPointIndex>-1&&this.selectedID){const c=this.selectedPolygon;if(!c)return;const g=G.getStrokeAndFill(d,c.valid,{isSelected:!0}),f=c==null?void 0:c.pointList[this.hoverPointIndex];if(f){const{x:v,y:p}=I.changePointByZoom(f,this.zoom,this.currentPos);C.drawCircleWithFill(this.canvas,{x:v,y:p},5,{color:g.fill})}}if(this.hoverEdgeIndex>-1&&this.selectedID){const c=this.selectedPolygon;if(!c)return;const g=G.getStrokeAndFill(d,c.valid,{isSelected:!0});C.drawLineWithPointList(this.canvas,I.changePointListByZoom(c.pointList,this.zoom,this.currentPos),{color:g.stroke,thickness:10,hoverEdgeIndex:this.hoverEdgeIndex,lineType:(h=this.config)==null?void 0:h.lineType})}}render(){!this.ctx||(super.render(),this.renderCursorLine(this.getLineColor(this.defaultAttribute)),this.renderPolygon())}undo(){if(this.drawingPointList.length>0){const e=this.drawingHistory.undo();if(!e)return;this.drawingPointList=e,this.render();return}const t=this.history.undo();t&&(t.length!==this.polygonList.length&&this.setSelectedID(""),this.setPolygonList(t),this.render())}redo(){if(this.drawingPointList.length>0){const e=this.drawingHistory.redo();if(!e)return;this.drawingPointList=e,this.render();return}const t=this.history.redo();t&&(t.length!==this.polygonList.length&&this.setSelectedID(""),this.setPolygonList(t),this.render())}}class Ve extends K{constructor(t){super(t);this.getInitResultList=(e,i)=>!(e===0||e===void 0)&&i.length===0?[]:gt.getDefaultTagResult(this.config.inputList,i),this.setLabel=(e,i)=>{var s,n;if(this.isImgError||!this.basicResult&&this.dependToolName)return;const o=this.config.inputList;if(!o[e])return;const{subSelected:a}=o[e];if(e<o.length&&o[e].subSelected&&a&&i<a.length){const l=o[e].value;let h=(s=a[i])==null?void 0:s.value;const d=(n=o[e])==null?void 0:n.isMulti,u=this.tagResult.filter(c=>{const g=`${c.sourceID}`;return b.isSameSourceID(g,this.sourceID)})[0];if(u){let c=0;const{result:g}=u;u.sourceID===0&&(u.sourceID="0");for(const f in u.result)if(f===o[e].value){if(c++,d===!0){const v=g[f].split(";").filter(x=>x!==""),p=v.indexOf(h);p===-1?v.push(h):v.splice(p,1),h=v.join(";")}h===""?Object.keys(g).length===1?this.tagResult=this.tagResult.filter(v=>{const p=`${v.sourceID}`;return b.isDifferSourceID(p,this.sourceID)}):Object.keys(g).length>1&&delete g[f]:g[f]=h}c===0&&Object.assign(u.result,{[l]:h})}else this.tagResult=[{sourceID:this.sourceID,id:W(8,62),result:{[l]:h}}];this.render()}},this.clearResult=(e=!0,i)=>{i?this.tagResult=this.tagResult.map(s=>((s==null?void 0:s.result[i])&&delete s.result[i],s)):this.tagResult=[],this.render()},this.config=b.jsonParser(t.config),this.tagResult=[],this.labelSelectedList=[],this.setShowDefaultCursor(!0)}destroy(){this.clearTag(),super.destroy()}setResult(t){this.tagResult=t,this.render()}get currentPageResult(){return[this.currentTagResult]}get currentTagResult(){var t;return(t=this.tagResult.filter(e=>{const i=`${e.sourceID}`;return b.isSameSourceID(i,this.sourceID)})[0])!=null?t:{}}get sourceID(){return b.getSourceID(this.basicResult)}onKeyDown(t){if(!b.hotkeyFilter(t))return;let{keyCode:e}=t;if(e&&(e<=57&&e>=49||e<=105&&e>=97)){if(e>57?e-=97:e-=49,this.config.inputList.length===1){this.labelSelectedList=[0,e],this.setLabel(0,e),setTimeout(()=>{this.labelSelectedList=[],this.render()},500);return}this.labelSelectedList.length===1?(this.labelSelectedList=[this.labelSelectedList[0],e],this.setLabel(this.labelSelectedList[0],e),setTimeout(()=>{this.labelSelectedList=[],this.render()},500)):(this.labelSelectedList=[e],this.emit("expend"))}}clearTag(){var t;const e=(t=this.canvas)==null?void 0:t.parentNode,i=window.self.document.getElementById("tagToolTag");i&&e&&e.contains(i)&&(e==null||e.removeChild(i))}renderTag(){var t,e,i,s,n,o;if(this.clearTag(),!(((t=this.tagResult)==null?void 0:t.length)>0))return;const a=document.createElement("div"),l=gt.getTagNameList((i=(e=this.currentTagResult)==null?void 0:e.result)!=null?i:{},this.config.inputList);a.innerHTML=(s=l.reduce((h,d)=>`${h}${d.keyName}: ${d.value.join(" \u3001 ")}
|
|
58
|
+
`),this._textDOM&&(this._textDOM.innerHTML=`${t}`),this._textareaDOM&&(this._textareaDOM.style.width=`${l}px`,this._textareaDOM.style.borderColor=`${o}`)}changeSelected(){this.isExitTextareaDOM&&this.submitTextarea()}}var ir=Object.defineProperty,sr=Object.defineProperties,rr=Object.getOwnPropertyDescriptors,Fe=Object.getOwnPropertySymbols,nr=Object.prototype.hasOwnProperty,or=Object.prototype.propertyIsEnumerable,$e=(r,t,e)=>t in r?ir(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,V=(r,t)=>{for(var e in t||(t={}))nr.call(t,e)&&$e(r,e,t[e]);if(Fe)for(var e of Fe(t))or.call(t,e)&&$e(r,e,t[e]);return r},it=(r,t)=>sr(r,rr(t));const Ze=164,Ue={x:8,y:26};class ze extends K{constructor(t){super(t);this.isAllowDouble=e=>{const{selectedID:i}=this,s=this.getHoverID(e);return!!(i&&i===s)},this.textChange=e=>{this.config.textConfigurable===!1||!this.selectedID||(this.setPolygonList(D.textChange(e,this.selectedID,this.polygonList)),this.emit("selectedChange"),this.render())},this.config=b.jsonParser(t.config),this.drawingPointList=[],this.polygonList=[],this.hoverPointIndex=-1,this.hoverEdgeIndex=-1,this.drawingHistory=new Vt,this.isCtrl=!1,this.isAlt=!1,this.getCurrentSelectedData=this.getCurrentSelectedData.bind(this),this.updateSelectedTextAttribute=this.updateSelectedTextAttribute.bind(this)}eventBinding(){super.eventBinding(),this.container.removeEventListener("mouseup",this.onMouseUp),this.container.addEventListener("mouseup",this.dragMouseUp),this.dblClickListener.addEvent(this.onMouseUp,this.onLeftDblClick,this.onRightDblClick,this.isAllowDouble)}eventUnbinding(){super.eventUnbinding(),this.container.removeEventListener("mouseup",this.dragMouseUp)}destroy(){super.destroy(),this._textAttributInstance&&this._textAttributInstance.clearTextAttribute()}get selectedPolygon(){return M.getPolygonByID(this.polygonList,this.selectedID)}get polygonListUnderZoom(){return this.polygonList.map(t=>it(V({},t),{pointList:I.changePointListByZoom(t.pointList,this.zoom)}))}get selectedText(){var t;return(t=this.selectedPolygon)==null?void 0:t.textAttribute}get dataList(){return this.polygonList}get currentShowList(){let t=[];const[e,i]=b.getRenderResultList(this.polygonList,b.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);return t=e,this.isHidden&&(t=[]),i&&t.push(i),t}get currentPageResult(){const[t]=b.getRenderResultList(this.polygonList,b.getSourceID(this.basicResult),[]);return t}setResult(t){this.clearActiveStatus(),this.setPolygonList(t),this.render()}setPolygonDataByID(t,e){return this.polygonList.map(i=>i.id===e?V(V({},i),t):i)}addPointInDrawing(t){if(!this.imgInfo)return;const{upperLimitPointNum:e,edgeAdsorption:i}=this.config;if(e&&this.drawingPointList.length>=e){this.emit("messageInfo",`${$.getMessagesByLocale(L.UpperLimitErrorNotice,this.lang)}${e}`);return}this.setSelectedID("");const s=this.getCoordinateUnderZoom(t),n=I.changeDrawOutsideTarget(s,{x:0,y:0},this.imgInfo,this.config.drawOutsideTarget,this.basicResult,this.zoom);if(I.returnClosePointIndex(n,I.changePointListByZoom(this.drawingPointList,this.zoom))===0){this.addDrawingPointToPolygonList();return}const{dropFoot:a}=M.getClosestPoint(n,this.polygonListUnderZoom,this.config.lineType,bt),l=I.changePointByZoom(a&&t.altKey===!1&&i?a:n,1/this.zoom);this.drawingPointList.push(l),this.drawingPointList.length===1?this.drawingHistory.initRecord(this.drawingPointList):this.drawingHistory.pushHistory(this.drawingPointList)}clearResult(){this.setPolygonList([]),this.setSelectedID(void 0),this.render()}clearPolygonDrag(){this.drawingPointList=[],this.dragInfo=void 0,this.dragInfo=void 0,this.dragStatus=_.Wait,this.hoverEdgeIndex=-1,this.hoverPointIndex=-1,this.hoverID=""}clearActiveStatus(){this.clearPolygonDrag(),this.setSelectedID(void 0)}setPolygonList(t){const e=this.polygonList.length;this.polygonList=t,e!==t.length&&this.emit("updatePageNumber")}setSelectedID(t){var e,i;const s=this.selectedID;t!==s&&s&&((e=this._textAttributInstance)==null||e.changeSelected()),t||(i=this._textAttributInstance)==null||i.clearTextAttribute(),this.selectedID=t,this.render(),this.emit("selectedChange")}setDefaultAttribute(t=""){const e=this.defaultAttribute;if(this.defaultAttribute=t,e!==t){this.changeStyle(t),this.emit("changeAttributeSidebar");const{selectedID:i}=this;if(i&&(this.selectedPolygon&&(this.selectedPolygon.attribute=t),this.history.pushHistory(this.polygonList),this.render()),this._textAttributInstance){if(this.attributeLockList.length>0&&!this.attributeLockList.includes(t)){this._textAttributInstance.clearTextAttribute();return}this._textAttributInstance.updateIcon(this.getTextIconSvg(t))}}}setStyle(t){var e;super.setStyle(t),this._textAttributInstance&&this.config.attributeConfigurable===!1&&((e=this._textAttributInstance)==null||e.updateIcon(this.getTextIconSvg()))}setPolygonValidAndRender(t){if(!t)return;const e=this.polygonList.map(i=>i.id===t?it(V({},i),{valid:!i.valid}):i);this.setPolygonList(e),this.history.pushHistory(this.polygonList),this.render(),this.emit("updateResult")}addDrawingPointToPolygonList(){let{lowerLimitPointNum:t=3}=this.config;if(t<3&&(t=3),this.drawingPointList.length<t){this.drawingPointList=[],this.editPolygonID="";return}const e=b.getSourceID(this.basicResult),i=[...this.polygonList];if(this.editPolygonID){const s=i.find(n=>n.id===this.editPolygonID);if(!s)return;s.pointList=this.drawingPointList,this.editPolygonID=""}else{const s=W(8,62);let n={id:s,sourceID:e,valid:!this.isCtrl,textAttribute:"",pointList:this.drawingPointList,attribute:this.defaultAttribute,order:b.getMaxOrder(i.filter(o=>b.isSameSourceID(o.sourceID,e)))+1};if(this.config.textConfigurable){let o="";o=D.getTextAttribute(this.polygonList.filter(a=>b.isSameSourceID(a.sourceID,e)),this.config.textCheckType),n=it(V({},n),{textAttribute:o})}i.push(n),this.setSelectedIdAfterAddingDrawing(s)}this.setPolygonList(i),this.isCtrl=!1,this.drawingPointList=[],this.history.pushHistory(i)}setSelectedIdAfterAddingDrawing(t){this.drawingPointList.length!==0&&(this.config.textConfigurable?this.setSelectedID(t):this.setSelectedID())}getHoverID(t){var e;const i=this.getCoordinateUnderZoom(t),s=this.currentShowList.map(n=>it(V({},n),{pointList:I.changePointListByZoom(n.pointList,this.zoom)}));return M.getHoverPolygonID(i,s,10,(e=this.config)==null?void 0:e.lineType)}getHoverEdgeIndex(t){var e;if(!this.selectedID)return-1;const i=this.selectedPolygon;if(!i)return-1;const s=this.getCoordinateUnderZoom(t),n=I.changePointListByZoom(i.pointList,this.zoom);return M.getHoverEdgeIndex(s,n,(e=this.config)==null?void 0:e.lineType)}getHoverPointIndex(t){if(!this.selectedID)return-1;const e=this.selectedPolygon;if(!e)return-1;const i=this.getCoordinateUnderZoom(t),s=I.changePointListByZoom(e.pointList,this.zoom);return I.returnClosePointIndex(i,s)}deletePolygon(t){var e;!t||(this.setPolygonList(this.polygonList.filter(i=>i.id!==t)),this.history.pushHistory(this.polygonList),(e=this._textAttributInstance)==null||e.clearTextAttribute(),this.emit("selectedChange"),this.render())}deletePolygonPoint(t){if(!this.selectedID)return;const{selectedPolygon:e}=this;if(!e)return;let{lowerLimitPointNum:i}=this.config;if(i<3&&(i=3),e.pointList.length<=i){this.emit("messageInfo",`${$.getMessagesByLocale(L.LowerLimitErrorNotice,this.lang)}${i}`);return}e==null||e.pointList.splice(t,1),this.history.pushHistory(this.polygonList),this.render()}spaceKeydown(){var t,e;this.selectedID&&(this.editPolygonID=this.selectedID,this.drawingPointList=(e=(t=this.selectedPolygon)==null?void 0:t.pointList)!=null?e:[],this.drawingHistory.empty(),this.drawingHistory.initRecord(this.drawingPointList),this.hoverID="",this.setSelectedID(""),this.render())}onTabKeyDown(t){if(t.preventDefault(),this.drawingPointList.length>0)return;let e=z.ascend;t.shiftKey&&(e=z.descend);const[i,s]=b.getRenderResultList(this.polygonList,b.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);let n=[...i];s&&(n=[...n,s]);const o=ot.getViewPort(this.canvas,this.currentPos,this.zoom),a=n.map(h=>{var d,u,c,g;return it(V({},h),{x:(u=(d=h.pointList[0])==null?void 0:d.x)!=null?u:0,y:(g=(c=h.pointList[0])==null?void 0:c.y)!=null?g:0})}).filter(h=>ot.inViewPort({x:h.x,y:h.y},o)),l=b.getNextSelectedRectID(a,e,this.selectedID);if(l){this.setSelectedID(l.id);const{selectedPolygon:h}=this;h&&this.setDefaultAttribute(h.attribute)}this.render()}onKeyDown(t){if(!b.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;const{keyCode:e}=t;switch(e){case P.Space:this.spaceKeydown();break;case P.Esc:this.drawingPointList=[],this.editPolygonID="";break;case P.F:this.selectedID&&this.setPolygonValidAndRender(this.selectedID);break;case P.Z:this.setIsHidden(!this.isHidden),this.render();break;case P.Delete:this.deletePolygon(this.selectedID),this.render();break;case P.Ctrl:this.isCtrl=!0;break;case P.Alt:this.isAlt===!1&&(t.preventDefault(),this.isAlt=!0,this.render());break;case P.Tab:{this.onTabKeyDown(t);break}default:{if(this.config.attributeConfigurable){const i=D.getAttributeByKeycode(e,this.config.attributeList);i!==void 0&&this.setDefaultAttribute(i)}break}}}onKeyUp(t){switch(super.onKeyUp(t),t.keyCode){case P.Ctrl:this.isCtrl=!1;break;case P.Alt:{const e=this.isAlt;this.isAlt=!1,e===!0&&this.render();break}}}rightMouseUp(){if(this.drawingPointList.length>0){this.addDrawingPointToPolygonList();return}this.setSelectedID(this.hoverID);const{selectedPolygon:t}=this;t&&this.setDefaultAttribute(t.attribute)}onLeftDblClick(t){if(this.hoverEdgeIndex>-1){const e=this.getCoordinateUnderZoom(t),{selectedPolygon:i}=this;if(!i)return;const{dropFoot:s}=M.getClosestPoint(e,this.polygonListUnderZoom,this.config.lineType,bt);if(!s)return;const{upperLimitPointNum:n}=this.config;if(n&&i.pointList.length>=n){this.emit("messageInfo",`${$.getMessagesByLocale(L.UpperLimitErrorNotice,this.lang)}${n}`),this.clearPolygonDrag();return}i==null||i.pointList.splice(this.hoverEdgeIndex+1,0,I.changePointByZoom(s,1/this.zoom)),this.setPolygonDataByID(i,this.selectedID),this.history.pushHistory(this.polygonList),this.hoverPointIndex=-1,this.hoverEdgeIndex=-1,this.render()}this.dragInfo=void 0}onRightDblClick(t){this.dragInfo=void 0,this.clearImgDrag();const e=this.getHoverID(t),i=this.getHoverPointIndex(t);if(this.hoverPointIndex>-1&&this.hoverPointIndex===i){this.deletePolygonPoint(i),this.dragInfo=void 0,this.hoverPointIndex=-1,this.render();return}this.hoverID===this.selectedID&&this.deletePolygon(e),this.render()}onMouseDown(t){if(super.onMouseDown(t)||this.forbidMouseOperation||t.ctrlKey===!0)return;const e=this.selectedPolygon;if(!e||t.button!==0||this.getHoverID(t)!==this.selectedID)return;const s=e.pointList,n=this.getCoordinateUnderZoom(t);let o=[0],a=Y.Plane;this.dragStatus=_.Start;const l=this.getHoverPointIndex(t),h=this.getHoverEdgeIndex(t);return l>-1?(a=Y.Point,o=[l]):h>-1&&this.hoverEdgeIndex>-1&&(a=Y.Line,o=[h,(h+1)%s.length]),this.dragInfo={dragStartCoord:n,dragTarget:a,initPointList:s,changePointIndex:o},!0}onDragMove(t){var e;if(!this.dragInfo||!this.selectedID)return;let i=(e=this.selectedPolygon)==null?void 0:e.pointList;if(!i)return;const{initPointList:s,dragStartCoord:n,dragTarget:o,changePointIndex:a}=this.dragInfo,l=this.getCoordinateUnderZoom(t),h={x:(l.x-n.x)/this.zoom,y:(l.y-n.y)/this.zoom};switch(this.dragStatus=_.Move,o){case Y.Plane:i=i.map((u,c)=>it(V({},u),{x:s[c].x+h.x,y:s[c].y+h.y}));break;case Y.Point:case Y.Line:i=i.map((u,c)=>a&&a.includes(c)?it(V({},u),{x:s[c].x+h.x,y:s[c].y+h.y}):u);break}if(this.config.drawOutsideTarget===!1&&this.imgInfo){if(this.dependToolName&&this.basicCanvas&&this.basicResult){let p=!1;switch(this.dependToolName){case m.Rect:{p=i.filter(x=>!H.isInRect(x,this.basicResult)).length>0;break}case m.Polygon:{p=M.isPointListOutSidePolygon(i,this.basicResult.pointList,this.config.lineType);break}}if(p)return}const{left:u,top:c,right:g,bottom:f}=w.calcViewportBoundaries(I.changePointListByZoom(i,this.zoom)),v=1e-5;if(u<0||c<0||g>this.imgInfo.width+v||f>this.imgInfo.height+v)return}const d=this.polygonList.map(u=>u.id===this.selectedID?it(V({},u),{pointList:i}):u);this.setPolygonList(d),this.render()}onMouseMove(t){if(super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo)return;if(this.selectedID&&this.dragInfo){this.onDragMove(t);return}let e=-1,i=-1;const{selectedID:s}=this;if(s&&(this.hoverEdgeIndex=-1,this.hoverPointIndex=-1,e=this.getHoverPointIndex(t),e>-1?this.hoverPointIndex=e:(i=this.getHoverEdgeIndex(t),this.hoverEdgeIndex=i)),this.drawingPointList.length>0)return;const n=this.getHoverID(t);this.hoverID!==n&&(this.hoverID=n,this.render())}leftMouseUp(t){const e=this.getHoverID(t);if(this.drawingPointList.length===0&&t.ctrlKey===!0&&e){this.setPolygonValidAndRender(e);return}this.addPointInDrawing(t)}onMouseUp(t){if(!(super.onMouseUp(t)||this.forbidMouseOperation||!this.imgInfo)){if(this.dragInfo&&this.dragStatus===_.Move){this.dragInfo=void 0,this.dragStatus=_.Wait,this.history.pushHistory(this.polygonList),this.emit("updateResult");return}switch(t.button){case 0:{this.leftMouseUp(t);break}case 2:{this.rightMouseUp();break}}this.render()}}dragMouseUp(){this.dragStatus===_.Start&&(this.dragInfo=void 0,this.dragStatus=_.Wait)}exportData(){const{polygonList:t}=this;return[t,this.basicImgInfo]}getTextIconSvg(t=""){return D.getTextIconSvg(t,this.config.attributeList,this.config.attributeConfigurable,this.baseIcon)}getCurrentSelectedData(){const{selectedPolygon:t}=this;if(!t)return;const e=this.getColor(t.attribute),i=t.valid?e==null?void 0:e.valid.stroke:e==null?void 0:e.invalid.stroke;return{width:Ze,textAttribute:t.textAttribute,color:i}}updateSelectedTextAttribute(t){if(this._textAttributInstance&&t&&this.selectedID){let e=t;D.textAttributeValidate(this.config.textCheckType,"",e)===!1&&(this.emit("messageError",D.getErrorNotice(this.config.textCheckType,this.lang)),e=""),this.setPolygonList(D.textChange(e,this.selectedID,this.polygonList)),this.emit("updateTextAttribute"),this.render()}}renderTextAttribute(){var t;const{selectedPolygon:e}=this;if(!this.ctx||this.config.textConfigurable===!1||!e)return;const{pointList:i,attribute:s,valid:n,textAttribute:o}=e,{x:a,y:l}=i[i.length-1],h=Ze,d=I.getOffsetCoordinate({x:a,y:l},this.currentPos,this.zoom),u=this.getColor(s),c=n?u==null?void 0:u.valid.stroke:u==null?void 0:u.invalid.stroke;this._textAttributInstance||(this._textAttributInstance=new Pt({width:h,container:this.container,icon:this.getTextIconSvg(s),color:c,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedTextAttribute})),this._textAttributInstance&&!((t=this._textAttributInstance)==null?void 0:t.isExit)&&this._textAttributInstance.appendToContainer(),this._textAttributInstance.update(`${o}`,{left:d.x,top:d.y,color:c,width:h})}renderPolygon(){var t,e,i,s,n,o,a,l,h;if(this.isHidden===!1&&((t=this.polygonList)==null||t.forEach(c=>{var g,f,v,p,x;if([this.selectedID,this.editPolygonID].includes(c.id))return;const{textAttribute:y,attribute:A}=c,k=this.getColor(A),S=G.getStrokeAndFill(k,c.valid),Z=I.changePointListByZoom(c.pointList||[],this.zoom,this.currentPos);C.drawPolygonWithFillAndLine(this.canvas,Z,{fillColor:S.fill,strokeColor:S.stroke,pointColor:"white",thickness:(f=(g=this.style)==null?void 0:g.width)!=null?f:2,lineCap:"round",isClose:!0,lineType:(v=this.config)==null?void 0:v.lineType});let st=`${(p=D.getAttributeShowText(A,this.config.attributeList))!=null?p:""}`;((x=this.config)==null?void 0:x.isShowOrder)&&(c==null?void 0:c.order)>0&&(st=`${c.order} ${st}`),C.drawText(this.canvas,Z[0],st,V({color:S.stroke},nt));const at=Z[Z.length-1];C.drawText(this.canvas,{x:at.x+Ue.x,y:at.y+Ue.y},y,V({color:S.stroke},nt))})),this.hoverID&&this.hoverID!==this.editPolygonID){const c=this.polygonList.find(g=>g.id===this.hoverID&&g.id!==this.selectedID);if(c){let g="";const f=this.getColor(c.attribute);c.valid?g=f.validHover.fill:g=G.getStrokeAndFill(f,!1,{isHover:!0}).fill,C.drawPolygonWithFill(this.canvas,I.changePointListByZoom(c.pointList,this.zoom,this.currentPos),{color:g,lineType:(e=this.config)==null?void 0:e.lineType})}}if(this.selectedID){const c=this.selectedPolygon;if(c){const g=this.getColor(c.attribute),f=G.getStrokeAndFill(g,c.valid,{isSelected:!0});C.drawSelectedPolygonWithFillAndLine(this.canvas,I.changePointListByZoom(c.pointList,this.zoom,this.currentPos),{fillColor:f.fill,strokeColor:f.stroke,pointColor:"white",thickness:2,lineCap:"round",isClose:!0,lineType:(i=this.config)==null?void 0:i.lineType});let v=`${(s=D.getAttributeShowText(c.attribute,this.config.attributeList))!=null?s:""}`;((n=this.config)==null?void 0:n.isShowOrder)&&(c==null?void 0:c.order)>0&&(v=`${c.order} ${v}`),C.drawText(this.canvas,I.changePointByZoom(c.pointList[0],this.zoom,this.currentPos),v,V({color:f.stroke},nt)),this.renderTextAttribute()}}const d=this.getColor(this.defaultAttribute),u=G.getStrokeAndFill(d,!this.isCtrl);if(((o=this.drawingPointList)==null?void 0:o.length)>0){const c=[...this.drawingPointList];let g=I.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);if(((a=this.config)==null?void 0:a.edgeAdsorption)&&this.isAlt===!1){const{dropFoot:f}=M.getClosestPoint(g,this.polygonList,(l=this.config)==null?void 0:l.lineType,bt/this.zoom);f&&(g=f)}c.push(g),C.drawSelectedPolygonWithFillAndLine(this.canvas,I.changePointListByZoom(c,this.zoom,this.currentPos),{fillColor:u.fill,strokeColor:u.stroke,pointColor:"white",thickness:2,lineCap:"round",isClose:!1,lineType:this.config.lineType})}if(this.hoverPointIndex>-1&&this.selectedID){const c=this.selectedPolygon;if(!c)return;const g=G.getStrokeAndFill(d,c.valid,{isSelected:!0}),f=c==null?void 0:c.pointList[this.hoverPointIndex];if(f){const{x:v,y:p}=I.changePointByZoom(f,this.zoom,this.currentPos);C.drawCircleWithFill(this.canvas,{x:v,y:p},5,{color:g.fill})}}if(this.hoverEdgeIndex>-1&&this.selectedID){const c=this.selectedPolygon;if(!c)return;const g=G.getStrokeAndFill(d,c.valid,{isSelected:!0});C.drawLineWithPointList(this.canvas,I.changePointListByZoom(c.pointList,this.zoom,this.currentPos),{color:g.stroke,thickness:10,hoverEdgeIndex:this.hoverEdgeIndex,lineType:(h=this.config)==null?void 0:h.lineType})}}render(){!this.ctx||(super.render(),this.renderCursorLine(this.getLineColor(this.defaultAttribute)),this.renderPolygon())}undo(){if(this.drawingPointList.length>0){const e=this.drawingHistory.undo();if(!e)return;this.drawingPointList=e,this.render();return}const t=this.history.undo();t&&(t.length!==this.polygonList.length&&this.setSelectedID(""),this.setPolygonList(t),this.render())}redo(){if(this.drawingPointList.length>0){const e=this.drawingHistory.redo();if(!e)return;this.drawingPointList=e,this.render();return}const t=this.history.redo();t&&(t.length!==this.polygonList.length&&this.setSelectedID(""),this.setPolygonList(t),this.render())}}class Ve extends K{constructor(t){super(t);this.getInitResultList=(e,i)=>!(e===0||e===void 0)&&i.length===0?[]:gt.getDefaultTagResult(this.config.inputList,i),this.setLabel=(e,i)=>{var s,n;if(this.isImgError||!this.basicResult&&this.dependToolName)return;const o=this.config.inputList;if(!o[e])return;const{subSelected:a}=o[e];if(e<o.length&&o[e].subSelected&&a&&i<a.length){const l=o[e].value;let h=(s=a[i])==null?void 0:s.value;const d=(n=o[e])==null?void 0:n.isMulti,u=this.tagResult.filter(c=>{const g=`${c.sourceID}`;return b.isSameSourceID(g,this.sourceID)})[0];if(u){let c=0;const{result:g}=u;u.sourceID===0&&(u.sourceID="0");for(const f in u.result)if(f===o[e].value){if(c++,d===!0){const v=g[f].split(";").filter(x=>x!==""),p=v.indexOf(h);p===-1?v.push(h):v.splice(p,1),h=v.join(";")}h===""?Object.keys(g).length===1?this.tagResult=this.tagResult.filter(v=>{const p=`${v.sourceID}`;return b.isDifferSourceID(p,this.sourceID)}):Object.keys(g).length>1&&delete g[f]:g[f]=h}c===0&&Object.assign(u.result,{[l]:h})}else this.tagResult=[{sourceID:this.sourceID,id:W(8,62),result:{[l]:h}}];this.render()}},this.clearResult=(e=!0,i)=>{i?this.tagResult=this.tagResult.map(s=>((s==null?void 0:s.result[i])&&delete s.result[i],s)):this.tagResult=[],this.render()},this.config=b.jsonParser(t.config),this.tagResult=[],this.labelSelectedList=[],this.setShowDefaultCursor(!0)}destroy(){this.clearTag(),super.destroy()}setResult(t){this.tagResult=t,this.render()}get currentPageResult(){return[this.currentTagResult]}get currentTagResult(){var t;return(t=this.tagResult.filter(e=>{const i=`${e.sourceID}`;return b.isSameSourceID(i,this.sourceID)})[0])!=null?t:{}}get sourceID(){return b.getSourceID(this.basicResult)}onKeyDown(t){if(!b.hotkeyFilter(t))return;let{keyCode:e}=t;if(e&&(e<=57&&e>=49||e<=105&&e>=97)){if(e>57?e-=97:e-=49,this.config.inputList.length===1){this.labelSelectedList=[0,e],this.setLabel(0,e),setTimeout(()=>{this.labelSelectedList=[],this.render()},500);return}this.labelSelectedList.length===1?(this.labelSelectedList=[this.labelSelectedList[0],e],this.setLabel(this.labelSelectedList[0],e),setTimeout(()=>{this.labelSelectedList=[],this.render()},500)):(this.labelSelectedList=[e],this.emit("expend"))}}clearTag(){var t;const e=(t=this.canvas)==null?void 0:t.parentNode,i=window==null?void 0:window.self.document.getElementById("tagToolTag");i&&e&&e.contains(i)&&(e==null||e.removeChild(i))}renderTag(){var t,e,i,s,n,o;if(this.clearTag(),!(((t=this.tagResult)==null?void 0:t.length)>0))return;const a=document.createElement("div"),l=gt.getTagNameList((i=(e=this.currentTagResult)==null?void 0:e.result)!=null?i:{},this.config.inputList);a.innerHTML=(s=l.reduce((h,d)=>`${h}${d.keyName}: ${d.value.join(" \u3001 ")}
|
|
59
59
|
`,""))!=null?s:"",a.setAttribute("id","tagToolTag"),a.setAttribute("style",`
|
|
60
60
|
position: absolute;
|
|
61
61
|
top: 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@labelbee/lb-annotation",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.4-alpha.0",
|
|
4
4
|
"description": "Annotation tool collection",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"annotation",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"lihuaqi"
|
|
33
33
|
],
|
|
34
34
|
"scripts": {
|
|
35
|
-
"dev": "cross-env NODE_ENV=
|
|
35
|
+
"dev": "cross-env NODE_ENV=development rollup -c rollup.config.js -w",
|
|
36
36
|
"start": "npm run dev",
|
|
37
37
|
"build:type": "tsc --emitDeclarationOnly",
|
|
38
38
|
"build": "rm -rf dist && cross-env NODE_ENV=production rollup -c rollup.config.js && npm run build:type",
|