/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{pt2px as e}from"../../../../../../../core/screenUtils.js";import{complexFillVertexSpec as t,getPatternSize as s,packComplexFillBitset as r}from"./ComplexFillMeshWriter.js";import{packBitset as i}from"./meshWriterUtils.js";import{OutlineFillMeshWriter as a,OutlineFillOutlineMeshWriter as o,outlineFillVertexSpec_Outline as u}from"./OutlineFillMeshWriter.js";import{packPrecision as n,signedToUnsignedByte as c,bitsetTypeFillOutline as p}from"../shaders/constants.js";import{DataType as l}from"../../../../../../webgl/enums.js";const d=t,h=u,m={createComputedParams:e=>e,optionalAttributes:d.optionalAttributes,attributes:{...d.attributes,bitset:{type:l.UNSIGNED_BYTE,count:1,pack:e=>r(e)},aux1:{count:1,type:l.HALF_FLOAT,pack:e=>s(e).width},aux2:{count:1,type:l.HALF_FLOAT,pack:e=>s(e).height},aux3:{count:2,type:l.HALF_FLOAT,pack:({offsetX:t,offsetY:s})=>[e(t),e(s)]},aux4:{count:2,type:l.UNSIGNED_BYTE,pack:({scaleX:e,scaleY:t})=>[e*n,t*n]}}},x={createComputedParams:e=>e,optionalAttributes:d.optionalAttributes,attributes:{...d.attributes,color:h.attributes.color,bitset:{type:l.UNSIGNED_BYTE,count:1,pack:e=>i([[p,!0]])},aux1:{count:1,type:l.HALF_FLOAT,pack:t=>e(.5*t.width)},aux2:{count:1,type:l.HALF_FLOAT,pack:t=>e(.5*t.referenceWidth)},aux3:{count:2,type:l.HALF_FLOAT,packTessellation:({extrusionOffsetX:e,extrusionOffsetY:t})=>[e,t]},aux4:{count:2,type:l.UNSIGNED_BYTE,packTessellation:({normalX:e,normalY:t})=>[e*n+c,t*n+c]}}};class A extends o{constructor(){super(...arguments),this.vertexSpec=x}}class f extends a{constructor(){super(...arguments),this.vertexSpec=m}_createOutlineWriter(e,t,s,r){return new A(e,t,s,r)}write(e,t,s,r,i){this.ensurePacked(t,s,r);const a=this.evaluatedMeshParams.sprite?.textureBinding;e.recordStart(this.instanceId,this.attributeLayout,a),this._write(e,{target:s,options:r,level:i}),e.recordEnd()}ensurePacked(e,t,s){super.ensurePacked(e,t,s),this._lineMeshWriter.ensurePacked(e,t,s)}enqueueRequest(e,t,s){super.enqueueRequest(e,t,s),this._lineMeshWriter.enqueueRequest(e,t,s)}async loadDependencies(){await Promise.all([super.loadDependencies(),this._lineMeshWriter.loadDependencies()])}}export{f as ComplexOutlineFillMeshWriter};
