/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../../../chunks/_rollupPluginBabelHelpers","../../../../../geometry/support/meshUtils/deduplicate","../../../support/meshProcessing","../../../support/buffer/InterleavedLayout","../../../support/buffer/workerHelper","../VertexAttribute","./bufferLayouts","./edgeBufferWriters","./edgePreprocessing"],(function(e,t,n,r,i,u,o,s,a,c){"use strict";let f=function(){function e(){}var n=e.prototype;return n.extract=function(){var e=t._asyncToGenerator((function*(e){const t=l(e),n=d(t),r=[t.data.buffer];return{result:p(n,r),transferList:r}}));function n(t){return e.apply(this,arguments)}return n}(),n.extractComponentsEdgeLocations=function(){var e=t._asyncToGenerator((function*(e){const t=l(e),n=g(t.data,t.skipDeduplicate,t.indices,t.indicesLength),r=c.extractEdges(n,v,w),i=[];return{result:u.packInterleavedBuffer(r.regular.instancesData,i),transferList:i}}));function n(t){return e.apply(this,arguments)}return n}(),n.extractEdgeLocations=function(){var e=t._asyncToGenerator((function*(e){const t=l(e),n=g(t.data,t.skipDeduplicate,t.indices,t.indicesLength),r=c.extractEdges(n,b,w),i=[];return{result:u.packInterleavedBuffer(r.regular.instancesData,i),transferList:i}}));function n(t){return e.apply(this,arguments)}return n}(),e}();function d(e){const t=g(e.data,e.skipDeduplicate,e.indices,e.indicesLength);return h.updateSettings(e.writerSettings),I.updateSettings(e.writerSettings),c.extractEdges(t,h,I)}function l(e){return{data:s.EdgeInputBufferLayout.createView(e.dataBuffer),indices:"Uint32Array"===e.indicesType?new Uint32Array(e.indicesBuffer):"Uint16Array"===e.indicesType?new Uint16Array(e.indicesBuffer):void 0,indicesLength:e.indicesLength,writerSettings:e.writerSettings,skipDeduplicate:e.skipDeduplicate}}function p(e,t){t.push(e.regular.lodInfo.lengths.buffer),t.push(e.silhouette.lodInfo.lengths.buffer);return{regular:{instancesData:u.packInterleavedBuffer(e.regular.instancesData,t),lodInfo:{lengths:e.regular.lodInfo.lengths.buffer}},silhouette:{instancesData:u.packInterleavedBuffer(e.silhouette.instancesData,t),lodInfo:{lengths:e.silhouette.lodInfo.lengths.buffer}},averageEdgeLength:e.averageEdgeLength}}function g(e,t,i,u){if(t){return{faces:i,facesLength:u,neighbors:r.computeNeighbors(i,u,e.count),vertices:e}}const o=n.deduplicate(e.buffer,e.stride/4,{originalIndices:i,originalIndicesLength:u}),a=r.computeNeighbors(o.indices,u,o.uniqueCount);return{faces:o.indices,facesLength:o.indices.length,neighbors:a,vertices:s.EdgeInputBufferLayout.createView(o.buffer)}}const h=new a.RegularEdgeBufferWriter,I=new a.SilhouetteEdgeBufferWriter;let y=function(){function e(){}var t=e.prototype;return t.allocate=function(e){return x.createBuffer(e)},t.trim=function(e,t){return e.slice(0,t)},t.write=function(e,t,n){e.position0.setVec(t,n.position0),e.position1.setVec(t,n.position1)},e}(),L=function(){function e(){}var t=e.prototype;return t.allocate=function(e){return E.createBuffer(e)},t.trim=function(e,t){return e.slice(0,t)},t.write=function(e,t,n){e.position0.setVec(t,n.position0),e.position1.setVec(t,n.position1),e.componentIndex.set(t,n.componentIndex)},e}();const b=new y,v=new L,w={allocate:()=>null,write:()=>{},trim:()=>null},x=i.newLayout().vec3f(o.VertexAttribute.POSITION0).vec3f(o.VertexAttribute.POSITION1),E=i.newLayout().vec3f(o.VertexAttribute.POSITION0).vec3f(o.VertexAttribute.POSITION1).u16(o.VertexAttribute.COMPONENTINDEX).u16(o.VertexAttribute.U16PADDING,{glPadding:!0});function B(){return new f}e.EdgeProcessingWorker=f,e.default=B,e.extract=d,e.extractComponentsEdgeLocationsLayout=E,e.extractEdgeLocationsLayout=x,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
