import {a as a$2}from'./chunk-ZU6C4VWO.js';import {a as a$1}from'./chunk-NPDG2TI5.js';import {a}from'./chunk-D5PIEZCN.js';import {Barcode}from'@scandit/web-datacapture-barcode';import {Point,AnchorPositions,Quadrilateral}from'@scandit/web-datacapture-core';function d(e){let t=Math.sqrt(e.x*e.x+e.y*e.y);return new Point(e.x/t,e.y/t)}function u(e){return Math.sqrt(e.x*e.x+e.y*e.y)}function w(e){return {[a$2.Barcode]:"barcode",[a$2.Text]:"text",[a$2.Unknown]:"unknown"}[e]}function v(e){let t={barcode:a$2.Barcode,text:a$2.Text,unknown:a$2.Unknown}[e];if(t==null)throw new Error(`Invalid label field type: ${e}`);return t}function V(e){let t={date:a$1.Date,price:a$1.Price,weight:a$1.Weight,text:a$1.Text,numeric:a$1.Numeric}[e];if(t==null)throw new Error(`Invalid label field value type: ${e}`);return t}function q(e){let t={[a$1.Date]:"date",[a$1.Price]:"price",[a$1.Weight]:"weight",[a$1.Text]:"text",[a$1.Numeric]:"numeric"}[e];if(t==null)throw new Error(`Invalid label field value type: ${e}`);return t}var T=class e{get name(){return this._name}get type(){return this._type}get predictedLocation(){return this._predictedLocation}get state(){return this._state}get isRequired(){return this._isRequired}get barcode(){return this._barcode}get text(){return this._text}get valueType(){return this._valueType}get anchorPositions(){let t=this.predictedLocation,i=new Point(t.topRight.x-t.topLeft.x,t.topRight.y-t.topLeft.y),b=new Point(t.bottomRight.x-t.topRight.x,t.bottomRight.y-t.topRight.y),s=new Point(t.bottomLeft.x-t.bottomRight.x,t.bottomLeft.y-t.bottomRight.y),y=new Point(t.topLeft.x-t.bottomLeft.x,t.topLeft.y-t.bottomLeft.y),h=u(i)/2,m=u(b)/2,g=u(s)/2,x=u(y)/2,L=d(i),f=d(b),O=d(s),_=d(y),r={x:t.topLeft.x+L.x*h,y:t.topLeft.y+L.y*h},n={x:t.topRight.x+f.x*m,y:t.topRight.y+f.y*m},c={x:t.bottomRight.x+O.x*g,y:t.bottomRight.y+O.y*g},p={x:t.bottomLeft.x+_.x*x,y:t.bottomLeft.y+_.y*x},S={x:(r.x+n.x+c.x+p.x)/4,y:(r.y+n.y+c.y+p.y)/4};return AnchorPositions.fromJSON({center:new Point(S.x,S.y).toJSONObject(),topCenter:new Point(r.x,r.y).toJSONObject(),bottomCenter:new Point(c.x,c.y).toJSONObject(),centerLeft:new Point(p.x,p.y).toJSONObject(),centerRight:new Point(n.x,n.y).toJSONObject(),topLeft:t.topLeft.toJSONObject(),topRight:t.topRight.toJSONObject(),bottomLeft:t.bottomLeft.toJSONObject(),bottomRight:t.bottomRight.toJSONObject()})}get date(){return this._date}static fromJSON(t){let i=new e;return i._valueType=V(t.valueType),i._name=t.name,i._type=v(t.type),i._predictedLocation=Quadrilateral.fromJSON(t.location),i._state=t.state,i._isRequired=t.isRequired,i._barcode=t.barcode?Barcode.fromJSON(t.barcode):null,i._text=t.text,i._date=t.date?a.fromJSON(t.date):null,i}toJSONObject(){return {name:this._name,type:w(this._type),location:this._predictedLocation.toJSONObject(),state:this._state,isRequired:this._isRequired,barcode:this._barcode?this._barcode.toJSONObject():null,text:this._text,date:this._date?this._date.toJSONObject():null,valueType:q(this._valueType)}}};export{T as a};