diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 3b4c1733e..3f8855c86 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.3.3](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.3.2...@jscad/cli@2.3.3) (2024-10-06) + +**Note:** Version bump only for package @jscad/cli + + + + + ## [2.3.2](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/cli@2.3.1...@jscad/cli@2.3.2) (2024-06-02) **Note:** Version bump only for package @jscad/cli diff --git a/packages/cli/package.json b/packages/cli/package.json index 46d18f08b..438d961dc 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@jscad/cli", - "version": "2.3.2", + "version": "2.3.3", "description": "Command Line Interface (CLI) for JSCAD", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -36,9 +36,9 @@ "license": "MIT", "dependencies": { "@jscad/array-utils": "2.1.4", - "@jscad/core": "2.6.9", - "@jscad/io": "2.4.8", - "@jscad/modeling": "2.12.2", + "@jscad/core": "2.6.10", + "@jscad/io": "2.4.9", + "@jscad/modeling": "2.12.3", "jszip": "^3.10.1" }, "devDependencies": { diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index f7b6ff0e6..a10e10832 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.6.10](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/core@2.6.9...@jscad/core@2.6.10) (2024-10-06) + +**Note:** Version bump only for package @jscad/core + + + + + ## [2.6.9](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/core@2.6.8...@jscad/core@2.6.9) (2024-06-02) **Note:** Version bump only for package @jscad/core diff --git a/packages/core/dist/jscad-core.min.js b/packages/core/dist/jscad-core.min.js index 176f10319..89bb09c48 100644 --- a/packages/core/dist/jscad-core.min.js +++ b/packages/core/dist/jscad-core.min.js @@ -26,7 +26,7 @@ var cachedSetTimeout,cachedClearTimeout,process=module.exports={};function defau },{}],8:[function(require,module,exports){ module.exports={ "name": "@jscad/core", - "version": "2.6.9", + "version": "2.6.10", "description": "Core functionality for JSCAD Applications", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -62,9 +62,9 @@ module.exports={ "license": "MIT", "dependencies": { "@jscad/array-utils": "2.1.4", - "@jscad/io": "2.4.8", - "@jscad/io-utils": "2.0.27", - "@jscad/modeling": "2.12.2", + "@jscad/io": "2.4.9", + "@jscad/io-utils": "2.0.28", + "@jscad/modeling": "2.12.3", "json5": "2.2.3", "strip-bom": "4.0.0" }, @@ -88,13 +88,13 @@ module.exports={rebuildGeometry:require("./rebuildGeometry"),rebuildGeometryCli: },{"./rebuildGeometry":11,"./rebuildGeometryCli":12,"./rebuildGeometryWorker":13,"./serializeSolids":14}],10:[function(require,module,exports){ const isGeom2=require("@jscad/modeling").geometries.geom2.isA,isGeom3=require("@jscad/modeling").geometries.geom3.isA,isPath2=require("@jscad/modeling").geometries.path2.isA,{flatten:flatten,toArray:toArray}=require("@jscad/array-utils"),serializeSolids=require("./serializeSolids"),isResultGeometry=e=>!!(Array.isArray(e)&&e.length>0)&&e.reduce((e,i)=>e||isGeom3(i)||isGeom2(i)||isPath2(i),!1),instanciateDesign=(e,i,r)=>{const{serialize:s}=r;let t;const o=flatten(toArray(e.main(i)));if(isResultGeometry(o))return{solids:t=s?serializeSolids(o):o};throw new Error("bad output from script: expected geom3/geom2/path2 objects")};module.exports=instanciateDesign; -},{"./serializeSolids":14,"@jscad/array-utils":531,"@jscad/modeling":216}],11:[function(require,module,exports){ +},{"./serializeSolids":14,"@jscad/array-utils":532,"@jscad/modeling":216}],11:[function(require,module,exports){ const loadDesign=require("../code-loading/loadDesign"),instanciateDesign=require("./instanciateDesign"),applyParameterDefinitions=require("../parameters/applyParameterDefinitions"),rebuildSolids=(e,a)=>{let{mainPath:i,apiMainPath:n,serialize:s,lookup:o,lookupCounts:r,parameterValues:l}=Object.assign({},{mainPath:"",apiMainPath:"@jscad/modeling",serialize:!1,lookup:null,lookupCounts:null,parameterValues:{}},e);try{const t=e.filesAndFolders,u=loadDesign(i,n,t,l);a(null,{type:"params",parameterDefaults:u.parameterValues,parameterDefinitions:u.parameterDefinitions}),l=applyParameterDefinitions(l,u.parameterDefinitions),l=Object.assign({},u.parameterValues,l);const m={lookup:o,lookupCounts:r,serialize:s},p=instanciateDesign(u.rootModule,l,m);a(null,{type:"solids",solids:p.solids,lookup:p.lookup,lookupCounts:p.lookupCounts})}catch(e){a({type:"errors",name:e.name?e.name:"Error",message:e.message?e.message:e.toString(),description:e.description?e.description:"",number:e.number?e.number:"",fileName:e.fileName?e.fileName:"",lineNumber:e.lineNumber?e.lineNumber:"",columnNumber:e.columnNumber?e.columnNumber:"",stack:e.stack?e.stack:""},null)}};module.exports=rebuildSolids; },{"../code-loading/loadDesign":16,"../parameters/applyParameterDefinitions":27,"./instanciateDesign":10}],12:[function(require,module,exports){ const path=require("path"),{toArray:toArray}=require("@jscad/array-utils"),requireDesignFromModule=require("../code-loading/requireDesignFromModule"),getAllParameterDefintionsAndValues=require("../parameters/getParameterDefinitionsAndValues"),makeWebRequire=require("../code-loading/webRequire"),rebuildSolids=e=>{let{apiMainPath:r,mainPath:a,parameterValues:i,useFakeFs:t}=Object.assign({},{apiMainPath:"@jscad/modeling"},e),s=require;if(t){const i=path.parse(a),t=`${i.name}.js`,u=`/${i.name}.js`,n=[{ext:"js",fullPath:u,name:t,source:e.source}];s=makeWebRequire(n,{apiMainPath:r}),a=u}const u=requireDesignFromModule(a,s),n=getAllParameterDefintionsAndValues(u,i);return toArray(u.main(n.parameterValues))};module.exports=rebuildSolids; -},{"../code-loading/requireDesignFromModule":19,"../code-loading/webRequire":23,"../parameters/getParameterDefinitionsAndValues":28,"@jscad/array-utils":531,"path":4}],13:[function(require,module,exports){ +},{"../code-loading/requireDesignFromModule":19,"../code-loading/webRequire":23,"../parameters/getParameterDefinitionsAndValues":28,"@jscad/array-utils":532,"path":4}],13:[function(require,module,exports){ const rebuildGeometryWorker=e=>{const o=require("./rebuildGeometry");e.onmessage=function(t){if(t.data instanceof Object){const{data:r}=t;"generate"===r.cmd&&o(r,(o,t)=>{t&&e.postMessage(t),o&&e.postMessage(o)})}}};module.exports=rebuildGeometryWorker; },{"./rebuildGeometry":11}],14:[function(require,module,exports){ @@ -118,7 +118,7 @@ const validateDesignModule=require("./validateDesignModule"),normalizeDesignModu },{"./normalizeDesignModule":18,"./validateDesignModule":22}],20:[function(require,module,exports){ const path=require("path"),{toArray:toArray}=require("@jscad/array-utils"),splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^/]+?|)(\.[^./]*|))(?:[/]*)$/,splitPath=e=>splitPathRe.exec(e).slice(1),parsePath=e=>{assertPath(e);const t=splitPath(e);if(!t||4!==t.length)throw new TypeError("Invalid path '"+e+"'");return t[1]=t[1]||"",t[2]=t[2]||"",t[3]=t[3]||"",{root:t[0],dir:t[0]+t[1].slice(0,t[1].length-1),base:t[2],ext:t[3],name:t[2].slice(0,t[2].length-t[3].length)}},assertPath=e=>{if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+e)},getDesignEntryPoint=(e,t)=>{if(!t)return;const a=toArray(t)[0];let r;const n=e.statSync(a);if(n.isFile())return a;if(n.isDirectory()){const t=path.join(a,"package.json");if(e.existsSync(t)){const r=JSON.parse(e.readFileSync(t)).main;if(r)return path.join(a,r)}const n=e.readdirSync(a),i=["main","index",parsePath(path.basename(a)).name],s=i.map(e=>e+".js"),o=i.map(e=>e+".jscad"),c=n.filter(e=>s.concat(o).includes(e));return c.length>0&&(r=path.join(a,c[0])),r}return a},packageNameFromDir=(e,t,a)=>{const r=path.join(t,"package.json");if(e.existsSync(r)){const t=JSON.parse(e.readFileSync(r)).name;if(t)return t}return a?parsePath(path.basename(a)).name:path.basename(t)},getDesignName=(e,t)=>{if(!t)return"undefined";const a=toArray(t)[0],r=e.statSync(a);if(r.isFile()){const t=path.dirname(a);return packageNameFromDir(e,t,a)}return r.isDirectory()?packageNameFromDir(e,a):void 0};module.exports={getDesignEntryPoint:getDesignEntryPoint,getDesignName:getDesignName}; -},{"@jscad/array-utils":531,"path":4}],21:[function(require,module,exports){ +},{"@jscad/array-utils":532,"path":4}],21:[function(require,module,exports){ const{deserializers:deserializers}=require("@jscad/io"),modulifyTransform=(e,r)=>Object.assign({},r,{source:r.source}),createJscadEntry=(e,r)=>{const s=e.name.substring(0,e.name.lastIndexOf(".")+1)+"jscad",t="/"+s;return Object.assign({},e,{ext:"jscad",name:s,fullPath:t,source:r})},transformSources=(e,r)=>{if(r&&r.length>1)return r;const s={js:[modulifyTransform],jscad:[modulifyTransform]};return r&&(r=r.map(r=>(r=>{if(r.source&&r.ext){const t=Object.assign({},e,{filename:r.name,output:"script"});if(r.ext in deserializers){const e=(0,deserializers[r.ext])(t,r.source);return createJscadEntry(r,e)}if(r.ext in s)return s[r.ext].reduce((e,r)=>r(t,e),r)}return r})(r))),r};module.exports=transformSources; },{"@jscad/io":74}],22:[function(require,module,exports){ @@ -127,7 +127,7 @@ const validateDesignModule=n=>{if(!n)throw new Error("undefined root module pass },{}],23:[function(require,module,exports){ const path=require("path"),posix=path.posix?path.posix:path,getFileExtensionFromString=require("../utils/getFileExtensionFromString"),{combineParameterDefinitions:combineParameterDefinitions,getParameterDefinitionsFromSource:getParameterDefinitionsFromSource}=require("../parameters/getParameterDefinitionsFromSource"),findMatch=(e,t)=>{for(let r=0;r{const r=require("strip-bom");t.extensions[".js"]=((t,n)=>{const i=e.readFileSync(n,"utf8");t._compile(r(i),n)})},registerJsonExtension=(e,t)=>{t.extensions[".json"]=((t,r)=>{const n=e.readFileSync(r,"utf8");t.exports=JSON.parse(n)})},makeWebRequire=(e,t)=>{const r={apiMainPath:"@jscad/modeling",fakeFs:require("./makeFakeFs")(e)},{apiMainPath:n,fakeFs:i}=Object.assign({},r,t),s="@jscad/modeling"===n?require("@jscad/modeling"):require(n),o={"@jscad/io":{exports:require("@jscad/io")},"@jscad/array-utils":{exports:require("@jscad/array-utils")},"@jscad/modeling":{exports:s},fs:{exports:i}},a={},l={},u=(t,r)=>{const n=o[r];if(n)return n.exports;t&&!r.startsWith("/")||(t="/");const i=t=>{let r=getFileExtensionFromString(t);r||(r="js",t+=".js"),r="."+r;const n=findMatch(t,e);if(!n)return null;if(n.children)return null;if(a[r]){if(l[t])return l[t];const e={exports:{},_compile:(t,r)=>{try{new Function("require","module",t)(u.bind(null,n.fullPath),e)}catch(e){const t=e.message;r=r.replace("/","");const n=e.lineNumber?e.lineNumber-2:0,i=e.columnNumber?e.columnNumber:0;throw e.stack.startsWith("Object")?e.stack=`${e.stack}\nObject. (${r}:${n}:${i})`:((e=new SyntaxError(t,r,n)).columnNumber=i,e.stack=`Object. (${r}:${n}:${i})`),e}const i=t.includes("@jscad-params")?getParameterDefinitionsFromSource(t,r):[],s=e.exports.getParameterDefinitions;e.exports.getParameterDefinitions=(()=>combineParameterDefinitions(i,s&&s()||[]))}};return a[r](e,n.fullPath),l[t]=e.exports,l[t]}return null},s=t=>{if(!findMatch(t,e))return null;"/"===t&&(t="");let r=t+"/index.js",n=i(r);return n||((n=i(r=t+"/index.json"))||null)},c=t=>{let r,n=findMatch(t,e);if(!n)return null;if(!n.children)return null;if(n=findMatch(t+"/package.json",e)){const e=JSON.parse(n.source).main;if(e){const n=posix.normalize(t+"/"+e);return(r=i(n))?r:(r=s(n))||null}}return(r=s(t))||null};if(r.startsWith("./")||r.startsWith("/")||r.startsWith("../")){r=posix.normalize(posix.dirname(t)+posix.sep+r);let e=i(r);if(e)return e;if(e=c(r))return e;throw new Error(`Cannot find relative path to module ${r}`)}const m=((e,t)=>{const r=(e=>{const t=e.split("/"),r=[];for(let e=t.length-1;e>0;e--){if("node_modules"===t[e])continue;const n=posix.sep+posix.join(...t.slice(1,e+1),"node_modules");r.push(n)}return r})(t);for(let t=0;t{}),registerJsExtension(i,c),registerJsonExtension(i,c),c};module.exports=makeWebRequire; -},{"../parameters/getParameterDefinitionsFromSource":29,"../utils/getFileExtensionFromString":33,"./makeFakeFs":17,"@jscad/array-utils":531,"@jscad/io":74,"@jscad/modeling":216,"path":4,"strip-bom":7}],24:[function(require,module,exports){ +},{"../parameters/getParameterDefinitionsFromSource":29,"../utils/getFileExtensionFromString":33,"./makeFakeFs":17,"@jscad/array-utils":532,"@jscad/io":74,"@jscad/modeling":216,"path":4,"strip-bom":7}],24:[function(require,module,exports){ module.exports={evaluation:require("./code-evaluation"),io:require("./io"),loading:require("./code-loading"),parameters:require("./parameters"),utils:require("./utils"),web:require("./web")}; },{"./code-evaluation":9,"./code-loading":15,"./io":25,"./parameters":32,"./utils":34,"./web":36}],25:[function(require,module,exports){ @@ -169,7 +169,7 @@ module.exports={walkFileTree:require("./walkFileTree")}; },{"./walkFileTree":37}],37:[function(require,module,exports){ const{flatten:flatten}=require("@jscad/array-utils"),{formats:formats}=require("@jscad/io/formats"),getFileExtensionFromString=require("../utils/getFileExtensionFromString"),binaryMimetypes={bmp:"image/bmp",gif:"image/gif",jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",tif:"image/tiff",tiff:"image/tiff",otc:"font/otf",otf:"font/otf",ttc:"font/ttf",ttf:"font/ttf",woff:"font/woff",woff2:"font/woff",stl:"application/sla"},readFileAsync=(e,t)=>{const r=e.fullPath?e.fullPath:t.fullPath?t.fullPath:"",i=getFileExtensionFromString(e.name),n=e.mimetype;return new Promise((t,s)=>{const o=new FileReader;o.onload=(s=>{const o=s.target.result;o.byteLength?t({name:e.name,ext:i,fullPath:r,mimetype:n,source:o}):"string"==typeof o&&t({name:e.name,ext:i,fullPath:r,mimetype:n,source:o})}),o.onerror=(e=>{s(new Error(`Failed to load file: ${r} [${o.error}]`))}),binaryMimetypes[i]?o.readAsArrayBuffer(e):o.readAsText(e)})},isSupportedFormat=e=>{const t=getFileExtensionFromString(e.name),r=formats[t]?formats[t].mimetype:binaryMimetypes[t];return e.mimetype=e.type&&e.type.length?e.type:r,e.mimetype&&e.mimetype.length},pseudoArraytoArray=e=>{const t=[];for(let r=0;rnull!=e,processEntries=e=>{const t=pseudoArraytoArray(e.filter(isEmpty)).filter(isEmpty).reduce((e,t)=>{if(t.name.startsWith("."))return e;if(t.isFile)e.push(processFile(t));else if(t.isDirectory)e.push(processDirectory(t));else if(t instanceof File){const r=t.webkitRelativePath?t.webkitRelativePath:void 0,i=isSupportedFormat(t)?readFileAsync(t,{fullPath:r}):void 0;if(!i)throw new Error("Unsuported format (or folder in Safari)!");e.push(i)}return e},[]);return Promise.all(t).then(e=>e.filter(e=>null!=e))},processFile=e=>{return new Promise((t,r)=>{e.file(r=>{isSupportedFormat(r)?t(readFileAsync(r,e)):t(void 0)},t=>{const i=`${t.message} (${t.code})`;r(new Error(`Failed to load file: ${e.fullPath} [${i}]`))})})},processDirectory=e=>{return new Promise((t,r)=>{if(e.entries)e.entries.length?processEntries(e.entries).then(t):t([]);else{e.createReader().readEntries(e=>{e.length?processEntries(e).then(t):t([])},r)}}).then(flatten).then(t=>({children:t=t.map(t=>(t.fullPath.startsWith("/")||(t.fullPath=e.fullPath+"/"+t.name),t)),fullPath:e.fullPath,name:e.name}))},transformFileList=e=>{const t=require("path");if(1===e.length){const r=e[0],i=r.webkitRelativePath?r.webkitRelativePath:r.name;if(i.split(t.sep).length<2){const e=t.sep,n={fullPath:e,name:e,isDirectory:!0,entries:[]};return r.fullPath=t.normalize(e+i),n.entries.push(r),[n]}}let r;const i=new Map,n=(e,n)=>{if(!i.has(e)){const s={fullPath:e,name:n,isDirectory:!0,entries:[]};r||(r=s),i.set(e,s);const o=e.split(t.sep);if(o.length>1){const e=t.sep+t.join(...o.slice(0,-1)),r=i.get(e);r&&r.entries.push(s)}}};for(let r=0;re||t.startsWith("."),!1))continue;if(!isSupportedFormat(s))continue;const l=o.slice(0,-1);for(let e=0;e{let t=e;return e.length&&e[0]instanceof File&&(t=transformFileList(e)),processEntries(t)};module.exports=walkFileTree; -},{"../utils/getFileExtensionFromString":33,"@jscad/array-utils":531,"@jscad/io/formats":73,"path":4}],38:[function(require,module,exports){ +},{"../utils/getFileExtensionFromString":33,"@jscad/array-utils":532,"@jscad/io/formats":73,"path":4}],38:[function(require,module,exports){ "use strict";var node_worker_1=require("./node-worker.cjs"),u8=Uint8Array,u16=Uint16Array,u32=Uint32Array,fleb=new u8([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),fdeb=new u8([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),clim=new u8([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),freb=function(t,n){for(var e=new u16(31),r=0;r<31;++r)e[r]=n+=1<>>1|(21845&i)<<1;x=(61680&(x=(52428&x)>>>2|(13107&x)<<2))>>>4|(3855&x)<<4,rev[i]=((65280&x)>>>8|(255&x)<<8)>>>1}var hMap=function(t,n,e){for(var r=t.length,i=0,s=new u16(n);i>>f]=u}else for(o=new u16(r),i=0;i>>15-t[i]);return o},flt=new u8(288);for(i=0;i<144;++i)flt[i]=8;for(i=144;i<256;++i)flt[i]=9;for(i=256;i<280;++i)flt[i]=7;for(i=280;i<288;++i)flt[i]=8;var fdt=new u8(32);for(i=0;i<32;++i)fdt[i]=5;var flm=hMap(flt,9,0),flrm=hMap(flt,9,1),fdm=hMap(fdt,5,0),fdrm=hMap(fdt,5,1),max=function(t){for(var n=t[0],e=1;en&&(n=t[e]);return n},bits=function(t,n,e){var r=n/8|0;return(t[r]|t[r+1]<<8)>>(7&n)&e},bits16=function(t,n){var e=n/8|0;return(t[e]|t[e+1]<<8|t[e+2]<<16)>>(7&n)},shft=function(t){return(t+7)/8|0},slc=function(t,n,e){(null==n||n<0)&&(n=0),(null==e||e>t.length)&&(e=t.length);var r=new(2==t.BYTES_PER_ELEMENT?u16:4==t.BYTES_PER_ELEMENT?u32:u8)(e-n);return r.set(t.subarray(n,e)),r};exports.FlateErrorCode={UnexpectedEOF:0,InvalidBlockType:1,InvalidLengthLiteral:2,InvalidDistance:3,StreamFinished:4,NoStreamHandler:5,InvalidHeader:6,NoCallback:7,InvalidUTF8:8,ExtraFieldTooLong:9,InvalidDate:10,FilenameTooLong:11,StreamFinishing:12,InvalidZipData:13,UnknownCompressionMethod:14};var ec=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],err=function(t,n,e){var r=new Error(n||ec[t]);if(r.code=t,Error.captureStackTrace&&Error.captureStackTrace(r,err),!e)throw r;return r},inflt=function(t,n,e){var r=t.length;if(!r||e&&e.f&&!e.l)return n||new u8(0);var i=!n||e,s=!e||e.i;e||(e={}),n||(n=new u8(3*r));var o=function(t){var e=n.length;if(t>e){var r=new u8(Math.max(2*e,t));r.set(n),n=r}},a=e.f||0,f=e.p||0,u=e.b||0,l=e.l,c=e.d,h=e.m,p=e.n,v=8*r;do{if(!l){a=bits(t,f,1);var d=bits(t,f+1,3);if(f+=3,!d){var b=t[(A=shft(f)+4)-4]|t[A-3]<<8,y=A+b;if(y>r){s&&err(0);break}i&&o(u+b),n.set(t.subarray(A,y),u),e.b=u+=b,e.p=f=8*y,e.f=a;continue}if(1==d)l=flrm,c=fdrm,h=9,p=5;else if(2==d){var g=bits(t,f,31)+257,m=bits(t,f+10,15)+4,z=g+bits(t,f+5,31)+1;f+=14;for(var w=new u8(z),x=new u8(19),S=0;S>>4)<16)w[S++]=A;else{var I=0,M=0;for(16==A?(M=3+bits(t,f,3),f+=2,I=w[S-1]):17==A?(M=3+bits(t,f,7),f+=3):18==A&&(M=11+bits(t,f,127),f+=7);M--;)w[S++]=I}}var Z=w.subarray(0,g),C=w.subarray(g);h=max(Z),p=max(C),l=hMap(Z,h,1),c=hMap(C,p,1)}else err(1);if(f>v){s&&err(0);break}}i&&o(u+131072);for(var G=(1<>>4;if((f+=15&I)>v){s&&err(0);break}if(I||err(2),_<256)n[u++]=_;else{if(256==_){F=f,l=null;break}var P=_-254;if(_>264){var O=fleb[S=_-257];P=bits(t,f,(1<>>4;L||err(3),f+=15&L;C=fd[N];if(N>3){O=fdeb[N];C+=bits16(t,f)&(1<v){s&&err(0);break}i&&o(u+131072);for(var q=u+P;u>>8},wbits16=function(t,n,e){e<<=7&n;var r=n/8|0;t[r]|=e,t[r+1]|=e>>>8,t[r+2]|=e>>>16},hTree=function(t,n){for(var e=[],r=0;rh&&(h=s[r].s);var p=new u16(h+1),v=ln(e[l-1],p,0);if(v>n){r=0;var d=0,b=v-n,y=1<n))break;d+=y-(1<>>=b;d>0;){var m=s[r].s;p[m]=0&&d;--r){var z=s[r].s;p[z]==n&&(--p[z],++d)}v=n}return[new u8(p),v]},ln=function(t,n,e){return-1==t.s?Math.max(ln(t.l,n,e+1),ln(t.r,n,e+1)):n[t.s]=e},lc=function(t){for(var n=t.length;n&&!t[--n];);for(var e=new u16(++n),r=0,i=t[0],s=1,o=function(t){e[r++]=t},a=1;a<=n;++a)if(t[a]==i&&a!=n)++s;else{if(!i&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(i),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(i);s=1,i=t[a]}return[e.subarray(0,r),n]},clen=function(t,n){for(var e=0,r=0;r>>8,t[i+2]=255^t[i],t[i+3]=255^t[i+1];for(var s=0;s4&&!T[clim[k-1]];--k);var I,M,Z,C,G=u+5<<3,E=clen(i,flt)+clen(s,fdt)+o,F=clen(i,h)+clen(s,d)+o+14+3*k+clen(S,T)+(2*S[16]+3*S[17]+7*S[18]);if(G<=E&&G<=F)return wfblk(n,l,t.subarray(f,f+u));if(wbits(n,l,1+(F15&&(wbits(n,l,L[U]>>>5&127),l+=L[U]>>>12)}}}else I=flm,M=flt,Z=fdm,C=fdt;for(U=0;U255){N=r[U]>>>18&31;wbits16(n,l,I[N+257]),l+=M[N+257],N>7&&(wbits(n,l,r[U]>>>23&31),l+=fleb[N]);var q=31&r[U];wbits16(n,l,Z[q]),l+=C[q],q>3&&(wbits16(n,l,r[U]>>>5&8191),l+=fdeb[q])}else wbits16(n,l,I[r[U]]),l+=M[r[U]];return wbits16(n,l,I[256]),l+M[256]},deo=new u32([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),et=new u8(0),dflt=function(t,n,e,r,i,s){var o=t.length,a=new u8(r+o+5*(1+Math.ceil(o/7e3))+i),f=a.subarray(r,a.length-i),u=0;if(!n||o<8)for(var l=0;l<=o;l+=65535){var c=l+65535;c>=o&&(f[u>>3]=s),u=wfblk(f,u+1,t.subarray(l,c))}else{for(var h=deo[n-1],p=h>>>13,v=8191&h,d=(1<7e3||T>24576)&&C>423){u=wblk(t,f,0,w,x,S,D,T,k,l-k,u),T=U=D=0,k=l;for(var G=0;G<286;++G)x[G]=0;for(G=0;G<30;++G)S[G]=0}var E=2,F=0,_=v,P=M-Z&32767;if(C>2&&I==z(l-P))for(var O=Math.min(p,C)-1,L=Math.min(32767,l),N=Math.min(258,C);P<=L&&--_&&M!=Z;){if(t[l+E]==t[l+E-P]){for(var q=0;qE){if(E=q,F=P,q>O)break;var B=Math.min(P,q-2),H=0;for(G=0;GH&&(H=j,Z=Y)}}}P+=(M=Z)-(Z=b[M])+32768&32767}if(F){w[T++]=268435456|revfl[E]<<18|revfd[F];var R=31&revfl[E],J=31&revfd[F];D+=fleb[R]+fdeb[J],++x[257+R],++S[J],A=l+E,++U}else w[T++]=t[l],++x[t[l]]}}u=wblk(t,f,s,w,x,S,D,T,k,l-k,u),!s&&7&u&&(u=wfblk(f,u+1,et))}return slc(a,0,r+shft(u)+i)},crct=function(){for(var t=new Int32Array(256),n=0;n<256;++n){for(var e=n,r=9;--r;)e=(1&e&&-306674912)^e>>>1;t[n]=e}return t}(),crc=function(){var t=-1;return{p:function(n){for(var e=t,r=0;r>>8;t=e},d:function(){return~t}}},adler=function(){var t=1,n=0;return{p:function(e){for(var r=t,i=n,s=0|e.length,o=0;o!=s;){for(var a=Math.min(o+2655,s);o>16),i=(65535&i)+15*(i>>16)}t=r,n=i},d:function(){return(255&(t%=65521))<<24|t>>>8<<16|(255&(n%=65521))<<8|n>>>8}}},dopt=function(t,n,e,r,i){return dflt(t,null==n.level?6:n.level,null==n.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):12+n.mem,e,r,!i)},mrg=function(t,n){var e={};for(var r in t)e[r]=t[r];for(var r in n)e[r]=n[r];return e},wcln=function(t,n,e){for(var r=t(),i=t.toString(),s=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/\s+/g,"").split(","),o=0;o>>0},b8=function(t,n){return b4(t,n)+4294967296*b4(t,n+4)},wbytes=function(t,n,e){for(;e;++n)t[n]=e,e>>>=8},gzh=function(t,n){var e=n.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=n.level<2?4:9==n.level?2:0,t[9]=3,0!=n.mtime&&wbytes(t,4,Math.floor(new Date(n.mtime||Date.now())/1e3)),e){t[3]=8;for(var r=0;r<=e.length;++r)t[r+10]=e.charCodeAt(r)}},gzs=function(t){31==t[0]&&139==t[1]&&8==t[2]||err(6,"invalid gzip data");var n=t[3],e=10;4&n&&(e+=t[10]|2+(t[11]<<8));for(var r=(n>>3&1)+(n>>4&1);r>0;r-=!t[e++]);return e+(2&n)},gzl=function(t){var n=t.length;return(t[n-4]|t[n-3]<<8|t[n-2]<<16|t[n-1]<<24)>>>0},gzhl=function(t){return 10+(t.filename&&t.filename.length+1||0)},zlh=function(t,n){var e=n.level,r=0==e?0:e<6?1:9==e?3:2;t[0]=120,t[1]=r<<6|(r?32-2*r:1)},zlv=function(t){(8!=(15&t[0])||t[0]>>>4>7||(t[0]<<8|t[1])%31)&&err(6,"invalid zlib data"),32&t[1]&&err(6,"invalid zlib data: preset dictionaries not supported")};function AsyncCmpStrm(t,n){return n||"function"!=typeof t||(n=t,t={}),this.ondata=n,t}var Deflate=function(){function t(t,n){n||"function"!=typeof t||(n=t,t={}),this.ondata=n,this.o=t||{}}return t.prototype.p=function(t,n){this.ondata(dopt(t,this.o,0,0,!n),n)},t.prototype.push=function(t,n){this.ondata||err(5),this.d&&err(4),this.d=n,this.p(t,n||!1)},t}();exports.Deflate=Deflate;var AsyncDeflate=function(){return function(t,n){astrmify([bDflt,function(){return[astrm,Deflate]}],this,AsyncCmpStrm.call(this,t,n),function(t){var n=new Deflate(t.data);onmessage=astrm(n)},6)}}();function deflate(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&err(7),cbify(t,n,[bDflt],function(t){return pbf(deflateSync(t.data[0],t.data[1]))},0,e)}function deflateSync(t,n){return dopt(t,n||{},0,0)}exports.AsyncDeflate=AsyncDeflate,exports.deflate=deflate,exports.deflateSync=deflateSync;var Inflate=function(){function t(t){this.s={},this.p=new u8(0),this.ondata=t}return t.prototype.e=function(t){this.ondata||err(5),this.d&&err(4);var n=this.p.length,e=new u8(n+t.length);e.set(this.p),e.set(t,n),this.p=e},t.prototype.c=function(t){this.d=this.s.i=t||!1;var n=this.s.b,e=inflt(this.p,this.o,this.s);this.ondata(slc(e,n,this.s.b),this.d),this.o=slc(e,this.s.b-32768),this.s.b=this.o.length,this.p=slc(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(t,n){this.e(t),this.c(n)},t}();exports.Inflate=Inflate;var AsyncInflate=function(){return function(t){this.ondata=t,astrmify([bInflt,function(){return[astrm,Inflate]}],this,0,function(){var t=new Inflate;onmessage=astrm(t)},7)}}();function inflate(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&err(7),cbify(t,n,[bInflt],function(t){return pbf(inflateSync(t.data[0],gu8(t.data[1])))},1,e)}function inflateSync(t,n){return inflt(t,n)}exports.AsyncInflate=AsyncInflate,exports.inflate=inflate,exports.inflateSync=inflateSync;var Gzip=function(){function t(t,n){this.c=crc(),this.l=0,this.v=1,Deflate.call(this,t,n)}return t.prototype.push=function(t,n){Deflate.prototype.push.call(this,t,n)},t.prototype.p=function(t,n){this.c.p(t),this.l+=t.length;var e=dopt(t,this.o,this.v&&gzhl(this.o),n&&8,!n);this.v&&(gzh(e,this.o),this.v=0),n&&(wbytes(e,e.length-8,this.c.d()),wbytes(e,e.length-4,this.l)),this.ondata(e,n)},t}();exports.Gzip=Gzip,exports.Compress=Gzip;var AsyncGzip=function(){return function(t,n){astrmify([bDflt,gze,function(){return[astrm,Deflate,Gzip]}],this,AsyncCmpStrm.call(this,t,n),function(t){var n=new Gzip(t.data);onmessage=astrm(n)},8)}}();function gzip(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&err(7),cbify(t,n,[bDflt,gze,function(){return[gzipSync]}],function(t){return pbf(gzipSync(t.data[0],t.data[1]))},2,e)}function gzipSync(t,n){n||(n={});var e=crc(),r=t.length;e.p(t);var i=dopt(t,n,gzhl(n),8),s=i.length;return gzh(i,n),wbytes(i,s-8,e.d()),wbytes(i,s-4,r),i}exports.AsyncGzip=AsyncGzip,exports.AsyncCompress=AsyncGzip,exports.gzip=gzip,exports.compress=gzip,exports.gzipSync=gzipSync,exports.compressSync=gzipSync;var Gunzip=function(){function t(t){this.v=1,Inflate.call(this,t)}return t.prototype.push=function(t,n){if(Inflate.prototype.e.call(this,t),this.v){var e=this.p.length>3?gzs(this.p):4;if(e>=this.p.length&&!n)return;this.p=this.p.subarray(e),this.v=0}n&&(this.p.length<8&&err(6,"invalid gzip data"),this.p=this.p.subarray(0,-8)),Inflate.prototype.c.call(this,n)},t}();exports.Gunzip=Gunzip;var AsyncGunzip=function(){return function(t){this.ondata=t,astrmify([bInflt,guze,function(){return[astrm,Inflate,Gunzip]}],this,0,function(){var t=new Gunzip;onmessage=astrm(t)},9)}}();function gunzip(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&err(7),cbify(t,n,[bInflt,guze,function(){return[gunzipSync]}],function(t){return pbf(gunzipSync(t.data[0]))},3,e)}function gunzipSync(t,n){return inflt(t.subarray(gzs(t),-8),n||new u8(gzl(t)))}exports.AsyncGunzip=AsyncGunzip,exports.gunzip=gunzip,exports.gunzipSync=gunzipSync;var Zlib=function(){function t(t,n){this.c=adler(),this.v=1,Deflate.call(this,t,n)}return t.prototype.push=function(t,n){Deflate.prototype.push.call(this,t,n)},t.prototype.p=function(t,n){this.c.p(t);var e=dopt(t,this.o,this.v&&2,n&&4,!n);this.v&&(zlh(e,this.o),this.v=0),n&&wbytes(e,e.length-4,this.c.d()),this.ondata(e,n)},t}();exports.Zlib=Zlib;var AsyncZlib=function(){return function(t,n){astrmify([bDflt,zle,function(){return[astrm,Deflate,Zlib]}],this,AsyncCmpStrm.call(this,t,n),function(t){var n=new Zlib(t.data);onmessage=astrm(n)},10)}}();function zlib(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&err(7),cbify(t,n,[bDflt,zle,function(){return[zlibSync]}],function(t){return pbf(zlibSync(t.data[0],t.data[1]))},4,e)}function zlibSync(t,n){n||(n={});var e=adler();e.p(t);var r=dopt(t,n,2,4);return zlh(r,n),wbytes(r,r.length-4,e.d()),r}exports.AsyncZlib=AsyncZlib,exports.zlib=zlib,exports.zlibSync=zlibSync;var Unzlib=function(){function t(t){this.v=1,Inflate.call(this,t)}return t.prototype.push=function(t,n){if(Inflate.prototype.e.call(this,t),this.v){if(this.p.length<2&&!n)return;this.p=this.p.subarray(2),this.v=0}n&&(this.p.length<4&&err(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),Inflate.prototype.c.call(this,n)},t}();exports.Unzlib=Unzlib;var AsyncUnzlib=function(){return function(t){this.ondata=t,astrmify([bInflt,zule,function(){return[astrm,Inflate,Unzlib]}],this,0,function(){var t=new Unzlib;onmessage=astrm(t)},11)}}();function unzlib(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&err(7),cbify(t,n,[bInflt,zule,function(){return[unzlibSync]}],function(t){return pbf(unzlibSync(t.data[0],gu8(t.data[1])))},5,e)}function unzlibSync(t,n){return inflt((zlv(t),t.subarray(2,-4)),n)}exports.AsyncUnzlib=AsyncUnzlib,exports.unzlib=unzlib,exports.unzlibSync=unzlibSync;var Decompress=function(){function t(t){this.G=Gunzip,this.I=Inflate,this.Z=Unzlib,this.ondata=t}return t.prototype.push=function(t,n){if(this.ondata||err(5),this.s)this.s.push(t,n);else{if(this.p&&this.p.length){var e=new u8(this.p.length+t.length);e.set(this.p),e.set(t,this.p.length)}else this.p=t;if(this.p.length>2){var r=this,i=function(){r.ondata.apply(r,arguments)};this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(i):8!=(15&this.p[0])||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(i):new this.Z(i),this.s.push(this.p,n),this.p=null}}},t}();exports.Decompress=Decompress;var AsyncDecompress=function(){function t(t){this.G=AsyncGunzip,this.I=AsyncInflate,this.Z=AsyncUnzlib,this.ondata=t}return t.prototype.push=function(t,n){Decompress.prototype.push.call(this,t,n)},t}();function decompress(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&err(7),31==t[0]&&139==t[1]&&8==t[2]?gunzip(t,n,e):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?inflate(t,n,e):unzlib(t,n,e)}function decompressSync(t,n){return 31==t[0]&&139==t[1]&&8==t[2]?gunzipSync(t,n):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?inflateSync(t,n):unzlibSync(t,n)}exports.AsyncDecompress=AsyncDecompress,exports.decompress=decompress,exports.decompressSync=decompressSync;var fltn=function(t,n,e,r){for(var i in t){var s=t[i],o=n+i,a=r;Array.isArray(s)&&(a=mrg(r,s[1]),s=s[0]),s instanceof u8?e[o]=[s,a]:(e[o+="/"]=[new u8(0),a],fltn(s,o,e,r))}},te="undefined"!=typeof TextEncoder&&new TextEncoder,td="undefined"!=typeof TextDecoder&&new TextDecoder,tds=0;try{td.decode(et,{stream:!0}),tds=1}catch(t){}var dutf8=function(t){for(var n="",e=0;;){var r=t[e++],i=(r>127)+(r>223)+(r>239);if(e+i>t.length)return[n,slc(t,e-1)];i?3==i?(r=((15&r)<<18|(63&t[e++])<<12|(63&t[e++])<<6|63&t[e++])-65536,n+=String.fromCharCode(55296|r>>10,56320|1023&r)):n+=1&i?String.fromCharCode((31&r)<<6|63&t[e++]):String.fromCharCode((15&r)<<12|(63&t[e++])<<6|63&t[e++]):n+=String.fromCharCode(r)}},DecodeUTF8=function(){function t(t){this.ondata=t,tds?this.t=new TextDecoder:this.p=et}return t.prototype.push=function(t,n){if(this.ondata||err(5),n=!!n,this.t)return this.ondata(this.t.decode(t,{stream:!0}),n),void(n&&(this.t.decode().length&&err(8),this.t=null));this.p||err(4);var e=new u8(this.p.length+t.length);e.set(this.p),e.set(t,this.p.length);var r=dutf8(e),i=r[0],s=r[1];n?(s.length&&err(8),this.p=null):this.p=s,this.ondata(i,n)},t}();exports.DecodeUTF8=DecodeUTF8;var EncodeUTF8=function(){function t(t){this.ondata=t}return t.prototype.push=function(t,n){this.ondata||err(5),this.d&&err(4),this.ondata(strToU8(t),this.d=n||!1)},t}();function strToU8(t,n){if(n){for(var e=new u8(t.length),r=0;r>1)),o=0,a=function(t){s[o++]=t};for(r=0;rs.length){var f=new u8(o+8+(i-r<<1));f.set(s),s=f}var u=t.charCodeAt(r);u<128||n?a(u):u<2048?(a(192|u>>6),a(128|63&u)):u>55295&&u<57344?(a(240|(u=65536+(1047552&u)|1023&t.charCodeAt(++r))>>18),a(128|u>>12&63),a(128|u>>6&63),a(128|63&u)):(a(224|u>>12),a(128|u>>6&63),a(128|63&u))}return slc(s,0,o)}function strFromU8(t,n){if(n){for(var e="",r=0;r65535&&err(9),n+=r+4}return n},wzh=function(t,n,e,r,i,s,o,a){var f=r.length,u=e.extra,l=a&&a.length,c=exfl(u);wbytes(t,n,null!=o?33639248:67324752),n+=4,null!=o&&(t[n++]=20,t[n++]=e.os),t[n]=20,n+=2,t[n++]=e.flag<<1|(null==s&&8),t[n++]=i&&8,t[n++]=255&e.compression,t[n++]=e.compression>>8;var h=new Date(null==e.mtime?Date.now():e.mtime),p=h.getFullYear()-1980;if((p<0||p>119)&&err(10),wbytes(t,n,p<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>>1),n+=4,null!=s&&(wbytes(t,n,e.crc),wbytes(t,n+4,s),wbytes(t,n+8,e.size)),wbytes(t,n+12,f),wbytes(t,n+14,c),n+=16,null!=o&&(wbytes(t,n,l),wbytes(t,n+6,e.attrs),wbytes(t,n+10,o),n+=14),t.set(r,n),n+=f,c)for(var v in u){var d=u[v],b=d.length;wbytes(t,n,+v),wbytes(t,n+2,b),t.set(d,n+4),n+=4+b}return l&&(t.set(a,n),n+=l),n},wzf=function(t,n,e,r,i){wbytes(t,n,101010256),wbytes(t,n+8,e),wbytes(t,n+10,e),wbytes(t,n+12,r),wbytes(t,n+16,i)},ZipPassThrough=function(){function t(t){this.filename=t,this.c=crc(),this.size=0,this.compression=0}return t.prototype.process=function(t,n){this.ondata(null,t,n)},t.prototype.push=function(t,n){this.ondata||err(5),this.c.p(t),this.size+=t.length,n&&(this.crc=this.c.d()),this.process(t,n||!1)},t}();exports.ZipPassThrough=ZipPassThrough;var ZipDeflate=function(){function t(t,n){var e=this;n||(n={}),ZipPassThrough.call(this,t),this.d=new Deflate(n,function(t,n){e.ondata(null,t,n)}),this.compression=8,this.flag=dbf(n.level)}return t.prototype.process=function(t,n){try{this.d.push(t,n)}catch(t){this.ondata(t,null,n)}},t.prototype.push=function(t,n){ZipPassThrough.prototype.push.call(this,t,n)},t}();exports.ZipDeflate=ZipDeflate;var AsyncZipDeflate=function(){function t(t,n){var e=this;n||(n={}),ZipPassThrough.call(this,t),this.d=new AsyncDeflate(n,function(t,n,r){e.ondata(t,n,r)}),this.compression=8,this.flag=dbf(n.level),this.terminate=this.d.terminate}return t.prototype.process=function(t,n){this.d.push(t,n)},t.prototype.push=function(t,n){ZipPassThrough.prototype.push.call(this,t,n)},t}();exports.AsyncZipDeflate=AsyncZipDeflate;var Zip=function(){function t(t){this.ondata=t,this.u=[],this.d=1}return t.prototype.add=function(t){var n=this;if(this.ondata||err(5),2&this.d)this.ondata(err(4+8*(1&this.d),0,1),null,!1);else{var e=strToU8(t.filename),r=e.length,i=t.comment,s=i&&strToU8(i),o=r!=t.filename.length||s&&i.length!=s.length,a=r+exfl(t.extra)+30;r>65535&&this.ondata(err(11,0,1),null,!1);var f=new u8(a);wzh(f,0,t,e,o);var u=[f],l=function(){for(var t=0,e=u;t65535&&U(err(11,0,1),null),S)if(b<16e4)try{U(null,deflateSync(f,v))}catch(t){U(t,null)}else l.push(deflate(f,v,U));else U(null,f)},d=0;d65535&&err(11);var b=l?deflateSync(f,u):f,y=b.length,g=crc();g.p(f),r.push(mrg(u,{size:f.length,crc:g.d(),c:b,f:S,m:p,u:c!=o.length||p&&h.length!=v,o:i,compression:l})),i+=30+c+d+y,s+=76+2*(c+d)+(v||0)+y}for(var m=new u8(s+22),z=i,w=s-i,x=0;x0){var r=Math.min(this.c,t.length),i=t.subarray(0,r);if(this.c-=r,this.d?this.d.push(i,!this.c):this.k[0].push(i),(t=t.subarray(r)).length)return this.push(t,n)}else{var s=0,o=0,a=void 0,f=void 0;this.p.length?t.length?((f=new u8(this.p.length+t.length)).set(this.p),f.set(t,this.p.length)):f=this.p:f=t;for(var u=f.length,l=this.c,c=l&&this.d,h=function(){var t,n=b4(f,o);if(67324752==n){s=1,a=o,p.d=null,p.c=0;var r=b2(f,o+6),i=b2(f,o+8),c=2048&r,h=8&r,v=b2(f,o+26),d=b2(f,o+28);if(u>o+30+v+d){var b=[];p.k.unshift(b),s=2;var y,g=b4(f,o+18),m=b4(f,o+22),z=strFromU8(f.subarray(o+30,o+=30+v),!c);4294967295==g?(t=h?[-2]:z64e(f,o),g=t[0],m=t[1]):h&&(g=-1),o+=d,p.c=g;var w={name:z,compression:i,start:function(){if(w.ondata||err(5),g){var t=e.o[i];t||w.ondata(err(14,"unknown compression type "+i,1),null,!1),(y=g<0?new t(z):new t(z,g,m)).ondata=function(t,n,e){w.ondata(t,n,e)};for(var n=0,r=b;n=0&&(w.size=g,w.originalSize=m),p.onfile(w)}return"break"}if(l){if(134695760==n)return a=o+=12+(-2==l&&8),s=3,p.c=0,"break";if(33639248==n)return a=o-=4,s=3,p.c=0,"break"}},p=this;o65558)return o(err(13,0,1),null),i;var f=b2(t,a+8);if(f){var u=f,l=b4(t,a+16),c=4294967295==l;if(c){if(a=b4(t,a-12),101075792!=b4(t,a))return o(err(13,0,1),null),i;u=f=b4(t,a+32),l=b4(t,a+48)}for(var h=n&&n.filter,p=function(n){var e=zh(t,l,c),a=e[0],u=e[1],p=e[2],v=e[3],d=e[4],b=e[5],y=slzh(t,b);l=d;var g=function(t,n){t?(i(),o(t,null)):(n&&(s[v]=n),--f||o(null,s))};if(!h||h({name:v,size:u,originalSize:p,compression:a}))if(a)if(8==a){var m=t.subarray(y,y+u);if(u<32e4)try{g(null,inflateSync(m,new u8(p)))}catch(t){g(t,null)}else r.push(inflate(m,{size:p},g))}else g(err(14,"unknown compression type "+a,1),null);else g(null,slc(t,y,y+u));else g(null,null)},v=0;v65558)&&err(13);var i=b2(t,r+8);if(!i)return{};var s=b4(t,r+16),o=4294967295==s;o&&(r=b4(t,r-12),101075792!=b4(t,r)&&err(13),i=b4(t,r+32),s=b4(t,r+48));for(var a=n&&n.filter,f=0;f{e=Object.assign({},{unit:"millimeter",metadata:!0,defaultcolor:[1,160/255,0,1],compress:!0},e);let o=(t=flatten(t)).filter(e=>geometries.geom3.isA(e));if(0===o.length)throw new Error("only 3D geometries can be serialized to 3MF");t.length!==o.length&&console.warn("some objects could not be serialized to 3MF"),t=toArray(modifiers.generalize({snap:!0,triangulate:!0},o));const r=["model",{unit:e.unit,"xml:lang":"und"},["metadata",{name:"Application"},"JSCAD"]];e.metadata&&r.push(["metadata",{name:"CreationDate"},(new Date).toISOString()]),r.push(translateResources(t,e)),r.push(translateBuild(t,e));const n=`\n${stringify(r,2)}`;if(e.compress){const e={"3D":{"3dmodel.model":strToU8(n)},_rels:{".rels":strToU8(rels)},"[Content_Types].xml":strToU8(contenttype)};return[zipSync(e,{comment:"created by JSCAD"}).buffer]}return[n]},contenttype='\n\n \n \n \n \n',rels='\n\n \n \n',translateResources=(e,t)=>{let o=["resources",{},translateMaterials(e,t)];return o=o.concat(translateObjects(e,t))},translateMaterials=(e,t)=>{let o=["basematerials",{id:"0"}];const r=[];return e.forEach((e,o)=>{let n=colors.rgbToHex(t.defaultcolor).toUpperCase();e.color&&(n=colors.rgbToHex(e.color).toUpperCase()),r.push(["base",{name:`mat${o}`,displaycolor:n}])}),o=o.concat(r)},translateObjects=(e,t)=>{const o=[];return e.forEach((e,r)=>{if(geometries.geom3.isA(e)){geometries.geom3.toPolygons(e).length>0&&(t.id=r,o.push(convertToObject(e,t)))}}),o},translateBuild=(e,t)=>{let o=["build",{}];const r=[];return e.forEach((e,t)=>{r.push(["item",{objectid:`${t+1}`}])}),o=o.concat(r)},convertToObject=(e,t)=>{const o=e.name?e.name:`Part ${t.id}`;return["object",{id:`${t.id+1}`,type:"model",pid:"0",pindex:`${t.id}`,name:o},convertToMesh(e,t)]},convertToMesh=(e,t)=>{return["mesh",{},convertToVertices(e,t),convertToVolumes(e,t)]},convertToVertices=(e,t)=>{const o=[];return geometries.geom3.toPolygons(e).forEach(e=>{for(let r=0;r{return["vertex",{x:e[0],y:e[1],z:e[2]}]},convertToVolumes=(e,t)=>{let o=0;const r=geometries.geom3.toPolygons(e);let n=["triangles",{}];return r.forEach(e=>{if(e.vertices.length<3)return;const t=convertToTriangles(e,o);n=n.concat(t),o+=e.vertices.length}),n},convertToTriangles=(e,t)=>{const o=[];for(let r=0;r=SPACE&&e<=55295||e===NL||e===CR||e===TAB||e>=57344&&e<=65533||e>=65536&&e<=1114111}function isS(e){return e===SPACE||e===NL||e===CR||e===TAB}function isNameStartChar(e){return e>=65&&e<=90||e>=97&&e<=122||58===e||95===e||8204===e||8205===e||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}function isNameChar(e){return isNameStartChar(e)||e>=48&&e<=57||45===e||46===e||183===e||e>=768&&e<=879||e>=8255&&e<=8256}exports.S_LIST=[SPACE,NL,CR,TAB],exports.isChar=isChar,exports.isS=isS,exports.isNameStartChar=isNameStartChar,exports.isNameChar=isNameChar; },{}],43:[function(require,module,exports){ @@ -196,7 +196,7 @@ const zipSync=require("fflate").zipSync,strToU8=require("fflate").strToU8,string },{"xmlchars/xml/1.0/ed5":42,"xmlchars/xml/1.1/ed2":43,"xmlchars/xmlns/1.0/ed3":44}],46:[function(require,module,exports){ module.exports={ "name": "@jscad/amf-deserializer", - "version": "2.3.7", + "version": "2.3.8", "description": "AMF Deserializer for JSCAD", "repository": "https://github.com/jscad/OpenJSCAD.org/", "main": "src/index.js", @@ -227,7 +227,7 @@ module.exports={ ], "license": "MIT", "dependencies": { - "@jscad/modeling": "2.12.2", + "@jscad/modeling": "2.12.3", "saxes": "5.0.1" }, "devDependencies": { @@ -261,7 +261,7 @@ const createObject=require("./objectBuilder"),parse=require("./parse"),translate },{"./constants":47,"./objectBuilder":51,"./parse":52}],54:[function(require,module,exports){ const stringify=require("onml/lib/stringify"),{geometries:geometries,modifiers:modifiers}=require("@jscad/modeling"),{flatten:flatten,toArray:toArray}=require("@jscad/array-utils"),mimeType="application/amf+xml",serialize=(e,...t)=>{e=Object.assign({},{statusCallback:null,unit:"millimeter"},e);let o=(t=flatten(t)).filter(e=>geometries.geom3.isA(e));if(0===o.length)throw new Error("only 3D geometries can be serialized to AMF");t.length!==o.length&&console.warn("some objects could not be serialized to AMF"),o=toArray(modifiers.generalize({snap:!0,triangulate:!0},o)),e.statusCallback&&e.statusCallback({progress:0});let r=["amf",{unit:e.unit,version:"1.1"},["metadata",{type:"author"},"Created by JSCAD"]];r=r.concat(translateObjects(o,e));const n=`\n${stringify(r,2)}`;return e&&e.statusCallback&&e.statusCallback({progress:100}),[n]},translateObjects=(e,t)=>{const o=[];return e.forEach((e,r)=>{geometries.geom3.toPolygons(e).length>0&&(t.id=r,o.push(convertToObject(e,t)))}),o},convertToObject=(e,t)=>{return["object",{id:t.id},convertToMesh(e,t)]},convertToMesh=(e,t)=>{let o=["mesh",{},convertToVertices(e,t)];return o=o.concat(convertToVolumes(e,t))},convertToVertices=(e,t)=>{const o=[];return geometries.geom3.toPolygons(e).forEach(e=>{for(let r=0;r{return["vertex",{},convertToCoordinates(e,t)]},convertToCoordinates=(e,t)=>{return["coordinates",{},["x",{},e[0]],["y",{},e[1]],["z",{},e[2]]]},convertToVolumes=(e,t)=>{const o=convertColor(e.color),r=geometries.geom3.toPolygons(e),n=[];let s=["volume",{}];o&&s.push(o);let l=0;return r.forEach(e=>{if(e.vertices.length<3)return;const o=convertToTriangles(e,l,t);s=s.concat(o),l+=e.vertices.length}),n.push(s),n},convertColor=e=>e?(e.length<4&&e.push(1),["color",{},["r",{},e[0]],["g",{},e[1]],["b",{},e[2]],["a",{},e[3]]]):null,convertToColor=(e,t)=>{const o=e.color;return convertColor(o)},convertToTriangles=(e,t,o)=>{const r=convertToColor(e),n=[];for(let o=0;ot&&"[object Object]"===Object.prototype.toString.call(t);function indenter(t){if(!(t>0))return t=>t;var e=" ".repeat(t);return t=>{if("string"!=typeof t)return t;const n=t.split("\n");return 1===n.length?e+t:n.map(t=>""===t.trim()?t:e+t).join("\n")}}const clean=t=>t.split("\n").filter(t=>""!==t.trim()).join("\n");function stringify(t,e){const n=e>0?"\n":"",r=indenter(e);return function t(e){let i,o="",s=!0;return e.some((e,r,c)=>{if(0===r)return i="<"+e,1===c.length;if(1===r){if(isObject(e))return Object.keys(e).map(t=>{let n=e[t];Array.isArray(n)&&(n=n.join(" ")),i+=" "+t+'="'+n+'"'}),2===c.length||void(i+=">");i+=">"}switch(typeof e){case"string":case"number":case"boolean":case"undefined":return void(o+=e+n)}s=!1,o+=t(e)})?i+"/>"+n:s?i+clean(o)+""+n:i+n+r(o)+""+n}(t)}module.exports=stringify; },{}],56:[function(require,module,exports){ @@ -285,7 +285,7 @@ const{geometries:geometries,maths:maths,primitives:primitives}=require("@jscad/m },{"./helpers":59,"@jscad/modeling":216}],62:[function(require,module,exports){ module.exports={ "name": "@jscad/dxf-deserializer", - "version": "2.3.24", + "version": "2.3.25", "description": "DXF Deserializer for JSCAD", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -313,7 +313,7 @@ module.exports={ ], "license": "MIT", "dependencies": { - "@jscad/modeling": "2.12.2" + "@jscad/modeling": "2.12.3" }, "devDependencies": { "ava": "3.15.0", @@ -334,7 +334,7 @@ const colorIndex=[[0,0,0,255],[255,0,0,255],[255,255,0,255],[0,255,0,255],[0,255 },{}],66:[function(require,module,exports){ const{geometries:geometries,modifiers:modifiers}=require("@jscad/modeling"),{geom3:geom3,geom2:geom2,path2:path2}=geometries,{flatten:flatten,toArray:toArray}=require("@jscad/array-utils"),{dxfHeaders:dxfHeaders,dxfClasses:dxfClasses,dxfTables:dxfTables,dxfBlocks:dxfBlocks,dxfObjects:dxfObjects}=require("./autocad_AC2017"),colorindex2017=require("./colorindex2017"),mimeType="application/dxf",serialize=(n,...e)=>{const t={geom2To:"lwpolyline",geom3To:"3dface",pathTo:"lwpolyline",statusCallback:null,colorIndex:colorindex2017};if((n=Object.assign({},t,n)).entityId=0,0===(e=(e=flatten(e)).filter(n=>geom3.isA(n)||geom2.isA(n)||path2.isA(n))).length)throw new Error("only JSCAD geometries can be serialized to DXF");return e=toArray(modifiers.generalize({snap:!0,triangulate:!0},e)),[`999\nCreated by JSCAD\n${dxfHeaders(n)}\n${dxfClasses(n)}\n${dxfTables(n)}\n${dxfBlocks(n)}\n${dxfEntities(e,n)}\n${dxfObjects(n)}\n 0\nEOF\n`]},dxfEntities=(n,e)=>{const t=n.map((n,t)=>{if(geom2.isA(n)){const t=n.color,o=n.name,s=geom2.toOutlines(n).map(n=>({closed:!0,points:n,color:t,name:o}));return"polyline"===e.geom2To?PathsToPolyine(s,e):PathsToLwpolyline(s,e)}if(geom3.isA(n))return"polyline"===e.geom3To?PolygonsToPolyline(n,e):PolygonsTo3DFaces(n,e);if(path2.isA(n)){const t=n.color,o=n.name,s={closed:n.isClosed,points:path2.toPoints(n),color:t,name:o};return PathsToLwpolyline([s],e)}return""});let o=" 0\nSECTION\n 2\nENTITIES\n";return t.forEach(n=>{n&&(o+=n)}),o+=" 0\nENDSEC"},PathsToLwpolyline=(n,e)=>{e.statusCallback&&e.statusCallback({progress:0});let t="";return n.forEach((o,s)=>{if(o.points.length<1)return;const l=o.points.length+(o.closed?1:0);t+=` 0\nLWPOLYLINE\n 5\n${getEntityId(e)}\n 100\nAcDbEntity\n 3\n${getName(o,e)}\n 8\n0\n 67\n0\n 62\n${getColorNumber(o,e)}\n 100\nAcDbPolyline\n 90\n${l}\n 70\n${o.closed?1:0}\n`;for(let n=0;n=o.points.length&&(e-=o.points.length);const s=o.points[e];t+=` 10\n${s[0]}\n 20\n${s[1]}\n`}e.statusCallback&&e.statusCallback({progress:100*s/n.length})}),e.statusCallback&&e.statusCallback({progress:100}),[t]},PathsToPolyine=(n,e)=>{e.statusCallback&&e.statusCallback({progress:0});let t="";return n.forEach((o,s)=>{const l=o.points.length+(o.closed?1:0);t+=` 0\nPOLYLINE\n 5\n${getEntityId(e)}\n 100\nAcDbEntity\n 3\n${getName(o,e)}\n 8\n0\n 62\n${getColorNumber(o,e)}\n 100\nAcDb2dPolyline\n`;for(let n=0;n=o.points.length&&(s-=o.points.length);const l=o.points[s];t+=` 0\nVERTEX\n 5\n${getEntityId(e)}\n 100\nAcDbEntity\n 8\n0\n 100\nAcDbVertex\n 100\nAcDb2dVertex\n 10\n${l[0]}\n 20\n${l[1]}\n`}t+=` 0\nSEQEND\n 5\n${getEntityId(e)}\n 100\nAcDbEntity\n`,e.statusCallback&&e.statusCallback({progress:100*s/n.length})}),e.statusCallback&&e.statusCallback({progress:100}),[t]},PolygonsTo3DFaces=(n,e)=>{e.statusCallback&&e.statusCallback({progress:0});let t="";const o=geom3.toPolygons(n),s=getColorNumber(n,e);return o.forEach((n,o)=>{const l=n.color?getColorNumber(n,e):s;polygonToTriangles(n).forEach((n,o)=>{t+=triangleTo3DFaces(n,e,l)})}),e.statusCallback&&e.statusCallback({progress:100}),[t]},polygonToTriangles=n=>{const e=n.vertices.length-2;if(e<1)return[];const t=n.vertices[0],o=[];for(let s=0;s{const o=n[0],s=n[1],l=n[2],r=n[2];return` 0\n3DFACE\n 5\n${getEntityId(e)}\n 100\nAcDbEntity\n 8\n0\n 62\n${t}\n 100\nAcDbFace\n 70\n0\n 10\n${o[0]}\n 20\n${o[1]}\n 30\n${o[2]}\n 11\n${s[0]}\n 21\n${s[1]}\n 31\n${s[2]}\n 12\n${l[0]}\n 22\n${l[1]}\n 32\n${l[2]}\n 13\n${r[0]}\n 23\n${r[1]}\n 33\n${r[2]}\n`},PolygonsToPolyline=(n,e)=>{let t="";const o=polygons2polyfaces(geom3.toPolygons(n));return o.faces.length>0&&(t+=` 0\nPOLYLINE\n 5\n${getEntityId(e)}\n 100\nAcDbEntity\n 3\n${getName(n,e)}\n 8\n0\n 62\n${getColorNumber(n,e)}\n 100\nAcDb3dPolyline\n 70\n64\n 71\n${o.vertices.length}\n 72\n${o.faces.length}\n`,o.vertices.forEach(n=>{t+=` 0\nVERTEX\n 5\n${getEntityId(e)}\n 100\nAcDbEntity\n 8\n0\n 100\nAcDbVertex\n 100\nAcDb3dPolylineVertex\n 10\n${n[0]}\n 20\n${n[1]}\n 30\n${n[2]}\n 70\n192\n`}),o.faces.forEach(n=>{t+=` 0\nVERTEX\n 5\n${getEntityId(e)}\n 100\nAcDbEntity\n 8\n0\n 100\nAcDbVertex\n 100\nAcDb3dPolylineVertex\n 10\n0\n 20\n0\n 30\n0\n 70\n128\n 71\n${n[0]}\n 72\n${n[1]}\n 73\n${n[2]}\n 74\n${n[3]}\n`})),[t]},polygons2polyfaces=n=>{const e=[],t=[];for(let o=0;o{n.entityId++;const e="00000"+n.entityId.toString(16).toUpperCase();return"CAD"+e.substr(e.length-5)},getName=(n,e)=>{if(n.name)return n.name;const t="00000"+e.entityId.toString(16).toUpperCase();return"CAD"+t.substr(t.length-5)},getColorNumber=(n,e)=>{let t=256;if(n.color){const o=Math.floor(255*n.color[0]),s=Math.floor(255*n.color[1]),l=Math.floor(255*n.color[2]),r=e.colorIndex;let a=765;for(let n=1;n>3;this._checkSize(r);const i=Math.pow(2,e-1)-1,h=this._readBits(t+e,1,s),d=this._readBits(t,e,s);let o=0,n=2,_=0,a=0;do{const e=this._readByte(++_,s);let r=1<<(a=t%8||8);for(;r>>=1;)e&r&&(o+=1/n),n*=2}while(t-=a);return this._pos+=s,d===1+(i<<1)?o?NaN:h?-1/0:1/0:(1+-2*h)*(d||o?d?Math.pow(2,d-i)*(1+o):Math.pow(2,1-i)*o:0)}_decodeInt(t,e){const r=this._readBits(0,t,t/8),s=Math.pow(2,t),i=e&&r>=s/2?r-s:r;return this._pos+=t/8,i}_shl(t,e){for(++e;--e;t=1073741824==(1073741824&(t%=2147483648))?2*t:2*(t-1073741824)+2147483647+1);return t}_readByte(t,e){return 255&this._buffer.charCodeAt(this._pos+e-t-1)}_readBits(t,e,r){const s=(t+e)%8,i=t%8,h=r-(t>>3)-1;let d=r+(-(t+e)>>3),o=h-d,n=this._readByte(h,r)>>i&(1<<(o?8-i:e))-1;for(o&&s&&(n+=(this._readByte(d++,r)&(1<{const i={format:void 0,version:"0.0.0"},{format:a,version:s}=Object.assign({},i,r),l={producer:"JSCAD "+s,date:new Date,version:s},t={amf:amfSerializer,stl:stlSerializer,stla:{mimeType:stlSerializer.mimeType,serialize:(e,r)=>stlSerializer.serialize(Object.assign({},{binary:!1},e),r)},stlb:stlSerializer,dxf:dxfSerializer,obj:objSerializer,svg:svgSerializer,x3d:x3dSerializer,"3mf":m3fSerializer,json:jsonSerializer,js:{mimeType:formats.js.mimetype,serialize:(e,r)=>toArray(r)},jscad:{mimeType:formats.jscad.mimetype,serialize:(e,r)=>toArray(r)},undefined:()=>{throw new Error("Not supported : only jscad, stl, amf, dxf, svg or json as output format")}},o=Object.assign({},l,r);return{data:t[a].serialize(o,e),mimeType:t[a].mimeType}};module.exports=prepareOutput; -},{"./formats":73,"@jscad/3mf-serializer":41,"@jscad/amf-serializer":54,"@jscad/array-utils":531,"@jscad/dxf-serializer":66,"@jscad/json-serializer":78,"@jscad/obj-serializer":81,"@jscad/stl-serializer":86,"@jscad/svg-serializer":98,"@jscad/x3d-serializer":124}],76:[function(require,module,exports){ +},{"./formats":73,"@jscad/3mf-serializer":41,"@jscad/amf-serializer":54,"@jscad/array-utils":532,"@jscad/dxf-serializer":66,"@jscad/json-serializer":78,"@jscad/obj-serializer":81,"@jscad/stl-serializer":86,"@jscad/svg-serializer":98,"@jscad/x3d-serializer":124}],76:[function(require,module,exports){ const{flatten:flatten,toArray:toArray}=require("@jscad/array-utils"),version=require("./package.json").version,deserialize=(e,t)=>{const n={filename:"json",output:"script",version:version,addMetaData:!0};e=Object.assign({},n,e);let r=JSON.parse(t);return r=flatten(toArray(r)),"script"===e.output?translate(e,r):r},translate=(e,t)=>{const{addMetaData:n,filename:r,version:s}=e;let a=n?`//\n// Produced by JSCAD IO Library : JSON Deserializer (${s})\n// date: ${new Date}\n// source: ${r}\n//\n`:"";return a+=`\nconst { geometries } = require('@jscad/modeling')\n\nconst main = () => {\n const objects = [${translateToList(t)} ]\n return objects\n}\n\n${translateToObjects(t)}\n\nmodule.exports = { main }\n`},translateToList=e=>e.reduce((e,t,n)=>e+` json${n},`,""),translateToObjects=e=>e.reduce((e,t,n)=>e+translateToObject(t,n),""),translateToObject=(e,t)=>`const json${t} = ${JSON.stringify(e)}\n`,extension="json";module.exports={deserialize:deserialize,extension:"json"}; -},{"./package.json":77,"@jscad/array-utils":531}],77:[function(require,module,exports){ +},{"./package.json":77,"@jscad/array-utils":532}],77:[function(require,module,exports){ module.exports={ "name": "@jscad/json-deserializer", - "version": "2.0.28", + "version": "2.0.29", "description": "JSON Deserializer for JSCAD", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -400,7 +400,7 @@ module.exports={ "@jscad/array-utils": "2.1.4" }, "devDependencies": { - "@jscad/modeling": "2.12.2", + "@jscad/modeling": "2.12.3", "ava": "3.15.0", "nyc": "15.1.0" }, @@ -416,7 +416,7 @@ const{colors:colors,primitives:primitives}=require("@jscad/modeling"),version=re },{"./package.json":80,"@jscad/modeling":216}],80:[function(require,module,exports){ module.exports={ "name": "@jscad/obj-deserializer", - "version": "2.0.27", + "version": "2.0.28", "description": "OBJ Deserializer for JSCAD", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -448,7 +448,7 @@ module.exports={ ], "license": "MIT", "dependencies": { - "@jscad/modeling": "2.12.2" + "@jscad/modeling": "2.12.3" }, "devDependencies": { "ava": "3.15.0", @@ -460,13 +460,13 @@ module.exports={ },{}],81:[function(require,module,exports){ const{colors:colors,geometries:geometries,modifiers:modifiers}=require("@jscad/modeling"),{flatten:flatten,toArray:toArray}=require("@jscad/array-utils"),mimeType="application/object",serialize=(e,...t)=>{e=Object.assign({},{statusCallback:null,triangulate:!0},e);let o=(t=flatten(t)).filter(e=>geometries.geom3.isA(e));if(0===o.length)throw new Error("only 3D geometries can be serialized to OBJ");t.length!==o.length&&console.warn("some objects could not be serialized to OBJ"),o=toArray(modifiers.generalize({snap:!0,triangulate:e.triangulate},o)),e.statusCallback&&e.statusCallback({progress:0});let r="# Wavefront OBJ file generated by JSCAD\n";const s=[];let a="default";return o.forEach((t,l)=>{e.statusCallback&&e.statusCallback({progress:100*l/o.length}),r+="\n";const i=getColorName(t),n=geometries.geom3.toPolygons(t).filter(e=>e.vertices.length>=3);n.forEach(e=>{e.vertices.forEach(e=>{const t=convertVertex(e);s.indexOf(t)<0&&(s.push(t),r+=`${t}\n`)})}),r+="\n",n.forEach(e=>{const t=e.vertices.map(e=>s.indexOf(convertVertex(e))+1),o=getColorName(e)||i||"default";o!==a&&(r+=`usemtl ${o}\n`,a=o),r+=`f ${t.join(" ")}\n`})}),e.statusCallback&&e.statusCallback({progress:100}),[r]},convertVertex=e=>`v ${e[0]} ${e[1]} ${e[2]}`,getColorName=e=>{let t;if(e.color){const o=e.color[0],r=e.color[1],s=e.color[2];let a=765;for(const e in colors.cssColors){const l=colors.cssColors[e],i=Math.abs(o-l[0])+Math.abs(r-l[1])+Math.abs(s-l[2]);if(i{const t={filename:"stl",version:packageVersion,addMetaData:!0,output:"script"};(e=Object.assign({},t,e))&&e.statusCallback&&e.statusCallback({progress:0});const{filename:r,version:a,output:n,addMetaData:o}=e;s=isBuffer(s)?bufferToBinaryString(s):s;const l=isDataBinaryRobust(s);e&&e.statusCallback&&e.statusCallback({progress:33});e&&e.statusCallback&&e.statusCallback({progress:66});const i=("script"===n?formatAsJscad:formatAsCsg)((l?deserializeBinarySTL:deserializeAsciiSTL)(s,r,a,"script"===n?({vertices:e,triangles:s,normals:t,colors:r,index:a})=>toScript(e,s,null,r,a):({vertices:e,triangles:s,normals:t,colors:r})=>toPolyhedron(e,s,null,r)),o,a,r);return e&&e.statusCallback&&e.statusCallback({progress:100}),i},bufferToBinaryString=e=>{let s="";const t=new Uint8Array(e),r=t.byteLength;for(let e=0;evoid 0!==e.byteLength&&"function"==typeof e.slice,ensureString=e=>{if("string"!=typeof e){const s=new Uint8Array(e);let t="";for(let r=0;r{const s=ensureString(e);return null===/vertex[\s]+([-+]?[0-9]+\.?[0-9]*([eE][-+]?[0-9]+)?)+[\s]+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)+[\s]+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)+/g.exec(s)},formatAsJscad=(e,s,t,r)=>{let a="";return s&&(a=`\n //\n // producer: JSCAD STL Deserializer ${t}\n // date: ${new Date}\n // source: ${r}\n // objects: ${e.length}\n //\n `),a+="const {primitives} = require('@jscad/modeling')\n",a+=e.join("\n"),a+=`\nconst main = () => {\n return [${e.map((e,s)=>`solid${s+1}()`)}]\n}\n\nmodule.exports = {main}\n`},formatAsCsg=e=>e,deserializeBinarySTL=(e,s,t,r)=>{const a=[],n=[],o=[],l=[];let i=0,c=0,u=null;const p=parseInt("01000000000000000",2),h=parseInt("00000000000011111",2),d=parseInt("00000001111100000",2),g=parseInt("00111110000000000",2),m=new BinaryReader(e);let f=0,v=0,b=0,S=0,F=0,y=0;for(let e=0;e<80;e++)switch(f){case 6:b=m.readUInt8(),f+=1;continue;case 7:S=m.readUInt8(),f+=1;continue;case 8:F=m.readUInt8(),f+=1;continue;case 9:y=m.readUInt8(),f+=1;continue;default:switch(v=m.readChar()){case"C":case"O":case"L":case"R":case"=":f+=1}}10===f&&(u=[b/255,S/255,F/255,y/255]);const C=m.readUInt32();for(let e=0;e0&&console.log("bad triangle vertice coords/normal: ",v),c+=v;const b=[];b.push(i++),b.push(i++),b.push(i++);const S=m.readUInt16();let F=null;if(10===f){const e=(S&h)/31,s=((S&d)>>>5)/31,t=((S&g)>>>10)/31,r=255;F=0===(S&p)?[e,s,t,r]:u,l.push(F)}if(0===v){const a=maths.vec3.subtract(maths.vec3.create(),t,s),n=maths.vec3.subtract(maths.vec3.create(),r,s),o=maths.vec3.cross(maths.vec3.create(),a,n);if(maths.vec3.dot(e,o)>0){const e=r;r=s,s=e}}a.push(s),a.push(t),a.push(r),n.push(b),o.push(e)}return c&&console.warn(`WARNING: import errors: ${c} (some triangles might be misaligned or missing)`),[r({vertices:a,triangles:n,normals:o,colors:l,index:1})]},deserializeAsciiSTL=(e,s,t,r)=>{let a=0;const n=e.split("endsolid"),o=[];for(let s=1;s0){const e=g;g=c,c=e}}n.push(c),n.push(d),n.push(g),i.push(o),l.push(m),a++}p&&console.warn(`WARNING: import errors: ${p} (some triangles might be misaligned or missing)`),o.push(r({vertices:n,triangles:l,colors:c,index:s}))}}return o},toPolyhedron=(e,s,t,r)=>{r&&s.length!==r.length&&(r=void 0);const a={orientation:"inward",points:e,faces:s,colors:r};return primitives.polyhedron(a)},toScript=(e,s,t,r,a)=>{let n=`\n//\n// solid ${a} : ${e.length} points, ${s.length} faces, ${r.length} colors\n//\nconst solid${a} = () => {\n`;n+=" const points = [\n";for(let s=0;s{ },{"@jscad/modeling":216}],86:[function(require,module,exports){ const{geometries:geometries,modifiers:modifiers}=require("@jscad/modeling"),{flatten:flatten,toArray:toArray}=require("@jscad/array-utils"),{serializeBinary:serializeBinary}=require("./CSGToStlb"),{serializeText:serializeText}=require("./CSGToStla"),mimeType="application/sla",serialize=(e,...i)=>{e=Object.assign({},{binary:!0,statusCallback:null},e);let r=(i=flatten(i)).filter(e=>geometries.geom3.isA(e));if(0===r.length)throw new Error("only 3D geometries can be serialized to STL");return i.length!==r.length&&console.warn("some objects could not be serialized to STL"),r=toArray(modifiers.generalize({snap:!0,triangulate:!0},r)),e.binary?serializeBinary(r,e):serializeText(r,e)};module.exports={mimeType:mimeType,serialize:serialize}; -},{"./CSGToStla":84,"./CSGToStlb":85,"@jscad/array-utils":531,"@jscad/modeling":216}],87:[function(require,module,exports){ +},{"./CSGToStla":84,"./CSGToStlb":85,"@jscad/array-utils":532,"@jscad/modeling":216}],87:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CHAR="\t\n\r -퟿-�𐀀-􏿿",exports.S=" \t\r\n",exports.NAME_START_CHAR=":A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿",exports.NAME_CHAR="-"+exports.NAME_START_CHAR+".0-9·̀-ͯ‿-⁀",exports.CHAR_RE=new RegExp("^["+exports.CHAR+"]$","u"),exports.S_RE=new RegExp("^["+exports.S+"]+$","u"),exports.NAME_START_CHAR_RE=new RegExp("^["+exports.NAME_START_CHAR+"]$","u"),exports.NAME_CHAR_RE=new RegExp("^["+exports.NAME_CHAR+"]$","u"),exports.NAME_RE=new RegExp("^["+exports.NAME_START_CHAR+"]["+exports.NAME_CHAR+"]*$","u"),exports.NMTOKEN_RE=new RegExp("^["+exports.NAME_CHAR+"]+$","u");var TAB=9,NL=10,CR=13,SPACE=32;function isChar(e){return e>=SPACE&&e<=55295||e===NL||e===CR||e===TAB||e>=57344&&e<=65533||e>=65536&&e<=1114111}function isS(e){return e===SPACE||e===NL||e===CR||e===TAB}function isNameStartChar(e){return e>=65&&e<=90||e>=97&&e<=122||58===e||95===e||8204===e||8205===e||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}function isNameChar(e){return isNameStartChar(e)||e>=48&&e<=57||45===e||46===e||183===e||e>=768&&e<=879||e>=8255&&e<=8256}exports.S_LIST=[SPACE,NL,CR,TAB],exports.isChar=isChar,exports.isS=isS,exports.isNameStartChar=isNameStartChar,exports.isNameChar=isNameChar; },{}],88:[function(require,module,exports){ @@ -532,7 +532,7 @@ const{geometries:geometries,modifiers:modifiers}=require("@jscad/modeling"),{fla },{"xmlchars/xml/1.0/ed5":87,"xmlchars/xml/1.1/ed2":88,"xmlchars/xmlns/1.0/ed3":89}],91:[function(require,module,exports){ module.exports={ "name": "@jscad/svg-deserializer", - "version": "2.5.8", + "version": "2.5.9", "description": "SVG Deserializer for JSCAD", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -565,7 +565,7 @@ module.exports={ "license": "MIT", "dependencies": { "@jscad/array-utils": "2.1.4", - "@jscad/modeling": "2.12.2", + "@jscad/modeling": "2.12.3", "saxes": "5.0.1" }, "devDependencies": { @@ -584,7 +584,7 @@ const{inchMM:inchMM,ptMM:ptMM,pcMM:pcMM,svgColors:svgColors}=require("./constant },{"./constants":92}],94:[function(require,module,exports){ const saxes=require("saxes"),{colors:colors,transforms:transforms}=require("@jscad/modeling"),{toArray:toArray}=require("@jscad/array-utils"),version=require("../package.json").version,{cagLengthX:cagLengthX,cagLengthY:cagLengthY,svgColorForTarget:svgColorForTarget}=require("./helpers"),{svgSvg:svgSvg,svgRect:svgRect,svgCircle:svgCircle,svgGroup:svgGroup,svgLine:svgLine,svgPath:svgPath,svgEllipse:svgEllipse,svgPolygon:svgPolygon,svgPolyline:svgPolyline,svgUse:svgUse}=require("./svgElementHelpers"),shapesMapGeometry=require("./shapesMapGeometry"),shapesMapJscad=require("./shapesMapJscad"),deserialize=(s,e)=>{const t={addMetaData:!0,filename:"svg",output:"script",pxPmm:require("./constants").pxPmm,segments:32,target:"path",pathSelfClosed:"error",version:version};return"script"===(s=Object.assign({},t,s)).output?translate(e,s):instantiate(e,s)},instantiate=(s,e)=>{const{pxPmm:t}=e;if(e&&e.statusCallback&&e.statusCallback({progress:0}),createSvgParser(s,t),!svgObj)throw new Error("SVG parsing failed, no valid SVG data retrieved");e&&e.statusCallback&&e.statusCallback({progress:50});const n=objectify(e,svgObj);return e&&e.statusCallback&&e.statusCallback({progress:100}),n},translate=(s,e)=>{const{filename:t,version:n,pxPmm:r,addMetaData:o}=e;if(e&&e.statusCallback&&e.statusCallback({progress:0}),createSvgParser(s,r),!svgObj)throw new Error("SVG parsing failed, no valid SVG data retrieved");let a=o?`//\n // producer: JSCAD SVG Deserializer ${n}\n // date: ${new Date}\n // source: ${t}\n //\n`:"";return a+="const { colors, geometries, primitives, transforms } = require('@jscad/modeling')\n\n",e&&e.statusCallback&&e.statusCallback({progress:50}),a+=codify(e,svgObj),a+="\nmodule.exports = { main }",e&&e.statusCallback&&e.statusCallback({progress:100}),a};let svgUnitsX,svgUnitsY,svgUnitsV;const svgObjects=[],svgGroups=[],svgDefs=[];let svgObj,svgInDefs=!1,svgUnitsPmm=[1,1];const objectify=(s,e)=>{const{target:t,segments:n,pathSelfClosed:r}=s,o=svgGroups.length;svgGroups.push(e);let a=o;for(;a>0;)a--;let g=[];const l={svgUnitsPmm:svgUnitsPmm,svgUnitsX:svgUnitsX,svgUnitsY:svgUnitsY,svgUnitsV:svgUnitsV,level:o,target:t,svgGroups:svgGroups,segments:n,pathSelfClosed:r};for(a=0;a{if("transforms"in s){let t=null,n=null,r=null;for(let e=0;e{const{target:t,segments:n}=s,r=svgGroups.length;svgGroups.push(e);let o=" ",a=r;for(;a>0;)o+=" ",a--;let g="";0===r&&(g+="function main(params) {\n let levels = {}\n let paths = {}\n let parts\n");const l="levels.l"+r;for(g+=`${o}${l} = []\n`,a=0;a{const t=new saxes.SaxesParser;return void 0!==e&&e>t.pxPmm&&(t.pxPmm=e),t.on("error",s=>{console.log(`ERROR: SVG file, line ${t.line}, column ${t.column}`),console.log(s)}),t.on("opentag",s=>{const n={SVG:svgSvg,G:svgGroup,RECT:svgRect,CIRCLE:svgCircle,ELLIPSE:svgEllipse,LINE:svgLine,POLYLINE:svgPolyline,POLYGON:svgPolygon,PATH:svgPath,USE:svgUse,DEFS:()=>{svgInDefs=!0},DESC:()=>void 0,TITLE:()=>void 0,STYLE:()=>void 0,undefined:()=>console.log("WARNING: unsupported SVG element: "+s.name)};s.attributes.position=[t.line+1,t.column+1];const r=s.name.toUpperCase(),o=n[r]?n[r](s.attributes,{svgObjects:svgObjects,customPxPmm:e}):void 0;if(o)if("id"in o&&(svgObjects[o.id]=o),"svg"===o.type)svgGroups.push(o),svgUnitsPmm=o.unitsPmm,svgUnitsX=o.viewW,svgUnitsY=o.viewH,svgUnitsV=o.viewP;else if(!0===svgInDefs){if(svgDefs.length>0){const s=svgDefs.pop();"objects"in s&&s.objects.push(o),svgDefs.push(s)}"group"===o.type&&svgDefs.push(o)}else{if(svgGroups.length>0){const s=svgGroups.pop();"objects"in s&&s.objects.push(o),svgGroups.push(s)}"group"===o.type&&svgGroups.push(o)}}),t.on("closetag",s=>{const e=()=>!0===svgInDefs?svgDefs.pop():svgGroups.pop(),t={SVG:e,DEFS:()=>{svgInDefs=!1},USE:e,G:e,undefined:()=>{}},n=s.name.toUpperCase(),r=t[n]?t[n]():void 0;0===svgGroups.length&&(svgObj=r)}),t.on("end",()=>{}),t.write(s).close(),t},extension="svg";module.exports={deserialize:deserialize,extension:"svg"}; -},{"../package.json":91,"./constants":92,"./helpers":93,"./shapesMapGeometry":95,"./shapesMapJscad":96,"./svgElementHelpers":97,"@jscad/array-utils":531,"@jscad/modeling":216,"saxes":90}],95:[function(require,module,exports){ +},{"../package.json":91,"./constants":92,"./helpers":93,"./shapesMapGeometry":95,"./shapesMapJscad":96,"./svgElementHelpers":97,"@jscad/array-utils":532,"@jscad/modeling":216,"saxes":90}],95:[function(require,module,exports){ const{geometries:geometries,primitives:primitives}=require("@jscad/modeling"),{svg2cag:svg2cag,cagLengthX:cagLengthX,cagLengthY:cagLengthY,cagLengthP:cagLengthP,reflect:reflect}=require("./helpers"),shapesMapGeometry=(e,t,s)=>{const{svgUnitsPmm:a,svgUnitsX:o,svgUnitsY:r,svgUnitsV:n,svgGroups:g,target:c,segments:p,pathSelfClosed:i}=s;return{group:e=>t({target:c,segments:p},e),rect:(e,t,s,a,o,r,n)=>{let g=cagLengthX(e.x,t,s),p=0-cagLengthY(e.y,t,a);const i=cagLengthX(e.width,t,s),l=cagLengthY(e.height,t,a),h=cagLengthX(e.rx,t,s);let m;return i>0&&l>0&&(g+=i/2,p-=l/2,m=0===h?primitives.rectangle({center:[g,p],size:[i,l]}):primitives.roundedRectangle({center:[g,p],segments:n,size:[i,l],roundRadius:h}),"path"===c&&(m=geometries.path2.fromPoints({closed:!0},geometries.geom2.toPoints(m)))),m},circle:(e,t,s,a,o,r,n)=>{const g=cagLengthX(e.x,t,s),p=0-cagLengthY(e.y,t,a),i=cagLengthP(e.radius,t,o);let l;return i>0&&(l=primitives.circle({center:[g,p],segments:n,radius:i}),"path"===c&&(l=geometries.path2.fromPoints({closed:!0},geometries.geom2.toPoints(l)))),l},ellipse:(e,t,s,a,o,r,n)=>{const g=cagLengthX(e.rx,t,s),p=cagLengthY(e.ry,t,a),i=cagLengthX(e.cx,t,s),l=0-cagLengthY(e.cy,t,a);let h;return g>0&&p>0&&(h=primitives.ellipse({center:[i,l],segments:n,radius:[g,p]}),"path"===c&&(h=geometries.path2.fromPoints({closed:!0},geometries.geom2.toPoints(h)))),h},line:(e,t,s,a,o)=>{const r=cagLengthX(e.x1,t,s),n=0-cagLengthY(e.y1,t,a),g=cagLengthX(e.x2,t,s),c=0-cagLengthY(e.y2,t,a);return primitives.line([[r,n],[g,c]])},polygon:(e,t,s,a)=>{const o=[];for(let r=0;r{const r=[];for(let o=0;o{const g=expandPath(e,t,s,a,o,r,n,i);return Object.entries(g).sort((e,t)=>e[0].localeCompare(t[0])).map(e=>{const t=e[1];if("geom2"===c&&t.isClosed){const e=geometries.path2.toPoints(t).slice();return e.push(e[0]),geometries.geom2.fromPoints(e)}return t})}}[e.type](e,a,o,r,n,g,p)};module.exports=shapesMapGeometry;const appendPoints=(e,t)=>t?geometries.path2.appendPoints(e,t):geometries.path2.fromPoints({},e),expandPath=(e,t,s,a,o,r,n,g)=>{const c={};let p=0,i=0,l=0,h=0,m=0,F="path"+m,v=!1,d=0,f=0,P=0,u=0;const L=()=>{F="path"+ ++m,v=!1},k=()=>{c[F]||(c[F]=geometries.path2.fromPoints({},[]))};for(let s=0;s=r+2&&(l+=parseFloat(o[r++]),h+=parseFloat(o[r++]),L(),c[F]=appendPoints([svg2cag([l,h],t)]),p=l,i=h);o.length>=r+2;)l+=parseFloat(o[r++]),h+=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"M":for(o.length>=r+2&&(l=parseFloat(o[r++]),h=parseFloat(o[r++]),L(),c[F]=appendPoints([svg2cag([l,h],t)]),p=l,i=h);o.length>=r+2;)l=parseFloat(o[r++]),h=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"a":for(;o.length>=r+7;){const e=parseFloat(o[r++]),s=parseFloat(o[r++]),a=0-.017453292519943295*parseFloat(o[r++]),g="1"===o[r++],p="1"===o[r++];l+=parseFloat(o[r++]),h+=parseFloat(o[r++]),k(),c[F]=geometries.path2.appendArc({segments:n,endpoint:svg2cag([l,h],t),radius:svg2cag([e,s],t),xaxisrotation:a,clockwise:p,large:g},c[F])}break;case"A":for(;o.length>=r+7;){const e=parseFloat(o[r++]),s=parseFloat(o[r++]),a=0-.017453292519943295*parseFloat(o[r++]),g="1"===o[r++],p="1"===o[r++];l=parseFloat(o[r++]),h=parseFloat(o[r++]),k(),c[F]=geometries.path2.appendArc({segments:n,endpoint:svg2cag([l,h],t),radius:svg2cag([e,s],t),xaxisrotation:a,clockwise:p,large:g},c[F])}break;case"c":for(;o.length>=r+6;){const e=l+parseFloat(o[r++]),s=h+parseFloat(o[r++]);d=l+parseFloat(o[r++]),f=h+parseFloat(o[r++]),l+=parseFloat(o[r++]),h+=parseFloat(o[r++]),k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag([e,s],t),svg2cag([d,f],t),svg2cag([l,h],t)]},c[F]);const a=reflect(d,f,l,h);d=a[0],f=a[1]}break;case"C":for(;o.length>=r+6;){const e=parseFloat(o[r++]),s=parseFloat(o[r++]);d=parseFloat(o[r++]),f=parseFloat(o[r++]),l=parseFloat(o[r++]),h=parseFloat(o[r++]),k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag([e,s],t),svg2cag([d,f],t),svg2cag([l,h],t)]},c[F]);const a=reflect(d,f,l,h);d=a[0],f=a[1]}break;case"q":for(;o.length>=r+4;){const e=[l,h];P=l+parseFloat(o[r++]),u=h+parseFloat(o[r++]),l+=parseFloat(o[r++]),h+=parseFloat(o[r++]);const s=[e[0]+2/3*(P-e[0]),e[1]+2/3*(u-e[1])],a=[s[0]+1/3*(l-e[0]),s[1]+1/3*(h-e[1])];k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag(s,t),svg2cag(a,t),svg2cag([l,h],t)]},c[F]);const g=reflect(P,u,l,h);P=g[0],u=g[1]}break;case"Q":for(;o.length>=r+4;){const e=[l,h];P=parseFloat(o[r++]),u=parseFloat(o[r++]),l=parseFloat(o[r++]),h=parseFloat(o[r++]);const s=[e[0]+2/3*(P-e[0]),e[1]+2/3*(u-e[1])],a=[s[0]+1/3*(l-e[0]),s[1]+1/3*(h-e[1])];k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag(s,t),svg2cag(a,t),svg2cag([l,h],t)]},c[F]);const g=reflect(P,u,l,h);P=g[0],u=g[1]}break;case"t":for(;o.length>=r+2;){const e=[l,h];l+=parseFloat(o[r++]),h+=parseFloat(o[r++]);const s=[e[0]+2/3*(P-e[0]),e[1]+2/3*(u-e[1])],a=[s[0]+1/3*(l-e[0]),s[1]+1/3*(h-e[1])];k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag(s,t),svg2cag(a,t),svg2cag([l,h],t)]},c[F]);const g=reflect(P,u,l,h);P=g[0],u=g[1]}break;case"T":for(;o.length>=r+2;){const e=[l,h];l=parseFloat(o[r++]),h=parseFloat(o[r++]);const s=[e[0]+2/3*(P-e[0]),e[1]+2/3*(u-e[1])],a=[s[0]+1/3*(l-e[0]),s[1]+1/3*(h-e[1])];k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag(s,t),svg2cag(a,t),svg2cag([l,h],t)]},c[F]);const g=reflect(P,u,l,h);P=g[0],u=g[1]}break;case"s":for(;o.length>=r+4;){const e=d,s=f;d=l+parseFloat(o[r++]),f=h+parseFloat(o[r++]),l+=parseFloat(o[r++]),h+=parseFloat(o[r++]),k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag([e,s],t),svg2cag([d,f],t),svg2cag([l,h],t)]},c[F]);const a=reflect(d,f,l,h);d=a[0],f=a[1]}break;case"S":for(;o.length>=r+4;){const e=d,s=f;d=parseFloat(o[r++]),f=parseFloat(o[r++]),l=parseFloat(o[r++]),h=parseFloat(o[r++]),k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag([e,s],t),svg2cag([d,f],t),svg2cag([l,h],t)]},c[F]);const a=reflect(d,f,l,h);d=a[0],f=a[1]}break;case"h":for(;o.length>=r+1;)l+=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"H":for(;o.length>=r+1;)l=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"l":for(;o.length>=r+2;)l+=parseFloat(o[r++]),h+=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"L":for(;o.length>=r+2;)l=parseFloat(o[r++]),h=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"v":for(;o.length>=r+1;)h+=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"V":for(;o.length>=r+1;)h=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"z":case"Z":c[F]=geometries.path2.close(c[F]),l=p,h=i,v=!0;break;default:console.log("Warning: Unknow PATH command ["+a.c+"]")}const m=e=>"z"===e||"Z"===e;if(!0!==v&&c[F]&&c[F].isClosed){let t=e.commands[s+1];if(t&&!m(t.c))if("trim"===g)for(;t&&!m(t.c);)s++,t=e.commands[s+1];else{if("split"!==g)throw new Error(`Malformed svg path at ${e.position[0]}:${a.pos}. Path closed itself with command #${s} ${a.c}${o.join(" ")}`);L()}}}return c}; },{"./helpers":93,"@jscad/modeling":216}],96:[function(require,module,exports){ @@ -602,7 +602,7 @@ const{geometries:geometries,maths:maths,measurements:measurements,utils:utils}=r },{}],100:[function(require,module,exports){ module.exports={ "name": "@jscad/svg-serializer", - "version": "2.3.15", + "version": "2.3.16", "description": "SVG Serializer for JSCAD", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -634,7 +634,7 @@ module.exports={ ], "license": "MIT", "dependencies": { - "@jscad/modeling": "2.12.2", + "@jscad/modeling": "2.12.3", "onml": "1.3.0" }, "devDependencies": { @@ -659,7 +659,7 @@ module.exports={ },{"xmlchars/xml/1.0/ed5":101,"xmlchars/xml/1.1/ed2":102,"xmlchars/xmlns/1.0/ed3":103}],105:[function(require,module,exports){ module.exports={ "name": "@jscad/x3d-deserializer", - "version": "2.2.7", + "version": "2.2.8", "description": "X3D Deserializer for JSCAD", "repository": "https://github.com/jscad/OpenJSCAD.org/", "main": "src/index.js", @@ -686,7 +686,7 @@ module.exports={ }, "dependencies": { "@jscad/array-utils": "2.1.4", - "@jscad/modeling": "2.12.2", + "@jscad/modeling": "2.12.3", "saxes": "5.0.1" }, "devDependencies": { @@ -710,7 +710,7 @@ const version=require("../package.json").version,translate=require("./translate" },{"../package.json":105,"./instantiate":110,"./translate":117}],110:[function(require,module,exports){ const{flatten:flatten}=require("@jscad/array-utils"),parse=require("./parse"),instantiateDefinitions=require("./instantiateDefinitions"),{x3dTypes:x3dTypes}=require("./objects"),instantiate=(t,e)=>{const s={pxPmm:require("./constants").pxPmm};t=Object.assign({},s,t);const{pxPmm:a}=t;t&&t.statusCallback&&t.statusCallback({progress:0});const{x3dObj:n}=parse(e,a);if(n.definition!==x3dTypes.X3D||!n.objects)throw new Error("X3D malformed");if(n.objects.length<1||n.objects[0].definition!==x3dTypes.SCENE)throw new Error("X3D did not define a SCENE");t&&t.statusCallback&&t.statusCallback({progress:50});const i=n.objects[0].objects;let r=instantiateDefinitions(t,i);return t.flatten&&(r=flatten(r)),t&&t.statusCallback&&t.statusCallback({progress:100}),r};module.exports=instantiate; -},{"./constants":106,"./instantiateDefinitions":111,"./objects":115,"./parse":116,"@jscad/array-utils":531}],111:[function(require,module,exports){ +},{"./constants":106,"./instantiateDefinitions":111,"./objects":115,"./parse":116,"@jscad/array-utils":532}],111:[function(require,module,exports){ const{colors:colors,transforms:transforms}=require("@jscad/modeling"),createTransform=require("./createTransform"),{x3dTypes:x3dTypes}=require("./objects"),{findColor:findColor}=require("./translateHelpers"),instantiatePrimitive=require("./instantiatePrimitive"),{instantiateLine:instantiateLine}=require("./instantiateLine"),{instantiateMesh:instantiateMesh}=require("./instantiateMesh"),instantiatedList=new Map,instantiateTransform=(t,n)=>{const i=n.objects.map(n=>instantiateDefinition(t,n)).filter(t=>null!=t);if(0===i.length)return null;const e=createTransform(n.center,n.rotation,n.scale,n.scaleOrientation,n.translation);return i.map(t=>{const n=t.color;return t=transforms.transform(e,t),n&&(t.color=n),t})},instantiateShape=(t,n)=>{const i=n.objects,e=findColor(i,t);let a=instantiatePrimitive(t,i);return a||(a=instantiateMesh(t,i)),a||(a=instantiateLine(t,i)),a||(a=null),a&&e&&(a=colors.colorize(e,a)),a},instantiateGroup=(t,n)=>{const i=n.objects.map(n=>instantiateDefinition(t,n)).filter(t=>null!=t);return 0===i.length?null:i},instantiateDefinition=(t,n)=>{let i;switch(n.definition){case x3dTypes.TRANSFORM:i=instantiateTransform(t,n);break;case x3dTypes.SHAPE:i=instantiateShape(t,n);break;case x3dTypes.GROUP:i=instantiateGroup(t,n);break;default:console.log("WARNING: unknown definition: "+n.definition)}return i},instantiateDefinitions=(t,n)=>{const i=n.map(n=>instantiateDefinition(t,n)).filter(t=>null!=t);return instantiatedList.clear(),i};module.exports=instantiateDefinitions; },{"./createTransform":107,"./instantiateLine":112,"./instantiateMesh":113,"./instantiatePrimitive":114,"./objects":115,"./translateHelpers":119,"@jscad/modeling":216}],112:[function(require,module,exports){ @@ -752,13 +752,13 @@ const{geometries:geometries}=require("@jscad/modeling"),{geom3:geom3,poly3:poly3 },{}],124:[function(require,module,exports){ const{geometries:geometries,modifiers:modifiers}=require("@jscad/modeling"),{geom2:geom2,geom3:geom3,path2:path2,poly2:poly2,poly3:poly3}=geometries,{flatten:flatten}=require("@jscad/array-utils"),stringify=require("onml/lib/stringify"),mimeType="model/x3d+xml",defNames=new Map,serialize=(e,...o)=>{if(e=Object.assign({},{color:[0,0,1,1],shininess:8/256,smooth:!1,decimals:1e3,metadata:!0,unit:"millimeter",statusCallback:null},e),0===(o=(o=flatten(o)).filter(e=>geom3.isA(e)||geom2.isA(e)||path2.isA(e))).length)throw new Error("expected one or more geom3/geom2/path2 objects");e.statusCallback&&e.statusCallback({progress:0});let t=["X3D",{profile:"Interchange",version:"3.3","xmlns:xsd":"http://www.w3.org/2001/XMLSchema-instance","xsd:noNamespaceSchemaLocation":"http://www.web3d.org/specifications/x3d-3.3.xsd"}];e.metadata?t.push(["head",{},["meta",{name:"creator",content:"Created by JSCAD"}],["meta",{name:"reference",content:"https://www.openjscad.xyz"}],["meta",{name:"created",content:(new Date).toISOString()}]]):t.push(["head",{},["meta",{name:"creator",content:"Created by JSCAD"}]]),t=t.concat(convertObjects(o,e));const r=`\n${stringify(t,2)}`;return e&&e.statusCallback&&e.statusCallback({progress:100}),[r]},convertObjects=(e,o)=>{const t=[];return e.forEach((r,s)=>{if(o.statusCallback&&o.statusCallback({progress:100*s/e.length}),geom3.isA(r)){r=modifiers.generalize({snap:!0,triangulate:!0},r),geom3.toPolygons(r).length>0&&t.push(convertGeom3(r,o))}geom2.isA(r)&&t.push(convertGeom2(r,o)),path2.isA(r)&&t.push(convertPath2(r,o))}),[["Scene",{},["Transform",{rotation:"1 0 0 -1.5708"},...t]]]},convertPath2=(e,o)=>{const t=path2.toPoints(e).slice();t.length>1&&e.isClosed&&t.push(t[0]);const r=["Shape",shapeAttributes(e),convertPolyline2D(poly2.create(t),o)];return e.color&&r.push(convertAppearance(e,"emissiveColor",o)),r},convertGeom2=(e,o)=>{const t=geom2.toOutlines(e),r=["Group",{}];return t.forEach(t=>{t.length>1&&t.push(t[0]);const s=["Shape",shapeAttributes(e),convertPolyline2D(poly2.create(t),o)];e.color&&s.push(convertAppearance(e,"emissiveColor",o)),r.push(s)}),r},shapeAttributes=(e,o={})=>(e.id&&Object.assign(o,{DEF:checkDefName(e.id)}),o),checkDefName=e=>{const o=defNames.get(e)||0;return defNames.set(e,o+1),o>0&&console.warn(`Warning: object.id set as DEF but not unique. ${e} set ${o+1} times.`),e},convertPolyline2D=(e,o)=>{return["Polyline2D",{lineSegments:e.vertices.map(e=>`${e[0]} ${e[1]}`).join(" ")}]},convertAppearance=(e,o,t)=>{const r={[o]:e.color.slice(0,3).join(" "),transparency:roundToDecimals(1-e.color[3],t)};return"diffuseColor"===o&&Object.assign(r,{specularColor:"0.2 0.2 0.2",shininess:t.shininess}),["Appearance",["Material",r]]},convertGeom3=(e,o)=>{const t=["Shape",shapeAttributes(e),convertMesh(e,o)];let r=["Appearance",{},["Material"]];return e.color&&(r=convertAppearance(e,"diffuseColor",o)),t.push(r),t},convertMesh=(e,o)=>{const t=convertToTriangles(e,o),r=polygons2coordinates(t,o),s=r[0].join(" "),n=r[1].join(" "),a=r[2].join(" "),c=["IndexedTriangleSet",{ccw:"true",colorPerVertex:"false",normalPerVertex:o.smooth,solid:"false",index:s},["Coordinate",{point:n}]];return e.color||c.push(["Color",{color:a}]),c},convertToTriangles=(e,o)=>{const t=[];return geom3.toPolygons(e).forEach(r=>{const s=r.vertices[0];for(let n=r.vertices.length-3;n>=0;n--){const a=poly3.fromPoints([s,r.vertices[n+1],r.vertices[n+2]]);let c=o.color;e.color&&(c=e.color),r.color&&(c=r.color),a.color=c,t.push(a)}}),t},convertToColor=(e,o)=>{let t=o.color;return e.color&&(t=e.color),`${t[0]} ${t[1]} ${t[2]}`},roundToDecimals=(e,o)=>Math.round(e*o.decimals)/o.decimals,polygons2coordinates=(e,o)=>{const t=[],r=[],s=[],n=new Map;return e.forEach(e=>{const a=[],c=e.vertices.length;for(let t=0;tcssColors[o.toLowerCase()];module.exports=colorNameToRgb; },{"./cssColors":127}],126:[function(require,module,exports){ const flatten=require("../utils/flatten"),geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),path2=require("../geometries/path2"),poly3=require("../geometries/poly3"),colorGeom2=(o,r)=>{const e=geom2.clone(r);return e.color=o,e},colorGeom3=(o,r)=>{const e=geom3.clone(r);return e.color=o,e},colorPath2=(o,r)=>{const e=path2.clone(r);return e.color=o,e},colorPoly3=(o,r)=>{const e=poly3.clone(r);return e.color=o,e},colorize=(o,...r)=>{if(!Array.isArray(o))throw new Error("color must be an array");if(o.length<3)throw new Error("color must contain R, G and B values");if(3===o.length&&(o=[o[0],o[1],o[2],1]),0===(r=flatten(r)).length)throw new Error("wrong number of arguments");const e=r.map(r=>geom2.isA(r)?colorGeom2(o,r):geom3.isA(r)?colorGeom3(o,r):path2.isA(r)?colorPath2(o,r):poly3.isA(r)?colorPoly3(o,r):(r.color=o,r));return 1===e.length?e[0]:e};module.exports=colorize; -},{"../geometries/geom2":149,"../geometries/geom3":165,"../geometries/path2":186,"../geometries/poly3":203,"../utils/flatten":521}],127:[function(require,module,exports){ +},{"../geometries/geom2":149,"../geometries/geom3":165,"../geometries/path2":186,"../geometries/poly3":203,"../utils/flatten":522}],127:[function(require,module,exports){ const cssColors={black:[0,0,0],silver:[192/255,192/255,192/255],gray:[128/255,128/255,128/255],white:[1,1,1],maroon:[128/255,0,0],red:[1,0,0],purple:[128/255,0,128/255],fuchsia:[1,0,1],green:[0,128/255,0],lime:[0,1,0],olive:[128/255,128/255,0],yellow:[1,1,0],navy:[0,0,128/255],blue:[0,0,1],teal:[0,128/255,128/255],aqua:[0,1,1],aliceblue:[240/255,248/255,1],antiquewhite:[250/255,235/255,215/255],aquamarine:[127/255,1,212/255],azure:[240/255,1,1],beige:[245/255,245/255,220/255],bisque:[1,228/255,196/255],blanchedalmond:[1,235/255,205/255],blueviolet:[138/255,43/255,226/255],brown:[165/255,42/255,42/255],burlywood:[222/255,184/255,135/255],cadetblue:[95/255,158/255,160/255],chartreuse:[127/255,1,0],chocolate:[210/255,105/255,30/255],coral:[1,127/255,80/255],cornflowerblue:[100/255,149/255,237/255],cornsilk:[1,248/255,220/255],crimson:[220/255,20/255,60/255],cyan:[0,1,1],darkblue:[0,0,139/255],darkcyan:[0,139/255,139/255],darkgoldenrod:[184/255,134/255,11/255],darkgray:[169/255,169/255,169/255],darkgreen:[0,100/255,0],darkgrey:[169/255,169/255,169/255],darkkhaki:[189/255,183/255,107/255],darkmagenta:[139/255,0,139/255],darkolivegreen:[85/255,107/255,47/255],darkorange:[1,140/255,0],darkorchid:[.6,50/255,.8],darkred:[139/255,0,0],darksalmon:[233/255,150/255,122/255],darkseagreen:[143/255,188/255,143/255],darkslateblue:[72/255,61/255,139/255],darkslategray:[47/255,79/255,79/255],darkslategrey:[47/255,79/255,79/255],darkturquoise:[0,206/255,209/255],darkviolet:[148/255,0,211/255],deeppink:[1,20/255,147/255],deepskyblue:[0,191/255,1],dimgray:[105/255,105/255,105/255],dimgrey:[105/255,105/255,105/255],dodgerblue:[30/255,144/255,1],firebrick:[178/255,34/255,34/255],floralwhite:[1,250/255,240/255],forestgreen:[34/255,139/255,34/255],gainsboro:[220/255,220/255,220/255],ghostwhite:[248/255,248/255,1],gold:[1,215/255,0],goldenrod:[218/255,165/255,32/255],greenyellow:[173/255,1,47/255],grey:[128/255,128/255,128/255],honeydew:[240/255,1,240/255],hotpink:[1,105/255,180/255],indianred:[205/255,92/255,92/255],indigo:[75/255,0,130/255],ivory:[1,1,240/255],khaki:[240/255,230/255,140/255],lavender:[230/255,230/255,250/255],lavenderblush:[1,240/255,245/255],lawngreen:[124/255,252/255,0],lemonchiffon:[1,250/255,205/255],lightblue:[173/255,216/255,230/255],lightcoral:[240/255,128/255,128/255],lightcyan:[224/255,1,1],lightgoldenrodyellow:[250/255,250/255,210/255],lightgray:[211/255,211/255,211/255],lightgreen:[144/255,238/255,144/255],lightgrey:[211/255,211/255,211/255],lightpink:[1,182/255,193/255],lightsalmon:[1,160/255,122/255],lightseagreen:[32/255,178/255,170/255],lightskyblue:[135/255,206/255,250/255],lightslategray:[119/255,136/255,.6],lightslategrey:[119/255,136/255,.6],lightsteelblue:[176/255,196/255,222/255],lightyellow:[1,1,224/255],limegreen:[50/255,205/255,50/255],linen:[250/255,240/255,230/255],magenta:[1,0,1],mediumaquamarine:[.4,205/255,170/255],mediumblue:[0,0,205/255],mediumorchid:[186/255,85/255,211/255],mediumpurple:[147/255,112/255,219/255],mediumseagreen:[60/255,179/255,113/255],mediumslateblue:[123/255,104/255,238/255],mediumspringgreen:[0,250/255,154/255],mediumturquoise:[72/255,209/255,.8],mediumvioletred:[199/255,21/255,133/255],midnightblue:[25/255,25/255,112/255],mintcream:[245/255,1,250/255],mistyrose:[1,228/255,225/255],moccasin:[1,228/255,181/255],navajowhite:[1,222/255,173/255],oldlace:[253/255,245/255,230/255],olivedrab:[107/255,142/255,35/255],orange:[1,165/255,0],orangered:[1,69/255,0],orchid:[218/255,112/255,214/255],palegoldenrod:[238/255,232/255,170/255],palegreen:[152/255,251/255,152/255],paleturquoise:[175/255,238/255,238/255],palevioletred:[219/255,112/255,147/255],papayawhip:[1,239/255,213/255],peachpuff:[1,218/255,185/255],peru:[205/255,133/255,63/255],pink:[1,192/255,203/255],plum:[221/255,160/255,221/255],powderblue:[176/255,224/255,230/255],rosybrown:[188/255,143/255,143/255],royalblue:[65/255,105/255,225/255],saddlebrown:[139/255,69/255,19/255],salmon:[250/255,128/255,114/255],sandybrown:[244/255,164/255,96/255],seagreen:[46/255,139/255,87/255],seashell:[1,245/255,238/255],sienna:[160/255,82/255,45/255],skyblue:[135/255,206/255,235/255],slateblue:[106/255,90/255,205/255],slategray:[112/255,128/255,144/255],slategrey:[112/255,128/255,144/255],snow:[1,250/255,250/255],springgreen:[0,1,127/255],steelblue:[70/255,130/255,180/255],tan:[210/255,180/255,140/255],thistle:[216/255,191/255,216/255],tomato:[1,99/255,71/255],turquoise:[64/255,224/255,208/255],violet:[238/255,130/255,238/255],wheat:[245/255,222/255,179/255],whitesmoke:[245/255,245/255,245/255],yellowgreen:[154/255,205/255,50/255]};module.exports=cssColors; },{}],128:[function(require,module,exports){ @@ -767,10 +767,10 @@ const hexToRgb=t=>{if((t=t.replace("#","")).length<6)throw new Error("the given },{}],129:[function(require,module,exports){ const flatten=require("../utils/flatten"),hueToColorComponent=require("./hueToColorComponent"),hslToRgb=(...o)=>{if((o=flatten(o)).length<3)throw new Error("values must contain H, S and L values");const e=o[0],n=o[1],t=o[2];let r=t,l=t,u=t;if(0!==n){const o=t<.5?t*(1+n):t+n-t*n,h=2*t-o;r=hueToColorComponent(h,o,e+1/3),l=hueToColorComponent(h,o,e),u=hueToColorComponent(h,o,e-1/3)}if(o.length>3){return[r,l,u,o[3]]}return[r,l,u]};module.exports=hslToRgb; -},{"../utils/flatten":521,"./hueToColorComponent":131}],130:[function(require,module,exports){ +},{"../utils/flatten":522,"./hueToColorComponent":131}],130:[function(require,module,exports){ const flatten=require("../utils/flatten"),hsvToRgb=(...e)=>{if((e=flatten(e)).length<3)throw new Error("values must contain H, S and V values");const t=e[0],a=e[1],r=e[2];let s=0,n=0,o=0;const c=Math.floor(6*t),l=6*t-c,u=r*(1-a),b=r*(1-l*a),h=r*(1-(1-l)*a);switch(c%6){case 0:s=r,n=h,o=u;break;case 1:s=b,n=r,o=u;break;case 2:s=u,n=r,o=h;break;case 3:s=u,n=b,o=r;break;case 4:s=h,n=u,o=r;break;case 5:s=r,n=u,o=b}if(e.length>3){return[s,n,o,e[3]]}return[s,n,o]};module.exports=hsvToRgb; -},{"../utils/flatten":521}],131:[function(require,module,exports){ +},{"../utils/flatten":522}],131:[function(require,module,exports){ const hueToColorComponent=(o,e,n)=>(n<0&&(n+=1),n>1&&(n-=1),n<1/6?o+6*(e-o)*n:n<.5?e:n<2/3?o+(e-o)*(2/3-n)*6:o);module.exports=hueToColorComponent; },{}],132:[function(require,module,exports){ @@ -779,13 +779,13 @@ module.exports={colorize:require("./colorize"),colorNameToRgb:require("./colorNa },{"./colorNameToRgb":125,"./colorize":126,"./cssColors":127,"./hexToRgb":128,"./hslToRgb":129,"./hsvToRgb":130,"./hueToColorComponent":131,"./rgbToHex":133,"./rgbToHsl":134,"./rgbToHsv":135}],133:[function(require,module,exports){ const flatten=require("../utils/flatten"),rgbToHex=(...t)=>{if((t=flatten(t)).length<3)throw new Error("values must contain R, G and B values");const e=255*t[0],r=255*t[1],n=255*t[2];let o=`#${Number(16777216+65536*e+256*r+n).toString(16).substring(1,7)}`;return t.length>3&&(o+=Number(255*t[3]).toString(16)),o};module.exports=rgbToHex; -},{"../utils/flatten":521}],134:[function(require,module,exports){ +},{"../utils/flatten":522}],134:[function(require,module,exports){ const flatten=require("../utils/flatten"),rgbToHsl=(...t)=>{if((t=flatten(t)).length<3)throw new Error("values must contain R, G and B values");const e=t[0],n=t[1],s=t[2],a=Math.max(e,n,s),r=Math.min(e,n,s);let l,o;const c=(a+r)/2;if(a===r)l=o=0;else{const t=a-r;switch(o=c>.5?t/(2-a-r):t/(a+r),a){case e:l=(n-s)/t+(n3){return[l,o,c,t[3]]}return[l,o,c]};module.exports=rgbToHsl; -},{"../utils/flatten":521}],135:[function(require,module,exports){ +},{"../utils/flatten":522}],135:[function(require,module,exports){ const flatten=require("../utils/flatten"),rgbToHsv=(...e)=>{if((e=flatten(e)).length<3)throw new Error("values must contain R, G and B values");const t=e[0],a=e[1],n=e[2],r=Math.max(t,a,n),s=Math.min(t,a,n);let l;const o=r,c=r-s,i=0===r?0:c/r;if(r===s)l=0;else{switch(r){case t:l=(a-n)/c+(a3){return[l,i,o,e[3]]}return[l,i,o]};module.exports=rgbToHsv; -},{"../utils/flatten":521}],136:[function(require,module,exports){ +},{"../utils/flatten":522}],136:[function(require,module,exports){ const lengths=require("./lengths"),arcLengthToT=(e,t)=>{const{distance:s,segments:n}=Object.assign({},{distance:0,segments:100},e),o=lengths(n,t);let r=0,c=n;for(;r<=c;){const e=Math.floor(r+(c-r)/2),t=o[e]-s;if(t<0)r=e+1;else{if(!(t>0)){c=e;break}c=e-1}}const g=c;if(o[g]===s)return g/n;const a=o[g];return(g+(s-a)/(o[g+1]-a))/n};module.exports=arcLengthToT; },{"./lengths":140}],137:[function(require,module,exports){ @@ -872,7 +872,7 @@ const poly3=require("../poly3"),create=require("./create"),fromPoints=r=>{if(!Ar },{"../poly3":203,"./create":161}],164:[function(require,module,exports){ const quickhull=require("../../operations/hulls/quickhull"),create=require("./create"),poly3=require("../poly3"),fromPointsConvex=r=>{if(!Array.isArray(r))throw new Error("the given points must be an array");const e=quickhull(r,{skipTriangulation:!0}).map(e=>{const o=e.map(e=>r[e]);return poly3.create(o)});return create(e)};module.exports=fromPointsConvex; -},{"../../operations/hulls/quickhull":471,"../poly3":203,"./create":161}],165:[function(require,module,exports){ +},{"../../operations/hulls/quickhull":472,"../poly3":203,"./create":161}],165:[function(require,module,exports){ module.exports={clone:require("./clone"),create:require("./create"),fromPointsConvex:require("./fromPointsConvex"),fromPoints:require("./fromPoints"),fromCompactBinary:require("./fromCompactBinary"),invert:require("./invert"),isA:require("./isA"),toPoints:require("./toPoints"),toPolygons:require("./toPolygons"),toString:require("./toString"),toCompactBinary:require("./toCompactBinary"),transform:require("./transform"),validate:require("./validate")}; },{"./clone":160,"./create":161,"./fromCompactBinary":162,"./fromPoints":163,"./fromPointsConvex":164,"./invert":166,"./isA":167,"./toCompactBinary":168,"./toPoints":169,"./toPolygons":170,"./toString":171,"./transform":172,"./validate":173}],166:[function(require,module,exports){ @@ -1028,7 +1028,7 @@ const signedDistanceToPoint=require("../../maths/plane/signedDistanceToPoint"),{ },{"../../maths/constants":218,"../../maths/plane/signedDistanceToPoint":289,"../../maths/vec3":346,"./isA":205,"./isConvex":206,"./measureArea":207,"./plane":211}],216:[function(require,module,exports){ module.exports={colors:require("./colors"),curves:require("./curves"),geometries:require("./geometries"),maths:require("./maths"),measurements:require("./measurements"),primitives:require("./primitives"),text:require("./text"),utils:require("./utils"),booleans:require("./operations/booleans"),expansions:require("./operations/expansions"),extrusions:require("./operations/extrusions"),hulls:require("./operations/hulls"),modifiers:require("./operations/modifiers"),transforms:require("./operations/transforms")}; -},{"./colors":132,"./curves":143,"./geometries":174,"./maths":219,"./measurements":376,"./operations/booleans":390,"./operations/expansions":419,"./operations/extrusions":442,"./operations/hulls":464,"./operations/modifiers":475,"./operations/transforms":485,"./primitives":501,"./text":515,"./utils":523}],217:[function(require,module,exports){ +},{"./colors":132,"./curves":143,"./geometries":174,"./maths":219,"./measurements":376,"./operations/booleans":390,"./operations/expansions":419,"./operations/extrusions":442,"./operations/hulls":465,"./operations/modifiers":476,"./operations/transforms":486,"./primitives":502,"./text":516,"./utils":524}],217:[function(require,module,exports){ const mat4=require("./mat4"),vec2=require("./vec2"),vec3=require("./vec3"),OrthoNormalBasis=function(e,t){arguments.length<2&&(t=vec3.orthogonal(vec3.create(),e)),this.v=vec3.normalize(vec3.create(),vec3.cross(vec3.create(),e,t)),this.u=vec3.cross(vec3.create(),this.v,e),this.plane=e,this.planeorigin=vec3.scale(vec3.create(),e,e[3])};OrthoNormalBasis.GetCartesian=function(e,t){const i=e+"/"+t;let s,n;if("X/Y"===i)s=[0,0,1],n=[1,0,0];else if("Y/-X"===i)s=[0,0,1],n=[0,1,0];else if("-X/-Y"===i)s=[0,0,1],n=[-1,0,0];else if("-Y/X"===i)s=[0,0,1],n=[0,-1,0];else if("-X/Y"===i)s=[0,0,-1],n=[-1,0,0];else if("-Y/-X"===i)s=[0,0,-1],n=[0,-1,0];else if("X/-Y"===i)s=[0,0,-1],n=[1,0,0];else if("Y/X"===i)s=[0,0,-1],n=[0,1,0];else if("X/Z"===i)s=[0,-1,0],n=[1,0,0];else if("Z/-X"===i)s=[0,-1,0],n=[0,0,1];else if("-X/-Z"===i)s=[0,-1,0],n=[-1,0,0];else if("-Z/X"===i)s=[0,-1,0],n=[0,0,-1];else if("-X/Z"===i)s=[0,1,0],n=[-1,0,0];else if("-Z/-X"===i)s=[0,1,0],n=[0,0,-1];else if("X/-Z"===i)s=[0,1,0],n=[1,0,0];else if("Z/X"===i)s=[0,1,0],n=[0,0,1];else if("Y/Z"===i)s=[1,0,0],n=[0,1,0];else if("Z/-Y"===i)s=[1,0,0],n=[0,0,1];else if("-Y/-Z"===i)s=[1,0,0],n=[0,-1,0];else if("-Z/Y"===i)s=[1,0,0],n=[0,0,-1];else if("-Y/Z"===i)s=[-1,0,0],n=[0,-1,0];else if("-Z/-Y"===i)s=[-1,0,0],n=[0,0,-1];else if("Y/-Z"===i)s=[-1,0,0],n=[0,1,0];else{if("Z/Y"!==i)throw new Error("OrthoNormalBasis.GetCartesian: invalid combination of axis identifiers. Should pass two string arguments from [X,Y,Z,-X,-Y,-Z], being two different axes.");s=[-1,0,0],n=[0,0,1]}return new OrthoNormalBasis(new Plane(new Vector3D(s),0),new Vector3D(n))},OrthoNormalBasis.Z0Plane=function(){const e=new Plane(new Vector3D([0,0,1]),0);return new OrthoNormalBasis(e,new Vector3D([1,0,0]))},OrthoNormalBasis.prototype={getProjectionMatrix:function(){return mat4.fromValues(this.u[0],this.v[0],this.plane[0],0,this.u[1],this.v[1],this.plane[1],0,this.u[2],this.v[2],this.plane[2],0,0,0,-this.plane[3],1)},getInverseProjectionMatrix:function(){const e=vec3.scale(vec3.create(),this.plane,this.plane[3]);return mat4.fromValues(this.u[0],this.u[1],this.u[2],0,this.v[0],this.v[1],this.v[2],0,this.plane[0],this.plane[1],this.plane[2],0,e[0],e[1],e[2],1)},to2D:function(e){return vec2.fromValues(vec3.dot(e,this.u),vec3.dot(e,this.v))},to3D:function(e){const t=vec3.scale(vec3.create(),this.u,e[0]),i=vec3.scale(vec3.create(),this.v,e[1]),s=vec3.add(t,t,this.planeorigin);return vec3.add(i,i,s)},line3Dto2D:function(e){const t=e.point,i=e.direction.plus(t),s=this.to2D(t),n=this.to2D(i);return Line2D.fromPoints(s,n)},line2Dto3D:function(e){const t=e.origin(),i=e.direction().plus(t),s=this.to3D(t),n=this.to3D(i);return Line3D.fromPoints(s,n)},transform:function(e){const t=this.plane.transform(e),i=this.u.transform(e),s=new Vector3D(0,0,0).transform(e),n=i.minus(s);return new OrthoNormalBasis(t,n)}},module.exports=OrthoNormalBasis; },{"./mat4":267,"./vec2":315,"./vec3":346}],218:[function(require,module,exports){ @@ -1511,40 +1511,40 @@ module.exports={measureAggregateArea:require("./measureAggregateArea"),measureAg },{"./measureAggregateArea":377,"./measureAggregateBoundingBox":378,"./measureAggregateEpsilon":379,"./measureAggregateVolume":380,"./measureArea":381,"./measureBoundingBox":382,"./measureBoundingSphere":383,"./measureCenter":384,"./measureCenterOfMass":385,"./measureDimensions":386,"./measureEpsilon":387,"./measureVolume":388}],377:[function(require,module,exports){ const flatten=require("../utils/flatten"),measureArea=require("./measureArea"),measureAggregateArea=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("measureAggregateArea: no geometries supplied");const r=measureArea(e);if(1===e.length)return r;return r.reduce((e,r)=>e+r,0)};module.exports=measureAggregateArea; -},{"../utils/flatten":521,"./measureArea":381}],378:[function(require,module,exports){ +},{"../utils/flatten":522,"./measureArea":381}],378:[function(require,module,exports){ const flatten=require("../utils/flatten"),vec3min=require("../maths/vec3/min"),vec3max=require("../maths/vec3/max"),measureBoundingBox=require("./measureBoundingBox"),measureAggregateBoundingBox=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("measureAggregateBoundingBox: no geometries supplied");const r=measureBoundingBox(e);if(1===e.length)return r;const u=[[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],[-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE]];return r.reduce((e,r)=>e=[vec3min(e[0],e[0],r[0]),vec3max(e[1],e[1],r[1])],u)};module.exports=measureAggregateBoundingBox; -},{"../maths/vec3/max":349,"../maths/vec3/min":350,"../utils/flatten":521,"./measureBoundingBox":382}],379:[function(require,module,exports){ +},{"../maths/vec3/max":349,"../maths/vec3/min":350,"../utils/flatten":522,"./measureBoundingBox":382}],379:[function(require,module,exports){ const flatten=require("../utils/flatten"),measureAggregateBoundingBox=require("./measureAggregateBoundingBox"),calculateEpsilonFromBounds=require("./calculateEpsilonFromBounds"),{geom2:geom2,geom3:geom3,path2:path2}=require("../geometries"),measureAggregateEpsilon=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("measureAggregateEpsilon: no geometries supplied");const o=measureAggregateBoundingBox(e);let r=0;return r=e.reduce((e,o)=>path2.isA(o)||geom2.isA(o)?Math.max(e,2):geom3.isA(o)?Math.max(e,3):0,r),calculateEpsilonFromBounds(o,r)};module.exports=measureAggregateEpsilon; -},{"../geometries":174,"../utils/flatten":521,"./calculateEpsilonFromBounds":375,"./measureAggregateBoundingBox":378}],380:[function(require,module,exports){ +},{"../geometries":174,"../utils/flatten":522,"./calculateEpsilonFromBounds":375,"./measureAggregateBoundingBox":378}],380:[function(require,module,exports){ const flatten=require("../utils/flatten"),measureVolume=require("./measureVolume"),measureAggregateVolume=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("measureAggregateVolume: no geometries supplied");const r=measureVolume(e);if(1===e.length)return r;return r.reduce((e,r)=>e+r,0)};module.exports=measureAggregateVolume; -},{"../utils/flatten":521,"./measureVolume":388}],381:[function(require,module,exports){ +},{"../utils/flatten":522,"./measureVolume":388}],381:[function(require,module,exports){ const flatten=require("../utils/flatten"),geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),path2=require("../geometries/path2"),poly3=require("../geometries/poly3"),cache=new WeakMap,measureAreaOfPath2=()=>0,measureAreaOfGeom2=e=>{let r=cache.get(e);if(r)return r;return r=geom2.toSides(e).reduce((e,r)=>e+(r[0][0]*r[1][1]-r[0][1]*r[1][0]),0),r*=.5,cache.set(e,r),r},measureAreaOfGeom3=e=>{let r=cache.get(e);if(r)return r;return r=geom3.toPolygons(e).reduce((e,r)=>e+poly3.measureArea(r),0),cache.set(e,r),r},measureArea=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");const r=e.map(e=>path2.isA(e)?0:geom2.isA(e)?measureAreaOfGeom2(e):geom3.isA(e)?measureAreaOfGeom3(e):0);return 1===r.length?r[0]:r};module.exports=measureArea; -},{"../geometries/geom2":149,"../geometries/geom3":165,"../geometries/path2":186,"../geometries/poly3":203,"../utils/flatten":521}],382:[function(require,module,exports){ +},{"../geometries/geom2":149,"../geometries/geom3":165,"../geometries/path2":186,"../geometries/poly3":203,"../utils/flatten":522}],382:[function(require,module,exports){ const flatten=require("../utils/flatten"),vec2=require("../maths/vec2"),vec3=require("../maths/vec3"),geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),path2=require("../geometries/path2"),poly3=require("../geometries/poly3"),cache=new WeakMap,measureBoundingBoxOfPath2=e=>{let o=cache.get(e);if(o)return o;const t=path2.toPoints(e);let n;n=0===t.length?vec2.create():vec2.clone(t[0]);let r=vec2.clone(n);return t.forEach(e=>{vec2.min(n,n,e),vec2.max(r,r,e)}),n=[n[0],n[1],0],r=[r[0],r[1],0],o=[n,r],cache.set(e,o),o},measureBoundingBoxOfGeom2=e=>{let o=cache.get(e);if(o)return o;const t=geom2.toPoints(e);let n;n=0===t.length?vec2.create():vec2.clone(t[0]);let r=vec2.clone(n);return t.forEach(e=>{vec2.min(n,n,e),vec2.max(r,r,e)}),n=[n[0],n[1],0],r=[r[0],r[1],0],o=[n,r],cache.set(e,o),o},measureBoundingBoxOfGeom3=e=>{let o=cache.get(e);if(o)return o;const t=geom3.toPolygons(e);let n=vec3.create();if(t.length>0){const e=poly3.toPoints(t[0]);vec3.copy(n,e[0])}let r=vec3.clone(n);return t.forEach(e=>{poly3.toPoints(e).forEach(e=>{vec3.min(n,n,e),vec3.max(r,r,e)})}),n=[n[0],n[1],n[2]],r=[r[0],r[1],r[2]],o=[n,r],cache.set(e,o),o},measureBoundingBox=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");const o=e.map(e=>path2.isA(e)?measureBoundingBoxOfPath2(e):geom2.isA(e)?measureBoundingBoxOfGeom2(e):geom3.isA(e)?measureBoundingBoxOfGeom3(e):[[0,0,0],[0,0,0]]);return 1===o.length?o[0]:o};module.exports=measureBoundingBox; -},{"../geometries/geom2":149,"../geometries/geom3":165,"../geometries/path2":186,"../geometries/poly3":203,"../maths/vec2":315,"../maths/vec3":346,"../utils/flatten":521}],383:[function(require,module,exports){ +},{"../geometries/geom2":149,"../geometries/geom3":165,"../geometries/path2":186,"../geometries/poly3":203,"../maths/vec2":315,"../maths/vec3":346,"../utils/flatten":522}],383:[function(require,module,exports){ const flatten=require("../utils/flatten"),vec2=require("../maths/vec2"),vec3=require("../maths/vec3"),geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),path2=require("../geometries/path2"),poly3=require("../geometries/poly3"),cacheOfBoundingSpheres=new WeakMap,measureBoundingSphereOfPath2=e=>{let t=cacheOfBoundingSpheres.get(e);if(void 0!==t)return t;const r=vec3.create();let o=0;const c=path2.toPoints(e);if(c.length>0){let e=0;const t=vec3.create();c.forEach(o=>{vec3.add(r,r,vec3.fromVec2(t,o,0)),e++}),vec3.scale(r,r,1/e),c.forEach(e=>{o=Math.max(o,vec2.squaredDistance(r,e))}),o=Math.sqrt(o)}return t=[r,o],cacheOfBoundingSpheres.set(e,t),t},measureBoundingSphereOfGeom2=e=>{let t=cacheOfBoundingSpheres.get(e);if(void 0!==t)return t;const r=vec3.create();let o=0;const c=geom2.toSides(e);if(c.length>0){let e=0;const t=vec3.create();c.forEach(o=>{vec3.add(r,r,vec3.fromVec2(t,o[0],0)),e++}),vec3.scale(r,r,1/e),c.forEach(e=>{o=Math.max(o,vec2.squaredDistance(r,e[0]))}),o=Math.sqrt(o)}return t=[r,o],cacheOfBoundingSpheres.set(e,t),t},measureBoundingSphereOfGeom3=e=>{let t=cacheOfBoundingSpheres.get(e);if(void 0!==t)return t;const r=vec3.create();let o=0;const c=geom3.toPolygons(e);if(c.length>0){let e=0;c.forEach(t=>{poly3.toPoints(t).forEach(t=>{vec3.add(r,r,t),e++})}),vec3.scale(r,r,1/e),c.forEach(e=>{poly3.toPoints(e).forEach(e=>{o=Math.max(o,vec3.squaredDistance(r,e))})}),o=Math.sqrt(o)}return t=[r,o],cacheOfBoundingSpheres.set(e,t),t},measureBoundingSphere=(...e)=>{const t=(e=flatten(e)).map(e=>path2.isA(e)?measureBoundingSphereOfPath2(e):geom2.isA(e)?measureBoundingSphereOfGeom2(e):geom3.isA(e)?measureBoundingSphereOfGeom3(e):[[0,0,0],0]);return 1===t.length?t[0]:t};module.exports=measureBoundingSphere; -},{"../geometries/geom2":149,"../geometries/geom3":165,"../geometries/path2":186,"../geometries/poly3":203,"../maths/vec2":315,"../maths/vec3":346,"../utils/flatten":521}],384:[function(require,module,exports){ +},{"../geometries/geom2":149,"../geometries/geom3":165,"../geometries/path2":186,"../geometries/poly3":203,"../maths/vec2":315,"../maths/vec3":346,"../utils/flatten":522}],384:[function(require,module,exports){ const flatten=require("../utils/flatten"),measureBoundingBox=require("./measureBoundingBox"),measureCenter=(...e)=>{const n=(e=flatten(e)).map(e=>{const n=measureBoundingBox(e);return[n[0][0]+(n[1][0]-n[0][0])/2,n[0][1]+(n[1][1]-n[0][1])/2,n[0][2]+(n[1][2]-n[0][2])/2]});return 1===n.length?n[0]:n};module.exports=measureCenter; -},{"../utils/flatten":521,"./measureBoundingBox":382}],385:[function(require,module,exports){ +},{"../utils/flatten":522,"./measureBoundingBox":382}],385:[function(require,module,exports){ const flatten=require("../utils/flatten"),vec3=require("../maths/vec3"),geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),cacheOfCenterOfMass=new WeakMap,measureCenterOfMassGeom2=e=>{let t=cacheOfCenterOfMass.get(e);if(void 0!==t)return t;const s=geom2.toSides(e);let r=0,c=0,a=0;if(s.length>0){for(let e=0;e{let t=cacheOfCenterOfMass.get(e);if(void 0!==t)return t;t=vec3.create();const s=geom3.toPolygons(e);if(0===s.length)return t;let r=0;const c=vec3.create();return s.forEach(e=>{const s=e.vertices;for(let e=0;e{const t=(e=flatten(e)).map(e=>geom2.isA(e)?measureCenterOfMassGeom2(e):geom3.isA(e)?measureCenterOfMassGeom3(e):[0,0,0]);return 1===t.length?t[0]:t};module.exports=measureCenterOfMass; -},{"../geometries/geom2":149,"../geometries/geom3":165,"../maths/vec3":346,"../utils/flatten":521}],386:[function(require,module,exports){ +},{"../geometries/geom2":149,"../geometries/geom3":165,"../maths/vec3":346,"../utils/flatten":522}],386:[function(require,module,exports){ const flatten=require("../utils/flatten"),measureBoundingBox=require("./measureBoundingBox"),measureDimensions=(...e)=>{const n=(e=flatten(e)).map(e=>{const n=measureBoundingBox(e);return[n[1][0]-n[0][0],n[1][1]-n[0][1],n[1][2]-n[0][2]]});return 1===n.length?n[0]:n};module.exports=measureDimensions; -},{"../utils/flatten":521,"./measureBoundingBox":382}],387:[function(require,module,exports){ +},{"../utils/flatten":522,"./measureBoundingBox":382}],387:[function(require,module,exports){ const flatten=require("../utils/flatten"),{geom2:geom2,geom3:geom3,path2:path2}=require("../geometries"),calculateEpsilonFromBounds=require("./calculateEpsilonFromBounds"),measureBoundingBox=require("./measureBoundingBox"),measureEpsilonOfPath2=e=>calculateEpsilonFromBounds(measureBoundingBox(e),2),measureEpsilonOfGeom2=e=>calculateEpsilonFromBounds(measureBoundingBox(e),2),measureEpsilonOfGeom3=e=>calculateEpsilonFromBounds(measureBoundingBox(e),3),measureEpsilon=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");const o=e.map(e=>path2.isA(e)?measureEpsilonOfPath2(e):geom2.isA(e)?measureEpsilonOfGeom2(e):geom3.isA(e)?measureEpsilonOfGeom3(e):0);return 1===o.length?o[0]:o};module.exports=measureEpsilon; -},{"../geometries":174,"../utils/flatten":521,"./calculateEpsilonFromBounds":375,"./measureBoundingBox":382}],388:[function(require,module,exports){ +},{"../geometries":174,"../utils/flatten":522,"./calculateEpsilonFromBounds":375,"./measureBoundingBox":382}],388:[function(require,module,exports){ const flatten=require("../utils/flatten"),geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),path2=require("../geometries/path2"),poly3=require("../geometries/poly3"),cache=new WeakMap,measureVolumeOfPath2=()=>0,measureVolumeOfGeom2=()=>0,measureVolumeOfGeom3=e=>{let r=cache.get(e);if(r)return r;return r=geom3.toPolygons(e).reduce((e,r)=>e+poly3.measureSignedVolume(r),0),cache.set(e,r),r},measureVolume=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");const r=e.map(e=>path2.isA(e)?0:geom2.isA(e)?0:geom3.isA(e)?measureVolumeOfGeom3(e):0);return 1===r.length?r[0]:r};module.exports=measureVolume; -},{"../geometries/geom2":149,"../geometries/geom3":165,"../geometries/path2":186,"../geometries/poly3":203,"../utils/flatten":521}],389:[function(require,module,exports){ +},{"../geometries/geom2":149,"../geometries/geom3":165,"../geometries/path2":186,"../geometries/poly3":203,"../utils/flatten":522}],389:[function(require,module,exports){ const vec2=require("../../maths/vec2"),geom2=require("../../geometries/geom2"),fromFakePolygon=(e,o)=>{if(o.vertices.length<4)return null;const r=[],n=o.vertices.filter((e,o)=>e[2]>0&&(r.push(o),!0));if(2!==n.length)throw new Error("Assertion failed: fromFakePolygon: not enough points found");const t=n.map(o=>{const r=Math.round(o[0]/e)*e+0,n=Math.round(o[1]/e)*e+0;return vec2.fromValues(r,n)});if(vec2.equals(t[0],t[1]))return null;const s=r[1]-r[0];if(1!==s&&3!==s)throw new Error("Assertion failed: fromFakePolygon: unknown index ordering");return 1===s&&t.reverse(),t},fromFakePolygons=(e,o)=>{const r=o.map(o=>fromFakePolygon(e,o)).filter(e=>null!==e);return geom2.create(r)};module.exports=fromFakePolygons; },{"../../geometries/geom2":149,"../../maths/vec2":315}],390:[function(require,module,exports){ @@ -1553,13 +1553,13 @@ module.exports={intersect:require("./intersect"),scission:require("./scission"), },{"./intersect":391,"./scission":396,"./subtract":398,"./union":409}],391:[function(require,module,exports){ const flatten=require("../../utils/flatten"),areAllShapesTheSameType=require("../../utils/areAllShapesTheSameType"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),intersectGeom2=require("./intersectGeom2"),intersectGeom3=require("./intersectGeom3"),intersect=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");if(!areAllShapesTheSameType(e))throw new Error("only intersect of the types are supported");const r=e[0];return geom2.isA(r)?intersectGeom2(e):geom3.isA(r)?intersectGeom3(e):r};module.exports=intersect; -},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../utils/areAllShapesTheSameType":519,"../../utils/flatten":521,"./intersectGeom2":392,"./intersectGeom3":393}],392:[function(require,module,exports){ +},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../utils/areAllShapesTheSameType":520,"../../utils/flatten":522,"./intersectGeom2":392,"./intersectGeom3":393}],392:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom3=require("../../geometries/geom3"),measureEpsilon=require("../../measurements/measureEpsilon"),fromFakePolygons=require("./fromFakePolygons"),to3DWalls=require("./to3DWalls"),intersectGeom3=require("./intersectGeom3"),intersect=(...e)=>{const o=(e=flatten(e)).map(e=>to3DWalls({z0:-1,z1:1},e)),r=intersectGeom3(o),t=measureEpsilon(r);return fromFakePolygons(t,geom3.toPolygons(r))};module.exports=intersect; -},{"../../geometries/geom3":165,"../../measurements/measureEpsilon":387,"../../utils/flatten":521,"./fromFakePolygons":389,"./intersectGeom3":393,"./to3DWalls":402}],393:[function(require,module,exports){ +},{"../../geometries/geom3":165,"../../measurements/measureEpsilon":387,"../../utils/flatten":522,"./fromFakePolygons":389,"./intersectGeom3":393,"./to3DWalls":402}],393:[function(require,module,exports){ const flatten=require("../../utils/flatten"),retessellate=require("../modifiers/retessellate"),intersectSub=require("./intersectGeom3Sub"),intersect=(...e)=>{let t=(e=flatten(e)).shift();return e.forEach(e=>{t=intersectSub(t,e)}),t=retessellate(t)};module.exports=intersect; -},{"../../utils/flatten":521,"../modifiers/retessellate":479,"./intersectGeom3Sub":394}],394:[function(require,module,exports){ +},{"../../utils/flatten":522,"../modifiers/retessellate":480,"./intersectGeom3Sub":394}],394:[function(require,module,exports){ const geom3=require("../../geometries/geom3"),mayOverlap=require("./mayOverlap"),{Tree:Tree}=require("./trees"),intersectGeom3Sub=(e,o)=>{if(!mayOverlap(e,o))return geom3.create();const r=new Tree(geom3.toPolygons(e)),t=new Tree(geom3.toPolygons(o));r.invert(),t.clipTo(r),t.invert(),r.clipTo(t),t.clipTo(r),r.addPolygons(t.allPolygons()),r.invert();const n=r.allPolygons();return geom3.create(n)};module.exports=intersectGeom3Sub; },{"../../geometries/geom3":165,"./mayOverlap":395,"./trees":406}],395:[function(require,module,exports){ @@ -1568,19 +1568,19 @@ const{EPS:EPS}=require("../../maths/constants"),measureBoundingBox=require("../. },{"../../maths/constants":218,"../../measurements/measureBoundingBox":382}],396:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom3=require("../../geometries/geom3"),scissionGeom3=require("./scissionGeom3"),scission=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");const s=e.map(e=>geom3.isA(e)?scissionGeom3(e):e);return 1===s.length?s[0]:s};module.exports=scission; -},{"../../geometries/geom3":165,"../../utils/flatten":521,"./scissionGeom3":397}],397:[function(require,module,exports){ +},{"../../geometries/geom3":165,"../../utils/flatten":522,"./scissionGeom3":397}],397:[function(require,module,exports){ const vec3=require("../../maths/vec3"),measureEpsilon=require("../../measurements/measureEpsilon"),geom3=require("../../geometries/geom3"),sortNb=e=>e.sort((e,s)=>e-s).filter((e,s,o)=>!s||e!==o[s-1]),insertMapping=(e,s,o)=>{const t=`${s}`,n=e.get(t);void 0===n?e.set(t,[o]):n.push(o)},findMapping=(e,s)=>{const o=`${s}`;return e.get(o)},scissionGeom3=e=>{const s=measureEpsilon(e),o=geom3.toPolygons(e),t=o.length,n=new Map,r=vec3.create();o.forEach((e,o)=>{e.vertices.forEach(e=>{insertMapping(n,vec3.snap(r,e,s),o)})});const c=o.map(e=>{let o=[];return e.vertices.forEach(e=>{o=o.concat(findMapping(n,vec3.snap(r,e,s)))}),{e:1,d:sortNb(o)}});n.clear();let i=0;const a=c.length;for(let e=0;e0){const o=new Array(t);o[e]=!0;do{i=0,o.forEach((e,s)=>{const t=c[s];if(t.e>0){t.e=-1;for(let e=0;e0);s.indexes=o}}const p=[];for(let e=0;es.push(o[t])),p.push(geom3.create(s))}return p};module.exports=scissionGeom3; },{"../../geometries/geom3":165,"../../maths/vec3":346,"../../measurements/measureEpsilon":387}],398:[function(require,module,exports){ const flatten=require("../../utils/flatten"),areAllShapesTheSameType=require("../../utils/areAllShapesTheSameType"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),subtractGeom2=require("./subtractGeom2"),subtractGeom3=require("./subtractGeom3"),subtract=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");if(!areAllShapesTheSameType(e))throw new Error("only subtract of the types are supported");const r=e[0];return geom2.isA(r)?subtractGeom2(e):geom3.isA(r)?subtractGeom3(e):r};module.exports=subtract; -},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../utils/areAllShapesTheSameType":519,"../../utils/flatten":521,"./subtractGeom2":399,"./subtractGeom3":400}],399:[function(require,module,exports){ +},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../utils/areAllShapesTheSameType":520,"../../utils/flatten":522,"./subtractGeom2":399,"./subtractGeom3":400}],399:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom3=require("../../geometries/geom3"),measureEpsilon=require("../../measurements/measureEpsilon"),fromFakePolygons=require("./fromFakePolygons"),to3DWalls=require("./to3DWalls"),subtractGeom3=require("./subtractGeom3"),subtract=(...e)=>{const o=(e=flatten(e)).map(e=>to3DWalls({z0:-1,z1:1},e)),r=subtractGeom3(o),t=measureEpsilon(r);return fromFakePolygons(t,geom3.toPolygons(r))};module.exports=subtract; -},{"../../geometries/geom3":165,"../../measurements/measureEpsilon":387,"../../utils/flatten":521,"./fromFakePolygons":389,"./subtractGeom3":400,"./to3DWalls":402}],400:[function(require,module,exports){ +},{"../../geometries/geom3":165,"../../measurements/measureEpsilon":387,"../../utils/flatten":522,"./fromFakePolygons":389,"./subtractGeom3":400,"./to3DWalls":402}],400:[function(require,module,exports){ const flatten=require("../../utils/flatten"),retessellate=require("../modifiers/retessellate"),subtractSub=require("./subtractGeom3Sub"),subtract=(...t)=>{let e=(t=flatten(t)).shift();return t.forEach(t=>{e=subtractSub(e,t)}),e=retessellate(e)};module.exports=subtract; -},{"../../utils/flatten":521,"../modifiers/retessellate":479,"./subtractGeom3Sub":401}],401:[function(require,module,exports){ +},{"../../utils/flatten":522,"../modifiers/retessellate":480,"./subtractGeom3Sub":401}],401:[function(require,module,exports){ const geom3=require("../../geometries/geom3"),mayOverlap=require("./mayOverlap"),{Tree:Tree}=require("./trees"),subtractGeom3Sub=(e,o)=>{if(!mayOverlap(e,o))return geom3.clone(e);const r=new Tree(geom3.toPolygons(e)),t=new Tree(geom3.toPolygons(o));r.invert(),r.clipTo(t),t.clipTo(r,!0),r.addPolygons(t.allPolygons()),r.invert();const l=r.allPolygons();return geom3.create(l)};module.exports=subtractGeom3Sub; },{"../../geometries/geom3":165,"./mayOverlap":395,"./trees":406}],402:[function(require,module,exports){ @@ -1607,19 +1607,19 @@ const{EPS:EPS}=require("../../../maths/constants"),plane=require("../../../maths },{"../../../geometries/poly3":203,"../../../maths/constants":218,"../../../maths/plane":287,"../../../maths/vec3":346,"./splitLineSegmentByPlane":407}],409:[function(require,module,exports){ const flatten=require("../../utils/flatten"),areAllShapesTheSameType=require("../../utils/areAllShapesTheSameType"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),unionGeom2=require("./unionGeom2"),unionGeom3=require("./unionGeom3"),union=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");if(!areAllShapesTheSameType(e))throw new Error("only unions of the same type are supported");const o=e[0];return geom2.isA(o)?unionGeom2(e):geom3.isA(o)?unionGeom3(e):o};module.exports=union; -},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../utils/areAllShapesTheSameType":519,"../../utils/flatten":521,"./unionGeom2":410,"./unionGeom3":411}],410:[function(require,module,exports){ +},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../utils/areAllShapesTheSameType":520,"../../utils/flatten":522,"./unionGeom2":410,"./unionGeom3":411}],410:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom3=require("../../geometries/geom3"),measureEpsilon=require("../../measurements/measureEpsilon"),fromFakePolygons=require("./fromFakePolygons"),to3DWalls=require("./to3DWalls"),unionGeom3=require("./unionGeom3"),union=(...e)=>{const o=(e=flatten(e)).map(e=>to3DWalls({z0:-1,z1:1},e)),n=unionGeom3(o),r=measureEpsilon(n);return fromFakePolygons(r,geom3.toPolygons(n))};module.exports=union; -},{"../../geometries/geom3":165,"../../measurements/measureEpsilon":387,"../../utils/flatten":521,"./fromFakePolygons":389,"./to3DWalls":402,"./unionGeom3":411}],411:[function(require,module,exports){ +},{"../../geometries/geom3":165,"../../measurements/measureEpsilon":387,"../../utils/flatten":522,"./fromFakePolygons":389,"./to3DWalls":402,"./unionGeom3":411}],411:[function(require,module,exports){ const flatten=require("../../utils/flatten"),retessellate=require("../modifiers/retessellate"),unionSub=require("./unionGeom3Sub"),union=(...e)=>{let t;for(e=flatten(e),t=1;t{if(!mayOverlap(e,o))return unionForNonIntersecting(e,o);const n=new Tree(geom3.toPolygons(e)),r=new Tree(geom3.toPolygons(o));n.clipTo(r,!1),r.clipTo(n),r.invert(),r.clipTo(n),r.invert();const t=n.allPolygons().concat(r.allPolygons());return geom3.create(t)},unionForNonIntersecting=(e,o)=>{let n=geom3.toPolygons(e);return n=n.concat(geom3.toPolygons(o)),geom3.create(n)};module.exports=unionSub; },{"../../geometries/geom3":165,"./mayOverlap":395,"./trees":406}],413:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),expandGeom2=require("./expandGeom2"),expandGeom3=require("./expandGeom3"),expandPath2=require("./expandPath2"),expand=(e,...r)=>{if(0===(r=flatten(r)).length)throw new Error("wrong number of arguments");const t=r.map(r=>path2.isA(r)?expandPath2(e,r):geom2.isA(r)?expandGeom2(e,r):geom3.isA(r)?expandGeom3(e,r):r);return 1===t.length?t[0]:t};module.exports=expand; -},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../geometries/path2":186,"../../utils/flatten":521,"./expandGeom2":414,"./expandGeom3":415,"./expandPath2":416}],414:[function(require,module,exports){ +},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../geometries/path2":186,"../../utils/flatten":522,"./expandGeom2":414,"./expandGeom3":415,"./expandPath2":416}],414:[function(require,module,exports){ const geom2=require("../../geometries/geom2"),offsetFromPoints=require("./offsetFromPoints"),expandGeom2=(e,o)=>{const{delta:r,corners:s,segments:t}=Object.assign({},{delta:1,corners:"edge",segments:16},e);if("edge"!==s&&"chamfer"!==s&&"round"!==s)throw new Error('corners must be "edge", "chamfer", or "round"');const n=geom2.toOutlines(o).map(o=>offsetFromPoints(e={delta:r,corners:s,closed:!0,segments:t},o)).reduce((e,o)=>e.concat(geom2.toSides(geom2.fromPoints(o))),[]);return geom2.create(n)};module.exports=expandGeom2; },{"../../geometries/geom2":149,"./offsetFromPoints":421}],415:[function(require,module,exports){ @@ -1631,7 +1631,7 @@ const area=require("../../maths/utils/area"),vec2=require("../../maths/vec2"),ge },{"../../geometries/geom2":149,"../../geometries/path2":186,"../../maths/utils/area":292,"../../maths/vec2":315,"./offsetFromPoints":421}],417:[function(require,module,exports){ const{EPS:EPS,TAU:TAU}=require("../../maths/constants"),mat4=require("../../maths/mat4"),vec3=require("../../maths/vec3"),fnNumberSort=require("../../utils/fnNumberSort"),geom3=require("../../geometries/geom3"),poly3=require("../../geometries/poly3"),sphere=require("../../primitives/sphere"),retessellate=require("../modifiers/retessellate"),unionGeom3Sub=require("../booleans/unionGeom3Sub"),extrudePolygon=require("./extrudePolygon"),mapPlaneToVertex=(e,t,o)=>{const n=t.toString();if(e.has(n)){e.get(n)[1].push(o)}else{const s=[t,[o]];e.set(n,s)}},mapPlaneToEdge=(e,t,o)=>{const n=t[0].toString(),s=t[1].toString(),r=n{e.findIndex(e=>e===t)<0&&e.push(t)},expandShell=(e,t)=>{const{delta:o,segments:n}=Object.assign({},{delta:1,segments:12},e);let s=geom3.create();const r=new Map,c=new Map,a=vec3.create(),l=vec3.create();return geom3.toPolygons(t).forEach((e,t)=>{const n=vec3.scale(vec3.create(),poly3.plane(e),2*o),a=poly3.transform(mat4.fromTranslation(mat4.create(),vec3.scale(vec3.create(),n,-.5)),e),l=extrudePolygon(n,a);s=unionGeom3Sub(s,l);const u=e.vertices;for(let t=0;t{const t=e[0],r=e[1],c=t[0],u=t[1],i=vec3.subtract(vec3.create(),u,c);vec3.normalize(i,i);const m=r[0],g=vec3.cross(vec3.create(),m,i);let p=[];for(let e=0;e=0&&vec3.distance(r,v)=0){f.push(r),S.push(i);const e=[d,i,r,v],t=poly3.create(e);q.push(t)}v=r,d=i}}S.reverse(),q.push(poly3.create(f)),q.push(poly3.create(S));const y=geom3.create(q);s=unionGeom3Sub(s,y)}),r.forEach(e=>{const t=e[0],r=e[1],c=r[0];let u=null,i=0;for(let e=1;e.05&&n>i&&(i=n,u=t)}u||(u=vec3.orthogonal(a,c));const m=vec3.cross(a,c,u);vec3.normalize(m,m);const g=vec3.cross(l,m,c),p=sphere({center:[t[0],t[1],t[2]],radius:o,segments:n,axes:[c,m,g]});s=unionGeom3Sub(s,p)}),retessellate(s)};module.exports=expandShell; -},{"../../geometries/geom3":165,"../../geometries/poly3":203,"../../maths/constants":218,"../../maths/mat4":267,"../../maths/vec3":346,"../../primitives/sphere":509,"../../utils/fnNumberSort":522,"../booleans/unionGeom3Sub":412,"../modifiers/retessellate":479,"./extrudePolygon":418}],418:[function(require,module,exports){ +},{"../../geometries/geom3":165,"../../geometries/poly3":203,"../../maths/constants":218,"../../maths/mat4":267,"../../maths/vec3":346,"../../primitives/sphere":510,"../../utils/fnNumberSort":523,"../booleans/unionGeom3Sub":412,"../modifiers/retessellate":480,"./extrudePolygon":418}],418:[function(require,module,exports){ const mat4=require("../../maths/mat4"),vec3=require("../../maths/vec3"),geom3=require("../../geometries/geom3"),poly3=require("../../geometries/poly3"),extrudePolygon=(e,r)=>{vec3.dot(poly3.plane(r),e)>0&&(r=poly3.invert(r));const t=[r],o=poly3.transform(mat4.fromTranslation(mat4.create(),e),r),s=r.vertices.length;for(let e=0;e{if(0===(t=flatten(t)).length)throw new Error("wrong number of arguments");const o=t.map(t=>path2.isA(t)?offsetPath2(e,t):geom2.isA(t)?offsetGeom2(e,t):t);return 1===o.length?o[0]:o};module.exports=offset; -},{"../../geometries/geom2":149,"../../geometries/path2":186,"../../utils/flatten":521,"./offsetGeom2":422,"./offsetPath2":423}],421:[function(require,module,exports){ +},{"../../geometries/geom2":149,"../../geometries/path2":186,"../../utils/flatten":522,"./offsetGeom2":422,"./offsetPath2":423}],421:[function(require,module,exports){ const{EPS:EPS,TAU:TAU}=require("../../maths/constants"),intersect=require("../../maths/utils/intersect"),line2=require("../../maths/line2"),vec2=require("../../maths/vec2"),area=require("../../maths/utils/area"),offsetFromPoints=(e,t)=>{let{delta:s,corners:c,closed:n,segments:a}=Object.assign({},{delta:1,corners:"edge",closed:!1,segments:16},e);if(Math.abs(s)0&&s>=0||r<0&&s<0;s=Math.abs(s);let i=null,l=[];const u=[],v=vec2.create(),f=t.length;for(let e=0;ee.set(t,s));const t=line2.create(),s=line2.create();u.forEach(c=>{line2.fromPoints(t,c.s0[0],c.s0[1]),line2.fromPoints(s,c.s1[0],c.s1[1]);const n=line2.intersectPointOfLines(t,s);if(Number.isFinite(n[0])&&Number.isFinite(n[1])){const t=c.s0[1],s=e.get(t);l[s]=n,l[(s+1)%l.length]=void 0}else{const t=c.s1[0],s=e.get(t);l[s]=void 0}}),l=l.filter(e=>void 0!==e)}if("round"===c){let e=Math.floor(a/4);const t=vec2.create();u.forEach(c=>{let n=vec2.angle(vec2.subtract(t,c.s1[0],c.c));if(n-=vec2.angle(vec2.subtract(t,c.s0[1],c.c)),o&&n<0&&(n+=Math.PI)<0&&(n+=Math.PI),!o&&n>0&&(n-=Math.PI)>0&&(n-=Math.PI),0!==n){const r=n/(e=Math.floor(a*(Math.abs(n)/TAU))),o=vec2.angle(vec2.subtract(t,c.s0[1],c.c)),i=[];for(let t=1;t0){const e=c.s0[1];let t=l.findIndex(t=>vec2.equals(e,t));t=(t+1)%l.length,l.splice(t,0,...i)}}else{const e=c.s1[0],t=l.findIndex(t=>vec2.equals(e,t));l.splice(t,1)}})}return l};module.exports=offsetFromPoints; },{"../../maths/constants":218,"../../maths/line2":229,"../../maths/utils/area":292,"../../maths/utils/intersect":295,"../../maths/vec2":315}],422:[function(require,module,exports){ @@ -1682,7 +1682,7 @@ const{TAU:TAU}=require("../../maths/constants"),slice=require("./slice"),mat4=re },{"../../geometries/geom2":149,"../../maths/constants":218,"../../maths/mat4":267,"./extrudeFromSlices":432,"./slice":450}],434:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom2=require("../../geometries/geom2"),path2=require("../../geometries/path2"),extrudeLinearGeom2=require("./extrudeLinearGeom2"),extrudeLinearPath2=require("./extrudeLinearPath2"),extrudeLinear=(e,...t)=>{const{height:r,twistAngle:i,twistSteps:n,repair:a}=Object.assign({},{height:1,twistAngle:0,twistSteps:1,repair:!0},e);if(0===(t=flatten(t)).length)throw new Error("wrong number of arguments");e={offset:[0,0,r],twistAngle:i,twistSteps:n,repair:a};const s=t.map(t=>path2.isA(t)?extrudeLinearPath2(e,t):geom2.isA(t)?extrudeLinearGeom2(e,t):t);return 1===s.length?s[0]:s};module.exports=extrudeLinear; -},{"../../geometries/geom2":149,"../../geometries/path2":186,"../../utils/flatten":521,"./extrudeLinearGeom2":435,"./extrudeLinearPath2":436}],435:[function(require,module,exports){ +},{"../../geometries/geom2":149,"../../geometries/path2":186,"../../utils/flatten":522,"./extrudeLinearGeom2":435,"./extrudeLinearPath2":436}],435:[function(require,module,exports){ const mat4=require("../../maths/mat4"),vec3=require("../../maths/vec3"),geom2=require("../../geometries/geom2"),slice=require("./slice"),extrudeFromSlices=require("./extrudeFromSlices"),extrudeGeom2=(e,t)=>{let{offset:r,twistAngle:s,twistSteps:o,repair:i}=Object.assign({},{offset:[0,0,1],twistAngle:0,twistSteps:12,repair:!0},e);if(o<1)throw new Error("twistSteps must be 1 or more");0===s&&(o=1);const c=vec3.clone(r),m=geom2.toSides(t);if(0===m.length)throw new Error("the given geometry cannot be empty");const a=slice.fromSides(m);c[2]<0&&slice.reverse(a,a);const n=mat4.create();return extrudeFromSlices(e={numberOfSlices:o+1,capStart:!0,capEnd:!0,repair:i,callback:(e,t,r)=>{const i=t/o*s,m=vec3.scale(vec3.create(),c,t/o);return mat4.multiply(n,mat4.fromZRotation(n,i),mat4.fromTranslation(mat4.create(),m)),slice.transform(n,r)}},a)};module.exports=extrudeGeom2; },{"../../geometries/geom2":149,"../../maths/mat4":267,"../../maths/vec3":346,"./extrudeFromSlices":432,"./slice":450}],436:[function(require,module,exports){ @@ -1691,7 +1691,7 @@ const geom2=require("../../geometries/geom2"),path2=require("../../geometries/pa },{"../../geometries/geom2":149,"../../geometries/path2":186,"./extrudeLinearGeom2":435}],437:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom2=require("../../geometries/geom2"),path2=require("../../geometries/path2"),extrudeRectangularPath2=require("./extrudeRectangularPath2"),extrudeRectangularGeom2=require("./extrudeRectangularGeom2"),extrudeRectangular=(e,...t)=>{const{size:r,height:a}=Object.assign({},{size:1,height:1},e);if(0===(t=flatten(t)).length)throw new Error("wrong number of arguments");if(r<=0)throw new Error("size must be positive");if(a<=0)throw new Error("height must be positive");const u=t.map(t=>path2.isA(t)?extrudeRectangularPath2(e,t):geom2.isA(t)?extrudeRectangularGeom2(e,t):t);return 1===u.length?u[0]:u};module.exports=extrudeRectangular; -},{"../../geometries/geom2":149,"../../geometries/path2":186,"../../utils/flatten":521,"./extrudeRectangularGeom2":438,"./extrudeRectangularPath2":439}],438:[function(require,module,exports){ +},{"../../geometries/geom2":149,"../../geometries/path2":186,"../../utils/flatten":522,"./extrudeRectangularGeom2":438,"./extrudeRectangularPath2":439}],438:[function(require,module,exports){ const{area:area}=require("../../maths/utils"),geom2=require("../../geometries/geom2"),path2=require("../../geometries/path2"),expand=require("../expansions/expand"),extrudeLinearGeom2=require("./extrudeLinearGeom2"),extrudeRectangularGeom2=(e,r)=>{const{size:t,height:o}=Object.assign({},{size:1,height:1},e);e.delta=t,e.offset=[0,0,o];const a=geom2.toOutlines(r);if(0===a.length)throw new Error("the given geometry cannot be empty");const n=a.map(r=>(area(r)<0&&r.reverse(),expand(e,path2.fromPoints({closed:!0},r)))).reduce((e,r)=>e.concat(geom2.toSides(r)),[]),i=geom2.create(n);return extrudeLinearGeom2(e,i)};module.exports=extrudeRectangularGeom2; },{"../../geometries/geom2":149,"../../geometries/path2":186,"../../maths/utils":293,"../expansions/expand":413,"./extrudeLinearGeom2":435}],439:[function(require,module,exports){ @@ -1700,7 +1700,7 @@ const path2=require("../../geometries/path2"),expand=require("../expansions/expa },{"../../geometries/path2":186,"../expansions/expand":413,"./extrudeLinearGeom2":435}],440:[function(require,module,exports){ const{TAU:TAU}=require("../../maths/constants"),mat4=require("../../maths/mat4"),{mirrorX:mirrorX}=require("../transforms/mirror"),geom2=require("../../geometries/geom2"),slice=require("./slice"),extrudeFromSlices=require("./extrudeFromSlices"),extrudeRotate=(e,t)=>{const r={segments:12,startAngle:0,angle:TAU,overflow:"cap"};let{segments:a,startAngle:o,angle:s,overflow:m}=Object.assign({},r,e);if(a<3)throw new Error("segments must be greater then 3");o=Math.abs(o)>TAU?o%TAU:o,s=Math.abs(s)>TAU?s%TAU:s;let n=o+s;if((n=Math.abs(n)>TAU?n%TAU:n)a*e&&a++}let i=geom2.toSides(t);if(0===i.length)throw new Error("the given geometry cannot be empty");const c=i.filter(e=>e[0][0]<0),g=i.filter(e=>e[0][0]>=0);c.length>0&&g.length>0&&"cap"===m&&(c.length>g.length?(i=i.map(e=>{let t=e[0],r=e[1];return[t=[Math.min(t[0],0),t[1]],r=[Math.min(r[0],0),r[1]]]}),t=geom2.create(i),t=mirrorX(t)):g.length>=c.length&&(i=i.map(e=>{let t=e[0],r=e[1];return[t=[Math.max(t[0],0),t[1]],r=[Math.max(r[0],0),r[1]]]}),t=geom2.create(i)));const h=l/a,u=Math.abs(l){let s=h*t+o;return l===TAU&&t===a&&(s=o),mat4.multiply(f,mat4.fromZRotation(f,s),mat4.fromXRotation(mat4.create(),TAU/4)),slice.transform(f,r)}},A)};module.exports=extrudeRotate; -},{"../../geometries/geom2":149,"../../maths/constants":218,"../../maths/mat4":267,"../transforms/mirror":486,"./extrudeFromSlices":432,"./slice":450}],441:[function(require,module,exports){ +},{"../../geometries/geom2":149,"../../maths/constants":218,"../../maths/mat4":267,"../transforms/mirror":487,"./extrudeFromSlices":432,"./slice":450}],441:[function(require,module,exports){ const{EPS:EPS}=require("../../maths/constants"),vec3=require("../../maths/vec3"),poly3=require("../../geometries/poly3"),slice=require("./slice"),gcd=(e,t)=>e===t?e:ee*t/gcd(e,t),repartitionEdges=(e,t)=>{const r=e/t.length;if(1===r)return t;const s=vec3.fromValues(r,r,r),c=[];return t.forEach(e=>{const t=vec3.subtract(vec3.create(),e[1],e[0]);vec3.divide(t,t,s);let l=e[0];for(let e=1;e<=r;++e){const e=vec3.add(vec3.create(),l,t);c.push([l,e]),l=e}}),c},EPSAREA=EPS*EPS/2*Math.sin(Math.PI/3),extrudeWalls=(e,t)=>{let r=slice.toEdges(e),s=slice.toEdges(t);if(r.length!==s.length){const e=lcm(r.length,s.length);e!==r.length&&(r=repartitionEdges(e,r)),e!==s.length&&(s=repartitionEdges(e,s))}const c=[];return r.forEach((e,t)=>{const r=s[t],l=poly3.create([e[0],e[1],r[1]]),o=poly3.measureArea(l);Number.isFinite(o)&&o>EPSAREA&&c.push(l);const n=poly3.create([e[0],r[1],r[0]]),i=poly3.measureArea(n);Number.isFinite(i)&&i>EPSAREA&&c.push(n)}),c};module.exports=extrudeWalls; },{"../../geometries/poly3":203,"../../maths/constants":218,"../../maths/vec3":346,"./slice":450}],442:[function(require,module,exports){ @@ -1709,7 +1709,7 @@ module.exports={extrudeFromSlices:require("./extrudeFromSlices"),extrudeLinear:r },{"./extrudeFromSlices":432,"./extrudeHelical":433,"./extrudeLinear":434,"./extrudeRectangular":437,"./extrudeRotate":440,"./project":443,"./slice":450}],443:[function(require,module,exports){ const flatten=require("../../utils/flatten"),aboutEqualNormals=require("../../maths/utils/aboutEqualNormals"),plane=require("../../maths/plane"),mat4=require("../../maths/mat4"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),poly3=require("../../geometries/poly3"),measureEpsilon=require("../../measurements/measureEpsilon"),unionGeom2=require("../booleans/unionGeom2"),projectGeom3=(e,o)=>{const r=plane.fromNormalAndPoint(plane.create(),e.axis,e.origin);if(Number.isNaN(r[0])||Number.isNaN(r[1])||Number.isNaN(r[2])||Number.isNaN(r[3]))throw new Error("project: invalid axis or origin");const t=measureEpsilon(o),a=t*t*Math.sqrt(3)/4;if(0===t)return geom2.create();const n=geom3.toPolygons(o);let s=[];for(let e=0;eplane.projectionOfPoint(r,e)),t=poly3.create(o),i=poly3.plane(t);aboutEqualNormals(r,i)&&(poly3.measureArea(t)poly3.transform(e,o))}const i=(s=s.sort((e,o)=>poly3.measureArea(o)-poly3.measureArea(e))).map(e=>geom2.fromPoints(e.vertices));return unionGeom2(i)},project=(e,...o)=>{const{axis:r,origin:t}=Object.assign({},{axis:[0,0,1],origin:[0,0,0]},e);if(0===(o=flatten(o)).length)throw new Error("wrong number of arguments");e={axis:r,origin:t};const a=o.map(o=>geom3.isA(o)?projectGeom3(e,o):o);return 1===a.length?a[0]:a};module.exports=project; -},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../geometries/poly3":203,"../../maths/mat4":267,"../../maths/plane":287,"../../maths/utils/aboutEqualNormals":291,"../../measurements/measureEpsilon":387,"../../utils/flatten":521,"../booleans/unionGeom2":410}],444:[function(require,module,exports){ +},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../geometries/poly3":203,"../../maths/mat4":267,"../../maths/plane":287,"../../maths/utils/aboutEqualNormals":291,"../../measurements/measureEpsilon":387,"../../utils/flatten":522,"../booleans/unionGeom2":410}],444:[function(require,module,exports){ const plane=require("../../../maths/plane"),vec3=require("../../../maths/vec3"),calculatePlane=e=>{const c=e.edges;if(c.length<3)throw new Error("slices must have 3 or more edges to calculate a plane");const a=c.reduce((e,c)=>vec3.add(vec3.create(),e,c[0]),vec3.create());let t;vec3.scale(a,a,1/c.length);let l=0;c.forEach(e=>{if(!vec3.equals(e[0],e[1])){const c=vec3.squaredDistance(a,e[0]);c>l&&(t=e,l=c)}});const r=c.find(e=>vec3.equals(e[1],t[0]));return plane.fromPoints(plane.create(),r[0],t[0],t[1])};module.exports=calculatePlane; },{"../../../maths/plane":287,"../../../maths/vec3":346}],445:[function(require,module,exports){ @@ -1754,235 +1754,238 @@ const vec3=require("../../../maths/vec3"),create=require("./create"),transform=( },{"../../../maths/vec3":346,"./create":446}],458:[function(require,module,exports){ const flatten=require("../../utils/flatten"),areAllShapesTheSameType=require("../../utils/areAllShapesTheSameType"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),hullPath2=require("./hullPath2"),hullGeom2=require("./hullGeom2"),hullGeom3=require("./hullGeom3"),hull=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");if(!areAllShapesTheSameType(e))throw new Error("only hulls of the same type are supported");const l=e[0];return path2.isA(l)?hullPath2(e):geom2.isA(l)?hullGeom2(e):geom3.isA(l)?hullGeom3(e):l};module.exports=hull; -},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../geometries/path2":186,"../../utils/areAllShapesTheSameType":519,"../../utils/flatten":521,"./hullGeom2":460,"./hullGeom3":461,"./hullPath2":462}],459:[function(require,module,exports){ +},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../geometries/path2":186,"../../utils/areAllShapesTheSameType":520,"../../utils/flatten":522,"./hullGeom2":460,"./hullGeom3":461,"./hullPath2":462}],459:[function(require,module,exports){ const flatten=require("../../utils/flatten"),union=require("../booleans/union"),hull=require("./hull"),hullChain=(...n)=>{if((n=flatten(n)).length<2)throw new Error("wrong number of arguments");const e=[];for(let l=1;l{e=flatten(e);const t=toUniquePoints(e),o=hullPoints2(t);return o.length<3?geom2.create():geom2.fromPoints(o)};module.exports=hullGeom2; -},{"../../geometries/geom2":149,"../../utils/flatten":521,"./hullPoints2":463,"./toUniquePoints":473}],461:[function(require,module,exports){ -const flatten=require("../../utils/flatten"),geom3=require("../../geometries/geom3"),poly3=require("../../geometries/poly3"),quickhull=require("./quickhull"),toUniquePoints=require("./toUniquePoints"),hullGeom3=(...e)=>{if(1===(e=flatten(e)).length)return e[0];const t=toUniquePoints(e),o=quickhull(t,{skipTriangulation:!0}).map(e=>{const o=e.map(e=>t[e]);return poly3.create(o)});return geom3.create(o)};module.exports=hullGeom3; +},{"../../geometries/geom2":149,"../../utils/flatten":522,"./hullPoints2":463,"./toUniquePoints":474}],461:[function(require,module,exports){ +const flatten=require("../../utils/flatten"),geom3=require("../../geometries/geom3"),toUniquePoints=require("./toUniquePoints"),hullPoints3=require("./hullPoints3"),hullGeom3=(...e)=>{e=flatten(e);const t=toUniquePoints(e);return 0===t.length?geom3.create():geom3.create(hullPoints3(t))};module.exports=hullGeom3; -},{"../../geometries/geom3":165,"../../geometries/poly3":203,"../../utils/flatten":521,"./quickhull":471,"./toUniquePoints":473}],462:[function(require,module,exports){ +},{"../../geometries/geom3":165,"../../utils/flatten":522,"./hullPoints3":464,"./toUniquePoints":474}],462:[function(require,module,exports){ const flatten=require("../../utils/flatten"),path2=require("../../geometries/path2"),hullPoints2=require("./hullPoints2"),toUniquePoints=require("./toUniquePoints"),hullPath2=(...t)=>{t=flatten(t);const e=toUniquePoints(t),o=hullPoints2(e);return path2.fromPoints({closed:!0},o)};module.exports=hullPath2; -},{"../../geometries/path2":186,"../../utils/flatten":521,"./hullPoints2":463,"./toUniquePoints":473}],463:[function(require,module,exports){ +},{"../../geometries/path2":186,"../../utils/flatten":522,"./hullPoints2":463,"./toUniquePoints":474}],463:[function(require,module,exports){ const vec2=require("../../maths/vec2"),hullPoints2=e=>{let t=vec2.fromValues(1/0,1/0);e.forEach(e=>{(e[1]{const o=fakeAtan2(e[1]-t[1],e[0]-t[0]),s=vec2.squaredDistance(e,t);n.push({point:e,angle:o,distSq:s})}),n.sort((e,t)=>e.angle!==t.angle?e.angle-t.angle:e.distSq-t.distSq);const o=[];return n.forEach(e=>{let t=o.length;for(;t>1&&ccw(o[t-2],o[t-1],e.point)<=Number.EPSILON;)o.pop(),t=o.length;o.push(e.point)}),o},ccw=(e,t,n)=>(t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0]),fakeAtan2=(e,t)=>0===e&&0===t?-1/0:-t/e;module.exports=hullPoints2; },{"../../maths/vec2":315}],464:[function(require,module,exports){ -module.exports={hull:require("./hull"),hullChain:require("./hullChain")}; +const poly3=require("../../geometries/poly3"),quickhull=require("./quickhull"),hullPoints3=l=>{return quickhull(l,{skipTriangulation:!0}).map(u=>{const e=u.map(u=>l[u]);return poly3.create(e)})};module.exports=hullPoints3; + +},{"../../geometries/poly3":203,"./quickhull":472}],465:[function(require,module,exports){ +module.exports={hull:require("./hull"),hullChain:require("./hullChain"),hullPoints2:require("./hullPoints2"),hullPoints3:require("./hullPoints3")}; -},{"./hull":458,"./hullChain":459}],465:[function(require,module,exports){ +},{"./hull":458,"./hullChain":459,"./hullPoints2":463,"./hullPoints3":464}],466:[function(require,module,exports){ const add=require("../../../maths/vec3/add"),copy=require("../../../maths/vec3/copy"),cross=require("../../../maths/vec3/cross"),dot=require("../../../maths/vec3/dot"),length=require("../../../maths/vec3/length"),normalize=require("../../../maths/vec3/normalize"),scale=require("../../../maths/vec3/scale"),subtract=require("../../../maths/vec3/subtract"),HalfEdge=require("./HalfEdge"),VISIBLE=0,NON_CONVEX=1,DELETED=2;class Face{constructor(){this.normal=[],this.centroid=[],this.offset=0,this.outside=null,this.mark=VISIBLE,this.edge=null,this.nVertices=0}getEdge(e){if("number"!=typeof e)throw Error("requires a number");let t=this.edge;for(;e>0;)t=t.next,e-=1;for(;e<0;)t=t.prev,e+=1;return t}computeNormal(){const e=this.edge,t=e.next;let r=t.next;const s=subtract([],t.head().point,e.head().point),o=[],i=[];for(this.nVertices=2,this.normal=[0,0,0];r!==e;)copy(i,s),subtract(s,r.head().point,e.head().point),add(this.normal,this.normal,cross(o,i,s)),r=r.next,this.nVertices+=1;this.area=length(this.normal),this.normal=scale(this.normal,this.normal,1/this.area)}computeNormalMinArea(e){if(this.computeNormal(),this.areat&&(e=r,t=s),r=r.next}while(r!==this.edge);const s=e.tail().point,o=e.head().point,i=subtract([],o,s),n=Math.sqrt(t);scale(i,i,1/n);const a=dot(this.normal,i);scale(i,i,-a),add(this.normal,this.normal,i),normalize(this.normal,this.normal)}}computeCentroid(){this.centroid=[0,0,0];let e=this.edge;do{add(this.centroid,this.centroid,e.head().point),e=e.next}while(e!==this.edge);scale(this.centroid,this.centroid,1/this.nVertices)}computeNormalAndCentroid(e){void 0!==e?this.computeNormalMinArea(e):this.computeNormal(),this.computeCentroid(),this.offset=dot(this.normal,this.centroid)}distanceToPlane(e){return dot(this.normal,e)-this.offset}connectHalfEdges(e,t){let r;if(e.opposite.face===t.opposite.face){const s=t.opposite.face;let o;e===this.edge&&(this.edge=t),3===s.nVertices?(o=t.opposite.prev.opposite,s.mark=DELETED,r=s):(o=t.opposite.next,s.edge===o.prev&&(s.edge=o),o.prev=o.prev.prev,o.prev.next=o),t.prev=e.prev,t.prev.next=t,t.setOpposite(o),s.computeNormalAndCentroid()}else e.next=t,t.prev=e;return r}mergeAdjacentFaces(e,t){const r=e.opposite,s=r.face;t.push(s),s.mark=DELETED;let o,i,n=e.prev,a=e.next,c=r.prev,h=r.next;for(;n.opposite.face===s;)n=n.prev,h=h.next;for(;a.opposite.face===s;)a=a.next,c=c.prev;for(o=h;o!==c.next;o=o.next)o.face=this;return this.edge=a,(i=this.connectHalfEdges(c,a))&&t.push(i),(i=this.connectHalfEdges(n,h))&&t.push(i),this.computeNormalAndCentroid(),t}collectIndices(){const e=[];let t=this.edge;do{e.push(t.head().index),t=t.next}while(t!==this.edge);return e}static createTriangle(e,t,r,s=0){const o=new Face,i=new HalfEdge(e,o),n=new HalfEdge(t,o),a=new HalfEdge(r,o);return i.next=a.prev=n,n.next=i.prev=a,a.next=n.prev=i,o.edge=i,o.computeNormalAndCentroid(s),o}}module.exports={VISIBLE:VISIBLE,NON_CONVEX:1,DELETED:DELETED,Face:Face}; -},{"../../../maths/vec3/add":333,"../../../maths/vec3/copy":336,"../../../maths/vec3/cross":338,"../../../maths/vec3/dot":341,"../../../maths/vec3/length":347,"../../../maths/vec3/normalize":353,"../../../maths/vec3/scale":358,"../../../maths/vec3/subtract":362,"./HalfEdge":466}],466:[function(require,module,exports){ +},{"../../../maths/vec3/add":333,"../../../maths/vec3/copy":336,"../../../maths/vec3/cross":338,"../../../maths/vec3/dot":341,"../../../maths/vec3/length":347,"../../../maths/vec3/normalize":353,"../../../maths/vec3/scale":358,"../../../maths/vec3/subtract":362,"./HalfEdge":467}],467:[function(require,module,exports){ const distance=require("../../../maths/vec3/distance"),squaredDistance=require("../../../maths/vec3/squaredDistance");class HalfEdge{constructor(t,e){this.vertex=t,this.face=e,this.next=null,this.prev=null,this.opposite=null}head(){return this.vertex}tail(){return this.prev?this.prev.vertex:null}length(){return this.tail()?distance(this.tail().point,this.head().point):-1}lengthSquared(){return this.tail()?squaredDistance(this.tail().point,this.head().point):-1}setOpposite(t){this.opposite=t,t.opposite=this}}module.exports=HalfEdge; -},{"../../../maths/vec3/distance":339,"../../../maths/vec3/squaredDistance":360}],467:[function(require,module,exports){ +},{"../../../maths/vec3/distance":339,"../../../maths/vec3/squaredDistance":360}],468:[function(require,module,exports){ const dot=require("../../../maths/vec3/dot"),pointLineDistance=require("./point-line-distance"),getPlaneNormal=require("./get-plane-normal"),VertexList=require("./VertexList"),Vertex=require("./Vertex"),{Face:Face,VISIBLE:VISIBLE,NON_CONVEX:NON_CONVEX,DELETED:DELETED}=require("./Face"),MERGE_NON_CONVEX_WRT_LARGER_FACE=1,MERGE_NON_CONVEX=2;class QuickHull{constructor(e){if(!Array.isArray(e))throw TypeError("input is not a valid array");if(e.length<4)throw Error("cannot build a simplex out of <4 points");this.tolerance=-1,this.nFaces=0,this.nPoints=e.length,this.faces=[],this.newFaces=[],this.claimed=new VertexList,this.unclaimed=new VertexList,this.vertices=[];for(let t=0;tthis.tolerance?this.addVertexToFace(s,t):this.unclaimed.add(s)}}else this.unclaimed.addAll(i)}resolveUnclaimedPoints(e){let t=this.unclaimed.first();for(let i=t;i;i=t){t=i.next;let s,o=this.tolerance;for(let t=0;to&&(o=e,s=a),o>1e3*this.tolerance)break}}s&&this.addVertexToFace(i,s)}}computeExtremes(){const e=[],t=[],i=[],s=[];let o,a;for(o=0;o<3;o+=1)i[o]=s[o]=this.vertices[0];for(o=0;o<3;o+=1)e[o]=t[o]=this.vertices[0].point[o];for(o=1;ot[a]&&(t[a]=n[a],s[a]=c)}return this.tolerance=3*Number.EPSILON*(Math.max(Math.abs(e[0]),Math.abs(t[0]))+Math.max(Math.abs(e[1]),Math.abs(t[1]))+Math.max(Math.abs(e[2]),Math.abs(t[2]))),[i,s]}createInitialSimplex(){const e=this.vertices,[t,i]=this.computeExtremes();let s,o,a,c,n=0,r=0;for(a=0;a<3;a+=1){const e=i[a].point[a]-t[a].point[a];e>n&&(n=e,r=a)}const l=t[r],h=i[r];for(n=0,a=0;an&&(n=t,s=e)}}const d=getPlaneNormal([],l.point,h.point,s.point),p=dot(l.point,d);for(n=-1,a=0;an&&(n=t,o=e)}}const f=[];if(dot(o.point,d)-p<0)for(f.push(Face.createTriangle(l,h,s),Face.createTriangle(o,h,l),Face.createTriangle(o,s,h),Face.createTriangle(o,l,s)),a=0;a<3;a+=1){const e=(a+1)%3;f[a+1].getEdge(2).setOpposite(f[0].getEdge(e)),f[a+1].getEdge(1).setOpposite(f[e+1].getEdge(0))}else for(f.push(Face.createTriangle(l,s,h),Face.createTriangle(o,l,h),Face.createTriangle(o,h,s),Face.createTriangle(o,s,l)),a=0;a<3;a+=1){const e=(a+1)%3;f[a+1].getEdge(2).setOpposite(f[0].getEdge((3-a)%3)),f[a+1].getEdge(0).setOpposite(f[e+1].getEdge(1))}for(a=0;a<4;a+=1)this.faces.push(f[a]);for(a=0;an&&(n=i,e=f[c])}e&&this.addVertexToFace(t,e)}}}reindexFaceAndVertices(){const e=[];for(let t=0;ti&&(i=o,e=t)}return e}}computeHorizon(e,t,i,s){let o;this.deleteFaceVertices(i),i.mark=DELETED,o=t?t.next:t=i.getEdge(0);do{const t=o.opposite,i=t.face;i.mark===VISIBLE&&(i.distanceToPlane(e)>this.tolerance?this.computeHorizon(e,t,i,s):s.push(o)),o=o.next}while(o!==t)}addAdjoiningFace(e,t){const i=Face.createTriangle(e,t.tail(),t.head());return this.faces.push(i),i.getEdge(-1).setOpposite(t.opposite),i.getEdge(0)}addNewFaces(e,t){let i,s;this.newFaces=[];for(let o=0;o=e.nVertices)throw Error("merge recursion limit exceeded");const a=i.opposite.face;let c=!1;if(t===MERGE_NON_CONVEX?(this.oppositeFaceDistance(i)>-this.tolerance||this.oppositeFaceDistance(i.opposite)>-this.tolerance)&&(c=!0):e.area>a.area?this.oppositeFaceDistance(i)>-this.tolerance?c=!0:this.oppositeFaceDistance(i.opposite)>-this.tolerance&&(s=!1):this.oppositeFaceDistance(i.opposite)>-this.tolerance?c=!0:this.oppositeFaceDistance(i)>-this.tolerance&&(s=!1),c){const t=e.mergeAdjacentFaces(i,[]);for(let i=0;i{const a=[0,0,0];return subtract(r,e,s),subtract(a,s,t),cross(r,r,a),normalize(r,r)};module.exports=planeNormal; -},{"../../../maths/vec3/cross":338,"../../../maths/vec3/normalize":353,"../../../maths/vec3/subtract":362}],471:[function(require,module,exports){ +},{"../../../maths/vec3/cross":338,"../../../maths/vec3/normalize":353,"../../../maths/vec3/subtract":362}],472:[function(require,module,exports){ const QuickHull=require("./QuickHull"),runner=(u,l={})=>{const e=new QuickHull(u);return e.build(),e.collectFaces(l.skipTriangulation)};module.exports=runner; -},{"./QuickHull":467}],472:[function(require,module,exports){ +},{"./QuickHull":468}],473:[function(require,module,exports){ const cross=require("../../../maths/vec3/cross"),subtract=require("../../../maths/vec3/subtract"),squaredLength=require("../../../maths/vec3/squaredLength"),distanceSquared=(e,t,r)=>{const s=[],a=[];subtract(s,r,t),subtract(a,e,t);const n=squaredLength(cross([],a,s)),c=squaredLength(s);if(0===c)throw Error("a and b are the same point");return n/c},pointLineDistance=(e,t,r)=>Math.sqrt(distanceSquared(e,t,r));module.exports=pointLineDistance; -},{"../../../maths/vec3/cross":338,"../../../maths/vec3/squaredLength":361,"../../../maths/vec3/subtract":362}],473:[function(require,module,exports){ +},{"../../../maths/vec3/cross":338,"../../../maths/vec3/squaredLength":361,"../../../maths/vec3/subtract":362}],474:[function(require,module,exports){ const geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),toUniquePoints=o=>{const e=new Set,t=[],r=o=>{const r=o.toString();e.has(r)||(t.push(o),e.add(r))};return o.forEach(o=>{geom2.isA(o)?geom2.toPoints(o).forEach(r):geom3.isA(o)?geom3.toPoints(o).forEach(o=>o.forEach(r)):path2.isA(o)&&path2.toPoints(o).forEach(r)}),t};module.exports=toUniquePoints; -},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../geometries/path2":186}],474:[function(require,module,exports){ +},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../geometries/path2":186}],475:[function(require,module,exports){ const flatten=require("../../utils/flatten"),measureEpsilon=require("../../measurements/measureEpsilon"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),snapPolygons=require("./snapPolygons"),mergePolygons=require("./mergePolygons"),insertTjunctions=require("./insertTjunctions"),triangulatePolygons=require("./triangulatePolygons"),generalizePath2=(e,r)=>r,generalizeGeom2=(e,r)=>r,generalizeGeom3=(e,r)=>{const{snap:n,simplify:o,triangulate:t}=Object.assign({},{snap:!1,simplify:!1,triangulate:!1},e),i=measureEpsilon(r);let s=geom3.toPolygons(r);n&&(s=snapPolygons(i,s)),o&&(s=mergePolygons(i,s)),t&&(s=insertTjunctions(s),s=triangulatePolygons(i,s));const g=Object.assign({},r);return g.polygons=s,g},generalize=(e,...r)=>{if(0===(r=flatten(r)).length)throw new Error("wrong number of arguments");const n=r.map(r=>{if(path2.isA(r))return generalizePath2(0,r);if(geom2.isA(r))return generalizeGeom2(0,r);if(geom3.isA(r))return generalizeGeom3(e,r);throw new Error("invalid geometry")});return 1===n.length?n[0]:n};module.exports=generalize; -},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../geometries/path2":186,"../../measurements/measureEpsilon":387,"../../utils/flatten":521,"./insertTjunctions":476,"./mergePolygons":477,"./snapPolygons":481,"./triangulatePolygons":482}],475:[function(require,module,exports){ +},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../geometries/path2":186,"../../measurements/measureEpsilon":387,"../../utils/flatten":522,"./insertTjunctions":477,"./mergePolygons":478,"./snapPolygons":482,"./triangulatePolygons":483}],476:[function(require,module,exports){ module.exports={generalize:require("./generalize"),snap:require("./snap"),retessellate:require("./retessellate")}; -},{"./generalize":474,"./retessellate":479,"./snap":480}],476:[function(require,module,exports){ +},{"./generalize":475,"./retessellate":480,"./snap":481}],477:[function(require,module,exports){ const constants=require("../../maths/constants"),vec3=require("../../maths/vec3"),poly3=require("../../geometries/poly3"),assert=!1,getTag=e=>`${e}`,addSide=(e,t,s,n,r,c)=>{const o=getTag(n),g=getTag(r);const l=`${o}/${g}`,a=`${g}/${o}`;if(e.has(a))return deleteSide(e,t,s,r,n,null),null;const i={vertex0:n,vertex1:r,polygonindex:c};return e.has(l)?e.get(l).push(i):e.set(l,[i]),t.has(o)?t.get(o).push(l):t.set(o,[l]),s.has(g)?s.get(g).push(l):s.set(g,[l]),l},deleteSide=(e,t,s,n,r,c)=>{const o=getTag(n),g=getTag(r),l=`${o}/${g}`;let a=-1;const i=e.get(l);for(let e=0;e{const t=new Map;for(let s=0;s=3){let e=n.vertices[0],c=getTag(e);for(let o=0;o0){const s=new Map,n=new Map,r=new Map;for(const[e,c]of t)r.set(e,!0),c.forEach(t=>{const r=getTag(t.vertex0),c=getTag(t.vertex1);s.has(r)?s.get(r).push(e):s.set(r,[e]),n.has(c)?n.get(c).push(e):n.set(c,[e])});const c=e.slice(0);for(;0!==t.size;){for(const e of t.keys())r.set(e,!0);let e=!1;for(;;){const o=Array.from(r.keys());if(0===o.length)break;const g=o[0];let l=!0;if(t.has(g)){const o=t.get(g);0;const a=o[0];for(let o=0;o<2;o++){const g=0===o?a.vertex0:a.vertex1,i=0===o?a.vertex1:a.vertex0,v=getTag(g),d=getTag(i);let h=[];0===o?n.has(v)&&(h=n.get(v)):s.has(v)&&(h=s.get(v));for(let a=0;a0&&x<1){const g=vec3.scale(vec3.create(),h,x);if(vec3.add(g,g,a),vec3.squaredDistance(g,v){const n=poly3.toPoints(e),t=[];for(let e=0;e{const t=`${n.v1}:${n.v2}`;e.set(t,n)},deleteEdge=(e,n)=>{const t=`${n.v1}:${n.v2}`;e.delete(t)},findOppositeEdge=(e,n)=>{const t=`${n.v2}:${n.v1}`;return e.get(t)},calculateAnglesBetween=(e,n,t)=>{let l=e.prev.v1,r=e.prev.v2,o=n.next.v2;const v=calculateAngle(l,r,o,t);return l=n.prev.v1,r=n.prev.v2,o=e.next.v2,[v,calculateAngle(l,r,o,t)]},v1=vec3.create(),v2=vec3.create(),calculateAngle=(e,n,t,l)=>{const r=vec3.subtract(v1,n,e),o=vec3.subtract(v2,t,n);return vec3.cross(r,r,o),vec3.dot(r,l)},createPolygonAnd=e=>{let n;const t=[];for(;e.next;){const n=e.next;t.push(e.v1),e.v1=null,e.v2=null,e.next=null,e.prev=null,e=n}return t.length>0&&(n=poly3.create(t)),n},mergeCoplanarPolygons=e=>{if(e.length<2)return e;const n=e[0].plane,t=e.slice(),l=new Map;for(;t.length>0;){const e=t.shift(),r=createEdges(e);for(let e=0;e=0&&e[1]>=0){const n=o.next,r=t.next;t.prev.next=o.next,t.next.prev=o.prev,o.prev.next=t.next,o.next.prev=t.prev,t.v1=null,t.v2=null,t.next=null,t.prev=null,deleteEdge(l,o),o.v1=null,o.v2=null,o.next=null,o.prev=null;const v=(e,n,t)=>{const l={v1:t.v1,v2:n.v2,next:n.next,prev:t.prev};t.prev.next=l,n.next.prev=l,deleteEdge(e,n),n.v1=null,n.v2=null,n.next=null,n.prev=null,deleteEdge(e,t),t.v1=null,t.v2=null,t.next=null,t.prev=null};0===e[0]&&v(l,n,n.prev),0===e[1]&&v(l,r,r.prev)}}else t.next&&insertEdge(l,t)}}const r=[];return l.forEach(e=>{const n=createPolygonAnd(e);n&&r.push(n)}),l.clear(),r},coplanar=(e,n)=>Math.abs(e[3]-n[3])<1.5e-7&&aboutEqualNormals(e,n),mergePolygons=(e,n)=>{const t=[];n.forEach(e=>{const n=t.find(n=>coplanar(n[0],poly3.plane(e)));if(n){n[1].push(e)}else t.push([poly3.plane(e),[e]])});let l=[];return t.forEach(e=>{const n=e[1],t=mergeCoplanarPolygons(n);l=l.concat(t)}),l};module.exports=mergePolygons; -},{"../../geometries/poly3":203,"../../maths/utils/aboutEqualNormals":291,"../../maths/vec3":346}],478:[function(require,module,exports){ +},{"../../geometries/poly3":203,"../../maths/utils/aboutEqualNormals":291,"../../maths/vec3":346}],479:[function(require,module,exports){ const{EPS:EPS}=require("../../maths/constants"),line2=require("../../maths/line2"),vec2=require("../../maths/vec2"),OrthoNormalBasis=require("../../maths/OrthoNormalBasis"),interpolateBetween2DPointsForY=require("../../maths/utils/interpolateBetween2DPointsForY"),{insertSorted:insertSorted,fnNumberSort:fnNumberSort}=require("../../utils"),poly3=require("../../geometries/poly3"),reTesselateCoplanarPolygons=t=>{if(t.length<2)return t;const e=[],o=t.length,n=poly3.plane(t[0]),l=new OrthoNormalBasis(n),i=[],r=[],s=new Map,f=new Map,p=new Map,h=10/EPS;for(let e=0;e0){let t,i;for(let r=0;ri)&&(i=u);let m=f.get(u);m||(m={},f.set(u,m)),m[e]=!0}if(t>=i)n=[],g=0,c=-1;else{let o=s.get(t);o||(o=[],s.set(t,o)),o.push(e)}}n.reverse(),c=g-c-1,i.push(n),r.push(c)}const g=[];f.forEach((t,e)=>g.push(e)),g.sort(fnNumberSort);let c=[],a=[];for(let t=0;t=l&&(t=0),n[t][1]!==p)break;r=t}let f=s-1;if(f<0&&(f=l-1),n[f][1]===p&&(s=f),r!==e.leftvertexindex&&r===s)c.splice(t,1),--t;else{e.leftvertexindex=r,e.rightvertexindex=s,e.topleft=n[r],e.topright=n[s];let t=r+1;t>=l&&(t=0),e.bottomleft=n[t];let o=s-1;o<0&&(o=l-1),e.bottomright=n[o]}}}let u;if(t>=g.length-1)c=[],u=null;else{const e=.5*(p+(u=Number(g[t+1]))),o=s.get(p);for(const t in o){const n=o[t],l=i[n],s=l.length,f=r[n];let h=f;for(;;){let t=h+1;if(t>=s&&(t=0),l[t][1]!==p)break;if(t===f)break;h=t}let g=f;for(;;){let t=g-1;if(t<0&&(t=s-1),l[t][1]!==p)break;if(t===h)break;g=t}let a=h+1;a>=s&&(a=0);let u=g-1;u<0&&(u=s-1);const m={polygonindex:n,leftvertexindex:h,rightvertexindex:g,topleft:l[h],topright:l[g],bottomleft:l[a],bottomright:l[u]};insertSorted(c,m,(t,o)=>{const n=interpolateBetween2DPointsForY(t.topleft,t.bottomleft,e),l=interpolateBetween2DPointsForY(o.topleft,o.bottomleft,e);return n>l?1:n0){const t=o[o.length-1],e=vec2.distance(f.topleft,t.topright),n=vec2.distance(f.bottomleft,t.bottomright);e0){const t=new Set,i=new Set;for(let e=0;e=0;(g||s>=0)&&a&&(n.outpolygon=o.outpolygon,n.leftlinecontinues=g,n.rightlinecontinues=c,t.add(e));break}}}for(let o=0;oEPS&&t.outpolygon.leftpoints.push(t.bottomleft),t.outpolygon.leftpoints.reverse();const i=t.outpolygon.rightpoints.concat(t.outpolygon.leftpoints).map(t=>l.to3D(t)),r=poly3.fromPointsAndPlane(i,n);r.vertices.length&&e.push(r)}}for(let t=0;tEPS&&e.outpolygon.rightpoints.push(e.topright))}a=o}return e};module.exports=reTesselateCoplanarPolygons; -},{"../../geometries/poly3":203,"../../maths/OrthoNormalBasis":217,"../../maths/constants":218,"../../maths/line2":229,"../../maths/utils/interpolateBetween2DPointsForY":294,"../../maths/vec2":315,"../../utils":523}],479:[function(require,module,exports){ +},{"../../geometries/poly3":203,"../../maths/OrthoNormalBasis":217,"../../maths/constants":218,"../../maths/line2":229,"../../maths/utils/interpolateBetween2DPointsForY":294,"../../maths/vec2":315,"../../utils":524}],480:[function(require,module,exports){ const geom3=require("../../geometries/geom3"),poly3=require("../../geometries/poly3"),{NEPS:NEPS}=require("../../maths/constants"),reTesselateCoplanarPolygons=require("./reTesselateCoplanarPolygons"),retessellate=e=>{if(e.isRetesselated)return e;const s=geom3.toPolygons(e).map((e,s)=>({vertices:e.vertices,plane:poly3.plane(e),index:s})),o=classifyPolygons(s),l=[];o.forEach(e=>{if(Array.isArray(e)){const s=reTesselateCoplanarPolygons(e);l.push(...s)}else l.push(e)});const n=geom3.create(l);return n.isRetesselated=!0,n},classifyPolygons=e=>{let s=[e];const o=[];for(let e=3;e>=0;e--){const l=[],n=3===e?1.5e-8:NEPS;s.forEach(s=>{s.sort(byPlaneComponent(e,n));let t=0;for(let r=1;rn&&(r-t==1?o.push(s[t]):l.push(s.slice(t,r)),t=r);s.length-t==1?o.push(s[t]):l.push(s.slice(t))}),s=l}const l=[];return s.forEach(e=>{e[0]&&(l[e[0].index]=e)}),o.forEach(e=>{l[e.index]=e}),l},byPlaneComponent=(e,s)=>(o,l)=>o.plane[e]-l.plane[e]>s?1:l.plane[e]-o.plane[e]>s?-1:0;module.exports=retessellate; -},{"../../geometries/geom3":165,"../../geometries/poly3":203,"../../maths/constants":218,"./reTesselateCoplanarPolygons":478}],480:[function(require,module,exports){ +},{"../../geometries/geom3":165,"../../geometries/poly3":203,"../../maths/constants":218,"./reTesselateCoplanarPolygons":479}],481:[function(require,module,exports){ const flatten=require("../../utils/flatten"),vec2=require("../../maths/vec2"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),measureEpsilon=require("../../measurements/measureEpsilon"),snapPolygons=require("./snapPolygons"),snapPath2=e=>{const s=measureEpsilon(e),r=path2.toPoints(e).map(e=>vec2.snap(vec2.create(),e,s));return path2.create(r)},snapGeom2=e=>{const s=measureEpsilon(e);let r=geom2.toSides(e).map(e=>[vec2.snap(vec2.create(),e[0],s),vec2.snap(vec2.create(),e[1],s)]);return r=r.filter(e=>!vec2.equals(e[0],e[1])),geom2.create(r)},snapGeom3=e=>{const s=measureEpsilon(e),r=geom3.toPolygons(e),o=snapPolygons(s,r);return geom3.create(o)},snap=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");const s=e.map(e=>path2.isA(e)?snapPath2(e):geom2.isA(e)?snapGeom2(e):geom3.isA(e)?snapGeom3(e):e);return 1===s.length?s[0]:s};module.exports=snap; -},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../geometries/path2":186,"../../maths/vec2":315,"../../measurements/measureEpsilon":387,"../../utils/flatten":521,"./snapPolygons":481}],481:[function(require,module,exports){ +},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../geometries/path2":186,"../../maths/vec2":315,"../../measurements/measureEpsilon":387,"../../utils/flatten":522,"./snapPolygons":482}],482:[function(require,module,exports){ const vec3=require("../../maths/vec3"),poly3=require("../../geometries/poly3"),isValidPoly3=(e,o)=>{const r=Math.abs(poly3.measureArea(o));return Number.isFinite(r)&&r>e},snapPolygons=(e,o)=>{let r=o.map(o=>{const r=o.vertices.map(o=>vec3.snap(vec3.create(),o,e)),t=[];for(let e=0;eisValidPoly3(t,e))};module.exports=snapPolygons; -},{"../../geometries/poly3":203,"../../maths/vec3":346}],482:[function(require,module,exports){ +},{"../../geometries/poly3":203,"../../maths/vec3":346}],483:[function(require,module,exports){ const vec3=require("../../maths/vec3"),poly3=require("../../geometries/poly3"),triangulatePolygon=(e,o,r)=>{const t=o.vertices.length;if(t>3){if(t>4){const c=[0,0,0];o.vertices.forEach(e=>vec3.add(c,c,e)),vec3.snap(c,vec3.divide(c,c,[t,t,t]),e);for(let e=0;e{const r=[];return o.forEach(o=>{triangulatePolygon(e,o,r)}),r};module.exports=triangulatePolygons; -},{"../../geometries/poly3":203,"../../maths/vec3":346}],483:[function(require,module,exports){ +},{"../../geometries/poly3":203,"../../maths/vec3":346}],484:[function(require,module,exports){ const flatten=require("../../utils/flatten"),padArrayToLength=require("../../utils/padArrayToLength"),measureAggregateBoundingBox=require("../../measurements/measureAggregateBoundingBox"),{translate:translate}=require("./translate"),validateOptions=e=>{if(!Array.isArray(e.modes)||e.modes.length>3)throw new Error("align(): modes must be an array of length <= 3");if(e.modes=padArrayToLength(e.modes,"none",3),3!==e.modes.filter(e=>["center","max","min","none"].includes(e)).length)throw new Error('align(): all modes must be one of "center", "max" or "min"');if(!Array.isArray(e.relativeTo)||e.relativeTo.length>3)throw new Error("align(): relativeTo must be an array of length <= 3");if(e.relativeTo=padArrayToLength(e.relativeTo,0,3),3!==e.relativeTo.filter(e=>Number.isFinite(e)||null==e).length)throw new Error("align(): all relativeTo values must be a number, or null.");if("boolean"!=typeof e.grouped)throw new Error("align(): grouped must be a boolean value.");return e},populateRelativeToFromBounds=(e,r,t)=>{for(let n=0;n<3;n++)null==e[n]&&("center"===r[n]?e[n]=(t[0][n]+t[1][n])/2:"max"===r[n]?e[n]=t[1][n]:"min"===r[n]&&(e[n]=t[0][n]));return e},alignGeometries=(e,r,t)=>{const n=measureAggregateBoundingBox(e),o=[0,0,0];for(let e=0;e<3;e++)"center"===r[e]?o[e]=t[e]-(n[0][e]+n[1][e])/2:"max"===r[e]?o[e]=t[e]-n[1][e]:"min"===r[e]&&(o[e]=t[e]-n[0][e]);return translate(o,e)},align=(e,...r)=>{e=Object.assign({},{modes:["center","center","min"],relativeTo:[0,0,0],grouped:!1},e),e=validateOptions(e);let{modes:t,relativeTo:n,grouped:o}=e;if(0===(r=flatten(r)).length)throw new Error("align(): No geometries were provided to act upon");if(n.filter(e=>null==e).length){const e=measureAggregateBoundingBox(r);n=populateRelativeToFromBounds(n,t,e)}return 1===(r=o?alignGeometries(r,t,n):r.map(e=>alignGeometries(e,t,n))).length?r[0]:r};module.exports=align; -},{"../../measurements/measureAggregateBoundingBox":378,"../../utils/flatten":521,"../../utils/padArrayToLength":525,"./translate":490}],484:[function(require,module,exports){ +},{"../../measurements/measureAggregateBoundingBox":378,"../../utils/flatten":522,"../../utils/padArrayToLength":526,"./translate":491}],485:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),measureBoundingBox=require("../../measurements/measureBoundingBox"),{translate:translate}=require("./translate"),centerGeometry=(e,r)=>{const{axes:t,relativeTo:n}=Object.assign({},{axes:[!0,!0,!0],relativeTo:[0,0,0]},e),a=measureBoundingBox(r),o=[0,0,0];return t[0]&&(o[0]=n[0]-(a[0][0]+(a[1][0]-a[0][0])/2)),t[1]&&(o[1]=n[1]-(a[0][1]+(a[1][1]-a[0][1])/2)),t[2]&&(o[2]=n[2]-(a[0][2]+(a[1][2]-a[0][2])/2)),translate(o,r)},center=(e,...r)=>{const{axes:t,relativeTo:n}=Object.assign({},{axes:[!0,!0,!0],relativeTo:[0,0,0]},e);if(0===(r=flatten(r)).length)throw new Error("wrong number of arguments");if(3!==n.length)throw new Error("relativeTo must be an array of length 3");e={axes:t,relativeTo:n};const a=r.map(r=>path2.isA(r)?centerGeometry(e,r):geom2.isA(r)?centerGeometry(e,r):geom3.isA(r)?centerGeometry(e,r):r);return 1===a.length?a[0]:a},centerX=(...e)=>center({axes:[!0,!1,!1]},e),centerY=(...e)=>center({axes:[!1,!0,!1]},e),centerZ=(...e)=>center({axes:[!1,!1,!0]},e);module.exports={center:center,centerX:centerX,centerY:centerY,centerZ:centerZ}; -},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../geometries/path2":186,"../../measurements/measureBoundingBox":382,"../../utils/flatten":521,"./translate":490}],485:[function(require,module,exports){ +},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../geometries/path2":186,"../../measurements/measureBoundingBox":382,"../../utils/flatten":522,"./translate":491}],486:[function(require,module,exports){ module.exports={align:require("./align"),center:require("./center").center,centerX:require("./center").centerX,centerY:require("./center").centerY,centerZ:require("./center").centerZ,mirror:require("./mirror").mirror,mirrorX:require("./mirror").mirrorX,mirrorY:require("./mirror").mirrorY,mirrorZ:require("./mirror").mirrorZ,rotate:require("./rotate").rotate,rotateX:require("./rotate").rotateX,rotateY:require("./rotate").rotateY,rotateZ:require("./rotate").rotateZ,scale:require("./scale").scale,scaleX:require("./scale").scaleX,scaleY:require("./scale").scaleY,scaleZ:require("./scale").scaleZ,transform:require("./transform"),translate:require("./translate").translate,translateX:require("./translate").translateX,translateY:require("./translate").translateY,translateZ:require("./translate").translateZ}; -},{"./align":483,"./center":484,"./mirror":486,"./rotate":487,"./scale":488,"./transform":489,"./translate":490}],486:[function(require,module,exports){ +},{"./align":484,"./center":485,"./mirror":487,"./rotate":488,"./scale":489,"./transform":490,"./translate":491}],487:[function(require,module,exports){ const flatten=require("../../utils/flatten"),mat4=require("../../maths/mat4"),plane=require("../../maths/plane"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),mirror=(r,...e)=>{const{origin:o,normal:m}=Object.assign({},{origin:[0,0,0],normal:[0,0,1]},r);if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");const i=plane.fromNormalAndPoint(plane.create(),m,o);if(Number.isNaN(i[0]))throw new Error("the given origin and normal do not define a proper plane");const n=mat4.mirrorByPlane(mat4.create(),i),t=e.map(r=>path2.isA(r)?path2.transform(n,r):geom2.isA(r)?geom2.transform(n,r):geom3.isA(r)?geom3.transform(n,r):r);return 1===t.length?t[0]:t},mirrorX=(...r)=>mirror({normal:[1,0,0]},r),mirrorY=(...r)=>mirror({normal:[0,1,0]},r),mirrorZ=(...r)=>mirror({normal:[0,0,1]},r);module.exports={mirror:mirror,mirrorX:mirrorX,mirrorY:mirrorY,mirrorZ:mirrorZ}; -},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../geometries/path2":186,"../../maths/mat4":267,"../../maths/plane":287,"../../utils/flatten":521}],487:[function(require,module,exports){ +},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../geometries/path2":186,"../../maths/mat4":267,"../../maths/plane":287,"../../utils/flatten":522}],488:[function(require,module,exports){ const flatten=require("../../utils/flatten"),mat4=require("../../maths/mat4"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),rotate=(t,...e)=>{if(!Array.isArray(t))throw new Error("angles must be an array");if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");for(t=t.slice();t.length<3;)t.push(0);const r=t[2],o=t[1],a=t[0],m=mat4.fromTaitBryanRotation(mat4.create(),r,o,a),n=e.map(t=>path2.isA(t)?path2.transform(m,t):geom2.isA(t)?geom2.transform(m,t):geom3.isA(t)?geom3.transform(m,t):t);return 1===n.length?n[0]:n},rotateX=(t,...e)=>rotate([t,0,0],e),rotateY=(t,...e)=>rotate([0,t,0],e),rotateZ=(t,...e)=>rotate([0,0,t],e);module.exports={rotate:rotate,rotateX:rotateX,rotateY:rotateY,rotateZ:rotateZ}; -},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../geometries/path2":186,"../../maths/mat4":267,"../../utils/flatten":521}],488:[function(require,module,exports){ +},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../geometries/path2":186,"../../maths/mat4":267,"../../utils/flatten":522}],489:[function(require,module,exports){ const flatten=require("../../utils/flatten"),mat4=require("../../maths/mat4"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),scale=(e,...r)=>{if(!Array.isArray(e))throw new Error("factors must be an array");if(0===(r=flatten(r)).length)throw new Error("wrong number of arguments");for(e=e.slice();e.length<3;)e.push(1);if(e[0]<=0||e[1]<=0||e[2]<=0)throw new Error("factors must be positive");const a=mat4.fromScaling(mat4.create(),e),t=r.map(e=>path2.isA(e)?path2.transform(a,e):geom2.isA(e)?geom2.transform(a,e):geom3.isA(e)?geom3.transform(a,e):e);return 1===t.length?t[0]:t},scaleX=(e,...r)=>scale([e,1,1],r),scaleY=(e,...r)=>scale([1,e,1],r),scaleZ=(e,...r)=>scale([1,1,e],r);module.exports={scale:scale,scaleX:scaleX,scaleY:scaleY,scaleZ:scaleZ}; -},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../geometries/path2":186,"../../maths/mat4":267,"../../utils/flatten":521}],489:[function(require,module,exports){ +},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../geometries/path2":186,"../../maths/mat4":267,"../../utils/flatten":522}],490:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),transform=(e,...r)=>{if(0===(r=flatten(r)).length)throw new Error("wrong number of arguments");const t=r.map(r=>path2.isA(r)?path2.transform(e,r):geom2.isA(r)?geom2.transform(e,r):geom3.isA(r)?geom3.transform(e,r):r);return 1===t.length?t[0]:t};module.exports=transform; -},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../geometries/path2":186,"../../utils/flatten":521}],490:[function(require,module,exports){ +},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../geometries/path2":186,"../../utils/flatten":522}],491:[function(require,module,exports){ const flatten=require("../../utils/flatten"),mat4=require("../../maths/mat4"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),translate=(t,...e)=>{if(!Array.isArray(t))throw new Error("offset must be an array");if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");for(t=t.slice();t.length<3;)t.push(0);const r=mat4.fromTranslation(mat4.create(),t),a=e.map(t=>path2.isA(t)?path2.transform(r,t):geom2.isA(t)?geom2.transform(r,t):geom3.isA(t)?geom3.transform(r,t):t);return 1===a.length?a[0]:a},translateX=(t,...e)=>translate([t,0,0],e),translateY=(t,...e)=>translate([0,t,0],e),translateZ=(t,...e)=>translate([0,0,t],e);module.exports={translate:translate,translateX:translateX,translateY:translateY,translateZ:translateZ}; -},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../geometries/path2":186,"../../maths/mat4":267,"../../utils/flatten":521}],491:[function(require,module,exports){ +},{"../../geometries/geom2":149,"../../geometries/geom3":165,"../../geometries/path2":186,"../../maths/mat4":267,"../../utils/flatten":522}],492:[function(require,module,exports){ const{EPS:EPS,TAU:TAU}=require("../maths/constants"),vec2=require("../maths/vec2"),path2=require("../geometries/path2"),{isGT:isGT,isGTE:isGTE,isNumberArray:isNumberArray}=require("./commonChecks"),arc=e=>{const r={center:[0,0],radius:1,startAngle:0,endAngle:TAU,makeTangent:!1,segments:32};let{center:t,radius:s,startAngle:n,endAngle:a,makeTangent:o,segments:c}=Object.assign({},r,e);if(!isNumberArray(t,2))throw new Error("center must be an array of X and Y values");if(!isGT(s,0))throw new Error("radius must be greater than zero");if(!isGTE(n,0))throw new Error("startAngle must be positive");if(!isGTE(a,0))throw new Error("endAngle must be positive");if(!isGTE(c,4))throw new Error("segments must be four or more");let i=TAU;(n%=TAU)<(a%=TAU)&&(i=a-n),n>a&&(i=a+(TAU-n));const m=Math.acos((s*s+s*s-EPS*EPS)/(2*s*s)),l=vec2.clone(t);let u;const A=[];if(i.25&&(r=.25);const t=o?e+2:e;for(let a=0;a<=t;a++){let t=a;o&&((t=(a-1)*(e-2*r)/e+r)<0&&(t=0),t>e&&(t=e));const c=n+t*(i/e);u=vec2.fromAngleRadians(vec2.create(),c),vec2.scale(u,u,s),vec2.add(u,u,l),A.push(u)}}return path2.fromPoints({closed:!1},A)};module.exports=arc; -},{"../geometries/path2":186,"../maths/constants":218,"../maths/vec2":315,"./commonChecks":493}],492:[function(require,module,exports){ +},{"../geometries/path2":186,"../maths/constants":218,"../maths/vec2":315,"./commonChecks":494}],493:[function(require,module,exports){ const{TAU:TAU}=require("../maths/constants"),ellipse=require("./ellipse"),{isGTE:isGTE}=require("./commonChecks"),circle=e=>{const s={center:[0,0],radius:1,startAngle:0,endAngle:TAU,segments:32};let{center:r,radius:t,startAngle:n,endAngle:i,segments:l}=Object.assign({},s,e);if(!isGTE(t,0))throw new Error("radius must be positive");return ellipse({center:r,radius:t=[t,t],startAngle:n,endAngle:i,segments:l})};module.exports=circle; -},{"../maths/constants":218,"./commonChecks":493,"./ellipse":498}],493:[function(require,module,exports){ +},{"../maths/constants":218,"./commonChecks":494,"./ellipse":499}],494:[function(require,module,exports){ const isNumberArray=(i,r)=>!!(Array.isArray(i)&&i.length>=r)&&i.every(i=>Number.isFinite(i)),isGT=(i,r)=>Number.isFinite(i)&&i>r,isGTE=(i,r)=>Number.isFinite(i)&&i>=r;module.exports={isNumberArray:isNumberArray,isGT:isGT,isGTE:isGTE}; -},{}],494:[function(require,module,exports){ +},{}],495:[function(require,module,exports){ const cuboid=require("./cuboid"),{isGTE:isGTE}=require("./commonChecks"),cube=e=>{let{center:i,size:r}=Object.assign({},{center:[0,0,0],size:2},e);if(!isGTE(r,0))throw new Error("size must be positive");return cuboid({center:i,size:r=[r,r,r]})};module.exports=cube; -},{"./commonChecks":493,"./cuboid":495}],495:[function(require,module,exports){ +},{"./commonChecks":494,"./cuboid":496}],496:[function(require,module,exports){ const geom3=require("../geometries/geom3"),poly3=require("../geometries/poly3"),{isNumberArray:isNumberArray}=require("./commonChecks"),cuboid=e=>{const{center:r,size:o}=Object.assign({},{center:[0,0,0],size:[2,2,2]},e);if(!isNumberArray(r,3))throw new Error("center must be an array of X, Y and Z values");if(!isNumberArray(o,3))throw new Error("size must be an array of width, depth and height values");if(!o.every(e=>e>=0))throw new Error("size values must be positive");return 0===o[0]||0===o[1]||0===o[2]?geom3.create():geom3.create([[[0,4,6,2],[-1,0,0]],[[1,3,7,5],[1,0,0]],[[0,1,5,4],[0,-1,0]],[[2,6,7,3],[0,1,0]],[[0,2,3,1],[0,0,-1]],[[4,5,7,6],[0,0,1]]].map(e=>{const t=e[0].map(e=>{return[r[0]+o[0]/2*(2*!!(1&e)-1),r[1]+o[1]/2*(2*!!(2&e)-1),r[2]+o[2]/2*(2*!!(4&e)-1)]});return poly3.create(t)}))};module.exports=cuboid; -},{"../geometries/geom3":165,"../geometries/poly3":203,"./commonChecks":493}],496:[function(require,module,exports){ +},{"../geometries/geom3":165,"../geometries/poly3":203,"./commonChecks":494}],497:[function(require,module,exports){ const geom3=require("../geometries/geom3"),cylinderElliptic=require("./cylinderElliptic"),{isGTE:isGTE}=require("./commonChecks"),cylinder=e=>{const{center:i,height:r,radius:s,segments:t}=Object.assign({},{center:[0,0,0],height:2,radius:1,segments:32},e);if(!isGTE(s,0))throw new Error("radius must be positive");return 0===r||0===s?geom3.create():cylinderElliptic({center:i,height:r,startRadius:[s,s],endRadius:[s,s],segments:t})};module.exports=cylinder; -},{"../geometries/geom3":165,"./commonChecks":493,"./cylinderElliptic":497}],497:[function(require,module,exports){ +},{"../geometries/geom3":165,"./commonChecks":494,"./cylinderElliptic":498}],498:[function(require,module,exports){ const{EPS:EPS,TAU:TAU}=require("../maths/constants"),vec3=require("../maths/vec3"),geom3=require("../geometries/geom3"),poly3=require("../geometries/poly3"),{sin:sin,cos:cos}=require("../maths/utils/trigonometry"),{isGT:isGT,isGTE:isGTE,isNumberArray:isNumberArray}=require("./commonChecks"),cylinderElliptic=e=>{const r={center:[0,0,0],height:2,startRadius:[1,1],startAngle:0,endRadius:[1,1],endAngle:TAU,segments:32};let{center:s,height:t,startRadius:a,startAngle:i,endRadius:o,endAngle:n,segments:u}=Object.assign({},r,e);if(!isNumberArray(s,3))throw new Error("center must be an array of X, Y and Z values");if(!isGT(t,0))throw new Error("height must be greater then zero");if(!isNumberArray(a,2))throw new Error("startRadius must be an array of X and Y values");if(!a.every(e=>e>=0))throw new Error("startRadius values must be positive");if(!isNumberArray(o,2))throw new Error("endRadius must be an array of X and Y values");if(!o.every(e=>e>=0))throw new Error("endRadius values must be positive");if(o.every(e=>0===e)&&a.every(e=>0===e))throw new Error("at least one radius must be positive");if(!isGTE(i,0))throw new Error("startAngle must be positive");if(!isGTE(n,0))throw new Error("endAngle must be positive");if(!isGTE(u,4))throw new Error("segments must be four or more");let c=TAU;(i%=TAU)<(n%=TAU)&&(c=n-i),i>n&&(c=n+(TAU-i));const l=Math.min(a[0],a[1],o[0],o[1]),m=Math.acos((l*l+l*l-EPS*EPS)/(2*l*l));if(c{const t=r*c+i;return vec3.scale(A,g,s[0]*cos(t)),vec3.scale(w,p,s[1]*sin(t)),vec3.add(A,A,w),vec3.scale(E,f,e),vec3.add(E,E,d),vec3.add(vec3.create(),A,E)},T=(...e)=>{const r=e.map(e=>vec3.add(vec3.create(),e,s));return poly3.create(r)},b=[];for(let e=0;e0&&a[1]>0&&b.push(T(d,y(0,s,a),y(0,r,a))),(a[0]>0||a[1]>0)&&b.push(T(y(0,r,a),y(0,s,a),y(1,r,o))),o[0]>0&&o[1]>0&&b.push(T(v,y(1,r,o),y(1,s,o))),(o[0]>0||o[1]>0)&&b.push(T(y(1,r,o),y(0,s,a),y(1,s,o))))}return c{const r={center:[0,0],radius:[1,1],startAngle:0,endAngle:TAU,segments:32};let{center:s,radius:t,startAngle:n,endAngle:o,segments:i}=Object.assign({},r,e);if(!isNumberArray(s,2))throw new Error("center must be an array of X and Y values");if(!isNumberArray(t,2))throw new Error("radius must be an array of X and Y values");if(!t.every(e=>e>=0))throw new Error("radius values must be positive");if(!isGTE(n,0))throw new Error("startAngle must be positive");if(!isGTE(o,0))throw new Error("endAngle must be positive");if(!isGTE(i,3))throw new Error("segments must be three or more");if(0===t[0]||0===t[1])return geom2.create();let a=TAU;(n%=TAU)<(o%=TAU)&&(a=o-n),n>o&&(a=o+(TAU-n));const m=Math.min(t[0],t[1]);if(a{const{center:c,radius:r,segments:s,axes:a}=Object.assign({},{center:[0,0,0],radius:[1,1,1],segments:32,axes:[[1,0,0],[0,-1,0],[0,0,1]]},e);if(!isNumberArray(c,3))throw new Error("center must be an array of X, Y and Z values");if(!isNumberArray(r,3))throw new Error("radius must be an array of X, Y and Z values");if(!r.every(e=>e>=0))throw new Error("radius values must be positive");if(!isGTE(s,4))throw new Error("segments must be four or more");if(0===r[0]||0===r[1]||0===r[2])return geom3.create();const t=vec3.scale(vec3.create(),vec3.normalize(vec3.create(),a[0]),r[0]),v=vec3.scale(vec3.create(),vec3.normalize(vec3.create(),a[1]),r[1]),o=vec3.scale(vec3.create(),vec3.normalize(vec3.create(),a[2]),r[2]),i=Math.round(s/4);let l;const u=[],d=vec3.create(),n=vec3.create();for(let e=0;e<=s;e++){const r=TAU*e/s,a=vec3.add(vec3.create(),vec3.scale(d,t,cos(r)),vec3.scale(n,v,sin(r)));if(e>0){let e,r;for(let s=0;s<=i;s++){const t=TAU/4*s/i,v=cos(t),m=sin(t);if(s>0){let t,h=[];t=vec3.subtract(vec3.create(),vec3.scale(d,l,e),vec3.scale(n,o,r)),h.push(vec3.add(t,t,c)),t=vec3.subtract(vec3.create(),vec3.scale(d,a,e),vec3.scale(n,o,r)),h.push(vec3.add(t,t,c)),s{let{radius:r,frequency:t}=Object.assign({},{radius:1,frequency:6},e);if(!isGTE(r,0))throw new Error("radius must be positive");if(!isGTE(t,6))throw new Error("frequency must be six or more");if(0===r)return geom3.create();t=Math.floor(t/6);const o=[[.850651,0,-.525731],[.850651,-0,.525731],[-.850651,-0,.525731],[-.850651,0,-.525731],[0,-.525731,.850651],[0,.525731,.850651],[0,.525731,-.850651],[0,-.525731,-.850651],[-.525731,-.850651,-0],[.525731,-.850651,-0],[.525731,.850651,0],[-.525731,.850651,0]],s=[[0,9,1],[1,10,0],[6,7,0],[10,6,0],[7,9,0],[5,1,4],[4,1,9],[5,10,1],[2,8,3],[3,11,2],[2,5,4],[4,8,2],[2,11,5],[3,7,6],[6,11,3],[8,7,3],[9,8,4],[11,10,5],[10,11,6],[8,9,7]],n=(e,r,t)=>{const o=e[0],s=e[1],n=e[2];let c=t;const f=[],l=[];for(let e=0;e{const o=1-t,s=[];for(let n=0;n<3;n++)s[n]=e[n]*o+r[n]*t;return s};let c=[],f=[],l=0;for(let e=0;e{if(!Array.isArray(r))throw new Error("points must be an array");return path2.fromPoints({},r)};module.exports=line; -},{"../geometries/path2":186}],503:[function(require,module,exports){ +},{"../geometries/path2":186}],504:[function(require,module,exports){ const geom2=require("../geometries/geom2"),polygon=r=>{const{points:o,paths:t,orientation:e}=Object.assign({},{points:[],paths:[],orientation:"counterclockwise"},r);if(!Array.isArray(o)||!Array.isArray(t))throw new Error("points and paths must be arrays");let s=o;Array.isArray(o[0])&&(Array.isArray(o[0][0])||(s=[o])),s.forEach((r,o)=>{if(!Array.isArray(r))throw new Error("list of points "+o+" must be an array");if(r.length<3)throw new Error("list of points "+o+" must contain three or more points");r.forEach((r,t)=>{if(!Array.isArray(r))throw new Error("list of points "+o+", point "+t+" must be an array");if(r.length<2)throw new Error("list of points "+o+", point "+t+" must contain by X and Y values")})});let a=t;if(0===t.length){let r=0;a=s.map(o=>o.map(o=>r++))}const n=[];s.forEach(r=>r.forEach(r=>n.push(r)));let i=[];a.forEach(r=>{const o=r.map(r=>n[r]),t=geom2.fromPoints(o);i=i.concat(geom2.toSides(t))});let c=geom2.create(i);return"clockwise"==e&&(c=geom2.reverse(c)),c};module.exports=polygon; -},{"../geometries/geom2":149}],504:[function(require,module,exports){ +},{"../geometries/geom2":149}],505:[function(require,module,exports){ const geom3=require("../geometries/geom3"),poly3=require("../geometries/poly3"),{isNumberArray:isNumberArray}=require("./commonChecks"),polyhedron=r=>{const e={points:[],faces:[],colors:void 0,orientation:"outward"},{points:o,faces:a,colors:t,orientation:n}=Object.assign({},e,r);if(!Array.isArray(o)||!Array.isArray(a))throw new Error("points and faces must be arrays");if(o.length<3)throw new Error("three or more points are required");if(a.length<1)throw new Error("one or more faces are required");if(t){if(!Array.isArray(t))throw new Error("colors must be an array");if(t.length!==a.length)throw new Error("faces and colors must have the same length")}o.forEach((r,e)=>{if(!isNumberArray(r,3))throw new Error(`point ${e} must be an array of X, Y, Z values`)}),a.forEach((r,e)=>{if(r.length<3)throw new Error(`face ${e} must contain 3 or more indexes`);if(!isNumberArray(r,r.length))throw new Error(`face ${e} must be an array of numbers`)}),"outward"!==n&&a.forEach(r=>r.reverse());const s=a.map((r,e)=>{const a=poly3.create(r.map(r=>o[r]));return t&&t[e]&&(a.color=t[e]),a});return geom3.create(s)};module.exports=polyhedron; -},{"../geometries/geom3":165,"../geometries/poly3":203,"./commonChecks":493}],505:[function(require,module,exports){ +},{"../geometries/geom3":165,"../geometries/poly3":203,"./commonChecks":494}],506:[function(require,module,exports){ const vec2=require("../maths/vec2"),geom2=require("../geometries/geom2"),{isNumberArray:isNumberArray}=require("./commonChecks"),rectangle=e=>{const{center:r,size:t}=Object.assign({},{center:[0,0],size:[2,2]},e);if(!isNumberArray(r,2))throw new Error("center must be an array of X and Y values");if(!isNumberArray(t,2))throw new Error("size must be an array of X and Y values");if(!t.every(e=>e>=0))throw new Error("size values must be positive");if(0===t[0]||0===t[1])return geom2.create();const a=[t[0]/2,t[1]/2],c=[a[0],-a[1]],s=[vec2.subtract(vec2.create(),r,a),vec2.add(vec2.create(),r,c),vec2.add(vec2.create(),r,a),vec2.subtract(vec2.create(),r,c)];return geom2.fromPoints(s)};module.exports=rectangle; -},{"../geometries/geom2":149,"../maths/vec2":315,"./commonChecks":493}],506:[function(require,module,exports){ +},{"../geometries/geom2":149,"../maths/vec2":315,"./commonChecks":494}],507:[function(require,module,exports){ const{EPS:EPS,TAU:TAU}=require("../maths/constants"),vec2=require("../maths/vec2"),vec3=require("../maths/vec3"),geom3=require("../geometries/geom3"),poly3=require("../geometries/poly3"),{sin:sin,cos:cos}=require("../maths/utils/trigonometry"),{isGTE:isGTE,isNumberArray:isNumberArray}=require("./commonChecks"),cuboid=require("./cuboid"),createCorners=(e,r,t,s,c,o)=>{const a=TAU/4*c/s,n=cos(a),i=sin(a),u=s-c;let l=t*n,h=r[2]-(t-t*i);o||(h=t-t*i-r[2]),l=l>EPS?l:0;const d=vec3.add(vec3.create(),e,[r[0]-t,r[1]-t,h]),v=vec3.add(vec3.create(),e,[t-r[0],r[1]-t,h]),m=vec3.add(vec3.create(),e,[t-r[0],t-r[1],h]),p=vec3.add(vec3.create(),e,[r[0]-t,t-r[1],h]),f=[],g=[],E=[],b=[];for(let e=0;e<=u;e++){const r=u>0?TAU/4*e/u:0,t=vec2.fromAngleRadians(vec2.create(),r);vec2.scale(t,t,l);const s=vec3.fromVec2(vec3.create(),t);f.push(vec3.add(vec3.create(),d,s)),vec3.rotateZ(s,s,[0,0,0],TAU/4),g.push(vec3.add(vec3.create(),v,s)),vec3.rotateZ(s,s,[0,0,0],TAU/4),E.push(vec3.add(vec3.create(),m,s)),vec3.rotateZ(s,s,[0,0,0],TAU/4),b.push(vec3.add(vec3.create(),p,s))}return o?[f,g,E,b]:(f.reverse(),g.reverse(),E.reverse(),b.reverse(),[b,E,g,f])},stitchCorners=(e,r)=>{const t=[];for(let s=0;s{const t=[];for(let s=0;s{e=(e=[e[3],e[2],e[1],e[0]]).map(e=>e.slice().reverse());const t=[];e.forEach(e=>{e.forEach(e=>t.push(e))});const s=[];r.forEach(e=>{e.forEach(e=>s.push(e))});const c=[];for(let e=0;e{let{center:r,size:t,roundRadius:s,segments:c}=Object.assign({},{center:[0,0,0],size:[2,2,2],roundRadius:.2,segments:32},e);if(!isNumberArray(r,3))throw new Error("center must be an array of X, Y and Z values");if(!isNumberArray(t,3))throw new Error("size must be an array of X, Y and Z values");if(!t.every(e=>e>=0))throw new Error("size values must be positive");if(!isGTE(s,0))throw new Error("roundRadius must be positive");if(!isGTE(c,4))throw new Error("segments must be four or more");if(0===t[0]||0===t[1]||0===t[2])return geom3.create();if(0===s)return cuboid({center:r,size:t});if(s>(t=t.map(e=>e/2))[0]-EPS||s>t[1]-EPS||s>t[2]-EPS)throw new Error("roundRadius must be smaller than the radius of all dimensions");c=Math.floor(c/4);let o=null,a=null,n=[];for(let e=0;e<=c;e++){const i=createCorners(r,t,s,c,e,!0),u=createCorners(r,t,s,c,e,!1);if(0===e&&(n=n.concat(stitchSides(u,i))),o&&(n=n.concat(stitchCorners(o,i),stitchWalls(o,i))),a&&(n=n.concat(stitchCorners(a,u),stitchWalls(a,u))),e===c){let e=i.map(e=>e[0]);n.push(poly3.create(e)),e=u.map(e=>e[0]),n.push(poly3.create(e))}o=i,a=u}return geom3.create(n)};module.exports=roundedCuboid; -},{"../geometries/geom3":165,"../geometries/poly3":203,"../maths/constants":218,"../maths/utils/trigonometry":297,"../maths/vec2":315,"../maths/vec3":346,"./commonChecks":493,"./cuboid":495}],507:[function(require,module,exports){ +},{"../geometries/geom3":165,"../geometries/poly3":203,"../maths/constants":218,"../maths/utils/trigonometry":297,"../maths/vec2":315,"../maths/vec3":346,"./commonChecks":494,"./cuboid":496}],508:[function(require,module,exports){ const{EPS:EPS,TAU:TAU}=require("../maths/constants"),vec3=require("../maths/vec3"),geom3=require("../geometries/geom3"),poly3=require("../geometries/poly3"),{sin:sin,cos:cos}=require("../maths/utils/trigonometry"),{isGTE:isGTE,isNumberArray:isNumberArray}=require("./commonChecks"),cylinder=require("./cylinder"),roundedCylinder=e=>{const{center:c,height:r,radius:s,roundRadius:a,segments:t}=Object.assign({},{center:[0,0,0],height:2,radius:1,roundRadius:.2,segments:32},e);if(!isNumberArray(c,3))throw new Error("center must be an array of X, Y and Z values");if(!isGTE(r,0))throw new Error("height must be positive");if(!isGTE(s,0))throw new Error("radius must be positive");if(!isGTE(a,0))throw new Error("roundRadius must be positive");if(a>s)throw new Error("roundRadius must be smaller than the radius");if(!isGTE(t,4))throw new Error("segments must be four or more");if(0===r||0===s)return geom3.create();if(0===a)return cylinder({center:c,height:r,radius:s});const v=[0,0,-r/2],o=[0,0,r/2],i=vec3.subtract(vec3.create(),o,v);if(2*a>vec3.length(i)-EPS)throw new Error("height must be larger than twice roundRadius");let u;u=Math.abs(i[0])>Math.abs(i[1])?vec3.fromValues(0,1,0):vec3.fromValues(1,0,0);const d=vec3.scale(vec3.create(),vec3.normalize(vec3.create(),i),a),n=vec3.scale(vec3.create(),vec3.normalize(vec3.create(),vec3.cross(vec3.create(),d,u)),s),l=vec3.scale(vec3.create(),vec3.normalize(vec3.create(),vec3.cross(vec3.create(),n,d)),s);vec3.add(v,v,d),vec3.subtract(o,o,d);const h=Math.floor(.25*t),m=e=>{const r=e.map(e=>vec3.add(e,e,c));return poly3.create(r)},p=[],b=vec3.create(),f=vec3.create();let g;for(let e=0;e<=t;e++){const c=TAU*e/t,r=vec3.add(vec3.create(),vec3.scale(b,n,cos(c)),vec3.scale(f,l,sin(c)));if(e>0){let e,c,s=[];s.push(vec3.add(vec3.create(),v,r)),s.push(vec3.add(vec3.create(),v,g)),s.push(vec3.add(vec3.create(),o,g)),s.push(vec3.add(vec3.create(),o,r)),p.push(m(s));for(let a=0;a<=h;a++){const t=TAU/4*a/h,i=cos(t),u=sin(t);if(a>0){let t;s=[],t=vec3.add(vec3.create(),v,vec3.subtract(b,vec3.scale(b,g,e),vec3.scale(f,d,c))),s.push(t),t=vec3.add(vec3.create(),v,vec3.subtract(b,vec3.scale(b,r,e),vec3.scale(f,d,c))),s.push(t),a{let{center:r,size:t,roundRadius:a,segments:c}=Object.assign({},{center:[0,0],size:[2,2],roundRadius:.2,segments:32},e);if(!isNumberArray(r,2))throw new Error("center must be an array of X and Y values");if(!isNumberArray(t,2))throw new Error("size must be an array of X and Y values");if(!t.every(e=>e>=0))throw new Error("size values must be positive");if(!isGTE(a,0))throw new Error("roundRadius must be positive");if(!isGTE(c,4))throw new Error("segments must be four or more");if(0===t[0]||0===t[1])return geom2.create();if(0===a)return rectangle({center:r,size:t});if(a>(t=t.map(e=>e/2))[0]-EPS||a>t[1]-EPS)throw new Error("roundRadius must be smaller than the radius of all dimensions");const s=Math.floor(c/4),o=vec2.add(vec2.create(),r,[t[0]-a,t[1]-a]),n=vec2.add(vec2.create(),r,[a-t[0],t[1]-a]),i=vec2.add(vec2.create(),r,[a-t[0],a-t[1]]),u=vec2.add(vec2.create(),r,[t[0]-a,a-t[1]]),d=[],v=[],m=[],l=[];for(let e=0;e<=s;e++){const r=TAU/4*e/s,t=vec2.fromAngleRadians(vec2.create(),r);vec2.scale(t,t,a),d.push(vec2.add(vec2.create(),o,t)),vec2.rotate(t,t,vec2.create(),TAU/4),v.push(vec2.add(vec2.create(),n,t)),vec2.rotate(t,t,vec2.create(),TAU/4),m.push(vec2.add(vec2.create(),i,t)),vec2.rotate(t,t,vec2.create(),TAU/4),l.push(vec2.add(vec2.create(),u,t))}return geom2.fromPoints(d.concat(v,m,l))};module.exports=roundedRectangle; -},{"../geometries/geom2":149,"../maths/constants":218,"../maths/vec2":315,"./commonChecks":493,"./rectangle":505}],509:[function(require,module,exports){ +},{"../geometries/geom2":149,"../maths/constants":218,"../maths/vec2":315,"./commonChecks":494,"./rectangle":506}],510:[function(require,module,exports){ const ellipsoid=require("./ellipsoid"),{isGTE:isGTE}=require("./commonChecks"),sphere=e=>{let{center:s,radius:r,segments:i,axes:t}=Object.assign({},{center:[0,0,0],radius:1,segments:32,axes:[[1,0,0],[0,-1,0],[0,0,1]]},e);if(!isGTE(r,0))throw new Error("radius must be positive");return ellipsoid({center:s,radius:r=[r,r,r],segments:i,axes:t})};module.exports=sphere; -},{"./commonChecks":493,"./ellipsoid":499}],510:[function(require,module,exports){ +},{"./commonChecks":494,"./ellipsoid":500}],511:[function(require,module,exports){ const rectangle=require("./rectangle"),{isGTE:isGTE}=require("./commonChecks"),square=e=>{let{center:r,size:s}=Object.assign({},{center:[0,0],size:2},e);if(!isGTE(s,0))throw new Error("size must be positive");return rectangle({center:r,size:s=[s,s]})};module.exports=square; -},{"./commonChecks":493,"./rectangle":505}],511:[function(require,module,exports){ +},{"./commonChecks":494,"./rectangle":506}],512:[function(require,module,exports){ const{TAU:TAU}=require("../maths/constants"),vec2=require("../maths/vec2"),geom2=require("../geometries/geom2"),{isGT:isGT,isGTE:isGTE,isNumberArray:isNumberArray}=require("./commonChecks"),getRadiusRatio=(e,r)=>e>0&&r>1&&r{const o=TAU/e,i=[];for(let a=0;a{let{center:r,vertices:t,outerRadius:s,innerRadius:o,density:i,startAngle:a}=Object.assign({},{center:[0,0],vertices:5,outerRadius:1,innerRadius:0,density:2,startAngle:0},e);if(!isNumberArray(r,2))throw new Error("center must be an array of X and Y values");if(!isGTE(t,2))throw new Error("vertices must be two or more");if(!isGT(s,0))throw new Error("outerRadius must be greater than zero");if(!isGTE(o,0))throw new Error("innerRadius must be greater than zero");if(!isGTE(a,0))throw new Error("startAngle must be greater than zero");if(t=Math.floor(t),i=Math.floor(i),a%=TAU,0===o){if(!isGTE(i,2))throw new Error("density must be two or more");o=s*getRadiusRatio(t,i)}const n=vec2.clone(r),u=getPoints(t,s,a,n),c=getPoints(t,o,a+Math.PI/t,n),h=[];for(let e=0;e{const r={innerRadius:1,innerSegments:32,outerRadius:4,outerSegments:32,innerRotation:0,startAngle:0,outerRotation:TAU},{innerRadius:t,innerSegments:o,outerRadius:n,outerSegments:s,innerRotation:i,startAngle:a,outerRotation:u}=Object.assign({},r,e);if(!isGT(t,0))throw new Error("innerRadius must be greater than zero");if(!isGTE(o,3))throw new Error("innerSegments must be three or more");if(!isGT(n,0))throw new Error("outerRadius must be greater than zero");if(!isGTE(s,3))throw new Error("outerSegments must be three or more");if(!isGTE(a,0))throw new Error("startAngle must be positive");if(!isGT(u,0))throw new Error("outerRotation must be greater than zero");if(t>=n)throw new Error("inner circle is two large to rotate about the outer circle");let m=circle({radius:t,segments:o});return 0!==i&&(m=rotate([0,0,i],m)),m=translate([n,0],m),extrudeRotate({startAngle:a,angle:u,segments:s},m)};module.exports=torus; -},{"../maths/constants":218,"../operations/extrusions/extrudeRotate":440,"../operations/transforms/rotate":487,"../operations/transforms/translate":490,"./circle":492,"./commonChecks":493}],513:[function(require,module,exports){ +},{"../maths/constants":218,"../operations/extrusions/extrudeRotate":440,"../operations/transforms/rotate":488,"../operations/transforms/translate":491,"./circle":493,"./commonChecks":494}],514:[function(require,module,exports){ const{NEPS:NEPS}=require("../maths/constants"),vec2=require("../maths/vec2"),geom2=require("../geometries/geom2"),{isNumberArray:isNumberArray}=require("./commonChecks"),solveAngleFromSSS=(e,r,t)=>Math.acos((e*e+r*r-t*t)/(2*e*r)),solveSideFromSAS=(e,r,t)=>r>NEPS?Math.sqrt(e*e+t*t-2*e*t*Math.cos(r)):Math.sqrt((e-t)*(e-t)+e*t*r*r*(1-r*r/12)),solveAAA=e=>{if(Math.abs(e[0]+e[1]+e[2]-Math.PI)>NEPS)throw new Error("AAA triangles require angles that sum to PI");const r=e[0],t=e[1],s=Math.PI-r-t,a=1/Math.sin(s)*Math.sin(r),n=1/Math.sin(s)*Math.sin(t);return createTriangle(r,t,s,a,n,1)},solveAAS=e=>{const r=e[0],t=e[1],s=Math.PI+NEPS-r-t;if(s{const r=e[0],t=e[2],s=Math.PI+NEPS-r-t;if(s{const r=e[0],t=e[1],s=e[2],a=solveSideFromSAS(r,t,s),n=solveAngleFromSSS(a,r,s),o=Math.PI-n-t;return createTriangle(n,t,o,s,a,r)},solveSSA=e=>{const r=e[0],t=e[1],s=e[2],a=Math.asin(t*Math.sin(s)/r),n=Math.PI-a-s,o=r/Math.sin(s)*Math.sin(n);return createTriangle(a,n,s,t,o,r)},solveSSS=e=>{const r=e[1],t=e[2],s=e[0];if(r+t<=s||t+s<=r||s+r<=t)throw new Error("SSS triangle is incorrect, as the longest side is longer than the sum of the other sides");const a=solveAngleFromSSS(t,s,r),n=solveAngleFromSSS(s,r,t),o=Math.PI-a-n;return createTriangle(a,n,o,r,t,s)},createTriangle=(e,r,t,s,a,n)=>{const o=vec2.fromValues(0,0),i=vec2.fromValues(n,0),S=vec2.fromValues(s,0);return vec2.add(S,vec2.rotate(S,S,[0,0],Math.PI-r),i),geom2.fromPoints([o,i,S])},triangle=e=>{let{type:r,values:t}=Object.assign({},{type:"SSS",values:[1,1,1]},e);if("string"!=typeof r)throw new Error("triangle type must be a string");if("A"!==(r=r.toUpperCase())[0]&&"S"!==r[0]||"A"!==r[1]&&"S"!==r[1]||"A"!==r[2]&&"S"!==r[2])throw new Error("triangle type must contain three letters; A or S");if(!isNumberArray(t,3))throw new Error("triangle values must contain three values");if(!t.every(e=>e>0))throw new Error("triangle values must be greater than zero");switch(r){case"AAA":return solveAAA(t);case"AAS":return solveAAS(t);case"ASA":return solveASA(t);case"SAS":return solveSAS(t);case"SSA":return solveSSA(t);case"SSS":return solveSSS(t);default:throw new Error("invalid triangle type, try again")}};module.exports=triangle; -},{"../geometries/geom2":149,"../maths/constants":218,"../maths/vec2":315,"./commonChecks":493}],514:[function(require,module,exports){ +},{"../geometries/geom2":149,"../maths/constants":218,"../maths/vec2":315,"./commonChecks":494}],515:[function(require,module,exports){ module.exports={height:14,32:[16],33:[10,5,21,5,7,void 0,5,2,4,1,5,0,6,1,5,2],34:[16,4,21,4,14,void 0,12,21,12,14],35:[21,11,25,4,-7,void 0,17,25,10,-7,void 0,4,12,18,12,void 0,3,6,17,6],36:[20,8,25,8,-4,void 0,12,25,12,-4,void 0,17,18,15,20,12,21,8,21,5,20,3,18,3,16,4,14,5,13,7,12,13,10,15,9,16,8,17,6,17,3,15,1,12,0,8,0,5,1,3,3],37:[24,21,21,3,0,void 0,8,21,10,19,10,17,9,15,7,14,5,14,3,16,3,18,4,20,6,21,8,21,10,20,13,19,16,19,19,20,21,21,void 0,17,7,15,6,14,4,14,2,16,0,18,0,20,1,21,3,21,5,19,7,17,7],38:[26,23,12,23,13,22,14,21,14,20,13,19,11,17,6,15,3,13,1,11,0,7,0,5,1,4,2,3,4,3,6,4,8,5,9,12,13,13,14,14,16,14,18,13,20,11,21,9,20,8,18,8,16,9,13,11,10,16,3,18,1,20,0,22,0,23,1,23,2],39:[10,5,19,4,20,5,21,6,20,6,18,5,16,4,15],40:[14,11,25,9,23,7,20,5,16,4,11,4,7,5,2,7,-2,9,-5,11,-7],41:[14,3,25,5,23,7,20,9,16,10,11,10,7,9,2,7,-2,5,-5,3,-7],42:[16,8,21,8,9,void 0,3,18,13,12,void 0,13,18,3,12],43:[26,13,18,13,0,void 0,4,9,22,9],44:[10,6,1,5,0,4,1,5,2,6,1,6,-1,5,-3,4,-4],45:[26,4,9,22,9],46:[10,5,2,4,1,5,0,6,1,5,2],47:[22,20,25,2,-7],48:[20,9,21,6,20,4,17,3,12,3,9,4,4,6,1,9,0,11,0,14,1,16,4,17,9,17,12,16,17,14,20,11,21,9,21],49:[20,6,17,8,18,11,21,11,0],50:[20,4,16,4,17,5,19,6,20,8,21,12,21,14,20,15,19,16,17,16,15,15,13,13,10,3,0,17,0],51:[20,5,21,16,21,10,13,13,13,15,12,16,11,17,8,17,6,16,3,14,1,11,0,8,0,5,1,4,2,3,4],52:[20,13,21,3,7,18,7,void 0,13,21,13,0],53:[20,15,21,5,21,4,12,5,13,8,14,11,14,14,13,16,11,17,8,17,6,16,3,14,1,11,0,8,0,5,1,4,2,3,4],54:[20,16,18,15,20,12,21,10,21,7,20,5,17,4,12,4,7,5,3,7,1,10,0,11,0,14,1,16,3,17,6,17,7,16,10,14,12,11,13,10,13,7,12,5,10,4,7],55:[20,17,21,7,0,void 0,3,21,17,21],56:[20,8,21,5,20,4,18,4,16,5,14,7,13,11,12,14,11,16,9,17,7,17,4,16,2,15,1,12,0,8,0,5,1,4,2,3,4,3,7,4,9,6,11,9,12,13,13,15,14,16,16,16,18,15,20,12,21,8,21],57:[20,16,14,15,11,13,9,10,8,9,8,6,9,4,11,3,14,3,15,4,18,6,20,9,21,10,21,13,20,15,18,16,14,16,9,15,4,13,1,10,0,8,0,5,1,4,3],58:[10,5,14,4,13,5,12,6,13,5,14,void 0,5,2,4,1,5,0,6,1,5,2],59:[10,5,14,4,13,5,12,6,13,5,14,void 0,6,1,5,0,4,1,5,2,6,1,6,-1,5,-3,4,-4],60:[24,20,18,4,9,20,0],61:[26,4,12,22,12,void 0,4,6,22,6],62:[24,4,18,20,9,4,0],63:[18,3,16,3,17,4,19,5,20,7,21,11,21,13,20,14,19,15,17,15,15,14,13,13,12,9,10,9,7,void 0,9,2,8,1,9,0,10,1,9,2],64:[27,18,13,17,15,15,16,12,16,10,15,9,14,8,11,8,8,9,6,11,5,14,5,16,6,17,8,void 0,12,16,10,14,9,11,9,8,10,6,11,5,void 0,18,16,17,8,17,6,19,5,21,5,23,7,24,10,24,12,23,15,22,17,20,19,18,20,15,21,12,21,9,20,7,19,5,17,4,15,3,12,3,9,4,6,5,4,7,2,9,1,12,0,15,0,18,1,20,2,21,3,void 0,19,16,18,8,18,6,19,5],65:[18,9,21,1,0,void 0,9,21,17,0,void 0,4,7,14,7],66:[21,4,21,4,0,void 0,4,21,13,21,16,20,17,19,18,17,18,15,17,13,16,12,13,11,void 0,4,11,13,11,16,10,17,9,18,7,18,4,17,2,16,1,13,0,4,0],67:[21,18,16,17,18,15,20,13,21,9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5],68:[21,4,21,4,0,void 0,4,21,11,21,14,20,16,18,17,16,18,13,18,8,17,5,16,3,14,1,11,0,4,0],69:[19,4,21,4,0,void 0,4,21,17,21,void 0,4,11,12,11,void 0,4,0,17,0],70:[18,4,21,4,0,void 0,4,21,17,21,void 0,4,11,12,11],71:[21,18,16,17,18,15,20,13,21,9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,18,8,void 0,13,8,18,8],72:[22,4,21,4,0,void 0,18,21,18,0,void 0,4,11,18,11],73:[8,4,21,4,0],74:[16,12,21,12,5,11,2,10,1,8,0,6,0,4,1,3,2,2,5,2,7],75:[21,4,21,4,0,void 0,18,21,4,7,void 0,9,12,18,0],76:[17,4,21,4,0,void 0,4,0,16,0],77:[24,4,21,4,0,void 0,4,21,12,0,void 0,20,21,12,0,void 0,20,21,20,0],78:[22,4,21,4,0,void 0,4,21,18,0,void 0,18,21,18,0],79:[22,9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,19,8,19,13,18,16,17,18,15,20,13,21,9,21],80:[21,4,21,4,0,void 0,4,21,13,21,16,20,17,19,18,17,18,14,17,12,16,11,13,10,4,10],81:[22,9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,19,8,19,13,18,16,17,18,15,20,13,21,9,21,void 0,12,4,18,-2],82:[21,4,21,4,0,void 0,4,21,13,21,16,20,17,19,18,17,18,15,17,13,16,12,13,11,4,11,void 0,11,11,18,0],83:[20,17,18,15,20,12,21,8,21,5,20,3,18,3,16,4,14,5,13,7,12,13,10,15,9,16,8,17,6,17,3,15,1,12,0,8,0,5,1,3,3],84:[16,8,21,8,0,void 0,1,21,15,21],85:[22,4,21,4,6,5,3,7,1,10,0,12,0,15,1,17,3,18,6,18,21],86:[18,1,21,9,0,void 0,17,21,9,0],87:[24,2,21,7,0,void 0,12,21,7,0,void 0,12,21,17,0,void 0,22,21,17,0],88:[20,3,21,17,0,void 0,17,21,3,0],89:[18,1,21,9,11,9,0,void 0,17,21,9,11],90:[20,17,21,3,0,void 0,3,21,17,21,void 0,3,0,17,0],91:[14,4,25,4,-7,void 0,5,25,5,-7,void 0,4,25,11,25,void 0,4,-7,11,-7],92:[14,0,21,14,-3],93:[14,9,25,9,-7,void 0,10,25,10,-7,void 0,3,25,10,25,void 0,3,-7,10,-7],94:[16,6,15,8,18,10,15,void 0,3,12,8,17,13,12,void 0,8,17,8,0],95:[16,0,-2,16,-2],96:[10,6,21,5,20,4,18,4,16,5,15,6,16,5,17],97:[19,15,14,15,0,void 0,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3],98:[19,4,21,4,0,void 0,4,11,6,13,8,14,11,14,13,13,15,11,16,8,16,6,15,3,13,1,11,0,8,0,6,1,4,3],99:[18,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3],100:[19,15,21,15,0,void 0,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3],101:[18,3,8,15,8,15,10,14,12,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3],102:[12,10,21,8,21,6,20,5,17,5,0,void 0,2,14,9,14],103:[19,15,14,15,-2,14,-5,13,-6,11,-7,8,-7,6,-6,void 0,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3],104:[19,4,21,4,0,void 0,4,10,7,13,9,14,12,14,14,13,15,10,15,0],105:[8,3,21,4,20,5,21,4,22,3,21,void 0,4,14,4,0],106:[10,5,21,6,20,7,21,6,22,5,21,void 0,6,14,6,-3,5,-6,3,-7,1,-7],107:[17,4,21,4,0,void 0,14,14,4,4,void 0,8,8,15,0],108:[8,4,21,4,0],109:[30,4,14,4,0,void 0,4,10,7,13,9,14,12,14,14,13,15,10,15,0,void 0,15,10,18,13,20,14,23,14,25,13,26,10,26,0],110:[19,4,14,4,0,void 0,4,10,7,13,9,14,12,14,14,13,15,10,15,0],111:[19,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3,16,6,16,8,15,11,13,13,11,14,8,14],112:[19,4,14,4,-7,void 0,4,11,6,13,8,14,11,14,13,13,15,11,16,8,16,6,15,3,13,1,11,0,8,0,6,1,4,3],113:[19,15,14,15,-7,void 0,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3],114:[13,4,14,4,0,void 0,4,8,5,11,7,13,9,14,12,14],115:[17,14,11,13,13,10,14,7,14,4,13,3,11,4,9,6,8,11,7,13,6,14,4,14,3,13,1,10,0,7,0,4,1,3,3],116:[12,5,21,5,4,6,1,8,0,10,0,void 0,2,14,9,14],117:[19,4,14,4,4,5,1,7,0,10,0,12,1,15,4,void 0,15,14,15,0],118:[16,2,14,8,0,void 0,14,14,8,0],119:[22,3,14,7,0,void 0,11,14,7,0,void 0,11,14,15,0,void 0,19,14,15,0],120:[17,3,14,14,0,void 0,14,14,3,0],121:[16,2,14,8,0,void 0,14,14,8,0,6,-4,4,-6,2,-7,1,-7],122:[17,14,14,3,0,void 0,3,14,14,14,void 0,3,0,14,0],123:[14,9,25,7,24,6,23,5,21,5,19,6,17,7,16,8,14,8,12,6,10,void 0,7,24,6,22,6,20,7,18,8,17,9,15,9,13,8,11,4,9,8,7,9,5,9,3,8,1,7,0,6,-2,6,-4,7,-6,void 0,6,8,8,6,8,4,7,2,6,1,5,-1,5,-3,6,-5,7,-6,9,-7],124:[8,4,25,4,-7],125:[14,5,25,7,24,8,23,9,21,9,19,8,17,7,16,6,14,6,12,8,10,void 0,7,24,8,22,8,20,7,18,6,17,5,15,5,13,6,11,10,9,6,7,5,5,5,3,6,1,7,0,8,-2,8,-4,7,-6,void 0,8,8,6,6,6,4,7,2,8,1,9,-1,9,-3,8,-5,7,-6,5,-7],126:[24,3,6,3,8,4,11,6,12,8,12,10,11,14,8,16,7,18,7,20,8,21,10,void 0,3,8,4,10,6,11,8,11,10,10,14,7,16,6,18,6,20,7,21,10,21,12]}; -},{}],515:[function(require,module,exports){ +},{}],516:[function(require,module,exports){ module.exports={vectorChar:require("./vectorChar"),vectorText:require("./vectorText")}; -},{"./vectorChar":516,"./vectorText":518}],516:[function(require,module,exports){ +},{"./vectorChar":517,"./vectorText":519}],517:[function(require,module,exports){ const vectorParams=require("./vectorParams"),vectorChar=(t,e)=>{const{xOffset:r,yOffset:s,input:h,font:o,height:c,extrudeOffset:n}=vectorParams(t,e);let a=h.charCodeAt(0);a&&o[a]||(a=63);const f=[].concat(o[a]),i=(c-n)/o.height,u=n/2,g=f.shift()*i,l=[];let v=[];for(let t=0,e=f.length;t{e||"string"!=typeof t||(t={input:t}),t=t||{};const s=Object.assign({},defaultsVectorParams,t);return s.input=e||s.input,s};module.exports=vectorParams; -},{"./fonts/single-line/hershey/simplex.js":514}],518:[function(require,module,exports){ +},{"./fonts/single-line/hershey/simplex.js":515}],519:[function(require,module,exports){ const vectorChar=require("./vectorChar"),vectorParams=require("./vectorParams"),translateLine=(t,e)=>{const{x:n,y:s}=Object.assign({x:0,y:0},t||{}),r=e.segments;let h=null,a=null;for(let t=0,e=r.length;t{const{xOffset:n,yOffset:s,input:r,font:h,height:a,align:o,extrudeOffset:i,lineSpacing:c,letterSpacing:g}=vectorParams(t,e);let l,f,m,x,u,d,[v,w]=[n,s],O={width:0,segments:[]};const p=[];let y=[],C=0;const L=v,P=()=>{p.push(O),C=Math.max(C,O.width),O={width:0,segments:[]}};for(l=0,f=r.length;lO.width&&(d=C-O.width,"right"===o?O=translateLine({x:d},O):"center"===o&&(O=translateLine({x:d/2},O))),y=y.concat(O.segments);return y};module.exports=vectorText; -},{"./vectorChar":516,"./vectorParams":517}],519:[function(require,module,exports){ +},{"./vectorChar":517,"./vectorParams":518}],520:[function(require,module,exports){ const geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),path2=require("../geometries/path2"),areAllShapesTheSameType=e=>{let r;for(const o of e){let e=0;if(geom2.isA(o)&&(e=1),geom3.isA(o)&&(e=2),path2.isA(o)&&(e=3),r&&e!==r)return!1;r=e}return!0};module.exports=areAllShapesTheSameType; -},{"../geometries/geom2":149,"../geometries/geom3":165,"../geometries/path2":186}],520:[function(require,module,exports){ +},{"../geometries/geom2":149,"../geometries/geom3":165,"../geometries/path2":186}],521:[function(require,module,exports){ const degToRad=d=>.017453292519943295*d;module.exports=degToRad; -},{}],521:[function(require,module,exports){ +},{}],522:[function(require,module,exports){ const flatten=t=>t.reduce((t,a)=>Array.isArray(a)?t.concat(flatten(a)):t.concat(a),[]);module.exports=flatten; -},{}],522:[function(require,module,exports){ +},{}],523:[function(require,module,exports){ const fnNumberSort=(o,r)=>o-r;module.exports=fnNumberSort; -},{}],523:[function(require,module,exports){ +},{}],524:[function(require,module,exports){ module.exports={areAllShapesTheSameType:require("./areAllShapesTheSameType"),degToRad:require("./degToRad"),flatten:require("./flatten"),fnNumberSort:require("./fnNumberSort"),insertSorted:require("./insertSorted"),radiusToSegments:require("./radiusToSegments"),radToDeg:require("./radToDeg")}; -},{"./areAllShapesTheSameType":519,"./degToRad":520,"./flatten":521,"./fnNumberSort":522,"./insertSorted":524,"./radToDeg":526,"./radiusToSegments":527}],524:[function(require,module,exports){ +},{"./areAllShapesTheSameType":520,"./degToRad":521,"./flatten":522,"./fnNumberSort":523,"./insertSorted":525,"./radToDeg":527,"./radiusToSegments":528}],525:[function(require,module,exports){ const insertSorted=(t,e,o)=>{let r=0,s=t.length;for(;s>r;){const l=Math.floor((r+s)/2);o(e,t[l])>0?r=l+1:s=l}t.splice(r,0,e)};module.exports=insertSorted; -},{}],525:[function(require,module,exports){ +},{}],526:[function(require,module,exports){ const padArrayToLength=(r,e,o)=>{for(r=r.slice();r.length57.29577951308232*o;module.exports=radToDeg; -},{}],527:[function(require,module,exports){ +},{}],528:[function(require,module,exports){ const{TAU:TAU}=require("../maths/constants"),radiusToSegments=(t,e,s)=>{const a=e>0?t*TAU/e:0,n=s>0?TAU/s:0;return Math.ceil(Math.max(a,n,4))};module.exports=radiusToSegments; -},{"../maths/constants":218}],528:[function(require,module,exports){ +},{"../maths/constants":218}],529:[function(require,module,exports){ const flatten=t=>t.reduce((t,a)=>Array.isArray(a)?t.concat(flatten(a)):t.concat(a),[]);module.exports=flatten; -},{}],529:[function(require,module,exports){ +},{}],530:[function(require,module,exports){ const fnNumberSort=(o,r)=>o-r;module.exports=fnNumberSort; -},{}],530:[function(require,module,exports){ +},{}],531:[function(require,module,exports){ const head=r=>{if(Array.isArray(r)&&0!==r.length)return r[0]};module.exports=head; -},{}],531:[function(require,module,exports){ +},{}],532:[function(require,module,exports){ module.exports={flatten:require("./flatten"),fnNumberSort:require("./fnNumberSort"),head:require("./head"),insertSorted:require("./insertSorted"),nth:require("./nth"),padToLength:require("./padToLength"),toArray:require("./toArray")}; -},{"./flatten":528,"./fnNumberSort":529,"./head":530,"./insertSorted":532,"./nth":533,"./padToLength":534,"./toArray":535}],532:[function(require,module,exports){ +},{"./flatten":529,"./fnNumberSort":530,"./head":531,"./insertSorted":533,"./nth":534,"./padToLength":535,"./toArray":536}],533:[function(require,module,exports){ const insertSorted=(t,e,o)=>{let r=0,n=t.length;for(;n>r;){const s=Math.floor((r+n)/2);o(e,t[s])>0?r=s+1:n=s}return t.splice(r,0,e),t};module.exports=insertSorted; -},{}],533:[function(require,module,exports){ +},{}],534:[function(require,module,exports){ const nth=(r,t)=>{if(Array.isArray(r)&&!(r.length{for(e=e.slice();e.lengthArray.isArray(r)?r:null==r?[]:[r];module.exports=toArray; },{}]},{},[24])(24) diff --git a/packages/core/package.json b/packages/core/package.json index c3f87515e..aa23ecee0 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@jscad/core", - "version": "2.6.9", + "version": "2.6.10", "description": "Core functionality for JSCAD Applications", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -36,9 +36,9 @@ "license": "MIT", "dependencies": { "@jscad/array-utils": "2.1.4", - "@jscad/io": "2.4.8", - "@jscad/io-utils": "2.0.27", - "@jscad/modeling": "2.12.2", + "@jscad/io": "2.4.9", + "@jscad/io-utils": "2.0.28", + "@jscad/modeling": "2.12.3", "json5": "2.2.3", "strip-bom": "4.0.0" }, diff --git a/packages/io/3mf-serializer/CHANGELOG.md b/packages/io/3mf-serializer/CHANGELOG.md index 427eb1f56..cc70326b2 100644 --- a/packages/io/3mf-serializer/CHANGELOG.md +++ b/packages/io/3mf-serializer/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.1.12](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/3mf-serializer@2.1.11...@jscad/3mf-serializer@2.1.12) (2024-10-06) + +**Note:** Version bump only for package @jscad/3mf-serializer + + + + + ## [2.1.11](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/3mf-serializer@2.1.10...@jscad/3mf-serializer@2.1.11) (2024-06-02) **Note:** Version bump only for package @jscad/3mf-serializer diff --git a/packages/io/3mf-serializer/package.json b/packages/io/3mf-serializer/package.json index 4068bec0a..b0f6d71dd 100644 --- a/packages/io/3mf-serializer/package.json +++ b/packages/io/3mf-serializer/package.json @@ -1,6 +1,6 @@ { "name": "@jscad/3mf-serializer", - "version": "2.1.11", + "version": "2.1.12", "description": "3MF serializer for JSCAD project", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -28,7 +28,7 @@ }, "dependencies": { "@jscad/array-utils": "2.1.4", - "@jscad/modeling": "2.12.2", + "@jscad/modeling": "2.12.3", "fflate": "0.7.3", "onml": "1.2.0" }, diff --git a/packages/io/amf-deserializer/CHANGELOG.md b/packages/io/amf-deserializer/CHANGELOG.md index 31cc832f4..b72cfa223 100644 --- a/packages/io/amf-deserializer/CHANGELOG.md +++ b/packages/io/amf-deserializer/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.3.8](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/amf-deserializer@2.3.7...@jscad/amf-deserializer@2.3.8) (2024-10-06) + +**Note:** Version bump only for package @jscad/amf-deserializer + + + + + ## [2.3.7](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/amf-deserializer@2.3.6...@jscad/amf-deserializer@2.3.7) (2024-06-02) **Note:** Version bump only for package @jscad/amf-deserializer diff --git a/packages/io/amf-deserializer/package.json b/packages/io/amf-deserializer/package.json index a3f94fa2e..98630c3dd 100644 --- a/packages/io/amf-deserializer/package.json +++ b/packages/io/amf-deserializer/package.json @@ -1,6 +1,6 @@ { "name": "@jscad/amf-deserializer", - "version": "2.3.7", + "version": "2.3.8", "description": "AMF Deserializer for JSCAD", "repository": "https://github.com/jscad/OpenJSCAD.org/", "main": "src/index.js", @@ -31,7 +31,7 @@ ], "license": "MIT", "dependencies": { - "@jscad/modeling": "2.12.2", + "@jscad/modeling": "2.12.3", "saxes": "5.0.1" }, "devDependencies": { diff --git a/packages/io/amf-serializer/CHANGELOG.md b/packages/io/amf-serializer/CHANGELOG.md index 2cae3ffea..5f526056f 100644 --- a/packages/io/amf-serializer/CHANGELOG.md +++ b/packages/io/amf-serializer/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.1.18](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/amf-serializer@2.1.17...@jscad/amf-serializer@2.1.18) (2024-10-06) + +**Note:** Version bump only for package @jscad/amf-serializer + + + + + ## [2.1.17](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/amf-serializer@2.1.16...@jscad/amf-serializer@2.1.17) (2024-06-02) **Note:** Version bump only for package @jscad/amf-serializer diff --git a/packages/io/amf-serializer/package.json b/packages/io/amf-serializer/package.json index cf363edf0..960885748 100644 --- a/packages/io/amf-serializer/package.json +++ b/packages/io/amf-serializer/package.json @@ -1,6 +1,6 @@ { "name": "@jscad/amf-serializer", - "version": "2.1.17", + "version": "2.1.18", "description": "AMF Serializer for JSCAD", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -33,7 +33,7 @@ "license": "MIT", "dependencies": { "@jscad/array-utils": "2.1.4", - "@jscad/modeling": "2.12.2", + "@jscad/modeling": "2.12.3", "onml": "1.3.0" }, "devDependencies": { diff --git a/packages/io/dxf-deserializer/CHANGELOG.md b/packages/io/dxf-deserializer/CHANGELOG.md index 97e0cdae7..60774204e 100644 --- a/packages/io/dxf-deserializer/CHANGELOG.md +++ b/packages/io/dxf-deserializer/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.3.25](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/dxf-deserializer@2.3.24...@jscad/dxf-deserializer@2.3.25) (2024-10-06) + +**Note:** Version bump only for package @jscad/dxf-deserializer + + + + + ## [2.3.24](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/dxf-deserializer@2.3.23...@jscad/dxf-deserializer@2.3.24) (2024-06-02) **Note:** Version bump only for package @jscad/dxf-deserializer diff --git a/packages/io/dxf-deserializer/package.json b/packages/io/dxf-deserializer/package.json index f1ba38b83..48c490489 100644 --- a/packages/io/dxf-deserializer/package.json +++ b/packages/io/dxf-deserializer/package.json @@ -1,6 +1,6 @@ { "name": "@jscad/dxf-deserializer", - "version": "2.3.24", + "version": "2.3.25", "description": "DXF Deserializer for JSCAD", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -28,7 +28,7 @@ ], "license": "MIT", "dependencies": { - "@jscad/modeling": "2.12.2" + "@jscad/modeling": "2.12.3" }, "devDependencies": { "ava": "3.15.0", diff --git a/packages/io/dxf-serializer/CHANGELOG.md b/packages/io/dxf-serializer/CHANGELOG.md index 963898f00..658d50162 100644 --- a/packages/io/dxf-serializer/CHANGELOG.md +++ b/packages/io/dxf-serializer/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.1.18](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/dxf-serializer@2.1.17...@jscad/dxf-serializer@2.1.18) (2024-10-06) + +**Note:** Version bump only for package @jscad/dxf-serializer + + + + + ## [2.1.17](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/dxf-serializer@2.1.16...@jscad/dxf-serializer@2.1.17) (2024-06-02) **Note:** Version bump only for package @jscad/dxf-serializer diff --git a/packages/io/dxf-serializer/package.json b/packages/io/dxf-serializer/package.json index 1d1a846f2..e229ef047 100644 --- a/packages/io/dxf-serializer/package.json +++ b/packages/io/dxf-serializer/package.json @@ -1,6 +1,6 @@ { "name": "@jscad/dxf-serializer", - "version": "2.1.17", + "version": "2.1.18", "description": "DXF Serializer for JSCAD", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -33,7 +33,7 @@ "license": "MIT", "dependencies": { "@jscad/array-utils": "2.1.4", - "@jscad/modeling": "2.12.2" + "@jscad/modeling": "2.12.3" }, "devDependencies": { "ava": "3.15.0", diff --git a/packages/io/io-utils/CHANGELOG.md b/packages/io/io-utils/CHANGELOG.md index 5d58ae614..0aceb513e 100644 --- a/packages/io/io-utils/CHANGELOG.md +++ b/packages/io/io-utils/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.0.28](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io-utils@2.0.27...@jscad/io-utils@2.0.28) (2024-10-06) + +**Note:** Version bump only for package @jscad/io-utils + + + + + ## [2.0.27](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io-utils@2.0.26...@jscad/io-utils@2.0.27) (2024-06-02) **Note:** Version bump only for package @jscad/io-utils diff --git a/packages/io/io-utils/package.json b/packages/io/io-utils/package.json index cd86b59b7..34a9e15d9 100644 --- a/packages/io/io-utils/package.json +++ b/packages/io/io-utils/package.json @@ -1,6 +1,6 @@ { "name": "@jscad/io-utils", - "version": "2.0.27", + "version": "2.0.28", "description": "Utilities for JSCAD IO Packages", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -33,7 +33,7 @@ ], "license": "MIT", "devDependencies": { - "@jscad/modeling": "2.12.2", + "@jscad/modeling": "2.12.3", "ava": "3.15.0", "nyc": "15.1.0" }, diff --git a/packages/io/io/CHANGELOG.md b/packages/io/io/CHANGELOG.md index 10f194514..a98a030c5 100644 --- a/packages/io/io/CHANGELOG.md +++ b/packages/io/io/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.4.9](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.4.8...@jscad/io@2.4.9) (2024-10-06) + +**Note:** Version bump only for package @jscad/io + + + + + ## [2.4.8](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.4.7...@jscad/io@2.4.8) (2024-06-02) **Note:** Version bump only for package @jscad/io diff --git a/packages/io/io/package.json b/packages/io/io/package.json index 824dd7ac7..33976e402 100644 --- a/packages/io/io/package.json +++ b/packages/io/io/package.json @@ -1,6 +1,6 @@ { "name": "@jscad/io", - "version": "2.4.8", + "version": "2.4.9", "description": "Meta Package for JSCAD IO Packages", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -30,24 +30,24 @@ ], "license": "MIT", "dependencies": { - "@jscad/3mf-serializer": "2.1.11", - "@jscad/amf-deserializer": "2.3.7", - "@jscad/amf-serializer": "2.1.17", + "@jscad/3mf-serializer": "2.1.12", + "@jscad/amf-deserializer": "2.3.8", + "@jscad/amf-serializer": "2.1.18", "@jscad/array-utils": "2.1.4", - "@jscad/dxf-deserializer": "2.3.24", - "@jscad/dxf-serializer": "2.1.17", - "@jscad/io-utils": "2.0.27", - "@jscad/json-deserializer": "2.0.28", - "@jscad/json-serializer": "2.0.27", - "@jscad/modeling": "2.12.2", - "@jscad/obj-deserializer": "2.0.27", - "@jscad/obj-serializer": "2.1.17", - "@jscad/stl-deserializer": "2.1.24", - "@jscad/stl-serializer": "2.1.17", - "@jscad/svg-deserializer": "2.5.8", - "@jscad/svg-serializer": "2.3.15", - "@jscad/x3d-deserializer": "2.2.7", - "@jscad/x3d-serializer": "2.4.7" + "@jscad/dxf-deserializer": "2.3.25", + "@jscad/dxf-serializer": "2.1.18", + "@jscad/io-utils": "2.0.28", + "@jscad/json-deserializer": "2.0.29", + "@jscad/json-serializer": "2.0.28", + "@jscad/modeling": "2.12.3", + "@jscad/obj-deserializer": "2.0.28", + "@jscad/obj-serializer": "2.1.18", + "@jscad/stl-deserializer": "2.1.25", + "@jscad/stl-serializer": "2.1.18", + "@jscad/svg-deserializer": "2.5.9", + "@jscad/svg-serializer": "2.3.16", + "@jscad/x3d-deserializer": "2.2.8", + "@jscad/x3d-serializer": "2.4.8" }, "gitHead": "a90b9bad95a417661c619dc733e62c587dc71a4a" } diff --git a/packages/io/json-deserializer/CHANGELOG.md b/packages/io/json-deserializer/CHANGELOG.md index fc2292bc5..abcded31d 100644 --- a/packages/io/json-deserializer/CHANGELOG.md +++ b/packages/io/json-deserializer/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.0.29](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.28...@jscad/json-deserializer@2.0.29) (2024-10-06) + +**Note:** Version bump only for package @jscad/json-deserializer + + + + + ## [2.0.28](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.27...@jscad/json-deserializer@2.0.28) (2024-06-02) **Note:** Version bump only for package @jscad/json-deserializer diff --git a/packages/io/json-deserializer/package.json b/packages/io/json-deserializer/package.json index 86bd1379c..7a8cd0c54 100644 --- a/packages/io/json-deserializer/package.json +++ b/packages/io/json-deserializer/package.json @@ -1,6 +1,6 @@ { "name": "@jscad/json-deserializer", - "version": "2.0.28", + "version": "2.0.29", "description": "JSON Deserializer for JSCAD", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -31,7 +31,7 @@ "@jscad/array-utils": "2.1.4" }, "devDependencies": { - "@jscad/modeling": "2.12.2", + "@jscad/modeling": "2.12.3", "ava": "3.15.0", "nyc": "15.1.0" }, diff --git a/packages/io/json-serializer/CHANGELOG.md b/packages/io/json-serializer/CHANGELOG.md index 75b484218..f975d3f82 100644 --- a/packages/io/json-serializer/CHANGELOG.md +++ b/packages/io/json-serializer/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.0.28](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.27...@jscad/json-serializer@2.0.28) (2024-10-06) + +**Note:** Version bump only for package @jscad/json-serializer + + + + + ## [2.0.27](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.26...@jscad/json-serializer@2.0.27) (2024-06-02) **Note:** Version bump only for package @jscad/json-serializer diff --git a/packages/io/json-serializer/package.json b/packages/io/json-serializer/package.json index 15557a635..ba17e6d09 100644 --- a/packages/io/json-serializer/package.json +++ b/packages/io/json-serializer/package.json @@ -1,6 +1,6 @@ { "name": "@jscad/json-serializer", - "version": "2.0.27", + "version": "2.0.28", "description": "JSON Serializer for JSCAD", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -28,7 +28,7 @@ ], "license": "MIT", "dependencies": { - "@jscad/modeling": "2.12.2" + "@jscad/modeling": "2.12.3" }, "devDependencies": { "ava": "3.15.0", diff --git a/packages/io/obj-deserializer/CHANGELOG.md b/packages/io/obj-deserializer/CHANGELOG.md index 8f0de9cba..02787fc90 100644 --- a/packages/io/obj-deserializer/CHANGELOG.md +++ b/packages/io/obj-deserializer/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.0.28](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/obj-deserializer@2.0.27...@jscad/obj-deserializer@2.0.28) (2024-10-06) + +**Note:** Version bump only for package @jscad/obj-deserializer + + + + + ## [2.0.27](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/obj-deserializer@2.0.26...@jscad/obj-deserializer@2.0.27) (2024-06-02) **Note:** Version bump only for package @jscad/obj-deserializer diff --git a/packages/io/obj-deserializer/package.json b/packages/io/obj-deserializer/package.json index ddfd189d2..92d3cb18b 100644 --- a/packages/io/obj-deserializer/package.json +++ b/packages/io/obj-deserializer/package.json @@ -1,6 +1,6 @@ { "name": "@jscad/obj-deserializer", - "version": "2.0.27", + "version": "2.0.28", "description": "OBJ Deserializer for JSCAD", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -32,7 +32,7 @@ ], "license": "MIT", "dependencies": { - "@jscad/modeling": "2.12.2" + "@jscad/modeling": "2.12.3" }, "devDependencies": { "ava": "3.15.0", diff --git a/packages/io/obj-serializer/CHANGELOG.md b/packages/io/obj-serializer/CHANGELOG.md index c07f32454..f7154e3f8 100644 --- a/packages/io/obj-serializer/CHANGELOG.md +++ b/packages/io/obj-serializer/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.1.18](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/obj-serializer@2.1.17...@jscad/obj-serializer@2.1.18) (2024-10-06) + +**Note:** Version bump only for package @jscad/obj-serializer + + + + + ## [2.1.17](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/obj-serializer@2.1.16...@jscad/obj-serializer@2.1.17) (2024-06-02) **Note:** Version bump only for package @jscad/obj-serializer diff --git a/packages/io/obj-serializer/package.json b/packages/io/obj-serializer/package.json index 5af2fc164..ab48a8f20 100644 --- a/packages/io/obj-serializer/package.json +++ b/packages/io/obj-serializer/package.json @@ -1,6 +1,6 @@ { "name": "@jscad/obj-serializer", - "version": "2.1.17", + "version": "2.1.18", "description": "OBJ Serializer for JSCAD", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -28,7 +28,7 @@ }, "dependencies": { "@jscad/array-utils": "2.1.4", - "@jscad/modeling": "2.12.2" + "@jscad/modeling": "2.12.3" }, "devDependencies": { "ava": "3.15.0", diff --git a/packages/io/stl-deserializer/CHANGELOG.md b/packages/io/stl-deserializer/CHANGELOG.md index 3bd180a02..a915ea41e 100644 --- a/packages/io/stl-deserializer/CHANGELOG.md +++ b/packages/io/stl-deserializer/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.1.25](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/stl-deserializer@2.1.24...@jscad/stl-deserializer@2.1.25) (2024-10-06) + +**Note:** Version bump only for package @jscad/stl-deserializer + + + + + ## [2.1.24](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/stl-deserializer@2.1.23...@jscad/stl-deserializer@2.1.24) (2024-06-02) **Note:** Version bump only for package @jscad/stl-deserializer diff --git a/packages/io/stl-deserializer/package.json b/packages/io/stl-deserializer/package.json index c46bebc92..d01a81f86 100644 --- a/packages/io/stl-deserializer/package.json +++ b/packages/io/stl-deserializer/package.json @@ -1,6 +1,6 @@ { "name": "@jscad/stl-deserializer", - "version": "2.1.24", + "version": "2.1.25", "description": "STL Deserializer for JSCAD", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -32,8 +32,8 @@ ], "license": "MIT", "dependencies": { - "@jscad/io-utils": "2.0.27", - "@jscad/modeling": "2.12.2" + "@jscad/io-utils": "2.0.28", + "@jscad/modeling": "2.12.3" }, "devDependencies": { "ava": "3.15.0", diff --git a/packages/io/stl-serializer/CHANGELOG.md b/packages/io/stl-serializer/CHANGELOG.md index 9519a065b..753aec663 100644 --- a/packages/io/stl-serializer/CHANGELOG.md +++ b/packages/io/stl-serializer/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.1.18](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/stl-serializer@2.1.17...@jscad/stl-serializer@2.1.18) (2024-10-06) + +**Note:** Version bump only for package @jscad/stl-serializer + + + + + ## [2.1.17](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/stl-serializer@2.1.16...@jscad/stl-serializer@2.1.17) (2024-06-02) **Note:** Version bump only for package @jscad/stl-serializer diff --git a/packages/io/stl-serializer/package.json b/packages/io/stl-serializer/package.json index f5bc135ce..74a3ebdf2 100644 --- a/packages/io/stl-serializer/package.json +++ b/packages/io/stl-serializer/package.json @@ -1,6 +1,6 @@ { "name": "@jscad/stl-serializer", - "version": "2.1.17", + "version": "2.1.18", "description": "STL Serializer for JSCAD", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -33,7 +33,7 @@ "license": "MIT", "dependencies": { "@jscad/array-utils": "2.1.4", - "@jscad/modeling": "2.12.2" + "@jscad/modeling": "2.12.3" }, "devDependencies": { "ava": "3.15.0", diff --git a/packages/io/svg-deserializer/CHANGELOG.md b/packages/io/svg-deserializer/CHANGELOG.md index ef7f0824c..9ed5b1878 100644 --- a/packages/io/svg-deserializer/CHANGELOG.md +++ b/packages/io/svg-deserializer/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.5.9](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/svg-deserializer@2.5.8...@jscad/svg-deserializer@2.5.9) (2024-10-06) + +**Note:** Version bump only for package @jscad/svg-deserializer + + + + + ## [2.5.8](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/svg-deserializer@2.5.7...@jscad/svg-deserializer@2.5.8) (2024-06-02) **Note:** Version bump only for package @jscad/svg-deserializer diff --git a/packages/io/svg-deserializer/package.json b/packages/io/svg-deserializer/package.json index deb5abb1e..f8da9af66 100644 --- a/packages/io/svg-deserializer/package.json +++ b/packages/io/svg-deserializer/package.json @@ -1,6 +1,6 @@ { "name": "@jscad/svg-deserializer", - "version": "2.5.8", + "version": "2.5.9", "description": "SVG Deserializer for JSCAD", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -33,7 +33,7 @@ "license": "MIT", "dependencies": { "@jscad/array-utils": "2.1.4", - "@jscad/modeling": "2.12.2", + "@jscad/modeling": "2.12.3", "saxes": "5.0.1" }, "devDependencies": { diff --git a/packages/io/svg-serializer/CHANGELOG.md b/packages/io/svg-serializer/CHANGELOG.md index c0f5379fe..47c528ec2 100644 --- a/packages/io/svg-serializer/CHANGELOG.md +++ b/packages/io/svg-serializer/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.3.16](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/svg-serializer@2.3.15...@jscad/svg-serializer@2.3.16) (2024-10-06) + +**Note:** Version bump only for package @jscad/svg-serializer + + + + + ## [2.3.15](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/svg-serializer@2.3.14...@jscad/svg-serializer@2.3.15) (2024-06-02) **Note:** Version bump only for package @jscad/svg-serializer diff --git a/packages/io/svg-serializer/package.json b/packages/io/svg-serializer/package.json index b8b4f60fa..7daeff1e8 100644 --- a/packages/io/svg-serializer/package.json +++ b/packages/io/svg-serializer/package.json @@ -1,6 +1,6 @@ { "name": "@jscad/svg-serializer", - "version": "2.3.15", + "version": "2.3.16", "description": "SVG Serializer for JSCAD", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -32,7 +32,7 @@ ], "license": "MIT", "dependencies": { - "@jscad/modeling": "2.12.2", + "@jscad/modeling": "2.12.3", "onml": "1.3.0" }, "devDependencies": { diff --git a/packages/io/x3d-deserializer/CHANGELOG.md b/packages/io/x3d-deserializer/CHANGELOG.md index b9c9d8956..f76681a74 100644 --- a/packages/io/x3d-deserializer/CHANGELOG.md +++ b/packages/io/x3d-deserializer/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.2.8](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/x3d-deserializer@2.2.7...@jscad/x3d-deserializer@2.2.8) (2024-10-06) + +**Note:** Version bump only for package @jscad/x3d-deserializer + + + + + ## [2.2.7](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/x3d-deserializer@2.2.6...@jscad/x3d-deserializer@2.2.7) (2024-06-02) diff --git a/packages/io/x3d-deserializer/package.json b/packages/io/x3d-deserializer/package.json index b54fce2f4..09188d5cd 100644 --- a/packages/io/x3d-deserializer/package.json +++ b/packages/io/x3d-deserializer/package.json @@ -1,6 +1,6 @@ { "name": "@jscad/x3d-deserializer", - "version": "2.2.7", + "version": "2.2.8", "description": "X3D Deserializer for JSCAD", "repository": "https://github.com/jscad/OpenJSCAD.org/", "main": "src/index.js", @@ -27,7 +27,7 @@ }, "dependencies": { "@jscad/array-utils": "2.1.4", - "@jscad/modeling": "2.12.2", + "@jscad/modeling": "2.12.3", "saxes": "5.0.1" }, "devDependencies": { diff --git a/packages/io/x3d-serializer/CHANGELOG.md b/packages/io/x3d-serializer/CHANGELOG.md index 8ed731a16..a9c206afe 100644 --- a/packages/io/x3d-serializer/CHANGELOG.md +++ b/packages/io/x3d-serializer/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.4.8](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/x3d-serializer@2.4.7...@jscad/x3d-serializer@2.4.8) (2024-10-06) + +**Note:** Version bump only for package @jscad/x3d-serializer + + + + + ## [2.4.7](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/x3d-serializer@2.4.6...@jscad/x3d-serializer@2.4.7) (2024-06-02) **Note:** Version bump only for package @jscad/x3d-serializer diff --git a/packages/io/x3d-serializer/package.json b/packages/io/x3d-serializer/package.json index 0d874c5d4..cdade6752 100644 --- a/packages/io/x3d-serializer/package.json +++ b/packages/io/x3d-serializer/package.json @@ -1,6 +1,6 @@ { "name": "@jscad/x3d-serializer", - "version": "2.4.7", + "version": "2.4.8", "description": "X3D Serializer for JSCAD", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -33,7 +33,7 @@ "license": "MIT", "dependencies": { "@jscad/array-utils": "2.1.4", - "@jscad/modeling": "2.12.2", + "@jscad/modeling": "2.12.3", "onml": "1.3.0" }, "devDependencies": { diff --git a/packages/modeling/CHANGELOG.md b/packages/modeling/CHANGELOG.md index c797dd516..0386c6c9f 100644 --- a/packages/modeling/CHANGELOG.md +++ b/packages/modeling/CHANGELOG.md @@ -3,6 +3,20 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.12.3](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/modeling@2.12.2...@jscad/modeling@2.12.3) (2024-10-06) + + +### Bug Fixes + +* **modeling:** added optional plane to poly3 TS definition ([2a3337a](https://github.com/jscad/OpenJSCAD.org/commit/2a3337a4b6d06d9072cb7f193eb0ef8de446c8c0)) +* **modeling:** corrected hull of single unconvex solid ([b3901f2](https://github.com/jscad/OpenJSCAD.org/commit/b3901f2b61a64a82a687f6f6062f15a20d35611b)) +* **modeling:** corrected TS definition of scission ([ad3d37d](https://github.com/jscad/OpenJSCAD.org/commit/ad3d37d32c308e99141d9ff0d8965e4d1d166123)) +* **modeling:** expose hullPoints2 and hullPoints3 ([01ceae8](https://github.com/jscad/OpenJSCAD.org/commit/01ceae89570dcaf40f9676aadd4ced515e41c291)) + + + + + ## [2.12.2](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/modeling@2.12.1...@jscad/modeling@2.12.2) (2024-06-02) diff --git a/packages/modeling/dist/jscad-modeling.min.js b/packages/modeling/dist/jscad-modeling.min.js index cc8952238..39e93a0cc 100644 --- a/packages/modeling/dist/jscad-modeling.min.js +++ b/packages/modeling/dist/jscad-modeling.min.js @@ -4,7 +4,7 @@ const cssColors=require("./cssColors"),colorNameToRgb=o=>cssColors[o.toLowerCase },{"./cssColors":3}],2:[function(require,module,exports){ const flatten=require("../utils/flatten"),geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),path2=require("../geometries/path2"),poly3=require("../geometries/poly3"),colorGeom2=(o,r)=>{const e=geom2.clone(r);return e.color=o,e},colorGeom3=(o,r)=>{const e=geom3.clone(r);return e.color=o,e},colorPath2=(o,r)=>{const e=path2.clone(r);return e.color=o,e},colorPoly3=(o,r)=>{const e=poly3.clone(r);return e.color=o,e},colorize=(o,...r)=>{if(!Array.isArray(o))throw new Error("color must be an array");if(o.length<3)throw new Error("color must contain R, G and B values");if(3===o.length&&(o=[o[0],o[1],o[2],1]),0===(r=flatten(r)).length)throw new Error("wrong number of arguments");const e=r.map(r=>geom2.isA(r)?colorGeom2(o,r):geom3.isA(r)?colorGeom3(o,r):path2.isA(r)?colorPath2(o,r):poly3.isA(r)?colorPoly3(o,r):(r.color=o,r));return 1===e.length?e[0]:e};module.exports=colorize; -},{"../geometries/geom2":25,"../geometries/geom3":41,"../geometries/path2":62,"../geometries/poly3":79,"../utils/flatten":397}],3:[function(require,module,exports){ +},{"../geometries/geom2":25,"../geometries/geom3":41,"../geometries/path2":62,"../geometries/poly3":79,"../utils/flatten":398}],3:[function(require,module,exports){ const cssColors={black:[0,0,0],silver:[192/255,192/255,192/255],gray:[128/255,128/255,128/255],white:[1,1,1],maroon:[128/255,0,0],red:[1,0,0],purple:[128/255,0,128/255],fuchsia:[1,0,1],green:[0,128/255,0],lime:[0,1,0],olive:[128/255,128/255,0],yellow:[1,1,0],navy:[0,0,128/255],blue:[0,0,1],teal:[0,128/255,128/255],aqua:[0,1,1],aliceblue:[240/255,248/255,1],antiquewhite:[250/255,235/255,215/255],aquamarine:[127/255,1,212/255],azure:[240/255,1,1],beige:[245/255,245/255,220/255],bisque:[1,228/255,196/255],blanchedalmond:[1,235/255,205/255],blueviolet:[138/255,43/255,226/255],brown:[165/255,42/255,42/255],burlywood:[222/255,184/255,135/255],cadetblue:[95/255,158/255,160/255],chartreuse:[127/255,1,0],chocolate:[210/255,105/255,30/255],coral:[1,127/255,80/255],cornflowerblue:[100/255,149/255,237/255],cornsilk:[1,248/255,220/255],crimson:[220/255,20/255,60/255],cyan:[0,1,1],darkblue:[0,0,139/255],darkcyan:[0,139/255,139/255],darkgoldenrod:[184/255,134/255,11/255],darkgray:[169/255,169/255,169/255],darkgreen:[0,100/255,0],darkgrey:[169/255,169/255,169/255],darkkhaki:[189/255,183/255,107/255],darkmagenta:[139/255,0,139/255],darkolivegreen:[85/255,107/255,47/255],darkorange:[1,140/255,0],darkorchid:[.6,50/255,.8],darkred:[139/255,0,0],darksalmon:[233/255,150/255,122/255],darkseagreen:[143/255,188/255,143/255],darkslateblue:[72/255,61/255,139/255],darkslategray:[47/255,79/255,79/255],darkslategrey:[47/255,79/255,79/255],darkturquoise:[0,206/255,209/255],darkviolet:[148/255,0,211/255],deeppink:[1,20/255,147/255],deepskyblue:[0,191/255,1],dimgray:[105/255,105/255,105/255],dimgrey:[105/255,105/255,105/255],dodgerblue:[30/255,144/255,1],firebrick:[178/255,34/255,34/255],floralwhite:[1,250/255,240/255],forestgreen:[34/255,139/255,34/255],gainsboro:[220/255,220/255,220/255],ghostwhite:[248/255,248/255,1],gold:[1,215/255,0],goldenrod:[218/255,165/255,32/255],greenyellow:[173/255,1,47/255],grey:[128/255,128/255,128/255],honeydew:[240/255,1,240/255],hotpink:[1,105/255,180/255],indianred:[205/255,92/255,92/255],indigo:[75/255,0,130/255],ivory:[1,1,240/255],khaki:[240/255,230/255,140/255],lavender:[230/255,230/255,250/255],lavenderblush:[1,240/255,245/255],lawngreen:[124/255,252/255,0],lemonchiffon:[1,250/255,205/255],lightblue:[173/255,216/255,230/255],lightcoral:[240/255,128/255,128/255],lightcyan:[224/255,1,1],lightgoldenrodyellow:[250/255,250/255,210/255],lightgray:[211/255,211/255,211/255],lightgreen:[144/255,238/255,144/255],lightgrey:[211/255,211/255,211/255],lightpink:[1,182/255,193/255],lightsalmon:[1,160/255,122/255],lightseagreen:[32/255,178/255,170/255],lightskyblue:[135/255,206/255,250/255],lightslategray:[119/255,136/255,.6],lightslategrey:[119/255,136/255,.6],lightsteelblue:[176/255,196/255,222/255],lightyellow:[1,1,224/255],limegreen:[50/255,205/255,50/255],linen:[250/255,240/255,230/255],magenta:[1,0,1],mediumaquamarine:[.4,205/255,170/255],mediumblue:[0,0,205/255],mediumorchid:[186/255,85/255,211/255],mediumpurple:[147/255,112/255,219/255],mediumseagreen:[60/255,179/255,113/255],mediumslateblue:[123/255,104/255,238/255],mediumspringgreen:[0,250/255,154/255],mediumturquoise:[72/255,209/255,.8],mediumvioletred:[199/255,21/255,133/255],midnightblue:[25/255,25/255,112/255],mintcream:[245/255,1,250/255],mistyrose:[1,228/255,225/255],moccasin:[1,228/255,181/255],navajowhite:[1,222/255,173/255],oldlace:[253/255,245/255,230/255],olivedrab:[107/255,142/255,35/255],orange:[1,165/255,0],orangered:[1,69/255,0],orchid:[218/255,112/255,214/255],palegoldenrod:[238/255,232/255,170/255],palegreen:[152/255,251/255,152/255],paleturquoise:[175/255,238/255,238/255],palevioletred:[219/255,112/255,147/255],papayawhip:[1,239/255,213/255],peachpuff:[1,218/255,185/255],peru:[205/255,133/255,63/255],pink:[1,192/255,203/255],plum:[221/255,160/255,221/255],powderblue:[176/255,224/255,230/255],rosybrown:[188/255,143/255,143/255],royalblue:[65/255,105/255,225/255],saddlebrown:[139/255,69/255,19/255],salmon:[250/255,128/255,114/255],sandybrown:[244/255,164/255,96/255],seagreen:[46/255,139/255,87/255],seashell:[1,245/255,238/255],sienna:[160/255,82/255,45/255],skyblue:[135/255,206/255,235/255],slateblue:[106/255,90/255,205/255],slategray:[112/255,128/255,144/255],slategrey:[112/255,128/255,144/255],snow:[1,250/255,250/255],springgreen:[0,1,127/255],steelblue:[70/255,130/255,180/255],tan:[210/255,180/255,140/255],thistle:[216/255,191/255,216/255],tomato:[1,99/255,71/255],turquoise:[64/255,224/255,208/255],violet:[238/255,130/255,238/255],wheat:[245/255,222/255,179/255],whitesmoke:[245/255,245/255,245/255],yellowgreen:[154/255,205/255,50/255]};module.exports=cssColors; },{}],4:[function(require,module,exports){ @@ -13,10 +13,10 @@ const hexToRgb=t=>{if((t=t.replace("#","")).length<6)throw new Error("the given },{}],5:[function(require,module,exports){ const flatten=require("../utils/flatten"),hueToColorComponent=require("./hueToColorComponent"),hslToRgb=(...o)=>{if((o=flatten(o)).length<3)throw new Error("values must contain H, S and L values");const e=o[0],n=o[1],t=o[2];let r=t,l=t,u=t;if(0!==n){const o=t<.5?t*(1+n):t+n-t*n,h=2*t-o;r=hueToColorComponent(h,o,e+1/3),l=hueToColorComponent(h,o,e),u=hueToColorComponent(h,o,e-1/3)}if(o.length>3){return[r,l,u,o[3]]}return[r,l,u]};module.exports=hslToRgb; -},{"../utils/flatten":397,"./hueToColorComponent":7}],6:[function(require,module,exports){ +},{"../utils/flatten":398,"./hueToColorComponent":7}],6:[function(require,module,exports){ const flatten=require("../utils/flatten"),hsvToRgb=(...e)=>{if((e=flatten(e)).length<3)throw new Error("values must contain H, S and V values");const t=e[0],a=e[1],r=e[2];let s=0,n=0,o=0;const c=Math.floor(6*t),l=6*t-c,u=r*(1-a),b=r*(1-l*a),h=r*(1-(1-l)*a);switch(c%6){case 0:s=r,n=h,o=u;break;case 1:s=b,n=r,o=u;break;case 2:s=u,n=r,o=h;break;case 3:s=u,n=b,o=r;break;case 4:s=h,n=u,o=r;break;case 5:s=r,n=u,o=b}if(e.length>3){return[s,n,o,e[3]]}return[s,n,o]};module.exports=hsvToRgb; -},{"../utils/flatten":397}],7:[function(require,module,exports){ +},{"../utils/flatten":398}],7:[function(require,module,exports){ const hueToColorComponent=(o,e,n)=>(n<0&&(n+=1),n>1&&(n-=1),n<1/6?o+6*(e-o)*n:n<.5?e:n<2/3?o+(e-o)*(2/3-n)*6:o);module.exports=hueToColorComponent; },{}],8:[function(require,module,exports){ @@ -25,13 +25,13 @@ module.exports={colorize:require("./colorize"),colorNameToRgb:require("./colorNa },{"./colorNameToRgb":1,"./colorize":2,"./cssColors":3,"./hexToRgb":4,"./hslToRgb":5,"./hsvToRgb":6,"./hueToColorComponent":7,"./rgbToHex":9,"./rgbToHsl":10,"./rgbToHsv":11}],9:[function(require,module,exports){ const flatten=require("../utils/flatten"),rgbToHex=(...t)=>{if((t=flatten(t)).length<3)throw new Error("values must contain R, G and B values");const e=255*t[0],r=255*t[1],n=255*t[2];let o=`#${Number(16777216+65536*e+256*r+n).toString(16).substring(1,7)}`;return t.length>3&&(o+=Number(255*t[3]).toString(16)),o};module.exports=rgbToHex; -},{"../utils/flatten":397}],10:[function(require,module,exports){ +},{"../utils/flatten":398}],10:[function(require,module,exports){ const flatten=require("../utils/flatten"),rgbToHsl=(...t)=>{if((t=flatten(t)).length<3)throw new Error("values must contain R, G and B values");const e=t[0],n=t[1],s=t[2],a=Math.max(e,n,s),r=Math.min(e,n,s);let l,o;const c=(a+r)/2;if(a===r)l=o=0;else{const t=a-r;switch(o=c>.5?t/(2-a-r):t/(a+r),a){case e:l=(n-s)/t+(n3){return[l,o,c,t[3]]}return[l,o,c]};module.exports=rgbToHsl; -},{"../utils/flatten":397}],11:[function(require,module,exports){ +},{"../utils/flatten":398}],11:[function(require,module,exports){ const flatten=require("../utils/flatten"),rgbToHsv=(...e)=>{if((e=flatten(e)).length<3)throw new Error("values must contain R, G and B values");const t=e[0],a=e[1],n=e[2],r=Math.max(t,a,n),s=Math.min(t,a,n);let l;const o=r,c=r-s,i=0===r?0:c/r;if(r===s)l=0;else{switch(r){case t:l=(a-n)/c+(a3){return[l,i,o,e[3]]}return[l,i,o]};module.exports=rgbToHsv; -},{"../utils/flatten":397}],12:[function(require,module,exports){ +},{"../utils/flatten":398}],12:[function(require,module,exports){ const lengths=require("./lengths"),arcLengthToT=(e,t)=>{const{distance:s,segments:n}=Object.assign({},{distance:0,segments:100},e),o=lengths(n,t);let r=0,c=n;for(;r<=c;){const e=Math.floor(r+(c-r)/2),t=o[e]-s;if(t<0)r=e+1;else{if(!(t>0)){c=e;break}c=e-1}}const g=c;if(o[g]===s)return g/n;const a=o[g];return(g+(s-a)/(o[g+1]-a))/n};module.exports=arcLengthToT; },{"./lengths":16}],13:[function(require,module,exports){ @@ -118,7 +118,7 @@ const poly3=require("../poly3"),create=require("./create"),fromPoints=r=>{if(!Ar },{"../poly3":79,"./create":37}],40:[function(require,module,exports){ const quickhull=require("../../operations/hulls/quickhull"),create=require("./create"),poly3=require("../poly3"),fromPointsConvex=r=>{if(!Array.isArray(r))throw new Error("the given points must be an array");const e=quickhull(r,{skipTriangulation:!0}).map(e=>{const o=e.map(e=>r[e]);return poly3.create(o)});return create(e)};module.exports=fromPointsConvex; -},{"../../operations/hulls/quickhull":347,"../poly3":79,"./create":37}],41:[function(require,module,exports){ +},{"../../operations/hulls/quickhull":348,"../poly3":79,"./create":37}],41:[function(require,module,exports){ module.exports={clone:require("./clone"),create:require("./create"),fromPointsConvex:require("./fromPointsConvex"),fromPoints:require("./fromPoints"),fromCompactBinary:require("./fromCompactBinary"),invert:require("./invert"),isA:require("./isA"),toPoints:require("./toPoints"),toPolygons:require("./toPolygons"),toString:require("./toString"),toCompactBinary:require("./toCompactBinary"),transform:require("./transform"),validate:require("./validate")}; },{"./clone":36,"./create":37,"./fromCompactBinary":38,"./fromPoints":39,"./fromPointsConvex":40,"./invert":42,"./isA":43,"./toCompactBinary":44,"./toPoints":45,"./toPolygons":46,"./toString":47,"./transform":48,"./validate":49}],42:[function(require,module,exports){ @@ -274,7 +274,7 @@ const signedDistanceToPoint=require("../../maths/plane/signedDistanceToPoint"),{ },{"../../maths/constants":94,"../../maths/plane/signedDistanceToPoint":165,"../../maths/vec3":222,"./isA":81,"./isConvex":82,"./measureArea":83,"./plane":87}],92:[function(require,module,exports){ module.exports={colors:require("./colors"),curves:require("./curves"),geometries:require("./geometries"),maths:require("./maths"),measurements:require("./measurements"),primitives:require("./primitives"),text:require("./text"),utils:require("./utils"),booleans:require("./operations/booleans"),expansions:require("./operations/expansions"),extrusions:require("./operations/extrusions"),hulls:require("./operations/hulls"),modifiers:require("./operations/modifiers"),transforms:require("./operations/transforms")}; -},{"./colors":8,"./curves":19,"./geometries":50,"./maths":95,"./measurements":252,"./operations/booleans":266,"./operations/expansions":295,"./operations/extrusions":318,"./operations/hulls":340,"./operations/modifiers":351,"./operations/transforms":361,"./primitives":377,"./text":391,"./utils":399}],93:[function(require,module,exports){ +},{"./colors":8,"./curves":19,"./geometries":50,"./maths":95,"./measurements":252,"./operations/booleans":266,"./operations/expansions":295,"./operations/extrusions":318,"./operations/hulls":341,"./operations/modifiers":352,"./operations/transforms":362,"./primitives":378,"./text":392,"./utils":400}],93:[function(require,module,exports){ const mat4=require("./mat4"),vec2=require("./vec2"),vec3=require("./vec3"),OrthoNormalBasis=function(e,t){arguments.length<2&&(t=vec3.orthogonal(vec3.create(),e)),this.v=vec3.normalize(vec3.create(),vec3.cross(vec3.create(),e,t)),this.u=vec3.cross(vec3.create(),this.v,e),this.plane=e,this.planeorigin=vec3.scale(vec3.create(),e,e[3])};OrthoNormalBasis.GetCartesian=function(e,t){const i=e+"/"+t;let s,n;if("X/Y"===i)s=[0,0,1],n=[1,0,0];else if("Y/-X"===i)s=[0,0,1],n=[0,1,0];else if("-X/-Y"===i)s=[0,0,1],n=[-1,0,0];else if("-Y/X"===i)s=[0,0,1],n=[0,-1,0];else if("-X/Y"===i)s=[0,0,-1],n=[-1,0,0];else if("-Y/-X"===i)s=[0,0,-1],n=[0,-1,0];else if("X/-Y"===i)s=[0,0,-1],n=[1,0,0];else if("Y/X"===i)s=[0,0,-1],n=[0,1,0];else if("X/Z"===i)s=[0,-1,0],n=[1,0,0];else if("Z/-X"===i)s=[0,-1,0],n=[0,0,1];else if("-X/-Z"===i)s=[0,-1,0],n=[-1,0,0];else if("-Z/X"===i)s=[0,-1,0],n=[0,0,-1];else if("-X/Z"===i)s=[0,1,0],n=[-1,0,0];else if("-Z/-X"===i)s=[0,1,0],n=[0,0,-1];else if("X/-Z"===i)s=[0,1,0],n=[1,0,0];else if("Z/X"===i)s=[0,1,0],n=[0,0,1];else if("Y/Z"===i)s=[1,0,0],n=[0,1,0];else if("Z/-Y"===i)s=[1,0,0],n=[0,0,1];else if("-Y/-Z"===i)s=[1,0,0],n=[0,-1,0];else if("-Z/Y"===i)s=[1,0,0],n=[0,0,-1];else if("-Y/Z"===i)s=[-1,0,0],n=[0,-1,0];else if("-Z/-Y"===i)s=[-1,0,0],n=[0,0,-1];else if("Y/-Z"===i)s=[-1,0,0],n=[0,1,0];else{if("Z/Y"!==i)throw new Error("OrthoNormalBasis.GetCartesian: invalid combination of axis identifiers. Should pass two string arguments from [X,Y,Z,-X,-Y,-Z], being two different axes.");s=[-1,0,0],n=[0,0,1]}return new OrthoNormalBasis(new Plane(new Vector3D(s),0),new Vector3D(n))},OrthoNormalBasis.Z0Plane=function(){const e=new Plane(new Vector3D([0,0,1]),0);return new OrthoNormalBasis(e,new Vector3D([1,0,0]))},OrthoNormalBasis.prototype={getProjectionMatrix:function(){return mat4.fromValues(this.u[0],this.v[0],this.plane[0],0,this.u[1],this.v[1],this.plane[1],0,this.u[2],this.v[2],this.plane[2],0,0,0,-this.plane[3],1)},getInverseProjectionMatrix:function(){const e=vec3.scale(vec3.create(),this.plane,this.plane[3]);return mat4.fromValues(this.u[0],this.u[1],this.u[2],0,this.v[0],this.v[1],this.v[2],0,this.plane[0],this.plane[1],this.plane[2],0,e[0],e[1],e[2],1)},to2D:function(e){return vec2.fromValues(vec3.dot(e,this.u),vec3.dot(e,this.v))},to3D:function(e){const t=vec3.scale(vec3.create(),this.u,e[0]),i=vec3.scale(vec3.create(),this.v,e[1]),s=vec3.add(t,t,this.planeorigin);return vec3.add(i,i,s)},line3Dto2D:function(e){const t=e.point,i=e.direction.plus(t),s=this.to2D(t),n=this.to2D(i);return Line2D.fromPoints(s,n)},line2Dto3D:function(e){const t=e.origin(),i=e.direction().plus(t),s=this.to3D(t),n=this.to3D(i);return Line3D.fromPoints(s,n)},transform:function(e){const t=this.plane.transform(e),i=this.u.transform(e),s=new Vector3D(0,0,0).transform(e),n=i.minus(s);return new OrthoNormalBasis(t,n)}},module.exports=OrthoNormalBasis; },{"./mat4":143,"./vec2":191,"./vec3":222}],94:[function(require,module,exports){ @@ -757,40 +757,40 @@ module.exports={measureAggregateArea:require("./measureAggregateArea"),measureAg },{"./measureAggregateArea":253,"./measureAggregateBoundingBox":254,"./measureAggregateEpsilon":255,"./measureAggregateVolume":256,"./measureArea":257,"./measureBoundingBox":258,"./measureBoundingSphere":259,"./measureCenter":260,"./measureCenterOfMass":261,"./measureDimensions":262,"./measureEpsilon":263,"./measureVolume":264}],253:[function(require,module,exports){ const flatten=require("../utils/flatten"),measureArea=require("./measureArea"),measureAggregateArea=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("measureAggregateArea: no geometries supplied");const r=measureArea(e);if(1===e.length)return r;return r.reduce((e,r)=>e+r,0)};module.exports=measureAggregateArea; -},{"../utils/flatten":397,"./measureArea":257}],254:[function(require,module,exports){ +},{"../utils/flatten":398,"./measureArea":257}],254:[function(require,module,exports){ const flatten=require("../utils/flatten"),vec3min=require("../maths/vec3/min"),vec3max=require("../maths/vec3/max"),measureBoundingBox=require("./measureBoundingBox"),measureAggregateBoundingBox=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("measureAggregateBoundingBox: no geometries supplied");const r=measureBoundingBox(e);if(1===e.length)return r;const u=[[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],[-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE]];return r.reduce((e,r)=>e=[vec3min(e[0],e[0],r[0]),vec3max(e[1],e[1],r[1])],u)};module.exports=measureAggregateBoundingBox; -},{"../maths/vec3/max":225,"../maths/vec3/min":226,"../utils/flatten":397,"./measureBoundingBox":258}],255:[function(require,module,exports){ +},{"../maths/vec3/max":225,"../maths/vec3/min":226,"../utils/flatten":398,"./measureBoundingBox":258}],255:[function(require,module,exports){ const flatten=require("../utils/flatten"),measureAggregateBoundingBox=require("./measureAggregateBoundingBox"),calculateEpsilonFromBounds=require("./calculateEpsilonFromBounds"),{geom2:geom2,geom3:geom3,path2:path2}=require("../geometries"),measureAggregateEpsilon=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("measureAggregateEpsilon: no geometries supplied");const o=measureAggregateBoundingBox(e);let r=0;return r=e.reduce((e,o)=>path2.isA(o)||geom2.isA(o)?Math.max(e,2):geom3.isA(o)?Math.max(e,3):0,r),calculateEpsilonFromBounds(o,r)};module.exports=measureAggregateEpsilon; -},{"../geometries":50,"../utils/flatten":397,"./calculateEpsilonFromBounds":251,"./measureAggregateBoundingBox":254}],256:[function(require,module,exports){ +},{"../geometries":50,"../utils/flatten":398,"./calculateEpsilonFromBounds":251,"./measureAggregateBoundingBox":254}],256:[function(require,module,exports){ const flatten=require("../utils/flatten"),measureVolume=require("./measureVolume"),measureAggregateVolume=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("measureAggregateVolume: no geometries supplied");const r=measureVolume(e);if(1===e.length)return r;return r.reduce((e,r)=>e+r,0)};module.exports=measureAggregateVolume; -},{"../utils/flatten":397,"./measureVolume":264}],257:[function(require,module,exports){ +},{"../utils/flatten":398,"./measureVolume":264}],257:[function(require,module,exports){ const flatten=require("../utils/flatten"),geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),path2=require("../geometries/path2"),poly3=require("../geometries/poly3"),cache=new WeakMap,measureAreaOfPath2=()=>0,measureAreaOfGeom2=e=>{let r=cache.get(e);if(r)return r;return r=geom2.toSides(e).reduce((e,r)=>e+(r[0][0]*r[1][1]-r[0][1]*r[1][0]),0),r*=.5,cache.set(e,r),r},measureAreaOfGeom3=e=>{let r=cache.get(e);if(r)return r;return r=geom3.toPolygons(e).reduce((e,r)=>e+poly3.measureArea(r),0),cache.set(e,r),r},measureArea=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");const r=e.map(e=>path2.isA(e)?0:geom2.isA(e)?measureAreaOfGeom2(e):geom3.isA(e)?measureAreaOfGeom3(e):0);return 1===r.length?r[0]:r};module.exports=measureArea; -},{"../geometries/geom2":25,"../geometries/geom3":41,"../geometries/path2":62,"../geometries/poly3":79,"../utils/flatten":397}],258:[function(require,module,exports){ +},{"../geometries/geom2":25,"../geometries/geom3":41,"../geometries/path2":62,"../geometries/poly3":79,"../utils/flatten":398}],258:[function(require,module,exports){ const flatten=require("../utils/flatten"),vec2=require("../maths/vec2"),vec3=require("../maths/vec3"),geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),path2=require("../geometries/path2"),poly3=require("../geometries/poly3"),cache=new WeakMap,measureBoundingBoxOfPath2=e=>{let o=cache.get(e);if(o)return o;const t=path2.toPoints(e);let n;n=0===t.length?vec2.create():vec2.clone(t[0]);let r=vec2.clone(n);return t.forEach(e=>{vec2.min(n,n,e),vec2.max(r,r,e)}),n=[n[0],n[1],0],r=[r[0],r[1],0],o=[n,r],cache.set(e,o),o},measureBoundingBoxOfGeom2=e=>{let o=cache.get(e);if(o)return o;const t=geom2.toPoints(e);let n;n=0===t.length?vec2.create():vec2.clone(t[0]);let r=vec2.clone(n);return t.forEach(e=>{vec2.min(n,n,e),vec2.max(r,r,e)}),n=[n[0],n[1],0],r=[r[0],r[1],0],o=[n,r],cache.set(e,o),o},measureBoundingBoxOfGeom3=e=>{let o=cache.get(e);if(o)return o;const t=geom3.toPolygons(e);let n=vec3.create();if(t.length>0){const e=poly3.toPoints(t[0]);vec3.copy(n,e[0])}let r=vec3.clone(n);return t.forEach(e=>{poly3.toPoints(e).forEach(e=>{vec3.min(n,n,e),vec3.max(r,r,e)})}),n=[n[0],n[1],n[2]],r=[r[0],r[1],r[2]],o=[n,r],cache.set(e,o),o},measureBoundingBox=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");const o=e.map(e=>path2.isA(e)?measureBoundingBoxOfPath2(e):geom2.isA(e)?measureBoundingBoxOfGeom2(e):geom3.isA(e)?measureBoundingBoxOfGeom3(e):[[0,0,0],[0,0,0]]);return 1===o.length?o[0]:o};module.exports=measureBoundingBox; -},{"../geometries/geom2":25,"../geometries/geom3":41,"../geometries/path2":62,"../geometries/poly3":79,"../maths/vec2":191,"../maths/vec3":222,"../utils/flatten":397}],259:[function(require,module,exports){ +},{"../geometries/geom2":25,"../geometries/geom3":41,"../geometries/path2":62,"../geometries/poly3":79,"../maths/vec2":191,"../maths/vec3":222,"../utils/flatten":398}],259:[function(require,module,exports){ const flatten=require("../utils/flatten"),vec2=require("../maths/vec2"),vec3=require("../maths/vec3"),geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),path2=require("../geometries/path2"),poly3=require("../geometries/poly3"),cacheOfBoundingSpheres=new WeakMap,measureBoundingSphereOfPath2=e=>{let t=cacheOfBoundingSpheres.get(e);if(void 0!==t)return t;const r=vec3.create();let o=0;const c=path2.toPoints(e);if(c.length>0){let e=0;const t=vec3.create();c.forEach(o=>{vec3.add(r,r,vec3.fromVec2(t,o,0)),e++}),vec3.scale(r,r,1/e),c.forEach(e=>{o=Math.max(o,vec2.squaredDistance(r,e))}),o=Math.sqrt(o)}return t=[r,o],cacheOfBoundingSpheres.set(e,t),t},measureBoundingSphereOfGeom2=e=>{let t=cacheOfBoundingSpheres.get(e);if(void 0!==t)return t;const r=vec3.create();let o=0;const c=geom2.toSides(e);if(c.length>0){let e=0;const t=vec3.create();c.forEach(o=>{vec3.add(r,r,vec3.fromVec2(t,o[0],0)),e++}),vec3.scale(r,r,1/e),c.forEach(e=>{o=Math.max(o,vec2.squaredDistance(r,e[0]))}),o=Math.sqrt(o)}return t=[r,o],cacheOfBoundingSpheres.set(e,t),t},measureBoundingSphereOfGeom3=e=>{let t=cacheOfBoundingSpheres.get(e);if(void 0!==t)return t;const r=vec3.create();let o=0;const c=geom3.toPolygons(e);if(c.length>0){let e=0;c.forEach(t=>{poly3.toPoints(t).forEach(t=>{vec3.add(r,r,t),e++})}),vec3.scale(r,r,1/e),c.forEach(e=>{poly3.toPoints(e).forEach(e=>{o=Math.max(o,vec3.squaredDistance(r,e))})}),o=Math.sqrt(o)}return t=[r,o],cacheOfBoundingSpheres.set(e,t),t},measureBoundingSphere=(...e)=>{const t=(e=flatten(e)).map(e=>path2.isA(e)?measureBoundingSphereOfPath2(e):geom2.isA(e)?measureBoundingSphereOfGeom2(e):geom3.isA(e)?measureBoundingSphereOfGeom3(e):[[0,0,0],0]);return 1===t.length?t[0]:t};module.exports=measureBoundingSphere; -},{"../geometries/geom2":25,"../geometries/geom3":41,"../geometries/path2":62,"../geometries/poly3":79,"../maths/vec2":191,"../maths/vec3":222,"../utils/flatten":397}],260:[function(require,module,exports){ +},{"../geometries/geom2":25,"../geometries/geom3":41,"../geometries/path2":62,"../geometries/poly3":79,"../maths/vec2":191,"../maths/vec3":222,"../utils/flatten":398}],260:[function(require,module,exports){ const flatten=require("../utils/flatten"),measureBoundingBox=require("./measureBoundingBox"),measureCenter=(...e)=>{const n=(e=flatten(e)).map(e=>{const n=measureBoundingBox(e);return[n[0][0]+(n[1][0]-n[0][0])/2,n[0][1]+(n[1][1]-n[0][1])/2,n[0][2]+(n[1][2]-n[0][2])/2]});return 1===n.length?n[0]:n};module.exports=measureCenter; -},{"../utils/flatten":397,"./measureBoundingBox":258}],261:[function(require,module,exports){ +},{"../utils/flatten":398,"./measureBoundingBox":258}],261:[function(require,module,exports){ const flatten=require("../utils/flatten"),vec3=require("../maths/vec3"),geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),cacheOfCenterOfMass=new WeakMap,measureCenterOfMassGeom2=e=>{let t=cacheOfCenterOfMass.get(e);if(void 0!==t)return t;const s=geom2.toSides(e);let r=0,c=0,a=0;if(s.length>0){for(let e=0;e{let t=cacheOfCenterOfMass.get(e);if(void 0!==t)return t;t=vec3.create();const s=geom3.toPolygons(e);if(0===s.length)return t;let r=0;const c=vec3.create();return s.forEach(e=>{const s=e.vertices;for(let e=0;e{const t=(e=flatten(e)).map(e=>geom2.isA(e)?measureCenterOfMassGeom2(e):geom3.isA(e)?measureCenterOfMassGeom3(e):[0,0,0]);return 1===t.length?t[0]:t};module.exports=measureCenterOfMass; -},{"../geometries/geom2":25,"../geometries/geom3":41,"../maths/vec3":222,"../utils/flatten":397}],262:[function(require,module,exports){ +},{"../geometries/geom2":25,"../geometries/geom3":41,"../maths/vec3":222,"../utils/flatten":398}],262:[function(require,module,exports){ const flatten=require("../utils/flatten"),measureBoundingBox=require("./measureBoundingBox"),measureDimensions=(...e)=>{const n=(e=flatten(e)).map(e=>{const n=measureBoundingBox(e);return[n[1][0]-n[0][0],n[1][1]-n[0][1],n[1][2]-n[0][2]]});return 1===n.length?n[0]:n};module.exports=measureDimensions; -},{"../utils/flatten":397,"./measureBoundingBox":258}],263:[function(require,module,exports){ +},{"../utils/flatten":398,"./measureBoundingBox":258}],263:[function(require,module,exports){ const flatten=require("../utils/flatten"),{geom2:geom2,geom3:geom3,path2:path2}=require("../geometries"),calculateEpsilonFromBounds=require("./calculateEpsilonFromBounds"),measureBoundingBox=require("./measureBoundingBox"),measureEpsilonOfPath2=e=>calculateEpsilonFromBounds(measureBoundingBox(e),2),measureEpsilonOfGeom2=e=>calculateEpsilonFromBounds(measureBoundingBox(e),2),measureEpsilonOfGeom3=e=>calculateEpsilonFromBounds(measureBoundingBox(e),3),measureEpsilon=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");const o=e.map(e=>path2.isA(e)?measureEpsilonOfPath2(e):geom2.isA(e)?measureEpsilonOfGeom2(e):geom3.isA(e)?measureEpsilonOfGeom3(e):0);return 1===o.length?o[0]:o};module.exports=measureEpsilon; -},{"../geometries":50,"../utils/flatten":397,"./calculateEpsilonFromBounds":251,"./measureBoundingBox":258}],264:[function(require,module,exports){ +},{"../geometries":50,"../utils/flatten":398,"./calculateEpsilonFromBounds":251,"./measureBoundingBox":258}],264:[function(require,module,exports){ const flatten=require("../utils/flatten"),geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),path2=require("../geometries/path2"),poly3=require("../geometries/poly3"),cache=new WeakMap,measureVolumeOfPath2=()=>0,measureVolumeOfGeom2=()=>0,measureVolumeOfGeom3=e=>{let r=cache.get(e);if(r)return r;return r=geom3.toPolygons(e).reduce((e,r)=>e+poly3.measureSignedVolume(r),0),cache.set(e,r),r},measureVolume=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");const r=e.map(e=>path2.isA(e)?0:geom2.isA(e)?0:geom3.isA(e)?measureVolumeOfGeom3(e):0);return 1===r.length?r[0]:r};module.exports=measureVolume; -},{"../geometries/geom2":25,"../geometries/geom3":41,"../geometries/path2":62,"../geometries/poly3":79,"../utils/flatten":397}],265:[function(require,module,exports){ +},{"../geometries/geom2":25,"../geometries/geom3":41,"../geometries/path2":62,"../geometries/poly3":79,"../utils/flatten":398}],265:[function(require,module,exports){ const vec2=require("../../maths/vec2"),geom2=require("../../geometries/geom2"),fromFakePolygon=(e,o)=>{if(o.vertices.length<4)return null;const r=[],n=o.vertices.filter((e,o)=>e[2]>0&&(r.push(o),!0));if(2!==n.length)throw new Error("Assertion failed: fromFakePolygon: not enough points found");const t=n.map(o=>{const r=Math.round(o[0]/e)*e+0,n=Math.round(o[1]/e)*e+0;return vec2.fromValues(r,n)});if(vec2.equals(t[0],t[1]))return null;const s=r[1]-r[0];if(1!==s&&3!==s)throw new Error("Assertion failed: fromFakePolygon: unknown index ordering");return 1===s&&t.reverse(),t},fromFakePolygons=(e,o)=>{const r=o.map(o=>fromFakePolygon(e,o)).filter(e=>null!==e);return geom2.create(r)};module.exports=fromFakePolygons; },{"../../geometries/geom2":25,"../../maths/vec2":191}],266:[function(require,module,exports){ @@ -799,13 +799,13 @@ module.exports={intersect:require("./intersect"),scission:require("./scission"), },{"./intersect":267,"./scission":272,"./subtract":274,"./union":285}],267:[function(require,module,exports){ const flatten=require("../../utils/flatten"),areAllShapesTheSameType=require("../../utils/areAllShapesTheSameType"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),intersectGeom2=require("./intersectGeom2"),intersectGeom3=require("./intersectGeom3"),intersect=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");if(!areAllShapesTheSameType(e))throw new Error("only intersect of the types are supported");const r=e[0];return geom2.isA(r)?intersectGeom2(e):geom3.isA(r)?intersectGeom3(e):r};module.exports=intersect; -},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../utils/areAllShapesTheSameType":395,"../../utils/flatten":397,"./intersectGeom2":268,"./intersectGeom3":269}],268:[function(require,module,exports){ +},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../utils/areAllShapesTheSameType":396,"../../utils/flatten":398,"./intersectGeom2":268,"./intersectGeom3":269}],268:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom3=require("../../geometries/geom3"),measureEpsilon=require("../../measurements/measureEpsilon"),fromFakePolygons=require("./fromFakePolygons"),to3DWalls=require("./to3DWalls"),intersectGeom3=require("./intersectGeom3"),intersect=(...e)=>{const o=(e=flatten(e)).map(e=>to3DWalls({z0:-1,z1:1},e)),r=intersectGeom3(o),t=measureEpsilon(r);return fromFakePolygons(t,geom3.toPolygons(r))};module.exports=intersect; -},{"../../geometries/geom3":41,"../../measurements/measureEpsilon":263,"../../utils/flatten":397,"./fromFakePolygons":265,"./intersectGeom3":269,"./to3DWalls":278}],269:[function(require,module,exports){ +},{"../../geometries/geom3":41,"../../measurements/measureEpsilon":263,"../../utils/flatten":398,"./fromFakePolygons":265,"./intersectGeom3":269,"./to3DWalls":278}],269:[function(require,module,exports){ const flatten=require("../../utils/flatten"),retessellate=require("../modifiers/retessellate"),intersectSub=require("./intersectGeom3Sub"),intersect=(...e)=>{let t=(e=flatten(e)).shift();return e.forEach(e=>{t=intersectSub(t,e)}),t=retessellate(t)};module.exports=intersect; -},{"../../utils/flatten":397,"../modifiers/retessellate":355,"./intersectGeom3Sub":270}],270:[function(require,module,exports){ +},{"../../utils/flatten":398,"../modifiers/retessellate":356,"./intersectGeom3Sub":270}],270:[function(require,module,exports){ const geom3=require("../../geometries/geom3"),mayOverlap=require("./mayOverlap"),{Tree:Tree}=require("./trees"),intersectGeom3Sub=(e,o)=>{if(!mayOverlap(e,o))return geom3.create();const r=new Tree(geom3.toPolygons(e)),t=new Tree(geom3.toPolygons(o));r.invert(),t.clipTo(r),t.invert(),r.clipTo(t),t.clipTo(r),r.addPolygons(t.allPolygons()),r.invert();const n=r.allPolygons();return geom3.create(n)};module.exports=intersectGeom3Sub; },{"../../geometries/geom3":41,"./mayOverlap":271,"./trees":282}],271:[function(require,module,exports){ @@ -814,19 +814,19 @@ const{EPS:EPS}=require("../../maths/constants"),measureBoundingBox=require("../. },{"../../maths/constants":94,"../../measurements/measureBoundingBox":258}],272:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom3=require("../../geometries/geom3"),scissionGeom3=require("./scissionGeom3"),scission=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");const s=e.map(e=>geom3.isA(e)?scissionGeom3(e):e);return 1===s.length?s[0]:s};module.exports=scission; -},{"../../geometries/geom3":41,"../../utils/flatten":397,"./scissionGeom3":273}],273:[function(require,module,exports){ +},{"../../geometries/geom3":41,"../../utils/flatten":398,"./scissionGeom3":273}],273:[function(require,module,exports){ const vec3=require("../../maths/vec3"),measureEpsilon=require("../../measurements/measureEpsilon"),geom3=require("../../geometries/geom3"),sortNb=e=>e.sort((e,s)=>e-s).filter((e,s,o)=>!s||e!==o[s-1]),insertMapping=(e,s,o)=>{const t=`${s}`,n=e.get(t);void 0===n?e.set(t,[o]):n.push(o)},findMapping=(e,s)=>{const o=`${s}`;return e.get(o)},scissionGeom3=e=>{const s=measureEpsilon(e),o=geom3.toPolygons(e),t=o.length,n=new Map,r=vec3.create();o.forEach((e,o)=>{e.vertices.forEach(e=>{insertMapping(n,vec3.snap(r,e,s),o)})});const c=o.map(e=>{let o=[];return e.vertices.forEach(e=>{o=o.concat(findMapping(n,vec3.snap(r,e,s)))}),{e:1,d:sortNb(o)}});n.clear();let i=0;const a=c.length;for(let e=0;e0){const o=new Array(t);o[e]=!0;do{i=0,o.forEach((e,s)=>{const t=c[s];if(t.e>0){t.e=-1;for(let e=0;e0);s.indexes=o}}const p=[];for(let e=0;es.push(o[t])),p.push(geom3.create(s))}return p};module.exports=scissionGeom3; },{"../../geometries/geom3":41,"../../maths/vec3":222,"../../measurements/measureEpsilon":263}],274:[function(require,module,exports){ const flatten=require("../../utils/flatten"),areAllShapesTheSameType=require("../../utils/areAllShapesTheSameType"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),subtractGeom2=require("./subtractGeom2"),subtractGeom3=require("./subtractGeom3"),subtract=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");if(!areAllShapesTheSameType(e))throw new Error("only subtract of the types are supported");const r=e[0];return geom2.isA(r)?subtractGeom2(e):geom3.isA(r)?subtractGeom3(e):r};module.exports=subtract; -},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../utils/areAllShapesTheSameType":395,"../../utils/flatten":397,"./subtractGeom2":275,"./subtractGeom3":276}],275:[function(require,module,exports){ +},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../utils/areAllShapesTheSameType":396,"../../utils/flatten":398,"./subtractGeom2":275,"./subtractGeom3":276}],275:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom3=require("../../geometries/geom3"),measureEpsilon=require("../../measurements/measureEpsilon"),fromFakePolygons=require("./fromFakePolygons"),to3DWalls=require("./to3DWalls"),subtractGeom3=require("./subtractGeom3"),subtract=(...e)=>{const o=(e=flatten(e)).map(e=>to3DWalls({z0:-1,z1:1},e)),r=subtractGeom3(o),t=measureEpsilon(r);return fromFakePolygons(t,geom3.toPolygons(r))};module.exports=subtract; -},{"../../geometries/geom3":41,"../../measurements/measureEpsilon":263,"../../utils/flatten":397,"./fromFakePolygons":265,"./subtractGeom3":276,"./to3DWalls":278}],276:[function(require,module,exports){ +},{"../../geometries/geom3":41,"../../measurements/measureEpsilon":263,"../../utils/flatten":398,"./fromFakePolygons":265,"./subtractGeom3":276,"./to3DWalls":278}],276:[function(require,module,exports){ const flatten=require("../../utils/flatten"),retessellate=require("../modifiers/retessellate"),subtractSub=require("./subtractGeom3Sub"),subtract=(...t)=>{let e=(t=flatten(t)).shift();return t.forEach(t=>{e=subtractSub(e,t)}),e=retessellate(e)};module.exports=subtract; -},{"../../utils/flatten":397,"../modifiers/retessellate":355,"./subtractGeom3Sub":277}],277:[function(require,module,exports){ +},{"../../utils/flatten":398,"../modifiers/retessellate":356,"./subtractGeom3Sub":277}],277:[function(require,module,exports){ const geom3=require("../../geometries/geom3"),mayOverlap=require("./mayOverlap"),{Tree:Tree}=require("./trees"),subtractGeom3Sub=(e,o)=>{if(!mayOverlap(e,o))return geom3.clone(e);const r=new Tree(geom3.toPolygons(e)),t=new Tree(geom3.toPolygons(o));r.invert(),r.clipTo(t),t.clipTo(r,!0),r.addPolygons(t.allPolygons()),r.invert();const l=r.allPolygons();return geom3.create(l)};module.exports=subtractGeom3Sub; },{"../../geometries/geom3":41,"./mayOverlap":271,"./trees":282}],278:[function(require,module,exports){ @@ -853,19 +853,19 @@ const{EPS:EPS}=require("../../../maths/constants"),plane=require("../../../maths },{"../../../geometries/poly3":79,"../../../maths/constants":94,"../../../maths/plane":163,"../../../maths/vec3":222,"./splitLineSegmentByPlane":283}],285:[function(require,module,exports){ const flatten=require("../../utils/flatten"),areAllShapesTheSameType=require("../../utils/areAllShapesTheSameType"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),unionGeom2=require("./unionGeom2"),unionGeom3=require("./unionGeom3"),union=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");if(!areAllShapesTheSameType(e))throw new Error("only unions of the same type are supported");const o=e[0];return geom2.isA(o)?unionGeom2(e):geom3.isA(o)?unionGeom3(e):o};module.exports=union; -},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../utils/areAllShapesTheSameType":395,"../../utils/flatten":397,"./unionGeom2":286,"./unionGeom3":287}],286:[function(require,module,exports){ +},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../utils/areAllShapesTheSameType":396,"../../utils/flatten":398,"./unionGeom2":286,"./unionGeom3":287}],286:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom3=require("../../geometries/geom3"),measureEpsilon=require("../../measurements/measureEpsilon"),fromFakePolygons=require("./fromFakePolygons"),to3DWalls=require("./to3DWalls"),unionGeom3=require("./unionGeom3"),union=(...e)=>{const o=(e=flatten(e)).map(e=>to3DWalls({z0:-1,z1:1},e)),n=unionGeom3(o),r=measureEpsilon(n);return fromFakePolygons(r,geom3.toPolygons(n))};module.exports=union; -},{"../../geometries/geom3":41,"../../measurements/measureEpsilon":263,"../../utils/flatten":397,"./fromFakePolygons":265,"./to3DWalls":278,"./unionGeom3":287}],287:[function(require,module,exports){ +},{"../../geometries/geom3":41,"../../measurements/measureEpsilon":263,"../../utils/flatten":398,"./fromFakePolygons":265,"./to3DWalls":278,"./unionGeom3":287}],287:[function(require,module,exports){ const flatten=require("../../utils/flatten"),retessellate=require("../modifiers/retessellate"),unionSub=require("./unionGeom3Sub"),union=(...e)=>{let t;for(e=flatten(e),t=1;t{if(!mayOverlap(e,o))return unionForNonIntersecting(e,o);const n=new Tree(geom3.toPolygons(e)),r=new Tree(geom3.toPolygons(o));n.clipTo(r,!1),r.clipTo(n),r.invert(),r.clipTo(n),r.invert();const t=n.allPolygons().concat(r.allPolygons());return geom3.create(t)},unionForNonIntersecting=(e,o)=>{let n=geom3.toPolygons(e);return n=n.concat(geom3.toPolygons(o)),geom3.create(n)};module.exports=unionSub; },{"../../geometries/geom3":41,"./mayOverlap":271,"./trees":282}],289:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),expandGeom2=require("./expandGeom2"),expandGeom3=require("./expandGeom3"),expandPath2=require("./expandPath2"),expand=(e,...r)=>{if(0===(r=flatten(r)).length)throw new Error("wrong number of arguments");const t=r.map(r=>path2.isA(r)?expandPath2(e,r):geom2.isA(r)?expandGeom2(e,r):geom3.isA(r)?expandGeom3(e,r):r);return 1===t.length?t[0]:t};module.exports=expand; -},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../geometries/path2":62,"../../utils/flatten":397,"./expandGeom2":290,"./expandGeom3":291,"./expandPath2":292}],290:[function(require,module,exports){ +},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../geometries/path2":62,"../../utils/flatten":398,"./expandGeom2":290,"./expandGeom3":291,"./expandPath2":292}],290:[function(require,module,exports){ const geom2=require("../../geometries/geom2"),offsetFromPoints=require("./offsetFromPoints"),expandGeom2=(e,o)=>{const{delta:r,corners:s,segments:t}=Object.assign({},{delta:1,corners:"edge",segments:16},e);if("edge"!==s&&"chamfer"!==s&&"round"!==s)throw new Error('corners must be "edge", "chamfer", or "round"');const n=geom2.toOutlines(o).map(o=>offsetFromPoints(e={delta:r,corners:s,closed:!0,segments:t},o)).reduce((e,o)=>e.concat(geom2.toSides(geom2.fromPoints(o))),[]);return geom2.create(n)};module.exports=expandGeom2; },{"../../geometries/geom2":25,"./offsetFromPoints":297}],291:[function(require,module,exports){ @@ -877,7 +877,7 @@ const area=require("../../maths/utils/area"),vec2=require("../../maths/vec2"),ge },{"../../geometries/geom2":25,"../../geometries/path2":62,"../../maths/utils/area":168,"../../maths/vec2":191,"./offsetFromPoints":297}],293:[function(require,module,exports){ const{EPS:EPS,TAU:TAU}=require("../../maths/constants"),mat4=require("../../maths/mat4"),vec3=require("../../maths/vec3"),fnNumberSort=require("../../utils/fnNumberSort"),geom3=require("../../geometries/geom3"),poly3=require("../../geometries/poly3"),sphere=require("../../primitives/sphere"),retessellate=require("../modifiers/retessellate"),unionGeom3Sub=require("../booleans/unionGeom3Sub"),extrudePolygon=require("./extrudePolygon"),mapPlaneToVertex=(e,t,o)=>{const n=t.toString();if(e.has(n)){e.get(n)[1].push(o)}else{const s=[t,[o]];e.set(n,s)}},mapPlaneToEdge=(e,t,o)=>{const n=t[0].toString(),s=t[1].toString(),r=n{e.findIndex(e=>e===t)<0&&e.push(t)},expandShell=(e,t)=>{const{delta:o,segments:n}=Object.assign({},{delta:1,segments:12},e);let s=geom3.create();const r=new Map,c=new Map,a=vec3.create(),l=vec3.create();return geom3.toPolygons(t).forEach((e,t)=>{const n=vec3.scale(vec3.create(),poly3.plane(e),2*o),a=poly3.transform(mat4.fromTranslation(mat4.create(),vec3.scale(vec3.create(),n,-.5)),e),l=extrudePolygon(n,a);s=unionGeom3Sub(s,l);const u=e.vertices;for(let t=0;t{const t=e[0],r=e[1],c=t[0],u=t[1],i=vec3.subtract(vec3.create(),u,c);vec3.normalize(i,i);const m=r[0],g=vec3.cross(vec3.create(),m,i);let p=[];for(let e=0;e=0&&vec3.distance(r,v)=0){f.push(r),S.push(i);const e=[d,i,r,v],t=poly3.create(e);q.push(t)}v=r,d=i}}S.reverse(),q.push(poly3.create(f)),q.push(poly3.create(S));const y=geom3.create(q);s=unionGeom3Sub(s,y)}),r.forEach(e=>{const t=e[0],r=e[1],c=r[0];let u=null,i=0;for(let e=1;e.05&&n>i&&(i=n,u=t)}u||(u=vec3.orthogonal(a,c));const m=vec3.cross(a,c,u);vec3.normalize(m,m);const g=vec3.cross(l,m,c),p=sphere({center:[t[0],t[1],t[2]],radius:o,segments:n,axes:[c,m,g]});s=unionGeom3Sub(s,p)}),retessellate(s)};module.exports=expandShell; -},{"../../geometries/geom3":41,"../../geometries/poly3":79,"../../maths/constants":94,"../../maths/mat4":143,"../../maths/vec3":222,"../../primitives/sphere":385,"../../utils/fnNumberSort":398,"../booleans/unionGeom3Sub":288,"../modifiers/retessellate":355,"./extrudePolygon":294}],294:[function(require,module,exports){ +},{"../../geometries/geom3":41,"../../geometries/poly3":79,"../../maths/constants":94,"../../maths/mat4":143,"../../maths/vec3":222,"../../primitives/sphere":386,"../../utils/fnNumberSort":399,"../booleans/unionGeom3Sub":288,"../modifiers/retessellate":356,"./extrudePolygon":294}],294:[function(require,module,exports){ const mat4=require("../../maths/mat4"),vec3=require("../../maths/vec3"),geom3=require("../../geometries/geom3"),poly3=require("../../geometries/poly3"),extrudePolygon=(e,r)=>{vec3.dot(poly3.plane(r),e)>0&&(r=poly3.invert(r));const t=[r],o=poly3.transform(mat4.fromTranslation(mat4.create(),e),r),s=r.vertices.length;for(let e=0;e{if(0===(t=flatten(t)).length)throw new Error("wrong number of arguments");const o=t.map(t=>path2.isA(t)?offsetPath2(e,t):geom2.isA(t)?offsetGeom2(e,t):t);return 1===o.length?o[0]:o};module.exports=offset; -},{"../../geometries/geom2":25,"../../geometries/path2":62,"../../utils/flatten":397,"./offsetGeom2":298,"./offsetPath2":299}],297:[function(require,module,exports){ +},{"../../geometries/geom2":25,"../../geometries/path2":62,"../../utils/flatten":398,"./offsetGeom2":298,"./offsetPath2":299}],297:[function(require,module,exports){ const{EPS:EPS,TAU:TAU}=require("../../maths/constants"),intersect=require("../../maths/utils/intersect"),line2=require("../../maths/line2"),vec2=require("../../maths/vec2"),area=require("../../maths/utils/area"),offsetFromPoints=(e,t)=>{let{delta:s,corners:c,closed:n,segments:a}=Object.assign({},{delta:1,corners:"edge",closed:!1,segments:16},e);if(Math.abs(s)0&&s>=0||r<0&&s<0;s=Math.abs(s);let i=null,l=[];const u=[],v=vec2.create(),f=t.length;for(let e=0;ee.set(t,s));const t=line2.create(),s=line2.create();u.forEach(c=>{line2.fromPoints(t,c.s0[0],c.s0[1]),line2.fromPoints(s,c.s1[0],c.s1[1]);const n=line2.intersectPointOfLines(t,s);if(Number.isFinite(n[0])&&Number.isFinite(n[1])){const t=c.s0[1],s=e.get(t);l[s]=n,l[(s+1)%l.length]=void 0}else{const t=c.s1[0],s=e.get(t);l[s]=void 0}}),l=l.filter(e=>void 0!==e)}if("round"===c){let e=Math.floor(a/4);const t=vec2.create();u.forEach(c=>{let n=vec2.angle(vec2.subtract(t,c.s1[0],c.c));if(n-=vec2.angle(vec2.subtract(t,c.s0[1],c.c)),o&&n<0&&(n+=Math.PI)<0&&(n+=Math.PI),!o&&n>0&&(n-=Math.PI)>0&&(n-=Math.PI),0!==n){const r=n/(e=Math.floor(a*(Math.abs(n)/TAU))),o=vec2.angle(vec2.subtract(t,c.s0[1],c.c)),i=[];for(let t=1;t0){const e=c.s0[1];let t=l.findIndex(t=>vec2.equals(e,t));t=(t+1)%l.length,l.splice(t,0,...i)}}else{const e=c.s1[0],t=l.findIndex(t=>vec2.equals(e,t));l.splice(t,1)}})}return l};module.exports=offsetFromPoints; },{"../../maths/constants":94,"../../maths/line2":105,"../../maths/utils/area":168,"../../maths/utils/intersect":171,"../../maths/vec2":191}],298:[function(require,module,exports){ @@ -928,7 +928,7 @@ const{TAU:TAU}=require("../../maths/constants"),slice=require("./slice"),mat4=re },{"../../geometries/geom2":25,"../../maths/constants":94,"../../maths/mat4":143,"./extrudeFromSlices":308,"./slice":326}],310:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom2=require("../../geometries/geom2"),path2=require("../../geometries/path2"),extrudeLinearGeom2=require("./extrudeLinearGeom2"),extrudeLinearPath2=require("./extrudeLinearPath2"),extrudeLinear=(e,...t)=>{const{height:r,twistAngle:i,twistSteps:n,repair:a}=Object.assign({},{height:1,twistAngle:0,twistSteps:1,repair:!0},e);if(0===(t=flatten(t)).length)throw new Error("wrong number of arguments");e={offset:[0,0,r],twistAngle:i,twistSteps:n,repair:a};const s=t.map(t=>path2.isA(t)?extrudeLinearPath2(e,t):geom2.isA(t)?extrudeLinearGeom2(e,t):t);return 1===s.length?s[0]:s};module.exports=extrudeLinear; -},{"../../geometries/geom2":25,"../../geometries/path2":62,"../../utils/flatten":397,"./extrudeLinearGeom2":311,"./extrudeLinearPath2":312}],311:[function(require,module,exports){ +},{"../../geometries/geom2":25,"../../geometries/path2":62,"../../utils/flatten":398,"./extrudeLinearGeom2":311,"./extrudeLinearPath2":312}],311:[function(require,module,exports){ const mat4=require("../../maths/mat4"),vec3=require("../../maths/vec3"),geom2=require("../../geometries/geom2"),slice=require("./slice"),extrudeFromSlices=require("./extrudeFromSlices"),extrudeGeom2=(e,t)=>{let{offset:r,twistAngle:s,twistSteps:o,repair:i}=Object.assign({},{offset:[0,0,1],twistAngle:0,twistSteps:12,repair:!0},e);if(o<1)throw new Error("twistSteps must be 1 or more");0===s&&(o=1);const c=vec3.clone(r),m=geom2.toSides(t);if(0===m.length)throw new Error("the given geometry cannot be empty");const a=slice.fromSides(m);c[2]<0&&slice.reverse(a,a);const n=mat4.create();return extrudeFromSlices(e={numberOfSlices:o+1,capStart:!0,capEnd:!0,repair:i,callback:(e,t,r)=>{const i=t/o*s,m=vec3.scale(vec3.create(),c,t/o);return mat4.multiply(n,mat4.fromZRotation(n,i),mat4.fromTranslation(mat4.create(),m)),slice.transform(n,r)}},a)};module.exports=extrudeGeom2; },{"../../geometries/geom2":25,"../../maths/mat4":143,"../../maths/vec3":222,"./extrudeFromSlices":308,"./slice":326}],312:[function(require,module,exports){ @@ -937,7 +937,7 @@ const geom2=require("../../geometries/geom2"),path2=require("../../geometries/pa },{"../../geometries/geom2":25,"../../geometries/path2":62,"./extrudeLinearGeom2":311}],313:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom2=require("../../geometries/geom2"),path2=require("../../geometries/path2"),extrudeRectangularPath2=require("./extrudeRectangularPath2"),extrudeRectangularGeom2=require("./extrudeRectangularGeom2"),extrudeRectangular=(e,...t)=>{const{size:r,height:a}=Object.assign({},{size:1,height:1},e);if(0===(t=flatten(t)).length)throw new Error("wrong number of arguments");if(r<=0)throw new Error("size must be positive");if(a<=0)throw new Error("height must be positive");const u=t.map(t=>path2.isA(t)?extrudeRectangularPath2(e,t):geom2.isA(t)?extrudeRectangularGeom2(e,t):t);return 1===u.length?u[0]:u};module.exports=extrudeRectangular; -},{"../../geometries/geom2":25,"../../geometries/path2":62,"../../utils/flatten":397,"./extrudeRectangularGeom2":314,"./extrudeRectangularPath2":315}],314:[function(require,module,exports){ +},{"../../geometries/geom2":25,"../../geometries/path2":62,"../../utils/flatten":398,"./extrudeRectangularGeom2":314,"./extrudeRectangularPath2":315}],314:[function(require,module,exports){ const{area:area}=require("../../maths/utils"),geom2=require("../../geometries/geom2"),path2=require("../../geometries/path2"),expand=require("../expansions/expand"),extrudeLinearGeom2=require("./extrudeLinearGeom2"),extrudeRectangularGeom2=(e,r)=>{const{size:t,height:o}=Object.assign({},{size:1,height:1},e);e.delta=t,e.offset=[0,0,o];const a=geom2.toOutlines(r);if(0===a.length)throw new Error("the given geometry cannot be empty");const n=a.map(r=>(area(r)<0&&r.reverse(),expand(e,path2.fromPoints({closed:!0},r)))).reduce((e,r)=>e.concat(geom2.toSides(r)),[]),i=geom2.create(n);return extrudeLinearGeom2(e,i)};module.exports=extrudeRectangularGeom2; },{"../../geometries/geom2":25,"../../geometries/path2":62,"../../maths/utils":169,"../expansions/expand":289,"./extrudeLinearGeom2":311}],315:[function(require,module,exports){ @@ -946,7 +946,7 @@ const path2=require("../../geometries/path2"),expand=require("../expansions/expa },{"../../geometries/path2":62,"../expansions/expand":289,"./extrudeLinearGeom2":311}],316:[function(require,module,exports){ const{TAU:TAU}=require("../../maths/constants"),mat4=require("../../maths/mat4"),{mirrorX:mirrorX}=require("../transforms/mirror"),geom2=require("../../geometries/geom2"),slice=require("./slice"),extrudeFromSlices=require("./extrudeFromSlices"),extrudeRotate=(e,t)=>{const r={segments:12,startAngle:0,angle:TAU,overflow:"cap"};let{segments:a,startAngle:o,angle:s,overflow:m}=Object.assign({},r,e);if(a<3)throw new Error("segments must be greater then 3");o=Math.abs(o)>TAU?o%TAU:o,s=Math.abs(s)>TAU?s%TAU:s;let n=o+s;if((n=Math.abs(n)>TAU?n%TAU:n)a*e&&a++}let i=geom2.toSides(t);if(0===i.length)throw new Error("the given geometry cannot be empty");const c=i.filter(e=>e[0][0]<0),g=i.filter(e=>e[0][0]>=0);c.length>0&&g.length>0&&"cap"===m&&(c.length>g.length?(i=i.map(e=>{let t=e[0],r=e[1];return[t=[Math.min(t[0],0),t[1]],r=[Math.min(r[0],0),r[1]]]}),t=geom2.create(i),t=mirrorX(t)):g.length>=c.length&&(i=i.map(e=>{let t=e[0],r=e[1];return[t=[Math.max(t[0],0),t[1]],r=[Math.max(r[0],0),r[1]]]}),t=geom2.create(i)));const h=l/a,u=Math.abs(l){let s=h*t+o;return l===TAU&&t===a&&(s=o),mat4.multiply(f,mat4.fromZRotation(f,s),mat4.fromXRotation(mat4.create(),TAU/4)),slice.transform(f,r)}},A)};module.exports=extrudeRotate; -},{"../../geometries/geom2":25,"../../maths/constants":94,"../../maths/mat4":143,"../transforms/mirror":362,"./extrudeFromSlices":308,"./slice":326}],317:[function(require,module,exports){ +},{"../../geometries/geom2":25,"../../maths/constants":94,"../../maths/mat4":143,"../transforms/mirror":363,"./extrudeFromSlices":308,"./slice":326}],317:[function(require,module,exports){ const{EPS:EPS}=require("../../maths/constants"),vec3=require("../../maths/vec3"),poly3=require("../../geometries/poly3"),slice=require("./slice"),gcd=(e,t)=>e===t?e:ee*t/gcd(e,t),repartitionEdges=(e,t)=>{const r=e/t.length;if(1===r)return t;const s=vec3.fromValues(r,r,r),c=[];return t.forEach(e=>{const t=vec3.subtract(vec3.create(),e[1],e[0]);vec3.divide(t,t,s);let l=e[0];for(let e=1;e<=r;++e){const e=vec3.add(vec3.create(),l,t);c.push([l,e]),l=e}}),c},EPSAREA=EPS*EPS/2*Math.sin(Math.PI/3),extrudeWalls=(e,t)=>{let r=slice.toEdges(e),s=slice.toEdges(t);if(r.length!==s.length){const e=lcm(r.length,s.length);e!==r.length&&(r=repartitionEdges(e,r)),e!==s.length&&(s=repartitionEdges(e,s))}const c=[];return r.forEach((e,t)=>{const r=s[t],l=poly3.create([e[0],e[1],r[1]]),o=poly3.measureArea(l);Number.isFinite(o)&&o>EPSAREA&&c.push(l);const n=poly3.create([e[0],r[1],r[0]]),i=poly3.measureArea(n);Number.isFinite(i)&&i>EPSAREA&&c.push(n)}),c};module.exports=extrudeWalls; },{"../../geometries/poly3":79,"../../maths/constants":94,"../../maths/vec3":222,"./slice":326}],318:[function(require,module,exports){ @@ -955,7 +955,7 @@ module.exports={extrudeFromSlices:require("./extrudeFromSlices"),extrudeLinear:r },{"./extrudeFromSlices":308,"./extrudeHelical":309,"./extrudeLinear":310,"./extrudeRectangular":313,"./extrudeRotate":316,"./project":319,"./slice":326}],319:[function(require,module,exports){ const flatten=require("../../utils/flatten"),aboutEqualNormals=require("../../maths/utils/aboutEqualNormals"),plane=require("../../maths/plane"),mat4=require("../../maths/mat4"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),poly3=require("../../geometries/poly3"),measureEpsilon=require("../../measurements/measureEpsilon"),unionGeom2=require("../booleans/unionGeom2"),projectGeom3=(e,o)=>{const r=plane.fromNormalAndPoint(plane.create(),e.axis,e.origin);if(Number.isNaN(r[0])||Number.isNaN(r[1])||Number.isNaN(r[2])||Number.isNaN(r[3]))throw new Error("project: invalid axis or origin");const t=measureEpsilon(o),a=t*t*Math.sqrt(3)/4;if(0===t)return geom2.create();const n=geom3.toPolygons(o);let s=[];for(let e=0;eplane.projectionOfPoint(r,e)),t=poly3.create(o),i=poly3.plane(t);aboutEqualNormals(r,i)&&(poly3.measureArea(t)poly3.transform(e,o))}const i=(s=s.sort((e,o)=>poly3.measureArea(o)-poly3.measureArea(e))).map(e=>geom2.fromPoints(e.vertices));return unionGeom2(i)},project=(e,...o)=>{const{axis:r,origin:t}=Object.assign({},{axis:[0,0,1],origin:[0,0,0]},e);if(0===(o=flatten(o)).length)throw new Error("wrong number of arguments");e={axis:r,origin:t};const a=o.map(o=>geom3.isA(o)?projectGeom3(e,o):o);return 1===a.length?a[0]:a};module.exports=project; -},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../geometries/poly3":79,"../../maths/mat4":143,"../../maths/plane":163,"../../maths/utils/aboutEqualNormals":167,"../../measurements/measureEpsilon":263,"../../utils/flatten":397,"../booleans/unionGeom2":286}],320:[function(require,module,exports){ +},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../geometries/poly3":79,"../../maths/mat4":143,"../../maths/plane":163,"../../maths/utils/aboutEqualNormals":167,"../../measurements/measureEpsilon":263,"../../utils/flatten":398,"../booleans/unionGeom2":286}],320:[function(require,module,exports){ const plane=require("../../../maths/plane"),vec3=require("../../../maths/vec3"),calculatePlane=e=>{const c=e.edges;if(c.length<3)throw new Error("slices must have 3 or more edges to calculate a plane");const a=c.reduce((e,c)=>vec3.add(vec3.create(),e,c[0]),vec3.create());let t;vec3.scale(a,a,1/c.length);let l=0;c.forEach(e=>{if(!vec3.equals(e[0],e[1])){const c=vec3.squaredDistance(a,e[0]);c>l&&(t=e,l=c)}});const r=c.find(e=>vec3.equals(e[1],t[0]));return plane.fromPoints(plane.create(),r[0],t[0],t[1])};module.exports=calculatePlane; },{"../../../maths/plane":163,"../../../maths/vec3":222}],321:[function(require,module,exports){ @@ -1000,211 +1000,214 @@ const vec3=require("../../../maths/vec3"),create=require("./create"),transform=( },{"../../../maths/vec3":222,"./create":322}],334:[function(require,module,exports){ const flatten=require("../../utils/flatten"),areAllShapesTheSameType=require("../../utils/areAllShapesTheSameType"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),hullPath2=require("./hullPath2"),hullGeom2=require("./hullGeom2"),hullGeom3=require("./hullGeom3"),hull=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");if(!areAllShapesTheSameType(e))throw new Error("only hulls of the same type are supported");const l=e[0];return path2.isA(l)?hullPath2(e):geom2.isA(l)?hullGeom2(e):geom3.isA(l)?hullGeom3(e):l};module.exports=hull; -},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../geometries/path2":62,"../../utils/areAllShapesTheSameType":395,"../../utils/flatten":397,"./hullGeom2":336,"./hullGeom3":337,"./hullPath2":338}],335:[function(require,module,exports){ +},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../geometries/path2":62,"../../utils/areAllShapesTheSameType":396,"../../utils/flatten":398,"./hullGeom2":336,"./hullGeom3":337,"./hullPath2":338}],335:[function(require,module,exports){ const flatten=require("../../utils/flatten"),union=require("../booleans/union"),hull=require("./hull"),hullChain=(...n)=>{if((n=flatten(n)).length<2)throw new Error("wrong number of arguments");const e=[];for(let l=1;l{e=flatten(e);const t=toUniquePoints(e),o=hullPoints2(t);return o.length<3?geom2.create():geom2.fromPoints(o)};module.exports=hullGeom2; -},{"../../geometries/geom2":25,"../../utils/flatten":397,"./hullPoints2":339,"./toUniquePoints":349}],337:[function(require,module,exports){ -const flatten=require("../../utils/flatten"),geom3=require("../../geometries/geom3"),poly3=require("../../geometries/poly3"),quickhull=require("./quickhull"),toUniquePoints=require("./toUniquePoints"),hullGeom3=(...e)=>{if(1===(e=flatten(e)).length)return e[0];const t=toUniquePoints(e),o=quickhull(t,{skipTriangulation:!0}).map(e=>{const o=e.map(e=>t[e]);return poly3.create(o)});return geom3.create(o)};module.exports=hullGeom3; +},{"../../geometries/geom2":25,"../../utils/flatten":398,"./hullPoints2":339,"./toUniquePoints":350}],337:[function(require,module,exports){ +const flatten=require("../../utils/flatten"),geom3=require("../../geometries/geom3"),toUniquePoints=require("./toUniquePoints"),hullPoints3=require("./hullPoints3"),hullGeom3=(...e)=>{e=flatten(e);const t=toUniquePoints(e);return 0===t.length?geom3.create():geom3.create(hullPoints3(t))};module.exports=hullGeom3; -},{"../../geometries/geom3":41,"../../geometries/poly3":79,"../../utils/flatten":397,"./quickhull":347,"./toUniquePoints":349}],338:[function(require,module,exports){ +},{"../../geometries/geom3":41,"../../utils/flatten":398,"./hullPoints3":340,"./toUniquePoints":350}],338:[function(require,module,exports){ const flatten=require("../../utils/flatten"),path2=require("../../geometries/path2"),hullPoints2=require("./hullPoints2"),toUniquePoints=require("./toUniquePoints"),hullPath2=(...t)=>{t=flatten(t);const e=toUniquePoints(t),o=hullPoints2(e);return path2.fromPoints({closed:!0},o)};module.exports=hullPath2; -},{"../../geometries/path2":62,"../../utils/flatten":397,"./hullPoints2":339,"./toUniquePoints":349}],339:[function(require,module,exports){ +},{"../../geometries/path2":62,"../../utils/flatten":398,"./hullPoints2":339,"./toUniquePoints":350}],339:[function(require,module,exports){ const vec2=require("../../maths/vec2"),hullPoints2=e=>{let t=vec2.fromValues(1/0,1/0);e.forEach(e=>{(e[1]{const o=fakeAtan2(e[1]-t[1],e[0]-t[0]),s=vec2.squaredDistance(e,t);n.push({point:e,angle:o,distSq:s})}),n.sort((e,t)=>e.angle!==t.angle?e.angle-t.angle:e.distSq-t.distSq);const o=[];return n.forEach(e=>{let t=o.length;for(;t>1&&ccw(o[t-2],o[t-1],e.point)<=Number.EPSILON;)o.pop(),t=o.length;o.push(e.point)}),o},ccw=(e,t,n)=>(t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0]),fakeAtan2=(e,t)=>0===e&&0===t?-1/0:-t/e;module.exports=hullPoints2; },{"../../maths/vec2":191}],340:[function(require,module,exports){ -module.exports={hull:require("./hull"),hullChain:require("./hullChain")}; +const poly3=require("../../geometries/poly3"),quickhull=require("./quickhull"),hullPoints3=l=>{return quickhull(l,{skipTriangulation:!0}).map(u=>{const e=u.map(u=>l[u]);return poly3.create(e)})};module.exports=hullPoints3; -},{"./hull":334,"./hullChain":335}],341:[function(require,module,exports){ +},{"../../geometries/poly3":79,"./quickhull":348}],341:[function(require,module,exports){ +module.exports={hull:require("./hull"),hullChain:require("./hullChain"),hullPoints2:require("./hullPoints2"),hullPoints3:require("./hullPoints3")}; + +},{"./hull":334,"./hullChain":335,"./hullPoints2":339,"./hullPoints3":340}],342:[function(require,module,exports){ const add=require("../../../maths/vec3/add"),copy=require("../../../maths/vec3/copy"),cross=require("../../../maths/vec3/cross"),dot=require("../../../maths/vec3/dot"),length=require("../../../maths/vec3/length"),normalize=require("../../../maths/vec3/normalize"),scale=require("../../../maths/vec3/scale"),subtract=require("../../../maths/vec3/subtract"),HalfEdge=require("./HalfEdge"),VISIBLE=0,NON_CONVEX=1,DELETED=2;class Face{constructor(){this.normal=[],this.centroid=[],this.offset=0,this.outside=null,this.mark=VISIBLE,this.edge=null,this.nVertices=0}getEdge(e){if("number"!=typeof e)throw Error("requires a number");let t=this.edge;for(;e>0;)t=t.next,e-=1;for(;e<0;)t=t.prev,e+=1;return t}computeNormal(){const e=this.edge,t=e.next;let r=t.next;const s=subtract([],t.head().point,e.head().point),o=[],i=[];for(this.nVertices=2,this.normal=[0,0,0];r!==e;)copy(i,s),subtract(s,r.head().point,e.head().point),add(this.normal,this.normal,cross(o,i,s)),r=r.next,this.nVertices+=1;this.area=length(this.normal),this.normal=scale(this.normal,this.normal,1/this.area)}computeNormalMinArea(e){if(this.computeNormal(),this.areat&&(e=r,t=s),r=r.next}while(r!==this.edge);const s=e.tail().point,o=e.head().point,i=subtract([],o,s),n=Math.sqrt(t);scale(i,i,1/n);const a=dot(this.normal,i);scale(i,i,-a),add(this.normal,this.normal,i),normalize(this.normal,this.normal)}}computeCentroid(){this.centroid=[0,0,0];let e=this.edge;do{add(this.centroid,this.centroid,e.head().point),e=e.next}while(e!==this.edge);scale(this.centroid,this.centroid,1/this.nVertices)}computeNormalAndCentroid(e){void 0!==e?this.computeNormalMinArea(e):this.computeNormal(),this.computeCentroid(),this.offset=dot(this.normal,this.centroid)}distanceToPlane(e){return dot(this.normal,e)-this.offset}connectHalfEdges(e,t){let r;if(e.opposite.face===t.opposite.face){const s=t.opposite.face;let o;e===this.edge&&(this.edge=t),3===s.nVertices?(o=t.opposite.prev.opposite,s.mark=DELETED,r=s):(o=t.opposite.next,s.edge===o.prev&&(s.edge=o),o.prev=o.prev.prev,o.prev.next=o),t.prev=e.prev,t.prev.next=t,t.setOpposite(o),s.computeNormalAndCentroid()}else e.next=t,t.prev=e;return r}mergeAdjacentFaces(e,t){const r=e.opposite,s=r.face;t.push(s),s.mark=DELETED;let o,i,n=e.prev,a=e.next,c=r.prev,h=r.next;for(;n.opposite.face===s;)n=n.prev,h=h.next;for(;a.opposite.face===s;)a=a.next,c=c.prev;for(o=h;o!==c.next;o=o.next)o.face=this;return this.edge=a,(i=this.connectHalfEdges(c,a))&&t.push(i),(i=this.connectHalfEdges(n,h))&&t.push(i),this.computeNormalAndCentroid(),t}collectIndices(){const e=[];let t=this.edge;do{e.push(t.head().index),t=t.next}while(t!==this.edge);return e}static createTriangle(e,t,r,s=0){const o=new Face,i=new HalfEdge(e,o),n=new HalfEdge(t,o),a=new HalfEdge(r,o);return i.next=a.prev=n,n.next=i.prev=a,a.next=n.prev=i,o.edge=i,o.computeNormalAndCentroid(s),o}}module.exports={VISIBLE:VISIBLE,NON_CONVEX:1,DELETED:DELETED,Face:Face}; -},{"../../../maths/vec3/add":209,"../../../maths/vec3/copy":212,"../../../maths/vec3/cross":214,"../../../maths/vec3/dot":217,"../../../maths/vec3/length":223,"../../../maths/vec3/normalize":229,"../../../maths/vec3/scale":234,"../../../maths/vec3/subtract":238,"./HalfEdge":342}],342:[function(require,module,exports){ +},{"../../../maths/vec3/add":209,"../../../maths/vec3/copy":212,"../../../maths/vec3/cross":214,"../../../maths/vec3/dot":217,"../../../maths/vec3/length":223,"../../../maths/vec3/normalize":229,"../../../maths/vec3/scale":234,"../../../maths/vec3/subtract":238,"./HalfEdge":343}],343:[function(require,module,exports){ const distance=require("../../../maths/vec3/distance"),squaredDistance=require("../../../maths/vec3/squaredDistance");class HalfEdge{constructor(t,e){this.vertex=t,this.face=e,this.next=null,this.prev=null,this.opposite=null}head(){return this.vertex}tail(){return this.prev?this.prev.vertex:null}length(){return this.tail()?distance(this.tail().point,this.head().point):-1}lengthSquared(){return this.tail()?squaredDistance(this.tail().point,this.head().point):-1}setOpposite(t){this.opposite=t,t.opposite=this}}module.exports=HalfEdge; -},{"../../../maths/vec3/distance":215,"../../../maths/vec3/squaredDistance":236}],343:[function(require,module,exports){ +},{"../../../maths/vec3/distance":215,"../../../maths/vec3/squaredDistance":236}],344:[function(require,module,exports){ const dot=require("../../../maths/vec3/dot"),pointLineDistance=require("./point-line-distance"),getPlaneNormal=require("./get-plane-normal"),VertexList=require("./VertexList"),Vertex=require("./Vertex"),{Face:Face,VISIBLE:VISIBLE,NON_CONVEX:NON_CONVEX,DELETED:DELETED}=require("./Face"),MERGE_NON_CONVEX_WRT_LARGER_FACE=1,MERGE_NON_CONVEX=2;class QuickHull{constructor(e){if(!Array.isArray(e))throw TypeError("input is not a valid array");if(e.length<4)throw Error("cannot build a simplex out of <4 points");this.tolerance=-1,this.nFaces=0,this.nPoints=e.length,this.faces=[],this.newFaces=[],this.claimed=new VertexList,this.unclaimed=new VertexList,this.vertices=[];for(let t=0;tthis.tolerance?this.addVertexToFace(s,t):this.unclaimed.add(s)}}else this.unclaimed.addAll(i)}resolveUnclaimedPoints(e){let t=this.unclaimed.first();for(let i=t;i;i=t){t=i.next;let s,o=this.tolerance;for(let t=0;to&&(o=e,s=a),o>1e3*this.tolerance)break}}s&&this.addVertexToFace(i,s)}}computeExtremes(){const e=[],t=[],i=[],s=[];let o,a;for(o=0;o<3;o+=1)i[o]=s[o]=this.vertices[0];for(o=0;o<3;o+=1)e[o]=t[o]=this.vertices[0].point[o];for(o=1;ot[a]&&(t[a]=n[a],s[a]=c)}return this.tolerance=3*Number.EPSILON*(Math.max(Math.abs(e[0]),Math.abs(t[0]))+Math.max(Math.abs(e[1]),Math.abs(t[1]))+Math.max(Math.abs(e[2]),Math.abs(t[2]))),[i,s]}createInitialSimplex(){const e=this.vertices,[t,i]=this.computeExtremes();let s,o,a,c,n=0,r=0;for(a=0;a<3;a+=1){const e=i[a].point[a]-t[a].point[a];e>n&&(n=e,r=a)}const l=t[r],h=i[r];for(n=0,a=0;an&&(n=t,s=e)}}const d=getPlaneNormal([],l.point,h.point,s.point),p=dot(l.point,d);for(n=-1,a=0;an&&(n=t,o=e)}}const f=[];if(dot(o.point,d)-p<0)for(f.push(Face.createTriangle(l,h,s),Face.createTriangle(o,h,l),Face.createTriangle(o,s,h),Face.createTriangle(o,l,s)),a=0;a<3;a+=1){const e=(a+1)%3;f[a+1].getEdge(2).setOpposite(f[0].getEdge(e)),f[a+1].getEdge(1).setOpposite(f[e+1].getEdge(0))}else for(f.push(Face.createTriangle(l,s,h),Face.createTriangle(o,l,h),Face.createTriangle(o,h,s),Face.createTriangle(o,s,l)),a=0;a<3;a+=1){const e=(a+1)%3;f[a+1].getEdge(2).setOpposite(f[0].getEdge((3-a)%3)),f[a+1].getEdge(0).setOpposite(f[e+1].getEdge(1))}for(a=0;a<4;a+=1)this.faces.push(f[a]);for(a=0;an&&(n=i,e=f[c])}e&&this.addVertexToFace(t,e)}}}reindexFaceAndVertices(){const e=[];for(let t=0;ti&&(i=o,e=t)}return e}}computeHorizon(e,t,i,s){let o;this.deleteFaceVertices(i),i.mark=DELETED,o=t?t.next:t=i.getEdge(0);do{const t=o.opposite,i=t.face;i.mark===VISIBLE&&(i.distanceToPlane(e)>this.tolerance?this.computeHorizon(e,t,i,s):s.push(o)),o=o.next}while(o!==t)}addAdjoiningFace(e,t){const i=Face.createTriangle(e,t.tail(),t.head());return this.faces.push(i),i.getEdge(-1).setOpposite(t.opposite),i.getEdge(0)}addNewFaces(e,t){let i,s;this.newFaces=[];for(let o=0;o=e.nVertices)throw Error("merge recursion limit exceeded");const a=i.opposite.face;let c=!1;if(t===MERGE_NON_CONVEX?(this.oppositeFaceDistance(i)>-this.tolerance||this.oppositeFaceDistance(i.opposite)>-this.tolerance)&&(c=!0):e.area>a.area?this.oppositeFaceDistance(i)>-this.tolerance?c=!0:this.oppositeFaceDistance(i.opposite)>-this.tolerance&&(s=!1):this.oppositeFaceDistance(i.opposite)>-this.tolerance?c=!0:this.oppositeFaceDistance(i)>-this.tolerance&&(s=!1),c){const t=e.mergeAdjacentFaces(i,[]);for(let i=0;i{const a=[0,0,0];return subtract(r,e,s),subtract(a,s,t),cross(r,r,a),normalize(r,r)};module.exports=planeNormal; -},{"../../../maths/vec3/cross":214,"../../../maths/vec3/normalize":229,"../../../maths/vec3/subtract":238}],347:[function(require,module,exports){ +},{"../../../maths/vec3/cross":214,"../../../maths/vec3/normalize":229,"../../../maths/vec3/subtract":238}],348:[function(require,module,exports){ const QuickHull=require("./QuickHull"),runner=(u,l={})=>{const e=new QuickHull(u);return e.build(),e.collectFaces(l.skipTriangulation)};module.exports=runner; -},{"./QuickHull":343}],348:[function(require,module,exports){ +},{"./QuickHull":344}],349:[function(require,module,exports){ const cross=require("../../../maths/vec3/cross"),subtract=require("../../../maths/vec3/subtract"),squaredLength=require("../../../maths/vec3/squaredLength"),distanceSquared=(e,t,r)=>{const s=[],a=[];subtract(s,r,t),subtract(a,e,t);const n=squaredLength(cross([],a,s)),c=squaredLength(s);if(0===c)throw Error("a and b are the same point");return n/c},pointLineDistance=(e,t,r)=>Math.sqrt(distanceSquared(e,t,r));module.exports=pointLineDistance; -},{"../../../maths/vec3/cross":214,"../../../maths/vec3/squaredLength":237,"../../../maths/vec3/subtract":238}],349:[function(require,module,exports){ +},{"../../../maths/vec3/cross":214,"../../../maths/vec3/squaredLength":237,"../../../maths/vec3/subtract":238}],350:[function(require,module,exports){ const geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),toUniquePoints=o=>{const e=new Set,t=[],r=o=>{const r=o.toString();e.has(r)||(t.push(o),e.add(r))};return o.forEach(o=>{geom2.isA(o)?geom2.toPoints(o).forEach(r):geom3.isA(o)?geom3.toPoints(o).forEach(o=>o.forEach(r)):path2.isA(o)&&path2.toPoints(o).forEach(r)}),t};module.exports=toUniquePoints; -},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../geometries/path2":62}],350:[function(require,module,exports){ +},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../geometries/path2":62}],351:[function(require,module,exports){ const flatten=require("../../utils/flatten"),measureEpsilon=require("../../measurements/measureEpsilon"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),snapPolygons=require("./snapPolygons"),mergePolygons=require("./mergePolygons"),insertTjunctions=require("./insertTjunctions"),triangulatePolygons=require("./triangulatePolygons"),generalizePath2=(e,r)=>r,generalizeGeom2=(e,r)=>r,generalizeGeom3=(e,r)=>{const{snap:n,simplify:o,triangulate:t}=Object.assign({},{snap:!1,simplify:!1,triangulate:!1},e),i=measureEpsilon(r);let s=geom3.toPolygons(r);n&&(s=snapPolygons(i,s)),o&&(s=mergePolygons(i,s)),t&&(s=insertTjunctions(s),s=triangulatePolygons(i,s));const g=Object.assign({},r);return g.polygons=s,g},generalize=(e,...r)=>{if(0===(r=flatten(r)).length)throw new Error("wrong number of arguments");const n=r.map(r=>{if(path2.isA(r))return generalizePath2(0,r);if(geom2.isA(r))return generalizeGeom2(0,r);if(geom3.isA(r))return generalizeGeom3(e,r);throw new Error("invalid geometry")});return 1===n.length?n[0]:n};module.exports=generalize; -},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../geometries/path2":62,"../../measurements/measureEpsilon":263,"../../utils/flatten":397,"./insertTjunctions":352,"./mergePolygons":353,"./snapPolygons":357,"./triangulatePolygons":358}],351:[function(require,module,exports){ +},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../geometries/path2":62,"../../measurements/measureEpsilon":263,"../../utils/flatten":398,"./insertTjunctions":353,"./mergePolygons":354,"./snapPolygons":358,"./triangulatePolygons":359}],352:[function(require,module,exports){ module.exports={generalize:require("./generalize"),snap:require("./snap"),retessellate:require("./retessellate")}; -},{"./generalize":350,"./retessellate":355,"./snap":356}],352:[function(require,module,exports){ +},{"./generalize":351,"./retessellate":356,"./snap":357}],353:[function(require,module,exports){ const constants=require("../../maths/constants"),vec3=require("../../maths/vec3"),poly3=require("../../geometries/poly3"),assert=!1,getTag=e=>`${e}`,addSide=(e,t,s,n,r,c)=>{const o=getTag(n),g=getTag(r);const l=`${o}/${g}`,a=`${g}/${o}`;if(e.has(a))return deleteSide(e,t,s,r,n,null),null;const i={vertex0:n,vertex1:r,polygonindex:c};return e.has(l)?e.get(l).push(i):e.set(l,[i]),t.has(o)?t.get(o).push(l):t.set(o,[l]),s.has(g)?s.get(g).push(l):s.set(g,[l]),l},deleteSide=(e,t,s,n,r,c)=>{const o=getTag(n),g=getTag(r),l=`${o}/${g}`;let a=-1;const i=e.get(l);for(let e=0;e{const t=new Map;for(let s=0;s=3){let e=n.vertices[0],c=getTag(e);for(let o=0;o0){const s=new Map,n=new Map,r=new Map;for(const[e,c]of t)r.set(e,!0),c.forEach(t=>{const r=getTag(t.vertex0),c=getTag(t.vertex1);s.has(r)?s.get(r).push(e):s.set(r,[e]),n.has(c)?n.get(c).push(e):n.set(c,[e])});const c=e.slice(0);for(;0!==t.size;){for(const e of t.keys())r.set(e,!0);let e=!1;for(;;){const o=Array.from(r.keys());if(0===o.length)break;const g=o[0];let l=!0;if(t.has(g)){const o=t.get(g);0;const a=o[0];for(let o=0;o<2;o++){const g=0===o?a.vertex0:a.vertex1,i=0===o?a.vertex1:a.vertex0,v=getTag(g),d=getTag(i);let h=[];0===o?n.has(v)&&(h=n.get(v)):s.has(v)&&(h=s.get(v));for(let a=0;a0&&x<1){const g=vec3.scale(vec3.create(),h,x);if(vec3.add(g,g,a),vec3.squaredDistance(g,v){const n=poly3.toPoints(e),t=[];for(let e=0;e{const t=`${n.v1}:${n.v2}`;e.set(t,n)},deleteEdge=(e,n)=>{const t=`${n.v1}:${n.v2}`;e.delete(t)},findOppositeEdge=(e,n)=>{const t=`${n.v2}:${n.v1}`;return e.get(t)},calculateAnglesBetween=(e,n,t)=>{let l=e.prev.v1,r=e.prev.v2,o=n.next.v2;const v=calculateAngle(l,r,o,t);return l=n.prev.v1,r=n.prev.v2,o=e.next.v2,[v,calculateAngle(l,r,o,t)]},v1=vec3.create(),v2=vec3.create(),calculateAngle=(e,n,t,l)=>{const r=vec3.subtract(v1,n,e),o=vec3.subtract(v2,t,n);return vec3.cross(r,r,o),vec3.dot(r,l)},createPolygonAnd=e=>{let n;const t=[];for(;e.next;){const n=e.next;t.push(e.v1),e.v1=null,e.v2=null,e.next=null,e.prev=null,e=n}return t.length>0&&(n=poly3.create(t)),n},mergeCoplanarPolygons=e=>{if(e.length<2)return e;const n=e[0].plane,t=e.slice(),l=new Map;for(;t.length>0;){const e=t.shift(),r=createEdges(e);for(let e=0;e=0&&e[1]>=0){const n=o.next,r=t.next;t.prev.next=o.next,t.next.prev=o.prev,o.prev.next=t.next,o.next.prev=t.prev,t.v1=null,t.v2=null,t.next=null,t.prev=null,deleteEdge(l,o),o.v1=null,o.v2=null,o.next=null,o.prev=null;const v=(e,n,t)=>{const l={v1:t.v1,v2:n.v2,next:n.next,prev:t.prev};t.prev.next=l,n.next.prev=l,deleteEdge(e,n),n.v1=null,n.v2=null,n.next=null,n.prev=null,deleteEdge(e,t),t.v1=null,t.v2=null,t.next=null,t.prev=null};0===e[0]&&v(l,n,n.prev),0===e[1]&&v(l,r,r.prev)}}else t.next&&insertEdge(l,t)}}const r=[];return l.forEach(e=>{const n=createPolygonAnd(e);n&&r.push(n)}),l.clear(),r},coplanar=(e,n)=>Math.abs(e[3]-n[3])<1.5e-7&&aboutEqualNormals(e,n),mergePolygons=(e,n)=>{const t=[];n.forEach(e=>{const n=t.find(n=>coplanar(n[0],poly3.plane(e)));if(n){n[1].push(e)}else t.push([poly3.plane(e),[e]])});let l=[];return t.forEach(e=>{const n=e[1],t=mergeCoplanarPolygons(n);l=l.concat(t)}),l};module.exports=mergePolygons; -},{"../../geometries/poly3":79,"../../maths/utils/aboutEqualNormals":167,"../../maths/vec3":222}],354:[function(require,module,exports){ +},{"../../geometries/poly3":79,"../../maths/utils/aboutEqualNormals":167,"../../maths/vec3":222}],355:[function(require,module,exports){ const{EPS:EPS}=require("../../maths/constants"),line2=require("../../maths/line2"),vec2=require("../../maths/vec2"),OrthoNormalBasis=require("../../maths/OrthoNormalBasis"),interpolateBetween2DPointsForY=require("../../maths/utils/interpolateBetween2DPointsForY"),{insertSorted:insertSorted,fnNumberSort:fnNumberSort}=require("../../utils"),poly3=require("../../geometries/poly3"),reTesselateCoplanarPolygons=t=>{if(t.length<2)return t;const e=[],o=t.length,n=poly3.plane(t[0]),l=new OrthoNormalBasis(n),i=[],r=[],s=new Map,f=new Map,p=new Map,h=10/EPS;for(let e=0;e0){let t,i;for(let r=0;ri)&&(i=u);let m=f.get(u);m||(m={},f.set(u,m)),m[e]=!0}if(t>=i)n=[],g=0,c=-1;else{let o=s.get(t);o||(o=[],s.set(t,o)),o.push(e)}}n.reverse(),c=g-c-1,i.push(n),r.push(c)}const g=[];f.forEach((t,e)=>g.push(e)),g.sort(fnNumberSort);let c=[],a=[];for(let t=0;t=l&&(t=0),n[t][1]!==p)break;r=t}let f=s-1;if(f<0&&(f=l-1),n[f][1]===p&&(s=f),r!==e.leftvertexindex&&r===s)c.splice(t,1),--t;else{e.leftvertexindex=r,e.rightvertexindex=s,e.topleft=n[r],e.topright=n[s];let t=r+1;t>=l&&(t=0),e.bottomleft=n[t];let o=s-1;o<0&&(o=l-1),e.bottomright=n[o]}}}let u;if(t>=g.length-1)c=[],u=null;else{const e=.5*(p+(u=Number(g[t+1]))),o=s.get(p);for(const t in o){const n=o[t],l=i[n],s=l.length,f=r[n];let h=f;for(;;){let t=h+1;if(t>=s&&(t=0),l[t][1]!==p)break;if(t===f)break;h=t}let g=f;for(;;){let t=g-1;if(t<0&&(t=s-1),l[t][1]!==p)break;if(t===h)break;g=t}let a=h+1;a>=s&&(a=0);let u=g-1;u<0&&(u=s-1);const m={polygonindex:n,leftvertexindex:h,rightvertexindex:g,topleft:l[h],topright:l[g],bottomleft:l[a],bottomright:l[u]};insertSorted(c,m,(t,o)=>{const n=interpolateBetween2DPointsForY(t.topleft,t.bottomleft,e),l=interpolateBetween2DPointsForY(o.topleft,o.bottomleft,e);return n>l?1:n0){const t=o[o.length-1],e=vec2.distance(f.topleft,t.topright),n=vec2.distance(f.bottomleft,t.bottomright);e0){const t=new Set,i=new Set;for(let e=0;e=0;(g||s>=0)&&a&&(n.outpolygon=o.outpolygon,n.leftlinecontinues=g,n.rightlinecontinues=c,t.add(e));break}}}for(let o=0;oEPS&&t.outpolygon.leftpoints.push(t.bottomleft),t.outpolygon.leftpoints.reverse();const i=t.outpolygon.rightpoints.concat(t.outpolygon.leftpoints).map(t=>l.to3D(t)),r=poly3.fromPointsAndPlane(i,n);r.vertices.length&&e.push(r)}}for(let t=0;tEPS&&e.outpolygon.rightpoints.push(e.topright))}a=o}return e};module.exports=reTesselateCoplanarPolygons; -},{"../../geometries/poly3":79,"../../maths/OrthoNormalBasis":93,"../../maths/constants":94,"../../maths/line2":105,"../../maths/utils/interpolateBetween2DPointsForY":170,"../../maths/vec2":191,"../../utils":399}],355:[function(require,module,exports){ +},{"../../geometries/poly3":79,"../../maths/OrthoNormalBasis":93,"../../maths/constants":94,"../../maths/line2":105,"../../maths/utils/interpolateBetween2DPointsForY":170,"../../maths/vec2":191,"../../utils":400}],356:[function(require,module,exports){ const geom3=require("../../geometries/geom3"),poly3=require("../../geometries/poly3"),{NEPS:NEPS}=require("../../maths/constants"),reTesselateCoplanarPolygons=require("./reTesselateCoplanarPolygons"),retessellate=e=>{if(e.isRetesselated)return e;const s=geom3.toPolygons(e).map((e,s)=>({vertices:e.vertices,plane:poly3.plane(e),index:s})),o=classifyPolygons(s),l=[];o.forEach(e=>{if(Array.isArray(e)){const s=reTesselateCoplanarPolygons(e);l.push(...s)}else l.push(e)});const n=geom3.create(l);return n.isRetesselated=!0,n},classifyPolygons=e=>{let s=[e];const o=[];for(let e=3;e>=0;e--){const l=[],n=3===e?1.5e-8:NEPS;s.forEach(s=>{s.sort(byPlaneComponent(e,n));let t=0;for(let r=1;rn&&(r-t==1?o.push(s[t]):l.push(s.slice(t,r)),t=r);s.length-t==1?o.push(s[t]):l.push(s.slice(t))}),s=l}const l=[];return s.forEach(e=>{e[0]&&(l[e[0].index]=e)}),o.forEach(e=>{l[e.index]=e}),l},byPlaneComponent=(e,s)=>(o,l)=>o.plane[e]-l.plane[e]>s?1:l.plane[e]-o.plane[e]>s?-1:0;module.exports=retessellate; -},{"../../geometries/geom3":41,"../../geometries/poly3":79,"../../maths/constants":94,"./reTesselateCoplanarPolygons":354}],356:[function(require,module,exports){ +},{"../../geometries/geom3":41,"../../geometries/poly3":79,"../../maths/constants":94,"./reTesselateCoplanarPolygons":355}],357:[function(require,module,exports){ const flatten=require("../../utils/flatten"),vec2=require("../../maths/vec2"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),measureEpsilon=require("../../measurements/measureEpsilon"),snapPolygons=require("./snapPolygons"),snapPath2=e=>{const s=measureEpsilon(e),r=path2.toPoints(e).map(e=>vec2.snap(vec2.create(),e,s));return path2.create(r)},snapGeom2=e=>{const s=measureEpsilon(e);let r=geom2.toSides(e).map(e=>[vec2.snap(vec2.create(),e[0],s),vec2.snap(vec2.create(),e[1],s)]);return r=r.filter(e=>!vec2.equals(e[0],e[1])),geom2.create(r)},snapGeom3=e=>{const s=measureEpsilon(e),r=geom3.toPolygons(e),o=snapPolygons(s,r);return geom3.create(o)},snap=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");const s=e.map(e=>path2.isA(e)?snapPath2(e):geom2.isA(e)?snapGeom2(e):geom3.isA(e)?snapGeom3(e):e);return 1===s.length?s[0]:s};module.exports=snap; -},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../geometries/path2":62,"../../maths/vec2":191,"../../measurements/measureEpsilon":263,"../../utils/flatten":397,"./snapPolygons":357}],357:[function(require,module,exports){ +},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../geometries/path2":62,"../../maths/vec2":191,"../../measurements/measureEpsilon":263,"../../utils/flatten":398,"./snapPolygons":358}],358:[function(require,module,exports){ const vec3=require("../../maths/vec3"),poly3=require("../../geometries/poly3"),isValidPoly3=(e,o)=>{const r=Math.abs(poly3.measureArea(o));return Number.isFinite(r)&&r>e},snapPolygons=(e,o)=>{let r=o.map(o=>{const r=o.vertices.map(o=>vec3.snap(vec3.create(),o,e)),t=[];for(let e=0;eisValidPoly3(t,e))};module.exports=snapPolygons; -},{"../../geometries/poly3":79,"../../maths/vec3":222}],358:[function(require,module,exports){ +},{"../../geometries/poly3":79,"../../maths/vec3":222}],359:[function(require,module,exports){ const vec3=require("../../maths/vec3"),poly3=require("../../geometries/poly3"),triangulatePolygon=(e,o,r)=>{const t=o.vertices.length;if(t>3){if(t>4){const c=[0,0,0];o.vertices.forEach(e=>vec3.add(c,c,e)),vec3.snap(c,vec3.divide(c,c,[t,t,t]),e);for(let e=0;e{const r=[];return o.forEach(o=>{triangulatePolygon(e,o,r)}),r};module.exports=triangulatePolygons; -},{"../../geometries/poly3":79,"../../maths/vec3":222}],359:[function(require,module,exports){ +},{"../../geometries/poly3":79,"../../maths/vec3":222}],360:[function(require,module,exports){ const flatten=require("../../utils/flatten"),padArrayToLength=require("../../utils/padArrayToLength"),measureAggregateBoundingBox=require("../../measurements/measureAggregateBoundingBox"),{translate:translate}=require("./translate"),validateOptions=e=>{if(!Array.isArray(e.modes)||e.modes.length>3)throw new Error("align(): modes must be an array of length <= 3");if(e.modes=padArrayToLength(e.modes,"none",3),3!==e.modes.filter(e=>["center","max","min","none"].includes(e)).length)throw new Error('align(): all modes must be one of "center", "max" or "min"');if(!Array.isArray(e.relativeTo)||e.relativeTo.length>3)throw new Error("align(): relativeTo must be an array of length <= 3");if(e.relativeTo=padArrayToLength(e.relativeTo,0,3),3!==e.relativeTo.filter(e=>Number.isFinite(e)||null==e).length)throw new Error("align(): all relativeTo values must be a number, or null.");if("boolean"!=typeof e.grouped)throw new Error("align(): grouped must be a boolean value.");return e},populateRelativeToFromBounds=(e,r,t)=>{for(let n=0;n<3;n++)null==e[n]&&("center"===r[n]?e[n]=(t[0][n]+t[1][n])/2:"max"===r[n]?e[n]=t[1][n]:"min"===r[n]&&(e[n]=t[0][n]));return e},alignGeometries=(e,r,t)=>{const n=measureAggregateBoundingBox(e),o=[0,0,0];for(let e=0;e<3;e++)"center"===r[e]?o[e]=t[e]-(n[0][e]+n[1][e])/2:"max"===r[e]?o[e]=t[e]-n[1][e]:"min"===r[e]&&(o[e]=t[e]-n[0][e]);return translate(o,e)},align=(e,...r)=>{e=Object.assign({},{modes:["center","center","min"],relativeTo:[0,0,0],grouped:!1},e),e=validateOptions(e);let{modes:t,relativeTo:n,grouped:o}=e;if(0===(r=flatten(r)).length)throw new Error("align(): No geometries were provided to act upon");if(n.filter(e=>null==e).length){const e=measureAggregateBoundingBox(r);n=populateRelativeToFromBounds(n,t,e)}return 1===(r=o?alignGeometries(r,t,n):r.map(e=>alignGeometries(e,t,n))).length?r[0]:r};module.exports=align; -},{"../../measurements/measureAggregateBoundingBox":254,"../../utils/flatten":397,"../../utils/padArrayToLength":401,"./translate":366}],360:[function(require,module,exports){ +},{"../../measurements/measureAggregateBoundingBox":254,"../../utils/flatten":398,"../../utils/padArrayToLength":402,"./translate":367}],361:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),measureBoundingBox=require("../../measurements/measureBoundingBox"),{translate:translate}=require("./translate"),centerGeometry=(e,r)=>{const{axes:t,relativeTo:n}=Object.assign({},{axes:[!0,!0,!0],relativeTo:[0,0,0]},e),a=measureBoundingBox(r),o=[0,0,0];return t[0]&&(o[0]=n[0]-(a[0][0]+(a[1][0]-a[0][0])/2)),t[1]&&(o[1]=n[1]-(a[0][1]+(a[1][1]-a[0][1])/2)),t[2]&&(o[2]=n[2]-(a[0][2]+(a[1][2]-a[0][2])/2)),translate(o,r)},center=(e,...r)=>{const{axes:t,relativeTo:n}=Object.assign({},{axes:[!0,!0,!0],relativeTo:[0,0,0]},e);if(0===(r=flatten(r)).length)throw new Error("wrong number of arguments");if(3!==n.length)throw new Error("relativeTo must be an array of length 3");e={axes:t,relativeTo:n};const a=r.map(r=>path2.isA(r)?centerGeometry(e,r):geom2.isA(r)?centerGeometry(e,r):geom3.isA(r)?centerGeometry(e,r):r);return 1===a.length?a[0]:a},centerX=(...e)=>center({axes:[!0,!1,!1]},e),centerY=(...e)=>center({axes:[!1,!0,!1]},e),centerZ=(...e)=>center({axes:[!1,!1,!0]},e);module.exports={center:center,centerX:centerX,centerY:centerY,centerZ:centerZ}; -},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../geometries/path2":62,"../../measurements/measureBoundingBox":258,"../../utils/flatten":397,"./translate":366}],361:[function(require,module,exports){ +},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../geometries/path2":62,"../../measurements/measureBoundingBox":258,"../../utils/flatten":398,"./translate":367}],362:[function(require,module,exports){ module.exports={align:require("./align"),center:require("./center").center,centerX:require("./center").centerX,centerY:require("./center").centerY,centerZ:require("./center").centerZ,mirror:require("./mirror").mirror,mirrorX:require("./mirror").mirrorX,mirrorY:require("./mirror").mirrorY,mirrorZ:require("./mirror").mirrorZ,rotate:require("./rotate").rotate,rotateX:require("./rotate").rotateX,rotateY:require("./rotate").rotateY,rotateZ:require("./rotate").rotateZ,scale:require("./scale").scale,scaleX:require("./scale").scaleX,scaleY:require("./scale").scaleY,scaleZ:require("./scale").scaleZ,transform:require("./transform"),translate:require("./translate").translate,translateX:require("./translate").translateX,translateY:require("./translate").translateY,translateZ:require("./translate").translateZ}; -},{"./align":359,"./center":360,"./mirror":362,"./rotate":363,"./scale":364,"./transform":365,"./translate":366}],362:[function(require,module,exports){ +},{"./align":360,"./center":361,"./mirror":363,"./rotate":364,"./scale":365,"./transform":366,"./translate":367}],363:[function(require,module,exports){ const flatten=require("../../utils/flatten"),mat4=require("../../maths/mat4"),plane=require("../../maths/plane"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),mirror=(r,...e)=>{const{origin:o,normal:m}=Object.assign({},{origin:[0,0,0],normal:[0,0,1]},r);if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");const i=plane.fromNormalAndPoint(plane.create(),m,o);if(Number.isNaN(i[0]))throw new Error("the given origin and normal do not define a proper plane");const n=mat4.mirrorByPlane(mat4.create(),i),t=e.map(r=>path2.isA(r)?path2.transform(n,r):geom2.isA(r)?geom2.transform(n,r):geom3.isA(r)?geom3.transform(n,r):r);return 1===t.length?t[0]:t},mirrorX=(...r)=>mirror({normal:[1,0,0]},r),mirrorY=(...r)=>mirror({normal:[0,1,0]},r),mirrorZ=(...r)=>mirror({normal:[0,0,1]},r);module.exports={mirror:mirror,mirrorX:mirrorX,mirrorY:mirrorY,mirrorZ:mirrorZ}; -},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../geometries/path2":62,"../../maths/mat4":143,"../../maths/plane":163,"../../utils/flatten":397}],363:[function(require,module,exports){ +},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../geometries/path2":62,"../../maths/mat4":143,"../../maths/plane":163,"../../utils/flatten":398}],364:[function(require,module,exports){ const flatten=require("../../utils/flatten"),mat4=require("../../maths/mat4"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),rotate=(t,...e)=>{if(!Array.isArray(t))throw new Error("angles must be an array");if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");for(t=t.slice();t.length<3;)t.push(0);const r=t[2],o=t[1],a=t[0],m=mat4.fromTaitBryanRotation(mat4.create(),r,o,a),n=e.map(t=>path2.isA(t)?path2.transform(m,t):geom2.isA(t)?geom2.transform(m,t):geom3.isA(t)?geom3.transform(m,t):t);return 1===n.length?n[0]:n},rotateX=(t,...e)=>rotate([t,0,0],e),rotateY=(t,...e)=>rotate([0,t,0],e),rotateZ=(t,...e)=>rotate([0,0,t],e);module.exports={rotate:rotate,rotateX:rotateX,rotateY:rotateY,rotateZ:rotateZ}; -},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../geometries/path2":62,"../../maths/mat4":143,"../../utils/flatten":397}],364:[function(require,module,exports){ +},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../geometries/path2":62,"../../maths/mat4":143,"../../utils/flatten":398}],365:[function(require,module,exports){ const flatten=require("../../utils/flatten"),mat4=require("../../maths/mat4"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),scale=(e,...r)=>{if(!Array.isArray(e))throw new Error("factors must be an array");if(0===(r=flatten(r)).length)throw new Error("wrong number of arguments");for(e=e.slice();e.length<3;)e.push(1);if(e[0]<=0||e[1]<=0||e[2]<=0)throw new Error("factors must be positive");const a=mat4.fromScaling(mat4.create(),e),t=r.map(e=>path2.isA(e)?path2.transform(a,e):geom2.isA(e)?geom2.transform(a,e):geom3.isA(e)?geom3.transform(a,e):e);return 1===t.length?t[0]:t},scaleX=(e,...r)=>scale([e,1,1],r),scaleY=(e,...r)=>scale([1,e,1],r),scaleZ=(e,...r)=>scale([1,1,e],r);module.exports={scale:scale,scaleX:scaleX,scaleY:scaleY,scaleZ:scaleZ}; -},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../geometries/path2":62,"../../maths/mat4":143,"../../utils/flatten":397}],365:[function(require,module,exports){ +},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../geometries/path2":62,"../../maths/mat4":143,"../../utils/flatten":398}],366:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),transform=(e,...r)=>{if(0===(r=flatten(r)).length)throw new Error("wrong number of arguments");const t=r.map(r=>path2.isA(r)?path2.transform(e,r):geom2.isA(r)?geom2.transform(e,r):geom3.isA(r)?geom3.transform(e,r):r);return 1===t.length?t[0]:t};module.exports=transform; -},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../geometries/path2":62,"../../utils/flatten":397}],366:[function(require,module,exports){ +},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../geometries/path2":62,"../../utils/flatten":398}],367:[function(require,module,exports){ const flatten=require("../../utils/flatten"),mat4=require("../../maths/mat4"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),translate=(t,...e)=>{if(!Array.isArray(t))throw new Error("offset must be an array");if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");for(t=t.slice();t.length<3;)t.push(0);const r=mat4.fromTranslation(mat4.create(),t),a=e.map(t=>path2.isA(t)?path2.transform(r,t):geom2.isA(t)?geom2.transform(r,t):geom3.isA(t)?geom3.transform(r,t):t);return 1===a.length?a[0]:a},translateX=(t,...e)=>translate([t,0,0],e),translateY=(t,...e)=>translate([0,t,0],e),translateZ=(t,...e)=>translate([0,0,t],e);module.exports={translate:translate,translateX:translateX,translateY:translateY,translateZ:translateZ}; -},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../geometries/path2":62,"../../maths/mat4":143,"../../utils/flatten":397}],367:[function(require,module,exports){ +},{"../../geometries/geom2":25,"../../geometries/geom3":41,"../../geometries/path2":62,"../../maths/mat4":143,"../../utils/flatten":398}],368:[function(require,module,exports){ const{EPS:EPS,TAU:TAU}=require("../maths/constants"),vec2=require("../maths/vec2"),path2=require("../geometries/path2"),{isGT:isGT,isGTE:isGTE,isNumberArray:isNumberArray}=require("./commonChecks"),arc=e=>{const r={center:[0,0],radius:1,startAngle:0,endAngle:TAU,makeTangent:!1,segments:32};let{center:t,radius:s,startAngle:n,endAngle:a,makeTangent:o,segments:c}=Object.assign({},r,e);if(!isNumberArray(t,2))throw new Error("center must be an array of X and Y values");if(!isGT(s,0))throw new Error("radius must be greater than zero");if(!isGTE(n,0))throw new Error("startAngle must be positive");if(!isGTE(a,0))throw new Error("endAngle must be positive");if(!isGTE(c,4))throw new Error("segments must be four or more");let i=TAU;(n%=TAU)<(a%=TAU)&&(i=a-n),n>a&&(i=a+(TAU-n));const m=Math.acos((s*s+s*s-EPS*EPS)/(2*s*s)),l=vec2.clone(t);let u;const A=[];if(i.25&&(r=.25);const t=o?e+2:e;for(let a=0;a<=t;a++){let t=a;o&&((t=(a-1)*(e-2*r)/e+r)<0&&(t=0),t>e&&(t=e));const c=n+t*(i/e);u=vec2.fromAngleRadians(vec2.create(),c),vec2.scale(u,u,s),vec2.add(u,u,l),A.push(u)}}return path2.fromPoints({closed:!1},A)};module.exports=arc; -},{"../geometries/path2":62,"../maths/constants":94,"../maths/vec2":191,"./commonChecks":369}],368:[function(require,module,exports){ +},{"../geometries/path2":62,"../maths/constants":94,"../maths/vec2":191,"./commonChecks":370}],369:[function(require,module,exports){ const{TAU:TAU}=require("../maths/constants"),ellipse=require("./ellipse"),{isGTE:isGTE}=require("./commonChecks"),circle=e=>{const s={center:[0,0],radius:1,startAngle:0,endAngle:TAU,segments:32};let{center:r,radius:t,startAngle:n,endAngle:i,segments:l}=Object.assign({},s,e);if(!isGTE(t,0))throw new Error("radius must be positive");return ellipse({center:r,radius:t=[t,t],startAngle:n,endAngle:i,segments:l})};module.exports=circle; -},{"../maths/constants":94,"./commonChecks":369,"./ellipse":374}],369:[function(require,module,exports){ +},{"../maths/constants":94,"./commonChecks":370,"./ellipse":375}],370:[function(require,module,exports){ const isNumberArray=(i,r)=>!!(Array.isArray(i)&&i.length>=r)&&i.every(i=>Number.isFinite(i)),isGT=(i,r)=>Number.isFinite(i)&&i>r,isGTE=(i,r)=>Number.isFinite(i)&&i>=r;module.exports={isNumberArray:isNumberArray,isGT:isGT,isGTE:isGTE}; -},{}],370:[function(require,module,exports){ +},{}],371:[function(require,module,exports){ const cuboid=require("./cuboid"),{isGTE:isGTE}=require("./commonChecks"),cube=e=>{let{center:i,size:r}=Object.assign({},{center:[0,0,0],size:2},e);if(!isGTE(r,0))throw new Error("size must be positive");return cuboid({center:i,size:r=[r,r,r]})};module.exports=cube; -},{"./commonChecks":369,"./cuboid":371}],371:[function(require,module,exports){ +},{"./commonChecks":370,"./cuboid":372}],372:[function(require,module,exports){ const geom3=require("../geometries/geom3"),poly3=require("../geometries/poly3"),{isNumberArray:isNumberArray}=require("./commonChecks"),cuboid=e=>{const{center:r,size:o}=Object.assign({},{center:[0,0,0],size:[2,2,2]},e);if(!isNumberArray(r,3))throw new Error("center must be an array of X, Y and Z values");if(!isNumberArray(o,3))throw new Error("size must be an array of width, depth and height values");if(!o.every(e=>e>=0))throw new Error("size values must be positive");return 0===o[0]||0===o[1]||0===o[2]?geom3.create():geom3.create([[[0,4,6,2],[-1,0,0]],[[1,3,7,5],[1,0,0]],[[0,1,5,4],[0,-1,0]],[[2,6,7,3],[0,1,0]],[[0,2,3,1],[0,0,-1]],[[4,5,7,6],[0,0,1]]].map(e=>{const t=e[0].map(e=>{return[r[0]+o[0]/2*(2*!!(1&e)-1),r[1]+o[1]/2*(2*!!(2&e)-1),r[2]+o[2]/2*(2*!!(4&e)-1)]});return poly3.create(t)}))};module.exports=cuboid; -},{"../geometries/geom3":41,"../geometries/poly3":79,"./commonChecks":369}],372:[function(require,module,exports){ +},{"../geometries/geom3":41,"../geometries/poly3":79,"./commonChecks":370}],373:[function(require,module,exports){ const geom3=require("../geometries/geom3"),cylinderElliptic=require("./cylinderElliptic"),{isGTE:isGTE}=require("./commonChecks"),cylinder=e=>{const{center:i,height:r,radius:s,segments:t}=Object.assign({},{center:[0,0,0],height:2,radius:1,segments:32},e);if(!isGTE(s,0))throw new Error("radius must be positive");return 0===r||0===s?geom3.create():cylinderElliptic({center:i,height:r,startRadius:[s,s],endRadius:[s,s],segments:t})};module.exports=cylinder; -},{"../geometries/geom3":41,"./commonChecks":369,"./cylinderElliptic":373}],373:[function(require,module,exports){ +},{"../geometries/geom3":41,"./commonChecks":370,"./cylinderElliptic":374}],374:[function(require,module,exports){ const{EPS:EPS,TAU:TAU}=require("../maths/constants"),vec3=require("../maths/vec3"),geom3=require("../geometries/geom3"),poly3=require("../geometries/poly3"),{sin:sin,cos:cos}=require("../maths/utils/trigonometry"),{isGT:isGT,isGTE:isGTE,isNumberArray:isNumberArray}=require("./commonChecks"),cylinderElliptic=e=>{const r={center:[0,0,0],height:2,startRadius:[1,1],startAngle:0,endRadius:[1,1],endAngle:TAU,segments:32};let{center:s,height:t,startRadius:a,startAngle:i,endRadius:o,endAngle:n,segments:u}=Object.assign({},r,e);if(!isNumberArray(s,3))throw new Error("center must be an array of X, Y and Z values");if(!isGT(t,0))throw new Error("height must be greater then zero");if(!isNumberArray(a,2))throw new Error("startRadius must be an array of X and Y values");if(!a.every(e=>e>=0))throw new Error("startRadius values must be positive");if(!isNumberArray(o,2))throw new Error("endRadius must be an array of X and Y values");if(!o.every(e=>e>=0))throw new Error("endRadius values must be positive");if(o.every(e=>0===e)&&a.every(e=>0===e))throw new Error("at least one radius must be positive");if(!isGTE(i,0))throw new Error("startAngle must be positive");if(!isGTE(n,0))throw new Error("endAngle must be positive");if(!isGTE(u,4))throw new Error("segments must be four or more");let c=TAU;(i%=TAU)<(n%=TAU)&&(c=n-i),i>n&&(c=n+(TAU-i));const l=Math.min(a[0],a[1],o[0],o[1]),m=Math.acos((l*l+l*l-EPS*EPS)/(2*l*l));if(c{const t=r*c+i;return vec3.scale(A,g,s[0]*cos(t)),vec3.scale(w,p,s[1]*sin(t)),vec3.add(A,A,w),vec3.scale(E,f,e),vec3.add(E,E,d),vec3.add(vec3.create(),A,E)},T=(...e)=>{const r=e.map(e=>vec3.add(vec3.create(),e,s));return poly3.create(r)},b=[];for(let e=0;e0&&a[1]>0&&b.push(T(d,y(0,s,a),y(0,r,a))),(a[0]>0||a[1]>0)&&b.push(T(y(0,r,a),y(0,s,a),y(1,r,o))),o[0]>0&&o[1]>0&&b.push(T(v,y(1,r,o),y(1,s,o))),(o[0]>0||o[1]>0)&&b.push(T(y(1,r,o),y(0,s,a),y(1,s,o))))}return c{const r={center:[0,0],radius:[1,1],startAngle:0,endAngle:TAU,segments:32};let{center:s,radius:t,startAngle:n,endAngle:o,segments:i}=Object.assign({},r,e);if(!isNumberArray(s,2))throw new Error("center must be an array of X and Y values");if(!isNumberArray(t,2))throw new Error("radius must be an array of X and Y values");if(!t.every(e=>e>=0))throw new Error("radius values must be positive");if(!isGTE(n,0))throw new Error("startAngle must be positive");if(!isGTE(o,0))throw new Error("endAngle must be positive");if(!isGTE(i,3))throw new Error("segments must be three or more");if(0===t[0]||0===t[1])return geom2.create();let a=TAU;(n%=TAU)<(o%=TAU)&&(a=o-n),n>o&&(a=o+(TAU-n));const m=Math.min(t[0],t[1]);if(a{const{center:c,radius:r,segments:s,axes:a}=Object.assign({},{center:[0,0,0],radius:[1,1,1],segments:32,axes:[[1,0,0],[0,-1,0],[0,0,1]]},e);if(!isNumberArray(c,3))throw new Error("center must be an array of X, Y and Z values");if(!isNumberArray(r,3))throw new Error("radius must be an array of X, Y and Z values");if(!r.every(e=>e>=0))throw new Error("radius values must be positive");if(!isGTE(s,4))throw new Error("segments must be four or more");if(0===r[0]||0===r[1]||0===r[2])return geom3.create();const t=vec3.scale(vec3.create(),vec3.normalize(vec3.create(),a[0]),r[0]),v=vec3.scale(vec3.create(),vec3.normalize(vec3.create(),a[1]),r[1]),o=vec3.scale(vec3.create(),vec3.normalize(vec3.create(),a[2]),r[2]),i=Math.round(s/4);let l;const u=[],d=vec3.create(),n=vec3.create();for(let e=0;e<=s;e++){const r=TAU*e/s,a=vec3.add(vec3.create(),vec3.scale(d,t,cos(r)),vec3.scale(n,v,sin(r)));if(e>0){let e,r;for(let s=0;s<=i;s++){const t=TAU/4*s/i,v=cos(t),m=sin(t);if(s>0){let t,h=[];t=vec3.subtract(vec3.create(),vec3.scale(d,l,e),vec3.scale(n,o,r)),h.push(vec3.add(t,t,c)),t=vec3.subtract(vec3.create(),vec3.scale(d,a,e),vec3.scale(n,o,r)),h.push(vec3.add(t,t,c)),s{let{radius:r,frequency:t}=Object.assign({},{radius:1,frequency:6},e);if(!isGTE(r,0))throw new Error("radius must be positive");if(!isGTE(t,6))throw new Error("frequency must be six or more");if(0===r)return geom3.create();t=Math.floor(t/6);const o=[[.850651,0,-.525731],[.850651,-0,.525731],[-.850651,-0,.525731],[-.850651,0,-.525731],[0,-.525731,.850651],[0,.525731,.850651],[0,.525731,-.850651],[0,-.525731,-.850651],[-.525731,-.850651,-0],[.525731,-.850651,-0],[.525731,.850651,0],[-.525731,.850651,0]],s=[[0,9,1],[1,10,0],[6,7,0],[10,6,0],[7,9,0],[5,1,4],[4,1,9],[5,10,1],[2,8,3],[3,11,2],[2,5,4],[4,8,2],[2,11,5],[3,7,6],[6,11,3],[8,7,3],[9,8,4],[11,10,5],[10,11,6],[8,9,7]],n=(e,r,t)=>{const o=e[0],s=e[1],n=e[2];let c=t;const f=[],l=[];for(let e=0;e{const o=1-t,s=[];for(let n=0;n<3;n++)s[n]=e[n]*o+r[n]*t;return s};let c=[],f=[],l=0;for(let e=0;e{if(!Array.isArray(r))throw new Error("points must be an array");return path2.fromPoints({},r)};module.exports=line; -},{"../geometries/path2":62}],379:[function(require,module,exports){ +},{"../geometries/path2":62}],380:[function(require,module,exports){ const geom2=require("../geometries/geom2"),polygon=r=>{const{points:o,paths:t,orientation:e}=Object.assign({},{points:[],paths:[],orientation:"counterclockwise"},r);if(!Array.isArray(o)||!Array.isArray(t))throw new Error("points and paths must be arrays");let s=o;Array.isArray(o[0])&&(Array.isArray(o[0][0])||(s=[o])),s.forEach((r,o)=>{if(!Array.isArray(r))throw new Error("list of points "+o+" must be an array");if(r.length<3)throw new Error("list of points "+o+" must contain three or more points");r.forEach((r,t)=>{if(!Array.isArray(r))throw new Error("list of points "+o+", point "+t+" must be an array");if(r.length<2)throw new Error("list of points "+o+", point "+t+" must contain by X and Y values")})});let a=t;if(0===t.length){let r=0;a=s.map(o=>o.map(o=>r++))}const n=[];s.forEach(r=>r.forEach(r=>n.push(r)));let i=[];a.forEach(r=>{const o=r.map(r=>n[r]),t=geom2.fromPoints(o);i=i.concat(geom2.toSides(t))});let c=geom2.create(i);return"clockwise"==e&&(c=geom2.reverse(c)),c};module.exports=polygon; -},{"../geometries/geom2":25}],380:[function(require,module,exports){ +},{"../geometries/geom2":25}],381:[function(require,module,exports){ const geom3=require("../geometries/geom3"),poly3=require("../geometries/poly3"),{isNumberArray:isNumberArray}=require("./commonChecks"),polyhedron=r=>{const e={points:[],faces:[],colors:void 0,orientation:"outward"},{points:o,faces:a,colors:t,orientation:n}=Object.assign({},e,r);if(!Array.isArray(o)||!Array.isArray(a))throw new Error("points and faces must be arrays");if(o.length<3)throw new Error("three or more points are required");if(a.length<1)throw new Error("one or more faces are required");if(t){if(!Array.isArray(t))throw new Error("colors must be an array");if(t.length!==a.length)throw new Error("faces and colors must have the same length")}o.forEach((r,e)=>{if(!isNumberArray(r,3))throw new Error(`point ${e} must be an array of X, Y, Z values`)}),a.forEach((r,e)=>{if(r.length<3)throw new Error(`face ${e} must contain 3 or more indexes`);if(!isNumberArray(r,r.length))throw new Error(`face ${e} must be an array of numbers`)}),"outward"!==n&&a.forEach(r=>r.reverse());const s=a.map((r,e)=>{const a=poly3.create(r.map(r=>o[r]));return t&&t[e]&&(a.color=t[e]),a});return geom3.create(s)};module.exports=polyhedron; -},{"../geometries/geom3":41,"../geometries/poly3":79,"./commonChecks":369}],381:[function(require,module,exports){ +},{"../geometries/geom3":41,"../geometries/poly3":79,"./commonChecks":370}],382:[function(require,module,exports){ const vec2=require("../maths/vec2"),geom2=require("../geometries/geom2"),{isNumberArray:isNumberArray}=require("./commonChecks"),rectangle=e=>{const{center:r,size:t}=Object.assign({},{center:[0,0],size:[2,2]},e);if(!isNumberArray(r,2))throw new Error("center must be an array of X and Y values");if(!isNumberArray(t,2))throw new Error("size must be an array of X and Y values");if(!t.every(e=>e>=0))throw new Error("size values must be positive");if(0===t[0]||0===t[1])return geom2.create();const a=[t[0]/2,t[1]/2],c=[a[0],-a[1]],s=[vec2.subtract(vec2.create(),r,a),vec2.add(vec2.create(),r,c),vec2.add(vec2.create(),r,a),vec2.subtract(vec2.create(),r,c)];return geom2.fromPoints(s)};module.exports=rectangle; -},{"../geometries/geom2":25,"../maths/vec2":191,"./commonChecks":369}],382:[function(require,module,exports){ +},{"../geometries/geom2":25,"../maths/vec2":191,"./commonChecks":370}],383:[function(require,module,exports){ const{EPS:EPS,TAU:TAU}=require("../maths/constants"),vec2=require("../maths/vec2"),vec3=require("../maths/vec3"),geom3=require("../geometries/geom3"),poly3=require("../geometries/poly3"),{sin:sin,cos:cos}=require("../maths/utils/trigonometry"),{isGTE:isGTE,isNumberArray:isNumberArray}=require("./commonChecks"),cuboid=require("./cuboid"),createCorners=(e,r,t,s,c,o)=>{const a=TAU/4*c/s,n=cos(a),i=sin(a),u=s-c;let l=t*n,h=r[2]-(t-t*i);o||(h=t-t*i-r[2]),l=l>EPS?l:0;const d=vec3.add(vec3.create(),e,[r[0]-t,r[1]-t,h]),v=vec3.add(vec3.create(),e,[t-r[0],r[1]-t,h]),m=vec3.add(vec3.create(),e,[t-r[0],t-r[1],h]),p=vec3.add(vec3.create(),e,[r[0]-t,t-r[1],h]),f=[],g=[],E=[],b=[];for(let e=0;e<=u;e++){const r=u>0?TAU/4*e/u:0,t=vec2.fromAngleRadians(vec2.create(),r);vec2.scale(t,t,l);const s=vec3.fromVec2(vec3.create(),t);f.push(vec3.add(vec3.create(),d,s)),vec3.rotateZ(s,s,[0,0,0],TAU/4),g.push(vec3.add(vec3.create(),v,s)),vec3.rotateZ(s,s,[0,0,0],TAU/4),E.push(vec3.add(vec3.create(),m,s)),vec3.rotateZ(s,s,[0,0,0],TAU/4),b.push(vec3.add(vec3.create(),p,s))}return o?[f,g,E,b]:(f.reverse(),g.reverse(),E.reverse(),b.reverse(),[b,E,g,f])},stitchCorners=(e,r)=>{const t=[];for(let s=0;s{const t=[];for(let s=0;s{e=(e=[e[3],e[2],e[1],e[0]]).map(e=>e.slice().reverse());const t=[];e.forEach(e=>{e.forEach(e=>t.push(e))});const s=[];r.forEach(e=>{e.forEach(e=>s.push(e))});const c=[];for(let e=0;e{let{center:r,size:t,roundRadius:s,segments:c}=Object.assign({},{center:[0,0,0],size:[2,2,2],roundRadius:.2,segments:32},e);if(!isNumberArray(r,3))throw new Error("center must be an array of X, Y and Z values");if(!isNumberArray(t,3))throw new Error("size must be an array of X, Y and Z values");if(!t.every(e=>e>=0))throw new Error("size values must be positive");if(!isGTE(s,0))throw new Error("roundRadius must be positive");if(!isGTE(c,4))throw new Error("segments must be four or more");if(0===t[0]||0===t[1]||0===t[2])return geom3.create();if(0===s)return cuboid({center:r,size:t});if(s>(t=t.map(e=>e/2))[0]-EPS||s>t[1]-EPS||s>t[2]-EPS)throw new Error("roundRadius must be smaller than the radius of all dimensions");c=Math.floor(c/4);let o=null,a=null,n=[];for(let e=0;e<=c;e++){const i=createCorners(r,t,s,c,e,!0),u=createCorners(r,t,s,c,e,!1);if(0===e&&(n=n.concat(stitchSides(u,i))),o&&(n=n.concat(stitchCorners(o,i),stitchWalls(o,i))),a&&(n=n.concat(stitchCorners(a,u),stitchWalls(a,u))),e===c){let e=i.map(e=>e[0]);n.push(poly3.create(e)),e=u.map(e=>e[0]),n.push(poly3.create(e))}o=i,a=u}return geom3.create(n)};module.exports=roundedCuboid; -},{"../geometries/geom3":41,"../geometries/poly3":79,"../maths/constants":94,"../maths/utils/trigonometry":173,"../maths/vec2":191,"../maths/vec3":222,"./commonChecks":369,"./cuboid":371}],383:[function(require,module,exports){ +},{"../geometries/geom3":41,"../geometries/poly3":79,"../maths/constants":94,"../maths/utils/trigonometry":173,"../maths/vec2":191,"../maths/vec3":222,"./commonChecks":370,"./cuboid":372}],384:[function(require,module,exports){ const{EPS:EPS,TAU:TAU}=require("../maths/constants"),vec3=require("../maths/vec3"),geom3=require("../geometries/geom3"),poly3=require("../geometries/poly3"),{sin:sin,cos:cos}=require("../maths/utils/trigonometry"),{isGTE:isGTE,isNumberArray:isNumberArray}=require("./commonChecks"),cylinder=require("./cylinder"),roundedCylinder=e=>{const{center:c,height:r,radius:s,roundRadius:a,segments:t}=Object.assign({},{center:[0,0,0],height:2,radius:1,roundRadius:.2,segments:32},e);if(!isNumberArray(c,3))throw new Error("center must be an array of X, Y and Z values");if(!isGTE(r,0))throw new Error("height must be positive");if(!isGTE(s,0))throw new Error("radius must be positive");if(!isGTE(a,0))throw new Error("roundRadius must be positive");if(a>s)throw new Error("roundRadius must be smaller than the radius");if(!isGTE(t,4))throw new Error("segments must be four or more");if(0===r||0===s)return geom3.create();if(0===a)return cylinder({center:c,height:r,radius:s});const v=[0,0,-r/2],o=[0,0,r/2],i=vec3.subtract(vec3.create(),o,v);if(2*a>vec3.length(i)-EPS)throw new Error("height must be larger than twice roundRadius");let u;u=Math.abs(i[0])>Math.abs(i[1])?vec3.fromValues(0,1,0):vec3.fromValues(1,0,0);const d=vec3.scale(vec3.create(),vec3.normalize(vec3.create(),i),a),n=vec3.scale(vec3.create(),vec3.normalize(vec3.create(),vec3.cross(vec3.create(),d,u)),s),l=vec3.scale(vec3.create(),vec3.normalize(vec3.create(),vec3.cross(vec3.create(),n,d)),s);vec3.add(v,v,d),vec3.subtract(o,o,d);const h=Math.floor(.25*t),m=e=>{const r=e.map(e=>vec3.add(e,e,c));return poly3.create(r)},p=[],b=vec3.create(),f=vec3.create();let g;for(let e=0;e<=t;e++){const c=TAU*e/t,r=vec3.add(vec3.create(),vec3.scale(b,n,cos(c)),vec3.scale(f,l,sin(c)));if(e>0){let e,c,s=[];s.push(vec3.add(vec3.create(),v,r)),s.push(vec3.add(vec3.create(),v,g)),s.push(vec3.add(vec3.create(),o,g)),s.push(vec3.add(vec3.create(),o,r)),p.push(m(s));for(let a=0;a<=h;a++){const t=TAU/4*a/h,i=cos(t),u=sin(t);if(a>0){let t;s=[],t=vec3.add(vec3.create(),v,vec3.subtract(b,vec3.scale(b,g,e),vec3.scale(f,d,c))),s.push(t),t=vec3.add(vec3.create(),v,vec3.subtract(b,vec3.scale(b,r,e),vec3.scale(f,d,c))),s.push(t),a{let{center:r,size:t,roundRadius:a,segments:c}=Object.assign({},{center:[0,0],size:[2,2],roundRadius:.2,segments:32},e);if(!isNumberArray(r,2))throw new Error("center must be an array of X and Y values");if(!isNumberArray(t,2))throw new Error("size must be an array of X and Y values");if(!t.every(e=>e>=0))throw new Error("size values must be positive");if(!isGTE(a,0))throw new Error("roundRadius must be positive");if(!isGTE(c,4))throw new Error("segments must be four or more");if(0===t[0]||0===t[1])return geom2.create();if(0===a)return rectangle({center:r,size:t});if(a>(t=t.map(e=>e/2))[0]-EPS||a>t[1]-EPS)throw new Error("roundRadius must be smaller than the radius of all dimensions");const s=Math.floor(c/4),o=vec2.add(vec2.create(),r,[t[0]-a,t[1]-a]),n=vec2.add(vec2.create(),r,[a-t[0],t[1]-a]),i=vec2.add(vec2.create(),r,[a-t[0],a-t[1]]),u=vec2.add(vec2.create(),r,[t[0]-a,a-t[1]]),d=[],v=[],m=[],l=[];for(let e=0;e<=s;e++){const r=TAU/4*e/s,t=vec2.fromAngleRadians(vec2.create(),r);vec2.scale(t,t,a),d.push(vec2.add(vec2.create(),o,t)),vec2.rotate(t,t,vec2.create(),TAU/4),v.push(vec2.add(vec2.create(),n,t)),vec2.rotate(t,t,vec2.create(),TAU/4),m.push(vec2.add(vec2.create(),i,t)),vec2.rotate(t,t,vec2.create(),TAU/4),l.push(vec2.add(vec2.create(),u,t))}return geom2.fromPoints(d.concat(v,m,l))};module.exports=roundedRectangle; -},{"../geometries/geom2":25,"../maths/constants":94,"../maths/vec2":191,"./commonChecks":369,"./rectangle":381}],385:[function(require,module,exports){ +},{"../geometries/geom2":25,"../maths/constants":94,"../maths/vec2":191,"./commonChecks":370,"./rectangle":382}],386:[function(require,module,exports){ const ellipsoid=require("./ellipsoid"),{isGTE:isGTE}=require("./commonChecks"),sphere=e=>{let{center:s,radius:r,segments:i,axes:t}=Object.assign({},{center:[0,0,0],radius:1,segments:32,axes:[[1,0,0],[0,-1,0],[0,0,1]]},e);if(!isGTE(r,0))throw new Error("radius must be positive");return ellipsoid({center:s,radius:r=[r,r,r],segments:i,axes:t})};module.exports=sphere; -},{"./commonChecks":369,"./ellipsoid":375}],386:[function(require,module,exports){ +},{"./commonChecks":370,"./ellipsoid":376}],387:[function(require,module,exports){ const rectangle=require("./rectangle"),{isGTE:isGTE}=require("./commonChecks"),square=e=>{let{center:r,size:s}=Object.assign({},{center:[0,0],size:2},e);if(!isGTE(s,0))throw new Error("size must be positive");return rectangle({center:r,size:s=[s,s]})};module.exports=square; -},{"./commonChecks":369,"./rectangle":381}],387:[function(require,module,exports){ +},{"./commonChecks":370,"./rectangle":382}],388:[function(require,module,exports){ const{TAU:TAU}=require("../maths/constants"),vec2=require("../maths/vec2"),geom2=require("../geometries/geom2"),{isGT:isGT,isGTE:isGTE,isNumberArray:isNumberArray}=require("./commonChecks"),getRadiusRatio=(e,r)=>e>0&&r>1&&r{const o=TAU/e,i=[];for(let a=0;a{let{center:r,vertices:t,outerRadius:s,innerRadius:o,density:i,startAngle:a}=Object.assign({},{center:[0,0],vertices:5,outerRadius:1,innerRadius:0,density:2,startAngle:0},e);if(!isNumberArray(r,2))throw new Error("center must be an array of X and Y values");if(!isGTE(t,2))throw new Error("vertices must be two or more");if(!isGT(s,0))throw new Error("outerRadius must be greater than zero");if(!isGTE(o,0))throw new Error("innerRadius must be greater than zero");if(!isGTE(a,0))throw new Error("startAngle must be greater than zero");if(t=Math.floor(t),i=Math.floor(i),a%=TAU,0===o){if(!isGTE(i,2))throw new Error("density must be two or more");o=s*getRadiusRatio(t,i)}const n=vec2.clone(r),u=getPoints(t,s,a,n),c=getPoints(t,o,a+Math.PI/t,n),h=[];for(let e=0;e{const r={innerRadius:1,innerSegments:32,outerRadius:4,outerSegments:32,innerRotation:0,startAngle:0,outerRotation:TAU},{innerRadius:t,innerSegments:o,outerRadius:n,outerSegments:s,innerRotation:i,startAngle:a,outerRotation:u}=Object.assign({},r,e);if(!isGT(t,0))throw new Error("innerRadius must be greater than zero");if(!isGTE(o,3))throw new Error("innerSegments must be three or more");if(!isGT(n,0))throw new Error("outerRadius must be greater than zero");if(!isGTE(s,3))throw new Error("outerSegments must be three or more");if(!isGTE(a,0))throw new Error("startAngle must be positive");if(!isGT(u,0))throw new Error("outerRotation must be greater than zero");if(t>=n)throw new Error("inner circle is two large to rotate about the outer circle");let m=circle({radius:t,segments:o});return 0!==i&&(m=rotate([0,0,i],m)),m=translate([n,0],m),extrudeRotate({startAngle:a,angle:u,segments:s},m)};module.exports=torus; -},{"../maths/constants":94,"../operations/extrusions/extrudeRotate":316,"../operations/transforms/rotate":363,"../operations/transforms/translate":366,"./circle":368,"./commonChecks":369}],389:[function(require,module,exports){ +},{"../maths/constants":94,"../operations/extrusions/extrudeRotate":316,"../operations/transforms/rotate":364,"../operations/transforms/translate":367,"./circle":369,"./commonChecks":370}],390:[function(require,module,exports){ const{NEPS:NEPS}=require("../maths/constants"),vec2=require("../maths/vec2"),geom2=require("../geometries/geom2"),{isNumberArray:isNumberArray}=require("./commonChecks"),solveAngleFromSSS=(e,r,t)=>Math.acos((e*e+r*r-t*t)/(2*e*r)),solveSideFromSAS=(e,r,t)=>r>NEPS?Math.sqrt(e*e+t*t-2*e*t*Math.cos(r)):Math.sqrt((e-t)*(e-t)+e*t*r*r*(1-r*r/12)),solveAAA=e=>{if(Math.abs(e[0]+e[1]+e[2]-Math.PI)>NEPS)throw new Error("AAA triangles require angles that sum to PI");const r=e[0],t=e[1],s=Math.PI-r-t,a=1/Math.sin(s)*Math.sin(r),n=1/Math.sin(s)*Math.sin(t);return createTriangle(r,t,s,a,n,1)},solveAAS=e=>{const r=e[0],t=e[1],s=Math.PI+NEPS-r-t;if(s{const r=e[0],t=e[2],s=Math.PI+NEPS-r-t;if(s{const r=e[0],t=e[1],s=e[2],a=solveSideFromSAS(r,t,s),n=solveAngleFromSSS(a,r,s),o=Math.PI-n-t;return createTriangle(n,t,o,s,a,r)},solveSSA=e=>{const r=e[0],t=e[1],s=e[2],a=Math.asin(t*Math.sin(s)/r),n=Math.PI-a-s,o=r/Math.sin(s)*Math.sin(n);return createTriangle(a,n,s,t,o,r)},solveSSS=e=>{const r=e[1],t=e[2],s=e[0];if(r+t<=s||t+s<=r||s+r<=t)throw new Error("SSS triangle is incorrect, as the longest side is longer than the sum of the other sides");const a=solveAngleFromSSS(t,s,r),n=solveAngleFromSSS(s,r,t),o=Math.PI-a-n;return createTriangle(a,n,o,r,t,s)},createTriangle=(e,r,t,s,a,n)=>{const o=vec2.fromValues(0,0),i=vec2.fromValues(n,0),S=vec2.fromValues(s,0);return vec2.add(S,vec2.rotate(S,S,[0,0],Math.PI-r),i),geom2.fromPoints([o,i,S])},triangle=e=>{let{type:r,values:t}=Object.assign({},{type:"SSS",values:[1,1,1]},e);if("string"!=typeof r)throw new Error("triangle type must be a string");if("A"!==(r=r.toUpperCase())[0]&&"S"!==r[0]||"A"!==r[1]&&"S"!==r[1]||"A"!==r[2]&&"S"!==r[2])throw new Error("triangle type must contain three letters; A or S");if(!isNumberArray(t,3))throw new Error("triangle values must contain three values");if(!t.every(e=>e>0))throw new Error("triangle values must be greater than zero");switch(r){case"AAA":return solveAAA(t);case"AAS":return solveAAS(t);case"ASA":return solveASA(t);case"SAS":return solveSAS(t);case"SSA":return solveSSA(t);case"SSS":return solveSSS(t);default:throw new Error("invalid triangle type, try again")}};module.exports=triangle; -},{"../geometries/geom2":25,"../maths/constants":94,"../maths/vec2":191,"./commonChecks":369}],390:[function(require,module,exports){ +},{"../geometries/geom2":25,"../maths/constants":94,"../maths/vec2":191,"./commonChecks":370}],391:[function(require,module,exports){ module.exports={height:14,32:[16],33:[10,5,21,5,7,void 0,5,2,4,1,5,0,6,1,5,2],34:[16,4,21,4,14,void 0,12,21,12,14],35:[21,11,25,4,-7,void 0,17,25,10,-7,void 0,4,12,18,12,void 0,3,6,17,6],36:[20,8,25,8,-4,void 0,12,25,12,-4,void 0,17,18,15,20,12,21,8,21,5,20,3,18,3,16,4,14,5,13,7,12,13,10,15,9,16,8,17,6,17,3,15,1,12,0,8,0,5,1,3,3],37:[24,21,21,3,0,void 0,8,21,10,19,10,17,9,15,7,14,5,14,3,16,3,18,4,20,6,21,8,21,10,20,13,19,16,19,19,20,21,21,void 0,17,7,15,6,14,4,14,2,16,0,18,0,20,1,21,3,21,5,19,7,17,7],38:[26,23,12,23,13,22,14,21,14,20,13,19,11,17,6,15,3,13,1,11,0,7,0,5,1,4,2,3,4,3,6,4,8,5,9,12,13,13,14,14,16,14,18,13,20,11,21,9,20,8,18,8,16,9,13,11,10,16,3,18,1,20,0,22,0,23,1,23,2],39:[10,5,19,4,20,5,21,6,20,6,18,5,16,4,15],40:[14,11,25,9,23,7,20,5,16,4,11,4,7,5,2,7,-2,9,-5,11,-7],41:[14,3,25,5,23,7,20,9,16,10,11,10,7,9,2,7,-2,5,-5,3,-7],42:[16,8,21,8,9,void 0,3,18,13,12,void 0,13,18,3,12],43:[26,13,18,13,0,void 0,4,9,22,9],44:[10,6,1,5,0,4,1,5,2,6,1,6,-1,5,-3,4,-4],45:[26,4,9,22,9],46:[10,5,2,4,1,5,0,6,1,5,2],47:[22,20,25,2,-7],48:[20,9,21,6,20,4,17,3,12,3,9,4,4,6,1,9,0,11,0,14,1,16,4,17,9,17,12,16,17,14,20,11,21,9,21],49:[20,6,17,8,18,11,21,11,0],50:[20,4,16,4,17,5,19,6,20,8,21,12,21,14,20,15,19,16,17,16,15,15,13,13,10,3,0,17,0],51:[20,5,21,16,21,10,13,13,13,15,12,16,11,17,8,17,6,16,3,14,1,11,0,8,0,5,1,4,2,3,4],52:[20,13,21,3,7,18,7,void 0,13,21,13,0],53:[20,15,21,5,21,4,12,5,13,8,14,11,14,14,13,16,11,17,8,17,6,16,3,14,1,11,0,8,0,5,1,4,2,3,4],54:[20,16,18,15,20,12,21,10,21,7,20,5,17,4,12,4,7,5,3,7,1,10,0,11,0,14,1,16,3,17,6,17,7,16,10,14,12,11,13,10,13,7,12,5,10,4,7],55:[20,17,21,7,0,void 0,3,21,17,21],56:[20,8,21,5,20,4,18,4,16,5,14,7,13,11,12,14,11,16,9,17,7,17,4,16,2,15,1,12,0,8,0,5,1,4,2,3,4,3,7,4,9,6,11,9,12,13,13,15,14,16,16,16,18,15,20,12,21,8,21],57:[20,16,14,15,11,13,9,10,8,9,8,6,9,4,11,3,14,3,15,4,18,6,20,9,21,10,21,13,20,15,18,16,14,16,9,15,4,13,1,10,0,8,0,5,1,4,3],58:[10,5,14,4,13,5,12,6,13,5,14,void 0,5,2,4,1,5,0,6,1,5,2],59:[10,5,14,4,13,5,12,6,13,5,14,void 0,6,1,5,0,4,1,5,2,6,1,6,-1,5,-3,4,-4],60:[24,20,18,4,9,20,0],61:[26,4,12,22,12,void 0,4,6,22,6],62:[24,4,18,20,9,4,0],63:[18,3,16,3,17,4,19,5,20,7,21,11,21,13,20,14,19,15,17,15,15,14,13,13,12,9,10,9,7,void 0,9,2,8,1,9,0,10,1,9,2],64:[27,18,13,17,15,15,16,12,16,10,15,9,14,8,11,8,8,9,6,11,5,14,5,16,6,17,8,void 0,12,16,10,14,9,11,9,8,10,6,11,5,void 0,18,16,17,8,17,6,19,5,21,5,23,7,24,10,24,12,23,15,22,17,20,19,18,20,15,21,12,21,9,20,7,19,5,17,4,15,3,12,3,9,4,6,5,4,7,2,9,1,12,0,15,0,18,1,20,2,21,3,void 0,19,16,18,8,18,6,19,5],65:[18,9,21,1,0,void 0,9,21,17,0,void 0,4,7,14,7],66:[21,4,21,4,0,void 0,4,21,13,21,16,20,17,19,18,17,18,15,17,13,16,12,13,11,void 0,4,11,13,11,16,10,17,9,18,7,18,4,17,2,16,1,13,0,4,0],67:[21,18,16,17,18,15,20,13,21,9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5],68:[21,4,21,4,0,void 0,4,21,11,21,14,20,16,18,17,16,18,13,18,8,17,5,16,3,14,1,11,0,4,0],69:[19,4,21,4,0,void 0,4,21,17,21,void 0,4,11,12,11,void 0,4,0,17,0],70:[18,4,21,4,0,void 0,4,21,17,21,void 0,4,11,12,11],71:[21,18,16,17,18,15,20,13,21,9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,18,8,void 0,13,8,18,8],72:[22,4,21,4,0,void 0,18,21,18,0,void 0,4,11,18,11],73:[8,4,21,4,0],74:[16,12,21,12,5,11,2,10,1,8,0,6,0,4,1,3,2,2,5,2,7],75:[21,4,21,4,0,void 0,18,21,4,7,void 0,9,12,18,0],76:[17,4,21,4,0,void 0,4,0,16,0],77:[24,4,21,4,0,void 0,4,21,12,0,void 0,20,21,12,0,void 0,20,21,20,0],78:[22,4,21,4,0,void 0,4,21,18,0,void 0,18,21,18,0],79:[22,9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,19,8,19,13,18,16,17,18,15,20,13,21,9,21],80:[21,4,21,4,0,void 0,4,21,13,21,16,20,17,19,18,17,18,14,17,12,16,11,13,10,4,10],81:[22,9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,19,8,19,13,18,16,17,18,15,20,13,21,9,21,void 0,12,4,18,-2],82:[21,4,21,4,0,void 0,4,21,13,21,16,20,17,19,18,17,18,15,17,13,16,12,13,11,4,11,void 0,11,11,18,0],83:[20,17,18,15,20,12,21,8,21,5,20,3,18,3,16,4,14,5,13,7,12,13,10,15,9,16,8,17,6,17,3,15,1,12,0,8,0,5,1,3,3],84:[16,8,21,8,0,void 0,1,21,15,21],85:[22,4,21,4,6,5,3,7,1,10,0,12,0,15,1,17,3,18,6,18,21],86:[18,1,21,9,0,void 0,17,21,9,0],87:[24,2,21,7,0,void 0,12,21,7,0,void 0,12,21,17,0,void 0,22,21,17,0],88:[20,3,21,17,0,void 0,17,21,3,0],89:[18,1,21,9,11,9,0,void 0,17,21,9,11],90:[20,17,21,3,0,void 0,3,21,17,21,void 0,3,0,17,0],91:[14,4,25,4,-7,void 0,5,25,5,-7,void 0,4,25,11,25,void 0,4,-7,11,-7],92:[14,0,21,14,-3],93:[14,9,25,9,-7,void 0,10,25,10,-7,void 0,3,25,10,25,void 0,3,-7,10,-7],94:[16,6,15,8,18,10,15,void 0,3,12,8,17,13,12,void 0,8,17,8,0],95:[16,0,-2,16,-2],96:[10,6,21,5,20,4,18,4,16,5,15,6,16,5,17],97:[19,15,14,15,0,void 0,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3],98:[19,4,21,4,0,void 0,4,11,6,13,8,14,11,14,13,13,15,11,16,8,16,6,15,3,13,1,11,0,8,0,6,1,4,3],99:[18,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3],100:[19,15,21,15,0,void 0,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3],101:[18,3,8,15,8,15,10,14,12,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3],102:[12,10,21,8,21,6,20,5,17,5,0,void 0,2,14,9,14],103:[19,15,14,15,-2,14,-5,13,-6,11,-7,8,-7,6,-6,void 0,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3],104:[19,4,21,4,0,void 0,4,10,7,13,9,14,12,14,14,13,15,10,15,0],105:[8,3,21,4,20,5,21,4,22,3,21,void 0,4,14,4,0],106:[10,5,21,6,20,7,21,6,22,5,21,void 0,6,14,6,-3,5,-6,3,-7,1,-7],107:[17,4,21,4,0,void 0,14,14,4,4,void 0,8,8,15,0],108:[8,4,21,4,0],109:[30,4,14,4,0,void 0,4,10,7,13,9,14,12,14,14,13,15,10,15,0,void 0,15,10,18,13,20,14,23,14,25,13,26,10,26,0],110:[19,4,14,4,0,void 0,4,10,7,13,9,14,12,14,14,13,15,10,15,0],111:[19,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3,16,6,16,8,15,11,13,13,11,14,8,14],112:[19,4,14,4,-7,void 0,4,11,6,13,8,14,11,14,13,13,15,11,16,8,16,6,15,3,13,1,11,0,8,0,6,1,4,3],113:[19,15,14,15,-7,void 0,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3],114:[13,4,14,4,0,void 0,4,8,5,11,7,13,9,14,12,14],115:[17,14,11,13,13,10,14,7,14,4,13,3,11,4,9,6,8,11,7,13,6,14,4,14,3,13,1,10,0,7,0,4,1,3,3],116:[12,5,21,5,4,6,1,8,0,10,0,void 0,2,14,9,14],117:[19,4,14,4,4,5,1,7,0,10,0,12,1,15,4,void 0,15,14,15,0],118:[16,2,14,8,0,void 0,14,14,8,0],119:[22,3,14,7,0,void 0,11,14,7,0,void 0,11,14,15,0,void 0,19,14,15,0],120:[17,3,14,14,0,void 0,14,14,3,0],121:[16,2,14,8,0,void 0,14,14,8,0,6,-4,4,-6,2,-7,1,-7],122:[17,14,14,3,0,void 0,3,14,14,14,void 0,3,0,14,0],123:[14,9,25,7,24,6,23,5,21,5,19,6,17,7,16,8,14,8,12,6,10,void 0,7,24,6,22,6,20,7,18,8,17,9,15,9,13,8,11,4,9,8,7,9,5,9,3,8,1,7,0,6,-2,6,-4,7,-6,void 0,6,8,8,6,8,4,7,2,6,1,5,-1,5,-3,6,-5,7,-6,9,-7],124:[8,4,25,4,-7],125:[14,5,25,7,24,8,23,9,21,9,19,8,17,7,16,6,14,6,12,8,10,void 0,7,24,8,22,8,20,7,18,6,17,5,15,5,13,6,11,10,9,6,7,5,5,5,3,6,1,7,0,8,-2,8,-4,7,-6,void 0,8,8,6,6,6,4,7,2,8,1,9,-1,9,-3,8,-5,7,-6,5,-7],126:[24,3,6,3,8,4,11,6,12,8,12,10,11,14,8,16,7,18,7,20,8,21,10,void 0,3,8,4,10,6,11,8,11,10,10,14,7,16,6,18,6,20,7,21,10,21,12]}; -},{}],391:[function(require,module,exports){ +},{}],392:[function(require,module,exports){ module.exports={vectorChar:require("./vectorChar"),vectorText:require("./vectorText")}; -},{"./vectorChar":392,"./vectorText":394}],392:[function(require,module,exports){ +},{"./vectorChar":393,"./vectorText":395}],393:[function(require,module,exports){ const vectorParams=require("./vectorParams"),vectorChar=(t,e)=>{const{xOffset:r,yOffset:s,input:h,font:o,height:c,extrudeOffset:n}=vectorParams(t,e);let a=h.charCodeAt(0);a&&o[a]||(a=63);const f=[].concat(o[a]),i=(c-n)/o.height,u=n/2,g=f.shift()*i,l=[];let v=[];for(let t=0,e=f.length;t{e||"string"!=typeof t||(t={input:t}),t=t||{};const s=Object.assign({},defaultsVectorParams,t);return s.input=e||s.input,s};module.exports=vectorParams; -},{"./fonts/single-line/hershey/simplex.js":390}],394:[function(require,module,exports){ +},{"./fonts/single-line/hershey/simplex.js":391}],395:[function(require,module,exports){ const vectorChar=require("./vectorChar"),vectorParams=require("./vectorParams"),translateLine=(t,e)=>{const{x:n,y:s}=Object.assign({x:0,y:0},t||{}),r=e.segments;let h=null,a=null;for(let t=0,e=r.length;t{const{xOffset:n,yOffset:s,input:r,font:h,height:a,align:o,extrudeOffset:i,lineSpacing:c,letterSpacing:g}=vectorParams(t,e);let l,f,m,x,u,d,[v,w]=[n,s],O={width:0,segments:[]};const p=[];let y=[],C=0;const L=v,P=()=>{p.push(O),C=Math.max(C,O.width),O={width:0,segments:[]}};for(l=0,f=r.length;lO.width&&(d=C-O.width,"right"===o?O=translateLine({x:d},O):"center"===o&&(O=translateLine({x:d/2},O))),y=y.concat(O.segments);return y};module.exports=vectorText; -},{"./vectorChar":392,"./vectorParams":393}],395:[function(require,module,exports){ +},{"./vectorChar":393,"./vectorParams":394}],396:[function(require,module,exports){ const geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),path2=require("../geometries/path2"),areAllShapesTheSameType=e=>{let r;for(const o of e){let e=0;if(geom2.isA(o)&&(e=1),geom3.isA(o)&&(e=2),path2.isA(o)&&(e=3),r&&e!==r)return!1;r=e}return!0};module.exports=areAllShapesTheSameType; -},{"../geometries/geom2":25,"../geometries/geom3":41,"../geometries/path2":62}],396:[function(require,module,exports){ +},{"../geometries/geom2":25,"../geometries/geom3":41,"../geometries/path2":62}],397:[function(require,module,exports){ const degToRad=d=>.017453292519943295*d;module.exports=degToRad; -},{}],397:[function(require,module,exports){ +},{}],398:[function(require,module,exports){ const flatten=t=>t.reduce((t,a)=>Array.isArray(a)?t.concat(flatten(a)):t.concat(a),[]);module.exports=flatten; -},{}],398:[function(require,module,exports){ +},{}],399:[function(require,module,exports){ const fnNumberSort=(o,r)=>o-r;module.exports=fnNumberSort; -},{}],399:[function(require,module,exports){ +},{}],400:[function(require,module,exports){ module.exports={areAllShapesTheSameType:require("./areAllShapesTheSameType"),degToRad:require("./degToRad"),flatten:require("./flatten"),fnNumberSort:require("./fnNumberSort"),insertSorted:require("./insertSorted"),radiusToSegments:require("./radiusToSegments"),radToDeg:require("./radToDeg")}; -},{"./areAllShapesTheSameType":395,"./degToRad":396,"./flatten":397,"./fnNumberSort":398,"./insertSorted":400,"./radToDeg":402,"./radiusToSegments":403}],400:[function(require,module,exports){ +},{"./areAllShapesTheSameType":396,"./degToRad":397,"./flatten":398,"./fnNumberSort":399,"./insertSorted":401,"./radToDeg":403,"./radiusToSegments":404}],401:[function(require,module,exports){ const insertSorted=(t,e,o)=>{let r=0,s=t.length;for(;s>r;){const l=Math.floor((r+s)/2);o(e,t[l])>0?r=l+1:s=l}t.splice(r,0,e)};module.exports=insertSorted; -},{}],401:[function(require,module,exports){ +},{}],402:[function(require,module,exports){ const padArrayToLength=(r,e,o)=>{for(r=r.slice();r.length57.29577951308232*o;module.exports=radToDeg; -},{}],403:[function(require,module,exports){ +},{}],404:[function(require,module,exports){ const{TAU:TAU}=require("../maths/constants"),radiusToSegments=(t,e,s)=>{const a=e>0?t*TAU/e:0,n=s>0?TAU/s:0;return Math.ceil(Math.max(a,n,4))};module.exports=radiusToSegments; },{"../maths/constants":94}]},{},[92])(92) diff --git a/packages/modeling/package.json b/packages/modeling/package.json index 7c7e7a963..ec2ec7ef7 100644 --- a/packages/modeling/package.json +++ b/packages/modeling/package.json @@ -1,6 +1,6 @@ { "name": "@jscad/modeling", - "version": "2.12.2", + "version": "2.12.3", "description": "Constructive Solid Geometry (CSG) Library for JSCAD", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", diff --git a/packages/utils/regl-renderer/CHANGELOG.md b/packages/utils/regl-renderer/CHANGELOG.md index 9097be20e..15a5a6057 100644 --- a/packages/utils/regl-renderer/CHANGELOG.md +++ b/packages/utils/regl-renderer/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.6.10](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/regl-renderer@2.6.9...@jscad/regl-renderer@2.6.10) (2024-10-06) + +**Note:** Version bump only for package @jscad/regl-renderer + + + + + ## [2.6.9](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/regl-renderer@2.6.8...@jscad/regl-renderer@2.6.9) (2024-06-02) **Note:** Version bump only for package @jscad/regl-renderer diff --git a/packages/utils/regl-renderer/package.json b/packages/utils/regl-renderer/package.json index e4f039773..e59dd528f 100644 --- a/packages/utils/regl-renderer/package.json +++ b/packages/utils/regl-renderer/package.json @@ -1,6 +1,6 @@ { "name": "@jscad/regl-renderer", - "version": "2.6.9", + "version": "2.6.10", "description": "Renderer for JSCAD Geometries", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -36,7 +36,7 @@ }, "devDependencies": { "@jscad/img-utils": "2.0.5", - "@jscad/modeling": "2.12.2", + "@jscad/modeling": "2.12.3", "ava": "3.15.0", "browserify": "16.5.1", "budo": "11.6.4", diff --git a/packages/vtree/CHANGELOG.md b/packages/vtree/CHANGELOG.md index 7a80bcbce..a7c7d1abd 100644 --- a/packages/vtree/CHANGELOG.md +++ b/packages/vtree/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.0.29](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/vtree@2.0.28...@jscad/vtree@2.0.29) (2024-10-06) + +**Note:** Version bump only for package @jscad/vtree + + + + + ## [2.0.28](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/vtree@2.0.27...@jscad/vtree@2.0.28) (2024-06-02) **Note:** Version bump only for package @jscad/vtree diff --git a/packages/vtree/package.json b/packages/vtree/package.json index daaa9d7e0..b4f14f4cd 100644 --- a/packages/vtree/package.json +++ b/packages/vtree/package.json @@ -1,6 +1,6 @@ { "name": "@jscad/vtree", - "version": "2.0.28", + "version": "2.0.29", "description": "Experimental Object Caching for JSCAD", "main": "index.js", "scripts": { @@ -19,12 +19,12 @@ }, "dependencies": { "@jscad/array-utils": "2.1.4", - "@jscad/modeling": "2.12.2", + "@jscad/modeling": "2.12.3", "object-hash": "2.0.3" }, "devDependencies": { - "@jscad/io-utils": "2.0.27", - "@jscad/stl-serializer": "2.1.17", + "@jscad/io-utils": "2.0.28", + "@jscad/stl-serializer": "2.1.18", "decache": "4.4.0", "just-diff": "2.1.1", "serialize-to-js": "3.0.2", diff --git a/packages/web/CHANGELOG.md b/packages/web/CHANGELOG.md index d31bb4ed3..58fcbd1cc 100644 --- a/packages/web/CHANGELOG.md +++ b/packages/web/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.6.8](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/web@2.6.7...@jscad/web@2.6.8) (2024-10-06) + +**Note:** Version bump only for package @jscad/web + + + + + ## [2.6.7](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/web@2.6.6...@jscad/web@2.6.7) (2024-06-02) **Note:** Version bump only for package @jscad/web diff --git a/packages/web/dist/jscad-web.min.js b/packages/web/dist/jscad-web.min.js index e3cda914f..7c495b4cb 100644 --- a/packages/web/dist/jscad-web.min.js +++ b/packages/web/dist/jscad-web.min.js @@ -7,7 +7,7 @@ },{}],3:[function(require,module,exports){ module.exports={ "name": "@jscad/core", - "version": "2.6.9", + "version": "2.6.10", "description": "Core functionality for JSCAD Applications", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -43,9 +43,9 @@ module.exports={ "license": "MIT", "dependencies": { "@jscad/array-utils": "2.1.4", - "@jscad/io": "2.4.8", - "@jscad/io-utils": "2.0.27", - "@jscad/modeling": "2.12.2", + "@jscad/io": "2.4.9", + "@jscad/io-utils": "2.0.28", + "@jscad/modeling": "2.12.3", "json5": "2.2.3", "strip-bom": "4.0.0" }, @@ -69,13 +69,13 @@ module.exports={rebuildGeometry:require("./rebuildGeometry"),rebuildGeometryCli: },{"./rebuildGeometry":6,"./rebuildGeometryCli":7,"./rebuildGeometryWorker":8,"./serializeSolids":9}],5:[function(require,module,exports){ const isGeom2=require("@jscad/modeling").geometries.geom2.isA,isGeom3=require("@jscad/modeling").geometries.geom3.isA,isPath2=require("@jscad/modeling").geometries.path2.isA,{flatten:flatten,toArray:toArray}=require("@jscad/array-utils"),serializeSolids=require("./serializeSolids"),isResultGeometry=e=>!!(Array.isArray(e)&&e.length>0)&&e.reduce((e,i)=>e||isGeom3(i)||isGeom2(i)||isPath2(i),!1),instanciateDesign=(e,i,r)=>{const{serialize:s}=r;let t;const o=flatten(toArray(e.main(i)));if(isResultGeometry(o))return{solids:t=s?serializeSolids(o):o};throw new Error("bad output from script: expected geom3/geom2/path2 objects")};module.exports=instanciateDesign; -},{"./serializeSolids":9,"@jscad/array-utils":526,"@jscad/modeling":211}],6:[function(require,module,exports){ +},{"./serializeSolids":9,"@jscad/array-utils":527,"@jscad/modeling":211}],6:[function(require,module,exports){ const loadDesign=require("../code-loading/loadDesign"),instanciateDesign=require("./instanciateDesign"),applyParameterDefinitions=require("../parameters/applyParameterDefinitions"),rebuildSolids=(e,a)=>{let{mainPath:i,apiMainPath:n,serialize:s,lookup:o,lookupCounts:r,parameterValues:l}=Object.assign({},{mainPath:"",apiMainPath:"@jscad/modeling",serialize:!1,lookup:null,lookupCounts:null,parameterValues:{}},e);try{const t=e.filesAndFolders,u=loadDesign(i,n,t,l);a(null,{type:"params",parameterDefaults:u.parameterValues,parameterDefinitions:u.parameterDefinitions}),l=applyParameterDefinitions(l,u.parameterDefinitions),l=Object.assign({},u.parameterValues,l);const m={lookup:o,lookupCounts:r,serialize:s},p=instanciateDesign(u.rootModule,l,m);a(null,{type:"solids",solids:p.solids,lookup:p.lookup,lookupCounts:p.lookupCounts})}catch(e){a({type:"errors",name:e.name?e.name:"Error",message:e.message?e.message:e.toString(),description:e.description?e.description:"",number:e.number?e.number:"",fileName:e.fileName?e.fileName:"",lineNumber:e.lineNumber?e.lineNumber:"",columnNumber:e.columnNumber?e.columnNumber:"",stack:e.stack?e.stack:""},null)}};module.exports=rebuildSolids; },{"../code-loading/loadDesign":11,"../parameters/applyParameterDefinitions":22,"./instanciateDesign":5}],7:[function(require,module,exports){ const path=require("path"),{toArray:toArray}=require("@jscad/array-utils"),requireDesignFromModule=require("../code-loading/requireDesignFromModule"),getAllParameterDefintionsAndValues=require("../parameters/getParameterDefinitionsAndValues"),makeWebRequire=require("../code-loading/webRequire"),rebuildSolids=e=>{let{apiMainPath:r,mainPath:a,parameterValues:i,useFakeFs:t}=Object.assign({},{apiMainPath:"@jscad/modeling"},e),s=require;if(t){const i=path.parse(a),t=`${i.name}.js`,u=`/${i.name}.js`,n=[{ext:"js",fullPath:u,name:t,source:e.source}];s=makeWebRequire(n,{apiMainPath:r}),a=u}const u=requireDesignFromModule(a,s),n=getAllParameterDefintionsAndValues(u,i);return toArray(u.main(n.parameterValues))};module.exports=rebuildSolids; -},{"../code-loading/requireDesignFromModule":14,"../code-loading/webRequire":18,"../parameters/getParameterDefinitionsAndValues":23,"@jscad/array-utils":526,"path":712}],8:[function(require,module,exports){ +},{"../code-loading/requireDesignFromModule":14,"../code-loading/webRequire":18,"../parameters/getParameterDefinitionsAndValues":23,"@jscad/array-utils":527,"path":713}],8:[function(require,module,exports){ const rebuildGeometryWorker=e=>{const o=require("./rebuildGeometry");e.onmessage=function(t){if(t.data instanceof Object){const{data:r}=t;"generate"===r.cmd&&o(r,(o,t)=>{t&&e.postMessage(t),o&&e.postMessage(o)})}}};module.exports=rebuildGeometryWorker; },{"./rebuildGeometry":6}],9:[function(require,module,exports){ @@ -99,7 +99,7 @@ const validateDesignModule=require("./validateDesignModule"),normalizeDesignModu },{"./normalizeDesignModule":13,"./validateDesignModule":17}],15:[function(require,module,exports){ const path=require("path"),{toArray:toArray}=require("@jscad/array-utils"),splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^/]+?|)(\.[^./]*|))(?:[/]*)$/,splitPath=e=>splitPathRe.exec(e).slice(1),parsePath=e=>{assertPath(e);const t=splitPath(e);if(!t||4!==t.length)throw new TypeError("Invalid path '"+e+"'");return t[1]=t[1]||"",t[2]=t[2]||"",t[3]=t[3]||"",{root:t[0],dir:t[0]+t[1].slice(0,t[1].length-1),base:t[2],ext:t[3],name:t[2].slice(0,t[2].length-t[3].length)}},assertPath=e=>{if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+e)},getDesignEntryPoint=(e,t)=>{if(!t)return;const a=toArray(t)[0];let r;const n=e.statSync(a);if(n.isFile())return a;if(n.isDirectory()){const t=path.join(a,"package.json");if(e.existsSync(t)){const r=JSON.parse(e.readFileSync(t)).main;if(r)return path.join(a,r)}const n=e.readdirSync(a),i=["main","index",parsePath(path.basename(a)).name],s=i.map(e=>e+".js"),o=i.map(e=>e+".jscad"),c=n.filter(e=>s.concat(o).includes(e));return c.length>0&&(r=path.join(a,c[0])),r}return a},packageNameFromDir=(e,t,a)=>{const r=path.join(t,"package.json");if(e.existsSync(r)){const t=JSON.parse(e.readFileSync(r)).name;if(t)return t}return a?parsePath(path.basename(a)).name:path.basename(t)},getDesignName=(e,t)=>{if(!t)return"undefined";const a=toArray(t)[0],r=e.statSync(a);if(r.isFile()){const t=path.dirname(a);return packageNameFromDir(e,t,a)}return r.isDirectory()?packageNameFromDir(e,a):void 0};module.exports={getDesignEntryPoint:getDesignEntryPoint,getDesignName:getDesignName}; -},{"@jscad/array-utils":526,"path":712}],16:[function(require,module,exports){ +},{"@jscad/array-utils":527,"path":713}],16:[function(require,module,exports){ const{deserializers:deserializers}=require("@jscad/io"),modulifyTransform=(e,r)=>Object.assign({},r,{source:r.source}),createJscadEntry=(e,r)=>{const s=e.name.substring(0,e.name.lastIndexOf(".")+1)+"jscad",t="/"+s;return Object.assign({},e,{ext:"jscad",name:s,fullPath:t,source:r})},transformSources=(e,r)=>{if(r&&r.length>1)return r;const s={js:[modulifyTransform],jscad:[modulifyTransform]};return r&&(r=r.map(r=>(r=>{if(r.source&&r.ext){const t=Object.assign({},e,{filename:r.name,output:"script"});if(r.ext in deserializers){const e=(0,deserializers[r.ext])(t,r.source);return createJscadEntry(r,e)}if(r.ext in s)return s[r.ext].reduce((e,r)=>r(t,e),r)}return r})(r))),r};module.exports=transformSources; },{"@jscad/io":69}],17:[function(require,module,exports){ @@ -108,7 +108,7 @@ const validateDesignModule=n=>{if(!n)throw new Error("undefined root module pass },{}],18:[function(require,module,exports){ const path=require("path"),posix=path.posix?path.posix:path,getFileExtensionFromString=require("../utils/getFileExtensionFromString"),{combineParameterDefinitions:combineParameterDefinitions,getParameterDefinitionsFromSource:getParameterDefinitionsFromSource}=require("../parameters/getParameterDefinitionsFromSource"),findMatch=(e,t)=>{for(let r=0;r{const r=require("strip-bom");t.extensions[".js"]=((t,n)=>{const i=e.readFileSync(n,"utf8");t._compile(r(i),n)})},registerJsonExtension=(e,t)=>{t.extensions[".json"]=((t,r)=>{const n=e.readFileSync(r,"utf8");t.exports=JSON.parse(n)})},makeWebRequire=(e,t)=>{const r={apiMainPath:"@jscad/modeling",fakeFs:require("./makeFakeFs")(e)},{apiMainPath:n,fakeFs:i}=Object.assign({},r,t),s="@jscad/modeling"===n?require("@jscad/modeling"):require(n),o={"@jscad/io":{exports:require("@jscad/io")},"@jscad/array-utils":{exports:require("@jscad/array-utils")},"@jscad/modeling":{exports:s},fs:{exports:i}},a={},l={},u=(t,r)=>{const n=o[r];if(n)return n.exports;t&&!r.startsWith("/")||(t="/");const i=t=>{let r=getFileExtensionFromString(t);r||(r="js",t+=".js"),r="."+r;const n=findMatch(t,e);if(!n)return null;if(n.children)return null;if(a[r]){if(l[t])return l[t];const e={exports:{},_compile:(t,r)=>{try{new Function("require","module",t)(u.bind(null,n.fullPath),e)}catch(e){const t=e.message;r=r.replace("/","");const n=e.lineNumber?e.lineNumber-2:0,i=e.columnNumber?e.columnNumber:0;throw e.stack.startsWith("Object")?e.stack=`${e.stack}\nObject. (${r}:${n}:${i})`:((e=new SyntaxError(t,r,n)).columnNumber=i,e.stack=`Object. (${r}:${n}:${i})`),e}const i=t.includes("@jscad-params")?getParameterDefinitionsFromSource(t,r):[],s=e.exports.getParameterDefinitions;e.exports.getParameterDefinitions=(()=>combineParameterDefinitions(i,s&&s()||[]))}};return a[r](e,n.fullPath),l[t]=e.exports,l[t]}return null},s=t=>{if(!findMatch(t,e))return null;"/"===t&&(t="");let r=t+"/index.js",n=i(r);return n||((n=i(r=t+"/index.json"))||null)},c=t=>{let r,n=findMatch(t,e);if(!n)return null;if(!n.children)return null;if(n=findMatch(t+"/package.json",e)){const e=JSON.parse(n.source).main;if(e){const n=posix.normalize(t+"/"+e);return(r=i(n))?r:(r=s(n))||null}}return(r=s(t))||null};if(r.startsWith("./")||r.startsWith("/")||r.startsWith("../")){r=posix.normalize(posix.dirname(t)+posix.sep+r);let e=i(r);if(e)return e;if(e=c(r))return e;throw new Error(`Cannot find relative path to module ${r}`)}const m=((e,t)=>{const r=(e=>{const t=e.split("/"),r=[];for(let e=t.length-1;e>0;e--){if("node_modules"===t[e])continue;const n=posix.sep+posix.join(...t.slice(1,e+1),"node_modules");r.push(n)}return r})(t);for(let t=0;t{}),registerJsExtension(i,c),registerJsonExtension(i,c),c};module.exports=makeWebRequire; -},{"../parameters/getParameterDefinitionsFromSource":24,"../utils/getFileExtensionFromString":28,"./makeFakeFs":12,"@jscad/array-utils":526,"@jscad/io":69,"@jscad/modeling":211,"path":712,"strip-bom":2}],19:[function(require,module,exports){ +},{"../parameters/getParameterDefinitionsFromSource":24,"../utils/getFileExtensionFromString":28,"./makeFakeFs":12,"@jscad/array-utils":527,"@jscad/io":69,"@jscad/modeling":211,"path":713,"strip-bom":2}],19:[function(require,module,exports){ module.exports={evaluation:require("./code-evaluation"),io:require("./io"),loading:require("./code-loading"),parameters:require("./parameters"),utils:require("./utils"),web:require("./web")}; },{"./code-evaluation":4,"./code-loading":10,"./io":20,"./parameters":27,"./utils":29,"./web":31}],20:[function(require,module,exports){ @@ -150,7 +150,7 @@ module.exports={walkFileTree:require("./walkFileTree")}; },{"./walkFileTree":32}],32:[function(require,module,exports){ const{flatten:flatten}=require("@jscad/array-utils"),{formats:formats}=require("@jscad/io/formats"),getFileExtensionFromString=require("../utils/getFileExtensionFromString"),binaryMimetypes={bmp:"image/bmp",gif:"image/gif",jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",tif:"image/tiff",tiff:"image/tiff",otc:"font/otf",otf:"font/otf",ttc:"font/ttf",ttf:"font/ttf",woff:"font/woff",woff2:"font/woff",stl:"application/sla"},readFileAsync=(e,t)=>{const r=e.fullPath?e.fullPath:t.fullPath?t.fullPath:"",i=getFileExtensionFromString(e.name),n=e.mimetype;return new Promise((t,s)=>{const o=new FileReader;o.onload=(s=>{const o=s.target.result;o.byteLength?t({name:e.name,ext:i,fullPath:r,mimetype:n,source:o}):"string"==typeof o&&t({name:e.name,ext:i,fullPath:r,mimetype:n,source:o})}),o.onerror=(e=>{s(new Error(`Failed to load file: ${r} [${o.error}]`))}),binaryMimetypes[i]?o.readAsArrayBuffer(e):o.readAsText(e)})},isSupportedFormat=e=>{const t=getFileExtensionFromString(e.name),r=formats[t]?formats[t].mimetype:binaryMimetypes[t];return e.mimetype=e.type&&e.type.length?e.type:r,e.mimetype&&e.mimetype.length},pseudoArraytoArray=e=>{const t=[];for(let r=0;rnull!=e,processEntries=e=>{const t=pseudoArraytoArray(e.filter(isEmpty)).filter(isEmpty).reduce((e,t)=>{if(t.name.startsWith("."))return e;if(t.isFile)e.push(processFile(t));else if(t.isDirectory)e.push(processDirectory(t));else if(t instanceof File){const r=t.webkitRelativePath?t.webkitRelativePath:void 0,i=isSupportedFormat(t)?readFileAsync(t,{fullPath:r}):void 0;if(!i)throw new Error("Unsuported format (or folder in Safari)!");e.push(i)}return e},[]);return Promise.all(t).then(e=>e.filter(e=>null!=e))},processFile=e=>{return new Promise((t,r)=>{e.file(r=>{isSupportedFormat(r)?t(readFileAsync(r,e)):t(void 0)},t=>{const i=`${t.message} (${t.code})`;r(new Error(`Failed to load file: ${e.fullPath} [${i}]`))})})},processDirectory=e=>{return new Promise((t,r)=>{if(e.entries)e.entries.length?processEntries(e.entries).then(t):t([]);else{e.createReader().readEntries(e=>{e.length?processEntries(e).then(t):t([])},r)}}).then(flatten).then(t=>({children:t=t.map(t=>(t.fullPath.startsWith("/")||(t.fullPath=e.fullPath+"/"+t.name),t)),fullPath:e.fullPath,name:e.name}))},transformFileList=e=>{const t=require("path");if(1===e.length){const r=e[0],i=r.webkitRelativePath?r.webkitRelativePath:r.name;if(i.split(t.sep).length<2){const e=t.sep,n={fullPath:e,name:e,isDirectory:!0,entries:[]};return r.fullPath=t.normalize(e+i),n.entries.push(r),[n]}}let r;const i=new Map,n=(e,n)=>{if(!i.has(e)){const s={fullPath:e,name:n,isDirectory:!0,entries:[]};r||(r=s),i.set(e,s);const o=e.split(t.sep);if(o.length>1){const e=t.sep+t.join(...o.slice(0,-1)),r=i.get(e);r&&r.entries.push(s)}}};for(let r=0;re||t.startsWith("."),!1))continue;if(!isSupportedFormat(s))continue;const l=o.slice(0,-1);for(let e=0;e{let t=e;return e.length&&e[0]instanceof File&&(t=transformFileList(e)),processEntries(t)};module.exports=walkFileTree; -},{"../utils/getFileExtensionFromString":28,"@jscad/array-utils":526,"@jscad/io/formats":68,"path":712}],33:[function(require,module,exports){ +},{"../utils/getFileExtensionFromString":28,"@jscad/array-utils":527,"@jscad/io/formats":68,"path":713}],33:[function(require,module,exports){ "use strict";var node_worker_1=require("./node-worker.cjs"),u8=Uint8Array,u16=Uint16Array,u32=Uint32Array,fleb=new u8([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),fdeb=new u8([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),clim=new u8([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),freb=function(t,n){for(var e=new u16(31),r=0;r<31;++r)e[r]=n+=1<>>1|(21845&i)<<1;x=(61680&(x=(52428&x)>>>2|(13107&x)<<2))>>>4|(3855&x)<<4,rev[i]=((65280&x)>>>8|(255&x)<<8)>>>1}var hMap=function(t,n,e){for(var r=t.length,i=0,s=new u16(n);i>>f]=u}else for(o=new u16(r),i=0;i>>15-t[i]);return o},flt=new u8(288);for(i=0;i<144;++i)flt[i]=8;for(i=144;i<256;++i)flt[i]=9;for(i=256;i<280;++i)flt[i]=7;for(i=280;i<288;++i)flt[i]=8;var fdt=new u8(32);for(i=0;i<32;++i)fdt[i]=5;var flm=hMap(flt,9,0),flrm=hMap(flt,9,1),fdm=hMap(fdt,5,0),fdrm=hMap(fdt,5,1),max=function(t){for(var n=t[0],e=1;en&&(n=t[e]);return n},bits=function(t,n,e){var r=n/8|0;return(t[r]|t[r+1]<<8)>>(7&n)&e},bits16=function(t,n){var e=n/8|0;return(t[e]|t[e+1]<<8|t[e+2]<<16)>>(7&n)},shft=function(t){return(t+7)/8|0},slc=function(t,n,e){(null==n||n<0)&&(n=0),(null==e||e>t.length)&&(e=t.length);var r=new(2==t.BYTES_PER_ELEMENT?u16:4==t.BYTES_PER_ELEMENT?u32:u8)(e-n);return r.set(t.subarray(n,e)),r};exports.FlateErrorCode={UnexpectedEOF:0,InvalidBlockType:1,InvalidLengthLiteral:2,InvalidDistance:3,StreamFinished:4,NoStreamHandler:5,InvalidHeader:6,NoCallback:7,InvalidUTF8:8,ExtraFieldTooLong:9,InvalidDate:10,FilenameTooLong:11,StreamFinishing:12,InvalidZipData:13,UnknownCompressionMethod:14};var ec=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],err=function(t,n,e){var r=new Error(n||ec[t]);if(r.code=t,Error.captureStackTrace&&Error.captureStackTrace(r,err),!e)throw r;return r},inflt=function(t,n,e){var r=t.length;if(!r||e&&e.f&&!e.l)return n||new u8(0);var i=!n||e,s=!e||e.i;e||(e={}),n||(n=new u8(3*r));var o=function(t){var e=n.length;if(t>e){var r=new u8(Math.max(2*e,t));r.set(n),n=r}},a=e.f||0,f=e.p||0,u=e.b||0,l=e.l,c=e.d,h=e.m,p=e.n,v=8*r;do{if(!l){a=bits(t,f,1);var d=bits(t,f+1,3);if(f+=3,!d){var b=t[(A=shft(f)+4)-4]|t[A-3]<<8,y=A+b;if(y>r){s&&err(0);break}i&&o(u+b),n.set(t.subarray(A,y),u),e.b=u+=b,e.p=f=8*y,e.f=a;continue}if(1==d)l=flrm,c=fdrm,h=9,p=5;else if(2==d){var g=bits(t,f,31)+257,m=bits(t,f+10,15)+4,z=g+bits(t,f+5,31)+1;f+=14;for(var w=new u8(z),x=new u8(19),S=0;S>>4)<16)w[S++]=A;else{var I=0,M=0;for(16==A?(M=3+bits(t,f,3),f+=2,I=w[S-1]):17==A?(M=3+bits(t,f,7),f+=3):18==A&&(M=11+bits(t,f,127),f+=7);M--;)w[S++]=I}}var Z=w.subarray(0,g),C=w.subarray(g);h=max(Z),p=max(C),l=hMap(Z,h,1),c=hMap(C,p,1)}else err(1);if(f>v){s&&err(0);break}}i&&o(u+131072);for(var G=(1<>>4;if((f+=15&I)>v){s&&err(0);break}if(I||err(2),_<256)n[u++]=_;else{if(256==_){F=f,l=null;break}var P=_-254;if(_>264){var O=fleb[S=_-257];P=bits(t,f,(1<>>4;L||err(3),f+=15&L;C=fd[N];if(N>3){O=fdeb[N];C+=bits16(t,f)&(1<v){s&&err(0);break}i&&o(u+131072);for(var q=u+P;u>>8},wbits16=function(t,n,e){e<<=7&n;var r=n/8|0;t[r]|=e,t[r+1]|=e>>>8,t[r+2]|=e>>>16},hTree=function(t,n){for(var e=[],r=0;rh&&(h=s[r].s);var p=new u16(h+1),v=ln(e[l-1],p,0);if(v>n){r=0;var d=0,b=v-n,y=1<n))break;d+=y-(1<>>=b;d>0;){var m=s[r].s;p[m]=0&&d;--r){var z=s[r].s;p[z]==n&&(--p[z],++d)}v=n}return[new u8(p),v]},ln=function(t,n,e){return-1==t.s?Math.max(ln(t.l,n,e+1),ln(t.r,n,e+1)):n[t.s]=e},lc=function(t){for(var n=t.length;n&&!t[--n];);for(var e=new u16(++n),r=0,i=t[0],s=1,o=function(t){e[r++]=t},a=1;a<=n;++a)if(t[a]==i&&a!=n)++s;else{if(!i&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(i),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(i);s=1,i=t[a]}return[e.subarray(0,r),n]},clen=function(t,n){for(var e=0,r=0;r>>8,t[i+2]=255^t[i],t[i+3]=255^t[i+1];for(var s=0;s4&&!T[clim[k-1]];--k);var I,M,Z,C,G=u+5<<3,E=clen(i,flt)+clen(s,fdt)+o,F=clen(i,h)+clen(s,d)+o+14+3*k+clen(S,T)+(2*S[16]+3*S[17]+7*S[18]);if(G<=E&&G<=F)return wfblk(n,l,t.subarray(f,f+u));if(wbits(n,l,1+(F15&&(wbits(n,l,L[U]>>>5&127),l+=L[U]>>>12)}}}else I=flm,M=flt,Z=fdm,C=fdt;for(U=0;U255){N=r[U]>>>18&31;wbits16(n,l,I[N+257]),l+=M[N+257],N>7&&(wbits(n,l,r[U]>>>23&31),l+=fleb[N]);var q=31&r[U];wbits16(n,l,Z[q]),l+=C[q],q>3&&(wbits16(n,l,r[U]>>>5&8191),l+=fdeb[q])}else wbits16(n,l,I[r[U]]),l+=M[r[U]];return wbits16(n,l,I[256]),l+M[256]},deo=new u32([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),et=new u8(0),dflt=function(t,n,e,r,i,s){var o=t.length,a=new u8(r+o+5*(1+Math.ceil(o/7e3))+i),f=a.subarray(r,a.length-i),u=0;if(!n||o<8)for(var l=0;l<=o;l+=65535){var c=l+65535;c>=o&&(f[u>>3]=s),u=wfblk(f,u+1,t.subarray(l,c))}else{for(var h=deo[n-1],p=h>>>13,v=8191&h,d=(1<7e3||T>24576)&&C>423){u=wblk(t,f,0,w,x,S,D,T,k,l-k,u),T=U=D=0,k=l;for(var G=0;G<286;++G)x[G]=0;for(G=0;G<30;++G)S[G]=0}var E=2,F=0,_=v,P=M-Z&32767;if(C>2&&I==z(l-P))for(var O=Math.min(p,C)-1,L=Math.min(32767,l),N=Math.min(258,C);P<=L&&--_&&M!=Z;){if(t[l+E]==t[l+E-P]){for(var q=0;qE){if(E=q,F=P,q>O)break;var B=Math.min(P,q-2),H=0;for(G=0;GH&&(H=j,Z=Y)}}}P+=(M=Z)-(Z=b[M])+32768&32767}if(F){w[T++]=268435456|revfl[E]<<18|revfd[F];var R=31&revfl[E],J=31&revfd[F];D+=fleb[R]+fdeb[J],++x[257+R],++S[J],A=l+E,++U}else w[T++]=t[l],++x[t[l]]}}u=wblk(t,f,s,w,x,S,D,T,k,l-k,u),!s&&7&u&&(u=wfblk(f,u+1,et))}return slc(a,0,r+shft(u)+i)},crct=function(){for(var t=new Int32Array(256),n=0;n<256;++n){for(var e=n,r=9;--r;)e=(1&e&&-306674912)^e>>>1;t[n]=e}return t}(),crc=function(){var t=-1;return{p:function(n){for(var e=t,r=0;r>>8;t=e},d:function(){return~t}}},adler=function(){var t=1,n=0;return{p:function(e){for(var r=t,i=n,s=0|e.length,o=0;o!=s;){for(var a=Math.min(o+2655,s);o>16),i=(65535&i)+15*(i>>16)}t=r,n=i},d:function(){return(255&(t%=65521))<<24|t>>>8<<16|(255&(n%=65521))<<8|n>>>8}}},dopt=function(t,n,e,r,i){return dflt(t,null==n.level?6:n.level,null==n.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):12+n.mem,e,r,!i)},mrg=function(t,n){var e={};for(var r in t)e[r]=t[r];for(var r in n)e[r]=n[r];return e},wcln=function(t,n,e){for(var r=t(),i=t.toString(),s=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/\s+/g,"").split(","),o=0;o>>0},b8=function(t,n){return b4(t,n)+4294967296*b4(t,n+4)},wbytes=function(t,n,e){for(;e;++n)t[n]=e,e>>>=8},gzh=function(t,n){var e=n.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=n.level<2?4:9==n.level?2:0,t[9]=3,0!=n.mtime&&wbytes(t,4,Math.floor(new Date(n.mtime||Date.now())/1e3)),e){t[3]=8;for(var r=0;r<=e.length;++r)t[r+10]=e.charCodeAt(r)}},gzs=function(t){31==t[0]&&139==t[1]&&8==t[2]||err(6,"invalid gzip data");var n=t[3],e=10;4&n&&(e+=t[10]|2+(t[11]<<8));for(var r=(n>>3&1)+(n>>4&1);r>0;r-=!t[e++]);return e+(2&n)},gzl=function(t){var n=t.length;return(t[n-4]|t[n-3]<<8|t[n-2]<<16|t[n-1]<<24)>>>0},gzhl=function(t){return 10+(t.filename&&t.filename.length+1||0)},zlh=function(t,n){var e=n.level,r=0==e?0:e<6?1:9==e?3:2;t[0]=120,t[1]=r<<6|(r?32-2*r:1)},zlv=function(t){(8!=(15&t[0])||t[0]>>>4>7||(t[0]<<8|t[1])%31)&&err(6,"invalid zlib data"),32&t[1]&&err(6,"invalid zlib data: preset dictionaries not supported")};function AsyncCmpStrm(t,n){return n||"function"!=typeof t||(n=t,t={}),this.ondata=n,t}var Deflate=function(){function t(t,n){n||"function"!=typeof t||(n=t,t={}),this.ondata=n,this.o=t||{}}return t.prototype.p=function(t,n){this.ondata(dopt(t,this.o,0,0,!n),n)},t.prototype.push=function(t,n){this.ondata||err(5),this.d&&err(4),this.d=n,this.p(t,n||!1)},t}();exports.Deflate=Deflate;var AsyncDeflate=function(){return function(t,n){astrmify([bDflt,function(){return[astrm,Deflate]}],this,AsyncCmpStrm.call(this,t,n),function(t){var n=new Deflate(t.data);onmessage=astrm(n)},6)}}();function deflate(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&err(7),cbify(t,n,[bDflt],function(t){return pbf(deflateSync(t.data[0],t.data[1]))},0,e)}function deflateSync(t,n){return dopt(t,n||{},0,0)}exports.AsyncDeflate=AsyncDeflate,exports.deflate=deflate,exports.deflateSync=deflateSync;var Inflate=function(){function t(t){this.s={},this.p=new u8(0),this.ondata=t}return t.prototype.e=function(t){this.ondata||err(5),this.d&&err(4);var n=this.p.length,e=new u8(n+t.length);e.set(this.p),e.set(t,n),this.p=e},t.prototype.c=function(t){this.d=this.s.i=t||!1;var n=this.s.b,e=inflt(this.p,this.o,this.s);this.ondata(slc(e,n,this.s.b),this.d),this.o=slc(e,this.s.b-32768),this.s.b=this.o.length,this.p=slc(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(t,n){this.e(t),this.c(n)},t}();exports.Inflate=Inflate;var AsyncInflate=function(){return function(t){this.ondata=t,astrmify([bInflt,function(){return[astrm,Inflate]}],this,0,function(){var t=new Inflate;onmessage=astrm(t)},7)}}();function inflate(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&err(7),cbify(t,n,[bInflt],function(t){return pbf(inflateSync(t.data[0],gu8(t.data[1])))},1,e)}function inflateSync(t,n){return inflt(t,n)}exports.AsyncInflate=AsyncInflate,exports.inflate=inflate,exports.inflateSync=inflateSync;var Gzip=function(){function t(t,n){this.c=crc(),this.l=0,this.v=1,Deflate.call(this,t,n)}return t.prototype.push=function(t,n){Deflate.prototype.push.call(this,t,n)},t.prototype.p=function(t,n){this.c.p(t),this.l+=t.length;var e=dopt(t,this.o,this.v&&gzhl(this.o),n&&8,!n);this.v&&(gzh(e,this.o),this.v=0),n&&(wbytes(e,e.length-8,this.c.d()),wbytes(e,e.length-4,this.l)),this.ondata(e,n)},t}();exports.Gzip=Gzip,exports.Compress=Gzip;var AsyncGzip=function(){return function(t,n){astrmify([bDflt,gze,function(){return[astrm,Deflate,Gzip]}],this,AsyncCmpStrm.call(this,t,n),function(t){var n=new Gzip(t.data);onmessage=astrm(n)},8)}}();function gzip(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&err(7),cbify(t,n,[bDflt,gze,function(){return[gzipSync]}],function(t){return pbf(gzipSync(t.data[0],t.data[1]))},2,e)}function gzipSync(t,n){n||(n={});var e=crc(),r=t.length;e.p(t);var i=dopt(t,n,gzhl(n),8),s=i.length;return gzh(i,n),wbytes(i,s-8,e.d()),wbytes(i,s-4,r),i}exports.AsyncGzip=AsyncGzip,exports.AsyncCompress=AsyncGzip,exports.gzip=gzip,exports.compress=gzip,exports.gzipSync=gzipSync,exports.compressSync=gzipSync;var Gunzip=function(){function t(t){this.v=1,Inflate.call(this,t)}return t.prototype.push=function(t,n){if(Inflate.prototype.e.call(this,t),this.v){var e=this.p.length>3?gzs(this.p):4;if(e>=this.p.length&&!n)return;this.p=this.p.subarray(e),this.v=0}n&&(this.p.length<8&&err(6,"invalid gzip data"),this.p=this.p.subarray(0,-8)),Inflate.prototype.c.call(this,n)},t}();exports.Gunzip=Gunzip;var AsyncGunzip=function(){return function(t){this.ondata=t,astrmify([bInflt,guze,function(){return[astrm,Inflate,Gunzip]}],this,0,function(){var t=new Gunzip;onmessage=astrm(t)},9)}}();function gunzip(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&err(7),cbify(t,n,[bInflt,guze,function(){return[gunzipSync]}],function(t){return pbf(gunzipSync(t.data[0]))},3,e)}function gunzipSync(t,n){return inflt(t.subarray(gzs(t),-8),n||new u8(gzl(t)))}exports.AsyncGunzip=AsyncGunzip,exports.gunzip=gunzip,exports.gunzipSync=gunzipSync;var Zlib=function(){function t(t,n){this.c=adler(),this.v=1,Deflate.call(this,t,n)}return t.prototype.push=function(t,n){Deflate.prototype.push.call(this,t,n)},t.prototype.p=function(t,n){this.c.p(t);var e=dopt(t,this.o,this.v&&2,n&&4,!n);this.v&&(zlh(e,this.o),this.v=0),n&&wbytes(e,e.length-4,this.c.d()),this.ondata(e,n)},t}();exports.Zlib=Zlib;var AsyncZlib=function(){return function(t,n){astrmify([bDflt,zle,function(){return[astrm,Deflate,Zlib]}],this,AsyncCmpStrm.call(this,t,n),function(t){var n=new Zlib(t.data);onmessage=astrm(n)},10)}}();function zlib(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&err(7),cbify(t,n,[bDflt,zle,function(){return[zlibSync]}],function(t){return pbf(zlibSync(t.data[0],t.data[1]))},4,e)}function zlibSync(t,n){n||(n={});var e=adler();e.p(t);var r=dopt(t,n,2,4);return zlh(r,n),wbytes(r,r.length-4,e.d()),r}exports.AsyncZlib=AsyncZlib,exports.zlib=zlib,exports.zlibSync=zlibSync;var Unzlib=function(){function t(t){this.v=1,Inflate.call(this,t)}return t.prototype.push=function(t,n){if(Inflate.prototype.e.call(this,t),this.v){if(this.p.length<2&&!n)return;this.p=this.p.subarray(2),this.v=0}n&&(this.p.length<4&&err(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),Inflate.prototype.c.call(this,n)},t}();exports.Unzlib=Unzlib;var AsyncUnzlib=function(){return function(t){this.ondata=t,astrmify([bInflt,zule,function(){return[astrm,Inflate,Unzlib]}],this,0,function(){var t=new Unzlib;onmessage=astrm(t)},11)}}();function unzlib(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&err(7),cbify(t,n,[bInflt,zule,function(){return[unzlibSync]}],function(t){return pbf(unzlibSync(t.data[0],gu8(t.data[1])))},5,e)}function unzlibSync(t,n){return inflt((zlv(t),t.subarray(2,-4)),n)}exports.AsyncUnzlib=AsyncUnzlib,exports.unzlib=unzlib,exports.unzlibSync=unzlibSync;var Decompress=function(){function t(t){this.G=Gunzip,this.I=Inflate,this.Z=Unzlib,this.ondata=t}return t.prototype.push=function(t,n){if(this.ondata||err(5),this.s)this.s.push(t,n);else{if(this.p&&this.p.length){var e=new u8(this.p.length+t.length);e.set(this.p),e.set(t,this.p.length)}else this.p=t;if(this.p.length>2){var r=this,i=function(){r.ondata.apply(r,arguments)};this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(i):8!=(15&this.p[0])||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(i):new this.Z(i),this.s.push(this.p,n),this.p=null}}},t}();exports.Decompress=Decompress;var AsyncDecompress=function(){function t(t){this.G=AsyncGunzip,this.I=AsyncInflate,this.Z=AsyncUnzlib,this.ondata=t}return t.prototype.push=function(t,n){Decompress.prototype.push.call(this,t,n)},t}();function decompress(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&err(7),31==t[0]&&139==t[1]&&8==t[2]?gunzip(t,n,e):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?inflate(t,n,e):unzlib(t,n,e)}function decompressSync(t,n){return 31==t[0]&&139==t[1]&&8==t[2]?gunzipSync(t,n):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?inflateSync(t,n):unzlibSync(t,n)}exports.AsyncDecompress=AsyncDecompress,exports.decompress=decompress,exports.decompressSync=decompressSync;var fltn=function(t,n,e,r){for(var i in t){var s=t[i],o=n+i,a=r;Array.isArray(s)&&(a=mrg(r,s[1]),s=s[0]),s instanceof u8?e[o]=[s,a]:(e[o+="/"]=[new u8(0),a],fltn(s,o,e,r))}},te="undefined"!=typeof TextEncoder&&new TextEncoder,td="undefined"!=typeof TextDecoder&&new TextDecoder,tds=0;try{td.decode(et,{stream:!0}),tds=1}catch(t){}var dutf8=function(t){for(var n="",e=0;;){var r=t[e++],i=(r>127)+(r>223)+(r>239);if(e+i>t.length)return[n,slc(t,e-1)];i?3==i?(r=((15&r)<<18|(63&t[e++])<<12|(63&t[e++])<<6|63&t[e++])-65536,n+=String.fromCharCode(55296|r>>10,56320|1023&r)):n+=1&i?String.fromCharCode((31&r)<<6|63&t[e++]):String.fromCharCode((15&r)<<12|(63&t[e++])<<6|63&t[e++]):n+=String.fromCharCode(r)}},DecodeUTF8=function(){function t(t){this.ondata=t,tds?this.t=new TextDecoder:this.p=et}return t.prototype.push=function(t,n){if(this.ondata||err(5),n=!!n,this.t)return this.ondata(this.t.decode(t,{stream:!0}),n),void(n&&(this.t.decode().length&&err(8),this.t=null));this.p||err(4);var e=new u8(this.p.length+t.length);e.set(this.p),e.set(t,this.p.length);var r=dutf8(e),i=r[0],s=r[1];n?(s.length&&err(8),this.p=null):this.p=s,this.ondata(i,n)},t}();exports.DecodeUTF8=DecodeUTF8;var EncodeUTF8=function(){function t(t){this.ondata=t}return t.prototype.push=function(t,n){this.ondata||err(5),this.d&&err(4),this.ondata(strToU8(t),this.d=n||!1)},t}();function strToU8(t,n){if(n){for(var e=new u8(t.length),r=0;r>1)),o=0,a=function(t){s[o++]=t};for(r=0;rs.length){var f=new u8(o+8+(i-r<<1));f.set(s),s=f}var u=t.charCodeAt(r);u<128||n?a(u):u<2048?(a(192|u>>6),a(128|63&u)):u>55295&&u<57344?(a(240|(u=65536+(1047552&u)|1023&t.charCodeAt(++r))>>18),a(128|u>>12&63),a(128|u>>6&63),a(128|63&u)):(a(224|u>>12),a(128|u>>6&63),a(128|63&u))}return slc(s,0,o)}function strFromU8(t,n){if(n){for(var e="",r=0;r65535&&err(9),n+=r+4}return n},wzh=function(t,n,e,r,i,s,o,a){var f=r.length,u=e.extra,l=a&&a.length,c=exfl(u);wbytes(t,n,null!=o?33639248:67324752),n+=4,null!=o&&(t[n++]=20,t[n++]=e.os),t[n]=20,n+=2,t[n++]=e.flag<<1|(null==s&&8),t[n++]=i&&8,t[n++]=255&e.compression,t[n++]=e.compression>>8;var h=new Date(null==e.mtime?Date.now():e.mtime),p=h.getFullYear()-1980;if((p<0||p>119)&&err(10),wbytes(t,n,p<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>>1),n+=4,null!=s&&(wbytes(t,n,e.crc),wbytes(t,n+4,s),wbytes(t,n+8,e.size)),wbytes(t,n+12,f),wbytes(t,n+14,c),n+=16,null!=o&&(wbytes(t,n,l),wbytes(t,n+6,e.attrs),wbytes(t,n+10,o),n+=14),t.set(r,n),n+=f,c)for(var v in u){var d=u[v],b=d.length;wbytes(t,n,+v),wbytes(t,n+2,b),t.set(d,n+4),n+=4+b}return l&&(t.set(a,n),n+=l),n},wzf=function(t,n,e,r,i){wbytes(t,n,101010256),wbytes(t,n+8,e),wbytes(t,n+10,e),wbytes(t,n+12,r),wbytes(t,n+16,i)},ZipPassThrough=function(){function t(t){this.filename=t,this.c=crc(),this.size=0,this.compression=0}return t.prototype.process=function(t,n){this.ondata(null,t,n)},t.prototype.push=function(t,n){this.ondata||err(5),this.c.p(t),this.size+=t.length,n&&(this.crc=this.c.d()),this.process(t,n||!1)},t}();exports.ZipPassThrough=ZipPassThrough;var ZipDeflate=function(){function t(t,n){var e=this;n||(n={}),ZipPassThrough.call(this,t),this.d=new Deflate(n,function(t,n){e.ondata(null,t,n)}),this.compression=8,this.flag=dbf(n.level)}return t.prototype.process=function(t,n){try{this.d.push(t,n)}catch(t){this.ondata(t,null,n)}},t.prototype.push=function(t,n){ZipPassThrough.prototype.push.call(this,t,n)},t}();exports.ZipDeflate=ZipDeflate;var AsyncZipDeflate=function(){function t(t,n){var e=this;n||(n={}),ZipPassThrough.call(this,t),this.d=new AsyncDeflate(n,function(t,n,r){e.ondata(t,n,r)}),this.compression=8,this.flag=dbf(n.level),this.terminate=this.d.terminate}return t.prototype.process=function(t,n){this.d.push(t,n)},t.prototype.push=function(t,n){ZipPassThrough.prototype.push.call(this,t,n)},t}();exports.AsyncZipDeflate=AsyncZipDeflate;var Zip=function(){function t(t){this.ondata=t,this.u=[],this.d=1}return t.prototype.add=function(t){var n=this;if(this.ondata||err(5),2&this.d)this.ondata(err(4+8*(1&this.d),0,1),null,!1);else{var e=strToU8(t.filename),r=e.length,i=t.comment,s=i&&strToU8(i),o=r!=t.filename.length||s&&i.length!=s.length,a=r+exfl(t.extra)+30;r>65535&&this.ondata(err(11,0,1),null,!1);var f=new u8(a);wzh(f,0,t,e,o);var u=[f],l=function(){for(var t=0,e=u;t65535&&U(err(11,0,1),null),S)if(b<16e4)try{U(null,deflateSync(f,v))}catch(t){U(t,null)}else l.push(deflate(f,v,U));else U(null,f)},d=0;d65535&&err(11);var b=l?deflateSync(f,u):f,y=b.length,g=crc();g.p(f),r.push(mrg(u,{size:f.length,crc:g.d(),c:b,f:S,m:p,u:c!=o.length||p&&h.length!=v,o:i,compression:l})),i+=30+c+d+y,s+=76+2*(c+d)+(v||0)+y}for(var m=new u8(s+22),z=i,w=s-i,x=0;x0){var r=Math.min(this.c,t.length),i=t.subarray(0,r);if(this.c-=r,this.d?this.d.push(i,!this.c):this.k[0].push(i),(t=t.subarray(r)).length)return this.push(t,n)}else{var s=0,o=0,a=void 0,f=void 0;this.p.length?t.length?((f=new u8(this.p.length+t.length)).set(this.p),f.set(t,this.p.length)):f=this.p:f=t;for(var u=f.length,l=this.c,c=l&&this.d,h=function(){var t,n=b4(f,o);if(67324752==n){s=1,a=o,p.d=null,p.c=0;var r=b2(f,o+6),i=b2(f,o+8),c=2048&r,h=8&r,v=b2(f,o+26),d=b2(f,o+28);if(u>o+30+v+d){var b=[];p.k.unshift(b),s=2;var y,g=b4(f,o+18),m=b4(f,o+22),z=strFromU8(f.subarray(o+30,o+=30+v),!c);4294967295==g?(t=h?[-2]:z64e(f,o),g=t[0],m=t[1]):h&&(g=-1),o+=d,p.c=g;var w={name:z,compression:i,start:function(){if(w.ondata||err(5),g){var t=e.o[i];t||w.ondata(err(14,"unknown compression type "+i,1),null,!1),(y=g<0?new t(z):new t(z,g,m)).ondata=function(t,n,e){w.ondata(t,n,e)};for(var n=0,r=b;n=0&&(w.size=g,w.originalSize=m),p.onfile(w)}return"break"}if(l){if(134695760==n)return a=o+=12+(-2==l&&8),s=3,p.c=0,"break";if(33639248==n)return a=o-=4,s=3,p.c=0,"break"}},p=this;o65558)return o(err(13,0,1),null),i;var f=b2(t,a+8);if(f){var u=f,l=b4(t,a+16),c=4294967295==l;if(c){if(a=b4(t,a-12),101075792!=b4(t,a))return o(err(13,0,1),null),i;u=f=b4(t,a+32),l=b4(t,a+48)}for(var h=n&&n.filter,p=function(n){var e=zh(t,l,c),a=e[0],u=e[1],p=e[2],v=e[3],d=e[4],b=e[5],y=slzh(t,b);l=d;var g=function(t,n){t?(i(),o(t,null)):(n&&(s[v]=n),--f||o(null,s))};if(!h||h({name:v,size:u,originalSize:p,compression:a}))if(a)if(8==a){var m=t.subarray(y,y+u);if(u<32e4)try{g(null,inflateSync(m,new u8(p)))}catch(t){g(t,null)}else r.push(inflate(m,{size:p},g))}else g(err(14,"unknown compression type "+a,1),null);else g(null,slc(t,y,y+u));else g(null,null)},v=0;v65558)&&err(13);var i=b2(t,r+8);if(!i)return{};var s=b4(t,r+16),o=4294967295==s;o&&(r=b4(t,r-12),101075792!=b4(t,r)&&err(13),i=b4(t,r+32),s=b4(t,r+48));for(var a=n&&n.filter,f=0;f{e=Object.assign({},{unit:"millimeter",metadata:!0,defaultcolor:[1,160/255,0,1],compress:!0},e);let o=(t=flatten(t)).filter(e=>geometries.geom3.isA(e));if(0===o.length)throw new Error("only 3D geometries can be serialized to 3MF");t.length!==o.length&&console.warn("some objects could not be serialized to 3MF"),t=toArray(modifiers.generalize({snap:!0,triangulate:!0},o));const r=["model",{unit:e.unit,"xml:lang":"und"},["metadata",{name:"Application"},"JSCAD"]];e.metadata&&r.push(["metadata",{name:"CreationDate"},(new Date).toISOString()]),r.push(translateResources(t,e)),r.push(translateBuild(t,e));const n=`\n${stringify(r,2)}`;if(e.compress){const e={"3D":{"3dmodel.model":strToU8(n)},_rels:{".rels":strToU8(rels)},"[Content_Types].xml":strToU8(contenttype)};return[zipSync(e,{comment:"created by JSCAD"}).buffer]}return[n]},contenttype='\n\n \n \n \n \n',rels='\n\n \n \n',translateResources=(e,t)=>{let o=["resources",{},translateMaterials(e,t)];return o=o.concat(translateObjects(e,t))},translateMaterials=(e,t)=>{let o=["basematerials",{id:"0"}];const r=[];return e.forEach((e,o)=>{let n=colors.rgbToHex(t.defaultcolor).toUpperCase();e.color&&(n=colors.rgbToHex(e.color).toUpperCase()),r.push(["base",{name:`mat${o}`,displaycolor:n}])}),o=o.concat(r)},translateObjects=(e,t)=>{const o=[];return e.forEach((e,r)=>{if(geometries.geom3.isA(e)){geometries.geom3.toPolygons(e).length>0&&(t.id=r,o.push(convertToObject(e,t)))}}),o},translateBuild=(e,t)=>{let o=["build",{}];const r=[];return e.forEach((e,t)=>{r.push(["item",{objectid:`${t+1}`}])}),o=o.concat(r)},convertToObject=(e,t)=>{const o=e.name?e.name:`Part ${t.id}`;return["object",{id:`${t.id+1}`,type:"model",pid:"0",pindex:`${t.id}`,name:o},convertToMesh(e,t)]},convertToMesh=(e,t)=>{return["mesh",{},convertToVertices(e,t),convertToVolumes(e,t)]},convertToVertices=(e,t)=>{const o=[];return geometries.geom3.toPolygons(e).forEach(e=>{for(let r=0;r{return["vertex",{x:e[0],y:e[1],z:e[2]}]},convertToVolumes=(e,t)=>{let o=0;const r=geometries.geom3.toPolygons(e);let n=["triangles",{}];return r.forEach(e=>{if(e.vertices.length<3)return;const t=convertToTriangles(e,o);n=n.concat(t),o+=e.vertices.length}),n},convertToTriangles=(e,t)=>{const o=[];for(let r=0;r=SPACE&&e<=55295||e===NL||e===CR||e===TAB||e>=57344&&e<=65533||e>=65536&&e<=1114111}function isS(e){return e===SPACE||e===NL||e===CR||e===TAB}function isNameStartChar(e){return e>=65&&e<=90||e>=97&&e<=122||58===e||95===e||8204===e||8205===e||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}function isNameChar(e){return isNameStartChar(e)||e>=48&&e<=57||45===e||46===e||183===e||e>=768&&e<=879||e>=8255&&e<=8256}exports.S_LIST=[SPACE,NL,CR,TAB],exports.isChar=isChar,exports.isS=isS,exports.isNameStartChar=isNameStartChar,exports.isNameChar=isNameChar; },{}],38:[function(require,module,exports){ @@ -177,7 +177,7 @@ const zipSync=require("fflate").zipSync,strToU8=require("fflate").strToU8,string },{"xmlchars/xml/1.0/ed5":37,"xmlchars/xml/1.1/ed2":38,"xmlchars/xmlns/1.0/ed3":39}],41:[function(require,module,exports){ module.exports={ "name": "@jscad/amf-deserializer", - "version": "2.3.7", + "version": "2.3.8", "description": "AMF Deserializer for JSCAD", "repository": "https://github.com/jscad/OpenJSCAD.org/", "main": "src/index.js", @@ -208,7 +208,7 @@ module.exports={ ], "license": "MIT", "dependencies": { - "@jscad/modeling": "2.12.2", + "@jscad/modeling": "2.12.3", "saxes": "5.0.1" }, "devDependencies": { @@ -242,7 +242,7 @@ const createObject=require("./objectBuilder"),parse=require("./parse"),translate },{"./constants":42,"./objectBuilder":46,"./parse":47}],49:[function(require,module,exports){ const stringify=require("onml/lib/stringify"),{geometries:geometries,modifiers:modifiers}=require("@jscad/modeling"),{flatten:flatten,toArray:toArray}=require("@jscad/array-utils"),mimeType="application/amf+xml",serialize=(e,...t)=>{e=Object.assign({},{statusCallback:null,unit:"millimeter"},e);let o=(t=flatten(t)).filter(e=>geometries.geom3.isA(e));if(0===o.length)throw new Error("only 3D geometries can be serialized to AMF");t.length!==o.length&&console.warn("some objects could not be serialized to AMF"),o=toArray(modifiers.generalize({snap:!0,triangulate:!0},o)),e.statusCallback&&e.statusCallback({progress:0});let r=["amf",{unit:e.unit,version:"1.1"},["metadata",{type:"author"},"Created by JSCAD"]];r=r.concat(translateObjects(o,e));const n=`\n${stringify(r,2)}`;return e&&e.statusCallback&&e.statusCallback({progress:100}),[n]},translateObjects=(e,t)=>{const o=[];return e.forEach((e,r)=>{geometries.geom3.toPolygons(e).length>0&&(t.id=r,o.push(convertToObject(e,t)))}),o},convertToObject=(e,t)=>{return["object",{id:t.id},convertToMesh(e,t)]},convertToMesh=(e,t)=>{let o=["mesh",{},convertToVertices(e,t)];return o=o.concat(convertToVolumes(e,t))},convertToVertices=(e,t)=>{const o=[];return geometries.geom3.toPolygons(e).forEach(e=>{for(let r=0;r{return["vertex",{},convertToCoordinates(e,t)]},convertToCoordinates=(e,t)=>{return["coordinates",{},["x",{},e[0]],["y",{},e[1]],["z",{},e[2]]]},convertToVolumes=(e,t)=>{const o=convertColor(e.color),r=geometries.geom3.toPolygons(e),n=[];let s=["volume",{}];o&&s.push(o);let l=0;return r.forEach(e=>{if(e.vertices.length<3)return;const o=convertToTriangles(e,l,t);s=s.concat(o),l+=e.vertices.length}),n.push(s),n},convertColor=e=>e?(e.length<4&&e.push(1),["color",{},["r",{},e[0]],["g",{},e[1]],["b",{},e[2]],["a",{},e[3]]]):null,convertToColor=(e,t)=>{const o=e.color;return convertColor(o)},convertToTriangles=(e,t,o)=>{const r=convertToColor(e),n=[];for(let o=0;ot&&"[object Object]"===Object.prototype.toString.call(t);function indenter(t){if(!(t>0))return t=>t;var e=" ".repeat(t);return t=>{if("string"!=typeof t)return t;const n=t.split("\n");return 1===n.length?e+t:n.map(t=>""===t.trim()?t:e+t).join("\n")}}const clean=t=>t.split("\n").filter(t=>""!==t.trim()).join("\n");function stringify(t,e){const n=e>0?"\n":"",r=indenter(e);return function t(e){let i,o="",s=!0;return e.some((e,r,c)=>{if(0===r)return i="<"+e,1===c.length;if(1===r){if(isObject(e))return Object.keys(e).map(t=>{let n=e[t];Array.isArray(n)&&(n=n.join(" ")),i+=" "+t+'="'+n+'"'}),2===c.length||void(i+=">");i+=">"}switch(typeof e){case"string":case"number":case"boolean":case"undefined":return void(o+=e+n)}s=!1,o+=t(e)})?i+"/>"+n:s?i+clean(o)+""+n:i+n+r(o)+""+n}(t)}module.exports=stringify; },{}],51:[function(require,module,exports){ @@ -266,7 +266,7 @@ const{geometries:geometries,maths:maths,primitives:primitives}=require("@jscad/m },{"./helpers":54,"@jscad/modeling":211}],57:[function(require,module,exports){ module.exports={ "name": "@jscad/dxf-deserializer", - "version": "2.3.24", + "version": "2.3.25", "description": "DXF Deserializer for JSCAD", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -294,7 +294,7 @@ module.exports={ ], "license": "MIT", "dependencies": { - "@jscad/modeling": "2.12.2" + "@jscad/modeling": "2.12.3" }, "devDependencies": { "ava": "3.15.0", @@ -315,7 +315,7 @@ const colorIndex=[[0,0,0,255],[255,0,0,255],[255,255,0,255],[0,255,0,255],[0,255 },{}],61:[function(require,module,exports){ const{geometries:geometries,modifiers:modifiers}=require("@jscad/modeling"),{geom3:geom3,geom2:geom2,path2:path2}=geometries,{flatten:flatten,toArray:toArray}=require("@jscad/array-utils"),{dxfHeaders:dxfHeaders,dxfClasses:dxfClasses,dxfTables:dxfTables,dxfBlocks:dxfBlocks,dxfObjects:dxfObjects}=require("./autocad_AC2017"),colorindex2017=require("./colorindex2017"),mimeType="application/dxf",serialize=(n,...e)=>{const t={geom2To:"lwpolyline",geom3To:"3dface",pathTo:"lwpolyline",statusCallback:null,colorIndex:colorindex2017};if((n=Object.assign({},t,n)).entityId=0,0===(e=(e=flatten(e)).filter(n=>geom3.isA(n)||geom2.isA(n)||path2.isA(n))).length)throw new Error("only JSCAD geometries can be serialized to DXF");return e=toArray(modifiers.generalize({snap:!0,triangulate:!0},e)),[`999\nCreated by JSCAD\n${dxfHeaders(n)}\n${dxfClasses(n)}\n${dxfTables(n)}\n${dxfBlocks(n)}\n${dxfEntities(e,n)}\n${dxfObjects(n)}\n 0\nEOF\n`]},dxfEntities=(n,e)=>{const t=n.map((n,t)=>{if(geom2.isA(n)){const t=n.color,o=n.name,s=geom2.toOutlines(n).map(n=>({closed:!0,points:n,color:t,name:o}));return"polyline"===e.geom2To?PathsToPolyine(s,e):PathsToLwpolyline(s,e)}if(geom3.isA(n))return"polyline"===e.geom3To?PolygonsToPolyline(n,e):PolygonsTo3DFaces(n,e);if(path2.isA(n)){const t=n.color,o=n.name,s={closed:n.isClosed,points:path2.toPoints(n),color:t,name:o};return PathsToLwpolyline([s],e)}return""});let o=" 0\nSECTION\n 2\nENTITIES\n";return t.forEach(n=>{n&&(o+=n)}),o+=" 0\nENDSEC"},PathsToLwpolyline=(n,e)=>{e.statusCallback&&e.statusCallback({progress:0});let t="";return n.forEach((o,s)=>{if(o.points.length<1)return;const l=o.points.length+(o.closed?1:0);t+=` 0\nLWPOLYLINE\n 5\n${getEntityId(e)}\n 100\nAcDbEntity\n 3\n${getName(o,e)}\n 8\n0\n 67\n0\n 62\n${getColorNumber(o,e)}\n 100\nAcDbPolyline\n 90\n${l}\n 70\n${o.closed?1:0}\n`;for(let n=0;n=o.points.length&&(e-=o.points.length);const s=o.points[e];t+=` 10\n${s[0]}\n 20\n${s[1]}\n`}e.statusCallback&&e.statusCallback({progress:100*s/n.length})}),e.statusCallback&&e.statusCallback({progress:100}),[t]},PathsToPolyine=(n,e)=>{e.statusCallback&&e.statusCallback({progress:0});let t="";return n.forEach((o,s)=>{const l=o.points.length+(o.closed?1:0);t+=` 0\nPOLYLINE\n 5\n${getEntityId(e)}\n 100\nAcDbEntity\n 3\n${getName(o,e)}\n 8\n0\n 62\n${getColorNumber(o,e)}\n 100\nAcDb2dPolyline\n`;for(let n=0;n=o.points.length&&(s-=o.points.length);const l=o.points[s];t+=` 0\nVERTEX\n 5\n${getEntityId(e)}\n 100\nAcDbEntity\n 8\n0\n 100\nAcDbVertex\n 100\nAcDb2dVertex\n 10\n${l[0]}\n 20\n${l[1]}\n`}t+=` 0\nSEQEND\n 5\n${getEntityId(e)}\n 100\nAcDbEntity\n`,e.statusCallback&&e.statusCallback({progress:100*s/n.length})}),e.statusCallback&&e.statusCallback({progress:100}),[t]},PolygonsTo3DFaces=(n,e)=>{e.statusCallback&&e.statusCallback({progress:0});let t="";const o=geom3.toPolygons(n),s=getColorNumber(n,e);return o.forEach((n,o)=>{const l=n.color?getColorNumber(n,e):s;polygonToTriangles(n).forEach((n,o)=>{t+=triangleTo3DFaces(n,e,l)})}),e.statusCallback&&e.statusCallback({progress:100}),[t]},polygonToTriangles=n=>{const e=n.vertices.length-2;if(e<1)return[];const t=n.vertices[0],o=[];for(let s=0;s{const o=n[0],s=n[1],l=n[2],r=n[2];return` 0\n3DFACE\n 5\n${getEntityId(e)}\n 100\nAcDbEntity\n 8\n0\n 62\n${t}\n 100\nAcDbFace\n 70\n0\n 10\n${o[0]}\n 20\n${o[1]}\n 30\n${o[2]}\n 11\n${s[0]}\n 21\n${s[1]}\n 31\n${s[2]}\n 12\n${l[0]}\n 22\n${l[1]}\n 32\n${l[2]}\n 13\n${r[0]}\n 23\n${r[1]}\n 33\n${r[2]}\n`},PolygonsToPolyline=(n,e)=>{let t="";const o=polygons2polyfaces(geom3.toPolygons(n));return o.faces.length>0&&(t+=` 0\nPOLYLINE\n 5\n${getEntityId(e)}\n 100\nAcDbEntity\n 3\n${getName(n,e)}\n 8\n0\n 62\n${getColorNumber(n,e)}\n 100\nAcDb3dPolyline\n 70\n64\n 71\n${o.vertices.length}\n 72\n${o.faces.length}\n`,o.vertices.forEach(n=>{t+=` 0\nVERTEX\n 5\n${getEntityId(e)}\n 100\nAcDbEntity\n 8\n0\n 100\nAcDbVertex\n 100\nAcDb3dPolylineVertex\n 10\n${n[0]}\n 20\n${n[1]}\n 30\n${n[2]}\n 70\n192\n`}),o.faces.forEach(n=>{t+=` 0\nVERTEX\n 5\n${getEntityId(e)}\n 100\nAcDbEntity\n 8\n0\n 100\nAcDbVertex\n 100\nAcDb3dPolylineVertex\n 10\n0\n 20\n0\n 30\n0\n 70\n128\n 71\n${n[0]}\n 72\n${n[1]}\n 73\n${n[2]}\n 74\n${n[3]}\n`})),[t]},polygons2polyfaces=n=>{const e=[],t=[];for(let o=0;o{n.entityId++;const e="00000"+n.entityId.toString(16).toUpperCase();return"CAD"+e.substr(e.length-5)},getName=(n,e)=>{if(n.name)return n.name;const t="00000"+e.entityId.toString(16).toUpperCase();return"CAD"+t.substr(t.length-5)},getColorNumber=(n,e)=>{let t=256;if(n.color){const o=Math.floor(255*n.color[0]),s=Math.floor(255*n.color[1]),l=Math.floor(255*n.color[2]),r=e.colorIndex;let a=765;for(let n=1;n>3;this._checkSize(r);const i=Math.pow(2,e-1)-1,h=this._readBits(t+e,1,s),d=this._readBits(t,e,s);let o=0,n=2,_=0,a=0;do{const e=this._readByte(++_,s);let r=1<<(a=t%8||8);for(;r>>=1;)e&r&&(o+=1/n),n*=2}while(t-=a);return this._pos+=s,d===1+(i<<1)?o?NaN:h?-1/0:1/0:(1+-2*h)*(d||o?d?Math.pow(2,d-i)*(1+o):Math.pow(2,1-i)*o:0)}_decodeInt(t,e){const r=this._readBits(0,t,t/8),s=Math.pow(2,t),i=e&&r>=s/2?r-s:r;return this._pos+=t/8,i}_shl(t,e){for(++e;--e;t=1073741824==(1073741824&(t%=2147483648))?2*t:2*(t-1073741824)+2147483647+1);return t}_readByte(t,e){return 255&this._buffer.charCodeAt(this._pos+e-t-1)}_readBits(t,e,r){const s=(t+e)%8,i=t%8,h=r-(t>>3)-1;let d=r+(-(t+e)>>3),o=h-d,n=this._readByte(h,r)>>i&(1<<(o?8-i:e))-1;for(o&&s&&(n+=(this._readByte(d++,r)&(1<{"string"==typeof e?this.length+=e.length:e instanceof ArrayBuffer&&(this.length+=e.byteLength)}),t.type&&(this.type=t.type.toLowerCase()),t.endings,t.encoding&&(this.encoding=t.encoding.toLowerCase()),t.length&&(this.length=t.length),this.buffer=Buffer.allocUnsafe(this.length);for(let t=0;t{const{data:e,mimeType:l}=o;return new Blob(e,{type:l})};module.exports=convertToBlob; },{"./makeBlob":66}],65:[function(require,module,exports){ @@ -344,13 +344,13 @@ const{makeBlob:makeBlob,convertToBlob:convertToBlob}=require("@jscad/io-utils"), },{"./deserializers":67,"./prepareOutput":70,"@jscad/3mf-serializer":36,"@jscad/amf-serializer":49,"@jscad/dxf-serializer":61,"@jscad/io-utils":65,"@jscad/json-serializer":73,"@jscad/obj-serializer":76,"@jscad/stl-serializer":81,"@jscad/svg-serializer":93,"@jscad/x3d-serializer":119}],70:[function(require,module,exports){ const{toArray:toArray}=require("@jscad/array-utils"),{formats:formats}=require("./formats"),amfSerializer=require("@jscad/amf-serializer"),dxfSerializer=require("@jscad/dxf-serializer"),jsonSerializer=require("@jscad/json-serializer"),objSerializer=require("@jscad/obj-serializer"),stlSerializer=require("@jscad/stl-serializer"),svgSerializer=require("@jscad/svg-serializer"),x3dSerializer=require("@jscad/x3d-serializer"),m3fSerializer=require("@jscad/3mf-serializer"),prepareOutput=(e,r)=>{const i={format:void 0,version:"0.0.0"},{format:a,version:s}=Object.assign({},i,r),l={producer:"JSCAD "+s,date:new Date,version:s},t={amf:amfSerializer,stl:stlSerializer,stla:{mimeType:stlSerializer.mimeType,serialize:(e,r)=>stlSerializer.serialize(Object.assign({},{binary:!1},e),r)},stlb:stlSerializer,dxf:dxfSerializer,obj:objSerializer,svg:svgSerializer,x3d:x3dSerializer,"3mf":m3fSerializer,json:jsonSerializer,js:{mimeType:formats.js.mimetype,serialize:(e,r)=>toArray(r)},jscad:{mimeType:formats.jscad.mimetype,serialize:(e,r)=>toArray(r)},undefined:()=>{throw new Error("Not supported : only jscad, stl, amf, dxf, svg or json as output format")}},o=Object.assign({},l,r);return{data:t[a].serialize(o,e),mimeType:t[a].mimeType}};module.exports=prepareOutput; -},{"./formats":68,"@jscad/3mf-serializer":36,"@jscad/amf-serializer":49,"@jscad/array-utils":526,"@jscad/dxf-serializer":61,"@jscad/json-serializer":73,"@jscad/obj-serializer":76,"@jscad/stl-serializer":81,"@jscad/svg-serializer":93,"@jscad/x3d-serializer":119}],71:[function(require,module,exports){ +},{"./formats":68,"@jscad/3mf-serializer":36,"@jscad/amf-serializer":49,"@jscad/array-utils":527,"@jscad/dxf-serializer":61,"@jscad/json-serializer":73,"@jscad/obj-serializer":76,"@jscad/stl-serializer":81,"@jscad/svg-serializer":93,"@jscad/x3d-serializer":119}],71:[function(require,module,exports){ const{flatten:flatten,toArray:toArray}=require("@jscad/array-utils"),version=require("./package.json").version,deserialize=(e,t)=>{const n={filename:"json",output:"script",version:version,addMetaData:!0};e=Object.assign({},n,e);let r=JSON.parse(t);return r=flatten(toArray(r)),"script"===e.output?translate(e,r):r},translate=(e,t)=>{const{addMetaData:n,filename:r,version:s}=e;let a=n?`//\n// Produced by JSCAD IO Library : JSON Deserializer (${s})\n// date: ${new Date}\n// source: ${r}\n//\n`:"";return a+=`\nconst { geometries } = require('@jscad/modeling')\n\nconst main = () => {\n const objects = [${translateToList(t)} ]\n return objects\n}\n\n${translateToObjects(t)}\n\nmodule.exports = { main }\n`},translateToList=e=>e.reduce((e,t,n)=>e+` json${n},`,""),translateToObjects=e=>e.reduce((e,t,n)=>e+translateToObject(t,n),""),translateToObject=(e,t)=>`const json${t} = ${JSON.stringify(e)}\n`,extension="json";module.exports={deserialize:deserialize,extension:"json"}; -},{"./package.json":72,"@jscad/array-utils":526}],72:[function(require,module,exports){ +},{"./package.json":72,"@jscad/array-utils":527}],72:[function(require,module,exports){ module.exports={ "name": "@jscad/json-deserializer", - "version": "2.0.28", + "version": "2.0.29", "description": "JSON Deserializer for JSCAD", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -381,7 +381,7 @@ module.exports={ "@jscad/array-utils": "2.1.4" }, "devDependencies": { - "@jscad/modeling": "2.12.2", + "@jscad/modeling": "2.12.3", "ava": "3.15.0", "nyc": "15.1.0" }, @@ -397,7 +397,7 @@ const{colors:colors,primitives:primitives}=require("@jscad/modeling"),version=re },{"./package.json":75,"@jscad/modeling":211}],75:[function(require,module,exports){ module.exports={ "name": "@jscad/obj-deserializer", - "version": "2.0.27", + "version": "2.0.28", "description": "OBJ Deserializer for JSCAD", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -429,7 +429,7 @@ module.exports={ ], "license": "MIT", "dependencies": { - "@jscad/modeling": "2.12.2" + "@jscad/modeling": "2.12.3" }, "devDependencies": { "ava": "3.15.0", @@ -441,13 +441,13 @@ module.exports={ },{}],76:[function(require,module,exports){ const{colors:colors,geometries:geometries,modifiers:modifiers}=require("@jscad/modeling"),{flatten:flatten,toArray:toArray}=require("@jscad/array-utils"),mimeType="application/object",serialize=(e,...t)=>{e=Object.assign({},{statusCallback:null,triangulate:!0},e);let o=(t=flatten(t)).filter(e=>geometries.geom3.isA(e));if(0===o.length)throw new Error("only 3D geometries can be serialized to OBJ");t.length!==o.length&&console.warn("some objects could not be serialized to OBJ"),o=toArray(modifiers.generalize({snap:!0,triangulate:e.triangulate},o)),e.statusCallback&&e.statusCallback({progress:0});let r="# Wavefront OBJ file generated by JSCAD\n";const s=[];let a="default";return o.forEach((t,l)=>{e.statusCallback&&e.statusCallback({progress:100*l/o.length}),r+="\n";const i=getColorName(t),n=geometries.geom3.toPolygons(t).filter(e=>e.vertices.length>=3);n.forEach(e=>{e.vertices.forEach(e=>{const t=convertVertex(e);s.indexOf(t)<0&&(s.push(t),r+=`${t}\n`)})}),r+="\n",n.forEach(e=>{const t=e.vertices.map(e=>s.indexOf(convertVertex(e))+1),o=getColorName(e)||i||"default";o!==a&&(r+=`usemtl ${o}\n`,a=o),r+=`f ${t.join(" ")}\n`})}),e.statusCallback&&e.statusCallback({progress:100}),[r]},convertVertex=e=>`v ${e[0]} ${e[1]} ${e[2]}`,getColorName=e=>{let t;if(e.color){const o=e.color[0],r=e.color[1],s=e.color[2];let a=765;for(const e in colors.cssColors){const l=colors.cssColors[e],i=Math.abs(o-l[0])+Math.abs(r-l[1])+Math.abs(s-l[2]);if(i{const t={filename:"stl",version:packageVersion,addMetaData:!0,output:"script"};(e=Object.assign({},t,e))&&e.statusCallback&&e.statusCallback({progress:0});const{filename:r,version:a,output:n,addMetaData:o}=e;s=isBuffer(s)?bufferToBinaryString(s):s;const l=isDataBinaryRobust(s);e&&e.statusCallback&&e.statusCallback({progress:33});e&&e.statusCallback&&e.statusCallback({progress:66});const i=("script"===n?formatAsJscad:formatAsCsg)((l?deserializeBinarySTL:deserializeAsciiSTL)(s,r,a,"script"===n?({vertices:e,triangles:s,normals:t,colors:r,index:a})=>toScript(e,s,null,r,a):({vertices:e,triangles:s,normals:t,colors:r})=>toPolyhedron(e,s,null,r)),o,a,r);return e&&e.statusCallback&&e.statusCallback({progress:100}),i},bufferToBinaryString=e=>{let s="";const t=new Uint8Array(e),r=t.byteLength;for(let e=0;evoid 0!==e.byteLength&&"function"==typeof e.slice,ensureString=e=>{if("string"!=typeof e){const s=new Uint8Array(e);let t="";for(let r=0;r{const s=ensureString(e);return null===/vertex[\s]+([-+]?[0-9]+\.?[0-9]*([eE][-+]?[0-9]+)?)+[\s]+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)+[\s]+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)+/g.exec(s)},formatAsJscad=(e,s,t,r)=>{let a="";return s&&(a=`\n //\n // producer: JSCAD STL Deserializer ${t}\n // date: ${new Date}\n // source: ${r}\n // objects: ${e.length}\n //\n `),a+="const {primitives} = require('@jscad/modeling')\n",a+=e.join("\n"),a+=`\nconst main = () => {\n return [${e.map((e,s)=>`solid${s+1}()`)}]\n}\n\nmodule.exports = {main}\n`},formatAsCsg=e=>e,deserializeBinarySTL=(e,s,t,r)=>{const a=[],n=[],o=[],l=[];let i=0,c=0,u=null;const p=parseInt("01000000000000000",2),h=parseInt("00000000000011111",2),d=parseInt("00000001111100000",2),g=parseInt("00111110000000000",2),m=new BinaryReader(e);let f=0,v=0,b=0,S=0,F=0,y=0;for(let e=0;e<80;e++)switch(f){case 6:b=m.readUInt8(),f+=1;continue;case 7:S=m.readUInt8(),f+=1;continue;case 8:F=m.readUInt8(),f+=1;continue;case 9:y=m.readUInt8(),f+=1;continue;default:switch(v=m.readChar()){case"C":case"O":case"L":case"R":case"=":f+=1}}10===f&&(u=[b/255,S/255,F/255,y/255]);const C=m.readUInt32();for(let e=0;e0&&console.log("bad triangle vertice coords/normal: ",v),c+=v;const b=[];b.push(i++),b.push(i++),b.push(i++);const S=m.readUInt16();let F=null;if(10===f){const e=(S&h)/31,s=((S&d)>>>5)/31,t=((S&g)>>>10)/31,r=255;F=0===(S&p)?[e,s,t,r]:u,l.push(F)}if(0===v){const a=maths.vec3.subtract(maths.vec3.create(),t,s),n=maths.vec3.subtract(maths.vec3.create(),r,s),o=maths.vec3.cross(maths.vec3.create(),a,n);if(maths.vec3.dot(e,o)>0){const e=r;r=s,s=e}}a.push(s),a.push(t),a.push(r),n.push(b),o.push(e)}return c&&console.warn(`WARNING: import errors: ${c} (some triangles might be misaligned or missing)`),[r({vertices:a,triangles:n,normals:o,colors:l,index:1})]},deserializeAsciiSTL=(e,s,t,r)=>{let a=0;const n=e.split("endsolid"),o=[];for(let s=1;s0){const e=g;g=c,c=e}}n.push(c),n.push(d),n.push(g),i.push(o),l.push(m),a++}p&&console.warn(`WARNING: import errors: ${p} (some triangles might be misaligned or missing)`),o.push(r({vertices:n,triangles:l,colors:c,index:s}))}}return o},toPolyhedron=(e,s,t,r)=>{r&&s.length!==r.length&&(r=void 0);const a={orientation:"inward",points:e,faces:s,colors:r};return primitives.polyhedron(a)},toScript=(e,s,t,r,a)=>{let n=`\n//\n// solid ${a} : ${e.length} points, ${s.length} faces, ${r.length} colors\n//\nconst solid${a} = () => {\n`;n+=" const points = [\n";for(let s=0;s{ },{"@jscad/modeling":211}],81:[function(require,module,exports){ const{geometries:geometries,modifiers:modifiers}=require("@jscad/modeling"),{flatten:flatten,toArray:toArray}=require("@jscad/array-utils"),{serializeBinary:serializeBinary}=require("./CSGToStlb"),{serializeText:serializeText}=require("./CSGToStla"),mimeType="application/sla",serialize=(e,...i)=>{e=Object.assign({},{binary:!0,statusCallback:null},e);let r=(i=flatten(i)).filter(e=>geometries.geom3.isA(e));if(0===r.length)throw new Error("only 3D geometries can be serialized to STL");return i.length!==r.length&&console.warn("some objects could not be serialized to STL"),r=toArray(modifiers.generalize({snap:!0,triangulate:!0},r)),e.binary?serializeBinary(r,e):serializeText(r,e)};module.exports={mimeType:mimeType,serialize:serialize}; -},{"./CSGToStla":79,"./CSGToStlb":80,"@jscad/array-utils":526,"@jscad/modeling":211}],82:[function(require,module,exports){ +},{"./CSGToStla":79,"./CSGToStlb":80,"@jscad/array-utils":527,"@jscad/modeling":211}],82:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CHAR="\t\n\r -퟿-�𐀀-􏿿",exports.S=" \t\r\n",exports.NAME_START_CHAR=":A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿",exports.NAME_CHAR="-"+exports.NAME_START_CHAR+".0-9·̀-ͯ‿-⁀",exports.CHAR_RE=new RegExp("^["+exports.CHAR+"]$","u"),exports.S_RE=new RegExp("^["+exports.S+"]+$","u"),exports.NAME_START_CHAR_RE=new RegExp("^["+exports.NAME_START_CHAR+"]$","u"),exports.NAME_CHAR_RE=new RegExp("^["+exports.NAME_CHAR+"]$","u"),exports.NAME_RE=new RegExp("^["+exports.NAME_START_CHAR+"]["+exports.NAME_CHAR+"]*$","u"),exports.NMTOKEN_RE=new RegExp("^["+exports.NAME_CHAR+"]+$","u");var TAB=9,NL=10,CR=13,SPACE=32;function isChar(e){return e>=SPACE&&e<=55295||e===NL||e===CR||e===TAB||e>=57344&&e<=65533||e>=65536&&e<=1114111}function isS(e){return e===SPACE||e===NL||e===CR||e===TAB}function isNameStartChar(e){return e>=65&&e<=90||e>=97&&e<=122||58===e||95===e||8204===e||8205===e||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}function isNameChar(e){return isNameStartChar(e)||e>=48&&e<=57||45===e||46===e||183===e||e>=768&&e<=879||e>=8255&&e<=8256}exports.S_LIST=[SPACE,NL,CR,TAB],exports.isChar=isChar,exports.isS=isS,exports.isNameStartChar=isNameStartChar,exports.isNameChar=isNameChar; },{}],83:[function(require,module,exports){ @@ -513,7 +513,7 @@ const{geometries:geometries,modifiers:modifiers}=require("@jscad/modeling"),{fla },{"xmlchars/xml/1.0/ed5":82,"xmlchars/xml/1.1/ed2":83,"xmlchars/xmlns/1.0/ed3":84}],86:[function(require,module,exports){ module.exports={ "name": "@jscad/svg-deserializer", - "version": "2.5.8", + "version": "2.5.9", "description": "SVG Deserializer for JSCAD", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -546,7 +546,7 @@ module.exports={ "license": "MIT", "dependencies": { "@jscad/array-utils": "2.1.4", - "@jscad/modeling": "2.12.2", + "@jscad/modeling": "2.12.3", "saxes": "5.0.1" }, "devDependencies": { @@ -565,7 +565,7 @@ const{inchMM:inchMM,ptMM:ptMM,pcMM:pcMM,svgColors:svgColors}=require("./constant },{"./constants":87}],89:[function(require,module,exports){ const saxes=require("saxes"),{colors:colors,transforms:transforms}=require("@jscad/modeling"),{toArray:toArray}=require("@jscad/array-utils"),version=require("../package.json").version,{cagLengthX:cagLengthX,cagLengthY:cagLengthY,svgColorForTarget:svgColorForTarget}=require("./helpers"),{svgSvg:svgSvg,svgRect:svgRect,svgCircle:svgCircle,svgGroup:svgGroup,svgLine:svgLine,svgPath:svgPath,svgEllipse:svgEllipse,svgPolygon:svgPolygon,svgPolyline:svgPolyline,svgUse:svgUse}=require("./svgElementHelpers"),shapesMapGeometry=require("./shapesMapGeometry"),shapesMapJscad=require("./shapesMapJscad"),deserialize=(s,e)=>{const t={addMetaData:!0,filename:"svg",output:"script",pxPmm:require("./constants").pxPmm,segments:32,target:"path",pathSelfClosed:"error",version:version};return"script"===(s=Object.assign({},t,s)).output?translate(e,s):instantiate(e,s)},instantiate=(s,e)=>{const{pxPmm:t}=e;if(e&&e.statusCallback&&e.statusCallback({progress:0}),createSvgParser(s,t),!svgObj)throw new Error("SVG parsing failed, no valid SVG data retrieved");e&&e.statusCallback&&e.statusCallback({progress:50});const n=objectify(e,svgObj);return e&&e.statusCallback&&e.statusCallback({progress:100}),n},translate=(s,e)=>{const{filename:t,version:n,pxPmm:r,addMetaData:o}=e;if(e&&e.statusCallback&&e.statusCallback({progress:0}),createSvgParser(s,r),!svgObj)throw new Error("SVG parsing failed, no valid SVG data retrieved");let a=o?`//\n // producer: JSCAD SVG Deserializer ${n}\n // date: ${new Date}\n // source: ${t}\n //\n`:"";return a+="const { colors, geometries, primitives, transforms } = require('@jscad/modeling')\n\n",e&&e.statusCallback&&e.statusCallback({progress:50}),a+=codify(e,svgObj),a+="\nmodule.exports = { main }",e&&e.statusCallback&&e.statusCallback({progress:100}),a};let svgUnitsX,svgUnitsY,svgUnitsV;const svgObjects=[],svgGroups=[],svgDefs=[];let svgObj,svgInDefs=!1,svgUnitsPmm=[1,1];const objectify=(s,e)=>{const{target:t,segments:n,pathSelfClosed:r}=s,o=svgGroups.length;svgGroups.push(e);let a=o;for(;a>0;)a--;let g=[];const l={svgUnitsPmm:svgUnitsPmm,svgUnitsX:svgUnitsX,svgUnitsY:svgUnitsY,svgUnitsV:svgUnitsV,level:o,target:t,svgGroups:svgGroups,segments:n,pathSelfClosed:r};for(a=0;a{if("transforms"in s){let t=null,n=null,r=null;for(let e=0;e{const{target:t,segments:n}=s,r=svgGroups.length;svgGroups.push(e);let o=" ",a=r;for(;a>0;)o+=" ",a--;let g="";0===r&&(g+="function main(params) {\n let levels = {}\n let paths = {}\n let parts\n");const l="levels.l"+r;for(g+=`${o}${l} = []\n`,a=0;a{const t=new saxes.SaxesParser;return void 0!==e&&e>t.pxPmm&&(t.pxPmm=e),t.on("error",s=>{console.log(`ERROR: SVG file, line ${t.line}, column ${t.column}`),console.log(s)}),t.on("opentag",s=>{const n={SVG:svgSvg,G:svgGroup,RECT:svgRect,CIRCLE:svgCircle,ELLIPSE:svgEllipse,LINE:svgLine,POLYLINE:svgPolyline,POLYGON:svgPolygon,PATH:svgPath,USE:svgUse,DEFS:()=>{svgInDefs=!0},DESC:()=>void 0,TITLE:()=>void 0,STYLE:()=>void 0,undefined:()=>console.log("WARNING: unsupported SVG element: "+s.name)};s.attributes.position=[t.line+1,t.column+1];const r=s.name.toUpperCase(),o=n[r]?n[r](s.attributes,{svgObjects:svgObjects,customPxPmm:e}):void 0;if(o)if("id"in o&&(svgObjects[o.id]=o),"svg"===o.type)svgGroups.push(o),svgUnitsPmm=o.unitsPmm,svgUnitsX=o.viewW,svgUnitsY=o.viewH,svgUnitsV=o.viewP;else if(!0===svgInDefs){if(svgDefs.length>0){const s=svgDefs.pop();"objects"in s&&s.objects.push(o),svgDefs.push(s)}"group"===o.type&&svgDefs.push(o)}else{if(svgGroups.length>0){const s=svgGroups.pop();"objects"in s&&s.objects.push(o),svgGroups.push(s)}"group"===o.type&&svgGroups.push(o)}}),t.on("closetag",s=>{const e=()=>!0===svgInDefs?svgDefs.pop():svgGroups.pop(),t={SVG:e,DEFS:()=>{svgInDefs=!1},USE:e,G:e,undefined:()=>{}},n=s.name.toUpperCase(),r=t[n]?t[n]():void 0;0===svgGroups.length&&(svgObj=r)}),t.on("end",()=>{}),t.write(s).close(),t},extension="svg";module.exports={deserialize:deserialize,extension:"svg"}; -},{"../package.json":86,"./constants":87,"./helpers":88,"./shapesMapGeometry":90,"./shapesMapJscad":91,"./svgElementHelpers":92,"@jscad/array-utils":526,"@jscad/modeling":211,"saxes":85}],90:[function(require,module,exports){ +},{"../package.json":86,"./constants":87,"./helpers":88,"./shapesMapGeometry":90,"./shapesMapJscad":91,"./svgElementHelpers":92,"@jscad/array-utils":527,"@jscad/modeling":211,"saxes":85}],90:[function(require,module,exports){ const{geometries:geometries,primitives:primitives}=require("@jscad/modeling"),{svg2cag:svg2cag,cagLengthX:cagLengthX,cagLengthY:cagLengthY,cagLengthP:cagLengthP,reflect:reflect}=require("./helpers"),shapesMapGeometry=(e,t,s)=>{const{svgUnitsPmm:a,svgUnitsX:o,svgUnitsY:r,svgUnitsV:n,svgGroups:g,target:c,segments:p,pathSelfClosed:i}=s;return{group:e=>t({target:c,segments:p},e),rect:(e,t,s,a,o,r,n)=>{let g=cagLengthX(e.x,t,s),p=0-cagLengthY(e.y,t,a);const i=cagLengthX(e.width,t,s),l=cagLengthY(e.height,t,a),h=cagLengthX(e.rx,t,s);let m;return i>0&&l>0&&(g+=i/2,p-=l/2,m=0===h?primitives.rectangle({center:[g,p],size:[i,l]}):primitives.roundedRectangle({center:[g,p],segments:n,size:[i,l],roundRadius:h}),"path"===c&&(m=geometries.path2.fromPoints({closed:!0},geometries.geom2.toPoints(m)))),m},circle:(e,t,s,a,o,r,n)=>{const g=cagLengthX(e.x,t,s),p=0-cagLengthY(e.y,t,a),i=cagLengthP(e.radius,t,o);let l;return i>0&&(l=primitives.circle({center:[g,p],segments:n,radius:i}),"path"===c&&(l=geometries.path2.fromPoints({closed:!0},geometries.geom2.toPoints(l)))),l},ellipse:(e,t,s,a,o,r,n)=>{const g=cagLengthX(e.rx,t,s),p=cagLengthY(e.ry,t,a),i=cagLengthX(e.cx,t,s),l=0-cagLengthY(e.cy,t,a);let h;return g>0&&p>0&&(h=primitives.ellipse({center:[i,l],segments:n,radius:[g,p]}),"path"===c&&(h=geometries.path2.fromPoints({closed:!0},geometries.geom2.toPoints(h)))),h},line:(e,t,s,a,o)=>{const r=cagLengthX(e.x1,t,s),n=0-cagLengthY(e.y1,t,a),g=cagLengthX(e.x2,t,s),c=0-cagLengthY(e.y2,t,a);return primitives.line([[r,n],[g,c]])},polygon:(e,t,s,a)=>{const o=[];for(let r=0;r{const r=[];for(let o=0;o{const g=expandPath(e,t,s,a,o,r,n,i);return Object.entries(g).sort((e,t)=>e[0].localeCompare(t[0])).map(e=>{const t=e[1];if("geom2"===c&&t.isClosed){const e=geometries.path2.toPoints(t).slice();return e.push(e[0]),geometries.geom2.fromPoints(e)}return t})}}[e.type](e,a,o,r,n,g,p)};module.exports=shapesMapGeometry;const appendPoints=(e,t)=>t?geometries.path2.appendPoints(e,t):geometries.path2.fromPoints({},e),expandPath=(e,t,s,a,o,r,n,g)=>{const c={};let p=0,i=0,l=0,h=0,m=0,F="path"+m,v=!1,d=0,f=0,P=0,u=0;const L=()=>{F="path"+ ++m,v=!1},k=()=>{c[F]||(c[F]=geometries.path2.fromPoints({},[]))};for(let s=0;s=r+2&&(l+=parseFloat(o[r++]),h+=parseFloat(o[r++]),L(),c[F]=appendPoints([svg2cag([l,h],t)]),p=l,i=h);o.length>=r+2;)l+=parseFloat(o[r++]),h+=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"M":for(o.length>=r+2&&(l=parseFloat(o[r++]),h=parseFloat(o[r++]),L(),c[F]=appendPoints([svg2cag([l,h],t)]),p=l,i=h);o.length>=r+2;)l=parseFloat(o[r++]),h=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"a":for(;o.length>=r+7;){const e=parseFloat(o[r++]),s=parseFloat(o[r++]),a=0-.017453292519943295*parseFloat(o[r++]),g="1"===o[r++],p="1"===o[r++];l+=parseFloat(o[r++]),h+=parseFloat(o[r++]),k(),c[F]=geometries.path2.appendArc({segments:n,endpoint:svg2cag([l,h],t),radius:svg2cag([e,s],t),xaxisrotation:a,clockwise:p,large:g},c[F])}break;case"A":for(;o.length>=r+7;){const e=parseFloat(o[r++]),s=parseFloat(o[r++]),a=0-.017453292519943295*parseFloat(o[r++]),g="1"===o[r++],p="1"===o[r++];l=parseFloat(o[r++]),h=parseFloat(o[r++]),k(),c[F]=geometries.path2.appendArc({segments:n,endpoint:svg2cag([l,h],t),radius:svg2cag([e,s],t),xaxisrotation:a,clockwise:p,large:g},c[F])}break;case"c":for(;o.length>=r+6;){const e=l+parseFloat(o[r++]),s=h+parseFloat(o[r++]);d=l+parseFloat(o[r++]),f=h+parseFloat(o[r++]),l+=parseFloat(o[r++]),h+=parseFloat(o[r++]),k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag([e,s],t),svg2cag([d,f],t),svg2cag([l,h],t)]},c[F]);const a=reflect(d,f,l,h);d=a[0],f=a[1]}break;case"C":for(;o.length>=r+6;){const e=parseFloat(o[r++]),s=parseFloat(o[r++]);d=parseFloat(o[r++]),f=parseFloat(o[r++]),l=parseFloat(o[r++]),h=parseFloat(o[r++]),k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag([e,s],t),svg2cag([d,f],t),svg2cag([l,h],t)]},c[F]);const a=reflect(d,f,l,h);d=a[0],f=a[1]}break;case"q":for(;o.length>=r+4;){const e=[l,h];P=l+parseFloat(o[r++]),u=h+parseFloat(o[r++]),l+=parseFloat(o[r++]),h+=parseFloat(o[r++]);const s=[e[0]+2/3*(P-e[0]),e[1]+2/3*(u-e[1])],a=[s[0]+1/3*(l-e[0]),s[1]+1/3*(h-e[1])];k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag(s,t),svg2cag(a,t),svg2cag([l,h],t)]},c[F]);const g=reflect(P,u,l,h);P=g[0],u=g[1]}break;case"Q":for(;o.length>=r+4;){const e=[l,h];P=parseFloat(o[r++]),u=parseFloat(o[r++]),l=parseFloat(o[r++]),h=parseFloat(o[r++]);const s=[e[0]+2/3*(P-e[0]),e[1]+2/3*(u-e[1])],a=[s[0]+1/3*(l-e[0]),s[1]+1/3*(h-e[1])];k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag(s,t),svg2cag(a,t),svg2cag([l,h],t)]},c[F]);const g=reflect(P,u,l,h);P=g[0],u=g[1]}break;case"t":for(;o.length>=r+2;){const e=[l,h];l+=parseFloat(o[r++]),h+=parseFloat(o[r++]);const s=[e[0]+2/3*(P-e[0]),e[1]+2/3*(u-e[1])],a=[s[0]+1/3*(l-e[0]),s[1]+1/3*(h-e[1])];k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag(s,t),svg2cag(a,t),svg2cag([l,h],t)]},c[F]);const g=reflect(P,u,l,h);P=g[0],u=g[1]}break;case"T":for(;o.length>=r+2;){const e=[l,h];l=parseFloat(o[r++]),h=parseFloat(o[r++]);const s=[e[0]+2/3*(P-e[0]),e[1]+2/3*(u-e[1])],a=[s[0]+1/3*(l-e[0]),s[1]+1/3*(h-e[1])];k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag(s,t),svg2cag(a,t),svg2cag([l,h],t)]},c[F]);const g=reflect(P,u,l,h);P=g[0],u=g[1]}break;case"s":for(;o.length>=r+4;){const e=d,s=f;d=l+parseFloat(o[r++]),f=h+parseFloat(o[r++]),l+=parseFloat(o[r++]),h+=parseFloat(o[r++]),k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag([e,s],t),svg2cag([d,f],t),svg2cag([l,h],t)]},c[F]);const a=reflect(d,f,l,h);d=a[0],f=a[1]}break;case"S":for(;o.length>=r+4;){const e=d,s=f;d=parseFloat(o[r++]),f=parseFloat(o[r++]),l=parseFloat(o[r++]),h=parseFloat(o[r++]),k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag([e,s],t),svg2cag([d,f],t),svg2cag([l,h],t)]},c[F]);const a=reflect(d,f,l,h);d=a[0],f=a[1]}break;case"h":for(;o.length>=r+1;)l+=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"H":for(;o.length>=r+1;)l=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"l":for(;o.length>=r+2;)l+=parseFloat(o[r++]),h+=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"L":for(;o.length>=r+2;)l=parseFloat(o[r++]),h=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"v":for(;o.length>=r+1;)h+=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"V":for(;o.length>=r+1;)h=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"z":case"Z":c[F]=geometries.path2.close(c[F]),l=p,h=i,v=!0;break;default:console.log("Warning: Unknow PATH command ["+a.c+"]")}const m=e=>"z"===e||"Z"===e;if(!0!==v&&c[F]&&c[F].isClosed){let t=e.commands[s+1];if(t&&!m(t.c))if("trim"===g)for(;t&&!m(t.c);)s++,t=e.commands[s+1];else{if("split"!==g)throw new Error(`Malformed svg path at ${e.position[0]}:${a.pos}. Path closed itself with command #${s} ${a.c}${o.join(" ")}`);L()}}}return c}; },{"./helpers":88,"@jscad/modeling":211}],91:[function(require,module,exports){ @@ -583,7 +583,7 @@ const{geometries:geometries,maths:maths,measurements:measurements,utils:utils}=r },{}],95:[function(require,module,exports){ module.exports={ "name": "@jscad/svg-serializer", - "version": "2.3.15", + "version": "2.3.16", "description": "SVG Serializer for JSCAD", "homepage": "https://openjscad.xyz/", "repository": "https://github.com/jscad/OpenJSCAD.org", @@ -615,7 +615,7 @@ module.exports={ ], "license": "MIT", "dependencies": { - "@jscad/modeling": "2.12.2", + "@jscad/modeling": "2.12.3", "onml": "1.3.0" }, "devDependencies": { @@ -640,7 +640,7 @@ module.exports={ },{"xmlchars/xml/1.0/ed5":96,"xmlchars/xml/1.1/ed2":97,"xmlchars/xmlns/1.0/ed3":98}],100:[function(require,module,exports){ module.exports={ "name": "@jscad/x3d-deserializer", - "version": "2.2.7", + "version": "2.2.8", "description": "X3D Deserializer for JSCAD", "repository": "https://github.com/jscad/OpenJSCAD.org/", "main": "src/index.js", @@ -667,7 +667,7 @@ module.exports={ }, "dependencies": { "@jscad/array-utils": "2.1.4", - "@jscad/modeling": "2.12.2", + "@jscad/modeling": "2.12.3", "saxes": "5.0.1" }, "devDependencies": { @@ -691,7 +691,7 @@ const version=require("../package.json").version,translate=require("./translate" },{"../package.json":100,"./instantiate":105,"./translate":112}],105:[function(require,module,exports){ const{flatten:flatten}=require("@jscad/array-utils"),parse=require("./parse"),instantiateDefinitions=require("./instantiateDefinitions"),{x3dTypes:x3dTypes}=require("./objects"),instantiate=(t,e)=>{const s={pxPmm:require("./constants").pxPmm};t=Object.assign({},s,t);const{pxPmm:a}=t;t&&t.statusCallback&&t.statusCallback({progress:0});const{x3dObj:n}=parse(e,a);if(n.definition!==x3dTypes.X3D||!n.objects)throw new Error("X3D malformed");if(n.objects.length<1||n.objects[0].definition!==x3dTypes.SCENE)throw new Error("X3D did not define a SCENE");t&&t.statusCallback&&t.statusCallback({progress:50});const i=n.objects[0].objects;let r=instantiateDefinitions(t,i);return t.flatten&&(r=flatten(r)),t&&t.statusCallback&&t.statusCallback({progress:100}),r};module.exports=instantiate; -},{"./constants":101,"./instantiateDefinitions":106,"./objects":110,"./parse":111,"@jscad/array-utils":526}],106:[function(require,module,exports){ +},{"./constants":101,"./instantiateDefinitions":106,"./objects":110,"./parse":111,"@jscad/array-utils":527}],106:[function(require,module,exports){ const{colors:colors,transforms:transforms}=require("@jscad/modeling"),createTransform=require("./createTransform"),{x3dTypes:x3dTypes}=require("./objects"),{findColor:findColor}=require("./translateHelpers"),instantiatePrimitive=require("./instantiatePrimitive"),{instantiateLine:instantiateLine}=require("./instantiateLine"),{instantiateMesh:instantiateMesh}=require("./instantiateMesh"),instantiatedList=new Map,instantiateTransform=(t,n)=>{const i=n.objects.map(n=>instantiateDefinition(t,n)).filter(t=>null!=t);if(0===i.length)return null;const e=createTransform(n.center,n.rotation,n.scale,n.scaleOrientation,n.translation);return i.map(t=>{const n=t.color;return t=transforms.transform(e,t),n&&(t.color=n),t})},instantiateShape=(t,n)=>{const i=n.objects,e=findColor(i,t);let a=instantiatePrimitive(t,i);return a||(a=instantiateMesh(t,i)),a||(a=instantiateLine(t,i)),a||(a=null),a&&e&&(a=colors.colorize(e,a)),a},instantiateGroup=(t,n)=>{const i=n.objects.map(n=>instantiateDefinition(t,n)).filter(t=>null!=t);return 0===i.length?null:i},instantiateDefinition=(t,n)=>{let i;switch(n.definition){case x3dTypes.TRANSFORM:i=instantiateTransform(t,n);break;case x3dTypes.SHAPE:i=instantiateShape(t,n);break;case x3dTypes.GROUP:i=instantiateGroup(t,n);break;default:console.log("WARNING: unknown definition: "+n.definition)}return i},instantiateDefinitions=(t,n)=>{const i=n.map(n=>instantiateDefinition(t,n)).filter(t=>null!=t);return instantiatedList.clear(),i};module.exports=instantiateDefinitions; },{"./createTransform":102,"./instantiateLine":107,"./instantiateMesh":108,"./instantiatePrimitive":109,"./objects":110,"./translateHelpers":114,"@jscad/modeling":211}],107:[function(require,module,exports){ @@ -733,13 +733,13 @@ const{geometries:geometries}=require("@jscad/modeling"),{geom3:geom3,poly3:poly3 },{}],119:[function(require,module,exports){ const{geometries:geometries,modifiers:modifiers}=require("@jscad/modeling"),{geom2:geom2,geom3:geom3,path2:path2,poly2:poly2,poly3:poly3}=geometries,{flatten:flatten}=require("@jscad/array-utils"),stringify=require("onml/lib/stringify"),mimeType="model/x3d+xml",defNames=new Map,serialize=(e,...o)=>{if(e=Object.assign({},{color:[0,0,1,1],shininess:8/256,smooth:!1,decimals:1e3,metadata:!0,unit:"millimeter",statusCallback:null},e),0===(o=(o=flatten(o)).filter(e=>geom3.isA(e)||geom2.isA(e)||path2.isA(e))).length)throw new Error("expected one or more geom3/geom2/path2 objects");e.statusCallback&&e.statusCallback({progress:0});let t=["X3D",{profile:"Interchange",version:"3.3","xmlns:xsd":"http://www.w3.org/2001/XMLSchema-instance","xsd:noNamespaceSchemaLocation":"http://www.web3d.org/specifications/x3d-3.3.xsd"}];e.metadata?t.push(["head",{},["meta",{name:"creator",content:"Created by JSCAD"}],["meta",{name:"reference",content:"https://www.openjscad.xyz"}],["meta",{name:"created",content:(new Date).toISOString()}]]):t.push(["head",{},["meta",{name:"creator",content:"Created by JSCAD"}]]),t=t.concat(convertObjects(o,e));const r=`\n${stringify(t,2)}`;return e&&e.statusCallback&&e.statusCallback({progress:100}),[r]},convertObjects=(e,o)=>{const t=[];return e.forEach((r,s)=>{if(o.statusCallback&&o.statusCallback({progress:100*s/e.length}),geom3.isA(r)){r=modifiers.generalize({snap:!0,triangulate:!0},r),geom3.toPolygons(r).length>0&&t.push(convertGeom3(r,o))}geom2.isA(r)&&t.push(convertGeom2(r,o)),path2.isA(r)&&t.push(convertPath2(r,o))}),[["Scene",{},["Transform",{rotation:"1 0 0 -1.5708"},...t]]]},convertPath2=(e,o)=>{const t=path2.toPoints(e).slice();t.length>1&&e.isClosed&&t.push(t[0]);const r=["Shape",shapeAttributes(e),convertPolyline2D(poly2.create(t),o)];return e.color&&r.push(convertAppearance(e,"emissiveColor",o)),r},convertGeom2=(e,o)=>{const t=geom2.toOutlines(e),r=["Group",{}];return t.forEach(t=>{t.length>1&&t.push(t[0]);const s=["Shape",shapeAttributes(e),convertPolyline2D(poly2.create(t),o)];e.color&&s.push(convertAppearance(e,"emissiveColor",o)),r.push(s)}),r},shapeAttributes=(e,o={})=>(e.id&&Object.assign(o,{DEF:checkDefName(e.id)}),o),checkDefName=e=>{const o=defNames.get(e)||0;return defNames.set(e,o+1),o>0&&console.warn(`Warning: object.id set as DEF but not unique. ${e} set ${o+1} times.`),e},convertPolyline2D=(e,o)=>{return["Polyline2D",{lineSegments:e.vertices.map(e=>`${e[0]} ${e[1]}`).join(" ")}]},convertAppearance=(e,o,t)=>{const r={[o]:e.color.slice(0,3).join(" "),transparency:roundToDecimals(1-e.color[3],t)};return"diffuseColor"===o&&Object.assign(r,{specularColor:"0.2 0.2 0.2",shininess:t.shininess}),["Appearance",["Material",r]]},convertGeom3=(e,o)=>{const t=["Shape",shapeAttributes(e),convertMesh(e,o)];let r=["Appearance",{},["Material"]];return e.color&&(r=convertAppearance(e,"diffuseColor",o)),t.push(r),t},convertMesh=(e,o)=>{const t=convertToTriangles(e,o),r=polygons2coordinates(t,o),s=r[0].join(" "),n=r[1].join(" "),a=r[2].join(" "),c=["IndexedTriangleSet",{ccw:"true",colorPerVertex:"false",normalPerVertex:o.smooth,solid:"false",index:s},["Coordinate",{point:n}]];return e.color||c.push(["Color",{color:a}]),c},convertToTriangles=(e,o)=>{const t=[];return geom3.toPolygons(e).forEach(r=>{const s=r.vertices[0];for(let n=r.vertices.length-3;n>=0;n--){const a=poly3.fromPoints([s,r.vertices[n+1],r.vertices[n+2]]);let c=o.color;e.color&&(c=e.color),r.color&&(c=r.color),a.color=c,t.push(a)}}),t},convertToColor=(e,o)=>{let t=o.color;return e.color&&(t=e.color),`${t[0]} ${t[1]} ${t[2]}`},roundToDecimals=(e,o)=>Math.round(e*o.decimals)/o.decimals,polygons2coordinates=(e,o)=>{const t=[],r=[],s=[],n=new Map;return e.forEach(e=>{const a=[],c=e.vertices.length;for(let t=0;tcssColors[o.toLowerCase()];module.exports=colorNameToRgb; },{"./cssColors":122}],121:[function(require,module,exports){ const flatten=require("../utils/flatten"),geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),path2=require("../geometries/path2"),poly3=require("../geometries/poly3"),colorGeom2=(o,r)=>{const e=geom2.clone(r);return e.color=o,e},colorGeom3=(o,r)=>{const e=geom3.clone(r);return e.color=o,e},colorPath2=(o,r)=>{const e=path2.clone(r);return e.color=o,e},colorPoly3=(o,r)=>{const e=poly3.clone(r);return e.color=o,e},colorize=(o,...r)=>{if(!Array.isArray(o))throw new Error("color must be an array");if(o.length<3)throw new Error("color must contain R, G and B values");if(3===o.length&&(o=[o[0],o[1],o[2],1]),0===(r=flatten(r)).length)throw new Error("wrong number of arguments");const e=r.map(r=>geom2.isA(r)?colorGeom2(o,r):geom3.isA(r)?colorGeom3(o,r):path2.isA(r)?colorPath2(o,r):poly3.isA(r)?colorPoly3(o,r):(r.color=o,r));return 1===e.length?e[0]:e};module.exports=colorize; -},{"../geometries/geom2":144,"../geometries/geom3":160,"../geometries/path2":181,"../geometries/poly3":198,"../utils/flatten":516}],122:[function(require,module,exports){ +},{"../geometries/geom2":144,"../geometries/geom3":160,"../geometries/path2":181,"../geometries/poly3":198,"../utils/flatten":517}],122:[function(require,module,exports){ const cssColors={black:[0,0,0],silver:[192/255,192/255,192/255],gray:[128/255,128/255,128/255],white:[1,1,1],maroon:[128/255,0,0],red:[1,0,0],purple:[128/255,0,128/255],fuchsia:[1,0,1],green:[0,128/255,0],lime:[0,1,0],olive:[128/255,128/255,0],yellow:[1,1,0],navy:[0,0,128/255],blue:[0,0,1],teal:[0,128/255,128/255],aqua:[0,1,1],aliceblue:[240/255,248/255,1],antiquewhite:[250/255,235/255,215/255],aquamarine:[127/255,1,212/255],azure:[240/255,1,1],beige:[245/255,245/255,220/255],bisque:[1,228/255,196/255],blanchedalmond:[1,235/255,205/255],blueviolet:[138/255,43/255,226/255],brown:[165/255,42/255,42/255],burlywood:[222/255,184/255,135/255],cadetblue:[95/255,158/255,160/255],chartreuse:[127/255,1,0],chocolate:[210/255,105/255,30/255],coral:[1,127/255,80/255],cornflowerblue:[100/255,149/255,237/255],cornsilk:[1,248/255,220/255],crimson:[220/255,20/255,60/255],cyan:[0,1,1],darkblue:[0,0,139/255],darkcyan:[0,139/255,139/255],darkgoldenrod:[184/255,134/255,11/255],darkgray:[169/255,169/255,169/255],darkgreen:[0,100/255,0],darkgrey:[169/255,169/255,169/255],darkkhaki:[189/255,183/255,107/255],darkmagenta:[139/255,0,139/255],darkolivegreen:[85/255,107/255,47/255],darkorange:[1,140/255,0],darkorchid:[.6,50/255,.8],darkred:[139/255,0,0],darksalmon:[233/255,150/255,122/255],darkseagreen:[143/255,188/255,143/255],darkslateblue:[72/255,61/255,139/255],darkslategray:[47/255,79/255,79/255],darkslategrey:[47/255,79/255,79/255],darkturquoise:[0,206/255,209/255],darkviolet:[148/255,0,211/255],deeppink:[1,20/255,147/255],deepskyblue:[0,191/255,1],dimgray:[105/255,105/255,105/255],dimgrey:[105/255,105/255,105/255],dodgerblue:[30/255,144/255,1],firebrick:[178/255,34/255,34/255],floralwhite:[1,250/255,240/255],forestgreen:[34/255,139/255,34/255],gainsboro:[220/255,220/255,220/255],ghostwhite:[248/255,248/255,1],gold:[1,215/255,0],goldenrod:[218/255,165/255,32/255],greenyellow:[173/255,1,47/255],grey:[128/255,128/255,128/255],honeydew:[240/255,1,240/255],hotpink:[1,105/255,180/255],indianred:[205/255,92/255,92/255],indigo:[75/255,0,130/255],ivory:[1,1,240/255],khaki:[240/255,230/255,140/255],lavender:[230/255,230/255,250/255],lavenderblush:[1,240/255,245/255],lawngreen:[124/255,252/255,0],lemonchiffon:[1,250/255,205/255],lightblue:[173/255,216/255,230/255],lightcoral:[240/255,128/255,128/255],lightcyan:[224/255,1,1],lightgoldenrodyellow:[250/255,250/255,210/255],lightgray:[211/255,211/255,211/255],lightgreen:[144/255,238/255,144/255],lightgrey:[211/255,211/255,211/255],lightpink:[1,182/255,193/255],lightsalmon:[1,160/255,122/255],lightseagreen:[32/255,178/255,170/255],lightskyblue:[135/255,206/255,250/255],lightslategray:[119/255,136/255,.6],lightslategrey:[119/255,136/255,.6],lightsteelblue:[176/255,196/255,222/255],lightyellow:[1,1,224/255],limegreen:[50/255,205/255,50/255],linen:[250/255,240/255,230/255],magenta:[1,0,1],mediumaquamarine:[.4,205/255,170/255],mediumblue:[0,0,205/255],mediumorchid:[186/255,85/255,211/255],mediumpurple:[147/255,112/255,219/255],mediumseagreen:[60/255,179/255,113/255],mediumslateblue:[123/255,104/255,238/255],mediumspringgreen:[0,250/255,154/255],mediumturquoise:[72/255,209/255,.8],mediumvioletred:[199/255,21/255,133/255],midnightblue:[25/255,25/255,112/255],mintcream:[245/255,1,250/255],mistyrose:[1,228/255,225/255],moccasin:[1,228/255,181/255],navajowhite:[1,222/255,173/255],oldlace:[253/255,245/255,230/255],olivedrab:[107/255,142/255,35/255],orange:[1,165/255,0],orangered:[1,69/255,0],orchid:[218/255,112/255,214/255],palegoldenrod:[238/255,232/255,170/255],palegreen:[152/255,251/255,152/255],paleturquoise:[175/255,238/255,238/255],palevioletred:[219/255,112/255,147/255],papayawhip:[1,239/255,213/255],peachpuff:[1,218/255,185/255],peru:[205/255,133/255,63/255],pink:[1,192/255,203/255],plum:[221/255,160/255,221/255],powderblue:[176/255,224/255,230/255],rosybrown:[188/255,143/255,143/255],royalblue:[65/255,105/255,225/255],saddlebrown:[139/255,69/255,19/255],salmon:[250/255,128/255,114/255],sandybrown:[244/255,164/255,96/255],seagreen:[46/255,139/255,87/255],seashell:[1,245/255,238/255],sienna:[160/255,82/255,45/255],skyblue:[135/255,206/255,235/255],slateblue:[106/255,90/255,205/255],slategray:[112/255,128/255,144/255],slategrey:[112/255,128/255,144/255],snow:[1,250/255,250/255],springgreen:[0,1,127/255],steelblue:[70/255,130/255,180/255],tan:[210/255,180/255,140/255],thistle:[216/255,191/255,216/255],tomato:[1,99/255,71/255],turquoise:[64/255,224/255,208/255],violet:[238/255,130/255,238/255],wheat:[245/255,222/255,179/255],whitesmoke:[245/255,245/255,245/255],yellowgreen:[154/255,205/255,50/255]};module.exports=cssColors; },{}],123:[function(require,module,exports){ @@ -748,10 +748,10 @@ const hexToRgb=t=>{if((t=t.replace("#","")).length<6)throw new Error("the given },{}],124:[function(require,module,exports){ const flatten=require("../utils/flatten"),hueToColorComponent=require("./hueToColorComponent"),hslToRgb=(...o)=>{if((o=flatten(o)).length<3)throw new Error("values must contain H, S and L values");const e=o[0],n=o[1],t=o[2];let r=t,l=t,u=t;if(0!==n){const o=t<.5?t*(1+n):t+n-t*n,h=2*t-o;r=hueToColorComponent(h,o,e+1/3),l=hueToColorComponent(h,o,e),u=hueToColorComponent(h,o,e-1/3)}if(o.length>3){return[r,l,u,o[3]]}return[r,l,u]};module.exports=hslToRgb; -},{"../utils/flatten":516,"./hueToColorComponent":126}],125:[function(require,module,exports){ +},{"../utils/flatten":517,"./hueToColorComponent":126}],125:[function(require,module,exports){ const flatten=require("../utils/flatten"),hsvToRgb=(...e)=>{if((e=flatten(e)).length<3)throw new Error("values must contain H, S and V values");const t=e[0],a=e[1],r=e[2];let s=0,n=0,o=0;const c=Math.floor(6*t),l=6*t-c,u=r*(1-a),b=r*(1-l*a),h=r*(1-(1-l)*a);switch(c%6){case 0:s=r,n=h,o=u;break;case 1:s=b,n=r,o=u;break;case 2:s=u,n=r,o=h;break;case 3:s=u,n=b,o=r;break;case 4:s=h,n=u,o=r;break;case 5:s=r,n=u,o=b}if(e.length>3){return[s,n,o,e[3]]}return[s,n,o]};module.exports=hsvToRgb; -},{"../utils/flatten":516}],126:[function(require,module,exports){ +},{"../utils/flatten":517}],126:[function(require,module,exports){ const hueToColorComponent=(o,e,n)=>(n<0&&(n+=1),n>1&&(n-=1),n<1/6?o+6*(e-o)*n:n<.5?e:n<2/3?o+(e-o)*(2/3-n)*6:o);module.exports=hueToColorComponent; },{}],127:[function(require,module,exports){ @@ -760,13 +760,13 @@ module.exports={colorize:require("./colorize"),colorNameToRgb:require("./colorNa },{"./colorNameToRgb":120,"./colorize":121,"./cssColors":122,"./hexToRgb":123,"./hslToRgb":124,"./hsvToRgb":125,"./hueToColorComponent":126,"./rgbToHex":128,"./rgbToHsl":129,"./rgbToHsv":130}],128:[function(require,module,exports){ const flatten=require("../utils/flatten"),rgbToHex=(...t)=>{if((t=flatten(t)).length<3)throw new Error("values must contain R, G and B values");const e=255*t[0],r=255*t[1],n=255*t[2];let o=`#${Number(16777216+65536*e+256*r+n).toString(16).substring(1,7)}`;return t.length>3&&(o+=Number(255*t[3]).toString(16)),o};module.exports=rgbToHex; -},{"../utils/flatten":516}],129:[function(require,module,exports){ +},{"../utils/flatten":517}],129:[function(require,module,exports){ const flatten=require("../utils/flatten"),rgbToHsl=(...t)=>{if((t=flatten(t)).length<3)throw new Error("values must contain R, G and B values");const e=t[0],n=t[1],s=t[2],a=Math.max(e,n,s),r=Math.min(e,n,s);let l,o;const c=(a+r)/2;if(a===r)l=o=0;else{const t=a-r;switch(o=c>.5?t/(2-a-r):t/(a+r),a){case e:l=(n-s)/t+(n3){return[l,o,c,t[3]]}return[l,o,c]};module.exports=rgbToHsl; -},{"../utils/flatten":516}],130:[function(require,module,exports){ +},{"../utils/flatten":517}],130:[function(require,module,exports){ const flatten=require("../utils/flatten"),rgbToHsv=(...e)=>{if((e=flatten(e)).length<3)throw new Error("values must contain R, G and B values");const t=e[0],a=e[1],n=e[2],r=Math.max(t,a,n),s=Math.min(t,a,n);let l;const o=r,c=r-s,i=0===r?0:c/r;if(r===s)l=0;else{switch(r){case t:l=(a-n)/c+(a3){return[l,i,o,e[3]]}return[l,i,o]};module.exports=rgbToHsv; -},{"../utils/flatten":516}],131:[function(require,module,exports){ +},{"../utils/flatten":517}],131:[function(require,module,exports){ const lengths=require("./lengths"),arcLengthToT=(e,t)=>{const{distance:s,segments:n}=Object.assign({},{distance:0,segments:100},e),o=lengths(n,t);let r=0,c=n;for(;r<=c;){const e=Math.floor(r+(c-r)/2),t=o[e]-s;if(t<0)r=e+1;else{if(!(t>0)){c=e;break}c=e-1}}const g=c;if(o[g]===s)return g/n;const a=o[g];return(g+(s-a)/(o[g+1]-a))/n};module.exports=arcLengthToT; },{"./lengths":135}],132:[function(require,module,exports){ @@ -853,7 +853,7 @@ const poly3=require("../poly3"),create=require("./create"),fromPoints=r=>{if(!Ar },{"../poly3":198,"./create":156}],159:[function(require,module,exports){ const quickhull=require("../../operations/hulls/quickhull"),create=require("./create"),poly3=require("../poly3"),fromPointsConvex=r=>{if(!Array.isArray(r))throw new Error("the given points must be an array");const e=quickhull(r,{skipTriangulation:!0}).map(e=>{const o=e.map(e=>r[e]);return poly3.create(o)});return create(e)};module.exports=fromPointsConvex; -},{"../../operations/hulls/quickhull":466,"../poly3":198,"./create":156}],160:[function(require,module,exports){ +},{"../../operations/hulls/quickhull":467,"../poly3":198,"./create":156}],160:[function(require,module,exports){ module.exports={clone:require("./clone"),create:require("./create"),fromPointsConvex:require("./fromPointsConvex"),fromPoints:require("./fromPoints"),fromCompactBinary:require("./fromCompactBinary"),invert:require("./invert"),isA:require("./isA"),toPoints:require("./toPoints"),toPolygons:require("./toPolygons"),toString:require("./toString"),toCompactBinary:require("./toCompactBinary"),transform:require("./transform"),validate:require("./validate")}; },{"./clone":155,"./create":156,"./fromCompactBinary":157,"./fromPoints":158,"./fromPointsConvex":159,"./invert":161,"./isA":162,"./toCompactBinary":163,"./toPoints":164,"./toPolygons":165,"./toString":166,"./transform":167,"./validate":168}],161:[function(require,module,exports){ @@ -1009,7 +1009,7 @@ const signedDistanceToPoint=require("../../maths/plane/signedDistanceToPoint"),{ },{"../../maths/constants":213,"../../maths/plane/signedDistanceToPoint":284,"../../maths/vec3":341,"./isA":200,"./isConvex":201,"./measureArea":202,"./plane":206}],211:[function(require,module,exports){ module.exports={colors:require("./colors"),curves:require("./curves"),geometries:require("./geometries"),maths:require("./maths"),measurements:require("./measurements"),primitives:require("./primitives"),text:require("./text"),utils:require("./utils"),booleans:require("./operations/booleans"),expansions:require("./operations/expansions"),extrusions:require("./operations/extrusions"),hulls:require("./operations/hulls"),modifiers:require("./operations/modifiers"),transforms:require("./operations/transforms")}; -},{"./colors":127,"./curves":138,"./geometries":169,"./maths":214,"./measurements":371,"./operations/booleans":385,"./operations/expansions":414,"./operations/extrusions":437,"./operations/hulls":459,"./operations/modifiers":470,"./operations/transforms":480,"./primitives":496,"./text":510,"./utils":518}],212:[function(require,module,exports){ +},{"./colors":127,"./curves":138,"./geometries":169,"./maths":214,"./measurements":371,"./operations/booleans":385,"./operations/expansions":414,"./operations/extrusions":437,"./operations/hulls":460,"./operations/modifiers":471,"./operations/transforms":481,"./primitives":497,"./text":511,"./utils":519}],212:[function(require,module,exports){ const mat4=require("./mat4"),vec2=require("./vec2"),vec3=require("./vec3"),OrthoNormalBasis=function(e,t){arguments.length<2&&(t=vec3.orthogonal(vec3.create(),e)),this.v=vec3.normalize(vec3.create(),vec3.cross(vec3.create(),e,t)),this.u=vec3.cross(vec3.create(),this.v,e),this.plane=e,this.planeorigin=vec3.scale(vec3.create(),e,e[3])};OrthoNormalBasis.GetCartesian=function(e,t){const i=e+"/"+t;let s,n;if("X/Y"===i)s=[0,0,1],n=[1,0,0];else if("Y/-X"===i)s=[0,0,1],n=[0,1,0];else if("-X/-Y"===i)s=[0,0,1],n=[-1,0,0];else if("-Y/X"===i)s=[0,0,1],n=[0,-1,0];else if("-X/Y"===i)s=[0,0,-1],n=[-1,0,0];else if("-Y/-X"===i)s=[0,0,-1],n=[0,-1,0];else if("X/-Y"===i)s=[0,0,-1],n=[1,0,0];else if("Y/X"===i)s=[0,0,-1],n=[0,1,0];else if("X/Z"===i)s=[0,-1,0],n=[1,0,0];else if("Z/-X"===i)s=[0,-1,0],n=[0,0,1];else if("-X/-Z"===i)s=[0,-1,0],n=[-1,0,0];else if("-Z/X"===i)s=[0,-1,0],n=[0,0,-1];else if("-X/Z"===i)s=[0,1,0],n=[-1,0,0];else if("-Z/-X"===i)s=[0,1,0],n=[0,0,-1];else if("X/-Z"===i)s=[0,1,0],n=[1,0,0];else if("Z/X"===i)s=[0,1,0],n=[0,0,1];else if("Y/Z"===i)s=[1,0,0],n=[0,1,0];else if("Z/-Y"===i)s=[1,0,0],n=[0,0,1];else if("-Y/-Z"===i)s=[1,0,0],n=[0,-1,0];else if("-Z/Y"===i)s=[1,0,0],n=[0,0,-1];else if("-Y/Z"===i)s=[-1,0,0],n=[0,-1,0];else if("-Z/-Y"===i)s=[-1,0,0],n=[0,0,-1];else if("Y/-Z"===i)s=[-1,0,0],n=[0,1,0];else{if("Z/Y"!==i)throw new Error("OrthoNormalBasis.GetCartesian: invalid combination of axis identifiers. Should pass two string arguments from [X,Y,Z,-X,-Y,-Z], being two different axes.");s=[-1,0,0],n=[0,0,1]}return new OrthoNormalBasis(new Plane(new Vector3D(s),0),new Vector3D(n))},OrthoNormalBasis.Z0Plane=function(){const e=new Plane(new Vector3D([0,0,1]),0);return new OrthoNormalBasis(e,new Vector3D([1,0,0]))},OrthoNormalBasis.prototype={getProjectionMatrix:function(){return mat4.fromValues(this.u[0],this.v[0],this.plane[0],0,this.u[1],this.v[1],this.plane[1],0,this.u[2],this.v[2],this.plane[2],0,0,0,-this.plane[3],1)},getInverseProjectionMatrix:function(){const e=vec3.scale(vec3.create(),this.plane,this.plane[3]);return mat4.fromValues(this.u[0],this.u[1],this.u[2],0,this.v[0],this.v[1],this.v[2],0,this.plane[0],this.plane[1],this.plane[2],0,e[0],e[1],e[2],1)},to2D:function(e){return vec2.fromValues(vec3.dot(e,this.u),vec3.dot(e,this.v))},to3D:function(e){const t=vec3.scale(vec3.create(),this.u,e[0]),i=vec3.scale(vec3.create(),this.v,e[1]),s=vec3.add(t,t,this.planeorigin);return vec3.add(i,i,s)},line3Dto2D:function(e){const t=e.point,i=e.direction.plus(t),s=this.to2D(t),n=this.to2D(i);return Line2D.fromPoints(s,n)},line2Dto3D:function(e){const t=e.origin(),i=e.direction().plus(t),s=this.to3D(t),n=this.to3D(i);return Line3D.fromPoints(s,n)},transform:function(e){const t=this.plane.transform(e),i=this.u.transform(e),s=new Vector3D(0,0,0).transform(e),n=i.minus(s);return new OrthoNormalBasis(t,n)}},module.exports=OrthoNormalBasis; },{"./mat4":262,"./vec2":310,"./vec3":341}],213:[function(require,module,exports){ @@ -1492,40 +1492,40 @@ module.exports={measureAggregateArea:require("./measureAggregateArea"),measureAg },{"./measureAggregateArea":372,"./measureAggregateBoundingBox":373,"./measureAggregateEpsilon":374,"./measureAggregateVolume":375,"./measureArea":376,"./measureBoundingBox":377,"./measureBoundingSphere":378,"./measureCenter":379,"./measureCenterOfMass":380,"./measureDimensions":381,"./measureEpsilon":382,"./measureVolume":383}],372:[function(require,module,exports){ const flatten=require("../utils/flatten"),measureArea=require("./measureArea"),measureAggregateArea=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("measureAggregateArea: no geometries supplied");const r=measureArea(e);if(1===e.length)return r;return r.reduce((e,r)=>e+r,0)};module.exports=measureAggregateArea; -},{"../utils/flatten":516,"./measureArea":376}],373:[function(require,module,exports){ +},{"../utils/flatten":517,"./measureArea":376}],373:[function(require,module,exports){ const flatten=require("../utils/flatten"),vec3min=require("../maths/vec3/min"),vec3max=require("../maths/vec3/max"),measureBoundingBox=require("./measureBoundingBox"),measureAggregateBoundingBox=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("measureAggregateBoundingBox: no geometries supplied");const r=measureBoundingBox(e);if(1===e.length)return r;const u=[[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],[-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE]];return r.reduce((e,r)=>e=[vec3min(e[0],e[0],r[0]),vec3max(e[1],e[1],r[1])],u)};module.exports=measureAggregateBoundingBox; -},{"../maths/vec3/max":344,"../maths/vec3/min":345,"../utils/flatten":516,"./measureBoundingBox":377}],374:[function(require,module,exports){ +},{"../maths/vec3/max":344,"../maths/vec3/min":345,"../utils/flatten":517,"./measureBoundingBox":377}],374:[function(require,module,exports){ const flatten=require("../utils/flatten"),measureAggregateBoundingBox=require("./measureAggregateBoundingBox"),calculateEpsilonFromBounds=require("./calculateEpsilonFromBounds"),{geom2:geom2,geom3:geom3,path2:path2}=require("../geometries"),measureAggregateEpsilon=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("measureAggregateEpsilon: no geometries supplied");const o=measureAggregateBoundingBox(e);let r=0;return r=e.reduce((e,o)=>path2.isA(o)||geom2.isA(o)?Math.max(e,2):geom3.isA(o)?Math.max(e,3):0,r),calculateEpsilonFromBounds(o,r)};module.exports=measureAggregateEpsilon; -},{"../geometries":169,"../utils/flatten":516,"./calculateEpsilonFromBounds":370,"./measureAggregateBoundingBox":373}],375:[function(require,module,exports){ +},{"../geometries":169,"../utils/flatten":517,"./calculateEpsilonFromBounds":370,"./measureAggregateBoundingBox":373}],375:[function(require,module,exports){ const flatten=require("../utils/flatten"),measureVolume=require("./measureVolume"),measureAggregateVolume=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("measureAggregateVolume: no geometries supplied");const r=measureVolume(e);if(1===e.length)return r;return r.reduce((e,r)=>e+r,0)};module.exports=measureAggregateVolume; -},{"../utils/flatten":516,"./measureVolume":383}],376:[function(require,module,exports){ +},{"../utils/flatten":517,"./measureVolume":383}],376:[function(require,module,exports){ const flatten=require("../utils/flatten"),geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),path2=require("../geometries/path2"),poly3=require("../geometries/poly3"),cache=new WeakMap,measureAreaOfPath2=()=>0,measureAreaOfGeom2=e=>{let r=cache.get(e);if(r)return r;return r=geom2.toSides(e).reduce((e,r)=>e+(r[0][0]*r[1][1]-r[0][1]*r[1][0]),0),r*=.5,cache.set(e,r),r},measureAreaOfGeom3=e=>{let r=cache.get(e);if(r)return r;return r=geom3.toPolygons(e).reduce((e,r)=>e+poly3.measureArea(r),0),cache.set(e,r),r},measureArea=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");const r=e.map(e=>path2.isA(e)?0:geom2.isA(e)?measureAreaOfGeom2(e):geom3.isA(e)?measureAreaOfGeom3(e):0);return 1===r.length?r[0]:r};module.exports=measureArea; -},{"../geometries/geom2":144,"../geometries/geom3":160,"../geometries/path2":181,"../geometries/poly3":198,"../utils/flatten":516}],377:[function(require,module,exports){ +},{"../geometries/geom2":144,"../geometries/geom3":160,"../geometries/path2":181,"../geometries/poly3":198,"../utils/flatten":517}],377:[function(require,module,exports){ const flatten=require("../utils/flatten"),vec2=require("../maths/vec2"),vec3=require("../maths/vec3"),geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),path2=require("../geometries/path2"),poly3=require("../geometries/poly3"),cache=new WeakMap,measureBoundingBoxOfPath2=e=>{let o=cache.get(e);if(o)return o;const t=path2.toPoints(e);let n;n=0===t.length?vec2.create():vec2.clone(t[0]);let r=vec2.clone(n);return t.forEach(e=>{vec2.min(n,n,e),vec2.max(r,r,e)}),n=[n[0],n[1],0],r=[r[0],r[1],0],o=[n,r],cache.set(e,o),o},measureBoundingBoxOfGeom2=e=>{let o=cache.get(e);if(o)return o;const t=geom2.toPoints(e);let n;n=0===t.length?vec2.create():vec2.clone(t[0]);let r=vec2.clone(n);return t.forEach(e=>{vec2.min(n,n,e),vec2.max(r,r,e)}),n=[n[0],n[1],0],r=[r[0],r[1],0],o=[n,r],cache.set(e,o),o},measureBoundingBoxOfGeom3=e=>{let o=cache.get(e);if(o)return o;const t=geom3.toPolygons(e);let n=vec3.create();if(t.length>0){const e=poly3.toPoints(t[0]);vec3.copy(n,e[0])}let r=vec3.clone(n);return t.forEach(e=>{poly3.toPoints(e).forEach(e=>{vec3.min(n,n,e),vec3.max(r,r,e)})}),n=[n[0],n[1],n[2]],r=[r[0],r[1],r[2]],o=[n,r],cache.set(e,o),o},measureBoundingBox=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");const o=e.map(e=>path2.isA(e)?measureBoundingBoxOfPath2(e):geom2.isA(e)?measureBoundingBoxOfGeom2(e):geom3.isA(e)?measureBoundingBoxOfGeom3(e):[[0,0,0],[0,0,0]]);return 1===o.length?o[0]:o};module.exports=measureBoundingBox; -},{"../geometries/geom2":144,"../geometries/geom3":160,"../geometries/path2":181,"../geometries/poly3":198,"../maths/vec2":310,"../maths/vec3":341,"../utils/flatten":516}],378:[function(require,module,exports){ +},{"../geometries/geom2":144,"../geometries/geom3":160,"../geometries/path2":181,"../geometries/poly3":198,"../maths/vec2":310,"../maths/vec3":341,"../utils/flatten":517}],378:[function(require,module,exports){ const flatten=require("../utils/flatten"),vec2=require("../maths/vec2"),vec3=require("../maths/vec3"),geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),path2=require("../geometries/path2"),poly3=require("../geometries/poly3"),cacheOfBoundingSpheres=new WeakMap,measureBoundingSphereOfPath2=e=>{let t=cacheOfBoundingSpheres.get(e);if(void 0!==t)return t;const r=vec3.create();let o=0;const c=path2.toPoints(e);if(c.length>0){let e=0;const t=vec3.create();c.forEach(o=>{vec3.add(r,r,vec3.fromVec2(t,o,0)),e++}),vec3.scale(r,r,1/e),c.forEach(e=>{o=Math.max(o,vec2.squaredDistance(r,e))}),o=Math.sqrt(o)}return t=[r,o],cacheOfBoundingSpheres.set(e,t),t},measureBoundingSphereOfGeom2=e=>{let t=cacheOfBoundingSpheres.get(e);if(void 0!==t)return t;const r=vec3.create();let o=0;const c=geom2.toSides(e);if(c.length>0){let e=0;const t=vec3.create();c.forEach(o=>{vec3.add(r,r,vec3.fromVec2(t,o[0],0)),e++}),vec3.scale(r,r,1/e),c.forEach(e=>{o=Math.max(o,vec2.squaredDistance(r,e[0]))}),o=Math.sqrt(o)}return t=[r,o],cacheOfBoundingSpheres.set(e,t),t},measureBoundingSphereOfGeom3=e=>{let t=cacheOfBoundingSpheres.get(e);if(void 0!==t)return t;const r=vec3.create();let o=0;const c=geom3.toPolygons(e);if(c.length>0){let e=0;c.forEach(t=>{poly3.toPoints(t).forEach(t=>{vec3.add(r,r,t),e++})}),vec3.scale(r,r,1/e),c.forEach(e=>{poly3.toPoints(e).forEach(e=>{o=Math.max(o,vec3.squaredDistance(r,e))})}),o=Math.sqrt(o)}return t=[r,o],cacheOfBoundingSpheres.set(e,t),t},measureBoundingSphere=(...e)=>{const t=(e=flatten(e)).map(e=>path2.isA(e)?measureBoundingSphereOfPath2(e):geom2.isA(e)?measureBoundingSphereOfGeom2(e):geom3.isA(e)?measureBoundingSphereOfGeom3(e):[[0,0,0],0]);return 1===t.length?t[0]:t};module.exports=measureBoundingSphere; -},{"../geometries/geom2":144,"../geometries/geom3":160,"../geometries/path2":181,"../geometries/poly3":198,"../maths/vec2":310,"../maths/vec3":341,"../utils/flatten":516}],379:[function(require,module,exports){ +},{"../geometries/geom2":144,"../geometries/geom3":160,"../geometries/path2":181,"../geometries/poly3":198,"../maths/vec2":310,"../maths/vec3":341,"../utils/flatten":517}],379:[function(require,module,exports){ const flatten=require("../utils/flatten"),measureBoundingBox=require("./measureBoundingBox"),measureCenter=(...e)=>{const n=(e=flatten(e)).map(e=>{const n=measureBoundingBox(e);return[n[0][0]+(n[1][0]-n[0][0])/2,n[0][1]+(n[1][1]-n[0][1])/2,n[0][2]+(n[1][2]-n[0][2])/2]});return 1===n.length?n[0]:n};module.exports=measureCenter; -},{"../utils/flatten":516,"./measureBoundingBox":377}],380:[function(require,module,exports){ +},{"../utils/flatten":517,"./measureBoundingBox":377}],380:[function(require,module,exports){ const flatten=require("../utils/flatten"),vec3=require("../maths/vec3"),geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),cacheOfCenterOfMass=new WeakMap,measureCenterOfMassGeom2=e=>{let t=cacheOfCenterOfMass.get(e);if(void 0!==t)return t;const s=geom2.toSides(e);let r=0,c=0,a=0;if(s.length>0){for(let e=0;e{let t=cacheOfCenterOfMass.get(e);if(void 0!==t)return t;t=vec3.create();const s=geom3.toPolygons(e);if(0===s.length)return t;let r=0;const c=vec3.create();return s.forEach(e=>{const s=e.vertices;for(let e=0;e{const t=(e=flatten(e)).map(e=>geom2.isA(e)?measureCenterOfMassGeom2(e):geom3.isA(e)?measureCenterOfMassGeom3(e):[0,0,0]);return 1===t.length?t[0]:t};module.exports=measureCenterOfMass; -},{"../geometries/geom2":144,"../geometries/geom3":160,"../maths/vec3":341,"../utils/flatten":516}],381:[function(require,module,exports){ +},{"../geometries/geom2":144,"../geometries/geom3":160,"../maths/vec3":341,"../utils/flatten":517}],381:[function(require,module,exports){ const flatten=require("../utils/flatten"),measureBoundingBox=require("./measureBoundingBox"),measureDimensions=(...e)=>{const n=(e=flatten(e)).map(e=>{const n=measureBoundingBox(e);return[n[1][0]-n[0][0],n[1][1]-n[0][1],n[1][2]-n[0][2]]});return 1===n.length?n[0]:n};module.exports=measureDimensions; -},{"../utils/flatten":516,"./measureBoundingBox":377}],382:[function(require,module,exports){ +},{"../utils/flatten":517,"./measureBoundingBox":377}],382:[function(require,module,exports){ const flatten=require("../utils/flatten"),{geom2:geom2,geom3:geom3,path2:path2}=require("../geometries"),calculateEpsilonFromBounds=require("./calculateEpsilonFromBounds"),measureBoundingBox=require("./measureBoundingBox"),measureEpsilonOfPath2=e=>calculateEpsilonFromBounds(measureBoundingBox(e),2),measureEpsilonOfGeom2=e=>calculateEpsilonFromBounds(measureBoundingBox(e),2),measureEpsilonOfGeom3=e=>calculateEpsilonFromBounds(measureBoundingBox(e),3),measureEpsilon=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");const o=e.map(e=>path2.isA(e)?measureEpsilonOfPath2(e):geom2.isA(e)?measureEpsilonOfGeom2(e):geom3.isA(e)?measureEpsilonOfGeom3(e):0);return 1===o.length?o[0]:o};module.exports=measureEpsilon; -},{"../geometries":169,"../utils/flatten":516,"./calculateEpsilonFromBounds":370,"./measureBoundingBox":377}],383:[function(require,module,exports){ +},{"../geometries":169,"../utils/flatten":517,"./calculateEpsilonFromBounds":370,"./measureBoundingBox":377}],383:[function(require,module,exports){ const flatten=require("../utils/flatten"),geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),path2=require("../geometries/path2"),poly3=require("../geometries/poly3"),cache=new WeakMap,measureVolumeOfPath2=()=>0,measureVolumeOfGeom2=()=>0,measureVolumeOfGeom3=e=>{let r=cache.get(e);if(r)return r;return r=geom3.toPolygons(e).reduce((e,r)=>e+poly3.measureSignedVolume(r),0),cache.set(e,r),r},measureVolume=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");const r=e.map(e=>path2.isA(e)?0:geom2.isA(e)?0:geom3.isA(e)?measureVolumeOfGeom3(e):0);return 1===r.length?r[0]:r};module.exports=measureVolume; -},{"../geometries/geom2":144,"../geometries/geom3":160,"../geometries/path2":181,"../geometries/poly3":198,"../utils/flatten":516}],384:[function(require,module,exports){ +},{"../geometries/geom2":144,"../geometries/geom3":160,"../geometries/path2":181,"../geometries/poly3":198,"../utils/flatten":517}],384:[function(require,module,exports){ const vec2=require("../../maths/vec2"),geom2=require("../../geometries/geom2"),fromFakePolygon=(e,o)=>{if(o.vertices.length<4)return null;const r=[],n=o.vertices.filter((e,o)=>e[2]>0&&(r.push(o),!0));if(2!==n.length)throw new Error("Assertion failed: fromFakePolygon: not enough points found");const t=n.map(o=>{const r=Math.round(o[0]/e)*e+0,n=Math.round(o[1]/e)*e+0;return vec2.fromValues(r,n)});if(vec2.equals(t[0],t[1]))return null;const s=r[1]-r[0];if(1!==s&&3!==s)throw new Error("Assertion failed: fromFakePolygon: unknown index ordering");return 1===s&&t.reverse(),t},fromFakePolygons=(e,o)=>{const r=o.map(o=>fromFakePolygon(e,o)).filter(e=>null!==e);return geom2.create(r)};module.exports=fromFakePolygons; },{"../../geometries/geom2":144,"../../maths/vec2":310}],385:[function(require,module,exports){ @@ -1534,13 +1534,13 @@ module.exports={intersect:require("./intersect"),scission:require("./scission"), },{"./intersect":386,"./scission":391,"./subtract":393,"./union":404}],386:[function(require,module,exports){ const flatten=require("../../utils/flatten"),areAllShapesTheSameType=require("../../utils/areAllShapesTheSameType"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),intersectGeom2=require("./intersectGeom2"),intersectGeom3=require("./intersectGeom3"),intersect=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");if(!areAllShapesTheSameType(e))throw new Error("only intersect of the types are supported");const r=e[0];return geom2.isA(r)?intersectGeom2(e):geom3.isA(r)?intersectGeom3(e):r};module.exports=intersect; -},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../utils/areAllShapesTheSameType":514,"../../utils/flatten":516,"./intersectGeom2":387,"./intersectGeom3":388}],387:[function(require,module,exports){ +},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../utils/areAllShapesTheSameType":515,"../../utils/flatten":517,"./intersectGeom2":387,"./intersectGeom3":388}],387:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom3=require("../../geometries/geom3"),measureEpsilon=require("../../measurements/measureEpsilon"),fromFakePolygons=require("./fromFakePolygons"),to3DWalls=require("./to3DWalls"),intersectGeom3=require("./intersectGeom3"),intersect=(...e)=>{const o=(e=flatten(e)).map(e=>to3DWalls({z0:-1,z1:1},e)),r=intersectGeom3(o),t=measureEpsilon(r);return fromFakePolygons(t,geom3.toPolygons(r))};module.exports=intersect; -},{"../../geometries/geom3":160,"../../measurements/measureEpsilon":382,"../../utils/flatten":516,"./fromFakePolygons":384,"./intersectGeom3":388,"./to3DWalls":397}],388:[function(require,module,exports){ +},{"../../geometries/geom3":160,"../../measurements/measureEpsilon":382,"../../utils/flatten":517,"./fromFakePolygons":384,"./intersectGeom3":388,"./to3DWalls":397}],388:[function(require,module,exports){ const flatten=require("../../utils/flatten"),retessellate=require("../modifiers/retessellate"),intersectSub=require("./intersectGeom3Sub"),intersect=(...e)=>{let t=(e=flatten(e)).shift();return e.forEach(e=>{t=intersectSub(t,e)}),t=retessellate(t)};module.exports=intersect; -},{"../../utils/flatten":516,"../modifiers/retessellate":474,"./intersectGeom3Sub":389}],389:[function(require,module,exports){ +},{"../../utils/flatten":517,"../modifiers/retessellate":475,"./intersectGeom3Sub":389}],389:[function(require,module,exports){ const geom3=require("../../geometries/geom3"),mayOverlap=require("./mayOverlap"),{Tree:Tree}=require("./trees"),intersectGeom3Sub=(e,o)=>{if(!mayOverlap(e,o))return geom3.create();const r=new Tree(geom3.toPolygons(e)),t=new Tree(geom3.toPolygons(o));r.invert(),t.clipTo(r),t.invert(),r.clipTo(t),t.clipTo(r),r.addPolygons(t.allPolygons()),r.invert();const n=r.allPolygons();return geom3.create(n)};module.exports=intersectGeom3Sub; },{"../../geometries/geom3":160,"./mayOverlap":390,"./trees":401}],390:[function(require,module,exports){ @@ -1549,19 +1549,19 @@ const{EPS:EPS}=require("../../maths/constants"),measureBoundingBox=require("../. },{"../../maths/constants":213,"../../measurements/measureBoundingBox":377}],391:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom3=require("../../geometries/geom3"),scissionGeom3=require("./scissionGeom3"),scission=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");const s=e.map(e=>geom3.isA(e)?scissionGeom3(e):e);return 1===s.length?s[0]:s};module.exports=scission; -},{"../../geometries/geom3":160,"../../utils/flatten":516,"./scissionGeom3":392}],392:[function(require,module,exports){ +},{"../../geometries/geom3":160,"../../utils/flatten":517,"./scissionGeom3":392}],392:[function(require,module,exports){ const vec3=require("../../maths/vec3"),measureEpsilon=require("../../measurements/measureEpsilon"),geom3=require("../../geometries/geom3"),sortNb=e=>e.sort((e,s)=>e-s).filter((e,s,o)=>!s||e!==o[s-1]),insertMapping=(e,s,o)=>{const t=`${s}`,n=e.get(t);void 0===n?e.set(t,[o]):n.push(o)},findMapping=(e,s)=>{const o=`${s}`;return e.get(o)},scissionGeom3=e=>{const s=measureEpsilon(e),o=geom3.toPolygons(e),t=o.length,n=new Map,r=vec3.create();o.forEach((e,o)=>{e.vertices.forEach(e=>{insertMapping(n,vec3.snap(r,e,s),o)})});const c=o.map(e=>{let o=[];return e.vertices.forEach(e=>{o=o.concat(findMapping(n,vec3.snap(r,e,s)))}),{e:1,d:sortNb(o)}});n.clear();let i=0;const a=c.length;for(let e=0;e0){const o=new Array(t);o[e]=!0;do{i=0,o.forEach((e,s)=>{const t=c[s];if(t.e>0){t.e=-1;for(let e=0;e0);s.indexes=o}}const p=[];for(let e=0;es.push(o[t])),p.push(geom3.create(s))}return p};module.exports=scissionGeom3; },{"../../geometries/geom3":160,"../../maths/vec3":341,"../../measurements/measureEpsilon":382}],393:[function(require,module,exports){ const flatten=require("../../utils/flatten"),areAllShapesTheSameType=require("../../utils/areAllShapesTheSameType"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),subtractGeom2=require("./subtractGeom2"),subtractGeom3=require("./subtractGeom3"),subtract=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");if(!areAllShapesTheSameType(e))throw new Error("only subtract of the types are supported");const r=e[0];return geom2.isA(r)?subtractGeom2(e):geom3.isA(r)?subtractGeom3(e):r};module.exports=subtract; -},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../utils/areAllShapesTheSameType":514,"../../utils/flatten":516,"./subtractGeom2":394,"./subtractGeom3":395}],394:[function(require,module,exports){ +},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../utils/areAllShapesTheSameType":515,"../../utils/flatten":517,"./subtractGeom2":394,"./subtractGeom3":395}],394:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom3=require("../../geometries/geom3"),measureEpsilon=require("../../measurements/measureEpsilon"),fromFakePolygons=require("./fromFakePolygons"),to3DWalls=require("./to3DWalls"),subtractGeom3=require("./subtractGeom3"),subtract=(...e)=>{const o=(e=flatten(e)).map(e=>to3DWalls({z0:-1,z1:1},e)),r=subtractGeom3(o),t=measureEpsilon(r);return fromFakePolygons(t,geom3.toPolygons(r))};module.exports=subtract; -},{"../../geometries/geom3":160,"../../measurements/measureEpsilon":382,"../../utils/flatten":516,"./fromFakePolygons":384,"./subtractGeom3":395,"./to3DWalls":397}],395:[function(require,module,exports){ +},{"../../geometries/geom3":160,"../../measurements/measureEpsilon":382,"../../utils/flatten":517,"./fromFakePolygons":384,"./subtractGeom3":395,"./to3DWalls":397}],395:[function(require,module,exports){ const flatten=require("../../utils/flatten"),retessellate=require("../modifiers/retessellate"),subtractSub=require("./subtractGeom3Sub"),subtract=(...t)=>{let e=(t=flatten(t)).shift();return t.forEach(t=>{e=subtractSub(e,t)}),e=retessellate(e)};module.exports=subtract; -},{"../../utils/flatten":516,"../modifiers/retessellate":474,"./subtractGeom3Sub":396}],396:[function(require,module,exports){ +},{"../../utils/flatten":517,"../modifiers/retessellate":475,"./subtractGeom3Sub":396}],396:[function(require,module,exports){ const geom3=require("../../geometries/geom3"),mayOverlap=require("./mayOverlap"),{Tree:Tree}=require("./trees"),subtractGeom3Sub=(e,o)=>{if(!mayOverlap(e,o))return geom3.clone(e);const r=new Tree(geom3.toPolygons(e)),t=new Tree(geom3.toPolygons(o));r.invert(),r.clipTo(t),t.clipTo(r,!0),r.addPolygons(t.allPolygons()),r.invert();const l=r.allPolygons();return geom3.create(l)};module.exports=subtractGeom3Sub; },{"../../geometries/geom3":160,"./mayOverlap":390,"./trees":401}],397:[function(require,module,exports){ @@ -1588,19 +1588,19 @@ const{EPS:EPS}=require("../../../maths/constants"),plane=require("../../../maths },{"../../../geometries/poly3":198,"../../../maths/constants":213,"../../../maths/plane":282,"../../../maths/vec3":341,"./splitLineSegmentByPlane":402}],404:[function(require,module,exports){ const flatten=require("../../utils/flatten"),areAllShapesTheSameType=require("../../utils/areAllShapesTheSameType"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),unionGeom2=require("./unionGeom2"),unionGeom3=require("./unionGeom3"),union=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");if(!areAllShapesTheSameType(e))throw new Error("only unions of the same type are supported");const o=e[0];return geom2.isA(o)?unionGeom2(e):geom3.isA(o)?unionGeom3(e):o};module.exports=union; -},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../utils/areAllShapesTheSameType":514,"../../utils/flatten":516,"./unionGeom2":405,"./unionGeom3":406}],405:[function(require,module,exports){ +},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../utils/areAllShapesTheSameType":515,"../../utils/flatten":517,"./unionGeom2":405,"./unionGeom3":406}],405:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom3=require("../../geometries/geom3"),measureEpsilon=require("../../measurements/measureEpsilon"),fromFakePolygons=require("./fromFakePolygons"),to3DWalls=require("./to3DWalls"),unionGeom3=require("./unionGeom3"),union=(...e)=>{const o=(e=flatten(e)).map(e=>to3DWalls({z0:-1,z1:1},e)),n=unionGeom3(o),r=measureEpsilon(n);return fromFakePolygons(r,geom3.toPolygons(n))};module.exports=union; -},{"../../geometries/geom3":160,"../../measurements/measureEpsilon":382,"../../utils/flatten":516,"./fromFakePolygons":384,"./to3DWalls":397,"./unionGeom3":406}],406:[function(require,module,exports){ +},{"../../geometries/geom3":160,"../../measurements/measureEpsilon":382,"../../utils/flatten":517,"./fromFakePolygons":384,"./to3DWalls":397,"./unionGeom3":406}],406:[function(require,module,exports){ const flatten=require("../../utils/flatten"),retessellate=require("../modifiers/retessellate"),unionSub=require("./unionGeom3Sub"),union=(...e)=>{let t;for(e=flatten(e),t=1;t{if(!mayOverlap(e,o))return unionForNonIntersecting(e,o);const n=new Tree(geom3.toPolygons(e)),r=new Tree(geom3.toPolygons(o));n.clipTo(r,!1),r.clipTo(n),r.invert(),r.clipTo(n),r.invert();const t=n.allPolygons().concat(r.allPolygons());return geom3.create(t)},unionForNonIntersecting=(e,o)=>{let n=geom3.toPolygons(e);return n=n.concat(geom3.toPolygons(o)),geom3.create(n)};module.exports=unionSub; },{"../../geometries/geom3":160,"./mayOverlap":390,"./trees":401}],408:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),expandGeom2=require("./expandGeom2"),expandGeom3=require("./expandGeom3"),expandPath2=require("./expandPath2"),expand=(e,...r)=>{if(0===(r=flatten(r)).length)throw new Error("wrong number of arguments");const t=r.map(r=>path2.isA(r)?expandPath2(e,r):geom2.isA(r)?expandGeom2(e,r):geom3.isA(r)?expandGeom3(e,r):r);return 1===t.length?t[0]:t};module.exports=expand; -},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../geometries/path2":181,"../../utils/flatten":516,"./expandGeom2":409,"./expandGeom3":410,"./expandPath2":411}],409:[function(require,module,exports){ +},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../geometries/path2":181,"../../utils/flatten":517,"./expandGeom2":409,"./expandGeom3":410,"./expandPath2":411}],409:[function(require,module,exports){ const geom2=require("../../geometries/geom2"),offsetFromPoints=require("./offsetFromPoints"),expandGeom2=(e,o)=>{const{delta:r,corners:s,segments:t}=Object.assign({},{delta:1,corners:"edge",segments:16},e);if("edge"!==s&&"chamfer"!==s&&"round"!==s)throw new Error('corners must be "edge", "chamfer", or "round"');const n=geom2.toOutlines(o).map(o=>offsetFromPoints(e={delta:r,corners:s,closed:!0,segments:t},o)).reduce((e,o)=>e.concat(geom2.toSides(geom2.fromPoints(o))),[]);return geom2.create(n)};module.exports=expandGeom2; },{"../../geometries/geom2":144,"./offsetFromPoints":416}],410:[function(require,module,exports){ @@ -1612,7 +1612,7 @@ const area=require("../../maths/utils/area"),vec2=require("../../maths/vec2"),ge },{"../../geometries/geom2":144,"../../geometries/path2":181,"../../maths/utils/area":287,"../../maths/vec2":310,"./offsetFromPoints":416}],412:[function(require,module,exports){ const{EPS:EPS,TAU:TAU}=require("../../maths/constants"),mat4=require("../../maths/mat4"),vec3=require("../../maths/vec3"),fnNumberSort=require("../../utils/fnNumberSort"),geom3=require("../../geometries/geom3"),poly3=require("../../geometries/poly3"),sphere=require("../../primitives/sphere"),retessellate=require("../modifiers/retessellate"),unionGeom3Sub=require("../booleans/unionGeom3Sub"),extrudePolygon=require("./extrudePolygon"),mapPlaneToVertex=(e,t,o)=>{const n=t.toString();if(e.has(n)){e.get(n)[1].push(o)}else{const s=[t,[o]];e.set(n,s)}},mapPlaneToEdge=(e,t,o)=>{const n=t[0].toString(),s=t[1].toString(),r=n{e.findIndex(e=>e===t)<0&&e.push(t)},expandShell=(e,t)=>{const{delta:o,segments:n}=Object.assign({},{delta:1,segments:12},e);let s=geom3.create();const r=new Map,c=new Map,a=vec3.create(),l=vec3.create();return geom3.toPolygons(t).forEach((e,t)=>{const n=vec3.scale(vec3.create(),poly3.plane(e),2*o),a=poly3.transform(mat4.fromTranslation(mat4.create(),vec3.scale(vec3.create(),n,-.5)),e),l=extrudePolygon(n,a);s=unionGeom3Sub(s,l);const u=e.vertices;for(let t=0;t{const t=e[0],r=e[1],c=t[0],u=t[1],i=vec3.subtract(vec3.create(),u,c);vec3.normalize(i,i);const m=r[0],g=vec3.cross(vec3.create(),m,i);let p=[];for(let e=0;e=0&&vec3.distance(r,v)=0){f.push(r),S.push(i);const e=[d,i,r,v],t=poly3.create(e);q.push(t)}v=r,d=i}}S.reverse(),q.push(poly3.create(f)),q.push(poly3.create(S));const y=geom3.create(q);s=unionGeom3Sub(s,y)}),r.forEach(e=>{const t=e[0],r=e[1],c=r[0];let u=null,i=0;for(let e=1;e.05&&n>i&&(i=n,u=t)}u||(u=vec3.orthogonal(a,c));const m=vec3.cross(a,c,u);vec3.normalize(m,m);const g=vec3.cross(l,m,c),p=sphere({center:[t[0],t[1],t[2]],radius:o,segments:n,axes:[c,m,g]});s=unionGeom3Sub(s,p)}),retessellate(s)};module.exports=expandShell; -},{"../../geometries/geom3":160,"../../geometries/poly3":198,"../../maths/constants":213,"../../maths/mat4":262,"../../maths/vec3":341,"../../primitives/sphere":504,"../../utils/fnNumberSort":517,"../booleans/unionGeom3Sub":407,"../modifiers/retessellate":474,"./extrudePolygon":413}],413:[function(require,module,exports){ +},{"../../geometries/geom3":160,"../../geometries/poly3":198,"../../maths/constants":213,"../../maths/mat4":262,"../../maths/vec3":341,"../../primitives/sphere":505,"../../utils/fnNumberSort":518,"../booleans/unionGeom3Sub":407,"../modifiers/retessellate":475,"./extrudePolygon":413}],413:[function(require,module,exports){ const mat4=require("../../maths/mat4"),vec3=require("../../maths/vec3"),geom3=require("../../geometries/geom3"),poly3=require("../../geometries/poly3"),extrudePolygon=(e,r)=>{vec3.dot(poly3.plane(r),e)>0&&(r=poly3.invert(r));const t=[r],o=poly3.transform(mat4.fromTranslation(mat4.create(),e),r),s=r.vertices.length;for(let e=0;e{if(0===(t=flatten(t)).length)throw new Error("wrong number of arguments");const o=t.map(t=>path2.isA(t)?offsetPath2(e,t):geom2.isA(t)?offsetGeom2(e,t):t);return 1===o.length?o[0]:o};module.exports=offset; -},{"../../geometries/geom2":144,"../../geometries/path2":181,"../../utils/flatten":516,"./offsetGeom2":417,"./offsetPath2":418}],416:[function(require,module,exports){ +},{"../../geometries/geom2":144,"../../geometries/path2":181,"../../utils/flatten":517,"./offsetGeom2":417,"./offsetPath2":418}],416:[function(require,module,exports){ const{EPS:EPS,TAU:TAU}=require("../../maths/constants"),intersect=require("../../maths/utils/intersect"),line2=require("../../maths/line2"),vec2=require("../../maths/vec2"),area=require("../../maths/utils/area"),offsetFromPoints=(e,t)=>{let{delta:s,corners:c,closed:n,segments:a}=Object.assign({},{delta:1,corners:"edge",closed:!1,segments:16},e);if(Math.abs(s)0&&s>=0||r<0&&s<0;s=Math.abs(s);let i=null,l=[];const u=[],v=vec2.create(),f=t.length;for(let e=0;ee.set(t,s));const t=line2.create(),s=line2.create();u.forEach(c=>{line2.fromPoints(t,c.s0[0],c.s0[1]),line2.fromPoints(s,c.s1[0],c.s1[1]);const n=line2.intersectPointOfLines(t,s);if(Number.isFinite(n[0])&&Number.isFinite(n[1])){const t=c.s0[1],s=e.get(t);l[s]=n,l[(s+1)%l.length]=void 0}else{const t=c.s1[0],s=e.get(t);l[s]=void 0}}),l=l.filter(e=>void 0!==e)}if("round"===c){let e=Math.floor(a/4);const t=vec2.create();u.forEach(c=>{let n=vec2.angle(vec2.subtract(t,c.s1[0],c.c));if(n-=vec2.angle(vec2.subtract(t,c.s0[1],c.c)),o&&n<0&&(n+=Math.PI)<0&&(n+=Math.PI),!o&&n>0&&(n-=Math.PI)>0&&(n-=Math.PI),0!==n){const r=n/(e=Math.floor(a*(Math.abs(n)/TAU))),o=vec2.angle(vec2.subtract(t,c.s0[1],c.c)),i=[];for(let t=1;t0){const e=c.s0[1];let t=l.findIndex(t=>vec2.equals(e,t));t=(t+1)%l.length,l.splice(t,0,...i)}}else{const e=c.s1[0],t=l.findIndex(t=>vec2.equals(e,t));l.splice(t,1)}})}return l};module.exports=offsetFromPoints; },{"../../maths/constants":213,"../../maths/line2":224,"../../maths/utils/area":287,"../../maths/utils/intersect":290,"../../maths/vec2":310}],417:[function(require,module,exports){ @@ -1663,7 +1663,7 @@ const{TAU:TAU}=require("../../maths/constants"),slice=require("./slice"),mat4=re },{"../../geometries/geom2":144,"../../maths/constants":213,"../../maths/mat4":262,"./extrudeFromSlices":427,"./slice":445}],429:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom2=require("../../geometries/geom2"),path2=require("../../geometries/path2"),extrudeLinearGeom2=require("./extrudeLinearGeom2"),extrudeLinearPath2=require("./extrudeLinearPath2"),extrudeLinear=(e,...t)=>{const{height:r,twistAngle:i,twistSteps:n,repair:a}=Object.assign({},{height:1,twistAngle:0,twistSteps:1,repair:!0},e);if(0===(t=flatten(t)).length)throw new Error("wrong number of arguments");e={offset:[0,0,r],twistAngle:i,twistSteps:n,repair:a};const s=t.map(t=>path2.isA(t)?extrudeLinearPath2(e,t):geom2.isA(t)?extrudeLinearGeom2(e,t):t);return 1===s.length?s[0]:s};module.exports=extrudeLinear; -},{"../../geometries/geom2":144,"../../geometries/path2":181,"../../utils/flatten":516,"./extrudeLinearGeom2":430,"./extrudeLinearPath2":431}],430:[function(require,module,exports){ +},{"../../geometries/geom2":144,"../../geometries/path2":181,"../../utils/flatten":517,"./extrudeLinearGeom2":430,"./extrudeLinearPath2":431}],430:[function(require,module,exports){ const mat4=require("../../maths/mat4"),vec3=require("../../maths/vec3"),geom2=require("../../geometries/geom2"),slice=require("./slice"),extrudeFromSlices=require("./extrudeFromSlices"),extrudeGeom2=(e,t)=>{let{offset:r,twistAngle:s,twistSteps:o,repair:i}=Object.assign({},{offset:[0,0,1],twistAngle:0,twistSteps:12,repair:!0},e);if(o<1)throw new Error("twistSteps must be 1 or more");0===s&&(o=1);const c=vec3.clone(r),m=geom2.toSides(t);if(0===m.length)throw new Error("the given geometry cannot be empty");const a=slice.fromSides(m);c[2]<0&&slice.reverse(a,a);const n=mat4.create();return extrudeFromSlices(e={numberOfSlices:o+1,capStart:!0,capEnd:!0,repair:i,callback:(e,t,r)=>{const i=t/o*s,m=vec3.scale(vec3.create(),c,t/o);return mat4.multiply(n,mat4.fromZRotation(n,i),mat4.fromTranslation(mat4.create(),m)),slice.transform(n,r)}},a)};module.exports=extrudeGeom2; },{"../../geometries/geom2":144,"../../maths/mat4":262,"../../maths/vec3":341,"./extrudeFromSlices":427,"./slice":445}],431:[function(require,module,exports){ @@ -1672,7 +1672,7 @@ const geom2=require("../../geometries/geom2"),path2=require("../../geometries/pa },{"../../geometries/geom2":144,"../../geometries/path2":181,"./extrudeLinearGeom2":430}],432:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom2=require("../../geometries/geom2"),path2=require("../../geometries/path2"),extrudeRectangularPath2=require("./extrudeRectangularPath2"),extrudeRectangularGeom2=require("./extrudeRectangularGeom2"),extrudeRectangular=(e,...t)=>{const{size:r,height:a}=Object.assign({},{size:1,height:1},e);if(0===(t=flatten(t)).length)throw new Error("wrong number of arguments");if(r<=0)throw new Error("size must be positive");if(a<=0)throw new Error("height must be positive");const u=t.map(t=>path2.isA(t)?extrudeRectangularPath2(e,t):geom2.isA(t)?extrudeRectangularGeom2(e,t):t);return 1===u.length?u[0]:u};module.exports=extrudeRectangular; -},{"../../geometries/geom2":144,"../../geometries/path2":181,"../../utils/flatten":516,"./extrudeRectangularGeom2":433,"./extrudeRectangularPath2":434}],433:[function(require,module,exports){ +},{"../../geometries/geom2":144,"../../geometries/path2":181,"../../utils/flatten":517,"./extrudeRectangularGeom2":433,"./extrudeRectangularPath2":434}],433:[function(require,module,exports){ const{area:area}=require("../../maths/utils"),geom2=require("../../geometries/geom2"),path2=require("../../geometries/path2"),expand=require("../expansions/expand"),extrudeLinearGeom2=require("./extrudeLinearGeom2"),extrudeRectangularGeom2=(e,r)=>{const{size:t,height:o}=Object.assign({},{size:1,height:1},e);e.delta=t,e.offset=[0,0,o];const a=geom2.toOutlines(r);if(0===a.length)throw new Error("the given geometry cannot be empty");const n=a.map(r=>(area(r)<0&&r.reverse(),expand(e,path2.fromPoints({closed:!0},r)))).reduce((e,r)=>e.concat(geom2.toSides(r)),[]),i=geom2.create(n);return extrudeLinearGeom2(e,i)};module.exports=extrudeRectangularGeom2; },{"../../geometries/geom2":144,"../../geometries/path2":181,"../../maths/utils":288,"../expansions/expand":408,"./extrudeLinearGeom2":430}],434:[function(require,module,exports){ @@ -1681,7 +1681,7 @@ const path2=require("../../geometries/path2"),expand=require("../expansions/expa },{"../../geometries/path2":181,"../expansions/expand":408,"./extrudeLinearGeom2":430}],435:[function(require,module,exports){ const{TAU:TAU}=require("../../maths/constants"),mat4=require("../../maths/mat4"),{mirrorX:mirrorX}=require("../transforms/mirror"),geom2=require("../../geometries/geom2"),slice=require("./slice"),extrudeFromSlices=require("./extrudeFromSlices"),extrudeRotate=(e,t)=>{const r={segments:12,startAngle:0,angle:TAU,overflow:"cap"};let{segments:a,startAngle:o,angle:s,overflow:m}=Object.assign({},r,e);if(a<3)throw new Error("segments must be greater then 3");o=Math.abs(o)>TAU?o%TAU:o,s=Math.abs(s)>TAU?s%TAU:s;let n=o+s;if((n=Math.abs(n)>TAU?n%TAU:n)a*e&&a++}let i=geom2.toSides(t);if(0===i.length)throw new Error("the given geometry cannot be empty");const c=i.filter(e=>e[0][0]<0),g=i.filter(e=>e[0][0]>=0);c.length>0&&g.length>0&&"cap"===m&&(c.length>g.length?(i=i.map(e=>{let t=e[0],r=e[1];return[t=[Math.min(t[0],0),t[1]],r=[Math.min(r[0],0),r[1]]]}),t=geom2.create(i),t=mirrorX(t)):g.length>=c.length&&(i=i.map(e=>{let t=e[0],r=e[1];return[t=[Math.max(t[0],0),t[1]],r=[Math.max(r[0],0),r[1]]]}),t=geom2.create(i)));const h=l/a,u=Math.abs(l){let s=h*t+o;return l===TAU&&t===a&&(s=o),mat4.multiply(f,mat4.fromZRotation(f,s),mat4.fromXRotation(mat4.create(),TAU/4)),slice.transform(f,r)}},A)};module.exports=extrudeRotate; -},{"../../geometries/geom2":144,"../../maths/constants":213,"../../maths/mat4":262,"../transforms/mirror":481,"./extrudeFromSlices":427,"./slice":445}],436:[function(require,module,exports){ +},{"../../geometries/geom2":144,"../../maths/constants":213,"../../maths/mat4":262,"../transforms/mirror":482,"./extrudeFromSlices":427,"./slice":445}],436:[function(require,module,exports){ const{EPS:EPS}=require("../../maths/constants"),vec3=require("../../maths/vec3"),poly3=require("../../geometries/poly3"),slice=require("./slice"),gcd=(e,t)=>e===t?e:ee*t/gcd(e,t),repartitionEdges=(e,t)=>{const r=e/t.length;if(1===r)return t;const s=vec3.fromValues(r,r,r),c=[];return t.forEach(e=>{const t=vec3.subtract(vec3.create(),e[1],e[0]);vec3.divide(t,t,s);let l=e[0];for(let e=1;e<=r;++e){const e=vec3.add(vec3.create(),l,t);c.push([l,e]),l=e}}),c},EPSAREA=EPS*EPS/2*Math.sin(Math.PI/3),extrudeWalls=(e,t)=>{let r=slice.toEdges(e),s=slice.toEdges(t);if(r.length!==s.length){const e=lcm(r.length,s.length);e!==r.length&&(r=repartitionEdges(e,r)),e!==s.length&&(s=repartitionEdges(e,s))}const c=[];return r.forEach((e,t)=>{const r=s[t],l=poly3.create([e[0],e[1],r[1]]),o=poly3.measureArea(l);Number.isFinite(o)&&o>EPSAREA&&c.push(l);const n=poly3.create([e[0],r[1],r[0]]),i=poly3.measureArea(n);Number.isFinite(i)&&i>EPSAREA&&c.push(n)}),c};module.exports=extrudeWalls; },{"../../geometries/poly3":198,"../../maths/constants":213,"../../maths/vec3":341,"./slice":445}],437:[function(require,module,exports){ @@ -1690,7 +1690,7 @@ module.exports={extrudeFromSlices:require("./extrudeFromSlices"),extrudeLinear:r },{"./extrudeFromSlices":427,"./extrudeHelical":428,"./extrudeLinear":429,"./extrudeRectangular":432,"./extrudeRotate":435,"./project":438,"./slice":445}],438:[function(require,module,exports){ const flatten=require("../../utils/flatten"),aboutEqualNormals=require("../../maths/utils/aboutEqualNormals"),plane=require("../../maths/plane"),mat4=require("../../maths/mat4"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),poly3=require("../../geometries/poly3"),measureEpsilon=require("../../measurements/measureEpsilon"),unionGeom2=require("../booleans/unionGeom2"),projectGeom3=(e,o)=>{const r=plane.fromNormalAndPoint(plane.create(),e.axis,e.origin);if(Number.isNaN(r[0])||Number.isNaN(r[1])||Number.isNaN(r[2])||Number.isNaN(r[3]))throw new Error("project: invalid axis or origin");const t=measureEpsilon(o),a=t*t*Math.sqrt(3)/4;if(0===t)return geom2.create();const n=geom3.toPolygons(o);let s=[];for(let e=0;eplane.projectionOfPoint(r,e)),t=poly3.create(o),i=poly3.plane(t);aboutEqualNormals(r,i)&&(poly3.measureArea(t)poly3.transform(e,o))}const i=(s=s.sort((e,o)=>poly3.measureArea(o)-poly3.measureArea(e))).map(e=>geom2.fromPoints(e.vertices));return unionGeom2(i)},project=(e,...o)=>{const{axis:r,origin:t}=Object.assign({},{axis:[0,0,1],origin:[0,0,0]},e);if(0===(o=flatten(o)).length)throw new Error("wrong number of arguments");e={axis:r,origin:t};const a=o.map(o=>geom3.isA(o)?projectGeom3(e,o):o);return 1===a.length?a[0]:a};module.exports=project; -},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../geometries/poly3":198,"../../maths/mat4":262,"../../maths/plane":282,"../../maths/utils/aboutEqualNormals":286,"../../measurements/measureEpsilon":382,"../../utils/flatten":516,"../booleans/unionGeom2":405}],439:[function(require,module,exports){ +},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../geometries/poly3":198,"../../maths/mat4":262,"../../maths/plane":282,"../../maths/utils/aboutEqualNormals":286,"../../measurements/measureEpsilon":382,"../../utils/flatten":517,"../booleans/unionGeom2":405}],439:[function(require,module,exports){ const plane=require("../../../maths/plane"),vec3=require("../../../maths/vec3"),calculatePlane=e=>{const c=e.edges;if(c.length<3)throw new Error("slices must have 3 or more edges to calculate a plane");const a=c.reduce((e,c)=>vec3.add(vec3.create(),e,c[0]),vec3.create());let t;vec3.scale(a,a,1/c.length);let l=0;c.forEach(e=>{if(!vec3.equals(e[0],e[1])){const c=vec3.squaredDistance(a,e[0]);c>l&&(t=e,l=c)}});const r=c.find(e=>vec3.equals(e[1],t[0]));return plane.fromPoints(plane.create(),r[0],t[0],t[1])};module.exports=calculatePlane; },{"../../../maths/plane":282,"../../../maths/vec3":341}],440:[function(require,module,exports){ @@ -1735,547 +1735,550 @@ const vec3=require("../../../maths/vec3"),create=require("./create"),transform=( },{"../../../maths/vec3":341,"./create":441}],453:[function(require,module,exports){ const flatten=require("../../utils/flatten"),areAllShapesTheSameType=require("../../utils/areAllShapesTheSameType"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),hullPath2=require("./hullPath2"),hullGeom2=require("./hullGeom2"),hullGeom3=require("./hullGeom3"),hull=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");if(!areAllShapesTheSameType(e))throw new Error("only hulls of the same type are supported");const l=e[0];return path2.isA(l)?hullPath2(e):geom2.isA(l)?hullGeom2(e):geom3.isA(l)?hullGeom3(e):l};module.exports=hull; -},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../geometries/path2":181,"../../utils/areAllShapesTheSameType":514,"../../utils/flatten":516,"./hullGeom2":455,"./hullGeom3":456,"./hullPath2":457}],454:[function(require,module,exports){ +},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../geometries/path2":181,"../../utils/areAllShapesTheSameType":515,"../../utils/flatten":517,"./hullGeom2":455,"./hullGeom3":456,"./hullPath2":457}],454:[function(require,module,exports){ const flatten=require("../../utils/flatten"),union=require("../booleans/union"),hull=require("./hull"),hullChain=(...n)=>{if((n=flatten(n)).length<2)throw new Error("wrong number of arguments");const e=[];for(let l=1;l{e=flatten(e);const t=toUniquePoints(e),o=hullPoints2(t);return o.length<3?geom2.create():geom2.fromPoints(o)};module.exports=hullGeom2; -},{"../../geometries/geom2":144,"../../utils/flatten":516,"./hullPoints2":458,"./toUniquePoints":468}],456:[function(require,module,exports){ -const flatten=require("../../utils/flatten"),geom3=require("../../geometries/geom3"),poly3=require("../../geometries/poly3"),quickhull=require("./quickhull"),toUniquePoints=require("./toUniquePoints"),hullGeom3=(...e)=>{if(1===(e=flatten(e)).length)return e[0];const t=toUniquePoints(e),o=quickhull(t,{skipTriangulation:!0}).map(e=>{const o=e.map(e=>t[e]);return poly3.create(o)});return geom3.create(o)};module.exports=hullGeom3; +},{"../../geometries/geom2":144,"../../utils/flatten":517,"./hullPoints2":458,"./toUniquePoints":469}],456:[function(require,module,exports){ +const flatten=require("../../utils/flatten"),geom3=require("../../geometries/geom3"),toUniquePoints=require("./toUniquePoints"),hullPoints3=require("./hullPoints3"),hullGeom3=(...e)=>{e=flatten(e);const t=toUniquePoints(e);return 0===t.length?geom3.create():geom3.create(hullPoints3(t))};module.exports=hullGeom3; -},{"../../geometries/geom3":160,"../../geometries/poly3":198,"../../utils/flatten":516,"./quickhull":466,"./toUniquePoints":468}],457:[function(require,module,exports){ +},{"../../geometries/geom3":160,"../../utils/flatten":517,"./hullPoints3":459,"./toUniquePoints":469}],457:[function(require,module,exports){ const flatten=require("../../utils/flatten"),path2=require("../../geometries/path2"),hullPoints2=require("./hullPoints2"),toUniquePoints=require("./toUniquePoints"),hullPath2=(...t)=>{t=flatten(t);const e=toUniquePoints(t),o=hullPoints2(e);return path2.fromPoints({closed:!0},o)};module.exports=hullPath2; -},{"../../geometries/path2":181,"../../utils/flatten":516,"./hullPoints2":458,"./toUniquePoints":468}],458:[function(require,module,exports){ +},{"../../geometries/path2":181,"../../utils/flatten":517,"./hullPoints2":458,"./toUniquePoints":469}],458:[function(require,module,exports){ const vec2=require("../../maths/vec2"),hullPoints2=e=>{let t=vec2.fromValues(1/0,1/0);e.forEach(e=>{(e[1]{const o=fakeAtan2(e[1]-t[1],e[0]-t[0]),s=vec2.squaredDistance(e,t);n.push({point:e,angle:o,distSq:s})}),n.sort((e,t)=>e.angle!==t.angle?e.angle-t.angle:e.distSq-t.distSq);const o=[];return n.forEach(e=>{let t=o.length;for(;t>1&&ccw(o[t-2],o[t-1],e.point)<=Number.EPSILON;)o.pop(),t=o.length;o.push(e.point)}),o},ccw=(e,t,n)=>(t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0]),fakeAtan2=(e,t)=>0===e&&0===t?-1/0:-t/e;module.exports=hullPoints2; },{"../../maths/vec2":310}],459:[function(require,module,exports){ -module.exports={hull:require("./hull"),hullChain:require("./hullChain")}; +const poly3=require("../../geometries/poly3"),quickhull=require("./quickhull"),hullPoints3=l=>{return quickhull(l,{skipTriangulation:!0}).map(u=>{const e=u.map(u=>l[u]);return poly3.create(e)})};module.exports=hullPoints3; + +},{"../../geometries/poly3":198,"./quickhull":467}],460:[function(require,module,exports){ +module.exports={hull:require("./hull"),hullChain:require("./hullChain"),hullPoints2:require("./hullPoints2"),hullPoints3:require("./hullPoints3")}; -},{"./hull":453,"./hullChain":454}],460:[function(require,module,exports){ +},{"./hull":453,"./hullChain":454,"./hullPoints2":458,"./hullPoints3":459}],461:[function(require,module,exports){ const add=require("../../../maths/vec3/add"),copy=require("../../../maths/vec3/copy"),cross=require("../../../maths/vec3/cross"),dot=require("../../../maths/vec3/dot"),length=require("../../../maths/vec3/length"),normalize=require("../../../maths/vec3/normalize"),scale=require("../../../maths/vec3/scale"),subtract=require("../../../maths/vec3/subtract"),HalfEdge=require("./HalfEdge"),VISIBLE=0,NON_CONVEX=1,DELETED=2;class Face{constructor(){this.normal=[],this.centroid=[],this.offset=0,this.outside=null,this.mark=VISIBLE,this.edge=null,this.nVertices=0}getEdge(e){if("number"!=typeof e)throw Error("requires a number");let t=this.edge;for(;e>0;)t=t.next,e-=1;for(;e<0;)t=t.prev,e+=1;return t}computeNormal(){const e=this.edge,t=e.next;let r=t.next;const s=subtract([],t.head().point,e.head().point),o=[],i=[];for(this.nVertices=2,this.normal=[0,0,0];r!==e;)copy(i,s),subtract(s,r.head().point,e.head().point),add(this.normal,this.normal,cross(o,i,s)),r=r.next,this.nVertices+=1;this.area=length(this.normal),this.normal=scale(this.normal,this.normal,1/this.area)}computeNormalMinArea(e){if(this.computeNormal(),this.areat&&(e=r,t=s),r=r.next}while(r!==this.edge);const s=e.tail().point,o=e.head().point,i=subtract([],o,s),n=Math.sqrt(t);scale(i,i,1/n);const a=dot(this.normal,i);scale(i,i,-a),add(this.normal,this.normal,i),normalize(this.normal,this.normal)}}computeCentroid(){this.centroid=[0,0,0];let e=this.edge;do{add(this.centroid,this.centroid,e.head().point),e=e.next}while(e!==this.edge);scale(this.centroid,this.centroid,1/this.nVertices)}computeNormalAndCentroid(e){void 0!==e?this.computeNormalMinArea(e):this.computeNormal(),this.computeCentroid(),this.offset=dot(this.normal,this.centroid)}distanceToPlane(e){return dot(this.normal,e)-this.offset}connectHalfEdges(e,t){let r;if(e.opposite.face===t.opposite.face){const s=t.opposite.face;let o;e===this.edge&&(this.edge=t),3===s.nVertices?(o=t.opposite.prev.opposite,s.mark=DELETED,r=s):(o=t.opposite.next,s.edge===o.prev&&(s.edge=o),o.prev=o.prev.prev,o.prev.next=o),t.prev=e.prev,t.prev.next=t,t.setOpposite(o),s.computeNormalAndCentroid()}else e.next=t,t.prev=e;return r}mergeAdjacentFaces(e,t){const r=e.opposite,s=r.face;t.push(s),s.mark=DELETED;let o,i,n=e.prev,a=e.next,c=r.prev,h=r.next;for(;n.opposite.face===s;)n=n.prev,h=h.next;for(;a.opposite.face===s;)a=a.next,c=c.prev;for(o=h;o!==c.next;o=o.next)o.face=this;return this.edge=a,(i=this.connectHalfEdges(c,a))&&t.push(i),(i=this.connectHalfEdges(n,h))&&t.push(i),this.computeNormalAndCentroid(),t}collectIndices(){const e=[];let t=this.edge;do{e.push(t.head().index),t=t.next}while(t!==this.edge);return e}static createTriangle(e,t,r,s=0){const o=new Face,i=new HalfEdge(e,o),n=new HalfEdge(t,o),a=new HalfEdge(r,o);return i.next=a.prev=n,n.next=i.prev=a,a.next=n.prev=i,o.edge=i,o.computeNormalAndCentroid(s),o}}module.exports={VISIBLE:VISIBLE,NON_CONVEX:1,DELETED:DELETED,Face:Face}; -},{"../../../maths/vec3/add":328,"../../../maths/vec3/copy":331,"../../../maths/vec3/cross":333,"../../../maths/vec3/dot":336,"../../../maths/vec3/length":342,"../../../maths/vec3/normalize":348,"../../../maths/vec3/scale":353,"../../../maths/vec3/subtract":357,"./HalfEdge":461}],461:[function(require,module,exports){ +},{"../../../maths/vec3/add":328,"../../../maths/vec3/copy":331,"../../../maths/vec3/cross":333,"../../../maths/vec3/dot":336,"../../../maths/vec3/length":342,"../../../maths/vec3/normalize":348,"../../../maths/vec3/scale":353,"../../../maths/vec3/subtract":357,"./HalfEdge":462}],462:[function(require,module,exports){ const distance=require("../../../maths/vec3/distance"),squaredDistance=require("../../../maths/vec3/squaredDistance");class HalfEdge{constructor(t,e){this.vertex=t,this.face=e,this.next=null,this.prev=null,this.opposite=null}head(){return this.vertex}tail(){return this.prev?this.prev.vertex:null}length(){return this.tail()?distance(this.tail().point,this.head().point):-1}lengthSquared(){return this.tail()?squaredDistance(this.tail().point,this.head().point):-1}setOpposite(t){this.opposite=t,t.opposite=this}}module.exports=HalfEdge; -},{"../../../maths/vec3/distance":334,"../../../maths/vec3/squaredDistance":355}],462:[function(require,module,exports){ +},{"../../../maths/vec3/distance":334,"../../../maths/vec3/squaredDistance":355}],463:[function(require,module,exports){ const dot=require("../../../maths/vec3/dot"),pointLineDistance=require("./point-line-distance"),getPlaneNormal=require("./get-plane-normal"),VertexList=require("./VertexList"),Vertex=require("./Vertex"),{Face:Face,VISIBLE:VISIBLE,NON_CONVEX:NON_CONVEX,DELETED:DELETED}=require("./Face"),MERGE_NON_CONVEX_WRT_LARGER_FACE=1,MERGE_NON_CONVEX=2;class QuickHull{constructor(e){if(!Array.isArray(e))throw TypeError("input is not a valid array");if(e.length<4)throw Error("cannot build a simplex out of <4 points");this.tolerance=-1,this.nFaces=0,this.nPoints=e.length,this.faces=[],this.newFaces=[],this.claimed=new VertexList,this.unclaimed=new VertexList,this.vertices=[];for(let t=0;tthis.tolerance?this.addVertexToFace(s,t):this.unclaimed.add(s)}}else this.unclaimed.addAll(i)}resolveUnclaimedPoints(e){let t=this.unclaimed.first();for(let i=t;i;i=t){t=i.next;let s,o=this.tolerance;for(let t=0;to&&(o=e,s=a),o>1e3*this.tolerance)break}}s&&this.addVertexToFace(i,s)}}computeExtremes(){const e=[],t=[],i=[],s=[];let o,a;for(o=0;o<3;o+=1)i[o]=s[o]=this.vertices[0];for(o=0;o<3;o+=1)e[o]=t[o]=this.vertices[0].point[o];for(o=1;ot[a]&&(t[a]=n[a],s[a]=c)}return this.tolerance=3*Number.EPSILON*(Math.max(Math.abs(e[0]),Math.abs(t[0]))+Math.max(Math.abs(e[1]),Math.abs(t[1]))+Math.max(Math.abs(e[2]),Math.abs(t[2]))),[i,s]}createInitialSimplex(){const e=this.vertices,[t,i]=this.computeExtremes();let s,o,a,c,n=0,r=0;for(a=0;a<3;a+=1){const e=i[a].point[a]-t[a].point[a];e>n&&(n=e,r=a)}const l=t[r],h=i[r];for(n=0,a=0;an&&(n=t,s=e)}}const d=getPlaneNormal([],l.point,h.point,s.point),p=dot(l.point,d);for(n=-1,a=0;an&&(n=t,o=e)}}const f=[];if(dot(o.point,d)-p<0)for(f.push(Face.createTriangle(l,h,s),Face.createTriangle(o,h,l),Face.createTriangle(o,s,h),Face.createTriangle(o,l,s)),a=0;a<3;a+=1){const e=(a+1)%3;f[a+1].getEdge(2).setOpposite(f[0].getEdge(e)),f[a+1].getEdge(1).setOpposite(f[e+1].getEdge(0))}else for(f.push(Face.createTriangle(l,s,h),Face.createTriangle(o,l,h),Face.createTriangle(o,h,s),Face.createTriangle(o,s,l)),a=0;a<3;a+=1){const e=(a+1)%3;f[a+1].getEdge(2).setOpposite(f[0].getEdge((3-a)%3)),f[a+1].getEdge(0).setOpposite(f[e+1].getEdge(1))}for(a=0;a<4;a+=1)this.faces.push(f[a]);for(a=0;an&&(n=i,e=f[c])}e&&this.addVertexToFace(t,e)}}}reindexFaceAndVertices(){const e=[];for(let t=0;ti&&(i=o,e=t)}return e}}computeHorizon(e,t,i,s){let o;this.deleteFaceVertices(i),i.mark=DELETED,o=t?t.next:t=i.getEdge(0);do{const t=o.opposite,i=t.face;i.mark===VISIBLE&&(i.distanceToPlane(e)>this.tolerance?this.computeHorizon(e,t,i,s):s.push(o)),o=o.next}while(o!==t)}addAdjoiningFace(e,t){const i=Face.createTriangle(e,t.tail(),t.head());return this.faces.push(i),i.getEdge(-1).setOpposite(t.opposite),i.getEdge(0)}addNewFaces(e,t){let i,s;this.newFaces=[];for(let o=0;o=e.nVertices)throw Error("merge recursion limit exceeded");const a=i.opposite.face;let c=!1;if(t===MERGE_NON_CONVEX?(this.oppositeFaceDistance(i)>-this.tolerance||this.oppositeFaceDistance(i.opposite)>-this.tolerance)&&(c=!0):e.area>a.area?this.oppositeFaceDistance(i)>-this.tolerance?c=!0:this.oppositeFaceDistance(i.opposite)>-this.tolerance&&(s=!1):this.oppositeFaceDistance(i.opposite)>-this.tolerance?c=!0:this.oppositeFaceDistance(i)>-this.tolerance&&(s=!1),c){const t=e.mergeAdjacentFaces(i,[]);for(let i=0;i{const a=[0,0,0];return subtract(r,e,s),subtract(a,s,t),cross(r,r,a),normalize(r,r)};module.exports=planeNormal; -},{"../../../maths/vec3/cross":333,"../../../maths/vec3/normalize":348,"../../../maths/vec3/subtract":357}],466:[function(require,module,exports){ +},{"../../../maths/vec3/cross":333,"../../../maths/vec3/normalize":348,"../../../maths/vec3/subtract":357}],467:[function(require,module,exports){ const QuickHull=require("./QuickHull"),runner=(u,l={})=>{const e=new QuickHull(u);return e.build(),e.collectFaces(l.skipTriangulation)};module.exports=runner; -},{"./QuickHull":462}],467:[function(require,module,exports){ +},{"./QuickHull":463}],468:[function(require,module,exports){ const cross=require("../../../maths/vec3/cross"),subtract=require("../../../maths/vec3/subtract"),squaredLength=require("../../../maths/vec3/squaredLength"),distanceSquared=(e,t,r)=>{const s=[],a=[];subtract(s,r,t),subtract(a,e,t);const n=squaredLength(cross([],a,s)),c=squaredLength(s);if(0===c)throw Error("a and b are the same point");return n/c},pointLineDistance=(e,t,r)=>Math.sqrt(distanceSquared(e,t,r));module.exports=pointLineDistance; -},{"../../../maths/vec3/cross":333,"../../../maths/vec3/squaredLength":356,"../../../maths/vec3/subtract":357}],468:[function(require,module,exports){ +},{"../../../maths/vec3/cross":333,"../../../maths/vec3/squaredLength":356,"../../../maths/vec3/subtract":357}],469:[function(require,module,exports){ const geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),toUniquePoints=o=>{const e=new Set,t=[],r=o=>{const r=o.toString();e.has(r)||(t.push(o),e.add(r))};return o.forEach(o=>{geom2.isA(o)?geom2.toPoints(o).forEach(r):geom3.isA(o)?geom3.toPoints(o).forEach(o=>o.forEach(r)):path2.isA(o)&&path2.toPoints(o).forEach(r)}),t};module.exports=toUniquePoints; -},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../geometries/path2":181}],469:[function(require,module,exports){ +},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../geometries/path2":181}],470:[function(require,module,exports){ const flatten=require("../../utils/flatten"),measureEpsilon=require("../../measurements/measureEpsilon"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),snapPolygons=require("./snapPolygons"),mergePolygons=require("./mergePolygons"),insertTjunctions=require("./insertTjunctions"),triangulatePolygons=require("./triangulatePolygons"),generalizePath2=(e,r)=>r,generalizeGeom2=(e,r)=>r,generalizeGeom3=(e,r)=>{const{snap:n,simplify:o,triangulate:t}=Object.assign({},{snap:!1,simplify:!1,triangulate:!1},e),i=measureEpsilon(r);let s=geom3.toPolygons(r);n&&(s=snapPolygons(i,s)),o&&(s=mergePolygons(i,s)),t&&(s=insertTjunctions(s),s=triangulatePolygons(i,s));const g=Object.assign({},r);return g.polygons=s,g},generalize=(e,...r)=>{if(0===(r=flatten(r)).length)throw new Error("wrong number of arguments");const n=r.map(r=>{if(path2.isA(r))return generalizePath2(0,r);if(geom2.isA(r))return generalizeGeom2(0,r);if(geom3.isA(r))return generalizeGeom3(e,r);throw new Error("invalid geometry")});return 1===n.length?n[0]:n};module.exports=generalize; -},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../geometries/path2":181,"../../measurements/measureEpsilon":382,"../../utils/flatten":516,"./insertTjunctions":471,"./mergePolygons":472,"./snapPolygons":476,"./triangulatePolygons":477}],470:[function(require,module,exports){ +},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../geometries/path2":181,"../../measurements/measureEpsilon":382,"../../utils/flatten":517,"./insertTjunctions":472,"./mergePolygons":473,"./snapPolygons":477,"./triangulatePolygons":478}],471:[function(require,module,exports){ module.exports={generalize:require("./generalize"),snap:require("./snap"),retessellate:require("./retessellate")}; -},{"./generalize":469,"./retessellate":474,"./snap":475}],471:[function(require,module,exports){ +},{"./generalize":470,"./retessellate":475,"./snap":476}],472:[function(require,module,exports){ const constants=require("../../maths/constants"),vec3=require("../../maths/vec3"),poly3=require("../../geometries/poly3"),assert=!1,getTag=e=>`${e}`,addSide=(e,t,s,n,r,c)=>{const o=getTag(n),g=getTag(r);const l=`${o}/${g}`,a=`${g}/${o}`;if(e.has(a))return deleteSide(e,t,s,r,n,null),null;const i={vertex0:n,vertex1:r,polygonindex:c};return e.has(l)?e.get(l).push(i):e.set(l,[i]),t.has(o)?t.get(o).push(l):t.set(o,[l]),s.has(g)?s.get(g).push(l):s.set(g,[l]),l},deleteSide=(e,t,s,n,r,c)=>{const o=getTag(n),g=getTag(r),l=`${o}/${g}`;let a=-1;const i=e.get(l);for(let e=0;e{const t=new Map;for(let s=0;s=3){let e=n.vertices[0],c=getTag(e);for(let o=0;o0){const s=new Map,n=new Map,r=new Map;for(const[e,c]of t)r.set(e,!0),c.forEach(t=>{const r=getTag(t.vertex0),c=getTag(t.vertex1);s.has(r)?s.get(r).push(e):s.set(r,[e]),n.has(c)?n.get(c).push(e):n.set(c,[e])});const c=e.slice(0);for(;0!==t.size;){for(const e of t.keys())r.set(e,!0);let e=!1;for(;;){const o=Array.from(r.keys());if(0===o.length)break;const g=o[0];let l=!0;if(t.has(g)){const o=t.get(g);0;const a=o[0];for(let o=0;o<2;o++){const g=0===o?a.vertex0:a.vertex1,i=0===o?a.vertex1:a.vertex0,v=getTag(g),d=getTag(i);let h=[];0===o?n.has(v)&&(h=n.get(v)):s.has(v)&&(h=s.get(v));for(let a=0;a0&&x<1){const g=vec3.scale(vec3.create(),h,x);if(vec3.add(g,g,a),vec3.squaredDistance(g,v){const n=poly3.toPoints(e),t=[];for(let e=0;e{const t=`${n.v1}:${n.v2}`;e.set(t,n)},deleteEdge=(e,n)=>{const t=`${n.v1}:${n.v2}`;e.delete(t)},findOppositeEdge=(e,n)=>{const t=`${n.v2}:${n.v1}`;return e.get(t)},calculateAnglesBetween=(e,n,t)=>{let l=e.prev.v1,r=e.prev.v2,o=n.next.v2;const v=calculateAngle(l,r,o,t);return l=n.prev.v1,r=n.prev.v2,o=e.next.v2,[v,calculateAngle(l,r,o,t)]},v1=vec3.create(),v2=vec3.create(),calculateAngle=(e,n,t,l)=>{const r=vec3.subtract(v1,n,e),o=vec3.subtract(v2,t,n);return vec3.cross(r,r,o),vec3.dot(r,l)},createPolygonAnd=e=>{let n;const t=[];for(;e.next;){const n=e.next;t.push(e.v1),e.v1=null,e.v2=null,e.next=null,e.prev=null,e=n}return t.length>0&&(n=poly3.create(t)),n},mergeCoplanarPolygons=e=>{if(e.length<2)return e;const n=e[0].plane,t=e.slice(),l=new Map;for(;t.length>0;){const e=t.shift(),r=createEdges(e);for(let e=0;e=0&&e[1]>=0){const n=o.next,r=t.next;t.prev.next=o.next,t.next.prev=o.prev,o.prev.next=t.next,o.next.prev=t.prev,t.v1=null,t.v2=null,t.next=null,t.prev=null,deleteEdge(l,o),o.v1=null,o.v2=null,o.next=null,o.prev=null;const v=(e,n,t)=>{const l={v1:t.v1,v2:n.v2,next:n.next,prev:t.prev};t.prev.next=l,n.next.prev=l,deleteEdge(e,n),n.v1=null,n.v2=null,n.next=null,n.prev=null,deleteEdge(e,t),t.v1=null,t.v2=null,t.next=null,t.prev=null};0===e[0]&&v(l,n,n.prev),0===e[1]&&v(l,r,r.prev)}}else t.next&&insertEdge(l,t)}}const r=[];return l.forEach(e=>{const n=createPolygonAnd(e);n&&r.push(n)}),l.clear(),r},coplanar=(e,n)=>Math.abs(e[3]-n[3])<1.5e-7&&aboutEqualNormals(e,n),mergePolygons=(e,n)=>{const t=[];n.forEach(e=>{const n=t.find(n=>coplanar(n[0],poly3.plane(e)));if(n){n[1].push(e)}else t.push([poly3.plane(e),[e]])});let l=[];return t.forEach(e=>{const n=e[1],t=mergeCoplanarPolygons(n);l=l.concat(t)}),l};module.exports=mergePolygons; -},{"../../geometries/poly3":198,"../../maths/utils/aboutEqualNormals":286,"../../maths/vec3":341}],473:[function(require,module,exports){ +},{"../../geometries/poly3":198,"../../maths/utils/aboutEqualNormals":286,"../../maths/vec3":341}],474:[function(require,module,exports){ const{EPS:EPS}=require("../../maths/constants"),line2=require("../../maths/line2"),vec2=require("../../maths/vec2"),OrthoNormalBasis=require("../../maths/OrthoNormalBasis"),interpolateBetween2DPointsForY=require("../../maths/utils/interpolateBetween2DPointsForY"),{insertSorted:insertSorted,fnNumberSort:fnNumberSort}=require("../../utils"),poly3=require("../../geometries/poly3"),reTesselateCoplanarPolygons=t=>{if(t.length<2)return t;const e=[],o=t.length,n=poly3.plane(t[0]),l=new OrthoNormalBasis(n),i=[],r=[],s=new Map,f=new Map,p=new Map,h=10/EPS;for(let e=0;e0){let t,i;for(let r=0;ri)&&(i=u);let m=f.get(u);m||(m={},f.set(u,m)),m[e]=!0}if(t>=i)n=[],g=0,c=-1;else{let o=s.get(t);o||(o=[],s.set(t,o)),o.push(e)}}n.reverse(),c=g-c-1,i.push(n),r.push(c)}const g=[];f.forEach((t,e)=>g.push(e)),g.sort(fnNumberSort);let c=[],a=[];for(let t=0;t=l&&(t=0),n[t][1]!==p)break;r=t}let f=s-1;if(f<0&&(f=l-1),n[f][1]===p&&(s=f),r!==e.leftvertexindex&&r===s)c.splice(t,1),--t;else{e.leftvertexindex=r,e.rightvertexindex=s,e.topleft=n[r],e.topright=n[s];let t=r+1;t>=l&&(t=0),e.bottomleft=n[t];let o=s-1;o<0&&(o=l-1),e.bottomright=n[o]}}}let u;if(t>=g.length-1)c=[],u=null;else{const e=.5*(p+(u=Number(g[t+1]))),o=s.get(p);for(const t in o){const n=o[t],l=i[n],s=l.length,f=r[n];let h=f;for(;;){let t=h+1;if(t>=s&&(t=0),l[t][1]!==p)break;if(t===f)break;h=t}let g=f;for(;;){let t=g-1;if(t<0&&(t=s-1),l[t][1]!==p)break;if(t===h)break;g=t}let a=h+1;a>=s&&(a=0);let u=g-1;u<0&&(u=s-1);const m={polygonindex:n,leftvertexindex:h,rightvertexindex:g,topleft:l[h],topright:l[g],bottomleft:l[a],bottomright:l[u]};insertSorted(c,m,(t,o)=>{const n=interpolateBetween2DPointsForY(t.topleft,t.bottomleft,e),l=interpolateBetween2DPointsForY(o.topleft,o.bottomleft,e);return n>l?1:n0){const t=o[o.length-1],e=vec2.distance(f.topleft,t.topright),n=vec2.distance(f.bottomleft,t.bottomright);e0){const t=new Set,i=new Set;for(let e=0;e=0;(g||s>=0)&&a&&(n.outpolygon=o.outpolygon,n.leftlinecontinues=g,n.rightlinecontinues=c,t.add(e));break}}}for(let o=0;oEPS&&t.outpolygon.leftpoints.push(t.bottomleft),t.outpolygon.leftpoints.reverse();const i=t.outpolygon.rightpoints.concat(t.outpolygon.leftpoints).map(t=>l.to3D(t)),r=poly3.fromPointsAndPlane(i,n);r.vertices.length&&e.push(r)}}for(let t=0;tEPS&&e.outpolygon.rightpoints.push(e.topright))}a=o}return e};module.exports=reTesselateCoplanarPolygons; -},{"../../geometries/poly3":198,"../../maths/OrthoNormalBasis":212,"../../maths/constants":213,"../../maths/line2":224,"../../maths/utils/interpolateBetween2DPointsForY":289,"../../maths/vec2":310,"../../utils":518}],474:[function(require,module,exports){ +},{"../../geometries/poly3":198,"../../maths/OrthoNormalBasis":212,"../../maths/constants":213,"../../maths/line2":224,"../../maths/utils/interpolateBetween2DPointsForY":289,"../../maths/vec2":310,"../../utils":519}],475:[function(require,module,exports){ const geom3=require("../../geometries/geom3"),poly3=require("../../geometries/poly3"),{NEPS:NEPS}=require("../../maths/constants"),reTesselateCoplanarPolygons=require("./reTesselateCoplanarPolygons"),retessellate=e=>{if(e.isRetesselated)return e;const s=geom3.toPolygons(e).map((e,s)=>({vertices:e.vertices,plane:poly3.plane(e),index:s})),o=classifyPolygons(s),l=[];o.forEach(e=>{if(Array.isArray(e)){const s=reTesselateCoplanarPolygons(e);l.push(...s)}else l.push(e)});const n=geom3.create(l);return n.isRetesselated=!0,n},classifyPolygons=e=>{let s=[e];const o=[];for(let e=3;e>=0;e--){const l=[],n=3===e?1.5e-8:NEPS;s.forEach(s=>{s.sort(byPlaneComponent(e,n));let t=0;for(let r=1;rn&&(r-t==1?o.push(s[t]):l.push(s.slice(t,r)),t=r);s.length-t==1?o.push(s[t]):l.push(s.slice(t))}),s=l}const l=[];return s.forEach(e=>{e[0]&&(l[e[0].index]=e)}),o.forEach(e=>{l[e.index]=e}),l},byPlaneComponent=(e,s)=>(o,l)=>o.plane[e]-l.plane[e]>s?1:l.plane[e]-o.plane[e]>s?-1:0;module.exports=retessellate; -},{"../../geometries/geom3":160,"../../geometries/poly3":198,"../../maths/constants":213,"./reTesselateCoplanarPolygons":473}],475:[function(require,module,exports){ +},{"../../geometries/geom3":160,"../../geometries/poly3":198,"../../maths/constants":213,"./reTesselateCoplanarPolygons":474}],476:[function(require,module,exports){ const flatten=require("../../utils/flatten"),vec2=require("../../maths/vec2"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),measureEpsilon=require("../../measurements/measureEpsilon"),snapPolygons=require("./snapPolygons"),snapPath2=e=>{const s=measureEpsilon(e),r=path2.toPoints(e).map(e=>vec2.snap(vec2.create(),e,s));return path2.create(r)},snapGeom2=e=>{const s=measureEpsilon(e);let r=geom2.toSides(e).map(e=>[vec2.snap(vec2.create(),e[0],s),vec2.snap(vec2.create(),e[1],s)]);return r=r.filter(e=>!vec2.equals(e[0],e[1])),geom2.create(r)},snapGeom3=e=>{const s=measureEpsilon(e),r=geom3.toPolygons(e),o=snapPolygons(s,r);return geom3.create(o)},snap=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");const s=e.map(e=>path2.isA(e)?snapPath2(e):geom2.isA(e)?snapGeom2(e):geom3.isA(e)?snapGeom3(e):e);return 1===s.length?s[0]:s};module.exports=snap; -},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../geometries/path2":181,"../../maths/vec2":310,"../../measurements/measureEpsilon":382,"../../utils/flatten":516,"./snapPolygons":476}],476:[function(require,module,exports){ +},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../geometries/path2":181,"../../maths/vec2":310,"../../measurements/measureEpsilon":382,"../../utils/flatten":517,"./snapPolygons":477}],477:[function(require,module,exports){ const vec3=require("../../maths/vec3"),poly3=require("../../geometries/poly3"),isValidPoly3=(e,o)=>{const r=Math.abs(poly3.measureArea(o));return Number.isFinite(r)&&r>e},snapPolygons=(e,o)=>{let r=o.map(o=>{const r=o.vertices.map(o=>vec3.snap(vec3.create(),o,e)),t=[];for(let e=0;eisValidPoly3(t,e))};module.exports=snapPolygons; -},{"../../geometries/poly3":198,"../../maths/vec3":341}],477:[function(require,module,exports){ +},{"../../geometries/poly3":198,"../../maths/vec3":341}],478:[function(require,module,exports){ const vec3=require("../../maths/vec3"),poly3=require("../../geometries/poly3"),triangulatePolygon=(e,o,r)=>{const t=o.vertices.length;if(t>3){if(t>4){const c=[0,0,0];o.vertices.forEach(e=>vec3.add(c,c,e)),vec3.snap(c,vec3.divide(c,c,[t,t,t]),e);for(let e=0;e{const r=[];return o.forEach(o=>{triangulatePolygon(e,o,r)}),r};module.exports=triangulatePolygons; -},{"../../geometries/poly3":198,"../../maths/vec3":341}],478:[function(require,module,exports){ +},{"../../geometries/poly3":198,"../../maths/vec3":341}],479:[function(require,module,exports){ const flatten=require("../../utils/flatten"),padArrayToLength=require("../../utils/padArrayToLength"),measureAggregateBoundingBox=require("../../measurements/measureAggregateBoundingBox"),{translate:translate}=require("./translate"),validateOptions=e=>{if(!Array.isArray(e.modes)||e.modes.length>3)throw new Error("align(): modes must be an array of length <= 3");if(e.modes=padArrayToLength(e.modes,"none",3),3!==e.modes.filter(e=>["center","max","min","none"].includes(e)).length)throw new Error('align(): all modes must be one of "center", "max" or "min"');if(!Array.isArray(e.relativeTo)||e.relativeTo.length>3)throw new Error("align(): relativeTo must be an array of length <= 3");if(e.relativeTo=padArrayToLength(e.relativeTo,0,3),3!==e.relativeTo.filter(e=>Number.isFinite(e)||null==e).length)throw new Error("align(): all relativeTo values must be a number, or null.");if("boolean"!=typeof e.grouped)throw new Error("align(): grouped must be a boolean value.");return e},populateRelativeToFromBounds=(e,r,t)=>{for(let n=0;n<3;n++)null==e[n]&&("center"===r[n]?e[n]=(t[0][n]+t[1][n])/2:"max"===r[n]?e[n]=t[1][n]:"min"===r[n]&&(e[n]=t[0][n]));return e},alignGeometries=(e,r,t)=>{const n=measureAggregateBoundingBox(e),o=[0,0,0];for(let e=0;e<3;e++)"center"===r[e]?o[e]=t[e]-(n[0][e]+n[1][e])/2:"max"===r[e]?o[e]=t[e]-n[1][e]:"min"===r[e]&&(o[e]=t[e]-n[0][e]);return translate(o,e)},align=(e,...r)=>{e=Object.assign({},{modes:["center","center","min"],relativeTo:[0,0,0],grouped:!1},e),e=validateOptions(e);let{modes:t,relativeTo:n,grouped:o}=e;if(0===(r=flatten(r)).length)throw new Error("align(): No geometries were provided to act upon");if(n.filter(e=>null==e).length){const e=measureAggregateBoundingBox(r);n=populateRelativeToFromBounds(n,t,e)}return 1===(r=o?alignGeometries(r,t,n):r.map(e=>alignGeometries(e,t,n))).length?r[0]:r};module.exports=align; -},{"../../measurements/measureAggregateBoundingBox":373,"../../utils/flatten":516,"../../utils/padArrayToLength":520,"./translate":485}],479:[function(require,module,exports){ +},{"../../measurements/measureAggregateBoundingBox":373,"../../utils/flatten":517,"../../utils/padArrayToLength":521,"./translate":486}],480:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),measureBoundingBox=require("../../measurements/measureBoundingBox"),{translate:translate}=require("./translate"),centerGeometry=(e,r)=>{const{axes:t,relativeTo:n}=Object.assign({},{axes:[!0,!0,!0],relativeTo:[0,0,0]},e),a=measureBoundingBox(r),o=[0,0,0];return t[0]&&(o[0]=n[0]-(a[0][0]+(a[1][0]-a[0][0])/2)),t[1]&&(o[1]=n[1]-(a[0][1]+(a[1][1]-a[0][1])/2)),t[2]&&(o[2]=n[2]-(a[0][2]+(a[1][2]-a[0][2])/2)),translate(o,r)},center=(e,...r)=>{const{axes:t,relativeTo:n}=Object.assign({},{axes:[!0,!0,!0],relativeTo:[0,0,0]},e);if(0===(r=flatten(r)).length)throw new Error("wrong number of arguments");if(3!==n.length)throw new Error("relativeTo must be an array of length 3");e={axes:t,relativeTo:n};const a=r.map(r=>path2.isA(r)?centerGeometry(e,r):geom2.isA(r)?centerGeometry(e,r):geom3.isA(r)?centerGeometry(e,r):r);return 1===a.length?a[0]:a},centerX=(...e)=>center({axes:[!0,!1,!1]},e),centerY=(...e)=>center({axes:[!1,!0,!1]},e),centerZ=(...e)=>center({axes:[!1,!1,!0]},e);module.exports={center:center,centerX:centerX,centerY:centerY,centerZ:centerZ}; -},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../geometries/path2":181,"../../measurements/measureBoundingBox":377,"../../utils/flatten":516,"./translate":485}],480:[function(require,module,exports){ +},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../geometries/path2":181,"../../measurements/measureBoundingBox":377,"../../utils/flatten":517,"./translate":486}],481:[function(require,module,exports){ module.exports={align:require("./align"),center:require("./center").center,centerX:require("./center").centerX,centerY:require("./center").centerY,centerZ:require("./center").centerZ,mirror:require("./mirror").mirror,mirrorX:require("./mirror").mirrorX,mirrorY:require("./mirror").mirrorY,mirrorZ:require("./mirror").mirrorZ,rotate:require("./rotate").rotate,rotateX:require("./rotate").rotateX,rotateY:require("./rotate").rotateY,rotateZ:require("./rotate").rotateZ,scale:require("./scale").scale,scaleX:require("./scale").scaleX,scaleY:require("./scale").scaleY,scaleZ:require("./scale").scaleZ,transform:require("./transform"),translate:require("./translate").translate,translateX:require("./translate").translateX,translateY:require("./translate").translateY,translateZ:require("./translate").translateZ}; -},{"./align":478,"./center":479,"./mirror":481,"./rotate":482,"./scale":483,"./transform":484,"./translate":485}],481:[function(require,module,exports){ +},{"./align":479,"./center":480,"./mirror":482,"./rotate":483,"./scale":484,"./transform":485,"./translate":486}],482:[function(require,module,exports){ const flatten=require("../../utils/flatten"),mat4=require("../../maths/mat4"),plane=require("../../maths/plane"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),mirror=(r,...e)=>{const{origin:o,normal:m}=Object.assign({},{origin:[0,0,0],normal:[0,0,1]},r);if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");const i=plane.fromNormalAndPoint(plane.create(),m,o);if(Number.isNaN(i[0]))throw new Error("the given origin and normal do not define a proper plane");const n=mat4.mirrorByPlane(mat4.create(),i),t=e.map(r=>path2.isA(r)?path2.transform(n,r):geom2.isA(r)?geom2.transform(n,r):geom3.isA(r)?geom3.transform(n,r):r);return 1===t.length?t[0]:t},mirrorX=(...r)=>mirror({normal:[1,0,0]},r),mirrorY=(...r)=>mirror({normal:[0,1,0]},r),mirrorZ=(...r)=>mirror({normal:[0,0,1]},r);module.exports={mirror:mirror,mirrorX:mirrorX,mirrorY:mirrorY,mirrorZ:mirrorZ}; -},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../geometries/path2":181,"../../maths/mat4":262,"../../maths/plane":282,"../../utils/flatten":516}],482:[function(require,module,exports){ +},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../geometries/path2":181,"../../maths/mat4":262,"../../maths/plane":282,"../../utils/flatten":517}],483:[function(require,module,exports){ const flatten=require("../../utils/flatten"),mat4=require("../../maths/mat4"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),rotate=(t,...e)=>{if(!Array.isArray(t))throw new Error("angles must be an array");if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");for(t=t.slice();t.length<3;)t.push(0);const r=t[2],o=t[1],a=t[0],m=mat4.fromTaitBryanRotation(mat4.create(),r,o,a),n=e.map(t=>path2.isA(t)?path2.transform(m,t):geom2.isA(t)?geom2.transform(m,t):geom3.isA(t)?geom3.transform(m,t):t);return 1===n.length?n[0]:n},rotateX=(t,...e)=>rotate([t,0,0],e),rotateY=(t,...e)=>rotate([0,t,0],e),rotateZ=(t,...e)=>rotate([0,0,t],e);module.exports={rotate:rotate,rotateX:rotateX,rotateY:rotateY,rotateZ:rotateZ}; -},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../geometries/path2":181,"../../maths/mat4":262,"../../utils/flatten":516}],483:[function(require,module,exports){ +},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../geometries/path2":181,"../../maths/mat4":262,"../../utils/flatten":517}],484:[function(require,module,exports){ const flatten=require("../../utils/flatten"),mat4=require("../../maths/mat4"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),scale=(e,...r)=>{if(!Array.isArray(e))throw new Error("factors must be an array");if(0===(r=flatten(r)).length)throw new Error("wrong number of arguments");for(e=e.slice();e.length<3;)e.push(1);if(e[0]<=0||e[1]<=0||e[2]<=0)throw new Error("factors must be positive");const a=mat4.fromScaling(mat4.create(),e),t=r.map(e=>path2.isA(e)?path2.transform(a,e):geom2.isA(e)?geom2.transform(a,e):geom3.isA(e)?geom3.transform(a,e):e);return 1===t.length?t[0]:t},scaleX=(e,...r)=>scale([e,1,1],r),scaleY=(e,...r)=>scale([1,e,1],r),scaleZ=(e,...r)=>scale([1,1,e],r);module.exports={scale:scale,scaleX:scaleX,scaleY:scaleY,scaleZ:scaleZ}; -},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../geometries/path2":181,"../../maths/mat4":262,"../../utils/flatten":516}],484:[function(require,module,exports){ +},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../geometries/path2":181,"../../maths/mat4":262,"../../utils/flatten":517}],485:[function(require,module,exports){ const flatten=require("../../utils/flatten"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),transform=(e,...r)=>{if(0===(r=flatten(r)).length)throw new Error("wrong number of arguments");const t=r.map(r=>path2.isA(r)?path2.transform(e,r):geom2.isA(r)?geom2.transform(e,r):geom3.isA(r)?geom3.transform(e,r):r);return 1===t.length?t[0]:t};module.exports=transform; -},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../geometries/path2":181,"../../utils/flatten":516}],485:[function(require,module,exports){ +},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../geometries/path2":181,"../../utils/flatten":517}],486:[function(require,module,exports){ const flatten=require("../../utils/flatten"),mat4=require("../../maths/mat4"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),translate=(t,...e)=>{if(!Array.isArray(t))throw new Error("offset must be an array");if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");for(t=t.slice();t.length<3;)t.push(0);const r=mat4.fromTranslation(mat4.create(),t),a=e.map(t=>path2.isA(t)?path2.transform(r,t):geom2.isA(t)?geom2.transform(r,t):geom3.isA(t)?geom3.transform(r,t):t);return 1===a.length?a[0]:a},translateX=(t,...e)=>translate([t,0,0],e),translateY=(t,...e)=>translate([0,t,0],e),translateZ=(t,...e)=>translate([0,0,t],e);module.exports={translate:translate,translateX:translateX,translateY:translateY,translateZ:translateZ}; -},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../geometries/path2":181,"../../maths/mat4":262,"../../utils/flatten":516}],486:[function(require,module,exports){ +},{"../../geometries/geom2":144,"../../geometries/geom3":160,"../../geometries/path2":181,"../../maths/mat4":262,"../../utils/flatten":517}],487:[function(require,module,exports){ const{EPS:EPS,TAU:TAU}=require("../maths/constants"),vec2=require("../maths/vec2"),path2=require("../geometries/path2"),{isGT:isGT,isGTE:isGTE,isNumberArray:isNumberArray}=require("./commonChecks"),arc=e=>{const r={center:[0,0],radius:1,startAngle:0,endAngle:TAU,makeTangent:!1,segments:32};let{center:t,radius:s,startAngle:n,endAngle:a,makeTangent:o,segments:c}=Object.assign({},r,e);if(!isNumberArray(t,2))throw new Error("center must be an array of X and Y values");if(!isGT(s,0))throw new Error("radius must be greater than zero");if(!isGTE(n,0))throw new Error("startAngle must be positive");if(!isGTE(a,0))throw new Error("endAngle must be positive");if(!isGTE(c,4))throw new Error("segments must be four or more");let i=TAU;(n%=TAU)<(a%=TAU)&&(i=a-n),n>a&&(i=a+(TAU-n));const m=Math.acos((s*s+s*s-EPS*EPS)/(2*s*s)),l=vec2.clone(t);let u;const A=[];if(i.25&&(r=.25);const t=o?e+2:e;for(let a=0;a<=t;a++){let t=a;o&&((t=(a-1)*(e-2*r)/e+r)<0&&(t=0),t>e&&(t=e));const c=n+t*(i/e);u=vec2.fromAngleRadians(vec2.create(),c),vec2.scale(u,u,s),vec2.add(u,u,l),A.push(u)}}return path2.fromPoints({closed:!1},A)};module.exports=arc; -},{"../geometries/path2":181,"../maths/constants":213,"../maths/vec2":310,"./commonChecks":488}],487:[function(require,module,exports){ +},{"../geometries/path2":181,"../maths/constants":213,"../maths/vec2":310,"./commonChecks":489}],488:[function(require,module,exports){ const{TAU:TAU}=require("../maths/constants"),ellipse=require("./ellipse"),{isGTE:isGTE}=require("./commonChecks"),circle=e=>{const s={center:[0,0],radius:1,startAngle:0,endAngle:TAU,segments:32};let{center:r,radius:t,startAngle:n,endAngle:i,segments:l}=Object.assign({},s,e);if(!isGTE(t,0))throw new Error("radius must be positive");return ellipse({center:r,radius:t=[t,t],startAngle:n,endAngle:i,segments:l})};module.exports=circle; -},{"../maths/constants":213,"./commonChecks":488,"./ellipse":493}],488:[function(require,module,exports){ +},{"../maths/constants":213,"./commonChecks":489,"./ellipse":494}],489:[function(require,module,exports){ const isNumberArray=(i,r)=>!!(Array.isArray(i)&&i.length>=r)&&i.every(i=>Number.isFinite(i)),isGT=(i,r)=>Number.isFinite(i)&&i>r,isGTE=(i,r)=>Number.isFinite(i)&&i>=r;module.exports={isNumberArray:isNumberArray,isGT:isGT,isGTE:isGTE}; -},{}],489:[function(require,module,exports){ +},{}],490:[function(require,module,exports){ const cuboid=require("./cuboid"),{isGTE:isGTE}=require("./commonChecks"),cube=e=>{let{center:i,size:r}=Object.assign({},{center:[0,0,0],size:2},e);if(!isGTE(r,0))throw new Error("size must be positive");return cuboid({center:i,size:r=[r,r,r]})};module.exports=cube; -},{"./commonChecks":488,"./cuboid":490}],490:[function(require,module,exports){ +},{"./commonChecks":489,"./cuboid":491}],491:[function(require,module,exports){ const geom3=require("../geometries/geom3"),poly3=require("../geometries/poly3"),{isNumberArray:isNumberArray}=require("./commonChecks"),cuboid=e=>{const{center:r,size:o}=Object.assign({},{center:[0,0,0],size:[2,2,2]},e);if(!isNumberArray(r,3))throw new Error("center must be an array of X, Y and Z values");if(!isNumberArray(o,3))throw new Error("size must be an array of width, depth and height values");if(!o.every(e=>e>=0))throw new Error("size values must be positive");return 0===o[0]||0===o[1]||0===o[2]?geom3.create():geom3.create([[[0,4,6,2],[-1,0,0]],[[1,3,7,5],[1,0,0]],[[0,1,5,4],[0,-1,0]],[[2,6,7,3],[0,1,0]],[[0,2,3,1],[0,0,-1]],[[4,5,7,6],[0,0,1]]].map(e=>{const t=e[0].map(e=>{return[r[0]+o[0]/2*(2*!!(1&e)-1),r[1]+o[1]/2*(2*!!(2&e)-1),r[2]+o[2]/2*(2*!!(4&e)-1)]});return poly3.create(t)}))};module.exports=cuboid; -},{"../geometries/geom3":160,"../geometries/poly3":198,"./commonChecks":488}],491:[function(require,module,exports){ +},{"../geometries/geom3":160,"../geometries/poly3":198,"./commonChecks":489}],492:[function(require,module,exports){ const geom3=require("../geometries/geom3"),cylinderElliptic=require("./cylinderElliptic"),{isGTE:isGTE}=require("./commonChecks"),cylinder=e=>{const{center:i,height:r,radius:s,segments:t}=Object.assign({},{center:[0,0,0],height:2,radius:1,segments:32},e);if(!isGTE(s,0))throw new Error("radius must be positive");return 0===r||0===s?geom3.create():cylinderElliptic({center:i,height:r,startRadius:[s,s],endRadius:[s,s],segments:t})};module.exports=cylinder; -},{"../geometries/geom3":160,"./commonChecks":488,"./cylinderElliptic":492}],492:[function(require,module,exports){ +},{"../geometries/geom3":160,"./commonChecks":489,"./cylinderElliptic":493}],493:[function(require,module,exports){ const{EPS:EPS,TAU:TAU}=require("../maths/constants"),vec3=require("../maths/vec3"),geom3=require("../geometries/geom3"),poly3=require("../geometries/poly3"),{sin:sin,cos:cos}=require("../maths/utils/trigonometry"),{isGT:isGT,isGTE:isGTE,isNumberArray:isNumberArray}=require("./commonChecks"),cylinderElliptic=e=>{const r={center:[0,0,0],height:2,startRadius:[1,1],startAngle:0,endRadius:[1,1],endAngle:TAU,segments:32};let{center:s,height:t,startRadius:a,startAngle:i,endRadius:o,endAngle:n,segments:u}=Object.assign({},r,e);if(!isNumberArray(s,3))throw new Error("center must be an array of X, Y and Z values");if(!isGT(t,0))throw new Error("height must be greater then zero");if(!isNumberArray(a,2))throw new Error("startRadius must be an array of X and Y values");if(!a.every(e=>e>=0))throw new Error("startRadius values must be positive");if(!isNumberArray(o,2))throw new Error("endRadius must be an array of X and Y values");if(!o.every(e=>e>=0))throw new Error("endRadius values must be positive");if(o.every(e=>0===e)&&a.every(e=>0===e))throw new Error("at least one radius must be positive");if(!isGTE(i,0))throw new Error("startAngle must be positive");if(!isGTE(n,0))throw new Error("endAngle must be positive");if(!isGTE(u,4))throw new Error("segments must be four or more");let c=TAU;(i%=TAU)<(n%=TAU)&&(c=n-i),i>n&&(c=n+(TAU-i));const l=Math.min(a[0],a[1],o[0],o[1]),m=Math.acos((l*l+l*l-EPS*EPS)/(2*l*l));if(c{const t=r*c+i;return vec3.scale(A,g,s[0]*cos(t)),vec3.scale(w,p,s[1]*sin(t)),vec3.add(A,A,w),vec3.scale(E,f,e),vec3.add(E,E,d),vec3.add(vec3.create(),A,E)},T=(...e)=>{const r=e.map(e=>vec3.add(vec3.create(),e,s));return poly3.create(r)},b=[];for(let e=0;e0&&a[1]>0&&b.push(T(d,y(0,s,a),y(0,r,a))),(a[0]>0||a[1]>0)&&b.push(T(y(0,r,a),y(0,s,a),y(1,r,o))),o[0]>0&&o[1]>0&&b.push(T(v,y(1,r,o),y(1,s,o))),(o[0]>0||o[1]>0)&&b.push(T(y(1,r,o),y(0,s,a),y(1,s,o))))}return c{const r={center:[0,0],radius:[1,1],startAngle:0,endAngle:TAU,segments:32};let{center:s,radius:t,startAngle:n,endAngle:o,segments:i}=Object.assign({},r,e);if(!isNumberArray(s,2))throw new Error("center must be an array of X and Y values");if(!isNumberArray(t,2))throw new Error("radius must be an array of X and Y values");if(!t.every(e=>e>=0))throw new Error("radius values must be positive");if(!isGTE(n,0))throw new Error("startAngle must be positive");if(!isGTE(o,0))throw new Error("endAngle must be positive");if(!isGTE(i,3))throw new Error("segments must be three or more");if(0===t[0]||0===t[1])return geom2.create();let a=TAU;(n%=TAU)<(o%=TAU)&&(a=o-n),n>o&&(a=o+(TAU-n));const m=Math.min(t[0],t[1]);if(a{const{center:c,radius:r,segments:s,axes:a}=Object.assign({},{center:[0,0,0],radius:[1,1,1],segments:32,axes:[[1,0,0],[0,-1,0],[0,0,1]]},e);if(!isNumberArray(c,3))throw new Error("center must be an array of X, Y and Z values");if(!isNumberArray(r,3))throw new Error("radius must be an array of X, Y and Z values");if(!r.every(e=>e>=0))throw new Error("radius values must be positive");if(!isGTE(s,4))throw new Error("segments must be four or more");if(0===r[0]||0===r[1]||0===r[2])return geom3.create();const t=vec3.scale(vec3.create(),vec3.normalize(vec3.create(),a[0]),r[0]),v=vec3.scale(vec3.create(),vec3.normalize(vec3.create(),a[1]),r[1]),o=vec3.scale(vec3.create(),vec3.normalize(vec3.create(),a[2]),r[2]),i=Math.round(s/4);let l;const u=[],d=vec3.create(),n=vec3.create();for(let e=0;e<=s;e++){const r=TAU*e/s,a=vec3.add(vec3.create(),vec3.scale(d,t,cos(r)),vec3.scale(n,v,sin(r)));if(e>0){let e,r;for(let s=0;s<=i;s++){const t=TAU/4*s/i,v=cos(t),m=sin(t);if(s>0){let t,h=[];t=vec3.subtract(vec3.create(),vec3.scale(d,l,e),vec3.scale(n,o,r)),h.push(vec3.add(t,t,c)),t=vec3.subtract(vec3.create(),vec3.scale(d,a,e),vec3.scale(n,o,r)),h.push(vec3.add(t,t,c)),s{let{radius:r,frequency:t}=Object.assign({},{radius:1,frequency:6},e);if(!isGTE(r,0))throw new Error("radius must be positive");if(!isGTE(t,6))throw new Error("frequency must be six or more");if(0===r)return geom3.create();t=Math.floor(t/6);const o=[[.850651,0,-.525731],[.850651,-0,.525731],[-.850651,-0,.525731],[-.850651,0,-.525731],[0,-.525731,.850651],[0,.525731,.850651],[0,.525731,-.850651],[0,-.525731,-.850651],[-.525731,-.850651,-0],[.525731,-.850651,-0],[.525731,.850651,0],[-.525731,.850651,0]],s=[[0,9,1],[1,10,0],[6,7,0],[10,6,0],[7,9,0],[5,1,4],[4,1,9],[5,10,1],[2,8,3],[3,11,2],[2,5,4],[4,8,2],[2,11,5],[3,7,6],[6,11,3],[8,7,3],[9,8,4],[11,10,5],[10,11,6],[8,9,7]],n=(e,r,t)=>{const o=e[0],s=e[1],n=e[2];let c=t;const f=[],l=[];for(let e=0;e{const o=1-t,s=[];for(let n=0;n<3;n++)s[n]=e[n]*o+r[n]*t;return s};let c=[],f=[],l=0;for(let e=0;e{if(!Array.isArray(r))throw new Error("points must be an array");return path2.fromPoints({},r)};module.exports=line; -},{"../geometries/path2":181}],498:[function(require,module,exports){ +},{"../geometries/path2":181}],499:[function(require,module,exports){ const geom2=require("../geometries/geom2"),polygon=r=>{const{points:o,paths:t,orientation:e}=Object.assign({},{points:[],paths:[],orientation:"counterclockwise"},r);if(!Array.isArray(o)||!Array.isArray(t))throw new Error("points and paths must be arrays");let s=o;Array.isArray(o[0])&&(Array.isArray(o[0][0])||(s=[o])),s.forEach((r,o)=>{if(!Array.isArray(r))throw new Error("list of points "+o+" must be an array");if(r.length<3)throw new Error("list of points "+o+" must contain three or more points");r.forEach((r,t)=>{if(!Array.isArray(r))throw new Error("list of points "+o+", point "+t+" must be an array");if(r.length<2)throw new Error("list of points "+o+", point "+t+" must contain by X and Y values")})});let a=t;if(0===t.length){let r=0;a=s.map(o=>o.map(o=>r++))}const n=[];s.forEach(r=>r.forEach(r=>n.push(r)));let i=[];a.forEach(r=>{const o=r.map(r=>n[r]),t=geom2.fromPoints(o);i=i.concat(geom2.toSides(t))});let c=geom2.create(i);return"clockwise"==e&&(c=geom2.reverse(c)),c};module.exports=polygon; -},{"../geometries/geom2":144}],499:[function(require,module,exports){ +},{"../geometries/geom2":144}],500:[function(require,module,exports){ const geom3=require("../geometries/geom3"),poly3=require("../geometries/poly3"),{isNumberArray:isNumberArray}=require("./commonChecks"),polyhedron=r=>{const e={points:[],faces:[],colors:void 0,orientation:"outward"},{points:o,faces:a,colors:t,orientation:n}=Object.assign({},e,r);if(!Array.isArray(o)||!Array.isArray(a))throw new Error("points and faces must be arrays");if(o.length<3)throw new Error("three or more points are required");if(a.length<1)throw new Error("one or more faces are required");if(t){if(!Array.isArray(t))throw new Error("colors must be an array");if(t.length!==a.length)throw new Error("faces and colors must have the same length")}o.forEach((r,e)=>{if(!isNumberArray(r,3))throw new Error(`point ${e} must be an array of X, Y, Z values`)}),a.forEach((r,e)=>{if(r.length<3)throw new Error(`face ${e} must contain 3 or more indexes`);if(!isNumberArray(r,r.length))throw new Error(`face ${e} must be an array of numbers`)}),"outward"!==n&&a.forEach(r=>r.reverse());const s=a.map((r,e)=>{const a=poly3.create(r.map(r=>o[r]));return t&&t[e]&&(a.color=t[e]),a});return geom3.create(s)};module.exports=polyhedron; -},{"../geometries/geom3":160,"../geometries/poly3":198,"./commonChecks":488}],500:[function(require,module,exports){ +},{"../geometries/geom3":160,"../geometries/poly3":198,"./commonChecks":489}],501:[function(require,module,exports){ const vec2=require("../maths/vec2"),geom2=require("../geometries/geom2"),{isNumberArray:isNumberArray}=require("./commonChecks"),rectangle=e=>{const{center:r,size:t}=Object.assign({},{center:[0,0],size:[2,2]},e);if(!isNumberArray(r,2))throw new Error("center must be an array of X and Y values");if(!isNumberArray(t,2))throw new Error("size must be an array of X and Y values");if(!t.every(e=>e>=0))throw new Error("size values must be positive");if(0===t[0]||0===t[1])return geom2.create();const a=[t[0]/2,t[1]/2],c=[a[0],-a[1]],s=[vec2.subtract(vec2.create(),r,a),vec2.add(vec2.create(),r,c),vec2.add(vec2.create(),r,a),vec2.subtract(vec2.create(),r,c)];return geom2.fromPoints(s)};module.exports=rectangle; -},{"../geometries/geom2":144,"../maths/vec2":310,"./commonChecks":488}],501:[function(require,module,exports){ +},{"../geometries/geom2":144,"../maths/vec2":310,"./commonChecks":489}],502:[function(require,module,exports){ const{EPS:EPS,TAU:TAU}=require("../maths/constants"),vec2=require("../maths/vec2"),vec3=require("../maths/vec3"),geom3=require("../geometries/geom3"),poly3=require("../geometries/poly3"),{sin:sin,cos:cos}=require("../maths/utils/trigonometry"),{isGTE:isGTE,isNumberArray:isNumberArray}=require("./commonChecks"),cuboid=require("./cuboid"),createCorners=(e,r,t,s,c,o)=>{const a=TAU/4*c/s,n=cos(a),i=sin(a),u=s-c;let l=t*n,h=r[2]-(t-t*i);o||(h=t-t*i-r[2]),l=l>EPS?l:0;const d=vec3.add(vec3.create(),e,[r[0]-t,r[1]-t,h]),v=vec3.add(vec3.create(),e,[t-r[0],r[1]-t,h]),m=vec3.add(vec3.create(),e,[t-r[0],t-r[1],h]),p=vec3.add(vec3.create(),e,[r[0]-t,t-r[1],h]),f=[],g=[],E=[],b=[];for(let e=0;e<=u;e++){const r=u>0?TAU/4*e/u:0,t=vec2.fromAngleRadians(vec2.create(),r);vec2.scale(t,t,l);const s=vec3.fromVec2(vec3.create(),t);f.push(vec3.add(vec3.create(),d,s)),vec3.rotateZ(s,s,[0,0,0],TAU/4),g.push(vec3.add(vec3.create(),v,s)),vec3.rotateZ(s,s,[0,0,0],TAU/4),E.push(vec3.add(vec3.create(),m,s)),vec3.rotateZ(s,s,[0,0,0],TAU/4),b.push(vec3.add(vec3.create(),p,s))}return o?[f,g,E,b]:(f.reverse(),g.reverse(),E.reverse(),b.reverse(),[b,E,g,f])},stitchCorners=(e,r)=>{const t=[];for(let s=0;s{const t=[];for(let s=0;s{e=(e=[e[3],e[2],e[1],e[0]]).map(e=>e.slice().reverse());const t=[];e.forEach(e=>{e.forEach(e=>t.push(e))});const s=[];r.forEach(e=>{e.forEach(e=>s.push(e))});const c=[];for(let e=0;e{let{center:r,size:t,roundRadius:s,segments:c}=Object.assign({},{center:[0,0,0],size:[2,2,2],roundRadius:.2,segments:32},e);if(!isNumberArray(r,3))throw new Error("center must be an array of X, Y and Z values");if(!isNumberArray(t,3))throw new Error("size must be an array of X, Y and Z values");if(!t.every(e=>e>=0))throw new Error("size values must be positive");if(!isGTE(s,0))throw new Error("roundRadius must be positive");if(!isGTE(c,4))throw new Error("segments must be four or more");if(0===t[0]||0===t[1]||0===t[2])return geom3.create();if(0===s)return cuboid({center:r,size:t});if(s>(t=t.map(e=>e/2))[0]-EPS||s>t[1]-EPS||s>t[2]-EPS)throw new Error("roundRadius must be smaller than the radius of all dimensions");c=Math.floor(c/4);let o=null,a=null,n=[];for(let e=0;e<=c;e++){const i=createCorners(r,t,s,c,e,!0),u=createCorners(r,t,s,c,e,!1);if(0===e&&(n=n.concat(stitchSides(u,i))),o&&(n=n.concat(stitchCorners(o,i),stitchWalls(o,i))),a&&(n=n.concat(stitchCorners(a,u),stitchWalls(a,u))),e===c){let e=i.map(e=>e[0]);n.push(poly3.create(e)),e=u.map(e=>e[0]),n.push(poly3.create(e))}o=i,a=u}return geom3.create(n)};module.exports=roundedCuboid; -},{"../geometries/geom3":160,"../geometries/poly3":198,"../maths/constants":213,"../maths/utils/trigonometry":292,"../maths/vec2":310,"../maths/vec3":341,"./commonChecks":488,"./cuboid":490}],502:[function(require,module,exports){ +},{"../geometries/geom3":160,"../geometries/poly3":198,"../maths/constants":213,"../maths/utils/trigonometry":292,"../maths/vec2":310,"../maths/vec3":341,"./commonChecks":489,"./cuboid":491}],503:[function(require,module,exports){ const{EPS:EPS,TAU:TAU}=require("../maths/constants"),vec3=require("../maths/vec3"),geom3=require("../geometries/geom3"),poly3=require("../geometries/poly3"),{sin:sin,cos:cos}=require("../maths/utils/trigonometry"),{isGTE:isGTE,isNumberArray:isNumberArray}=require("./commonChecks"),cylinder=require("./cylinder"),roundedCylinder=e=>{const{center:c,height:r,radius:s,roundRadius:a,segments:t}=Object.assign({},{center:[0,0,0],height:2,radius:1,roundRadius:.2,segments:32},e);if(!isNumberArray(c,3))throw new Error("center must be an array of X, Y and Z values");if(!isGTE(r,0))throw new Error("height must be positive");if(!isGTE(s,0))throw new Error("radius must be positive");if(!isGTE(a,0))throw new Error("roundRadius must be positive");if(a>s)throw new Error("roundRadius must be smaller than the radius");if(!isGTE(t,4))throw new Error("segments must be four or more");if(0===r||0===s)return geom3.create();if(0===a)return cylinder({center:c,height:r,radius:s});const v=[0,0,-r/2],o=[0,0,r/2],i=vec3.subtract(vec3.create(),o,v);if(2*a>vec3.length(i)-EPS)throw new Error("height must be larger than twice roundRadius");let u;u=Math.abs(i[0])>Math.abs(i[1])?vec3.fromValues(0,1,0):vec3.fromValues(1,0,0);const d=vec3.scale(vec3.create(),vec3.normalize(vec3.create(),i),a),n=vec3.scale(vec3.create(),vec3.normalize(vec3.create(),vec3.cross(vec3.create(),d,u)),s),l=vec3.scale(vec3.create(),vec3.normalize(vec3.create(),vec3.cross(vec3.create(),n,d)),s);vec3.add(v,v,d),vec3.subtract(o,o,d);const h=Math.floor(.25*t),m=e=>{const r=e.map(e=>vec3.add(e,e,c));return poly3.create(r)},p=[],b=vec3.create(),f=vec3.create();let g;for(let e=0;e<=t;e++){const c=TAU*e/t,r=vec3.add(vec3.create(),vec3.scale(b,n,cos(c)),vec3.scale(f,l,sin(c)));if(e>0){let e,c,s=[];s.push(vec3.add(vec3.create(),v,r)),s.push(vec3.add(vec3.create(),v,g)),s.push(vec3.add(vec3.create(),o,g)),s.push(vec3.add(vec3.create(),o,r)),p.push(m(s));for(let a=0;a<=h;a++){const t=TAU/4*a/h,i=cos(t),u=sin(t);if(a>0){let t;s=[],t=vec3.add(vec3.create(),v,vec3.subtract(b,vec3.scale(b,g,e),vec3.scale(f,d,c))),s.push(t),t=vec3.add(vec3.create(),v,vec3.subtract(b,vec3.scale(b,r,e),vec3.scale(f,d,c))),s.push(t),a{let{center:r,size:t,roundRadius:a,segments:c}=Object.assign({},{center:[0,0],size:[2,2],roundRadius:.2,segments:32},e);if(!isNumberArray(r,2))throw new Error("center must be an array of X and Y values");if(!isNumberArray(t,2))throw new Error("size must be an array of X and Y values");if(!t.every(e=>e>=0))throw new Error("size values must be positive");if(!isGTE(a,0))throw new Error("roundRadius must be positive");if(!isGTE(c,4))throw new Error("segments must be four or more");if(0===t[0]||0===t[1])return geom2.create();if(0===a)return rectangle({center:r,size:t});if(a>(t=t.map(e=>e/2))[0]-EPS||a>t[1]-EPS)throw new Error("roundRadius must be smaller than the radius of all dimensions");const s=Math.floor(c/4),o=vec2.add(vec2.create(),r,[t[0]-a,t[1]-a]),n=vec2.add(vec2.create(),r,[a-t[0],t[1]-a]),i=vec2.add(vec2.create(),r,[a-t[0],a-t[1]]),u=vec2.add(vec2.create(),r,[t[0]-a,a-t[1]]),d=[],v=[],m=[],l=[];for(let e=0;e<=s;e++){const r=TAU/4*e/s,t=vec2.fromAngleRadians(vec2.create(),r);vec2.scale(t,t,a),d.push(vec2.add(vec2.create(),o,t)),vec2.rotate(t,t,vec2.create(),TAU/4),v.push(vec2.add(vec2.create(),n,t)),vec2.rotate(t,t,vec2.create(),TAU/4),m.push(vec2.add(vec2.create(),i,t)),vec2.rotate(t,t,vec2.create(),TAU/4),l.push(vec2.add(vec2.create(),u,t))}return geom2.fromPoints(d.concat(v,m,l))};module.exports=roundedRectangle; -},{"../geometries/geom2":144,"../maths/constants":213,"../maths/vec2":310,"./commonChecks":488,"./rectangle":500}],504:[function(require,module,exports){ +},{"../geometries/geom2":144,"../maths/constants":213,"../maths/vec2":310,"./commonChecks":489,"./rectangle":501}],505:[function(require,module,exports){ const ellipsoid=require("./ellipsoid"),{isGTE:isGTE}=require("./commonChecks"),sphere=e=>{let{center:s,radius:r,segments:i,axes:t}=Object.assign({},{center:[0,0,0],radius:1,segments:32,axes:[[1,0,0],[0,-1,0],[0,0,1]]},e);if(!isGTE(r,0))throw new Error("radius must be positive");return ellipsoid({center:s,radius:r=[r,r,r],segments:i,axes:t})};module.exports=sphere; -},{"./commonChecks":488,"./ellipsoid":494}],505:[function(require,module,exports){ +},{"./commonChecks":489,"./ellipsoid":495}],506:[function(require,module,exports){ const rectangle=require("./rectangle"),{isGTE:isGTE}=require("./commonChecks"),square=e=>{let{center:r,size:s}=Object.assign({},{center:[0,0],size:2},e);if(!isGTE(s,0))throw new Error("size must be positive");return rectangle({center:r,size:s=[s,s]})};module.exports=square; -},{"./commonChecks":488,"./rectangle":500}],506:[function(require,module,exports){ +},{"./commonChecks":489,"./rectangle":501}],507:[function(require,module,exports){ const{TAU:TAU}=require("../maths/constants"),vec2=require("../maths/vec2"),geom2=require("../geometries/geom2"),{isGT:isGT,isGTE:isGTE,isNumberArray:isNumberArray}=require("./commonChecks"),getRadiusRatio=(e,r)=>e>0&&r>1&&r{const o=TAU/e,i=[];for(let a=0;a{let{center:r,vertices:t,outerRadius:s,innerRadius:o,density:i,startAngle:a}=Object.assign({},{center:[0,0],vertices:5,outerRadius:1,innerRadius:0,density:2,startAngle:0},e);if(!isNumberArray(r,2))throw new Error("center must be an array of X and Y values");if(!isGTE(t,2))throw new Error("vertices must be two or more");if(!isGT(s,0))throw new Error("outerRadius must be greater than zero");if(!isGTE(o,0))throw new Error("innerRadius must be greater than zero");if(!isGTE(a,0))throw new Error("startAngle must be greater than zero");if(t=Math.floor(t),i=Math.floor(i),a%=TAU,0===o){if(!isGTE(i,2))throw new Error("density must be two or more");o=s*getRadiusRatio(t,i)}const n=vec2.clone(r),u=getPoints(t,s,a,n),c=getPoints(t,o,a+Math.PI/t,n),h=[];for(let e=0;e{const r={innerRadius:1,innerSegments:32,outerRadius:4,outerSegments:32,innerRotation:0,startAngle:0,outerRotation:TAU},{innerRadius:t,innerSegments:o,outerRadius:n,outerSegments:s,innerRotation:i,startAngle:a,outerRotation:u}=Object.assign({},r,e);if(!isGT(t,0))throw new Error("innerRadius must be greater than zero");if(!isGTE(o,3))throw new Error("innerSegments must be three or more");if(!isGT(n,0))throw new Error("outerRadius must be greater than zero");if(!isGTE(s,3))throw new Error("outerSegments must be three or more");if(!isGTE(a,0))throw new Error("startAngle must be positive");if(!isGT(u,0))throw new Error("outerRotation must be greater than zero");if(t>=n)throw new Error("inner circle is two large to rotate about the outer circle");let m=circle({radius:t,segments:o});return 0!==i&&(m=rotate([0,0,i],m)),m=translate([n,0],m),extrudeRotate({startAngle:a,angle:u,segments:s},m)};module.exports=torus; -},{"../maths/constants":213,"../operations/extrusions/extrudeRotate":435,"../operations/transforms/rotate":482,"../operations/transforms/translate":485,"./circle":487,"./commonChecks":488}],508:[function(require,module,exports){ +},{"../maths/constants":213,"../operations/extrusions/extrudeRotate":435,"../operations/transforms/rotate":483,"../operations/transforms/translate":486,"./circle":488,"./commonChecks":489}],509:[function(require,module,exports){ const{NEPS:NEPS}=require("../maths/constants"),vec2=require("../maths/vec2"),geom2=require("../geometries/geom2"),{isNumberArray:isNumberArray}=require("./commonChecks"),solveAngleFromSSS=(e,r,t)=>Math.acos((e*e+r*r-t*t)/(2*e*r)),solveSideFromSAS=(e,r,t)=>r>NEPS?Math.sqrt(e*e+t*t-2*e*t*Math.cos(r)):Math.sqrt((e-t)*(e-t)+e*t*r*r*(1-r*r/12)),solveAAA=e=>{if(Math.abs(e[0]+e[1]+e[2]-Math.PI)>NEPS)throw new Error("AAA triangles require angles that sum to PI");const r=e[0],t=e[1],s=Math.PI-r-t,a=1/Math.sin(s)*Math.sin(r),n=1/Math.sin(s)*Math.sin(t);return createTriangle(r,t,s,a,n,1)},solveAAS=e=>{const r=e[0],t=e[1],s=Math.PI+NEPS-r-t;if(s{const r=e[0],t=e[2],s=Math.PI+NEPS-r-t;if(s{const r=e[0],t=e[1],s=e[2],a=solveSideFromSAS(r,t,s),n=solveAngleFromSSS(a,r,s),o=Math.PI-n-t;return createTriangle(n,t,o,s,a,r)},solveSSA=e=>{const r=e[0],t=e[1],s=e[2],a=Math.asin(t*Math.sin(s)/r),n=Math.PI-a-s,o=r/Math.sin(s)*Math.sin(n);return createTriangle(a,n,s,t,o,r)},solveSSS=e=>{const r=e[1],t=e[2],s=e[0];if(r+t<=s||t+s<=r||s+r<=t)throw new Error("SSS triangle is incorrect, as the longest side is longer than the sum of the other sides");const a=solveAngleFromSSS(t,s,r),n=solveAngleFromSSS(s,r,t),o=Math.PI-a-n;return createTriangle(a,n,o,r,t,s)},createTriangle=(e,r,t,s,a,n)=>{const o=vec2.fromValues(0,0),i=vec2.fromValues(n,0),S=vec2.fromValues(s,0);return vec2.add(S,vec2.rotate(S,S,[0,0],Math.PI-r),i),geom2.fromPoints([o,i,S])},triangle=e=>{let{type:r,values:t}=Object.assign({},{type:"SSS",values:[1,1,1]},e);if("string"!=typeof r)throw new Error("triangle type must be a string");if("A"!==(r=r.toUpperCase())[0]&&"S"!==r[0]||"A"!==r[1]&&"S"!==r[1]||"A"!==r[2]&&"S"!==r[2])throw new Error("triangle type must contain three letters; A or S");if(!isNumberArray(t,3))throw new Error("triangle values must contain three values");if(!t.every(e=>e>0))throw new Error("triangle values must be greater than zero");switch(r){case"AAA":return solveAAA(t);case"AAS":return solveAAS(t);case"ASA":return solveASA(t);case"SAS":return solveSAS(t);case"SSA":return solveSSA(t);case"SSS":return solveSSS(t);default:throw new Error("invalid triangle type, try again")}};module.exports=triangle; -},{"../geometries/geom2":144,"../maths/constants":213,"../maths/vec2":310,"./commonChecks":488}],509:[function(require,module,exports){ +},{"../geometries/geom2":144,"../maths/constants":213,"../maths/vec2":310,"./commonChecks":489}],510:[function(require,module,exports){ module.exports={height:14,32:[16],33:[10,5,21,5,7,void 0,5,2,4,1,5,0,6,1,5,2],34:[16,4,21,4,14,void 0,12,21,12,14],35:[21,11,25,4,-7,void 0,17,25,10,-7,void 0,4,12,18,12,void 0,3,6,17,6],36:[20,8,25,8,-4,void 0,12,25,12,-4,void 0,17,18,15,20,12,21,8,21,5,20,3,18,3,16,4,14,5,13,7,12,13,10,15,9,16,8,17,6,17,3,15,1,12,0,8,0,5,1,3,3],37:[24,21,21,3,0,void 0,8,21,10,19,10,17,9,15,7,14,5,14,3,16,3,18,4,20,6,21,8,21,10,20,13,19,16,19,19,20,21,21,void 0,17,7,15,6,14,4,14,2,16,0,18,0,20,1,21,3,21,5,19,7,17,7],38:[26,23,12,23,13,22,14,21,14,20,13,19,11,17,6,15,3,13,1,11,0,7,0,5,1,4,2,3,4,3,6,4,8,5,9,12,13,13,14,14,16,14,18,13,20,11,21,9,20,8,18,8,16,9,13,11,10,16,3,18,1,20,0,22,0,23,1,23,2],39:[10,5,19,4,20,5,21,6,20,6,18,5,16,4,15],40:[14,11,25,9,23,7,20,5,16,4,11,4,7,5,2,7,-2,9,-5,11,-7],41:[14,3,25,5,23,7,20,9,16,10,11,10,7,9,2,7,-2,5,-5,3,-7],42:[16,8,21,8,9,void 0,3,18,13,12,void 0,13,18,3,12],43:[26,13,18,13,0,void 0,4,9,22,9],44:[10,6,1,5,0,4,1,5,2,6,1,6,-1,5,-3,4,-4],45:[26,4,9,22,9],46:[10,5,2,4,1,5,0,6,1,5,2],47:[22,20,25,2,-7],48:[20,9,21,6,20,4,17,3,12,3,9,4,4,6,1,9,0,11,0,14,1,16,4,17,9,17,12,16,17,14,20,11,21,9,21],49:[20,6,17,8,18,11,21,11,0],50:[20,4,16,4,17,5,19,6,20,8,21,12,21,14,20,15,19,16,17,16,15,15,13,13,10,3,0,17,0],51:[20,5,21,16,21,10,13,13,13,15,12,16,11,17,8,17,6,16,3,14,1,11,0,8,0,5,1,4,2,3,4],52:[20,13,21,3,7,18,7,void 0,13,21,13,0],53:[20,15,21,5,21,4,12,5,13,8,14,11,14,14,13,16,11,17,8,17,6,16,3,14,1,11,0,8,0,5,1,4,2,3,4],54:[20,16,18,15,20,12,21,10,21,7,20,5,17,4,12,4,7,5,3,7,1,10,0,11,0,14,1,16,3,17,6,17,7,16,10,14,12,11,13,10,13,7,12,5,10,4,7],55:[20,17,21,7,0,void 0,3,21,17,21],56:[20,8,21,5,20,4,18,4,16,5,14,7,13,11,12,14,11,16,9,17,7,17,4,16,2,15,1,12,0,8,0,5,1,4,2,3,4,3,7,4,9,6,11,9,12,13,13,15,14,16,16,16,18,15,20,12,21,8,21],57:[20,16,14,15,11,13,9,10,8,9,8,6,9,4,11,3,14,3,15,4,18,6,20,9,21,10,21,13,20,15,18,16,14,16,9,15,4,13,1,10,0,8,0,5,1,4,3],58:[10,5,14,4,13,5,12,6,13,5,14,void 0,5,2,4,1,5,0,6,1,5,2],59:[10,5,14,4,13,5,12,6,13,5,14,void 0,6,1,5,0,4,1,5,2,6,1,6,-1,5,-3,4,-4],60:[24,20,18,4,9,20,0],61:[26,4,12,22,12,void 0,4,6,22,6],62:[24,4,18,20,9,4,0],63:[18,3,16,3,17,4,19,5,20,7,21,11,21,13,20,14,19,15,17,15,15,14,13,13,12,9,10,9,7,void 0,9,2,8,1,9,0,10,1,9,2],64:[27,18,13,17,15,15,16,12,16,10,15,9,14,8,11,8,8,9,6,11,5,14,5,16,6,17,8,void 0,12,16,10,14,9,11,9,8,10,6,11,5,void 0,18,16,17,8,17,6,19,5,21,5,23,7,24,10,24,12,23,15,22,17,20,19,18,20,15,21,12,21,9,20,7,19,5,17,4,15,3,12,3,9,4,6,5,4,7,2,9,1,12,0,15,0,18,1,20,2,21,3,void 0,19,16,18,8,18,6,19,5],65:[18,9,21,1,0,void 0,9,21,17,0,void 0,4,7,14,7],66:[21,4,21,4,0,void 0,4,21,13,21,16,20,17,19,18,17,18,15,17,13,16,12,13,11,void 0,4,11,13,11,16,10,17,9,18,7,18,4,17,2,16,1,13,0,4,0],67:[21,18,16,17,18,15,20,13,21,9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5],68:[21,4,21,4,0,void 0,4,21,11,21,14,20,16,18,17,16,18,13,18,8,17,5,16,3,14,1,11,0,4,0],69:[19,4,21,4,0,void 0,4,21,17,21,void 0,4,11,12,11,void 0,4,0,17,0],70:[18,4,21,4,0,void 0,4,21,17,21,void 0,4,11,12,11],71:[21,18,16,17,18,15,20,13,21,9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,18,8,void 0,13,8,18,8],72:[22,4,21,4,0,void 0,18,21,18,0,void 0,4,11,18,11],73:[8,4,21,4,0],74:[16,12,21,12,5,11,2,10,1,8,0,6,0,4,1,3,2,2,5,2,7],75:[21,4,21,4,0,void 0,18,21,4,7,void 0,9,12,18,0],76:[17,4,21,4,0,void 0,4,0,16,0],77:[24,4,21,4,0,void 0,4,21,12,0,void 0,20,21,12,0,void 0,20,21,20,0],78:[22,4,21,4,0,void 0,4,21,18,0,void 0,18,21,18,0],79:[22,9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,19,8,19,13,18,16,17,18,15,20,13,21,9,21],80:[21,4,21,4,0,void 0,4,21,13,21,16,20,17,19,18,17,18,14,17,12,16,11,13,10,4,10],81:[22,9,21,7,20,5,18,4,16,3,13,3,8,4,5,5,3,7,1,9,0,13,0,15,1,17,3,18,5,19,8,19,13,18,16,17,18,15,20,13,21,9,21,void 0,12,4,18,-2],82:[21,4,21,4,0,void 0,4,21,13,21,16,20,17,19,18,17,18,15,17,13,16,12,13,11,4,11,void 0,11,11,18,0],83:[20,17,18,15,20,12,21,8,21,5,20,3,18,3,16,4,14,5,13,7,12,13,10,15,9,16,8,17,6,17,3,15,1,12,0,8,0,5,1,3,3],84:[16,8,21,8,0,void 0,1,21,15,21],85:[22,4,21,4,6,5,3,7,1,10,0,12,0,15,1,17,3,18,6,18,21],86:[18,1,21,9,0,void 0,17,21,9,0],87:[24,2,21,7,0,void 0,12,21,7,0,void 0,12,21,17,0,void 0,22,21,17,0],88:[20,3,21,17,0,void 0,17,21,3,0],89:[18,1,21,9,11,9,0,void 0,17,21,9,11],90:[20,17,21,3,0,void 0,3,21,17,21,void 0,3,0,17,0],91:[14,4,25,4,-7,void 0,5,25,5,-7,void 0,4,25,11,25,void 0,4,-7,11,-7],92:[14,0,21,14,-3],93:[14,9,25,9,-7,void 0,10,25,10,-7,void 0,3,25,10,25,void 0,3,-7,10,-7],94:[16,6,15,8,18,10,15,void 0,3,12,8,17,13,12,void 0,8,17,8,0],95:[16,0,-2,16,-2],96:[10,6,21,5,20,4,18,4,16,5,15,6,16,5,17],97:[19,15,14,15,0,void 0,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3],98:[19,4,21,4,0,void 0,4,11,6,13,8,14,11,14,13,13,15,11,16,8,16,6,15,3,13,1,11,0,8,0,6,1,4,3],99:[18,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3],100:[19,15,21,15,0,void 0,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3],101:[18,3,8,15,8,15,10,14,12,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3],102:[12,10,21,8,21,6,20,5,17,5,0,void 0,2,14,9,14],103:[19,15,14,15,-2,14,-5,13,-6,11,-7,8,-7,6,-6,void 0,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3],104:[19,4,21,4,0,void 0,4,10,7,13,9,14,12,14,14,13,15,10,15,0],105:[8,3,21,4,20,5,21,4,22,3,21,void 0,4,14,4,0],106:[10,5,21,6,20,7,21,6,22,5,21,void 0,6,14,6,-3,5,-6,3,-7,1,-7],107:[17,4,21,4,0,void 0,14,14,4,4,void 0,8,8,15,0],108:[8,4,21,4,0],109:[30,4,14,4,0,void 0,4,10,7,13,9,14,12,14,14,13,15,10,15,0,void 0,15,10,18,13,20,14,23,14,25,13,26,10,26,0],110:[19,4,14,4,0,void 0,4,10,7,13,9,14,12,14,14,13,15,10,15,0],111:[19,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3,16,6,16,8,15,11,13,13,11,14,8,14],112:[19,4,14,4,-7,void 0,4,11,6,13,8,14,11,14,13,13,15,11,16,8,16,6,15,3,13,1,11,0,8,0,6,1,4,3],113:[19,15,14,15,-7,void 0,15,11,13,13,11,14,8,14,6,13,4,11,3,8,3,6,4,3,6,1,8,0,11,0,13,1,15,3],114:[13,4,14,4,0,void 0,4,8,5,11,7,13,9,14,12,14],115:[17,14,11,13,13,10,14,7,14,4,13,3,11,4,9,6,8,11,7,13,6,14,4,14,3,13,1,10,0,7,0,4,1,3,3],116:[12,5,21,5,4,6,1,8,0,10,0,void 0,2,14,9,14],117:[19,4,14,4,4,5,1,7,0,10,0,12,1,15,4,void 0,15,14,15,0],118:[16,2,14,8,0,void 0,14,14,8,0],119:[22,3,14,7,0,void 0,11,14,7,0,void 0,11,14,15,0,void 0,19,14,15,0],120:[17,3,14,14,0,void 0,14,14,3,0],121:[16,2,14,8,0,void 0,14,14,8,0,6,-4,4,-6,2,-7,1,-7],122:[17,14,14,3,0,void 0,3,14,14,14,void 0,3,0,14,0],123:[14,9,25,7,24,6,23,5,21,5,19,6,17,7,16,8,14,8,12,6,10,void 0,7,24,6,22,6,20,7,18,8,17,9,15,9,13,8,11,4,9,8,7,9,5,9,3,8,1,7,0,6,-2,6,-4,7,-6,void 0,6,8,8,6,8,4,7,2,6,1,5,-1,5,-3,6,-5,7,-6,9,-7],124:[8,4,25,4,-7],125:[14,5,25,7,24,8,23,9,21,9,19,8,17,7,16,6,14,6,12,8,10,void 0,7,24,8,22,8,20,7,18,6,17,5,15,5,13,6,11,10,9,6,7,5,5,5,3,6,1,7,0,8,-2,8,-4,7,-6,void 0,8,8,6,6,6,4,7,2,8,1,9,-1,9,-3,8,-5,7,-6,5,-7],126:[24,3,6,3,8,4,11,6,12,8,12,10,11,14,8,16,7,18,7,20,8,21,10,void 0,3,8,4,10,6,11,8,11,10,10,14,7,16,6,18,6,20,7,21,10,21,12]}; -},{}],510:[function(require,module,exports){ +},{}],511:[function(require,module,exports){ module.exports={vectorChar:require("./vectorChar"),vectorText:require("./vectorText")}; -},{"./vectorChar":511,"./vectorText":513}],511:[function(require,module,exports){ +},{"./vectorChar":512,"./vectorText":514}],512:[function(require,module,exports){ const vectorParams=require("./vectorParams"),vectorChar=(t,e)=>{const{xOffset:r,yOffset:s,input:h,font:o,height:c,extrudeOffset:n}=vectorParams(t,e);let a=h.charCodeAt(0);a&&o[a]||(a=63);const f=[].concat(o[a]),i=(c-n)/o.height,u=n/2,g=f.shift()*i,l=[];let v=[];for(let t=0,e=f.length;t{e||"string"!=typeof t||(t={input:t}),t=t||{};const s=Object.assign({},defaultsVectorParams,t);return s.input=e||s.input,s};module.exports=vectorParams; -},{"./fonts/single-line/hershey/simplex.js":509}],513:[function(require,module,exports){ +},{"./fonts/single-line/hershey/simplex.js":510}],514:[function(require,module,exports){ const vectorChar=require("./vectorChar"),vectorParams=require("./vectorParams"),translateLine=(t,e)=>{const{x:n,y:s}=Object.assign({x:0,y:0},t||{}),r=e.segments;let h=null,a=null;for(let t=0,e=r.length;t{const{xOffset:n,yOffset:s,input:r,font:h,height:a,align:o,extrudeOffset:i,lineSpacing:c,letterSpacing:g}=vectorParams(t,e);let l,f,m,x,u,d,[v,w]=[n,s],O={width:0,segments:[]};const p=[];let y=[],C=0;const L=v,P=()=>{p.push(O),C=Math.max(C,O.width),O={width:0,segments:[]}};for(l=0,f=r.length;lO.width&&(d=C-O.width,"right"===o?O=translateLine({x:d},O):"center"===o&&(O=translateLine({x:d/2},O))),y=y.concat(O.segments);return y};module.exports=vectorText; -},{"./vectorChar":511,"./vectorParams":512}],514:[function(require,module,exports){ +},{"./vectorChar":512,"./vectorParams":513}],515:[function(require,module,exports){ const geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),path2=require("../geometries/path2"),areAllShapesTheSameType=e=>{let r;for(const o of e){let e=0;if(geom2.isA(o)&&(e=1),geom3.isA(o)&&(e=2),path2.isA(o)&&(e=3),r&&e!==r)return!1;r=e}return!0};module.exports=areAllShapesTheSameType; -},{"../geometries/geom2":144,"../geometries/geom3":160,"../geometries/path2":181}],515:[function(require,module,exports){ +},{"../geometries/geom2":144,"../geometries/geom3":160,"../geometries/path2":181}],516:[function(require,module,exports){ const degToRad=d=>.017453292519943295*d;module.exports=degToRad; -},{}],516:[function(require,module,exports){ +},{}],517:[function(require,module,exports){ const flatten=t=>t.reduce((t,a)=>Array.isArray(a)?t.concat(flatten(a)):t.concat(a),[]);module.exports=flatten; -},{}],517:[function(require,module,exports){ +},{}],518:[function(require,module,exports){ const fnNumberSort=(o,r)=>o-r;module.exports=fnNumberSort; -},{}],518:[function(require,module,exports){ +},{}],519:[function(require,module,exports){ module.exports={areAllShapesTheSameType:require("./areAllShapesTheSameType"),degToRad:require("./degToRad"),flatten:require("./flatten"),fnNumberSort:require("./fnNumberSort"),insertSorted:require("./insertSorted"),radiusToSegments:require("./radiusToSegments"),radToDeg:require("./radToDeg")}; -},{"./areAllShapesTheSameType":514,"./degToRad":515,"./flatten":516,"./fnNumberSort":517,"./insertSorted":519,"./radToDeg":521,"./radiusToSegments":522}],519:[function(require,module,exports){ +},{"./areAllShapesTheSameType":515,"./degToRad":516,"./flatten":517,"./fnNumberSort":518,"./insertSorted":520,"./radToDeg":522,"./radiusToSegments":523}],520:[function(require,module,exports){ const insertSorted=(t,e,o)=>{let r=0,s=t.length;for(;s>r;){const l=Math.floor((r+s)/2);o(e,t[l])>0?r=l+1:s=l}t.splice(r,0,e)};module.exports=insertSorted; -},{}],520:[function(require,module,exports){ +},{}],521:[function(require,module,exports){ const padArrayToLength=(r,e,o)=>{for(r=r.slice();r.length57.29577951308232*o;module.exports=radToDeg; -},{}],522:[function(require,module,exports){ +},{}],523:[function(require,module,exports){ const{TAU:TAU}=require("../maths/constants"),radiusToSegments=(t,e,s)=>{const a=e>0?t*TAU/e:0,n=s>0?TAU/s:0;return Math.ceil(Math.max(a,n,4))};module.exports=radiusToSegments; -},{"../maths/constants":213}],523:[function(require,module,exports){ +},{"../maths/constants":213}],524:[function(require,module,exports){ const flatten=t=>t.reduce((t,a)=>Array.isArray(a)?t.concat(flatten(a)):t.concat(a),[]);module.exports=flatten; -},{}],524:[function(require,module,exports){ +},{}],525:[function(require,module,exports){ const fnNumberSort=(o,r)=>o-r;module.exports=fnNumberSort; -},{}],525:[function(require,module,exports){ +},{}],526:[function(require,module,exports){ const head=r=>{if(Array.isArray(r)&&0!==r.length)return r[0]};module.exports=head; -},{}],526:[function(require,module,exports){ +},{}],527:[function(require,module,exports){ module.exports={flatten:require("./flatten"),fnNumberSort:require("./fnNumberSort"),head:require("./head"),insertSorted:require("./insertSorted"),nth:require("./nth"),padToLength:require("./padToLength"),toArray:require("./toArray")}; -},{"./flatten":523,"./fnNumberSort":524,"./head":525,"./insertSorted":527,"./nth":528,"./padToLength":529,"./toArray":530}],527:[function(require,module,exports){ +},{"./flatten":524,"./fnNumberSort":525,"./head":526,"./insertSorted":528,"./nth":529,"./padToLength":530,"./toArray":531}],528:[function(require,module,exports){ const insertSorted=(t,e,o)=>{let r=0,n=t.length;for(;n>r;){const s=Math.floor((r+n)/2);o(e,t[s])>0?r=s+1:n=s}return t.splice(r,0,e),t};module.exports=insertSorted; -},{}],528:[function(require,module,exports){ +},{}],529:[function(require,module,exports){ const nth=(r,t)=>{if(Array.isArray(r)&&!(r.length{for(e=e.slice();e.lengthArray.isArray(r)?r:null==r?[]:[r];module.exports=toArray; -},{}],531:[function(require,module,exports){ +},{}],532:[function(require,module,exports){ var transform=require("./lib/projectMat4");function unproject(r,t,e,o){var n=e[0],u=e[1],a=e[2],c=e[3],p=t[0],f=t[1],i=t[2];return p-=n,f=c-f-1,f-=u,r[0]=2*p/a-1,r[1]=2*f/c-1,r[2]=2*i-1,transform(r,r,o)}module.exports=unproject; -},{"./lib/projectMat4":532}],532:[function(require,module,exports){ +},{"./lib/projectMat4":533}],533:[function(require,module,exports){ function project(r,e,o){var t=e[0],c=e[1],n=e[2],p=o[0],u=o[1],j=o[2],a=o[3],d=o[4],f=o[5],i=o[6],l=o[7],m=o[8],s=o[9],v=o[10],x=o[11],b=o[12],g=o[13],h=o[14],k=1/(t*a+c*l+n*x+o[15]);return r[0]=(t*p+c*d+n*m+b)*k,r[1]=(t*u+c*f+n*s+g)*k,r[2]=(t*j+c*i+n*v+h)*k,r}module.exports=project; -},{}],533:[function(require,module,exports){ +},{}],534:[function(require,module,exports){ function adjoint(n,o){var t=o[0],r=o[1],a=o[2],d=o[3],e=o[4],i=o[5],u=o[6],j=o[7],c=o[8],f=o[9],l=o[10],m=o[11],p=o[12],s=o[13],v=o[14],x=o[15];return n[0]=i*(l*x-m*v)-f*(u*x-j*v)+s*(u*m-j*l),n[1]=-(r*(l*x-m*v)-f*(a*x-d*v)+s*(a*m-d*l)),n[2]=r*(u*x-j*v)-i*(a*x-d*v)+s*(a*j-d*u),n[3]=-(r*(u*m-j*l)-i*(a*m-d*l)+f*(a*j-d*u)),n[4]=-(e*(l*x-m*v)-c*(u*x-j*v)+p*(u*m-j*l)),n[5]=t*(l*x-m*v)-c*(a*x-d*v)+p*(a*m-d*l),n[6]=-(t*(u*x-j*v)-e*(a*x-d*v)+p*(a*j-d*u)),n[7]=t*(u*m-j*l)-e*(a*m-d*l)+c*(a*j-d*u),n[8]=e*(f*x-m*s)-c*(i*x-j*s)+p*(i*m-j*f),n[9]=-(t*(f*x-m*s)-c*(r*x-d*s)+p*(r*m-d*f)),n[10]=t*(i*x-j*s)-e*(r*x-d*s)+p*(r*j-d*i),n[11]=-(t*(i*m-j*f)-e*(r*m-d*f)+c*(r*j-d*i)),n[12]=-(e*(f*v-l*s)-c*(i*v-u*s)+p*(i*l-u*f)),n[13]=t*(f*v-l*s)-c*(r*v-a*s)+p*(r*l-a*f),n[14]=-(t*(i*v-u*s)-e*(r*v-a*s)+p*(r*u-a*i)),n[15]=t*(i*l-u*f)-e*(r*l-a*f)+c*(r*u-a*i),n}module.exports=adjoint; -},{}],534:[function(require,module,exports){ +},{}],535:[function(require,module,exports){ function clone(e){var n=new Float32Array(16);return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}module.exports=clone; -},{}],535:[function(require,module,exports){ +},{}],536:[function(require,module,exports){ function copy(o,c){return o[0]=c[0],o[1]=c[1],o[2]=c[2],o[3]=c[3],o[4]=c[4],o[5]=c[5],o[6]=c[6],o[7]=c[7],o[8]=c[8],o[9]=c[9],o[10]=c[10],o[11]=c[11],o[12]=c[12],o[13]=c[13],o[14]=c[14],o[15]=c[15],o}module.exports=copy; -},{}],536:[function(require,module,exports){ +},{}],537:[function(require,module,exports){ function create(){var e=new Float32Array(16);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}module.exports=create; -},{}],537:[function(require,module,exports){ +},{}],538:[function(require,module,exports){ function determinant(e){var n=e[0],t=e[1],r=e[2],a=e[3],d=e[4],i=e[5],m=e[6],o=e[7],u=e[8],c=e[9],f=e[10],l=e[11],p=e[12],s=e[13],v=e[14],x=e[15];return(n*i-t*d)*(f*x-l*v)-(n*m-r*d)*(c*x-l*s)+(n*o-a*d)*(c*v-f*s)+(t*m-r*i)*(u*x-l*p)-(t*o-a*i)*(u*v-f*p)+(r*o-a*m)*(u*s-c*p)}module.exports=determinant; -},{}],538:[function(require,module,exports){ +},{}],539:[function(require,module,exports){ function fromQuat(r,o){var t=o[0],u=o[1],a=o[2],e=o[3],f=t+t,m=u+u,n=a+a,Q=t*f,c=u*f,d=u*m,i=a*f,l=a*m,p=a*n,s=e*f,v=e*m,x=e*n;return r[0]=1-d-p,r[1]=c+x,r[2]=i-v,r[3]=0,r[4]=c-x,r[5]=1-Q-p,r[6]=l+s,r[7]=0,r[8]=i+v,r[9]=l-s,r[10]=1-Q-d,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}module.exports=fromQuat; -},{}],539:[function(require,module,exports){ +},{}],540:[function(require,module,exports){ function fromRotation(t,o,a){var n,r,s,e=a[0],h=a[1],i=a[2],u=Math.sqrt(e*e+h*h+i*i);return Math.abs(u)<1e-6?null:(e*=u=1/u,h*=u,i*=u,n=Math.sin(o),s=1-(r=Math.cos(o)),t[0]=e*e*s+r,t[1]=h*e*s+i*n,t[2]=i*e*s-h*n,t[3]=0,t[4]=e*h*s-i*n,t[5]=h*h*s+r,t[6]=i*h*s+e*n,t[7]=0,t[8]=e*i*s+h*n,t[9]=h*i*s-e*n,t[10]=i*i*s+r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}module.exports=fromRotation; -},{}],540:[function(require,module,exports){ +},{}],541:[function(require,module,exports){ function fromRotationTranslation(o,n,t){var r=n[0],a=n[1],i=n[2],e=n[3],f=r+r,l=a+a,m=i+i,s=r*f,u=r*l,R=r*m,T=a*l,c=a*m,d=i*m,p=e*f,v=e*l,x=e*m;return o[0]=1-(T+d),o[1]=u+x,o[2]=R-v,o[3]=0,o[4]=u-x,o[5]=1-(s+d),o[6]=c+p,o[7]=0,o[8]=R+v,o[9]=c-p,o[10]=1-(s+T),o[11]=0,o[12]=t[0],o[13]=t[1],o[14]=t[2],o[15]=1,o}module.exports=fromRotationTranslation; -},{}],541:[function(require,module,exports){ +},{}],542:[function(require,module,exports){ function fromScaling(n,o){return n[0]=o[0],n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=o[1],n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=o[2],n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}module.exports=fromScaling; -},{}],542:[function(require,module,exports){ +},{}],543:[function(require,module,exports){ function fromTranslation(n,o){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=o[0],n[13]=o[1],n[14]=o[2],n[15]=1,n}module.exports=fromTranslation; -},{}],543:[function(require,module,exports){ +},{}],544:[function(require,module,exports){ function fromXRotation(o,t){var n=Math.sin(t),r=Math.cos(t);return o[0]=1,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=r,o[6]=n,o[7]=0,o[8]=0,o[9]=-n,o[10]=r,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,o}module.exports=fromXRotation; -},{}],544:[function(require,module,exports){ +},{}],545:[function(require,module,exports){ function fromYRotation(o,t){var n=Math.sin(t),r=Math.cos(t);return o[0]=r,o[1]=0,o[2]=-n,o[3]=0,o[4]=0,o[5]=1,o[6]=0,o[7]=0,o[8]=n,o[9]=0,o[10]=r,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,o}module.exports=fromYRotation; -},{}],545:[function(require,module,exports){ +},{}],546:[function(require,module,exports){ function fromZRotation(o,t){var n=Math.sin(t),r=Math.cos(t);return o[0]=r,o[1]=n,o[2]=0,o[3]=0,o[4]=-n,o[5]=r,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=1,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,o}module.exports=fromZRotation; -},{}],546:[function(require,module,exports){ +},{}],547:[function(require,module,exports){ function frustum(u,r,t,e,f,m,n){var o=1/(t-r),s=1/(f-e),a=1/(m-n);return u[0]=2*m*o,u[1]=0,u[2]=0,u[3]=0,u[4]=0,u[5]=2*m*s,u[6]=0,u[7]=0,u[8]=(t+r)*o,u[9]=(f+e)*s,u[10]=(n+m)*a,u[11]=-1,u[12]=0,u[13]=0,u[14]=n*m*2*a,u[15]=0,u}module.exports=frustum; -},{}],547:[function(require,module,exports){ +},{}],548:[function(require,module,exports){ function identity(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}module.exports=identity; -},{}],548:[function(require,module,exports){ +},{}],549:[function(require,module,exports){ module.exports={create:require("./create"),clone:require("./clone"),copy:require("./copy"),identity:require("./identity"),transpose:require("./transpose"),invert:require("./invert"),adjoint:require("./adjoint"),determinant:require("./determinant"),multiply:require("./multiply"),translate:require("./translate"),scale:require("./scale"),rotate:require("./rotate"),rotateX:require("./rotateX"),rotateY:require("./rotateY"),rotateZ:require("./rotateZ"),fromRotation:require("./fromRotation"),fromRotationTranslation:require("./fromRotationTranslation"),fromScaling:require("./fromScaling"),fromTranslation:require("./fromTranslation"),fromXRotation:require("./fromXRotation"),fromYRotation:require("./fromYRotation"),fromZRotation:require("./fromZRotation"),fromQuat:require("./fromQuat"),frustum:require("./frustum"),perspective:require("./perspective"),perspectiveFromFieldOfView:require("./perspectiveFromFieldOfView"),ortho:require("./ortho"),lookAt:require("./lookAt"),str:require("./str")}; -},{"./adjoint":533,"./clone":534,"./copy":535,"./create":536,"./determinant":537,"./fromQuat":538,"./fromRotation":539,"./fromRotationTranslation":540,"./fromScaling":541,"./fromTranslation":542,"./fromXRotation":543,"./fromYRotation":544,"./fromZRotation":545,"./frustum":546,"./identity":547,"./invert":549,"./lookAt":550,"./multiply":551,"./ortho":552,"./perspective":553,"./perspectiveFromFieldOfView":554,"./rotate":555,"./rotateX":556,"./rotateY":557,"./rotateZ":558,"./scale":559,"./str":560,"./translate":561,"./transpose":562}],549:[function(require,module,exports){ +},{"./adjoint":534,"./clone":535,"./copy":536,"./create":537,"./determinant":538,"./fromQuat":539,"./fromRotation":540,"./fromRotationTranslation":541,"./fromScaling":542,"./fromTranslation":543,"./fromXRotation":544,"./fromYRotation":545,"./fromZRotation":546,"./frustum":547,"./identity":548,"./invert":550,"./lookAt":551,"./multiply":552,"./ortho":553,"./perspective":554,"./perspectiveFromFieldOfView":555,"./rotate":556,"./rotateX":557,"./rotateY":558,"./rotateZ":559,"./scale":560,"./str":561,"./translate":562,"./transpose":563}],550:[function(require,module,exports){ function invert(n,r){var e=r[0],t=r[1],u=r[2],i=r[3],l=r[4],o=r[5],v=r[6],a=r[7],c=r[8],d=r[9],f=r[10],m=r[11],p=r[12],s=r[13],x=r[14],b=r[15],g=e*o-t*l,h=e*v-u*l,j=e*a-i*l,k=t*v-u*o,q=t*a-i*o,w=u*a-i*v,y=c*s-d*p,z=c*x-f*p,A=c*b-m*p,B=d*x-f*s,C=d*b-m*s,D=f*b-m*x,E=g*D-h*C+j*B+k*A-q*z+w*y;return E?(E=1/E,n[0]=(o*D-v*C+a*B)*E,n[1]=(u*C-t*D-i*B)*E,n[2]=(s*w-x*q+b*k)*E,n[3]=(f*q-d*w-m*k)*E,n[4]=(v*A-l*D-a*z)*E,n[5]=(e*D-u*A+i*z)*E,n[6]=(x*j-p*w-b*h)*E,n[7]=(c*w-f*j+m*h)*E,n[8]=(l*C-o*A+a*y)*E,n[9]=(t*A-e*C-i*y)*E,n[10]=(p*q-s*j+b*g)*E,n[11]=(d*j-c*q-m*g)*E,n[12]=(o*z-l*B-v*y)*E,n[13]=(e*B-t*z+u*y)*E,n[14]=(s*h-p*k-x*g)*E,n[15]=(c*k-d*h+f*g)*E,n):null}module.exports=invert; -},{}],550:[function(require,module,exports){ +},{}],551:[function(require,module,exports){ var identity=require("./identity");function lookAt(t,a,e,r){var i,o,s,h,n,M,d,q,u,b,l=a[0],y=a[1],k=a[2],v=r[0],A=r[1],c=r[2],f=e[0],m=e[1],p=e[2];return Math.abs(l-f)<1e-6&&Math.abs(y-m)<1e-6&&Math.abs(k-p)<1e-6?identity(t):(d=l-f,q=y-m,u=k-p,i=A*(u*=b=1/Math.sqrt(d*d+q*q+u*u))-c*(q*=b),o=c*(d*=b)-v*u,s=v*q-A*d,(b=Math.sqrt(i*i+o*o+s*s))?(i*=b=1/b,o*=b,s*=b):(i=0,o=0,s=0),h=q*s-u*o,n=u*i-d*s,M=d*o-q*i,(b=Math.sqrt(h*h+n*n+M*M))?(h*=b=1/b,n*=b,M*=b):(h=0,n=0,M=0),t[0]=i,t[1]=h,t[2]=d,t[3]=0,t[4]=o,t[5]=n,t[6]=q,t[7]=0,t[8]=s,t[9]=M,t[10]=u,t[11]=0,t[12]=-(i*l+o*y+s*k),t[13]=-(h*l+n*y+M*k),t[14]=-(d*l+q*y+u*k),t[15]=1,t)}module.exports=lookAt; -},{"./identity":547}],551:[function(require,module,exports){ +},{"./identity":548}],552:[function(require,module,exports){ function multiply(l,t,u){var r=t[0],e=t[1],i=t[2],m=t[3],n=t[4],o=t[5],p=t[6],y=t[7],a=t[8],c=t[9],d=t[10],f=t[11],s=t[12],v=t[13],x=t[14],b=t[15],g=u[0],h=u[1],j=u[2],k=u[3];return l[0]=g*r+h*n+j*a+k*s,l[1]=g*e+h*o+j*c+k*v,l[2]=g*i+h*p+j*d+k*x,l[3]=g*m+h*y+j*f+k*b,g=u[4],h=u[5],j=u[6],k=u[7],l[4]=g*r+h*n+j*a+k*s,l[5]=g*e+h*o+j*c+k*v,l[6]=g*i+h*p+j*d+k*x,l[7]=g*m+h*y+j*f+k*b,g=u[8],h=u[9],j=u[10],k=u[11],l[8]=g*r+h*n+j*a+k*s,l[9]=g*e+h*o+j*c+k*v,l[10]=g*i+h*p+j*d+k*x,l[11]=g*m+h*y+j*f+k*b,g=u[12],h=u[13],j=u[14],k=u[15],l[12]=g*r+h*n+j*a+k*s,l[13]=g*e+h*o+j*c+k*v,l[14]=g*i+h*p+j*d+k*x,l[15]=g*m+h*y+j*f+k*b,l}module.exports=multiply; -},{}],552:[function(require,module,exports){ +},{}],553:[function(require,module,exports){ function ortho(o,r,t,e,n,u,h){var a=1/(r-t),c=1/(e-n),d=1/(u-h);return o[0]=-2*a,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=-2*c,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=2*d,o[11]=0,o[12]=(r+t)*a,o[13]=(n+e)*c,o[14]=(h+u)*d,o[15]=1,o}module.exports=ortho; -},{}],553:[function(require,module,exports){ +},{}],554:[function(require,module,exports){ function perspective(e,t,r,p,n){var a=1/Math.tan(t/2),c=1/(p-n);return e[0]=a/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=(n+p)*c,e[11]=-1,e[12]=0,e[13]=0,e[14]=2*n*p*c,e[15]=0,e}module.exports=perspective; -},{}],554:[function(require,module,exports){ +},{}],555:[function(require,module,exports){ function perspectiveFromFieldOfView(e,t,a,r){var h=Math.tan(t.upDegrees*Math.PI/180),i=Math.tan(t.downDegrees*Math.PI/180),n=Math.tan(t.leftDegrees*Math.PI/180),M=Math.tan(t.rightDegrees*Math.PI/180),s=2/(n+M),o=2/(h+i);return e[0]=s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=-(n-M)*s*.5,e[9]=(h-i)*o*.5,e[10]=r/(a-r),e[11]=-1,e[12]=0,e[13]=0,e[14]=r*a/(a-r),e[15]=0,e}module.exports=perspectiveFromFieldOfView; -},{}],555:[function(require,module,exports){ +},{}],556:[function(require,module,exports){ function rotate(t,a,r,e){var o,n,s,h,u,M,l,c,i,b,d,f,m,p,q,v,x,g,j,k,w,y,z,A,B=e[0],C=e[1],D=e[2],E=Math.sqrt(B*B+C*C+D*D);return Math.abs(E)<1e-6?null:(B*=E=1/E,C*=E,D*=E,o=Math.sin(r),s=1-(n=Math.cos(r)),h=a[0],u=a[1],M=a[2],l=a[3],c=a[4],i=a[5],b=a[6],d=a[7],f=a[8],m=a[9],p=a[10],q=a[11],v=B*B*s+n,x=C*B*s+D*o,g=D*B*s-C*o,j=B*C*s-D*o,k=C*C*s+n,w=D*C*s+B*o,y=B*D*s+C*o,z=C*D*s-B*o,A=D*D*s+n,t[0]=h*v+c*x+f*g,t[1]=u*v+i*x+m*g,t[2]=M*v+b*x+p*g,t[3]=l*v+d*x+q*g,t[4]=h*j+c*k+f*w,t[5]=u*j+i*k+m*w,t[6]=M*j+b*k+p*w,t[7]=l*j+d*k+q*w,t[8]=h*y+c*z+f*A,t[9]=u*y+i*z+m*A,t[10]=M*y+b*z+p*A,t[11]=l*y+d*z+q*A,a!==t&&(t[12]=a[12],t[13]=a[13],t[14]=a[14],t[15]=a[15]),t)}module.exports=rotate; -},{}],556:[function(require,module,exports){ +},{}],557:[function(require,module,exports){ function rotateX(t,o,r){var a=Math.sin(r),e=Math.cos(r),n=o[4],s=o[5],u=o[6],c=o[7],h=o[8],i=o[9],M=o[10],X=o[11];return o!==t&&(t[0]=o[0],t[1]=o[1],t[2]=o[2],t[3]=o[3],t[12]=o[12],t[13]=o[13],t[14]=o[14],t[15]=o[15]),t[4]=n*e+h*a,t[5]=s*e+i*a,t[6]=u*e+M*a,t[7]=c*e+X*a,t[8]=h*e-n*a,t[9]=i*e-s*a,t[10]=M*e-u*a,t[11]=X*e-c*a,t}module.exports=rotateX; -},{}],557:[function(require,module,exports){ +},{}],558:[function(require,module,exports){ function rotateY(t,o,r){var a=Math.sin(r),e=Math.cos(r),n=o[0],s=o[1],u=o[2],c=o[3],h=o[8],i=o[9],M=o[10],Y=o[11];return o!==t&&(t[4]=o[4],t[5]=o[5],t[6]=o[6],t[7]=o[7],t[12]=o[12],t[13]=o[13],t[14]=o[14],t[15]=o[15]),t[0]=n*e-h*a,t[1]=s*e-i*a,t[2]=u*e-M*a,t[3]=c*e-Y*a,t[8]=n*a+h*e,t[9]=s*a+i*e,t[10]=u*a+M*e,t[11]=c*a+Y*e,t}module.exports=rotateY; -},{}],558:[function(require,module,exports){ +},{}],559:[function(require,module,exports){ function rotateZ(t,o,r){var a=Math.sin(r),e=Math.cos(r),n=o[0],s=o[1],u=o[2],c=o[3],h=o[4],i=o[5],M=o[6],Z=o[7];return o!==t&&(t[8]=o[8],t[9]=o[9],t[10]=o[10],t[11]=o[11],t[12]=o[12],t[13]=o[13],t[14]=o[14],t[15]=o[15]),t[0]=n*e+h*a,t[1]=s*e+i*a,t[2]=u*e+M*a,t[3]=c*e+Z*a,t[4]=h*e-n*a,t[5]=i*e-s*a,t[6]=M*e-u*a,t[7]=Z*e-c*a,t}module.exports=rotateZ; -},{}],559:[function(require,module,exports){ +},{}],560:[function(require,module,exports){ function scale(e,r,a){var c=a[0],l=a[1],n=a[2];return e[0]=r[0]*c,e[1]=r[1]*c,e[2]=r[2]*c,e[3]=r[3]*c,e[4]=r[4]*l,e[5]=r[5]*l,e[6]=r[6]*l,e[7]=r[7]*l,e[8]=r[8]*n,e[9]=r[9]*n,e[10]=r[10]*n,e[11]=r[11]*n,e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],e}module.exports=scale; -},{}],560:[function(require,module,exports){ +},{}],561:[function(require,module,exports){ function str(t){return"mat4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"}module.exports=str; -},{}],561:[function(require,module,exports){ +},{}],562:[function(require,module,exports){ function translate(t,r,a){var e,n,l,o,s,u,c,d,f,i,m,p,v=a[0],x=a[1],b=a[2];return r===t?(t[12]=r[0]*v+r[4]*x+r[8]*b+r[12],t[13]=r[1]*v+r[5]*x+r[9]*b+r[13],t[14]=r[2]*v+r[6]*x+r[10]*b+r[14],t[15]=r[3]*v+r[7]*x+r[11]*b+r[15]):(e=r[0],n=r[1],l=r[2],o=r[3],s=r[4],u=r[5],c=r[6],d=r[7],f=r[8],i=r[9],m=r[10],p=r[11],t[0]=e,t[1]=n,t[2]=l,t[3]=o,t[4]=s,t[5]=u,t[6]=c,t[7]=d,t[8]=f,t[9]=i,t[10]=m,t[11]=p,t[12]=e*v+s*x+f*b+r[12],t[13]=n*v+u*x+i*b+r[13],t[14]=l*v+c*x+m*b+r[14],t[15]=o*v+d*x+p*b+r[15]),t}module.exports=translate; -},{}],562:[function(require,module,exports){ +},{}],563:[function(require,module,exports){ function transpose(e,r){if(e===r){var s=r[1],n=r[2],o=r[3],t=r[6],a=r[7],p=r[11];e[1]=r[4],e[2]=r[8],e[3]=r[12],e[4]=s,e[6]=r[9],e[7]=r[13],e[8]=n,e[9]=t,e[11]=r[14],e[12]=o,e[13]=a,e[14]=p}else e[0]=r[0],e[1]=r[4],e[2]=r[8],e[3]=r[12],e[4]=r[1],e[5]=r[5],e[6]=r[9],e[7]=r[13],e[8]=r[2],e[9]=r[6],e[10]=r[10],e[11]=r[14],e[12]=r[3],e[13]=r[7],e[14]=r[11],e[15]=r[15];return e}module.exports=transpose; -},{}],563:[function(require,module,exports){ +},{}],564:[function(require,module,exports){ function add(d,e,n){return d[0]=e[0]+n[0],d[1]=e[1]+n[1],d[2]=e[2]+n[2],d}module.exports=add; -},{}],564:[function(require,module,exports){ +},{}],565:[function(require,module,exports){ module.exports=angle;var fromValues=require("./fromValues"),normalize=require("./normalize"),dot=require("./dot");function angle(r,e){var a=fromValues(r[0],r[1],r[2]),o=fromValues(e[0],e[1],e[2]);normalize(a,a),normalize(o,o);var l=dot(a,o);return l>1?0:Math.acos(l)} -},{"./dot":574,"./fromValues":580,"./normalize":591}],565:[function(require,module,exports){ +},{"./dot":575,"./fromValues":581,"./normalize":592}],566:[function(require,module,exports){ function ceil(e,c){return e[0]=Math.ceil(c[0]),e[1]=Math.ceil(c[1]),e[2]=Math.ceil(c[2]),e}module.exports=ceil; -},{}],566:[function(require,module,exports){ +},{}],567:[function(require,module,exports){ function clone(e){var n=new Float32Array(3);return n[0]=e[0],n[1]=e[1],n[2]=e[2],n}module.exports=clone; -},{}],567:[function(require,module,exports){ +},{}],568:[function(require,module,exports){ function copy(o,c){return o[0]=c[0],o[1]=c[1],o[2]=c[2],o}module.exports=copy; -},{}],568:[function(require,module,exports){ +},{}],569:[function(require,module,exports){ function create(){var e=new Float32Array(3);return e[0]=0,e[1]=0,e[2]=0,e}module.exports=create; -},{}],569:[function(require,module,exports){ +},{}],570:[function(require,module,exports){ function cross(r,o,s){var c=o[0],e=o[1],n=o[2],t=s[0],u=s[1],a=s[2];return r[0]=e*a-n*u,r[1]=n*t-c*a,r[2]=c*u-e*t,r}module.exports=cross; -},{}],570:[function(require,module,exports){ +},{}],571:[function(require,module,exports){ module.exports=require("./distance"); -},{"./distance":571}],571:[function(require,module,exports){ +},{"./distance":572}],572:[function(require,module,exports){ function distance(t,e){var n=e[0]-t[0],r=e[1]-t[1],a=e[2]-t[2];return Math.sqrt(n*n+r*r+a*a)}module.exports=distance; -},{}],572:[function(require,module,exports){ +},{}],573:[function(require,module,exports){ module.exports=require("./divide"); -},{"./divide":573}],573:[function(require,module,exports){ +},{"./divide":574}],574:[function(require,module,exports){ function divide(d,e,i){return d[0]=e[0]/i[0],d[1]=e[1]/i[1],d[2]=e[2]/i[2],d}module.exports=divide; -},{}],574:[function(require,module,exports){ +},{}],575:[function(require,module,exports){ function dot(o,t){return o[0]*t[0]+o[1]*t[1]+o[2]*t[2]}module.exports=dot; -},{}],575:[function(require,module,exports){ +},{}],576:[function(require,module,exports){ module.exports=1e-6; -},{}],576:[function(require,module,exports){ +},{}],577:[function(require,module,exports){ module.exports=equals;var EPSILON=require("./epsilon");function equals(a,t){var s=a[0],h=a[1],M=a[2],b=t[0],e=t[1],r=t[2];return Math.abs(s-b)<=EPSILON*Math.max(1,Math.abs(s),Math.abs(b))&&Math.abs(h-e)<=EPSILON*Math.max(1,Math.abs(h),Math.abs(e))&&Math.abs(M-r)<=EPSILON*Math.max(1,Math.abs(M),Math.abs(r))} -},{"./epsilon":575}],577:[function(require,module,exports){ +},{"./epsilon":576}],578:[function(require,module,exports){ function exactEquals(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}module.exports=exactEquals; -},{}],578:[function(require,module,exports){ +},{}],579:[function(require,module,exports){ function floor(o,r){return o[0]=Math.floor(r[0]),o[1]=Math.floor(r[1]),o[2]=Math.floor(r[2]),o}module.exports=floor; -},{}],579:[function(require,module,exports){ +},{}],580:[function(require,module,exports){ module.exports=forEach;var vec=require("./create")();function forEach(e,c,r,v,t,a){var n,o;for(c||(c=3),r||(r=0),o=v?Math.min(v*c+r,e.length):e.length,n=r;n0&&(a=1/Math.sqrt(a),r[0]=e[0]*a,r[1]=e[1]*a,r[2]=e[2]*a),r}module.exports=normalize; -},{}],592:[function(require,module,exports){ +},{}],593:[function(require,module,exports){ function random(a,t){t=t||1;var r=2*Math.random()*Math.PI,n=2*Math.random()-1,o=Math.sqrt(1-n*n)*t;return a[0]=Math.cos(r)*o,a[1]=Math.sin(r)*o,a[2]=n*t,a}module.exports=random; -},{}],593:[function(require,module,exports){ +},{}],594:[function(require,module,exports){ function rotateX(t,o,r,a){var e=r[1],n=r[2],s=o[1]-e,u=o[2]-n,c=Math.sin(a),h=Math.cos(a);return t[0]=o[0],t[1]=e+s*h-u*c,t[2]=n+s*c+u*h,t}module.exports=rotateX; -},{}],594:[function(require,module,exports){ +},{}],595:[function(require,module,exports){ function rotateY(t,o,r,a){var e=r[0],n=r[2],s=o[0]-e,u=o[2]-n,c=Math.sin(a),h=Math.cos(a);return t[0]=e+u*c+s*h,t[1]=o[1],t[2]=n+u*h-s*c,t}module.exports=rotateY; -},{}],595:[function(require,module,exports){ +},{}],596:[function(require,module,exports){ function rotateZ(t,o,r,a){var e=r[0],n=r[1],s=o[0]-e,u=o[1]-n,c=Math.sin(a),h=Math.cos(a);return t[0]=e+s*h-u*c,t[1]=n+s*c+u*h,t[2]=o[2],t}module.exports=rotateZ; -},{}],596:[function(require,module,exports){ +},{}],597:[function(require,module,exports){ function round(n,o){return n[0]=Math.round(o[0]),n[1]=Math.round(o[1]),n[2]=Math.round(o[2]),n}module.exports=round; -},{}],597:[function(require,module,exports){ +},{}],598:[function(require,module,exports){ function scale(e,c,l){return e[0]=c[0]*l,e[1]=c[1]*l,e[2]=c[2]*l,e}module.exports=scale; -},{}],598:[function(require,module,exports){ +},{}],599:[function(require,module,exports){ function scaleAndAdd(d,e,n,A){return d[0]=e[0]+n[0]*A,d[1]=e[1]+n[1]*A,d[2]=e[2]+n[2]*A,d}module.exports=scaleAndAdd; -},{}],599:[function(require,module,exports){ +},{}],600:[function(require,module,exports){ function set(e,t,n,o){return e[0]=t,e[1]=n,e[2]=o,e}module.exports=set; -},{}],600:[function(require,module,exports){ +},{}],601:[function(require,module,exports){ module.exports=require("./squaredDistance"); -},{"./squaredDistance":602}],601:[function(require,module,exports){ +},{"./squaredDistance":603}],602:[function(require,module,exports){ module.exports=require("./squaredLength"); -},{"./squaredLength":603}],602:[function(require,module,exports){ +},{"./squaredLength":604}],603:[function(require,module,exports){ function squaredDistance(e,r){var a=r[0]-e[0],n=r[1]-e[1],s=r[2]-e[2];return a*a+n*n+s*s}module.exports=squaredDistance; -},{}],603:[function(require,module,exports){ +},{}],604:[function(require,module,exports){ function squaredLength(e){var r=e[0],n=e[1],t=e[2];return r*r+n*n+t*t}module.exports=squaredLength; -},{}],604:[function(require,module,exports){ +},{}],605:[function(require,module,exports){ module.exports=require("./subtract"); -},{"./subtract":605}],605:[function(require,module,exports){ +},{"./subtract":606}],606:[function(require,module,exports){ function subtract(t,r,u){return t[0]=r[0]-u[0],t[1]=r[1]-u[1],t[2]=r[2]-u[2],t}module.exports=subtract; -},{}],606:[function(require,module,exports){ +},{}],607:[function(require,module,exports){ function transformMat3(r,t,a){var n=t[0],o=t[1],e=t[2];return r[0]=n*a[0]+o*a[3]+e*a[6],r[1]=n*a[1]+o*a[4]+e*a[7],r[2]=n*a[2]+o*a[5]+e*a[8],r}module.exports=transformMat3; -},{}],607:[function(require,module,exports){ +},{}],608:[function(require,module,exports){ function transformMat4(r,t,a){var n=t[0],o=t[1],e=t[2],f=a[3]*n+a[7]*o+a[11]*e+a[15];return f=f||1,r[0]=(a[0]*n+a[4]*o+a[8]*e+a[12])/f,r[1]=(a[1]*n+a[5]*o+a[9]*e+a[13])/f,r[2]=(a[2]*n+a[6]*o+a[10]*e+a[14])/f,r}module.exports=transformMat4; -},{}],608:[function(require,module,exports){ +},{}],609:[function(require,module,exports){ function transformQuat(r,t,a){var n=t[0],o=t[1],u=t[2],e=a[0],f=a[1],m=a[2],s=a[3],Q=s*n+f*u-m*o,c=s*o+m*n-e*u,d=s*u+e*o-f*n,i=-e*n-f*o-m*u;return r[0]=Q*s+i*-e+c*-m-d*-f,r[1]=c*s+i*-f+d*-e-Q*-m,r[2]=d*s+i*-m+Q*-f-c*-e,r}module.exports=transformQuat; -},{}],609:[function(require,module,exports){ +},{}],610:[function(require,module,exports){ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.createREGL=t()}(this,function(){function e(e,t){this.id=H++,this.type=e,this.data=t}function t(e){return"["+function e(t){if(0===t.length)return[];var r=t.charAt(0),n=t.charAt(t.length-1);if(1>>=t))<<3,(t|=r=(15<(e>>>=r))<<2)|(r=(3<(e>>>=r))<<1)|e>>>r>>1}function o(){function e(e){e:{for(var t=16;268435456>=t;t*=16)if(e<=t){e=t;break e}e=0}return 0<(t=r[f(e)>>2]).length?t.pop():new ArrayBuffer(e)}function t(e){r[f(e.byteLength)>>2].push(e)}var r=a(8,function(){return[]});return{alloc:e,free:t,allocType:function(t,r){var n=null;switch(t){case 5120:n=new Int8Array(e(r),0,r);break;case 5121:n=new Uint8Array(e(r),0,r);break;case 5122:n=new Int16Array(e(2*r),0,r);break;case 5123:n=new Uint16Array(e(2*r),0,r);break;case 5124:n=new Int32Array(e(4*r),0,r);break;case 5125:n=new Uint32Array(e(4*r),0,r);break;case 5126:n=new Float32Array(e(4*r),0,r);break;default:return null}return n.length!==r?n.subarray(0,r):n},freeType:function(e){t(e.buffer)}}}function u(e){return!!e&&"object"==typeof e&&Array.isArray(e.shape)&&Array.isArray(e.stride)&&"number"==typeof e.offset&&e.shape.length===e.stride.length&&(Array.isArray(e.data)||G(e.data))}function s(e,t,r,n,i,a){for(var f=0;f(i=o)&&(i=n.buffer.byteLength,5123===l?i>>=1:5125===l&&(i>>=2)),n.vertCount=i,i=f,0>f&&(i=4,1===(f=n.buffer.dimension)&&(i=0),2===f&&(i=1),3===f&&(i=4)),n.primType=i}function f(e){n.elementsCount--,delete o[e.id],e.buffer.destroy(),e.buffer=null}var o={},s=0,c={uint8:5121,uint16:5123};t.oes_element_index_uint&&(c.uint32=5125),i.prototype.bind=function(){this.buffer.bind()};var l=[];return{create:function(e,t){function o(e){if(e)if("number"==typeof e)s(e),l.primType=4,l.vertCount=0|e,l.type=5121;else{var t=null,r=35044,n=-1,i=-1,f=0,p=0;Array.isArray(e)||G(e)||u(e)?t=e:("data"in e&&(t=e.data),"usage"in e&&(r=Z[e.usage]),"primitive"in e&&(n=re[e.primitive]),"count"in e&&(i=0|e.count),"type"in e&&(p=c[e.type]),"length"in e?f=0|e.length:(f=i,5123===p||5122===p?f*=2:5125!==p&&5124!==p||(f*=4))),a(l,t,r,n,i,f,p)}else s(),l.primType=4,l.vertCount=0,l.type=5121;return o}var s=r.create(null,34963,!0),l=new i(s._buffer);return n.elementsCount++,o(e),o._reglType="elements",o._elements=l,o.subdata=function(e,t){return s.subdata(e,t),o},o.destroy=function(){f(l)},o},createStream:function(e){var t=l.pop();return t||(t=new i(r.create(null,34963,!0,!1)._buffer)),a(t,e,35040,-1,-1,0,0),t},destroyStream:function(e){l.push(e)},getElements:function(e){return"function"==typeof e&&e._elements instanceof i?e._elements:null},clear:function(){Y(o).forEach(f)}}}function m(e){for(var t=q.allocType(5123,e.length),r=0;r>>31<<15,i=(a<<1>>>24)-127,a=a>>13&1023;t[r]=-24>i?n:-14>i?n+(a+1024>>-14-i):15>=i,r.height>>=i,d(r,n[i]),e.mipmask|=1<t;++t)e.images[t]=null;return e}function j(e){for(var t=e.images,r=0;rt){for(var r=0;r=--this.refCount&&P(this)}}),f.profile&&(a.getTotalTextureSize=function(){var e=0;return Object.keys(ye).forEach(function(t){e+=ye[t].stats.size}),e}),{create2D:function(t,r){function n(e,t){var r=i.texInfo;C.call(r);var a=S();return"number"==typeof e?E(a,0|e,"number"==typeof t?0|t:0|e):e?(V(r,e),D(a,e)):E(a,1,1),r.genMipmaps&&(a.mipmask=(a.width<<1)-1),i.mipmask=a.mipmask,s(i,a),i.internalformat=a.internalformat,n.width=a.width,n.height=a.height,z(i),T(a,3553),F(r,3553),I(),j(a),f.profile&&(i.stats.size=k(i.internalformat,i.type,a.width,a.height,r.genMipmaps,!1)),n.format=ee[i.internalformat],n.type=te[i.type],n.mag=re[r.magFilter],n.min=ne[r.minFilter],n.wrapS=ie[r.wrapS],n.wrapT=ie[r.wrapT],n}var i=new B(3553);return ye[i.id]=i,a.textureCount++,n(t,r),n.subimage=function(e,t,r,a){t|=0,r|=0,a|=0;var f=g();return s(f,i),f.width=0,f.height=0,d(f,e),f.width=f.width||(i.width>>a)-t,f.height=f.height||(i.height>>a)-r,z(i),h(f,3553,t,r,a),I(),_(f),n},n.resize=function(t,r){var a=0|t,o=0|r||a;if(a===i.width&&o===i.height)return n;n.width=i.width=a,n.height=i.height=o,z(i);for(var u=0;i.mipmask>>u;++u){var s=a>>u,c=o>>u;if(!s||!c)break;e.texImage2D(3553,u,i.format,s,c,0,i.format,i.type,null)}return I(),f.profile&&(i.stats.size=k(i.internalformat,i.type,a,o,!1,!1)),n},n._reglType="texture2d",n._texture=i,f.profile&&(n.stats=i.stats),n.destroy=function(){i.decRef()},n},createCube:function(t,r,n,i,o,u){function l(e,t,r,n,i,a){var o,u=p.texInfo;for(C.call(u),o=0;6>o;++o)m[o]=S();if("number"!=typeof e&&e){if("object"==typeof e)if(t)D(m[0],e),D(m[1],t),D(m[2],r),D(m[3],n),D(m[4],i),D(m[5],a);else if(V(u,e),c(p,e),"faces"in e)for(e=e.faces,o=0;6>o;++o)s(m[o],p),D(m[o],e[o]);else for(o=0;6>o;++o)D(m[o],e)}else for(e=0|e||1,o=0;6>o;++o)E(m[o],e,e);for(s(p,m[0]),p.mipmask=u.genMipmaps?(m[0].width<<1)-1:m[0].mipmask,p.internalformat=m[0].internalformat,l.width=m[0].width,l.height=m[0].height,z(p),o=0;6>o;++o)T(m[o],34069+o);for(F(u,34067),I(),f.profile&&(p.stats.size=k(p.internalformat,p.type,l.width,l.height,u.genMipmaps,!0)),l.format=ee[p.internalformat],l.type=te[p.type],l.mag=re[u.magFilter],l.min=ne[u.minFilter],l.wrapS=ie[u.wrapS],l.wrapT=ie[u.wrapT],o=0;6>o;++o)j(m[o]);return l}var p=new B(34067);ye[p.id]=p,a.cubeCount++;var m=Array(6);return l(t,r,n,i,o,u),l.subimage=function(e,t,r,n,i){r|=0,n|=0,i|=0;var a=g();return s(a,p),a.width=0,a.height=0,d(a,t),a.width=a.width||(p.width>>i)-r,a.height=a.height||(p.height>>i)-n,z(p),h(a,34069+e,r,n,i),I(),_(a),l},l.resize=function(t){if((t|=0)!==p.width){l.width=p.width=t,l.height=p.height=t,z(p);for(var r=0;6>r;++r)for(var n=0;p.mipmask>>n;++n)e.texImage2D(34069+r,n,p.format,t>>n,t>>n,0,p.format,p.type,null);return I(),f.profile&&(p.stats.size=k(p.internalformat,p.type,l.width,l.height,!1,!0)),l}},l._reglType="textureCube",l._texture=p,f.profile&&(l.stats=p.stats),l.destroy=function(){p.decRef()},l},clear:function(){for(var t=0;tr;++r)if(0!=(t.mipmask&1<>r,t.height>>r,0,t.internalformat,t.type,null);else for(var n=0;6>n;++n)e.texImage2D(34069+n,r,t.internalformat,t.width>>r,t.height>>r,0,t.internalformat,t.type,null);F(t.texInfo,t.target)})},refresh:function(){for(var t=0;ti;++i){for(s=0;se;++e)r[e].resize(n);return t.width=t.height=n,t},_reglType:"framebufferCube",destroy:function(){r.forEach(function(e){e.destroy()})}})},clear:function(){Y(_).forEach(b)},restore:function(){v.cur=null,v.next=null,v.dirty=!0,Y(_).forEach(function(t){t.framebuffer=e.createFramebuffer(),g(t)})}})}function E(){this.w=this.z=this.y=this.x=this.state=0,this.buffer=null,this.size=0,this.normalized=!1,this.type=5126,this.divisor=this.stride=this.offset=0}function D(e,t,r,n,i,a,f){function o(){this.id=++l,this.attributes=[],this.elements=null,this.ownsElements=!1,this.offset=this.count=0,this.instances=-1,this.primitive=4;var e=t.oes_vertex_array_object;this.vao=e?e.createVertexArrayOES():null,p[this.id]=this,this.buffers=[]}var s=r.maxAttributes,c=Array(s);for(r=0;r=p.byteLength?s.subdata(p):(s.destroy(),r.buffers[o]=null)),r.buffers[o]||(s=r.buffers[o]=i.create(c,34962,!1,!0)),l.buffer=i.getBuffer(s),l.size=0|l.buffer.dimension,l.normalized=!1,l.type=l.buffer.dtype,l.offset=0,l.stride=0,l.divisor=0,l.state=1,e[o]=1;else i.getBuffer(c)?(l.buffer=i.getBuffer(c),l.size=0|l.buffer.dimension,l.normalized=!1,l.type=l.buffer.dtype,l.offset=0,l.stride=0,l.divisor=0,l.state=1):i.getBuffer(c.buffer)?(l.buffer=i.getBuffer(c.buffer),l.size=0|(+c.size||l.buffer.dimension),l.normalized=!!c.normalized||!1,l.type="type"in c?K[c.type]:l.buffer.dtype,l.offset=0|(c.offset||0),l.stride=0|(c.stride||0),l.divisor=0|(c.divisor||0),l.state=1):"x"in c&&(l.x=+c.x||0,l.y=+c.y||0,l.z=+c.z||0,l.w=+c.w||0,l.state=2)}for(s=0;se&&(e=t.stats.uniformsCount)}),e},r.getMaxAttributesCount=function(){var e=0;return p.forEach(function(t){t.stats.attributesCount>e&&(e=t.stats.attributesCount)}),e}),{clear:function(){var t=e.deleteShader.bind(e);Y(s).forEach(t),s={},Y(c).forEach(t),c={},p.forEach(function(t){e.deleteProgram(t.program)}),p.length=0,l={},r.shaderCount=0},program:function(t,n,i,a){var f=l[n];f||(f=l[n]={});var d=f[t];if(d&&(d.refCount++,!a))return d;var h=new o(n,t);return r.shaderCount++,u(h,i,a),d||(f[t]=h),p.push(h),R(h,{destroy:function(){if(h.refCount--,0>=h.refCount){e.deleteProgram(h.program);var t=p.indexOf(h);p.splice(t,1),r.shaderCount--}0>=f[h.vertId].refCount&&(e.deleteShader(c[h.vertId]),delete c[h.vertId],delete l[h.fragId][h.vertId]),Object.keys(l[h.fragId]).length||(e.deleteShader(s[h.fragId]),delete s[h.fragId],delete l[h.fragId])}})},restore:function(){s={},c={};for(var e=0;e"+t+"?"+i+".constant["+t+"]:0;"}).join(""),"}}else{","if(",o,"(",i,".buffer)){",c,"=",a,".createStream(",34962,",",i,".buffer);","}else{",c,"=",a,".getBuffer(",i,".buffer);","}",l,'="type" in ',i,"?",f.glTypes,"[",i,".type]:",c,".dtype;",u.normalized,"=!!",i,".normalized;"),n("size"),n("offset"),n("stride"),n("divisor"),r("}}"),r.exit("if(",u.isStream,"){",a,".destroyStream(",c,");","}"),u})}),f}function O(e,t,n,i,f){function o(e){var t=s[e];t&&(p[e]=t)}var u=function(e,t){if("string"==typeof(r=e.static).frag&&"string"==typeof r.vert){if(0>1)",o],");")}function t(){r(u,".drawArraysInstancedANGLE(",[h,m,b,o],");")}d&&"null"!==d?y?e():(r("if(",d,"){"),e(),r("}else{"),t(),r("}")):t()}function f(){function e(){r(c+".drawElements("+[h,b,g,m+"<<(("+g+"-5121)>>1)"]+");")}function t(){r(c+".drawArrays("+[h,m,b]+");")}d&&"null"!==d?y?e():(r("if(",d,"){"),e(),r("}else{"),t(),r("}")):t()}var o,u,s=e.shared,c=s.gl,l=s.draw,p=n.draw,d=function(){var i=p.elements,a=t;return i?((i.contextDep&&n.contextDynamic||i.propDep)&&(a=r),i=i.append(e,a),p.elementsActive&&a("if("+i+")"+c+".bindBuffer(34963,"+i+".buffer.buffer);")):(i=a.def(),a(i,"=",l,".","elements",";","if(",i,"){",c,".bindBuffer(",34963,",",i,".buffer.buffer);}","else if(",s.vao,".currentVAO){",i,"=",e.shared.elements+".getElements("+s.vao,".currentVAO.elements);",ne?"":"if("+i+")"+c+".bindBuffer(34963,"+i+".buffer.buffer);","}")),i}(),h=i("primitive"),m=i("offset"),b=function(){var i=p.count,a=t;return i?((i.contextDep&&n.contextDynamic||i.propDep)&&(a=r),i=i.append(e,a)):i=a.def(l,".","count"),i}();if("number"==typeof b){if(0===b)return}else r("if(",b,"){"),r.exit("}");ee&&(o=i("instances"),u=e.instancing);var g=d+".type",y=p.elements&&z(p.elements)&&!p.vaoActive;ee&&("number"!=typeof o||0<=o)?"string"==typeof o?(r("if(",o,">0){"),a(),r("}else if(",o,"<0){"),f(),r("}")):a():f()}function q(e,t,r,n,i){return i=(t=x()).proc("body",i),ee&&(t.instancing=i.def(t.shared.extensions,".angle_instanced_arrays")),e(t,i,r,n),t.compile().body}function Q(e,t,r,n){L(e,t),r.useVAO?r.drawVAO?t(e.shared.vao,".setVAO(",r.drawVAO.append(e,t),");"):t(e.shared.vao,".setVAO(",e.shared.vao,".targetVAO);"):(t(e.shared.vao,".setVAO(null);"),H(e,t,r,n.attributes,function(){return!0})),U(e,t,r,n.uniforms,function(){return!0},!1),N(e,t,t,r)}function G(e,t,r,n){function i(){return!0}e.batchId="a1",L(e,t),H(e,t,r,n.attributes,i),U(e,t,r,n.uniforms,i,!1),N(e,t,t,r)}function Y(e,t,r,n){function i(e){return e.contextDep&&f||e.propDep}function a(e){return!i(e)}L(e,t);var f=r.contextDep,o=t.def(),u=t.def();e.shared.props=u,e.batchId=o;var s=e.scope(),c=e.scope();t(s.entry,"for(",o,"=0;",o,"<","a1",";++",o,"){",u,"=","a0","[",o,"];",c,"}",s.exit),r.needsContext&&E(e,c,r.context),r.needsFramebuffer&&D(e,c,r.framebuffer),S(e,c,r.state,i),r.profile&&i(r.profile)&&M(e,c,r,!1,!0),n?(r.useVAO?r.drawVAO?i(r.drawVAO)?c(e.shared.vao,".setVAO(",r.drawVAO.append(e,c),");"):s(e.shared.vao,".setVAO(",r.drawVAO.append(e,s),");"):s(e.shared.vao,".setVAO(",e.shared.vao,".targetVAO);"):(s(e.shared.vao,".setVAO(null);"),H(e,s,r,n.attributes,a),H(e,c,r,n.attributes,i)),U(e,s,r,n.uniforms,a,!1),U(e,c,r,n.uniforms,i,!0),N(e,s,c,r)):(t=e.global.def("{}"),n=r.shader.progVar.append(e,c),u=c.def(n,".id"),s=c.def(t,"[",u,"]"),c(e.shared.gl,".useProgram(",n,".program);","if(!",s,"){",s,"=",t,"[",u,"]=",e.link(function(t){return q(G,e,r,t,2)}),"(",n,");}",s,".call(this,a0[",o,"],",o,");"))}function X(e,r){function n(t){var n=r.shader[t];n&&i.set(a.shader,"."+t,n.append(e,i))}var i=e.proc("scope",3);e.batchId="a2";var a=e.shared,f=a.current;E(e,i,r.context),r.framebuffer&&r.framebuffer.append(e,i),F(Object.keys(r.state)).forEach(function(t){var n=r.state[t].append(e,i);b(n)?n.forEach(function(r,n){i.set(e.next[t],"["+n+"]",r)}):i.set(a.next,"."+t,n)}),M(e,i,r,!0,!0),["elements","offset","count","instances","primitive"].forEach(function(t){var n=r.draw[t];n&&i.set(a.draw,"."+t,""+n.append(e,i))}),Object.keys(r.uniforms).forEach(function(n){var f=r.uniforms[n].append(e,i);Array.isArray(f)&&(f="["+f.join()+"]"),i.set(a.uniforms,"["+t.id(n)+"]",f)}),Object.keys(r.attributes).forEach(function(t){var n=r.attributes[t].append(e,i),a=e.scopeAttrib(t);Object.keys(new Z).forEach(function(e){i.set(a,"."+e,n[e])})}),r.scopeVAO&&i.set(a.vao,".targetVAO",r.scopeVAO.append(e,i)),n("vert"),n("frag"),0=--this.refCount&&f(this)},i.profile&&(n.getTotalRenderbufferSize=function(){var e=0;return Object.keys(c).forEach(function(t){e+=c[t].stats.size}),e}),{create:function(t,r){function f(t,r){var n=0,a=0,c=32854;if("object"==typeof t&&t?("shape"in t?(n=0|(a=t.shape)[0],a=0|a[1]):("radius"in t&&(n=a=0|t.radius),"width"in t&&(n=0|t.width),"height"in t&&(a=0|t.height)),"format"in t&&(c=o[t.format])):"number"==typeof t?(n=0|t,a="number"==typeof r?0|r:n):t||(n=a=1),n!==s.width||a!==s.height||c!==s.format)return f.width=s.width=n,f.height=s.height=a,s.format=c,e.bindRenderbuffer(36161,s.renderbuffer),e.renderbufferStorage(36161,c,n,a),i.profile&&(s.stats.size=ge[s.format]*s.width*s.height),f.format=u[s.format],f}var s=new a(e.createRenderbuffer());return c[s.id]=s,n.renderbufferCount++,f(t,r),f.resize=function(t,r){var n=0|t,a=0|r||n;return n===s.width&&a===s.height?f:(f.width=s.width=n,f.height=s.height=a,e.bindRenderbuffer(36161,s.renderbuffer),e.renderbufferStorage(36161,s.format,n,a),i.profile&&(s.stats.size=ge[s.format]*s.width*s.height),f)},f._reglType="renderbuffer",f._renderbuffer=s,i.profile&&(f.stats=s.stats),f.destroy=function(){s.decRef()},f},clear:function(){Y(c).forEach(f)},restore:function(){Y(c).forEach(function(t){t.renderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(36161,t.renderbuffer),e.renderbufferStorage(36161,t.format,t.width,t.height)}),e.bindRenderbuffer(36161,null)}}},ve=[];ve[6408]=4,ve[6407]=3;var xe=[];xe[5121]=1,xe[5126]=4,xe[36193]=2;var we=["x","y","z","w"],Ae="blend.func blend.equation stencil.func stencil.opFront stencil.opBack sample.coverage viewport scissor.box polygonOffset.offset".split(" "),ke={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771,"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771,"one minus constant alpha":32772,"src alpha saturate":776},_e={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},Oe={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},Ee={cw:2304,ccw:2305},De=new B(!1,!1,!1,function(){});return function(e){function t(){if(0===J.length)A&&A.update(),ee=null;else{ee=U.next(t),l();for(var e=J.length-1;0<=e;--e){var r=J[e];r&&r(C,null,0)}b.flush(),A&&A.update()}}function r(){!ee&&0=J.length&&n()}}}}function c(){var e=Y.viewport,t=Y.scissor_box;e[0]=e[1]=t[0]=t[1]=0,C.viewportWidth=C.framebufferWidth=C.drawingBufferWidth=e[2]=t[2]=b.drawingBufferWidth,C.viewportHeight=C.framebufferHeight=C.drawingBufferHeight=e[3]=t[3]=b.drawingBufferHeight}function l(){C.tick+=1,C.time=m(),c(),G.procs.poll()}function p(){P.refresh(),c(),G.procs.refresh(),A&&A.update()}function m(){return(N()-k)/1e3}if(!(e=i(e)))return null;var b=e.gl,g=b.getContextAttributes();b.isContextLost();var y=function(e,t){function r(t){var r;t=t.toLowerCase();try{r=n[t]=e.getExtension(t)}catch(e){}return!!r}for(var n={},i=0;it;++t)te(R({framebuffer:e.framebuffer.faces[t]},e),u);else te(e,u);else u(0,e)},prop:W.define.bind(null,1),context:W.define.bind(null,2),this:W.define.bind(null,3),draw:o({}),buffer:function(e){return F.create(e,34962,!1,!1)},elements:function(e){return B.create(e,!1)},texture:P.create2D,cube:P.createCube,renderbuffer:H.create,framebuffer:q.create,framebufferCube:q.createCube,vao:z.createVAO,attributes:g,frame:s,on:function(e,t){var r;switch(e){case"frame":return s(t);case"lost":r=K;break;case"restore":r=Z;break;case"destroy":r=$}return r.push(t),{cancel:function(){for(var e=0;e{if(0===r.length)return[[0,0,0],[0,0,0]];const e=Array.isArray(r)&&Array.isArray(r[0]),n=e?r[0].length:3,o=new Array(n),t=new Array(n);for(let r=0;r{for(let l=0;lt[l]?n:t[l],o[l]=nt[l]?n:t[l],o[l]=n{let c;(e=flatten(e)).forEach(e=>{let t=boundingBox(e.positions);t=t.map(c=>vec3.transformMat4(c,c,e.transforms)),c?(vec3.min(c[0],c[0],t[0]),vec3.max(c[1],c[1],t[1])):c=t});const t=vec3.min(vec3.create(),c[1],c[0]),a=vec3.max(vec3.create(),c[1],c[0]),n=vec3.subtract(vec3.create(),a,t);let r=vec3.scale(vec3.create(),n,.5);return r=vec3.add(r,t,r),{dia:vec3.distance(r,a),center:[...r],min:[...t],max:[...a],size:[...n]}};module.exports=computeBounds; -},{"./boundingBox":610,"@jscad/array-utils":526,"gl-vec3":581}],612:[function(require,module,exports){ +},{"./boundingBox":611,"@jscad/array-utils":527,"gl-vec3":582}],613:[function(require,module,exports){ const vec3=require("gl-vec3"),mat4=require("gl-mat4"),fromOrthographicToPerspective=e=>{const{near:t,far:r,fov:o,zoom:a}=e,{viewport:i}=e,c=require("./perspectiveCamera").setProjection(e,{width:i[2],height:i[3]}),{projectionType:p}=require("./perspectiveCamera").cameraState;return Object.assign({},e,c,{projectionType:p},{near:t,far:r,fov:o})},fromPerspectiveToOrthographic=e=>{const{fov:t,aspect:r}=e,o=.3*vec3.length(vec3.subtract([],e.position,e.target)),a=Math.tan(t)*o*r,i=Math.tan(t)*o,{near:c,far:p,viewport:s}=e,n={zoom:1,near:c,far:p},v=require("./orthographicCamera").cameraState,h=require("./orthographicCamera").setProjection(n,{width:a,height:i});return Object.assign({},v,e,h,{projectionType:v.projectionType,viewport:s})},toPerspectiveView=({camera:e})=>{const t=vec3.distance(e.position,e.target),r=[t,t,t];return{view:mat4.lookAt(mat4.create(),r,e.target,e.up),position:r}},toPresetView=(e,{camera:t})=>{const r=vec3.distance(t.position,t.target),o=vec3.add(vec3.create(),{top:[0,-1e-6,1],bottom:[0,0,-1],front:[0,1,0],back:[0,-1,0],left:[-1,0,0],right:[1,0,0],undefined:[0,0,0]}[e].map(e=>e*r),t.target);return{view:mat4.lookAt(mat4.create(),o,t.target,t.up),position:o}};module.exports={toPerspectiveView:toPerspectiveView,toPresetView:toPresetView,fromOrthographicToPerspective:fromOrthographicToPerspective,fromPerspectiveToOrthographic:fromPerspectiveToOrthographic}; -},{"./orthographicCamera":613,"./perspectiveCamera":614,"gl-mat4":548,"gl-vec3":581}],613:[function(require,module,exports){ +},{"./orthographicCamera":614,"./perspectiveCamera":615,"gl-mat4":549,"gl-vec3":582}],614:[function(require,module,exports){ const mat4=require("gl-mat4"),cameraState={view:mat4.identity(new Float32Array(16)),projection:mat4.identity(new Float32Array(16)),matrix:mat4.identity(new Float32Array(16)),near:1,far:1300,up:[0,0,1],eye:new Float32Array(3),position:[150,250,200],target:[0,0,0],fov:Math.PI/4,aspect:1,viewport:[0,0,0,0],zoom:1,projectionType:"orthographic"},cameraProps={},setProjection=(t,e)=>{const{width:a,height:r}=e,o=a/r,i=[0,0,a,r],n=t.zoom,c=-a*n,m=a*n,p=-r*n,s=r*n;return{projection:mat4.ortho([],c,m,p,s,t.near,t.far),aspect:o,viewport:i}};module.exports={cameraState:cameraState,cameraProps:cameraProps,setProjection:setProjection}; -},{"gl-mat4":548}],614:[function(require,module,exports){ +},{"gl-mat4":549}],615:[function(require,module,exports){ const mat4=require("gl-mat4"),vec3=require("gl-vec3"),cameraState={view:mat4.identity(new Float32Array(16)),projection:mat4.identity(new Float32Array(16)),matrix:mat4.identity(new Float32Array(16)),near:1,far:18e3,up:[0,0,1],eye:new Float32Array(3),position:[450,550,700],target:[0,0,0],fov:Math.PI/4,aspect:1,viewport:[0,0,0,0],projectionType:"perspective"},cameraProps={},defaults=Object.assign({},cameraState,cameraProps),setProjection=(e,t,a)=>{const r=a.width/a.height,o=mat4.perspective(mat4.identity([]),t.fov,r,t.near,t.far),i=[0,0,a.width,a.height],c=e||{};return c.projection=o,c.aspect=r,c.viewport=i,c},update=(e,t)=>{t||(t=e);const{position:a,target:r,up:o}=t,i=vec3.subtract([],a,r),c=vec3.add(vec3.create(),r,i),n=mat4.lookAt(mat4.create(),c,r,o),p=e||{};return p.position=c,p.view=n,p};module.exports={cameraState:cameraState,cameraProps:cameraProps,defaults:defaults,setProjection:setProjection,update:update}; -},{"gl-mat4":548,"gl-vec3":581}],615:[function(require,module,exports){ +},{"gl-mat4":549,"gl-vec3":582}],616:[function(require,module,exports){ const vec3=require("gl-vec3"),mat4=require("gl-mat4"),{max:max,min:min,sqrt:sqrt,PI:PI,sin:sin,cos:cos,atan2:atan2}=Math,computeBounds=require("../bound-utils/computeBounds"),controlsProps={limits:{minDistance:.01,maxDistance:1e4},drag:.27,EPS:1e-6,zoomToFit:{auto:!0,targets:"all",tightness:1.5},userControl:{zoom:!0,zoomSpeed:1,rotate:!0,rotateSpeed:1,pan:!0,panSpeed:1},autoRotate:{enabled:!1,speed:1},autoAdjustPlanes:!0},controlsState={thetaDelta:0,phiDelta:0,scale:1},defaults=Object.assign({},controlsState,controlsProps),update=({controls:t,camera:e},a)=>{const{EPS:o,drag:s}=t,{position:r,target:n}=e,c=t.up?t.up:e.up;let i=t.thetaDelta;const l=t.phiDelta,m=t.scale,p=vec3.subtract([],r,n);let u,d;1===c[2]?(u=atan2(p[0],p[1]),d=atan2(sqrt(p[0]*p[0]+p[1]*p[1]),p[2])):(u=atan2(p[0],p[2]),d=atan2(sqrt(p[0]*p[0]+p[2]*p[2]),p[1])),t.autoRotate.enabled&&t.userControl.rotate&&(i+=2*Math.PI/60/60*t.autoRotate.speed),u+=i,d=max(o,min(PI-o,d+=l));const h=max(t.limits.minDistance,min(t.limits.maxDistance,vec3.length(p)*m));1===c[2]?(p[0]=h*sin(d)*sin(u),p[2]=h*cos(d),p[1]=h*sin(d)*cos(u)):(p[0]=h*sin(d)*sin(u),p[1]=h*cos(d),p[2]=h*sin(d)*cos(u));const g=vec3.add(vec3.create(),n,p),v=mat4.lookAt(mat4.create(),g,n,c),D=1-max(min(s,1),.01);return{controls:{thetaDelta:i*D,phiDelta:l*D,scale:1,changed:vec3.distance(r,g)>.001},camera:{position:g,view:v}}},rotate=({controls:t,camera:e,speed:a=1},o)=>{let{thetaDelta:s,phiDelta:r}=t;return t.userControl.rotate&&(s+=o[0]*a,r+=o[1]*a),{controls:{thetaDelta:s,phiDelta:r},camera:e}},zoom=({controls:t,camera:e,speed:a=1},o=0)=>{let{scale:s}=t;if(t.userControl.zoom&&e&&void 0!==o&&0!==o&&!isNaN(o)){const r=(o=o/o*(0===Math.sign(o)?1:Math.sign(o))*a)+t.scale,n=vec3.distance(e.position,e.target)*r;if(n>t.limits.minDistance&&n{const s=require("camera-unproject"),{projection:r,view:n,viewport:c}=e,i=mat4.multiply([],r,n),l=mat4.invert([],i),m=[c[2],c[3],0],p=[c[2]-o[0],c[3]+o[1],0],u=s([],m,c,l),d=s([],p,c,l),h=vec3.distance(e.position,e.eye),g=vec3.subtract([],u,d).map(e=>e*a*h*t.scale);return{controls:t,camera:{position:vec3.add(vec3.create(),e.position,g),target:vec3.add(vec3.create(),e.target,g)}}},zoomToFit=({controls:t,camera:e,entities:a})=>{const{zoomToFit:o}=t;if("all"!==o.targets)return{controls:t,camera:e};if(0===a.length)return{controls:t,camera:e};const s=a.map(t=>t.geometry),r=computeBounds(s),{fov:n,target:c,position:i}=e,{tightness:l}=Object.assign({},o,controlsProps.zoomToFit),m=r.dia*l/Math.tan(n/2)/vec3.distance(c,i);return{camera:{target:r.center},controls:{scale:m}}},reset=({controls:t,camera:e},a)=>{return{camera:{position:a.camera.position,target:a.camera.target,projection:mat4.perspective([],e.fov,e.aspect,e.near,e.far),view:a.camera.view},controls:{thetaDelta:a.controls.thetaDelta,phiDelta:a.controls.phiDelta,scale:a.controls.scale}}};module.exports={controlsProps:controlsProps,controlsState:controlsState,defaults:defaults,update:update,rotate:rotate,zoom:zoom,pan:pan,zoomToFit:zoomToFit,reset:reset}; -},{"../bound-utils/computeBounds":611,"../cameras/orthographicCamera":613,"camera-unproject":531,"gl-mat4":548,"gl-vec3":581}],616:[function(require,module,exports){ +},{"../bound-utils/computeBounds":612,"../cameras/orthographicCamera":614,"camera-unproject":532,"gl-mat4":549,"gl-vec3":582}],617:[function(require,module,exports){ const{flatten:flatten,toArray:toArray}=require("@jscad/array-utils"),{meshColor:meshColor}=require("../rendering/renderDefaults"),geom2ToGeometries=require("./geom2ToGeometries"),geom3ToGeometries=require("./geom3ToGeometries"),path2ToGeometries=require("./path2ToGeometries"),assembleEntities=e=>{return e.map(e=>{return{geometry:e,visuals:{drawCmd:"2d"===e.type?"drawLines":"drawMesh",show:!0,transparent:e.isTransparent,useVertexColors:!0}}})},entitiesFromSolids=(e,...o)=>{const r={color:meshColor,smoothNormals:!0},{color:t,smoothNormals:s}=Object.assign({},r,e);o=(o=flatten(toArray(o))).filter(e=>e&&e instanceof Object);const i=[];return o.forEach(e=>{let o=[];"sides"in e?o=geom2ToGeometries({color:t},e):"points"in e?o=path2ToGeometries({color:t},e):"polygons"in e&&(o=geom3ToGeometries({smoothLighting:s,normalThreshold:.3,color:t},e)),i.push(...assembleEntities(o))}),i};module.exports=entitiesFromSolids; -},{"../rendering/renderDefaults":633,"./geom2ToGeometries":617,"./geom3ToGeometries":618,"./path2ToGeometries":619,"@jscad/array-utils":526}],617:[function(require,module,exports){ +},{"../rendering/renderDefaults":634,"./geom2ToGeometries":618,"./geom3ToGeometries":619,"./path2ToGeometries":620,"@jscad/array-utils":527}],618:[function(require,module,exports){ const mat4=require("gl-mat4"),maxIndex=Math.floor(32767.5),geom2ToGeometries=(o,e)=>{let{color:t}=o;const n=e.sides;if(0===n.length)return[];"color"in e&&(t=e.color);const r=t[3]<1,s=[],l=Math.floor(n.length/maxIndex)+1,a=(o,e)=>{s.push(o,e||o)},m=[];for(let o=0;o0){const o=h.length;for(let e=0;e[0,0,-1]),f=h.map((o,e)=>e),p=e.transforms?mat4.clone(e.transforms):mat4.create();m.push({type:"2d",positions:h,normals:i,indices:f,transforms:p,color:t,colors:s,isTransparent:r})}return m};module.exports=geom2ToGeometries; -},{"gl-mat4":548}],618:[function(require,module,exports){ +},{"gl-mat4":549}],619:[function(require,module,exports){ const vec3=require("gl-vec3"),mat4=require("gl-mat4"),maxIndex=65535,geom3ToGeometries=(o,e)=>{let{color:t,smoothLighting:n}=o;"color"in e&&(t=e.color);const r=e.polygons,l=e.transforms?mat4.clone(e.transforms):mat4.create(),s=[];let c=0;for(;c65535);t++)e++;const n=[],i=[],a=[],p=[],m=t[3]<1;for(let o=c;o{const o=[],e=[];let t=!0;const n=[],r=[],l=[],s=[],c=[];let i=0;for(let a=0;a{let t=e;return o.color&&(t=o.color),t&&t.length<4&&t.push(1),t},calculateNormal=o=>{if(o.plane)return vec3.clone(o.plane);const e=o.vertices,t=vec3.create();vec3.subtract(t,e[1],e[0]);const n=vec3.create();vec3.subtract(n,e[2],e[0]);const r=vec3.create();return vec3.cross(r,t,n),vec3.normalize(r,r),r},areNormalsSimilar=(o,e,t)=>vec3.distance(o,e)<=t,fuzyNormalAndPositionLookup=(o,e,t)=>{const n=o[e.position];if(n)for(let o=0;o{let{color:e}=o;const s=t.points;if(0===s.length)return[];"color"in t&&(e=t.color);const n=e[3]<1,r=Math.floor(s.length/maxIndex)+1,a=[];for(let o=0;o[0,0,-1]),h=c.map((o,t)=>t),f=t.transforms?mat4.clone(t.transforms):mat4.create();a.push({type:"2d",positions:c,normals:p,indices:h,transforms:f,color:e,isTransparent:n})}return a};module.exports=path2ToGeometries; -},{"gl-mat4":548}],620:[function(require,module,exports){ +},{"gl-mat4":549}],621:[function(require,module,exports){ module.exports={prepareRender:require("./rendering/render"),drawCommands:{drawGrid:require("./rendering/commands/drawGrid/multi.js"),drawAxis:require("./rendering/commands/drawAxis"),drawMesh:require("./rendering/commands/drawMesh"),drawLines:require("./rendering/commands/drawLines")},cameras:{camera:require("./cameras/camera"),orthographic:require("./cameras/orthographicCamera"),perspective:require("./cameras/perspectiveCamera")},controls:{orbit:require("./controls/orbitControls")},entitiesFromSolids:require("./geometry-utils-V2/entitiesFromSolids")}; -},{"./cameras/camera":612,"./cameras/orthographicCamera":613,"./cameras/perspectiveCamera":614,"./controls/orbitControls":615,"./geometry-utils-V2/entitiesFromSolids":616,"./rendering/commands/drawAxis":621,"./rendering/commands/drawGrid/multi.js":623,"./rendering/commands/drawLines":625,"./rendering/commands/drawMesh":628,"./rendering/render":631}],621:[function(require,module,exports){ +},{"./cameras/camera":613,"./cameras/orthographicCamera":614,"./cameras/perspectiveCamera":615,"./controls/orbitControls":616,"./geometry-utils-V2/entitiesFromSolids":617,"./rendering/commands/drawAxis":622,"./rendering/commands/drawGrid/multi.js":624,"./rendering/commands/drawLines":626,"./rendering/commands/drawMesh":629,"./rendering/render":632}],622:[function(require,module,exports){ const mat4=require("gl-mat4"),drawAxis=(t,i)=>{let{size:o,xColor:e,yColor:l,zColor:m,lineWidth:a,alwaysVisible:n}=Object.assign({},{xColor:[1,0,0,1],yColor:[0,1,0,1],zColor:[0,0,1,1],size:10,lineWidth:3,alwaysVisible:!0},i);a>t.limits.lineWidthDims[1]&&(a=t.limits.lineWidthDims[1]);const r=[0,0,0,o,0,0],d={frag:"precision mediump float;\n uniform vec4 color;\n void main() {\n gl_FragColor = color;\n }",vert:"\n precision mediump float;\n attribute vec3 position;\n uniform mat4 model, view, projection;\n void main() {\n gl_Position = projection * view * model * vec4(position, 1);\n }",uniforms:{model:(t,i)=>i&&i.model?i.model:mat4.identity([]),color:(t,i)=>i.color,angle:(t,i)=>i.angle},attributes:{position:r},count:r.length/3,primitive:"line loop",lineWidth:a,depth:{enable:!n}},s=mat4.identity([]),c=mat4.rotateZ(mat4.create(),mat4.identity([]),Math.PI/2),p=mat4.rotateY(mat4.create(),mat4.identity([]),-Math.PI/2),u=t(d);return t=>{const i={model:mat4.identity([])};return t=Object.assign({},i,t),u([{color:e,model:mat4.multiply(mat4.create(),t.model,s)},{color:l,model:mat4.multiply(mat4.create(),t.model,c)},{color:m,model:mat4.multiply(mat4.create(),t.model,p)}])}};module.exports=drawAxis; -},{"gl-mat4":548}],622:[function(require,module,exports){ +},{"gl-mat4":549}],623:[function(require,module,exports){ const mat4=require("gl-mat4"),makeDrawGrid=(o,i={})=>{const n=[],t={visuals:{color:[0,0,1,1],fadeOut:!1},ticks:1,size:[16,16],centered:!1,lineWidth:2},e=Object.assign({},t.visuals,i.visuals||{}),{fadeOut:r,color:s}=e,{size:l,ticks:a,centered:c,lineWidth:d}=Object.assign({},t,i),f=l[0],u=l[1];if(c){const o=.5*f,i=.5*u,t=-o+o%a,e=-t,r=-i+i%a,s=-r,l=0;for(let o=t,i=0;o<=e;o+=a,i+=1)i%l!=0&&(n.push(r,o,0),n.push(s,o,0),n.push(r,o,0));for(let o=r,i=0;o<=s;o+=a,i+=1)i%l!=0&&(n.push(o,t,0),n.push(o,e,0),n.push(o,t,0))}else{for(let o=.5*-f;o<=.5*f;o+=a)n.push(.5*-u,o,0),n.push(.5*u,o,0),n.push(.5*-u,o,0);for(let o=.5*-u;o<=.5*u;o+=a)n.push(o,.5*-f,0),n.push(o,.5*f,0),n.push(o,.5*-f,0)}return o({vert:"precision mediump float;\n\n uniform float camNear, camFar;\n uniform mat4 model, view, projection;\n\n attribute vec3 position;\n varying vec3 fragNormal, fragPosition;\n varying vec4 worldPosition;\n\n void main() {\n fragPosition = position;\n worldPosition = model * vec4(position, 1);\n vec4 glPosition = projection * view * worldPosition;\n gl_Position = glPosition;\n }",frag:"precision mediump float;\n uniform vec4 color;\n varying vec3 fragNormal, fragPosition;\n varying vec4 worldPosition;\n\n uniform vec4 fogColor;\n uniform bool fadeOut;\n void main() {\n float dist = .5;\n if(fadeOut){\n dist = distance( vec2(0.,0.), vec2(worldPosition.x, worldPosition.y));\n dist *= 0.0025;\n dist = sqrt(dist);\n }\n\n gl_FragColor = mix(color, fogColor, dist);\n }\n ",attributes:{position:o.buffer(n)},count:n.length/3,uniforms:{model:(o,i)=>i&&i.model?i.model:mat4.identity([]),color:(o,i)=>i&&i.color?i.color:s,fogColor:(o,i)=>i&&i.color?[i.color[0],i.color[1],i.color[2],0]:[s[0],s[1],s[2],0],fadeOut:(o,i)=>i&&void 0!==i.fadeOut?i.fadeOut:r},lineWidth:(i,n)=>Math.min(n&&n.lineWidth?n.lineWidth:d,o.limits.lineWidthDims[1]),primitive:"lines",cull:{enable:!0,face:"front"},polygonOffset:{enable:!0,offset:{factor:1,units:10*Math.random()}},blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"}}})};module.exports=makeDrawGrid; -},{"gl-mat4":548}],623:[function(require,module,exports){ +},{"gl-mat4":549}],624:[function(require,module,exports){ const makeDrawMultiGrid=(e,i)=>{const{size:s,ticks:r}=Object.assign({},{size:[50,50],ticks:[10,1]},i),t=require("./index")(e,{size:s,ticks:r[0]}),u=require("./index")(e,{size:s,ticks:r[1]});return e=>{t(e),u({color:e.subColor,fadeOut:e.fadeOut})}};module.exports=makeDrawMultiGrid; -},{"./index":622}],624:[function(require,module,exports){ +},{"./index":623}],625:[function(require,module,exports){ const vColorFrag="\nprecision mediump float;\nuniform vec4 ucolor;\n\nvoid main () {\n gl_FragColor = ucolor;\n}\n";module.exports={frag:vColorFrag}; -},{}],625:[function(require,module,exports){ +},{}],626:[function(require,module,exports){ const mat4=require("gl-mat4"),{meshColor:meshColor}=require("../../renderDefaults"),drawLines=(e,r={})=>{const o={color:meshColor,geometry:void 0};let{geometry:t,color:s,transparent:a}=Object.assign({},o,r);"color"in t&&(s=t.color);const l=!!(t.indices&&t.indices.length>0),i=!!(t.normals&&t.normals.length>0),n=!!(t.colors&&t.colors.length>0),c={primitive:"lines",vert:n?require("./vColorShaders").vert:require("./meshShaders").vert,frag:n?require("./vColorShaders").frag:require("./colorOnlyShaders").frag,uniforms:{model:(e,r)=>r.model||t.transforms||mat4.create(),ucolor:(e,r)=>r&&r.color?r.color:s},attributes:{position:e.buffer({usage:"static",type:"float",data:t.positions})}};return a&&(c.blend={enable:!0,func:{src:"src alpha",dst:"one minus src alpha"}}),n&&(c.attributes.color=e.buffer({usage:"static",type:"float",data:t.colors})),l&&(c.elements=e.elements({usage:"static",type:"uint16",data:t.indices})),i&&(c.attributes.normal=e.buffer({usage:"static",type:"float",data:t.normals})),e(c)};module.exports=drawLines; -},{"../../renderDefaults":633,"./colorOnlyShaders":624,"./meshShaders":626,"./vColorShaders":627,"gl-mat4":548}],626:[function(require,module,exports){ +},{"../../renderDefaults":634,"./colorOnlyShaders":625,"./meshShaders":627,"./vColorShaders":628,"gl-mat4":549}],627:[function(require,module,exports){ const meshVert="\nprecision mediump float;\n\nuniform float camNear, camFar;\nuniform mat4 model, view, projection;\n\nattribute vec3 position, normal;\n\n\nvarying vec3 surfaceNormal, surfacePosition;\nvarying vec4 _worldSpacePosition;\n\n\nvoid main() {\n\n\n surfacePosition = position;\n surfaceNormal = normal;\n vec4 worldSpacePosition = model * vec4(position, 1);\n _worldSpacePosition = worldSpacePosition;\n\n vec4 glPosition = projection * view * model * vec4(position, 1);\n gl_Position = glPosition;\n}\n",meshFrag="\nprecision mediump float;\nvarying vec3 surfaceNormal;\nuniform float ambientLightAmount;\nuniform float diffuseLightAmount;\nuniform vec4 ucolor;\nuniform vec3 lightDirection;\nuniform vec3 opacity;\n\nvarying vec4 _worldSpacePosition;\n\nuniform vec2 printableArea;\n\nvec4 errorColor = vec4(0.15, 0.15, 0.15, 0.3);\n\nvoid main () {\n vec4 depth = gl_FragCoord;\n\n float v = 0.8; // shadow value\n vec4 endColor = ucolor;\n\n vec3 ambient = ambientLightAmount * endColor.rgb;\n float cosTheta = dot(surfaceNormal, lightDirection);\n vec3 diffuse = diffuseLightAmount * endColor.rgb * clamp(cosTheta , 0.0, 1.0 );\n\n float cosTheta2 = dot(surfaceNormal, vec3(-lightDirection.x, -lightDirection.y, lightDirection.z));\n vec3 diffuse2 = diffuseLightAmount * endColor.rgb * clamp(cosTheta2 , 0.0, 1.0 );\n\n gl_FragColor = vec4((ambient + diffuse + diffuse2 * v), endColor.a);\n}";module.exports={vert:meshVert,frag:meshFrag}; -},{}],627:[function(require,module,exports){ +},{}],628:[function(require,module,exports){ const vColorVert="\nprecision mediump float;\n\nuniform float camNear, camFar;\nuniform mat4 model, view, projection;\n\nattribute vec3 position, normal;\nattribute vec4 color;\n\nvarying vec3 surfaceNormal, surfacePosition;\nvarying vec4 _worldSpacePosition;\nvarying vec4 vColor;\n\nvoid main() {\n vColor = color;\n\n surfacePosition = position;\n surfaceNormal = normal;\n vec4 worldSpacePosition = model * vec4(position, 1);\n _worldSpacePosition = worldSpacePosition;\n\n vec4 glPosition = projection * view * model * vec4(position, 1);\n gl_Position = glPosition;\n}\n",vColorFrag="\nprecision mediump float;\nvarying vec4 vColor;\n\nvoid main () {\n gl_FragColor = vColor;\n}\n";module.exports={frag:vColorFrag,vert:vColorVert}; -},{}],628:[function(require,module,exports){ +},{}],629:[function(require,module,exports){ const mat4=require("gl-mat4"),{meshColor:meshColor}=require("../../renderDefaults"),drawMesh=(e,r={extras:{}})=>{const t={useVertexColors:!0,dynamicCulling:!0,geometry:void 0,color:meshColor,visuals:{}},{geometry:s,dynamicCulling:a,useVertexColors:o,color:l,visuals:n}=Object.assign({},t,r),i=e.buffer([]),u=!!(s.indices&&s.indices.length>0),c=!!(s.normals&&s.normals.length>0),m="transparent"in n&&n.transparent,g=!!(o&&s.colors&&s.colors.length>0),d=s.transforms||mat4.create(),f=mat4.determinant(d)<0,h=a&&f?"front":"back",p=g?require("./vColorShaders").vert:require("./meshShaders").vert,b=g?require("./vColorShaders").frag:require("./meshShaders").frag,v=mat4.invert(mat4.create(),d);let C={primitive:"triangles",vert:p,frag:b,uniforms:{model:(e,r)=>d,ucolor:(e,r)=>r&&r.color?r.color:l,vColorToggler:(e,r)=>r&&r.useVertexColors&&!0===r.useVertexColors?1:0,unormal:(e,r)=>{const t=mat4.invert(mat4.create(),r.camera.view);return mat4.multiply(t,v,t),mat4.transpose(t,t),t}},attributes:{position:e.buffer({usage:"static",type:"float",data:s.positions}),ao:i},cull:{enable:!0,face:h}};return m&&(C.blend={enable:!0,func:{src:"src alpha",dst:"one minus src alpha"}}),s.cells?C.elements=s.cells:u?C.elements=e.elements({usage:"static",type:"uint16",data:s.indices}):s.triangles?C.elements=s.triangles:C.count=s.positions.length/3,c&&(C.attributes.normal=e.buffer({usage:"static",type:"float",data:s.normals})),g&&(C.attributes.color=e.buffer({usage:"static",type:"float",data:s.colors})),e(C=Object.assign({},C,r.extras))};module.exports=drawMesh; -},{"../../renderDefaults":633,"./meshShaders":629,"./vColorShaders":630,"gl-mat4":548}],629:[function(require,module,exports){ +},{"../../renderDefaults":634,"./meshShaders":630,"./vColorShaders":631,"gl-mat4":549}],630:[function(require,module,exports){ const meshFrag="\nprecision mediump float;\nvarying vec3 surfaceNormal;\nuniform float ambientLightAmount;\nuniform float diffuseLightAmount;\nuniform vec4 ucolor;\nuniform vec3 lightDirection;\nuniform vec3 opacity;\n\nvarying vec4 _worldSpacePosition;\n\nuniform vec2 printableArea;\n\nvec4 errorColor = vec4(0.15, 0.15, 0.15, 0.3);\n\nvoid main () {\n vec4 depth = gl_FragCoord;\n\n float v = 0.8; // shadow value\n vec4 endColor = ucolor;\n\n vec3 ambient = ambientLightAmount * endColor.rgb;\n float cosTheta = dot(surfaceNormal, lightDirection);\n vec3 diffuse = diffuseLightAmount * endColor.rgb * clamp(cosTheta , 0.0, 1.0 );\n\n float cosTheta2 = dot(surfaceNormal, vec3(-lightDirection.x, -lightDirection.y, lightDirection.z));\n vec3 diffuse2 = diffuseLightAmount * endColor.rgb * clamp(cosTheta2 , 0.0, 1.0 );\n\n gl_FragColor = vec4((ambient + diffuse + diffuse2 * v), endColor.a);\n}",meshVert="\nprecision mediump float;\n\nuniform float camNear, camFar;\nuniform mat4 model, view, projection;\n\nattribute vec3 position, normal;\n\nvarying vec3 surfaceNormal, surfacePosition;\nvarying vec4 _worldSpacePosition;\n\nvoid main() {\n surfacePosition = position;\n surfaceNormal = normal;\n vec4 worldSpacePosition = model * vec4(position, 1);\n _worldSpacePosition = worldSpacePosition;\n\n vec4 glPosition = projection * view * model * vec4(position, 1);\n gl_Position = glPosition;\n}\n";module.exports={vert:meshVert,frag:meshFrag}; -},{}],630:[function(require,module,exports){ +},{}],631:[function(require,module,exports){ const vColorVert="\nprecision mediump float;\n\nuniform float camNear, camFar;\nuniform mat4 model, view, projection, unormal;\n\nattribute vec3 position, normal;\nattribute vec4 color;\n\nattribute float ao;\nvarying float ambientAo;\n\nvarying vec3 surfaceNormal, surfacePosition;\nvarying vec4 _worldSpacePosition;\nvarying vec4 vColor;\n\nvoid main() {\n surfacePosition = (unormal * vec4(position, 1.0)).xyz;\n surfaceNormal = normalize((unormal * vec4(normal, 1.0)).xyz); //vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);\n vec4 worldSpacePosition = model * vec4(position, 1);\n _worldSpacePosition = worldSpacePosition;\n //gl_Position = projection * view * worldSpacePosition;\n\n vColor = color;\n\n //ambientAo = (1. - ao) * (0.5 * max(normal.x, 0.) + 0.5);\n\n vec4 glPosition = projection * view * model * vec4(position, 1);\n gl_Position = glPosition;\n //gl_Position = zBufferAdjust(glPosition, camNear, camFar);\n}\n",vColorFrag="\nprecision mediump float;\nvarying vec3 surfaceNormal, surfacePosition;\n\nuniform float ambientLightAmount;\nuniform float diffuseLightAmount;\nuniform float specularLightAmount;\n\nuniform vec3 lightDirection;\nuniform vec4 lightColor;\nuniform vec3 opacity;\nuniform float uMaterialShininess;\n\nvarying vec4 vColor;\nuniform vec4 ucolor;\nuniform float vColorToggler;\n\nuniform vec2 printableArea;\nvec4 errorColor = vec4(0.15, 0.15, 0.15, 0.3);//vec4(0.15, 0.15, 0.15, 0.3);\nvarying vec4 _worldSpacePosition;\nvarying float ambientAo;\n\nvoid main () {\n vec4 depth = gl_FragCoord;\n vec4 endColor = vColor * vColorToggler + ucolor * (1.0 - vColorToggler);\n\n vec3 ambient = ambientLightAmount * endColor.rgb ; //ambientAo * \n\n float diffuseWeight = dot(surfaceNormal, lightDirection);\n vec3 diffuse = diffuseLightAmount * endColor.rgb * clamp(diffuseWeight , 0.0, 1.0 );\n\n //specular\n \n vec4 specularColor = vec4(lightColor);\n vec3 eyeDirection = normalize(surfacePosition.xyz);\n vec3 reflectionDirection = reflect(-lightDirection, -surfaceNormal);\n float specularLightWeight = pow(max(dot(reflectionDirection, eyeDirection), 0.0), uMaterialShininess);\n vec3 specular = specularColor.rgb * specularLightWeight * specularLightAmount;\n\n gl_FragColor = vec4((ambient + diffuse + specular), endColor.a);\n}\n";module.exports={frag:vColorFrag,vert:vColorVert}; -},{}],631:[function(require,module,exports){ +},{}],632:[function(require,module,exports){ const renderContext=require("./renderContext"),renderDefaults=require("./renderDefaults"),prepareRender=e=>{const r=Object.assign({},{},e.glOptions,{onDone:(e,r)=>{if(e)throw e}}),n=require("regl")(r),a=new Map;return function(e){var r;n.poll(),(r=e).rendering=Object.assign({},renderDefaults,r.rendering),renderContext(n)(r,e=>{n.clear({color:r.rendering.background,depth:1}),r.entities&&r.entities.sort((e,r)=>{const n="transparent"in e.visuals&&e.visuals.transparent;return n===("transparent"in r.visuals&&r.visuals.transparent)?0:n?1:-1}).forEach(e=>{const{visuals:t}=e;if((!("show"in t)||t.show)&&t.drawCmd&&r.drawCommands[t.drawCmd]){let s;t.cacheId?s=a.get(t.cacheId):(t.cacheId=a.size,s=r.drawCommands[t.drawCmd](n,e),a.set(t.cacheId,s)),s({...e,...t,camera:r.camera})}})})}};module.exports=prepareRender; -},{"./renderContext":632,"./renderDefaults":633,"regl":609}],632:[function(require,module,exports){ +},{"./renderContext":633,"./renderDefaults":634,"regl":610}],633:[function(require,module,exports){ const mat4=require("gl-mat4"),renderWrapper=(e,i={})=>{const{fbo:r}=i,n={cull:{enable:!0},context:{lightDirection:[.2,.2,1]},uniforms:{view:(e,i)=>i.camera.view,eye:(e,i)=>i.camera.position,projection:(e,i)=>i.camera.projection,camNear:(e,i)=>i.camera.near,camFar:(e,i)=>i.camera.far,invertedView:(e,i)=>mat4.invert([],i.camera.view),lightPosition:(e,i)=>i&&i.rendering&&i.rendering.lightPosition?i.rendering.lightPosition:[100,200,100],lightDirection:(e,i)=>i&&i.rendering&&i.rendering.lightDirection?i.rendering.lightDirection:e.lightDirection||[0,0,0],lightView:e=>mat4.lookAt([],e.lightDirection,[0,0,0],[0,0,1]),lightProjection:mat4.ortho([],-25,-25,-20,20,-25,25),lightColor:(e,i)=>i&&i.rendering&&i.rendering.lightColor?i.rendering.lightColor:[1,.8,0],ambientLightAmount:(e,i)=>i&&i.rendering&&i.rendering.ambientLightAmount?i.rendering.ambientLightAmount:.3,diffuseLightAmount:(e,i)=>i&&i.rendering&&i.rendering.diffuseLightAmount?i&&i.rendering&&i.rendering.diffuseLightAmount:.89,specularLightAmount:(e,i)=>i&&i.rendering&&i.rendering.specularLightAmount?i.rendering.specularLightAmount:.16,uMaterialShininess:(e,i)=>i&&i.rendering&&i.rendering.materialShininess?i.rendering.materialShininess:8,materialAmbient:[.5,.8,.3],materialDiffuse:[.5,.8,.3],materialSpecular:[.5,.8,.3]},framebuffer:r};return e(Object.assign({},n,i.extras))};module.exports=renderWrapper; -},{"gl-mat4":548}],633:[function(require,module,exports){ +},{"gl-mat4":549}],634:[function(require,module,exports){ module.exports={background:[1,1,1,1],meshColor:[0,.6,1,1],lightColor:[1,1,1,1],lightDirection:[.2,.2,1],lightPosition:[100,200,100],ambientLightAmount:.3,diffuseLightAmount:.89,specularLightAmount:.16,materialShininess:8}; -},{}],634:[function(require,module,exports){ +},{}],635:[function(require,module,exports){ module.exports=[ {"key": "f", "command": "toPresetView", "args": "front" }, {"key": "b", "command": "toPresetView", "args": "back" }, @@ -2291,29 +2294,29 @@ module.exports=[ {"key": "shift+enter", "command": "editorCommand", "args": "reevaluate"} ] -},{}],635:[function(require,module,exports){ +},{}],636:[function(require,module,exports){ module.exports={ "livereloadUrl": "ws://127.0.0.1:35729/livereload" } -},{}],636:[function(require,module,exports){ -module.exports={"name":"Arctic Sunrise","viewer":{"rendering":{"background":[1,0.8,0.7333333333333333,1],"meshColor":[0.43137254901960786,0.7098039215686275,0.7529411764705882,1]},"grid":{"color":[0,0.4235294117647059,0.5176470588235295,1],"subColor":[0.8862745098039215,0.9098039215686274,0.8941176470588236,1]}},"mainTextColor":[0,0.4235294117647059,0.5176470588235295,1],"secondaryTextColor":"#000000"} },{}],637:[function(require,module,exports){ -module.exports={"name":"Back to School","viewer":{"rendering":{"background":[0.5058823529411764,0.44313725490196076,0.3686274509803922,1],"meshColor":[0.9803921568627451,0.6823529411764706,0.23921568627450981,1]},"grid":{"color":[0.9215686274509803,0.5411764705882353,0.26666666666666666,1],"subColor":[0.9176470588235294,0.3254901960784314,0.3686274509803922,1]}},"mainTextColor":[0.9215686274509803,0.5411764705882353,0.26666666666666666,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Arctic Sunrise","viewer":{"rendering":{"background":[1,0.8,0.7333333333333333,1],"meshColor":[0.43137254901960786,0.7098039215686275,0.7529411764705882,1]},"grid":{"color":[0,0.4235294117647059,0.5176470588235295,1],"subColor":[0.8862745098039215,0.9098039215686274,0.8941176470588236,1]}},"mainTextColor":[0,0.4235294117647059,0.5176470588235295,1],"secondaryTextColor":"#000000"} },{}],638:[function(require,module,exports){ -module.exports={"name":"Beyond Black & White","viewer":{"rendering":{"background":[0.3568627450980392,0.7843137254901961,0.6745098039215687,1],"meshColor":[0.6862745098039216,0.10980392156862745,0.10980392156862745,1]},"grid":{"color":[0.9411764705882353,0.9372549019607843,0.996078431372549,1],"subColor":[0.00784313725490196,0.0196078431372549,0.03529411764705882,1]}},"mainTextColor":[0.9411764705882353,0.9372549019607843,0.996078431372549,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Back to School","viewer":{"rendering":{"background":[0.5058823529411764,0.44313725490196076,0.3686274509803922,1],"meshColor":[0.9803921568627451,0.6823529411764706,0.23921568627450981,1]},"grid":{"color":[0.9215686274509803,0.5411764705882353,0.26666666666666666,1],"subColor":[0.9176470588235294,0.3254901960784314,0.3686274509803922,1]}},"mainTextColor":[0.9215686274509803,0.5411764705882353,0.26666666666666666,1],"secondaryTextColor":"#000000"} },{}],639:[function(require,module,exports){ -module.exports={"name":"Bold Berries","viewer":{"rendering":{"background":[0.3137254901960784,0.19215686274509805,0.1843137254901961,1],"meshColor":[0.796078431372549,0,0,1]},"grid":{"color":[0.8941176470588236,0.9176470588235294,0.5490196078431373,1],"subColor":[0.24705882352941178,0.4235294117647059,0.27058823529411763,1]}},"mainTextColor":[0.8941176470588236,0.9176470588235294,0.5490196078431373,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Beyond Black & White","viewer":{"rendering":{"background":[0.3568627450980392,0.7843137254901961,0.6745098039215687,1],"meshColor":[0.6862745098039216,0.10980392156862745,0.10980392156862745,1]},"grid":{"color":[0.9411764705882353,0.9372549019607843,0.996078431372549,1],"subColor":[0.00784313725490196,0.0196078431372549,0.03529411764705882,1]}},"mainTextColor":[0.9411764705882353,0.9372549019607843,0.996078431372549,1],"secondaryTextColor":"#000000"} },{}],640:[function(require,module,exports){ -module.exports={"name":"Candy-coated Brights","viewer":{"rendering":{"background":[0.9215686274509803,0.5411764705882353,0.26666666666666666,1],"meshColor":[0.8823529411764706,0.19215686274509805,0.34509803921568627,1]},"grid":{"color":[1,0.9254901960784314,0.3607843137254902,1],"subColor":[0,0.5529411764705883,0.796078431372549,1]}},"mainTextColor":[1,0.9254901960784314,0.3607843137254902,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Bold Berries","viewer":{"rendering":{"background":[0.3137254901960784,0.19215686274509805,0.1843137254901961,1],"meshColor":[0.796078431372549,0,0,1]},"grid":{"color":[0.8941176470588236,0.9176470588235294,0.5490196078431373,1],"subColor":[0.24705882352941178,0.4235294117647059,0.27058823529411763,1]}},"mainTextColor":[0.8941176470588236,0.9176470588235294,0.5490196078431373,1],"secondaryTextColor":"#000000"} },{}],641:[function(require,module,exports){ -module.exports={"name":"Cheerful & Friendly","viewer":{"rendering":{"background":[0.16862745098039217,0.3803921568627451,0.42745098039215684,1],"meshColor":[0.6980392156862745,0.8588235294117647,0.8352941176470589,1]},"grid":{"color":[1,1,1,1],"subColor":[0.9803921568627451,0.5529411764705883,0.3843137254901961,1]}},"mainTextColor":[1,1,1,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Candy-coated Brights","viewer":{"rendering":{"background":[0.9215686274509803,0.5411764705882353,0.26666666666666666,1],"meshColor":[0.8823529411764706,0.19215686274509805,0.34509803921568627,1]},"grid":{"color":[1,0.9254901960784314,0.3607843137254902,1],"subColor":[0,0.5529411764705883,0.796078431372549,1]}},"mainTextColor":[1,0.9254901960784314,0.3607843137254902,1],"secondaryTextColor":"#000000"} },{}],642:[function(require,module,exports){ -module.exports={"name":"Classic Metallics","viewer":{"rendering":{"background":[0.03137254901960784,0.027450980392156862,0.023529411764705882,1],"meshColor":[0.9568627450980393,0.9568627450980393,0.9372549019607843,1]},"grid":{"color":[0.8196078431372549,0.6980392156862745,0.5019607843137255,1],"subColor":[0.34901960784313724,0.30196078431372547,0.27450980392156865,1]}},"mainTextColor":[0.8196078431372549,0.6980392156862745,0.5019607843137255,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Cheerful & Friendly","viewer":{"rendering":{"background":[0.16862745098039217,0.3803921568627451,0.42745098039215684,1],"meshColor":[0.6980392156862745,0.8588235294117647,0.8352941176470589,1]},"grid":{"color":[1,1,1,1],"subColor":[0.9803921568627451,0.5529411764705883,0.3843137254901961,1]}},"mainTextColor":[1,1,1,1],"secondaryTextColor":"#000000"} },{}],643:[function(require,module,exports){ -module.exports={"name":"Cozy & Warm","viewer":{"rendering":{"background":[0.4,0.13333333333333333,0.1450980392156863,1],"meshColor":[0.7098039215686275,0.11372549019607843,0.0392156862745098,1]},"grid":{"color":[0.9176470588235294,0.8274509803921568,0.611764705882353,1],"subColor":[0.49019607843137253,0.3686274509803922,0.23529411764705882,1]}},"mainTextColor":[0.9176470588235294,0.8274509803921568,0.611764705882353,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Classic Metallics","viewer":{"rendering":{"background":[0.03137254901960784,0.027450980392156862,0.023529411764705882,1],"meshColor":[0.9568627450980393,0.9568627450980393,0.9372549019607843,1]},"grid":{"color":[0.8196078431372549,0.6980392156862745,0.5019607843137255,1],"subColor":[0.34901960784313724,0.30196078431372547,0.27450980392156865,1]}},"mainTextColor":[0.8196078431372549,0.6980392156862745,0.5019607843137255,1],"secondaryTextColor":"#000000"} },{}],644:[function(require,module,exports){ -module.exports={"name":"Crisp & Dramatic","viewer":{"rendering":{"background":[0.3137254901960784,0.3176470588235294,0.3764705882352941,1],"meshColor":[0.40784313725490196,0.5098039215686274,0.6196078431372549,1]},"grid":{"color":[0.6823529411764706,0.7411764705882353,0.2196078431372549,1],"subColor":[0.34901960784313724,0.5098039215686274,0.20392156862745098,1]}},"mainTextColor":[0.6823529411764706,0.7411764705882353,0.2196078431372549,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Cozy & Warm","viewer":{"rendering":{"background":[0.4,0.13333333333333333,0.1450980392156863,1],"meshColor":[0.7098039215686275,0.11372549019607843,0.0392156862745098,1]},"grid":{"color":[0.9176470588235294,0.8274509803921568,0.611764705882353,1],"subColor":[0.49019607843137253,0.3686274509803922,0.23529411764705882,1]}},"mainTextColor":[0.9176470588235294,0.8274509803921568,0.611764705882353,1],"secondaryTextColor":"#000000"} },{}],645:[function(require,module,exports){ +module.exports={"name":"Crisp & Dramatic","viewer":{"rendering":{"background":[0.3137254901960784,0.3176470588235294,0.3764705882352941,1],"meshColor":[0.40784313725490196,0.5098039215686274,0.6196078431372549,1]},"grid":{"color":[0.6823529411764706,0.7411764705882353,0.2196078431372549,1],"subColor":[0.34901960784313724,0.5098039215686274,0.20392156862745098,1]}},"mainTextColor":[0.6823529411764706,0.7411764705882353,0.2196078431372549,1],"secondaryTextColor":"#000000"} +},{}],646:[function(require,module,exports){ module.exports={ "name": "Dark", "viewer": { @@ -2330,13 +2333,13 @@ module.exports={ "secondaryTextColor": "#000" } -},{}],646:[function(require,module,exports){ -module.exports={"name":"Distinctive & Unexpected","viewer":{"rendering":{"background":[0.3568627450980392,0.7843137254901961,0.6745098039215687,1],"meshColor":[0.6941176470588235,0.8431372549019608,0.8235294117647058,1]},"grid":{"color":[0.2627450980392157,0.1803921568627451,0.2,1],"subColor":[0.9058823529411765,0.2784313725490196,0.1803921568627451,1]}},"mainTextColor":[0.2627450980392157,0.1803921568627451,0.2,1],"secondaryTextColor":"#000000"} },{}],647:[function(require,module,exports){ -module.exports={"name":"Exotic & High-impact","viewer":{"rendering":{"background":[0.058823529411764705,0.12156862745098039,0.2196078431372549,1],"meshColor":[0.45098039215686275,0.3764705882352941,0.3568627450980392,1]},"grid":{"color":[0.9607843137254902,0.32941176470588235,0.28627450980392155,1],"subColor":[0.10588235294117647,0.29411764705882354,0.35294117647058826,1]}},"mainTextColor":[0.9607843137254902,0.32941176470588235,0.28627450980392155,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Distinctive & Unexpected","viewer":{"rendering":{"background":[0.3568627450980392,0.7843137254901961,0.6745098039215687,1],"meshColor":[0.6941176470588235,0.8431372549019608,0.8235294117647058,1]},"grid":{"color":[0.2627450980392157,0.1803921568627451,0.2,1],"subColor":[0.9058823529411765,0.2784313725490196,0.1803921568627451,1]}},"mainTextColor":[0.2627450980392157,0.1803921568627451,0.2,1],"secondaryTextColor":"#000000"} },{}],648:[function(require,module,exports){ -module.exports={"name":"Golden Afternoon","viewer":{"rendering":{"background":[0.5333333333333333,0.1411764705882353,0.14901960784313725,1],"meshColor":[0.803921568627451,0.7450980392156863,0.6549019607843137,1]},"grid":{"color":[0.19607843137254902,0.18823529411764706,0.18823529411764706,1],"subColor":[0.7607843137254902,0.5843137254901961,0.27058823529411763,1]}},"mainTextColor":[0.19607843137254902,0.18823529411764706,0.18823529411764706,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Exotic & High-impact","viewer":{"rendering":{"background":[0.058823529411764705,0.12156862745098039,0.2196078431372549,1],"meshColor":[0.45098039215686275,0.3764705882352941,0.3568627450980392,1]},"grid":{"color":[0.9607843137254902,0.32941176470588235,0.28627450980392155,1],"subColor":[0.10588235294117647,0.29411764705882354,0.35294117647058826,1]}},"mainTextColor":[0.9607843137254902,0.32941176470588235,0.28627450980392155,1],"secondaryTextColor":"#000000"} },{}],649:[function(require,module,exports){ +module.exports={"name":"Golden Afternoon","viewer":{"rendering":{"background":[0.5333333333333333,0.1411764705882353,0.14901960784313725,1],"meshColor":[0.803921568627451,0.7450980392156863,0.6549019607843137,1]},"grid":{"color":[0.19607843137254902,0.18823529411764706,0.18823529411764706,1],"subColor":[0.7607843137254902,0.5843137254901961,0.27058823529411763,1]}},"mainTextColor":[0.19607843137254902,0.18823529411764706,0.18823529411764706,1],"secondaryTextColor":"#000000"} +},{}],650:[function(require,module,exports){ module.exports={ "name": "Grass", "viewer": { @@ -2353,13 +2356,13 @@ module.exports={ "secondaryTextColor": "#000" } -},{}],650:[function(require,module,exports){ -module.exports={"name":"Grecian Holiday","viewer":{"rendering":{"background":[0.1607843137254902,0.5333333333333333,0.7372549019607844,1],"meshColor":[0.12549019607843137,0.5803921568627451,0.5450980392156862,1]},"grid":{"color":[0.9568627450980393,0.9176470588235294,0.8705882352941177,1],"subColor":[0.9294117647058824,0.5490196078431373,0.4470588235294118,1]}},"mainTextColor":[0.9568627450980393,0.9176470588235294,0.8705882352941177,1],"secondaryTextColor":"#000000"} },{}],651:[function(require,module,exports){ -module.exports={"name":"Green Fields","viewer":{"rendering":{"background":[0.5686274509803921,0.5882352941176471,0.21176470588235294,1],"meshColor":[0.3215686274509804,0.2901960784313726,0.22745098039215686,1]},"grid":{"color":[1,0.9803921568627451,0.8823529411764706,1],"subColor":[0.35294117647058826,0.37254901960784315,0.21568627450980393,1]}},"mainTextColor":[1,0.9803921568627451,0.8823529411764706,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Grecian Holiday","viewer":{"rendering":{"background":[0.1607843137254902,0.5333333333333333,0.7372549019607844,1],"meshColor":[0.12549019607843137,0.5803921568627451,0.5450980392156862,1]},"grid":{"color":[0.9568627450980393,0.9176470588235294,0.8705882352941177,1],"subColor":[0.9294117647058824,0.5490196078431373,0.4470588235294118,1]}},"mainTextColor":[0.9568627450980393,0.9176470588235294,0.8705882352941177,1],"secondaryTextColor":"#000000"} },{}],652:[function(require,module,exports){ -module.exports={"name":"Icy Blues and Grays","viewer":{"rendering":{"background":[0.9450980392156862,0.9450980392156862,0.9490196078431372,1],"meshColor":[0.7372549019607844,0.7294117647058823,0.7450980392156863,1]},"grid":{"color":[0.6313725490196078,0.8392156862745098,0.8862745098039215,1],"subColor":[0.09803921568627451,0.5843137254901961,0.6784313725490196,1]}},"mainTextColor":[0.6313725490196078,0.8392156862745098,0.8862745098039215,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Green Fields","viewer":{"rendering":{"background":[0.5686274509803921,0.5882352941176471,0.21176470588235294,1],"meshColor":[0.3215686274509804,0.2901960784313726,0.22745098039215686,1]},"grid":{"color":[1,0.9803921568627451,0.8823529411764706,1],"subColor":[0.35294117647058826,0.37254901960784315,0.21568627450980393,1]}},"mainTextColor":[1,0.9803921568627451,0.8823529411764706,1],"secondaryTextColor":"#000000"} },{}],653:[function(require,module,exports){ +module.exports={"name":"Icy Blues and Grays","viewer":{"rendering":{"background":[0.9450980392156862,0.9450980392156862,0.9490196078431372,1],"meshColor":[0.7372549019607844,0.7294117647058823,0.7450980392156863,1]},"grid":{"color":[0.6313725490196078,0.8392156862745098,0.8862745098039215,1],"subColor":[0.09803921568627451,0.5843137254901961,0.6784313725490196,1]}},"mainTextColor":[0.6313725490196078,0.8392156862745098,0.8862745098039215,1],"secondaryTextColor":"#000000"} +},{}],654:[function(require,module,exports){ module.exports={ "name": "Light", "viewer": { @@ -2376,17 +2379,17 @@ module.exports={ "secondaryTextColor": "#000" } -},{}],654:[function(require,module,exports){ -module.exports={"name":"Light & Natural","viewer":{"rendering":{"background":[0.2,0.4196078431372549,0.5294117647058824,1],"meshColor":[0.6313725490196078,0.7450980392156863,0.5843137254901961,1]},"grid":{"color":[0.9803921568627451,0.9372549019607843,0.8313725490196079,1],"subColor":[0.6470588235294118,0.48627450980392156,0.396078431372549,1]}},"mainTextColor":[0.9803921568627451,0.9372549019607843,0.8313725490196079,1],"secondaryTextColor":"#000000"} },{}],655:[function(require,module,exports){ -module.exports={"name":"Modern & Urban","viewer":{"rendering":{"background":[0.9764705882352941,0.7294117647058823,0.19607843137254902,1],"meshColor":[0.25882352941176473,0.43137254901960786,0.5254901960784314,1]},"grid":{"color":[0.9725490196078431,0.9450980392156862,0.8980392156862745,1],"subColor":[0.1843137254901961,0.19215686274509805,0.19215686274509805,1]}},"mainTextColor":[0.9725490196078431,0.9450980392156862,0.8980392156862745,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Light & Natural","viewer":{"rendering":{"background":[0.2,0.4196078431372549,0.5294117647058824,1],"meshColor":[0.6313725490196078,0.7450980392156863,0.5843137254901961,1]},"grid":{"color":[0.9803921568627451,0.9372549019607843,0.8313725490196079,1],"subColor":[0.6470588235294118,0.48627450980392156,0.396078431372549,1]}},"mainTextColor":[0.9803921568627451,0.9372549019607843,0.8313725490196079,1],"secondaryTextColor":"#000000"} },{}],656:[function(require,module,exports){ -module.exports={"name":"Naturally Elegant","viewer":{"rendering":{"background":[0.9215686274509803,0.8745098039215686,0,1],"meshColor":[0.49411764705882355,0.4823529411764706,0.08235294117647059,1]},"grid":{"color":[0.33725490196078434,0.24313725490196078,0.12549019607843137,1],"subColor":[0.788235294117647,0.6196078431372549,0.06274509803921569,1]}},"mainTextColor":[0.33725490196078434,0.24313725490196078,0.12549019607843137,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Modern & Urban","viewer":{"rendering":{"background":[0.9764705882352941,0.7294117647058823,0.19607843137254902,1],"meshColor":[0.25882352941176473,0.43137254901960786,0.5254901960784314,1]},"grid":{"color":[0.9725490196078431,0.9450980392156862,0.8980392156862745,1],"subColor":[0.1843137254901961,0.19215686274509805,0.19215686274509805,1]}},"mainTextColor":[0.9725490196078431,0.9450980392156862,0.8980392156862745,1],"secondaryTextColor":"#000000"} },{}],657:[function(require,module,exports){ -module.exports={"name":"Neon Night","viewer":{"rendering":{"background":[0.9686274509803922,0.4627450980392157,0.01568627450980392,1],"meshColor":[0.1450980392156863,0.5019607843137255,0.2235294117647059,1]},"grid":{"color":[0.9607843137254902,0.4235294117647059,0.3411764705882353,1],"subColor":[0.13725490196078433,0.10588235294117647,0.07058823529411765,1]}},"mainTextColor":[0.9607843137254902,0.4235294117647059,0.3411764705882353,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Naturally Elegant","viewer":{"rendering":{"background":[0.9215686274509803,0.8745098039215686,0,1],"meshColor":[0.49411764705882355,0.4823529411764706,0.08235294117647059,1]},"grid":{"color":[0.33725490196078434,0.24313725490196078,0.12549019607843137,1],"subColor":[0.788235294117647,0.6196078431372549,0.06274509803921569,1]}},"mainTextColor":[0.33725490196078434,0.24313725490196078,0.12549019607843137,1],"secondaryTextColor":"#000000"} },{}],658:[function(require,module,exports){ -module.exports={"name":"Nightlife","viewer":{"rendering":{"background":[0,0.8117647058823529,0.9803921568627451,1],"meshColor":[1,0,0.2196078431372549,1]},"grid":{"color":[0.9764705882352941,0.8627450980392157,0.1411764705882353,1],"subColor":[0.00784313725490196,0.0196078431372549,0.03529411764705882,1]}},"mainTextColor":[0.9764705882352941,0.8627450980392157,0.1411764705882353,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Neon Night","viewer":{"rendering":{"background":[0.9686274509803922,0.4627450980392157,0.01568627450980392,1],"meshColor":[0.1450980392156863,0.5019607843137255,0.2235294117647059,1]},"grid":{"color":[0.9607843137254902,0.4235294117647059,0.3411764705882353,1],"subColor":[0.13725490196078433,0.10588235294117647,0.07058823529411765,1]}},"mainTextColor":[0.9607843137254902,0.4235294117647059,0.3411764705882353,1],"secondaryTextColor":"#000000"} },{}],659:[function(require,module,exports){ +module.exports={"name":"Nightlife","viewer":{"rendering":{"background":[0,0.8117647058823529,0.9803921568627451,1],"meshColor":[1,0,0.2196078431372549,1]},"grid":{"color":[0.9764705882352941,0.8627450980392157,0.1411764705882353,1],"subColor":[0.00784313725490196,0.0196078431372549,0.03529411764705882,1]}},"mainTextColor":[0.9764705882352941,0.8627450980392157,0.1411764705882353,1],"secondaryTextColor":"#000000"} +},{}],660:[function(require,module,exports){ module.exports={ "name": "Ocean", "viewer": { @@ -2403,44 +2406,44 @@ module.exports={ "secondaryTextColor": "#000" } -},{}],660:[function(require,module,exports){ -module.exports={"name":"Outdoorsy & Natural","viewer":{"rendering":{"background":[0.1803921568627451,0.27450980392156865,0,1],"meshColor":[0.2823529411764706,0.4196078431372549,0,1]},"grid":{"color":[0.6352941176470588,0.7725490196078432,0.13725490196078433,1],"subColor":[0.49019607843137253,0.26666666666666666,0.15294117647058825,1]}},"mainTextColor":[0.6352941176470588,0.7725490196078432,0.13725490196078433,1],"secondaryTextColor":"#000000"} },{}],661:[function(require,module,exports){ -module.exports={"name":"Pool Party","viewer":{"rendering":{"background":[0.20392156862745098,0.30196078431372547,0.5647058823529412,1],"meshColor":[0.3607843137254902,0.7725490196078432,0.9372549019607843,1]},"grid":{"color":[0.9764705882352941,0.6509803921568628,0.011764705882352941,1],"subColor":[0.9058823529411765,0.3333333333333333,0.17254901960784313,1]}},"mainTextColor":[0.9764705882352941,0.6509803921568628,0.011764705882352941,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Outdoorsy & Natural","viewer":{"rendering":{"background":[0.1803921568627451,0.27450980392156865,0,1],"meshColor":[0.2823529411764706,0.4196078431372549,0,1]},"grid":{"color":[0.6352941176470588,0.7725490196078432,0.13725490196078433,1],"subColor":[0.49019607843137253,0.26666666666666666,0.15294117647058825,1]}},"mainTextColor":[0.6352941176470588,0.7725490196078432,0.13725490196078433,1],"secondaryTextColor":"#000000"} },{}],662:[function(require,module,exports){ -module.exports={"name":"Primary Colors","viewer":{"rendering":{"background":[0.21568627450980393,0.3686274509803922,0.592156862745098,1],"meshColor":[0.984313725490196,0.396078431372549,0.25882352941176473,1]},"grid":{"color":[1,0.7333333333333333,0,1],"subColor":[0.2823529411764706,0.4196078431372549,0,1]}},"mainTextColor":[1,0.7333333333333333,0,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Pool Party","viewer":{"rendering":{"background":[0.20392156862745098,0.30196078431372547,0.5647058823529412,1],"meshColor":[0.3607843137254902,0.7725490196078432,0.9372549019607843,1]},"grid":{"color":[0.9764705882352941,0.6509803921568628,0.011764705882352941,1],"subColor":[0.9058823529411765,0.3333333333333333,0.17254901960784313,1]}},"mainTextColor":[0.9764705882352941,0.6509803921568628,0.011764705882352941,1],"secondaryTextColor":"#000000"} },{}],663:[function(require,module,exports){ -module.exports={"name":"Serene & Spa-like","viewer":{"rendering":{"background":[0.6313725490196078,0.7450980392156863,0.5843137254901961,1],"meshColor":[0.8862745098039215,0.8745098039215686,0.6352941176470588,1]},"grid":{"color":[0.5725490196078431,0.6666666666666666,0.7803921568627451,1],"subColor":[0.9294117647058824,0.3411764705882353,0.3215686274509804,1]}},"mainTextColor":[0.5725490196078431,0.6666666666666666,0.7803921568627451,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Primary Colors","viewer":{"rendering":{"background":[0.21568627450980393,0.3686274509803922,0.592156862745098,1],"meshColor":[0.984313725490196,0.396078431372549,0.25882352941176473,1]},"grid":{"color":[1,0.7333333333333333,0,1],"subColor":[0.2823529411764706,0.4196078431372549,0,1]}},"mainTextColor":[1,0.7333333333333333,0,1],"secondaryTextColor":"#000000"} },{}],664:[function(require,module,exports){ -module.exports={"name":"Shades of Citrus","viewer":{"rendering":{"background":[0.9215686274509803,0.5411764705882353,0.26666666666666666,1],"meshColor":[0.9764705882352941,0.8627450980392157,0.1411764705882353,1]},"grid":{"color":[0.29411764705882354,0.4549019607843137,0.2784313725490196,1],"subColor":[0.6352941176470588,0.7725490196078432,0.13725490196078433,1]}},"mainTextColor":[0.29411764705882354,0.4549019607843137,0.2784313725490196,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Serene & Spa-like","viewer":{"rendering":{"background":[0.6313725490196078,0.7450980392156863,0.5843137254901961,1],"meshColor":[0.8862745098039215,0.8745098039215686,0.6352941176470588,1]},"grid":{"color":[0.5725490196078431,0.6666666666666666,0.7803921568627451,1],"subColor":[0.9294117647058824,0.3411764705882353,0.3215686274509804,1]}},"mainTextColor":[0.5725490196078431,0.6666666666666666,0.7803921568627451,1],"secondaryTextColor":"#000000"} },{}],665:[function(require,module,exports){ -module.exports={"name":"Sleek & Modern","viewer":{"rendering":{"background":[0.00784313725490196,0.10980392156862745,0.11764705882352941,1],"meshColor":[0.6941176470588235,0.8431372549019608,0.8235294117647058,1]},"grid":{"color":[1,1,1,1],"subColor":[0.22745098039215686,0.3176470588235294,0.6,1]}},"mainTextColor":[1,1,1,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Shades of Citrus","viewer":{"rendering":{"background":[0.9215686274509803,0.5411764705882353,0.26666666666666666,1],"meshColor":[0.9764705882352941,0.8627450980392157,0.1411764705882353,1]},"grid":{"color":[0.29411764705882354,0.4549019607843137,0.2784313725490196,1],"subColor":[0.6352941176470588,0.7725490196078432,0.13725490196078433,1]}},"mainTextColor":[0.29411764705882354,0.4549019607843137,0.2784313725490196,1],"secondaryTextColor":"#000000"} },{}],666:[function(require,module,exports){ -module.exports={"name":"Smoky Purples","viewer":{"rendering":{"background":[0.7372549019607844,0.7294117647058823,0.7450980392156863,1],"meshColor":[0.4470588235294118,0.4392156862745098,0.4666666666666667,1]},"grid":{"color":[0.9333333333333333,0.8470588235294118,0.788235294117647,1],"subColor":[0.9137254901960784,0.592156862745098,0.5294117647058824,1]}},"mainTextColor":[0.9333333333333333,0.8470588235294118,0.788235294117647,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Sleek & Modern","viewer":{"rendering":{"background":[0.00784313725490196,0.10980392156862745,0.11764705882352941,1],"meshColor":[0.6941176470588235,0.8431372549019608,0.8235294117647058,1]},"grid":{"color":[1,1,1,1],"subColor":[0.22745098039215686,0.3176470588235294,0.6,1]}},"mainTextColor":[1,1,1,1],"secondaryTextColor":"#000000"} },{}],667:[function(require,module,exports){ -module.exports={"name":"Subtle & Versatile","viewer":{"rendering":{"background":[0.17254901960784313,0.2901960784313726,0.3215686274509804,1],"meshColor":[0.7490196078431373,0.8627450980392157,0.8117647058823529,1]},"grid":{"color":[0.8784313725490196,0.34509803921568627,0.34509803921568627,1],"subColor":[0.8352941176470589,0.788235294117647,0.6941176470588235,1]}},"mainTextColor":[0.8784313725490196,0.34509803921568627,0.34509803921568627,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Smoky Purples","viewer":{"rendering":{"background":[0.7372549019607844,0.7294117647058823,0.7450980392156863,1],"meshColor":[0.4470588235294118,0.4392156862745098,0.4666666666666667,1]},"grid":{"color":[0.9333333333333333,0.8470588235294118,0.788235294117647,1],"subColor":[0.9137254901960784,0.592156862745098,0.5294117647058824,1]}},"mainTextColor":[0.9333333333333333,0.8470588235294118,0.788235294117647,1],"secondaryTextColor":"#000000"} },{}],668:[function(require,module,exports){ -module.exports={"name":"Summer Barbeque","viewer":{"rendering":{"background":[0.3607843137254902,0.5607843137254902,0.13333333333333333,1],"meshColor":[0.4588235294117647,0.16470588235294117,0.027450980392156862,1]},"grid":{"color":[0.984313725490196,0.796078431372549,0.4823529411764706,1],"subColor":[0.8117647058823529,0.21568627450980393,0.12941176470588237,1]}},"mainTextColor":[0.984313725490196,0.796078431372549,0.4823529411764706,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Subtle & Versatile","viewer":{"rendering":{"background":[0.17254901960784313,0.2901960784313726,0.3215686274509804,1],"meshColor":[0.7490196078431373,0.8627450980392157,0.8117647058823529,1]},"grid":{"color":[0.8784313725490196,0.34509803921568627,0.34509803921568627,1],"subColor":[0.8352941176470589,0.788235294117647,0.6941176470588235,1]}},"mainTextColor":[0.8784313725490196,0.34509803921568627,0.34509803921568627,1],"secondaryTextColor":"#000000"} },{}],669:[function(require,module,exports){ -module.exports={"name":"Summer Sunflower","viewer":{"rendering":{"background":[0.30196078431372547,0.5215686274509804,0.7411764705882353,1],"meshColor":[0.48627450980392156,0.6666666666666666,0.17647058823529413,1]},"grid":{"color":[1,0.7333333333333333,0,1],"subColor":[0.796078431372549,0.38823529411764707,0.09411764705882353,1]}},"mainTextColor":[1,0.7333333333333333,0,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Summer Barbeque","viewer":{"rendering":{"background":[0.3607843137254902,0.5607843137254902,0.13333333333333333,1],"meshColor":[0.4588235294117647,0.16470588235294117,0.027450980392156862,1]},"grid":{"color":[0.984313725490196,0.796078431372549,0.4823529411764706,1],"subColor":[0.8117647058823529,0.21568627450980393,0.12941176470588237,1]}},"mainTextColor":[0.984313725490196,0.796078431372549,0.4823529411764706,1],"secondaryTextColor":"#000000"} },{}],670:[function(require,module,exports){ -module.exports={"name":"Surf & Turf","viewer":{"rendering":{"background":[0.9568627450980393,0.8,0.4392156862745098,1],"meshColor":[0.8705882352941177,0.47843137254901963,0.13333333333333333,1]},"grid":{"color":[0.12549019607843137,0.5803921568627451,0.5450980392156862,1],"subColor":[0.41568627450980394,0.6941176470588235,0.5294117647058824,1]}},"mainTextColor":[0.12549019607843137,0.5803921568627451,0.5450980392156862,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Summer Sunflower","viewer":{"rendering":{"background":[0.30196078431372547,0.5215686274509804,0.7411764705882353,1],"meshColor":[0.48627450980392156,0.6666666666666666,0.17647058823529413,1]},"grid":{"color":[1,0.7333333333333333,0,1],"subColor":[0.796078431372549,0.38823529411764707,0.09411764705882353,1]}},"mainTextColor":[1,0.7333333333333333,0,1],"secondaryTextColor":"#000000"} },{}],671:[function(require,module,exports){ -module.exports={"name":"Technology Meets Nature","viewer":{"rendering":{"background":[0.984313725490196,0.803921568627451,0.29411764705882354,1],"meshColor":[0.6392156862745098,0.6470588235294118,0.6,1]},"grid":{"color":[0.11764705882352941,0,0,1],"subColor":[0.3607843137254902,0.5607843137254902,0.13333333333333333,1]}},"mainTextColor":[0.11764705882352941,0,0,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Surf & Turf","viewer":{"rendering":{"background":[0.9568627450980393,0.8,0.4392156862745098,1],"meshColor":[0.8705882352941177,0.47843137254901963,0.13333333333333333,1]},"grid":{"color":[0.12549019607843137,0.5803921568627451,0.5450980392156862,1],"subColor":[0.41568627450980394,0.6941176470588235,0.5294117647058824,1]}},"mainTextColor":[0.12549019607843137,0.5803921568627451,0.5450980392156862,1],"secondaryTextColor":"#000000"} },{}],672:[function(require,module,exports){ -module.exports={"name":"Understated & Versatile","viewer":{"rendering":{"background":[0.2,0.3215686274509804,0.3215686274509804,1],"meshColor":[0.788235294117647,0.8196078431372549,0.7843137254901961,1]},"grid":{"color":[0.6078431372549019,0.30980392156862746,0.058823529411764705,1],"subColor":[0.17647058823529413,0.18823529411764706,0.2,1]}},"mainTextColor":[0.6078431372549019,0.30980392156862746,0.058823529411764705,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Technology Meets Nature","viewer":{"rendering":{"background":[0.984313725490196,0.803921568627451,0.29411764705882354,1],"meshColor":[0.6392156862745098,0.6470588235294118,0.6,1]},"grid":{"color":[0.11764705882352941,0,0,1],"subColor":[0.3607843137254902,0.5607843137254902,0.13333333333333333,1]}},"mainTextColor":[0.11764705882352941,0,0,1],"secondaryTextColor":"#000000"} },{}],673:[function(require,module,exports){ -module.exports={"name":"Warm & Cool","viewer":{"rendering":{"background":[0.26666666666666666,0.2980392156862745,0.3607843137254902,1],"meshColor":[0.807843137254902,0.35294117647058826,0.3411764705882353,1]},"grid":{"color":[0.47058823529411764,0.6470588235294118,0.6392156862745098,1],"subColor":[0.8823529411764706,0.6941176470588235,0.41568627450980394,1]}},"mainTextColor":[0.47058823529411764,0.6470588235294118,0.6392156862745098,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Understated & Versatile","viewer":{"rendering":{"background":[0.2,0.3215686274509804,0.3215686274509804,1],"meshColor":[0.788235294117647,0.8196078431372549,0.7843137254901961,1]},"grid":{"color":[0.6078431372549019,0.30980392156862746,0.058823529411764705,1],"subColor":[0.17647058823529413,0.18823529411764706,0.2,1]}},"mainTextColor":[0.6078431372549019,0.30980392156862746,0.058823529411764705,1],"secondaryTextColor":"#000000"} },{}],674:[function(require,module,exports){ -module.exports={"name":"Warm & Rustic","viewer":{"rendering":{"background":[0.996078431372549,0.9490196078431372,0.8941176470588236,1],"meshColor":[0.9921568627450981,0.592156862745098,0.30980392156862746,1]},"grid":{"color":[0.7764705882352941,0,0,1],"subColor":[0.5019607843137255,0.35294117647058826,0.23137254901960785,1]}},"mainTextColor":[0.7764705882352941,0,0,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Warm & Cool","viewer":{"rendering":{"background":[0.26666666666666666,0.2980392156862745,0.3607843137254902,1],"meshColor":[0.807843137254902,0.35294117647058826,0.3411764705882353,1]},"grid":{"color":[0.47058823529411764,0.6470588235294118,0.6392156862745098,1],"subColor":[0.8823529411764706,0.6941176470588235,0.41568627450980394,1]}},"mainTextColor":[0.47058823529411764,0.6470588235294118,0.6392156862745098,1],"secondaryTextColor":"#000000"} },{}],675:[function(require,module,exports){ -module.exports={"name":"Wintery Reds","viewer":{"rendering":{"background":[0.9254901960784314,0.5882352941176471,0.6431372549019608,1],"meshColor":[0.8431372549019608,0.17254901960784313,0.08627450980392157,1]},"grid":{"color":[0.9411764705882353,0.9372549019607843,0.9176470588235294,1],"subColor":[0.7529411764705882,0.6980392156862745,0.7098039215686275,1]}},"mainTextColor":[0.9411764705882353,0.9372549019607843,0.9176470588235294,1],"secondaryTextColor":"#000000"} +module.exports={"name":"Warm & Rustic","viewer":{"rendering":{"background":[0.996078431372549,0.9490196078431372,0.8941176470588236,1],"meshColor":[0.9921568627450981,0.592156862745098,0.30980392156862746,1]},"grid":{"color":[0.7764705882352941,0,0,1],"subColor":[0.5019607843137255,0.35294117647058826,0.23137254901960785,1]}},"mainTextColor":[0.7764705882352941,0,0,1],"secondaryTextColor":"#000000"} },{}],676:[function(require,module,exports){ +module.exports={"name":"Wintery Reds","viewer":{"rendering":{"background":[0.9254901960784314,0.5882352941176471,0.6431372549019608,1],"meshColor":[0.8431372549019608,0.17254901960784313,0.08627450980392157,1]},"grid":{"color":[0.9411764705882353,0.9372549019607843,0.9176470588235294,1],"subColor":[0.7529411764705882,0.6980392156862745,0.7098039215686275,1]}},"mainTextColor":[0.9411764705882353,0.9372549019607843,0.9176470588235294,1],"secondaryTextColor":"#000000"} +},{}],677:[function(require,module,exports){ module.exports={dark:require("./theme.dark.json"),grass:require("./theme.grass.json"),light:require("./theme.light.json"),ocean:require("./theme.ocean.json"),arcticsunrise:require("./theme.arcticsunrise.json"),backtoschool:require("./theme.backtoschool.json"),beyondblackwhite:require("./theme.beyondblackwhite.json"),boldberries:require("./theme.boldberries.json"),candycoatedbrights:require("./theme.candycoatedbrights.json"),cheerfulfriendly:require("./theme.cheerfulfriendly.json"),classicmetallics:require("./theme.classicmetallics.json"),cozywarm:require("./theme.cozywarm.json"),crispdramatic:require("./theme.crispdramatic.json"),distinctiveunexpected:require("./theme.distinctiveunexpected.json"),exotichighimpact:require("./theme.exotichighimpact.json"),goldenafternoon:require("./theme.goldenafternoon.json"),grecianholiday:require("./theme.grecianholiday.json"),greenfields:require("./theme.greenfields.json"),icybluesandgrays:require("./theme.icybluesandgrays.json"),lightnatural:require("./theme.lightnatural.json"),modernurban:require("./theme.modernurban.json"),naturallyelegant:require("./theme.naturallyelegant.json"),neonnight:require("./theme.neonnight.json"),nightlife:require("./theme.nightlife.json"),outdoorsynatural:require("./theme.outdoorsynatural.json"),poolparty:require("./theme.poolparty.json"),primarycolors:require("./theme.primarycolors.json"),serenespalike:require("./theme.serenespalike.json"),shadesofcitrus:require("./theme.shadesofcitrus.json"),sleekmodern:require("./theme.sleekmodern.json"),smokypurples:require("./theme.smokypurples.json"),subtleversatile:require("./theme.subtleversatile.json"),summerbarbeque:require("./theme.summerbarbeque.json"),summersunflower:require("./theme.summersunflower.json"),surfturf:require("./theme.surfturf.json"),technologymeetsnature:require("./theme.technologymeetsnature.json"),understatedversatile:require("./theme.understatedversatile.json"),warmcool:require("./theme.warmcool.json"),warmrustic:require("./theme.warmrustic.json"),winteryreds:require("./theme.winteryreds.json")}; -},{"./theme.arcticsunrise.json":636,"./theme.backtoschool.json":637,"./theme.beyondblackwhite.json":638,"./theme.boldberries.json":639,"./theme.candycoatedbrights.json":640,"./theme.cheerfulfriendly.json":641,"./theme.classicmetallics.json":642,"./theme.cozywarm.json":643,"./theme.crispdramatic.json":644,"./theme.dark.json":645,"./theme.distinctiveunexpected.json":646,"./theme.exotichighimpact.json":647,"./theme.goldenafternoon.json":648,"./theme.grass.json":649,"./theme.grecianholiday.json":650,"./theme.greenfields.json":651,"./theme.icybluesandgrays.json":652,"./theme.light.json":653,"./theme.lightnatural.json":654,"./theme.modernurban.json":655,"./theme.naturallyelegant.json":656,"./theme.neonnight.json":657,"./theme.nightlife.json":658,"./theme.ocean.json":659,"./theme.outdoorsynatural.json":660,"./theme.poolparty.json":661,"./theme.primarycolors.json":662,"./theme.serenespalike.json":663,"./theme.shadesofcitrus.json":664,"./theme.sleekmodern.json":665,"./theme.smokypurples.json":666,"./theme.subtleversatile.json":667,"./theme.summerbarbeque.json":668,"./theme.summersunflower.json":669,"./theme.surfturf.json":670,"./theme.technologymeetsnature.json":671,"./theme.understatedversatile.json":672,"./theme.warmcool.json":673,"./theme.warmrustic.json":674,"./theme.winteryreds.json":675}],677:[function(require,module,exports){ +},{"./theme.arcticsunrise.json":637,"./theme.backtoschool.json":638,"./theme.beyondblackwhite.json":639,"./theme.boldberries.json":640,"./theme.candycoatedbrights.json":641,"./theme.cheerfulfriendly.json":642,"./theme.classicmetallics.json":643,"./theme.cozywarm.json":644,"./theme.crispdramatic.json":645,"./theme.dark.json":646,"./theme.distinctiveunexpected.json":647,"./theme.exotichighimpact.json":648,"./theme.goldenafternoon.json":649,"./theme.grass.json":650,"./theme.grecianholiday.json":651,"./theme.greenfields.json":652,"./theme.icybluesandgrays.json":653,"./theme.light.json":654,"./theme.lightnatural.json":655,"./theme.modernurban.json":656,"./theme.naturallyelegant.json":657,"./theme.neonnight.json":658,"./theme.nightlife.json":659,"./theme.ocean.json":660,"./theme.outdoorsynatural.json":661,"./theme.poolparty.json":662,"./theme.primarycolors.json":663,"./theme.serenespalike.json":664,"./theme.shadesofcitrus.json":665,"./theme.sleekmodern.json":666,"./theme.smokypurples.json":667,"./theme.subtleversatile.json":668,"./theme.summerbarbeque.json":669,"./theme.summersunflower.json":670,"./theme.surfturf.json":671,"./theme.technologymeetsnature.json":672,"./theme.understatedversatile.json":673,"./theme.warmcool.json":674,"./theme.warmrustic.json":675,"./theme.winteryreds.json":676}],678:[function(require,module,exports){ module.exports={"Creating Shapes":[{"title":"2D Primitives Demonstration","filePath":"examples/core/primitives/primitives2D.js","sort":1,"description":"Demonstrating the basics of a variety of 2D primitives"},{"title":"3D Primitives Demonstration","filePath":"examples/core/primitives/primitives3D.js","sort":1,"description":"Demonstrating the basics of a variety of 3D primitives"},{"title":"Rounded Cuboid","filePath":"examples/core/primitives/roundedCuboid.js","sort":1,"description":"Demonstrating the roundedCuboid() functiom"},{"title":"Spheres of all sorts","filePath":"examples/core/primitives/sphere.js","sort":1,"description":"Demonstrating the sphere() and geodesicSphere() functions"},{"title":"Building a Dodecahedron","filePath":"examples/core/primitives/dodecahedron.js","sort":2,"description":"building dodecahedron() from cuboids"},{"title":"Torus Variety","filePath":"examples/core/primitives/torus.js","sort":2,"description":"Demonstrating the capabilities and variations of the torus() primitive"},{"title":"Building a Polyhedron from scratch","filePath":"examples/core/primitives/polyhedron.js","sort":4,"description":"Demonstrating the polyhedron() function"},{"title":"Basic Extrude Functions","filePath":"examples/core/extrusions/basicExtrusions.js","sort":5,"description":"Demonstrating the basic types of extrusions, and the variety of objects they can create."},{"title":"Extrude Along a Bezier Path","filePath":"examples/core/curves/bezier/extrudeAlongPath.js","sort":5,"description":"Using a 3D bezier path to create a solid tube"},{"title":"Extrude From Slices","filePath":"examples/core/extrusions/extrudeFromSlices.js","sort":5,"description":"Demonstrating the advanced extrusion using slices with varying numbers of points."},{"title":"Simple Bezier Extrude","filePath":"examples/core/curves/bezier/simpleExtrude.js","sort":5,"description":"Using a 1D bezier function to create a non-uniform extrusion"},{"title":"Hull and HullChain 2D example","filePath":"examples/core/hulls/hull2D.js","sort":8,"description":"Demonstrating the basics of Hulls in two dimensions"},{"title":"Hull and HullChain 3D example","filePath":"examples/core/hulls/hull3D.js","sort":8,"description":"Demonstrating the basics of Hulls in three dimensions"},{"title":"Nuts and Bolts","filePath":"examples/core/extrusions/nutsAndBolts.js","sort":8,"description":"Demonstrating the advanced extrusion using slices to generate screw threads."},{"title":"Basic Text Creation","filePath":"examples/core/text/text.js","sort":10,"description":"Demonstrating methods of building 3D text"}],"Manipulating Shapes":[{"title":"Basic Booleans Demonstration","filePath":"examples/core/booleans/basicBooleans.js","sort":2,"description":"Demonstrating the basics of boolean shape combinations"},{"title":"Align function demonstration","filePath":"examples/core/transforms/align.js","sort":3,"description":"Demonstrating aligning shapes using the align function"},{"title":"Expanding 2D and 3D Shapes","filePath":"examples/core/expansions/expand.js","sort":5,"description":"Exploring the expand() function on 2D and 3D geometries"},{"title":"Offsetting 2D Shapes","filePath":"examples/core/expansions/offset.js","sort":5,"description":"Demonstrating the offset() function. Moves all points in a 2d path or 2D geometry perpendicular to the line's tangent."},{"title":"Center function demonstration","filePath":"examples/core/transforms/center.js","sort":10,"description":"Using center() to translate objects"},{"title":"Measure Aggregate Bounding Box","filePath":"examples/core/measurements/measureAggregateBounds.js","sort":10,"description":"Examples of measureAggregateBoundingBox function"},{"title":"Measure Area and Volume","filePath":"examples/core/measurements/measureAreaAndVolume.js","sort":10,"description":"Examples of measureArea() and measureVolume() function"},{"title":"Measure Bounding Box","filePath":"examples/core/measurements/measureBounds.js","sort":10,"description":"Examples of measureBoundingBox function"}],"Colors":[{"title":"Basic Colors","filePath":"examples/core/colors/basicColors.js","sort":1,"description":"showing various color functions"},{"title":"Color Cube","filePath":"examples/core/colors/colorCube.js","sort":2,"description":"looking at the different ways to specify a color"},{"title":"Transparency","filePath":"examples/core/colors/transparency.js","sort":2,"description":"showing transparent objects"}],"Parameters":[{"title":"All Parameter Types Demo","filePath":"examples/parameters/allParamTypes.js","sort":1,"description":"Example of interactive parameters"},{"title":"Birthday Balloons","filePath":"examples/parameters/balloons.js","sort":1,"description":"Example of building models from interactive parameters"},{"title":"Parametric Involute Gear","filePath":"examples/parameters/gear.js","sort":1,"description":"Build a proper involute gear, demonstrating parameters, and how they can be used in complex math."}],"Other":[{"title":"Coordinate system and Rotation demonstration","filePath":"examples/core/other/orientation.js","sort":1,"description":"Demonstrating rotation about the three axes."}]} -},{}],678:[function(require,module,exports){ +},{}],679:[function(require,module,exports){ module.exports={ "language":"german", @@ -2504,7 +2507,7 @@ module.exports={ "always":"Immer" } -},{}],679:[function(require,module,exports){ +},{}],680:[function(require,module,exports){ module.exports={ "language":"english", @@ -2568,7 +2571,7 @@ module.exports={ "always":"Always" } -},{}],680:[function(require,module,exports){ +},{}],681:[function(require,module,exports){ module.exports={ "language":"french", @@ -2632,7 +2635,7 @@ module.exports={ "always":"Toujours" } -},{}],681:[function(require,module,exports){ +},{}],682:[function(require,module,exports){ module.exports={ "language":"croatian", @@ -2696,7 +2699,7 @@ module.exports={ "always":"Uvijek" } -},{}],682:[function(require,module,exports){ +},{}],683:[function(require,module,exports){ module.exports={ "language":"japanese", @@ -2772,7 +2775,7 @@ module.exports={ "always":"いつも" } -},{}],683:[function(require,module,exports){ +},{}],684:[function(require,module,exports){ module.exports={ "language":"chinese", @@ -2836,413 +2839,413 @@ module.exports={ "always":"永远" } -},{}],684:[function(require,module,exports){ +},{}],685:[function(require,module,exports){ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("most"),require("@most/multicast")):"function"==typeof define&&define.amd?define(["exports","most","@most/multicast"],e):e(t.mostCreate=t.mostCreate||{},t.most,t.mostMulticast)}(this,function(t,e,i){"use strict";function n(t){return Promise.resolve(t).then(s)}function s(t){try{return t.run()}catch(e){return t.error(e)}}var r=function(t,e,i){this.sink=t,this.time=e,this.events=i};r.prototype.run=function(){for(var t,e=this.events,i=this.sink,n=0,s=e.length;n=0&&(this.sinks=e.remove(s,this.sinks)),this.sinks.length},u.prototype.event=function(t,e){var s=this.sinks;if(1===s.length)return s[0].event(t,e);for(var n=0;n= 0");var e=n.length;return 0===r||0===e?n:r>=e?[]:function(r,n,e){for(var t=new Array(e),u=0;u= 0");var e=n.length;return 0===e||r>=e?n:1===e?[]:function(r,n,e){var t,u=new Array(e);for(t=0;t= 0");for(var t=e.length,u=new Array(t),o=0;o0)throw new Error("Invalid string. Length must be a multiple of 4");var e=o.indexOf("=");return-1===e&&(e=r),[e,e===r?0:4-e%4]}function byteLength(o){var r=getLens(o),e=r[0],t=r[1];return 3*(e+t)/4-t}function _byteLength(o,r,e){return 3*(r+e)/4-e}function toByteArray(o){var r,e,t=getLens(o),n=t[0],u=t[1],p=new Arr(_byteLength(o,n,u)),a=0,h=u>0?n-4:n;for(e=0;e>16&255,p[a++]=r>>8&255,p[a++]=255&r;return 2===u&&(r=revLookup[o.charCodeAt(e)]<<2|revLookup[o.charCodeAt(e+1)]>>4,p[a++]=255&r),1===u&&(r=revLookup[o.charCodeAt(e)]<<10|revLookup[o.charCodeAt(e+1)]<<4|revLookup[o.charCodeAt(e+2)]>>2,p[a++]=r>>8&255,p[a++]=255&r),p}function tripletToBase64(o){return lookup[o>>18&63]+lookup[o>>12&63]+lookup[o>>6&63]+lookup[63&o]}function encodeChunk(o,r,e){for(var t,n=[],u=r;up?p:u+16383));return 1===t?(r=o[e-1],n.push(lookup[r>>2]+lookup[r<<4&63]+"==")):2===t&&(r=(o[e-2]<<8)+o[e-1],n.push(lookup[r>>10]+lookup[r>>4&63]+lookup[r<<2&63]+"=")),n.join("")}revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63; - },{}],688:[function(require,module,exports){ +"use strict";exports.byteLength=byteLength,exports.toByteArray=toByteArray,exports.fromByteArray=fromByteArray;for(var lookup=[],revLookup=[],Arr="undefined"!=typeof Uint8Array?Uint8Array:Array,code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i0)throw new Error("Invalid string. Length must be a multiple of 4");var e=o.indexOf("=");return-1===e&&(e=r),[e,e===r?0:4-e%4]}function byteLength(o){var r=getLens(o),e=r[0],t=r[1];return 3*(e+t)/4-t}function _byteLength(o,r,e){return 3*(r+e)/4-e}function toByteArray(o){var r,e,t=getLens(o),n=t[0],u=t[1],p=new Arr(_byteLength(o,n,u)),a=0,h=u>0?n-4:n;for(e=0;e>16&255,p[a++]=r>>8&255,p[a++]=255&r;return 2===u&&(r=revLookup[o.charCodeAt(e)]<<2|revLookup[o.charCodeAt(e+1)]>>4,p[a++]=255&r),1===u&&(r=revLookup[o.charCodeAt(e)]<<10|revLookup[o.charCodeAt(e+1)]<<4|revLookup[o.charCodeAt(e+2)]>>2,p[a++]=r>>8&255,p[a++]=255&r),p}function tripletToBase64(o){return lookup[o>>18&63]+lookup[o>>12&63]+lookup[o>>6&63]+lookup[63&o]}function encodeChunk(o,r,e){for(var t,n=[],u=r;up?p:u+16383));return 1===t?(r=o[e-1],n.push(lookup[r>>2]+lookup[r<<4&63]+"==")):2===t&&(r=(o[e-2]<<8)+o[e-1],n.push(lookup[r>>10]+lookup[r>>4&63]+lookup[r<<2&63]+"=")),n.join("")}revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63; },{}],689:[function(require,module,exports){ + +},{}],690:[function(require,module,exports){ (function (Buffer){(function (){ "use strict";var base64=require("base64-js"),ieee754=require("ieee754");exports.Buffer=Buffer,exports.SlowBuffer=SlowBuffer,exports.INSPECT_MAX_BYTES=50;var K_MAX_LENGTH=2147483647;function typedArraySupport(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}function createBuffer(e){if(e>K_MAX_LENGTH)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=Buffer.prototype,t}function Buffer(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return allocUnsafe(e)}return from(e,t,r)}function from(e,t,r){if("string"==typeof e)return fromString(e,t);if(ArrayBuffer.isView(e))return fromArrayLike(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(isInstance(e,ArrayBuffer)||e&&isInstance(e.buffer,ArrayBuffer))return fromArrayBuffer(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return Buffer.from(n,t,r);var f=fromObject(e);if(f)return f;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return Buffer.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function assertSize(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function alloc(e,t,r){return assertSize(e),e<=0?createBuffer(e):void 0!==t?"string"==typeof r?createBuffer(e).fill(t,r):createBuffer(e).fill(t):createBuffer(e)}function allocUnsafe(e){return assertSize(e),createBuffer(e<0?0:0|checked(e))}function fromString(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!Buffer.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|byteLength(e,t),n=createBuffer(r),f=n.write(e,t);return f!==r&&(n=n.slice(0,f)),n}function fromArrayLike(e){for(var t=e.length<0?0:0|checked(e.length),r=createBuffer(t),n=0;n=K_MAX_LENGTH)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+K_MAX_LENGTH.toString(16)+" bytes");return 0|e}function SlowBuffer(e){return+e!=e&&(e=0),Buffer.alloc(+e)}function byteLength(e,t){if(Buffer.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||isInstance(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var f=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return utf8ToBytes(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return base64ToBytes(e).length;default:if(f)return n?-1:utf8ToBytes(e).length;t=(""+t).toLowerCase(),f=!0}}function slowToString(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return hexSlice(this,t,r);case"utf8":case"utf-8":return utf8Slice(this,t,r);case"ascii":return asciiSlice(this,t,r);case"latin1":case"binary":return latin1Slice(this,t,r);case"base64":return base64Slice(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function swap(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function bidirectionalIndexOf(e,t,r,n,f){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),numberIsNaN(r=+r)&&(r=f?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(f)return-1;r=e.length-1}else if(r<0){if(!f)return-1;r=0}if("string"==typeof t&&(t=Buffer.from(t,n)),Buffer.isBuffer(t))return 0===t.length?-1:arrayIndexOf(e,t,r,n,f);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?f?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):arrayIndexOf(e,[t],r,n,f);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(e,t,r,n,f){var i,o=1,u=e.length,s=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;o=2,u/=2,s/=2,r/=2}function a(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(f){var h=-1;for(i=r;iu&&(r=u-s),i=r;i>=0;i--){for(var c=!0,l=0;lf&&(n=f):n=f;var i=t.length;n>i/2&&(n=i/2);for(var o=0;o239?4:a>223?3:a>191?2:1;if(f+c<=r)switch(c){case 1:a<128&&(h=a);break;case 2:128==(192&(i=e[f+1]))&&(s=(31&a)<<6|63&i)>127&&(h=s);break;case 3:i=e[f+1],o=e[f+2],128==(192&i)&&128==(192&o)&&(s=(15&a)<<12|(63&i)<<6|63&o)>2047&&(s<55296||s>57343)&&(h=s);break;case 4:i=e[f+1],o=e[f+2],u=e[f+3],128==(192&i)&&128==(192&o)&&128==(192&u)&&(s=(15&a)<<18|(63&i)<<12|(63&o)<<6|63&u)>65535&&s<1114112&&(h=s)}null===h?(h=65533,c=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),f+=c}return decodeCodePointsArray(n)}exports.kMaxLength=K_MAX_LENGTH,Buffer.TYPED_ARRAY_SUPPORT=typedArraySupport(),Buffer.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(Buffer.prototype,"parent",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.buffer}}),Object.defineProperty(Buffer.prototype,"offset",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&Buffer[Symbol.species]===Buffer&&Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),Buffer.poolSize=8192,Buffer.from=function(e,t,r){return from(e,t,r)},Buffer.prototype.__proto__=Uint8Array.prototype,Buffer.__proto__=Uint8Array,Buffer.alloc=function(e,t,r){return alloc(e,t,r)},Buffer.allocUnsafe=function(e){return allocUnsafe(e)},Buffer.allocUnsafeSlow=function(e){return allocUnsafe(e)},Buffer.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==Buffer.prototype},Buffer.compare=function(e,t){if(isInstance(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),isInstance(t,Uint8Array)&&(t=Buffer.from(t,t.offset,t.byteLength)),!Buffer.isBuffer(e)||!Buffer.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,n=t.length,f=0,i=Math.min(r,n);ft&&(e+=" ... "),""},Buffer.prototype.compare=function(e,t,r,n,f){if(isInstance(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),!Buffer.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===f&&(f=this.length),t<0||r>e.length||n<0||f>this.length)throw new RangeError("out of range index");if(n>=f&&t>=r)return 0;if(n>=f)return-1;if(t>=r)return 1;if(this===e)return 0;for(var i=(f>>>=0)-(n>>>=0),o=(r>>>=0)-(t>>>=0),u=Math.min(i,o),s=this.slice(n,f),a=e.slice(t,r),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var f=this.length-t;if((void 0===r||r>f)&&(r=f),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return hexWrite(this,e,t,r);case"utf8":case"utf-8":return utf8Write(this,e,t,r);case"ascii":return asciiWrite(this,e,t,r);case"latin1":case"binary":return latin1Write(this,e,t,r);case"base64":return base64Write(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(e){var t=e.length;if(t<=MAX_ARGUMENTS_LENGTH)return String.fromCharCode.apply(String,e);for(var r="",n=0;nn)&&(r=n);for(var f="",i=t;ir)throw new RangeError("Trying to access beyond buffer length")}function checkInt(e,t,r,n,f,i){if(!Buffer.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>f||te.length)throw new RangeError("Index out of range")}function checkIEEE754(e,t,r,n,f,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function writeFloat(e,t,r,n,f){return t=+t,r>>>=0,f||checkIEEE754(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),ieee754.write(e,t,r,n,23,4),r+4}function writeDouble(e,t,r,n,f){return t=+t,r>>>=0,f||checkIEEE754(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),ieee754.write(e,t,r,n,52,8),r+8}Buffer.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=this[e],f=1,i=0;++i>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=this[e+--t],f=1;t>0&&(f*=256);)n+=this[e+--t]*f;return n},Buffer.prototype.readUInt8=function(e,t){return e>>>=0,t||checkOffset(e,1,this.length),this[e]},Buffer.prototype.readUInt16LE=function(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]|this[e+1]<<8},Buffer.prototype.readUInt16BE=function(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]<<8|this[e+1]},Buffer.prototype.readUInt32LE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Buffer.prototype.readUInt32BE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Buffer.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=this[e],f=1,i=0;++i=(f*=128)&&(n-=Math.pow(2,8*t)),n},Buffer.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=t,f=1,i=this[e+--n];n>0&&(f*=256);)i+=this[e+--n]*f;return i>=(f*=128)&&(i-=Math.pow(2,8*t)),i},Buffer.prototype.readInt8=function(e,t){return e>>>=0,t||checkOffset(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Buffer.prototype.readInt16LE=function(e,t){e>>>=0,t||checkOffset(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function(e,t){e>>>=0,t||checkOffset(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Buffer.prototype.readInt32BE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Buffer.prototype.readFloatLE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),ieee754.read(this,e,!0,23,4)},Buffer.prototype.readFloatBE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),ieee754.read(this,e,!1,23,4)},Buffer.prototype.readDoubleLE=function(e,t){return e>>>=0,t||checkOffset(e,8,this.length),ieee754.read(this,e,!0,52,8)},Buffer.prototype.readDoubleBE=function(e,t){return e>>>=0,t||checkOffset(e,8,this.length),ieee754.read(this,e,!1,52,8)},Buffer.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t>>>=0,r>>>=0,n)||checkInt(this,e,t,r,Math.pow(2,8*r)-1,0);var f=1,i=0;for(this[t]=255&e;++i>>=0,r>>>=0,n)||checkInt(this,e,t,r,Math.pow(2,8*r)-1,0);var f=r-1,i=1;for(this[t+f]=255&e;--f>=0&&(i*=256);)this[t+f]=e/i&255;return t+r},Buffer.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,1,255,0),this[t]=255&e,t+1},Buffer.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},Buffer.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var f=Math.pow(2,8*r-1);checkInt(this,e,t,r,f-1,-f)}var i=0,o=1,u=0;for(this[t]=255&e;++i>0)-u&255;return t+r},Buffer.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var f=Math.pow(2,8*r-1);checkInt(this,e,t,r,f-1,-f)}var i=r-1,o=1,u=0;for(this[t+i]=255&e;--i>=0&&(o*=256);)e<0&&0===u&&0!==this[t+i+1]&&(u=1),this[t+i]=(e/o>>0)-u&255;return t+r},Buffer.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},Buffer.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},Buffer.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeFloatLE=function(e,t,r){return writeFloat(this,e,t,!0,r)},Buffer.prototype.writeFloatBE=function(e,t,r){return writeFloat(this,e,t,!1,r)},Buffer.prototype.writeDoubleLE=function(e,t,r){return writeDouble(this,e,t,!0,r)},Buffer.prototype.writeDoubleBE=function(e,t,r){return writeDouble(this,e,t,!1,r)},Buffer.prototype.copy=function(e,t,r,n){if(!Buffer.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,n),t);return f},Buffer.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Buffer.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){var f=e.charCodeAt(0);("utf8"===n&&f<128||"latin1"===n)&&(e=f)}}else"number"==typeof e&&(e&=255);if(t<0||this.length>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i55295&&r<57344){if(!f){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&i.push(239,191,189);continue}f=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),f=r;continue}r=65536+(f-55296<<10|r-56320)}else f&&(t-=3)>-1&&i.push(239,191,189);if(f=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function asciiToBytes(e){for(var t=[],r=0;r>8,f=r%256,i.push(f),i.push(n);return i}function base64ToBytes(e){return base64.toByteArray(base64clean(e))}function blitBuffer(e,t,r,n){for(var f=0;f=t.length||f>=e.length);++f)t[f+r]=e[f];return f}function isInstance(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function numberIsNaN(e){return e!=e} }).call(this)}).call(this,require("buffer").Buffer) -},{"base64-js":687,"buffer":689,"ieee754":710}],690:[function(require,module,exports){ +},{"base64-js":688,"buffer":690,"ieee754":711}],691:[function(require,module,exports){ "use strict";var GetIntrinsic=require("get-intrinsic"),callBind=require("./"),$indexOf=callBind(GetIntrinsic("String.prototype.indexOf"));module.exports=function(i,n){var t=GetIntrinsic(i,!!n);return"function"==typeof t&&$indexOf(i,".prototype.")>-1?callBind(t):t}; -},{"./":691,"get-intrinsic":703}],691:[function(require,module,exports){ +},{"./":692,"get-intrinsic":704}],692:[function(require,module,exports){ "use strict";var bind=require("function-bind"),GetIntrinsic=require("get-intrinsic"),setFunctionLength=require("set-function-length"),$TypeError=require("es-errors/type"),$apply=GetIntrinsic("%Function.prototype.apply%"),$call=GetIntrinsic("%Function.prototype.call%"),$reflectApply=GetIntrinsic("%Reflect.apply%",!0)||bind.call($call,$apply),$defineProperty=require("es-define-property"),$max=GetIntrinsic("%Math.max%");module.exports=function(e){if("function"!=typeof e)throw new $TypeError("a function is required");var t=$reflectApply(bind,$call,arguments);return setFunctionLength(t,1+$max(0,e.length-(arguments.length-1)),!0)};var applyBind=function(){return $reflectApply(bind,$apply,arguments)};$defineProperty?$defineProperty(module.exports,"apply",{value:applyBind}):module.exports.apply=applyBind; -},{"es-define-property":693,"es-errors/type":699,"function-bind":702,"get-intrinsic":703,"set-function-length":720}],692:[function(require,module,exports){ +},{"es-define-property":694,"es-errors/type":700,"function-bind":703,"get-intrinsic":704,"set-function-length":721}],693:[function(require,module,exports){ "use strict";var $defineProperty=require("es-define-property"),$SyntaxError=require("es-errors/syntax"),$TypeError=require("es-errors/type"),gopd=require("gopd");module.exports=function(e,r,o){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new $TypeError("`obj` must be an object or a function`");if("string"!=typeof r&&"symbol"!=typeof r)throw new $TypeError("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new $TypeError("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new $TypeError("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new $TypeError("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new $TypeError("`loose`, if provided, must be a boolean");var n=arguments.length>3?arguments[3]:null,l=arguments.length>4?arguments[4]:null,t=arguments.length>5?arguments[5]:null,i=arguments.length>6&&arguments[6],u=!!gopd&&gopd(e,r);if($defineProperty)$defineProperty(e,r,{configurable:null===t&&u?u.configurable:!t,enumerable:null===n&&u?u.enumerable:!n,value:o,writable:null===l&&u?u.writable:!l});else{if(!i&&(n||l||t))throw new $SyntaxError("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");e[r]=o}}; -},{"es-define-property":693,"es-errors/syntax":698,"es-errors/type":699,"gopd":704}],693:[function(require,module,exports){ +},{"es-define-property":694,"es-errors/syntax":699,"es-errors/type":700,"gopd":705}],694:[function(require,module,exports){ "use strict";var GetIntrinsic=require("get-intrinsic"),$defineProperty=GetIntrinsic("%Object.defineProperty%",!0)||!1;if($defineProperty)try{$defineProperty({},"a",{value:1})}catch(e){$defineProperty=!1}module.exports=$defineProperty; -},{"get-intrinsic":703}],694:[function(require,module,exports){ +},{"get-intrinsic":704}],695:[function(require,module,exports){ "use strict";module.exports=EvalError; -},{}],695:[function(require,module,exports){ +},{}],696:[function(require,module,exports){ "use strict";module.exports=Error; -},{}],696:[function(require,module,exports){ +},{}],697:[function(require,module,exports){ "use strict";module.exports=RangeError; -},{}],697:[function(require,module,exports){ +},{}],698:[function(require,module,exports){ "use strict";module.exports=ReferenceError; -},{}],698:[function(require,module,exports){ +},{}],699:[function(require,module,exports){ "use strict";module.exports=SyntaxError; -},{}],699:[function(require,module,exports){ +},{}],700:[function(require,module,exports){ "use strict";module.exports=TypeError; -},{}],700:[function(require,module,exports){ +},{}],701:[function(require,module,exports){ "use strict";module.exports=URIError; -},{}],701:[function(require,module,exports){ +},{}],702:[function(require,module,exports){ "use strict";var ERROR_MESSAGE="Function.prototype.bind called on incompatible ",toStr=Object.prototype.toString,max=Math.max,funcType="[object Function]",concatty=function(t,n){for(var r=[],o=0;o1&&"boolean"!=typeof e)throw new $TypeError('"allowMissing" argument must be a boolean');if(null===$exec(/^%?[^%]*%?$/,r))throw new $SyntaxError("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var t=stringToPath(r),o=t.length>0?t[0]:"",n=getBaseIntrinsic("%"+o+"%",e),a=n.name,y=n.value,i=!1,p=n.alias;p&&(o=p[0],$spliceApply(t,$concat([0,1],p)));for(var d=1,s=!0;d=t.length){var c=$gOPD(y,f);y=(s=!!c)&&"get"in c&&!("originalValue"in c.get)?c.get:y[f]}else s=hasOwn(y,f),y=y[f];s&&!i&&(INTRINSICS[a]=y)}}return y}; -},{"es-errors":695,"es-errors/eval":694,"es-errors/range":696,"es-errors/ref":697,"es-errors/syntax":698,"es-errors/type":699,"es-errors/uri":700,"function-bind":702,"has-proto":706,"has-symbols":707,"hasown":709}],704:[function(require,module,exports){ +},{"es-errors":696,"es-errors/eval":695,"es-errors/range":697,"es-errors/ref":698,"es-errors/syntax":699,"es-errors/type":700,"es-errors/uri":701,"function-bind":703,"has-proto":707,"has-symbols":708,"hasown":710}],705:[function(require,module,exports){ "use strict";var GetIntrinsic=require("get-intrinsic"),$gOPD=GetIntrinsic("%Object.getOwnPropertyDescriptor%",!0);if($gOPD)try{$gOPD([],"length")}catch(t){$gOPD=null}module.exports=$gOPD; -},{"get-intrinsic":703}],705:[function(require,module,exports){ +},{"get-intrinsic":704}],706:[function(require,module,exports){ "use strict";var $defineProperty=require("es-define-property"),hasPropertyDescriptors=function(){return!!$defineProperty};hasPropertyDescriptors.hasArrayLengthDefineBug=function(){if(!$defineProperty)return null;try{return 1!==$defineProperty([],"length",{value:1}).length}catch(r){return!0}},module.exports=hasPropertyDescriptors; -},{"es-define-property":693}],706:[function(require,module,exports){ +},{"es-define-property":694}],707:[function(require,module,exports){ "use strict";var test={__proto__:null,foo:{}},$Object=Object;module.exports=function(){return{__proto__:test}.foo===test.foo&&!(test instanceof $Object)}; -},{}],707:[function(require,module,exports){ +},{}],708:[function(require,module,exports){ "use strict";var origSymbol="undefined"!=typeof Symbol&&Symbol,hasSymbolSham=require("./shams");module.exports=function(){return"function"==typeof origSymbol&&("function"==typeof Symbol&&("symbol"==typeof origSymbol("foo")&&("symbol"==typeof Symbol("bar")&&hasSymbolSham())))}; -},{"./shams":708}],708:[function(require,module,exports){ +},{"./shams":709}],709:[function(require,module,exports){ "use strict";module.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var t={},e=Symbol("test"),r=Object(e);if("string"==typeof e)return!1;if("[object Symbol]"!==Object.prototype.toString.call(e))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(e in t[e]=42,t)return!1;if("function"==typeof Object.keys&&0!==Object.keys(t).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(t).length)return!1;var o=Object.getOwnPropertySymbols(t);if(1!==o.length||o[0]!==e)return!1;if(!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var n=Object.getOwnPropertyDescriptor(t,e);if(42!==n.value||!0!==n.enumerable)return!1}return!0}; -},{}],709:[function(require,module,exports){ +},{}],710:[function(require,module,exports){ "use strict";var call=Function.prototype.call,$hasOwn=Object.prototype.hasOwnProperty,bind=require("function-bind");module.exports=bind.call(call,$hasOwn); -},{"function-bind":702}],710:[function(require,module,exports){ +},{"function-bind":703}],711:[function(require,module,exports){ exports.read=function(a,o,t,r,h){var M,p,w=8*h-r-1,f=(1<>1,i=-7,N=t?h-1:0,n=t?-1:1,s=a[o+N];for(N+=n,M=s&(1<<-i)-1,s>>=-i,i+=w;i>0;M=256*M+a[o+N],N+=n,i-=8);for(p=M&(1<<-i)-1,M>>=-i,i+=r;i>0;p=256*p+a[o+N],N+=n,i-=8);if(0===M)M=1-e;else{if(M===f)return p?NaN:1/0*(s?-1:1);p+=Math.pow(2,r),M-=e}return(s?-1:1)*p*Math.pow(2,M-r)},exports.write=function(a,o,t,r,h,M){var p,w,f,e=8*M-h-1,i=(1<>1,n=23===h?Math.pow(2,-24)-Math.pow(2,-77):0,s=r?0:M-1,u=r?1:-1,l=o<0||0===o&&1/o<0?1:0;for(o=Math.abs(o),isNaN(o)||o===1/0?(w=isNaN(o)?1:0,p=i):(p=Math.floor(Math.log(o)/Math.LN2),o*(f=Math.pow(2,-p))<1&&(p--,f*=2),(o+=p+N>=1?n/f:n*Math.pow(2,1-N))*f>=2&&(p++,f/=2),p+N>=i?(w=0,p=i):p+N>=1?(w=(o*f-1)*Math.pow(2,h),p+=N):(w=o*Math.pow(2,N-1)*Math.pow(2,h),p=0));h>=8;a[t+s]=255&w,s+=u,w/=256,h-=8);for(p=p<0;a[t+s]=255&p,s+=u,p/=256,e-=8);a[t+s-u]|=128*l}; -},{}],711:[function(require,module,exports){ +},{}],712:[function(require,module,exports){ (function (global){(function (){ -var hasMap="function"==typeof Map&&Map.prototype,mapSizeDescriptor=Object.getOwnPropertyDescriptor&&hasMap?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,mapSize=hasMap&&mapSizeDescriptor&&"function"==typeof mapSizeDescriptor.get?mapSizeDescriptor.get:null,mapForEach=hasMap&&Map.prototype.forEach,hasSet="function"==typeof Set&&Set.prototype,setSizeDescriptor=Object.getOwnPropertyDescriptor&&hasSet?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,setSize=hasSet&&setSizeDescriptor&&"function"==typeof setSizeDescriptor.get?setSizeDescriptor.get:null,setForEach=hasSet&&Set.prototype.forEach,hasWeakMap="function"==typeof WeakMap&&WeakMap.prototype,weakMapHas=hasWeakMap?WeakMap.prototype.has:null,hasWeakSet="function"==typeof WeakSet&&WeakSet.prototype,weakSetHas=hasWeakSet?WeakSet.prototype.has:null,hasWeakRef="function"==typeof WeakRef&&WeakRef.prototype,weakRefDeref=hasWeakRef?WeakRef.prototype.deref:null,booleanValueOf=Boolean.prototype.valueOf,objectToString=Object.prototype.toString,functionToString=Function.prototype.toString,$match=String.prototype.match,$slice=String.prototype.slice,$replace=String.prototype.replace,$toUpperCase=String.prototype.toUpperCase,$toLowerCase=String.prototype.toLowerCase,$test=RegExp.prototype.test,$concat=Array.prototype.concat,$join=Array.prototype.join,$arrSlice=Array.prototype.slice,$floor=Math.floor,bigIntValueOf="function"==typeof BigInt?BigInt.prototype.valueOf:null,gOPS=Object.getOwnPropertySymbols,symToString="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,hasShammedSymbols="function"==typeof Symbol&&"object"==typeof Symbol.iterator,toStringTag="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===hasShammedSymbols||"symbol")?Symbol.toStringTag:null,isEnumerable=Object.prototype.propertyIsEnumerable,gPO=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function addNumericSeparator(t,e){if(t===1/0||t===-1/0||t!=t||t&&t>-1e3&&t<1e3||$test.call(/e/,e))return e;var r=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof t){var n=t<0?-$floor(-t):$floor(t);if(n!==t){var o=String(n),a=$slice.call(e,o.length+1);return $replace.call(o,r,"$&_")+"."+$replace.call($replace.call(a,/([0-9]{3})/g,"$&_"),/_$/,"")}}return $replace.call(e,r,"$&_")}var utilInspect=require("./util.inspect"),inspectCustom=utilInspect.custom,inspectSymbol=isSymbol(inspectCustom)?inspectCustom:null;function wrapQuotes(t,e,r){var n="double"===(r.quoteStyle||e)?'"':"'";return n+t+n}function quote(t){return $replace.call(String(t),/"/g,""")}function isArray(t){return!("[object Array]"!==toStr(t)||toStringTag&&"object"==typeof t&&toStringTag in t)}function isDate(t){return!("[object Date]"!==toStr(t)||toStringTag&&"object"==typeof t&&toStringTag in t)}function isRegExp(t){return!("[object RegExp]"!==toStr(t)||toStringTag&&"object"==typeof t&&toStringTag in t)}function isError(t){return!("[object Error]"!==toStr(t)||toStringTag&&"object"==typeof t&&toStringTag in t)}function isString(t){return!("[object String]"!==toStr(t)||toStringTag&&"object"==typeof t&&toStringTag in t)}function isNumber(t){return!("[object Number]"!==toStr(t)||toStringTag&&"object"==typeof t&&toStringTag in t)}function isBoolean(t){return!("[object Boolean]"!==toStr(t)||toStringTag&&"object"==typeof t&&toStringTag in t)}function isSymbol(t){if(hasShammedSymbols)return t&&"object"==typeof t&&t instanceof Symbol;if("symbol"==typeof t)return!0;if(!t||"object"!=typeof t||!symToString)return!1;try{return symToString.call(t),!0}catch(t){}return!1}function isBigInt(t){if(!t||"object"!=typeof t||!bigIntValueOf)return!1;try{return bigIntValueOf.call(t),!0}catch(t){}return!1}module.exports=function t(e,r,n,o){var a=r||{};if(has(a,"quoteStyle")&&"single"!==a.quoteStyle&&"double"!==a.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(has(a,"maxStringLength")&&("number"==typeof a.maxStringLength?a.maxStringLength<0&&a.maxStringLength!==1/0:null!==a.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var i=!has(a,"customInspect")||a.customInspect;if("boolean"!=typeof i&&"symbol"!==i)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(has(a,"indent")&&null!==a.indent&&"\t"!==a.indent&&!(parseInt(a.indent,10)===a.indent&&a.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(has(a,"numericSeparator")&&"boolean"!=typeof a.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var c=a.numericSeparator;if(void 0===e)return"undefined";if(null===e)return"null";if("boolean"==typeof e)return e?"true":"false";if("string"==typeof e)return inspectString(e,a);if("number"==typeof e){if(0===e)return 1/0/e>0?"0":"-0";var l=String(e);return c?addNumericSeparator(e,l):l}if("bigint"==typeof e){var u=String(e)+"n";return c?addNumericSeparator(e,u):u}var p=void 0===a.depth?5:a.depth;if(void 0===n&&(n=0),n>=p&&p>0&&"object"==typeof e)return isArray(e)?"[Array]":"[Object]";var f=getIndent(a,n);if(void 0===o)o=[];else if(indexOf(o,e)>=0)return"[Circular]";function s(e,r,i){if(r&&(o=$arrSlice.call(o)).push(r),i){var c={depth:a.depth};return has(a,"quoteStyle")&&(c.quoteStyle=a.quoteStyle),t(e,c,n+1,o)}return t(e,a,n+1,o)}if("function"==typeof e&&!isRegExp(e)){var y=nameOf(e),S=arrObjKeys(e,s);return"[Function"+(y?": "+y:" (anonymous)")+"]"+(S.length>0?" { "+$join.call(S,", ")+" }":"")}if(isSymbol(e)){var g=hasShammedSymbols?$replace.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):symToString.call(e);return"object"!=typeof e||hasShammedSymbols?g:markBoxed(g)}if(isElement(e)){for(var m="<"+$toLowerCase.call(String(e.nodeName)),b=e.attributes||[],h=0;h"}if(isArray(e)){if(0===e.length)return"[]";var d=arrObjKeys(e,s);return f&&!singleLineValues(d)?"["+indentedJoin(d,f)+"]":"[ "+$join.call(d,", ")+" ]"}if(isError(e)){var j=arrObjKeys(e,s);return"cause"in Error.prototype||!("cause"in e)||isEnumerable.call(e,"cause")?0===j.length?"["+String(e)+"]":"{ ["+String(e)+"] "+$join.call(j,", ")+" }":"{ ["+String(e)+"] "+$join.call($concat.call("[cause]: "+s(e.cause),j),", ")+" }"}if("object"==typeof e&&i){if(inspectSymbol&&"function"==typeof e[inspectSymbol]&&utilInspect)return utilInspect(e,{depth:p-n});if("symbol"!==i&&"function"==typeof e.inspect)return e.inspect()}if(isMap(e)){var O=[];return mapForEach&&mapForEach.call(e,function(t,r){O.push(s(r,e,!0)+" => "+s(t,e))}),collectionOf("Map",mapSize.call(e),O,f)}if(isSet(e)){var w=[];return setForEach&&setForEach.call(e,function(t){w.push(s(t,e))}),collectionOf("Set",setSize.call(e),w,f)}if(isWeakMap(e))return weakCollectionOf("WeakMap");if(isWeakSet(e))return weakCollectionOf("WeakSet");if(isWeakRef(e))return weakCollectionOf("WeakRef");if(isNumber(e))return markBoxed(s(Number(e)));if(isBigInt(e))return markBoxed(s(bigIntValueOf.call(e)));if(isBoolean(e))return markBoxed(booleanValueOf.call(e));if(isString(e))return markBoxed(s(String(e)));if("undefined"!=typeof window&&e===window)return"{ [object Window] }";if(e===global)return"{ [object globalThis] }";if(!isDate(e)&&!isRegExp(e)){var $=arrObjKeys(e,s),k=gPO?gPO(e)===Object.prototype:e instanceof Object||e.constructor===Object,v=e instanceof Object?"":"null prototype",T=!k&&toStringTag&&Object(e)===e&&toStringTag in e?$slice.call(toStr(e),8,-1):v?"Object":"",E=(k||"function"!=typeof e.constructor?"":e.constructor.name?e.constructor.name+" ":"")+(T||v?"["+$join.call($concat.call([],T||[],v||[]),": ")+"] ":"");return 0===$.length?E+"{}":f?E+"{"+indentedJoin($,f)+"}":E+"{ "+$join.call($,", ")+" }"}return String(e)};var hasOwn=Object.prototype.hasOwnProperty||function(t){return t in this};function has(t,e){return hasOwn.call(t,e)}function toStr(t){return objectToString.call(t)}function nameOf(t){if(t.name)return t.name;var e=$match.call(functionToString.call(t),/^function\s*([\w$]+)/);return e?e[1]:null}function indexOf(t,e){if(t.indexOf)return t.indexOf(e);for(var r=0,n=t.length;re.maxStringLength){var r=t.length-e.maxStringLength,n="... "+r+" more character"+(r>1?"s":"");return inspectString($slice.call(t,0,e.maxStringLength),e)+n}return wrapQuotes($replace.call($replace.call(t,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,lowbyte),"single",e)}function lowbyte(t){var e=t.charCodeAt(0),r={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return r?"\\"+r:"\\x"+(e<16?"0":"")+$toUpperCase.call(e.toString(16))}function markBoxed(t){return"Object("+t+")"}function weakCollectionOf(t){return t+" { ? }"}function collectionOf(t,e,r,n){return t+" ("+e+") {"+(n?indentedJoin(r,n):$join.call(r,", "))+"}"}function singleLineValues(t){for(var e=0;e=0)return!1;return!0}function getIndent(t,e){var r;if("\t"===t.indent)r="\t";else{if(!("number"==typeof t.indent&&t.indent>0))return null;r=$join.call(Array(t.indent+1)," ")}return{base:r,prev:$join.call(Array(e+1),r)}}function indentedJoin(t,e){if(0===t.length)return"";var r="\n"+e.prev+e.base;return r+$join.call(t,","+r)+"\n"+e.prev}function arrObjKeys(t,e){var r=isArray(t),n=[];if(r){n.length=t.length;for(var o=0;o-1e3&&t<1e3||$test.call(/e/,e))return e;var r=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof t){var n=t<0?-$floor(-t):$floor(t);if(n!==t){var o=String(n),a=$slice.call(e,o.length+1);return $replace.call(o,r,"$&_")+"."+$replace.call($replace.call(a,/([0-9]{3})/g,"$&_"),/_$/,"")}}return $replace.call(e,r,"$&_")}var utilInspect=require("./util.inspect"),inspectCustom=utilInspect.custom,inspectSymbol=isSymbol(inspectCustom)?inspectCustom:null;function wrapQuotes(t,e,r){var n="double"===(r.quoteStyle||e)?'"':"'";return n+t+n}function quote(t){return $replace.call(String(t),/"/g,""")}function isArray(t){return!("[object Array]"!==toStr(t)||toStringTag&&"object"==typeof t&&toStringTag in t)}function isDate(t){return!("[object Date]"!==toStr(t)||toStringTag&&"object"==typeof t&&toStringTag in t)}function isRegExp(t){return!("[object RegExp]"!==toStr(t)||toStringTag&&"object"==typeof t&&toStringTag in t)}function isError(t){return!("[object Error]"!==toStr(t)||toStringTag&&"object"==typeof t&&toStringTag in t)}function isString(t){return!("[object String]"!==toStr(t)||toStringTag&&"object"==typeof t&&toStringTag in t)}function isNumber(t){return!("[object Number]"!==toStr(t)||toStringTag&&"object"==typeof t&&toStringTag in t)}function isBoolean(t){return!("[object Boolean]"!==toStr(t)||toStringTag&&"object"==typeof t&&toStringTag in t)}function isSymbol(t){if(hasShammedSymbols)return t&&"object"==typeof t&&t instanceof Symbol;if("symbol"==typeof t)return!0;if(!t||"object"!=typeof t||!symToString)return!1;try{return symToString.call(t),!0}catch(t){}return!1}function isBigInt(t){if(!t||"object"!=typeof t||!bigIntValueOf)return!1;try{return bigIntValueOf.call(t),!0}catch(t){}return!1}module.exports=function t(e,r,n,o){var a=r||{};if(has(a,"quoteStyle")&&"single"!==a.quoteStyle&&"double"!==a.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(has(a,"maxStringLength")&&("number"==typeof a.maxStringLength?a.maxStringLength<0&&a.maxStringLength!==1/0:null!==a.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var i=!has(a,"customInspect")||a.customInspect;if("boolean"!=typeof i&&"symbol"!==i)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(has(a,"indent")&&null!==a.indent&&"\t"!==a.indent&&!(parseInt(a.indent,10)===a.indent&&a.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(has(a,"numericSeparator")&&"boolean"!=typeof a.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var l=a.numericSeparator;if(void 0===e)return"undefined";if(null===e)return"null";if("boolean"==typeof e)return e?"true":"false";if("string"==typeof e)return inspectString(e,a);if("number"==typeof e){if(0===e)return 1/0/e>0?"0":"-0";var c=String(e);return l?addNumericSeparator(e,c):c}if("bigint"==typeof e){var u=String(e)+"n";return l?addNumericSeparator(e,u):u}var p=void 0===a.depth?5:a.depth;if(void 0===n&&(n=0),n>=p&&p>0&&"object"==typeof e)return isArray(e)?"[Array]":"[Object]";var f=getIndent(a,n);if(void 0===o)o=[];else if(indexOf(o,e)>=0)return"[Circular]";function s(e,r,i){if(r&&(o=$arrSlice.call(o)).push(r),i){var l={depth:a.depth};return has(a,"quoteStyle")&&(l.quoteStyle=a.quoteStyle),t(e,l,n+1,o)}return t(e,a,n+1,o)}if("function"==typeof e&&!isRegExp(e)){var y=nameOf(e),S=arrObjKeys(e,s);return"[Function"+(y?": "+y:" (anonymous)")+"]"+(S.length>0?" { "+$join.call(S,", ")+" }":"")}if(isSymbol(e)){var g=hasShammedSymbols?$replace.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):symToString.call(e);return"object"!=typeof e||hasShammedSymbols?g:markBoxed(g)}if(isElement(e)){for(var b="<"+$toLowerCase.call(String(e.nodeName)),m=e.attributes||[],h=0;h"}if(isArray(e)){if(0===e.length)return"[]";var d=arrObjKeys(e,s);return f&&!singleLineValues(d)?"["+indentedJoin(d,f)+"]":"[ "+$join.call(d,", ")+" ]"}if(isError(e)){var j=arrObjKeys(e,s);return"cause"in Error.prototype||!("cause"in e)||isEnumerable.call(e,"cause")?0===j.length?"["+String(e)+"]":"{ ["+String(e)+"] "+$join.call(j,", ")+" }":"{ ["+String(e)+"] "+$join.call($concat.call("[cause]: "+s(e.cause),j),", ")+" }"}if("object"==typeof e&&i){if(inspectSymbol&&"function"==typeof e[inspectSymbol]&&utilInspect)return utilInspect(e,{depth:p-n});if("symbol"!==i&&"function"==typeof e.inspect)return e.inspect()}if(isMap(e)){var O=[];return mapForEach&&mapForEach.call(e,function(t,r){O.push(s(r,e,!0)+" => "+s(t,e))}),collectionOf("Map",mapSize.call(e),O,f)}if(isSet(e)){var w=[];return setForEach&&setForEach.call(e,function(t){w.push(s(t,e))}),collectionOf("Set",setSize.call(e),w,f)}if(isWeakMap(e))return weakCollectionOf("WeakMap");if(isWeakSet(e))return weakCollectionOf("WeakSet");if(isWeakRef(e))return weakCollectionOf("WeakRef");if(isNumber(e))return markBoxed(s(Number(e)));if(isBigInt(e))return markBoxed(s(bigIntValueOf.call(e)));if(isBoolean(e))return markBoxed(booleanValueOf.call(e));if(isString(e))return markBoxed(s(String(e)));if("undefined"!=typeof window&&e===window)return"{ [object Window] }";if("undefined"!=typeof globalThis&&e===globalThis||"undefined"!=typeof global&&e===global)return"{ [object globalThis] }";if(!isDate(e)&&!isRegExp(e)){var $=arrObjKeys(e,s),k=gPO?gPO(e)===Object.prototype:e instanceof Object||e.constructor===Object,v=e instanceof Object?"":"null prototype",T=!k&&toStringTag&&Object(e)===e&&toStringTag in e?$slice.call(toStr(e),8,-1):v?"Object":"",E=(k||"function"!=typeof e.constructor?"":e.constructor.name?e.constructor.name+" ":"")+(T||v?"["+$join.call($concat.call([],T||[],v||[]),": ")+"] ":"");return 0===$.length?E+"{}":f?E+"{"+indentedJoin($,f)+"}":E+"{ "+$join.call($,", ")+" }"}return String(e)};var hasOwn=Object.prototype.hasOwnProperty||function(t){return t in this};function has(t,e){return hasOwn.call(t,e)}function toStr(t){return objectToString.call(t)}function nameOf(t){if(t.name)return t.name;var e=$match.call(functionToString.call(t),/^function\s*([\w$]+)/);return e?e[1]:null}function indexOf(t,e){if(t.indexOf)return t.indexOf(e);for(var r=0,n=t.length;re.maxStringLength){var r=t.length-e.maxStringLength,n="... "+r+" more character"+(r>1?"s":"");return inspectString($slice.call(t,0,e.maxStringLength),e)+n}return wrapQuotes($replace.call($replace.call(t,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,lowbyte),"single",e)}function lowbyte(t){var e=t.charCodeAt(0),r={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return r?"\\"+r:"\\x"+(e<16?"0":"")+$toUpperCase.call(e.toString(16))}function markBoxed(t){return"Object("+t+")"}function weakCollectionOf(t){return t+" { ? }"}function collectionOf(t,e,r,n){return t+" ("+e+") {"+(n?indentedJoin(r,n):$join.call(r,", "))+"}"}function singleLineValues(t){for(var e=0;e=0)return!1;return!0}function getIndent(t,e){var r;if("\t"===t.indent)r="\t";else{if(!("number"==typeof t.indent&&t.indent>0))return null;r=$join.call(Array(t.indent+1)," ")}return{base:r,prev:$join.call(Array(e+1),r)}}function indentedJoin(t,e){if(0===t.length)return"";var r="\n"+e.prev+e.base;return r+$join.call(t,","+r)+"\n"+e.prev}function arrObjKeys(t,e){var r=isArray(t),n=[];if(r){n.length=t.length;for(var o=0;o=0;n--){var o=r[n];"."===o?r.splice(n,1):".."===o?(r.splice(n,1),e++):e&&(r.splice(n,1),e--)}if(t)for(;e--;e)r.unshift("..");return r}function basename(r){"string"!=typeof r&&(r+="");var t,e=0,n=-1,o=!0;for(t=r.length-1;t>=0;--t)if(47===r.charCodeAt(t)){if(!o){e=t+1;break}}else-1===n&&(o=!1,n=t+1);return-1===n?"":r.slice(e,n)}function filter(r,t){if(r.filter)return r.filter(t);for(var e=[],n=0;n=-1&&!t;e--){var n=e>=0?arguments[e]:process.cwd();if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");n&&(r=n+"/"+r,t="/"===n.charAt(0))}return(t?"/":"")+(r=normalizeArray(filter(r.split("/"),function(r){return!!r}),!t).join("/"))||"."},exports.normalize=function(r){var t=exports.isAbsolute(r),e="/"===substr(r,-1);return(r=normalizeArray(filter(r.split("/"),function(r){return!!r}),!t).join("/"))||t||(r="."),r&&e&&(r+="/"),(t?"/":"")+r},exports.isAbsolute=function(r){return"/"===r.charAt(0)},exports.join=function(){var r=Array.prototype.slice.call(arguments,0);return exports.normalize(filter(r,function(r,t){if("string"!=typeof r)throw new TypeError("Arguments to path.join must be strings");return r}).join("/"))},exports.relative=function(r,t){function e(r){for(var t=0;t=0&&""===r[e];e--);return t>e?[]:r.slice(t,e-t+1)}r=exports.resolve(r).substr(1),t=exports.resolve(t).substr(1);for(var n=e(r.split("/")),o=e(t.split("/")),s=Math.min(n.length,o.length),i=s,u=0;u=1;--s)if(47===(t=r.charCodeAt(s))){if(!o){n=s;break}}else o=!1;return-1===n?e?"/":".":e&&1===n?"/":r.slice(0,n)},exports.basename=function(r,t){var e=basename(r);return t&&e.substr(-1*t.length)===t&&(e=e.substr(0,e.length-t.length)),e},exports.extname=function(r){"string"!=typeof r&&(r+="");for(var t=-1,e=0,n=-1,o=!0,s=0,i=r.length-1;i>=0;--i){var u=r.charCodeAt(i);if(47!==u)-1===n&&(o=!1,n=i+1),46===u?-1===t?t=i:1!==s&&(s=1):-1!==t&&(s=-1);else if(!o){e=i+1;break}}return-1===t||-1===n||0===s||1===s&&t===n-1&&t===e+1?"":r.slice(t,n)};var substr="b"==="ab".substr(-1)?function(r,t,e){return r.substr(t,e)}:function(r,t,e){return t<0&&(t=r.length+t),r.substr(t,e)}; }).call(this)}).call(this,require('_process')) -},{"_process":713}],713:[function(require,module,exports){ +},{"_process":714}],714:[function(require,module,exports){ var cachedSetTimeout,cachedClearTimeout,process=module.exports={};function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}function runTimeout(e){if(cachedSetTimeout===setTimeout)return setTimeout(e,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(e,0);try{return cachedSetTimeout(e,0)}catch(t){try{return cachedSetTimeout.call(null,e,0)}catch(t){return cachedSetTimeout.call(this,e,0)}}}function runClearTimeout(e){if(cachedClearTimeout===clearTimeout)return clearTimeout(e);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(e);try{return cachedClearTimeout(e)}catch(t){try{return cachedClearTimeout.call(null,e)}catch(t){return cachedClearTimeout.call(this,e)}}}!function(){try{cachedSetTimeout="function"==typeof setTimeout?setTimeout:defaultSetTimout}catch(e){cachedSetTimeout=defaultSetTimout}try{cachedClearTimeout="function"==typeof clearTimeout?clearTimeout:defaultClearTimeout}catch(e){cachedClearTimeout=defaultClearTimeout}}();var currentQueue,queue=[],draining=!1,queueIndex=-1;function cleanUpNextTick(){draining&¤tQueue&&(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var e=runTimeout(cleanUpNextTick);draining=!0;for(var t=queue.length;t;){for(currentQueue=queue,queue=[];++queueIndex1)for(var r=1;r= 0x80 (not a basic code point)","invalid-input":"Invalid input"},b=f-c,y=Math.floor,C=String.fromCharCode;function m(e){throw new RangeError(x[e])}function j(e,o){for(var n=e.length,t=[];n--;)t[n]=o(e[n]);return t}function A(e,o){var n=e.split("@"),t="";return n.length>1&&(t=n[0]+"@",e=n[1]),t+j((e=e.replace(w,".")).split("."),o).join(".")}function I(e){for(var o,n,t=[],r=0,u=e.length;r=55296&&o<=56319&&r65535&&(o+=C((e-=65536)>>>10&1023|55296),e=56320|1023&e),o+=C(e)}).join("")}function F(e,o){return e+22+75*(e<26)-((0!=o)<<5)}function O(e,o,n){var t=0;for(e=n?y(e/d):e>>1,e+=y(e/o);e>b*l>>1;t+=f)e=y(e/b);return y(t+(b+1)*e/(e+s))}function S(e){var o,n,t,r,u,s,d,v,g,w,x,b=[],C=e.length,j=0,A=a,I=p;for((n=e.lastIndexOf(h))<0&&(n=0),t=0;t=128&&m("not-basic"),b.push(e.charCodeAt(t));for(r=n>0?n+1:0;r=C&&m("invalid-input"),((v=(x=e.charCodeAt(r++))-48<10?x-22:x-65<26?x-65:x-97<26?x-97:f)>=f||v>y((i-j)/s))&&m("overflow"),j+=v*s,!(v<(g=d<=I?c:d>=I+l?l:d-I));d+=f)s>y(i/(w=f-g))&&m("overflow"),s*=w;I=O(j-u,o=b.length+1,0==u),y(j/o)>i-A&&m("overflow"),A+=y(j/o),j%=o,b.splice(j++,0,A)}return E(b)}function T(e){var o,n,t,r,u,s,d,v,g,w,x,b,j,A,E,S=[];for(b=(e=I(e)).length,o=a,n=0,u=p,s=0;s=o&&xy((i-n)/(j=t+1))&&m("overflow"),n+=(d-o)*j,o=d,s=0;si&&m("overflow"),x==o){for(v=n,g=f;!(v<(w=g<=u?c:g>=u+l?l:g-u));g+=f)E=v-w,A=f-w,S.push(C(F(w+E%A,0))),v=y(E/A);S.push(C(F(v,0))),u=O(n,j,t==r),n=0,++t}++n,++o}return S.join("")}if(r={version:"1.4.1",ucs2:{decode:I,encode:E},decode:S,encode:T,toASCII:function(e){return A(e,function(e){return g.test(e)?"xn--"+T(e):e})},toUnicode:function(e){return A(e,function(e){return v.test(e)?S(e.slice(4).toLowerCase()):e})}},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return r});else if(o&&n)if(module.exports==o)n.exports=r;else for(u in r)r.hasOwnProperty(u)&&(o[u]=r[u]);else e.punycode=r}(this); }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],715:[function(require,module,exports){ +},{}],716:[function(require,module,exports){ "use strict";var replace=String.prototype.replace,percentTwenties=/%20/g,Format={RFC1738:"RFC1738",RFC3986:"RFC3986"};module.exports={default:Format.RFC3986,formatters:{RFC1738:function(e){return replace.call(e,percentTwenties,"+")},RFC3986:function(e){return String(e)}},RFC1738:Format.RFC1738,RFC3986:Format.RFC3986}; -},{}],716:[function(require,module,exports){ +},{}],717:[function(require,module,exports){ "use strict";var stringify=require("./stringify"),parse=require("./parse"),formats=require("./formats");module.exports={formats:formats,parse:parse,stringify:stringify}; -},{"./formats":715,"./parse":717,"./stringify":718}],717:[function(require,module,exports){ -"use strict";var utils=require("./utils"),has=Object.prototype.hasOwnProperty,isArray=Array.isArray,defaults={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:utils.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},interpretNumericEntities=function(e){return e.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})},parseArrayValue=function(e,t){return e&&"string"==typeof e&&t.comma&&e.indexOf(",")>-1?e.split(","):e},isoSentinel="utf8=%26%2310003%3B",charsetSentinel="utf8=%E2%9C%93",parseValues=function(e,t){var r,a={__proto__:null},o=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,i=t.parameterLimit===1/0?void 0:t.parameterLimit,l=o.split(t.delimiter,i),s=-1,n=t.charset;if(t.charsetSentinel)for(r=0;r-1&&(c=isArray(c)?[c]:c);var y=has.call(a,p);y&&"combine"===t.duplicates?a[p]=utils.combine(a[p],c):y&&"last"!==t.duplicates||(a[p]=c)}return a},parseObject=function(e,t,r,a){for(var o=a?t:parseArrayValue(t,r),i=e.length-1;i>=0;--i){var l,s=e[i];if("[]"===s&&r.parseArrays)l=r.allowEmptyArrays&&""===o?[]:[].concat(o);else{l=r.plainObjects?Object.create(null):{};var n="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,p=r.decodeDotInKeys?n.replace(/%2E/g,"."):n,c=parseInt(p,10);r.parseArrays||""!==p?!isNaN(c)&&s!==p&&String(c)===p&&c>=0&&r.parseArrays&&c<=r.arrayLimit?(l=[])[c]=o:"__proto__"!==p&&(l[p]=o):l={0:o}}o=l}return o},parseKeys=function(e,t,r,a){if(e){var o=r.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,l=r.depth>0&&/(\[[^[\]]*])/.exec(o),s=l?o.slice(0,l.index):o,n=[];if(s){if(!r.plainObjects&&has.call(Object.prototype,s)&&!r.allowPrototypes)return;n.push(s)}for(var p=0;r.depth>0&&null!==(l=i.exec(o))&&p-1?e.split(","):e},isoSentinel="utf8=%26%2310003%3B",charsetSentinel="utf8=%E2%9C%93",parseValues=function(e,t){var r={__proto__:null},a=t.ignoreQueryPrefix?e.replace(/^\?/,""):e;a=a.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var i,o=t.parameterLimit===1/0?void 0:t.parameterLimit,l=a.split(t.delimiter,o),s=-1,n=t.charset;if(t.charsetSentinel)for(i=0;i-1&&(c=isArray(c)?[c]:c);var y=has.call(r,p);y&&"combine"===t.duplicates?r[p]=utils.combine(r[p],c):y&&"last"!==t.duplicates||(r[p]=c)}return r},parseObject=function(e,t,r,a){for(var i=a?t:parseArrayValue(t,r),o=e.length-1;o>=0;--o){var l,s=e[o];if("[]"===s&&r.parseArrays)l=r.allowEmptyArrays&&(""===i||r.strictNullHandling&&null===i)?[]:[].concat(i);else{l=r.plainObjects?Object.create(null):{};var n="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,p=r.decodeDotInKeys?n.replace(/%2E/g,"."):n,c=parseInt(p,10);r.parseArrays||""!==p?!isNaN(c)&&s!==p&&String(c)===p&&c>=0&&r.parseArrays&&c<=r.arrayLimit?(l=[])[c]=i:"__proto__"!==p&&(l[p]=i):l={0:i}}i=l}return i},parseKeys=function(e,t,r,a){if(e){var i=r.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/g,l=r.depth>0&&/(\[[^[\]]*])/.exec(i),s=l?i.slice(0,l.index):i,n=[];if(s){if(!r.plainObjects&&has.call(Object.prototype,s)&&!r.allowPrototypes)return;n.push(s)}for(var p=0;r.depth>0&&null!==(l=o.exec(i))&&p0?b.join(",")||null:void 0}];else if(isArray(u))N=u;else{var T=Object.keys(b);N=d?T.sort(d):T}var O=s?t.replace(/\./g,"%2E"):t,k=a&&isArray(b)&&1===b.length?O+"[]":O;if(n&&isArray(b)&&0===b.length)return k+"[]";for(var I=0;I0?y+d:""}; -},{"./formats":715,"./utils":719,"side-channel":721}],719:[function(require,module,exports){ +},{"./formats":716,"./utils":720,"side-channel":722}],720:[function(require,module,exports){ "use strict";var formats=require("./formats"),has=Object.prototype.hasOwnProperty,isArray=Array.isArray,hexTable=function(){for(var e=[],r=0;r<256;++r)e.push("%"+((r<16?"0":"")+r.toString(16)).toUpperCase());return e}(),compactQueue=function(e){for(;e.length>1;){var r=e.pop(),t=r.obj[r.prop];if(isArray(t)){for(var o=[],n=0;n=limit?a.slice(i,i+limit):a,f=[],p=0;p=48&&s<=57||s>=65&&s<=90||s>=97&&s<=122||n===formats.RFC1738&&(40===s||41===s)?f[f.length]=u.charAt(p):s<128?f[f.length]=hexTable[s]:s<2048?f[f.length]=hexTable[192|s>>6]+hexTable[128|63&s]:s<55296||s>=57344?f[f.length]=hexTable[224|s>>12]+hexTable[128|s>>6&63]+hexTable[128|63&s]:(p+=1,s=65536+((1023&s)<<10|1023&u.charCodeAt(p)),f[f.length]=hexTable[240|s>>18]+hexTable[128|s>>12&63]+hexTable[128|s>>6&63]+hexTable[128|63&s])}c+=f.join("")}return c},compact=function(e){for(var r=[{obj:{o:e},prop:"o"}],t=[],o=0;o4294967295||$floor(r)!==r)throw new $TypeError("`length` must be a positive 32-bit integer");var t=arguments.length>2&&!!arguments[2],i=!0,n=!0;if("length"in e&&gOPD){var o=gOPD(e,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(n=!1)}return(i||n||!t)&&(hasDescriptors?define(e,"length",r,!0,!0):define(e,"length",r)),e}; -},{"define-data-property":692,"es-errors/type":699,"get-intrinsic":703,"gopd":704,"has-property-descriptors":705}],721:[function(require,module,exports){ +},{"define-data-property":693,"es-errors/type":700,"get-intrinsic":704,"gopd":705,"has-property-descriptors":706}],722:[function(require,module,exports){ "use strict";var GetIntrinsic=require("get-intrinsic"),callBound=require("call-bind/callBound"),inspect=require("object-inspect"),$TypeError=require("es-errors/type"),$WeakMap=GetIntrinsic("%WeakMap%",!0),$Map=GetIntrinsic("%Map%",!0),$weakMapGet=callBound("WeakMap.prototype.get",!0),$weakMapSet=callBound("WeakMap.prototype.set",!0),$weakMapHas=callBound("WeakMap.prototype.has",!0),$mapGet=callBound("Map.prototype.get",!0),$mapSet=callBound("Map.prototype.set",!0),$mapHas=callBound("Map.prototype.has",!0),listGetNode=function(e,t){for(var a,n=e;null!==(a=n.next);n=a)if(a.key===t)return n.next=a.next,a.next=e.next,e.next=a,a},listGet=function(e,t){var a=listGetNode(e,t);return a&&a.value},listSet=function(e,t,a){var n=listGetNode(e,t);n?n.value=a:e.next={key:t,next:e.next,value:a}},listHas=function(e,t){return!!listGetNode(e,t)};module.exports=function(){var e,t,a,n={assert:function(e){if(!n.has(e))throw new $TypeError("Side channel does not contain "+inspect(e))},get:function(n){if($WeakMap&&n&&("object"==typeof n||"function"==typeof n)){if(e)return $weakMapGet(e,n)}else if($Map){if(t)return $mapGet(t,n)}else if(a)return listGet(a,n)},has:function(n){if($WeakMap&&n&&("object"==typeof n||"function"==typeof n)){if(e)return $weakMapHas(e,n)}else if($Map){if(t)return $mapHas(t,n)}else if(a)return listHas(a,n);return!1},set:function(n,r){$WeakMap&&n&&("object"==typeof n||"function"==typeof n)?(e||(e=new $WeakMap),$weakMapSet(e,n,r)):$Map?(t||(t=new $Map),$mapSet(t,n,r)):(a||(a={key:{},next:null}),listSet(a,n,r))}};return n}; -},{"call-bind/callBound":690,"es-errors/type":699,"get-intrinsic":703,"object-inspect":711}],722:[function(require,module,exports){ -"use strict";var punycode=require("punycode");function Url(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var protocolPattern=/^([a-z0-9.+-]+:)/i,portPattern=/:[0-9]*$/,simplePathPattern=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,delims=["<",">",'"',"`"," ","\r","\n","\t"],unwise=["{","}","|","\\","^","`"].concat(delims),autoEscape=["'"].concat(unwise),nonHostChars=["%","/","?",";","#"].concat(autoEscape),hostEndingChars=["/","?","#"],hostnameMaxLen=255,hostnamePartPattern=/^[+a-z0-9A-Z_-]{0,63}$/,hostnamePartStart=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,unsafeProtocol={javascript:!0,"javascript:":!0},hostlessProtocol={javascript:!0,"javascript:":!0},slashedProtocol={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},querystring=require("qs");function urlParse(t,s,e){if(t&&"object"==typeof t&&t instanceof Url)return t;var h=new Url;return h.parse(t,s,e),h}function urlFormat(t){return"string"==typeof t&&(t=urlParse(t)),t instanceof Url?t.format():Url.prototype.format.call(t)}function urlResolve(t,s){return urlParse(t,!1,!0).resolve(s)}function urlResolveObject(t,s){return t?urlParse(t,!1,!0).resolveObject(s):s}Url.prototype.parse=function(t,s,e){if("string"!=typeof t)throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var h=t.indexOf("?"),r=-1!==h&&h127?b+="x":b+=d[q];if(!b.match(hostnamePartPattern)){var j=g.slice(0,m),O=g.slice(m+1),U=d.match(hostnamePartStart);U&&(j.push(U[1]),O.unshift(U[2])),O.length&&(o="/"+O.join(".")+o),this.hostname=j.join(".");break}}}this.hostname.length>hostnameMaxLen?this.hostname="":this.hostname=this.hostname.toLowerCase(),y||(this.hostname=punycode.toASCII(this.hostname));var C=this.port?":"+this.port:"",A=this.hostname||"";this.host=A+C,this.href+=this.host,y&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==o[0]&&(o="/"+o))}if(!unsafeProtocol[l])for(m=0,P=autoEscape.length;m0)&&e.host.split("@"))&&(e.auth=U.shift(),e.hostname=U.shift(),e.host=e.hostname);return e.search=t.search,e.query=t.query,null===e.pathname&&null===e.search||(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.href=e.format(),e}if(!d.length)return e.pathname=null,e.search?e.path="/"+e.search:e.path=null,e.href=e.format(),e;for(var q=d.slice(-1)[0],x=(e.host||t.host||d.length>1)&&("."===q||".."===q)||""===q,j=0,O=d.length;O>=0;O--)"."===(q=d[O])?d.splice(O,1):".."===q?(d.splice(O,1),j++):j&&(d.splice(O,1),j--);if(!g&&!P)for(;j--;j)d.unshift("..");!g||""===d[0]||d[0]&&"/"===d[0].charAt(0)||d.unshift(""),x&&"/"!==d.join("/").substr(-1)&&d.push("");var U,C=""===d[0]||d[0]&&"/"===d[0].charAt(0);b&&(e.hostname=C?"":d.length?d.shift():"",e.host=e.hostname,(U=!!(e.host&&e.host.indexOf("@")>0)&&e.host.split("@"))&&(e.auth=U.shift(),e.hostname=U.shift(),e.host=e.hostname));return(g=g||e.host&&d.length)&&!C&&d.unshift(""),d.length>0?e.pathname=d.join("/"):(e.pathname=null,e.path=null),null===e.pathname&&null===e.search||(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.auth=t.auth||e.auth,e.slashes=e.slashes||t.slashes,e.href=e.format(),e},Url.prototype.parseHost=function(){var t=this.host,s=portPattern.exec(t);s&&(":"!==(s=s[0])&&(this.port=s.substr(1)),t=t.substr(0,t.length-s.length)),t&&(this.hostname=t)},exports.parse=urlParse,exports.resolve=urlResolve,exports.resolveObject=urlResolveObject,exports.format=urlFormat,exports.Url=Url; +},{"call-bind/callBound":691,"es-errors/type":700,"get-intrinsic":704,"object-inspect":712}],723:[function(require,module,exports){ +"use strict";var punycode=require("punycode/");function Url(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var protocolPattern=/^([a-z0-9.+-]+:)/i,portPattern=/:[0-9]*$/,simplePathPattern=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,delims=["<",">",'"',"`"," ","\r","\n","\t"],unwise=["{","}","|","\\","^","`"].concat(delims),autoEscape=["'"].concat(unwise),nonHostChars=["%","/","?",";","#"].concat(autoEscape),hostEndingChars=["/","?","#"],hostnameMaxLen=255,hostnamePartPattern=/^[+a-z0-9A-Z_-]{0,63}$/,hostnamePartStart=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,unsafeProtocol={javascript:!0,"javascript:":!0},hostlessProtocol={javascript:!0,"javascript:":!0},slashedProtocol={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},querystring=require("qs");function urlParse(t,s,e){if(t&&"object"==typeof t&&t instanceof Url)return t;var h=new Url;return h.parse(t,s,e),h}function urlFormat(t){return"string"==typeof t&&(t=urlParse(t)),t instanceof Url?t.format():Url.prototype.format.call(t)}function urlResolve(t,s){return urlParse(t,!1,!0).resolve(s)}function urlResolveObject(t,s){return t?urlParse(t,!1,!0).resolveObject(s):s}Url.prototype.parse=function(t,s,e){if("string"!=typeof t)throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var h=t.indexOf("?"),r=-1!==h&&h127?b+="x":b+=d[q];if(!b.match(hostnamePartPattern)){var j=g.slice(0,m),O=g.slice(m+1),U=d.match(hostnamePartStart);U&&(j.push(U[1]),O.unshift(U[2])),O.length&&(o="/"+O.join(".")+o),this.hostname=j.join(".");break}}}this.hostname.length>hostnameMaxLen?this.hostname="":this.hostname=this.hostname.toLowerCase(),y||(this.hostname=punycode.toASCII(this.hostname));var C=this.port?":"+this.port:"",A=this.hostname||"";this.host=A+C,this.href+=this.host,y&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==o[0]&&(o="/"+o))}if(!unsafeProtocol[l])for(m=0,P=autoEscape.length;m0)&&e.host.split("@"))&&(e.auth=U.shift(),e.hostname=U.shift(),e.host=e.hostname);return e.search=t.search,e.query=t.query,null===e.pathname&&null===e.search||(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.href=e.format(),e}if(!d.length)return e.pathname=null,e.search?e.path="/"+e.search:e.path=null,e.href=e.format(),e;for(var q=d.slice(-1)[0],x=(e.host||t.host||d.length>1)&&("."===q||".."===q)||""===q,j=0,O=d.length;O>=0;O--)"."===(q=d[O])?d.splice(O,1):".."===q?(d.splice(O,1),j++):j&&(d.splice(O,1),j--);if(!g&&!P)for(;j--;j)d.unshift("..");!g||""===d[0]||d[0]&&"/"===d[0].charAt(0)||d.unshift(""),x&&"/"!==d.join("/").substr(-1)&&d.push("");var U,C=""===d[0]||d[0]&&"/"===d[0].charAt(0);b&&(e.hostname=C?"":d.length?d.shift():"",e.host=e.hostname,(U=!!(e.host&&e.host.indexOf("@")>0)&&e.host.split("@"))&&(e.auth=U.shift(),e.hostname=U.shift(),e.host=e.hostname));return(g=g||e.host&&d.length)&&!C&&d.unshift(""),d.length>0?e.pathname=d.join("/"):(e.pathname=null,e.path=null),null===e.pathname&&null===e.search||(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.auth=t.auth||e.auth,e.slashes=e.slashes||t.slashes,e.href=e.format(),e},Url.prototype.parseHost=function(){var t=this.host,s=portPattern.exec(t);s&&(":"!==(s=s[0])&&(this.port=s.substr(1)),t=t.substr(0,t.length-s.length)),t&&(this.hostname=t)},exports.parse=urlParse,exports.resolve=urlResolve,exports.resolveObject=urlResolveObject,exports.format=urlFormat,exports.Url=Url; -},{"punycode":714,"qs":716}],723:[function(require,module,exports){ +},{"punycode/":715,"qs":717}],724:[function(require,module,exports){ !function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(t){var e=t.Pos;function r(t,e){for(var r=0,n=t.length;rs.ch&&(a.end=s.ch,a.string=a.string.slice(0,s.ch-a.start)):a={start:s.ch,end:s.ch,string:"",state:a.state,type:"."==a.string?"property":null};for(var f=a;"property"==f.type;){if("."!=(f=i(r,e(s.line,f.start))).string)return;if(f=i(r,e(s.line,f.start)),!p)var p=[];p.push(f)}return{list:c(a,p,n,o),from:e(s.line,a.start),to:e(s.line,a.end)}}}}function i(t,e){var r=t.getTokenAt(e);return e.ch==r.start+1&&"."==r.string.charAt(0)?(r.end=r.start,r.string=".",r.type="property"):/^\.[\w$_]*$/.test(r.string)&&(r.type="property",r.start++,r.string=r.string.replace(/\./,"")),r}t.registerHelper("hint","javascript",function(t,e){return n(t,l,function(t,e){return t.getTokenAt(e)},e)}),t.registerHelper("hint","coffeescript",function(t,e){return n(t,f,i,e)});var o="charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight toUpperCase toLowerCase split concat match replace search".split(" "),s="length concat join splice push pop shift unshift slice reverse sort indexOf lastIndexOf every some filter forEach map reduce reduceRight ".split(" "),a="prototype apply call bind".split(" "),l="break case catch class const continue debugger default delete do else export extends false finally for function if in import instanceof new null return super switch this throw true try typeof var void while with yield".split(" "),f="and break catch class continue delete do else extends false finally for if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes".split(" ");function c(t,e,n,i){var l=[],f=t.string,c=i&&i.globalScope||window;function p(t){0!=t.lastIndexOf(f,0)||function(t,e){if(!Array.prototype.indexOf){for(var r=t.length;r--;)if(t[r]===e)return!0;return!1}return-1!=t.indexOf(e)}(l,t)||l.push(t)}function u(t){"string"==typeof t?r(o,p):t instanceof Array?r(s,p):t instanceof Function&&r(a,p),function(t,e){if(Object.getOwnPropertyNames&&Object.getPrototypeOf)for(var r=t;r;r=Object.getPrototypeOf(r))Object.getOwnPropertyNames(r).forEach(e);else for(var n in t)e(n)}(t,p)}if(e&&e.length){var d,g=e.pop();for(g.type&&0===g.type.indexOf("variable")?(i&&i.additionalContext&&(d=i.additionalContext[g.string]),i&&!1===i.useGlobalScope||(d=d||c[g.string])):"string"==g.type?d="":"atom"==g.type?d=1:"function"==g.type&&(null==c.jQuery||"$"!=g.string&&"jQuery"!=g.string||"function"!=typeof c.jQuery?null!=c._&&"_"==g.string&&"function"==typeof c._&&(d=c._()):d=c.jQuery());null!=d&&e.length;)d=d[e.pop().string];null!=d&&u(d)}else{for(var y=t.state.localVars;y;y=y.next)p(y.name);for(var h=t.state.context;h;h=h.prev)for(y=h.vars;y;y=y.next)p(y.name);for(y=t.state.globalVars;y;y=y.next)p(y.name);if(i&&null!=i.additionalContext)for(var v in i.additionalContext)p(v);i&&!1===i.useGlobalScope||u(c),r(n,p)}return l}}); -},{"../../lib/codemirror":724}],724:[function(require,module,exports){ +},{"../../lib/codemirror":725}],725:[function(require,module,exports){ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).CodeMirror=t()}(this,function(){"use strict";var e=navigator.userAgent,t=navigator.platform,r=/gecko\/\d/i.test(e),n=/MSIE \d/.test(e),i=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(e),o=/Edge\/(\d+)/.exec(e),l=n||i||o,s=l&&(n?document.documentMode||6:+(o||i)[1]),a=!o&&/WebKit\//.test(e),u=a&&/Qt\/\d+\.\d+/.test(e),c=!o&&/Chrome\//.test(e),h=/Opera\//.test(e),f=/Apple Computer/.test(navigator.vendor),d=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(e),p=/PhantomJS/.test(e),g=f&&(/Mobile\/\w+/.test(e)||navigator.maxTouchPoints>2),v=/Android/.test(e),m=g||v||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(e),y=g||/Mac/.test(t),b=/\bCrOS\b/.test(e),w=/win/i.test(t),x=h&&e.match(/Version\/(\d*\.\d*)/);x&&(x=Number(x[1])),x&&x>=15&&(h=!1,a=!0);var C=y&&(u||h&&(null==x||x<12.11)),S=r||l&&s>=9;function L(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var k,T=function(e,t){var r=e.className,n=L(t).exec(r);if(n){var i=r.slice(n.index+n[0].length);e.className=r.slice(0,n.index)+(i?n[1]+i:"")}};function M(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function N(e,t){return M(e).appendChild(t)}function O(e,t,r,n){var i=document.createElement(e);if(r&&(i.className=r),n&&(i.style.cssText=n),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o=t)return l+(t-o);l+=s-o,l+=r-l%r,o=s+1}}g?P=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:l&&(P=function(e){try{e.select()}catch(e){}});var z=function(){this.id=null,this.f=null,this.time=0,this.handler=E(this.onTimeout,this)};function B(e,t){for(var r=0;r=t)return n+Math.min(l,t-i);if(i+=o-n,n=o+1,(i+=r-i%r)>=t)return n}}var Y=[""];function $(e){for(;Y.length<=e;)Y.push(_(Y)+" ");return Y[e]}function _(e){return e[e.length-1]}function q(e,t){for(var r=[],n=0;n"€"&&(e.toUpperCase()!=e.toLowerCase()||J.test(e))}function te(e,t){return t?!!(t.source.indexOf("\\w")>-1&&ee(e))||t.test(e):ee(e)}function re(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var ne=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;function ie(e){return e.charCodeAt(0)>=768&&ne.test(e)}function oe(e,t,r){for(;(r<0?t>0:tr?-1:1;;){if(t==r)return t;var i=(t+r)/2,o=n<0?Math.ceil(i):Math.floor(i);if(o==t)return e(o)?t:r;e(o)?r=o:t=o+n}}var se=null;function ae(e,t,r){var n;se=null;for(var i=0;it)return i;o.to==t&&(o.from!=o.to&&"before"==r?n=i:se=i),o.from==t&&(o.from!=o.to&&"before"!=r?n=i:se=i)}return null!=n?n:se}var ue=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,n=/[stwN]/,i=/[LRr]/,o=/[Lb1n]/,l=/[1n]/;function s(e,t,r){this.level=e,this.from=t,this.to=r}return function(a,u){var c="ltr"==u?"L":"R";if(0==a.length||"ltr"==u&&!r.test(a))return!1;for(var h,f=a.length,d=[],p=0;p-1&&(n[t]=i.slice(0,o).concat(i.slice(o+1)))}}}function ge(e,t){var r=de(e,t);if(r.length)for(var n=Array.prototype.slice.call(arguments,2),i=0;i0}function be(e){e.prototype.on=function(e,t){fe(this,e,t)},e.prototype.off=function(e,t){pe(this,e,t)}}function we(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function xe(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function Ce(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function Se(e){we(e),xe(e)}function Le(e){return e.target||e.srcElement}function ke(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),y&&e.ctrlKey&&1==t&&(t=3),t}var Te,Me,Ne=function(){if(l&&s<9)return!1;var e=O("div");return"draggable"in e||"dragDrop"in e}();function Oe(e){if(null==Te){var t=O("span","​");N(e,O("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(Te=t.offsetWidth<=1&&t.offsetHeight>2&&!(l&&s<8))}var r=Te?O("span","​"):O("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return r.setAttribute("cm-text",""),r}function Ae(e){if(null!=Me)return Me;var t=N(e,document.createTextNode("AخA")),r=k(t,0,1).getBoundingClientRect(),n=k(t,1,2).getBoundingClientRect();return M(e),!(!r||r.left==r.right)&&(Me=n.right-r.right<3)}var De,We=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,r=[],n=e.length;t<=n;){var i=e.indexOf("\n",t);-1==i&&(i=e.length);var o=e.slice(t,"\r"==e.charAt(i-1)?i-1:i),l=o.indexOf("\r");-1!=l?(r.push(o.slice(0,l)),t+=l+1):(r.push(o),t=i+1)}return r}:function(e){return e.split(/\r\n?|\n/)},He=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(e){return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(e){}return!(!t||t.parentElement()!=e)&&0!=t.compareEndPoints("StartToEnd",t)},Fe="oncopy"in(De=O("div"))||(De.setAttribute("oncopy","return;"),"function"==typeof De.oncopy),Pe=null;var Ee={},Ie={};function Re(e){if("string"==typeof e&&Ie.hasOwnProperty(e))e=Ie[e];else if(e&&"string"==typeof e.name&&Ie.hasOwnProperty(e.name)){var t=Ie[e.name];"string"==typeof t&&(t={name:t}),(e=Q(t,e)).name=t.name}else{if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return Re("application/xml");if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Re("application/json")}return"string"==typeof e?{name:e}:e||{name:"null"}}function ze(e,t){t=Re(t);var r=Ee[t.name];if(!r)return ze(e,"text/plain");var n=r(e,t);if(Be.hasOwnProperty(t.name)){var i=Be[t.name];for(var o in i)i.hasOwnProperty(o)&&(n.hasOwnProperty(o)&&(n["_"+o]=n[o]),n[o]=i[o])}if(n.name=t.name,t.helperType&&(n.helperType=t.helperType),t.modeProps)for(var l in t.modeProps)n[l]=t.modeProps[l];return n}var Be={};function Ge(e,t){I(t,Be.hasOwnProperty(e)?Be[e]:Be[e]={})}function Ue(e,t){if(!0===t)return t;if(e.copyState)return e.copyState(t);var r={};for(var n in t){var i=t[n];i instanceof Array&&(i=i.concat([])),r[n]=i}return r}function Ve(e,t){for(var r;e.innerMode&&(r=e.innerMode(t))&&r.mode!=e;)t=r.state,e=r.mode;return r||{mode:e,state:t}}function Ke(e,t,r){return!e.startState||e.startState(t,r)}var je=function(e,t,r){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=r};function Xe(e,t){if((t-=e.first)<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var r=e;!r.lines;)for(var n=0;;++n){var i=r.children[n],o=i.chunkSize();if(t=e.first&&tr?et(r,Xe(e,r).text.length):function(e,t){var r=e.ch;return null==r||r>t?et(e.line,t):r<0?et(e.line,0):e}(t,Xe(e,t.line).text.length)}function at(e,t){for(var r=[],n=0;n=this.string.length},je.prototype.sol=function(){return this.pos==this.lineStart},je.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},je.prototype.next=function(){if(this.post},je.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},je.prototype.skipToEnd=function(){this.pos=this.string.length},je.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},je.prototype.backUp=function(e){this.pos-=e},je.prototype.column=function(){return this.lastColumnPos0?null:(n&&!1!==t&&(this.pos+=n[0].length),n)}var i=function(e){return r?e.toLowerCase():e};if(i(this.string.substr(this.pos,e.length))==i(e))return!1!==t&&(this.pos+=e.length),!0},je.prototype.current=function(){return this.string.slice(this.start,this.pos)},je.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},je.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},je.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};var ut=function(e,t){this.state=e,this.lookAhead=t},ct=function(e,t,r,n){this.state=t,this.doc=e,this.line=r,this.maxLookAhead=n||0,this.baseTokens=null,this.baseTokenPos=1};function ht(e,t,r,n){var i=[e.state.modeGen],o={};wt(e,t.text,e.doc.mode,r,function(e,t){return i.push(e,t)},o,n);for(var l=r.state,s=function(n){r.baseTokens=i;var s=e.state.overlays[n],a=1,u=0;r.state=!0,wt(e,t.text,s.mode,r,function(e,t){for(var r=a;ue&&i.splice(a,1,e,i[a+1],n),a+=2,u=Math.min(e,n)}if(t)if(s.opaque)i.splice(r,a-r,e,"overlay "+t),a=r+2;else for(;re.options.maxHighlightLength&&Ue(e.doc.mode,n.state),o=ht(e,t,n);i&&(n.state=i),t.stateAfter=n.save(!i),t.styles=o.styles,o.classes?t.styleClasses=o.classes:t.styleClasses&&(t.styleClasses=null),r===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))}return t.styles}function dt(e,t,r){var n=e.doc,i=e.display;if(!n.mode.startState)return new ct(n,!0,t);var o=function(e,t,r){for(var n,i,o=e.doc,l=r?-1:t-(e.doc.mode.innerMode?1e3:100),s=t;s>l;--s){if(s<=o.first)return o.first;var a=Xe(o,s-1),u=a.stateAfter;if(u&&(!r||s+(u instanceof ut?u.lookAhead:0)<=o.modeFrontier))return s;var c=R(a.text,null,e.options.tabSize);(null==i||n>c)&&(i=s-1,n=c)}return i}(e,t,r),l=o>n.first&&Xe(n,o-1).stateAfter,s=l?ct.fromSaved(n,l,o):new ct(n,Ke(n.mode),o);return n.iter(o,t,function(r){pt(e,r.text,s);var n=s.line;r.stateAfter=n==t-1||n%5==0||n>=i.viewFrom&&nt.start)return o}throw new Error("Mode "+e.name+" failed to advance stream.")}ct.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return null!=t&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},ct.prototype.baseToken=function(e){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=e;)this.baseTokenPos+=2;var t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}},ct.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},ct.fromSaved=function(e,t,r){return t instanceof ut?new ct(e,Ue(e.mode,t.state),r,t.lookAhead):new ct(e,Ue(e.mode,t),r)},ct.prototype.save=function(e){var t=!1!==e?Ue(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new ut(t,this.maxLookAhead):t};var mt=function(e,t,r){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=r};function yt(e,t,r,n){var i,o,l=e.doc,s=l.mode,a=Xe(l,(t=st(l,t)).line),u=dt(e,t.line,r),c=new je(a.text,e.options.tabSize,u);for(n&&(o=[]);(n||c.pose.options.maxHighlightLength?(s=!1,l&&pt(e,t,n,h.pos),h.pos=t.length,a=null):a=bt(vt(r,h,n.state,f),o),f){var d=f[0].name;d&&(a="m-"+(a?d+" "+a:d))}if(!s||c!=a){for(;u=t:o.to>t);(n||(n=[])).push(new St(l,o.from,s?null:o.to))}}return n}(r,i,l),a=function(e,t,r){var n;if(e)for(var i=0;i=t:o.to>t)||o.from==t&&"bookmark"==l.type&&(!r||o.marker.insertLeft)){var s=null==o.from||(l.inclusiveLeft?o.from<=t:o.from0&&s)for(var b=0;bt)&&(!r||Wt(r,o.marker)<0)&&(r=o.marker)}return r}function It(e,t,r,n,i){var o=Xe(e,t),l=Ct&&o.markedSpans;if(l)for(var s=0;s=0&&h<=0||c<=0&&h>=0)&&(c<=0&&(a.marker.inclusiveRight&&i.inclusiveLeft?tt(u.to,r)>=0:tt(u.to,r)>0)||c>=0&&(a.marker.inclusiveRight&&i.inclusiveLeft?tt(u.from,n)<=0:tt(u.from,n)<0)))return!0}}}function Rt(e){for(var t;t=Ft(e);)e=t.find(-1,!0).line;return e}function zt(e,t){var r=Xe(e,t),n=Rt(r);return r==n?t:qe(n)}function Bt(e,t){if(t>e.lastLine())return t;var r,n=Xe(e,t);if(!Gt(e,n))return t;for(;r=Pt(n);)n=r.find(1,!0).line;return qe(n)+1}function Gt(e,t){var r=Ct&&t.markedSpans;if(r)for(var n=void 0,i=0;it.maxLineLength&&(t.maxLineLength=r,t.maxLine=e)})}var Xt=function(e,t,r){this.text=e,Ot(this,t),this.height=r?r(this):1};function Yt(e){e.parent=null,Nt(e)}Xt.prototype.lineNo=function(){return qe(this)},be(Xt);var $t={},_t={};function qt(e,t){if(!e||/^\s*$/.test(e))return null;var r=t.addModeClass?_t:$t;return r[e]||(r[e]=e.replace(/\S+/g,"cm-$&"))}function Zt(e,t){var r=A("span",null,null,a?"padding-right: .1px":null),n={pre:A("pre",[r],"CodeMirror-line"),content:r,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var o=i?t.rest[i-1]:t.line,l=void 0;n.pos=0,n.addToken=Jt,Ae(e.display.measure)&&(l=ce(o,e.doc.direction))&&(n.addToken=er(n.addToken,l)),n.map=[],rr(o,n,ft(e,o,t!=e.display.externalMeasured&&qe(o))),o.styleClasses&&(o.styleClasses.bgClass&&(n.bgClass=F(o.styleClasses.bgClass,n.bgClass||"")),o.styleClasses.textClass&&(n.textClass=F(o.styleClasses.textClass,n.textClass||""))),0==n.map.length&&n.map.push(0,0,n.content.appendChild(Oe(e.display.measure))),0==i?(t.measure.map=n.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(n.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(a){var s=n.content.lastChild;(/\bcm-tab\b/.test(s.className)||s.querySelector&&s.querySelector(".cm-tab"))&&(n.content.className="cm-tab-wrap-hack")}return ge(e,"renderLine",e,t.line,n.pre),n.pre.className&&(n.textClass=F(n.pre.className,n.textClass||"")),n}function Qt(e){var t=O("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Jt(e,t,r,n,i,o,a){if(t){var u,c=e.splitSpaces?function(e,t){if(e.length>1&&!/ /.test(e))return e;for(var r=t,n="",i=0;iu&&h.from<=u);f++);if(h.to>=c)return e(r,n,i,o,l,s,a);e(r,n.slice(0,h.to-u),i,o,null,s,a),o=null,n=n.slice(h.to-u),u=h.to}}}function tr(e,t,r,n){var i=!n&&r.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!n&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",r.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t,e.trailingSpace=!1}function rr(e,t,r){var n=e.markedSpans,i=e.text,o=0;if(n)for(var l,s,a,u,c,h,f,d=i.length,p=0,g=1,v="",m=0;;){if(m==p){a=u=c=s="",f=null,h=null,m=1/0;for(var y=[],b=void 0,w=0;wp||C.collapsed&&x.to==p&&x.from==p)){if(null!=x.to&&x.to!=p&&m>x.to&&(m=x.to,u=""),C.className&&(a+=" "+C.className),C.css&&(s=(s?s+";":"")+C.css),C.startStyle&&x.from==p&&(c+=" "+C.startStyle),C.endStyle&&x.to==m&&(b||(b=[])).push(C.endStyle,x.to),C.title&&((f||(f={})).title=C.title),C.attributes)for(var S in C.attributes)(f||(f={}))[S]=C.attributes[S];C.collapsed&&(!h||Wt(h.marker,C)<0)&&(h=x)}else x.from>p&&m>x.from&&(m=x.from)}if(b)for(var L=0;L=d)break;for(var T=Math.min(d,m);;){if(v){var M=p+v.length;if(!h){var N=M>T?v.slice(0,T-p):v;t.addToken(t,N,l?l+a:a,c,p+N.length==m?u:"",s,f)}if(M>=T){v=v.slice(T-p),p=T;break}p=M,c=""}v=i.slice(o,o=r[g++]),l=qt(r[g++],t.cm.options)}}else for(var O=1;Or)return{map:e.measure.maps[i],cache:e.measure.caches[i],before:!0}}}function Or(e,t,r,n){return Wr(e,Dr(e,t),r,n)}function Ar(e,t){if(t>=e.display.viewFrom&&t=r.lineN&&t2&&o.push((a.bottom+u.top)/2-r.top)}}o.push(r.bottom-r.top)}}(e,t.view,t.rect),t.hasHeights=!0),(o=function(e,t,r,n){var i,o=Pr(t.map,r,n),a=o.node,u=o.start,c=o.end,h=o.collapse;if(3==a.nodeType){for(var f=0;f<4;f++){for(;u&&ie(t.line.text.charAt(o.coverStart+u));)--u;for(;o.coverStart+c1}(e))return t;var r=screen.logicalXDPI/screen.deviceXDPI,n=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*r,right:t.right*r,top:t.top*n,bottom:t.bottom*n}}(e.display.measure,i))}else{var d;u>0&&(h=n="right"),i=e.options.lineWrapping&&(d=a.getClientRects()).length>1?d["right"==n?d.length-1:0]:a.getBoundingClientRect()}if(l&&s<9&&!u&&(!i||!i.left&&!i.right)){var p=a.parentNode.getClientRects()[0];i=p?{left:p.left,right:p.left+tn(e.display),top:p.top,bottom:p.bottom}:Fr}for(var g=i.top-t.rect.top,v=i.bottom-t.rect.top,m=(g+v)/2,y=t.view.measure.heights,b=0;bt)&&(i=(o=a-s)-1,t>=a&&(l="right")),null!=i){if(n=e[u+2],s==a&&r==(n.insertLeft?"left":"right")&&(l=r),"left"==r&&0==i)for(;u&&e[u-2]==e[u-3]&&e[u-1].insertLeft;)n=e[2+(u-=3)],l="left";if("right"==r&&i==a-s)for(;u=0&&(r=e[i]).left==r.right;i--);return r}function Ir(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t=n.text.length?(a=n.text.length,u="before"):a<=0&&(a=0,u="after"),!s)return l("before"==u?a-1:a,"before"==u);function c(e,t,r){return l(r?e-1:e,1==s[t].level!=r)}var h=ae(s,a,u),f=se,d=c(a,h,"before"==u);return null!=f&&(d.other=c(a,f,"before"!=u)),d}function Yr(e,t){var r=0;t=st(e.doc,t),e.options.lineWrapping||(r=tn(e.display)*t.ch);var n=Xe(e.doc,t.line),i=Vt(n)+Cr(e.display);return{left:r,right:r,top:i,bottom:i+n.height}}function $r(e,t,r,n,i){var o=et(e,t,r);return o.xRel=i,n&&(o.outside=n),o}function _r(e,t,r){var n=e.doc;if((r+=e.display.viewOffset)<0)return $r(n.first,0,null,-1,-1);var i=Ze(n,r),o=n.first+n.size-1;if(i>o)return $r(n.first+n.size-1,Xe(n,o).text.length,null,1,1);t<0&&(t=0);for(var l=Xe(n,i);;){var s=Jr(e,l,i,t,r),a=Et(l,s.ch+(s.xRel>0||s.outside>0?1:0));if(!a)return s;var u=a.find(1);if(u.line==i)return u;l=Xe(n,i=u.line)}}function qr(e,t,r,n){n-=Ur(t);var i=t.text.length,o=le(function(t){return Wr(e,r,t-1).bottom<=n},i,0);return{begin:o,end:i=le(function(t){return Wr(e,r,t).top>n},o,i)}}function Zr(e,t,r,n){return r||(r=Dr(e,t)),qr(e,t,r,Vr(e,t,Wr(e,r,n),"line").top)}function Qr(e,t,r,n){return!(e.bottom<=r)&&(e.top>r||(n?e.left:e.right)>t)}function Jr(e,t,r,n,i){i-=Vt(t);var o=Dr(e,t),l=Ur(t),s=0,a=t.text.length,u=!0,c=ce(t,e.doc.direction);if(c){var h=(e.options.lineWrapping?function(e,t,r,n,i,o,l){var s=qr(e,t,n,l),a=s.begin,u=s.end;/\s/.test(t.text.charAt(u-1))&&u--;for(var c=null,h=null,f=0;f=u||d.to<=a)){var p=1!=d.level,g=Wr(e,n,p?Math.min(u,d.to)-1:Math.max(a,d.from)).right,v=gv)&&(c=d,h=v)}}c||(c=i[i.length-1]);c.fromu&&(c={from:c.from,to:u,level:c.level});return c}:function(e,t,r,n,i,o,l){var s=le(function(s){var a=i[s],u=1!=a.level;return Qr(Xr(e,et(r,u?a.to:a.from,u?"before":"after"),"line",t,n),o,l,!0)},0,i.length-1),a=i[s];if(s>0){var u=1!=a.level,c=Xr(e,et(r,u?a.from:a.to,u?"after":"before"),"line",t,n);Qr(c,o,l,!0)&&c.top>l&&(a=i[s-1])}return a})(e,t,r,o,c,n,i);s=(u=1!=h.level)?h.from:h.to-1,a=u?h.to:h.from-1}var f,d,p=null,g=null,v=le(function(t){var r=Wr(e,o,t);return r.top+=l,r.bottom+=l,!!Qr(r,n,i,!1)&&(r.top<=i&&r.left<=n&&(p=t,g=r),!0)},s,a),m=!1;if(g){var y=n-g.left=w.bottom?1:0}return $r(r,v=oe(t.text,v,1),d,m,n-f)}function en(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Hr){Hr=O("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)Hr.appendChild(document.createTextNode("x")),Hr.appendChild(O("br"));Hr.appendChild(document.createTextNode("x"))}N(e.measure,Hr);var r=Hr.offsetHeight/50;return r>3&&(e.cachedTextHeight=r),M(e.measure),r||1}function tn(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=O("span","xxxxxxxxxx"),r=O("pre",[t],"CodeMirror-line-like");N(e.measure,r);var n=t.getBoundingClientRect(),i=(n.right-n.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function rn(e){for(var t=e.display,r={},n={},i=t.gutters.clientLeft,o=t.gutters.firstChild,l=0;o;o=o.nextSibling,++l){var s=e.display.gutterSpecs[l].className;r[s]=o.offsetLeft+o.clientLeft+i,n[s]=o.clientWidth}return{fixedPos:nn(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:r,gutterWidth:n,wrapperWidth:t.wrapper.clientWidth}}function nn(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function on(e){var t=en(e.display),r=e.options.lineWrapping,n=r&&Math.max(5,e.display.scroller.clientWidth/tn(e.display)-3);return function(i){if(Gt(e.doc,i))return 0;var o=0;if(i.widgets)for(var l=0;l0&&(a=Xe(e.doc,u.line).text).length==u.ch){var c=R(a,a.length,e.options.tabSize)-a.length;u=et(u.line,Math.max(0,Math.round((o-Lr(e.display).left)/tn(e.display))-c))}return u}function an(e,t){if(t>=e.display.viewTo)return null;if((t-=e.display.viewFrom)<0)return null;for(var r=e.display.view,n=0;nt)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)Ct&&zt(e.doc,t)i.viewFrom?hn(e):(i.viewFrom+=n,i.viewTo+=n);else if(t<=i.viewFrom&&r>=i.viewTo)hn(e);else if(t<=i.viewFrom){var o=fn(e,r,r+n,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=n):hn(e)}else if(r>=i.viewTo){var l=fn(e,t,t,-1);l?(i.view=i.view.slice(0,l.index),i.viewTo=l.lineN):hn(e)}else{var s=fn(e,t,t,-1),a=fn(e,r,r+n,1);s&&a?(i.view=i.view.slice(0,s.index).concat(ir(e,s.lineN,a.lineN)).concat(i.view.slice(a.index)),i.viewTo+=n):hn(e)}var u=i.externalMeasured;u&&(r=i.lineN&&t=n.viewTo)){var o=n.view[an(e,t)];if(null!=o.node){var l=o.changes||(o.changes=[]);-1==B(l,r)&&l.push(r)}}}function hn(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function fn(e,t,r,n){var i,o=an(e,t),l=e.display.view;if(!Ct||r==e.doc.first+e.doc.size)return{index:o,lineN:r};for(var s=e.display.viewFrom,a=0;a0){if(o==l.length-1)return null;i=s+l[o].size-t,o++}else i=s-t;t+=i,r+=i}for(;zt(e.doc,r)!=r;){if(o==(n<0?0:l.length-1))return null;r+=n*l[o-(n<0?1:0)].size,o+=n}return{index:o,lineN:r}}function dn(e){for(var t=e.display.view,r=0,n=0;n=e.display.viewTo||a.to().line0?l:e.defaultCharWidth())+"px"}if(n.other){var s=r.appendChild(O("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));s.style.display="",s.style.left=n.other.left+"px",s.style.top=n.other.top+"px",s.style.height=.85*(n.other.bottom-n.other.top)+"px"}}function mn(e,t){return e.top-t.top||e.left-t.left}function yn(e,t,r){var n=e.display,i=e.doc,o=document.createDocumentFragment(),l=Lr(e.display),s=l.left,a=Math.max(n.sizerWidth,Tr(e)-n.sizer.offsetLeft)-l.right,u="ltr"==i.direction;function c(e,t,r,n){t<0&&(t=0),t=Math.round(t),n=Math.round(n),o.appendChild(O("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px;\n top: "+t+"px; width: "+(null==r?a-e:r)+"px;\n height: "+(n-t)+"px"))}function h(t,r,n){var o,l,h=Xe(i,t),f=h.text.length;function d(r,n){return jr(e,et(t,r),"div",h,n)}function p(t,r,n){var i=Zr(e,h,null,t),o="ltr"==r==("after"==n)?"left":"right";return d("after"==n?i.begin:i.end-(/\s/.test(h.text.charAt(i.end-1))?2:1),o)[o]}var g=ce(h,i.direction);return function(e,t,r,n){if(!e)return n(t,r,"ltr",0);for(var i=!1,o=0;ot||t==r&&l.to==t)&&(n(Math.max(l.from,t),Math.min(l.to,r),1==l.level?"rtl":"ltr",o),i=!0)}i||n(t,r,"ltr")}(g,r||0,null==n?f:n,function(e,t,i,h){var v="ltr"==i,m=d(e,v?"left":"right"),y=d(t-1,v?"right":"left"),b=null==r&&0==e,w=null==n&&t==f,x=0==h,C=!g||h==g.length-1;if(y.top-m.top<=3){var S=(u?w:b)&&C,L=(u?b:w)&&x?s:(v?m:y).left,k=S?a:(v?y:m).right;c(L,m.top,k-L,m.bottom)}else{var T,M,N,O;v?(T=u&&b&&x?s:m.left,M=u?a:p(e,i,"before"),N=u?s:p(t,i,"after"),O=u&&w&&C?a:y.right):(T=u?p(e,i,"before"):s,M=!u&&b&&x?a:m.right,N=!u&&w&&C?s:y.left,O=u?p(t,i,"after"):a),c(T,m.top,M-T,m.bottom),m.bottom0?t.blinker=setInterval(function(){e.hasFocus()||Sn(e),t.cursorDiv.style.visibility=(r=!r)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function wn(e){e.hasFocus()||(e.display.input.focus(),e.state.focused||Cn(e))}function xn(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,e.state.focused&&Sn(e))},100)}function Cn(e,t){e.state.delayingBlurEvent&&!e.state.draggingText&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(ge(e,"focus",e,t),e.state.focused=!0,H(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),a&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),bn(e))}function Sn(e,t){e.state.delayingBlurEvent||(e.state.focused&&(ge(e,"blur",e,t),e.state.focused=!1,T(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function Ln(e){for(var t=e.display,r=t.lineDiv.offsetTop,n=Math.max(0,t.scroller.getBoundingClientRect().top),i=t.lineDiv.getBoundingClientRect().top,o=0,a=0;a.005||g<-.005)&&(ie.display.sizerWidth){var m=Math.ceil(f/tn(e.display));m>e.display.maxLineLength&&(e.display.maxLineLength=m,e.display.maxLine=u.line,e.display.maxLineChanged=!0)}}}Math.abs(o)>2&&(t.scroller.scrollTop+=o)}function kn(e){if(e.widgets)for(var t=0;t=l&&(o=Ze(t,Vt(Xe(t,a))-e.wrapper.clientHeight),l=a)}return{from:o,to:Math.max(l,o+1)}}function Mn(e,t){var r=e.display,n=en(e.display);t.top<0&&(t.top=0);var i=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:r.scroller.scrollTop,o=Mr(e),l={};t.bottom-t.top>o&&(t.bottom=t.top+o);var s=e.doc.height+Sr(r),a=t.tops-n;if(t.topi+o){var c=Math.min(t.top,(u?s:t.bottom)-o);c!=i&&(l.scrollTop=c)}var h=e.options.fixedGutter?0:r.gutters.offsetWidth,f=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:r.scroller.scrollLeft-h,d=Tr(e)-r.gutters.offsetWidth,p=t.right-t.left>d;return p&&(t.right=t.left+d),t.left<10?l.scrollLeft=0:t.leftd+f-3&&(l.scrollLeft=t.right+(p?0:10)-d),l}function Nn(e,t){null!=t&&(Dn(e),e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+t)}function On(e){Dn(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function An(e,t,r){null==t&&null==r||Dn(e),null!=t&&(e.curOp.scrollLeft=t),null!=r&&(e.curOp.scrollTop=r)}function Dn(e){var t=e.curOp.scrollToPos;t&&(e.curOp.scrollToPos=null,Wn(e,Yr(e,t.from),Yr(e,t.to),t.margin))}function Wn(e,t,r,n){var i=Mn(e,{left:Math.min(t.left,r.left),top:Math.min(t.top,r.top)-n,right:Math.max(t.right,r.right),bottom:Math.max(t.bottom,r.bottom)+n});An(e,i.scrollLeft,i.scrollTop)}function Hn(e,t){Math.abs(e.doc.scrollTop-t)<2||(r||oi(e,{top:t}),Fn(e,t,!0),r&&oi(e),ei(e,100))}function Fn(e,t,r){t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),(e.display.scroller.scrollTop!=t||r)&&(e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t))}function Pn(e,t,r,n){t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),(r?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!n||(e.doc.scrollLeft=t,ai(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function En(e){var t=e.display,r=t.gutters.offsetWidth,n=Math.round(e.doc.height+Sr(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?r:0,docHeight:n,scrollHeight:n+kr(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:r}}var In=function(e,t,r){this.cm=r;var n=this.vert=O("div",[O("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=O("div",[O("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");n.tabIndex=i.tabIndex=-1,e(n),e(i),fe(n,"scroll",function(){n.clientHeight&&t(n.scrollTop,"vertical")}),fe(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,l&&s<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};In.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,r=e.scrollHeight>e.clientHeight+1,n=e.nativeBarWidth;if(r){this.vert.style.display="block",this.vert.style.bottom=t?n+"px":"0";var i=e.viewHeight-(t?n:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else this.vert.scrollTop=0,this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=r?n+"px":"0",this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(r?n:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+o)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(0==n&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:r?n:0,bottom:t?n:0}},In.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},In.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},In.prototype.zeroWidthHack=function(){var e=y&&!d?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new z,this.disableVert=new z},In.prototype.enableZeroWidthBar=function(e,t,r){e.style.pointerEvents="auto",t.set(1e3,function n(){var i=e.getBoundingClientRect();("vert"==r?document.elementFromPoint(i.right-1,(i.top+i.bottom)/2):document.elementFromPoint((i.right+i.left)/2,i.bottom-1))!=e?e.style.pointerEvents="none":t.set(1e3,n)})},In.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var Rn=function(){};function zn(e,t){t||(t=En(e));var r=e.display.barWidth,n=e.display.barHeight;Bn(e,t);for(var i=0;i<4&&r!=e.display.barWidth||n!=e.display.barHeight;i++)r!=e.display.barWidth&&e.options.lineWrapping&&Ln(e),Bn(e,En(e)),r=e.display.barWidth,n=e.display.barHeight}function Bn(e,t){var r=e.display,n=r.scrollbars.update(t);r.sizer.style.paddingRight=(r.barWidth=n.right)+"px",r.sizer.style.paddingBottom=(r.barHeight=n.bottom)+"px",r.heightForcer.style.borderBottom=n.bottom+"px solid transparent",n.right&&n.bottom?(r.scrollbarFiller.style.display="block",r.scrollbarFiller.style.height=n.bottom+"px",r.scrollbarFiller.style.width=n.right+"px"):r.scrollbarFiller.style.display="",n.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(r.gutterFiller.style.display="block",r.gutterFiller.style.height=n.bottom+"px",r.gutterFiller.style.width=t.gutterWidth+"px"):r.gutterFiller.style.display=""}Rn.prototype.update=function(){return{bottom:0,right:0}},Rn.prototype.setScrollLeft=function(){},Rn.prototype.setScrollTop=function(){},Rn.prototype.clear=function(){};var Gn={native:In,null:Rn};function Un(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&T(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new Gn[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),fe(t,"mousedown",function(){e.state.focused&&setTimeout(function(){return e.display.input.focus()},0)}),t.setAttribute("cm-not-content","true")},function(t,r){"horizontal"==r?Pn(e,t):Hn(e,t)},e),e.display.scrollbars.addClass&&H(e.display.wrapper,e.display.scrollbars.addClass)}var Vn=0;function Kn(e){var t;e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Vn,markArrays:null},t=e.curOp,or?or.ops.push(t):t.ownsGroup=or={ops:[t],delayedCallbacks:[]}}function jn(e){var t=e.curOp;t&&function(e,t){var r=e.ownsGroup;if(r)try{!function(e){var t=e.delayedCallbacks,r=0;do{for(;r=r.viewTo)||r.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new ri(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function Yn(e){var t=e.cm,r=t.display;e.updatedDisplay&&Ln(t),e.barMeasure=En(t),r.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=Or(t,r.maxLine,r.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(r.scroller.clientWidth,r.sizer.offsetLeft+e.adjustWidthTo+kr(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,r.sizer.offsetLeft+e.adjustWidthTo-Tr(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=r.input.prepareSelection())}function $n(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null!=i&&!p){var o=O("div","​",null,"position: absolute;\n top: "+(t.top-r.viewOffset-Cr(e.display))+"px;\n height: "+(t.bottom-t.top+kr(e)+r.barHeight)+"px;\n left: "+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)}}}(t,function(e,t,r,n){var i;null==n&&(n=0),e.options.lineWrapping||t!=r||(r="before"==t.sticky?et(t.line,t.ch+1,"before"):t,t=t.ch?et(t.line,"before"==t.sticky?t.ch-1:t.ch,"after"):t);for(var o=0;o<5;o++){var l=!1,s=Xr(e,t),a=r&&r!=t?Xr(e,r):s,u=Mn(e,i={left:Math.min(s.left,a.left),top:Math.min(s.top,a.top)-n,right:Math.max(s.left,a.left),bottom:Math.max(s.bottom,a.bottom)+n}),c=e.doc.scrollTop,h=e.doc.scrollLeft;if(null!=u.scrollTop&&(Hn(e,u.scrollTop),Math.abs(e.doc.scrollTop-c)>1&&(l=!0)),null!=u.scrollLeft&&(Pn(e,u.scrollLeft),Math.abs(e.doc.scrollLeft-h)>1&&(l=!0)),!l)break}return i}(t,st(n,e.scrollToPos.from),st(n,e.scrollToPos.to),e.scrollToPos.margin));var i=e.maybeHiddenMarkers,o=e.maybeUnhiddenMarkers;if(i)for(var l=0;l=e.display.viewTo)){var r=+new Date+e.options.workTime,n=dt(e,t.highlightFrontier),i=[];t.iter(n.line,Math.min(t.first+t.size,e.display.viewTo+500),function(o){if(n.line>=e.display.viewFrom){var l=o.styles,s=o.text.length>e.options.maxHighlightLength?Ue(t.mode,n.state):null,a=ht(e,o,n,!0);s&&(n.state=s),o.styles=a.styles;var u=o.styleClasses,c=a.classes;c?o.styleClasses=c:u&&(o.styleClasses=null);for(var h=!l||l.length!=o.styles.length||u!=c&&(!u||!c||u.bgClass!=c.bgClass||u.textClass!=c.textClass),f=0;!h&&fr)return ei(e,e.options.workDelay),!0}),t.highlightFrontier=n.line,t.modeFrontier=Math.max(t.modeFrontier,n.line),i.length&&qn(e,function(){for(var t=0;t=r.viewFrom&&t.visible.to<=r.viewTo&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo)&&r.renderedView==r.view&&0==dn(e))return!1;ui(e)&&(hn(e),t.dims=rn(e));var i=n.first+n.size,o=Math.max(t.visible.from-e.options.viewportMargin,n.first),l=Math.min(i,t.visible.to+e.options.viewportMargin);r.viewFroml&&r.viewTo-l<20&&(l=Math.min(i,r.viewTo)),Ct&&(o=zt(e.doc,o),l=Bt(e.doc,l));var s=o!=r.viewFrom||l!=r.viewTo||r.lastWrapHeight!=t.wrapperHeight||r.lastWrapWidth!=t.wrapperWidth;!function(e,t,r){var n=e.display;0==n.view.length||t>=n.viewTo||r<=n.viewFrom?(n.view=ir(e,t,r),n.viewFrom=t):(n.viewFrom>t?n.view=ir(e,t,n.viewFrom).concat(n.view):n.viewFromr&&(n.view=n.view.slice(0,an(e,r)))),n.viewTo=r}(e,o,l),r.viewOffset=Vt(Xe(e.doc,r.viewFrom)),e.display.mover.style.top=r.viewOffset+"px";var u=dn(e);if(!s&&0==u&&!t.force&&r.renderedView==r.view&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo))return!1;var c=function(e){if(e.hasFocus())return null;var t=W();if(!t||!D(e.display.lineDiv,t))return null;var r={activeElt:t};if(window.getSelection){var n=window.getSelection();n.anchorNode&&n.extend&&D(e.display.lineDiv,n.anchorNode)&&(r.anchorNode=n.anchorNode,r.anchorOffset=n.anchorOffset,r.focusNode=n.focusNode,r.focusOffset=n.focusOffset)}return r}(e);return u>4&&(r.lineDiv.style.display="none"),function(e,t,r){var n=e.display,i=e.options.lineNumbers,o=n.lineDiv,l=o.firstChild;function s(t){var r=t.nextSibling;return a&&y&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),r}for(var u=n.view,c=n.viewFrom,h=0;h-1&&(d=!1),ur(e,f,c,r)),d&&(M(f.lineNumber),f.lineNumber.appendChild(document.createTextNode(Je(e.options,c)))),l=f.node.nextSibling}else{var p=vr(e,f,c,r);o.insertBefore(p,l)}c+=f.size}for(;l;)l=s(l)}(e,r.updateLineNumbers,t.dims),u>4&&(r.lineDiv.style.display=""),r.renderedView=r.view,function(e){if(e&&e.activeElt&&e.activeElt!=W()&&(e.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(e.activeElt.nodeName)&&e.anchorNode&&D(document.body,e.anchorNode)&&D(document.body,e.focusNode))){var t=window.getSelection(),r=document.createRange();r.setEnd(e.anchorNode,e.anchorOffset),r.collapse(!1),t.removeAllRanges(),t.addRange(r),t.extend(e.focusNode,e.focusOffset)}}(c),M(r.cursorDiv),M(r.selectionDiv),r.gutters.style.height=r.sizer.style.minHeight=0,s&&(r.lastWrapHeight=t.wrapperHeight,r.lastWrapWidth=t.wrapperWidth,ei(e,400)),r.updateLineNumbers=null,!0}function ii(e,t){for(var r=t.viewport,n=!0;;n=!1){if(n&&e.options.lineWrapping&&t.oldDisplayWidth!=Tr(e))n&&(t.visible=Tn(e.display,e.doc,r));else if(r&&null!=r.top&&(r={top:Math.min(e.doc.height+Sr(e.display)-Mr(e),r.top)}),t.visible=Tn(e.display,e.doc,r),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break;if(!ni(e,t))break;Ln(e);var i=En(e);pn(e),zn(e,i),si(e,i),t.force=!1}t.signal(e,"update",e),e.display.viewFrom==e.display.reportedViewFrom&&e.display.viewTo==e.display.reportedViewTo||(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function oi(e,t){var r=new ri(e,t);if(ni(e,r)){Ln(e),ii(e,r);var n=En(e);pn(e),zn(e,n),si(e,n),r.finish()}}function li(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px",sr(e,"gutterChanged",e)}function si(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+kr(e)+"px"}function ai(e){var t=e.display,r=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var n=nn(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=n+"px",l=0;lu.clientWidth,f=u.scrollHeight>u.clientHeight;if(i&&c||o&&f){if(o&&y&&a)e:for(var d=t.target,p=s.view;d!=u;d=d.parentNode)for(var g=0;g=0&&tt(e,n.to())<=0)return r}return-1};var wi=function(e,t){this.anchor=e,this.head=t};function xi(e,t,r){var n=e&&e.options.selectionsMayTouch,i=t[r];t.sort(function(e,t){return tt(e.from(),t.from())}),r=B(t,i);for(var o=1;o0:a>=0){var u=ot(s.from(),l.from()),c=it(s.to(),l.to()),h=s.empty()?l.from()==l.head:s.from()==s.head;o<=r&&--r,t.splice(--o,2,new wi(h?c:u,h?u:c))}}return new bi(t,r)}function Ci(e,t){return new bi([new wi(e,t||e)],0)}function Si(e){return e.text?et(e.from.line+e.text.length-1,_(e.text).length+(1==e.text.length?e.from.ch:0)):e.to}function Li(e,t){if(tt(e,t.from)<0)return e;if(tt(e,t.to)<=0)return Si(t);var r=e.line+t.text.length-(t.to.line-t.from.line)-1,n=e.ch;return e.line==t.to.line&&(n+=Si(t).ch-t.to.ch),et(r,n)}function ki(e,t){for(var r=[],n=0;n1&&e.remove(s.line+1,p-1),e.insert(s.line+1,m)}sr(e,"change",e,t)}function Di(e,t,r){!function e(n,i,o){if(n.linked)for(var l=0;ls-(e.cm?e.cm.options.historyEventDelay:500)||"*"==t.origin.charAt(0)))&&(o=function(e,t){return t?(Ei(e.done),_(e.done)):e.done.length&&!_(e.done).ranges?_(e.done):e.done.length>1&&!e.done[e.done.length-2].ranges?(e.done.pop(),_(e.done)):void 0}(i,i.lastOp==n)))l=_(o.changes),0==tt(t.from,t.to)&&0==tt(t.from,l.to)?l.to=Si(t):o.changes.push(Pi(e,t));else{var a=_(i.done);for(a&&a.ranges||zi(e.sel,i.done),o={changes:[Pi(e,t)],generation:i.generation},i.done.push(o);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(r),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=s,i.lastOp=i.lastSelOp=n,i.lastOrigin=i.lastSelOrigin=t.origin,l||ge(e,"historyAdded")}function Ri(e,t,r,n){var i=e.history,o=n&&n.origin;r==i.lastSelOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||function(e,t,r,n){var i=t.charAt(0);return"*"==i||"+"==i&&r.ranges.length==n.ranges.length&&r.somethingSelected()==n.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}(e,o,_(i.done),t))?i.done[i.done.length-1]=t:zi(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=r,n&&!1!==n.clearRedo&&Ei(i.undone)}function zi(e,t){var r=_(t);r&&r.ranges&&r.equals(e)||t.push(e)}function Bi(e,t,r,n){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,r),Math.min(e.first+e.size,n),function(r){r.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=r.markedSpans),++o})}function Gi(e){if(!e)return null;for(var t,r=0;r-1&&(_(s)[h]=u[h],delete u[h])}}}return n}function Ki(e,t,r,n){if(n){var i=e.anchor;if(r){var o=tt(t,i)<0;o!=tt(r,i)<0?(i=t,t=r):o!=tt(t,r)<0&&(t=r)}return new wi(i,t)}return new wi(r||t,t)}function ji(e,t,r,n,i){null==i&&(i=e.cm&&(e.cm.display.shift||e.extend)),qi(e,new bi([Ki(e.sel.primary(),t,r,i)],0),n)}function Xi(e,t,r){for(var n=[],i=e.cm&&(e.cm.display.shift||e.extend),o=0;o=t.ch:s.to>t.ch))){if(i&&(ge(a,"beforeCursorEnter"),a.explicitlyCleared)){if(o.markedSpans){--l;continue}break}if(!a.atomic)continue;if(r){var h=a.find(n<0?1:-1),f=void 0;if((n<0?c:u)&&(h=no(e,h,-n,h&&h.line==t.line?o:null)),h&&h.line==t.line&&(f=tt(h,r))&&(n<0?f<0:f>0))return to(e,h,t,n,i)}var d=a.find(n<0?-1:1);return(n<0?u:c)&&(d=no(e,d,n,d.line==t.line?o:null)),d?to(e,d,t,n,i):null}}return t}function ro(e,t,r,n,i){var o=n||1,l=to(e,t,r,o,i)||!i&&to(e,t,r,o,!0)||to(e,t,r,-o,i)||!i&&to(e,t,r,-o,!0);return l||(e.cantEdit=!0,et(e.first,0))}function no(e,t,r,n){return r<0&&0==t.ch?t.line>e.first?st(e,et(t.line-1)):null:r>0&&t.ch==(n||Xe(e,t.line)).text.length?t.line0)){var c=[a,1],h=tt(u.from,s.from),f=tt(u.to,s.to);(h<0||!l.inclusiveLeft&&!h)&&c.push({from:u.from,to:s.from}),(f>0||!l.inclusiveRight&&!f)&&c.push({from:s.to,to:u.to}),i.splice.apply(i,c),a+=c.length-3}}return i}(e,t.from,t.to);if(n)for(var i=n.length-1;i>=0;--i)so(e,{from:n[i].from,to:n[i].to,text:i?[""]:t.text,origin:t.origin});else so(e,t)}}function so(e,t){if(1!=t.text.length||""!=t.text[0]||0!=tt(t.from,t.to)){var r=ki(e,t);Ii(e,t,r,e.cm?e.cm.curOp.id:NaN),co(e,t,r,Tt(e,t));var n=[];Di(e,function(e,r){r||-1!=B(n,e.history)||(go(e.history,t),n.push(e.history)),co(e,t,null,Tt(e,t))})}}function ao(e,t,r){var n=e.cm&&e.cm.state.suppressEdits;if(!n||r){for(var i,o=e.history,l=e.sel,s="undo"==t?o.done:o.undone,a="undo"==t?o.undone:o.done,u=0;u=0;--d){var p=f(d);if(p)return p.v}}}}function uo(e,t){if(0!=t&&(e.first+=t,e.sel=new bi(q(e.sel.ranges,function(e){return new wi(et(e.anchor.line+t,e.anchor.ch),et(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){un(e.cm,e.first,e.first-t,t);for(var r=e.cm.display,n=r.viewFrom;ne.lastLine())){if(t.from.lineo&&(t={from:t.from,to:et(o,Xe(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Ye(e,t.from,t.to),r||(r=ki(e,t)),e.cm?function(e,t,r){var n=e.doc,i=e.display,o=t.from,l=t.to,s=!1,a=o.line;e.options.lineWrapping||(a=qe(Rt(Xe(n,o.line))),n.iter(a,l.line+1,function(e){if(e==i.maxLine)return s=!0,!0}));n.sel.contains(t.from,t.to)>-1&&me(e);Ai(n,t,r,on(e)),e.options.lineWrapping||(n.iter(a,o.line+t.text.length,function(e){var t=Kt(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,s=!1)}),s&&(e.curOp.updateMaxLine=!0));(function(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),!(e.highlightFrontierr;n--){var i=Xe(e,n).stateAfter;if(i&&(!(i instanceof ut)||n+i.lookAhead1||!(this.children[0]instanceof mo))){var s=[];this.collapse(s),this.children=[new mo(s)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t50){for(var l=i.lines.length%25+25,s=l;s10);e.parent.maybeSpill()}},iterN:function(e,t,r){for(var n=0;n0||0==l&&!1!==o.clearWhenEmpty)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=A("span",[o.replacedWith],"CodeMirror-widget"),n.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),n.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(It(e,t.line,t,r,o)||t.line!=r.line&&It(e,r.line,t,r,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");Ct=!0}o.addToHistory&&Ii(e,{from:t,to:r,origin:"markText"},e.sel,NaN);var s,a=t.line,u=e.cm;if(e.iter(a,r.line+1,function(n){u&&o.collapsed&&!u.options.lineWrapping&&Rt(n)==u.display.maxLine&&(s=!0),o.collapsed&&a!=t.line&&_e(n,0),function(e,t,r){var n=r&&window.WeakSet&&(r.markedSpans||(r.markedSpans=new WeakSet));n&&n.has(e.markedSpans)?e.markedSpans.push(t):(e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],n&&n.add(e.markedSpans)),t.marker.attachLine(e)}(n,new St(o,a==t.line?t.ch:null,a==r.line?r.ch:null),e.cm&&e.cm.curOp),++a}),o.collapsed&&e.iter(t.line,r.line+1,function(t){Gt(e,t)&&_e(t,0)}),o.clearOnEnter&&fe(o,"beforeCursorEnter",function(){return o.clear()}),o.readOnly&&(xt=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++xo,o.atomic=!0),u){if(s&&(u.curOp.updateMaxLine=!0),o.collapsed)un(u,t.line,r.line+1);else if(o.className||o.startStyle||o.endStyle||o.css||o.attributes||o.title)for(var c=t.line;c<=r.line;c++)cn(u,c,"text");o.atomic&&Ji(u.doc),sr(u,"markerAdded",u,o)}return o}Co.prototype.clear=function(){if(!this.explicitlyCleared){var e=this.doc.cm,t=e&&!e.curOp;if(t&&Kn(e),ye(this,"clear")){var r=this.find();r&&sr(this,"clear",r.from,r.to)}for(var n=null,i=null,o=0;oe.display.maxLineLength&&(e.display.maxLine=u,e.display.maxLineLength=c,e.display.maxLineChanged=!0)}null!=n&&e&&this.collapsed&&un(e,n,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Ji(e.doc)),e&&sr(e,"markerCleared",e,this,n,i),t&&jn(e),this.parent&&this.parent.clear()}},Co.prototype.find=function(e,t){var r,n;null==e&&"bookmark"==this.type&&(e=1);for(var i=0;i=0;a--)lo(this,n[a]);s?_i(this,s):this.cm&&On(this.cm)}),undo:Jn(function(){ao(this,"undo")}),redo:Jn(function(){ao(this,"redo")}),undoSelection:Jn(function(){ao(this,"undo",!0)}),redoSelection:Jn(function(){ao(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,r=0,n=0;n=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,r){e=st(this,e),t=st(this,t);var n=[],i=e.line;return this.iter(e.line,t.line+1,function(o){var l=o.markedSpans;if(l)for(var s=0;s=a.to||null==a.from&&i!=e.line||null!=a.from&&i==t.line&&a.from>=t.ch||r&&!r(a.marker)||n.push(a.marker.parent||a.marker)}++i}),n},getAllMarks:function(){var e=[];return this.iter(function(t){var r=t.markedSpans;if(r)for(var n=0;ne)return t=e,!0;e-=o,++r}),st(this,et(r,t))},indexFromPos:function(e){var t=(e=st(this,e)).ch;if(e.linet&&(t=e.from),null!=e.to&&e.to-1)return t.state.draggingText(e),void setTimeout(function(){return t.display.input.focus()},20);try{var h=e.dataTransfer.getData("Text");if(h){var f;if(t.state.draggingText&&!t.state.draggingText.copy&&(f=t.listSelections()),Zi(t.doc,Ci(r,r)),f)for(var d=0;d=0;t--)ho(e.doc,"",n[t].from,n[t].to,"+delete");On(e)})}function _o(e,t,r){var n=oe(e.text,t+r,r);return n<0||n>e.text.length?null:n}function qo(e,t,r){var n=_o(e,t.ch,r);return null==n?null:new et(t.line,n,r<0?"after":"before")}function Zo(e,t,r,n,i){if(e){"rtl"==t.doc.direction&&(i=-i);var o=ce(r,t.doc.direction);if(o){var l,s=i<0?_(o):o[0],a=i<0==(1==s.level)?"after":"before";if(s.level>0||"rtl"==t.doc.direction){var u=Dr(t,r);l=i<0?r.text.length-1:0;var c=Wr(t,u,l).top;l=le(function(e){return Wr(t,u,e).top==c},i<0==(1==s.level)?s.from:s.to-1,l),"before"==a&&(l=_o(r,l,1))}else l=i<0?s.to:s.from;return new et(n,l,a)}}return new et(n,i<0?r.text.length:0,i<0?"before":"after")}Bo.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},Bo.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},Bo.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},Bo.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},Bo.default=y?Bo.macDefault:Bo.pcDefault;var Qo={selectAll:io,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),V)},killLine:function(e){return $o(e,function(t){if(t.empty()){var r=Xe(e.doc,t.head.line).text.length;return t.head.ch==r&&t.head.line0)i=new et(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),et(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var l=Xe(e.doc,i.line-1).text;l&&(i=new et(i.line,1),e.replaceRange(o.charAt(0)+e.doc.lineSeparator()+l.charAt(l.length-1),et(i.line-1,l.length-1),i,"+transpose"))}r.push(new wi(i,i))}e.setSelections(r)})},newlineAndIndent:function(e){return qn(e,function(){for(var t=e.listSelections(),r=t.length-1;r>=0;r--)e.replaceRange(e.doc.lineSeparator(),t[r].anchor,t[r].head,"+input");t=e.listSelections();for(var n=0;n-1&&(tt((i=u.ranges[i]).from(),t)<0||t.xRel>0)&&(tt(i.to(),t)>0||t.xRel<0)?function(e,t,r,n){var i=e.display,o=!1,u=Zn(e,function(t){a&&(i.scroller.draggable=!1),e.state.draggingText=!1,e.state.delayingBlurEvent&&(e.hasFocus()?e.state.delayingBlurEvent=!1:xn(e)),pe(i.wrapper.ownerDocument,"mouseup",u),pe(i.wrapper.ownerDocument,"mousemove",c),pe(i.scroller,"dragstart",h),pe(i.scroller,"drop",u),o||(we(t),n.addNew||ji(e.doc,r,null,null,n.extend),a&&!f||l&&9==s?setTimeout(function(){i.wrapper.ownerDocument.body.focus({preventScroll:!0}),i.input.focus()},20):i.input.focus())}),c=function(e){o=o||Math.abs(t.clientX-e.clientX)+Math.abs(t.clientY-e.clientY)>=10},h=function(){return o=!0};a&&(i.scroller.draggable=!0);e.state.draggingText=u,u.copy=!n.moveOnDrag,fe(i.wrapper.ownerDocument,"mouseup",u),fe(i.wrapper.ownerDocument,"mousemove",c),fe(i.scroller,"dragstart",h),fe(i.scroller,"drop",u),e.state.delayingBlurEvent=!0,setTimeout(function(){return i.input.focus()},20),i.scroller.dragDrop&&i.scroller.dragDrop()}(e,n,t,o):function(e,t,r,n){l&&xn(e);var i=e.display,o=e.doc;we(t);var s,a,u=o.sel,c=u.ranges;n.addNew&&!n.extend?(a=o.sel.contains(r),s=a>-1?c[a]:new wi(r,r)):(s=o.sel.primary(),a=o.sel.primIndex);if("rectangle"==n.unit)n.addNew||(s=new wi(r,r)),r=sn(e,t,!0,!0),a=-1;else{var h=pl(e,r,n.unit);s=n.extend?Ki(s,h.anchor,h.head,n.extend):h}n.addNew?-1==a?(a=c.length,qi(o,xi(e,c.concat([s]),a),{scroll:!1,origin:"*mouse"})):c.length>1&&c[a].empty()&&"char"==n.unit&&!n.extend?(qi(o,xi(e,c.slice(0,a).concat(c.slice(a+1)),0),{scroll:!1,origin:"*mouse"}),u=o.sel):Yi(o,a,s,K):(a=0,qi(o,new bi([s],0),K),u=o.sel);var f=r;function d(t){if(0!=tt(f,t))if(f=t,"rectangle"==n.unit){for(var i=[],l=e.options.tabSize,c=R(Xe(o,r.line).text,r.ch,l),h=R(Xe(o,t.line).text,t.ch,l),d=Math.min(c,h),p=Math.max(c,h),g=Math.min(r.line,t.line),v=Math.min(e.lastLine(),Math.max(r.line,t.line));g<=v;g++){var m=Xe(o,g).text,y=X(m,d,l);d==p?i.push(new wi(et(g,y),et(g,y))):m.length>y&&i.push(new wi(et(g,y),et(g,X(m,p,l))))}i.length||i.push(new wi(r,r)),qi(o,xi(e,u.ranges.slice(0,a).concat(i),a),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var b,w=s,x=pl(e,t,n.unit),C=w.anchor;tt(x.anchor,C)>0?(b=x.head,C=ot(w.from(),x.anchor)):(b=x.anchor,C=it(w.to(),x.head));var S=u.ranges.slice(0);S[a]=function(e,t){var r=t.anchor,n=t.head,i=Xe(e.doc,r.line);if(0==tt(r,n)&&r.sticky==n.sticky)return t;var o=ce(i);if(!o)return t;var l=ae(o,r.ch,r.sticky),s=o[l];if(s.from!=r.ch&&s.to!=r.ch)return t;var a,u=l+(s.from==r.ch==(1!=s.level)?0:1);if(0==u||u==o.length)return t;if(n.line!=r.line)a=(n.line-r.line)*("ltr"==e.doc.direction?1:-1)>0;else{var c=ae(o,n.ch,n.sticky),h=c-l||(n.ch-r.ch)*(1==s.level?-1:1);a=c==u-1||c==u?h<0:h>0}var f=o[u+(a?-1:0)],d=a==(1==f.level),p=d?f.from:f.to,g=d?"after":"before";return r.ch==p&&r.sticky==g?t:new wi(new et(r.line,p,g),n)}(e,new wi(st(o,C),b)),qi(o,xi(e,S,a),K)}}var p=i.wrapper.getBoundingClientRect(),g=0;function v(t){e.state.selectingText=!1,g=1/0,t&&(we(t),i.input.focus()),pe(i.wrapper.ownerDocument,"mousemove",m),pe(i.wrapper.ownerDocument,"mouseup",y),o.history.lastSelOrigin=null}var m=Zn(e,function(t){0!==t.buttons&&ke(t)?function t(r){var l=++g;var s=sn(e,r,!0,"rectangle"==n.unit);if(!s)return;if(0!=tt(s,f)){e.curOp.focus=W(),d(s);var a=Tn(i,o);(s.line>=a.to||s.linep.bottom?20:0;u&&setTimeout(Zn(e,function(){g==l&&(i.scroller.scrollTop+=u,t(r))}),50)}}(t):v(t)}),y=Zn(e,v);e.state.selectingText=y,fe(i.wrapper.ownerDocument,"mousemove",m),fe(i.wrapper.ownerDocument,"mouseup",y)}(e,n,t,o)}(t,n,o,e):Le(e)==r.scroller&&we(e):2==i?(n&&ji(t.doc,n),setTimeout(function(){return r.input.focus()},20)):3==i&&(S?t.display.input.onContextMenu(e):xn(t)))}}function pl(e,t,r){if("char"==r)return new wi(t,t);if("word"==r)return e.findWordAt(t);if("line"==r)return new wi(et(t.line,0),st(e.doc,et(t.line+1,0)));var n=r(e,t);return new wi(n.from,n.to)}function gl(e,t,r,n){var i,o;if(t.touches)i=t.touches[0].clientX,o=t.touches[0].clientY;else try{i=t.clientX,o=t.clientY}catch(e){return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;n&&we(t);var l=e.display,s=l.lineDiv.getBoundingClientRect();if(o>s.bottom||!ye(e,r))return Ce(t);o-=s.top-l.viewOffset;for(var a=0;a=i)return ge(e,r,e,Ze(e.doc,o),e.display.gutterSpecs[a].className,t),Ce(t)}}function vl(e,t){return gl(e,t,"gutterClick",!0)}function ml(e,t){xr(e.display,t)||function(e,t){if(!ye(e,"gutterContextMenu"))return!1;return gl(e,t,"gutterContextMenu",!1)}(e,t)||ve(e,t,"contextmenu")||S||e.display.input.onContextMenu(t)}function yl(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),zr(e)}fl.prototype.compare=function(e,t,r){return this.time+400>e&&0==tt(t,this.pos)&&r==this.button};var bl={toString:function(){return"CodeMirror.Init"}},wl={},xl={};function Cl(e,t,r){if(!t!=!(r&&r!=bl)){var n=e.display.dragFunctions,i=t?fe:pe;i(e.display.scroller,"dragstart",n.start),i(e.display.scroller,"dragenter",n.enter),i(e.display.scroller,"dragover",n.over),i(e.display.scroller,"dragleave",n.leave),i(e.display.scroller,"drop",n.drop)}}function Sl(e){e.options.lineWrapping?(H(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(T(e.display.wrapper,"CodeMirror-wrap"),jt(e)),ln(e),un(e),zr(e),setTimeout(function(){return zn(e)},100)}function Ll(e,t){var r=this;if(!(this instanceof Ll))return new Ll(e,t);this.options=t=t?I(t):{},I(wl,t,!1);var n=t.value;"string"==typeof n?n=new No(n,t.mode,null,t.lineSeparator,t.direction):t.mode&&(n.modeOption=t.mode),this.doc=n;var i=new Ll.inputStyles[t.inputStyle](this),o=this.display=new di(e,n,i,t);for(var u in o.wrapper.CodeMirror=this,yl(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Un(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new z,keySeq:null,specialChars:null},t.autofocus&&!m&&o.input.focus(),l&&s<11&&setTimeout(function(){return r.display.input.reset(!0)},20),function(e){var t=e.display;fe(t.scroller,"mousedown",Zn(e,dl)),fe(t.scroller,"dblclick",l&&s<11?Zn(e,function(t){if(!ve(e,t)){var r=sn(e,t);if(r&&!vl(e,t)&&!xr(e.display,t)){we(t);var n=e.findWordAt(r);ji(e.doc,n.anchor,n.head)}}}):function(t){return ve(e,t)||we(t)});fe(t.scroller,"contextmenu",function(t){return ml(e,t)}),fe(t.input.getField(),"contextmenu",function(r){t.scroller.contains(r.target)||ml(e,r)});var r,n={end:0};function i(){t.activeTouch&&(r=setTimeout(function(){return t.activeTouch=null},1e3),(n=t.activeTouch).end=+new Date)}function o(e,t){if(null==t.left)return!0;var r=t.left-e.left,n=t.top-e.top;return r*r+n*n>400}fe(t.scroller,"touchstart",function(i){if(!ve(e,i)&&!function(e){if(1!=e.touches.length)return!1;var t=e.touches[0];return t.radiusX<=1&&t.radiusY<=1}(i)&&!vl(e,i)){t.input.ensurePolled(),clearTimeout(r);var o=+new Date;t.activeTouch={start:o,moved:!1,prev:o-n.end<=300?n:null},1==i.touches.length&&(t.activeTouch.left=i.touches[0].pageX,t.activeTouch.top=i.touches[0].pageY)}}),fe(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),fe(t.scroller,"touchend",function(r){var n=t.activeTouch;if(n&&!xr(t,r)&&null!=n.left&&!n.moved&&new Date-n.start<300){var l,s=e.coordsChar(t.activeTouch,"page");l=!n.prev||o(n,n.prev)?new wi(s,s):!n.prev.prev||o(n,n.prev.prev)?e.findWordAt(s):new wi(et(s.line,0),st(e.doc,et(s.line+1,0))),e.setSelection(l.anchor,l.head),e.focus(),we(r)}i()}),fe(t.scroller,"touchcancel",i),fe(t.scroller,"scroll",function(){t.scroller.clientHeight&&(Hn(e,t.scroller.scrollTop),Pn(e,t.scroller.scrollLeft,!0),ge(e,"scroll",e))}),fe(t.scroller,"mousewheel",function(t){return yi(e,t)}),fe(t.scroller,"DOMMouseScroll",function(t){return yi(e,t)}),fe(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(t){ve(e,t)||Se(t)},over:function(t){ve(e,t)||(!function(e,t){var r=sn(e,t);if(r){var n=document.createDocumentFragment();vn(e,r,n),e.display.dragCursor||(e.display.dragCursor=O("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),N(e.display.dragCursor,n)}}(e,t),Se(t))},start:function(t){return function(e,t){if(l&&(!e.state.draggingText||+new Date-Oo<100))Se(t);else if(!ve(e,t)&&!xr(e.display,t)&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!f)){var r=O("img",null,null,"position: fixed; left: 0; top: 0;");r.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",h&&(r.width=r.height=1,e.display.wrapper.appendChild(r),r._top=r.offsetTop),t.dataTransfer.setDragImage(r,0,0),h&&r.parentNode.removeChild(r)}}(e,t)},drop:Zn(e,Ao),leave:function(t){ve(e,t)||Do(e)}};var a=t.input.getField();fe(a,"keyup",function(t){return al.call(e,t)}),fe(a,"keydown",Zn(e,sl)),fe(a,"keypress",Zn(e,ul)),fe(a,"focus",function(t){return Cn(e,t)}),fe(a,"blur",function(t){return Sn(e,t)})}(this),Fo(),Kn(this),this.curOp.forceUpdate=!0,Wi(this,n),t.autofocus&&!m||this.hasFocus()?setTimeout(function(){r.hasFocus()&&!r.state.focused&&Cn(r)},20):Sn(this),xl)xl.hasOwnProperty(u)&&xl[u](this,t[u],bl);ui(this),t.finishInit&&t.finishInit(this);for(var c=0;c150)){if(!n)return;r="prev"}}else u=0,r="not";"prev"==r?u=t>o.first?R(Xe(o,t-1).text,null,l):0:"add"==r?u=a+e.options.indentUnit:"subtract"==r?u=a-e.options.indentUnit:"number"==typeof r&&(u=a+r),u=Math.max(0,u);var h="",f=0;if(e.options.indentWithTabs)for(var d=Math.floor(u/l);d;--d)f+=l,h+="\t";if(fl,a=We(t),u=null;if(s&&n.ranges.length>1)if(Ml&&Ml.text.join("\n")==t){if(n.ranges.length%Ml.text.length==0){u=[];for(var c=0;c=0;f--){var d=n.ranges[f],p=d.from(),g=d.to();d.empty()&&(r&&r>0?p=et(p.line,p.ch-r):e.state.overwrite&&!s?g=et(g.line,Math.min(Xe(o,g.line).text.length,g.ch+_(a).length)):s&&Ml&&Ml.lineWise&&Ml.text.join("\n")==a.join("\n")&&(p=g=et(p.line,0)));var v={from:p,to:g,text:u?u[f%u.length]:a,origin:i||(s?"paste":e.state.cutIncoming>l?"cut":"+input")};lo(e.doc,v),sr(e,"inputRead",e,v)}t&&!s&&Dl(e,t),On(e),e.curOp.updateInput<2&&(e.curOp.updateInput=h),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function Al(e,t){var r=e.clipboardData&&e.clipboardData.getData("Text");if(r)return e.preventDefault(),t.isReadOnly()||t.options.disableInput||qn(t,function(){return Ol(t,r,0,null,"paste")}),!0}function Dl(e,t){if(e.options.electricChars&&e.options.smartIndent)for(var r=e.doc.sel,n=r.ranges.length-1;n>=0;n--){var i=r.ranges[n];if(!(i.head.ch>100||n&&r.ranges[n-1].head.line==i.head.line)){var o=e.getModeAt(i.head),l=!1;if(o.electricChars){for(var s=0;s-1){l=Tl(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(Xe(e.doc,i.head.line).text.slice(0,i.head.ch))&&(l=Tl(e,i.head.line,"smart"));l&&sr(e,"electricInput",e,i.head.line)}}}function Wl(e){for(var t=[],r=[],n=0;n0?0:-1));if(isNaN(c))l=null;else{var h=r>0?c>=55296&&c<56320:c>=56320&&c<57343;l=new et(t.line,Math.max(0,Math.min(s.text.length,t.ch+r*(h?2:1))),-r)}}else l=i?function(e,t,r,n){var i=ce(t,e.doc.direction);if(!i)return qo(t,r,n);r.ch>=t.text.length?(r.ch=t.text.length,r.sticky="before"):r.ch<=0&&(r.ch=0,r.sticky="after");var o=ae(i,r.ch,r.sticky),l=i[o];if("ltr"==e.doc.direction&&l.level%2==0&&(n>0?l.to>r.ch:l.from=l.from&&f>=c.begin)){var d=h?"before":"after";return new et(r.line,f,d)}}var p=function(e,t,n){for(var o=function(e,t){return t?new et(r.line,a(e,1),"before"):new et(r.line,e,"after")};e>=0&&e0==(1!=l.level),u=s?n.begin:a(n.end,-1);if(l.from<=u&&u0?c.end:a(c.begin,-1);return null==v||n>0&&v==t.text.length||!(g=p(n>0?0:i.length-1,n,u(v)))?null:g}(e.cm,s,t,r):qo(s,t,r);if(null==l){if(o||(u=t.line+a)=e.first+e.size||(t=new et(u,t.ch,t.sticky),!(s=Xe(e,u))))return!1;t=Zo(i,e.cm,s,t.line,a)}else t=l;return!0}if("char"==n||"codepoint"==n)u();else if("column"==n)u(!0);else if("word"==n||"group"==n)for(var c=null,h="group"==n,f=e.cm&&e.cm.getHelper(t,"wordChars"),d=!0;!(r<0)||u(!d);d=!1){var p=s.text.charAt(t.ch)||"\n",g=te(p,f)?"w":h&&"\n"==p?"n":!h||/\s/.test(p)?null:"p";if(!h||d||g||(g="s"),c&&c!=g){r<0&&(r=1,u(),t.sticky="after");break}if(g&&(c=g),r>0&&!u(!d))break}var v=ro(e,t,o,l,!0);return rt(o,v)&&(v.hitSide=!0),v}function El(e,t,r,n){var i,o,l=e.doc,s=t.left;if("page"==n){var a=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),u=Math.max(a-.5*en(e.display),3);i=(r>0?t.bottom:t.top)+r*u}else"line"==n&&(i=r>0?t.bottom+3:t.top-3);for(;(o=_r(e,s,i)).outside;){if(r<0?i<=0:i>=l.height){o.hitSide=!0;break}i+=5*r}return o}var Il=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new z,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};function Rl(e,t){var r=Ar(e,t.line);if(!r||r.hidden)return null;var n=Xe(e.doc,t.line),i=Nr(r,n,t.line),o=ce(n,e.doc.direction),l="left";o&&(l=ae(o,t.ch)%2?"right":"left");var s=Pr(i.map,t.ch,l);return s.offset="right"==s.collapse?s.end:s.start,s}function zl(e,t){return t&&(e.bad=!0),e}function Bl(e,t,r){var n;if(t==e.display.lineDiv){if(!(n=e.display.lineDiv.childNodes[r]))return zl(e.clipPos(et(e.display.viewTo-1)),!0);t=null,r=0}else for(n=t;;n=n.parentNode){if(!n||n==e.display.lineDiv)return null;if(n.parentNode&&n.parentNode==e.display.lineDiv)break}for(var i=0;i=t.display.viewTo||o.line=t.display.viewFrom&&Rl(t,i)||{node:a[0].measure.map[2],offset:0},c=o.linen.firstLine()&&(l=et(l.line-1,Xe(n.doc,l.line-1).length)),s.ch==Xe(n.doc,s.line).text.length&&s.linei.viewTo-1)return!1;l.line==i.viewFrom||0==(e=an(n,l.line))?(t=qe(i.view[0].line),r=i.view[0].node):(t=qe(i.view[e].line),r=i.view[e-1].node.nextSibling);var a,u,c=an(n,s.line);if(c==i.view.length-1?(a=i.viewTo-1,u=i.lineDiv.lastChild):(a=qe(i.view[c+1].line)-1,u=i.view[c+1].node.previousSibling),!r)return!1;for(var h=n.doc.splitLines(function(e,t,r,n,i){var o="",l=!1,s=e.doc.lineSeparator(),a=!1;function u(){l&&(o+=s,a&&(o+=s),l=a=!1)}function c(e){e&&(u(),o+=e)}function h(t){if(1==t.nodeType){var r=t.getAttribute("cm-text");if(r)return void c(r);var o,f=t.getAttribute("cm-marker");if(f){var d=e.findMarks(et(n,0),et(i+1,0),(v=+f,function(e){return e.id==v}));return void(d.length&&(o=d[0].find(0))&&c(Ye(e.doc,o.from,o.to).join(s)))}if("false"==t.getAttribute("contenteditable"))return;var p=/^(pre|div|p|li|table|br)$/i.test(t.nodeName);if(!/^br$/i.test(t.nodeName)&&0==t.textContent.length)return;p&&u();for(var g=0;g1&&f.length>1;)if(_(h)==_(f))h.pop(),f.pop(),a--;else{if(h[0]!=f[0])break;h.shift(),f.shift(),t++}for(var d=0,p=0,g=h[0],v=f[0],m=Math.min(g.length,v.length);dl.ch&&y.charCodeAt(y.length-p-1)==b.charCodeAt(b.length-p-1);)d--,p++;h[h.length-1]=y.slice(0,y.length-p).replace(/^\u200b+/,""),h[0]=h[0].slice(d).replace(/\u200b+$/,"");var x=et(t,d),C=et(a,f.length?_(f).length-p:0);return h.length>1||h[0]||tt(x,C)?(ho(n.doc,h,x,C,"+input"),!0):void 0},Il.prototype.ensurePolled=function(){this.forceCompositionEnd()},Il.prototype.reset=function(){this.forceCompositionEnd()},Il.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},Il.prototype.readFromDOMSoon=function(){var e=this;null==this.readDOMTimeout&&(this.readDOMTimeout=setTimeout(function(){if(e.readDOMTimeout=null,e.composing){if(!e.composing.done)return;e.composing=null}e.updateFromDOM()},80))},Il.prototype.updateFromDOM=function(){var e=this;!this.cm.isReadOnly()&&this.pollContent()||qn(this.cm,function(){return un(e.cm)})},Il.prototype.setUneditable=function(e){e.contentEditable="false"},Il.prototype.onKeyPress=function(e){0==e.charCode||this.composing||(e.preventDefault(),this.cm.isReadOnly()||Zn(this.cm,Ol)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0))},Il.prototype.readOnlyChanged=function(e){this.div.contentEditable=String("nocursor"!=e)},Il.prototype.onContextMenu=function(){},Il.prototype.resetPosition=function(){},Il.prototype.needsContentAttribute=!0;var Ul=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new z,this.hasSelection=!1,this.composing=null};Ul.prototype.init=function(e){var t=this,r=this,n=this.cm;this.createField(e);var i=this.textarea;function o(e){if(!ve(n,e)){if(n.somethingSelected())Nl({lineWise:!1,text:n.getSelections()});else{if(!n.options.lineWiseCopyCut)return;var t=Wl(n);Nl({lineWise:!0,text:t.text}),"cut"==e.type?n.setSelections(t.ranges,null,V):(r.prevInput="",i.value=t.text.join("\n"),P(i))}"cut"==e.type&&(n.state.cutIncoming=+new Date)}}e.wrapper.insertBefore(this.wrapper,e.wrapper.firstChild),g&&(i.style.width="0px"),fe(i,"input",function(){l&&s>=9&&t.hasSelection&&(t.hasSelection=null),r.poll()}),fe(i,"paste",function(e){ve(n,e)||Al(e,n)||(n.state.pasteIncoming=+new Date,r.fastPoll())}),fe(i,"cut",o),fe(i,"copy",o),fe(e.scroller,"paste",function(t){if(!xr(e,t)&&!ve(n,t)){if(!i.dispatchEvent)return n.state.pasteIncoming=+new Date,void r.focus();var o=new Event("paste");o.clipboardData=t.clipboardData,i.dispatchEvent(o)}}),fe(e.lineSpace,"selectstart",function(t){xr(e,t)||we(t)}),fe(i,"compositionstart",function(){var e=n.getCursor("from");r.composing&&r.composing.range.clear(),r.composing={start:e,range:n.markText(e,n.getCursor("to"),{className:"CodeMirror-composing"})}}),fe(i,"compositionend",function(){r.composing&&(r.poll(),r.composing.range.clear(),r.composing=null)})},Ul.prototype.createField=function(e){this.wrapper=Fl(),this.textarea=this.wrapper.firstChild},Ul.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},Ul.prototype.prepareSelection=function(){var e=this.cm,t=e.display,r=e.doc,n=gn(e);if(e.options.moveInputWithCursor){var i=Xr(e,r.sel.primary().head,"div"),o=t.wrapper.getBoundingClientRect(),l=t.lineDiv.getBoundingClientRect();n.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+l.top-o.top)),n.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+l.left-o.left))}return n},Ul.prototype.showSelection=function(e){var t=this.cm.display;N(t.cursorDiv,e.cursors),N(t.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},Ul.prototype.reset=function(e){if(!this.contextMenuPending&&!this.composing){var t=this.cm;if(t.somethingSelected()){this.prevInput="";var r=t.getSelection();this.textarea.value=r,t.state.focused&&P(this.textarea),l&&s>=9&&(this.hasSelection=r)}else e||(this.prevInput=this.textarea.value="",l&&s>=9&&(this.hasSelection=null))}},Ul.prototype.getField=function(){return this.textarea},Ul.prototype.supportsTouch=function(){return!1},Ul.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!m||W()!=this.textarea))try{this.textarea.focus()}catch(e){}},Ul.prototype.blur=function(){this.textarea.blur()},Ul.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},Ul.prototype.receivedFocus=function(){this.slowPoll()},Ul.prototype.slowPoll=function(){var e=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},Ul.prototype.fastPoll=function(){var e=!1,t=this;t.pollingFast=!0,t.polling.set(20,function r(){t.poll()||e?(t.pollingFast=!1,t.slowPoll()):(e=!0,t.polling.set(60,r))})},Ul.prototype.poll=function(){var e=this,t=this.cm,r=this.textarea,n=this.prevInput;if(this.contextMenuPending||!t.state.focused||He(r)&&!n&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var i=r.value;if(i==n&&!t.somethingSelected())return!1;if(l&&s>=9&&this.hasSelection===i||y&&/[\uf700-\uf7ff]/.test(i))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var o=i.charCodeAt(0);if(8203!=o||n||(n="​"),8666==o)return this.reset(),this.cm.execCommand("undo")}for(var a=0,u=Math.min(n.length,i.length);a1e3||i.indexOf("\n")>-1?r.value=e.prevInput="":e.prevInput=i,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},Ul.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},Ul.prototype.onKeyPress=function(){l&&s>=9&&(this.hasSelection=null),this.fastPoll()},Ul.prototype.onContextMenu=function(e){var t=this,r=t.cm,n=r.display,i=t.textarea;t.contextMenuPending&&t.contextMenuPending();var o=sn(r,e),u=n.scroller.scrollTop;if(o&&!h){r.options.resetSelectionOnContextMenu&&-1==r.doc.sel.contains(o)&&Zn(r,qi)(r.doc,Ci(o),V);var c,f=i.style.cssText,d=t.wrapper.style.cssText,p=t.wrapper.offsetParent.getBoundingClientRect();if(t.wrapper.style.cssText="position: static",i.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(e.clientY-p.top-5)+"px; left: "+(e.clientX-p.left-5)+"px;\n z-index: 1000; background: "+(l?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",a&&(c=window.scrollY),n.input.focus(),a&&window.scrollTo(null,c),n.input.reset(),r.somethingSelected()||(i.value=t.prevInput=" "),t.contextMenuPending=m,n.selForContextMenu=r.doc.sel,clearTimeout(n.detectingSelectAll),l&&s>=9&&v(),S){Se(e);var g=function(){pe(window,"mouseup",g),setTimeout(m,20)};fe(window,"mouseup",g)}else setTimeout(m,50)}function v(){if(null!=i.selectionStart){var e=r.somethingSelected(),o="​"+(e?i.value:"");i.value="⇚",i.value=o,t.prevInput=e?"":"​",i.selectionStart=1,i.selectionEnd=o.length,n.selForContextMenu=r.doc.sel}}function m(){if(t.contextMenuPending==m&&(t.contextMenuPending=!1,t.wrapper.style.cssText=d,i.style.cssText=f,l&&s<9&&n.scrollbars.setScrollTop(n.scroller.scrollTop=u),null!=i.selectionStart)){(!l||l&&s<9)&&v();var e=0,o=function(){n.selForContextMenu==r.doc.sel&&0==i.selectionStart&&i.selectionEnd>0&&"​"==t.prevInput?Zn(r,io)(r):e++<10?n.detectingSelectAll=setTimeout(o,500):(n.selForContextMenu=null,n.input.reset())};n.detectingSelectAll=setTimeout(o,200)}}},Ul.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled="nocursor"==e,this.textarea.readOnly=!!e},Ul.prototype.setUneditable=function(){},Ul.prototype.needsContentAttribute=!1,function(e){var t=e.optionHandlers;function r(r,n,i,o){e.defaults[r]=n,i&&(t[r]=o?function(e,t,r){r!=bl&&i(e,t,r)}:i)}e.defineOption=r,e.Init=bl,r("value","",function(e,t){return e.setValue(t)},!0),r("mode",null,function(e,t){e.doc.modeOption=t,Mi(e)},!0),r("indentUnit",2,Mi,!0),r("indentWithTabs",!1),r("smartIndent",!0),r("tabSize",4,function(e){Ni(e),zr(e),un(e)},!0),r("lineSeparator",null,function(e,t){if(e.doc.lineSep=t,t){var r=[],n=e.doc.first;e.doc.iter(function(e){for(var i=0;;){var o=e.text.indexOf(t,i);if(-1==o)break;i=o+t.length,r.push(et(n,o))}n++});for(var i=r.length-1;i>=0;i--)ho(e.doc,t,r[i],et(r[i].line,r[i].ch+t.length))}}),r("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,function(e,t,r){e.state.specialChars=new RegExp(t.source+(t.test("\t")?"":"|\t"),"g"),r!=bl&&e.refresh()}),r("specialCharPlaceholder",Qt,function(e){return e.refresh()},!0),r("electricChars",!0),r("inputStyle",m?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),r("spellcheck",!1,function(e,t){return e.getInputField().spellcheck=t},!0),r("autocorrect",!1,function(e,t){return e.getInputField().autocorrect=t},!0),r("autocapitalize",!1,function(e,t){return e.getInputField().autocapitalize=t},!0),r("rtlMoveVisually",!w),r("wholeLineUpdateBefore",!0),r("theme","default",function(e){yl(e),fi(e)},!0),r("keyMap","default",function(e,t,r){var n=Yo(t),i=r!=bl&&Yo(r);i&&i.detach&&i.detach(e,n),n.attach&&n.attach(e,i||null)}),r("extraKeys",null),r("configureMouse",null),r("lineWrapping",!1,Sl,!0),r("gutters",[],function(e,t){e.display.gutterSpecs=ci(t,e.options.lineNumbers),fi(e)},!0),r("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?nn(e.display)+"px":"0",e.refresh()},!0),r("coverGutterNextToScrollbar",!1,function(e){return zn(e)},!0),r("scrollbarStyle","native",function(e){Un(e),zn(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),r("lineNumbers",!1,function(e,t){e.display.gutterSpecs=ci(e.options.gutters,t),fi(e)},!0),r("firstLineNumber",1,fi,!0),r("lineNumberFormatter",function(e){return e},fi,!0),r("showCursorWhenSelecting",!1,pn,!0),r("resetSelectionOnContextMenu",!0),r("lineWiseCopyCut",!0),r("pasteLinesPerSelection",!0),r("selectionsMayTouch",!1),r("readOnly",!1,function(e,t){"nocursor"==t&&(Sn(e),e.display.input.blur()),e.display.input.readOnlyChanged(t)}),r("screenReaderLabel",null,function(e,t){t=""===t?null:t,e.display.input.screenReaderLabelChanged(t)}),r("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),r("dragDrop",!0,Cl),r("allowDropFileTypes",null),r("cursorBlinkRate",530),r("cursorScrollMargin",0),r("cursorHeight",1,pn,!0),r("singleCursorHeightPerLine",!0,pn,!0),r("workTime",100),r("workDelay",100),r("flattenSpans",!0,Ni,!0),r("addModeClass",!1,Ni,!0),r("pollInterval",100),r("undoDepth",200,function(e,t){return e.doc.history.undoDepth=t}),r("historyEventDelay",1250),r("viewportMargin",10,function(e){return e.refresh()},!0),r("maxHighlightLength",1e4,Ni,!0),r("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),r("tabindex",null,function(e,t){return e.display.input.getField().tabIndex=t||""}),r("autofocus",null),r("direction","ltr",function(e,t){return e.doc.setDirection(t)},!0),r("phrases",null)}(Ll),function(e){var t=e.optionHandlers,r=e.helpers={};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,r){var n=this.options,i=n[e];n[e]==r&&"mode"!=e||(n[e]=r,t.hasOwnProperty(e)&&Zn(this,t[e])(this,r,i),ge(this,"optionChange",this,e))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](Yo(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,r=0;rr&&(Tl(this,i.head.line,e,!0),r=i.head.line,n==this.doc.sel.primIndex&&On(this));else{var o=i.from(),l=i.to(),s=Math.max(r,o.line);r=Math.min(this.lastLine(),l.line-(l.ch?0:1))+1;for(var a=s;a0&&Yi(this.doc,n,new wi(o,u[n].to()),V)}}}),getTokenAt:function(e,t){return yt(this,e,t)},getLineTokens:function(e,t){return yt(this,et(e),t,!0)},getTokenTypeAt:function(e){e=st(this.doc,e);var t,r=ft(this,Xe(this.doc,e.line)),n=0,i=(r.length-1)/2,o=e.ch;if(0==o)t=r[2];else for(;;){var l=n+i>>1;if((l?r[2*l-1]:0)>=o)i=l;else{if(!(r[2*l+1]o&&(e=o,i=!0),n=Xe(this.doc,e)}else n=e;return Vr(this,n,{top:0,left:0},t||"page",r||i).top+(i?this.doc.height-Vt(n):0)},defaultTextHeight:function(){return en(this.display)},defaultCharWidth:function(){return tn(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,r,n,i){var o,l,s,a=this.display,u=(e=Xr(this,st(this.doc,e))).bottom,c=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),a.sizer.appendChild(t),"over"==n)u=e.top;else if("above"==n||"near"==n){var h=Math.max(a.wrapper.clientHeight,this.doc.height),f=Math.max(a.sizer.clientWidth,a.lineSpace.clientWidth);("above"==n||e.bottom+t.offsetHeight>h)&&e.top>t.offsetHeight?u=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=h&&(u=e.bottom),c+t.offsetWidth>f&&(c=f-t.offsetWidth)}t.style.top=u+"px",t.style.left=t.style.right="","right"==i?(c=a.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?c=0:"middle"==i&&(c=(a.sizer.clientWidth-t.offsetWidth)/2),t.style.left=c+"px"),r&&(o=this,l={left:c,top:u,right:c+t.offsetWidth,bottom:u+t.offsetHeight},null!=(s=Mn(o,l)).scrollTop&&Hn(o,s.scrollTop),null!=s.scrollLeft&&Pn(o,s.scrollLeft))},triggerOnKeyDown:Qn(sl),triggerOnKeyPress:Qn(ul),triggerOnKeyUp:al,triggerOnMouseDown:Qn(dl),execCommand:function(e){if(Qo.hasOwnProperty(e))return Qo[e].call(null,this)},triggerElectric:Qn(function(e){Dl(this,e)}),findPosH:function(e,t,r,n){var i=1;t<0&&(i=-1,t=-t);for(var o=st(this.doc,e),l=0;l0&&l(t.charAt(r-1));)--r;for(;n.5||this.options.lineWrapping)&&ln(this),ge(this,"refresh",this)}),swapDoc:Qn(function(e){var t=this.doc;return t.cm=null,this.state.selectingText&&this.state.selectingText(),Wi(this,e),zr(this),this.display.input.reset(),An(this,e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,sr(this,"swapDoc",this,t),t}),phrase:function(e){var t=this.options.phrases;return t&&Object.prototype.hasOwnProperty.call(t,e)?t[e]:e},getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},be(e),e.registerHelper=function(t,n,i){r.hasOwnProperty(t)||(r[t]=e[t]={_global:[]}),r[t][n]=i},e.registerGlobalHelper=function(t,n,i,o){e.registerHelper(t,n,o),r[t]._global.push({pred:i,val:o})}}(Ll);var Vl="iter insert remove copy getEditor constructor".split(" ");for(var Kl in No.prototype)No.prototype.hasOwnProperty(Kl)&&B(Vl,Kl)<0&&(Ll.prototype[Kl]=function(e){return function(){return e.apply(this.doc,arguments)}}(No.prototype[Kl]));return be(No),Ll.inputStyles={textarea:Ul,contenteditable:Il},Ll.defineMode=function(e){Ll.defaults.mode||"null"==e||(Ll.defaults.mode=e),function(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Ee[e]=t}.apply(this,arguments)},Ll.defineMIME=function(e,t){Ie[e]=t},Ll.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),Ll.defineMIME("text/plain","null"),Ll.defineExtension=function(e,t){Ll.prototype[e]=t},Ll.defineDocExtension=function(e,t){No.prototype[e]=t},Ll.fromTextArea=function(e,t){if((t=t?I(t):{}).value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),null==t.autofocus){var r=W();t.autofocus=r==e||null!=e.getAttribute("autofocus")&&r==document.body}function n(){e.value=s.getValue()}var i;if(e.form&&(fe(e.form,"submit",n),!t.leaveSubmitMethodAlone)){var o=e.form;i=o.submit;try{var l=o.submit=function(){n(),o.submit=i,o.submit(),o.submit=l}}catch(e){}}t.finishInit=function(r){r.save=n,r.getTextArea=function(){return e},r.toTextArea=function(){r.toTextArea=isNaN,n(),e.parentNode.removeChild(r.getWrapperElement()),e.style.display="",e.form&&(pe(e.form,"submit",n),t.leaveSubmitMethodAlone||"function"!=typeof e.form.submit||(e.form.submit=i))}},e.style.display="none";var s=Ll(function(t){return e.parentNode.insertBefore(t,e.nextSibling)},t);return s},function(e){e.off=pe,e.on=fe,e.wheelEventPixels=mi,e.Doc=No,e.splitLines=We,e.countColumn=R,e.findColumn=X,e.isWordChar=ee,e.Pass=U,e.signal=ge,e.Line=Xt,e.changeEnd=Si,e.scrollbarModel=Gn,e.Pos=et,e.cmpPos=tt,e.modes=Ee,e.mimeModes=Ie,e.resolveMode=Re,e.getMode=ze,e.modeExtensions=Be,e.extendMode=Ge,e.copyState=Ue,e.startState=Ke,e.innerMode=Ve,e.commands=Qo,e.keyMap=Bo,e.keyName=Xo,e.isModifierKey=Ko,e.lookupKey=Vo,e.normalizeKeyMap=Uo,e.StringStream=je,e.SharedTextMarker=Lo,e.TextMarker=Co,e.LineWidget=bo,e.e_preventDefault=we,e.e_stopPropagation=xe,e.e_stop=Se,e.addClass=H,e.contains=D,e.rmClass=T,e.keyNames=Eo}(Ll),Ll.version="5.65.2",Ll}); -},{}],725:[function(require,module,exports){ +},{}],726:[function(require,module,exports){ !function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.defineMode("javascript",function(t,r){var n,a,i=t.indentUnit,o=r.statementIndent,c=r.jsonld,s=r.json||c,u=!1!==r.trackScope,f=r.typescript,l=r.wordCharacters||/[\w$\xa1-\uffff]/,d=function(){function e(e){return{type:e,style:"keyword"}}var t=e("keyword a"),r=e("keyword b"),n=e("keyword c"),a=e("keyword d"),i=e("operator"),o={type:"atom",style:"atom"};return{if:e("if"),while:t,with:t,else:r,do:r,try:r,finally:r,return:a,break:a,continue:a,new:e("new"),delete:n,void:n,throw:n,debugger:e("debugger"),var:e("var"),const:e("var"),let:e("var"),function:e("function"),catch:e("catch"),for:e("for"),switch:e("switch"),case:e("case"),default:e("default"),in:i,typeof:i,instanceof:i,true:o,false:o,null:o,undefined:o,NaN:o,Infinity:o,this:e("this"),class:e("class"),super:e("atom"),yield:n,export:e("export"),import:e("import"),extends:n,await:n}}(),p=/[+\-*&%=<>!?|~^@]/,m=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;function v(e,t,r){return n=e,a=r,t}function k(e,t){var r,n=e.next();if('"'==n||"'"==n)return t.tokenize=(r=n,function(e,t){var n,a=!1;if(c&&"@"==e.peek()&&e.match(m))return t.tokenize=k,v("jsonld-keyword","meta");for(;null!=(n=e.next())&&(n!=r||a);)a=!a&&"\\"==n;return a||(t.tokenize=k),v("string","string")}),t.tokenize(e,t);if("."==n&&e.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/))return v("number","number");if("."==n&&e.match(".."))return v("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(n))return v(n);if("="==n&&e.eat(">"))return v("=>","operator");if("0"==n&&e.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/))return v("number","number");if(/\d/.test(n))return e.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/),v("number","number");if("/"==n)return e.eat("*")?(t.tokenize=y,y(e,t)):e.eat("/")?(e.skipToEnd(),v("comment","comment")):Ze(e,t,1)?(function(e){for(var t,r=!1,n=!1;null!=(t=e.next());){if(!r){if("/"==t&&!n)return;"["==t?n=!0:n&&"]"==t&&(n=!1)}r=!r&&"\\"==t}}(e),e.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/),v("regexp","string-2")):(e.eat("="),v("operator","operator",e.current()));if("`"==n)return t.tokenize=w,w(e,t);if("#"==n&&"!"==e.peek())return e.skipToEnd(),v("meta","meta");if("#"==n&&e.eatWhile(l))return v("variable","property");if("<"==n&&e.match("!--")||"-"==n&&e.match("->")&&!/\S/.test(e.string.slice(0,e.start)))return e.skipToEnd(),v("comment","comment");if(p.test(n))return">"==n&&t.lexical&&">"==t.lexical.type||(e.eat("=")?"!"!=n&&"="!=n||e.eat("="):/[<>*+\-|&?]/.test(n)&&(e.eat(n),">"==n&&e.eat(n))),"?"==n&&e.eat(".")?v("."):v("operator","operator",e.current());if(l.test(n)){e.eatWhile(l);var a=e.current();if("."!=t.lastType){if(d.propertyIsEnumerable(a)){var i=d[a];return v(i.type,i.style,a)}if("async"==a&&e.match(/^(\s|\/\*([^*]|\*(?!\/))*?\*\/)*[\[\(\w]/,!1))return v("async","keyword",a)}return v("variable","variable",a)}}function y(e,t){for(var r,n=!1;r=e.next();){if("/"==r&&n){t.tokenize=k;break}n="*"==r}return v("comment","comment")}function w(e,t){for(var r,n=!1;null!=(r=e.next());){if(!n&&("`"==r||"$"==r&&e.eat("{"))){t.tokenize=k;break}n=!n&&"\\"==r}return v("quasi","string-2",e.current())}var b="([{}])";function x(e,t){t.fatArrowAt&&(t.fatArrowAt=null);var r=e.string.indexOf("=>",e.start);if(!(r<0)){if(f){var n=/:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(e.string.slice(e.start,r));n&&(r=n.index)}for(var a=0,i=!1,o=r-1;o>=0;--o){var c=e.string.charAt(o),s=b.indexOf(c);if(s>=0&&s<3){if(!a){++o;break}if(0==--a){"("==c&&(i=!0);break}}else if(s>=3&&s<6)++a;else if(l.test(c))i=!0;else if(/["'\/`]/.test(c))for(;;--o){if(0==o)return;if(e.string.charAt(o-1)==c&&"\\"!=e.string.charAt(o-2)){o--;break}}else if(i&&!a){++o;break}}i&&!a&&(t.fatArrowAt=o)}}var h={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,this:!0,import:!0,"jsonld-keyword":!0};function g(e,t,r,n,a,i){this.indented=e,this.column=t,this.type=r,this.prev=a,this.info=i,null!=n&&(this.align=n)}function j(e,t){if(!u)return!1;for(var r=e.localVars;r;r=r.next)if(r.name==t)return!0;for(var n=e.context;n;n=n.prev)for(r=n.vars;r;r=r.next)if(r.name==t)return!0}function M(e,t,r,n,a){var i=e.cc;for(A.state=e,A.stream=a,A.marked=null,A.cc=i,A.style=t,e.lexical.hasOwnProperty("align")||(e.lexical.align=!0);;){if((i.length?i.pop():s?F:W)(r,n)){for(;i.length&&i[i.length-1].lex;)i.pop()();return A.marked?A.marked:"variable"==r&&j(e,n)?"variable-2":t}}}var A={state:null,column:null,marked:null,cc:null};function V(){for(var e=arguments.length-1;e>=0;e--)A.cc.push(arguments[e])}function E(){return V.apply(null,arguments),!0}function z(e,t){for(var r=t;r;r=r.next)if(r.name==e)return!0;return!1}function I(e){var t=A.state;if(A.marked="def",u){if(t.context)if("var"==t.lexical.info&&t.context&&t.context.block){var n=function e(t,r){if(r){if(r.block){var n=e(t,r.prev);return n?n==r.prev?r:new $(n,r.vars,!0):null}return z(t,r.vars)?r:new $(r.prev,new q(t,r.vars),!1)}return null}(e,t.context);if(null!=n)return void(t.context=n)}else if(!z(e,t.localVars))return void(t.localVars=new q(e,t.localVars));r.globalVars&&!z(e,t.globalVars)&&(t.globalVars=new q(e,t.globalVars))}}function T(e){return"public"==e||"private"==e||"protected"==e||"abstract"==e||"readonly"==e}function $(e,t,r){this.prev=e,this.vars=t,this.block=r}function q(e,t){this.name=e,this.next=t}var C=new q("this",new q("arguments",null));function S(){A.state.context=new $(A.state.context,A.state.localVars,!1),A.state.localVars=C}function _(){A.state.context=new $(A.state.context,A.state.localVars,!0),A.state.localVars=null}function O(){A.state.localVars=A.state.context.vars,A.state.context=A.state.context.prev}function P(e,t){var r=function(){var r=A.state,n=r.indented;if("stat"==r.lexical.type)n=r.lexical.indented;else for(var a=r.lexical;a&&")"==a.type&&a.align;a=a.prev)n=a.indented;r.lexical=new g(n,A.stream.column(),e,null,r.lexical,t)};return r.lex=!0,r}function N(){var e=A.state;e.lexical.prev&&(")"==e.lexical.type&&(e.indented=e.lexical.indented),e.lexical=e.lexical.prev)}function U(e){return function t(r){return r==e?E():";"==e||"}"==r||")"==r||"]"==r?V():E(t)}}function W(e,t){return"var"==e?E(P("vardef",t),Me,U(";"),N):"keyword a"==e?E(P("form"),D,W,N):"keyword b"==e?E(P("form"),W,N):"keyword d"==e?A.stream.match(/^\s*$/,!1)?E():E(P("stat"),J,U(";"),N):"debugger"==e?E(U(";")):"{"==e?E(P("}"),_,se,N,O):";"==e?E():"if"==e?("else"==A.state.lexical.info&&A.state.cc[A.state.cc.length-1]==N&&A.state.cc.pop()(),E(P("form"),D,W,N,Te)):"function"==e?E(Se):"for"==e?E(P("form"),_,$e,W,O,N):"class"==e||f&&"interface"==t?(A.marked="keyword",E(P("form","class"==e?e:t),Ue,N)):"variable"==e?f&&"declare"==t?(A.marked="keyword",E(W)):f&&("module"==t||"enum"==t||"type"==t)&&A.stream.match(/^\s*\w/,!1)?(A.marked="keyword","enum"==t?E(Xe):"type"==t?E(Oe,U("operator"),pe,U(";")):E(P("form"),Ae,U("{"),P("}"),se,N,N)):f&&"namespace"==t?(A.marked="keyword",E(P("form"),F,W,N)):f&&"abstract"==t?(A.marked="keyword",E(W)):E(P("stat"),te):"switch"==e?E(P("form"),D,U("{"),P("}","switch"),_,se,N,N,O):"case"==e?E(F,U(":")):"default"==e?E(U(":")):"catch"==e?E(P("form"),S,B,W,N,O):"export"==e?E(P("stat"),He,N):"import"==e?E(P("stat"),Ge,N):"async"==e?E(W):"@"==t?E(F,W):V(P("stat"),F,U(";"),N)}function B(e){if("("==e)return E(Pe,U(")"))}function F(e,t){return G(e,t,!1)}function H(e,t){return G(e,t,!0)}function D(e){return"("!=e?V():E(P(")"),J,U(")"),N)}function G(e,t,r){if(A.state.fatArrowAt==A.stream.start){var n=r?Y:X;if("("==e)return E(S,P(")"),oe(Pe,")"),N,U("=>"),n,O);if("variable"==e)return V(S,Ae,U("=>"),n,O)}var a=r?L:K;return h.hasOwnProperty(e)?E(a):"function"==e?E(Se,a):"class"==e||f&&"interface"==t?(A.marked="keyword",E(P("form"),Ne,N)):"keyword c"==e||"async"==e?E(r?H:F):"("==e?E(P(")"),J,U(")"),N,a):"operator"==e||"spread"==e?E(r?H:F):"["==e?E(P("]"),Re,N,a):"{"==e?ce(ne,"}",null,a):"quasi"==e?V(Q,a):"new"==e?E(function(e){return function(t){return"."==t?E(e?ee:Z):"variable"==t&&f?E(he,e?L:K):V(e?H:F)}}(r)):E()}function J(e){return e.match(/[;\}\)\],]/)?V():V(F)}function K(e,t){return","==e?E(J):L(e,t,!1)}function L(e,t,r){var n=0==r?K:L,a=0==r?F:H;return"=>"==e?E(S,r?Y:X,O):"operator"==e?/\+\+|--/.test(t)||f&&"!"==t?E(n):f&&"<"==t&&A.stream.match(/^([^<>]|<[^<>]*>)*>\s*\(/,!1)?E(P(">"),oe(pe,">"),N,n):"?"==t?E(F,U(":"),a):E(a):"quasi"==e?V(Q,n):";"!=e?"("==e?ce(H,")","call",n):"."==e?E(re,n):"["==e?E(P("]"),J,U("]"),N,n):f&&"as"==t?(A.marked="keyword",E(pe,n)):"regexp"==e?(A.state.lastType=A.marked="operator",A.stream.backUp(A.stream.pos-A.stream.start-1),E(a)):void 0:void 0}function Q(e,t){return"quasi"!=e?V():"${"!=t.slice(t.length-2)?E(Q):E(J,R)}function R(e){if("}"==e)return A.marked="string-2",A.state.tokenize=w,E(Q)}function X(e){return x(A.stream,A.state),V("{"==e?W:F)}function Y(e){return x(A.stream,A.state),V("{"==e?W:H)}function Z(e,t){if("target"==t)return A.marked="keyword",E(K)}function ee(e,t){if("target"==t)return A.marked="keyword",E(L)}function te(e){return":"==e?E(N,W):V(K,U(";"),N)}function re(e){if("variable"==e)return A.marked="property",E()}function ne(e,t){return"async"==e?(A.marked="property",E(ne)):"variable"==e||"keyword"==A.style?(A.marked="property","get"==t||"set"==t?E(ae):(f&&A.state.fatArrowAt==A.stream.start&&(r=A.stream.match(/^\s*:\s*/,!1))&&(A.state.fatArrowAt=A.stream.pos+r[0].length),E(ie))):"number"==e||"string"==e?(A.marked=c?"property":A.style+" property",E(ie)):"jsonld-keyword"==e?E(ie):f&&T(t)?(A.marked="keyword",E(ne)):"["==e?E(F,ue,U("]"),ie):"spread"==e?E(H,ie):"*"==t?(A.marked="keyword",E(ne)):":"==e?V(ie):void 0;var r}function ae(e){return"variable"!=e?V(ie):(A.marked="property",E(Se))}function ie(e){return":"==e?E(H):"("==e?V(Se):void 0}function oe(e,t,r){function n(a,i){if(r?r.indexOf(a)>-1:","==a){var o=A.state.lexical;return"call"==o.info&&(o.pos=(o.pos||0)+1),E(function(r,n){return r==t||n==t?V():V(e)},n)}return a==t||i==t?E():r&&r.indexOf(";")>-1?V(e):E(U(t))}return function(r,a){return r==t||a==t?E():V(e,n)}}function ce(e,t,r){for(var n=3;n"),pe):"quasi"==e?V(ye,xe):void 0}function me(e){if("=>"==e)return E(pe)}function ve(e){return e.match(/[\}\)\]]/)?E():","==e||";"==e?E(ve):V(ke,ve)}function ke(e,t){return"variable"==e||"keyword"==A.style?(A.marked="property",E(ke)):"?"==t||"number"==e||"string"==e?E(ke):":"==e?E(pe):"["==e?E(U("variable"),fe,U("]"),ke):"("==e?V(_e,ke):e.match(/[;\}\)\],]/)?void 0:E()}function ye(e,t){return"quasi"!=e?V():"${"!=t.slice(t.length-2)?E(ye):E(pe,we)}function we(e){if("}"==e)return A.marked="string-2",A.state.tokenize=w,E(ye)}function be(e,t){return"variable"==e&&A.stream.match(/^\s*[?:]/,!1)||"?"==t?E(be):":"==e?E(pe):"spread"==e?E(be):V(pe)}function xe(e,t){return"<"==t?E(P(">"),oe(pe,">"),N,xe):"|"==t||"."==e||"&"==t?E(pe):"["==e?E(pe,U("]"),xe):"extends"==t||"implements"==t?(A.marked="keyword",E(pe)):"?"==t?E(pe,U(":"),pe):void 0}function he(e,t){if("<"==t)return E(P(">"),oe(pe,">"),N,xe)}function ge(){return V(pe,je)}function je(e,t){if("="==t)return E(pe)}function Me(e,t){return"enum"==t?(A.marked="keyword",E(Xe)):V(Ae,ue,ze,Ie)}function Ae(e,t){return f&&T(t)?(A.marked="keyword",E(Ae)):"variable"==e?(I(t),E()):"spread"==e?E(Ae):"["==e?ce(Ee,"]"):"{"==e?ce(Ve,"}"):void 0}function Ve(e,t){return"variable"!=e||A.stream.match(/^\s*:/,!1)?("variable"==e&&(A.marked="property"),"spread"==e?E(Ae):"}"==e?V():"["==e?E(F,U("]"),U(":"),Ve):E(U(":"),Ae,ze)):(I(t),E(ze))}function Ee(){return V(Ae,ze)}function ze(e,t){if("="==t)return E(H)}function Ie(e){if(","==e)return E(Me)}function Te(e,t){if("keyword b"==e&&"else"==t)return E(P("form","else"),W,N)}function $e(e,t){return"await"==t?E($e):"("==e?E(P(")"),qe,N):void 0}function qe(e){return"var"==e?E(Me,Ce):"variable"==e?E(Ce):V(Ce)}function Ce(e,t){return")"==e?E():";"==e?E(Ce):"in"==t||"of"==t?(A.marked="keyword",E(F,Ce)):V(F,Ce)}function Se(e,t){return"*"==t?(A.marked="keyword",E(Se)):"variable"==e?(I(t),E(Se)):"("==e?E(S,P(")"),oe(Pe,")"),N,le,W,O):f&&"<"==t?E(P(">"),oe(ge,">"),N,Se):void 0}function _e(e,t){return"*"==t?(A.marked="keyword",E(_e)):"variable"==e?(I(t),E(_e)):"("==e?E(S,P(")"),oe(Pe,")"),N,le,O):f&&"<"==t?E(P(">"),oe(ge,">"),N,_e):void 0}function Oe(e,t){return"keyword"==e||"variable"==e?(A.marked="type",E(Oe)):"<"==t?E(P(">"),oe(ge,">"),N):void 0}function Pe(e,t){return"@"==t&&E(F,Pe),"spread"==e?E(Pe):f&&T(t)?(A.marked="keyword",E(Pe)):f&&"this"==e?E(ue,ze):V(Ae,ue,ze)}function Ne(e,t){return"variable"==e?Ue(e,t):We(e,t)}function Ue(e,t){if("variable"==e)return I(t),E(We)}function We(e,t){return"<"==t?E(P(">"),oe(ge,">"),N,We):"extends"==t||"implements"==t||f&&","==e?("implements"==t&&(A.marked="keyword"),E(f?pe:F,We)):"{"==e?E(P("}"),Be,N):void 0}function Be(e,t){return"async"==e||"variable"==e&&("static"==t||"get"==t||"set"==t||f&&T(t))&&A.stream.match(/^\s+[\w$\xa1-\uffff]/,!1)?(A.marked="keyword",E(Be)):"variable"==e||"keyword"==A.style?(A.marked="property",E(Fe,Be)):"number"==e||"string"==e?E(Fe,Be):"["==e?E(F,ue,U("]"),Fe,Be):"*"==t?(A.marked="keyword",E(Be)):f&&"("==e?V(_e,Be):";"==e||","==e?E(Be):"}"==e?E():"@"==t?E(F,Be):void 0}function Fe(e,t){if("!"==t)return E(Fe);if("?"==t)return E(Fe);if(":"==e)return E(pe,ze);if("="==t)return E(H);var r=A.state.lexical.prev;return V(r&&"interface"==r.info?_e:Se)}function He(e,t){return"*"==t?(A.marked="keyword",E(Qe,U(";"))):"default"==t?(A.marked="keyword",E(F,U(";"))):"{"==e?E(oe(De,"}"),Qe,U(";")):V(W)}function De(e,t){return"as"==t?(A.marked="keyword",E(U("variable"))):"variable"==e?V(H,De):void 0}function Ge(e){return"string"==e?E():"("==e?V(F):"."==e?V(K):V(Je,Ke,Qe)}function Je(e,t){return"{"==e?ce(Je,"}"):("variable"==e&&I(t),"*"==t&&(A.marked="keyword"),E(Le))}function Ke(e){if(","==e)return E(Je,Ke)}function Le(e,t){if("as"==t)return A.marked="keyword",E(Je)}function Qe(e,t){if("from"==t)return A.marked="keyword",E(F)}function Re(e){return"]"==e?E():V(oe(H,"]"))}function Xe(){return V(P("form"),Ae,U("{"),P("}"),oe(Ye,"}"),N,N)}function Ye(){return V(Ae,ze)}function Ze(e,t,r){return t.tokenize==k&&/^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(t.lastType)||"quasi"==t.lastType&&/\{\s*$/.test(e.string.slice(0,e.pos-(r||0)))}return S.lex=_.lex=!0,O.lex=!0,N.lex=!0,{startState:function(e){var t={tokenize:k,lastType:"sof",cc:[],lexical:new g((e||0)-i,0,"block",!1),localVars:r.localVars,context:r.localVars&&new $(null,null,!1),indented:e||0};return r.globalVars&&"object"==typeof r.globalVars&&(t.globalVars=r.globalVars),t},token:function(e,t){if(e.sol()&&(t.lexical.hasOwnProperty("align")||(t.lexical.align=!1),t.indented=e.indentation(),x(e,t)),t.tokenize!=y&&e.eatSpace())return null;var r=t.tokenize(e,t);return"comment"==n?r:(t.lastType="operator"!=n||"++"!=a&&"--"!=a?n:"incdec",M(t,r,n,a,e))},indent:function(t,n){if(t.tokenize==y||t.tokenize==w)return e.Pass;if(t.tokenize!=k)return 0;var a,c=n&&n.charAt(0),s=t.lexical;if(!/^\s*else\b/.test(n))for(var u=t.cc.length-1;u>=0;--u){var f=t.cc[u];if(f==N)s=s.prev;else if(f!=Te&&f!=O)break}for(;("stat"==s.type||"form"==s.type)&&("}"==c||(a=t.cc[t.cc.length-1])&&(a==K||a==L)&&!/^[,\.=+\-*:?[\(]/.test(n));)s=s.prev;o&&")"==s.type&&"stat"==s.prev.type&&(s=s.prev);var l=s.type,d=c==l;return"vardef"==l?s.indented+("operator"==t.lastType||","==t.lastType?s.info.length+1:0):"form"==l&&"{"==c?s.indented:"form"==l?s.indented+i:"stat"==l?s.indented+(function(e,t){return"operator"==e.lastType||","==e.lastType||p.test(t.charAt(0))||/[,.]/.test(t.charAt(0))}(t,n)?o||i:0):"switch"!=s.info||d||0==r.doubleIndentSwitch?s.align?s.column+(d?0:1):s.indented+(d?0:i):s.indented+(/^(?:case|default)\b/.test(n)?i:2*i)},electricInput:/^\s*(?:case .*?:|default:|\{|\})$/,blockCommentStart:s?null:"/*",blockCommentEnd:s?null:"*/",blockCommentContinue:s?null:" * ",lineComment:s?null:"//",fold:"brace",closeBrackets:"()[]{}''\"\"``",helperType:s?"json":"javascript",jsonldMode:c,jsonMode:s,expressionAllowed:Ze,skipExpression:function(t){M(t,"atom","atom","true",new e.StringStream("",2,null))}}}),e.registerHelper("wordChars","javascript",/[\w$]/),e.defineMIME("text/javascript","javascript"),e.defineMIME("text/ecmascript","javascript"),e.defineMIME("application/javascript","javascript"),e.defineMIME("application/x-javascript","javascript"),e.defineMIME("application/ecmascript","javascript"),e.defineMIME("application/json",{name:"javascript",json:!0}),e.defineMIME("application/x-json",{name:"javascript",json:!0}),e.defineMIME("application/manifest+json",{name:"javascript",json:!0}),e.defineMIME("application/ld+json",{name:"javascript",jsonld:!0}),e.defineMIME("text/typescript",{name:"javascript",typescript:!0}),e.defineMIME("application/typescript",{name:"javascript",typescript:!0})}); -},{"../../lib/codemirror":724}],726:[function(require,module,exports){ +},{"../../lib/codemirror":725}],727:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_createClass=function(){function t(t,n){for(var e=0;e3?s-3:0),l=3;l3?u-3:0),s=3;s1?n-1:0),i=1;i1?n-1:0),i=1;i1?i-1:0),o=1;o1?i-1:0),o=1;o1?e-1:0),r=1;r1?e-1:0),r=1;r1?n-1:0),i=1;i1?i-1:0),o=1;o1?i-1:0),o=1;o=t.status}function n(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(n){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var o="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof global&&global.global===global?global:void 0,a=o.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),i=o.saveAs||("object"!=typeof window||window!==o?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(a,i,r){var c=o.URL||o.webkitURL,l=document.createElement("a");i=i||a.name||"download",l.download=i,l.rel="noopener","string"==typeof a?(l.href=a,l.origin===location.origin?n(l):t(l.href)?e(a,i,r):n(l,l.target="_blank")):(l.href=c.createObjectURL(a),setTimeout(function(){c.revokeObjectURL(l.href)},4e4),setTimeout(function(){n(l)},0))}:"msSaveOrOpenBlob"in navigator?function(o,a,i){if(a=a||o.name||"download","string"!=typeof o)navigator.msSaveOrOpenBlob(function(e,t){return void 0===t?t={autoBom:!1}:"object"!=typeof t&&(console.warn("Deprecated: Expected third argument to be a object"),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\ufeff",e],{type:e.type}):e}(o,i),a);else if(t(o))e(o,a,i);else{var r=document.createElement("a");r.href=o,r.target="_blank",setTimeout(function(){n(r)})}}:function(t,n,i,r){if((r=r||open("","_blank"))&&(r.document.title=r.document.body.innerText="downloading..."),"string"==typeof t)return e(t,n,i);var c="application/octet-stream"===t.type,l=/constructor/i.test(o.HTMLElement)||o.safari,s=/CriOS\/[\d]+/.test(navigator.userAgent);if((s||c&&l||a)&&"undefined"!=typeof FileReader){var f=new FileReader;f.onloadend=function(){var e=f.result;e=s?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),r?r.location.href=e:location=e,r=null},f.readAsDataURL(t)}else{var u=o.URL||o.webkitURL,d=u.createObjectURL(t);r?r.location=d:location.href=d,r=null,setTimeout(function(){u.revokeObjectURL(d)},4e4)}});o.saveAs=i.saveAs=i,"undefined"!=typeof module&&(module.exports=i)}); }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],728:[function(require,module,exports){ +},{}],729:[function(require,module,exports){ (function (process){(function (){ function isElectron(){return"undefined"!=typeof window&&"object"==typeof window.process&&"renderer"===window.process.type||(!("undefined"==typeof process||"object"!=typeof process.versions||!process.versions.electron)||"object"==typeof navigator&&"string"==typeof navigator.userAgent&&navigator.userAgent.indexOf("Electron")>=0)}module.exports=isElectron; }).call(this)}).call(this,require('_process')) -},{"_process":713}],729:[function(require,module,exports){ +},{"_process":714}],730:[function(require,module,exports){ "use strict";var range,DOCUMENT_FRAGMENT_NODE=11;function morphAttrs(e,t){var n,r,o,a,i=t.attributes;if(t.nodeType!==DOCUMENT_FRAGMENT_NODE&&e.nodeType!==DOCUMENT_FRAGMENT_NODE){for(var d=i.length-1;d>=0;d--)r=(n=i[d]).name,o=n.namespaceURI,a=n.value,o?(r=n.localName||r,e.getAttributeNS(o,r)!==a&&("xmlns"===n.prefix&&(r=n.name),e.setAttributeNS(o,r,a))):e.getAttribute(r)!==a&&e.setAttribute(r,a);for(var l=e.attributes,c=l.length-1;c>=0;c--)r=(n=l[c]).name,(o=n.namespaceURI)?(r=n.localName||r,t.hasAttributeNS(o,r)||e.removeAttributeNS(o,r)):t.hasAttribute(r)||e.removeAttribute(r)}}var NS_XHTML="http://www.w3.org/1999/xhtml",doc="undefined"==typeof document?void 0:document,HAS_TEMPLATE_SUPPORT=!!doc&&"content"in doc.createElement("template"),HAS_RANGE_SUPPORT=!!doc&&doc.createRange&&"createContextualFragment"in doc.createRange();function createFragmentFromTemplate(e){var t=doc.createElement("template");return t.innerHTML=e,t.content.childNodes[0]}function createFragmentFromRange(e){return range||(range=doc.createRange()).selectNode(doc.body),range.createContextualFragment(e).childNodes[0]}function createFragmentFromWrap(e){var t=doc.createElement("body");return t.innerHTML=e,t.childNodes[0]}function toElement(e){return e=e.trim(),HAS_TEMPLATE_SUPPORT?createFragmentFromTemplate(e):HAS_RANGE_SUPPORT?createFragmentFromRange(e):createFragmentFromWrap(e)}function compareNodeNames(e,t){var n,r,o=e.nodeName,a=t.nodeName;return o===a||(n=o.charCodeAt(0),r=a.charCodeAt(0),n<=90&&r>=97?o===a.toUpperCase():r<=90&&n>=97&&a===o.toUpperCase())}function createElementNS(e,t){return t&&t!==NS_XHTML?doc.createElementNS(t,e):doc.createElement(e)}function moveChildren(e,t){for(var n=e.firstChild;n;){var r=n.nextSibling;t.appendChild(n),n=r}return t}function syncBooleanAttrProp(e,t,n){e[n]!==t[n]&&(e[n]=t[n],e[n]?e.setAttribute(n,""):e.removeAttribute(n))}var specialElHandlers={OPTION:function(e,t){var n=e.parentNode;if(n){var r=n.nodeName.toUpperCase();"OPTGROUP"===r&&(r=(n=n.parentNode)&&n.nodeName.toUpperCase()),"SELECT"!==r||n.hasAttribute("multiple")||(e.hasAttribute("selected")&&!t.selected&&(e.setAttribute("selected","selected"),e.removeAttribute("selected")),n.selectedIndex=-1)}syncBooleanAttrProp(e,t,"selected")},INPUT:function(e,t){syncBooleanAttrProp(e,t,"checked"),syncBooleanAttrProp(e,t,"disabled"),e.value!==t.value&&(e.value=t.value),t.hasAttribute("value")||e.removeAttribute("value")},TEXTAREA:function(e,t){var n=t.value;e.value!==n&&(e.value=n);var r=e.firstChild;if(r){var o=r.nodeValue;if(o==n||!n&&o==e.placeholder)return;r.nodeValue=n}},SELECT:function(e,t){if(!t.hasAttribute("multiple")){for(var n,r,o=-1,a=0,i=e.firstChild;i;)if("OPTGROUP"===(r=i.nodeName&&i.nodeName.toUpperCase()))i=(n=i).firstChild;else{if("OPTION"===r){if(i.hasAttribute("selected")){o=a;break}a++}!(i=i.nextSibling)&&n&&(i=n.nextSibling,n=null)}e.selectedIndex=o}}},ELEMENT_NODE=1,DOCUMENT_FRAGMENT_NODE$1=11,TEXT_NODE=3,COMMENT_NODE=8;function noop(){}function defaultGetNodeKey(e){if(e)return e.getAttribute&&e.getAttribute("id")||e.id}function morphdomFactory(e){return function(t,n,r){if(r||(r={}),"string"==typeof n)if("#document"===t.nodeName||"HTML"===t.nodeName||"BODY"===t.nodeName){var o=n;(n=doc.createElement("html")).innerHTML=o}else n=toElement(n);var a=r.getNodeKey||defaultGetNodeKey,i=r.onBeforeNodeAdded||noop,d=r.onNodeAdded||noop,l=r.onBeforeElUpdated||noop,c=r.onElUpdated||noop,u=r.onBeforeNodeDiscarded||noop,N=r.onNodeDiscarded||noop,m=r.onBeforeElChildrenUpdated||noop,f=!0===r.childrenOnly,E=Object.create(null),s=[];function p(e){s.push(e)}function T(e,t,n){!1!==u(e)&&(t&&t.removeChild(e),N(e),function e(t,n){if(t.nodeType===ELEMENT_NODE)for(var r=t.firstChild;r;){var o=void 0;n&&(o=a(r))?p(o):(N(r),r.firstChild&&e(r,n)),r=r.nextSibling}}(e,n))}function v(e){d(e);for(var t=e.firstChild;t;){var n=t.nextSibling,r=a(t);if(r){var o=E[r];o&&compareNodeNames(t,o)?(t.parentNode.replaceChild(o,t),A(o,t)):v(t)}else v(t);t=n}}function A(t,n,r){var o=a(n);if(o&&delete E[o],!r){if(!1===l(t,n))return;if(e(t,n),c(t),!1===m(t,n))return}"TEXTAREA"!==t.nodeName?function(e,t){var n,r,o,d,l,c=t.firstChild,u=e.firstChild;e:for(;c;){for(d=c.nextSibling,n=a(c);u;){if(o=u.nextSibling,c.isSameNode&&c.isSameNode(u)){c=d,u=o;continue e}r=a(u);var N=u.nodeType,m=void 0;if(N===c.nodeType&&(N===ELEMENT_NODE?(n?n!==r&&((l=E[n])?o===l?m=!1:(e.insertBefore(l,u),r?p(r):T(u,e,!0),u=l):m=!1):r&&(m=!1),(m=!1!==m&&compareNodeNames(u,c))&&A(u,c)):N!==TEXT_NODE&&N!=COMMENT_NODE||(m=!0,u.nodeValue!==c.nodeValue&&(u.nodeValue=c.nodeValue))),m){c=d,u=o;continue e}r?p(r):T(u,e,!0),u=o}if(n&&(l=E[n])&&compareNodeNames(l,c))e.appendChild(l),A(l,c);else{var f=i(c);!1!==f&&(f&&(c=f),c.actualize&&(c=c.actualize(e.ownerDocument||doc)),e.appendChild(c),v(c))}c=d,u=o}!function(e,t,n){for(;t;){var r=t.nextSibling;(n=a(t))?p(n):T(t,e,!0),t=r}}(e,u,r);var s=specialElHandlers[e.nodeName];s&&s(e,t)}(t,n):specialElHandlers.TEXTAREA(t,n)}!function e(t){if(t.nodeType===ELEMENT_NODE||t.nodeType===DOCUMENT_FRAGMENT_NODE$1)for(var n=t.firstChild;n;){var r=a(n);r&&(E[r]=n),e(n),n=n.nextSibling}}(t);var h=t,O=h.nodeType,C=n.nodeType;if(!f)if(O===ELEMENT_NODE)C===ELEMENT_NODE?compareNodeNames(t,n)||(N(t),h=moveChildren(t,createElementNS(n.nodeName,n.namespaceURI))):h=n;else if(O===TEXT_NODE||O===COMMENT_NODE){if(C===O)return h.nodeValue!==n.nodeValue&&(h.nodeValue=n.nodeValue),h;h=n}if(h===n)N(t);else{if(n.isSameNode&&n.isSameNode(h))return;if(A(h,n,f),s)for(var b=0,g=s.length;b=0&&(this.sinks=e.remove(s,this.sinks)),this.sinks.length},u.prototype.event=function(t,e){var s=this.sinks;if(1===s.length)return s[0].event(t,e);for(var n=0;n= 0");var e=n.length;return 0===r||0===e?n:r>=e?[]:function(r,n,e){for(var t=new Array(e),u=0;u= 0");var e=n.length;return 0===e||r>=e?n:1===e?[]:function(r,n,e){var t,u=new Array(e);for(t=0;t= 0");for(var t=e.length,u=new Array(t),o=0;oe&©(this,0,this,e,i&e-1)}; -},{}],738:[function(require,module,exports){ +},{}],739:[function(require,module,exports){ "use strict";function Stream(e){this.source=e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=Stream,Stream.prototype.run=function(e,t){return this.source.run(e,t)}; -},{}],739:[function(require,module,exports){ +},{}],740:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.scan=scan,exports.reduce=reduce;var _Stream=require("../Stream"),_Stream2=_interopRequireDefault(_Stream),_Pipe=require("../sink/Pipe"),_Pipe2=_interopRequireDefault(_Pipe),_runSource=require("../runSource"),_dispose=require("../disposable/dispose"),dispose=_interopRequireWildcard(_dispose),_PropagateTask=require("../scheduler/PropagateTask"),_PropagateTask2=_interopRequireDefault(_PropagateTask);function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function scan(e,t,r){return new _Stream2.default(new Scan(e,t,r.source))}function Scan(e,t,r){this.source=r,this.f=e,this.value=t}function ScanSink(e,t,r){this.f=e,this.value=t,this.sink=r}function reduce(e,t,r){return(0,_runSource.withDefaultScheduler)(new Reduce(e,t,r.source))}function Reduce(e,t,r){this.source=r,this.f=e,this.value=t}function ReduceSink(e,t,r){this.f=e,this.value=t,this.sink=r}Scan.prototype.run=function(e,t){var r=t.asap(_PropagateTask2.default.event(this.value,e)),i=this.source.run(new ScanSink(this.f,this.value,e),t);return dispose.all([r,i])},ScanSink.prototype.event=function(e,t){var r=this.f;this.value=r(this.value,t),this.sink.event(e,this.value)},ScanSink.prototype.error=_Pipe2.default.prototype.error,ScanSink.prototype.end=_Pipe2.default.prototype.end,Reduce.prototype.run=function(e,t){return this.source.run(new ReduceSink(this.f,this.value,e),t)},ReduceSink.prototype.event=function(e,t){var r=this.f;this.value=r(this.value,t),this.sink.event(e,this.value)},ReduceSink.prototype.error=_Pipe2.default.prototype.error,ReduceSink.prototype.end=function(e){this.sink.end(e,this.value)}; -},{"../Stream":738,"../disposable/dispose":766,"../runSource":777,"../scheduler/PropagateTask":779,"../sink/Pipe":786}],740:[function(require,module,exports){ +},{"../Stream":739,"../disposable/dispose":767,"../runSource":778,"../scheduler/PropagateTask":780,"../sink/Pipe":787}],741:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ap=ap;var _combine=require("./combine"),_prelude=require("@most/prelude");function ap(e,r){return(0,_combine.combine)(_prelude.apply,e,r)} -},{"./combine":742,"@most/prelude":802}],741:[function(require,module,exports){ +},{"./combine":743,"@most/prelude":803}],742:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.cons=cons,exports.concat=concat;var _core=require("../source/core"),_continueWith=require("./continueWith");function cons(e,n){return concat((0,_core.of)(e),n)}function concat(e,n){return(0,_continueWith.continueWith)(function(){return n},e)} -},{"../source/core":790,"./continueWith":744}],742:[function(require,module,exports){ +},{"../source/core":791,"./continueWith":745}],743:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.combine=combine,exports.combineArray=combineArray;var _Stream=require("../Stream"),_Stream2=_interopRequireDefault(_Stream),_transform=require("./transform"),transform=_interopRequireWildcard(_transform),_core=require("../source/core"),core=_interopRequireWildcard(_core),_Pipe=require("../sink/Pipe"),_Pipe2=_interopRequireDefault(_Pipe),_IndexSink=require("../sink/IndexSink"),_IndexSink2=_interopRequireDefault(_IndexSink),_dispose=require("../disposable/dispose"),dispose=_interopRequireWildcard(_dispose),_prelude=require("@most/prelude"),base=_interopRequireWildcard(_prelude),_invoke=require("../invoke"),_invoke2=_interopRequireDefault(_invoke);function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var i={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r]);return i.default=e,i}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var map=base.map,tail=base.tail;function combine(e){return combineArray(e,tail(arguments))}function combineArray(e,i){var r=i.length;return 0===r?core.empty():1===r?transform.map(e,i[0]):new _Stream2.default(combineSources(e,i))}function combineSources(e,i){return new Combine(e,map(getSource,i))}function getSource(e){return e.source}function Combine(e,i){this.f=e,this.sources=i}function CombineSink(e,i,r,t){this.sink=r,this.disposables=e,this.sinks=i,this.f=t;var n=i.length;this.awaiting=n,this.values=new Array(n),this.hasValue=new Array(n);for(var o=0;o0&&(this.hasValue[e]||(this.hasValue[e]=!0,this.awaiting-=1)),this.awaiting},CombineSink.prototype.end=function(e,i){dispose.tryDispose(e,this.disposables[i.index],this.sink),0==--this.activeCount&&this.sink.end(e,i.value)}; -},{"../Stream":738,"../disposable/dispose":766,"../invoke":772,"../sink/IndexSink":785,"../sink/Pipe":786,"../source/core":790,"./transform":762,"@most/prelude":802}],743:[function(require,module,exports){ +},{"../Stream":739,"../disposable/dispose":767,"../invoke":773,"../sink/IndexSink":786,"../sink/Pipe":787,"../source/core":791,"./transform":763,"@most/prelude":803}],744:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.concatMap=concatMap;var _mergeConcurrently=require("./mergeConcurrently");function concatMap(e,r){return(0,_mergeConcurrently.mergeMapConcurrently)(e,1,r)} -},{"./mergeConcurrently":752}],744:[function(require,module,exports){ +},{"./mergeConcurrently":753}],745:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.continueWith=continueWith;var _Stream=require("../Stream"),_Stream2=_interopRequireDefault(_Stream),_Pipe=require("../sink/Pipe"),_Pipe2=_interopRequireDefault(_Pipe),_dispose=require("../disposable/dispose"),dispose=_interopRequireWildcard(_dispose);function _interopRequireWildcard(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e.default=t,e}function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}function continueWith(t,e){return new _Stream2.default(new ContinueWith(t,e.source))}function ContinueWith(t,e){this.f=t,this.source=e}function ContinueWithSink(t,e,i,n){this.f=t,this.sink=i,this.scheduler=n,this.active=!0,this.disposable=dispose.once(e.run(this,n))}ContinueWith.prototype.run=function(t,e){return new ContinueWithSink(this.f,this.source,t,e)},ContinueWithSink.prototype.error=_Pipe2.default.prototype.error,ContinueWithSink.prototype.event=function(t,e){this.active&&this.sink.event(t,e)},ContinueWithSink.prototype.end=function(t,e){this.active&&(dispose.tryDispose(t,this.disposable,this.sink),this._startNext(t,e,this.sink))},ContinueWithSink.prototype._startNext=function(t,e,i){try{this.disposable=this._continue(this.f,e,i)}catch(e){i.error(t,e)}},ContinueWithSink.prototype._continue=function(t,e,i){return t(e).source.run(i,this.scheduler)},ContinueWithSink.prototype.dispose=function(){return this.active=!1,this.disposable.dispose()}; -},{"../Stream":738,"../disposable/dispose":766,"../sink/Pipe":786}],745:[function(require,module,exports){ +},{"../Stream":739,"../disposable/dispose":767,"../sink/Pipe":787}],746:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.delay=delay;var _Stream=require("../Stream"),_Stream2=_interopRequireDefault(_Stream),_Pipe=require("../sink/Pipe"),_Pipe2=_interopRequireDefault(_Pipe),_dispose=require("../disposable/dispose"),dispose=_interopRequireWildcard(_dispose),_PropagateTask=require("../scheduler/PropagateTask"),_PropagateTask2=_interopRequireDefault(_PropagateTask);function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function delay(e,t){return e<=0?t:new _Stream2.default(new Delay(e,t.source))}function Delay(e,t){this.dt=e,this.source=t}function DelaySink(e,t,r){this.dt=e,this.sink=t,this.scheduler=r}Delay.prototype.run=function(e,t){var r=new DelaySink(this.dt,e,t);return dispose.all([r,this.source.run(r,t)])},DelaySink.prototype.dispose=function(){var e=this;this.scheduler.cancelAll(function(t){return t.task.sink===e.sink})},DelaySink.prototype.event=function(e,t){this.scheduler.delay(this.dt,_PropagateTask2.default.event(t,this.sink))},DelaySink.prototype.end=function(e,t){this.scheduler.delay(this.dt,_PropagateTask2.default.end(t,this.sink))},DelaySink.prototype.error=_Pipe2.default.prototype.error; -},{"../Stream":738,"../disposable/dispose":766,"../scheduler/PropagateTask":779,"../sink/Pipe":786}],746:[function(require,module,exports){ +},{"../Stream":739,"../disposable/dispose":767,"../scheduler/PropagateTask":780,"../sink/Pipe":787}],747:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.flatMapError=void 0,exports.recoverWith=recoverWith,exports.throwError=throwError;var _Stream=require("../Stream"),_Stream2=_interopRequireDefault(_Stream),_SafeSink=require("../sink/SafeSink"),_SafeSink2=_interopRequireDefault(_SafeSink),_dispose=require("../disposable/dispose"),dispose=_interopRequireWildcard(_dispose),_tryEvent=require("../source/tryEvent"),tryEvent=_interopRequireWildcard(_tryEvent),_PropagateTask=require("../scheduler/PropagateTask"),_PropagateTask2=_interopRequireDefault(_PropagateTask);function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function recoverWith(e,r){return new _Stream2.default(new RecoverWith(e,r.source))}var flatMapError=exports.flatMapError=recoverWith;function throwError(e){return new _Stream2.default(new ErrorSource(e))}function ErrorSource(e){this.value=e}function runError(e,r,t){t.error(e,r)}function RecoverWith(e,r){this.f=e,this.source=r}function RecoverWithSink(e,r,t,i){this.f=e,this.sink=new _SafeSink2.default(t),this.scheduler=i,this.disposable=r.run(this,i)}ErrorSource.prototype.run=function(e,r){return r.asap(new _PropagateTask2.default(runError,this.value,e))},RecoverWith.prototype.run=function(e,r){return new RecoverWithSink(this.f,this.source,e,r)},RecoverWithSink.prototype.event=function(e,r){tryEvent.tryEvent(e,r,this.sink)},RecoverWithSink.prototype.end=function(e,r){tryEvent.tryEnd(e,r,this.sink)},RecoverWithSink.prototype.error=function(e,r){var t=this.sink.disable();dispose.tryDispose(e,this.disposable,this.sink),this._startNext(e,r,t)},RecoverWithSink.prototype._startNext=function(e,r,t){try{this.disposable=this._continue(this.f,r,t)}catch(r){t.error(e,r)}},RecoverWithSink.prototype._continue=function(e,r,t){return e(r).source.run(t,this.scheduler)},RecoverWithSink.prototype.dispose=function(){return this.disposable.dispose()}; -},{"../Stream":738,"../disposable/dispose":766,"../scheduler/PropagateTask":779,"../sink/SafeSink":787,"../source/tryEvent":798}],747:[function(require,module,exports){ +},{"../Stream":739,"../disposable/dispose":767,"../scheduler/PropagateTask":780,"../sink/SafeSink":788,"../source/tryEvent":799}],748:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.filter=filter,exports.skipRepeats=skipRepeats,exports.skipRepeatsWith=skipRepeatsWith;var _Stream=require("../Stream"),_Stream2=_interopRequireDefault(_Stream),_Pipe=require("../sink/Pipe"),_Pipe2=_interopRequireDefault(_Pipe),_Filter=require("../fusion/Filter"),_Filter2=_interopRequireDefault(_Filter);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function filter(e,t){return new _Stream2.default(_Filter2.default.create(e,t.source))}function skipRepeats(e){return skipRepeatsWith(same,e)}function skipRepeatsWith(e,t){return new _Stream2.default(new SkipRepeats(e,t.source))}function SkipRepeats(e,t){this.equals=e,this.source=t}function SkipRepeatsSink(e,t){this.equals=e,this.sink=t,this.value=void 0,this.init=!0}function same(e,t){return e===t}SkipRepeats.prototype.run=function(e,t){return this.source.run(new SkipRepeatsSink(this.equals,e),t)},SkipRepeatsSink.prototype.end=_Pipe2.default.prototype.end,SkipRepeatsSink.prototype.error=_Pipe2.default.prototype.error,SkipRepeatsSink.prototype.event=function(e,t){this.init?(this.init=!1,this.value=t,this.sink.event(e,t)):this.equals(this.value,t)||(this.value=t,this.sink.event(e,t))}; -},{"../Stream":738,"../fusion/Filter":768,"../sink/Pipe":786}],748:[function(require,module,exports){ +},{"../Stream":739,"../fusion/Filter":769,"../sink/Pipe":787}],749:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.flatMap=flatMap,exports.join=join;var _mergeConcurrently=require("./mergeConcurrently");function flatMap(e,r){return(0,_mergeConcurrently.mergeMapConcurrently)(e,1/0,r)}function join(e){return(0,_mergeConcurrently.mergeConcurrently)(1/0,e)} -},{"./mergeConcurrently":752}],749:[function(require,module,exports){ +},{"./mergeConcurrently":753}],750:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.throttle=throttle,exports.debounce=debounce;var _Stream=require("../Stream"),_Stream2=_interopRequireDefault(_Stream),_Pipe=require("../sink/Pipe"),_Pipe2=_interopRequireDefault(_Pipe),_Map=require("../fusion/Map"),_Map2=_interopRequireDefault(_Map);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function throttle(e,t){return new _Stream2.default(throttleSource(e,t.source))}function throttleSource(e,t){return t instanceof _Map2.default?commuteMapThrottle(e,t):t instanceof Throttle?fuseThrottle(e,t):new Throttle(e,t)}function commuteMapThrottle(e,t){return _Map2.default.create(t.f,throttleSource(e,t.source))}function fuseThrottle(e,t){return new Throttle(Math.max(e,t.period),t.source)}function Throttle(e,t){this.period=e,this.source=t}function ThrottleSink(e,t){this.time=0,this.period=e,this.sink=t}function debounce(e,t){return new _Stream2.default(new Debounce(e,t.source))}function Debounce(e,t){this.dt=e,this.source=t}function DebounceSink(e,t,o,r){this.dt=e,this.sink=o,this.scheduler=r,this.value=void 0,this.timer=null,this.disposable=t.run(this,r)}function DebounceTask(e,t){this.debounce=e,this.value=t}Throttle.prototype.run=function(e,t){return this.source.run(new ThrottleSink(this.period,e),t)},ThrottleSink.prototype.event=function(e,t){e>=this.time&&(this.time=e+this.period,this.sink.event(e,t))},ThrottleSink.prototype.end=_Pipe2.default.prototype.end,ThrottleSink.prototype.error=_Pipe2.default.prototype.error,Debounce.prototype.run=function(e,t){return new DebounceSink(this.dt,this.source,e,t)},DebounceSink.prototype.event=function(e,t){this._clearTimer(),this.value=t,this.timer=this.scheduler.delay(this.dt,new DebounceTask(this,t))},DebounceSink.prototype._event=function(e,t){this._clearTimer(),this.sink.event(e,t)},DebounceSink.prototype.end=function(e,t){this._clearTimer()&&(this.sink.event(e,this.value),this.value=void 0),this.sink.end(e,t)},DebounceSink.prototype.error=function(e,t){this._clearTimer(),this.sink.error(e,t)},DebounceSink.prototype.dispose=function(){return this._clearTimer(),this.disposable.dispose()},DebounceSink.prototype._clearTimer=function(){return null!==this.timer&&(this.timer.dispose(),this.timer=null,!0)},DebounceTask.prototype.run=function(e){this.debounce._event(e,this.value)},DebounceTask.prototype.error=function(e,t){this.debounce.error(e,t)},DebounceTask.prototype.dispose=function(){}; -},{"../Stream":738,"../fusion/Map":770,"../sink/Pipe":786}],750:[function(require,module,exports){ +},{"../Stream":739,"../fusion/Map":771,"../sink/Pipe":787}],751:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.loop=loop;var _Stream=require("../Stream"),_Stream2=_interopRequireDefault(_Stream),_Pipe=require("../sink/Pipe"),_Pipe2=_interopRequireDefault(_Pipe);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function loop(e,t,o){return new _Stream2.default(new Loop(e,t,o.source))}function Loop(e,t,o){this.step=e,this.seed=t,this.source=o}function LoopSink(e,t,o){this.step=e,this.seed=t,this.sink=o}Loop.prototype.run=function(e,t){return this.source.run(new LoopSink(this.step,this.seed,e),t)},LoopSink.prototype.error=_Pipe2.default.prototype.error,LoopSink.prototype.event=function(e,t){var o=this.step(this.seed,t);this.seed=o.seed,this.sink.event(e,o.value)},LoopSink.prototype.end=function(e){this.sink.end(e,this.seed)}; -},{"../Stream":738,"../sink/Pipe":786}],751:[function(require,module,exports){ +},{"../Stream":739,"../sink/Pipe":787}],752:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.merge=merge,exports.mergeArray=mergeArray;var _Stream=require("../Stream"),_Stream2=_interopRequireDefault(_Stream),_Pipe=require("../sink/Pipe"),_Pipe2=_interopRequireDefault(_Pipe),_IndexSink=require("../sink/IndexSink"),_IndexSink2=_interopRequireDefault(_IndexSink),_core=require("../source/core"),_dispose=require("../disposable/dispose"),dispose=_interopRequireWildcard(_dispose),_prelude=require("@most/prelude"),base=_interopRequireWildcard(_prelude);function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var copy=base.copy,reduce=base.reduce;function merge(){return mergeArray(copy(arguments))}function mergeArray(e){var r=e.length;return 0===r?(0,_core.empty)():1===r?e[0]:new _Stream2.default(mergeSources(e))}function mergeSources(e){return new Merge(reduce(appendSources,[],e))}function appendSources(e,r){var t=r.source;return t instanceof Merge?e.concat(t.sources):e.concat(t)}function Merge(e){this.sources=e}function MergeSink(e,r,t){this.sink=t,this.disposables=e,this.activeCount=r.length}Merge.prototype.run=function(e,r){for(var t,n=this.sources.length,i=new Array(n),o=new Array(n),u=new MergeSink(i,o,e),s=0;s0?this.skip-=1:0!==this.take&&(this.take-=1,this.sink.event(e,i),0===this.take&&(this.disposable.dispose(),this.sink.end(e,i)))},TakeWhile.prototype.run=function(e,i){var t=dispose.settable(),r=new TakeWhileSink(this.p,e,t);return t.setDisposable(this.source.run(r,i)),t},TakeWhileSink.prototype.end=_Pipe2.default.prototype.end,TakeWhileSink.prototype.error=_Pipe2.default.prototype.error,TakeWhileSink.prototype.event=function(e,i){if(this.active){var t=this.p;this.active=t(i),this.active?this.sink.event(e,i):(this.disposable.dispose(),this.sink.end(e,i))}},SkipWhile.prototype.run=function(e,i){return this.source.run(new SkipWhileSink(this.p,e),i)},SkipWhileSink.prototype.end=_Pipe2.default.prototype.end,SkipWhileSink.prototype.error=_Pipe2.default.prototype.error,SkipWhileSink.prototype.event=function(e,i){if(this.skipping){var t=this.p;if(this.skipping=t(i),this.skipping)return}this.sink.event(e,i)},SkipAfter.prototype.run=function(e,i){return this.source.run(new SkipAfterSink(this.p,e),i)},SkipAfterSink.prototype.event=function(e,i){if(!this.skipping){var t=this.p;this.skipping=t(i),this.sink.event(e,i),this.skipping&&this.sink.end(e,i)}},SkipAfterSink.prototype.end=_Pipe2.default.prototype.end,SkipAfterSink.prototype.error=_Pipe2.default.prototype.error; -},{"../Stream":738,"../disposable/dispose":766,"../fusion/Map":770,"../sink/Pipe":786,"../source/core":790}],757:[function(require,module,exports){ +},{"../Stream":739,"../disposable/dispose":767,"../fusion/Map":771,"../sink/Pipe":787,"../source/core":791}],758:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.switch=void 0,exports.switchLatest=switchLatest;var _Stream=require("../Stream"),_Stream2=_interopRequireDefault(_Stream),_dispose=require("../disposable/dispose"),dispose=_interopRequireWildcard(_dispose);function _interopRequireWildcard(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e.default=t,e}function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}function switchLatest(t){return new _Stream2.default(new Switch(t.source))}function Switch(t){this.source=t}function SwitchSink(t,e){this.sink=t,this.scheduler=e,this.current=null,this.ended=!1}function Segment(t,e,i,n){this.min=t,this.max=e,this.outer=i,this.sink=n,this.disposable=dispose.empty()}exports.switch=switchLatest,Switch.prototype.run=function(t,e){var i=new SwitchSink(t,e);return dispose.all([i,this.source.run(i,e)])},SwitchSink.prototype.event=function(t,e){this._disposeCurrent(t),this.current=new Segment(t,1/0,this,this.sink),this.current.disposable=e.source.run(this.current,this.scheduler)},SwitchSink.prototype.end=function(t,e){this.ended=!0,this._checkEnd(t,e)},SwitchSink.prototype.error=function(t,e){this.ended=!0,this.sink.error(t,e)},SwitchSink.prototype.dispose=function(){return this._disposeCurrent(this.scheduler.now())},SwitchSink.prototype._disposeCurrent=function(t){if(null!==this.current)return this.current._dispose(t)},SwitchSink.prototype._disposeInner=function(t,e){e._dispose(t),e===this.current&&(this.current=null)},SwitchSink.prototype._checkEnd=function(t,e){this.ended&&null===this.current&&this.sink.end(t,e)},SwitchSink.prototype._endInner=function(t,e,i){this._disposeInner(t,i),this._checkEnd(t,e)},SwitchSink.prototype._errorInner=function(t,e,i){this._disposeInner(t,i),this.sink.error(t,e)},Segment.prototype.event=function(t,e){t=this.min.value&&e=0&&n.active&&(n.time=n.time+n.period,insertByTime(n,i)))}return i}function insertByTime(e,t){var i=t.length;if(0!==i){var r=binarySearch(e.time,t);r>=i?t.push(newTimeslot(e.time,[e])):e.time===t[r].time?t[r].events.push(e):t.splice(r,0,newTimeslot(e.time,[e]))}else t.push(newTimeslot(e.time,[e]))}function removeAllFrom(e,t){t.events=base.removeAll(e,t.events)}function binarySearch(e,t){for(var i,r,s=0,n=t.length;s=0&&t=0)return this.tasks[t].events.splice(i,1),!0}return!1},Timeline.prototype.removeAll=function(e){for(var t=0,i=this.tasks.length;t1){for(var o=new Array(i),u=0;u=0&&(this.sinks=e.remove(s,this.sinks)),this.sinks.length},u.prototype.event=function(t,e){var s=this.sinks;if(1===s.length)return s[0].event(t,e);for(var n=0;n= 0");var e=n.length;return 0===r||0===e?n:r>=e?[]:function(r,n,e){for(var t=new Array(e),u=0;u= 0");var e=n.length;return 0===e||r>=e?n:1===e?[]:function(r,n,e){var t,u=new Array(e);for(t=0;t= 0");for(var t=e.length,u=new Array(t),o=0;o1&&(f.pop(),f[f.length-1][0][2][a]=T(p[0],p[1],p[2].length?p[2]:void 0))}else if(u===OPEN){var g=[l[1],{},[]];p[2].push(g),f.push([g,p[2].length-1])}else if(u===ATTR_KEY||u===VAR&&l[1]===ATTR_KEY){for(var L,V="";_1&&/^\s*$/.test(i[2][0])&&i[2].shift(),i[2].length>2||2===i[2].length&&/\S/.test(i[2][1])){if(e.createFragment)return e.createFragment(i[2]);throw new Error("multiple root elements must be wrapped in an enclosing tag")}return Array.isArray(i[2][0])&&"string"==typeof i[2][0][0]&&Array.isArray(i[2][0][2])&&(i[2][0]=T(i[2][0][0],i[2][0][1],i[2][0][2])),i[2][0];function U(T){var A=[];n===ATTR_VALUE_W&&(n=ATTR);for(var t=0;t"!==E||quot(n)||n===COMMENT?n===COMMENT&&/-$/.test(r)&&"-"===E?(e.comments&&A.push([ATTR_VALUE,r.substr(0,r.length-1)]),r="",n=TEXT):n===OPEN&&/^!--$/.test(r)?(e.comments&&A.push([OPEN,r],[ATTR_KEY,"comment"],[ATTR_EQ]),r=E,n=COMMENT):n===TEXT||n===COMMENT?r+=E:n===OPEN&&"/"===E&&r.length||(n===OPEN&&/\s/.test(E)?(r.length&&A.push([OPEN,r]),r="",n=ATTR):n===OPEN?r+=E:n===ATTR&&/[^\s"'=/]/.test(E)?(n=ATTR_KEY,r=E):n===ATTR&&/\s/.test(E)?(r.length&&A.push([ATTR_KEY,r]),A.push([ATTR_BREAK])):n===ATTR_KEY&&/\s/.test(E)?(A.push([ATTR_KEY,r]),r="",n=ATTR_KEY_W):n===ATTR_KEY&&"="===E?(A.push([ATTR_KEY,r],[ATTR_EQ]),r="",n=ATTR_VALUE_W):n===ATTR_KEY?r+=E:n!==ATTR_KEY_W&&n!==ATTR||"="!==E?n!==ATTR_KEY_W&&n!==ATTR||/\s/.test(E)?n===ATTR_VALUE_W&&'"'===E?n=ATTR_VALUE_DQ:n===ATTR_VALUE_W&&"'"===E?n=ATTR_VALUE_SQ:n===ATTR_VALUE_DQ&&'"'===E?(A.push([ATTR_VALUE,r],[ATTR_BREAK]),r="",n=ATTR):n===ATTR_VALUE_SQ&&"'"===E?(A.push([ATTR_VALUE,r],[ATTR_BREAK]),r="",n=ATTR):n!==ATTR_VALUE_W||/\s/.test(E)?n===ATTR_VALUE&&/\s/.test(E)?(A.push([ATTR_VALUE,r],[ATTR_BREAK]),r="",n=ATTR):n!==ATTR_VALUE&&n!==ATTR_VALUE_SQ&&n!==ATTR_VALUE_DQ||(r+=E):(n=ATTR_VALUE,t--):(A.push([ATTR_BREAK]),/[\w-]/.test(E)?(r+=E,n=ATTR_KEY):n=ATTR):(A.push([ATTR_EQ]),n=ATTR_VALUE_W)):(n===OPEN&&r.length?A.push([OPEN,r]):n===ATTR_KEY?A.push([ATTR_KEY,r]):n===ATTR_VALUE&&r.length&&A.push([ATTR_VALUE,r]),A.push([CLOSE]),r="",n=TEXT)}return n===TEXT&&r.length?(A.push([TEXT,r]),r=""):n===ATTR_VALUE&&r.length?(A.push([ATTR_VALUE,r]),r=""):n===ATTR_VALUE_DQ&&r.length?(A.push([ATTR_VALUE,r]),r=""):n===ATTR_VALUE_SQ&&r.length?(A.push([ATTR_VALUE,r]),r=""):n===ATTR_KEY&&(A.push([ATTR_KEY,r]),r=""),A}};function t(T){return"function"==typeof T?T:"string"==typeof T?T:T&&"object"==typeof T?T:null==T?T:A("",T)}};var closeRE=RegExp("^("+["area","base","basefont","bgsound","br","col","command","embed","frame","hr","img","input","isindex","keygen","link","meta","param","source","track","wbr","!--","animate","animateTransform","circle","cursor","desc","ellipse","feBlend","feColorMatrix","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","font-face-format","font-face-name","font-face-uri","glyph","glyphRef","hkern","image","line","missing-glyph","mpath","path","polygon","polyline","rect","set","stop","tref","use","view","vkern"].join("|")+")(?:[.#][a-zA-Z0-9-￿_:-]+)*$");function selfClosing(T){return closeRE.test(T)} -},{"hyperscript-attribute-to-property":811}],813:[function(require,module,exports){ +},{"hyperscript-attribute-to-property":812}],814:[function(require,module,exports){ var bundleFn=arguments[3],sources=arguments[4],cache=arguments[5],stringify=JSON.stringify;module.exports=function(r,e){for(var t,o=Object.keys(cache),n=0,a=o.length;n{const r=["jscad","js"],o=supportedFormatsForObjects(a).filter(a=>!r.includes(a)).map(a=>({name:a,displayName:formats[a].displayName}));return{exportFormat:head(o)?head(o).name:void 0,availableExportFormats:o}},exportFilePathFromFormatAndDesign=(a,r)=>{const o=r?formats[r].extension:"",t=`${a.name}.${o}`;return{exportFilePath:path.join(a.path,t)}};module.exports={availableExportFormatsFromSolids:availableExportFormatsFromSolids,exportFilePathFromFormatAndDesign:exportFilePathFromFormatAndDesign}; -},{"@jscad/array-utils":526,"@jscad/io/formats":68,"path":712}],816:[function(require,module,exports){ +},{"@jscad/array-utils":527,"@jscad/io/formats":68,"path":713}],817:[function(require,module,exports){ const html=require("nanohtml"),{evaluation:evaluation}=require("@jscad/core"),callbackToObservable=require("./most-utils/callbackToObservable"),packageMetadata=require("../package.json"),keyBindings=require("../data/keybindings.json");let instances=0;const makeJscad=async(e,s)=>{const{name:a,logging:r}=Object.assign({},{name:"jscad",logging:!1},s),i=html`
`;e.appendChild(i);const t=require("./sideEffects/localStorage")({name:a,logging:r}),o=require("./sideEffects/titleBar")({logging:r}),l=require("./sideEffects/dragDrop")({targetEl:i,logging:r}),n=require("./sideEffects/fileDialog")({targetEl:i,logging:r}),c=require("./sideEffects/dom")({targetEl:i},r),g=require("./sideEffects/state/index")({logging:r,packageMetadata:packageMetadata,keyBindings:keyBindings}),u=await require("./sideEffects/localFs")({logging:r}),d=require("./sideEffects/http")({logging:r}),k=await require("./sideEffects/dat")({logging:r}),f=require("./sideEffects/i18n")({translations:{en:require("../locales/en.json"),fr:require("../locales/fr.json"),de:require("../locales/de.json"),ja:require("../locales/ja.json"),hr:require("../locales/hr.json"),zh:require("../locales/zh.json")},logging:r}),m=require("./sideEffects/worker")(evaluation.rebuildGeometryWorker),q=callbackToObservable(),b=callbackToObservable(),p={paramChanges:q.stream,editor:b.stream,state:g.source(),store:t.source(),fs:u.source(),http:d.source(),https:d.source(),drops:l.source(),dom:c.source(),solidWorker:m.source(),i18n:f.source(),titleBar:o.source(),fileDialog:n.source(),dat:await k.source()},E={store:t.sink,fs:u.sink,http:d.sink,https:d.sink,i18n:f.sink,dom:c.sink,solidWorker:m.sink,state:g.sink,fileDialog:n.sink,dat:k.sink},j=require("./ui/flow/flowIn")(p),h={jscadEl:i,paramsCallbacktoStream:q,editorCallbackToStream:b};require("./ui/flow/flowOut")({sinks:E,sources:p,outputs$:j,extras:h}),instances+=1,setTimeout(()=>{document.getElementById("toggleAxes").click()},100),setTimeout(()=>{document.getElementById("toggleAxes").click()},200);const v=callbackToObservable();return e=>{v.callback(e)}};module.exports=makeJscad; -},{"../data/keybindings.json":634,"../locales/de.json":678,"../locales/en.json":679,"../locales/fr.json":680,"../locales/hr.json":681,"../locales/ja.json":682,"../locales/zh.json":683,"../package.json":814,"./most-utils/callbackToObservable":823,"./sideEffects/dat":828,"./sideEffects/dom":829,"./sideEffects/dragDrop":830,"./sideEffects/fileDialog":831,"./sideEffects/http":832,"./sideEffects/i18n":833,"./sideEffects/localFs":834,"./sideEffects/localStorage":836,"./sideEffects/state/index":837,"./sideEffects/titleBar":838,"./sideEffects/worker":839,"./ui/flow/flowIn":844,"./ui/flow/flowOut":845,"@jscad/core":19,"nanohtml":807}],817:[function(require,module,exports){ +},{"../data/keybindings.json":635,"../locales/de.json":679,"../locales/en.json":680,"../locales/fr.json":681,"../locales/hr.json":682,"../locales/ja.json":683,"../locales/zh.json":684,"../package.json":815,"./most-utils/callbackToObservable":824,"./sideEffects/dat":829,"./sideEffects/dom":830,"./sideEffects/dragDrop":831,"./sideEffects/fileDialog":832,"./sideEffects/http":833,"./sideEffects/i18n":834,"./sideEffects/localFs":835,"./sideEffects/localStorage":837,"./sideEffects/state/index":838,"./sideEffects/titleBar":839,"./sideEffects/worker":840,"./ui/flow/flowIn":845,"./ui/flow/flowOut":846,"@jscad/core":19,"nanohtml":808}],818:[function(require,module,exports){ const{merge:merge}=require("most");let isPinching=!1;"undefined"!=typeof window&&(window.addEventListener("pinchStarted",e=>{isPinching=!0}),window.addEventListener("pinchEnded",e=>{isPinching=!1}));const mouseDrags=(e,t,s,o)=>{const{pixelRatio:n}=o;return e.flatMap(e=>{const o=e.pageX*n,a=e.pageY*n;let r=o,i=a;return s.map(e=>{const t=e.pageX*n,s=e.pageY*n,u={left:t-o,top:s-a,x:r-t,y:s-i};return r=t,i=s,{originalEvents:[e],delta:u,normalized:{x:t,y:s},type:"mouse"}}).takeUntil(t)})},touchDrags=(e,t,s,o)=>{const{pixelRatio:n}=o;return e.filter(e=>1===e.touches.length||3===e.touches.length).flatMap(e=>{const o=e.touches[0].pageX*n,a=e.touches[0].pageY*n;let r=o,i=a;return s.takeWhile(e=>!1===isPinching).map(e=>{const t=e.touches[0].pageX*n,s=e.touches[0].pageY*n,u={left:t-o,top:s-a,x:r-t,y:s-i};return r=t,i=s,{originalEvents:[e],delta:u,normalized:{x:t,y:s},type:"touch"}}).takeUntil(t)})},drags=({mouseDowns$:e,mouseUps$:t,mouseMoves$:s,touchStarts$:o,touchEnds$:n,longTaps$:a,touchMoves$:r},i)=>{return merge(mouseDrags(e,t,s,i),touchDrags(o,n,r,i))};module.exports={mouseDrags:mouseDrags,touchDrags:touchDrags,drags:drags}; -},{"most":771}],818:[function(require,module,exports){ +},{"most":772}],819:[function(require,module,exports){ const{fromEvent:fromEvent,merge:merge}=require("most"),{normalizeWheel:normalizeWheel,preventDefault:preventDefault}=require("./utils"),{presses:presses}=require("./presses"),{taps:taps}=require("./taps"),{drags:drags}=require("./drags"),{zooms:zooms}=require("./zooms"),baseInteractionsFromEvents=(e,s)=>{s=Object.assign({},{passiveEventsHandlers:!0,preventScroll:!0,preventMenu:!0},s);const{passiveEventsHandlers:t,preventScroll:r,preventMenu:o}=s,a=fromEvent("mousedown",e,{passive:t,capture:!1}),n=fromEvent("mouseup",e,{passive:t,capture:!1}),p=fromEvent("mousemove",e,{passive:t,capture:!1}),i=fromEvent("contextmenu",e,{passive:!s.preventMenu,capture:!1}),u=fromEvent("touchstart",e,{passive:t,capture:!1}),v=fromEvent("touchmove",e,{passive:t,capture:!1}),m=fromEvent("touchend",e,{passive:t,capture:!1}),l=merge(a,u),c=merge(n,m),f=merge(p,v.filter(e=>1===e.touches.length));return r&&(e=>{fromEvent("mousewheel",e,{passive:!1,capture:!1}).forEach(preventDefault),fromEvent("DOMMouseScroll",e,{passive:!1,capture:!1}).forEach(preventDefault),fromEvent("wheel",e,{passive:!1,capture:!1}).forEach(preventDefault),fromEvent("touchmove",e,{passive:!1,capture:!1}).forEach(preventDefault)})(e),o&&i.forEach(preventDefault),{mouseDowns$:a,mouseUps$:n,mouseMoves$:p,rightClicks$:i,wheel$:merge(fromEvent("wheel",e,{passive:t,capture:!1}),fromEvent("DOMMouseScroll",e,{passive:t,capture:!1}),fromEvent("mousewheel",e,{passive:t,capture:!1})).map(normalizeWheel),touchStarts$:u,touchMoves$:v,touchEnds$:m,pointerDowns$:l,pointerUps$:c,pointerMoves$:f}},pointerGestures=(e,s)=>{const t="addEventListener"in e?baseInteractionsFromEvents(e,s):e,r={multiTapDelay:250,longPressDelay:250,maxStaticDeltaSqr:100,zoomMultiplier:200,pinchThreshold:4e3,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio?window.devicePixelRatio:1},o=Object.assign({},r,s),a=presses(t,o),n=a.filter(e=>e.timeDelta>o.longPressDelay).filter(e=>e.moveDelta.sqrd{l=l.filter(e=>1===e.touches.length);const r=merge(e,u),i=merge(s,a);return r.timestamp().flatMap(e=>merge(just(e),i.take(1).timestamp())).loop((e,s)=>{let t;if(1===e.length){const u=s.time-e[0].time,a="touches"in s.value?s.value.changedTouches[0].pageX:s.value.pageX,l="touches"in s.value?s.value.changedTouches[0].pageY:s.value.pageY,o="touches"in e[0].value?e[0].value.touches[0].pageX:e[0].value.pageX,r="touches"in e[0].value?e[0].value.touches[0].pageY:e[0].value.pageY;let i=[a-o,l-r];const v={x:o-a,y:l-r,sqrd:i=i[0]*i[0]+i[1]*i[1]};t={value:s.value,originalEvent:s.value,timeDelta:u,moveDelta:v,x:a,y:l},e=[]}else e.push(s);return{seed:e,value:t}},[]).filter(exists).filter(e=>void 0!==e.value).multicast()},presses=(e,s)=>{return basePresses(e)};module.exports={presses:presses}; -},{"./utils":821,"most":771}],820:[function(require,module,exports){ +},{"./utils":822,"most":772}],821:[function(require,module,exports){ const{exists:exists}=require("./utils"),taps=(t,e)=>{const{longPressDelay:a,maxStaticDeltaSqr:s,multiTapDelay:l}=e;return t.filter(t=>t.timeDelta<=a).filter(t=>t.moveDelta.sqrd({type:"data",data:t})).merge(t.debounce(l).map(t=>({type:"reset"}))).loop((t,{type:e,data:a})=>{let s;return"data"===e?t.push(a):(s=t,t=[]),{seed:t,value:s}},[]).filter(exists).map(t=>({list:t,nb:t.length})).multicast()};module.exports={taps:taps}; -},{"./utils":821}],821:[function(require,module,exports){ +},{"./utils":822}],822:[function(require,module,exports){ const{empty:empty,continueWith:continueWith}=require("most"),repeat=(e,t)=>0===e?empty():1===e?t:continueWith(()=>repeat(e-1,t),t),preventDefault=e=>(e.preventDefault(),e),isMoving=(e,t)=>!0,normalizeWheel=e=>{let t={x:0,y:0};return e.wheelDelta?t=e.wheelDelta:e.detail?t=-e.detail:e.deltaY&&(t=-e.deltaY),t=t>=0?1:-1},exists=e=>null!=e;module.exports={repeat:repeat,preventDefault:preventDefault,isMoving:isMoving,normalizeWheel:normalizeWheel,exists:exists}; -},{"most":771}],822:[function(require,module,exports){ +},{"most":772}],823:[function(require,module,exports){ const{merge:merge}=require("most"),pinchZooms=({touchStarts$:e,touchMoves$:t,touchEnds$:o},s)=>{const{pixelRatio:n,pinchThreshold:u}=s;return e.filter(e=>2===e.touches.length).flatMap(e=>{const s=e.touches[0].pageX*n,c=e.touches[0].pageY*n,h=e.touches[1].pageX*n,a=e.touches[1].pageY*n,p=(s-h)*(s-h)+(c-a)*(c-a);return t.tap(e=>e.preventDefault()).filter(e=>2===e.touches.length).tap(e=>{if("undefined"!=typeof CustomEvent){const e=new CustomEvent("pinchStarted",{detail:!0});window.dispatchEvent(e)}}).map(e=>{const t=e.touches[0].pageX*n,o=e.touches[0].pageY*n,s=e.touches[1].pageX*n,u=e.touches[1].pageY*n;return(t-s)*(t-s)+(o-u)*(o-u)}).loop((e,t)=>e?Math.abs(t-e)void 0!==e).map(e=>3e-6*e).takeUntil(o.tap(e=>{if("undefined"!=typeof CustomEvent){const e=new CustomEvent("pinchEnded",{detail:!0});window.dispatchEvent(e)}}))})},zooms=({touchStarts$:e,touchMoves$:t,touchEnds$:o,wheel$:s},n)=>{return merge(pinchZooms({touchStarts$:e,touchMoves$:t,touchEnds$:o},n),s).map(e=>e*n.zoomMultiplier)};module.exports={pinchZooms:pinchZooms,zooms:zooms}; -},{"most":771}],823:[function(require,module,exports){ +},{"most":772}],824:[function(require,module,exports){ const{create:create}=require("@most/create"),callBackToStream=()=>{let e=function(){};const t=t=>{e(t)};return{stream:create((t,a,c)=>{e=t}),callback:t}};module.exports=callBackToStream; -},{"@most/create":684}],824:[function(require,module,exports){ +},{"@most/create":685}],825:[function(require,module,exports){ const most=require("most"),delayFromObservable=(e,s)=>{const t=(e,s)=>most.just(s).delay(e),o=s.map(e);return e=>most.combine(t,o,e).switchLatest()};module.exports=delayFromObservable; -},{"most":771}],825:[function(require,module,exports){ +},{"most":772}],826:[function(require,module,exports){ const withLatestFrom=require("./withLatestFrom"),holdUntil=t=>{return e=>e.skipUntil(t).merge(t.take(1).thru(withLatestFrom(t=>t,e)))};module.exports=holdUntil; -},{"./withLatestFrom":827}],826:[function(require,module,exports){ +},{"./withLatestFrom":828}],827:[function(require,module,exports){ module.exports={callbackToObservable:require("./callbackToObservable"),delayFromObservable:require("./delayFromObservable"),holdUntil:require("./holdUntil"),withLatestFrom:require("./withLatestFrom")}; -},{"./callbackToObservable":823,"./delayFromObservable":824,"./holdUntil":825,"./withLatestFrom":827}],827:[function(require,module,exports){ +},{"./callbackToObservable":824,"./delayFromObservable":825,"./holdUntil":826,"./withLatestFrom":828}],828:[function(require,module,exports){ const most=require("most"),withLatestFrom=(t,o)=>s=>most.sample(t,s,o,s);module.exports=withLatestFrom; -},{"most":771}],828:[function(require,module,exports){ +},{"most":772}],829:[function(require,module,exports){ const{getFileExtensionFromString:getFileExtensionFromString}=require("@jscad/core").utils,callbackToObservable=require("../../most-utils/callbackToObservable"),makeLogger=require("../../utils/logger"),makeDatSideEffect=async e=>{const a=callbackToObservable(),{logging:t}=Object.assign({},{logging:!1},e),n=makeLogger({enabled:t});let r=!0;const i=window.DatArchive;i||(n.error("Dat archives not supported in this environment!"),r=!1);return{source:()=>a.stream.multicast(),sink:e=>{let t,l,o,s=[];e.forEach(e=>{const{type:c,id:d,urls:m,path:u}=e;if(!r)return void a.callback({type:c,id:d,error:new Error("Dat archives not supported in this environment!")});const h={unhandled:()=>{a.callback({type:c,id:d,error:new Error(`Dat: no handler found for command ${c}`)})},read:()=>{m.map(async e=>{e=e.replace(" ","+"),l=e,t=new i(e,{});const n=await t.readdir(u,{recursive:!0,stat:!0}),r=await Promise.all(n.map(async e=>{const a=`${u}/${e.name}`;if(e.stat.isFile()&&e.name.includes("js"))return{content:await t.readFile(a),name:e.name,fullPath:e.name,isFile:!0}})),m=await t.getInfo();o=m.title||"unnamed";const h=r.filter(e=>void 0!==e).map(e=>({name:e.name,ext:getFileExtensionFromString(e.name),source:e.content,fullPath:`/${o}/`+e.fullPath}));s=[{children:h,fullPath:`/${o}`,name:o}],a.callback({type:c,id:d,url:e,data:s}),await t.history()})},write:()=>{n.warning("writing to dat archives is not implemented yet")},watch:()=>{t.watch().addEventListener("changed",async({path:e})=>{const n=await t.readFile(e),r={name:require("path").basename(e),ext:"js",source:n,fullPath:`/${o}`+e},i=s[0].children.findIndex(e=>e.fullPath===r.fullPath);(s=JSON.parse(JSON.stringify(s)))[0].children[i]=r,a.callback({type:"read",id:"loadRemote",url:l,data:s})})}};(h[c]||h.unhandled)()})}}};module.exports=makeDatSideEffect; -},{"../../most-utils/callbackToObservable":823,"../../utils/logger":866,"@jscad/core":19,"path":712}],829:[function(require,module,exports){ +},{"../../most-utils/callbackToObservable":824,"../../utils/logger":867,"@jscad/core":19,"path":713}],830:[function(require,module,exports){ const most=require("most"),morph=require("morphdom"),{proxy:proxy}=require("most-proxy"),makeDomSideEffect=({targetEl:e})=>{const{attach:t,stream:r}=proxy(),o=r,s={};return{source:()=>{const t=t=>Array.from(e.querySelectorAll(t));return o.forEach(()=>{Object.keys(s).forEach(e=>{const[r]=e.split("@@"),o=t(r);if(o&&o.length>0){const t=s[e];if(!1===t.live){t.live=!0;const e=o.map(e=>most.fromEvent(t.events,e)),r=most.mergeArray(e);t.observable.attach(r)}}})}),{select:e=>{const r=t(e);let o;return{events:function(t){if(!r||r&&0===r.length){const r=proxy();o=r.stream,s[e+"@@"+t]={observable:r,live:!1}}return s[e+"@@"+t].events=t,o.multicast()}}},element:e}},sink:((e,r)=>{let o;const s=r.take(1).map(t=>{o=t,e.appendChild(o)}),m=r.skip(1).map(e=>{morph(o,e)}),n=most.mergeArray([s,m]).multicast();t(n),n.forEach(e=>e)}).bind(null,e)}};module.exports=makeDomSideEffect; -},{"morphdom":729,"most":771,"most-proxy":732}],830:[function(require,module,exports){ +},{"morphdom":730,"most":772,"most-proxy":733}],831:[function(require,module,exports){ const{fromEvent:fromEvent}=require("most"),preventDefault=t=>(t.preventDefault(),t),isTextNotEmpty=t=>""!==t,exists=t=>null!=t,itemListToArray=t=>{const e=[];for(let r=0;r{if(isTextNotEmpty(t.dataTransfer.getData("url")))return{type:"url",data:t.dataTransfer.getData("url")};if(t.dataTransfer.types.includes("text/plain")){const e=t.dataTransfer.getData("text");try{return{type:"url",data:new URL(e).href}}catch{return{type:"text",data:e}}}return t.dataTransfer.items&&t.dataTransfer.items.length>0?{type:"fileOrFolder",data:itemListToArray(t.dataTransfer.items)}:void 0},makeDragAndDropSideEffect=({targetEl:t})=>{return{source:()=>{const{dragOvers$:e,drops$:r}=(t=>({dragOvers$:fromEvent("dragover",t),drops$:fromEvent("drop",t)}))(t);return r.multicast(),r.forEach(preventDefault),e.forEach(preventDefault),r.map(t=>extractData(t)).filter(exists).multicast()}}};module.exports=makeDragAndDropSideEffect; -},{"most":771}],831:[function(require,module,exports){ +},{"most":772}],832:[function(require,module,exports){ const callbackToObservable=require("../../most-utils/callbackToObservable"),makeFileDialog=e=>{const a=callbackToObservable();return{source:()=>{},sink:e=>{e.forEach(e=>{a.callback(e);const l=document.createElement("input");l.id="foo",l.name="gna",l.setAttribute("type","file"),l.click(),l.addEventListener("change",()=>{})})}}};module.exports=makeFileDialog; -},{"../../most-utils/callbackToObservable":823}],832:[function(require,module,exports){ +},{"../../most-utils/callbackToObservable":824}],833:[function(require,module,exports){ const path=require("path"),{getFileExtensionFromString:getFileExtensionFromString}=require("@jscad/core").utils,{formats:formats}=require("@jscad/io/formats"),callbackToObservable=require("../../most-utils/callbackToObservable"),makeLogger=require("../../utils/logger"),proxyUrl="./remote.pl?url=",binaryMimetypes={stl:"application/sla"},makeHttpSideEffect=e=>{const{logging:t}=Object.assign({},{logging:!1},e),r=callbackToObservable(),a=makeLogger({enabled:t});return{source:()=>r.stream.multicast(),sink:e=>{e.forEach(e=>{const{type:t,id:o,urls:n,origin:i,proxy:l}=e,s={read:()=>{let e=[];n.forEach(n=>{const s=e=>{r.callback({type:t,id:o,url:n,error:e}),a.error(e)},c=a=>{e=e.concat(a),r.callback({type:t,id:o,url:n,data:e})};l?readProxy(n,s,e=>{if(e.file){const t=new URL(i),r=new URL(e.file,t);readFile(r.toString(),s,c)}}):readFile(n,s,c)})},write:()=>{a.warning("writing to http is not implemented yet")},watch:()=>{a.warning("watching http is not implemented yet")},unhandled:()=>{r.callback({type:t,id:o,error:new Error(`http: no handler found for command ${t}`)})}};(s[t]||s.unhandled)()})}}},readFile=(e,t,r)=>{const a=getFileExtensionFromString(e),o=void 0!==binaryMimetypes[a];fetch(e).then(e=>{if(e.ok)return o?e.arrayBuffer():e.text();t(new Error(`fetch error: ${e.status} ${e.statusText}`))}).then(t=>{const o=path.basename(e),n=`/${o}`,i=formats[a]?formats[a].mimetype:"";r({name:o,ext:a,mimetype:i,source:t,fullPath:n})}).catch(e=>{t(e)})},readProxy=(e,t,r)=>{fetch(proxyUrl+e).then(e=>{if(e.ok)return e.json();t(new Error(`fetch error: ${e.status} ${e.statusText}`))}).then(e=>{r(e)}).catch(e=>{t(e)})};module.exports=makeHttpSideEffect; -},{"../../most-utils/callbackToObservable":823,"../../utils/logger":866,"@jscad/core":19,"@jscad/io/formats":68,"path":712}],833:[function(require,module,exports){ +},{"../../most-utils/callbackToObservable":824,"../../utils/logger":867,"@jscad/core":19,"@jscad/io/formats":68,"path":713}],834:[function(require,module,exports){ const isElectron=require("is-electron"),callBackToStream=require("../../most-utils/callbackToObservable"),longNames={en:"english",de:"german",fr:"french",ja:"japanese",hr:"croatian",zh:"chinese"},getDefaultLocale=()=>{let a;return isElectron()||(a=navigator.languages&&navigator.languages.length?navigator.languages[0]:navigator.language),a?a.split("-")[0]:""},initTranslations=a=>{const{translations:e}=Object.assign({},{translations:{}},a);return e},i18nImport=require("es2015-i18n-tag"),i18n=i18nImport.default,{i18nConfig:i18nConfig}=i18nImport,makei18nSideEffect=a=>{const e=callBackToStream();let t=initTranslations(a);const n={setAvailableTranslations:a=>{t=a.data},getDefaultLocale:a=>{e.callback({data:getDefaultLocale(),type:a.type})},changeSettings:a=>{const n=a.data;i18nConfig({locales:n,translations:t[n]}),e.callback({data:i18n,type:"changeSettings"})},getAvailableLanguages:a=>{const n=Object.keys(t).map(a=>{let e=longNames[a]?longNames[a]:"placeholder";const n=t[a];return n&&"language"in n&&(e=n.language),{code:a,fullName:e}});e.callback({data:n,type:"getAvailableLanguages"})}};return{sink:a=>{a.forEach(a=>{const e=n[a.type];e&&e(a)})},source:()=>e.stream.multicast()}};module.exports=makei18nSideEffect; -},{"../../most-utils/callbackToObservable":823,"es2015-i18n-tag":726,"is-electron":728}],834:[function(require,module,exports){ +},{"../../most-utils/callbackToObservable":824,"es2015-i18n-tag":727,"is-electron":729}],835:[function(require,module,exports){ const{walkFileTree:walkFileTree}=require("@jscad/core").web,callbackToObservable=require("../../most-utils/callbackToObservable"),{changedFiles:changedFiles,flattenFiles:flattenFiles}=require("./utils"),localFsOptions=require("../../../data/localFsOptions.json"),makeLocalFsSideEffect=async e=>{const l=callbackToObservable();let o=null,a=0;const t=e=>o.send(JSON.stringify(e));return{source:()=>l.stream.multicast(),sink:e=>{let n,c,r,s=5e3;e.forEach(e=>{const{type:i,id:d,data:f,options:m,path:u}=e,h={unhandled:()=>{l.callback({type:i,id:d,error:new Error(`LocalFs: no handler found for command ${i}`)})},read:async()=>{n=void 0,c=void 0,r&&(clearInterval(r),r=0,o&&o.close()),f.length&&f[0]instanceof File||(c=f),n=await walkFileTree(f),l.callback({type:i,id:d,data:n})},watch:()=>{if(void 0===c)return;const{enabled:e}=m;e?(o||((o=new WebSocket(localFsOptions.livereloadUrl)).onopen=function(e){t({command:"hello",protocols:["http://livereload.com/protocols/official-6","http://livereload.com/protocols/official-7"],ver:"2.0.8",ext:"Chrome",extver:"2.1.0"})},o.onmessage=function(e){const l=JSON.parse(e.data);"hello"===l.command&&t({command:"info",plugins:{less:{disable:!1,version:"1.0"}},url:document.location}),"reload"===l.command&&(a=0)},o.onerror=function(e){console.warn("websocket error",e)},o.onclose=function(e){o=null}),r=setInterval(()=>{const e=Date.now();!c||o&&a||e-a{console.error("failed to read files",e)}).then(o=>{const a=flattenFiles(n),t=flattenFiles(o),c=changedFiles(a,t);c.length>0&&(n=o,l.callback({type:"read",id:"loadRemote",data:n,path:u,changed:c}));const r=Date.now();s=Math.max(2*(r-e),1e3)}))},50)):r&&(clearInterval(r),r=0)},write:()=>{}};(h[i]||h.unhandled)()})}}};module.exports=makeLocalFsSideEffect; -},{"../../../data/localFsOptions.json":635,"../../most-utils/callbackToObservable":823,"./utils":835,"@jscad/core":19}],835:[function(require,module,exports){ +},{"../../../data/localFsOptions.json":636,"../../most-utils/callbackToObservable":824,"./utils":836,"@jscad/core":19}],836:[function(require,module,exports){ const sameFile=(e,t)=>{if(e.fullPath===t.fullPath&&typeof e.source==typeof t.source){if(e.source.byteLength){const n=new Uint8Array(e.source),r=new Uint8Array(t.source);return n.length===r.length&&n.every((e,t)=>e===r[t])}return e.length===t.length&&e.source===t.source}return!1},changedFiles=(e,t)=>{const n=e.slice();return t.filter(e=>{const t=n.findIndex((t,n)=>sameFile(t,e));return t<0||(n.splice(t,1),!1)})},flattenFiles=e=>{let t=[];return e.forEach(e=>{e.children?t=t.concat(flattenFiles(e.children)):t.push(e)}),t};module.exports={changedFiles:changedFiles,flattenFiles:flattenFiles}; -},{}],836:[function(require,module,exports){ +},{}],837:[function(require,module,exports){ const callbackToObservable=require("../../most-utils/callbackToObservable"),makeStorageSideEffect=({name:e})=>{const a=callbackToObservable();return{sink:t=>{let r=!0;try{localStorage.getItem("jscad:")}catch(e){r=!1}r?t&&t.forEach(t=>{const{type:r,key:c,data:o}=t;if("write"===r)localStorage.setItem(`jscad:${e}-${c}`,JSON.stringify(o));else if("read"===r){const t=localStorage.getItem(`jscad:${e}-${c}`),o=JSON.parse(t)||{};a.callback({type:r,key:c,data:o})}}):callbackToObservable().callback({type:void 0,id:void 0,error:new Error("Local storage not supported in this environment!")})},source:()=>{return a.stream.multicast()}}};module.exports=makeStorageSideEffect; -},{"../../most-utils/callbackToObservable":823}],837:[function(require,module,exports){ +},{"../../most-utils/callbackToObservable":824}],838:[function(require,module,exports){ const most=require("most"),callbackToObservable=require("../../most-utils/callbackToObservable"),makeState=t=>{const{packageMetadata:s,keyBindings:a}=t,e=callbackToObservable(),r={appTitle:`jscad v ${s.version}`,activeTool:void 0,status:{message:"",error:void 0,busy:!1},shortcuts:a,storage:{path:""},version:s.version};return{source:()=>{const t=e.stream.multicast();return most.scan((t,s)=>Object.assign({},t,s.state),r,t).startWith(r).skipRepeatsWith((t,s)=>JSON.stringify(t)===JSON.stringify(s)).multicast()},sink:t=>{t.forEach(t=>{e.callback(t)})}}};module.exports=makeState; -},{"../../most-utils/callbackToObservable":823,"most":771}],838:[function(require,module,exports){ +},{"../../most-utils/callbackToObservable":824,"most":772}],839:[function(require,module,exports){ const most=require("most"),makeTitleBarSideEffect=()=>{return{sink:e=>{e.forEach(e=>{document.title=e})},source:()=>{const e=window.location.href;return most.just(e).filter(e=>void 0!==e).multicast().skipRepeats()}}};module.exports=makeTitleBarSideEffect; -},{"most":771}],839:[function(require,module,exports){ +},{"most":772}],840:[function(require,module,exports){ const WebWorkify=require("webworkify"),callBackToStream=require("../../most-utils/callbackToObservable"),makeWorkerEffect=e=>{const r=callBackToStream();let a=WebWorkify(e,{});a.onerror=(e=>r.callback({error:e})),a.onmessage=(e=>r.callback(e));return{sink:c=>{c.filter(({cmd:e})=>"cancel"===e).forEach(c=>{a.terminate(),(a=WebWorkify(e)).onerror=(e=>r.callback({error:e})),a.onmessage=(e=>r.callback(e))}),c.filter(({cmd:e})=>"cancel"!==e).forEach(e=>{a.postMessage(e)})},source:function(){return r.stream.multicast()}}};module.exports=makeWorkerEffect; -},{"../../most-utils/callbackToObservable":823,"webworkify":813}],840:[function(require,module,exports){ +},{"../../most-utils/callbackToObservable":824,"webworkify":814}],841:[function(require,module,exports){ const most=require("most"),{delayFromObservable:delayFromObservable,holdUntil:holdUntil,withLatestFrom:withLatestFrom}=require("../../most-utils"),{getParameterValuesFromUIControls:getParameterValuesFromUIControls}=require("@jscad/core").parameters,{fetchUriParams:fetchUriParams,getAllUriParams:getAllUriParams}=require("../../utils/urlUtils"),reducers=require("./reducers"),jsonCompare=(e,t)=>JSON.stringify(e)===JSON.stringify(t),actions=({sources:e})=>{const t=most.just({}).thru(withLatestFrom(reducers.initialize,e.state)).map(e=>({type:"initializeDesign",state:e,sink:"state"})).multicast(),r=t.map(e=>({sink:"store",key:"design",type:"read"})),s=e.state.filter(reducers.isDesignValid).skipRepeatsWith(reducers.isDesignTheSameForSerialization).thru(holdUntil(e.store.filter(e=>"design"===e.key&&"read"===e.type))).map(reducers.requestSaveSettings).map(e=>Object.assign({},{data:e},{sink:"store",key:"design",type:"write"})).multicast(),a=e.store.filter(e=>"design"===e.key&&"read"===e.type&&void 0!==e.data).thru(withLatestFrom(reducers.setSettings,e.state)).map(e=>({type:"setDesignSettings",state:e,sink:"state"})).multicast(),i=most.mergeArray([e.drops.filter(e=>"fileOrFolder"===e.type).tap(e=>console.log("dropped file",e)).map(({data:e})=>({sink:"fs",data:e,path:"realFs",urls:[]})),e.drops.filter(e=>"url"===e.type).tap(e=>console.log("dropped url",e)).map(e=>{const t=window.location.href,r=e.data,s=new URL(r),a=r?[r]:[],{protocol:i,pathname:o}=s;return{sink:i.replace(":",""),urls:a,origin:t,path:o,proxy:!0}}),e.dom.select(".example").events("click").map(e=>e.target.dataset.path).map(e=>{const t=new URL(e),r=e?[e]:[],{protocol:s,origin:a}=t;return{sink:s.replace(":",""),urls:r,origin:a}}).tap(e=>console.log("load example",e)),e.dom.select("#fileLoader").events("change").tap(e=>console.log("selected directory",e)).filter(e=>e.target.files.length>0).map(e=>{const t=e.target.files,r=[];for(let e=0;evoid 0!==e).tap(e=>console.log("window href processing",e)).map(e=>{const t=e;let r=fetchUriParams(e,"uri",void 0);if(!r){const t=new URL(e);if(0===t.hash.length)return;r=t.hash.slice(1)}const s=new URL(r),a=[r],{protocol:i,pathname:o}=s;return{sink:i.replace(":",""),urls:a,origin:t,path:o,proxy:!0}})]).filter(e=>void 0!==e).thru(holdUntil(a)).map(e=>({type:"read",id:"loadRemote",urls:e.urls,sink:e.sink,origin:e.origin,path:e.path,data:e.data,proxy:e.proxy})).multicast().skipRepeats(),o=most.mergeArray(Object.values(e).filter(e=>void 0!==e&&"source"in e)).filter(e=>!("loadRemote"!==e.id||"read"!==e.type||"error"in e||"sink"in e)).map(({data:e})=>({filesAndFolders:e})).thru(withLatestFrom(reducers.setDesignContent,e.state)).map(e=>({type:"setDesignContent",state:e,sink:"state"})).multicast(),n=most.mergeArray([e.state.filter(reducers.isDesignValid).map(({design:e})=>{return{id:"watchScript",path:e.mainPath,origin:e.origin,options:{enabled:e.autoReload}}}).skipRepeatsWith(jsonCompare)]).map(e=>Object.assign({},{type:"watch",sink:e.origin},e)).multicast(),l=most.mergeArray([e.state.filter(reducers.isDesignValid).filter(e=>void 0!==e.design.solids).map(e=>e.design.solids).skipRepeatsWith(jsonCompare)]).thru(withLatestFrom(reducers.requestWriteCachedGeometry,e.state)).map(e=>Object.assign({},{type:"write",id:"cachedGeometry",sink:e.origin},e)).multicast(),m=most.mergeArray([i.map(({sink:e})=>e)]).thru(withLatestFrom(reducers.resetDesign,e.state)).map(e=>({type:"resetDesign",state:e,sink:"state"})).multicast(),d=most.mergeArray([e.solidWorker.filter(e=>!("error"in e)&&e.data instanceof Object&&"solids"===e.data.type).map(e=>{const{lookupCounts:t,lookup:r,solids:s}=e.data;return{solids:s,lookup:r,lookupCounts:t}}).multicast(),e.fs.filter(e=>"read"===e.type&&"loadCachedGeometry"===e.id&&e.data).map(e=>{return{solids:void 0,lookupCounts:void 0,lookup:void e.data}}).multicast()]).thru(withLatestFrom(reducers.setDesignSolids,e.state)).map(e=>({type:"setDesignSolids",state:e,sink:"state"})).multicast(),p=e.state.skipRepeatsWith(reducers.isDesignTheSame).filter(reducers.isDesignValid).map(reducers.requestGeometryRecompute).map(e=>Object.assign({},e,{sink:"geometryWorker",cmd:"generate"})).multicast(),u=p.thru(delayFromObservable(e=>e.design.solidsTimeOut,e.state.filter(reducers.isDesignValid))).thru(withLatestFrom(reducers.timeoutGeometryRecompute,e.state)).map(e=>Object.assign({},{state:e},{sink:"state",type:"timeOutDesignGeneration"})).multicast(),c=u.filter(({state:e})=>void 0!==e.status.error).map(e=>Object.assign({},{sink:"geometryWorker",cmd:"cancel"})).multicast(),g=e.solidWorker.filter(e=>!("error"in e)&&e.data instanceof Object&&"params"===e.data.type).map(({data:e})=>({parameterDefaults:e.parameterDefaults,parameterDefinitions:e.parameterDefinitions,origin:"worker"})),h=most.mergeArray([g]).skipRepeatsWith(jsonCompare).thru(holdUntil(e.state.filter(reducers.isDesignValid))).thru(withLatestFrom(reducers.setDesignParameterDefinitions,e.state)).map(e=>({type:"setDesignParameterDefinitions",state:e,sink:"state"})).multicast(),y=()=>Array.from(document.getElementById("paramsTable").getElementsByTagName("input")).concat(Array.from(document.getElementById("paramsTable").getElementsByTagName("select"))).concat(Array.from(document.getElementById("paramsTable").getElementsByClassName("groupTitle"))),k=most.mergeArray([e.dom.select("#updateDesignFromParams").events("click").map(()=>{const e=y();return{parameterValues:getParameterValuesFromUIControls(e),origin:"uiManualUpdate"}}),e.paramChanges.filter(e=>(()=>document.getElementById("instantUpdate").checked)()).map(()=>{try{const e=y();return{parameterValues:getParameterValuesFromUIControls(e),origin:"uiInstantUpdate"}}catch(e){return{error:e,origin:"instantUpdate"}}})]).multicast().debounce(10),f=e.store.filter(e=>"design"===e.key&&"read"===e.type&&void 0!==e.data.parameterValues).map(({data:e})=>({parameterValues:e.parameterValues,origin:"store"})).multicast(),D=e.titleBar.map(e=>getAllUriParams(e)).filter(e=>Object.keys(e).length>0).map(e=>({parameterValues:e,origin:"titleBar"})).multicast(),F=e.state.filter(reducers.isDesignValid).multicast(),w=most.mergeArray([k,f,D,e.dom.select("#resetDesignToParameterDefaults").events("click").thru(withLatestFrom((e,t)=>({parameterValues:e.design.parameterDefaults,origin:"reset"}),e.state))]).skipRepeatsWith(jsonCompare).thru(holdUntil(e.state.filter(reducers.isDesignValid))).thru(holdUntil(F.filter(e=>{return e.design&&Object.keys(e.design.parameterDefinitions).length>0}))).thru(withLatestFrom(reducers.setDesignParameterValues,e.state)).map(e=>({type:"setDesignParameterValues",state:e,sink:"state"})).multicast().delay(10),U=e.solidWorker.filter(e=>e.data instanceof Object&&"errors"===e.data.type).map(({data:e})=>({error:e,origin:"worker"}));return{initialize$:t,requestLoadDesignContent$:i,requestWatchDesign$:n,requestWriteCachedGeometry$:l,resetDesign$:m,setDesignContent$:o,setDesignSolids$:d,setDesignParameterDefinitions$:h,setDesignParameterValues$:w,reportErrorsFromWorker$:most.mergeArray([U]).skipRepeatsWith(jsonCompare).tap(e=>console.log("errors",e)),requestGeometryRecompute$:p,timeoutGeometryRecompute$:u,cancelGeometryRecompute$:c,requestLoadSettings$:r,requestSaveSettings$:s,setDesignSettings$:a,toggleAutoReload$:most.mergeArray([e.dom.select("#toggleAutoReload").events("click").map(e=>e.target.checked)]).thru(withLatestFrom(reducers.toggleAutoReload,e.state)).map(e=>({type:"toggleAutoReload",state:e,sink:"state"})),toggleInstantUpdate$:most.mergeArray([e.dom.select("#instantUpdate").events("click").map(e=>e.target.checked)]).thru(withLatestFrom(reducers.toggleInstantUpdate,e.state)).map(e=>({type:"toggleInstantUpdate",state:e,sink:"state"})),toggleVTreeMode$:most.mergeArray([e.dom.select("#toggleVtreeMode").events("click").map(e=>e.target.checked)]).thru(withLatestFrom(reducers.toggleVtreeMode,e.state)).map(e=>({type:"toggleVtreeMode",state:e,sink:"state"})),setSolidsTimeout$:most.mergeArray([e.dom.select("#solidsTimeout").events("change").map(e=>e.target.value).map(e=>parseFloat(e))]).thru(withLatestFrom(reducers.setSolidsTimeout,e.state)).map(e=>({type:"setSolidsTimeout",state:e,sink:"state"}))}};module.exports=actions; -},{"../../most-utils":826,"../../utils/urlUtils":868,"./reducers":847,"@jscad/core":19,"most":771}],841:[function(require,module,exports){ +},{"../../most-utils":827,"../../utils/urlUtils":869,"./reducers":848,"@jscad/core":19,"most":772}],842:[function(require,module,exports){ const makeOutput=({sources:e,extras:t})=>e.state.filter(e=>e.design&&e.languages&&e.viewer).skipRepeatsWith((e,t)=>JSON.stringify(e)===JSON.stringify(t)).combine((e,a)=>require("../views/main")(e,a,t.paramsCallbacktoStream,t.editorCallbackToStream),e.i18n.filter(e=>"changeSettings"===e.type).map(e=>e.data));module.exports=makeOutput; -},{"../views/main":857}],842:[function(require,module,exports){ +},{"../views/main":858}],843:[function(require,module,exports){ const most=require("most"),{withLatestFrom:withLatestFrom}=require("../../most-utils"),reducers={setErrors:(r,t)=>{const{error:s}=t;return{status:Object.assign({},r.status,{error:s,busy:!1})}},clearErrors:(r,t)=>{return{status:Object.assign({},r.status,{error:void 0,busy:!1})}}},actions=({sources:r})=>{return{setErrors$:most.mergeArray(Object.values(r).filter(r=>void 0!==r&&"source"in r)).filter(r=>{try{return"error"in r}catch(r){return!1}}).thru(withLatestFrom(reducers.setErrors,r.state)).map(r=>Object.assign({},{type:"setErrors",sink:"state"},{state:r})),clearErrors$:most.never().thru(withLatestFrom(reducers.clearErrors,r.state)).map(r=>Object.assign({},{type:"clearErrors",sink:"state"},{state:r}))}};module.exports=actions; -},{"../../most-utils":826,"most":771}],843:[function(require,module,exports){ +},{"../../most-utils":827,"most":772}],844:[function(require,module,exports){ const most=require("most"),{solidsAsBlob:solidsAsBlob}=require("@jscad/io"),{withLatestFrom:withLatestFrom}=require("../../most-utils"),{exportFilePathFromFormatAndDesign:exportFilePathFromFormatAndDesign}=require("../../core/io/exportUtils"),reducers={initialize:t=>{return{io:{exportFormat:"",exportFilePath:"",availableExportFormats:[]}}},setExportFormat:(t,e)=>{return{io:Object.assign({},t.io,exportFilePathFromFormatAndDesign(t.design,e),{exportFormat:e})}},requestExport:t=>{const{exportFilePath:e,exportFormat:r}=t.io,{solids:s}=t.design,{saveAs:o}=require("file-saver");o(solidsAsBlob(s,{format:r}),e)}},actions=({sources:t})=>{const e=most.just({}).thru(withLatestFrom(reducers.initialize,t.state)).map(t=>Object.assign({},{type:"initializeExports",sink:"state"},{state:t})),r=t.dom.select("#exportFormats").events("change").map(t=>t.target.value).thru(withLatestFrom(reducers.setExportFormat,t.state)).map(t=>Object.assign({},{type:"changeExportFormat",sink:"state"},{state:t})).multicast();return{initializeExports$:e,requestExport$:t.dom.select("#exportBtn").events("click").thru(withLatestFrom(reducers.requestExport,t.state)).map(t=>({type:"exportRequested",data:t})),changeExportFormat$:r}};module.exports=actions; -},{"../../core/io/exportUtils":815,"../../most-utils":826,"@jscad/io":69,"file-saver":727,"most":771}],844:[function(require,module,exports){ +},{"../../core/io/exportUtils":816,"../../most-utils":827,"@jscad/io":69,"file-saver":728,"most":772}],845:[function(require,module,exports){ const most=require("most"),{flatten:flatten}=require("@jscad/array-utils"),{proxy:proxy}=require("most-proxy"),makeActions=e=>{const{attach:r,stream:s}=proxy();e.actions=s.skipRepeatsWith((e,r)=>JSON.stringify(e)===JSON.stringify(r)).multicast();const t=require("./tools")({sources:e}),i=require("./viewer")({sources:e}),o=require("./themes")({sources:e}),u=require("./languages")({sources:e}),a=require("./shortcuts")({sources:e}),c=require("./errors")({sources:e}),n=require("./exports")({sources:e}),m=[c,require("./design")({sources:e}),n,t,o,i,u,a],l=most.mergeArray(flatten(m.map(e=>Object.values(e)))).skipRepeatsWith((e,r)=>JSON.stringify(e)===JSON.stringify(r)).multicast().filter(e=>void 0!==e);return r(l),l};module.exports=makeActions; -},{"./design":840,"./errors":842,"./exports":843,"./languages":846,"./shortcuts":848,"./themes":849,"./tools":850,"./viewer":851,"@jscad/array-utils":526,"most":771,"most-proxy":732}],845:[function(require,module,exports){ +},{"./design":841,"./errors":843,"./exports":844,"./languages":847,"./shortcuts":849,"./themes":850,"./tools":851,"./viewer":852,"@jscad/array-utils":527,"most":772,"most-proxy":733}],846:[function(require,module,exports){ const makeReactions=i=>{const{sinks:s,outputs$:t}=i,{store:n,fs:e,http:k,https:r,i18n:o,dom:f,solidWorker:l,state:a,dat:d}=s;f(require("./dom")(i)),o(t.filter(i=>"sink"in i&&"i18n"===i.sink)),n(t.filter(i=>"sink"in i&&"store"===i.sink)),k(t.filter(i=>"sink"in i&&"http"===i.sink)),r(t.filter(i=>"sink"in i&&"https"===i.sink)),e(t.filter(i=>"sink"in i&&"fs"===i.sink)),l(t.filter(i=>"sink"in i&&"geometryWorker"===i.sink)),a(t.filter(i=>"sink"in i&&"state"===i.sink)),d(t.filter(i=>"sink"in i&&"dat"===i.sink))};module.exports=makeReactions; -},{"./dom":841}],846:[function(require,module,exports){ +},{"./dom":842}],847:[function(require,module,exports){ const most=require("most"),{holdUntil:holdUntil,withLatestFrom:withLatestFrom}=require("../../most-utils"),reducers={initialize:e=>{return{languages:{active:void 0,available:[]}}},setLanguage:(e,a)=>{return{languages:Object.assign({},e.languages,{active:a})}},setAvailableLanguages:(e,a)=>{return{languages:Object.assign({},e.languages,{available:a})}},requestSaveSettings:e=>({active:e.active})},actions=({sources:e})=>{const a=most.just({}).thru(withLatestFrom(reducers.initialize,e.state)).map(e=>Object.assign({},{type:"initializeLanguages",sink:"state"},{state:e})),t=a.map(e=>({type:"getAvailableLanguages",sink:"i18n"})),s=t.map(e=>({type:"getDefaultLocale",sink:"i18n"})),i=e.state.filter(e=>e.languages&&void 0!==e.languages.active).map(e=>e.languages.active).skipRepeatsWith((e,a)=>JSON.stringify(e)===JSON.stringify(a)).map(e=>({type:"changeSettings",data:e,sink:"i18n"})),g=most.mergeArray([e.i18n.filter(e=>"getAvailableLanguages"===e.type).map(e=>e.data)]).thru(withLatestFrom(reducers.setAvailableLanguages,e.state)).map(e=>Object.assign({},{type:"setAvailableLanguages",sink:"state"},{state:e})).multicast(),n=a.map(e=>({sink:"store",key:"languages",type:"read"})),l=e.i18n.thru(holdUntil(g)).filter(e=>"getDefaultLocale"===e.type).map(e=>e.data).multicast().delay(1),r=e.store.filter(e=>"languages"===e.key&&"read"===e.type).thru(holdUntil(l)).map(e=>e.data.active).filter(e=>void 0!==e);return{initialize$:a,requestGetAvailableLanguages$:t,requestGetDefaultLanguage$:s,requestGetLanguageData$:i,setLanguage$:most.mergeArray([l,e.dom.select("#languageSwitcher").events("change").map(e=>e.target.value),r]).thru(withLatestFrom(reducers.setLanguage,e.state)).map(e=>Object.assign({},{type:"setLanguage",sink:"state"},{state:e})),setAvailableLanguages$:g,requestLoadSettings$:n,requestSaveSettings$:e.state.filter(e=>e.languages).map(e=>e.languages).thru(holdUntil(e.store.filter(e=>"languages"===e.key&&"read"===e.type))).map(reducers.requestSaveSettings).map(e=>Object.assign({},{data:e},{sink:"store",key:"languages",type:"write"})).multicast()}};module.exports=actions; -},{"../../most-utils":826,"most":771}],847:[function(require,module,exports){ +},{"../../most-utils":827,"most":772}],848:[function(require,module,exports){ const path=require("path"),{applyParameterDefinitions:applyParameterDefinitions}=require("@jscad/core").parameters,{makeFakeFs:makeFakeFs}=require("@jscad/core").loading,{getDesignEntryPoint:getDesignEntryPoint,getDesignName:getDesignName}=require("@jscad/core").loading.requireDesignUtilsFs,{keep:keep}=require("../../utils/object"),packageMetadata=require("../../../package.json"),{availableExportFormatsFromSolids:availableExportFormatsFromSolids,exportFilePathFromFormatAndDesign:exportFilePathFromFormatAndDesign}=require("../../core/io/exportUtils"),designEqualityFields=["parameterDefinitions","parameterValues","mainPath","filesAndFolders","vtreeMode"],serializableFields=["name","mainPath","origin","parameterValues","vtreeMode","autoReload","instantUpdate","solidsTimeOut"],reducers={initialize:()=>{return{design:{name:"",path:"",mainPath:"",origin:void 0,filesAndFolders:[],instantUpdate:!1,autoReload:!1,parameterDefinitions:[],parameterValues:{},parameterDefaults:{},solidsTimeOut:8e4,solids:[],vtreeMode:!1,lookup:{},lookupCounts:{},debug:{startTime:0,endTime:0,totalTime:0}}}},resetDesign:(e,t)=>{const i=Object.assign({},e.design,keep(["name","path","mainPath","origin","filesAndFolders","parameterDefinitions","parameterValues","parameterDefaults","lookup","lookupCounts","debug","solids"],reducers.initialize().design));return i.origin=t,{design:i}},setDesignContent:(e,t)=>{const{filesAndFolders:i}=t,s=makeFakeFs(i),a=i[0].fullPath,n=getDesignEntryPoint(s,a),r=getDesignName(s,a),o=path.dirname(a);let d=e.design;const g=Object.assign({},e.design.debug,{startTime:new Date});return{design:d=Object.assign({},d,{name:r,path:o,mainPath:n,filesAndFolders:i,debug:g}),appTitle:`jscad v ${packageMetadata.version}: ${e.design.name}`,status:Object.assign({},e.status,{busy:!0,error:void 0})}},setDesignSolids:(e,{solids:t,lookup:i,lookupCounts:s})=>{t=t||[],i=i||{},s=s||{};const a=new Date,n=a-e.design.debug.startTime,r=Object.assign({},e.design.debug,{endTime:a,totalTime:n});console.warn("total time for design regeneration",n,(new Date).getSeconds());const o=Object.assign({},e.design,{solids:t,lookup:i,lookupCounts:s,debug:r}),{exportFormat:d,availableExportFormats:g}=availableExportFormatsFromSolids(t),l={exportFormat:d,exportFilePath:exportFilePathFromFormatAndDesign(o,d).exportFilePath,availableExportFormats:g};return{design:o,status:Object.assign({},e.status,{busy:!1}),io:l}},setDesignParameterDefinitions:(e,t)=>{const i=t.parameterDefaults||e.design.parameterDefaults,s=t.parameterDefinitions||e.design.parameterDefinitions;return{design:Object.assign({},e.design,{parameterDefaults:i,parameterDefinitions:s,parametersOrigin:t.origin})}},setDesignParameterValues:(e,t)=>{let i=t.parameterValues;"instantUpdate"!==t.origin||e.design.instantUpdate||(i=e.design.parameterValues),i=i?applyParameterDefinitions(i,e.design.parameterDefinitions):i,i=Object.assign({},e.design.parameterValues,i);let s=Object.assign({},e.design,{parameterValues:i,parametersOrigin:t.origin});const a=Object.assign({},e.design.debug,{startTime:new Date});return{design:s=Object.assign({},s,{debug:a}),status:Object.assign({},e.status,{busy:!0,error:void 0})}},setSettings:(e,{data:t})=>{const{vtreeMode:i,autoReload:s,instantUpdate:a,solidsTimeOut:n}=t;return void 0===i?{design:e.design}:{design:Object.assign({},e.design,{vtreeMode:i,autoReload:s,instantUpdate:a,solidsTimeOut:n})}},requestGeometryRecompute:({design:e},t)=>keep(["mainPath","parameterValues","filesAndFolders","vtreeMode","lookup","lookupCounts"],e),timeoutGeometryRecompute:({status:e},t)=>e.isBusy?Object.assign({},e,{busy:!1,error:new Error("Failed to generate design within an acceptable time, bailing out")}):{status:e},requestWriteCachedGeometry:({design:e},t)=>{const i={};return Object.keys(t).forEach(e=>{i[e]=t[e]}),{path:".solidsCache",options:{isRawData:!0},origin:e.origin}},requestSaveSettings:({design:e})=>keep(serializableFields,e),isDesignValid:e=>e.design&&e.design.name&&""!==e.design.path,isDesignTheSame:(e,t)=>{if(!e.design)return!1;const i=JSON.stringify(keep(designEqualityFields,t.design));return JSON.stringify(keep(designEqualityFields,e.design))===i},isDesignTheSameForSerialization:(e,t)=>{if(!e.design)return!1;const i=JSON.stringify(keep(serializableFields,t.design));return JSON.stringify(keep(serializableFields,e.design))===i},toggleAutoReload:(e,t)=>{return{design:Object.assign({},e.design,{autoReload:t})}},toggleInstantUpdate:(e,t)=>{return{design:Object.assign({},e.design,{instantUpdate:t})}},toggleVtreeMode:(e,t)=>{return{design:Object.assign({},e.design,{vtreeMode:t})}},setSolidsTimeout:(e,t)=>{return{design:Object.assign({},e.design,{solidsTimeOut:t})}}};module.exports=reducers; -},{"../../../package.json":814,"../../core/io/exportUtils":815,"../../utils/object":867,"@jscad/core":19,"path":712}],848:[function(require,module,exports){ +},{"../../../package.json":815,"../../core/io/exportUtils":816,"../../utils/object":868,"@jscad/core":19,"path":713}],849:[function(require,module,exports){ const most=require("most"),{head:head}=require("@jscad/array-utils"),{holdUntil:holdUntil,withLatestFrom:withLatestFrom}=require("../../most-utils"),{getKeyCombos:getKeyCombos,isKeyEventScopeValid:isKeyEventScopeValid,simpleKey:simpleKey}=require("../../utils/keys"),{merge:merge}=require("../../utils/utils"),reducers={initialize:e=>e,setShortcuts:(e,t)=>{return{shortcuts:merge([],e.shortcuts,t)}},setShortcut:(e,t)=>{const s=t=>e.shortcuts.filter(e=>e.key===t).length>0;return{shortcuts:e.shortcuts.map(e=>{if(e.command===t.command&&e.args===t.args){if("inProgress"in t){const{inProgress:r,tmpKey:o}=t;if(r){const t=s(o)?"shortcut already exists":void 0;return Object.assign({},e,{inProgress:r,tmpKey:o,error:t})}return Object.assign({},e,{inProgress:r,tmpKey:o})}if(t.done&&!s(t.key)){const{command:s,args:r}=e;return{key:t.key,command:s,args:r}}return e}return e})}},triggerShortcut:(e,{event:t,compositeKey:s})=>{const r=head(e.shortcuts.filter(e=>e.key.toLowerCase()===s));if(r){const{command:e,args:t}=r;return{type:e,data:t}}},requestSaveSettings:e=>e},actions=({sources:e})=>{const t=most.just({}).thru(withLatestFrom(reducers.initialize,e.state)).map(e=>Object.assign({},{type:"initializeShortcuts",sink:"state"},{state:e})),s=most.mergeArray([e.store.filter(e=>"shortcuts"===e.key&&"read"===e.type&&e.data&&e.data.shortcuts).map(e=>e.data.shortcuts)]).thru(withLatestFrom(reducers.setShortcuts,e.state)).map(e=>Object.assign({},{type:"setShortcuts",sink:"state"},{state:e})),r=e.dom.select(".shortcutCommand").events("keyup").multicast(),o=e.dom.select(".shortcutCommand").events("keydown").multicast(),a=getKeyCombos({dropRepeats:!0,endKeys:["enter","escape"]},r,o);r.forEach(e=>(e.preventDefault(),e.stopPropagation(),!1)),o.forEach(e=>(e.preventDefault(),e.stopPropagation(),!1));const i=most.mergeArray([a.map(({event:e,compositeKey:t})=>({event:e,compositeKey:t,inProgress:!0})).merge(e.dom.select(".shortcutCommand").events("focus").map(e=>({event:e,compositeKey:"",inProgress:!0}))).merge(e.dom.select(".shortcutCommand").events("blur").map(e=>({event:e,compositeKey:"",inProgress:!1}))).merge(r.filter(e=>"escape"===simpleKey(e)).map(e=>({event:e,compositeKey:"",inProgress:!1}))).merge(r.filter(e=>"enter"===simpleKey(e)).map(e=>({event:e,done:!0}))).scan((e,t)=>{const{event:s,compositeKey:r,inProgress:o,done:a}=t,i=s.target.dataset.command,n=s.target.dataset.args,m=Object.assign({},e,{command:i,args:n,inProgress:o,done:a});return void 0!==r&&""!==r&&(m.key=r,m.tmpKey=r),"done"in m&&m.done&&(delete m.inProgress,delete m.tmpKey),m},{}).filter(e=>void 0!==e)]).thru(withLatestFrom(reducers.setShortcut,e.state)).map(e=>({type:"setShortcut",state:e,sink:"state"})).multicast(),n=e.dom.element.getAttribute("key"),m=most.fromEvent("keyup",e.dom.element).filter(e=>isKeyEventScopeValid(n,e.target)).multicast(),c=most.fromEvent("keydown",e.dom.element).filter(e=>isKeyEventScopeValid(n,e.target)).multicast(),u=getKeyCombos({dropRepeats:!1},m,c).thru(withLatestFrom(reducers.triggerShortcut,e.state)).filter(e=>void 0!==e),d=t.map(e=>({sink:"store",key:"shortcuts",type:"read"}));return{initialize$:t,setShortcut$:i,setShortcuts$:s,triggerFromShortcut$:u,requestLoadSettings$:d,requestSaveSettings$:e.state.filter(e=>e.shortcuts).map(e=>e.shortcuts).thru(holdUntil(e.store.filter(e=>"shortcuts"===e.key&&"read"===e.type))).map(reducers.requestSaveSettings).map(e=>Object.assign({},{data:e},{sink:"store",key:"shortcuts",type:"write"})).multicast()}};module.exports=actions; -},{"../../most-utils":826,"../../utils/keys":865,"../../utils/utils":869,"@jscad/array-utils":526,"most":771}],849:[function(require,module,exports){ +},{"../../most-utils":827,"../../utils/keys":866,"../../utils/utils":870,"@jscad/array-utils":527,"most":772}],850:[function(require,module,exports){ const most=require("most"),{holdUntil:holdUntil,withLatestFrom:withLatestFrom}=require("../../most-utils"),{merge:merge}=require("../../utils/utils"),reducers={initialize:e=>{return{themes:{active:"light",themeSettings:{mainTextColor:"#FFF"}}}},setTheme:(e,t)=>{const s=require("../../../data/themes"),i=s[t]?s[t]:s.light;return{viewer:e.viewer?merge({},e.viewer,i.viewer):i.viewer,themes:Object.assign({},e.themes,{available:s,active:t,themeSettings:i})}},requestSaveSettings:e=>({active:e.active})},actions=({sources:e})=>{const t=most.just({}).thru(withLatestFrom(reducers.initialize,e.state)).map(e=>Object.assign({},{type:"initializeThemes",sink:"state"},{state:e})),s=most.mergeArray([e.dom.select("#themeSwitcher").events("change").map(e=>e.target.value),e.store.filter(e=>"themes"===e.key&&"read"===e.type&&e.data&&e.data.active).map(e=>e.data.active)]).startWith("light").thru(withLatestFrom(reducers.setTheme,e.state)).map(e=>Object.assign({},{type:"setTheme",sink:"state"},{state:e})),i=t.map(e=>({sink:"store",key:"themes",type:"read"}));return{initialize$:t,setTheme$:s,requestLoadSettings$:i,requestSaveSettings$:e.state.filter(e=>e.themes).map(e=>e.themes).thru(holdUntil(e.store.filter(e=>"themes"===e.key&&"read"===e.type))).map(reducers.requestSaveSettings).map(e=>Object.assign({},{data:e},{sink:"store",key:"themes",type:"write"})).multicast()}};module.exports=actions; -},{"../../../data/themes":676,"../../most-utils":826,"../../utils/utils":869,"most":771}],850:[function(require,module,exports){ +},{"../../../data/themes":677,"../../most-utils":827,"../../utils/utils":870,"most":772}],851:[function(require,module,exports){ const most=require("most"),{withLatestFrom:withLatestFrom}=require("../../most-utils"),actions=({sources:e})=>{return{setActiveTool$:most.mergeArray([e.dom.select("#toggleOptions").events("click").map(e=>"options"),e.dom.select("#toggleEditor").events("click").map(e=>"editor"),e.dom.select("#toggleHelp").events("click").map(e=>"help"),e.dom.select(".example").events("mouseup").map(e=>void 0)]).thru(withLatestFrom((e,t)=>{return{activeTool:e.activeTool===t?void 0:t}},e.state)).map(e=>Object.assign({},{type:"setActiveTool",sink:"state"},{state:e}))}};module.exports=actions; -},{"../../most-utils":826,"most":771}],851:[function(require,module,exports){ +},{"../../most-utils":827,"most":772}],852:[function(require,module,exports){ const most=require("most"),{withLatestFrom:withLatestFrom}=require("../../most-utils"),reducers={initialize:e=>{return{viewer:{rendering:{background:[1,1,1,1],meshColor:[0,.6,1,1],autoRotate:!1,autoZoom:!1},grid:{show:!1,color:[1,1,1,.1]},axes:{show:!0},camera:{position:""}}}},toggleAutoRotate:(e,t)=>{const r=Object.assign({},e.viewer.rendering,{autoRotate:t});return{viewer:Object.assign({},e.viewer,{rendering:r})}},toggleAutoZoom:(e,t)=>{const r=Object.assign({},e.viewer.rendering,{autoZoom:t});return{viewer:Object.assign({},e.viewer,{rendering:r})}},toggleGrid:(e,t)=>{const r=Object.assign({},e.viewer.grid,{show:t});return{viewer:Object.assign({},e.viewer,{grid:r})}},toggleAxes:(e,t)=>{const r=Object.assign({},e.viewer.axes,{show:t});return{viewer:Object.assign({},e.viewer,{axes:r})}},toPresetView:(e,t)=>{const r=Object.assign({},e.viewer.camera,{position:t});return{viewer:Object.assign({},e.viewer,{camera:r})}},setProjectionType:(e,t)=>{return{viewer:Object.assign({},e.viewer,{camera:{projectionType:t}})}}},actions=({sources:e})=>{const t=most.just({}).thru(withLatestFrom(reducers.initialize,e.state)).map(e=>Object.assign({},{type:"initializeViewer",sink:"state"},{state:e})),r=most.mergeArray([e.dom.select("#toggleGrid").events("click").map(e=>e.target.checked)]).thru(withLatestFrom(reducers.toggleGrid,e.state)).map(e=>({type:"toggleGrid",state:e,sink:"state"})),s=most.mergeArray([e.dom.select("#toggleAxes").events("click").map(e=>e.target.checked)]).thru(withLatestFrom(reducers.toggleAxes,e.state)).map(e=>({type:"toggleAxes",state:e,sink:"state"})),o=most.mergeArray([e.dom.select("#toggleAutoRotate").events("click").map(e=>e.target.checked)]).thru(withLatestFrom(reducers.toggleAutoRotate,e.state)).map(e=>({type:"toggleAutoRotate",state:e,sink:"state"})),i=most.mergeArray([e.dom.select("#toggleAutoZoom").events("click").map(e=>e.target.checked)]).thru(withLatestFrom(reducers.toggleAutoZoom,e.state)).map(e=>({type:"toggleAutoZoom",state:e,sink:"state"})),a=["toPresetView"];return{initializeViewer$:t,toggleGrid$:r,toggleAxes$:s,toggleAutoRotate$:o,toggleAutoZoom$:i,otherViewerActions$:e.actions.filter(e=>a.includes(e.type)).thru(withLatestFrom((e,t)=>reducers[t.type](e,t.data),e.state)).map(e=>({type:"otherActions",state:e,sink:"state"}))}};module.exports=actions; -},{"../../most-utils":826,"most":771}],852:[function(require,module,exports){ +},{"../../most-utils":827,"most":772}],853:[function(require,module,exports){ const html=require("nanohtml"),{createParamControls:createParamControls}=require("./parameterControls"),designParameters=(e,t,a)=>{const{parameterValues:s,parameterDefinitions:r,parameterDefaults:n}=e.design;try{const{controls:i}=createParamControls(Object.assign({},n,s),r,t.callback);return html`
@@ -3440,7 +3443,7 @@ const html=require("nanohtml"),{createParamControls:createParamControls}=require
`}catch(t){t.stack=void 0,e.status.error=t}};module.exports=designParameters; -},{"./parameterControls":859,"nanohtml":807}],853:[function(require,module,exports){ +},{"./parameterControls":860,"nanohtml":808}],854:[function(require,module,exports){ const html=require("nanohtml"),CodeMirror=require("codemirror");require("codemirror/mode/javascript/javascript"),require("codemirror/addon/hint/javascript-hint");const editorOptions={mode:"javascript",indentUnit:2,smartIndent:!1,indentWithTabs:!1,lineNumbers:!0,autofocus:!0};let editor,wrapper;const createFileTree=e=>{const r=e.getValue();return r&&r.length>0?[{ext:"js",fullPath:"/changes.js",mimetype:"javascript",name:"changes.js",source:r}]:null},createWrapper=(e,r)=>{if(!wrapper){(wrapper=html`