@labelbee/lb-annotation 1.5.4 → 1.5.5-alpha.2
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/es/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* sense-annotation v1.5.
|
|
2
|
+
* sense-annotation v1.5.5-alpha.2
|
|
3
3
|
* (c) 2020-2022
|
|
4
4
|
* Released under the Apache-2.0 License.
|
|
5
|
-
*/import N,{isNumber as Nt,cloneDeep as Ai,isObject as Ri}from"lodash";import ue from"color-rgba";const Ti=320;var gt;(function(r){r.PointCloud="pointCloudTool"})(gt||(gt={}));var ft;(function(r){r.VideoTextTool="videoTextTool",r.VideoTagTool="videoTagTool",r.VideoClipTool="videoClipTool"})(ft||(ft={}));var Bt;(function(r){r[r.Rect=0]="Rect",r[r.Tag=1]="Tag"})(Bt||(Bt={}));var w;(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"})(w||(w={}));var Lt;(function(r){r.Check="check"})(Lt||(Lt={}));var $t;(function(r){r[r.nothing=0]="nothing",r[r.RectBG=1]="RectBG",r[r.showOrder=2]="showOrder"})($t||($t={}));const Si={[w.Rect]:"\u62C9\u6846",[w.Tag]:"\u6807\u7B7E",[w.Point]:"\u6807\u70B9",[w.PointMarker]:"\u5217\u8868\u6807\u70B9",[w.Segmentation]:"\u524D\u666F\u5206\u5272",[w.Filter]:"\u7B5B\u9009",[w.Text]:"\u6587\u672C",[w.Polygon]:"\u591A\u8FB9\u5F62",[w.Line]:"\u7EBF\u6761",[w.LineMarker]:"\u5217\u8868\u7EBF\u6761",[w.FolderTag]:"\u6587\u4EF6\u5939\u6807\u7B7E",[w.RectTrack]:"\u62C9\u6846\u8DDF\u8E2A",[w.Face]:"\u4EBA\u8138106\u5DE5\u5177",[w.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[w.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177",[ft.VideoTextTool]:"\u89C6\u9891\u6587\u672C",[ft.VideoTagTool]:"\u89C6\u9891\u6807\u7B7E",[ft.VideoClipTool]:"\u89C6\u9891\u622A\u53D6",[gt.PointCloud]:"\u70B9\u4E91"};var Ft;(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"})(Ft||(Ft={}));var ct;(function(r){r.lc="leftClick",r.rc="rightClick",r.clc="ctrlLeftClick",r.crc="ctrlRightClick"})(ct||(ct={}));const ki={leftClick:"\u9F20\u6807\u5DE6\u952E",rightClick:"\u9F20\u6807\u53F3\u952E",ctrlLeftClick:"ctrl + \u9F20\u6807\u5DE6\u952E",ctrlRightClick:"ctrl + \u9F20\u6807\u53F3\u952E"};var
|
|
6
|
-
`);let h=0;for(let u=0;u<l.length;u++){const g=l[u].split("");let c="";for(let d=0;d<g.length;d++){const f=c+g[d],p=n.measureText(f).width;p>e&&d>0?(c=g[d],o+=s,h=e):(c=f,p>h&&(h=p))}u!==l.length-1&&(o+=s)}return{width:h,height:o+a,lineHeight:s,fontHeight:a}}static getLineCenterPoint(r){const[t,e]=r,i=Vi.getVector(t,e);return{x:t.x+i.x/2,y:t.y+i.y/2}}};let C=At;C.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))},C.withinRange=(r,t)=>{const e=Math.min(...t),i=Math.max(...t);return r>i?i:r<e?e:r},C.calcViewportBoundaries=(r,t=!1,e=W,i=1)=>{if(!r)return{top:0,bottom:0,left:0,right:0};const s=20/i,n=[],o=[];let a=r;t&&(a=_t(r,e)),a.forEach(({x:f,y:v})=>{n.push(f),o.push(v)});let l=Math.min(...n),h=Math.max(...n),u=Math.min(...o),g=Math.max(...o);const c=h-l,d=g-u;if(c<s){const f=(s-c)/2;l-=f,h+=f}if(d<s){const f=(s-d)/2;u-=f,g+=f}return{top:u,bottom:g,left:l,right:h}},C.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=At.getLineLength(r,s),h=2,u=Math.min(t.x,e.x),g=Math.max(t.x,e.x),c=Math.min(t.y,e.y),d=Math.max(t.y,e.y),f=!(At.isInRange(r.x,[u,g])||At.isInRange(r.y,[c,d])),v=r.x>g+h||r.x<u-h||r.y>d+h||r.y<c-h;return(i?f:v)?{footPoint:s,length:Infinity}:{footPoint:s,length:l}};const Wi=61,ji=40,Xi=40,Yi=240;var yt;(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"})(yt||(yt={}));const Gi=1e3;var Gt;(function(r){r[r.Backward=0]="Backward",r[r.Forward=1]="Forward",r[r.JumpSkip=2]="JumpSkip",r[r.None=3]="None"})(Gt||(Gt={}));var k;(function(r){r[r.Start=0]="Start",r[r.Stop=1]="Stop",r[r.Wait=2]="Wait",r[r.Move=3]="Move"})(k||(k={}));var tt;(function(r){r[r.Point=0]="Point",r[r.Line=1]="Line",r[r.Plane=2]="Plane"})(tt||(tt={}));var j;(function(r){r[r.ascend=0]="ascend",r[r.descend=1]="descend"})(j||(j={}));var vt;(function(r){r[r.Intelligence=0]="Intelligence",r[r.Linear=1]="Linear"})(vt||(vt={}));var nt;(function(r){r.Zh="zh_CN",r.US="en_US"})(nt||(nt={}));const Y={offsetX:-10,offsetY:-10},dt={shadowColor:"rgba(0,0,0,0.6)",shadowOffsetX:0,shadowOffsetY:2,shadowBlur:4},ut={x:8,y:26};var Ki=Object.freeze({__proto__:null,headerHeight:Wi,tipsHeight:ji,footerHeight:Xi,sidebarWidth:Yi,get EStepType(){return yt},ANNOTATION_MAX_SIZE:Gi,get EPageOperator(){return Gt},get EDragStatus(){return k},get EDragTarget(){return tt},get ESortDirection(){return j},get EGrowthMode(){return vt},get ELang(){return nt},DEFAULT_TEXT_OFFSET:Y,DEFAULT_TEXT_SHADOW:dt,TEXT_ATTRIBUTE_OFFSET:ut}),Ji=Object.defineProperty,qi=Object.defineProperties,Qi=Object.getOwnPropertyDescriptors,me=Object.getOwnPropertySymbols,ts=Object.prototype.hasOwnProperty,es=Object.prototype.propertyIsEnumerable,Ie=(r,t,e)=>t in r?Ji(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ot=(r,t)=>{for(var e in t||(t={}))ts.call(t,e)&&Ie(r,e,t[e]);if(me)for(var e of me(t))es.call(t,e)&&Ie(r,e,t[e]);return r},at=(r,t)=>qi(r,Qi(t));class ${static composeResult(t,e,i,s,n){try{const o=JSON.parse(t),a=x.getCurrentStepInfo(e,s),{dataSourceStep:l}=a,h=`step_${a.step}`;if(Object.assign(o,n),o[h]){const u=o[h];return u.result?(u.result=i,JSON.stringify(o)):JSON.stringify(at(ot({},o),{[h]:at(ot({},o[h]),{result:i})}))}return JSON.stringify(at(ot({},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=L.changeCoordinateByRotate({x:s,y:n},e,i);switch(e%360){case 90:return at(ot({},t),{x:l.x-a,y:l.y,width:a,height:o});case 180:return at(ot({},t),{x:l.x-o,y:l.y-a});case 270:return at(ot({},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 at(ot({},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 at(ot({},t),{x:i*e,y:s*e,width:n*e,height:o*e})}static isRectNotInPolygon(t,e){return this.getRectPointList(t).some(s=>!be(s,e))}}function K(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 is=Object.defineProperty,we=Object.getOwnPropertySymbols,ss=Object.prototype.hasOwnProperty,rs=Object.prototype.propertyIsEnumerable,Le=(r,t,e)=>t in r?is(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Pe=(r,t)=>{for(var e in t||(t={}))ss.call(t,e)&&Le(r,e,t[e]);if(we)for(var e of we(t))rs.call(t,e)&&Le(r,e,t[e]);return r};class mt{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:K(),sourceID:s.id,result:Pe({},i)})):[{id:K(),sourceID:"",result:Pe({},i)}]}}var Ce='<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>',ns='<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>',os='<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>',as='<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>',ls='<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>',hs='<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>',cs='<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>',ds='<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>',us='<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>',gs='<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>',fs='<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>',vs='<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>',ps='<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>',bs='<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>',De='<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 _e=Ce,xs=61,ys=80,ms=62,Is=20,ws=55,Ls=55,Ps=40,Cs=80,Ds=240,_s=320,As="rgba(102, 111, 255, 1)",pt=["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)"],Rt=[Ce,cs,as,ds,os,us,hs,ns,ls],Ae={1:gs,3:fs,5:vs,7:ps,9:bs},Rs="rgba(255, 51, 51, 1)",Kt="rgba(204, 204, 204, 1)",Ts={[ct.lc]:"rgba(153, 51, 255, 1)",[ct.rc]:"rgba(51, 153, 255, 1)",[ct.clc]:"rgba(46, 230, 46, 1)",[ct.crc]:"rgba(255, 51, 51, 1)"};var Ss=Object.freeze({__proto__:null,HEADER_HEIGHT:xs,TAB_HEIGHT:ys,SEARCH_HEIGHT:ms,PADDING:Is,TABLE_ROW_HEIGHT:ws,PAGINATION_HEIGHT:Ls,TIPS_HEIGHT:Ps,FOOTER_HEIGHT:Cs,SIDERBAR_WIDTH:Ds,EDIT_STEP_WIDTH:_s,THEME_COLOR:As,COLORS_ARRAY:pt,ICON_ARRAY:Rt,BASE_ICON:Ae,INVALID_COLOR:Rs,NULL_COLOR:Kt,NULL_ICON:_e,INVALID_ICON:De,FILTER_TOOL_COLOR:Ts}),D;(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"})(D||(D={}));const ks={[D.NoRotateNotice]:"This Image contains data and cannot be rotated",[D.RectErrorSizeNotice]:"The drawing frame size is smaller than the minimum drawing size",[D.TextCheckNumberErrorNotice]:"Please enter in number-only format",[D.TextCheckEnglishErrorNotice]:"Please enter in English only format",[D.TextCheckCustomErrorNotice]:"Please enter in the required format",[D.UpperLimitErrorNotice]:"The number of vertices is not more than",[D.LowerLimitErrorNotice]:"The number of vertices is not less than",[D.InvalidImage]:"Invalid image, please skip this image",[D.DisableDelete]:"Disable delete",[D.ClearPartialData]:"Clear partial data",[D.MarkerFinish]:"ListAnnotation is finished",[D.LowerLimitPoint]:"\u5DF2\u5230\u8FBE\u6807\u70B9\u6570\u91CF\u4E0A\u9650",[D.NoRotateInDependence]:"Disallow rotation in dependent cases"},Os={[D.NoRotateNotice]:"\u672C\u56FE\u542B\u6709\u6570\u636E\uFF0C\u65E0\u6CD5\u8FDB\u884C\u65CB\u8F6C",[D.RectErrorSizeNotice]:"\u7ED8\u5236\u6846\u5C3A\u5BF8\u5C0F\u4E8E\u6700\u5C0F\u7ED8\u5236\u5C3A\u5BF8",[D.TextCheckNumberErrorNotice]:"\u8BF7\u6309\u4EC5\u6570\u5B57\u7684\u683C\u5F0F\u8F93\u5165",[D.TextCheckEnglishErrorNotice]:"\u8BF7\u6309\u4EC5\u82F1\u6587\u7684\u683C\u5F0F\u8F93\u5165",[D.TextCheckCustomErrorNotice]:"\u8BF7\u6309\u8981\u6C42\u7684\u683C\u5F0F\u8F93\u5165",[D.UpperLimitErrorNotice]:"\u9876\u70B9\u6570\u4E0D\u591A\u4E8E",[D.LowerLimitErrorNotice]:"\u9876\u70B9\u6570\u4E0D\u5C11\u4E8E",[D.InvalidImage]:"\u65E0\u6548\u56FE\u7247\uFF0C\u8BF7\u8DF3\u8FC7\u6B64\u56FE",[D.DisableDelete]:"\u8BE5\u6570\u636E\u7981\u6B62\u5220\u9664",[D.ClearPartialData]:"\u5B58\u5728\u90E8\u5206\u6570\u636E\u65E0\u6CD5\u6E05\u9664",[D.MarkerFinish]:"\u5217\u8868\u6807\u6CE8\u5DF2\u5B8C\u6210",[D.LowerLimitPoint]:"\u5DF2\u5230\u8FBE\u6807\u70B9\u6570\u91CF\u4E0A\u9650",[D.NoRotateInDependence]:"\u4F9D\u8D56\u60C5\u51B5\u4E0B\u65E0\u6CD5\u8FDB\u884C\u65CB\u8F6C"};class F{}F.getMessagesByLocale=(r,t)=>{switch(t){case nt.US:return ks[r];case nt.Zh:default:return Os[r]}};var Ms=Object.defineProperty,Es=Object.defineProperties,Hs=Object.getOwnPropertyDescriptors,Re=Object.getOwnPropertySymbols,Ns=Object.prototype.hasOwnProperty,Bs=Object.prototype.propertyIsEnumerable,Te=(r,t,e)=>t in r?Ms(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Se=(r,t)=>{for(var e in t||(t={}))Ns.call(t,e)&&Te(r,e,t[e]);if(Re)for(var e of Re(t))Bs.call(t,e)&&Te(r,e,t[e]);return r},ke=(r,t)=>Es(r,Hs(t));const $s="^[0-9]+$",Fs="^[A-Za-z]+$";class T{static getAttributeIcon(t,e,i=!0){var s;const n=e.findIndex(l=>l.value===t);let o=(s=Rt[n%Rt.length])!=null?s:_e;i||(o=De),o="";const a=new Image;return a.src=o,a}static checkString(t,e){let i="";switch(t){case V.Order:case V.NumberOnly:i=$s;break;case V.EnglishOnly:i=Fs;break;case V.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?Kt:pt[i%pt.length]}catch(i){return Kt}}static getTextAttribute(t,e){try{if(e===V.Order){const i=t.map(n=>parseInt(n.textAttribute,10)).filter(n=>Nt(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?ke(Se({},s),{textAttribute:t}):s)}static getErrorNotice(t,e){switch(t){case V.Order:case V.NumberOnly:return F.getMessagesByLocale(D.TextCheckNumberErrorNotice,e);case V.EnglishOnly:return F.getMessagesByLocale(D.TextCheckEnglishErrorNotice,e);case V.CustomFormat:return F.getMessagesByLocale(D.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 ke(Se({},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))%pt.length+1;return Rt[n]}return s}static getAttributeByKeycode(t,e){var i;let s;return C.isInRange(t,[48,57])&&(s=t-48),C.isInRange(t,[96,105])&&(s=t-96),s===0?"":s?(i=e[s-1])==null?void 0:i.value:void 0}}class Tt{static deg2rad(t){return t*Math.PI/180}static rad2deg(t){return t*180/Math.PI}}var Zs=Object.defineProperty,Us=Object.defineProperties,zs=Object.getOwnPropertyDescriptors,Oe=Object.getOwnPropertySymbols,Vs=Object.prototype.hasOwnProperty,Ws=Object.prototype.propertyIsEnumerable,Me=(r,t,e)=>t in r?Zs(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,js=(r,t)=>{for(var e in t||(t={}))Vs.call(t,e)&&Me(r,e,t[e]);if(Oe)for(var e of Oe(t))Ws.call(t,e)&&Me(r,e,t[e]);return r},Xs=(r,t)=>Us(r,zs(t));const Ys=1,Gs={x:0,y:0},Ks=0,J="";class m{static drawLine(t,e,i,s={}){const n=t.getContext("2d"),{color:o=J,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=J,thickness:o=1,lineCap:a="round",hiddenText:l=!1,lineDash:h}=i;if(s.save(),s.strokeStyle=n,s.lineWidth=o,s.lineCap=a,Array.isArray(h)&&s.setLineDash(h),s.beginPath(),s.fillStyle=n,s.strokeRect(e.x,e.y,e.width,e.height),l===!1){let u="";if(e.attribute&&(u=`${u} ${e.attribute}`),this.drawText(t,{x:e.x,y:e.y-5},u),e.textAttribute){const c=`${~~e.width} * ${~~e.height}`.length*7,d=0,f=Math.max(20,e.width-c);this.drawText(t,{x:e.x,y:e.y+e.height+20+d},e.textAttribute,{textMaxWidth:f})}}s.restore()}static drawRectWithFill(t,e,i={}){const s=t.getContext("2d"),{color:n=J}=i;s.save(),s.beginPath(),s.fillStyle=n,s.fillRect(e.x,e.y,e.width,e.height),s.restore()}static drawTagByDom(t,e,i){const s=t;if(!((e==null?void 0:e.length)>0))return;const n=document.createElement("div");return n.innerHTML=e,n.setAttribute("id",i),s==null||s.appendChild(n),n}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");return o.innerHTML=(i=e.reduce((a,l)=>`${a}${l.keyName}: ${l.value.join(" \u3001 ")}
|
|
7
|
-
`,""))!=null?i:"",o.setAttribute("id","tagToolTag"),s==null||s.appendChild(o),o}static drawLineWithPointList(t,e,i={}){if(e.length<2)return;const s=t.getContext("2d"),{color:n=J,thickness:o=1,lineCap:a="round",lineType:l=S.Line,lineDash:h,hoverEdgeIndex:
|
|
8
|
-
`);for(let h=0;h<l.length;h++){const u=l[h].split("");let g="";for(let c=0;c<u.length;c++){const d=g+u[c],v=a.measureText(d).width;n||(n=300),v>n&&c>0?(a.fillText(g,i,s),g=u[c],s+=o):g=d}a.fillText(g,i,s),s+=o}}static drawArrow(t,e,i,s={}){const{color:n=J,thickness:o=1,lineCap:a="round",theta:l=30,headLen:h=10}=s,u=Math.atan2(e.y-i.y,e.x-i.x)*180/Math.PI,g=(u+l)*Math.PI/180,c=(u-l)*Math.PI/180,d=h*Math.cos(g),f=h*Math.sin(g),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+d,i.y+f),t.lineTo(i.x,i.y),t.lineTo(i.x+v,i.y+p),t.stroke(),t.restore()}static drawArrowByCanvas(t,e,i,s={}){const n=t.getContext("2d");this.drawArrow(n,e,i,s)}}m.drawImg=(r,t,e={})=>{const i=r.getContext("2d"),{zoom:s=Ys,currentPos:n=Gs,rotate:o=Ks,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:u}=a;i.filter=`saturate(${h+100}%) contrast(${l+100}%) brightness(${u+100}%)`}i.drawImage(t,0,0,t.width*s,t.height*s),i.restore()};class q{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}}static getStyle2String(t){if(!!t)return Object.entries(t).reduce((e,i)=>`${e} ${i[0]}: ${i[1]};`,"")}}class et{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?C.isInRange(t.x,[e.left,e.right])&&C.isInRange(t.y,[e.top,e.bottom]):!1}}et.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,u=l+i/e;return{top:a,bottom:h,left:l,right:u}},et.getPixelRatio=r=>{if(!r||!window)return 1;const t=r.backingStorePixelRatio||r.webkitBackingStorePixelRatio||r.mozBackingStorePixelRatio||r.msBackingStorePixelRatio||r.oBackingStorePixelRatio||r.backingStorePixelRatio||1;return(window.devicePixelRatio||1)/t};const Ee={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:""},Js={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}]}]},qs={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"]},Qs={showConfirm:!1,skipWhileNoDependencies:!1,enableTextRecognition:!1,recognitionMode:"general",configList:[{label:"\u6587\u672C",key:"text",required:!1,default:"",maxLength:1e3}],filterData:["valid","invalid"]},tr={lineType:0,lineColor:0,lowerLimitPointNum:3,edgeAdsorption:!1,drawOutsideTarget:!1,copyBackwardResult:!1,isShowOrder:!1,attributeConfigurable:!1,attributeList:[],textConfigurable:!0,textCheckType:0,customFormat:""},He=r=>r==="lineTool"?qs:r==="rectTool"?Ee:r==="tagTool"?Js:r==="textTool"?Qs:r==="polygonTool"?tr:Ee,Ne={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 er=Object.defineProperty,ir=Object.defineProperties,sr=Object.getOwnPropertyDescriptors,Be=Object.getOwnPropertySymbols,rr=Object.prototype.hasOwnProperty,nr=Object.prototype.propertyIsEnumerable,$e=(r,t,e)=>t in r?er(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Fe=(r,t)=>{for(var e in t||(t={}))rr.call(t,e)&&$e(r,e,t[e]);if(Be)for(var e of Be(t))nr.call(t,e)&&$e(r,e,t[e]);return r},Ze=(r,t)=>ir(r,sr(t)),Ue;(function(r){r[r.Create=0]="Create",r[r.Active=1]="Active",r[r.Edit=1]="Edit",r[r.None=2]="None"})(Ue||(Ue={}));var ze;(function(r){r.ActiveArea="#B3B8FF"})(ze||(ze={}));const Ve=16,or=3,Z=class{static isInLine(r,t,e,i=3){const{length:s}=C.getFootOfPerpendicular(r,t,e);return s<i}};let O=Z;O.setSpecialEdgeStyle=r=>{r.lineCap="butt",r.setLineDash([10,10])},O.setReferenceCtx=r=>{r.lineCap="butt",r.setLineDash([6])},O.calcOptimalIntersection=(r,t,e,i,s)=>{let n,o=Infinity,a;if(r.find((h,u)=>{if(u===0)return;const g=Z.isInLine(t.pointA,h,r[u-1]),c=Z.isInLine(t.pointB,h,r[u-1]);return g&&c}))return{point:e};if(r.forEach((h,u)=>{if(u===0)return;const g={pointA:r[u-1],pointB:h},c=Z.lineIntersection(t,g);if(c&&t){const{onLine2:d,onLine1:f,x:v,y:p}=c,b=Z.calcDistance(e,c);if(Z.isOnLine(t.pointB.x,t.pointB.y,h.x,h.y,r[u-1].x,r[u-1].y)){if(Z.calcDistance(e,c)<i/s){const A=t.pointB,{footPoint:I,length:R}=C.getFootOfPerpendicular(A,g.pointA,g.pointB,!0);if(R!==void 0){const E=Z.calcDistance(g.pointA,I),G=Z.calcDistance(g.pointB,I);a={point:I,minDistance:R},R===Infinity&&(a.point=E>G?g.pointB:g.pointA)}}return}b<o&&d&&f&&(o=b,n={x:v,y:p})}}),n)return{point:n,minDistance:o};if(a)return a},O.lineIntersection=(r,t)=>{let e=!1,i=!1;const s=Z.getAxisDiff(r),n=Z.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,u=(r.pointB.x-r.pointA.x)*a-(r.pointB.y-r.pointA.y)*l;a=h/o,l=u/o,a>0&&a<1&&(e=!0),l>0&&l<1&&(i=!0);const g=r.pointA.x+a*(r.pointB.x-r.pointA.x),c=r.pointA.y+a*(r.pointB.y-r.pointA.y);return{x:g,y:c,onLine1:e,onLine2:i}},O.getAxisDiff=r=>({x:r.pointB.x-r.pointA.x,y:r.pointB.y-r.pointA.y}),O.calcDistance=(r,t)=>Math.sqrt(Math.pow(Math.abs(r.x-t.x),2)+Math.pow(Math.abs(r.y-t.y),2)),O.drawCurveLine=(r,t,e,i=!0,s=!1,n)=>{const o=_t(t,Ve);r.save(),r.lineCap="round",r.lineJoin="round",r.strokeStyle=e.color,i&&(r.lineWidth=e.lineWidth),s&&Z.setReferenceCtx(r),t.forEach((a,l)=>{const h=a==null?void 0:a.specialEdge,u=o.splice(0,Ve+1);r.save(),r.beginPath(),n===l&&(r.lineWidth=4),u.forEach(({x:g,y:c},d)=>{const f=d>0?"lineTo":"moveTo";h&&Z.setSpecialEdgeStyle(r),r[f](g,c)}),r.stroke(),r.restore()}),r.restore()},O.calcTwoPointDistance=(r,t)=>Math.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2)),O.pointOverTarget=(r,t,e,i,s,n,o,a,l,h)=>{const u=r;if(!t)return r;if(e===w.Polygon){const g=Z.getPolygonPointList(i,s);if(g.length===0||H.isInPolygon(r,g))return u;const d=g.concat(g[0]).map(y=>l(y)),f=l(t),v=l(r),p={pointA:f,pointB:v},b=Z.calcOptimalIntersection(d,p,f,o,a);if(b){const y=h(b==null?void 0:b.point);u.x=y.x,u.y=y.y}else return t;return u}if(e===w.Rect){const{x:g,y:c,width:d,height:f}=i;return u.x=C.withinRange(u.x,[g,g+d]),u.y=C.withinRange(u.y,[c,c+f]),u}return u.x=C.withinRange(u.x,[0,n.width]),u.y=C.withinRange(u.y,[0,n.height]),u},O.getPolygonPointList=(r,t)=>{const{pointList:e}=r,{lineType:i}=t;return i===S.Line?e:H.createSmoothCurvePoints(e.reduce((s,n)=>[...s,n.x,n.y],[]),.5,!0,20)},O.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,O.inArea=({top:r,left:t,right:e,bottom:i},{x:s,y:n})=>n>=r&&n<=i&&s>=t&&s<=e,O.getVHPoint=(r,t,e,i)=>{const s=Z.getAngle(r,e);return Math.abs(s)<45?Ze(Fe({},t),{y:i.y}):Ze(Fe({},t),{x:i.x})},O.getAngle=(r,t)=>{const e=t.x-r.x,i=t.y-r.y;return 360*Math.atan(i/e)/(2*Math.PI)};var Jt;(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",r[r.BackSpace=8]="BackSpace"})(Jt||(Jt={}));var _=Jt,ar=Object.freeze({__proto__:null,default:_});class qt{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(N.cloneDeepWith(t)),this.recordIndex+=1,this.emitHistoryChanged()}updateHistory(t){this.record[this.recordIndex]=N.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(),N.cloneDeep(this.record[this.recordIndex])||[]}redo(){if(this.redoEnabled)return this.recordIndex+=1,this.emitHistoryChanged(),N.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?[N.cloneDeep(t)]:[],this.minRecordIndex=i?0:-1,this.recordIndex=0}}class We{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&&!L.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 je{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},u=e.width*l,g=e.height*l;return n&&(l=1),{zoom:l,currentPos:h,imgInfo:{width:u,height:g}}}static getBasicRecPos(t,e,i,s=.9,n=1,o=!1){if(e&&t){const{x:a,y:l,height:h,width:u}=e;let g=i.height/h;u/h>i.width/i.height&&(g=i.width/u);const c=o?1:g*s*n,d={x:i.width/2,y:i.height/2},f={x:(a+u/2)*c,y:(l+h/2)*c};return{currentPos:{x:d.x-f.x,y:d.y-f.y},innerZoom:c}}return!1}}class lr{static renderInvalidPage(t,e,i){const s=document.createElement("div");return s.setAttribute("style",`
|
|
5
|
+
*/import N,{isNumber as Nt,cloneDeep as Ai,isObject as Ri}from"lodash";import ue from"color-rgba";const Ti=320;var gt;(function(r){r.PointCloud="pointCloudTool"})(gt||(gt={}));var ft;(function(r){r.VideoTextTool="videoTextTool",r.VideoTagTool="videoTagTool",r.VideoClipTool="videoClipTool"})(ft||(ft={}));var Bt;(function(r){r[r.Rect=0]="Rect",r[r.Tag=1]="Tag"})(Bt||(Bt={}));var w;(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"})(w||(w={}));var Lt;(function(r){r.Check="check"})(Lt||(Lt={}));var $t;(function(r){r[r.nothing=0]="nothing",r[r.RectBG=1]="RectBG",r[r.showOrder=2]="showOrder"})($t||($t={}));const Si={[w.Rect]:"\u62C9\u6846",[w.Tag]:"\u6807\u7B7E",[w.Point]:"\u6807\u70B9",[w.PointMarker]:"\u5217\u8868\u6807\u70B9",[w.Segmentation]:"\u524D\u666F\u5206\u5272",[w.Filter]:"\u7B5B\u9009",[w.Text]:"\u6587\u672C",[w.Polygon]:"\u591A\u8FB9\u5F62",[w.Line]:"\u7EBF\u6761",[w.LineMarker]:"\u5217\u8868\u7EBF\u6761",[w.FolderTag]:"\u6587\u4EF6\u5939\u6807\u7B7E",[w.RectTrack]:"\u62C9\u6846\u8DDF\u8E2A",[w.Face]:"\u4EBA\u8138106\u5DE5\u5177",[w.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[w.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177",[ft.VideoTextTool]:"\u89C6\u9891\u6587\u672C",[ft.VideoTagTool]:"\u89C6\u9891\u6807\u7B7E",[ft.VideoClipTool]:"\u89C6\u9891\u622A\u53D6",[gt.PointCloud]:"\u70B9\u4E91"};var Ft;(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"})(Ft||(Ft={}));var ct;(function(r){r.lc="leftClick",r.rc="rightClick",r.clc="ctrlLeftClick",r.crc="ctrlRightClick"})(ct||(ct={}));const ki={leftClick:"\u9F20\u6807\u5DE6\u952E",rightClick:"\u9F20\u6807\u53F3\u952E",ctrlLeftClick:"ctrl + \u9F20\u6807\u5DE6\u952E",ctrlRightClick:"ctrl + \u9F20\u6807\u53F3\u952E"};var Ut;(function(r){r[r.Normal=1]="Normal",r[r.Modify=2]="Modify"})(Ut||(Ut={}));var S;(function(r){r[r.Line=0]="Line",r[r.Curve=1]="Curve"})(S||(S={}));var Pt;(function(r){r[r.SingleColor=0]="SingleColor",r[r.MultiColor=1]="MultiColor"})(Pt||(Pt={}));var Zt;(function(r){r[r.Form=1]="Form",r[r.Json=2]="Json"})(Zt||(Zt={}));var z;(function(r){r[r.Point=0]="Point",r[r.Line=1]="Line",r[r.Plane=2]="Plane"})(z||(z={}));var zt;(function(r){r[r.None=0]="None",r[r.Drawing=1]="Drawing",r[r.Edit=2]="Edit"})(zt||(zt={}));var Vt;(function(r){r[r.Backward=0]="Backward",r[r.Forward=1]="Forward",r[r.JumpSkip=2]="JumpSkip",r[r.None=3]="None"})(Vt||(Vt={}));var Wt;(function(r){r[r.Wait=0]="Wait",r[r.Pass=1]="Pass",r[r.Fail=2]="Fail",r[r.Loading=3]="Loading"})(Wt||(Wt={}));var V;(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"})(V||(V={}));const Oi={0:"\u4EFB\u610F\u5B57\u7B26",1:"\u5E8F\u53F7",2:"\u4EC5\u82F1\u6587",3:"\u4EC5\u6570\u5B57"},jt=1e3,ge=16,fe=300,Ct="normal normal 500 14px Arial";var Xt;(function(r){r[r.ImgList=1e3]="ImgList",r[r.TrackPrediction=1001]="TrackPrediction",r[r.ImgSearch=1002]="ImgSearch"})(Xt||(Xt={}));const Mi={[gt.PointCloud]:"sensebeepc",[w.ClientAttribute]:"sensebeepc-EnumAttributeTool",[w.Face]:"sensebeepc-FacePointsLabellingTool",[w.OCRRelation]:"sensebeepc-OCRRelationTool"},Ei={[gt.PointCloud]:"\u70B9\u4E91\u5BA2\u6237\u7AEF",[w.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[w.Face]:"\u4EBA\u8138106\u70B9\u5DE5\u5177",[w.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177"},W=16,Dt=10;var Hi=Object.freeze({__proto__:null,editStepWidth:Ti,get EPointCloudName(){return gt},get EVideoToolName(){return ft},get EToolType(){return Bt},get EToolName(){return w},get ECheckModel(){return Lt},get ERectPattern(){return $t},TOOL_NAME:Si,get EDependPattern(){return Ft},get EFilterToolOperation(){return ct},OPERATION_LIST:ki,get EAnnotationMode(){return Ut},get ELineTypes(){return S},get ELineColor(){return Pt},get ESelectedType(){return Zt},get EDragTarget(){return z},get EDrawPointPattern(){return zt},get EPageOperator(){return Vt},get EAuditStatus(){return Wt},get ETextType(){return V},TEXT_TYPE:Oi,TEXT_ATTRIBUTE_MAX_LENGTH:jt,TEXT_ATTRIBUTE_LINE_HEIGHT:ge,DEFAULT_TEXT_MAX_WIDTH:fe,DEFAULT_FONT:Ct,get EThumbnailOption(){return Xt},CLIENT_TOOL_HEAD_TYPE:Mi,CLIENT_TOOL_NAME:Ei,SEGMENT_NUMBER:W,edgeAdsorptionScope:Dt}),Ni=Object.defineProperty,Bi=Object.defineProperties,$i=Object.getOwnPropertyDescriptors,ve=Object.getOwnPropertySymbols,Fi=Object.prototype.hasOwnProperty,Ui=Object.prototype.propertyIsEnumerable,pe=(r,t,e)=>t in r?Ni(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Zi=(r,t)=>{for(var e in t||(t={}))Fi.call(t,e)&&pe(r,e,t[e]);if(ve)for(var e of ve(t))Ui.call(t,e)&&pe(r,e,t[e]);return r},zi=(r,t)=>Bi(r,$i(t));function Yt(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,g,u,c,f,v,p,b,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,g=(n[y+5]-n[y+1])*t,b=0;b<=i;b++)p=b/i,u=2*Math.pow(p,3)-3*Math.pow(p,2)+1,c=-(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=u*n[y]+c*n[y+2]+f*l+v*h,a=u*n[y+1]+c*n[y+3]+f*d+v*g,s.push(o),s.push(a);const P=[];for(let A=0;A<s.length-1;A+=2)P.push({x:s[A],y:s[A+1]});if(e)for(let A=0;A<i+1;A++){const I=P.shift();P.push(I)}return P}const _t=(r,t=16)=>Yt(r.reduce((e,i)=>[...e,i.x,i.y],[]),.5,!1,t);function be(r,t,e=S.Line){let i=0,s,n,o,a;t=[...t],e===S.Curve&&(t=Yt(t.reduce((h,d)=>[...h,d.x,d.y],[]),.5,!0,W)),[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 xe(r,t=1){return r.map(e=>zi(Zi({},e),{x:e.x*t,y:e.y*t}))}var ye=Math.pow;class Vi{static add(t,e){return{x:t.x+e.x,y:t.y+e.y}}static getVector(t,e){return{x:e.x-t.x,y:e.y-t.y}}static len(t){return Math.sqrt(ye(t.x,2)+ye(t.y,2))}static dotProduct(t,e){return t.x*e.x+t.y+e.y}}const At=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))}static getTextArea(r,t,e=fe,i=Ct,s){if(typeof t!="string")return{width:0,height:0};const n=r.getContext("2d");n.font=i;let o=0;typeof s=="undefined"&&(s=r&&parseInt(window.getComputedStyle(r).lineHeight,10)||parseInt(window.getComputedStyle(document.body).lineHeight,10));const a=r&&parseInt(window.getComputedStyle(r).fontSize,10)||parseInt(window.getComputedStyle(document.body).fontSize,10)||0,l=t.split(`
|
|
6
|
+
`);let h=0;for(let d=0;d<l.length;d++){const g=l[d].split("");let u="";for(let c=0;c<g.length;c++){const f=u+g[c],p=n.measureText(f).width;p>e&&c>0?(u=g[c],o+=s,h=e):(u=f,p>h&&(h=p))}d!==l.length-1&&(o+=s)}return{width:h,height:o+a,lineHeight:s,fontHeight:a}}static getLineCenterPoint(r){const[t,e]=r,i=Vi.getVector(t,e);return{x:t.x+i.x/2,y:t.y+i.y/2}}};let C=At;C.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))},C.withinRange=(r,t)=>{const e=Math.min(...t),i=Math.max(...t);return r>i?i:r<e?e:r},C.calcViewportBoundaries=(r,t=!1,e=W,i=1)=>{if(!r)return{top:0,bottom:0,left:0,right:0};const s=20/i,n=[],o=[];let a=r;t&&(a=_t(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),g=Math.max(...o);const u=h-l,c=g-d;if(u<s){const f=(s-u)/2;l-=f,h+=f}if(c<s){const f=(s-c)/2;d-=f,g+=f}return{top:d,bottom:g,left:l,right:h}},C.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=At.getLineLength(r,s),h=2,d=Math.min(t.x,e.x),g=Math.max(t.x,e.x),u=Math.min(t.y,e.y),c=Math.max(t.y,e.y),f=!(At.isInRange(r.x,[d,g])||At.isInRange(r.y,[u,c])),v=r.x>g+h||r.x<d-h||r.y>c+h||r.y<u-h;return(i?f:v)?{footPoint:s,length:Infinity}:{footPoint:s,length:l}};const Wi=61,ji=40,Xi=40,Yi=240;var yt;(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"})(yt||(yt={}));const Gi=1e3;var Gt;(function(r){r[r.Backward=0]="Backward",r[r.Forward=1]="Forward",r[r.JumpSkip=2]="JumpSkip",r[r.None=3]="None"})(Gt||(Gt={}));var k;(function(r){r[r.Start=0]="Start",r[r.Stop=1]="Stop",r[r.Wait=2]="Wait",r[r.Move=3]="Move"})(k||(k={}));var tt;(function(r){r[r.Point=0]="Point",r[r.Line=1]="Line",r[r.Plane=2]="Plane"})(tt||(tt={}));var j;(function(r){r[r.ascend=0]="ascend",r[r.descend=1]="descend"})(j||(j={}));var vt;(function(r){r[r.Intelligence=0]="Intelligence",r[r.Linear=1]="Linear"})(vt||(vt={}));var nt;(function(r){r.Zh="zh_CN",r.US="en_US"})(nt||(nt={}));const Y={offsetX:-10,offsetY:-10},dt={shadowColor:"rgba(0,0,0,0.6)",shadowOffsetX:0,shadowOffsetY:2,shadowBlur:4},ut={x:8,y:26};var Ki=Object.freeze({__proto__:null,headerHeight:Wi,tipsHeight:ji,footerHeight:Xi,sidebarWidth:Yi,get EStepType(){return yt},ANNOTATION_MAX_SIZE:Gi,get EPageOperator(){return Gt},get EDragStatus(){return k},get EDragTarget(){return tt},get ESortDirection(){return j},get EGrowthMode(){return vt},get ELang(){return nt},DEFAULT_TEXT_OFFSET:Y,DEFAULT_TEXT_SHADOW:dt,TEXT_ATTRIBUTE_OFFSET:ut}),Ji=Object.defineProperty,qi=Object.defineProperties,Qi=Object.getOwnPropertyDescriptors,me=Object.getOwnPropertySymbols,ts=Object.prototype.hasOwnProperty,es=Object.prototype.propertyIsEnumerable,Ie=(r,t,e)=>t in r?Ji(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ot=(r,t)=>{for(var e in t||(t={}))ts.call(t,e)&&Ie(r,e,t[e]);if(me)for(var e of me(t))es.call(t,e)&&Ie(r,e,t[e]);return r},at=(r,t)=>qi(r,Qi(t));class ${static composeResult(t,e,i,s,n){try{const o=JSON.parse(t),a=x.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(at(ot({},o),{[h]:at(ot({},o[h]),{result:i})}))}return JSON.stringify(at(ot({},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=L.changeCoordinateByRotate({x:s,y:n},e,i);switch(e%360){case 90:return at(ot({},t),{x:l.x-a,y:l.y,width:a,height:o});case 180:return at(ot({},t),{x:l.x-o,y:l.y-a});case 270:return at(ot({},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 at(ot({},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 at(ot({},t),{x:i*e,y:s*e,width:n*e,height:o*e})}static isRectNotInPolygon(t,e){return this.getRectPointList(t).some(s=>!be(s,e))}}function K(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 is=Object.defineProperty,we=Object.getOwnPropertySymbols,ss=Object.prototype.hasOwnProperty,rs=Object.prototype.propertyIsEnumerable,Le=(r,t,e)=>t in r?is(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Pe=(r,t)=>{for(var e in t||(t={}))ss.call(t,e)&&Le(r,e,t[e]);if(we)for(var e of we(t))rs.call(t,e)&&Le(r,e,t[e]);return r};class mt{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:K(),sourceID:s.id,result:Pe({},i)})):[{id:K(),sourceID:"",result:Pe({},i)}]}}var Ce='<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>',ns='<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>',os='<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>',as='<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>',ls='<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>',hs='<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>',cs='<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>',ds='<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>',us='<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>',gs='<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>',fs='<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>',vs='<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>',ps='<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>',bs='<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>',De='<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 _e=Ce,xs=61,ys=80,ms=62,Is=20,ws=55,Ls=55,Ps=40,Cs=80,Ds=240,_s=320,As="rgba(102, 111, 255, 1)",pt=["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)"],Rt=[Ce,cs,as,ds,os,us,hs,ns,ls],Ae={1:gs,3:fs,5:vs,7:ps,9:bs},Rs="rgba(255, 51, 51, 1)",Kt="rgba(204, 204, 204, 1)",Ts={[ct.lc]:"rgba(153, 51, 255, 1)",[ct.rc]:"rgba(51, 153, 255, 1)",[ct.clc]:"rgba(46, 230, 46, 1)",[ct.crc]:"rgba(255, 51, 51, 1)"};var Ss=Object.freeze({__proto__:null,HEADER_HEIGHT:xs,TAB_HEIGHT:ys,SEARCH_HEIGHT:ms,PADDING:Is,TABLE_ROW_HEIGHT:ws,PAGINATION_HEIGHT:Ls,TIPS_HEIGHT:Ps,FOOTER_HEIGHT:Cs,SIDERBAR_WIDTH:Ds,EDIT_STEP_WIDTH:_s,THEME_COLOR:As,COLORS_ARRAY:pt,ICON_ARRAY:Rt,BASE_ICON:Ae,INVALID_COLOR:Rs,NULL_COLOR:Kt,NULL_ICON:_e,INVALID_ICON:De,FILTER_TOOL_COLOR:Ts}),D;(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"})(D||(D={}));const ks={[D.NoRotateNotice]:"This Image contains data and cannot be rotated",[D.RectErrorSizeNotice]:"The drawing frame size is smaller than the minimum drawing size",[D.TextCheckNumberErrorNotice]:"Please enter in number-only format",[D.TextCheckEnglishErrorNotice]:"Please enter in English only format",[D.TextCheckCustomErrorNotice]:"Please enter in the required format",[D.UpperLimitErrorNotice]:"The number of vertices is not more than",[D.LowerLimitErrorNotice]:"The number of vertices is not less than",[D.InvalidImage]:"Invalid image, please skip this image",[D.DisableDelete]:"Disable delete",[D.ClearPartialData]:"Clear partial data",[D.MarkerFinish]:"ListAnnotation is finished",[D.LowerLimitPoint]:"\u5DF2\u5230\u8FBE\u6807\u70B9\u6570\u91CF\u4E0A\u9650",[D.NoRotateInDependence]:"Disallow rotation in dependent cases"},Os={[D.NoRotateNotice]:"\u672C\u56FE\u542B\u6709\u6570\u636E\uFF0C\u65E0\u6CD5\u8FDB\u884C\u65CB\u8F6C",[D.RectErrorSizeNotice]:"\u7ED8\u5236\u6846\u5C3A\u5BF8\u5C0F\u4E8E\u6700\u5C0F\u7ED8\u5236\u5C3A\u5BF8",[D.TextCheckNumberErrorNotice]:"\u8BF7\u6309\u4EC5\u6570\u5B57\u7684\u683C\u5F0F\u8F93\u5165",[D.TextCheckEnglishErrorNotice]:"\u8BF7\u6309\u4EC5\u82F1\u6587\u7684\u683C\u5F0F\u8F93\u5165",[D.TextCheckCustomErrorNotice]:"\u8BF7\u6309\u8981\u6C42\u7684\u683C\u5F0F\u8F93\u5165",[D.UpperLimitErrorNotice]:"\u9876\u70B9\u6570\u4E0D\u591A\u4E8E",[D.LowerLimitErrorNotice]:"\u9876\u70B9\u6570\u4E0D\u5C11\u4E8E",[D.InvalidImage]:"\u65E0\u6548\u56FE\u7247\uFF0C\u8BF7\u8DF3\u8FC7\u6B64\u56FE",[D.DisableDelete]:"\u8BE5\u6570\u636E\u7981\u6B62\u5220\u9664",[D.ClearPartialData]:"\u5B58\u5728\u90E8\u5206\u6570\u636E\u65E0\u6CD5\u6E05\u9664",[D.MarkerFinish]:"\u5217\u8868\u6807\u6CE8\u5DF2\u5B8C\u6210",[D.LowerLimitPoint]:"\u5DF2\u5230\u8FBE\u6807\u70B9\u6570\u91CF\u4E0A\u9650",[D.NoRotateInDependence]:"\u4F9D\u8D56\u60C5\u51B5\u4E0B\u65E0\u6CD5\u8FDB\u884C\u65CB\u8F6C"};class F{}F.getMessagesByLocale=(r,t)=>{switch(t){case nt.US:return ks[r];case nt.Zh:default:return Os[r]}};var Ms=Object.defineProperty,Es=Object.defineProperties,Hs=Object.getOwnPropertyDescriptors,Re=Object.getOwnPropertySymbols,Ns=Object.prototype.hasOwnProperty,Bs=Object.prototype.propertyIsEnumerable,Te=(r,t,e)=>t in r?Ms(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Se=(r,t)=>{for(var e in t||(t={}))Ns.call(t,e)&&Te(r,e,t[e]);if(Re)for(var e of Re(t))Bs.call(t,e)&&Te(r,e,t[e]);return r},ke=(r,t)=>Es(r,Hs(t));const $s="^[0-9]+$",Fs="^[A-Za-z]+$";class T{static getAttributeIcon(t,e,i=!0){var s;const n=e.findIndex(l=>l.value===t);let o=(s=Rt[n%Rt.length])!=null?s:_e;i||(o=De),o="";const a=new Image;return a.src=o,a}static checkString(t,e){let i="";switch(t){case V.Order:case V.NumberOnly:i=$s;break;case V.EnglishOnly:i=Fs;break;case V.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?Kt:pt[i%pt.length]}catch(i){return Kt}}static getTextAttribute(t,e){try{if(e===V.Order){const i=t.map(n=>parseInt(n.textAttribute,10)).filter(n=>Nt(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?ke(Se({},s),{textAttribute:t}):s)}static getErrorNotice(t,e){switch(t){case V.Order:case V.NumberOnly:return F.getMessagesByLocale(D.TextCheckNumberErrorNotice,e);case V.EnglishOnly:return F.getMessagesByLocale(D.TextCheckEnglishErrorNotice,e);case V.CustomFormat:return F.getMessagesByLocale(D.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 ke(Se({},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))%pt.length+1;return Rt[n]}return s}static getAttributeByKeycode(t,e){var i;let s;return C.isInRange(t,[48,57])&&(s=t-48),C.isInRange(t,[96,105])&&(s=t-96),s===0?"":s?(i=e[s-1])==null?void 0:i.value:void 0}}class Tt{static deg2rad(t){return t*Math.PI/180}static rad2deg(t){return t*180/Math.PI}}var Us=Object.defineProperty,Zs=Object.defineProperties,zs=Object.getOwnPropertyDescriptors,Oe=Object.getOwnPropertySymbols,Vs=Object.prototype.hasOwnProperty,Ws=Object.prototype.propertyIsEnumerable,Me=(r,t,e)=>t in r?Us(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,js=(r,t)=>{for(var e in t||(t={}))Vs.call(t,e)&&Me(r,e,t[e]);if(Oe)for(var e of Oe(t))Ws.call(t,e)&&Me(r,e,t[e]);return r},Xs=(r,t)=>Zs(r,zs(t));const Ys=1,Gs={x:0,y:0},Ks=0,J="";class m{static drawLine(t,e,i,s={}){const n=t.getContext("2d"),{color:o=J,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=J,thickness:o=1,lineCap:a="round",hiddenText:l=!1,lineDash:h}=i;if(s.save(),s.strokeStyle=n,s.lineWidth=o,s.lineCap=a,Array.isArray(h)&&s.setLineDash(h),s.beginPath(),s.fillStyle=n,s.strokeRect(e.x,e.y,e.width,e.height),l===!1){let d="";if(e.attribute&&(d=`${d} ${e.attribute}`),this.drawText(t,{x:e.x,y:e.y-5},d),e.textAttribute){const u=`${~~e.width} * ${~~e.height}`.length*7,c=0,f=Math.max(20,e.width-u);this.drawText(t,{x:e.x,y:e.y+e.height+20+c},e.textAttribute,{textMaxWidth:f})}}s.restore()}static drawRectWithFill(t,e,i={}){const s=t.getContext("2d"),{color:n=J}=i;s.save(),s.beginPath(),s.fillStyle=n,s.fillRect(e.x,e.y,e.width,e.height),s.restore()}static drawTagByDom(t,e,i){const s=t;if(!((e==null?void 0:e.length)>0))return;const n=document.createElement("div");return n.innerHTML=e,n.setAttribute("id",i),s==null||s.appendChild(n),n}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");return o.innerHTML=(i=e.reduce((a,l)=>`${a}${l.keyName}: ${l.value.join(" \u3001 ")}
|
|
7
|
+
`,""))!=null?i:"",o.setAttribute("id","tagToolTag"),s==null||s.appendChild(o),o}static drawLineWithPointList(t,e,i={}){if(e.length<2)return;const s=t.getContext("2d"),{color:n=J,thickness:o=1,lineCap:a="round",lineType:l=S.Line,lineDash:h,hoverEdgeIndex:d}=i;s.save(),(()=>{s.strokeStyle=n,s.lineWidth=o,s.lineCap=a,Array.isArray(h)?s.setLineDash(h):s.setLineDash([])})(),l===S.Curve?(d!==void 0&&d>-1&&e.push(e[0]),e=H.createSmoothCurvePointsFromPointList([...e],W),d!==void 0&&d>-1&&(e=e.slice((W+1)*d,(W+1)*(d+1)))):d!==void 0&&d>-1&&(e=[...e,e[0]],e=e.slice(d,d+2));const u=[];s.beginPath(),s.moveTo(e[0].x,e[0].y);for(let v=0;v<e.length-1;v++)e[v].specialEdge&&u.push({i1:v,i2:v+1}),s.lineTo(e[v+1].x,e[v+1].y);s.stroke(),s.save(),s.lineWidth=o*.8,s.lineCap="butt",s.strokeStyle="white",s.setLineDash([3,3]),u.forEach(v=>{const p=e[v.i1],b=e[v.i2];s.beginPath(),s.moveTo(p.x,p.y),s.lineTo(b.x,b.y),s.stroke()}),s.restore();const c=4,f=2;return e.forEach(v=>{v.specialPoint&&(this.drawSpecialPoint(t,v,c+f,n),this.drawSpecialPoint(t,v,c,"white"))}),s.restore(),e}static drawCircle(t,e,i,s={}){const n=t.getContext("2d"),{startAngleDeg:o=0,endAngleDeg:a=360,thickness:l=1,color:h=J,fill:d=J}=s,g=Tt.deg2rad(o),u=Tt.deg2rad(a);n.save(),n.beginPath(),n.strokeStyle=h,n.fillStyle=d,n.lineWidth=l,n.arc(e.x,e.y,i,g,u,!1),n.stroke(),d&&n.fill(),n.closePath(),n.restore()}static drawCircleWithFill(t,e,i=3,s={}){const n=t.getContext("2d"),{color:o=J}=s;n.save();const a=Tt.deg2rad(0),l=Tt.deg2rad(360);n.fillStyle=o,n.beginPath(),n.arc(e.x,e.y,i,a,l,!1),n.fill(),n.restore()}static drawSpecialPoint(t,e,i=6,s){const n=t.getContext("2d"),{x:o,y:a}=e;n.save(),n.beginPath(),n.fillStyle=s;const l=i*1.5,h=l*Math.sqrt(3)/2,d=l/2;n.moveTo(o,a-l),n.lineTo(o-h,a+d),n.lineTo(o+h,a+d),n.closePath(),n.fill(),n.restore()}static drawPolygon(t,e,i={}){const{isClose:s=!1,lineType:n=S.Line}=i;return s===!0&&(e=[...e,e[0]]),n===S.Curve&&(e=H.createSmoothCurvePointsFromPointList([...e])),this.drawLineWithPointList(t,e,Xs(js({},i),{lineType:S.Line})),e}static drawPolygonWithFill(t,e,i={}){if(e.length<2)return;const s=t.getContext("2d"),{color:n=J,lineType:o=S.Line}=i;s.save(),s.fillStyle=n,s.beginPath(),o===S.Curve&&(e=H.createSmoothCurvePointsFromPointList([...e,e[0]]));const[a,...l]=e;return s.moveTo(a.x,a.y),l.forEach(h=>{s.lineTo(h.x,h.y)}),s.fill(),s.restore(),e}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=J,font:a=Ct,shadowColor:l="",shadowBlur:h=0,shadowOffsetX:d=0,shadowOffsetY:g=0,textMaxWidth:u=164,offsetX:c=0,offsetY:f=0,textAlign:v="start",lineHeight:p}=s;n.save(),n.textAlign=v,n.fillStyle=o!=null?o:"white",n.font=a,n.shadowColor=l,n.shadowOffsetX=d,n.shadowOffsetY=g,n.shadowBlur=h,this.wrapText(t,`${i}`,e.x+c,e.y+f,u,p),n.restore()}static wrapText(t,e,i,s,n,o){if(typeof e!="string"||typeof i!="number"||typeof s!="number")return;const a=t.getContext("2d");typeof n=="undefined"&&(n=t&&t.width||300),typeof o=="undefined"&&(o=t&&parseInt(window.getComputedStyle(t).lineHeight,10)||parseInt(window.getComputedStyle(document.body).lineHeight,10));const l=e.split(`
|
|
8
|
+
`);for(let h=0;h<l.length;h++){const d=l[h].split("");let g="";for(let u=0;u<d.length;u++){const c=g+d[u],v=a.measureText(c).width;n||(n=300),v>n&&u>0?(a.fillText(g,i,s),g=d[u],s+=o):g=c}a.fillText(g,i,s),s+=o}}static drawArrow(t,e,i,s={}){const{color:n=J,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,g=(d+l)*Math.PI/180,u=(d-l)*Math.PI/180,c=h*Math.cos(g),f=h*Math.sin(g),v=h*Math.cos(u),p=h*Math.sin(u);t.save(),t.strokeStyle=n,t.lineWidth=o,t.lineCap=a,t.beginPath(),t.moveTo(i.x+c,i.y+f),t.lineTo(i.x,i.y),t.lineTo(i.x+v,i.y+p),t.stroke(),t.restore()}static drawArrowByCanvas(t,e,i,s={}){const n=t.getContext("2d");this.drawArrow(n,e,i,s)}}m.drawImg=(r,t,e={})=>{const i=r.getContext("2d"),{zoom:s=Ys,currentPos:n=Gs,rotate:o=Ks,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 q{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}}static getStyle2String(t){if(!!t)return Object.entries(t).reduce((e,i)=>`${e} ${i[0]}: ${i[1]};`,"")}}class et{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?C.isInRange(t.x,[e.left,e.right])&&C.isInRange(t.y,[e.top,e.bottom]):!1}}et.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}},et.getPixelRatio=r=>{if(!r||!window)return 1;const t=r.backingStorePixelRatio||r.webkitBackingStorePixelRatio||r.mozBackingStorePixelRatio||r.msBackingStorePixelRatio||r.oBackingStorePixelRatio||r.backingStorePixelRatio||1;return(window.devicePixelRatio||1)/t};const Ee={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:""},Js={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}]}]},qs={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"]},Qs={showConfirm:!1,skipWhileNoDependencies:!1,enableTextRecognition:!1,recognitionMode:"general",configList:[{label:"\u6587\u672C",key:"text",required:!1,default:"",maxLength:1e3}],filterData:["valid","invalid"]},tr={lineType:0,lineColor:0,lowerLimitPointNum:3,edgeAdsorption:!1,drawOutsideTarget:!1,copyBackwardResult:!1,isShowOrder:!1,attributeConfigurable:!1,attributeList:[],textConfigurable:!0,textCheckType:0,customFormat:""},He=r=>r==="lineTool"?qs:r==="rectTool"?Ee:r==="tagTool"?Js:r==="textTool"?Qs:r==="polygonTool"?tr:Ee,Ne={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 er=Object.defineProperty,ir=Object.defineProperties,sr=Object.getOwnPropertyDescriptors,Be=Object.getOwnPropertySymbols,rr=Object.prototype.hasOwnProperty,nr=Object.prototype.propertyIsEnumerable,$e=(r,t,e)=>t in r?er(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Fe=(r,t)=>{for(var e in t||(t={}))rr.call(t,e)&&$e(r,e,t[e]);if(Be)for(var e of Be(t))nr.call(t,e)&&$e(r,e,t[e]);return r},Ue=(r,t)=>ir(r,sr(t)),Ze;(function(r){r[r.Create=0]="Create",r[r.Active=1]="Active",r[r.Edit=1]="Edit",r[r.None=2]="None"})(Ze||(Ze={}));var ze;(function(r){r.ActiveArea="#B3B8FF"})(ze||(ze={}));const Ve=16,or=3,U=class{static isInLine(r,t,e,i=3){const{length:s}=C.getFootOfPerpendicular(r,t,e);return s<i}};let O=U;O.setSpecialEdgeStyle=r=>{r.lineCap="butt",r.setLineDash([10,10])},O.setReferenceCtx=r=>{r.lineCap="butt",r.setLineDash([6])},O.calcOptimalIntersection=(r,t,e,i,s)=>{let n,o=Infinity,a;if(r.find((h,d)=>{if(d===0)return;const g=U.isInLine(t.pointA,h,r[d-1]),u=U.isInLine(t.pointB,h,r[d-1]);return g&&u}))return{point:e};if(r.forEach((h,d)=>{if(d===0)return;const g={pointA:r[d-1],pointB:h},u=U.lineIntersection(t,g);if(u&&t){const{onLine2:c,onLine1:f,x:v,y:p}=u,b=U.calcDistance(e,u);if(U.isOnLine(t.pointB.x,t.pointB.y,h.x,h.y,r[d-1].x,r[d-1].y)){if(U.calcDistance(e,u)<i/s){const A=t.pointB,{footPoint:I,length:R}=C.getFootOfPerpendicular(A,g.pointA,g.pointB,!0);if(R!==void 0){const E=U.calcDistance(g.pointA,I),G=U.calcDistance(g.pointB,I);a={point:I,minDistance:R},R===Infinity&&(a.point=E>G?g.pointB:g.pointA)}}return}b<o&&c&&f&&(o=b,n={x:v,y:p})}}),n)return{point:n,minDistance:o};if(a)return a},O.lineIntersection=(r,t)=>{let e=!1,i=!1;const s=U.getAxisDiff(r),n=U.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 g=r.pointA.x+a*(r.pointB.x-r.pointA.x),u=r.pointA.y+a*(r.pointB.y-r.pointA.y);return{x:g,y:u,onLine1:e,onLine2:i}},O.getAxisDiff=r=>({x:r.pointB.x-r.pointA.x,y:r.pointB.y-r.pointA.y}),O.calcDistance=(r,t)=>Math.sqrt(Math.pow(Math.abs(r.x-t.x),2)+Math.pow(Math.abs(r.y-t.y),2)),O.drawCurveLine=(r,t,e,i=!0,s=!1,n)=>{const o=_t(t,Ve);r.save(),r.lineCap="round",r.lineJoin="round",r.strokeStyle=e.color,i&&(r.lineWidth=e.lineWidth),s&&U.setReferenceCtx(r),t.forEach((a,l)=>{const h=a==null?void 0:a.specialEdge,d=o.splice(0,Ve+1);r.save(),r.beginPath(),n===l&&(r.lineWidth=4),d.forEach(({x:g,y:u},c)=>{const f=c>0?"lineTo":"moveTo";h&&U.setSpecialEdgeStyle(r),r[f](g,u)}),r.stroke(),r.restore()}),r.restore()},O.calcTwoPointDistance=(r,t)=>Math.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2)),O.pointOverTarget=(r,t,e,i,s,n,o,a,l,h)=>{const d=r;if(!t)return r;if(e===w.Polygon){const g=U.getPolygonPointList(i,s);if(g.length===0||H.isInPolygon(r,g))return d;const c=g.concat(g[0]).map(y=>l(y)),f=l(t),v=l(r),p={pointA:f,pointB:v},b=U.calcOptimalIntersection(c,p,f,o,a);if(b){const y=h(b==null?void 0:b.point);d.x=y.x,d.y=y.y}else return t;return d}if(e===w.Rect){const{x:g,y:u,width:c,height:f}=i;return d.x=C.withinRange(d.x,[g,g+c]),d.y=C.withinRange(d.y,[u,u+f]),d}return d.x=C.withinRange(d.x,[0,n.width]),d.y=C.withinRange(d.y,[0,n.height]),d},O.getPolygonPointList=(r,t)=>{const{pointList:e}=r,{lineType:i}=t;return i===S.Line?e:H.createSmoothCurvePoints(e.reduce((s,n)=>[...s,n.x,n.y],[]),.5,!0,20)},O.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,O.inArea=({top:r,left:t,right:e,bottom:i},{x:s,y:n})=>n>=r&&n<=i&&s>=t&&s<=e,O.getVHPoint=(r,t,e,i)=>{const s=U.getAngle(r,e);return Math.abs(s)<45?Ue(Fe({},t),{y:i.y}):Ue(Fe({},t),{x:i.x})},O.getAngle=(r,t)=>{const e=t.x-r.x,i=t.y-r.y;return 360*Math.atan(i/e)/(2*Math.PI)};var Jt;(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",r[r.BackSpace=8]="BackSpace"})(Jt||(Jt={}));var _=Jt,ar=Object.freeze({__proto__:null,default:_});class qt{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(N.cloneDeepWith(t)),this.recordIndex+=1,this.emitHistoryChanged()}updateHistory(t){this.record[this.recordIndex]=N.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(),N.cloneDeep(this.record[this.recordIndex])||[]}redo(){if(this.redoEnabled)return this.recordIndex+=1,this.emitHistoryChanged(),N.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?[N.cloneDeep(t)]:[],this.minRecordIndex=i?0:-1,this.recordIndex=0}}class We{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&&!L.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 je{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,g=e.height*l;return n&&(l=1),{zoom:l,currentPos:h,imgInfo:{width:d,height:g}}}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 g=i.height/h;d/h>i.width/i.height&&(g=i.width/d);const u=o?1:g*s*n,c={x:i.width/2,y:i.height/2},f={x:(a+d/2)*u,y:(l+h/2)*u};return{currentPos:{x:c.x-f.x,y:c.y-f.y},innerZoom:u}}return!1}}class lr{static renderInvalidPage(t,e,i){const s=document.createElement("div");return s.setAttribute("style",`
|
|
9
9
|
position: absolute;
|
|
10
10
|
left: 0px;
|
|
11
11
|
top: 0px;
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
font-size: 30px;
|
|
21
21
|
opacity: 0.7;
|
|
22
22
|
z-index: 30;
|
|
23
|
-
`),s.innerHTML=F.getMessagesByLocale(D.InvalidImage,i),t.appendChild(s),s}}const lt=[1,5,10,20,30,50,80,100].concat(Array.from({length:9}).map((r,t)=>(t+2)*100));class St{}St.zoomChanged=(r,t,e=vt.Linear)=>{switch(e){case vt.Intelligence:{const i=Math.max(...lt),s=Math.min(...lt),n=lt.slice(0,lt.length).findIndex((a,l)=>r>=a&&(r<lt[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-(lt.includes(r)?1:0);o=lt[C.withinRange(a,[0,lt.length-1])]}return o}default:{const i=t?2:1/2;return r*i}}},St.wheelChangePos=(r,t,e,i,s={})=>{const{zoom:n=1,innerZoom:o=1,basicZoom:a=1,zoomMax:l=1e3,rotate:h=0}=s,{x:u,y:g}=i,c=parseFloat((n+1/10).toFixed(1))/5;if(r&&t){let{width:d,height:f}=r;[90,270].includes(h)&&(d=r.height,f=r.width);const v=d*o,p=f*o,b=t.x-u,y=t.y-g,P=b/v,A=y/p;let I=n+e*c;I=C.withinRange(I,[a,l]);const R=d*I*P,E=f*I*A,G=u+(b-R),Q=g+(y-E);return{zoom:I,currentPos:{x:G,y:Q},imgInfo:{width:d*I,height:f*I},ratio:c}}return null};class hr{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)}}var cr=Object.defineProperty,dr=Object.defineProperties,ur=Object.getOwnPropertyDescriptors,Xe=Object.getOwnPropertySymbols,gr=Object.prototype.hasOwnProperty,fr=Object.prototype.propertyIsEnumerable,Ye=(r,t,e)=>t in r?cr(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ge=(r,t)=>{for(var e in t||(t={}))gr.call(t,e)&&Ye(r,e,t[e]);if(Xe)for(var e of Xe(t))fr.call(t,e)&&Ye(r,e,t[e]);return r},vr=(r,t)=>dr(r,ur(t)),pr=(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 kt={min:.2,max:1e3,ratio:.4};class it extends hr{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=()=>pr(this,null,function*(){var g,c;if(!this.imgNode)return;const d=(g=this._imgAttribute)==null?void 0:g.zoomRatio,f=(c=this._imgAttribute)==null?void 0:c.isOriginalSize,{currentPos:v,imgInfo:p,zoom:b}=je.getInitImgPos(this.size,{width:this.imgNode.width,height:this.imgNode.height},this.rotate,d,f);this.setCurrentPos(v),this.currentPosStorage=v,this.imgInfo=p,this.setZoom(b),this.innerZoom=b,this.render(),this.renderBasicCanvas(),this.emit("dependRender"),this.emit("renderZoom",b)}),this.getCurrentPos=g=>{const{_firstClickCoordinate:c,currentPosStorage:d}=this;try{let f;return c&&d?f={y:d.y+g.y-c.y,x:d.x+g.x-c.x}:f={x:0,y:0},f}catch(f){return console.error(f),{x:0,y:0}}},this.wheelChangePos=(g,c,d)=>{const{currentPos:f,imgNode:v}=this;if(!v){console.error("unable to load image");return}if(this.zoom===this.basicZoom&&c===-1)return;const p=St.wheelChangePos(v,g,c,f,{zoom:d||this.zoom,innerZoom:this.innerZoom,basicZoom:this.basicZoom,zoomMax:kt.max,rotate:this.rotate});if(!p)return;const{currentPos:b,ratio:y,zoom:P,imgInfo:A}=p;this.innerZoom=P,this.setZoom(P),this.setCurrentPos(b),this.currentPosStorage=b,this.imgInfo=A,kt.ratio=y,this.emit("renderZoom",P,f)},this.zoomChanged=(g,c=vt.Linear)=>{const d=St.zoomChanged(this.zoom,g,c);this.wheelChangePos(this.getGetCenterCoordinate(),d>this.zoom?1:-1,d),this.render(),this.renderBasicCanvas()},this.drawImg=()=>{!this.imgNode||m.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,u;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.forbidBasicResultRender=(a=t.forbidBasicResultRender)!=null?a:!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:pt[4],fillColor:pt[4],strokeWidth:2,opacity:1},this.attributeLockList=[],this.history=new qt,this.style=(l=t.style)!=null?l:{},this._imgAttribute=(h=t.imgAttribute)!=null?h:{},this.isHidden=!1,this.dragStatus=k.Wait,this.defaultAttribute=(u=t==null?void 0:t.defaultAttribute)!=null?u:"",this.forbidCursorLine=!!t.forbidCursorLine,this.lang=nt.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 We(this.container,200),this.coordUtils=new qr(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 Ae[this.style.color]}get defaultCursor(){return this.showDefaultCursor?"default":"none"}get dataList(){return[]}get hasMarkerConfig(){return this.config.markerConfigurable===!0&&this.config.markerList&&this.config.markerList.length>0}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}get pixelRatio(){var t;return et.getPixelRatio((t=this.canvas)==null?void 0:t.getContext("2d"))}init(){this.eventUnbinding(),this.initPosition(),this.eventBinding(),this.render(),this.renderBasicCanvas()}destroy(){this.destroyCanvas(),this.eventUnbinding()}createCanvas(t){var e,i;const s=document.createElement("canvas"),n=this.pixelRatio;s.width=t.width*n,s.height=t.height*n,s.style.width=`${t.width}px`,s.style.height=`${t.height}px`,s.style.left="0",s.style.top="0",s.style.zIndex="0",this.basicCanvas=s;const o=document.createElement("canvas");o.style.position="absolute",o.style.left="0",o.style.top="0",o.style.zIndex="10",o.style.width=`${t.width}px`,o.style.height=`${t.height}px`,o.width=t.width*n,o.height=t.height*n,this.container.hasChildNodes()?(this.container.insertBefore(o,this.container.childNodes[0]),this.container.insertBefore(s,this.container.childNodes[0])):(this.container.appendChild(s),this.container.appendChild(o)),this.canvas=o,this.container.style.cursor=this.defaultCursor,(e=this.ctx)==null||e.scale(n,n),(i=this.basicCtx)==null||i.scale(n,n)}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(Ge({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 w.Polygon:case w.Line:{if(t.pointList){const h=C.calcViewportBoundaries(t.pointList);a={x:h.left,y:h.top,width:h.right-h.left,height:h.bottom-h.top}}break}}const l=je.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=vr(Ge({},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||!Nt(e==null?void 0:e.x)||!Nt(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.emit("dragMove",{currentPos:i,zoom:this.zoom})}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||O.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===_.Alt&&t.preventDefault(),t.keyCode){case _.Space:this.isSpaceKey=!0;break;case _.Z:if(t.ctrlKey)return t.shiftKey?this.redo():this.undo(),!1;break}return!0}onKeyUp(t){switch(t.keyCode){case _.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>kt.min&&(n=-1),s<0&&this.zoom<kt.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;m.drawLine(this.canvas,{x:0,y:i},{x:1e4,y:i},{color:t}),m.drawLine(this.canvas,{x:e,y:0},{x:e,y:1e4},{color:t}),m.drawCircleWithFill(this.canvas,{x:e,y:i},1,{color:"white"})}setSize(t){var e;this.size=t,this.container.contains(this.canvas)&&(this.destroyCanvas(),this.createCanvas(t),this.eventUnbinding(),this.init(),((e=this.basicImgInfo)==null?void 0:e.valid)===!1&&this.renderInvalidPage())}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=x.jsonParser(t)}updateRotate(){if(this.dependToolName)return this.emit("messageInfo",F.getMessagesByLocale(D.NoRotateInDependence,this.lang)),!1;if(this.dataList.length>0)return this.emit("messageInfo",F.getMessagesByLocale(D.NoRotateNotice,this.lang)),!1;const t=C.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=T.getAttributeIndex(t,(i=e.attributeList)!=null?i:[])+1;return this.style.attributeColor[o]}const{color:s,toolColor:n}=this.style;return n?n[s]:Ne.toolColor["1"]}getLineColor(t=""){var e,i,s;if(((e=this.config)==null?void 0:e.attributeConfigurable)===!0){const a=T.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=lr.renderInvalidPage(this.container,this.size,this.lang))}renderBasicCanvas(){if(!this.basicCanvas)return;this.clearBasicCanvas(),this.drawImg();const t=3;if(!this.forbidBasicResultRender&&this.basicResult&&this.dependToolName)switch(this.dependToolName){case w.Rect:{m.drawRect(this.basicCanvas,L.changeRectByZoom(this.basicResult,this.zoom,this.currentPos),{color:"rgba(204,204,204,1.00)",thickness:t});break}case w.Polygon:{m.drawPolygonWithFillAndLine(this.basicCanvas,L.changePointListByZoom(this.basicResult.pointList,this.zoom,this.currentPos),{fillColor:"transparent",strokeColor:"rgba(204,204,204,1.00)",isClose:!0,thickness:t});break}case w.Line:{m.drawLineWithPointList(this.basicCanvas,L.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 br=Object.defineProperty,Ke=Object.getOwnPropertySymbols,xr=Object.prototype.hasOwnProperty,yr=Object.prototype.propertyIsEnumerable,Je=(r,t,e)=>t in r?br(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,qe=(r,t)=>{for(var e in t||(t={}))xr.call(t,e)&&Je(r,e,t[e]);if(Ke)for(var e of Ke(t))yr.call(t,e)&&Je(r,e,t[e]);return r};const Qe={x:8,y:26},mr=2;class Ir extends it{constructor(t){super(t);this.getHoverRectID=e=>{var i,s;const n=this.getCoordinateUnderZoom(e),o=(s=(i=this.resultList.find(a=>a.toolName===w.Rect))==null?void 0:i.result)!=null?s:[];if(o.length>0){const a=o.filter(l=>$.isInRect(n,l,mr,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,u)=>h.size-u.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===w.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=Ai(t),this.render()}drawPolygon(t,e){t==null||t.forEach(i=>{var s,n,o,a,l;const h=this.getColor(i.attribute,e),u=q.getStrokeAndFill(h,i.valid);let g=(n=(s=this.style)==null?void 0:s.width)!=null?n:2;this.hoverID.includes(i.id)?(g=4,m.drawPolygonWithFillAndLine(this.canvas,L.changePointListByZoom(i.pointList,this.zoom,this.currentPos),{fillColor:u.fill,strokeColor:u.stroke,pointColor:"white",thickness:g,lineCap:"round",isClose:!0,lineType:e==null?void 0:e.lineType})):m.drawPolygon(this.canvas,L.changePointListByZoom(i.pointList,this.zoom,this.currentPos),{color:u.fill,lineType:(o=this.config)==null?void 0:o.lineType,thickness:g,isClose:!0}),m.drawText(this.canvas,L.changePointByZoom(i.pointList[0],this.zoom,this.currentPos),(l=T.getAttributeShowText(i.attribute,(a=e==null?void 0:e.attributeList)!=null?a:[]))!=null?l:"",qe({color:u.stroke},Y));const c=L.changePointListByZoom(i.pointList||[],this.zoom,this.currentPos),d=c[c.length-1];m.drawText(this.canvas,{x:d.x+Qe.x,y:d.y+Qe.y},i==null?void 0:i.textAttribute,qe({color:u.stroke},Y))})}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=L.changeRectByZoom(i,this.zoom,this.currentPos);m.drawRect(this.canvas,o,{color:(i==null?void 0:i.valid)?n.valid.stroke:n.invalid.stroke,thickness:s}),this.fillID.includes(i.id)&&m.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)?mt.getTagNameList(n.result,e.inputList):mt.getTagnameListWithoutConfig(n.result)],[]);m.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 w.Rect:this.drawRect(e.result,x.jsonParser(e.config));break;case w.Polygon:this.drawPolygon(e.result,x.jsonParser(e.config));break;case w.Tag:this.drawTag(e.result,x.jsonParser(e.config));break}})}exportData(){return[[],{}]}}const Qt=30,te=164;class Ot{constructor(t){this.textKeyDown=l=>{switch(l.stopPropagation(),l.keyCode){case _.Enter:this.submitTextarea(),this.appendToContainer();break}};const{container:e,icon:i,color:s,getCurrentSelectedData:n,updateSelectedTextAttribute:o}=t,a=t.width||te;this.container=e,this.getCurrentSelectedData=n,this.updateSelectedTextAttribute=o,this._textAttributeDOM=this.initTextAttributeDOM(),this._iconDOM=this.initIconDOM(i),this._textDOM=this.initTextDOM(a,ge),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
|
+
`),s.innerHTML=F.getMessagesByLocale(D.InvalidImage,i),t.appendChild(s),s}}const lt=[1,5,10,20,30,50,80,100].concat(Array.from({length:9}).map((r,t)=>(t+2)*100));class St{}St.zoomChanged=(r,t,e=vt.Linear)=>{switch(e){case vt.Intelligence:{const i=Math.max(...lt),s=Math.min(...lt),n=lt.slice(0,lt.length).findIndex((a,l)=>r>=a&&(r<lt[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-(lt.includes(r)?1:0);o=lt[C.withinRange(a,[0,lt.length-1])]}return o}default:{const i=t?2:1/2;return r*i}}},St.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:g}=i,u=parseFloat((n+1/10).toFixed(1))/5;if(r&&t){let{width:c,height:f}=r;[90,270].includes(h)&&(c=r.height,f=r.width);const v=c*o,p=f*o,b=t.x-d,y=t.y-g,P=b/v,A=y/p;let I=n+e*u;I=C.withinRange(I,[a,l]);const R=c*I*P,E=f*I*A,G=d+(b-R),Q=g+(y-E);return{zoom:I,currentPos:{x:G,y:Q},imgInfo:{width:c*I,height:f*I},ratio:u}}return null};class hr{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)}}var cr=Object.defineProperty,dr=Object.defineProperties,ur=Object.getOwnPropertyDescriptors,Xe=Object.getOwnPropertySymbols,gr=Object.prototype.hasOwnProperty,fr=Object.prototype.propertyIsEnumerable,Ye=(r,t,e)=>t in r?cr(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ge=(r,t)=>{for(var e in t||(t={}))gr.call(t,e)&&Ye(r,e,t[e]);if(Xe)for(var e of Xe(t))fr.call(t,e)&&Ye(r,e,t[e]);return r},vr=(r,t)=>dr(r,ur(t)),pr=(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 kt={min:.2,max:1e3,ratio:.4};class it extends hr{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=()=>pr(this,null,function*(){var g,u;if(!this.imgNode)return;const c=(g=this._imgAttribute)==null?void 0:g.zoomRatio,f=(u=this._imgAttribute)==null?void 0:u.isOriginalSize,{currentPos:v,imgInfo:p,zoom:b}=je.getInitImgPos(this.size,{width:this.imgNode.width,height:this.imgNode.height},this.rotate,c,f);this.setCurrentPos(v),this.currentPosStorage=v,this.imgInfo=p,this.setZoom(b),this.innerZoom=b,this.render(),this.renderBasicCanvas(),this.emit("dependRender"),this.emit("renderZoom",b)}),this.getCurrentPos=g=>{const{_firstClickCoordinate:u,currentPosStorage:c}=this;try{let f;return u&&c?f={y:c.y+g.y-u.y,x:c.x+g.x-u.x}:f={x:0,y:0},f}catch(f){return console.error(f),{x:0,y:0}}},this.wheelChangePos=(g,u,c)=>{const{currentPos:f,imgNode:v}=this;if(!v){console.error("unable to load image");return}if(this.zoom===this.basicZoom&&u===-1)return;const p=St.wheelChangePos(v,g,u,f,{zoom:c||this.zoom,innerZoom:this.innerZoom,basicZoom:this.basicZoom,zoomMax:kt.max,rotate:this.rotate});if(!p)return;const{currentPos:b,ratio:y,zoom:P,imgInfo:A}=p;this.innerZoom=P,this.setZoom(P),this.setCurrentPos(b),this.currentPosStorage=b,this.imgInfo=A,kt.ratio=y,this.emit("renderZoom",P,f)},this.zoomChanged=(g,u=vt.Linear)=>{const c=St.zoomChanged(this.zoom,g,u);this.wheelChangePos(this.getGetCenterCoordinate(),c>this.zoom?1:-1,c),this.render(),this.renderBasicCanvas()},this.drawImg=()=>{!this.imgNode||m.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,d;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.forbidBasicResultRender=(a=t.forbidBasicResultRender)!=null?a:!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:pt[4],fillColor:pt[4],strokeWidth:2,opacity:1},this.attributeLockList=[],this.history=new qt,this.style=(l=t.style)!=null?l:{},this._imgAttribute=(h=t.imgAttribute)!=null?h:{},this.isHidden=!1,this.dragStatus=k.Wait,this.defaultAttribute=(d=t==null?void 0:t.defaultAttribute)!=null?d:"",this.forbidCursorLine=!!t.forbidCursorLine,this.lang=nt.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 We(this.container,200),this.coordUtils=new qr(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 Ae[this.style.color]}get defaultCursor(){return this.showDefaultCursor?"default":"none"}get dataList(){return[]}get hasMarkerConfig(){return this.config.markerConfigurable===!0&&this.config.markerList&&this.config.markerList.length>0}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}get pixelRatio(){var t;return et.getPixelRatio((t=this.canvas)==null?void 0:t.getContext("2d"))}init(){this.eventUnbinding(),this.initPosition(),this.eventBinding(),this.render(),this.renderBasicCanvas()}destroy(){this.destroyCanvas(),this.eventUnbinding()}createCanvas(t){var e,i;const s=document.createElement("canvas"),n=this.pixelRatio;s.width=t.width*n,s.height=t.height*n,s.style.width=`${t.width}px`,s.style.height=`${t.height}px`,s.style.left="0",s.style.top="0",s.style.zIndex="0",this.basicCanvas=s;const o=document.createElement("canvas");o.style.position="absolute",o.style.left="0",o.style.top="0",o.style.zIndex="10",o.style.width=`${t.width}px`,o.style.height=`${t.height}px`,o.width=t.width*n,o.height=t.height*n,this.container.hasChildNodes()?(this.container.insertBefore(o,this.container.childNodes[0]),this.container.insertBefore(s,this.container.childNodes[0])):(this.container.appendChild(s),this.container.appendChild(o)),this.canvas=o,this.container.style.cursor=this.defaultCursor,(e=this.ctx)==null||e.scale(n,n),(i=this.basicCtx)==null||i.scale(n,n)}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(Ge({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 w.Polygon:case w.Line:{if(t.pointList){const h=C.calcViewportBoundaries(t.pointList);a={x:h.left,y:h.top,width:h.right-h.left,height:h.bottom-h.top}}break}}const l=je.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=vr(Ge({},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||!Nt(e==null?void 0:e.x)||!Nt(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.emit("dragMove",{currentPos:i,zoom:this.zoom})}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||O.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===_.Alt&&t.preventDefault(),t.keyCode){case _.Space:this.isSpaceKey=!0;break;case _.Z:if(t.ctrlKey)return t.shiftKey?this.redo():this.undo(),!1;break}return!0}onKeyUp(t){switch(t.keyCode){case _.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>kt.min&&(n=-1),s<0&&this.zoom<kt.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;m.drawLine(this.canvas,{x:0,y:i},{x:1e4,y:i},{color:t}),m.drawLine(this.canvas,{x:e,y:0},{x:e,y:1e4},{color:t}),m.drawCircleWithFill(this.canvas,{x:e,y:i},1,{color:"white"})}setSize(t){var e;this.size=t,this.container.contains(this.canvas)&&(this.destroyCanvas(),this.createCanvas(t),this.eventUnbinding(),this.init(),((e=this.basicImgInfo)==null?void 0:e.valid)===!1&&this.renderInvalidPage())}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=x.jsonParser(t)}updateRotate(){if(this.dependToolName)return this.emit("messageInfo",F.getMessagesByLocale(D.NoRotateInDependence,this.lang)),!1;if(this.dataList.length>0)return this.emit("messageInfo",F.getMessagesByLocale(D.NoRotateNotice,this.lang)),!1;const t=C.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=T.getAttributeIndex(t,(i=e.attributeList)!=null?i:[])+1;return this.style.attributeColor[o]}const{color:s,toolColor:n}=this.style;return n?n[s]:Ne.toolColor["1"]}getLineColor(t=""){var e,i,s;if(((e=this.config)==null?void 0:e.attributeConfigurable)===!0){const a=T.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=lr.renderInvalidPage(this.container,this.size,this.lang))}renderBasicCanvas(){if(!this.basicCanvas)return;this.clearBasicCanvas(),this.drawImg();const t=3;if(!this.forbidBasicResultRender&&this.basicResult&&this.dependToolName)switch(this.dependToolName){case w.Rect:{m.drawRect(this.basicCanvas,L.changeRectByZoom(this.basicResult,this.zoom,this.currentPos),{color:"rgba(204,204,204,1.00)",thickness:t});break}case w.Polygon:{m.drawPolygonWithFillAndLine(this.basicCanvas,L.changePointListByZoom(this.basicResult.pointList,this.zoom,this.currentPos),{fillColor:"transparent",strokeColor:"rgba(204,204,204,1.00)",isClose:!0,thickness:t});break}case w.Line:{m.drawLineWithPointList(this.basicCanvas,L.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 br=Object.defineProperty,Ke=Object.getOwnPropertySymbols,xr=Object.prototype.hasOwnProperty,yr=Object.prototype.propertyIsEnumerable,Je=(r,t,e)=>t in r?br(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,qe=(r,t)=>{for(var e in t||(t={}))xr.call(t,e)&&Je(r,e,t[e]);if(Ke)for(var e of Ke(t))yr.call(t,e)&&Je(r,e,t[e]);return r};const Qe={x:8,y:26},mr=2;class Ir extends it{constructor(t){super(t);this.getHoverRectID=e=>{var i,s;const n=this.getCoordinateUnderZoom(e),o=(s=(i=this.resultList.find(a=>a.toolName===w.Rect))==null?void 0:i.result)!=null?s:[];if(o.length>0){const a=o.filter(l=>$.isInRect(n,l,mr,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===w.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=Ai(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=q.getStrokeAndFill(h,i.valid);let g=(n=(s=this.style)==null?void 0:s.width)!=null?n:2;this.hoverID.includes(i.id)?(g=4,m.drawPolygonWithFillAndLine(this.canvas,L.changePointListByZoom(i.pointList,this.zoom,this.currentPos),{fillColor:d.fill,strokeColor:d.stroke,pointColor:"white",thickness:g,lineCap:"round",isClose:!0,lineType:e==null?void 0:e.lineType})):m.drawPolygon(this.canvas,L.changePointListByZoom(i.pointList,this.zoom,this.currentPos),{color:d.fill,lineType:(o=this.config)==null?void 0:o.lineType,thickness:g,isClose:!0}),m.drawText(this.canvas,L.changePointByZoom(i.pointList[0],this.zoom,this.currentPos),(l=T.getAttributeShowText(i.attribute,(a=e==null?void 0:e.attributeList)!=null?a:[]))!=null?l:"",qe({color:d.stroke},Y));const u=L.changePointListByZoom(i.pointList||[],this.zoom,this.currentPos),c=u[u.length-1];m.drawText(this.canvas,{x:c.x+Qe.x,y:c.y+Qe.y},i==null?void 0:i.textAttribute,qe({color:d.stroke},Y))})}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=L.changeRectByZoom(i,this.zoom,this.currentPos);m.drawRect(this.canvas,o,{color:(i==null?void 0:i.valid)?n.valid.stroke:n.invalid.stroke,thickness:s}),this.fillID.includes(i.id)&&m.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)?mt.getTagNameList(n.result,e.inputList):mt.getTagnameListWithoutConfig(n.result)],[]);m.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 w.Rect:this.drawRect(e.result,x.jsonParser(e.config));break;case w.Polygon:this.drawPolygon(e.result,x.jsonParser(e.config));break;case w.Tag:this.drawTag(e.result,x.jsonParser(e.config));break}})}exportData(){return[[],{}]}}const Qt=30,te=164;class Ot{constructor(t){this.textKeyDown=l=>{switch(l.stopPropagation(),l.keyCode){case _.Enter:this.submitTextarea(),this.appendToContainer();break}};const{container:e,icon:i,color:s,getCurrentSelectedData:n,updateSelectedTextAttribute:o}=t,a=t.width||te;this.container=e,this.getCurrentSelectedData=n,this.updateSelectedTextAttribute=o,this._textAttributeDOM=this.initTextAttributeDOM(),this._iconDOM=this.initIconDOM(i),this._textDOM=this.initTextDOM(a,ge),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",`
|
|
24
24
|
width: ${Math.max(t,Qt)}px;
|
|
25
25
|
line-height: ${e}px;
|
|
26
26
|
word-break: break-all;
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
left:${s}px;
|
|
57
57
|
top: ${n}px;
|
|
58
58
|
color: ${o};
|
|
59
|
-
`),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 wr=Object.defineProperty,Lr=Object.defineProperties,Pr=Object.getOwnPropertyDescriptors,ti=Object.getOwnPropertySymbols,Cr=Object.prototype.hasOwnProperty,Dr=Object.prototype.propertyIsEnumerable,ei=(r,t,e)=>t in r?wr(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,X=(r,t)=>{for(var e in t||(t={}))Cr.call(t,e)&&ei(r,e,t[e]);if(ti)for(var e of ti(t))Dr.call(t,e)&&ei(r,e,t[e]);return r},ht=(r,t)=>Lr(r,Pr(t));const ii=164;class si extends it{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(T.textChange(e,this.selectedID,this.polygonList)),this.emit("selectedChange"),this.render())},this.config=x.jsonParser(t.config),this.drawingPointList=[],this.polygonList=[],this.hoverPointIndex=-1,this.hoverEdgeIndex=-1,this.drawingHistory=new qt,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 H.getPolygonByID(this.polygonList,this.selectedID)}get polygonListUnderZoom(){return this.polygonList.map(t=>ht(X({},t),{pointList:L.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]=x.getRenderResultList(this.polygonList,x.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);return t=e,this.isHidden&&(t=[]),i&&t.push(i),t}get currentPageResult(){const[t]=x.getRenderResultList(this.polygonList,x.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?X(X({},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",`${F.getMessagesByLocale(D.UpperLimitErrorNotice,this.lang)}${e}`);return}this.setSelectedID("");const s=this.getCoordinateUnderZoom(t),n=L.changeDrawOutsideTarget(s,{x:0,y:0},this.imgInfo,this.config.drawOutsideTarget,this.basicResult,this.zoom);if(L.returnClosePointIndex(n,L.changePointListByZoom(this.drawingPointList,this.zoom))===0){this.addDrawingPointToPolygonList();return}const{dropFoot:a}=H.getClosestPoint(n,this.polygonListUnderZoom,this.config.lineType,Dt),l=L.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=k.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?ht(X({},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=x.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=K(8,62);let n={id:s,sourceID:e,valid:!this.isCtrl,textAttribute:"",pointList:this.drawingPointList,attribute:this.defaultAttribute,order:x.getMaxOrder(i.filter(o=>x.isSameSourceID(o.sourceID,e)))+1};if(this.config.textConfigurable){let o="";o=T.getTextAttribute(this.polygonList.filter(a=>x.isSameSourceID(a.sourceID,e)),this.config.textCheckType),n=ht(X({},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=>ht(X({},n),{pointList:L.changePointListByZoom(n.pointList,this.zoom)}));return H.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=L.changePointListByZoom(i.pointList,this.zoom);return H.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=L.changePointListByZoom(e.pointList,this.zoom);return L.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",`${F.getMessagesByLocale(D.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=j.ascend;t.shiftKey&&(e=j.descend);const[i,s]=x.getRenderResultList(this.polygonList,x.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);let n=[...i];s&&(n=[...n,s]);const o=et.getViewPort(this.canvas,this.currentPos,this.zoom),a=n.map(h=>{var u,g,c,d;return ht(X({},h),{x:(g=(u=h.pointList[0])==null?void 0:u.x)!=null?g:0,y:(d=(c=h.pointList[0])==null?void 0:c.y)!=null?d:0})}).filter(h=>et.inViewPort({x:h.x,y:h.y},o)),l=x.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(!x.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;const{keyCode:e}=t;switch(e){case _.Space:this.spaceKeydown();break;case _.Esc:this.drawingPointList=[],this.editPolygonID="";break;case _.F:this.selectedID&&this.setPolygonValidAndRender(this.selectedID);break;case _.Z:this.setIsHidden(!this.isHidden),this.render();break;case _.Delete:this.deletePolygon(this.selectedID),this.render();break;case _.Ctrl:this.isCtrl=!0;break;case _.Alt:this.isAlt===!1&&(t.preventDefault(),this.isAlt=!0,this.render());break;case _.Tab:{this.onTabKeyDown(t);break}default:{if(this.config.attributeConfigurable){const i=T.getAttributeByKeycode(e,this.config.attributeList);i!==void 0&&this.setDefaultAttribute(i)}break}}}onKeyUp(t){switch(super.onKeyUp(t),t.keyCode){case _.Ctrl:this.isCtrl=!1;break;case _.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}=H.getClosestPoint(e,this.polygonListUnderZoom,this.config.lineType,Dt);if(!s)return;const{upperLimitPointNum:n}=this.config;if(n&&i.pointList.length>=n){this.emit("messageInfo",`${F.getMessagesByLocale(D.UpperLimitErrorNotice,this.lang)}${n}`),this.clearPolygonDrag();return}i==null||i.pointList.splice(this.hoverEdgeIndex+1,0,L.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=tt.Plane;this.dragStatus=k.Start;const l=this.getHoverPointIndex(t),h=this.getHoverEdgeIndex(t);return l>-1?(a=tt.Point,o=[l]):h>-1&&this.hoverEdgeIndex>-1&&(a=tt.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=k.Move,o){case tt.Plane:i=i.map((g,c)=>ht(X({},g),{x:s[c].x+h.x,y:s[c].y+h.y}));break;case tt.Point:case tt.Line:i=i.map((g,c)=>a&&a.includes(c)?ht(X({},g),{x:s[c].x+h.x,y:s[c].y+h.y}):g);break}if(this.config.drawOutsideTarget===!1&&this.imgInfo){if(this.dependToolName&&this.basicCanvas&&this.basicResult){let p=!1;switch(this.dependToolName){case w.Rect:{p=i.filter(b=>!$.isInRect(b,this.basicResult)).length>0;break}case w.Polygon:{p=H.isPointListOutSidePolygon(i,this.basicResult.pointList,this.config.lineType);break}}if(p)return}const{left:g,top:c,right:d,bottom:f}=C.calcViewportBoundaries(L.changePointListByZoom(i,this.zoom)),v=1e-5;if(g<0||c<0||d>this.imgInfo.width+v||f>this.imgInfo.height+v)return}const u=this.polygonList.map(g=>g.id===this.selectedID?ht(X({},g),{pointList:i}):g);this.setPolygonList(u),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===k.Move){this.dragInfo=void 0,this.dragStatus=k.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===k.Start&&(this.dragInfo=void 0,this.dragStatus=k.Wait)}exportData(){const{polygonList:t}=this;return[t,this.basicImgInfo]}getTextIconSvg(t=""){return T.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:ii,textAttribute:t.textAttribute,color:i}}updateSelectedTextAttribute(t){if(this._textAttributInstance&&t&&this.selectedID){let e=t;T.textAttributeValidate(this.config.textCheckType,"",e)===!1&&(this.emit("messageError",T.getErrorNotice(this.config.textCheckType,this.lang)),e=""),this.setPolygonList(T.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=ii,u=L.getOffsetCoordinate({x:a,y:l},this.currentPos,this.zoom),g=this.getColor(s),c=n?g==null?void 0:g.valid.stroke:g==null?void 0:g.invalid.stroke;this._textAttributInstance||(this._textAttributInstance=new Ot({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:u.x,top:u.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 d,f,v,p,b;if([this.selectedID,this.editPolygonID].includes(c.id))return;const{textAttribute:y,attribute:P}=c,A=this.getColor(P),I=q.getStrokeAndFill(A,c.valid),R=L.changePointListByZoom(c.pointList||[],this.zoom,this.currentPos);m.drawPolygonWithFillAndLine(this.canvas,R,{fillColor:I.fill,strokeColor:I.stroke,pointColor:"white",thickness:(f=(d=this.style)==null?void 0:d.width)!=null?f:2,lineCap:"round",isClose:!0,lineType:(v=this.config)==null?void 0:v.lineType});let E=`${(p=T.getAttributeShowText(P,this.config.attributeList))!=null?p:""}`;((b=this.config)==null?void 0:b.isShowOrder)&&(c==null?void 0:c.order)>0&&(E=`${c.order} ${E}`),m.drawText(this.canvas,R[0],E,X({color:I.stroke},Y));const G=R[R.length-1];m.drawText(this.canvas,{x:G.x+ut.x,y:G.y+ut.y},y,X({color:I.stroke},Y))})),this.hoverID&&this.hoverID!==this.editPolygonID){const c=this.polygonList.find(d=>d.id===this.hoverID&&d.id!==this.selectedID);if(c){let d="";const f=this.getColor(c.attribute);c.valid?d=f.validHover.fill:d=q.getStrokeAndFill(f,!1,{isHover:!0}).fill,m.drawPolygonWithFill(this.canvas,L.changePointListByZoom(c.pointList,this.zoom,this.currentPos),{color:d,lineType:(e=this.config)==null?void 0:e.lineType})}}if(this.selectedID){const c=this.selectedPolygon;if(c){const d=this.getColor(c.attribute),f=q.getStrokeAndFill(d,c.valid,{isSelected:!0});m.drawSelectedPolygonWithFillAndLine(this.canvas,L.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=T.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}`),m.drawText(this.canvas,L.changePointByZoom(c.pointList[0],this.zoom,this.currentPos),v,X({color:f.stroke},Y)),this.renderTextAttribute()}}const u=this.getColor(this.defaultAttribute),g=q.getStrokeAndFill(u,!this.isCtrl);if(((o=this.drawingPointList)==null?void 0:o.length)>0){const c=[...this.drawingPointList];let d=L.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);if(((a=this.config)==null?void 0:a.edgeAdsorption)&&this.isAlt===!1){const{dropFoot:f}=H.getClosestPoint(d,this.polygonList,(l=this.config)==null?void 0:l.lineType,Dt/this.zoom);f&&(d=f)}c.push(d),m.drawSelectedPolygonWithFillAndLine(this.canvas,L.changePointListByZoom(c,this.zoom,this.currentPos),{fillColor:g.fill,strokeColor:g.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 d=q.getStrokeAndFill(u,c.valid,{isSelected:!0}),f=c==null?void 0:c.pointList[this.hoverPointIndex];if(f){const{x:v,y:p}=L.changePointByZoom(f,this.zoom,this.currentPos);m.drawCircleWithFill(this.canvas,{x:v,y:p},5,{color:d.fill})}}if(this.hoverEdgeIndex>-1&&this.selectedID){const c=this.selectedPolygon;if(!c)return;const d=q.getStrokeAndFill(u,c.valid,{isSelected:!0});m.drawLineWithPointList(this.canvas,L.changePointListByZoom(c.pointList,this.zoom,this.currentPos),{color:d.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 ri extends it{constructor(t){super(t);this.getInitResultList=(e,i)=>!(e===0||e===void 0)&&i.length===0?[]:mt.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 u=(n=o[e])==null?void 0:n.isMulti,g=this.tagResult.filter(c=>{const d=`${c.sourceID}`;return x.isSameSourceID(d,this.sourceID)})[0];if(g){let c=0;const{result:d}=g;g.sourceID===0&&(g.sourceID="0");for(const f in g.result)if(f===o[e].value){if(c++,u===!0){const v=d[f].split(";").filter(b=>b!==""),p=v.indexOf(h);p===-1?v.push(h):v.splice(p,1),h=v.join(";")}h===""?Object.keys(d).length===1?this.tagResult=this.tagResult.filter(v=>{const p=`${v.sourceID}`;return x.isDifferSourceID(p,this.sourceID)}):Object.keys(d).length>1&&delete d[f]:d[f]=h}c===0&&Object.assign(g.result,{[l]:h})}else this.tagResult=[{sourceID:this.sourceID,id:K(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=x.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 x.isSameSourceID(i,this.sourceID)})[0])!=null?t:{}}get sourceID(){return x.getSourceID(this.basicResult)}onKeyDown(t){if(!x.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=mt.getTagNameList((i=(e=this.currentTagResult)==null?void 0:e.result)!=null?i:{},this.config.inputList);a.innerHTML=(s=l.reduce((h,u)=>`${h}${u.keyName}: ${u.value.join(" \u3001 ")}
|
|
59
|
+
`),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 wr=Object.defineProperty,Lr=Object.defineProperties,Pr=Object.getOwnPropertyDescriptors,ti=Object.getOwnPropertySymbols,Cr=Object.prototype.hasOwnProperty,Dr=Object.prototype.propertyIsEnumerable,ei=(r,t,e)=>t in r?wr(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,X=(r,t)=>{for(var e in t||(t={}))Cr.call(t,e)&&ei(r,e,t[e]);if(ti)for(var e of ti(t))Dr.call(t,e)&&ei(r,e,t[e]);return r},ht=(r,t)=>Lr(r,Pr(t));const ii=164;class si extends it{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(T.textChange(e,this.selectedID,this.polygonList)),this.emit("selectedChange"),this.render())},this.config=x.jsonParser(t.config),this.drawingPointList=[],this.polygonList=[],this.hoverPointIndex=-1,this.hoverEdgeIndex=-1,this.drawingHistory=new qt,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 H.getPolygonByID(this.polygonList,this.selectedID)}get polygonListUnderZoom(){return this.polygonList.map(t=>ht(X({},t),{pointList:L.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]=x.getRenderResultList(this.polygonList,x.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);return t=e,this.isHidden&&(t=[]),i&&t.push(i),t}get currentPageResult(){const[t]=x.getRenderResultList(this.polygonList,x.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?X(X({},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",`${F.getMessagesByLocale(D.UpperLimitErrorNotice,this.lang)}${e}`);return}this.setSelectedID("");const s=this.getCoordinateUnderZoom(t),n=L.changeDrawOutsideTarget(s,{x:0,y:0},this.imgInfo,this.config.drawOutsideTarget,this.basicResult,this.zoom);if(L.returnClosePointIndex(n,L.changePointListByZoom(this.drawingPointList,this.zoom))===0){this.addDrawingPointToPolygonList();return}const{dropFoot:a}=H.getClosestPoint(n,this.polygonListUnderZoom,this.config.lineType,Dt),l=L.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=k.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?ht(X({},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=x.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=K(8,62);let n={id:s,sourceID:e,valid:!this.isCtrl,textAttribute:"",pointList:this.drawingPointList,attribute:this.defaultAttribute,order:x.getMaxOrder(i.filter(o=>x.isSameSourceID(o.sourceID,e)))+1};if(this.config.textConfigurable){let o="";o=T.getTextAttribute(this.polygonList.filter(a=>x.isSameSourceID(a.sourceID,e)),this.config.textCheckType),n=ht(X({},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=>ht(X({},n),{pointList:L.changePointListByZoom(n.pointList,this.zoom)}));return H.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=L.changePointListByZoom(i.pointList,this.zoom);return H.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=L.changePointListByZoom(e.pointList,this.zoom);return L.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",`${F.getMessagesByLocale(D.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=j.ascend;t.shiftKey&&(e=j.descend);const[i,s]=x.getRenderResultList(this.polygonList,x.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);let n=[...i];s&&(n=[...n,s]);const o=et.getViewPort(this.canvas,this.currentPos,this.zoom),a=n.map(h=>{var d,g,u,c;return ht(X({},h),{x:(g=(d=h.pointList[0])==null?void 0:d.x)!=null?g:0,y:(c=(u=h.pointList[0])==null?void 0:u.y)!=null?c:0})}).filter(h=>et.inViewPort({x:h.x,y:h.y},o)),l=x.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(!x.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;const{keyCode:e}=t;switch(e){case _.Space:this.spaceKeydown();break;case _.Esc:this.drawingPointList=[],this.editPolygonID="";break;case _.F:this.selectedID&&this.setPolygonValidAndRender(this.selectedID);break;case _.Z:this.setIsHidden(!this.isHidden),this.render();break;case _.Delete:this.deletePolygon(this.selectedID),this.render();break;case _.Ctrl:this.isCtrl=!0;break;case _.Alt:this.isAlt===!1&&(t.preventDefault(),this.isAlt=!0,this.render());break;case _.Tab:{this.onTabKeyDown(t);break}default:{if(this.config.attributeConfigurable){const i=T.getAttributeByKeycode(e,this.config.attributeList);i!==void 0&&this.setDefaultAttribute(i)}break}}}onKeyUp(t){switch(super.onKeyUp(t),t.keyCode){case _.Ctrl:this.isCtrl=!1;break;case _.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}=H.getClosestPoint(e,this.polygonListUnderZoom,this.config.lineType,Dt);if(!s)return;const{upperLimitPointNum:n}=this.config;if(n&&i.pointList.length>=n){this.emit("messageInfo",`${F.getMessagesByLocale(D.UpperLimitErrorNotice,this.lang)}${n}`),this.clearPolygonDrag();return}i==null||i.pointList.splice(this.hoverEdgeIndex+1,0,L.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=tt.Plane;this.dragStatus=k.Start;const l=this.getHoverPointIndex(t),h=this.getHoverEdgeIndex(t);return l>-1?(a=tt.Point,o=[l]):h>-1&&this.hoverEdgeIndex>-1&&(a=tt.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=k.Move,o){case tt.Plane:i=i.map((g,u)=>ht(X({},g),{x:s[u].x+h.x,y:s[u].y+h.y}));break;case tt.Point:case tt.Line:i=i.map((g,u)=>a&&a.includes(u)?ht(X({},g),{x:s[u].x+h.x,y:s[u].y+h.y}):g);break}if(this.config.drawOutsideTarget===!1&&this.imgInfo){if(this.dependToolName&&this.basicCanvas&&this.basicResult){let p=!1;switch(this.dependToolName){case w.Rect:{p=i.filter(b=>!$.isInRect(b,this.basicResult)).length>0;break}case w.Polygon:{p=H.isPointListOutSidePolygon(i,this.basicResult.pointList,this.config.lineType);break}}if(p)return}const{left:g,top:u,right:c,bottom:f}=C.calcViewportBoundaries(L.changePointListByZoom(i,this.zoom)),v=1e-5;if(g<0||u<0||c>this.imgInfo.width+v||f>this.imgInfo.height+v)return}const d=this.polygonList.map(g=>g.id===this.selectedID?ht(X({},g),{pointList:i}):g);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===k.Move){this.dragInfo=void 0,this.dragStatus=k.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===k.Start&&(this.dragInfo=void 0,this.dragStatus=k.Wait)}exportData(){const{polygonList:t}=this;return[t,this.basicImgInfo]}getTextIconSvg(t=""){return T.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:ii,textAttribute:t.textAttribute,color:i}}updateSelectedTextAttribute(t){if(this._textAttributInstance&&t&&this.selectedID){let e=t;T.textAttributeValidate(this.config.textCheckType,"",e)===!1&&(this.emit("messageError",T.getErrorNotice(this.config.textCheckType,this.lang)),e=""),this.setPolygonList(T.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=ii,d=L.getOffsetCoordinate({x:a,y:l},this.currentPos,this.zoom),g=this.getColor(s),u=n?g==null?void 0:g.valid.stroke:g==null?void 0:g.invalid.stroke;this._textAttributInstance||(this._textAttributInstance=new Ot({width:h,container:this.container,icon:this.getTextIconSvg(s),color:u,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:u,width:h})}renderPolygon(){var t,e,i,s,n,o,a,l,h;if(this.isHidden===!1&&((t=this.polygonList)==null||t.forEach(u=>{var c,f,v,p,b;if([this.selectedID,this.editPolygonID].includes(u.id))return;const{textAttribute:y,attribute:P}=u,A=this.getColor(P),I=q.getStrokeAndFill(A,u.valid),R=L.changePointListByZoom(u.pointList||[],this.zoom,this.currentPos);m.drawPolygonWithFillAndLine(this.canvas,R,{fillColor:I.fill,strokeColor:I.stroke,pointColor:"white",thickness:(f=(c=this.style)==null?void 0:c.width)!=null?f:2,lineCap:"round",isClose:!0,lineType:(v=this.config)==null?void 0:v.lineType});let E=`${(p=T.getAttributeShowText(P,this.config.attributeList))!=null?p:""}`;((b=this.config)==null?void 0:b.isShowOrder)&&(u==null?void 0:u.order)>0&&(E=`${u.order} ${E}`),m.drawText(this.canvas,R[0],E,X({color:I.stroke},Y));const G=R[R.length-1];m.drawText(this.canvas,{x:G.x+ut.x,y:G.y+ut.y},y,X({color:I.stroke},Y))})),this.hoverID&&this.hoverID!==this.editPolygonID){const u=this.polygonList.find(c=>c.id===this.hoverID&&c.id!==this.selectedID);if(u){let c="";const f=this.getColor(u.attribute);u.valid?c=f.validHover.fill:c=q.getStrokeAndFill(f,!1,{isHover:!0}).fill,m.drawPolygonWithFill(this.canvas,L.changePointListByZoom(u.pointList,this.zoom,this.currentPos),{color:c,lineType:(e=this.config)==null?void 0:e.lineType})}}if(this.selectedID){const u=this.selectedPolygon;if(u){const c=this.getColor(u.attribute),f=q.getStrokeAndFill(c,u.valid,{isSelected:!0});m.drawSelectedPolygonWithFillAndLine(this.canvas,L.changePointListByZoom(u.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=T.getAttributeShowText(u.attribute,this.config.attributeList))!=null?s:""}`;((n=this.config)==null?void 0:n.isShowOrder)&&(u==null?void 0:u.order)>0&&(v=`${u.order} ${v}`),m.drawText(this.canvas,L.changePointByZoom(u.pointList[0],this.zoom,this.currentPos),v,X({color:f.stroke},Y)),this.renderTextAttribute()}}const d=this.getColor(this.defaultAttribute),g=q.getStrokeAndFill(d,!this.isCtrl);if(((o=this.drawingPointList)==null?void 0:o.length)>0){const u=[...this.drawingPointList];let c=L.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);if(((a=this.config)==null?void 0:a.edgeAdsorption)&&this.isAlt===!1){const{dropFoot:f}=H.getClosestPoint(c,this.polygonList,(l=this.config)==null?void 0:l.lineType,Dt/this.zoom);f&&(c=f)}u.push(c),m.drawSelectedPolygonWithFillAndLine(this.canvas,L.changePointListByZoom(u,this.zoom,this.currentPos),{fillColor:g.fill,strokeColor:g.stroke,pointColor:"white",thickness:2,lineCap:"round",isClose:!1,lineType:this.config.lineType})}if(this.hoverPointIndex>-1&&this.selectedID){const u=this.selectedPolygon;if(!u)return;const c=q.getStrokeAndFill(d,u.valid,{isSelected:!0}),f=u==null?void 0:u.pointList[this.hoverPointIndex];if(f){const{x:v,y:p}=L.changePointByZoom(f,this.zoom,this.currentPos);m.drawCircleWithFill(this.canvas,{x:v,y:p},5,{color:c.fill})}}if(this.hoverEdgeIndex>-1&&this.selectedID){const u=this.selectedPolygon;if(!u)return;const c=q.getStrokeAndFill(d,u.valid,{isSelected:!0});m.drawLineWithPointList(this.canvas,L.changePointListByZoom(u.pointList,this.zoom,this.currentPos),{color:c.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 ri extends it{constructor(t){super(t);this.getInitResultList=(e,i)=>!(e===0||e===void 0)&&i.length===0?[]:mt.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,g=this.tagResult.filter(u=>{const c=`${u.sourceID}`;return x.isSameSourceID(c,this.sourceID)})[0];if(g){let u=0;const{result:c}=g;g.sourceID===0&&(g.sourceID="0");for(const f in g.result)if(f===o[e].value){if(u++,d===!0){const v=c[f].split(";").filter(b=>b!==""),p=v.indexOf(h);p===-1?v.push(h):v.splice(p,1),h=v.join(";")}h===""?Object.keys(c).length===1?this.tagResult=this.tagResult.filter(v=>{const p=`${v.sourceID}`;return x.isDifferSourceID(p,this.sourceID)}):Object.keys(c).length>1&&delete c[f]:c[f]=h}u===0&&Object.assign(g.result,{[l]:h})}else this.tagResult=[{sourceID:this.sourceID,id:K(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=x.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 x.isSameSourceID(i,this.sourceID)})[0])!=null?t:{}}get sourceID(){return x.getSourceID(this.basicResult)}onKeyDown(t){if(!x.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=mt.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 ")}
|
|
60
60
|
`,""))!=null?s:"",a.setAttribute("id","tagToolTag"),a.setAttribute("style",`
|
|
61
61
|
position: absolute;
|
|
62
62
|
top: 0;
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
background: rgba(102, 111, 255, 1);
|
|
75
75
|
opacity: 0.6;
|
|
76
76
|
clear: both;
|
|
77
|
-
`),(o=(n=this.canvas)==null?void 0:n.parentNode)==null||o.appendChild(a)}render(){this.renderTag(),super.render(),this.emit("render")}exportData(){let{tagResult:t}=this;return this.isImgError&&(t=[]),[t,this.basicImgInfo]}}var _r=Object.defineProperty,Ar=Object.defineProperties,Rr=Object.getOwnPropertyDescriptors,ni=Object.getOwnPropertySymbols,Tr=Object.prototype.hasOwnProperty,Sr=Object.prototype.propertyIsEnumerable,oi=(r,t,e)=>t in r?_r(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ee=(r,t)=>{for(var e in t||(t={}))Tr.call(t,e)&&oi(r,e,t[e]);if(ni)for(var e of ni(t))Sr.call(t,e)&&oi(r,e,t[e]);return r},ie=(r,t)=>Ar(r,Rr(t)),ai;(function(r){r[r.Create=0]="Create",r[r.Active=1]="Active",r[r.None=2]="None"})(ai||(ai={}));const st=16,Mt={x:0,y:20},se=3,Et=5,kr=2;class li extends it{constructor(t){super(t);this.drawActivatedLine=(e,i,s)=>{const n=N.cloneDeep(this.activeLine);if(!n||n.length===0)return;const o=this.isActiveLineValid();let a;const l=this.selectedID?this.lineList.find(u=>u.id===this.selectedID):void 0;l?a=l.order:a=this.nextOrder();const h=this.getLineColorByAttribute({attribute:this.defaultAttribute,valid:!!o});n.map(u=>Object.assign(u,this.coordUtils.getRenderCoord(u))),this.updateActiveArea(),this.drawLine(n,e,h,!0,!0),this.drawLineNumber(n[0],a,h,"",this.defaultAttribute,o),e&&this.isCreate&&this.arc(e,se,h),this.cursor&&!this.selectedPoint&&!s&&!this.isShift&&this.arc(this.cursor,Et,h)},this.drawHoverPoint=e=>{if(!this.isMousedown&&e&&this.isLineSelected){const i=this.getPointList(this.activeLine),s=this.activeLine.find(o=>O.calcDistance(this.coordUtils.getRenderCoord(o),e)<=Et);let n;!s&&this.activeLine&&(n=this.findNearestPoint(i,e)),this.hoverPointID=s?s.id:void 0,this.cursor=s||n==null?void 0:n.point}},this.lineList=[],this.activeLine=[],this.coordsInsideActiveArea=!1,this.hoverLineSegmentIndex=-1,this.isShift=!1,this.isReference=!1,this.drawCurveLine=(e,i,s,n=!0,o=!1,a)=>{const l=_t(i,st);e.save(),e.lineCap="round",e.lineJoin="round",e.strokeStyle=s.color,n&&(e.lineWidth=s.lineWidth),o&&O.setReferenceCtx(e),i.forEach(({specialEdge:h},u)=>{const g=l.splice(0,st+1);e.save(),e.beginPath(),a===u&&(e.lineWidth=4),g.forEach(({x:c,y:d},f)=>{const v=f>0?"lineTo":"moveTo";h&&O.setSpecialEdgeStyle(e),e[v](c,d)}),e.stroke(),e.restore()}),e.restore()},this.drawLine=(e,i,s,n=!1,o=!1)=>{const a=i?e.concat(i):e,l={color:s,lineWidth:o?1:this.lineStyle.lineWidth};this.isCurve?O.drawCurveLine(this.ctx,a,l,!n,this.isReference,o?this.hoverLineSegmentIndex:-1):this.drawStraightLine(a,l,o),n&&e.forEach(h=>{var u,g;const c=h.id,d=c&&[this.hoverPointID,(u=this.selectedPoint)==null?void 0:u.id].includes(c)?Et:se;this.arc(h,d,s),[this.hoverPointID,(g=this.selectedPoint)==null?void 0:g.id].includes(c)||this.arc(h,kr,"white")})},this.drawStraightLine=(e,i,s=!1)=>{const{ctx:n}=this;n&&(n.save(),n.lineCap="round",n.lineJoin="round",n.strokeStyle=i.color,n.lineWidth=i.lineWidth,this.isReference&&O.setReferenceCtx(n),e.forEach((o,a)=>{if(n.beginPath(),a>0){const l=e[a-1];n.save(),(l==null?void 0:l.specialEdge)&&O.setSpecialEdgeStyle(n),s&&this.hoverLineSegmentIndex+1===a&&(n.lineWidth=4),n.moveTo(l.x,l.y),n.lineTo(o.x,o.y),n.stroke(),n.restore()}}),n.restore())},this.drawLines=()=>{try{const e=N.cloneDeep(this.attributeFilteredLines);if(this.isHidden)return;e.forEach(i=>{if(i.id!==this.selectedID&&i.pointList){i.pointList.map(l=>Object.assign(l,this.coordUtils.getRenderCoord(l)));const{order:s,label:n}=i,o=s,a=i&&this.getLineColorByAttribute(i);this.drawLine(i.pointList,void 0,a,!1),this.drawLineNumber(i.pointList[0],o,a,n,i.attribute,i.valid),i.id!==this.textEditingID&&this.drawLineTextAttribute(i.pointList[1],a,i==null?void 0:i.textAttribute)}})}catch(e){console.error(e,"\u7EBF\u6761\u5DE5\u5177\u6570\u636E\u89E3\u6790\u9519\u8BEF"),this.lineList=[],this.clearCanvas()}},this.render=e=>{super.render(),this.drawLines(),this.drawActivatedLine(e,void 0,!0),this.renderTextAttribute(),this.renderCursorLine(this.getLineColor(this.defaultAttribute))},this.moveLineInPolygon=(e,i)=>{var s;if(!Array.isArray(this.activeLine))return!1;((s=this.activeLine)==null?void 0:s.every(o=>this.isInBasicPolygon({x:o.x+e,y:o.y+i})))&&(this.lineDragging=!0,this.moveActiveArea(e,i))},this.moveLineInRectRange=(e,i,s,n)=>{if(this.activeArea===void 0)return;const{top:o,left:a,right:l,bottom:h}=this.activeArea,u=[a,l].map(p=>N.isNumber(p)?p+e:0),g=[o,h].map(p=>N.isNumber(p)?p+i:0),c=a>=0&&l&&C.isInRange(u,s),d=o>=0&&h&&C.isInRange(g,n),f=c?e:0,v=d?i:0;this.lineDragging=!0,this.moveActiveArea(f,v)},this.onRightClick=e=>{if(this.cursor=void 0,this.isCreate){if(this.isLinePointsNotEnough())return;this.stopLineCreating(!0);return}this.setActiveArea(this.getCoordinate(e),!0),this.emit("contextmenu")},this.updateSelectedAttributeAfterHistoryChanged=()=>{if(this.selectedID){const e=this.lineList.find(s=>s.id===this.selectedID),i=e==null?void 0:e.attribute;typeof i=="string"&&(this.defaultAttribute=i,this.updateAttribute(i),this.render())}},this.onLeftClick=e=>{const i=this.getCoordinate(e),{lineDragging:s}=this;if(this.lineDragging=!1,this.isSpaceKey)return;if(this.isNone&&e.ctrlKey){const o=this.findHoverLine(i);o&&this.setInvalidLine(o.id);return}if(this.isLinePointsExceed())return;const n=this.getNextPoint(e,i);if(this.isCreate||this.isNone){this.setCreatStatusAndAddPoint(n);return}if(this.isActive){if(s)return;if(this.isMouseCoordOutsideActiveArea()){this.setNoneStatus(!1),this.setCreatStatusAndAddPoint(n);return}if(e.shiftKey){this.updateLineSegmentSpecial(i);return}if(this.coordsInsideActiveArea&&e.ctrlKey){this.setInvalidLine(this.selectedID);return}this.addLinePointToActiveLine()}},this.onDblclick=()=>{},this.onKeyUp=e=>{if(super.onKeyUp(e),this.isShift=!1,this.hoverLineSegmentIndex=-1,e.keyCode===_.Esc){this.stopLineCreating(!1);return}if(this.isActive){if(e.keyCode===_.Delete){this.deleteLine();return}if(e.keyCode===_.F){this.setInvalidLine(this.selectedID);return}if(e.keyCode===_.Space){this.continueToEdit();return}}this.keyboardEventWhileLineCreating(e)},this.onRightDblClick=e=>{super.onRightDblClick(e);const i=this.getCoordinate(e);if(this.isActive){const s=this.findHoveredPoint(i);if(s){this.deleteSelectedLinePoint(s.id);return}this.deleteSelectedLine(i)}},this.setReference=e=>{this.isReference=e},this.pointsWithinRange=e=>!(this.lowerLimitPointNum&&e<this.lowerLimitPointNum||this.upperLimitPointNum&&e>this.upperLimitPointNum),this.setLineList=e=>{const i=e.length!==this.lineListLen;this.lineList=e,i&&this.emit("updatePageNumber")},this.textChange=e=>{this.config.textConfigurable===!1||!this.selectedID||(this.updateSelectedTextAttribute(e),this.emit("selectedChange"))},this.status=2,this.isMousedown=!1,this.lineDragging=!1,this.isLineValid=!0,this.setConfig(t.config),this.prevAxis={x:0,y:0},this.textEditingID="",this.updateSelectedTextAttribute=this.updateSelectedTextAttribute.bind(this),this.getCurrentSelectedData=this.getCurrentSelectedData.bind(this),this.actionsHistory=new qt,this.dependToolConfig={lineType:S.Line}}get isLineSelected(){return this.selectedID&&this.activeLine}get selectedLinePoints(){return this.activeLine?this.getPointList(this.activeLine):[]}get isCreate(){return this.status===0}get isActive(){return this.status===1}get isNone(){return this.status===2}get isCurve(){return this.config.lineType===S.Curve}get isMultipleColor(){return this.config.lineColor===Pt.MultiColor}get imageSize(){return this.rotate%180==0?this.basicImgInfo:{width:this.basicImgInfo.height,height:this.basicImgInfo.width}}get lineListLen(){return this.lineList.length}get edgeAdsorptionEnabled(){return this.edgeAdsorption&&!this.isCurve&&this.lineListLen>0}get attributeConfigurable(){return this.config.attributeConfigurable}get isTextConfigurable(){return this.config.textConfigurable}get isDependPolygon(){return this.dependToolName===w.Polygon}get isDependRect(){return this.dependToolName===w.Rect}get isCurrentAttributeLocked(){return this.attributeLockList.includes(this.defaultAttribute)}get attributeFilteredLines(){return this.attributeLockList.length>0?this.lineList.filter(t=>this.attributeLockList.includes((t==null?void 0:t.attribute)||"")):this.lineList}get enableOutOfTarget(){return this.config.enableOutOfTarget}get showOrder(){return this.config.showOrder}get edgeAdsorption(){return this.config.edgeAdsorption}get attributeList(){return this.config.attributeList}get lowerLimitPointNum(){return this.config.lowerLimitPointNum}get upperLimitPointNum(){return this.config.upperLimitPointNum}get textCheckType(){return this.config.textCheckType}get customFormat(){return this.config.customFormat}get dataList(){return this.lineList}get hasActiveLine(){return this.activeLine&&this.activeLine.length>0}get viewPortLines(){const t=et.getViewPort(this.canvas,this.currentPos,this.zoom);return this.isHidden?[]:this.attributeFilteredLines.filter(e=>{var i;return(i=e==null?void 0:e.pointList)==null?void 0:i.some(s=>et.inViewPort(s,t))})}get lineStyle(){return{lineWidth:this.style.width,color:this.getLineColor(this.defaultAttribute),opacity:this.style.opacity}}get selectedText(){var t,e;return(e=(t=this.lineList.find(i=>i.id===this.selectedID))==null?void 0:t.textAttribute)!=null?e:""}get currentPageResult(){return this.lineList}updateStatus(t,e=!1){if(t!==this.status){if(e){let i="";this.textCheckType===V.Order&&this.isTextConfigurable&&(i=T.getTextAttribute(this.lineList,this.textCheckType)),this.emit("updateText",i)}this.status=t,this.lineStatusChanged()}}isInBasicPolygon(t){var e,i;return be(t,((e=this.basicResult)==null?void 0:e.pointList)||[],(i=this.dependToolConfig)==null?void 0:i.lineType)}getPolygonPointList(){if(!this.basicResult)return[];const{pointList:t}=this.basicResult,{lineType:e}=this.dependToolConfig;return e===S.Curve?Yt(t.reduce((i,s)=>[...i,s.x,s.y],[]),.5,!0,20):t}getNextCoordByRenderCoord(t){return this.getNextCoordByAbsCoord(this.coordUtils.getAbsCoord(t))}getNextCoordByAbsCoord(t){var e;const i=(e=this.activeLine)==null?void 0:e.slice(-1)[0];return i?this.coordUtils.getNextCoordByDependTool(t,i):t}pointInLine(t,e,i){return t.filter(s=>s).length<2?!1:t.some((s,n)=>{if(n===0)return!1;const o=this.coordUtils.getRenderCoord(t[n-1]),a=this.coordUtils.getRenderCoord(s);return O.isInLine(e,o,a,i)})}arc(t,e=se,i){var s,n,o,a,l,h;if(this.ctx){const{x:u,y:g}=t;(s=this.ctx)==null||s.save(),(n=this.ctx)==null||n.beginPath(),this.ctx.fillStyle=i||this.lineStyle.color,(o=this.ctx)==null||o.arc(u,g,e,0,360),(a=this.ctx)==null||a.closePath(),(l=this.ctx)==null||l.fill(),(h=this.ctx)==null||h.restore()}}renderActiveArea(){if(this.isActive&&this.activeArea&&this.ctx){const{top:t,left:e,right:i,bottom:s}=this.activeArea,{x:n,y:o}=this.coordUtils.getRenderCoord({x:e,y:t});this.ctx.save(),this.ctx.beginPath(),this.ctx.strokeStyle="#B3B8FF",this.ctx.rect(n,o,(i-e)*this.zoom,(s-t)*this.zoom),this.ctx.stroke(),this.ctx.restore()}}addLinePoint(t){var e,i,s,n;this.arc(t),(e=this.activeLine)==null||e.push(ie(ee({},t),{id:K()})),((i=this.activeLine)==null?void 0:i.length)===1?(s=this.actionsHistory)==null||s.initRecord(this.activeLine):(n=this.actionsHistory)==null||n.pushHistory(this.activeLine),this.render()}setCreatStatusAndAddPoint(t,e=!1){this.updateStatus(0,e),this.addLinePoint(t)}isActiveLineValid(){var t;return this.selectedID?(t=this.lineList.find(e=>e.id===this.selectedID))==null?void 0:t.valid:this.isLineValid}nextOrder(){return this.lineListLen===0?1:this.lineList.slice(-1)[0].order+1}getLineColorByAttribute(t,e=!1){return q.getStrokeAndFill(this.getColor(t.attribute),t.valid,{isSelected:e}).stroke}updateActiveArea(){this.activeArea=this.getActiveArea(),this.renderActiveArea()}getActiveArea(){return this.hasActiveLine?C.calcViewportBoundaries(this.activeLine,this.isCurve,st,this.zoom):void 0}drawLineNumber(t,e=1,i,s="",n,o=!0){var a,l,h;if((this.showOrder||this.attributeConfigurable)&&this.ctx){let u=this.showOrder?e.toString():`${s}`;if(this.attributeConfigurable){const g=n?(h=(l=(a=this.attributeList)==null?void 0:a.find(c=>c.value===n))==null?void 0:l.key)!=null?h:n:"";u=[u,`${!o&&g?"\u65E0\u6548":""}${g}`].filter(c=>c).join("_")}this.drawText(t,u,i)}}drawLineTextAttribute(t,e,i){if(t&&i)return this.drawText(t,i,e,200)}drawText(t,e,i,s){var n,o;this.ctx&&((n=this.ctx)==null||n.save(),this.ctx.font="italic bold 14px SourceHanSansCN-Regular",this.ctx.fillStyle=i,this.ctx.strokeStyle=i,this.ctx.shadowColor="rgba(0, 0, 0, 0.6)",this.ctx.shadowOffsetY=2,this.ctx.shadowBlur=4,s?m.wrapText(this.canvas,e,t.x-Mt.x,t.y-Mt.y,s):this.ctx.fillText(e,t.x-Mt.x,t.y-Mt.y),(o=this.ctx)==null||o.restore())}moveActiveArea(t,e){this.activeArea&&(this.activeArea=Object.assign(this.activeArea,{top:this.activeArea.top+e,bottom:this.activeArea.bottom+e,right:this.activeArea.right+t,left:this.activeArea.left+t})),this.activeLine&&(this.activeLine.map(i=>Object.assign(i,{x:i.x+t,y:i.y+e})),this.updateLines())}findHoveredPoint(t){if(!!this.activeLine)return this.activeLine.find(e=>{const i=this.coordUtils.getRenderCoord(e);return O.calcDistance(i,t)<=Et})}findHoverLine(t){return N.cloneDeep(this.lineList).reverse().find(({pointList:i})=>{const s=i?this.getPointList(i):[],n=this.getLineWidthScope();return s.some((o,a)=>{if(a===0)return!1;const l=this.coordUtils.getRenderCoord(o),h=this.coordUtils.getRenderCoord(s[a-1]);return O.isInLine(t,l,h,n)})})}getAdsorptionPoint(t){let e,i,s;return N.cloneDeep(this.lineList).reverse().forEach(({pointList:n,id:o})=>{if(o===this.selectedID||!n||(n==null?void 0:n.length)<2)return;const a=this.findNearestPoint(n,t);if(a){if(a.minDistance===0){e=a.point;return}(i===void 0||a.minDistance<i)&&(e=a.point,i=a.minDistance)}}),s||e}findNearestPoint(t,e,i=7){let s;const n=i;for(let o=1;o<=t.length-1;o++){const a=this.coordUtils.getRenderCoord(t[o]),l=this.coordUtils.getRenderCoord(t[o-1]),{length:h,footPoint:u}=C.getFootOfPerpendicular(e,a,l),g=O.calcTwoPointDistance(a,e),c=O.calcTwoPointDistance(l,e);if(g<=i*2){s=a,i=0;break}if(c<=i*2){s=l,i=0;break}h<i&&(s=u,i=h)}return s?{point:s,minDistance:n}:void 0}getPointList(t){return this.isCurve?_t(t,st):t}moveSelectedLine(t){const e=(t.x-this.prevAxis.x)/this.zoom,i=(t.y-this.prevAxis.y)/this.zoom;if(this.enableOutOfTarget){this.lineDragging=!0,this.moveActiveArea(e,i);return}if(this.isDependPolygon){this.moveLineInPolygon(e,i);return}let s=[0,this.imageSize.width],n=[0,this.imageSize.height];if(this.isDependRect){const{x:o,y:a,width:l,height:h}=this.basicResult;s=[o,o+l],n=[a,a+h]}this.moveLineInRectRange(e,i,s,n)}moveSelectPoint(t){const e=t.x-this.prevAxis.x,i=t.y-this.prevAxis.y,s=(this.selectedPoint?this.selectedPoint.x:0)+e/this.zoom,n=(this.selectedPoint?this.selectedPoint.y:0)+i/this.zoom,o={x:s,y:n};Object.assign(this.selectedPoint,this.getNextCoordByAbsCoord(o)),this.updateLines(),this.render()}getCoordByConfig(t,e){var i;const s=!!t.shiftKey,n=t.altKey;if(((i=this.activeLine)==null?void 0:i.length)>0&&s){const o=this.activeLine.slice(-1)[0];return O.getVHPoint(o,e,this.coordUtils.getAbsCoord(e),this.coordUtils.getRenderCoord(o))}return this.edgeAdsorptionEnabled&&!n?this.getAdsorptionPoint(e):e}getNextPoint(t,e){const i=this.getCoordByConfig(t,e)||e;return this.enableOutOfTarget?i:this.getNextCoordByRenderCoord(i)}lineHover(){this.render()}mouseMoveHandler(t){const e=this.getCoordinate(t),i=t.which===1;if(this.isCreate){this.hasActiveLine&&this.renderNextPoint(t,e);return}if(this.isNone&&(this.lineHover(),this.edgeAdsorptionEnabled&&!t.altKey)){const s=this.getAdsorptionPoint(e);s&&this.arc(s)}if(this.isActive){if(this.isMousedown&&i){if(this.selectedPoint){this.moveSelectPoint(e);return}if(this.coordsInsideActiveArea){this.moveSelectedLine(e),this.drawActivatedLine(void 0,void 0,!0);return}}this.drawHoverPoint(e),this.render()}}onMouseMove(t){if(super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo)return;const e=this.getCoordinate(t);this.mouseMoveHandler(t),this.prevAxis=e}setActiveArea(t,e=!1){const i=this.findHoverLine(t);if(i){const s=this.lineList.findIndex(a=>a.id===(i==null?void 0:i.id)),n=C.calcViewportBoundaries((i==null?void 0:i.pointList)||[],this.isCurve,st,this.zoom),o=this.lineList[s];this.updateStatus(1),this.setActiveLine(o.pointList),this.setSelectedLineID(o.id),this.activeArea=n,this.updateLineAttributes(o)}else e&&this.setNoneStatus();this.render()}setActiveLineByID(t){const e=this.lineList.find(i=>i.id===t);if(e){const i=C.calcViewportBoundaries((e==null?void 0:e.pointList)||[],this.isCurve,st,this.zoom);this.updateStatus(1),this.setActiveLine(e.pointList),this.setSelectedLineID(e.id),this.activeArea=i,this.updateLineAttributes(e)}this.render()}setActiveLine(t){this.activeLine=t?N.cloneDeep(t):void 0}historyChanged(t){const e=`${t}Enabled`;if(this.isCreate){if(this.actionsHistory&&this.actionsHistory[e]){const i=this.actionsHistory&&this.actionsHistory[t]();this.setActiveLine(i),this.render()}return}if(this.history&&this.history[e]){const i=this.history[t](),s=i==null?void 0:i.find(n=>n.id===this.selectedID);this.lineList=i,this.selectedID&&s?this.setActiveLine(s==null?void 0:s.pointList):this.setNoneStatus(),this.render()}this.emit("dataUpdated",this.lineList)}undo(){this.historyChanged("undo"),this.updateSelectedAttributeAfterHistoryChanged()}redo(){this.historyChanged("redo"),this.updateSelectedAttributeAfterHistoryChanged()}isCoordInsideTarget(t){if(this.isDependPolygon)return this.isInBasicPolygon(t);if(this.isDependRect){const{x:e,y:i,width:s,height:n}=this.basicResult,o=[e,e+s],a=[i,i+n];return C.isInRange(t.x,o)&&C.isInRange(t.y,a)}return C.isInRange(t.x,[0,this.imageSize.width])&&C.isInRange(t.y,[0,this.imageSize.height])}getPointInsertIndex(t,e){if(t&&this.activeLine){const i=this.getPointList(this.activeLine);return this.activeLine.length===2?1:this.activeLine.findIndex((s,n)=>{if(n>0){const o=this.activeLine?this.activeLine[n-1]:void 0,a=this.isCurve?i.slice((n-1)*(st+1),n*(st+1)):[o,s];return this.pointInLine(a,t,e||this.getLineWidthScope())}return!1})}return-1}getLineWidthScope(){return this.lineStyle.lineWidth}isMouseCoordOutsideActiveArea(){return!this.coordsInsideActiveArea&&!this.selectedPoint}isLinePointsExceed(){return this.isCreate&&this.activeLine&&this.upperLimitPointNum&&~~this.upperLimitPointNum<=this.activeLine.length}isLinePointsNotEnough(){var t;return this.activeLine&&((t=this.activeLine)==null?void 0:t.length)<this.lowerLimitPointNum}updateLineSegmentSpecial(t){const e=this.getPointInsertIndex(t,2)-1;if(e>-1){const i=this.activeLine[e];i.specialEdge=!i.specialEdge,this.hoverLineSegmentIndex=-1,this.render()}}addLinePointToActiveLine(){var t;const e=this.getPointInsertIndex(this.cursor),i=this.pointsWithinRange(this.activeLine.length+1);this.cursor&&e>-1&&i&&(this.activeLine.splice(e,0,ie(ee({},this.coordUtils.getAbsCoord(this.cursor)),{id:K()})),this.updateLines(),(t=this.history)==null||t.pushHistory(this.lineList),this.render(),this.cursor=void 0)}onMouseDown(t){if(super.onMouseDown(t)||this.forbidMouseOperation||!this.imgInfo)return;const e=this.getCoordinate(t);if(this.isMousedown=!0,this.prevAxis=e,t.which===3){this.cursor=void 0;return}this.selectedPoint=this.findHoveredPoint(e),this.coordsInsideActiveArea=this.isActive&&this.activeArea?O.inArea(this.activeArea,this.coordUtils.getAbsCoord(e)):!1,this.lineDragging=!1}lineHasChanged(){const t=this.lineList.find(e=>e.id===this.selectedID);return t?JSON.stringify(t.pointList)!==JSON.stringify(this.activeLine):!1}updateLines(){const t=this.lineList.find(e=>e.id===this.selectedID);t&&(t.pointList=N.cloneDeep(this.activeLine),this.emit("dataUpdated",this.lineList))}onMouseUp(t){const e=()=>{this.isMousedown=!1,this.hoverPointID=void 0,this.cursor=void 0,this.selectedPoint=void 0};if(this.hoverPointID=void 0,super.onMouseUp(t)||this.forbidMouseOperation||!this.imgInfo){e();return}t.which===1&&this.onLeftClick(t),t.which===3&&this.onRightClick(t),e()}isTextValid(t){return T.textAttributeValidate(this.textCheckType,this.customFormat,t)}createLineData(){const t=K(),e={pointList:N.cloneDeep(this.activeLine),id:t,valid:this.isLineValid,order:this.nextOrder()};return e.attribute=this.defaultAttribute,e}stopLineCreating(t=!0){var e,i,s,n;const o=this.selectedID?!0:!!this.isTextConfigurable;let a;if(t){if(this.selectedID){const l=this.lineList.find(h=>h.id===this.selectedID);a=this.selectedID,l&&(l.pointList=N.cloneWith(this.activeLine),N.isEqual(l.pointList,(e=this.history)==null?void 0:e.pushHistory(this.lineList))||(i=this.history)==null||i.pushHistory(this.lineList))}else if(this.isCreate&&this.activeLine&&this.activeLine.length>1){const l=this.createLineData();a=l.id,this.setLineList([...this.lineList,l]),(s=this.history)==null||s.pushHistory(this.lineList)}}o?this.setActiveStatus(a):this.setNoneStatus(),(n=this.actionsHistory)==null||n.empty(),this.emit("dataUpdated",this.lineList),this.render()}setActiveStatus(t){const e=t?this.lineList.find(i=>i.id===t):void 0;if(e){const i=e==null?void 0:e.pointList;this.updateStatus(1),this.setActiveLine(i),this.setSelectedLineID(t)}else this.setNoneStatus()}setNoneStatus(t=!0){t&&this.updateStatus(2),this.activeLine=[],this.setSelectedLineID(void 0),this.activeArea=void 0,this.isLineValid=!0,this.cursor=void 0}setKeyDownStatus(t,e){this.isShift=e!=null?e:t.keyCode===_.Shift}continueToEdit(){var t;this.updateStatus(0),this.cursor=void 0,(t=this.actionsHistory)==null||t.pushHistory(this.activeLine),this.render()}setInvalidLineOnCreating(t){if(this.selectedID&&t.keyCode!==_.Ctrl||!this.isCreate)return;const e=!t.ctrlKey;this.selectedID?this.setInvalidLine(this.selectedID,e,!1):this.isLineValid=e}onKeyDown(t){if(super.onKeyDown(t),this.setKeyDownStatus(t),t.keyCode===_.Z&&!t.ctrlKey&&this.toggleIsHide(),t.keyCode===_.Shift&&this.render(),t.keyCode===_.Tab){t.preventDefault(),this.selectToNextLine(t);return}if(this.isCreate&&this.keyboardEventWhileLineCreating(t),this.config.attributeConfigurable){const e=T.getAttributeByKeycode(t.keyCode,this.config.attributeList);e!==void 0&&this.setDefaultAttribute(e)}}selectToNextLine(t){const e=x.getNextSelectedRectIDByEvent(this.viewPortLines.map(i=>{var s,n,o,a;return ie(ee({},i),{x:(n=(s=i.pointList[0])==null?void 0:s.x)!=null?n:0,y:(a=(o=i.pointList[0])==null?void 0:o.y)!=null?a:0})}),t,this.selectedID);e&&this.setActiveLineByID(e.id)}keyboardEventWhileLineCreating(t){!this.isCreate||(t.keyCode===_.Ctrl&&this.setInvalidLineOnCreating(t),[_.Shift,_.Alt].includes(t.keyCode)&&this.renderNextPoint(t,this.prevAxis))}renderNextPoint(t,e){const i=this.coordUtils.getRenderCoord(this.getNextPoint(t,e));this.render(i)}deleteSelectedLine(t){const e=C.calcViewportBoundaries(this.activeLine,this.isCurve,st,this.zoom);O.inArea(e,this.coordUtils.getAbsCoord(t))&&this.deleteLine()}deleteSelectedLinePoint(t){var e;this.pointsWithinRange(this.activeLine.length-1)&&t&&(this.setActiveLine(this.activeLine.filter(s=>s.id!==t)),this.updateLines(),(e=this.history)==null||e.pushHistory(this.lineList)),this.cursor=void 0,this.render()}deleteLine(){var t;this.lineList=this.lineList.filter(e=>e.id!==this.selectedID),(t=this.history)==null||t.pushHistory(this.lineList),this.setNoneStatus(),this.emit("dataUpdated",this.lineList),this.render()}setInvalidLine(t,e,i=!0){var s;const n=this.lineList.find(o=>o.id===t);n&&(n.valid=e!==void 0?e:!n.valid,(s=this.history)==null||s.pushHistory(this.lineList),i&&this.render())}empty(){var t,e;this.lineList=[],this.setNoneStatus(),this.selectedPoint=void 0,(t=this.actionsHistory)==null||t.empty(),(e=this.history)==null||e.init(),this.emit("dataUpdated",this.lineList),this.render()}setAttribute(t){var e;this.attributeConfigurable&&(this.defaultAttribute=t,this.setLineAttribute("attribute",t),this.selectedID&&((e=this.history)==null||e.pushHistory(this.lineList)))}setTextAttribute(t){var e;this.isTextConfigurable&&(this.setLineAttribute("textAttribute",t),(e=this.history)==null||e.applyAttribute(this.selectedID,"textAttribute",t))}setLineAttribute(t,e,i){const s=i||this.selectedID;if(s){const n=this.lineList.find(o=>o.id===s);n&&(n[t]=e)}this.render()}updateAttribute(t){this.emit("updateAttribute",t)}updateLineAttributes(t){var e;if(this.attributeConfigurable&&t){const i=(t==null?void 0:t.attribute)||"";this.defaultAttribute=i,this.updateAttribute(i)}if(this.isTextConfigurable&&t){const i=(t==null?void 0:t.textAttribute)||"";this.updateTextAttribute(i)}(e=this.history)==null||e.updateHistory(this.lineList)}lineStatusChanged(){this.emit("lineStatusChanged",{status:this.status,selectedLineID:this.selectedID})}updateTextAttribute(t){if(this.selectedID){const e=this.lineList.find(i=>i.id===this.selectedID);e&&(e.textAttribute=t)}this.emit("updateText",t)}saveData(){this.stopLineCreating(),this.setNoneStatus(),this.render()}setTextEditingID(t){this.textEditingID=t,this.render()}setSelectedLineID(t){var e,i;if(this.selectedID===t)return;const s=this.selectedID;t!==s&&s&&((e=this._textAttributeInstance)==null||e.changeSelected()),t||(i=this._textAttributeInstance)==null||i.clearTextAttribute(),this.selectedID=t,this.emit("selectedChange")}attributeLockListChange(t){this.attributeLockList=t,this.render()}setResult(t){this.setNoneStatus(),this.setLineList(t),this.render()}setConfig(t){super.setConfig(t)}toggleIsHide(){this.setIsHidden(!this.isHidden),this.render()}clearCanvas(){super.clearCanvas()}clearResult(){this.setResult([]),this.setSelectedLineID(void 0),this.render()}exportData(){return[this.lineList,this.basicImgInfo]}setDefaultAttribute(t=""){var e;this.attributeConfigurable&&(this.defaultAttribute=t,this.setLineAttribute("attribute",t),this.selectedID&&((e=this.history)==null||e.pushHistory(this.lineList)),this.emit("changeAttributeSidebar"))}getCurrentSelectedData(){var t,e;const i=this.isActiveLineValid(),s=this.defaultAttribute,n=this.getColor(s),o=i?n==null?void 0:n.valid.stroke:n==null?void 0:n.invalid.stroke,a=(e=(t=this.lineList.find(l=>l.id===this.selectedID))==null?void 0:t.textAttribute)!=null?e:"";return{color:o,textAttribute:a}}renderTextAttribute(){var t,e,i,s;if(!this.ctx||!this.activeLine||((t=this.activeLine)==null?void 0:t.length)<2||this.isCreate)return;const n=this.isActiveLineValid(),o=this.defaultAttribute,{x:a,y:l}=this.activeLine[1],h=this.coordUtils.getRenderCoord({x:a,y:l}),u=this.getColor(o),g=n?u==null?void 0:u.valid.stroke:u==null?void 0:u.invalid.stroke,c=(i=(e=this.lineList.find(d=>d.id===this.selectedID))==null?void 0:e.textAttribute)!=null?i:"";this._textAttributeInstance||(this._textAttributeInstance=new Ot({container:this.container,icon:this.getTextIconSvg(o),color:g,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedTextAttribute})),this._textAttributeInstance&&!((s=this._textAttributeInstance)==null?void 0:s.isExit)&&this._textAttributeInstance.appendToContainer(),this._textAttributeInstance.update(`${c}`,{left:h.x,top:h.y,color:g}),this._textAttributeInstance.updateIcon(this.getTextIconSvg(o))}getTextIconSvg(t=""){return T.getTextIconSvg(t,this.config.attributeList,this.config.attributeConfigurable,this.baseIcon)}updateSelectedTextAttribute(t){if(this._textAttributeInstance&&t&&this.selectedID){let e=t;!T.textAttributeValidate(this.config.textCheckType,"",e)&&(this.emit("messageError",T.getErrorNotice(this.config.textCheckType,this.lang)),e=""),this.setTextAttribute(e),this.emit("updateTextAttribute"),this.render()}}}class re{static getMarkerShowText(t,e=[]){return T.getAttributeShowText(t,e)}}var Or=Object.defineProperty,Mr=Object.defineProperties,Er=Object.getOwnPropertyDescriptors,hi=Object.getOwnPropertySymbols,Hr=Object.prototype.hasOwnProperty,Nr=Object.prototype.propertyIsEnumerable,ci=Math.pow,di=(r,t,e)=>t in r?Or(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ht=(r,t)=>{for(var e in t||(t={}))Hr.call(t,e)&&di(r,e,t[e]);if(hi)for(var e of hi(t))Nr.call(t,e)&&di(r,e,t[e]);return r},ne=(r,t)=>Mr(r,Er(t));const ui=200;class gi extends it{constructor(t){super(t);this.setMarkerIndex=e=>{this.markerIndex=e},this.setMarkerIndexAndSelect=e=>{if(!this.config.markerList)return;this.markerIndex=e;const i=this.config.markerList[e].value,s=this.currentPageResult.find(n=>n.label===i);s&&(this.setSelectedID(s.id),this.config.attributeConfigurable===!0&&this.setDefaultAttribute(s.attribute)),this.emit("markIndexChange")},this.textChange=e=>{this.config.textConfigurable!==!0||!this.selectedID||(this.setPointList(T.textChange(e,this.selectedID,this.pointList)),this.emit("selectedChange"),this.render())},this.config=x.jsonParser(t.config),this.pointList=[],this.markerIndex=0,this.setStyle(t.style),this.createPoint=this.createPoint.bind(this),this.getCurrentSelectedData=this.getCurrentSelectedData.bind(this),this.updateSelectedTextAttribute=this.updateSelectedTextAttribute.bind(this),this.setSelectedID=this.setSelectedID.bind(this)}get dataList(){return this.pointList}setResult(t){if(this.clearActiveStatus(),this.setPointList(t),this.hasMarkerConfig){const e=x.getNextMarker(this.getCurrentPageResult(t),this.config.markerList);e&&this.setMarkerIndex(e.index)}this.render()}setPointList(t,e=!1){const i=this.pointList.length;this.pointList=t,i!==t.length&&this.emit("updatePageNumber"),e&&this.emit("updateResult")}setConfig(t,e=!1){this.config=x.jsonParser(t),e===!0&&this.clearResult()}clearResult(){this.setPointList([]),this.setSelectedID(void 0),this.history.pushHistory([]),this.hoverID="",this.render()}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.pointList.forEach(s=>{s.id===i&&(s.attribute=t)}),this.history.pushHistory(this.pointList),this.render()),this._textAttributInstance){if(this.attributeLockList.length>0&&!this.attributeLockList.includes(t)){this._textAttributInstance.clearTextAttribute();return}this._textAttributInstance.updateIcon(this.getTextIconSvg(t))}}}get selectedText(){var t;return(t=this.pointList.find(e=>e.id===this.selectedID))==null?void 0:t.textAttribute}setStyle(t){var e;super.setStyle(t),this._textAttributInstance&&this.config.attributeConfigurable===!1&&((e=this._textAttributInstance)==null||e.updateIcon(this.getTextIconSvg()))}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")}getTextIconSvg(t=""){return T.getTextIconSvg(t,this.config.attributeList,this.config.attributeConfigurable,this.baseIcon)}clearActiveStatus(){this.hoverID=void 0,this.dragStatus=k.Wait,this.setSelectedID(void 0)}setBasicResult(t){super.setBasicResult(t),this.clearActiveStatus()}onMouseDown(t){if(!(super.onMouseDown(t)||this.forbidMouseOperation)){if(t.button===0&&!this.hoverID){this.createPoint(t),this.render();return}return this.hoverID===this.selectedID&&t.button===0&&(this.dragStatus=k.Start),this.render(),!0}}onMouseMove(t){super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo||(this.hoverID=this.getHoverId(),(this.dragStatus===k.Start||this.dragStatus===k.Move)&&this.onDragMove(t),this.hoverID&&this.render())}onMouseUp(t){if(super.onMouseUp(t)||this.forbidMouseOperation||!this.imgInfo)return!0;t.button===2&&this.rightMouseUp(),this.dragStatus===k.Move&&(this.dragStatus=k.Wait,this.history.pushHistory(this.pointList)),this.render()}onDragMove(t){if(!this.imgInfo)return;this.dragStatus=k.Move;const e=this.getCoordinateUnderZoom(t),i=L.changeDrawOutsideTarget(e,{x:0,y:0},this.imgInfo,this.config.drawOutsideTarget,this.basicResult,this.zoom),s=this.config.drawOutsideTarget?L.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos):L.changePointByZoom(i,1/this.zoom);this.pointList.forEach(n=>{n.id===this.selectedID&&(n.x=s.x,n.y=s.y)}),this.render()}onKeyDown(t){if(!x.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;const{keyCode:e}=t;switch(e){case _.Delete:this.deletePoint();break;case _.Tab:{this.onTabKeyDown(t);break}case _.Z:this.setIsHidden(!this.isHidden),this.render();break;default:{if(this.config.attributeConfigurable){const i=T.getAttributeByKeycode(e,this.config.attributeList);i!==void 0&&this.setDefaultAttribute(i)}break}}}createPoint(t){if(!this.imgInfo)return;const{upperLimit:e}=this.config;if(e&&this.currentPageResult.length>=e){this.emit("messageInfo",`${F.getMessagesByLocale(D.LowerLimitPoint,this.lang)}`);return}const i=x.getSourceID(this.basicResult),s=this.getCoordinateUnderZoom(t),n=L.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);if(this.config.drawOutsideTarget===!1){if(this.dependToolName&&this.basicCanvas){let l=!1;switch(this.dependToolName){case w.Rect:{l=!$.isInRect(n,this.basicResult);break}case w.Polygon:{l=!H.isInPolygon(n,this.basicResult.pointList);break}}if(l)return}if(s.x<0||s.y<0||s.x>this.imgInfo.width||s.y>this.imgInfo.height)return}let o=ne(Ht({},n),{attribute:this.defaultAttribute,valid:!t.ctrlKey,id:K(8,62),sourceID:i,textAttribute:"",order:x.getMaxOrder(this.pointList.filter(l=>x.isSameSourceID(l.sourceID,i)))+1});if(this.config.textConfigurable){let l="";l=T.getTextAttribute(this.pointList.filter(h=>x.isSameSourceID(h.sourceID,i)),this.config.textCheckType),o=ne(Ht({},o),{textAttribute:l})}if(this.hasMarkerConfig){const l=x.getNextMarker(this.currentPageResult,this.config.markerList,this.markerIndex);if(l)o=ne(Ht({},o),{label:l.label}),this.markerIndex=l.index,this.emit("markIndexChange");else{this.emit("messageInfo",F.getMessagesByLocale(D.MarkerFinish,this.lang));return}}this.hoverID=o.id;const a=[...this.pointList,o];this.setPointList(a),this.history.pushHistory(a),this.setSelectedID(o.id)}isInPoint(t,e,i=this.zoom){return(this.style.width+2)/i>=Math.sqrt(ci(t.x-e.x,2)+ci(t.y-e.y,2))}getHoverId(){var t;const e=L.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos),i=(t=this.pointList)==null?void 0:t.find(s=>this.isInPoint(e,s));return i==null?void 0:i.id}rightMouseUp(){if(this.selectedID===this.hoverID){const e=this.pointList.filter(i=>i.id!==this.selectedID);this.setPointList(e),this.setSelectedID(""),this.hoverID="";return}const t=this.pointList.find(e=>e.id===this.hoverID);if(this.setSelectedID(this.hoverID),this.setDefaultAttribute(t==null?void 0:t.attribute),(t==null?void 0:t.label)&&this.hasMarkerConfig){const e=x.getCurrentMarkerIndex(t.label,this.config.markerList);e>=0&&(this.setMarkerIndex(e),this.emit("markIndexChange"))}}onTabKeyDown(t){if(t.preventDefault(),this.dragStatus===k.Move||this.dragStatus===k.Start)return;let e=j.ascend;t.shiftKey&&(e=j.descend);const[i,s]=x.getRenderResultList(this.pointList,x.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);let n=[...i];s&&(n=[...n,s]);const o=x.getNextSelectedRectID(n,e,this.selectedID);o&&this.setSelectedID(o.id)}get currentPageResult(){const[t]=x.getRenderResultList(this.pointList,x.getSourceID(this.basicResult),[]);return t}getCurrentPageResult(t){const[e]=x.getRenderResultList(t,x.getSourceID(this.basicResult),[]);return e}exportData(){const{pointList:t}=this;return[t,this.basicImgInfo]}deletePoint(){var t;this.selectedID&&(this.setPointList(this.pointList.filter(e=>e.id!==this.selectedID)),this.history.pushHistory(this.pointList),(t=this._textAttributInstance)==null||t.clearTextAttribute(),this.emit("selectedChange"),this.render())}undoAndRedo(t){var e,i;if(this.dragStatus===k.Move||this.dragStatus===k.Start)return;const s=(i=(e=this.history)[t])==null?void 0:i.call(e);(s==null?void 0:s.some(n=>n.id===this.selectedID))||this.setSelectedID(""),s&&(this.setPointList(s,!0),this.render())}undo(){this.undoAndRedo("undo")}redo(){this.undoAndRedo("redo")}getCurrentSelectedData(){var t;if(!this.selectedID)return;const e=(t=this.pointList)==null?void 0:t.find(n=>n.id===this.selectedID),i=this.getColor(e==null?void 0:e.attribute),s=(e==null?void 0:e.valid)?i==null?void 0:i.valid.stroke:i==null?void 0:i.invalid.stroke;return this.dragStatus=k.Wait,{width:ui*this.zoom*.6,textAttribute:(e==null?void 0:e.textAttribute)||"",color:s}}updateSelectedTextAttribute(t){if(this._textAttributInstance&&t&&this.selectedID){let e=t;T.textAttributeValidate(this.config.textCheckType,"",e)===!1&&(this.emit("messageError",T.getErrorNotice(this.config.textCheckType,this.lang)),e=""),this.setPointList(T.textChange(e,this.selectedID,this.pointList)),this.emit("updateTextAttribute"),this.render()}}renderTextAttribute(){var t,e;const i=(t=this.pointList)==null?void 0:t.find(d=>d.id===this.selectedID);if(!this.ctx||this.config.textConfigurable!==!0||!i)return;const{x:s,y:n,attribute:o,valid:a}=i,l=ui*this.zoom*.6,h=L.getOffsetCoordinate({x:s,y:n},this.currentPos,this.zoom),u=this.getColor(o),g=a?u==null?void 0:u.valid.stroke:u==null?void 0:u.invalid.stroke,c=4;this._textAttributInstance||(this._textAttributInstance=new Ot({width:l,container:this.container,icon:this.getTextIconSvg(o),color:g,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedTextAttribute})),this._textAttributInstance&&!((e=this._textAttributInstance)==null?void 0:e.isExit)&&this._textAttributInstance.appendToContainer(),this._textAttributInstance.update(`${i.textAttribute}`,{left:h.x,top:h.y+c,color:g,width:l})}renderPoint(t){var e,i,s;const{textAttribute:n="",attribute:o}=t,a=t.id===this.selectedID,l=this.getColor(o),h=L.changePointByZoom(t,this.zoom,this.currentPos),{width:u=2,hiddenText:g=!1}=this.style,c=q.getStrokeAndFill(l,t.valid,{isSelected:a||t.id===this.hoverID});m.drawCircle(this.canvas,h,u,{startAngleDeg:0,endAngleDeg:360,thickness:1,color:c.stroke,fill:c.fill});let d="";(((e=this.config)==null?void 0:e.isShowOrder)||((i=this.config)==null?void 0:i.showOrder))&&t.order&&(t==null?void 0:t.order)>0&&(d=`${t.order}`),t.label&&this.hasMarkerConfig&&(d=`${x.getCurrentMarkerIndex(t.label,this.config.markerList)+1}_${re.getMarkerShowText(t.label,this.config.markerList)}`),t.attribute&&(d=`${d} ${T.getAttributeShowText(t.attribute,(s=this.config)==null?void 0:s.attributeList)}`),g||m.drawText(this.canvas,{x:h.x+u/2,y:h.y-u-4},d,{textAlign:"center",color:c.stroke}),a?this.renderTextAttribute():g||m.drawText(this.canvas,{x:h.x+u,y:h.y+u+24},n,Ht({color:c.stroke},Y))}renderPointList(){const[t,e]=x.getRenderResultList(this.pointList,x.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);this.isHidden||t.forEach(i=>{this.renderPoint(i)}),e&&this.renderPoint(e)}render(){!this.ctx||(super.render(),this.renderPointList(),this.renderCursorLine(this.getLineColor(this.defaultAttribute)))}}class fi extends it{constructor(t){super(t);this.getSingleResult=e=>{const i={};return this.config.configList.length>0&&this.config.configList.forEach(s=>{var n;i[s.key]=(n=s.default)!=null?n:""}),{value:i,id:K(),sourceID:e!=null?e:x.getSourceID()}},this.getInitResultList=(e,i)=>e===0?[this.getSingleResult()]:i.map(s=>this.getSingleResult(s.id)),this.textList=[],this.setShowDefaultCursor(!0),this.setConfig(t.config),this.initTextDisplayContainer()}get dataList(){return this.textList}get textValueContainerID(){return"textValueContainer"}get textValueContainer(){return document.getElementById(this.textValueContainerID)}get currentPageResult(){return this.textList}setResult(t){var e;this.textList=t,this.toggleTextContainerVisible(!0);const i=(e=this.textList[0])==null?void 0:e.value;i&&Object.keys(i).forEach(s=>{this.renderText(s,i[s])}),this.emit("valueUpdated"),this.toggleTextContainerVisible(!!i)}updateTextValue(t,e){this.textList[0].value[t]=e,this.renderText(t,e),this.emit("valueUpdated")}renderText(t,e){const i=document.getElementById(`textKey${t}`);i&&(i.innerText=e)}getTextDomID(t){return`textKey${t}`}initTextDisplayContainer(){const t=document.createElement("div"),e={position:"absolute",right:"0",top:"0","z-index":"20","max-width":"20%","font-family":"SourceHanSansCN-Regular",background:"rgb(102, 230, 255)",color:"white","word-break":"break-all","line-height":"24px","white-space":"pre-wrap","max-height":"80%","overflow-y":"auto",opacity:"0.6"};t.setAttribute("style",Object.keys(e).reduce((i,s)=>(i+=`${s}: ${e[s]};`,i),"")),t.setAttribute("id",this.textValueContainerID),this.config.configList.forEach(i=>{const s=document.createElement("div"),n=document.createElement("div"),o=document.createElement("div");s.setAttribute("style","padding: 8px 16px"),n.innerText=`${i.key}:`,o.innerText="",o.setAttribute("id",this.getTextDomID(i.key)),s.appendChild(n),s.appendChild(o),t.appendChild(s)}),this.container.appendChild(t)}exportData(){return[this.textList,this.basicImgInfo]}destroyCanvas(){super.destroyCanvas(),this.textValueContainer&&this.container.removeChild(this.textValueContainer)}onKeyDown(t){super.onKeyDown(t),t.keyCode===_.Z&&this.toggleTextContainerVisible()}toggleTextContainerVisible(t){if(this.textValueContainer){const e=(t!==void 0?!t:this.textValueContainer.style.display==="block")?"none":"block";this.textValueContainer.style.display=e}}}var Br=Object.defineProperty,$r=Object.defineProperties,Fr=Object.getOwnPropertyDescriptors,vi=Object.getOwnPropertySymbols,Zr=Object.prototype.hasOwnProperty,Ur=Object.prototype.propertyIsEnumerable,pi=(r,t,e)=>t in r?Br(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,bi=(r,t)=>{for(var e in t||(t={}))Zr.call(t,e)&&pi(r,e,t[e]);if(vi)for(var e of vi(t))Ur.call(t,e)&&pi(r,e,t[e]);return r},zr=(r,t)=>$r(r,Fr(t));class x{static getStepInfo(t,e){return e==null?void 0:e.filter(i=>i.step===t)[0]}static getCurrentStepInfo(t,e){const i=this.getStepInfo(t,e);return i&&(i.type===yt.QUALITY_INSPECTION||i.type===yt.MANUAL_CORRECTION)?this.getCurrentStepInfo(i.dataSourceStep,e):i}static getMaxOrder(t){let e=0;return t.forEach(i=>{i.order&&i.order>e&&(e=i.order)}),e}static hotkeyFilter(t){const e=t.target||t.srcElement;if(!e)return!0;const{tagName:i,type:s}=e;if(!i||!s)return!0;let n=!0;return(e.isContentEditable||i==="TEXTAREA"||(i==="INPUT"&&s!=="radio"||i==="TEXTAREA")&&!e.readOnly)&&(n=!1),n}static getCurrentOperation(t){switch(t){case w.Rect:case w.RectTrack:return he;case w.Tag:return ri;case w.Polygon:return si;case Lt.Check:return Ir;case w.Line:return li;case w.Point:return gi;case w.Text:return fi;default:throw new Error("not match tool")}}static getNextSelectedRectID(t,e=j.ascend,i){let s=1;e===j.descend&&(s=-1);const n=t.sort((l,h)=>l.x-h.x==0?l.y-h.y:s*(l.x-h.x)),o=n.findIndex(l=>l.id===i),a=n.length;return n[(o+1)%a]}static getNextSelectedRectIDByEvent(t,e,i){const s=e.shiftKey?j.descend:j.ascend;return this.getNextSelectedRectID(t,s,i)}static getRenderResultList(t,e,i=[],s){let n;return[t.filter(a=>s&&s===(a==null?void 0:a.id)?(n=a,!1):!(i.length>0&&!i.includes(a==null?void 0:a.attribute)||this.isDifferSourceID(a==null?void 0:a.sourceID,e))),n]}static getSourceID(t){var e;const i="";return t&&(e=t==null?void 0:t.id)!=null?e:i}static findAllLine(t){const e=[],i=[...t];i.length>=3&&i.push(bi({},i[0]));for(let s=0;s<i.length;s++)i[s+1]&&e.push({point1:i[s],point2:i[s+1],pointIndex:s});return e}static translateSourceID(t){return(t===void 0||t===0||t==="0")&&(t=""),t}static isDifferSourceID(t,e){return t=this.translateSourceID(t),e=this.translateSourceID(e),`${t}`!=`${e}`}static isSameSourceID(t,e){return t=this.translateSourceID(t),e=this.translateSourceID(e),`${t}`==`${e}`}static getNextMarker(t,e=[],i){if((e==null?void 0:e.length)===0)return;let s=e.map((n,o)=>zr(bi({},n),{index:o}));if(typeof i=="number"&&i>0){const n=e[i];if(n&&t.every(o=>o.label!==n.value))return{label:n.value,index:i};s=[...s.slice(i,e.length),...s.slice(0,i)]}for(let n=0;n<s.length;n++)if(!t.some(o=>o.label===s[n].value))return{label:s[n].value,index:s[n].index}}static getCurrentMarkerIndex(t,e=[]){return e.findIndex(i=>t===i.value)}}x.jsonParser=(r,t={})=>{try{return typeof r=="string"?JSON.parse(r):Ri(r)?r:t}catch(e){return t}};var Vr=Object.defineProperty,xi=Object.getOwnPropertySymbols,Wr=Object.prototype.hasOwnProperty,jr=Object.prototype.propertyIsEnumerable,yi=(r,t,e)=>t in r?Vr(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,oe=(r,t)=>{for(var e in t||(t={}))Wr.call(t,e)&&yi(r,e,t[e]);if(xi)for(var e of xi(t))jr.call(t,e)&&yi(r,e,t[e]);return r};class H{static getHoverPolygonID(t,e,i=3,s=S.Line){let n="",o=Infinity;const a=L.axisArea(t,i);return e.forEach(l=>{l.pointList&&a.forEach(h=>{const u=this.calcPolygonSize(l.pointList);this.isInPolygon(h,l.pointList,s)&&u<o&&(n=l.id,o=u)})}),n}static calcPolygonSize(t=[]){if((t==null?void 0:t.length)<=2)return 0;const e=t.length,i=t.reduce((s,n,o,a)=>{const l=a[(o+1)%e];return s+n.x*l.y-l.x*n.y},0);return Math.abs(i)/2}static isInPolygon(t,e,i=S.Line){let s=0,n,o,a,l;e=[...e],i===S.Curve&&(e=this.createSmoothCurvePoints(e.reduce((u,g)=>[...u,g.x,g.y],[]),.5,!0,20)),[a]=e;const h=e.length;for(n=1;n<=h;n++)l=e[n%h],t.x>Math.min(a.x,l.x)&&t.x<=Math.max(a.x,l.x)&&t.y<=Math.max(a.y,l.y)&&a.x!==l.x&&(o=(t.x-a.x)*(l.y-a.y)/(l.x-a.x)+a.y,(a.y===l.y||t.y<=o)&&s++),a=l;return s%2!=0}static createSmoothCurvePointsFromPointList(t,e=W){return this.createSmoothCurvePoints(t.reduce((s,n)=>[...s,n.x,n.y],[]),.5,!1,e).map((s,n)=>{var o;const a=n/(W+1),l=Math.floor(a),h=(o=t[l])!=null?o:{};return oe(l===a?oe({},h):{specialEdge:h.specialEdge},s)})}static createSmoothCurvePoints(t,e=.5,i=!1,s=W){if(t.length<4)return t;const n=[],o=t.slice(0);let a,l,h,u,g,c,d,f,v,p,b,y,P;for(i?(o.unshift(t[t.length-1]),o.unshift(t[t.length-2]),o.unshift(t[t.length-1]),o.unshift(t[t.length-2]),o.push(t[0]),o.push(t[1])):(o.unshift(t[1]),o.unshift(t[0]),o.push(t[t.length-2]),o.push(t[t.length-1])),P=2;P<o.length-4;P+=2)for(h=(o[P+2]-o[P-2])*e,u=(o[P+4]-o[P-0])*e,g=(o[P+3]-o[P-1])*e,c=(o[P+5]-o[P+1])*e,y=0;y<=s;y++)b=y/s,d=2*Math.pow(b,3)-3*Math.pow(b,2)+1,f=-(2*Math.pow(b,3))+3*Math.pow(b,2),v=Math.pow(b,3)-2*Math.pow(b,2)+b,p=Math.pow(b,3)-Math.pow(b,2),a=d*o[P]+f*o[P+2]+v*h+p*u,l=d*o[P+1]+f*o[P+3]+v*g+p*c,n.push(a),n.push(l);const A=[];for(let I=0;I<n.length-1;I+=2)A.push({x:n[I],y:n[I+1]});if(i)for(let I=0;I<s+1;I++){const R=A.shift();A.push(R)}return A}static getPolygonByID(t,e){return t.find(i=>i.id===e)}static getHoverEdgeIndex(t,e,i=S.Line,s=3){let n=[...e];i===S.Curve?n=this.createSmoothCurvePoints(e.reduce((l,h)=>[...l,h.x,h.y],[]),.5,!0,W):i===S.Line&&n.push(n[0]);let o=-1,a=s;for(let l=0;l<n.length-1;l++){const{length:h}=C.getFootOfPerpendicular(t,n[l],n[l+1]);h<a&&(o=l,a=h)}return o===-1?-1:i===S.Curve?Math.floor(o/W):o}static getClosestPoint(t,e,i=S.Line,s=3){let n="",o=-1,a=Infinity,l=t;const h=20;return e.forEach(u=>{if(!!u.pointList)switch(i){case S.Line:x.findAllLine(u.pointList).forEach((c,d)=>{const{length:f,footPoint:v}=C.getFootOfPerpendicular(t,c.point1,c.point2);f<a&&f<s&&(n=u.id,o=d,a=f,l=v)});break;case S.Curve:{const g=this.createSmoothCurvePoints(u.pointList.reduce((c,d)=>[...c,d.x,d.y],[]),.5,!0,h);for(let c=0;c<g.length-1;c++){const{length:d,footPoint:f}=C.getFootOfPerpendicular(t,g[c],g[c+1]);d<a&&d<s&&(n=u.id,o=Math.floor(c/(h+1)),a=d,l=f)}}break}}),{dropFoot:l,closestEdgeIndex:o,closestPolygonID:n}}static isPointListInPolygon(t,e,i=S.Line){return t.every(s=>this.isInPolygon(s,e,i))}static isPointListOutSidePolygon(t,e,i=S.Line){return t.some(s=>!this.isInPolygon(s,e,i))}static getPolygonArea(t){let e=0;for(let i=0,s=t.length;i<s;i++){const n=t[i].x,o=t[i===t.length-1?0:i+1].y,a=t[i===t.length-1?0:i+1].x,l=t[i].y;e+=n*o*.5,e-=a*l*.5}return Math.abs(e)}}var Xr=Object.defineProperty,Yr=Object.defineProperties,Gr=Object.getOwnPropertyDescriptors,mi=Object.getOwnPropertySymbols,Kr=Object.prototype.hasOwnProperty,Jr=Object.prototype.propertyIsEnumerable,Ii=(r,t,e)=>t in r?Xr(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ae=(r,t)=>{for(var e in t||(t={}))Kr.call(t,e)&&Ii(r,e,t[e]);if(mi)for(var e of mi(t))Jr.call(t,e)&&Ii(r,e,t[e]);return r},le=(r,t)=>Yr(r,Gr(t));class L{static getOffsetCoordinate(t,e,i){return{x:t.x*i+e.x,y:t.y*i+e.y}}static changeDrawOutsideTarget(t,e,i,s,n,o){return typeof s=="boolean"&&!s&&(n&&o?(t.x-e.x>(n.x+n.width)*o&&(t.x=(n.x+n.width)*o+e.x),t.x-e.x<n.x*o&&(t.x=n.x*o+e.x),t.y-e.y>(n.y+n.height)*o&&(t.y=(n.y+n.height)*o+e.y),t.y-e.y<n.y*o&&(t.y=n.y*o+e.y)):(t.x-e.x>i.width&&(t.x=i.width+e.x),t.x-e.x<0&&(t.x=e.x),t.y-e.y>i.height&&(t.y=i.height+e.y),t.y-e.y<0&&(t.y=e.y))),t}static changeCoordinateByRotate(t,e,i){const{width:s,height:n}=i,{x:o,y:a}=t;switch(e%360){case 90:return{x:n-a,y:o};case 180:return{x:s-o,y:n-a};case 270:return{x:a,y:s-o};default:return t}}static changeRectByZoom(t,e,i={x:0,y:0}){return le(ae({},t),{x:t.x*e+i.x,y:t.y*e+i.y,width:t.width*e,height:t.height*e})}static changePointByZoom(t,e,i={x:0,y:0}){return le(ae({},t),{x:t.x*e+i.x,y:t.y*e+i.y})}static changePointListByZoom(t,e,i={x:0,y:0}){return t.map(s=>this.changePointByZoom(s,e,i))}static axisArea(t,e=3){const{x:i,y:s}=t,n=[];for(let o=i-e;o<i+e;o+=e/3)for(let a=s-e;a<s+e;a+=e/3)n.push({x:o,y:a});return n}static getOriginCoordinateWithOffsetCoordinate(t,e=1,i={x:0,y:0}){return{x:(t.x-i.x)/e,y:(t.y-i.y)/e}}static returnClosePointIndex(t,e,i=3){let s=-1;for(let n=0;n<e.length;n++){const o=e[n];this.getIsInScope(t,o,i)&&(s=n)}return s}static getIsInScope(t,e,i){return Math.abs(t.x-e.x)<i&&Math.abs(t.y-e.y)<i}}class qr{constructor(t){this.currentPos=t.currentPos,this.zoom=t.zoom,this.basicImgInfo=t.basicImgInfo,this.dependToolName=""}get isDependPolygon(){return this.dependToolName===w.Polygon}get isDependRect(){return this.dependToolName===w.Rect}get isDependOriginalImage(){return this.dependToolName===""}getAbsCoord(t){return{x:(t.x-this.currentPos.x)/this.zoom,y:(t.y-this.currentPos.y)/this.zoom}}getRenderCoord(t){return{x:t.x*this.zoom+this.currentPos.x,y:t.y*this.zoom+this.currentPos.y}}coordInsideRect(t,e){const{x:i,y:s,width:n,height:o}=e;return{x:C.withinRange(t.x,[i,i+n]),y:C.withinRange(t.y,[s,s+o])}}getPolygonPointList(t,e){return t===S.Curve?H.createSmoothCurvePointsFromPointList(e):e}getIntersection(t,e,i){const s=this.getRenderCoord(e),n=this.getRenderCoord(t),o={pointA:s,pointB:n};return O.calcOptimalIntersection(i,o,s,or,this.zoom)}coordInsidePolygon(t,e,i,s){const{pointList:n}=i,o=s==null?void 0:s.lineType;if(n.length===0)return t;const a=this.getPolygonPointList(o,n);if(H.isInPolygon(t,a))return t;const h=a.concat(a[0]).map(g=>this.getRenderCoord(g)),u=this.getIntersection(t,e,h);return u?this.getAbsCoord(u==null?void 0:u.point):t}coordInsideImage(t){return this.coordInsideRect(t,le(ae({},this.basicImgInfo),{x:0,y:0}))}getNextCoordByDependTool(t,e){if(this.isDependRect)return this.coordInsideRect(t,this.basicResult);if(this.isDependPolygon)return this.coordInsidePolygon(t,e,this.basicResult,this.dependToolConfig);if(this.isDependOriginalImage)return this.coordInsideImage(t)}setDependInfo(t,e){this.dependToolName=t!=null?t:"",this.dependToolConfig=t?e:void 0}setBasicImgInfo(t){this.basicImgInfo=t}setBasicResult(t){this.basicResult=t}setZoomAndCurrentPos(t,e){this.zoom=t,this.currentPos=e}isCoordInsideTarget(t){if(this.isDependPolygon)return this.isInBasicPolygon(t);if(this.isDependRect){const{x:e,y:i,width:s,height:n}=this.basicResult,o=[e,e+s],a=[i,i+n];return C.isInRange(t.x,o)&&C.isInRange(t.y,a)}return C.isInRange(t.x,[0,this.basicImgInfo.width])&&C.isInRange(t.y,[0,this.basicImgInfo.height])}isInBasicPolygon(t){var e,i;return H.isInPolygon(t,((e=this.basicResult)==null?void 0:e.pointList)||[],(i=this.dependToolConfig)==null?void 0:i.lineType)}}var Qr=Object.defineProperty,tn=Object.defineProperties,en=Object.getOwnPropertyDescriptors,wi=Object.getOwnPropertySymbols,sn=Object.prototype.hasOwnProperty,rn=Object.prototype.propertyIsEnumerable,Li=(r,t,e)=>t in r?Qr(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,M=(r,t)=>{for(var e in t||(t={}))sn.call(t,e)&&Li(r,e,t[e]);if(wi)for(var e of wi(t))rn.call(t,e)&&Li(r,e,t[e]);return r},U=(r,t)=>tn(r,en(t));const It=6;class he extends it{constructor(t){super(t);this.setMarkerIndex=e=>{this.markerIndex=e},this.setMarkerIndexAndSelect=e=>{if(!this.config.markerList)return;this.markerIndex=e;const i=this.config.markerList[e].value,s=this.currentPageResult.find(n=>n.label===i);s&&(this.setSelectedID(s.id),this.config.attributeConfigurable===!0&&this.setDefaultAttribute(s.attribute)),this.emit("markIndexChange")},this.getHoverRectID=e=>{const i=this.getCoordinateUnderZoom(e),s=It,{currentShowList:n}=this;if(n.length>0){if(this.selectedRectID){const{selectedRect:a}=this;if(a&&$.isInRect(i,a,s,this.zoom))return a.id}const o=n.filter(a=>$.isInRect(i,a,s,this.zoom));if(o.length===0)return"";if(o.length===1)return o[0].id;if(o.length>1)return o.map(l=>({size:l.width*l.height,id:l.id})).sort((l,h)=>l.size-h.size)[0].id}return""},this.textChange=e=>{this.config.textConfigurable!==!0||!this.selectedRectID||(this.setRectList(T.textChange(e,this.selectedRectID,this.rectList),!0),this.emit("selectedChange"),this.render())},this.drawOutSideTarget=t.drawOutSideTarget||!1,this.rectList=[],this.isFlow=!0,this.config=x.jsonParser(t.config),this.hoverRectEdgeIndex=-1,this.hoverRectPointIndex=-1,this.markerIndex=0,this.setStyle(t.style),this.createNewDrawingRect=this.createNewDrawingRect.bind(this),this.getDrawingRectWithRectList=this.getDrawingRectWithRectList.bind(this),this.setSelectedIdAfterAddingDrawingRect=this.setSelectedIdAfterAddingDrawingRect.bind(this),this.getCurrentSelectedData=this.getCurrentSelectedData.bind(this),this.updateSelectedRectTextAttribute=this.updateSelectedRectTextAttribute.bind(this),this.setSelectedID=this.setSelectedID.bind(this)}setResult(t){if(this.clearActiveStatus(),this.setRectList(t),this.hasMarkerConfig){const e=x.getNextMarker(this.getCurrentPageResult(t),this.config.markerList);e&&this.setMarkerIndex(e.index)}this.render()}destroy(){super.destroy(),this._textAttributInstance&&this._textAttributInstance.clearTextAttribute()}setConfig(t,e=!1){this.config=x.jsonParser(t),e===!0&&this.clearResult(!1)}setRectList(t,e=!1){const i=this.rectList.length;this.rectList=t,i!==t.length&&this.emit("updatePageNumber"),e&&this.emit("updateResult")}get selectedRect(){return this.rectList.find(t=>t.id===this.selectedRectID)}get selectedID(){return this.selectedRectID}get selectedText(){var t;return(t=this.selectedRect)==null?void 0:t.textAttribute}get dataList(){return this.rectList}get currentShowList(){let t=[];const[e,i]=x.getRenderResultList(this.rectList,x.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);return t=e,this.isHidden&&(t=[]),i&&t.push(i),t}get currentPageResult(){const[t]=x.getRenderResultList(this.rectList,x.getSourceID(this.basicResult),[]);return t}getCurrentPageResult(t){const[e]=x.getRenderResultList(t,x.getSourceID(this.basicResult),[]);return e}setSelectedID(t){this.setSelectedRectID(t)}setSelectedRectID(t){var e,i;const s=this.selectedRectID;t!==s&&s&&((e=this._textAttributInstance)==null||e.changeSelected()),t||(i=this._textAttributInstance)==null||i.clearTextAttribute(),this.selectedRectID=t,this.render(),this.emit("selectedChange")}setStyle(t){var e;super.setStyle(t),this._textAttributInstance&&this.config.attributeConfigurable===!1&&((e=this._textAttributInstance)==null||e.updateIcon(this.getTextIconSvg()))}updateSelectedRectTextAttribute(t){if(this._textAttributInstance&&t){let e=t;T.textAttributeValidate(this.config.textCheckType,"",e)===!1&&(this.emit("messageError",T.getErrorNotice(this.config.textCheckType,this.lang)),e=""),this.setRectList(this.rectList.map(i=>i.id===this.selectedRectID?U(M({},i),{textAttribute:e}):i),!0),this.emit("updateTextAttribute"),this.render()}}getHoverRectPointIndex(t){return this.selectedRect?L.returnClosePointIndex(this.getCoordinateUnderZoom(t),$.getRectPointList(this.selectedRect,this.zoom),It+2):-1}getHoverRectEdgeIndex(t){if(!this.selectedRect)return-1;let e=-1;const{selectedRect:i}=this,s=$.getRectEdgeList(i,this.zoom),n=this.getCoordinateUnderZoom(t);for(let o=0;o<s.length;o++){const a=s[o],{length:l}=C.getFootOfPerpendicular(n,a.begin,a.end);l<It+10&&(e=o)}return e}getTextIconSvg(t=""){return T.getTextIconSvg(t,this.config.attributeList,this.config.attributeConfigurable,this.baseIcon)}onMouseDown(t){if(super.onMouseDown(t)||this.forbidMouseOperation||t.ctrlKey===!0)return;const e=this.getCoordinateUnderZoom(t),i=this.getHoverRectID(t),s=this.currentShowList.find(n=>n.id===this.selectedRectID);if(!(!s||t.button===2||t.button===0&&this.isSpaceKey===!0)){if(this.selectedRectID){if(this.getHoverRectPointIndex(t)>-1){const n=z.Point;this.dragInfo={dragStartCoord:e,dragTarget:n,startTime:+new Date,firstRect:s},this.dragStatus=k.Start;return}if(this.getHoverRectEdgeIndex(t)>-1){const n=z.Line;this.dragInfo={dragStartCoord:e,dragTarget:n,startTime:+new Date,firstRect:s},this.dragStatus=k.Start;return}}if(i===this.selectedRectID&&!this.drawingRect){const n=z.Plane;this.dragInfo={dragStartCoord:e,dragTarget:n,firstRect:s,startTime:+new Date},this.dragStatus=k.Start}}}onDragMove(t){var e,i,s,n,o,a;if(!this.dragInfo)return;this.dragStatus=k.Move;const l=$.getRectUnderZoom(this.dragInfo.firstRect,this.zoom),{x:h,y:u,width:g,height:c}=l,d={x:t.x-this.dragInfo.dragStartCoord.x,y:t.y-this.dragInfo.dragStartCoord.y};let f=this.rectList.filter(v=>v.id===this.selectedRectID)[0];switch(this.dragInfo.dragTarget){case z.Plane:f=U(M({},f),{x:h+d.x,y:u+d.y,width:g,height:c});break;case z.Point:{let v=h,p=u,b=g,y=c;switch(this.hoverRectPointIndex){case 0:{v=g-d.x<0?h+g:h+d.x,p=c-d.y<0?u+c:u+d.y,b=Math.abs(d.x-g),y=Math.abs(d.y-c);break}case 1:{v=g+d.x>0?h:h+g+d.x,p=c-d.y<0?u+c:u+d.y,b=Math.abs(g+d.x),y=Math.abs(c-d.y);break}case 2:{v=g+d.x>0?h:h+g+d.x,p=c+d.y>0?u:u+c+d.y,b=Math.abs(g+d.x),y=c+d.y>0?c+d.y:Math.abs(c+d.y);break}case 3:{v=g-d.x<0?h+g:h+d.x,p=c+d.y>0?u:u+c+d.y,b=Math.abs(d.x-g),y=c+d.y>0?c+d.y:Math.abs(c+d.y);break}default:return}f=U(M({},f),{x:v,y:p,width:b,height:y})}break;case z.Line:{let v=h,p=u,b=g,y=c;switch(this.hoverRectEdgeIndex){case 0:{p=c-d.y<0?u+c:u+d.y,y=Math.abs(d.y-c);break}case 1:{v=g+d.x>0?h:h+g+d.x,b=Math.abs(g+d.x);break}case 2:{p=c+d.y>0?u:u+c+d.y,y=c+d.y>0?c+d.y:Math.abs(c+d.y);break}case 3:{v=g-d.x<0?h+g:h+d.x,b=Math.abs(d.x-g);break}default:return}f=U(M({},f),{x:v,y:p,width:b,height:y});break}default:return}if(this.config.drawOutsideTarget===!1){if(this.basicResult){if(((i=(e=this.basicResult)==null?void 0:e.pointList)==null?void 0:i.length)>0&&$.isRectNotInPolygon(f,xe(this.basicResult.pointList,this.zoom)))return;const v=this.basicResult.x*this.zoom,p=this.basicResult.y*this.zoom,b=this.basicResult.width*this.zoom,y=this.basicResult.height*this.zoom;if(this.dragInfo.dragTarget!==z.Plane&&(f.x<v-.01||f.y<p-.01||f.width>v+b-f.x+.01||f.height>p+y-f.y+.01))return;if(f.x<v&&(f.x=v),f.y<p&&(f.y=p),f.width>v+b-f.x)switch(this.dragInfo.dragTarget){case z.Plane:f.x=v+b-g;break;case z.Point:case z.Line:d.x>0&&d.y>0&&(f.width=v+b-f.x);break;default:return}if(f.height>p+y-f.y)switch(this.dragInfo.dragTarget){case z.Plane:f.y=p+y-c;break}}else if(f.x<0&&(f.x=0),f.y<0&&(f.y=0),this.imgInfo)switch(this.dragInfo.dragTarget){case z.Plane:f.x+f.width>((s=this.imgInfo)==null?void 0:s.width)&&(f.x=this.imgInfo.width-g),f.y+f.height>((n=this.imgInfo)==null?void 0:n.height)&&(f.y=this.imgInfo.height-c);break;default:if(f.x+f.width>((o=this.imgInfo)==null?void 0:o.width)||f.y+f.height>((a=this.imgInfo)==null?void 0:a.height))return}}this.setRectList(this.rectList.map(v=>v.id===f.id?$.getRectUnderZoom(f,1/this.zoom):v)),this.render()}onMouseMove(t){var e,i;if(super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo)return;const s=this.getCoordinateUnderZoom(t),n=L.changeDrawOutsideTarget(s,{x:0,y:0},this.imgInfo,this.config.drawOutsideTarget,this.basicResult,this.zoom);if(this.selectedRectID&&this.dragInfo){this.onDragMove(n);return}if(this.selectedRectID){const l=this.getHoverRectPointIndex(t);if(l!==this.hoverRectPointIndex){this.hoverRectPointIndex=l,this.hoverRectEdgeIndex=-1,this.render();return}if(this.hoverRectPointIndex===-1){const h=this.getHoverRectEdgeIndex(t);if(h!==this.hoverRectEdgeIndex){this.hoverRectEdgeIndex=h,this.render();return}}}const o=this.getHoverRectID(t),a=this.hoverRectID;if(this.hoverRectID=o,o!==a&&this.render(),this.drawingRect&&this.firstClickCoord){let{x:l,y:h}=this.firstClickCoord,{width:u,height:g}=this.drawingRect;if(u=Math.abs(l-n.x),g=Math.abs(h-n.y),n.x<l&&(l=n.x),n.y<h&&(h=n.y),this.config.drawOutsideTarget===!1){if(((i=(e=this.basicResult)==null?void 0:e.pointList)==null?void 0:i.length)>0&&$.isRectNotInPolygon(U(M({},this.drawingRect),{x:l,y:h,width:u,height:g}),xe(this.basicResult.pointList,this.zoom)))return;n.x<0&&(u=Math.abs(this.firstClickCoord.x),l=0),n.y<0&&(g=Math.abs(this.firstClickCoord.y),h=0),this.imgInfo&&(l+u>this.imgInfo.width&&(u=Math.abs(this.imgInfo.width-l)),h+g>this.imgInfo.height&&(g=Math.abs(this.imgInfo.height-h)))}this.drawingRect=U(M({},this.drawingRect),{x:l,y:h,width:u,height:g}),this.render()}}setAttributeLockList(t){this.setSelectedRectID(void 0),super.setAttributeLockList(t)}setBasicResult(t){super.setBasicResult(t),this.clearActiveStatus()}setRectValidAndRender(t){!t||(this.setRectList(this.rectList.map(e=>e.id===t?U(M({},e),{valid:!e.valid}):e),!0),this.render(),this.emit("updateResult"))}createNewDrawingRect(t,e){if(!this.imgInfo)return;const i=this.getCoordinateUnderZoom(t),s=L.changeDrawOutsideTarget(i,{x:0,y:0},this.imgInfo,this.config.drawOutsideTarget,this.basicResult,this.zoom);if(this.setSelectedRectID(""),this.hoverRectID="",this.drawOutSideTarget&&(s.x<0&&(s.x=0),s.y<0&&(s.y=0)),this.drawingRect=U(M({},s),{width:0,height:0,attribute:this.defaultAttribute,valid:!t.ctrlKey,id:K(8,62),sourceID:e,textAttribute:""}),this.hasMarkerConfig){const n=x.getNextMarker(this.currentPageResult,this.config.markerList,this.markerIndex);if(n)this.drawingRect&&(this.drawingRect=U(M({},this.drawingRect),{label:n.label})),this.markerIndex=n.index,this.emit("markIndexChange");else{this.emit("messageInfo",F.getMessagesByLocale(D.MarkerFinish,this.lang)),this.drawingRect=void 0;return}}if(this.config.textConfigurable){let n="";n=T.getTextAttribute(this.rectList.filter(o=>x.isSameSourceID(o.sourceID,e)),this.config.textCheckType),this.drawingRect&&(this.drawingRect=U(M({},this.drawingRect),{textAttribute:n}))}Object.assign(this.drawingRect,{order:x.getMaxOrder(this.rectList.filter(n=>x.isSameSourceID(n.sourceID,e)))+1}),this.firstClickCoord=M({},s),this.firstCurrentPos=M({},this.currentPos)}addDrawingRectToRectList(){if(!this.drawingRect)return;let{width:t,height:e}=this.drawingRect;if(t/=this.zoom,e/=this.zoom,Math.round(t)<this.config.minWidth||Math.round(e)<this.config.minHeight){this.emit("messageInfo",F.getMessagesByLocale(D.RectErrorSizeNotice,this.lang)),this.drawingRect=void 0,this.firstClickCoord=void 0,this.dragInfo=void 0,this.dragStatus=k.Wait,this.render();return}const i=this.getDrawingRectWithRectList();this.setRectList(i,!0),this.history.pushHistory(this.rectList),this.setSelectedIdAfterAddingDrawingRect(),this.firstClickCoord=void 0,this.drawingRect=void 0,this.dragInfo=void 0,this.dragStatus=k.Wait}setSelectedIdAfterAddingDrawingRect(){!this.drawingRect||(this.config.textConfigurable?this.setSelectedRectID(this.drawingRect.id):this.setSelectedRectID())}getDrawingRectWithRectList(){if(!this.drawingRect)return this.rectList;let{x:t,y:e,width:i,height:s}=this.drawingRect;return t/=this.zoom,e/=this.zoom,i/=this.zoom,s/=this.zoom,[...this.rectList,U(M({},this.drawingRect),{x:t,y:e,width:i,height:s})]}rightMouseUp(t){const e=this.getHoverRectID(t),i=this.rectList.find(n=>n.id===e),{selectedRectID:s}=this;if(this.setSelectedRectID(void 0),i&&this.setDefaultAttribute(i.attribute),this.drawingRect)this.drawingRect=void 0,this.firstClickCoord=void 0;else if(s!==e&&this.dblClickListener.clearRightDblClick(),this.setSelectedRectID(e),this.hoverRectID="",(i==null?void 0:i.label)&&this.hasMarkerConfig){const n=x.getCurrentMarkerIndex(i.label,this.config.markerList);n>=0&&(this.setMarkerIndex(n),this.emit("markIndexChange"))}this.render()}shiftRightMouseUp(t){const e=this.getHoverRectID(t);this.emit("shiftRightMouseUp",e)}onMouseUp(t){if(super.onMouseUp(t)||this.forbidMouseOperation||!this.imgInfo)return!0;if(this.dragInfo&&this.dragStatus===k.Move){this.dragInfo=void 0,this.dragStatus=k.Wait,this.history.pushHistory(this.rectList),this.emit("updateResult");return}if(t.button===2&&t.shiftKey===!0){this.shiftRightMouseUp(t);return}if(t.button===2){this.rightMouseUp(t);return}const e=x.getSourceID(this.basicResult);if(this.drawingRect){this.addDrawingRectToRectList();return}if(t.ctrlKey===!0&&t.button===0&&this.hoverRectID){this.setRectValidAndRender(this.hoverRectID);return}this.createNewDrawingRect(t,e),this.render()}onRightDblClick(t){super.onRightDblClick(t);const e=this.getHoverRectID(t);this.selectedRectID&&this.selectedRectID===e&&this.deleteRect(e)}onKeyDown(t){if(!x.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;const{keyCode:e}=t;switch(e){case _.Ctrl:this.drawingRect&&(this.drawingRect=U(M({},this.drawingRect),{valid:!t.ctrlKey}),this.render());break;case _.F:this.selectedRectID&&this.setRectValidAndRender(this.selectedRectID);break;case _.Z:this.setIsHidden(!this.isHidden),this.render();break;case _.Delete:this.deleteRect(this.selectedRectID);break;case _.Tab:{if(t.preventDefault(),this.drawingRect)return;let i=j.ascend;t.shiftKey&&(i=j.descend);const[s,n]=x.getRenderResultList(this.rectList,x.getSourceID(this.basicResult),this.attributeLockList,this.selectedRectID);let o=[...s];n&&(o=[...o,n]);const a=et.getViewPort(this.canvas,this.currentPos,this.zoom);o=o.filter(h=>et.inViewPort({x:h.x,y:h.y},a));const l=x.getNextSelectedRectID(o,i,this.selectedRectID);l&&(this.setSelectedRectID(l.id),this.config.attributeConfigurable===!0&&this.setDefaultAttribute(l.attribute));break}default:{if(this.config.attributeConfigurable){const i=T.getAttributeByKeycode(e,this.config.attributeList);i!==void 0&&this.setDefaultAttribute(i)}break}}return!0}onKeyUp(t){switch(super.onKeyUp(t),t.keyCode){case _.Ctrl:this.drawingRect&&(this.drawingRect=U(M({},this.drawingRect),{valid:!0}),this.render());break}}onWheel(t){const e=this.zoom;let i,s;this.drawingRect&&this.firstClickCoord&&(i=$.getRectUnderZoom(this.drawingRect,1/e),s=L.changePointByZoom(this.firstClickCoord,1/e)),super.onWheel(t,!1),i&&s&&(this.drawingRect=$.getRectUnderZoom(i,this.zoom),this.firstClickCoord=L.changePointByZoom(s,this.zoom)),this.render()}getCurrentSelectedData(){const{selectedRect: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:t.width*this.zoom*.6,textAttribute:t.textAttribute,color:i}}renderTextAttribute(){var t;const{selectedRect:e}=this;if(!this.ctx||this.config.textConfigurable!==!0||!e)return;const{x:i,y:s,width:n,height:o,attribute:a,valid:l}=e,h=n*this.zoom*.6,u=L.getOffsetCoordinate({x:i,y:s+o},this.currentPos,this.zoom),g=this.getColor(a),c=l?g==null?void 0:g.valid.stroke:g==null?void 0:g.invalid.stroke,d=4;this._textAttributInstance||(this._textAttributInstance=new Ot({width:h,container:this.container,icon:this.getTextIconSvg(a),color:c,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedRectTextAttribute})),this._textAttributInstance&&!((t=this._textAttributInstance)==null?void 0:t.isExit)&&this._textAttributInstance.appendToContainer(),this._textAttributInstance.update(`${e.textAttribute}`,{left:u.x,top:u.y+d,color:c,width:h})}renderSelectedRect(t){const{selectedRect:e}=this;if(!this.ctx||!t||!e)return;const{ctx:i}=this;let s=10;const n=$.getRectPointList(e),o=n.length,a=this.getColor(t.attribute);n.forEach((l,h)=>{var u,g;if(i.save(),i.moveTo(l.x,l.y),i.beginPath(),this.hoverRectPointIndex===h?s=It+6:s=It,t.valid===!1?(i.strokeStyle=a==null?void 0:a.invalid.stroke,i.fillStyle=a==null?void 0:a.invalid.stroke):(i.strokeStyle=a==null?void 0:a.valid.stroke,i.fillStyle=a==null?void 0:a.valid.stroke),i.arc(l.x*this.zoom+this.currentPos.x,l.y*this.zoom+this.currentPos.y,s,0,2*Math.PI),i.fill(),this.hoverRectEdgeIndex===h){i.beginPath(),i.lineWidth=10;const c=this.getColor(t.attribute),d=t.valid===!1?(u=c==null?void 0:c.invalid)==null?void 0:u.stroke:(g=c==null?void 0:c.valid)==null?void 0:g.stroke;i.strokeStyle=d,i.moveTo(n[h].x*this.zoom+this.currentPos.x,n[h].y*this.zoom+this.currentPos.y),i.lineTo(n[(h+1)%o].x*this.zoom+this.currentPos.x,n[(h+1)%o].y*this.zoom+this.currentPos.y),i.stroke()}i.restore()}),this.renderTextAttribute()}renderDrawingRect(t,e=this.zoom,i=!1){var s,n,o,a;if(this.ctx&&t){const{ctx:l,style:h}=this,{hiddenText:u=!1}=h,g=this.getColor(t.attribute);let{x:c,y:d,width:f,height:v}=t;c*=e,d*=e,f*=e,v*=e,l.save();let p;t.valid===!1?(l.strokeStyle=g==null?void 0:g.invalid.stroke,l.fillStyle=g==null?void 0:g.invalid.fill,p=g==null?void 0:g.invalid.stroke):(l.strokeStyle=g==null?void 0:g.valid.stroke,l.fillStyle=g==null?void 0:g.valid.fill,p=g==null?void 0:g.valid.stroke),l.font="lighter 14px Arial";let b="";((s=this.config)==null?void 0:s.isShowOrder)&&t.order&&(t==null?void 0:t.order)>0&&(b=`${t.order}`),t.label&&this.hasMarkerConfig&&(b=`${x.getCurrentMarkerIndex(t.label,this.config.markerList)+1}_${re.getMarkerShowText(t.label,this.config.markerList)}`),t.attribute&&(b=`${b} ${T.getAttributeShowText(t.attribute,(n=this.config)==null?void 0:n.attributeList)}`),u||m.drawText(this.canvas,{x:this.currentPos.x+c,y:this.currentPos.y+d-6},b,U(M({color:p,font:"normal normal 900 14px SourceHanSansCN-Regular"},dt),{textMaxWidth:300})),l.lineWidth=(a=(o=this.style)==null?void 0:o.width)!=null?a:2,(t.id===this.hoverRectID||t.id===this.selectedRectID)&&l.fillRect(this.currentPos.x+c,this.currentPos.y+d,f,v),l.strokeRect(this.currentPos.x+c,this.currentPos.y+d,f,v),l.restore();let y=`${Math.round(f/e)} * ${Math.round(v/e)}`;i===!0&&(y=`${Math.round(f/this.zoom)} * ${Math.round(v/this.zoom)}`);const P=y.length*7,A=t.valid?g==null?void 0:g.valid.stroke:g==null?void 0:g.invalid.stroke;if(u||m.drawText(this.canvas,{x:this.currentPos.x+c+f-P,y:this.currentPos.y+d+v+15},y,M({color:A,font:"normal normal 600 14px Arial"},dt)),!u&&t.textAttribute&&t.id!==this.selectedRectID){const I=0,R=Math.max(20,f-P);m.drawText(this.canvas,{x:this.currentPos.x+c,y:this.currentPos.y+d+v+20+I},t.textAttribute,M({color:A,font:"italic normal 900 14px Arial",textMaxWidth:R},dt))}}}renderRect(){var t;if(((t=this.rectList)==null?void 0:t.length)>0&&JSON.stringify(this.rectList)){const[e,i]=x.getRenderResultList(this.rectList,x.getSourceID(this.basicResult),this.attributeLockList,this.selectedRectID);this.isHidden||e==null||e.forEach(s=>this.renderDrawingRect(s)),i&&(this.renderDrawingRect(i),this.renderSelectedRect(i))}this.drawingRect&&this.renderDrawingRect(this.drawingRect,1,!0)}render(){!this.ctx||(super.render(),this.renderRect(),this.renderCursorLine(this.getLineColor(this.defaultAttribute)))}setDefaultAttribute(t){const e=this.defaultAttribute;if(this.defaultAttribute=t!=null?t:"",e!==t){this.changeStyle(t),this.emit("changeAttributeSidebar");const{selectedRect:i}=this;if(i&&(this.setRectList(this.rectList.map(s=>s.id===this.selectedID?U(M({},s),{attribute:this.defaultAttribute}):s),!0),this.history.pushHistory(this.rectList),this.render()),this.drawingRect&&(this.drawingRect=U(M({},this.drawingRect),{attribute:this.defaultAttribute}),this.render()),this._textAttributInstance){if(this.attributeLockList.length>0&&!this.attributeLockList.includes(this.defaultAttribute)){this._textAttributInstance.clearTextAttribute();return}this._textAttributInstance.updateIcon(this.getTextIconSvg(t))}}}setValid(t){super.setValid(t),this.emit("updateResult")}clearActiveStatus(){this.drawingRect=void 0,this.firstClickCoord=void 0,this.dragInfo=void 0,this.dragStatus=k.Wait,this.setSelectedRectID(void 0)}clearResult(t=!0){const e=this.rectList.filter(i=>i.disableDelete===!0);e.length>0&&t&&this.emit("messageInfo",F.getMessagesByLocale(D.ClearPartialData,this.lang)),this.setRectList(e,!0),this.setSelectedRectID(void 0)}deleteRect(t){var e;if(!t)return;const i=this.rectList.find(s=>s.id===t);if((i==null?void 0:i.disableDelete)===!0){this.emit("messageInfo",F.getMessagesByLocale(D.DisableDelete,this.lang));return}this.setRectList(this.rectList.filter(s=>s.id!==t),!0),this.history.pushHistory(this.rectList),this.setSelectedRectID(void 0),(e=this._textAttributInstance)==null||e.clearTextAttribute(),this.render()}exportData(){const{rectList:t}=this;return[t,this.basicImgInfo]}undo(){const t=this.history.undo();t&&(t.length!==this.rectList.length&&this.setSelectedRectID(""),this.setRectList(t,!0),this.render())}redo(){const t=this.history.redo();t&&(t.length!==this.rectList.length&&this.setSelectedRectID(""),this.setRectList(t,!0),this.render())}}var nn=Object.defineProperty,on=Object.defineProperties,an=Object.getOwnPropertyDescriptors,Pi=Object.getOwnPropertySymbols,ln=Object.prototype.hasOwnProperty,hn=Object.prototype.propertyIsEnumerable,Ci=(r,t,e)=>t in r?nn(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,cn=(r,t)=>{for(var e in t||(t={}))ln.call(t,e)&&Ci(r,e,t[e]);if(Pi)for(var e of Pi(t))hn.call(t,e)&&Ci(r,e,t[e]);return r},dn=(r,t)=>on(r,an(t));const un={textConfigurable:!1,attributeConfigurable:!0,attributeList:[]};class gn extends he{constructor(t){super(dn(cn({},t),{config:JSON.stringify(un)}))}setSelectedIdAfterAddingDrawingRect(){!this.drawingRect||this.setSelectedRectID(this.drawingRect.id)}}class fn{constructor(t){this._domMap=new Map,this._container=t.container,this._height=t.height}wheelChange(t){t.stopPropagation()}clearTag(t){const e=this._container,i=window.self.document.getElementById(t);i&&e&&e.contains(i)&&(i.removeEventListener("wheel",this.wheelChange),e==null||e.removeChild(i))}render(t){const e=Array.from(this._domMap.keys()),i=t.map(s=>s.id);t.forEach(s=>{const{text:n,textMaxWidth:o,color:a="white",background:l="rgba(0, 0, 0, 0.6)",style:h}=s;if(this._domMap.has(s.id)){const u=this._domMap.get(s.id);u&&(u.innerHTML=n)}else{const u=m.drawTagByDom(this._container,n,s.id);u&&(u.setAttribute("style",`
|
|
77
|
+
`),(o=(n=this.canvas)==null?void 0:n.parentNode)==null||o.appendChild(a)}render(){this.renderTag(),super.render(),this.emit("render")}exportData(){let{tagResult:t}=this;return this.isImgError&&(t=[]),[t,this.basicImgInfo]}}var _r=Object.defineProperty,Ar=Object.defineProperties,Rr=Object.getOwnPropertyDescriptors,ni=Object.getOwnPropertySymbols,Tr=Object.prototype.hasOwnProperty,Sr=Object.prototype.propertyIsEnumerable,oi=(r,t,e)=>t in r?_r(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ee=(r,t)=>{for(var e in t||(t={}))Tr.call(t,e)&&oi(r,e,t[e]);if(ni)for(var e of ni(t))Sr.call(t,e)&&oi(r,e,t[e]);return r},ie=(r,t)=>Ar(r,Rr(t)),ai;(function(r){r[r.Create=0]="Create",r[r.Active=1]="Active",r[r.None=2]="None"})(ai||(ai={}));const st=16,Mt={x:0,y:20},se=3,Et=5,kr=2;class li extends it{constructor(t){super(t);this.drawActivatedLine=(e,i,s)=>{const n=N.cloneDeep(this.activeLine);if(!n||n.length===0)return;const o=this.isActiveLineValid();let a;const l=this.selectedID?this.lineList.find(d=>d.id===this.selectedID):void 0;l?a=l.order:a=this.nextOrder();const h=this.getLineColorByAttribute({attribute:this.defaultAttribute,valid:!!o});n.map(d=>Object.assign(d,this.coordUtils.getRenderCoord(d))),this.updateActiveArea(),this.drawLine(n,e,h,!0,!0),this.drawLineNumber(n[0],a,h,"",this.defaultAttribute,o),e&&this.isCreate&&this.arc(e,se,h),this.cursor&&!this.selectedPoint&&!s&&!this.isShift&&this.arc(this.cursor,Et,h)},this.drawHoverPoint=e=>{if(!this.isMousedown&&e&&this.isLineSelected){const i=this.getPointList(this.activeLine),s=this.activeLine.find(o=>O.calcDistance(this.coordUtils.getRenderCoord(o),e)<=Et);let n;!s&&this.activeLine&&(n=this.findNearestPoint(i,e)),this.hoverPointID=s?s.id:void 0,this.cursor=s||n==null?void 0:n.point}},this.lineList=[],this.activeLine=[],this.coordsInsideActiveArea=!1,this.hoverLineSegmentIndex=-1,this.isShift=!1,this.isReference=!1,this.drawCurveLine=(e,i,s,n=!0,o=!1,a)=>{const l=_t(i,st);e.save(),e.lineCap="round",e.lineJoin="round",e.strokeStyle=s.color,n&&(e.lineWidth=s.lineWidth),o&&O.setReferenceCtx(e),i.forEach(({specialEdge:h},d)=>{const g=l.splice(0,st+1);e.save(),e.beginPath(),a===d&&(e.lineWidth=4),g.forEach(({x:u,y:c},f)=>{const v=f>0?"lineTo":"moveTo";h&&O.setSpecialEdgeStyle(e),e[v](u,c)}),e.stroke(),e.restore()}),e.restore()},this.drawLine=(e,i,s,n=!1,o=!1)=>{const a=i?e.concat(i):e,l={color:s,lineWidth:o?1:this.lineStyle.lineWidth};this.isCurve?O.drawCurveLine(this.ctx,a,l,!n,this.isReference,o?this.hoverLineSegmentIndex:-1):this.drawStraightLine(a,l,o),n&&e.forEach(h=>{var d,g;const u=h.id,c=u&&[this.hoverPointID,(d=this.selectedPoint)==null?void 0:d.id].includes(u)?Et:se;this.arc(h,c,s),[this.hoverPointID,(g=this.selectedPoint)==null?void 0:g.id].includes(u)||this.arc(h,kr,"white")})},this.drawStraightLine=(e,i,s=!1)=>{const{ctx:n}=this;n&&(n.save(),n.lineCap="round",n.lineJoin="round",n.strokeStyle=i.color,n.lineWidth=i.lineWidth,this.isReference&&O.setReferenceCtx(n),e.forEach((o,a)=>{if(n.beginPath(),a>0){const l=e[a-1];n.save(),(l==null?void 0:l.specialEdge)&&O.setSpecialEdgeStyle(n),s&&this.hoverLineSegmentIndex+1===a&&(n.lineWidth=4),n.moveTo(l.x,l.y),n.lineTo(o.x,o.y),n.stroke(),n.restore()}}),n.restore())},this.drawLines=()=>{try{const e=N.cloneDeep(this.attributeFilteredLines);if(this.isHidden)return;e.forEach(i=>{if(i.id!==this.selectedID&&i.pointList){i.pointList.map(l=>Object.assign(l,this.coordUtils.getRenderCoord(l)));const{order:s,label:n}=i,o=s,a=i&&this.getLineColorByAttribute(i);this.drawLine(i.pointList,void 0,a,!1),this.drawLineNumber(i.pointList[0],o,a,n,i.attribute,i.valid),i.id!==this.textEditingID&&this.drawLineTextAttribute(i.pointList[1],a,i==null?void 0:i.textAttribute)}})}catch(e){console.error(e,"\u7EBF\u6761\u5DE5\u5177\u6570\u636E\u89E3\u6790\u9519\u8BEF"),this.lineList=[],this.clearCanvas()}},this.render=e=>{super.render(),this.drawLines(),this.drawActivatedLine(e,void 0,!0),this.renderTextAttribute(),this.renderCursorLine(this.getLineColor(this.defaultAttribute))},this.moveLineInPolygon=(e,i)=>{var s;if(!Array.isArray(this.activeLine))return!1;((s=this.activeLine)==null?void 0:s.every(o=>this.isInBasicPolygon({x:o.x+e,y:o.y+i})))&&(this.lineDragging=!0,this.moveActiveArea(e,i))},this.moveLineInRectRange=(e,i,s,n)=>{if(this.activeArea===void 0)return;const{top:o,left:a,right:l,bottom:h}=this.activeArea,d=[a,l].map(p=>N.isNumber(p)?p+e:0),g=[o,h].map(p=>N.isNumber(p)?p+i:0),u=a>=0&&l&&C.isInRange(d,s),c=o>=0&&h&&C.isInRange(g,n),f=u?e:0,v=c?i:0;this.lineDragging=!0,this.moveActiveArea(f,v)},this.onRightClick=e=>{if(this.cursor=void 0,this.isCreate){if(this.isLinePointsNotEnough())return;this.stopLineCreating(!0);return}this.setActiveArea(this.getCoordinate(e),!0),this.emit("contextmenu")},this.updateSelectedAttributeAfterHistoryChanged=()=>{if(this.selectedID){const e=this.lineList.find(s=>s.id===this.selectedID),i=e==null?void 0:e.attribute;typeof i=="string"&&(this.defaultAttribute=i,this.updateAttribute(i),this.render())}},this.onLeftClick=e=>{const i=this.getCoordinate(e),{lineDragging:s}=this;if(this.lineDragging=!1,this.isSpaceKey)return;if(this.isNone&&e.ctrlKey){const o=this.findHoverLine(i);o&&this.setInvalidLine(o.id);return}if(this.isLinePointsExceed())return;const n=this.getNextPoint(e,i);if(this.isCreate||this.isNone){this.setCreatStatusAndAddPoint(n);return}if(this.isActive){if(s)return;if(this.isMouseCoordOutsideActiveArea()){this.setNoneStatus(!1),this.setCreatStatusAndAddPoint(n);return}if(e.shiftKey){this.updateLineSegmentSpecial(i);return}if(this.coordsInsideActiveArea&&e.ctrlKey){this.setInvalidLine(this.selectedID);return}this.addLinePointToActiveLine()}},this.onDblclick=()=>{},this.onKeyUp=e=>{if(super.onKeyUp(e),this.isShift=!1,this.hoverLineSegmentIndex=-1,e.keyCode===_.Esc){this.stopLineCreating(!1);return}if(this.isActive){if(e.keyCode===_.Delete){this.deleteLine();return}if(e.keyCode===_.F){this.setInvalidLine(this.selectedID);return}if(e.keyCode===_.Space){this.continueToEdit();return}}this.keyboardEventWhileLineCreating(e)},this.onRightDblClick=e=>{super.onRightDblClick(e);const i=this.getCoordinate(e);if(this.isActive){const s=this.findHoveredPoint(i);if(s){this.deleteSelectedLinePoint(s.id);return}this.deleteSelectedLine(i)}},this.setReference=e=>{this.isReference=e},this.pointsWithinRange=e=>!(this.lowerLimitPointNum&&e<this.lowerLimitPointNum||this.upperLimitPointNum&&e>this.upperLimitPointNum),this.setLineList=e=>{const i=e.length!==this.lineListLen;this.lineList=e,i&&this.emit("updatePageNumber")},this.textChange=e=>{this.config.textConfigurable===!1||!this.selectedID||(this.updateSelectedTextAttribute(e),this.emit("selectedChange"))},this.status=2,this.isMousedown=!1,this.lineDragging=!1,this.isLineValid=!0,this.setConfig(t.config),this.prevAxis={x:0,y:0},this.textEditingID="",this.updateSelectedTextAttribute=this.updateSelectedTextAttribute.bind(this),this.getCurrentSelectedData=this.getCurrentSelectedData.bind(this),this.actionsHistory=new qt,this.dependToolConfig={lineType:S.Line}}get isLineSelected(){return this.selectedID&&this.activeLine}get selectedLinePoints(){return this.activeLine?this.getPointList(this.activeLine):[]}get isCreate(){return this.status===0}get isActive(){return this.status===1}get isNone(){return this.status===2}get isCurve(){return this.config.lineType===S.Curve}get isMultipleColor(){return this.config.lineColor===Pt.MultiColor}get imageSize(){return this.rotate%180==0?this.basicImgInfo:{width:this.basicImgInfo.height,height:this.basicImgInfo.width}}get lineListLen(){return this.lineList.length}get edgeAdsorptionEnabled(){return this.edgeAdsorption&&!this.isCurve&&this.lineListLen>0}get attributeConfigurable(){return this.config.attributeConfigurable}get isTextConfigurable(){return this.config.textConfigurable}get isDependPolygon(){return this.dependToolName===w.Polygon}get isDependRect(){return this.dependToolName===w.Rect}get isCurrentAttributeLocked(){return this.attributeLockList.includes(this.defaultAttribute)}get attributeFilteredLines(){return this.attributeLockList.length>0?this.lineList.filter(t=>this.attributeLockList.includes((t==null?void 0:t.attribute)||"")):this.lineList}get enableOutOfTarget(){return this.config.enableOutOfTarget}get showOrder(){return this.config.showOrder}get edgeAdsorption(){return this.config.edgeAdsorption}get attributeList(){return this.config.attributeList}get lowerLimitPointNum(){return this.config.lowerLimitPointNum}get upperLimitPointNum(){return this.config.upperLimitPointNum}get textCheckType(){return this.config.textCheckType}get customFormat(){return this.config.customFormat}get dataList(){return this.lineList}get hasActiveLine(){return this.activeLine&&this.activeLine.length>0}get viewPortLines(){const t=et.getViewPort(this.canvas,this.currentPos,this.zoom);return this.isHidden?[]:this.attributeFilteredLines.filter(e=>{var i;return(i=e==null?void 0:e.pointList)==null?void 0:i.some(s=>et.inViewPort(s,t))})}get lineStyle(){return{lineWidth:this.style.width,color:this.getLineColor(this.defaultAttribute),opacity:this.style.opacity}}get selectedText(){var t,e;return(e=(t=this.lineList.find(i=>i.id===this.selectedID))==null?void 0:t.textAttribute)!=null?e:""}get currentPageResult(){return this.lineList}updateStatus(t,e=!1){if(t!==this.status){if(e){let i="";this.textCheckType===V.Order&&this.isTextConfigurable&&(i=T.getTextAttribute(this.lineList,this.textCheckType)),this.emit("updateText",i)}this.status=t,this.lineStatusChanged()}}isInBasicPolygon(t){var e,i;return be(t,((e=this.basicResult)==null?void 0:e.pointList)||[],(i=this.dependToolConfig)==null?void 0:i.lineType)}getPolygonPointList(){if(!this.basicResult)return[];const{pointList:t}=this.basicResult,{lineType:e}=this.dependToolConfig;return e===S.Curve?Yt(t.reduce((i,s)=>[...i,s.x,s.y],[]),.5,!0,20):t}getNextCoordByRenderCoord(t){return this.getNextCoordByAbsCoord(this.coordUtils.getAbsCoord(t))}getNextCoordByAbsCoord(t){var e;const i=(e=this.activeLine)==null?void 0:e.slice(-1)[0];return i?this.coordUtils.getNextCoordByDependTool(t,i):t}pointInLine(t,e,i){return t.filter(s=>s).length<2?!1:t.some((s,n)=>{if(n===0)return!1;const o=this.coordUtils.getRenderCoord(t[n-1]),a=this.coordUtils.getRenderCoord(s);return O.isInLine(e,o,a,i)})}arc(t,e=se,i){var s,n,o,a,l,h;if(this.ctx){const{x:d,y:g}=t;(s=this.ctx)==null||s.save(),(n=this.ctx)==null||n.beginPath(),this.ctx.fillStyle=i||this.lineStyle.color,(o=this.ctx)==null||o.arc(d,g,e,0,360),(a=this.ctx)==null||a.closePath(),(l=this.ctx)==null||l.fill(),(h=this.ctx)==null||h.restore()}}renderActiveArea(){if(this.isActive&&this.activeArea&&this.ctx){const{top:t,left:e,right:i,bottom:s}=this.activeArea,{x:n,y:o}=this.coordUtils.getRenderCoord({x:e,y:t});this.ctx.save(),this.ctx.beginPath(),this.ctx.strokeStyle="#B3B8FF",this.ctx.rect(n,o,(i-e)*this.zoom,(s-t)*this.zoom),this.ctx.stroke(),this.ctx.restore()}}addLinePoint(t){var e,i,s,n;this.arc(t),(e=this.activeLine)==null||e.push(ie(ee({},t),{id:K()})),((i=this.activeLine)==null?void 0:i.length)===1?(s=this.actionsHistory)==null||s.initRecord(this.activeLine):(n=this.actionsHistory)==null||n.pushHistory(this.activeLine),this.render()}setCreatStatusAndAddPoint(t,e=!1){this.updateStatus(0,e),this.addLinePoint(t)}isActiveLineValid(){var t;return this.selectedID?(t=this.lineList.find(e=>e.id===this.selectedID))==null?void 0:t.valid:this.isLineValid}nextOrder(){return this.lineListLen===0?1:this.lineList.slice(-1)[0].order+1}getLineColorByAttribute(t,e=!1){return q.getStrokeAndFill(this.getColor(t.attribute),t.valid,{isSelected:e}).stroke}updateActiveArea(){this.activeArea=this.getActiveArea(),this.renderActiveArea()}getActiveArea(){return this.hasActiveLine?C.calcViewportBoundaries(this.activeLine,this.isCurve,st,this.zoom):void 0}drawLineNumber(t,e=1,i,s="",n,o=!0){var a,l,h;if((this.showOrder||this.attributeConfigurable)&&this.ctx){let d=this.showOrder?e.toString():`${s}`;if(this.attributeConfigurable){const g=n?(h=(l=(a=this.attributeList)==null?void 0:a.find(u=>u.value===n))==null?void 0:l.key)!=null?h:n:"";d=[d,`${!o&&g?"\u65E0\u6548":""}${g}`].filter(u=>u).join("_")}this.drawText(t,d,i)}}drawLineTextAttribute(t,e,i){if(t&&i)return this.drawText(t,i,e,200)}drawText(t,e,i,s){var n,o;this.ctx&&((n=this.ctx)==null||n.save(),this.ctx.font="italic bold 14px SourceHanSansCN-Regular",this.ctx.fillStyle=i,this.ctx.strokeStyle=i,this.ctx.shadowColor="rgba(0, 0, 0, 0.6)",this.ctx.shadowOffsetY=2,this.ctx.shadowBlur=4,s?m.wrapText(this.canvas,e,t.x-Mt.x,t.y-Mt.y,s):this.ctx.fillText(e,t.x-Mt.x,t.y-Mt.y),(o=this.ctx)==null||o.restore())}moveActiveArea(t,e){this.activeArea&&(this.activeArea=Object.assign(this.activeArea,{top:this.activeArea.top+e,bottom:this.activeArea.bottom+e,right:this.activeArea.right+t,left:this.activeArea.left+t})),this.activeLine&&(this.activeLine.map(i=>Object.assign(i,{x:i.x+t,y:i.y+e})),this.updateLines())}findHoveredPoint(t){if(!!this.activeLine)return this.activeLine.find(e=>{const i=this.coordUtils.getRenderCoord(e);return O.calcDistance(i,t)<=Et})}findHoverLine(t){return N.cloneDeep(this.lineList).reverse().find(({pointList:i})=>{const s=i?this.getPointList(i):[],n=this.getLineWidthScope();return s.some((o,a)=>{if(a===0)return!1;const l=this.coordUtils.getRenderCoord(o),h=this.coordUtils.getRenderCoord(s[a-1]);return O.isInLine(t,l,h,n)})})}getAdsorptionPoint(t){let e,i,s;return N.cloneDeep(this.lineList).reverse().forEach(({pointList:n,id:o})=>{if(o===this.selectedID||!n||(n==null?void 0:n.length)<2)return;const a=this.findNearestPoint(n,t);if(a){if(a.minDistance===0){e=a.point;return}(i===void 0||a.minDistance<i)&&(e=a.point,i=a.minDistance)}}),s||e}findNearestPoint(t,e,i=7){let s;const n=i;for(let o=1;o<=t.length-1;o++){const a=this.coordUtils.getRenderCoord(t[o]),l=this.coordUtils.getRenderCoord(t[o-1]),{length:h,footPoint:d}=C.getFootOfPerpendicular(e,a,l),g=O.calcTwoPointDistance(a,e),u=O.calcTwoPointDistance(l,e);if(g<=i*2){s=a,i=0;break}if(u<=i*2){s=l,i=0;break}h<i&&(s=d,i=h)}return s?{point:s,minDistance:n}:void 0}getPointList(t){return this.isCurve?_t(t,st):t}moveSelectedLine(t){const e=(t.x-this.prevAxis.x)/this.zoom,i=(t.y-this.prevAxis.y)/this.zoom;if(this.enableOutOfTarget){this.lineDragging=!0,this.moveActiveArea(e,i);return}if(this.isDependPolygon){this.moveLineInPolygon(e,i);return}let s=[0,this.imageSize.width],n=[0,this.imageSize.height];if(this.isDependRect){const{x:o,y:a,width:l,height:h}=this.basicResult;s=[o,o+l],n=[a,a+h]}this.moveLineInRectRange(e,i,s,n)}moveSelectPoint(t){const e=t.x-this.prevAxis.x,i=t.y-this.prevAxis.y,s=(this.selectedPoint?this.selectedPoint.x:0)+e/this.zoom,n=(this.selectedPoint?this.selectedPoint.y:0)+i/this.zoom,o={x:s,y:n};Object.assign(this.selectedPoint,this.getNextCoordByAbsCoord(o)),this.updateLines(),this.render()}getCoordByConfig(t,e){var i;const s=!!t.shiftKey,n=t.altKey;if(((i=this.activeLine)==null?void 0:i.length)>0&&s){const o=this.activeLine.slice(-1)[0];return O.getVHPoint(o,e,this.coordUtils.getAbsCoord(e),this.coordUtils.getRenderCoord(o))}return this.edgeAdsorptionEnabled&&!n?this.getAdsorptionPoint(e):e}getNextPoint(t,e){const i=this.getCoordByConfig(t,e)||e;return this.enableOutOfTarget?i:this.getNextCoordByRenderCoord(i)}lineHover(){this.render()}mouseMoveHandler(t){const e=this.getCoordinate(t),i=t.which===1;if(this.isCreate){this.hasActiveLine&&this.renderNextPoint(t,e);return}if(this.isNone&&(this.lineHover(),this.edgeAdsorptionEnabled&&!t.altKey)){const s=this.getAdsorptionPoint(e);s&&this.arc(s)}if(this.isActive){if(this.isMousedown&&i){if(this.selectedPoint){this.moveSelectPoint(e);return}if(this.coordsInsideActiveArea){this.moveSelectedLine(e),this.drawActivatedLine(void 0,void 0,!0);return}}this.drawHoverPoint(e),this.render()}}onMouseMove(t){if(super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo)return;const e=this.getCoordinate(t);this.mouseMoveHandler(t),this.prevAxis=e}setActiveArea(t,e=!1){const i=this.findHoverLine(t);if(i){const s=this.lineList.findIndex(a=>a.id===(i==null?void 0:i.id)),n=C.calcViewportBoundaries((i==null?void 0:i.pointList)||[],this.isCurve,st,this.zoom),o=this.lineList[s];this.updateStatus(1),this.setActiveLine(o.pointList),this.setSelectedLineID(o.id),this.activeArea=n,this.updateLineAttributes(o)}else e&&this.setNoneStatus();this.render()}setActiveLineByID(t){const e=this.lineList.find(i=>i.id===t);if(e){const i=C.calcViewportBoundaries((e==null?void 0:e.pointList)||[],this.isCurve,st,this.zoom);this.updateStatus(1),this.setActiveLine(e.pointList),this.setSelectedLineID(e.id),this.activeArea=i,this.updateLineAttributes(e)}this.render()}setActiveLine(t){this.activeLine=t?N.cloneDeep(t):void 0}historyChanged(t){const e=`${t}Enabled`;if(this.isCreate){if(this.actionsHistory&&this.actionsHistory[e]){const i=this.actionsHistory&&this.actionsHistory[t]();this.setActiveLine(i),this.render()}return}if(this.history&&this.history[e]){const i=this.history[t](),s=i==null?void 0:i.find(n=>n.id===this.selectedID);this.lineList=i,this.selectedID&&s?this.setActiveLine(s==null?void 0:s.pointList):this.setNoneStatus(),this.render()}this.emit("dataUpdated",this.lineList)}undo(){this.historyChanged("undo"),this.updateSelectedAttributeAfterHistoryChanged()}redo(){this.historyChanged("redo"),this.updateSelectedAttributeAfterHistoryChanged()}isCoordInsideTarget(t){if(this.isDependPolygon)return this.isInBasicPolygon(t);if(this.isDependRect){const{x:e,y:i,width:s,height:n}=this.basicResult,o=[e,e+s],a=[i,i+n];return C.isInRange(t.x,o)&&C.isInRange(t.y,a)}return C.isInRange(t.x,[0,this.imageSize.width])&&C.isInRange(t.y,[0,this.imageSize.height])}getPointInsertIndex(t,e){if(t&&this.activeLine){const i=this.getPointList(this.activeLine);return this.activeLine.length===2?1:this.activeLine.findIndex((s,n)=>{if(n>0){const o=this.activeLine?this.activeLine[n-1]:void 0,a=this.isCurve?i.slice((n-1)*(st+1),n*(st+1)):[o,s];return this.pointInLine(a,t,e||this.getLineWidthScope())}return!1})}return-1}getLineWidthScope(){return this.lineStyle.lineWidth}isMouseCoordOutsideActiveArea(){return!this.coordsInsideActiveArea&&!this.selectedPoint}isLinePointsExceed(){return this.isCreate&&this.activeLine&&this.upperLimitPointNum&&~~this.upperLimitPointNum<=this.activeLine.length}isLinePointsNotEnough(){var t;return this.activeLine&&((t=this.activeLine)==null?void 0:t.length)<this.lowerLimitPointNum}updateLineSegmentSpecial(t){const e=this.getPointInsertIndex(t,2)-1;if(e>-1){const i=this.activeLine[e];i.specialEdge=!i.specialEdge,this.hoverLineSegmentIndex=-1,this.render()}}addLinePointToActiveLine(){var t;const e=this.getPointInsertIndex(this.cursor),i=this.pointsWithinRange(this.activeLine.length+1);this.cursor&&e>-1&&i&&(this.activeLine.splice(e,0,ie(ee({},this.coordUtils.getAbsCoord(this.cursor)),{id:K()})),this.updateLines(),(t=this.history)==null||t.pushHistory(this.lineList),this.render(),this.cursor=void 0)}onMouseDown(t){if(super.onMouseDown(t)||this.forbidMouseOperation||!this.imgInfo)return;const e=this.getCoordinate(t);if(this.isMousedown=!0,this.prevAxis=e,t.which===3){this.cursor=void 0;return}this.selectedPoint=this.findHoveredPoint(e),this.coordsInsideActiveArea=this.isActive&&this.activeArea?O.inArea(this.activeArea,this.coordUtils.getAbsCoord(e)):!1,this.lineDragging=!1}lineHasChanged(){const t=this.lineList.find(e=>e.id===this.selectedID);return t?JSON.stringify(t.pointList)!==JSON.stringify(this.activeLine):!1}updateLines(){const t=this.lineList.find(e=>e.id===this.selectedID);t&&(t.pointList=N.cloneDeep(this.activeLine),this.emit("dataUpdated",this.lineList))}onMouseUp(t){const e=()=>{this.isMousedown=!1,this.hoverPointID=void 0,this.cursor=void 0,this.selectedPoint=void 0};if(this.hoverPointID=void 0,super.onMouseUp(t)||this.forbidMouseOperation||!this.imgInfo){e();return}t.which===1&&this.onLeftClick(t),t.which===3&&this.onRightClick(t),e()}isTextValid(t){return T.textAttributeValidate(this.textCheckType,this.customFormat,t)}createLineData(){const t=K(),e={pointList:N.cloneDeep(this.activeLine),id:t,valid:this.isLineValid,order:this.nextOrder()};return e.attribute=this.defaultAttribute,e}stopLineCreating(t=!0){var e,i,s,n;const o=this.selectedID?!0:!!this.isTextConfigurable;let a;if(t){if(this.selectedID){const l=this.lineList.find(h=>h.id===this.selectedID);a=this.selectedID,l&&(l.pointList=N.cloneWith(this.activeLine),N.isEqual(l.pointList,(e=this.history)==null?void 0:e.pushHistory(this.lineList))||(i=this.history)==null||i.pushHistory(this.lineList))}else if(this.isCreate&&this.activeLine&&this.activeLine.length>1){const l=this.createLineData();a=l.id,this.setLineList([...this.lineList,l]),(s=this.history)==null||s.pushHistory(this.lineList)}}o?this.setActiveStatus(a):this.setNoneStatus(),(n=this.actionsHistory)==null||n.empty(),this.emit("dataUpdated",this.lineList),this.render()}setActiveStatus(t){const e=t?this.lineList.find(i=>i.id===t):void 0;if(e){const i=e==null?void 0:e.pointList;this.updateStatus(1),this.setActiveLine(i),this.setSelectedLineID(t)}else this.setNoneStatus()}setNoneStatus(t=!0){t&&this.updateStatus(2),this.activeLine=[],this.setSelectedLineID(void 0),this.activeArea=void 0,this.isLineValid=!0,this.cursor=void 0}setKeyDownStatus(t,e){this.isShift=e!=null?e:t.keyCode===_.Shift}continueToEdit(){var t;this.updateStatus(0),this.cursor=void 0,(t=this.actionsHistory)==null||t.pushHistory(this.activeLine),this.render()}setInvalidLineOnCreating(t){if(this.selectedID&&t.keyCode!==_.Ctrl||!this.isCreate)return;const e=!t.ctrlKey;this.selectedID?this.setInvalidLine(this.selectedID,e,!1):this.isLineValid=e}onKeyDown(t){if(super.onKeyDown(t),this.setKeyDownStatus(t),t.keyCode===_.Z&&!t.ctrlKey&&this.toggleIsHide(),t.keyCode===_.Shift&&this.render(),t.keyCode===_.Tab){t.preventDefault(),this.selectToNextLine(t);return}if(this.isCreate&&this.keyboardEventWhileLineCreating(t),this.config.attributeConfigurable){const e=T.getAttributeByKeycode(t.keyCode,this.config.attributeList);e!==void 0&&this.setDefaultAttribute(e)}}selectToNextLine(t){const e=x.getNextSelectedRectIDByEvent(this.viewPortLines.map(i=>{var s,n,o,a;return ie(ee({},i),{x:(n=(s=i.pointList[0])==null?void 0:s.x)!=null?n:0,y:(a=(o=i.pointList[0])==null?void 0:o.y)!=null?a:0})}),t,this.selectedID);e&&this.setActiveLineByID(e.id)}keyboardEventWhileLineCreating(t){!this.isCreate||(t.keyCode===_.Ctrl&&this.setInvalidLineOnCreating(t),[_.Shift,_.Alt].includes(t.keyCode)&&this.renderNextPoint(t,this.prevAxis))}renderNextPoint(t,e){const i=this.coordUtils.getRenderCoord(this.getNextPoint(t,e));this.render(i)}deleteSelectedLine(t){const e=C.calcViewportBoundaries(this.activeLine,this.isCurve,st,this.zoom);O.inArea(e,this.coordUtils.getAbsCoord(t))&&this.deleteLine()}deleteSelectedLinePoint(t){var e;this.pointsWithinRange(this.activeLine.length-1)&&t&&(this.setActiveLine(this.activeLine.filter(s=>s.id!==t)),this.updateLines(),(e=this.history)==null||e.pushHistory(this.lineList)),this.cursor=void 0,this.render()}deleteLine(){var t;this.lineList=this.lineList.filter(e=>e.id!==this.selectedID),(t=this.history)==null||t.pushHistory(this.lineList),this.setNoneStatus(),this.emit("dataUpdated",this.lineList),this.render()}setInvalidLine(t,e,i=!0){var s;const n=this.lineList.find(o=>o.id===t);n&&(n.valid=e!==void 0?e:!n.valid,(s=this.history)==null||s.pushHistory(this.lineList),i&&this.render())}empty(){var t,e;this.lineList=[],this.setNoneStatus(),this.selectedPoint=void 0,(t=this.actionsHistory)==null||t.empty(),(e=this.history)==null||e.init(),this.emit("dataUpdated",this.lineList),this.render()}setAttribute(t){var e;this.attributeConfigurable&&(this.defaultAttribute=t,this.setLineAttribute("attribute",t),this.selectedID&&((e=this.history)==null||e.pushHistory(this.lineList)))}setTextAttribute(t){var e;this.isTextConfigurable&&(this.setLineAttribute("textAttribute",t),(e=this.history)==null||e.applyAttribute(this.selectedID,"textAttribute",t))}setLineAttribute(t,e,i){const s=i||this.selectedID;if(s){const n=this.lineList.find(o=>o.id===s);n&&(n[t]=e)}this.render()}updateAttribute(t){this.emit("updateAttribute",t)}updateLineAttributes(t){var e;if(this.attributeConfigurable&&t){const i=(t==null?void 0:t.attribute)||"";this.defaultAttribute=i,this.updateAttribute(i)}if(this.isTextConfigurable&&t){const i=(t==null?void 0:t.textAttribute)||"";this.updateTextAttribute(i)}(e=this.history)==null||e.updateHistory(this.lineList)}lineStatusChanged(){this.emit("lineStatusChanged",{status:this.status,selectedLineID:this.selectedID})}updateTextAttribute(t){if(this.selectedID){const e=this.lineList.find(i=>i.id===this.selectedID);e&&(e.textAttribute=t)}this.emit("updateText",t)}saveData(){this.stopLineCreating(),this.setNoneStatus(),this.render()}setTextEditingID(t){this.textEditingID=t,this.render()}setSelectedLineID(t){var e,i;if(this.selectedID===t)return;const s=this.selectedID;t!==s&&s&&((e=this._textAttributeInstance)==null||e.changeSelected()),t||(i=this._textAttributeInstance)==null||i.clearTextAttribute(),this.selectedID=t,this.emit("selectedChange")}attributeLockListChange(t){this.attributeLockList=t,this.render()}setResult(t){this.setNoneStatus(),this.setLineList(t),this.render()}setConfig(t){super.setConfig(t)}toggleIsHide(){this.setIsHidden(!this.isHidden),this.render()}clearCanvas(){super.clearCanvas()}clearResult(){this.setResult([]),this.setSelectedLineID(void 0),this.render()}exportData(){return[this.lineList,this.basicImgInfo]}setDefaultAttribute(t=""){var e;this.attributeConfigurable&&(this.defaultAttribute=t,this.setLineAttribute("attribute",t),this.selectedID&&((e=this.history)==null||e.pushHistory(this.lineList)),this.emit("changeAttributeSidebar"))}getCurrentSelectedData(){var t,e;const i=this.isActiveLineValid(),s=this.defaultAttribute,n=this.getColor(s),o=i?n==null?void 0:n.valid.stroke:n==null?void 0:n.invalid.stroke,a=(e=(t=this.lineList.find(l=>l.id===this.selectedID))==null?void 0:t.textAttribute)!=null?e:"";return{color:o,textAttribute:a}}renderTextAttribute(){var t,e,i,s;if(!this.ctx||!this.activeLine||((t=this.activeLine)==null?void 0:t.length)<2||this.isCreate)return;const n=this.isActiveLineValid(),o=this.defaultAttribute,{x:a,y:l}=this.activeLine[1],h=this.coordUtils.getRenderCoord({x:a,y:l}),d=this.getColor(o),g=n?d==null?void 0:d.valid.stroke:d==null?void 0:d.invalid.stroke,u=(i=(e=this.lineList.find(c=>c.id===this.selectedID))==null?void 0:e.textAttribute)!=null?i:"";this._textAttributeInstance||(this._textAttributeInstance=new Ot({container:this.container,icon:this.getTextIconSvg(o),color:g,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedTextAttribute})),this._textAttributeInstance&&!((s=this._textAttributeInstance)==null?void 0:s.isExit)&&this._textAttributeInstance.appendToContainer(),this._textAttributeInstance.update(`${u}`,{left:h.x,top:h.y,color:g}),this._textAttributeInstance.updateIcon(this.getTextIconSvg(o))}getTextIconSvg(t=""){return T.getTextIconSvg(t,this.config.attributeList,this.config.attributeConfigurable,this.baseIcon)}updateSelectedTextAttribute(t){if(this._textAttributeInstance&&t&&this.selectedID){let e=t;!T.textAttributeValidate(this.config.textCheckType,"",e)&&(this.emit("messageError",T.getErrorNotice(this.config.textCheckType,this.lang)),e=""),this.setTextAttribute(e),this.emit("updateTextAttribute"),this.render()}}}class re{static getMarkerShowText(t,e=[]){return T.getAttributeShowText(t,e)}}var Or=Object.defineProperty,Mr=Object.defineProperties,Er=Object.getOwnPropertyDescriptors,hi=Object.getOwnPropertySymbols,Hr=Object.prototype.hasOwnProperty,Nr=Object.prototype.propertyIsEnumerable,ci=Math.pow,di=(r,t,e)=>t in r?Or(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ht=(r,t)=>{for(var e in t||(t={}))Hr.call(t,e)&&di(r,e,t[e]);if(hi)for(var e of hi(t))Nr.call(t,e)&&di(r,e,t[e]);return r},ne=(r,t)=>Mr(r,Er(t));const ui=200;class gi extends it{constructor(t){super(t);this.setMarkerIndex=e=>{this.markerIndex=e},this.setMarkerIndexAndSelect=e=>{if(!this.config.markerList)return;this.markerIndex=e;const i=this.config.markerList[e].value,s=this.currentPageResult.find(n=>n.label===i);s&&(this.setSelectedID(s.id),this.config.attributeConfigurable===!0&&this.setDefaultAttribute(s.attribute)),this.emit("markIndexChange")},this.textChange=e=>{this.config.textConfigurable!==!0||!this.selectedID||(this.setPointList(T.textChange(e,this.selectedID,this.pointList)),this.emit("selectedChange"),this.render())},this.config=x.jsonParser(t.config),this.pointList=[],this.markerIndex=0,this.setStyle(t.style),this.createPoint=this.createPoint.bind(this),this.getCurrentSelectedData=this.getCurrentSelectedData.bind(this),this.updateSelectedTextAttribute=this.updateSelectedTextAttribute.bind(this),this.setSelectedID=this.setSelectedID.bind(this)}get dataList(){return this.pointList}setNextMarker(t=this.pointList){if(this.hasMarkerConfig){const e=x.getNextMarker(this.getCurrentPageResult(t),this.config.markerList);e&&this.setMarkerIndexAndSelect(e.index)}}setResult(t){this.clearActiveStatus(),this.setPointList(t),this.setNextMarker(t),this.render()}setPointList(t,e=!1){const i=this.pointList.length;this.pointList=t,i!==t.length&&this.emit("updatePageNumber"),e&&this.emit("updateResult")}setConfig(t,e=!1){this.config=x.jsonParser(t),e===!0&&this.clearResult()}clearResult(){this.setPointList([]),this.setSelectedID(void 0),this.history.pushHistory([]),this.hoverID="",this.render()}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.pointList.forEach(s=>{s.id===i&&(s.attribute=t)}),this.history.pushHistory(this.pointList),this.render()),this._textAttributInstance){if(this.attributeLockList.length>0&&!this.attributeLockList.includes(t)){this._textAttributInstance.clearTextAttribute();return}this._textAttributInstance.updateIcon(this.getTextIconSvg(t))}}}get selectedText(){var t;return(t=this.pointList.find(e=>e.id===this.selectedID))==null?void 0:t.textAttribute}setStyle(t){var e;super.setStyle(t),this._textAttributInstance&&this.config.attributeConfigurable===!1&&((e=this._textAttributInstance)==null||e.updateIcon(this.getTextIconSvg()))}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")}getTextIconSvg(t=""){return T.getTextIconSvg(t,this.config.attributeList,this.config.attributeConfigurable,this.baseIcon)}clearActiveStatus(){this.hoverID=void 0,this.dragStatus=k.Wait,this.setSelectedID(void 0)}setBasicResult(t){super.setBasicResult(t),this.setNextMarker(),this.clearActiveStatus()}onMouseDown(t){if(!(super.onMouseDown(t)||this.forbidMouseOperation)){if(t.button===0&&!this.hoverID){this.createPoint(t),this.render();return}return this.hoverID===this.selectedID&&t.button===0&&(this.dragStatus=k.Start),this.render(),!0}}onMouseMove(t){super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo||(this.hoverID=this.getHoverId(),(this.dragStatus===k.Start||this.dragStatus===k.Move)&&this.onDragMove(t),this.hoverID&&this.render())}onMouseUp(t){if(super.onMouseUp(t)||this.forbidMouseOperation||!this.imgInfo)return!0;t.button===2&&this.rightMouseUp(),this.dragStatus===k.Move&&(this.dragStatus=k.Wait,this.history.pushHistory(this.pointList)),this.render()}onDragMove(t){if(!this.imgInfo)return;this.dragStatus=k.Move;const e=this.getCoordinateUnderZoom(t),i=L.changeDrawOutsideTarget(e,{x:0,y:0},this.imgInfo,this.config.drawOutsideTarget,this.basicResult,this.zoom),s=this.config.drawOutsideTarget?L.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos):L.changePointByZoom(i,1/this.zoom);this.pointList.forEach(n=>{n.id===this.selectedID&&(n.x=s.x,n.y=s.y)}),this.render()}onKeyDown(t){if(!x.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;const{keyCode:e}=t;switch(e){case _.Delete:this.deletePoint();break;case _.Tab:{this.onTabKeyDown(t);break}case _.Z:this.setIsHidden(!this.isHidden),this.render();break;default:{if(this.config.attributeConfigurable){const i=T.getAttributeByKeycode(e,this.config.attributeList);i!==void 0&&this.setDefaultAttribute(i)}break}}}createPoint(t){if(!this.imgInfo)return;const{upperLimit:e}=this.config;if(e&&this.currentPageResult.length>=e){this.emit("messageInfo",`${F.getMessagesByLocale(D.LowerLimitPoint,this.lang)}`);return}const i=x.getSourceID(this.basicResult),s=this.getCoordinateUnderZoom(t),n=L.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);if(this.config.drawOutsideTarget===!1){if(this.dependToolName&&this.basicCanvas){let l=!1;switch(this.dependToolName){case w.Rect:{l=!$.isInRect(n,this.basicResult);break}case w.Polygon:{l=!H.isInPolygon(n,this.basicResult.pointList);break}}if(l)return}if(s.x<0||s.y<0||s.x>this.imgInfo.width||s.y>this.imgInfo.height)return}let o=ne(Ht({},n),{attribute:this.defaultAttribute,valid:!t.ctrlKey,id:K(8,62),sourceID:i,textAttribute:"",order:x.getMaxOrder(this.pointList.filter(l=>x.isSameSourceID(l.sourceID,i)))+1});if(this.config.textConfigurable){let l="";l=T.getTextAttribute(this.pointList.filter(h=>x.isSameSourceID(h.sourceID,i)),this.config.textCheckType),o=ne(Ht({},o),{textAttribute:l})}if(this.hasMarkerConfig){const l=x.getNextMarker(this.currentPageResult,this.config.markerList,this.markerIndex);if(l)o=ne(Ht({},o),{label:l.label}),this.markerIndex=l.index,this.emit("markIndexChange");else{this.emit("messageInfo",F.getMessagesByLocale(D.MarkerFinish,this.lang));return}}this.hoverID=o.id;const a=[...this.pointList,o];this.setPointList(a),this.history.pushHistory(a),this.setSelectedID(o.id)}isInPoint(t,e,i=this.zoom){return(this.style.width+2)/i>=Math.sqrt(ci(t.x-e.x,2)+ci(t.y-e.y,2))}getHoverId(){var t;const e=L.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos),i=(t=this.pointList)==null?void 0:t.find(s=>this.isInPoint(e,s));return i==null?void 0:i.id}rightMouseUp(){if(this.selectedID===this.hoverID){const e=this.pointList.filter(i=>i.id!==this.selectedID);this.setPointList(e),this.setSelectedID(""),this.hoverID="";return}const t=this.pointList.find(e=>e.id===this.hoverID);if(this.setSelectedID(this.hoverID),this.setDefaultAttribute(t==null?void 0:t.attribute),(t==null?void 0:t.label)&&this.hasMarkerConfig){const e=x.getCurrentMarkerIndex(t.label,this.config.markerList);e>=0&&(this.setMarkerIndex(e),this.emit("markIndexChange"))}}onTabKeyDown(t){if(t.preventDefault(),this.dragStatus===k.Move||this.dragStatus===k.Start)return;let e=j.ascend;t.shiftKey&&(e=j.descend);const[i,s]=x.getRenderResultList(this.pointList,x.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);let n=[...i];s&&(n=[...n,s]);const o=x.getNextSelectedRectID(n,e,this.selectedID);o&&this.setSelectedID(o.id)}get currentPageResult(){const[t]=x.getRenderResultList(this.pointList,x.getSourceID(this.basicResult),[]);return t}getCurrentPageResult(t){const[e]=x.getRenderResultList(t,x.getSourceID(this.basicResult),[]);return e}exportData(){const{pointList:t}=this;return[t,this.basicImgInfo]}deletePoint(){var t;this.selectedID&&(this.setPointList(this.pointList.filter(e=>e.id!==this.selectedID)),this.history.pushHistory(this.pointList),(t=this._textAttributInstance)==null||t.clearTextAttribute(),this.emit("selectedChange"),this.render())}undoAndRedo(t){var e,i;if(this.dragStatus===k.Move||this.dragStatus===k.Start)return;const s=(i=(e=this.history)[t])==null?void 0:i.call(e);(s==null?void 0:s.some(n=>n.id===this.selectedID))||this.setSelectedID(""),s&&(this.setPointList(s,!0),this.render())}undo(){this.undoAndRedo("undo")}redo(){this.undoAndRedo("redo")}getCurrentSelectedData(){var t;if(!this.selectedID)return;const e=(t=this.pointList)==null?void 0:t.find(n=>n.id===this.selectedID),i=this.getColor(e==null?void 0:e.attribute),s=(e==null?void 0:e.valid)?i==null?void 0:i.valid.stroke:i==null?void 0:i.invalid.stroke;return this.dragStatus=k.Wait,{width:ui*this.zoom*.6,textAttribute:(e==null?void 0:e.textAttribute)||"",color:s}}updateSelectedTextAttribute(t){if(this._textAttributInstance&&t&&this.selectedID){let e=t;T.textAttributeValidate(this.config.textCheckType,"",e)===!1&&(this.emit("messageError",T.getErrorNotice(this.config.textCheckType,this.lang)),e=""),this.setPointList(T.textChange(e,this.selectedID,this.pointList)),this.emit("updateTextAttribute"),this.render()}}renderTextAttribute(){var t,e;const i=(t=this.pointList)==null?void 0:t.find(c=>c.id===this.selectedID);if(!this.ctx||this.config.textConfigurable!==!0||!i)return;const{x:s,y:n,attribute:o,valid:a}=i,l=ui*this.zoom*.6,h=L.getOffsetCoordinate({x:s,y:n},this.currentPos,this.zoom),d=this.getColor(o),g=a?d==null?void 0:d.valid.stroke:d==null?void 0:d.invalid.stroke,u=4;this._textAttributInstance||(this._textAttributInstance=new Ot({width:l,container:this.container,icon:this.getTextIconSvg(o),color:g,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedTextAttribute})),this._textAttributInstance&&!((e=this._textAttributInstance)==null?void 0:e.isExit)&&this._textAttributInstance.appendToContainer(),this._textAttributInstance.update(`${i.textAttribute}`,{left:h.x,top:h.y+u,color:g,width:l})}renderPoint(t){var e,i,s;const{textAttribute:n="",attribute:o}=t,a=t.id===this.selectedID,l=this.getColor(o),h=L.changePointByZoom(t,this.zoom,this.currentPos),{width:d=2,hiddenText:g=!1}=this.style,u=q.getStrokeAndFill(l,t.valid,{isSelected:a||t.id===this.hoverID});m.drawCircle(this.canvas,h,d,{startAngleDeg:0,endAngleDeg:360,thickness:1,color:u.stroke,fill:u.fill});let c="";(((e=this.config)==null?void 0:e.isShowOrder)||((i=this.config)==null?void 0:i.showOrder))&&t.order&&(t==null?void 0:t.order)>0&&(c=`${t.order}`),t.label&&this.hasMarkerConfig&&(c=`${x.getCurrentMarkerIndex(t.label,this.config.markerList)+1}_${re.getMarkerShowText(t.label,this.config.markerList)}`),t.attribute&&(c=`${c} ${T.getAttributeShowText(t.attribute,(s=this.config)==null?void 0:s.attributeList)}`),g||m.drawText(this.canvas,{x:h.x+d/2,y:h.y-d-4},c,{textAlign:"center",color:u.stroke}),a?this.renderTextAttribute():g||m.drawText(this.canvas,{x:h.x+d,y:h.y+d+24},n,Ht({color:u.stroke},Y))}renderPointList(){const[t,e]=x.getRenderResultList(this.pointList,x.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);this.isHidden||t.forEach(i=>{this.renderPoint(i)}),e&&this.renderPoint(e)}render(){!this.ctx||(super.render(),this.renderPointList(),this.renderCursorLine(this.getLineColor(this.defaultAttribute)))}}class fi extends it{constructor(t){super(t);this.getSingleResult=e=>{const i={};return this.config.configList.length>0&&this.config.configList.forEach(s=>{var n;i[s.key]=(n=s.default)!=null?n:""}),{value:i,id:K(),sourceID:e!=null?e:x.getSourceID()}},this.getInitResultList=(e,i)=>e===0?[this.getSingleResult()]:i.map(s=>this.getSingleResult(s.id)),this.textList=[],this.setShowDefaultCursor(!0),this.setConfig(t.config),this.initTextDisplayContainer()}get dataList(){return this.textList}get textValueContainerID(){return"textValueContainer"}get textValueContainer(){return document.getElementById(this.textValueContainerID)}get currentPageResult(){return this.textList}setResult(t){var e;this.textList=t,this.toggleTextContainerVisible(!0);const i=(e=this.textList[0])==null?void 0:e.value;i&&Object.keys(i).forEach(s=>{this.renderText(s,i[s])}),this.emit("valueUpdated"),this.toggleTextContainerVisible(!!i)}updateTextValue(t,e){this.textList[0].value[t]=e,this.renderText(t,e),this.emit("valueUpdated")}renderText(t,e){const i=document.getElementById(`textKey${t}`);i&&(i.innerText=e)}getTextDomID(t){return`textKey${t}`}initTextDisplayContainer(){const t=document.createElement("div"),e={position:"absolute",right:"0",top:"0","z-index":"20","max-width":"20%","font-family":"SourceHanSansCN-Regular",background:"rgb(102, 230, 255)",color:"white","word-break":"break-all","line-height":"24px","white-space":"pre-wrap","max-height":"80%","overflow-y":"auto",opacity:"0.6"};t.setAttribute("style",Object.keys(e).reduce((i,s)=>(i+=`${s}: ${e[s]};`,i),"")),t.setAttribute("id",this.textValueContainerID),this.config.configList.forEach(i=>{const s=document.createElement("div"),n=document.createElement("div"),o=document.createElement("div");s.setAttribute("style","padding: 8px 16px"),n.innerText=`${i.key}:`,o.innerText="",o.setAttribute("id",this.getTextDomID(i.key)),s.appendChild(n),s.appendChild(o),t.appendChild(s)}),this.container.appendChild(t)}exportData(){return[this.textList,this.basicImgInfo]}destroyCanvas(){super.destroyCanvas(),this.textValueContainer&&this.container.removeChild(this.textValueContainer)}onKeyDown(t){super.onKeyDown(t),t.keyCode===_.Z&&this.toggleTextContainerVisible()}toggleTextContainerVisible(t){if(this.textValueContainer){const e=(t!==void 0?!t:this.textValueContainer.style.display==="block")?"none":"block";this.textValueContainer.style.display=e}}}var Br=Object.defineProperty,$r=Object.defineProperties,Fr=Object.getOwnPropertyDescriptors,vi=Object.getOwnPropertySymbols,Ur=Object.prototype.hasOwnProperty,Zr=Object.prototype.propertyIsEnumerable,pi=(r,t,e)=>t in r?Br(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,bi=(r,t)=>{for(var e in t||(t={}))Ur.call(t,e)&&pi(r,e,t[e]);if(vi)for(var e of vi(t))Zr.call(t,e)&&pi(r,e,t[e]);return r},zr=(r,t)=>$r(r,Fr(t));class x{static getStepInfo(t,e){return e==null?void 0:e.filter(i=>i.step===t)[0]}static getCurrentStepInfo(t,e){const i=this.getStepInfo(t,e);return i&&(i.type===yt.QUALITY_INSPECTION||i.type===yt.MANUAL_CORRECTION)?this.getCurrentStepInfo(i.dataSourceStep,e):i}static getMaxOrder(t){let e=0;return t.forEach(i=>{i.order&&i.order>e&&(e=i.order)}),e}static hotkeyFilter(t){const e=t.target||t.srcElement;if(!e)return!0;const{tagName:i,type:s}=e;if(!i||!s)return!0;let n=!0;return(e.isContentEditable||i==="TEXTAREA"||(i==="INPUT"&&s!=="radio"||i==="TEXTAREA")&&!e.readOnly)&&(n=!1),n}static getCurrentOperation(t){switch(t){case w.Rect:case w.RectTrack:return he;case w.Tag:return ri;case w.Polygon:return si;case Lt.Check:return Ir;case w.Line:return li;case w.Point:return gi;case w.Text:return fi;default:throw new Error("not match tool")}}static getNextSelectedRectID(t,e=j.ascend,i){let s=1;e===j.descend&&(s=-1);const n=t.sort((l,h)=>l.x-h.x==0?l.y-h.y:s*(l.x-h.x)),o=n.findIndex(l=>l.id===i),a=n.length;return n[(o+1)%a]}static getNextSelectedRectIDByEvent(t,e,i){const s=e.shiftKey?j.descend:j.ascend;return this.getNextSelectedRectID(t,s,i)}static getRenderResultList(t,e,i=[],s){let n;return[t.filter(a=>s&&s===(a==null?void 0:a.id)?(n=a,!1):!(i.length>0&&!i.includes(a==null?void 0:a.attribute)||this.isDifferSourceID(a==null?void 0:a.sourceID,e))),n]}static getSourceID(t){var e;const i="";return t&&(e=t==null?void 0:t.id)!=null?e:i}static findAllLine(t){const e=[],i=[...t];i.length>=3&&i.push(bi({},i[0]));for(let s=0;s<i.length;s++)i[s+1]&&e.push({point1:i[s],point2:i[s+1],pointIndex:s});return e}static translateSourceID(t){return(t===void 0||t===0||t==="0")&&(t=""),t}static isDifferSourceID(t,e){return t=this.translateSourceID(t),e=this.translateSourceID(e),`${t}`!=`${e}`}static isSameSourceID(t,e){return t=this.translateSourceID(t),e=this.translateSourceID(e),`${t}`==`${e}`}static getNextMarker(t,e=[],i){if((e==null?void 0:e.length)===0)return;let s=e.map((n,o)=>zr(bi({},n),{index:o}));if(typeof i=="number"&&i>0){const n=e[i];if(n&&t.every(o=>o.label!==n.value))return{label:n.value,index:i};s=[...s.slice(i,e.length),...s.slice(0,i)]}for(let n=0;n<s.length;n++)if(!t.some(o=>o.label===s[n].value))return{label:s[n].value,index:s[n].index}}static getCurrentMarkerIndex(t,e=[]){return e.findIndex(i=>t===i.value)}}x.jsonParser=(r,t={})=>{try{return typeof r=="string"?JSON.parse(r):Ri(r)?r:t}catch(e){return t}};var Vr=Object.defineProperty,xi=Object.getOwnPropertySymbols,Wr=Object.prototype.hasOwnProperty,jr=Object.prototype.propertyIsEnumerable,yi=(r,t,e)=>t in r?Vr(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,oe=(r,t)=>{for(var e in t||(t={}))Wr.call(t,e)&&yi(r,e,t[e]);if(xi)for(var e of xi(t))jr.call(t,e)&&yi(r,e,t[e]);return r};class H{static getHoverPolygonID(t,e,i=3,s=S.Line){let n="",o=Infinity;const a=L.axisArea(t,i);return e.forEach(l=>{l.pointList&&a.forEach(h=>{const d=this.calcPolygonSize(l.pointList);this.isInPolygon(h,l.pointList,s)&&d<o&&(n=l.id,o=d)})}),n}static calcPolygonSize(t=[]){if((t==null?void 0:t.length)<=2)return 0;const e=t.length,i=t.reduce((s,n,o,a)=>{const l=a[(o+1)%e];return s+n.x*l.y-l.x*n.y},0);return Math.abs(i)/2}static isInPolygon(t,e,i=S.Line){let s=0,n,o,a,l;e=[...e],i===S.Curve&&(e=this.createSmoothCurvePoints(e.reduce((d,g)=>[...d,g.x,g.y],[]),.5,!0,20)),[a]=e;const h=e.length;for(n=1;n<=h;n++)l=e[n%h],t.x>Math.min(a.x,l.x)&&t.x<=Math.max(a.x,l.x)&&t.y<=Math.max(a.y,l.y)&&a.x!==l.x&&(o=(t.x-a.x)*(l.y-a.y)/(l.x-a.x)+a.y,(a.y===l.y||t.y<=o)&&s++),a=l;return s%2!=0}static createSmoothCurvePointsFromPointList(t,e=W){return this.createSmoothCurvePoints(t.reduce((s,n)=>[...s,n.x,n.y],[]),.5,!1,e).map((s,n)=>{var o;const a=n/(W+1),l=Math.floor(a),h=(o=t[l])!=null?o:{};return oe(l===a?oe({},h):{specialEdge:h.specialEdge},s)})}static createSmoothCurvePoints(t,e=.5,i=!1,s=W){if(t.length<4)return t;const n=[],o=t.slice(0);let a,l,h,d,g,u,c,f,v,p,b,y,P;for(i?(o.unshift(t[t.length-1]),o.unshift(t[t.length-2]),o.unshift(t[t.length-1]),o.unshift(t[t.length-2]),o.push(t[0]),o.push(t[1])):(o.unshift(t[1]),o.unshift(t[0]),o.push(t[t.length-2]),o.push(t[t.length-1])),P=2;P<o.length-4;P+=2)for(h=(o[P+2]-o[P-2])*e,d=(o[P+4]-o[P-0])*e,g=(o[P+3]-o[P-1])*e,u=(o[P+5]-o[P+1])*e,y=0;y<=s;y++)b=y/s,c=2*Math.pow(b,3)-3*Math.pow(b,2)+1,f=-(2*Math.pow(b,3))+3*Math.pow(b,2),v=Math.pow(b,3)-2*Math.pow(b,2)+b,p=Math.pow(b,3)-Math.pow(b,2),a=c*o[P]+f*o[P+2]+v*h+p*d,l=c*o[P+1]+f*o[P+3]+v*g+p*u,n.push(a),n.push(l);const A=[];for(let I=0;I<n.length-1;I+=2)A.push({x:n[I],y:n[I+1]});if(i)for(let I=0;I<s+1;I++){const R=A.shift();A.push(R)}return A}static getPolygonByID(t,e){return t.find(i=>i.id===e)}static getHoverEdgeIndex(t,e,i=S.Line,s=3){let n=[...e];i===S.Curve?n=this.createSmoothCurvePoints(e.reduce((l,h)=>[...l,h.x,h.y],[]),.5,!0,W):i===S.Line&&n.push(n[0]);let o=-1,a=s;for(let l=0;l<n.length-1;l++){const{length:h}=C.getFootOfPerpendicular(t,n[l],n[l+1]);h<a&&(o=l,a=h)}return o===-1?-1:i===S.Curve?Math.floor(o/W):o}static getClosestPoint(t,e,i=S.Line,s=3){let n="",o=-1,a=Infinity,l=t;const h=20;return e.forEach(d=>{if(!!d.pointList)switch(i){case S.Line:x.findAllLine(d.pointList).forEach((u,c)=>{const{length:f,footPoint:v}=C.getFootOfPerpendicular(t,u.point1,u.point2);f<a&&f<s&&(n=d.id,o=c,a=f,l=v)});break;case S.Curve:{const g=this.createSmoothCurvePoints(d.pointList.reduce((u,c)=>[...u,c.x,c.y],[]),.5,!0,h);for(let u=0;u<g.length-1;u++){const{length:c,footPoint:f}=C.getFootOfPerpendicular(t,g[u],g[u+1]);c<a&&c<s&&(n=d.id,o=Math.floor(u/(h+1)),a=c,l=f)}}break}}),{dropFoot:l,closestEdgeIndex:o,closestPolygonID:n}}static isPointListInPolygon(t,e,i=S.Line){return t.every(s=>this.isInPolygon(s,e,i))}static isPointListOutSidePolygon(t,e,i=S.Line){return t.some(s=>!this.isInPolygon(s,e,i))}static getPolygonArea(t){let e=0;for(let i=0,s=t.length;i<s;i++){const n=t[i].x,o=t[i===t.length-1?0:i+1].y,a=t[i===t.length-1?0:i+1].x,l=t[i].y;e+=n*o*.5,e-=a*l*.5}return Math.abs(e)}}var Xr=Object.defineProperty,Yr=Object.defineProperties,Gr=Object.getOwnPropertyDescriptors,mi=Object.getOwnPropertySymbols,Kr=Object.prototype.hasOwnProperty,Jr=Object.prototype.propertyIsEnumerable,Ii=(r,t,e)=>t in r?Xr(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ae=(r,t)=>{for(var e in t||(t={}))Kr.call(t,e)&&Ii(r,e,t[e]);if(mi)for(var e of mi(t))Jr.call(t,e)&&Ii(r,e,t[e]);return r},le=(r,t)=>Yr(r,Gr(t));class L{static getOffsetCoordinate(t,e,i){return{x:t.x*i+e.x,y:t.y*i+e.y}}static changeDrawOutsideTarget(t,e,i,s,n,o){return typeof s=="boolean"&&!s&&(n&&o?(t.x-e.x>(n.x+n.width)*o&&(t.x=(n.x+n.width)*o+e.x),t.x-e.x<n.x*o&&(t.x=n.x*o+e.x),t.y-e.y>(n.y+n.height)*o&&(t.y=(n.y+n.height)*o+e.y),t.y-e.y<n.y*o&&(t.y=n.y*o+e.y)):(t.x-e.x>i.width&&(t.x=i.width+e.x),t.x-e.x<0&&(t.x=e.x),t.y-e.y>i.height&&(t.y=i.height+e.y),t.y-e.y<0&&(t.y=e.y))),t}static changeCoordinateByRotate(t,e,i){const{width:s,height:n}=i,{x:o,y:a}=t;switch(e%360){case 90:return{x:n-a,y:o};case 180:return{x:s-o,y:n-a};case 270:return{x:a,y:s-o};default:return t}}static changeRectByZoom(t,e,i={x:0,y:0}){return le(ae({},t),{x:t.x*e+i.x,y:t.y*e+i.y,width:t.width*e,height:t.height*e})}static changePointByZoom(t,e,i={x:0,y:0}){return le(ae({},t),{x:t.x*e+i.x,y:t.y*e+i.y})}static changePointListByZoom(t,e,i={x:0,y:0}){return t.map(s=>this.changePointByZoom(s,e,i))}static axisArea(t,e=3){const{x:i,y:s}=t,n=[];for(let o=i-e;o<i+e;o+=e/3)for(let a=s-e;a<s+e;a+=e/3)n.push({x:o,y:a});return n}static getOriginCoordinateWithOffsetCoordinate(t,e=1,i={x:0,y:0}){return{x:(t.x-i.x)/e,y:(t.y-i.y)/e}}static returnClosePointIndex(t,e,i=3){let s=-1;for(let n=0;n<e.length;n++){const o=e[n];this.getIsInScope(t,o,i)&&(s=n)}return s}static getIsInScope(t,e,i){return Math.abs(t.x-e.x)<i&&Math.abs(t.y-e.y)<i}}class qr{constructor(t){this.currentPos=t.currentPos,this.zoom=t.zoom,this.basicImgInfo=t.basicImgInfo,this.dependToolName=""}get isDependPolygon(){return this.dependToolName===w.Polygon}get isDependRect(){return this.dependToolName===w.Rect}get isDependOriginalImage(){return this.dependToolName===""}getAbsCoord(t){return{x:(t.x-this.currentPos.x)/this.zoom,y:(t.y-this.currentPos.y)/this.zoom}}getRenderCoord(t){return{x:t.x*this.zoom+this.currentPos.x,y:t.y*this.zoom+this.currentPos.y}}coordInsideRect(t,e){const{x:i,y:s,width:n,height:o}=e;return{x:C.withinRange(t.x,[i,i+n]),y:C.withinRange(t.y,[s,s+o])}}getPolygonPointList(t,e){return t===S.Curve?H.createSmoothCurvePointsFromPointList(e):e}getIntersection(t,e,i){const s=this.getRenderCoord(e),n=this.getRenderCoord(t),o={pointA:s,pointB:n};return O.calcOptimalIntersection(i,o,s,or,this.zoom)}coordInsidePolygon(t,e,i,s){const{pointList:n}=i,o=s==null?void 0:s.lineType;if(n.length===0)return t;const a=this.getPolygonPointList(o,n);if(H.isInPolygon(t,a))return t;const h=a.concat(a[0]).map(g=>this.getRenderCoord(g)),d=this.getIntersection(t,e,h);return d?this.getAbsCoord(d==null?void 0:d.point):t}coordInsideImage(t){return this.coordInsideRect(t,le(ae({},this.basicImgInfo),{x:0,y:0}))}getNextCoordByDependTool(t,e){if(this.isDependRect)return this.coordInsideRect(t,this.basicResult);if(this.isDependPolygon)return this.coordInsidePolygon(t,e,this.basicResult,this.dependToolConfig);if(this.isDependOriginalImage)return this.coordInsideImage(t)}setDependInfo(t,e){this.dependToolName=t!=null?t:"",this.dependToolConfig=t?e:void 0}setBasicImgInfo(t){this.basicImgInfo=t}setBasicResult(t){this.basicResult=t}setZoomAndCurrentPos(t,e){this.zoom=t,this.currentPos=e}isCoordInsideTarget(t){if(this.isDependPolygon)return this.isInBasicPolygon(t);if(this.isDependRect){const{x:e,y:i,width:s,height:n}=this.basicResult,o=[e,e+s],a=[i,i+n];return C.isInRange(t.x,o)&&C.isInRange(t.y,a)}return C.isInRange(t.x,[0,this.basicImgInfo.width])&&C.isInRange(t.y,[0,this.basicImgInfo.height])}isInBasicPolygon(t){var e,i;return H.isInPolygon(t,((e=this.basicResult)==null?void 0:e.pointList)||[],(i=this.dependToolConfig)==null?void 0:i.lineType)}}var Qr=Object.defineProperty,tn=Object.defineProperties,en=Object.getOwnPropertyDescriptors,wi=Object.getOwnPropertySymbols,sn=Object.prototype.hasOwnProperty,rn=Object.prototype.propertyIsEnumerable,Li=(r,t,e)=>t in r?Qr(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,M=(r,t)=>{for(var e in t||(t={}))sn.call(t,e)&&Li(r,e,t[e]);if(wi)for(var e of wi(t))rn.call(t,e)&&Li(r,e,t[e]);return r},Z=(r,t)=>tn(r,en(t));const It=6;class he extends it{constructor(t){super(t);this.setMarkerIndex=e=>{this.markerIndex=e},this.setMarkerIndexAndSelect=e=>{if(!this.config.markerList)return;this.markerIndex=e;const i=this.config.markerList[e].value,s=this.currentPageResult.find(n=>n.label===i);s&&(this.setSelectedID(s.id),this.config.attributeConfigurable===!0&&this.setDefaultAttribute(s.attribute)),this.emit("markIndexChange")},this.getHoverRectID=e=>{const i=this.getCoordinateUnderZoom(e),s=It,{currentShowList:n}=this;if(n.length>0){if(this.selectedRectID){const{selectedRect:a}=this;if(a&&$.isInRect(i,a,s,this.zoom))return a.id}const o=n.filter(a=>$.isInRect(i,a,s,this.zoom));if(o.length===0)return"";if(o.length===1)return o[0].id;if(o.length>1)return o.map(l=>({size:l.width*l.height,id:l.id})).sort((l,h)=>l.size-h.size)[0].id}return""},this.textChange=e=>{this.config.textConfigurable!==!0||!this.selectedRectID||(this.setRectList(T.textChange(e,this.selectedRectID,this.rectList),!0),this.emit("selectedChange"),this.render())},this.drawOutSideTarget=t.drawOutSideTarget||!1,this.rectList=[],this.isFlow=!0,this.config=x.jsonParser(t.config),this.hoverRectEdgeIndex=-1,this.hoverRectPointIndex=-1,this.markerIndex=0,this.setStyle(t.style),this.createNewDrawingRect=this.createNewDrawingRect.bind(this),this.getDrawingRectWithRectList=this.getDrawingRectWithRectList.bind(this),this.setSelectedIdAfterAddingDrawingRect=this.setSelectedIdAfterAddingDrawingRect.bind(this),this.getCurrentSelectedData=this.getCurrentSelectedData.bind(this),this.updateSelectedRectTextAttribute=this.updateSelectedRectTextAttribute.bind(this),this.setSelectedID=this.setSelectedID.bind(this)}setResult(t){if(this.clearActiveStatus(),this.setRectList(t),this.hasMarkerConfig){const e=x.getNextMarker(this.getCurrentPageResult(t),this.config.markerList);e&&this.setMarkerIndex(e.index)}this.render()}destroy(){super.destroy(),this._textAttributInstance&&this._textAttributInstance.clearTextAttribute()}setConfig(t,e=!1){this.config=x.jsonParser(t),e===!0&&this.clearResult(!1)}setRectList(t,e=!1){const i=this.rectList.length;this.rectList=t,i!==t.length&&this.emit("updatePageNumber"),e&&this.emit("updateResult")}get selectedRect(){return this.rectList.find(t=>t.id===this.selectedRectID)}get selectedID(){return this.selectedRectID}get selectedText(){var t;return(t=this.selectedRect)==null?void 0:t.textAttribute}get dataList(){return this.rectList}get currentShowList(){let t=[];const[e,i]=x.getRenderResultList(this.rectList,x.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);return t=e,this.isHidden&&(t=[]),i&&t.push(i),t}get currentPageResult(){const[t]=x.getRenderResultList(this.rectList,x.getSourceID(this.basicResult),[]);return t}getCurrentPageResult(t){const[e]=x.getRenderResultList(t,x.getSourceID(this.basicResult),[]);return e}setSelectedID(t){this.setSelectedRectID(t)}setSelectedRectID(t){var e,i;const s=this.selectedRectID;t!==s&&s&&((e=this._textAttributInstance)==null||e.changeSelected()),t||(i=this._textAttributInstance)==null||i.clearTextAttribute(),this.selectedRectID=t,this.render(),this.emit("selectedChange")}setStyle(t){var e;super.setStyle(t),this._textAttributInstance&&this.config.attributeConfigurable===!1&&((e=this._textAttributInstance)==null||e.updateIcon(this.getTextIconSvg()))}updateSelectedRectTextAttribute(t){if(this._textAttributInstance&&t){let e=t;T.textAttributeValidate(this.config.textCheckType,"",e)===!1&&(this.emit("messageError",T.getErrorNotice(this.config.textCheckType,this.lang)),e=""),this.setRectList(this.rectList.map(i=>i.id===this.selectedRectID?Z(M({},i),{textAttribute:e}):i),!0),this.emit("updateTextAttribute"),this.render()}}getHoverRectPointIndex(t){return this.selectedRect?L.returnClosePointIndex(this.getCoordinateUnderZoom(t),$.getRectPointList(this.selectedRect,this.zoom),It+2):-1}getHoverRectEdgeIndex(t){if(!this.selectedRect)return-1;let e=-1;const{selectedRect:i}=this,s=$.getRectEdgeList(i,this.zoom),n=this.getCoordinateUnderZoom(t);for(let o=0;o<s.length;o++){const a=s[o],{length:l}=C.getFootOfPerpendicular(n,a.begin,a.end);l<It+10&&(e=o)}return e}getTextIconSvg(t=""){return T.getTextIconSvg(t,this.config.attributeList,this.config.attributeConfigurable,this.baseIcon)}onMouseDown(t){if(super.onMouseDown(t)||this.forbidMouseOperation||t.ctrlKey===!0)return;const e=this.getCoordinateUnderZoom(t),i=this.getHoverRectID(t),s=this.currentShowList.find(n=>n.id===this.selectedRectID);if(!(!s||t.button===2||t.button===0&&this.isSpaceKey===!0)){if(this.selectedRectID){if(this.getHoverRectPointIndex(t)>-1){const n=z.Point;this.dragInfo={dragStartCoord:e,dragTarget:n,startTime:+new Date,firstRect:s},this.dragStatus=k.Start;return}if(this.getHoverRectEdgeIndex(t)>-1){const n=z.Line;this.dragInfo={dragStartCoord:e,dragTarget:n,startTime:+new Date,firstRect:s},this.dragStatus=k.Start;return}}if(i===this.selectedRectID&&!this.drawingRect){const n=z.Plane;this.dragInfo={dragStartCoord:e,dragTarget:n,firstRect:s,startTime:+new Date},this.dragStatus=k.Start}}}onDragMove(t){var e,i,s,n,o,a;if(!this.dragInfo)return;this.dragStatus=k.Move;const l=$.getRectUnderZoom(this.dragInfo.firstRect,this.zoom),{x:h,y:d,width:g,height:u}=l,c={x:t.x-this.dragInfo.dragStartCoord.x,y:t.y-this.dragInfo.dragStartCoord.y};let f=this.rectList.filter(v=>v.id===this.selectedRectID)[0];switch(this.dragInfo.dragTarget){case z.Plane:f=Z(M({},f),{x:h+c.x,y:d+c.y,width:g,height:u});break;case z.Point:{let v=h,p=d,b=g,y=u;switch(this.hoverRectPointIndex){case 0:{v=g-c.x<0?h+g:h+c.x,p=u-c.y<0?d+u:d+c.y,b=Math.abs(c.x-g),y=Math.abs(c.y-u);break}case 1:{v=g+c.x>0?h:h+g+c.x,p=u-c.y<0?d+u:d+c.y,b=Math.abs(g+c.x),y=Math.abs(u-c.y);break}case 2:{v=g+c.x>0?h:h+g+c.x,p=u+c.y>0?d:d+u+c.y,b=Math.abs(g+c.x),y=u+c.y>0?u+c.y:Math.abs(u+c.y);break}case 3:{v=g-c.x<0?h+g:h+c.x,p=u+c.y>0?d:d+u+c.y,b=Math.abs(c.x-g),y=u+c.y>0?u+c.y:Math.abs(u+c.y);break}default:return}f=Z(M({},f),{x:v,y:p,width:b,height:y})}break;case z.Line:{let v=h,p=d,b=g,y=u;switch(this.hoverRectEdgeIndex){case 0:{p=u-c.y<0?d+u:d+c.y,y=Math.abs(c.y-u);break}case 1:{v=g+c.x>0?h:h+g+c.x,b=Math.abs(g+c.x);break}case 2:{p=u+c.y>0?d:d+u+c.y,y=u+c.y>0?u+c.y:Math.abs(u+c.y);break}case 3:{v=g-c.x<0?h+g:h+c.x,b=Math.abs(c.x-g);break}default:return}f=Z(M({},f),{x:v,y:p,width:b,height:y});break}default:return}if(this.config.drawOutsideTarget===!1){if(this.basicResult){if(((i=(e=this.basicResult)==null?void 0:e.pointList)==null?void 0:i.length)>0&&$.isRectNotInPolygon(f,xe(this.basicResult.pointList,this.zoom)))return;const v=this.basicResult.x*this.zoom,p=this.basicResult.y*this.zoom,b=this.basicResult.width*this.zoom,y=this.basicResult.height*this.zoom;if(this.dragInfo.dragTarget!==z.Plane&&(f.x<v-.01||f.y<p-.01||f.width>v+b-f.x+.01||f.height>p+y-f.y+.01))return;if(f.x<v&&(f.x=v),f.y<p&&(f.y=p),f.width>v+b-f.x)switch(this.dragInfo.dragTarget){case z.Plane:f.x=v+b-g;break;case z.Point:case z.Line:c.x>0&&c.y>0&&(f.width=v+b-f.x);break;default:return}if(f.height>p+y-f.y)switch(this.dragInfo.dragTarget){case z.Plane:f.y=p+y-u;break}}else if(f.x<0&&(f.x=0),f.y<0&&(f.y=0),this.imgInfo)switch(this.dragInfo.dragTarget){case z.Plane:f.x+f.width>((s=this.imgInfo)==null?void 0:s.width)&&(f.x=this.imgInfo.width-g),f.y+f.height>((n=this.imgInfo)==null?void 0:n.height)&&(f.y=this.imgInfo.height-u);break;default:if(f.x+f.width>((o=this.imgInfo)==null?void 0:o.width)||f.y+f.height>((a=this.imgInfo)==null?void 0:a.height))return}}this.setRectList(this.rectList.map(v=>v.id===f.id?$.getRectUnderZoom(f,1/this.zoom):v)),this.render()}onMouseMove(t){var e,i;if(super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo)return;const s=this.getCoordinateUnderZoom(t),n=L.changeDrawOutsideTarget(s,{x:0,y:0},this.imgInfo,this.config.drawOutsideTarget,this.basicResult,this.zoom);if(this.selectedRectID&&this.dragInfo){this.onDragMove(n);return}if(this.selectedRectID){const l=this.getHoverRectPointIndex(t);if(l!==this.hoverRectPointIndex){this.hoverRectPointIndex=l,this.hoverRectEdgeIndex=-1,this.render();return}if(this.hoverRectPointIndex===-1){const h=this.getHoverRectEdgeIndex(t);if(h!==this.hoverRectEdgeIndex){this.hoverRectEdgeIndex=h,this.render();return}}}const o=this.getHoverRectID(t),a=this.hoverRectID;if(this.hoverRectID=o,o!==a&&this.render(),this.drawingRect&&this.firstClickCoord){let{x:l,y:h}=this.firstClickCoord,{width:d,height:g}=this.drawingRect;if(d=Math.abs(l-n.x),g=Math.abs(h-n.y),n.x<l&&(l=n.x),n.y<h&&(h=n.y),this.config.drawOutsideTarget===!1){if(((i=(e=this.basicResult)==null?void 0:e.pointList)==null?void 0:i.length)>0&&$.isRectNotInPolygon(Z(M({},this.drawingRect),{x:l,y:h,width:d,height:g}),xe(this.basicResult.pointList,this.zoom)))return;n.x<0&&(d=Math.abs(this.firstClickCoord.x),l=0),n.y<0&&(g=Math.abs(this.firstClickCoord.y),h=0),this.imgInfo&&(l+d>this.imgInfo.width&&(d=Math.abs(this.imgInfo.width-l)),h+g>this.imgInfo.height&&(g=Math.abs(this.imgInfo.height-h)))}this.drawingRect=Z(M({},this.drawingRect),{x:l,y:h,width:d,height:g}),this.render()}}setAttributeLockList(t){this.setSelectedRectID(void 0),super.setAttributeLockList(t)}setBasicResult(t){super.setBasicResult(t),this.clearActiveStatus()}setRectValidAndRender(t){!t||(this.setRectList(this.rectList.map(e=>e.id===t?Z(M({},e),{valid:!e.valid}):e),!0),this.render(),this.emit("updateResult"))}createNewDrawingRect(t,e){if(!this.imgInfo)return;const i=this.getCoordinateUnderZoom(t),s=L.changeDrawOutsideTarget(i,{x:0,y:0},this.imgInfo,this.config.drawOutsideTarget,this.basicResult,this.zoom);if(this.setSelectedRectID(""),this.hoverRectID="",this.drawOutSideTarget&&(s.x<0&&(s.x=0),s.y<0&&(s.y=0)),this.drawingRect=Z(M({},s),{width:0,height:0,attribute:this.defaultAttribute,valid:!t.ctrlKey,id:K(8,62),sourceID:e,textAttribute:""}),this.hasMarkerConfig){const n=x.getNextMarker(this.currentPageResult,this.config.markerList,this.markerIndex);if(n)this.drawingRect&&(this.drawingRect=Z(M({},this.drawingRect),{label:n.label})),this.markerIndex=n.index,this.emit("markIndexChange");else{this.emit("messageInfo",F.getMessagesByLocale(D.MarkerFinish,this.lang)),this.drawingRect=void 0;return}}if(this.config.textConfigurable){let n="";n=T.getTextAttribute(this.rectList.filter(o=>x.isSameSourceID(o.sourceID,e)),this.config.textCheckType),this.drawingRect&&(this.drawingRect=Z(M({},this.drawingRect),{textAttribute:n}))}Object.assign(this.drawingRect,{order:x.getMaxOrder(this.rectList.filter(n=>x.isSameSourceID(n.sourceID,e)))+1}),this.firstClickCoord=M({},s),this.firstCurrentPos=M({},this.currentPos)}addDrawingRectToRectList(){if(!this.drawingRect)return;let{width:t,height:e}=this.drawingRect;if(t/=this.zoom,e/=this.zoom,Math.round(t)<this.config.minWidth||Math.round(e)<this.config.minHeight){this.emit("messageInfo",F.getMessagesByLocale(D.RectErrorSizeNotice,this.lang)),this.drawingRect=void 0,this.firstClickCoord=void 0,this.dragInfo=void 0,this.dragStatus=k.Wait,this.render();return}const i=this.getDrawingRectWithRectList();this.setRectList(i,!0),this.history.pushHistory(this.rectList),this.setSelectedIdAfterAddingDrawingRect(),this.firstClickCoord=void 0,this.drawingRect=void 0,this.dragInfo=void 0,this.dragStatus=k.Wait}setSelectedIdAfterAddingDrawingRect(){!this.drawingRect||(this.config.textConfigurable?this.setSelectedRectID(this.drawingRect.id):this.setSelectedRectID())}getDrawingRectWithRectList(){if(!this.drawingRect)return this.rectList;let{x:t,y:e,width:i,height:s}=this.drawingRect;return t/=this.zoom,e/=this.zoom,i/=this.zoom,s/=this.zoom,[...this.rectList,Z(M({},this.drawingRect),{x:t,y:e,width:i,height:s})]}rightMouseUp(t){const e=this.getHoverRectID(t),i=this.rectList.find(n=>n.id===e),{selectedRectID:s}=this;if(this.setSelectedRectID(void 0),i&&this.setDefaultAttribute(i.attribute),this.drawingRect)this.drawingRect=void 0,this.firstClickCoord=void 0;else if(s!==e&&this.dblClickListener.clearRightDblClick(),this.setSelectedRectID(e),this.hoverRectID="",(i==null?void 0:i.label)&&this.hasMarkerConfig){const n=x.getCurrentMarkerIndex(i.label,this.config.markerList);n>=0&&(this.setMarkerIndex(n),this.emit("markIndexChange"))}this.render()}shiftRightMouseUp(t){const e=this.getHoverRectID(t);this.emit("shiftRightMouseUp",e)}onMouseUp(t){if(super.onMouseUp(t)||this.forbidMouseOperation||!this.imgInfo)return!0;if(this.dragInfo&&this.dragStatus===k.Move){this.dragInfo=void 0,this.dragStatus=k.Wait,this.history.pushHistory(this.rectList),this.emit("updateResult");return}if(t.button===2&&t.shiftKey===!0){this.shiftRightMouseUp(t);return}if(t.button===2){this.rightMouseUp(t);return}const e=x.getSourceID(this.basicResult);if(this.drawingRect){this.addDrawingRectToRectList();return}if(t.ctrlKey===!0&&t.button===0&&this.hoverRectID){this.setRectValidAndRender(this.hoverRectID);return}this.createNewDrawingRect(t,e),this.render()}onRightDblClick(t){super.onRightDblClick(t);const e=this.getHoverRectID(t);this.selectedRectID&&this.selectedRectID===e&&this.deleteRect(e)}onKeyDown(t){if(!x.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;const{keyCode:e}=t;switch(e){case _.Ctrl:this.drawingRect&&(this.drawingRect=Z(M({},this.drawingRect),{valid:!t.ctrlKey}),this.render());break;case _.F:this.selectedRectID&&this.setRectValidAndRender(this.selectedRectID);break;case _.Z:this.setIsHidden(!this.isHidden),this.render();break;case _.Delete:this.deleteRect(this.selectedRectID);break;case _.Tab:{if(t.preventDefault(),this.drawingRect)return;let i=j.ascend;t.shiftKey&&(i=j.descend);const[s,n]=x.getRenderResultList(this.rectList,x.getSourceID(this.basicResult),this.attributeLockList,this.selectedRectID);let o=[...s];n&&(o=[...o,n]);const a=et.getViewPort(this.canvas,this.currentPos,this.zoom);o=o.filter(h=>et.inViewPort({x:h.x,y:h.y},a));const l=x.getNextSelectedRectID(o,i,this.selectedRectID);l&&(this.setSelectedRectID(l.id),this.config.attributeConfigurable===!0&&this.setDefaultAttribute(l.attribute));break}default:{if(this.config.attributeConfigurable){const i=T.getAttributeByKeycode(e,this.config.attributeList);i!==void 0&&this.setDefaultAttribute(i)}break}}return!0}onKeyUp(t){switch(super.onKeyUp(t),t.keyCode){case _.Ctrl:this.drawingRect&&(this.drawingRect=Z(M({},this.drawingRect),{valid:!0}),this.render());break}}onWheel(t){const e=this.zoom;let i,s;this.drawingRect&&this.firstClickCoord&&(i=$.getRectUnderZoom(this.drawingRect,1/e),s=L.changePointByZoom(this.firstClickCoord,1/e)),super.onWheel(t,!1),i&&s&&(this.drawingRect=$.getRectUnderZoom(i,this.zoom),this.firstClickCoord=L.changePointByZoom(s,this.zoom)),this.render()}getCurrentSelectedData(){const{selectedRect: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:t.width*this.zoom*.6,textAttribute:t.textAttribute,color:i}}renderTextAttribute(){var t;const{selectedRect:e}=this;if(!this.ctx||this.config.textConfigurable!==!0||!e)return;const{x:i,y:s,width:n,height:o,attribute:a,valid:l}=e,h=n*this.zoom*.6,d=L.getOffsetCoordinate({x:i,y:s+o},this.currentPos,this.zoom),g=this.getColor(a),u=l?g==null?void 0:g.valid.stroke:g==null?void 0:g.invalid.stroke,c=4;this._textAttributInstance||(this._textAttributInstance=new Ot({width:h,container:this.container,icon:this.getTextIconSvg(a),color:u,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedRectTextAttribute})),this._textAttributInstance&&!((t=this._textAttributInstance)==null?void 0:t.isExit)&&this._textAttributInstance.appendToContainer(),this._textAttributInstance.update(`${e.textAttribute}`,{left:d.x,top:d.y+c,color:u,width:h})}renderSelectedRect(t){const{selectedRect:e}=this;if(!this.ctx||!t||!e)return;const{ctx:i}=this;let s=10;const n=$.getRectPointList(e),o=n.length,a=this.getColor(t.attribute);n.forEach((l,h)=>{var d,g;if(i.save(),i.moveTo(l.x,l.y),i.beginPath(),this.hoverRectPointIndex===h?s=It+6:s=It,t.valid===!1?(i.strokeStyle=a==null?void 0:a.invalid.stroke,i.fillStyle=a==null?void 0:a.invalid.stroke):(i.strokeStyle=a==null?void 0:a.valid.stroke,i.fillStyle=a==null?void 0:a.valid.stroke),i.arc(l.x*this.zoom+this.currentPos.x,l.y*this.zoom+this.currentPos.y,s,0,2*Math.PI),i.fill(),this.hoverRectEdgeIndex===h){i.beginPath(),i.lineWidth=10;const u=this.getColor(t.attribute),c=t.valid===!1?(d=u==null?void 0:u.invalid)==null?void 0:d.stroke:(g=u==null?void 0:u.valid)==null?void 0:g.stroke;i.strokeStyle=c,i.moveTo(n[h].x*this.zoom+this.currentPos.x,n[h].y*this.zoom+this.currentPos.y),i.lineTo(n[(h+1)%o].x*this.zoom+this.currentPos.x,n[(h+1)%o].y*this.zoom+this.currentPos.y),i.stroke()}i.restore()}),this.renderTextAttribute()}renderDrawingRect(t,e=this.zoom,i=!1){var s,n,o,a;if(this.ctx&&t){const{ctx:l,style:h}=this,{hiddenText:d=!1}=h,g=this.getColor(t.attribute);let{x:u,y:c,width:f,height:v}=t;u*=e,c*=e,f*=e,v*=e,l.save();let p;t.valid===!1?(l.strokeStyle=g==null?void 0:g.invalid.stroke,l.fillStyle=g==null?void 0:g.invalid.fill,p=g==null?void 0:g.invalid.stroke):(l.strokeStyle=g==null?void 0:g.valid.stroke,l.fillStyle=g==null?void 0:g.valid.fill,p=g==null?void 0:g.valid.stroke),l.font="lighter 14px Arial";let b="";((s=this.config)==null?void 0:s.isShowOrder)&&t.order&&(t==null?void 0:t.order)>0&&(b=`${t.order}`),t.label&&this.hasMarkerConfig&&(b=`${x.getCurrentMarkerIndex(t.label,this.config.markerList)+1}_${re.getMarkerShowText(t.label,this.config.markerList)}`),t.attribute&&(b=`${b} ${T.getAttributeShowText(t.attribute,(n=this.config)==null?void 0:n.attributeList)}`),d||m.drawText(this.canvas,{x:this.currentPos.x+u,y:this.currentPos.y+c-6},b,Z(M({color:p,font:"normal normal 900 14px SourceHanSansCN-Regular"},dt),{textMaxWidth:300})),l.lineWidth=(a=(o=this.style)==null?void 0:o.width)!=null?a:2,(t.id===this.hoverRectID||t.id===this.selectedRectID)&&l.fillRect(this.currentPos.x+u,this.currentPos.y+c,f,v),l.strokeRect(this.currentPos.x+u,this.currentPos.y+c,f,v),l.restore();let y=`${Math.round(f/e)} * ${Math.round(v/e)}`;i===!0&&(y=`${Math.round(f/this.zoom)} * ${Math.round(v/this.zoom)}`);const P=y.length*7,A=t.valid?g==null?void 0:g.valid.stroke:g==null?void 0:g.invalid.stroke;if(d||m.drawText(this.canvas,{x:this.currentPos.x+u+f-P,y:this.currentPos.y+c+v+15},y,M({color:A,font:"normal normal 600 14px Arial"},dt)),!d&&t.textAttribute&&t.id!==this.selectedRectID){const I=0,R=Math.max(20,f-P);m.drawText(this.canvas,{x:this.currentPos.x+u,y:this.currentPos.y+c+v+20+I},t.textAttribute,M({color:A,font:"italic normal 900 14px Arial",textMaxWidth:R},dt))}}}renderRect(){var t;if(((t=this.rectList)==null?void 0:t.length)>0&&JSON.stringify(this.rectList)){const[e,i]=x.getRenderResultList(this.rectList,x.getSourceID(this.basicResult),this.attributeLockList,this.selectedRectID);this.isHidden||e==null||e.forEach(s=>this.renderDrawingRect(s)),i&&(this.renderDrawingRect(i),this.renderSelectedRect(i))}this.drawingRect&&this.renderDrawingRect(this.drawingRect,1,!0)}render(){!this.ctx||(super.render(),this.renderRect(),this.renderCursorLine(this.getLineColor(this.defaultAttribute)))}setDefaultAttribute(t){const e=this.defaultAttribute;if(this.defaultAttribute=t!=null?t:"",e!==t){this.changeStyle(t),this.emit("changeAttributeSidebar");const{selectedRect:i}=this;if(i&&(this.setRectList(this.rectList.map(s=>s.id===this.selectedID?Z(M({},s),{attribute:this.defaultAttribute}):s),!0),this.history.pushHistory(this.rectList),this.render()),this.drawingRect&&(this.drawingRect=Z(M({},this.drawingRect),{attribute:this.defaultAttribute}),this.render()),this._textAttributInstance){if(this.attributeLockList.length>0&&!this.attributeLockList.includes(this.defaultAttribute)){this._textAttributInstance.clearTextAttribute();return}this._textAttributInstance.updateIcon(this.getTextIconSvg(t))}}}setValid(t){super.setValid(t),this.emit("updateResult")}clearActiveStatus(){this.drawingRect=void 0,this.firstClickCoord=void 0,this.dragInfo=void 0,this.dragStatus=k.Wait,this.setSelectedRectID(void 0)}clearResult(t=!0){const e=this.rectList.filter(i=>i.disableDelete===!0);e.length>0&&t&&this.emit("messageInfo",F.getMessagesByLocale(D.ClearPartialData,this.lang)),this.setRectList(e,!0),this.setSelectedRectID(void 0)}deleteRect(t){var e;if(!t)return;const i=this.rectList.find(s=>s.id===t);if((i==null?void 0:i.disableDelete)===!0){this.emit("messageInfo",F.getMessagesByLocale(D.DisableDelete,this.lang));return}this.setRectList(this.rectList.filter(s=>s.id!==t),!0),this.history.pushHistory(this.rectList),this.setSelectedRectID(void 0),(e=this._textAttributInstance)==null||e.clearTextAttribute(),this.render()}exportData(){const{rectList:t}=this;return[t,this.basicImgInfo]}undo(){const t=this.history.undo();t&&(t.length!==this.rectList.length&&this.setSelectedRectID(""),this.setRectList(t,!0),this.render())}redo(){const t=this.history.redo();t&&(t.length!==this.rectList.length&&this.setSelectedRectID(""),this.setRectList(t,!0),this.render())}}var nn=Object.defineProperty,on=Object.defineProperties,an=Object.getOwnPropertyDescriptors,Pi=Object.getOwnPropertySymbols,ln=Object.prototype.hasOwnProperty,hn=Object.prototype.propertyIsEnumerable,Ci=(r,t,e)=>t in r?nn(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,cn=(r,t)=>{for(var e in t||(t={}))ln.call(t,e)&&Ci(r,e,t[e]);if(Pi)for(var e of Pi(t))hn.call(t,e)&&Ci(r,e,t[e]);return r},dn=(r,t)=>on(r,an(t));const un={textConfigurable:!1,attributeConfigurable:!0,attributeList:[]};class gn extends he{constructor(t){super(dn(cn({},t),{config:JSON.stringify(un)}))}setSelectedIdAfterAddingDrawingRect(){!this.drawingRect||this.setSelectedRectID(this.drawingRect.id)}}class fn{constructor(t){this._domMap=new Map,this._container=t.container,this._height=t.height}wheelChange(t){t.stopPropagation()}clearTag(t){const e=this._container,i=window.self.document.getElementById(t);i&&e&&e.contains(i)&&(i.removeEventListener("wheel",this.wheelChange),e==null||e.removeChild(i))}render(t){const e=Array.from(this._domMap.keys()),i=t.map(s=>s.id);t.forEach(s=>{const{text:n,textMaxWidth:o,color:a="white",background:l="rgba(0, 0, 0, 0.6)",style:h}=s;if(this._domMap.has(s.id)){const d=this._domMap.get(s.id);d&&(d.innerHTML=n)}else{const d=m.drawTagByDom(this._container,n,s.id);d&&(d.setAttribute("style",`
|
|
78
78
|
position: absolute;
|
|
79
79
|
top: 0;
|
|
80
80
|
right: 0;
|
|
@@ -93,4 +93,4 @@
|
|
|
93
93
|
overflow-y: scroll;
|
|
94
94
|
clear: both;
|
|
95
95
|
${q.getStyle2String(h)}
|
|
96
|
-
`),u.addEventListener("wheel",this.wheelChange),this._domMap.set(s.id,u))}}),e.forEach(s=>{i.indexOf(s)===-1&&(this.clearTag(s),this._domMap.delete(s))})}}var vn=Object.defineProperty,pn=Object.defineProperties,bn=Object.getOwnPropertyDescriptors,Di=Object.getOwnPropertySymbols,xn=Object.prototype.hasOwnProperty,yn=Object.prototype.propertyIsEnumerable,_i=(r,t,e)=>t in r?vn(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,B=(r,t)=>{for(var e in t||(t={}))xn.call(t,e)&&_i(r,e,t[e]);if(Di)for(var e of Di(t))yn.call(t,e)&&_i(r,e,t[e]);return r},bt=(r,t)=>pn(r,bn(t));const mn=3,In=3,ce="#6371FF";class wn extends it{constructor(t){super(bt(B({},t),{showDefaultCursor:!0}));this.style={},this.annotations=[],this.getHoverRectID=i=>{var s,n;const o=this.getCoordinateUnderZoom(i),a=L.changePointByZoom(o,1/this.zoom);if(((s=this.annotations)==null?void 0:s.length)<=0||!((n=this.annotations)==null?void 0:n.length))return;let l="",h=Number.MAX_SAFE_INTEGER;for(let u=0;u<this.annotations.length;u++){const g=this.annotations[u];switch(g.type){case"rect":{const c=g.annotation;if($.isInRect(o,c,mn,this.zoom)){const d=c.width*c.height;d<h&&(l=c.id,h=d)}break}case"polygon":{const c=g.annotation;if(H.isInPolygon(a,c.pointList)){const d=H.getPolygonArea(c.pointList);d<h&&(l=c.id,h=d)}break}}}return l};var e;this.style=(e=t.style)!=null?e:{stroke:ce,thickness:3},this.annotations=t.annotations,this.loading=!1,this.renderDomInstance=new fn({container:this.container,height:this.canvas.height})}setLoading(t){this.loading=t,this.render()}onMouseLeave(){super.onMouseLeave(),this.mouseHoverID=void 0,this.emit("onChange","hover",[])}onMouseDown(t){if(super.onMouseDown(t)||this.forbidMouseOperation||!this.imgInfo)return!0;const e=this.mouseHoverID;if(t.button===0){let i=[];e&&(i=[e]),this.emit("onChange","selected",i),this.render()}}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&&(s=[i]),this.emit("onChange","hover",s),this.render()}}updateData(t){this.annotations=t,this.render()}getSpecificStyle(t){const e=N.pick(t,["stroke","thickness","fill","radius"]),i=B(B({},this.style),e);return i.stroke&&Object.assign(i,{color:i.stroke}),i}getRenderText(t,e=!1){let i="",s="";return!t||e===!0?{headerText:i,bottomText:s}:((t==null?void 0:t.order)&&(i=`${t.order}`),(t==null?void 0:t.label)&&(i?i=`${i}_${t.label}`:i=`${t.label}`),(t==null?void 0:t.attribute)&&(i?i=`${i} ${t.attribute}`:i=`${t.attribute}`),(t==null?void 0:t.textAttribute)&&(s=t==null?void 0:t.textAttribute),{headerText:i,bottomText:s})}getReferenceOptions(t){return t?{lineCap:"butt",lineDash:[20,20]}:{}}render(){try{if(super.render(),this.loading===!0)return;this.renderDomInstance.render(this.annotations.filter(t=>t.type==="text"&&t.annotation.position==="rt").map(t=>t.annotation)),this.annotations.forEach(t=>{var e,i,s,n,o,a,l,h,u,g,c;switch(t.type){case"rect":{const d=t.annotation,{hiddenText:f=!1,isReference:v}=d,{zoom:p}=this,b=L.changeRectByZoom(d,this.zoom,this.currentPos),{x:y,y:P,width:A,height:I}=b,R=this.getSpecificStyle(d);if(d.id===this.mouseHoverID||R.fill){const rt=ue((i=(e=R==null?void 0:R.fill)!=null?e:R==null?void 0:R.stroke)!=null?i:ce),xt=`rgba(${rt[0]}, ${rt[1]}, ${rt[2]},${rt[3]*.8})`;m.drawRectWithFill(this.canvas,b,{color:xt})}m.drawRect(this.canvas,b,B(bt(B({},R),{hiddenText:!0}),this.getReferenceOptions(v)));const{headerText:E,bottomText:G}=this.getRenderText(d,d==null?void 0:d.hiddenText);E&&m.drawText(this.canvas,{x:y,y:P-6},E,bt(B({color:R.stroke,font:"normal normal 900 14px SourceHanSansCN-Regular"},dt),{textMaxWidth:300}));const Q=`${Math.round(A/p)} * ${Math.round(I/p)}`,wt=Q.length*7;if(f||m.drawText(this.canvas,{x:y+A-wt,y:P+I+15},Q,B({color:R.stroke,font:"normal normal 600 14px Arial"},dt)),G){const rt=20,xt=Math.max(20,A-wt);m.drawText(this.canvas,{x:y,y:P+I+rt},d.textAttribute,B({color:R.stroke,font:"italic normal 900 14px Arial",textMaxWidth:xt},dt))}break}case"polygon":{const d=t.annotation;if(!(((s=d==null?void 0:d.pointList)==null?void 0:s.length)>=3))return;const{lineType:f=S.Line}=d,v=L.changePointListByZoom((n=d==null?void 0:d.pointList)!=null?n:[],this.zoom,this.currentPos),p=this.getSpecificStyle(d);if(d.id===this.mouseHoverID||p.fill){const I=ue((a=(o=p==null?void 0:p.fill)!=null?o:p==null?void 0:p.stroke)!=null?a:ce),R=`rgba(${I[0]}, ${I[1]}, ${I[2]},${I[3]*.8})`;m.drawPolygonWithFill(this.canvas,v,{color:R,lineType:f})}const b=m.drawPolygon(this.canvas,v,bt(B(bt(B({},p),{isClose:!0}),this.getReferenceOptions(d==null?void 0:d.isReference)),{lineType:f}));if((d==null?void 0:d.showDirection)===!0&&((l=d==null?void 0:d.pointList)==null?void 0:l.length)>2){let I=v[0],R=C.getLineCenterPoint([v[0],v[1]]);if(f===S.Curve){const E=Math.floor(W/2);I=b[E],R=b[E+1]}m.drawArrowByCanvas(this.canvas,I,R,{color:p.stroke,thickness:p.thickness}),m.drawCircleWithFill(this.canvas,v[0],p.thickness+2,{color:p.stroke})}const{headerText:P,bottomText:A}=this.getRenderText(d,d==null?void 0:d.hiddenText);if(P&&m.drawText(this.canvas,v[0],P,B({color:p.stroke},Y)),A){const I=v[v.length-1];m.drawText(this.canvas,{x:I.x+ut.x,y:I.y+ut.y},A,B({color:p.stroke},Y))}break}case"line":{const d=t.annotation;if(!(((h=d==null?void 0:d.pointList)==null?void 0:h.length)>=2))return;const{lineType:f=S.Line}=d,v=L.changePointListByZoom((u=d==null?void 0:d.pointList)!=null?u:[],this.zoom,this.currentPos),p=this.getSpecificStyle(d),b=m.drawPolygon(this.canvas,v,bt(B(B({},p),this.getReferenceOptions(d==null?void 0:d.isReference)),{lineType:f}));if((d==null?void 0:d.showDirection)===!0&&((g=d==null?void 0:d.pointList)==null?void 0:g.length)>2){let I=v[0],R=C.getLineCenterPoint([v[0],v[1]]);if(f===S.Curve){const E=Math.floor(W/2);I=b[E],R=b[E+1]}m.drawArrowByCanvas(this.canvas,I,R,{color:p.stroke,thickness:p.thickness}),m.drawCircleWithFill(this.canvas,v[0],p.thickness+2,{color:p.stroke})}const{headerText:P,bottomText:A}=this.getRenderText(d,d==null?void 0:d.hiddenText);if(P&&m.drawText(this.canvas,v[0],P,B({color:p.stroke},Y)),A){const I=v[v.length-1];m.drawText(this.canvas,{x:I.x+ut.x,y:I.y+ut.y},A,B({color:p.stroke},Y))}break}case"point":{const d=t.annotation,f=L.changePointByZoom(d,this.zoom,this.currentPos),v=this.getSpecificStyle(d),p=(c=v.radius)!=null?c:In;m.drawCircle(this.canvas,f,p,v);const{headerText:b,bottomText:y}=this.getRenderText(d,d==null?void 0:d.hiddenText);b&&m.drawText(this.canvas,{x:f.x+p/2,y:f.y-p-4},b,{textAlign:"center",color:v.stroke}),y&&m.drawText(this.canvas,{x:f.x+p,y:f.y+p+24},y,B({color:v.stroke},Y));break}case"text":{const d=t.annotation,{text:f,x:v,y:p,textMaxWidth:b,color:y="white",background:P="rgba(0, 0, 0, 0.6)",lineHeight:A=25,font:I=Ct,position:R}=d,E=10,G=10,Q=L.changePointByZoom({x:v,y:p},this.zoom,this.currentPos),{width:wt,height:rt,fontHeight:xt=0}=C.getTextArea(this.canvas,d.text,b,I,A);if(R==="rt")break;m.drawRectWithFill(this.canvas,{x:Q.x,y:Q.y,width:wt+G*2,height:rt+E*2,id:"",sourceID:"",valid:!0,textAttribute:"",attribute:""},{color:P}),m.drawText(this.canvas,{x:Q.x+G,y:Q.y+xt+E},f,{color:y,lineHeight:A,font:I,textMaxWidth:b});break}default:}})}catch(t){console.error("ViewOperation Render Error",t)}}}const Ln={0:"\u76EE\u6807\u68C0\u6D4B",1:"\u56FE\u50CF\u5206\u7C7B"},Pn={0:"\u6807\u6CE8\u6587\u4EF6\u4F20\u8F93\u4E2D",1:"\u6807\u6CE8\u6587\u4EF6\u4F20\u8F93\u91CD\u8BD5",2:"\u6807\u6CE8\u6587\u4EF6\u4F20\u8F93\u5931\u8D25",3:"\u6807\u6CE8\u4E2D",4:"\u4EFB\u52A1\u7EC8\u6B62",5:"\u4EFB\u52A1\u5B8C\u6210",6:"\u6570\u636E\u5DF2\u53D1\u5E03"};var de;(function(r){r[r.Upload=0]="Upload",r[r.UploadRetry=1]="UploadRetry",r[r.UploadFail=2]="UploadFail",r[r.Annotation=3]="Annotation",r[r.Terminated=4]="Terminated",r[r.Finish=5]="Finish",r[r.Publish=6]="Publish"})(de||(de={}));var Cn=Object.freeze({__proto__:null,ANNOTATION_TYPE:Ln,ANNOTATION_STATUS:Pn,get EAnnotationStatus(){return de}});class Dn{static load(t){return new Promise((e,i)=>{const s=new Image;t.startsWith("file")?s.src=encodeURI(t):s.src=t,s.onload=()=>{e(s)},s.onerror=()=>{i(s)}})}}var _n=(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 An=r=>new Promise((t,e)=>{const i=document.createElement("img");i.crossOrigin="Anonymous",i.onerror=s=>{console.error(s),e(i)},i.src=r,i.onload=()=>{t(i)}});class Rn{constructor(t){this.setImgSrc=s=>_n(this,null,function*(){const n=yield An(s);!n||this.setImgNode(n)});var e,i;this.container=t.container,this.size=t.size,this.toolName=t.toolName,this.imgNode=t.imgNode,this.config=(e=t.config)!=null?e:JSON.stringify(He(t.toolName)),this.style=(i=t.style)!=null?i:Ne,this._initToolOperation()}setToolName(t,e){this.toolName=t;const i=e||JSON.stringify(He(t));this.config=i,this._initToolOperation()}setImgNode(t,e){!this.toolInstance||(this.imgNode=t,this.toolInstance.setImgNode(t,e))}setSize(t){this.size=t}setStyle(t){this.style=t}_initToolOperation(){this.toolInstance&&this.toolInstance.destroy();const t=x.getCurrentOperation(this.toolName);if(!t)return;const e={container:this.container,size:this.size,config:this.config,drawOutSideTarget:!1,style:this.style};this.imgNode&&Object.assign(e,{imgNode:this.imgNode}),this.toolInstance=new t(e),this.toolInstance.init()}setBasicInfo(t,e){this.dependToolName=t,this.basicResult=e,this.toolInstance.setDependName(t),this.toolInstance.setBasicResult(e),this.toolInstance.renderBasicCanvas()}clearBasicResult(){this.setBasicInfo()}forbidOperation(){this.toolInstance.setForbidOperation(!0)}launchOperation(){this.toolInstance.setForbidOperation(!1)}setLang(t){switch(t){case"cn":this.toolInstance.setLang(nt.Zh);break;case"en":this.toolInstance.setLang(nt.US);break}}}const Tn=x;export{Rn as AnnotationEngine,L as AxisUtils,it as BasicToolOperation,x as CommonToolUtils,We as DblClickEventListener,m as DrawUtils,Dn as ImgUtils,li as LineToolOperation,re as MarkerUtils,gn as MeasureOperation,gi as PointOperation,si as PolygonOperation,he as RectOperation,$ as RectUtils,ri as TagOperation,mt as TagUtils,fi as TextToolOperation,wn as ViewOperation,Ki as cAnnotation,Cn as cAnnotationTask,ar as cKeyCode,Ss as cStyle,Hi as cTool,Tn as toolUtils,K as uuid};
|
|
96
|
+
`),d.addEventListener("wheel",this.wheelChange),this._domMap.set(s.id,d))}}),e.forEach(s=>{i.indexOf(s)===-1&&(this.clearTag(s),this._domMap.delete(s))})}}var vn=Object.defineProperty,pn=Object.defineProperties,bn=Object.getOwnPropertyDescriptors,Di=Object.getOwnPropertySymbols,xn=Object.prototype.hasOwnProperty,yn=Object.prototype.propertyIsEnumerable,_i=(r,t,e)=>t in r?vn(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,B=(r,t)=>{for(var e in t||(t={}))xn.call(t,e)&&_i(r,e,t[e]);if(Di)for(var e of Di(t))yn.call(t,e)&&_i(r,e,t[e]);return r},bt=(r,t)=>pn(r,bn(t));const mn=3,In=3,ce="#6371FF";class wn extends it{constructor(t){super(bt(B({},t),{showDefaultCursor:!0}));this.style={},this.annotations=[],this.getHoverRectID=i=>{var s,n;const o=this.getCoordinateUnderZoom(i),a=L.changePointByZoom(o,1/this.zoom);if(((s=this.annotations)==null?void 0:s.length)<=0||!((n=this.annotations)==null?void 0:n.length))return;let l="",h=Number.MAX_SAFE_INTEGER;for(let d=0;d<this.annotations.length;d++){const g=this.annotations[d];switch(g.type){case"rect":{const u=g.annotation;if($.isInRect(o,u,mn,this.zoom)){const c=u.width*u.height;c<h&&(l=u.id,h=c)}break}case"polygon":{const u=g.annotation;if(H.isInPolygon(a,u.pointList)){const c=H.getPolygonArea(u.pointList);c<h&&(l=u.id,h=c)}break}}}return l};var e;this.style=(e=t.style)!=null?e:{stroke:ce,thickness:3},this.annotations=t.annotations,this.loading=!1,this.renderDomInstance=new fn({container:this.container,height:this.canvas.height})}setLoading(t){this.loading=t,this.render()}onMouseLeave(){super.onMouseLeave(),this.mouseHoverID=void 0,this.emit("onChange","hover",[])}onMouseDown(t){if(super.onMouseDown(t)||this.forbidMouseOperation||!this.imgInfo)return!0;const e=this.mouseHoverID;if(t.button===0){let i=[];e&&(i=[e]),this.emit("onChange","selected",i),this.render()}}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&&(s=[i]),this.emit("onChange","hover",s),this.render()}}updateData(t){this.annotations=t,this.render()}getSpecificStyle(t){const e=N.pick(t,["stroke","thickness","fill","radius"]),i=B(B({},this.style),e);return i.stroke&&Object.assign(i,{color:i.stroke}),i}getRenderText(t,e=!1){let i="",s="";return!t||e===!0?{headerText:i,bottomText:s}:((t==null?void 0:t.order)&&(i=`${t.order}`),(t==null?void 0:t.label)&&(i?i=`${i}_${t.label}`:i=`${t.label}`),(t==null?void 0:t.attribute)&&(i?i=`${i} ${t.attribute}`:i=`${t.attribute}`),(t==null?void 0:t.textAttribute)&&(s=t==null?void 0:t.textAttribute),{headerText:i,bottomText:s})}getReferenceOptions(t){return t?{lineCap:"butt",lineDash:[20,20]}:{}}render(){try{if(super.render(),this.loading===!0)return;this.renderDomInstance.render(this.annotations.filter(t=>t.type==="text"&&t.annotation.position==="rt").map(t=>t.annotation)),this.annotations.forEach(t=>{var e,i,s,n,o,a,l,h,d,g,u;switch(t.type){case"rect":{const c=t.annotation,{hiddenText:f=!1,isReference:v}=c,{zoom:p}=this,b=L.changeRectByZoom(c,this.zoom,this.currentPos),{x:y,y:P,width:A,height:I}=b,R=this.getSpecificStyle(c);if(c.id===this.mouseHoverID||R.fill){const rt=ue((i=(e=R==null?void 0:R.fill)!=null?e:R==null?void 0:R.stroke)!=null?i:ce),xt=`rgba(${rt[0]}, ${rt[1]}, ${rt[2]},${rt[3]*.8})`;m.drawRectWithFill(this.canvas,b,{color:xt})}m.drawRect(this.canvas,b,B(bt(B({},R),{hiddenText:!0}),this.getReferenceOptions(v)));const{headerText:E,bottomText:G}=this.getRenderText(c,c==null?void 0:c.hiddenText);E&&m.drawText(this.canvas,{x:y,y:P-6},E,bt(B({color:R.stroke,font:"normal normal 900 14px SourceHanSansCN-Regular"},dt),{textMaxWidth:300}));const Q=`${Math.round(A/p)} * ${Math.round(I/p)}`,wt=Q.length*7;if(f||m.drawText(this.canvas,{x:y+A-wt,y:P+I+15},Q,B({color:R.stroke,font:"normal normal 600 14px Arial"},dt)),G){const rt=20,xt=Math.max(20,A-wt);m.drawText(this.canvas,{x:y,y:P+I+rt},c.textAttribute,B({color:R.stroke,font:"italic normal 900 14px Arial",textMaxWidth:xt},dt))}break}case"polygon":{const c=t.annotation;if(!(((s=c==null?void 0:c.pointList)==null?void 0:s.length)>=3))return;const{lineType:f=S.Line}=c,v=L.changePointListByZoom((n=c==null?void 0:c.pointList)!=null?n:[],this.zoom,this.currentPos),p=this.getSpecificStyle(c);if(c.id===this.mouseHoverID||p.fill){const I=ue((a=(o=p==null?void 0:p.fill)!=null?o:p==null?void 0:p.stroke)!=null?a:ce),R=`rgba(${I[0]}, ${I[1]}, ${I[2]},${I[3]*.8})`;m.drawPolygonWithFill(this.canvas,v,{color:R,lineType:f})}const b=m.drawPolygon(this.canvas,v,bt(B(bt(B({},p),{isClose:!0}),this.getReferenceOptions(c==null?void 0:c.isReference)),{lineType:f}));if((c==null?void 0:c.showDirection)===!0&&((l=c==null?void 0:c.pointList)==null?void 0:l.length)>2){let I=v[0],R=C.getLineCenterPoint([v[0],v[1]]);if(f===S.Curve){const E=Math.floor(W/2);I=b[E],R=b[E+1]}m.drawArrowByCanvas(this.canvas,I,R,{color:p.stroke,thickness:p.thickness}),m.drawCircle(this.canvas,v[0],p.thickness+6,{color:p.stroke,thickness:p.thickness})}const{headerText:P,bottomText:A}=this.getRenderText(c,c==null?void 0:c.hiddenText);if(P&&m.drawText(this.canvas,v[0],P,B({color:p.stroke},Y)),A){const I=v[v.length-1];m.drawText(this.canvas,{x:I.x+ut.x,y:I.y+ut.y},A,B({color:p.stroke},Y))}break}case"line":{const c=t.annotation;if(!(((h=c==null?void 0:c.pointList)==null?void 0:h.length)>=2))return;const{lineType:f=S.Line}=c,v=L.changePointListByZoom((d=c==null?void 0:c.pointList)!=null?d:[],this.zoom,this.currentPos),p=this.getSpecificStyle(c),b=m.drawPolygon(this.canvas,v,bt(B(B({},p),this.getReferenceOptions(c==null?void 0:c.isReference)),{lineType:f}));if((c==null?void 0:c.showDirection)===!0&&((g=c==null?void 0:c.pointList)==null?void 0:g.length)>2){let I=v[0],R=C.getLineCenterPoint([v[0],v[1]]);if(f===S.Curve){const E=Math.floor(W/2);I=b[E],R=b[E+1]}m.drawArrowByCanvas(this.canvas,I,R,{color:p.stroke,thickness:p.thickness}),m.drawCircle(this.canvas,v[0],p.thickness+6,{color:p.stroke,thickness:p.thickness})}const{headerText:P,bottomText:A}=this.getRenderText(c,c==null?void 0:c.hiddenText);if(P&&m.drawText(this.canvas,v[0],P,B({color:p.stroke},Y)),A){const I=v[v.length-1];m.drawText(this.canvas,{x:I.x+ut.x,y:I.y+ut.y},A,B({color:p.stroke},Y))}break}case"point":{const c=t.annotation,f=L.changePointByZoom(c,this.zoom,this.currentPos),v=this.getSpecificStyle(c),p=(u=v.radius)!=null?u:In;m.drawCircle(this.canvas,f,p,v);const{headerText:b,bottomText:y}=this.getRenderText(c,c==null?void 0:c.hiddenText);b&&m.drawText(this.canvas,{x:f.x+p/2,y:f.y-p-4},b,{textAlign:"center",color:v.stroke}),y&&m.drawText(this.canvas,{x:f.x+p,y:f.y+p+24},y,B({color:v.stroke},Y));break}case"text":{const c=t.annotation,{text:f,x:v,y:p,textMaxWidth:b,color:y="white",background:P="rgba(0, 0, 0, 0.6)",lineHeight:A=25,font:I=Ct,position:R}=c,E=10,G=10,Q=L.changePointByZoom({x:v,y:p},this.zoom,this.currentPos),{width:wt,height:rt,fontHeight:xt=0}=C.getTextArea(this.canvas,c.text,b,I,A);if(R==="rt")break;m.drawRectWithFill(this.canvas,{x:Q.x,y:Q.y,width:wt+G*2,height:rt+E*2,id:"",sourceID:"",valid:!0,textAttribute:"",attribute:""},{color:P}),m.drawText(this.canvas,{x:Q.x+G,y:Q.y+xt+E},f,{color:y,lineHeight:A,font:I,textMaxWidth:b});break}default:}})}catch(t){console.error("ViewOperation Render Error",t)}}}const Ln={0:"\u76EE\u6807\u68C0\u6D4B",1:"\u56FE\u50CF\u5206\u7C7B"},Pn={0:"\u6807\u6CE8\u6587\u4EF6\u4F20\u8F93\u4E2D",1:"\u6807\u6CE8\u6587\u4EF6\u4F20\u8F93\u91CD\u8BD5",2:"\u6807\u6CE8\u6587\u4EF6\u4F20\u8F93\u5931\u8D25",3:"\u6807\u6CE8\u4E2D",4:"\u4EFB\u52A1\u7EC8\u6B62",5:"\u4EFB\u52A1\u5B8C\u6210",6:"\u6570\u636E\u5DF2\u53D1\u5E03"};var de;(function(r){r[r.Upload=0]="Upload",r[r.UploadRetry=1]="UploadRetry",r[r.UploadFail=2]="UploadFail",r[r.Annotation=3]="Annotation",r[r.Terminated=4]="Terminated",r[r.Finish=5]="Finish",r[r.Publish=6]="Publish"})(de||(de={}));var Cn=Object.freeze({__proto__:null,ANNOTATION_TYPE:Ln,ANNOTATION_STATUS:Pn,get EAnnotationStatus(){return de}});class Dn{static load(t){return new Promise((e,i)=>{const s=new Image;t.startsWith("file")?s.src=encodeURI(t):s.src=t,s.onload=()=>{e(s)},s.onerror=()=>{i(s)}})}}var _n=(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 An=r=>new Promise((t,e)=>{const i=document.createElement("img");i.crossOrigin="Anonymous",i.onerror=s=>{console.error(s),e(i)},i.src=r,i.onload=()=>{t(i)}});class Rn{constructor(t){this.setImgSrc=s=>_n(this,null,function*(){const n=yield An(s);!n||this.setImgNode(n)});var e,i;this.container=t.container,this.size=t.size,this.toolName=t.toolName,this.imgNode=t.imgNode,this.config=(e=t.config)!=null?e:JSON.stringify(He(t.toolName)),this.style=(i=t.style)!=null?i:Ne,this._initToolOperation()}setToolName(t,e){this.toolName=t;const i=e||JSON.stringify(He(t));this.config=i,this._initToolOperation()}setImgNode(t,e){!this.toolInstance||(this.imgNode=t,this.toolInstance.setImgNode(t,e))}setSize(t){this.size=t}setStyle(t){this.style=t}_initToolOperation(){this.toolInstance&&this.toolInstance.destroy();const t=x.getCurrentOperation(this.toolName);if(!t)return;const e={container:this.container,size:this.size,config:this.config,drawOutSideTarget:!1,style:this.style};this.imgNode&&Object.assign(e,{imgNode:this.imgNode}),this.toolInstance=new t(e),this.toolInstance.init()}setBasicInfo(t,e){this.dependToolName=t,this.basicResult=e,this.toolInstance.setDependName(t),this.toolInstance.setBasicResult(e),this.toolInstance.renderBasicCanvas()}clearBasicResult(){this.setBasicInfo()}forbidOperation(){this.toolInstance.setForbidOperation(!0)}launchOperation(){this.toolInstance.setForbidOperation(!1)}setLang(t){switch(t){case"cn":this.toolInstance.setLang(nt.Zh);break;case"en":this.toolInstance.setLang(nt.US);break}}}const Tn=x;export{Rn as AnnotationEngine,L as AxisUtils,it as BasicToolOperation,x as CommonToolUtils,We as DblClickEventListener,m as DrawUtils,Dn as ImgUtils,li as LineToolOperation,re as MarkerUtils,gn as MeasureOperation,gi as PointOperation,si as PolygonOperation,he as RectOperation,$ as RectUtils,ri as TagOperation,mt as TagUtils,fi as TextToolOperation,wn as ViewOperation,Ki as cAnnotation,Cn as cAnnotationTask,ar as cKeyCode,Ss as cStyle,Hi as cTool,Tn as toolUtils,K as uuid};
|