selva-compute 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +71 -10
  2. package/dist/{base-DbB0Ggdq.d.cts → base-dtik4Dlu.d.cts} +20 -0
  3. package/dist/{base-DbB0Ggdq.d.ts → base-dtik4Dlu.d.ts} +20 -0
  4. package/dist/chunk-F7DPIDIA.cjs +2 -0
  5. package/dist/{chunk-NQYH7IAS.cjs.map → chunk-F7DPIDIA.cjs.map} +1 -1
  6. package/dist/chunk-FMFP7GIM.js +2 -0
  7. package/dist/chunk-FMFP7GIM.js.map +1 -0
  8. package/dist/chunk-MK3M76VN.js +3 -0
  9. package/dist/chunk-MK3M76VN.js.map +1 -0
  10. package/dist/chunk-PE2FMBXD.cjs +3 -0
  11. package/dist/chunk-PE2FMBXD.cjs.map +1 -0
  12. package/dist/{chunk-M2HPEWXH.cjs → chunk-QCHPQ22Y.cjs} +2 -2
  13. package/dist/{chunk-M2HPEWXH.cjs.map → chunk-QCHPQ22Y.cjs.map} +1 -1
  14. package/dist/{chunk-QFHFH5BS.js → chunk-WD3ENUAA.js} +2 -2
  15. package/dist/core.cjs +1 -1
  16. package/dist/core.d.cts +10 -10
  17. package/dist/core.d.ts +10 -10
  18. package/dist/core.js +1 -1
  19. package/dist/grasshopper.cjs +1 -1
  20. package/dist/grasshopper.d.cts +9 -6
  21. package/dist/grasshopper.d.ts +9 -6
  22. package/dist/grasshopper.js +1 -1
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.d.cts +2 -2
  25. package/dist/index.d.ts +2 -2
  26. package/dist/index.js +1 -1
  27. package/dist/{schemas-CQEJ5EZy.d.ts → schemas-BE5ai7jG.d.cts} +17 -4
  28. package/dist/{schemas-CQEJ5EZy.d.cts → schemas-BE5ai7jG.d.ts} +17 -4
  29. package/dist/visualization.cjs +1 -1
  30. package/dist/visualization.d.cts +1 -1
  31. package/dist/visualization.d.ts +1 -1
  32. package/dist/visualization.js +1 -1
  33. package/package.json +1 -2
  34. package/dist/chunk-FNWG34KH.cjs +0 -3
  35. package/dist/chunk-FNWG34KH.cjs.map +0 -1
  36. package/dist/chunk-MUIYGZQS.js +0 -2
  37. package/dist/chunk-MUIYGZQS.js.map +0 -1
  38. package/dist/chunk-NQYH7IAS.cjs +0 -2
  39. package/dist/chunk-VGM4KAFN.js +0 -3
  40. package/dist/chunk-VGM4KAFN.js.map +0 -1
  41. /package/dist/{chunk-QFHFH5BS.js.map → chunk-WD3ENUAA.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/selva-compute/selva-compute/dist/chunk-M2HPEWXH.cjs","../src/core/utils/encoding.ts"],"names":["encodeStringToBase64","str","isBase64","decodeBase64ToBinary","base64File","c","RhinoComputeError","ErrorCodes","base64ByteArray","bytes","encodings","inputBytes","byteLength","byteRemainder","mainLength","base64","a","b","d","chunk","i","byte1","byte2","byte3","innerChunk","charA","charB","charC","charD"],"mappings":"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","file":"/home/runner/work/selva-compute/selva-compute/dist/chunk-M2HPEWXH.cjs","sourcesContent":[null,"/**\n * Encodes a string to base64 (Node 20+ safe)\n *\n * @internal Internal encoding helper — kept internal to `selva-compute`.\n *\n * @param str - String to encode\n * @returns Base64 encoded string\n */\nexport function encodeStringToBase64(str: string): string {\n\treturn Buffer.from(str, 'utf-8').toString('base64');\n}\n\n/**\n * Decodes a base64 string to a UTF-8 string (Node 20+ safe)\n *\n * @internal Internal encoding helper — kept internal to `selva-compute`.\n *\n * @param base64Str - Base64 encoded string\n * @returns Decoded UTF-8 string\n */\nexport function decodeBase64ToString(base64Str: string): string {\n\treturn Buffer.from(base64Str, 'base64').toString('utf-8');\n}\n\n/**\n * Checks if a string is valid base64\n *\n * @internal Internal encoding helper — kept internal to `selva-compute`.\n *\n * @param str - String to check\n * @returns True if the string is valid base64\n */\nexport function isBase64(str: string): boolean {\n\tif (!str || str.trim().length === 0) return false;\n\ttry {\n\t\treturn Buffer.from(str, 'base64').toString('base64') === str;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Decodes a base64 string to binary data (Uint8Array)\n *\n * @internal Internal encoding helper — kept internal to `selva-compute`.\n *\n * @param base64File - Base64 encoded string\n * @returns Decoded binary data as Uint8Array\n * @throws {RhinoComputeError} If base64 decoding is not supported in this environment.\n */\nexport function decodeBase64ToBinary(base64File: string): Uint8Array {\n\tif (typeof globalThis.atob === 'function') {\n\t\treturn Uint8Array.from(globalThis.atob(base64File), (c) => c.charCodeAt(0));\n\t}\n\tif (typeof (globalThis as any).Buffer === 'function') {\n\t\t// Buffer.from returns a Uint8Array-compatible Buffer\n\t\treturn (globalThis as any).Buffer.from(base64File, 'base64');\n\t}\n\n\t// Import here to avoid circular dependencies at top level\n\t// eslint-disable-next-line @typescript-eslint/no-require-imports\n\tconst { RhinoComputeError, ErrorCodes } = require('./../../core/errors');\n\tthrow new RhinoComputeError(\n\t\t'Base64 decoding not supported in this environment.',\n\t\tErrorCodes.INVALID_STATE,\n\t\t{ context: { environmentInfo: 'atob or Buffer not available' } }\n\t);\n}\n\n/**\n * Encodes binary data (Uint8Array) to base64 string\n *\n * @internal Internal encoding helper — kept internal to `selva-compute`.\n *\n * Source: https://github.com/mcneel/compute.rhino3d.appserver/blob/92c95a3b1d076a4d4a5360214ffd27c46425ff03/src/examples/convert/scriptjs\n * https://gist.github.com/jonleighton/958841\n *\n * MIT LICENSE\n * Copyright 2011 Jon Leighton\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\nexport function base64ByteArray(bytes: Uint8Array | null | undefined): string {\n\tif (bytes === null || bytes === undefined) {\n\t\t// Import here to avoid circular dependencies at top level\n\t\t// eslint-disable-next-line @typescript-eslint/no-require-imports\n\t\tconst { RhinoComputeError, ErrorCodes } = require('./../../core/errors');\n\t\tthrow new RhinoComputeError(\n\t\t\t'Input bytes must not be null or undefined',\n\t\t\tErrorCodes.INVALID_INPUT,\n\t\t\t{ context: { receivedValue: bytes } }\n\t\t);\n\t}\n\n\tconst encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n\n\tlet inputBytes = bytes;\n\n\t// strip bom (Byte Order Mark)\n\tif (\n\t\tinputBytes.length >= 3 &&\n\t\tinputBytes[0] === 239 &&\n\t\tinputBytes[1] === 187 &&\n\t\tinputBytes[2] === 191\n\t) {\n\t\tinputBytes = inputBytes.slice(3);\n\t}\n\n\tconst byteLength = inputBytes.byteLength;\n\tconst byteRemainder = byteLength % 3;\n\tconst mainLength = byteLength - byteRemainder;\n\n\tlet base64 = '';\n\tlet a, b, c, d;\n\tlet chunk;\n\n\t// Main loop deals with bytes in chunks of 3\n\tfor (let i = 0; i < mainLength; i += 3) {\n\t\t// Combine the three bytes into a single integer\n\n\t\tconst byte1 = inputBytes[i] !== undefined ? inputBytes[i] : 0;\n\t\tconst byte2 = inputBytes[i + 1] !== undefined ? inputBytes[i + 1] : 0;\n\t\tconst byte3 = inputBytes[i + 2] !== undefined ? inputBytes[i + 2] : 0;\n\n\t\tconst innerChunk = (byte1 << 16) | (byte2 << 8) | byte3;\n\n\t\t// Use bitmasks to extract 6-bit segments from the triplet\n\t\ta = (innerChunk & 16515072) >> 18;\n\t\tb = (innerChunk & 258048) >> 12;\n\t\tc = (innerChunk & 4032) >> 6;\n\t\td = innerChunk & 63;\n\n\t\t// Convert the raw binary segments to the appropriate ASCII encoding\n\t\tif (typeof encodings !== 'string') {\n\t\t\tthrow new Error('encodings must be a string');\n\t\t}\n\n\t\tif (typeof a !== 'number' || a < 0 || a >= encodings.length) {\n\t\t\tthrow new Error('Invalid index a');\n\t\t}\n\n\t\tif (typeof b !== 'number' || b < 0 || b >= encodings.length) {\n\t\t\tthrow new Error('Invalid index b');\n\t\t}\n\n\t\tif (typeof c !== 'number' || c < 0 || c >= encodings.length) {\n\t\t\tthrow new Error('Invalid index c');\n\t\t}\n\n\t\tif (typeof d !== 'number' || d < 0 || d >= encodings.length) {\n\t\t\tthrow new Error('Invalid index d');\n\t\t}\n\n\t\tconst charA = encodings[a];\n\t\tconst charB = encodings[b];\n\t\tconst charC = encodings[c];\n\t\tconst charD = encodings[d];\n\n\t\tif (charA === undefined || charB === undefined || charC === undefined || charD === undefined) {\n\t\t\tthrow new Error('Invalid encoding index');\n\t\t}\n\n\t\tbase64 += charA + charB + charC + charD;\n\t}\n\n\t// Deal with the remaining bytes and padding\n\tif (byteRemainder === 1) {\n\t\tchunk = inputBytes[mainLength];\n\n\t\tif (chunk === undefined) {\n\t\t\tthrow new Error(\"'chunk' must not be undefined\");\n\t\t}\n\n\t\ta = (chunk & 252) >> 2;\n\t\tb = (chunk & 3) << 4;\n\n\t\tconst charA = encodings[a];\n\t\tconst charB = encodings[b];\n\n\t\tif (charA === undefined || charB === undefined) {\n\t\t\tthrow new Error('Invalid encoding index');\n\t\t}\n\n\t\tbase64 += `${charA + charB}==`;\n\t} else if (byteRemainder === 2) {\n\t\tconst byte1 = inputBytes[mainLength] ?? 0;\n\t\tconst byte2 = inputBytes[mainLength + 1] !== undefined ? inputBytes[mainLength + 1] : 0;\n\n\t\tif (\n\t\t\ttypeof byte1 !== 'number' ||\n\t\t\tbyte1 < 0 ||\n\t\t\tbyte1 > 255 ||\n\t\t\ttypeof byte2 !== 'number' ||\n\t\t\tbyte2 < 0 ||\n\t\t\tbyte2 > 255\n\t\t) {\n\t\t\tthrow new Error('Invalid byte1');\n\t\t}\n\n\t\tchunk = (byte1 << 8) | byte2;\n\n\t\ta = (chunk & 64512) >> 10;\n\t\tb = (chunk & 1008) >> 4;\n\t\tc = (chunk & 15) << 2;\n\n\t\tconst charA = encodings[a];\n\t\tconst charB = encodings[b];\n\t\tconst charC = encodings[c];\n\n\t\tif (charA === undefined || charB === undefined || charC === undefined) {\n\t\t\tthrow new Error('Invalid encoding index');\n\t\t}\n\n\t\tbase64 += `${charA + charB + charC}=`;\n\t}\n\n\treturn base64;\n}\n\n/**\n * Convert base64 string to rhino object\n *\n * @internal Internal helper for decoding Rhino objects — not public API.\n *\n * Source: https://github.com/mcneel/compute.rhino3d.appserver/blob/92c95a3b1d076a4d4a5360214ffd27c46425ff03/src/examples/convert/scriptjs\n * @param rhino is the rhino module form rhino3dm. Since not properly typed its not used here.\n * @param item\n * @returns\n */\nexport function base64ToRhinoObject(\n\trhino: any,\n\titem: {\n\t\ttype: string;\n\t\tdata: string;\n\t}\n) {\n\t// Import here to avoid circular dependencies at top level\n\t// eslint-disable-next-line @typescript-eslint/no-require-imports\n\tconst { getLogger } = require('./logger');\n\n\t//Make a type definition for this?\n\tlet decodata: null | object = null;\n\ttry {\n\t\tdecodata = JSON.parse(item.data);\n\t} catch (error) {\n\t\tdecodata = item;\n\t\tgetLogger().warn('Failed to parse JSON, returning original data:', error, item);\n\t}\n\tif (item.type === 'System.String') {\n\t\ttry {\n\t\t\treturn rhino.DracoCompression.decompressBase64String(decodata);\n\t\t} catch (error) {\n\t\t\tgetLogger().error('Failed to decompress Draco base64 string:', error);\n\t\t}\n\t} else if (\n\t\ttypeof decodata === 'object' &&\n\t\tObject.prototype.hasOwnProperty.call(decodata, 'opennurbs')\n\t) {\n\t\treturn rhino.CommonObject.decode(decodata);\n\t} else if (typeof decodata === 'object') {\n\t\ttry {\n\t\t\treturn rhino.CommonObject.decode(decodata);\n\t\t} catch (error) {\n\t\t\tgetLogger().error('Failed to decode Rhino object:', error);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/selva-compute/selva-compute/dist/chunk-QCHPQ22Y.cjs","../src/core/utils/encoding.ts"],"names":["encodeStringToBase64","str","isBase64","decodeBase64ToBinary","base64File","c","RhinoComputeError","ErrorCodes","base64ByteArray","bytes","encodings","inputBytes","byteLength","byteRemainder","mainLength","base64","a","b","d","chunk","i","byte1","byte2","byte3","innerChunk","charA","charB","charC","charD"],"mappings":"AAAA,qOAAsD,SCQtCA,CAAAA,CAAqBC,CAAAA,CAAqB,CACzD,OAAO,MAAA,CAAO,IAAA,CAAKA,CAAAA,CAAK,OAAO,CAAA,CAAE,QAAA,CAAS,QAAQ,CACnD,CAsBO,SAASC,CAAAA,CAASD,CAAAA,CAAsB,CAC9C,EAAA,CAAI,CAACA,CAAAA,EAAOA,CAAAA,CAAI,IAAA,CAAK,CAAA,CAAE,MAAA,GAAW,CAAA,CAAG,MAAO,CAAA,CAAA,CAC5C,GAAI,CACH,OAAO,MAAA,CAAO,IAAA,CAAKA,CAAAA,CAAK,QAAQ,CAAA,CAAE,QAAA,CAAS,QAAQ,CAAA,GAAMA,CAC1D,CAAA,UAAQ,CACP,MAAO,CAAA,CACR,CACD,CAWO,SAASE,CAAAA,CAAqBC,CAAAA,CAAgC,CACpE,EAAA,CAAI,OAAO,UAAA,CAAW,IAAA,EAAS,UAAA,CAC9B,OAAO,UAAA,CAAW,IAAA,CAAK,UAAA,CAAW,IAAA,CAAKA,CAAU,CAAA,CAAIC,CAAAA,EAAMA,CAAAA,CAAE,UAAA,CAAW,CAAC,CAAC,CAAA,CAE3E,EAAA,CAAI,OAAQ,UAAA,CAAmB,MAAA,EAAW,UAAA,CAEzC,OAAQ,UAAA,CAAmB,MAAA,CAAO,IAAA,CAAKD,CAAAA,CAAY,QAAQ,CAAA,CAK5D,GAAM,CAAE,iBAAA,CAAAE,CAAAA,CAAmB,UAAA,CAAAC,CAAW,CAAA,CAAI,CAAA,iCAAA,CAAA,CAAA,iCAAA,mBAAA,CAAA,CAAA,CAC1C,MAAM,IAAID,CAAAA,CACT,oDAAA,CACAC,CAAAA,CAAW,aAAA,CACX,CAAE,OAAA,CAAS,CAAE,eAAA,CAAiB,8BAA+B,CAAE,CAChE,CACD,CAgBO,SAASC,CAAAA,CAAgBC,CAAAA,CAA8C,CAC7E,EAAA,CAAIA,CAAAA,EAAU,IAAA,CAA6B,CAG1C,GAAM,CAAE,iBAAA,CAAAH,CAAAA,CAAmB,UAAA,CAAAC,CAAW,CAAA,CAAI,CAAA,iCAAA,CAAA,CAAA,iCAAA,mBAAA,CAAA,CAAA,CAC1C,MAAM,IAAID,CAAAA,CACT,2CAAA,CACAC,CAAAA,CAAW,aAAA,CACX,CAAE,OAAA,CAAS,CAAE,aAAA,CAAeE,CAAM,CAAE,CACrC,CACD,CAEA,IAAMC,CAAAA,CAAY,kEAAA,CAEdC,CAAAA,CAAaF,CAAAA,CAIhBE,CAAAA,CAAW,MAAA,EAAU,CAAA,EACrBA,CAAAA,CAAW,CAAC,CAAA,GAAM,GAAA,EAClBA,CAAAA,CAAW,CAAC,CAAA,GAAM,GAAA,EAClBA,CAAAA,CAAW,CAAC,CAAA,GAAM,GAAA,EAAA,CAElBA,CAAAA,CAAaA,CAAAA,CAAW,KAAA,CAAM,CAAC,CAAA,CAAA,CAGhC,IAAMC,CAAAA,CAAaD,CAAAA,CAAW,UAAA,CACxBE,CAAAA,CAAgBD,CAAAA,CAAa,CAAA,CAC7BE,CAAAA,CAAaF,CAAAA,CAAaC,CAAAA,CAE5BE,CAAAA,CAAS,EAAA,CACTC,CAAAA,CAAGC,CAAAA,CAAG,CAAA,CAAGC,CAAAA,CACTC,CAAAA,CAGJ,GAAA,CAAA,IAASC,CAAAA,CAAI,CAAA,CAAGA,CAAAA,CAAIN,CAAAA,CAAYM,CAAAA,EAAK,CAAA,CAAG,CAGvC,IAAMC,CAAAA,CAAQV,CAAAA,CAAWS,CAAC,CAAA,GAAM,KAAA,CAAA,CAAYT,CAAAA,CAAWS,CAAC,CAAA,CAAI,CAAA,CACtDE,CAAAA,CAAQX,CAAAA,CAAWS,CAAAA,CAAI,CAAC,CAAA,GAAM,KAAA,CAAA,CAAYT,CAAAA,CAAWS,CAAAA,CAAI,CAAC,CAAA,CAAI,CAAA,CAC9DG,CAAAA,CAAQZ,CAAAA,CAAWS,CAAAA,CAAI,CAAC,CAAA,GAAM,KAAA,CAAA,CAAYT,CAAAA,CAAWS,CAAAA,CAAI,CAAC,CAAA,CAAI,CAAA,CAE9DI,CAAAA,CAAcH,CAAAA,EAAS,EAAA,CAAOC,CAAAA,EAAS,CAAA,CAAKC,CAAAA,CASlD,EAAA,CANAP,CAAAA,CAAAA,CAAKQ,CAAAA,CAAa,QAAA,CAAA,EAAa,EAAA,CAC/BP,CAAAA,CAAAA,CAAKO,CAAAA,CAAa,MAAA,CAAA,EAAW,EAAA,CAC7B,CAAA,CAAA,CAAKA,CAAAA,CAAa,IAAA,CAAA,EAAS,CAAA,CAC3BN,CAAAA,CAAIM,CAAAA,CAAa,EAAA,CAGb,OAAOd,CAAAA,EAAc,QAAA,CACxB,MAAM,IAAI,KAAA,CAAM,4BAA4B,CAAA,CAG7C,EAAA,CAAI,OAAOM,CAAAA,EAAM,QAAA,EAAYA,CAAAA,CAAI,CAAA,EAAKA,CAAAA,EAAKN,CAAAA,CAAU,MAAA,CACpD,MAAM,IAAI,KAAA,CAAM,iBAAiB,CAAA,CAGlC,EAAA,CAAI,OAAOO,CAAAA,EAAM,QAAA,EAAYA,CAAAA,CAAI,CAAA,EAAKA,CAAAA,EAAKP,CAAAA,CAAU,MAAA,CACpD,MAAM,IAAI,KAAA,CAAM,iBAAiB,CAAA,CAGlC,EAAA,CAAI,OAAO,CAAA,EAAM,QAAA,EAAY,CAAA,CAAI,CAAA,EAAK,CAAA,EAAKA,CAAAA,CAAU,MAAA,CACpD,MAAM,IAAI,KAAA,CAAM,iBAAiB,CAAA,CAGlC,EAAA,CAAI,OAAOQ,CAAAA,EAAM,QAAA,EAAYA,CAAAA,CAAI,CAAA,EAAKA,CAAAA,EAAKR,CAAAA,CAAU,MAAA,CACpD,MAAM,IAAI,KAAA,CAAM,iBAAiB,CAAA,CAGlC,IAAMe,CAAAA,CAAQf,CAAAA,CAAUM,CAAC,CAAA,CACnBU,CAAAA,CAAQhB,CAAAA,CAAUO,CAAC,CAAA,CACnBU,CAAAA,CAAQjB,CAAAA,CAAU,CAAC,CAAA,CACnBkB,CAAAA,CAAQlB,CAAAA,CAAUQ,CAAC,CAAA,CAEzB,EAAA,CAAIO,CAAAA,GAAU,KAAA,CAAA,EAAaC,CAAAA,GAAU,KAAA,CAAA,EAAaC,CAAAA,GAAU,KAAA,CAAA,EAAaC,CAAAA,GAAU,KAAA,CAAA,CAClF,MAAM,IAAI,KAAA,CAAM,wBAAwB,CAAA,CAGzCb,CAAAA,EAAUU,CAAAA,CAAQC,CAAAA,CAAQC,CAAAA,CAAQC,CACnC,CAGA,EAAA,CAAIf,CAAAA,GAAkB,CAAA,CAAG,CAGxB,EAAA,CAFAM,CAAAA,CAAQR,CAAAA,CAAWG,CAAU,CAAA,CAEzBK,CAAAA,GAAU,KAAA,CAAA,CACb,MAAM,IAAI,KAAA,CAAM,+BAA+B,CAAA,CAGhDH,CAAAA,CAAAA,CAAKG,CAAAA,CAAQ,GAAA,CAAA,EAAQ,CAAA,CACrBF,CAAAA,CAAAA,CAAKE,CAAAA,CAAQ,CAAA,CAAA,EAAM,CAAA,CAEnB,IAAMM,CAAAA,CAAQf,CAAAA,CAAUM,CAAC,CAAA,CACnBU,CAAAA,CAAQhB,CAAAA,CAAUO,CAAC,CAAA,CAEzB,EAAA,CAAIQ,CAAAA,GAAU,KAAA,CAAA,EAAaC,CAAAA,GAAU,KAAA,CAAA,CACpC,MAAM,IAAI,KAAA,CAAM,wBAAwB,CAAA,CAGzCX,CAAAA,EAAU,CAAA,EAAA","file":"/home/runner/work/selva-compute/selva-compute/dist/chunk-QCHPQ22Y.cjs","sourcesContent":[null,"/**\n * Encodes a string to base64 (Node 20+ safe)\n *\n * @internal Internal encoding helper — kept internal to `selva-compute`.\n *\n * @param str - String to encode\n * @returns Base64 encoded string\n */\nexport function encodeStringToBase64(str: string): string {\n\treturn Buffer.from(str, 'utf-8').toString('base64');\n}\n\n/**\n * Decodes a base64 string to a UTF-8 string (Node 20+ safe)\n *\n * @internal Internal encoding helper — kept internal to `selva-compute`.\n *\n * @param base64Str - Base64 encoded string\n * @returns Decoded UTF-8 string\n */\nexport function decodeBase64ToString(base64Str: string): string {\n\treturn Buffer.from(base64Str, 'base64').toString('utf-8');\n}\n\n/**\n * Checks if a string is valid base64\n *\n * @internal Internal encoding helper — kept internal to `selva-compute`.\n *\n * @param str - String to check\n * @returns True if the string is valid base64\n */\nexport function isBase64(str: string): boolean {\n\tif (!str || str.trim().length === 0) return false;\n\ttry {\n\t\treturn Buffer.from(str, 'base64').toString('base64') === str;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Decodes a base64 string to binary data (Uint8Array)\n *\n * @internal Internal encoding helper — kept internal to `selva-compute`.\n *\n * @param base64File - Base64 encoded string\n * @returns Decoded binary data as Uint8Array\n * @throws {RhinoComputeError} If base64 decoding is not supported in this environment.\n */\nexport function decodeBase64ToBinary(base64File: string): Uint8Array {\n\tif (typeof globalThis.atob === 'function') {\n\t\treturn Uint8Array.from(globalThis.atob(base64File), (c) => c.charCodeAt(0));\n\t}\n\tif (typeof (globalThis as any).Buffer === 'function') {\n\t\t// Buffer.from returns a Uint8Array-compatible Buffer\n\t\treturn (globalThis as any).Buffer.from(base64File, 'base64');\n\t}\n\n\t// Import here to avoid circular dependencies at top level\n\t// eslint-disable-next-line @typescript-eslint/no-require-imports\n\tconst { RhinoComputeError, ErrorCodes } = require('./../../core/errors');\n\tthrow new RhinoComputeError(\n\t\t'Base64 decoding not supported in this environment.',\n\t\tErrorCodes.INVALID_STATE,\n\t\t{ context: { environmentInfo: 'atob or Buffer not available' } }\n\t);\n}\n\n/**\n * Encodes binary data (Uint8Array) to base64 string\n *\n * @internal Internal encoding helper — kept internal to `selva-compute`.\n *\n * Source: https://github.com/mcneel/compute.rhino3d.appserver/blob/92c95a3b1d076a4d4a5360214ffd27c46425ff03/src/examples/convert/scriptjs\n * https://gist.github.com/jonleighton/958841\n *\n * MIT LICENSE\n * Copyright 2011 Jon Leighton\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\nexport function base64ByteArray(bytes: Uint8Array | null | undefined): string {\n\tif (bytes === null || bytes === undefined) {\n\t\t// Import here to avoid circular dependencies at top level\n\t\t// eslint-disable-next-line @typescript-eslint/no-require-imports\n\t\tconst { RhinoComputeError, ErrorCodes } = require('./../../core/errors');\n\t\tthrow new RhinoComputeError(\n\t\t\t'Input bytes must not be null or undefined',\n\t\t\tErrorCodes.INVALID_INPUT,\n\t\t\t{ context: { receivedValue: bytes } }\n\t\t);\n\t}\n\n\tconst encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n\n\tlet inputBytes = bytes;\n\n\t// strip bom (Byte Order Mark)\n\tif (\n\t\tinputBytes.length >= 3 &&\n\t\tinputBytes[0] === 239 &&\n\t\tinputBytes[1] === 187 &&\n\t\tinputBytes[2] === 191\n\t) {\n\t\tinputBytes = inputBytes.slice(3);\n\t}\n\n\tconst byteLength = inputBytes.byteLength;\n\tconst byteRemainder = byteLength % 3;\n\tconst mainLength = byteLength - byteRemainder;\n\n\tlet base64 = '';\n\tlet a, b, c, d;\n\tlet chunk;\n\n\t// Main loop deals with bytes in chunks of 3\n\tfor (let i = 0; i < mainLength; i += 3) {\n\t\t// Combine the three bytes into a single integer\n\n\t\tconst byte1 = inputBytes[i] !== undefined ? inputBytes[i] : 0;\n\t\tconst byte2 = inputBytes[i + 1] !== undefined ? inputBytes[i + 1] : 0;\n\t\tconst byte3 = inputBytes[i + 2] !== undefined ? inputBytes[i + 2] : 0;\n\n\t\tconst innerChunk = (byte1 << 16) | (byte2 << 8) | byte3;\n\n\t\t// Use bitmasks to extract 6-bit segments from the triplet\n\t\ta = (innerChunk & 16515072) >> 18;\n\t\tb = (innerChunk & 258048) >> 12;\n\t\tc = (innerChunk & 4032) >> 6;\n\t\td = innerChunk & 63;\n\n\t\t// Convert the raw binary segments to the appropriate ASCII encoding\n\t\tif (typeof encodings !== 'string') {\n\t\t\tthrow new Error('encodings must be a string');\n\t\t}\n\n\t\tif (typeof a !== 'number' || a < 0 || a >= encodings.length) {\n\t\t\tthrow new Error('Invalid index a');\n\t\t}\n\n\t\tif (typeof b !== 'number' || b < 0 || b >= encodings.length) {\n\t\t\tthrow new Error('Invalid index b');\n\t\t}\n\n\t\tif (typeof c !== 'number' || c < 0 || c >= encodings.length) {\n\t\t\tthrow new Error('Invalid index c');\n\t\t}\n\n\t\tif (typeof d !== 'number' || d < 0 || d >= encodings.length) {\n\t\t\tthrow new Error('Invalid index d');\n\t\t}\n\n\t\tconst charA = encodings[a];\n\t\tconst charB = encodings[b];\n\t\tconst charC = encodings[c];\n\t\tconst charD = encodings[d];\n\n\t\tif (charA === undefined || charB === undefined || charC === undefined || charD === undefined) {\n\t\t\tthrow new Error('Invalid encoding index');\n\t\t}\n\n\t\tbase64 += charA + charB + charC + charD;\n\t}\n\n\t// Deal with the remaining bytes and padding\n\tif (byteRemainder === 1) {\n\t\tchunk = inputBytes[mainLength];\n\n\t\tif (chunk === undefined) {\n\t\t\tthrow new Error(\"'chunk' must not be undefined\");\n\t\t}\n\n\t\ta = (chunk & 252) >> 2;\n\t\tb = (chunk & 3) << 4;\n\n\t\tconst charA = encodings[a];\n\t\tconst charB = encodings[b];\n\n\t\tif (charA === undefined || charB === undefined) {\n\t\t\tthrow new Error('Invalid encoding index');\n\t\t}\n\n\t\tbase64 += `${charA + charB}==`;\n\t} else if (byteRemainder === 2) {\n\t\tconst byte1 = inputBytes[mainLength] ?? 0;\n\t\tconst byte2 = inputBytes[mainLength + 1] !== undefined ? inputBytes[mainLength + 1] : 0;\n\n\t\tif (\n\t\t\ttypeof byte1 !== 'number' ||\n\t\t\tbyte1 < 0 ||\n\t\t\tbyte1 > 255 ||\n\t\t\ttypeof byte2 !== 'number' ||\n\t\t\tbyte2 < 0 ||\n\t\t\tbyte2 > 255\n\t\t) {\n\t\t\tthrow new Error('Invalid byte1');\n\t\t}\n\n\t\tchunk = (byte1 << 8) | byte2;\n\n\t\ta = (chunk & 64512) >> 10;\n\t\tb = (chunk & 1008) >> 4;\n\t\tc = (chunk & 15) << 2;\n\n\t\tconst charA = encodings[a];\n\t\tconst charB = encodings[b];\n\t\tconst charC = encodings[c];\n\n\t\tif (charA === undefined || charB === undefined || charC === undefined) {\n\t\t\tthrow new Error('Invalid encoding index');\n\t\t}\n\n\t\tbase64 += `${charA + charB + charC}=`;\n\t}\n\n\treturn base64;\n}\n\n/**\n * Convert base64 string to rhino object\n *\n * @internal Internal helper for decoding Rhino objects — not public API.\n *\n * Source: https://github.com/mcneel/compute.rhino3d.appserver/blob/92c95a3b1d076a4d4a5360214ffd27c46425ff03/src/examples/convert/scriptjs\n * @param rhino is the rhino module form rhino3dm. Since not properly typed its not used here.\n * @param item\n * @returns\n */\nexport function base64ToRhinoObject(\n\trhino: any,\n\titem: {\n\t\ttype: string;\n\t\tdata: string;\n\t}\n) {\n\t// Import here to avoid circular dependencies at top level\n\t// eslint-disable-next-line @typescript-eslint/no-require-imports\n\tconst { getLogger } = require('./logger');\n\n\t//Make a type definition for this?\n\tlet decodata: null | object = null;\n\ttry {\n\t\tdecodata = JSON.parse(item.data);\n\t} catch (error) {\n\t\tdecodata = item;\n\t\tgetLogger().warn('Failed to parse JSON, returning original data:', error, item);\n\t}\n\tif (item.type === 'System.String') {\n\t\ttry {\n\t\t\treturn rhino.DracoCompression.decompressBase64String(decodata);\n\t\t} catch (error) {\n\t\t\tgetLogger().error('Failed to decompress Draco base64 string:', error);\n\t\t}\n\t} else if (\n\t\ttypeof decodata === 'object' &&\n\t\tObject.prototype.hasOwnProperty.call(decodata, 'opennurbs')\n\t) {\n\t\treturn rhino.CommonObject.decode(decodata);\n\t} else if (typeof decodata === 'object') {\n\t\ttry {\n\t\t\treturn rhino.CommonObject.decode(decodata);\n\t\t} catch (error) {\n\t\t\tgetLogger().error('Failed to decode Rhino object:', error);\n\t\t}\n\t}\n}\n"]}
@@ -1,2 +1,2 @@
1
- import{b as x,h as E,i as I}from"./chunk-VGM4KAFN.js";function v(t){return Buffer.from(t,"utf-8").toString("base64")}function A(t){if(!t||t.trim().length===0)return!1;try{return Buffer.from(t,"base64").toString("base64")===t}catch{return!1}}function C(t){if(typeof globalThis.atob=="function")return Uint8Array.from(globalThis.atob(t),l=>l.charCodeAt(0));if(typeof globalThis.Buffer=="function")return globalThis.Buffer.from(t,"base64");let{RhinoComputeError:r,ErrorCodes:e}=(I(),x(E));throw new r("Base64 decoding not supported in this environment.",e.INVALID_STATE,{context:{environmentInfo:"atob or Buffer not available"}})}function S(t){if(t==null){let{RhinoComputeError:n,ErrorCodes:o}=(I(),x(E));throw new n("Input bytes must not be null or undefined",o.INVALID_INPUT,{context:{receivedValue:t}})}let r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=t;e.length>=3&&e[0]===239&&e[1]===187&&e[2]===191&&(e=e.slice(3));let l=e.byteLength,y=l%3,s=l-y,h="",i,d,c,u,a;for(let n=0;n<s;n+=3){let o=e[n]!==void 0?e[n]:0,b=e[n+1]!==void 0?e[n+1]:0,g=e[n+2]!==void 0?e[n+2]:0,f=o<<16|b<<8|g;if(i=(f&16515072)>>18,d=(f&258048)>>12,c=(f&4032)>>6,u=f&63,typeof r!="string")throw new Error("encodings must be a string");if(typeof i!="number"||i<0||i>=r.length)throw new Error("Invalid index a");if(typeof d!="number"||d<0||d>=r.length)throw new Error("Invalid index b");if(typeof c!="number"||c<0||c>=r.length)throw new Error("Invalid index c");if(typeof u!="number"||u<0||u>=r.length)throw new Error("Invalid index d");let p=r[i],m=r[d],w=r[c],B=r[u];if(p===void 0||m===void 0||w===void 0||B===void 0)throw new Error("Invalid encoding index");h+=p+m+w+B}if(y===1){if(a=e[s],a===void 0)throw new Error("'chunk' must not be undefined");i=(a&252)>>2,d=(a&3)<<4;let n=r[i],o=r[d];if(n===void 0||o===void 0)throw new Error("Invalid encoding index");h+=`${n+o}==`}else if(y===2){let n=e[s]??0,o=e[s+1]!==void 0?e[s+1]:0;if(typeof n!="number"||n<0||n>255||typeof o!="number"||o<0||o>255)throw new Error("Invalid byte1");a=n<<8|o,i=(a&64512)>>10,d=(a&1008)>>4,c=(a&15)<<2;let b=r[i],g=r[d],f=r[c];if(b===void 0||g===void 0||f===void 0)throw new Error("Invalid encoding index");h+=`${b+g+f}=`}return h}export{v as a,A as b,C as c,S as d};
2
- //# sourceMappingURL=chunk-QFHFH5BS.js.map
1
+ import{b as x,g as E,h as I}from"./chunk-MK3M76VN.js";function v(t){return Buffer.from(t,"utf-8").toString("base64")}function A(t){if(!t||t.trim().length===0)return!1;try{return Buffer.from(t,"base64").toString("base64")===t}catch{return!1}}function C(t){if(typeof globalThis.atob=="function")return Uint8Array.from(globalThis.atob(t),l=>l.charCodeAt(0));if(typeof globalThis.Buffer=="function")return globalThis.Buffer.from(t,"base64");let{RhinoComputeError:r,ErrorCodes:e}=(I(),x(E));throw new r("Base64 decoding not supported in this environment.",e.INVALID_STATE,{context:{environmentInfo:"atob or Buffer not available"}})}function S(t){if(t==null){let{RhinoComputeError:n,ErrorCodes:o}=(I(),x(E));throw new n("Input bytes must not be null or undefined",o.INVALID_INPUT,{context:{receivedValue:t}})}let r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=t;e.length>=3&&e[0]===239&&e[1]===187&&e[2]===191&&(e=e.slice(3));let l=e.byteLength,y=l%3,s=l-y,h="",i,d,c,u,a;for(let n=0;n<s;n+=3){let o=e[n]!==void 0?e[n]:0,b=e[n+1]!==void 0?e[n+1]:0,g=e[n+2]!==void 0?e[n+2]:0,f=o<<16|b<<8|g;if(i=(f&16515072)>>18,d=(f&258048)>>12,c=(f&4032)>>6,u=f&63,typeof r!="string")throw new Error("encodings must be a string");if(typeof i!="number"||i<0||i>=r.length)throw new Error("Invalid index a");if(typeof d!="number"||d<0||d>=r.length)throw new Error("Invalid index b");if(typeof c!="number"||c<0||c>=r.length)throw new Error("Invalid index c");if(typeof u!="number"||u<0||u>=r.length)throw new Error("Invalid index d");let p=r[i],m=r[d],w=r[c],B=r[u];if(p===void 0||m===void 0||w===void 0||B===void 0)throw new Error("Invalid encoding index");h+=p+m+w+B}if(y===1){if(a=e[s],a===void 0)throw new Error("'chunk' must not be undefined");i=(a&252)>>2,d=(a&3)<<4;let n=r[i],o=r[d];if(n===void 0||o===void 0)throw new Error("Invalid encoding index");h+=`${n+o}==`}else if(y===2){let n=e[s]??0,o=e[s+1]!==void 0?e[s+1]:0;if(typeof n!="number"||n<0||n>255||typeof o!="number"||o<0||o>255)throw new Error("Invalid byte1");a=n<<8|o,i=(a&64512)>>10,d=(a&1008)>>4,c=(a&15)<<2;let b=r[i],g=r[d],f=r[c];if(b===void 0||g===void 0||f===void 0)throw new Error("Invalid encoding index");h+=`${b+g+f}=`}return h}export{v as a,A as b,C as c,S as d};
2
+ //# sourceMappingURL=chunk-WD3ENUAA.js.map
package/dist/core.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkFNWG34KHcjs = require('./chunk-FNWG34KH.cjs');exports.ComputeServerStats = _chunkFNWG34KHcjs.o; exports.ErrorCodes = _chunkFNWG34KHcjs.f; exports.RhinoComputeError = _chunkFNWG34KHcjs.d; exports.enableDebugLogging = _chunkFNWG34KHcjs.l; exports.fetchRhinoCompute = _chunkFNWG34KHcjs.n; exports.getLogger = _chunkFNWG34KHcjs.j; exports.setLogger = _chunkFNWG34KHcjs.k;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkPE2FMBXDcjs = require('./chunk-PE2FMBXD.cjs');exports.ComputeServerStats = _chunkPE2FMBXDcjs.n; exports.ErrorCodes = _chunkPE2FMBXDcjs.d; exports.RhinoComputeError = _chunkPE2FMBXDcjs.e; exports.enableDebugLogging = _chunkPE2FMBXDcjs.k; exports.fetchRhinoCompute = _chunkPE2FMBXDcjs.m; exports.getLogger = _chunkPE2FMBXDcjs.i; exports.setLogger = _chunkPE2FMBXDcjs.j;
2
2
  //# sourceMappingURL=core.cjs.map
package/dist/core.d.cts CHANGED
@@ -1,9 +1,9 @@
1
- import { C as ComputeConfig, d as GrasshopperComputeConfig, c as GrasshopperComputeResponse, g as IoResponseSchema } from './schemas-CQEJ5EZy.cjs';
2
- export { R as RhinoModelUnit } from './schemas-CQEJ5EZy.cjs';
3
- export { C as ComputeServerStats, R as RhinoComputeError } from './base-DbB0Ggdq.cjs';
1
+ import { C as ComputeConfig, d as GrasshopperComputeConfig, c as GrasshopperComputeResponse, g as IoResponseSchema } from './schemas-BE5ai7jG.cjs';
2
+ export { R as RhinoModelUnit } from './schemas-BE5ai7jG.cjs';
3
+ export { C as ComputeServerStats, R as RhinoComputeError } from './base-dtik4Dlu.cjs';
4
4
 
5
5
  /**
6
- * Valid endpoints for Rhino Compute
6
+ * Valid endpoints for Rhino Compute (improved response type handling).
7
7
  */
8
8
  type Endpoint = 'grasshopper' | 'io' | string;
9
9
  type EndpointResponseMap = {
@@ -15,24 +15,24 @@ type ComputeResponseFor<E extends string> = E extends keyof EndpointResponseMap
15
15
  * Generic Rhino Compute fetch function.
16
16
  * Sends a POST request to any Compute endpoint with pre-prepared arguments.
17
17
  *
18
- * @public Use this for advanced low-level control over compute requests. For most use cases, prefer higher-level APIs.
18
+ * Use this for advanced, low-level control over compute requests. For most use cases, prefer higher-level APIs.
19
19
  *
20
+ * @typeParam E - The endpoint name (e.g., 'grasshopper', 'io'). Determines the response type for better type safety.
20
21
  * @param endpoint - The Compute API endpoint (e.g., 'grasshopper', 'io', 'mesh').
21
- * @param args - Pre-prepared arguments for the request.
22
+ * @param args - Pre-prepared arguments for the request body.
22
23
  * @param config - Compute configuration (server URL, API key, timeout, debug).
23
- * @returns The parsed JSON response from the server.
24
+ * @returns The parsed JSON response from the server, typed according to the endpoint.
24
25
  *
25
26
  * @example
26
- * ```typescript
27
+ * // Basic usage for the Grasshopper endpoint:
27
28
  * const response = await fetchRhinoCompute(
28
29
  * 'grasshopper',
29
30
  * {
30
31
  * pointer: { url: 'https://example.com/definition.gh' },
31
32
  * values: [{ ParamName: 'x', InnerTree: { '0': [{ type: 'System.Double', data: 10 }] } }]
32
33
  * },
33
- * { serverUrl: 'https://compute.rhino3d.com', debug: true, timeoutMs: 30000 }
34
+ * { serverUrl: 'https://my-server.com', debug: true, timeoutMs: 30000 }
34
35
  * );
35
- * ```
36
36
  */
37
37
  declare function fetchRhinoCompute<E extends Endpoint>(endpoint: E, args: Record<string, any>, config: ComputeConfig | GrasshopperComputeConfig): Promise<ComputeResponseFor<E>>;
38
38
 
package/dist/core.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { C as ComputeConfig, d as GrasshopperComputeConfig, c as GrasshopperComputeResponse, g as IoResponseSchema } from './schemas-CQEJ5EZy.js';
2
- export { R as RhinoModelUnit } from './schemas-CQEJ5EZy.js';
3
- export { C as ComputeServerStats, R as RhinoComputeError } from './base-DbB0Ggdq.js';
1
+ import { C as ComputeConfig, d as GrasshopperComputeConfig, c as GrasshopperComputeResponse, g as IoResponseSchema } from './schemas-BE5ai7jG.js';
2
+ export { R as RhinoModelUnit } from './schemas-BE5ai7jG.js';
3
+ export { C as ComputeServerStats, R as RhinoComputeError } from './base-dtik4Dlu.js';
4
4
 
5
5
  /**
6
- * Valid endpoints for Rhino Compute
6
+ * Valid endpoints for Rhino Compute (improved response type handling).
7
7
  */
8
8
  type Endpoint = 'grasshopper' | 'io' | string;
9
9
  type EndpointResponseMap = {
@@ -15,24 +15,24 @@ type ComputeResponseFor<E extends string> = E extends keyof EndpointResponseMap
15
15
  * Generic Rhino Compute fetch function.
16
16
  * Sends a POST request to any Compute endpoint with pre-prepared arguments.
17
17
  *
18
- * @public Use this for advanced low-level control over compute requests. For most use cases, prefer higher-level APIs.
18
+ * Use this for advanced, low-level control over compute requests. For most use cases, prefer higher-level APIs.
19
19
  *
20
+ * @typeParam E - The endpoint name (e.g., 'grasshopper', 'io'). Determines the response type for better type safety.
20
21
  * @param endpoint - The Compute API endpoint (e.g., 'grasshopper', 'io', 'mesh').
21
- * @param args - Pre-prepared arguments for the request.
22
+ * @param args - Pre-prepared arguments for the request body.
22
23
  * @param config - Compute configuration (server URL, API key, timeout, debug).
23
- * @returns The parsed JSON response from the server.
24
+ * @returns The parsed JSON response from the server, typed according to the endpoint.
24
25
  *
25
26
  * @example
26
- * ```typescript
27
+ * // Basic usage for the Grasshopper endpoint:
27
28
  * const response = await fetchRhinoCompute(
28
29
  * 'grasshopper',
29
30
  * {
30
31
  * pointer: { url: 'https://example.com/definition.gh' },
31
32
  * values: [{ ParamName: 'x', InnerTree: { '0': [{ type: 'System.Double', data: 10 }] } }]
32
33
  * },
33
- * { serverUrl: 'https://compute.rhino3d.com', debug: true, timeoutMs: 30000 }
34
+ * { serverUrl: 'https://my-server.com', debug: true, timeoutMs: 30000 }
34
35
  * );
35
- * ```
36
36
  */
37
37
  declare function fetchRhinoCompute<E extends Endpoint>(endpoint: E, args: Record<string, any>, config: ComputeConfig | GrasshopperComputeConfig): Promise<ComputeResponseFor<E>>;
38
38
 
package/dist/core.js CHANGED
@@ -1,2 +1,2 @@
1
- import{d as a,f as b,j as c,k as d,l as e,n as f,o as g}from"./chunk-VGM4KAFN.js";export{g as ComputeServerStats,b as ErrorCodes,a as RhinoComputeError,e as enableDebugLogging,f as fetchRhinoCompute,c as getLogger,d as setLogger};
1
+ import{d as a,e as b,i as c,j as d,k as e,m as f,n as g}from"./chunk-MK3M76VN.js";export{g as ComputeServerStats,a as ErrorCodes,b as RhinoComputeError,e as enableDebugLogging,f as fetchRhinoCompute,c as getLogger,d as setLogger};
2
2
  //# sourceMappingURL=core.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkNQYH7IAScjs = require('./chunk-NQYH7IAS.cjs');require('./chunk-M2HPEWXH.cjs');var _chunkFNWG34KHcjs = require('./chunk-FNWG34KH.cjs');exports.GrasshopperClient = _chunkNQYH7IAScjs.a; exports.GrasshopperResponseProcessor = _chunkNQYH7IAScjs.d; exports.RhinoComputeError = _chunkFNWG34KHcjs.d; exports.TreeBuilder = _chunkNQYH7IAScjs.j; exports.downloadFileData = _chunkNQYH7IAScjs.c; exports.extractFilesFromComputeResponse = _chunkNQYH7IAScjs.b; exports.fetchDefinitionIO = _chunkNQYH7IAScjs.h; exports.fetchParsedDefinitionIO = _chunkNQYH7IAScjs.i; exports.processInput = _chunkNQYH7IAScjs.f; exports.processInputs = _chunkNQYH7IAScjs.g; exports.solveGrasshopperDefinition = _chunkNQYH7IAScjs.e;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkF7DPIDIAcjs = require('./chunk-F7DPIDIA.cjs');require('./chunk-QCHPQ22Y.cjs');var _chunkPE2FMBXDcjs = require('./chunk-PE2FMBXD.cjs');exports.GrasshopperClient = _chunkF7DPIDIAcjs.a; exports.GrasshopperResponseProcessor = _chunkF7DPIDIAcjs.d; exports.RhinoComputeError = _chunkPE2FMBXDcjs.e; exports.TreeBuilder = _chunkF7DPIDIAcjs.j; exports.downloadFileData = _chunkF7DPIDIAcjs.c; exports.extractFilesFromComputeResponse = _chunkF7DPIDIAcjs.b; exports.fetchDefinitionIO = _chunkF7DPIDIAcjs.h; exports.fetchParsedDefinitionIO = _chunkF7DPIDIAcjs.i; exports.processInput = _chunkF7DPIDIAcjs.f; exports.processInputs = _chunkF7DPIDIAcjs.g; exports.solveGrasshopperDefinition = _chunkF7DPIDIAcjs.e;
2
2
  //# sourceMappingURL=grasshopper.cjs.map
@@ -1,7 +1,7 @@
1
- import { C as ComputeServerStats } from './base-DbB0Ggdq.cjs';
2
- export { R as RhinoComputeError } from './base-DbB0Ggdq.cjs';
3
- import { e as DataTreeDefault, O as OutputParamSchema, I as InputParamSchema, d as GrasshopperComputeConfig, b as DataTree, c as GrasshopperComputeResponse, C as ComputeConfig, D as DataTreePath } from './schemas-CQEJ5EZy.cjs';
4
- export { a as DataItem, G as GrasshopperRequestSchema, f as InnerTreeData, R as RhinoModelUnit } from './schemas-CQEJ5EZy.cjs';
1
+ import { C as ComputeServerStats } from './base-dtik4Dlu.cjs';
2
+ export { R as RhinoComputeError } from './base-dtik4Dlu.cjs';
3
+ import { e as DataTreeDefault, O as OutputParamSchema, I as InputParamSchema, d as GrasshopperComputeConfig, b as DataTree, c as GrasshopperComputeResponse, C as ComputeConfig, D as DataTreePath } from './schemas-BE5ai7jG.cjs';
4
+ export { a as DataItem, G as GrasshopperRequestSchema, f as InnerTreeData, R as RhinoModelUnit } from './schemas-BE5ai7jG.cjs';
5
5
  import * as THREE from 'three';
6
6
  import { M as MeshExtractionOptions } from './types-r00wVwfo.cjs';
7
7
 
@@ -276,6 +276,8 @@ declare class GrasshopperResponseProcessor {
276
276
  * @param options - Controls parsing behavior such as Rhino geometry decoding.
277
277
  * @returns Parsed Grasshopper output values.
278
278
  *
279
+ * **Note:** Using `byId` only works with the custom VektorNode rhino.compute branch.
280
+ *
279
281
  * @example
280
282
  * ```ts
281
283
  * const processor = new GrasshopperResponseProcessor(response);
@@ -323,8 +325,7 @@ declare class GrasshopperResponseProcessor {
323
325
  * All processing options (scaling, positioning, compression, etc.) can be customized.
324
326
  * The processor's debug flag is merged with options - explicit options take precedence.
325
327
  *
326
- * **Note:** This method dynamically imports three.js visualization modules. Ensure
327
- * three.js is installed as a peer dependency if you use this feature.
328
+ * **Note:** This only works when using the **Selva Display** component in Grasshopper, and requires the custom branch of rhino.compute from VektorNode. This method dynamically imports three.js visualization modules. Ensure three.js is installed as a peer dependency if you use this feature.
328
329
  *
329
330
  * @param options - Configuration for mesh extraction and parsing. Overrides processor's debug flag if provided.
330
331
  * @returns Promise resolving to an array of Three.js mesh objects.
@@ -356,6 +357,8 @@ declare class GrasshopperResponseProcessor {
356
357
  * This includes Grasshopper-generated textures, JSON exports,
357
358
  * CAD formats, or any file structure packaged in the response.
358
359
  *
360
+ * **Note:** This only works when using the **Block to File** and **Geometry To File** components from the Selva plugin in Grasshopper, and requires the custom branch of rhino.compute from VektorNode.
361
+ *
359
362
  * @returns Raw file data entries.
360
363
  */
361
364
  private getFileData;
@@ -1,7 +1,7 @@
1
- import { C as ComputeServerStats } from './base-DbB0Ggdq.js';
2
- export { R as RhinoComputeError } from './base-DbB0Ggdq.js';
3
- import { e as DataTreeDefault, O as OutputParamSchema, I as InputParamSchema, d as GrasshopperComputeConfig, b as DataTree, c as GrasshopperComputeResponse, C as ComputeConfig, D as DataTreePath } from './schemas-CQEJ5EZy.js';
4
- export { a as DataItem, G as GrasshopperRequestSchema, f as InnerTreeData, R as RhinoModelUnit } from './schemas-CQEJ5EZy.js';
1
+ import { C as ComputeServerStats } from './base-dtik4Dlu.js';
2
+ export { R as RhinoComputeError } from './base-dtik4Dlu.js';
3
+ import { e as DataTreeDefault, O as OutputParamSchema, I as InputParamSchema, d as GrasshopperComputeConfig, b as DataTree, c as GrasshopperComputeResponse, C as ComputeConfig, D as DataTreePath } from './schemas-BE5ai7jG.js';
4
+ export { a as DataItem, G as GrasshopperRequestSchema, f as InnerTreeData, R as RhinoModelUnit } from './schemas-BE5ai7jG.js';
5
5
  import * as THREE from 'three';
6
6
  import { M as MeshExtractionOptions } from './types-r00wVwfo.js';
7
7
 
@@ -276,6 +276,8 @@ declare class GrasshopperResponseProcessor {
276
276
  * @param options - Controls parsing behavior such as Rhino geometry decoding.
277
277
  * @returns Parsed Grasshopper output values.
278
278
  *
279
+ * **Note:** Using `byId` only works with the custom VektorNode rhino.compute branch.
280
+ *
279
281
  * @example
280
282
  * ```ts
281
283
  * const processor = new GrasshopperResponseProcessor(response);
@@ -323,8 +325,7 @@ declare class GrasshopperResponseProcessor {
323
325
  * All processing options (scaling, positioning, compression, etc.) can be customized.
324
326
  * The processor's debug flag is merged with options - explicit options take precedence.
325
327
  *
326
- * **Note:** This method dynamically imports three.js visualization modules. Ensure
327
- * three.js is installed as a peer dependency if you use this feature.
328
+ * **Note:** This only works when using the **Selva Display** component in Grasshopper, and requires the custom branch of rhino.compute from VektorNode. This method dynamically imports three.js visualization modules. Ensure three.js is installed as a peer dependency if you use this feature.
328
329
  *
329
330
  * @param options - Configuration for mesh extraction and parsing. Overrides processor's debug flag if provided.
330
331
  * @returns Promise resolving to an array of Three.js mesh objects.
@@ -356,6 +357,8 @@ declare class GrasshopperResponseProcessor {
356
357
  * This includes Grasshopper-generated textures, JSON exports,
357
358
  * CAD formats, or any file structure packaged in the response.
358
359
  *
360
+ * **Note:** This only works when using the **Block to File** and **Geometry To File** components from the Selva plugin in Grasshopper, and requires the custom branch of rhino.compute from VektorNode.
361
+ *
359
362
  * @returns Raw file data entries.
360
363
  */
361
364
  private getFileData;
@@ -1,2 +1,2 @@
1
- import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k}from"./chunk-MUIYGZQS.js";import"./chunk-QFHFH5BS.js";import{d as a}from"./chunk-VGM4KAFN.js";export{b as GrasshopperClient,e as GrasshopperResponseProcessor,a as RhinoComputeError,k as TreeBuilder,d as downloadFileData,c as extractFilesFromComputeResponse,i as fetchDefinitionIO,j as fetchParsedDefinitionIO,g as processInput,h as processInputs,f as solveGrasshopperDefinition};
1
+ import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k}from"./chunk-FMFP7GIM.js";import"./chunk-WD3ENUAA.js";import{e as a}from"./chunk-MK3M76VN.js";export{b as GrasshopperClient,e as GrasshopperResponseProcessor,a as RhinoComputeError,k as TreeBuilder,d as downloadFileData,c as extractFilesFromComputeResponse,i as fetchDefinitionIO,j as fetchParsedDefinitionIO,g as processInput,h as processInputs,f as solveGrasshopperDefinition};
2
2
  //# sourceMappingURL=grasshopper.js.map
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkNQYH7IAScjs = require('./chunk-NQYH7IAS.cjs');require('./chunk-M2HPEWXH.cjs');var _chunkFNWG34KHcjs = require('./chunk-FNWG34KH.cjs');exports.ComputeServerStats = _chunkFNWG34KHcjs.o; exports.ErrorCodes = _chunkFNWG34KHcjs.f; exports.GrasshopperClient = _chunkNQYH7IAScjs.a; exports.GrasshopperResponseProcessor = _chunkNQYH7IAScjs.d; exports.RhinoComputeError = _chunkFNWG34KHcjs.d; exports.TreeBuilder = _chunkNQYH7IAScjs.j; exports.downloadFileData = _chunkNQYH7IAScjs.c; exports.enableDebugLogging = _chunkFNWG34KHcjs.l; exports.extractFilesFromComputeResponse = _chunkNQYH7IAScjs.b; exports.fetchDefinitionIO = _chunkNQYH7IAScjs.h; exports.fetchParsedDefinitionIO = _chunkNQYH7IAScjs.i; exports.fetchRhinoCompute = _chunkFNWG34KHcjs.n; exports.getLogger = _chunkFNWG34KHcjs.j; exports.processInput = _chunkNQYH7IAScjs.f; exports.processInputs = _chunkNQYH7IAScjs.g; exports.setLogger = _chunkFNWG34KHcjs.k; exports.solveGrasshopperDefinition = _chunkNQYH7IAScjs.e;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkF7DPIDIAcjs = require('./chunk-F7DPIDIA.cjs');require('./chunk-QCHPQ22Y.cjs');var _chunkPE2FMBXDcjs = require('./chunk-PE2FMBXD.cjs');exports.ComputeServerStats = _chunkPE2FMBXDcjs.n; exports.ErrorCodes = _chunkPE2FMBXDcjs.d; exports.GrasshopperClient = _chunkF7DPIDIAcjs.a; exports.GrasshopperResponseProcessor = _chunkF7DPIDIAcjs.d; exports.RhinoComputeError = _chunkPE2FMBXDcjs.e; exports.TreeBuilder = _chunkF7DPIDIAcjs.j; exports.downloadFileData = _chunkF7DPIDIAcjs.c; exports.enableDebugLogging = _chunkPE2FMBXDcjs.k; exports.extractFilesFromComputeResponse = _chunkF7DPIDIAcjs.b; exports.fetchDefinitionIO = _chunkF7DPIDIAcjs.h; exports.fetchParsedDefinitionIO = _chunkF7DPIDIAcjs.i; exports.fetchRhinoCompute = _chunkPE2FMBXDcjs.m; exports.getLogger = _chunkPE2FMBXDcjs.i; exports.processInput = _chunkF7DPIDIAcjs.f; exports.processInputs = _chunkF7DPIDIAcjs.g; exports.setLogger = _chunkPE2FMBXDcjs.j; exports.solveGrasshopperDefinition = _chunkF7DPIDIAcjs.e;
2
2
  //# sourceMappingURL=index.cjs.map
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { ErrorCode, ErrorCodes, Logger, enableDebugLogging, fetchRhinoCompute, getLogger, setLogger } from './core.cjs';
2
- export { C as ComputeServerStats, R as RhinoComputeError } from './base-DbB0Ggdq.cjs';
3
- export { C as ComputeConfig, a as DataItem, b as DataTree, e as DataTreeDefault, D as DataTreePath, d as GrasshopperComputeConfig, c as GrasshopperComputeResponse, G as GrasshopperRequestSchema, f as InnerTreeData, I as InputParamSchema, O as OutputParamSchema, R as RhinoModelUnit } from './schemas-CQEJ5EZy.cjs';
2
+ export { C as ComputeServerStats, R as RhinoComputeError } from './base-dtik4Dlu.cjs';
3
+ export { C as ComputeConfig, a as DataItem, b as DataTree, e as DataTreeDefault, D as DataTreePath, d as GrasshopperComputeConfig, c as GrasshopperComputeResponse, G as GrasshopperRequestSchema, f as InnerTreeData, I as InputParamSchema, O as OutputParamSchema, R as RhinoModelUnit } from './schemas-BE5ai7jG.cjs';
4
4
  export { BooleanInputType, DataTreeValue, DefaultValue, FileBaseInfo, FileData, FileInputType, GeometryInputType, GetValuesOptions, GetValuesResult, GrasshopperClient, GrasshopperParsedIO, GrasshopperParsedIORaw, GrasshopperResponseProcessor, InputParam, NumericInputType, OutputType, ParsedContext, ProcessedFile, TextInputType, TreeBuilder, ValueListInputType, downloadFileData, extractFilesFromComputeResponse, fetchDefinitionIO, fetchParsedDefinitionIO, processInput, processInputs, solveGrasshopperDefinition } from './grasshopper.cjs';
5
5
  import 'three';
6
6
  import './types-r00wVwfo.cjs';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { ErrorCode, ErrorCodes, Logger, enableDebugLogging, fetchRhinoCompute, getLogger, setLogger } from './core.js';
2
- export { C as ComputeServerStats, R as RhinoComputeError } from './base-DbB0Ggdq.js';
3
- export { C as ComputeConfig, a as DataItem, b as DataTree, e as DataTreeDefault, D as DataTreePath, d as GrasshopperComputeConfig, c as GrasshopperComputeResponse, G as GrasshopperRequestSchema, f as InnerTreeData, I as InputParamSchema, O as OutputParamSchema, R as RhinoModelUnit } from './schemas-CQEJ5EZy.js';
2
+ export { C as ComputeServerStats, R as RhinoComputeError } from './base-dtik4Dlu.js';
3
+ export { C as ComputeConfig, a as DataItem, b as DataTree, e as DataTreeDefault, D as DataTreePath, d as GrasshopperComputeConfig, c as GrasshopperComputeResponse, G as GrasshopperRequestSchema, f as InnerTreeData, I as InputParamSchema, O as OutputParamSchema, R as RhinoModelUnit } from './schemas-BE5ai7jG.js';
4
4
  export { BooleanInputType, DataTreeValue, DefaultValue, FileBaseInfo, FileData, FileInputType, GeometryInputType, GetValuesOptions, GetValuesResult, GrasshopperClient, GrasshopperParsedIO, GrasshopperParsedIORaw, GrasshopperResponseProcessor, InputParam, NumericInputType, OutputType, ParsedContext, ProcessedFile, TextInputType, TreeBuilder, ValueListInputType, downloadFileData, extractFilesFromComputeResponse, fetchDefinitionIO, fetchParsedDefinitionIO, processInput, processInputs, solveGrasshopperDefinition } from './grasshopper.js';
5
5
  import 'three';
6
6
  import './types-r00wVwfo.js';
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a as x,b as a,c as b,d as c,e as d,f as g,g as h,h as i,i as j,j as k}from"./chunk-MUIYGZQS.js";import"./chunk-QFHFH5BS.js";import{d as o,f as r,j as e,k as f,l as m,n as p,o as t}from"./chunk-VGM4KAFN.js";export{t as ComputeServerStats,r as ErrorCodes,x as GrasshopperClient,c as GrasshopperResponseProcessor,o as RhinoComputeError,k as TreeBuilder,b as downloadFileData,m as enableDebugLogging,a as extractFilesFromComputeResponse,i as fetchDefinitionIO,j as fetchParsedDefinitionIO,p as fetchRhinoCompute,e as getLogger,g as processInput,h as processInputs,f as setLogger,d as solveGrasshopperDefinition};
1
+ import{a as x,b as a,c as b,d as c,e as d,f as g,g as h,h as i,i as j,j as k}from"./chunk-FMFP7GIM.js";import"./chunk-WD3ENUAA.js";import{d as o,e as r,i as e,j as f,k as m,m as p,n as t}from"./chunk-MK3M76VN.js";export{t as ComputeServerStats,o as ErrorCodes,x as GrasshopperClient,c as GrasshopperResponseProcessor,r as RhinoComputeError,k as TreeBuilder,b as downloadFileData,m as enableDebugLogging,a as extractFilesFromComputeResponse,i as fetchDefinitionIO,j as fetchParsedDefinitionIO,p as fetchRhinoCompute,e as getLogger,g as processInput,h as processInputs,f as setLogger,d as solveGrasshopperDefinition};
2
2
  //# sourceMappingURL=index.js.map
@@ -5,9 +5,9 @@ type RhinoModelUnit = 'None' | 'Microns' | 'Millimeters' | 'Centimeters' | 'Mete
5
5
  interface ComputeConfig {
6
6
  /** The base URL of the Rhino Compute server (e.g., http://localhost:6500) */
7
7
  serverUrl: string;
8
- /** Optional API key for authenticating with the server */
8
+ /** Optional API key for authenticating with the server (RhinoComputeKey) */
9
9
  apiKey?: string;
10
- /** Optional auth token (Bearer token) for authentication */
10
+ /** Optional Bearer token for authentication (e.g., when behind a proxy or API gateway) */
11
11
  authToken?: string;
12
12
  /** Enable debug logging to the console */
13
13
  debug?: boolean;
@@ -101,9 +101,22 @@ interface GrasshopperDefinitionSource {
101
101
  }
102
102
  /**
103
103
  * Configuration for Grasshopper compute operations
104
- * Extends base config with Grasshopper-specific options
104
+ * Combines server config with optional Grasshopper-specific computation settings
105
+ *
106
+ * Note: The definition source (pointer/algo) is NOT part of config.
107
+ * Instead, pass the definition directly to methods like solve(), getIO(), etc.
105
108
  */
106
- interface GrasshopperComputeConfig extends ComputeConfig, GrasshopperBaseSchema, GrasshopperDefinitionSource {
109
+ interface GrasshopperComputeConfig extends ComputeConfig {
110
+ /** Absolute tolerance used in computation */
111
+ absolutetolerance?: number | null;
112
+ /** Angular tolerance used in computation */
113
+ angletolerance?: number | null;
114
+ /** Model units used */
115
+ modelunits?: RhinoModelUnit | null;
116
+ /** Data version (7 or 8) */
117
+ dataversion?: 7 | 8 | null;
118
+ /** Whether to use cached solution */
119
+ cachesolve?: boolean | null;
107
120
  }
108
121
  /**
109
122
  * Raw I/O response schema from API (PascalCase)
@@ -5,9 +5,9 @@ type RhinoModelUnit = 'None' | 'Microns' | 'Millimeters' | 'Centimeters' | 'Mete
5
5
  interface ComputeConfig {
6
6
  /** The base URL of the Rhino Compute server (e.g., http://localhost:6500) */
7
7
  serverUrl: string;
8
- /** Optional API key for authenticating with the server */
8
+ /** Optional API key for authenticating with the server (RhinoComputeKey) */
9
9
  apiKey?: string;
10
- /** Optional auth token (Bearer token) for authentication */
10
+ /** Optional Bearer token for authentication (e.g., when behind a proxy or API gateway) */
11
11
  authToken?: string;
12
12
  /** Enable debug logging to the console */
13
13
  debug?: boolean;
@@ -101,9 +101,22 @@ interface GrasshopperDefinitionSource {
101
101
  }
102
102
  /**
103
103
  * Configuration for Grasshopper compute operations
104
- * Extends base config with Grasshopper-specific options
104
+ * Combines server config with optional Grasshopper-specific computation settings
105
+ *
106
+ * Note: The definition source (pointer/algo) is NOT part of config.
107
+ * Instead, pass the definition directly to methods like solve(), getIO(), etc.
105
108
  */
106
- interface GrasshopperComputeConfig extends ComputeConfig, GrasshopperBaseSchema, GrasshopperDefinitionSource {
109
+ interface GrasshopperComputeConfig extends ComputeConfig {
110
+ /** Absolute tolerance used in computation */
111
+ absolutetolerance?: number | null;
112
+ /** Angular tolerance used in computation */
113
+ angletolerance?: number | null;
114
+ /** Model units used */
115
+ modelunits?: RhinoModelUnit | null;
116
+ /** Data version (7 or 8) */
117
+ dataversion?: 7 | 8 | null;
118
+ /** Whether to use cached solution */
119
+ cachesolve?: boolean | null;
107
120
  }
108
121
  /**
109
122
  * Raw I/O response schema from API (PascalCase)
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkM2HPEWXHcjs = require('./chunk-M2HPEWXH.cjs');var _chunkFNWG34KHcjs = require('./chunk-FNWG34KH.cjs');var _three = require('three'); var i = _interopRequireWildcard(_three); var T = _interopRequireWildcard(_three); var m = _interopRequireWildcard(_three); var w = _interopRequireWildcard(_three);var _OrbitControlsjs = require('three/addons/controls/OrbitControls.js');var _RGBELoaderjs = require('three/addons/loaders/RGBELoader.js');var V=new i.Vector3(0,0,1),k= exports.initThree =function(e,n){let t=J(n||{}),r=X(t),o=oe(t),a=ae(e,t),s=ie(o,e,t);te(r,t),re(r,t),_optionalChain([t, 'access', _2 => _2.floor, 'optionalAccess', _3 => _3.enabled])&&ne(r,t);let l=t.events.enableEventHandlers!==!1?se(e,r,o,s,t):{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{}},{resize:c,dispose:R}=ee(e,a,o),{animate:h,dispose:u}=Q(a,r,o,s);h();let p=_optionalChain([t, 'access', _4 => _4.environment, 'optionalAccess', _5 => _5.sceneUp])||V;return r.up.set(p.x,p.y,p.z),{scene:r,camera:o,controls:s,renderer:a,dispose:()=>{u(),R(),l.dispose(),s.dispose(),a.dispose(),r.traverse(f=>{f instanceof i.Mesh&&(_optionalChain([f, 'access', _6 => _6.geometry, 'optionalAccess', _7 => _7.dispose, 'call', _8 => _8()]),Array.isArray(f.material)?f.material.forEach(v=>v.dispose()):_optionalChain([f, 'access', _9 => _9.material, 'optionalAccess', _10 => _10.dispose, 'call', _11 => _11()]))})},resize:c,fitToView:l.fitToView,clearSelection:l.clearSelection}};function J(e){let n=e.sceneScale||"m",r={mm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:10,lightHeight:20,minDistance:.1,shadowSize:100,scaleFactor:1e3},cm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:25,lightHeight:50,minDistance:.1,shadowSize:100,scaleFactor:100},m:{cameraDistance:10,near:.01,far:2e3,floorSize:50,lightDistance:25,lightHeight:50,minDistance:.001,shadowSize:100,scaleFactor:1},inches:{cameraDistance:15,near:.1,far:2e3,floorSize:80,lightDistance:20,lightHeight:40,minDistance:.1,shadowSize:80,scaleFactor:39.37},feet:{cameraDistance:8,near:.1,far:2e3,floorSize:40,lightDistance:15,lightHeight:30,minDistance:.1,shadowSize:60,scaleFactor:3.28084}}[n];return{sceneScale:n,camera:{position:_optionalChain([e, 'access', _12 => _12.camera, 'optionalAccess', _13 => _13.position])||new i.Vector3(-r.cameraDistance,r.cameraDistance,r.cameraDistance),fov:_optionalChain([e, 'access', _14 => _14.camera, 'optionalAccess', _15 => _15.fov])||20,near:_optionalChain([e, 'access', _16 => _16.camera, 'optionalAccess', _17 => _17.near])||r.near,far:_optionalChain([e, 'access', _18 => _18.camera, 'optionalAccess', _19 => _19.far])||r.far,target:_optionalChain([e, 'access', _20 => _20.camera, 'optionalAccess', _21 => _21.target])||new i.Vector3(0,0,0)},lighting:{enableSunlight:_nullishCoalesce(_optionalChain([e, 'access', _22 => _22.lighting, 'optionalAccess', _23 => _23.enableSunlight]), () => (!0)),sunlightIntensity:_optionalChain([e, 'access', _24 => _24.lighting, 'optionalAccess', _25 => _25.sunlightIntensity])||1,sunlightPosition:_optionalChain([e, 'access', _26 => _26.lighting, 'optionalAccess', _27 => _27.sunlightPosition])||new i.Vector3(r.lightDistance,r.lightHeight,r.lightDistance),ambientLightColor:_optionalChain([e, 'access', _28 => _28.lighting, 'optionalAccess', _29 => _29.ambientLightColor])||new i.Color(4210752),ambientLightIntensity:_optionalChain([e, 'access', _30 => _30.lighting, 'optionalAccess', _31 => _31.ambientLightIntensity])||1,sunlightColor:_optionalChain([e, 'access', _32 => _32.lighting, 'optionalAccess', _33 => _33.sunlightColor])||16777215},environment:{hdrPath:_optionalChain([e, 'access', _34 => _34.environment, 'optionalAccess', _35 => _35.hdrPath])||"/baseHDR.hdr",backgroundColor:_optionalChain([e, 'access', _36 => _36.environment, 'optionalAccess', _37 => _37.backgroundColor])||new i.Color(15790320),enableEnvironmentLighting:_nullishCoalesce(_optionalChain([e, 'access', _38 => _38.environment, 'optionalAccess', _39 => _39.enableEnvironmentLighting]), () => (!0)),sceneUp:_optionalChain([e, 'access', _40 => _40.environment, 'optionalAccess', _41 => _41.sceneUp])||V,showEnvironment:_nullishCoalesce(_optionalChain([e, 'access', _42 => _42.environment, 'optionalAccess', _43 => _43.showEnvironment]), () => (!1))},floor:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _44 => _44.floor, 'optionalAccess', _45 => _45.enabled]), () => (!1)),size:_optionalChain([e, 'access', _46 => _46.floor, 'optionalAccess', _47 => _47.size])||r.floorSize,color:_optionalChain([e, 'access', _48 => _48.floor, 'optionalAccess', _49 => _49.color])||new i.Color(8421504),roughness:_optionalChain([e, 'access', _50 => _50.floor, 'optionalAccess', _51 => _51.roughness])||.7,metalness:_optionalChain([e, 'access', _52 => _52.floor, 'optionalAccess', _53 => _53.metalness])||0,receiveShadow:_nullishCoalesce(_optionalChain([e, 'access', _54 => _54.floor, 'optionalAccess', _55 => _55.receiveShadow]), () => (!0))},render:{enableShadows:_nullishCoalesce(_optionalChain([e, 'access', _56 => _56.render, 'optionalAccess', _57 => _57.enableShadows]), () => (!0)),shadowMapSize:_optionalChain([e, 'access', _58 => _58.render, 'optionalAccess', _59 => _59.shadowMapSize])||2048,antialias:_nullishCoalesce(_optionalChain([e, 'access', _60 => _60.render, 'optionalAccess', _61 => _61.antialias]), () => (!0)),pixelRatio:_optionalChain([e, 'access', _62 => _62.render, 'optionalAccess', _63 => _63.pixelRatio])||Math.min(window.devicePixelRatio,2),toneMapping:_optionalChain([e, 'access', _64 => _64.render, 'optionalAccess', _65 => _65.toneMapping])||i.NeutralToneMapping,toneMappingExposure:_optionalChain([e, 'access', _66 => _66.render, 'optionalAccess', _67 => _67.toneMappingExposure])||1,preserveDrawingBuffer:_nullishCoalesce(_optionalChain([e, 'access', _68 => _68.render, 'optionalAccess', _69 => _69.preserveDrawingBuffer]), () => (!1))},controls:{enableDamping:_nullishCoalesce(_optionalChain([e, 'access', _70 => _70.controls, 'optionalAccess', _71 => _71.enableDamping]), () => (!1)),dampingFactor:_optionalChain([e, 'access', _72 => _72.controls, 'optionalAccess', _73 => _73.dampingFactor])||.05,autoRotate:_nullishCoalesce(_optionalChain([e, 'access', _74 => _74.controls, 'optionalAccess', _75 => _75.autoRotate]), () => (!1)),autoRotateSpeed:_optionalChain([e, 'access', _76 => _76.controls, 'optionalAccess', _77 => _77.autoRotateSpeed])||.5,enableZoom:_nullishCoalesce(_optionalChain([e, 'access', _78 => _78.controls, 'optionalAccess', _79 => _79.enableZoom]), () => (!0)),enablePan:_nullishCoalesce(_optionalChain([e, 'access', _80 => _80.controls, 'optionalAccess', _81 => _81.enablePan]), () => (!0)),minDistance:_optionalChain([e, 'access', _82 => _82.controls, 'optionalAccess', _83 => _83.minDistance])||r.minDistance,maxDistance:_optionalChain([e, 'access', _84 => _84.controls, 'optionalAccess', _85 => _85.maxDistance])||1/0},events:{onBackgroundClicked:_optionalChain([e, 'access', _86 => _86.events, 'optionalAccess', _87 => _87.onBackgroundClicked]),onObjectSelected:_optionalChain([e, 'access', _88 => _88.events, 'optionalAccess', _89 => _89.onObjectSelected]),onMeshMetadataClicked:_optionalChain([e, 'access', _90 => _90.events, 'optionalAccess', _91 => _91.onMeshMetadataClicked]),selectionColor:_optionalChain([e, 'access', _92 => _92.events, 'optionalAccess', _93 => _93.selectionColor])||"#ff0000",enableEventHandlers:_nullishCoalesce(_optionalChain([e, 'access', _94 => _94.events, 'optionalAccess', _95 => _95.enableEventHandlers]), () => (!0)),enableKeyboardControls:_nullishCoalesce(_optionalChain([e, 'access', _96 => _96.events, 'optionalAccess', _97 => _97.enableKeyboardControls]), () => (!0)),enableClickToFocus:_nullishCoalesce(_optionalChain([e, 'access', _98 => _98.events, 'optionalAccess', _99 => _99.enableClickToFocus]), () => (!0))}}}function X(e){let n=new i.Scene;n.children.forEach(r=>{r.userData.id!=="floor"&&n.remove(r)});let t=typeof e.environment.backgroundColor=="string"?new i.Color(e.environment.backgroundColor):e.environment.backgroundColor;return n.background=t||null,n}function Q(e,n,t,r){let o=null,a=function(){o=requestAnimationFrame(a),r.enableDamping&&r.update(),e.render(n,t)};return{animate:a,dispose:()=>{o!==null&&(cancelAnimationFrame(o),o=null)}}}function ee(e,n,t){let r=e.parentElement,o,a=null,s=()=>r?{width:r.clientWidth,height:r.clientHeight}:{width:window.innerWidth,height:window.innerHeight},l=()=>{o&&clearTimeout(o),o=setTimeout(()=>{let{width:R,height:h}=s();(n.domElement.width!==R||n.domElement.height!==h)&&(n.setSize(R,h,!1),t.aspect=R/h,t.updateProjectionMatrix())},16)};return r&&typeof ResizeObserver<"u"?(a=new ResizeObserver(l),a.observe(r)):window.addEventListener("resize",l),{resize:l,dispose:()=>{o&&clearTimeout(o),a?a.disconnect():window.removeEventListener("resize",l)}}}function te(e,n){n.environment.enableEnvironmentLighting&&new (0, _RGBELoaderjs.RGBELoader)().load(n.environment.hdrPath||"/baseHDR.hdr",function(t){t.mapping=i.EquirectangularReflectionMapping,e.environment=t,n.environment.showEnvironment&&(e.background=t)},void 0,function(t){_chunkFNWG34KHcjs.j.call(void 0, ).warn("HDR texture could not be loaded, falling back to basic lighting:",t);let r=new i.AmbientLight(4210752,.4);e.add(r)})}function re(e,n){let t=new i.AmbientLight(n.lighting.ambientLightColor,n.lighting.ambientLightIntensity);if(e.add(t),n.lighting.enableSunlight){let r=new i.DirectionalLight(_nullishCoalesce(n.lighting.sunlightColor, () => (16777215)),n.lighting.sunlightIntensity),o=n.lighting.sunlightPosition;if(o&&r.position.set(o.x,o.y,o.z),n.render.enableShadows){r.castShadow=!0;let a=n.sceneScale==="mm"?.1:n.sceneScale==="cm"?10:100;r.shadow.camera.left=-a,r.shadow.camera.right=a,r.shadow.camera.top=a,r.shadow.camera.bottom=-a;let s=n.sceneScale==="mm"?.001:n.sceneScale==="cm"?.1:.5,l=n.sceneScale==="mm"?1:n.sceneScale==="cm"?100:500;r.shadow.camera.near=s,r.shadow.camera.far=l,r.shadow.mapSize.width=n.render.shadowMapSize||2048,r.shadow.mapSize.height=n.render.shadowMapSize||2048,r.shadow.bias=-1e-4,r.shadow.normalBias=.02}e.add(r)}}function ne(e,n){let t=n.floor.size,r=new i.PlaneGeometry(t,t),o=typeof n.floor.color=="string"?new i.Color(n.floor.color):n.floor.color,a=new i.MeshStandardMaterial({color:o,roughness:n.floor.roughness,metalness:n.floor.metalness,side:i.DoubleSide}),s=new i.Mesh(r,a);s.userData.id="floor",s.name="floor",s.rotation.x=-Math.PI/2,s.position.y=0,n.floor.receiveShadow&&n.render.enableShadows&&(s.receiveShadow=!0),e.add(s)}function oe(e){let t=_optionalChain([document, 'access', _100 => _100.querySelector, 'call', _101 => _101("canvas"), 'optionalAccess', _102 => _102.parentElement]),r=t?t.clientWidth:window.innerWidth,o=t?t.clientHeight:window.innerHeight,a=new i.PerspectiveCamera(e.camera.fov,r/o,e.camera.near,e.camera.far),s=e.camera.position;return s&&a.position.set(s.x,s.y,s.z),a}function ae(e,n){let t=new i.WebGLRenderer({antialias:n.render.antialias,canvas:e,alpha:!0,powerPreference:"high-performance",preserveDrawingBuffer:n.render.preserveDrawingBuffer,logarithmicDepthBuffer:!0}),r=e.parentElement,o=r?r.clientWidth:window.innerWidth,a=r?r.clientHeight:window.innerHeight;return r&&(e.style.width="100%",e.style.height="100%",e.style.display="block"),t.setSize(o,a,!1),t.setPixelRatio(n.render.pixelRatio||Math.min(window.devicePixelRatio,2)),n.render.enableShadows&&(t.shadowMap.enabled=!0,t.shadowMap.type=i.VSMShadowMap),t.toneMapping=n.render.toneMapping||i.ACESFilmicToneMapping,t.toneMappingExposure=n.render.toneMappingExposure||1,t.outputColorSpace=i.SRGBColorSpace,t.sortObjects=!0,t}function se(e,n,t,r,o){let a=new Set,s=new Map,l=new i.Raycaster,c=new i.Vector2,R=new i.Vector2,h=()=>{let d=new i.Box3;if(n.traverse(L=>{L.visible&&L.userData.id!=="floor"&&L instanceof i.Mesh&&d.expandByObject(L)}),d.isEmpty()){_chunkFNWG34KHcjs.j.call(void 0, ).warn("No objects to fit to view");return}let b=d.getCenter(new i.Vector3),g=d.getSize(new i.Vector3),O=Math.max(g.x,g.y,g.z),y=t.fov*(Math.PI/180),S=O/(2*Math.tan(y/2));S*=1.5;let q=t.position.clone().sub(r.target).normalize();t.position.copy(b.clone().add(q.multiplyScalar(S))),r.target.copy(b),r.update()},u=typeof o.events.selectionColor=="string"?new i.Color(o.events.selectionColor):o.events.selectionColor instanceof i.Color?o.events.selectionColor:new i.Color("#ff0000"),p=()=>{a.forEach(d=>{d instanceof i.Mesh&&s.has(d)&&(d.material=s.get(d),s.delete(d))}),a.clear()},x=d=>{R.set(d.clientX,d.clientY)},f=d=>{let b=new i.Vector2(d.clientX,d.clientY);if(R.distanceTo(b)>5)return;let g=e.getBoundingClientRect();c.x=(d.clientX-g.left)/g.width*2-1,c.y=-((d.clientY-g.top)/g.height)*2+1,l.setFromCamera(c,t);let O=l.intersectObjects(n.children,!0);if(O.length>0){let y=O[0].object;if(!a.has(y)){if(p(),a.add(y),y instanceof i.Mesh&&y.material instanceof i.Material){s.set(y,y.material);let S=y.material.clone();S.emissive=u.clone(),y.material=S}_optionalChain([o, 'access', _103 => _103.events, 'optionalAccess', _104 => _104.onObjectSelected, 'optionalCall', _105 => _105(y)]),y instanceof i.Mesh&&Object.keys(y.userData).length>0&&_optionalChain([o, 'access', _106 => _106.events, 'optionalAccess', _107 => _107.onMeshMetadataClicked, 'optionalCall', _108 => _108(y.userData)])}}else p(),_optionalChain([o, 'access', _109 => _109.events, 'optionalAccess', _110 => _110.onBackgroundClicked, 'optionalCall', _111 => _111({x:c.x,y:c.y})])},v=d=>{if(_optionalChain([o, 'access', _112 => _112.events, 'optionalAccess', _113 => _113.enableKeyboardControls]))switch(d.key.toLowerCase()){case"f":d.preventDefault(),h();break;case"escape":d.preventDefault(),p();break;case" ":d.preventDefault(),h();break}};return _optionalChain([o, 'access', _114 => _114.events, 'optionalAccess', _115 => _115.enableClickToFocus])&&(e.addEventListener("mousedown",x),e.addEventListener("click",f)),_optionalChain([o, 'access', _116 => _116.events, 'optionalAccess', _117 => _117.enableKeyboardControls])&&(e.setAttribute("tabindex","0"),e.addEventListener("keydown",v)),{dispose:()=>{e.removeEventListener("mousedown",x),e.removeEventListener("click",f),e.removeEventListener("keydown",v),p()},fitToView:h,clearSelection:p}}function ie(e,n,t){let r=new (0, _OrbitControlsjs.OrbitControls)(e,n),o=t.camera.target;return o&&r.target.set(o.x,o.y,o.z),r.enableDamping=t.controls.enableDamping||!1,r.dampingFactor=t.controls.dampingFactor||.05,r.autoRotate=t.controls.autoRotate||!1,r.autoRotateSpeed=t.controls.autoRotateSpeed||.5,r.enableZoom=t.controls.enableZoom||!0,r.enablePan=t.controls.enablePan||!0,r.minDistance=t.controls.minDistance||.001,r.maxDistance=t.controls.maxDistance||1/0,r.screenSpacePanning=!1,r.maxPolarAngle=Math.PI,r.update(),r}var H={HUGE_THRESHOLD:1e4,LARGE_THRESHOLD:1e3,SCALE_RATIO_THRESHOLD:100,NEAR_PLANE_FACTOR:{TINY:1e-4,SMALL:.001,NORMAL:.01},FAR_PLANE_FACTOR:{HUGE:100,LARGE:50,NORMAL:20},InitialDistanceMultiplier:4};function G(e,n,t,r,o){if(ce(e),n.length===0)return;n.forEach(h=>{e.add(h)});let a=D(n),s=a.getCenter(new T.Vector3),l=a.getSize(new T.Vector3),c=Math.max(l.x,l.y,l.z);if(c/Math.min(l.x||1,l.y||1,l.z||1)>H.SCALE_RATIO_THRESHOLD||c>H.HUGE_THRESHOLD?(t.near=c*H.NEAR_PLANE_FACTOR.TINY,t.far=c*H.FAR_PLANE_FACTOR.HUGE):c>H.LARGE_THRESHOLD?(t.near=c*H.NEAR_PLANE_FACTOR.SMALL,t.far=c*H.FAR_PLANE_FACTOR.LARGE):(t.near=Math.max(.01,c*H.NEAR_PLANE_FACTOR.NORMAL),t.far=Math.max(2e3,c*H.FAR_PLANE_FACTOR.NORMAL)),t.updateProjectionMatrix(),o)r.minDistance=t.near*2,r.maxDistance=t.far*.9;else{let h=c*H.InitialDistanceMultiplier;t.position.set(s.x+h*.8,s.y+h,s.z+h*1.2),r.target.copy(s),r.minDistance=t.near*2,r.maxDistance=t.far*.9,r.update()}}function I(e){if(!e||typeof e!="string")return _chunkFNWG34KHcjs.j.call(void 0, ).warn(`Invalid color input: ${e}, using white`),new T.Color(16777215);let n=e.trim();if(n.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(n))try{let t=n.startsWith("#")?n:`#${n}`;return new T.Color(t)}catch (e2){return _chunkFNWG34KHcjs.j.call(void 0, ).warn(`Invalid hex color: ${e}, using white`),new T.Color(16777215)}if(n.includes(",")){let t=n.split(",").map(r=>parseInt(r.trim(),10));if(t.length===3&&t.every(r=>!isNaN(r)&&r>=0&&r<=255))return new T.Color(t[0]/255,t[1]/255,t[2]/255)}try{return new T.Color(n.toLowerCase())}catch (e3){return _chunkFNWG34KHcjs.j.call(void 0, ).warn(`Invalid color string: ${e}, using white`),new T.Color(16777215)}}function B(e,n){e.forEach(t=>{t.position.y-=n,t.updateMatrix()})}function D(e){let n=new T.Box3;return e.forEach(t=>{t.updateMatrixWorld(!0);let r=new T.Box3().setFromObject(t);n.union(r)}),n}function ce(e){let n=[];e.traverse(t=>{t instanceof T.Mesh&&t.userData.id!=="floor"&&n.push(t)}),n.forEach(t=>{t instanceof T.Mesh&&(_optionalChain([t, 'access', _118 => _118.geometry, 'optionalAccess', _119 => _119.dispose, 'call', _120 => _120()]),(Array.isArray(t.material)?t.material:[t.material]).forEach(o=>{for(let a in o){let s=o[a];s&&s instanceof T.Texture&&s.dispose()}o.dispose()})),t.removeFromParent()})}var F={};_chunkFNWG34KHcjs.a.call(void 0, F,{CONCRETE_MATERIAL:()=>de,EMISSIVE_MATERIAL:()=>le,GLASS_MATERIAL:()=>me,METAL_MATERIAL:()=>fe,PLASTIC_MATERIAL:()=>he,RUBBER_MATERIAL:()=>Ee,WOOD_MATERIAL:()=>ue});var le=new m.MeshPhysicalMaterial({color:0,emissive:new m.Color(16777215),emissiveIntensity:5,metalness:0,roughness:.2,clearcoat:.3,clearcoatRoughness:.2,depthWrite:!0,depthTest:!0,transparent:!1,alphaTest:0,polygonOffset:!0,side:m.FrontSide,dithering:!0}),fe=new m.MeshPhysicalMaterial({color:new m.Color(0),metalness:.9,roughness:.3,envMapIntensity:1.2,clearcoat:.3,clearcoatRoughness:.2,reflectivity:1,ior:2.5,thickness:1,depthWrite:!0,transparent:!1,alphaTest:0,depthTest:!0,polygonOffset:!0,side:m.FrontSide,dithering:!0}),de=new m.MeshPhysicalMaterial({color:new m.Color(13421772),metalness:0,roughness:.92,envMapIntensity:.15,clearcoat:.05,clearcoatRoughness:.9,reflectivity:.15,transmission:0,ior:1.45,thickness:0,depthWrite:!0,transparent:!1,alphaTest:.5,depthTest:!0,polygonOffset:!0,side:m.FrontSide,dithering:!0}),he=new m.MeshPhysicalMaterial({color:new m.Color(16777215),metalness:0,roughness:.3,envMapIntensity:.5,clearcoat:.5,clearcoatRoughness:.1,reflectivity:.5,ior:1.4,transmission:0,transparent:!1,depthWrite:!0,side:m.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),me=new m.MeshPhysicalMaterial({color:new m.Color(16777215),metalness:0,roughness:0,transmission:.95,transparent:!0,opacity:.3,envMapIntensity:1,clearcoat:1,clearcoatRoughness:0,ior:1.52,reflectivity:.9,thickness:1,side:m.DoubleSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),Ee=new m.MeshPhysicalMaterial({color:new m.Color(1710618),metalness:0,roughness:.9,envMapIntensity:.2,clearcoat:.1,clearcoatRoughness:.8,reflectivity:.2,ior:1.3,transmission:0,depthWrite:!0,side:m.FrontSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),ue=new m.MeshPhysicalMaterial({color:new m.Color(8934707),metalness:0,roughness:.7,envMapIntensity:.3,clearcoat:.3,clearcoatRoughness:.4,reflectivity:.3,ior:1.3,transmission:0,depthWrite:!0,side:m.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1});var _fflate = require('fflate'); var U = _interopRequireWildcard(_fflate);_chunkFNWG34KHcjs.i.call(void 0, );async function W(e){return new Promise((n,t)=>{try{let r=()=>{try{let o=_chunkM2HPEWXHcjs.c.call(void 0, e),a=U.gunzipSync(o),s=pe(a);n(s)}catch(o){t(new (0, _chunkFNWG34KHcjs.d)(o instanceof _chunkFNWG34KHcjs.d?o.message:`Failed to decompress batched data: ${o instanceof Error?o.message:String(o)}`,o instanceof _chunkFNWG34KHcjs.d?o.code:_chunkFNWG34KHcjs.f.VALIDATION_ERROR,{context:{base64StringLength:e.length},originalError:o instanceof Error?o:new Error(String(o))}))}};"requestIdleCallback"in globalThis?globalThis.requestIdleCallback(r,{timeout:5e3}):setTimeout(r,0)}catch(r){t(new (0, _chunkFNWG34KHcjs.d)(`Failed to schedule decompression: ${r instanceof Error?r.message:String(r)}`,_chunkFNWG34KHcjs.f.VALIDATION_ERROR,{originalError:r instanceof Error?r:new Error(String(r))}))}})}function pe(e){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),t=0;if(t+4>n.byteLength)throw new (0, _chunkFNWG34KHcjs.d)("Insufficient data to read the number of vertex floats.",_chunkFNWG34KHcjs.f.VALIDATION_ERROR,{context:{expectedBytes:4,availableBytes:n.byteLength,offset:t}});let r=n.getUint32(t,!0);if(t+=4,r%3!==0)throw new (0, _chunkFNWG34KHcjs.d)("Invalid number of vertex floats; should be divisible by 3.",_chunkFNWG34KHcjs.f.VALIDATION_ERROR,{context:{numVertexFloats:r,remainder:r%3,totalBytes:n.byteLength}});let o=r*Float32Array.BYTES_PER_ELEMENT;if(t+o>n.byteLength)throw new (0, _chunkFNWG34KHcjs.d)("Insufficient data to read vertices.",_chunkFNWG34KHcjs.f.VALIDATION_ERROR,{context:{expectedBytes:o,availableBytes:n.byteLength-t,offset:t}});let a=new Float32Array(e.buffer,e.byteOffset+t,r);if(t+=o,t+4>n.byteLength)throw new (0, _chunkFNWG34KHcjs.d)("Insufficient data to read the number of face indices.",_chunkFNWG34KHcjs.f.VALIDATION_ERROR,{context:{expectedBytes:4,availableBytes:n.byteLength-t,offset:t}});let s=n.getUint32(t,!0);t+=4;let l=s*Uint32Array.BYTES_PER_ELEMENT;if(t+l>n.byteLength)throw new (0, _chunkFNWG34KHcjs.d)("Insufficient data to read face indices.",_chunkFNWG34KHcjs.f.VALIDATION_ERROR,{context:{expectedBytes:l,availableBytes:n.byteLength-t,offset:t}});let c=new Uint32Array(e.buffer,e.byteOffset+t,s);return{vertices:a,faces:c}}async function z(e,n){let{mergeByMaterial:t=!0,applyTransforms:r=!0,debug:o=!1}=_nullishCoalesce(n, () => ({})),a=o?performance.now():0,s=0;try{let l=performance.now(),c=JSON.parse(e);return s=performance.now()-l,await P(c,{mergeByMaterial:t,applyTransforms:r,debug:o,parseTime:s,perfStart:a})}catch(l){return _chunkFNWG34KHcjs.j.call(void 0, ).error("Error parsing mesh batch:",l),[]}}async function P(e,n){let{mergeByMaterial:t=!0,applyTransforms:r=!0,scaleFactor:o=1,debug:a=!1,parseTime:s=0,perfStart:l=a?performance.now():0}=_nullishCoalesce(n, () => ({})),c=0,R=0;try{let h=performance.now(),{vertices:u,faces:p}=await W(e.compressedData);c=performance.now()-h;let x=(e.compressedData.length*.75/1024/1024).toFixed(2),f=((u.byteLength+p.byteLength)/1024/1024).toFixed(2),v=((1-parseFloat(x)/parseFloat(f))*100).toFixed(1);a&&(_chunkFNWG34KHcjs.j.call(void 0, ).debug("Mesh Batch Stats:"),_chunkFNWG34KHcjs.j.call(void 0, ).debug(` Materials: ${e.materials.length} | Groups: ${e.groups.length}`),_chunkFNWG34KHcjs.j.call(void 0, ).debug(` Vertices: ${(u.length/3).toLocaleString()} | Faces: ${(p.length/3).toLocaleString()}`),_chunkFNWG34KHcjs.j.call(void 0, ).debug(` Compressed: ${x} MB | Uncompressed: ${f} MB`),_chunkFNWG34KHcjs.j.call(void 0, ).debug(` Compression Ratio: ${v}%`)),r&&we(u);let A=performance.now(),d=e.materials.map(ge),b=[];for(let g of e.groups)if(t&&g.meshes.length>1){let O=Re(g,u,p,d);b.push(O)}else{let O=Te(g,u,p,d);b.push(...O)}if(o!==1)for(let g of b)g.scale.set(o,o,o);if(R=performance.now()-A,a){let g=performance.now()-l;_chunkFNWG34KHcjs.j.call(void 0, ).debug("Performance:"),s>0&&_chunkFNWG34KHcjs.j.call(void 0, ).debug(` Parse JSON: ${s.toFixed(2)}ms`),_chunkFNWG34KHcjs.j.call(void 0, ).debug(` Decompress: ${c.toFixed(2)}ms`),_chunkFNWG34KHcjs.j.call(void 0, ).debug(` Create Meshes: ${R.toFixed(2)}ms`),_chunkFNWG34KHcjs.j.call(void 0, ).debug(` Total: ${g.toFixed(2)}ms`)}return b}catch(h){return _chunkFNWG34KHcjs.j.call(void 0, ).error("Error parsing mesh batch object:",h),[]}}function ge(e){let n=I(e.color);return new w.MeshPhysicalMaterial({color:n,metalness:e.metalness,roughness:e.roughness,opacity:e.opacity,transparent:e.transparent,side:w.DoubleSide,polygonOffset:!0,polygonOffsetFactor:.5,polygonOffsetUnits:.5,depthWrite:!0,depthTest:!0})}function Re(e,n,t,r){let o=new w.BufferGeometry,a=0,s=0;for(let f of e.meshes)a+=f.vertexCount,s+=f.faceCount;let l=new Float32Array(a),c=new Uint32Array(s),R=0,h=0;for(let f of e.meshes){l.set(n.subarray(f.vertexOffset,f.vertexOffset+f.vertexCount),R);let v=t.subarray(f.faceOffset,f.faceOffset+f.faceCount),A=Math.floor(f.vertexOffset/3),b=Math.floor(R/3)-A;for(let g=0;g<v.length;g++)c[h+g]=v[g]+b;R+=f.vertexCount,h+=f.faceCount}o.setAttribute("position",new w.BufferAttribute(l,3)),o.setIndex(new w.BufferAttribute(c,1)),o.computeVertexNormals();let u=new w.Mesh(o,r[e.materialId]),p=e.meshes.map(f=>f.name).filter(f=>f&&f.length>0);u.name=p.length>0?p[0]:`merged_material_${e.materialId}`,u.castShadow=!0,u.receiveShadow=!0;let x=e.meshes.map(f=>f.metadata).filter(f=>f);return x.length>0&&(u.userData.mergedMetadata=x),u}function Te(e,n,t,r){let o=[];for(let a of e.meshes){let s=new w.BufferGeometry,l=n.subarray(a.vertexOffset,a.vertexOffset+a.vertexCount),c=t.subarray(a.faceOffset,a.faceOffset+a.faceCount),R=Math.floor(a.vertexOffset/3),h=new Uint32Array(c.length);for(let p=0;p<c.length;p++)h[p]=c[p]-R;s.setAttribute("position",new w.BufferAttribute(l,3)),s.setIndex(new w.BufferAttribute(h,1)),s.computeVertexNormals();let u=new w.Mesh(s,r[e.materialId]);u.name=a.name,a.metadata&&(u.userData={...u.userData,...a.metadata}),u.castShadow=!0,u.receiveShadow=!0,o.push(u)}return o}function we(e){let n=Math.cos(-Math.PI/2),t=Math.sin(-Math.PI/2);for(let r=0;r<e.length;r+=3){let o=e[r],a=e[r+1],s=e[r+2];e[r]=o,e[r+1]=a*n-s*t,e[r+2]=a*t+s*n}}var _={Millimeters:1/1e3,Centimeters:1/100,Meters:1,Inches:1/39.37,Feet:1/3.28084},ye="Display";async function $(e,n){let t=performance.now(),r=[],{allowScaling:o=!0,allowAutoPosition:a=!0,debug:s=!1,parsing:l={}}=_nullishCoalesce(n, () => ({}));try{let c=o?be(e.modelunits):1;return await Me(e,r,c,l,s),a&&xe(r),r}catch(c){throw ve(c,r),c}finally{s&&Ce(t)}}function be(e){return _nullishCoalesce(_[e], () => (1))}async function Me(e,n,t,r,o){for(let a of e.values){let s=a.InnerTree;for(let l in s){let c=s[l];c&&await He(c,n,t,r,o)}}}async function He(e,n,t,r,o){for(let a of e)if(a.type.includes(ye)){let s={mergeByMaterial:!0,applyTransforms:!0,debug:!1,...r},l=await z(a.data,s);if(t!==1)for(let c of l)c.scale.set(t,t,t);n.push(...l),o&&_chunkFNWG34KHcjs.j.call(void 0, ).debug(`Extracted ${l.length} meshes from batch`)}}function xe(e){if(e.length===0)return;let t=D(e).min.y;B(e,t)}function ve(e,n){_chunkFNWG34KHcjs.j.call(void 0, ).error("An unexpected error occurred:",e),Oe(n)}function Oe(e){for(let n of e)n.geometry&&n.geometry.dispose(),n.material&&(Array.isArray(n.material)?n.material.forEach(t=>t.dispose()):n.material.dispose())}function Ce(e){let n=performance.now()-e;_chunkFNWG34KHcjs.j.call(void 0, ).info("Time to process meshes:",`${n.toFixed(2)}ms`)}exports.Materials = F; exports.SCALE_FACTORS = _; exports.getThreeMeshesFromComputeResponse = $; exports.initThree = k; exports.parseMeshBatchObject = P; exports.updateScene = G;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkQCHPQ22Ycjs = require('./chunk-QCHPQ22Y.cjs');var _chunkPE2FMBXDcjs = require('./chunk-PE2FMBXD.cjs');var _three = require('three'); var i = _interopRequireWildcard(_three); var T = _interopRequireWildcard(_three); var m = _interopRequireWildcard(_three); var w = _interopRequireWildcard(_three);var _OrbitControlsjs = require('three/addons/controls/OrbitControls.js');var _RGBELoaderjs = require('three/addons/loaders/RGBELoader.js');var V=new i.Vector3(0,0,1),k= exports.initThree =function(e,n){let t=J(n||{}),r=X(t),o=oe(t),a=ae(e,t),s=ie(o,e,t);te(r,t),re(r,t),_optionalChain([t, 'access', _2 => _2.floor, 'optionalAccess', _3 => _3.enabled])&&ne(r,t);let l=t.events.enableEventHandlers!==!1?se(e,r,o,s,t):{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{}},{resize:c,dispose:R}=ee(e,a,o),{animate:h,dispose:u}=Q(a,r,o,s);h();let p=_optionalChain([t, 'access', _4 => _4.environment, 'optionalAccess', _5 => _5.sceneUp])||V;return r.up.set(p.x,p.y,p.z),{scene:r,camera:o,controls:s,renderer:a,dispose:()=>{u(),R(),l.dispose(),s.dispose(),a.dispose(),r.traverse(f=>{f instanceof i.Mesh&&(_optionalChain([f, 'access', _6 => _6.geometry, 'optionalAccess', _7 => _7.dispose, 'call', _8 => _8()]),Array.isArray(f.material)?f.material.forEach(v=>v.dispose()):_optionalChain([f, 'access', _9 => _9.material, 'optionalAccess', _10 => _10.dispose, 'call', _11 => _11()]))})},resize:c,fitToView:l.fitToView,clearSelection:l.clearSelection}};function J(e){let n=e.sceneScale||"m",r={mm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:10,lightHeight:20,minDistance:.1,shadowSize:100,scaleFactor:1e3},cm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:25,lightHeight:50,minDistance:.1,shadowSize:100,scaleFactor:100},m:{cameraDistance:10,near:.01,far:2e3,floorSize:50,lightDistance:25,lightHeight:50,minDistance:.001,shadowSize:100,scaleFactor:1},inches:{cameraDistance:15,near:.1,far:2e3,floorSize:80,lightDistance:20,lightHeight:40,minDistance:.1,shadowSize:80,scaleFactor:39.37},feet:{cameraDistance:8,near:.1,far:2e3,floorSize:40,lightDistance:15,lightHeight:30,minDistance:.1,shadowSize:60,scaleFactor:3.28084}}[n];return{sceneScale:n,camera:{position:_optionalChain([e, 'access', _12 => _12.camera, 'optionalAccess', _13 => _13.position])||new i.Vector3(-r.cameraDistance,r.cameraDistance,r.cameraDistance),fov:_optionalChain([e, 'access', _14 => _14.camera, 'optionalAccess', _15 => _15.fov])||20,near:_optionalChain([e, 'access', _16 => _16.camera, 'optionalAccess', _17 => _17.near])||r.near,far:_optionalChain([e, 'access', _18 => _18.camera, 'optionalAccess', _19 => _19.far])||r.far,target:_optionalChain([e, 'access', _20 => _20.camera, 'optionalAccess', _21 => _21.target])||new i.Vector3(0,0,0)},lighting:{enableSunlight:_nullishCoalesce(_optionalChain([e, 'access', _22 => _22.lighting, 'optionalAccess', _23 => _23.enableSunlight]), () => (!0)),sunlightIntensity:_optionalChain([e, 'access', _24 => _24.lighting, 'optionalAccess', _25 => _25.sunlightIntensity])||1,sunlightPosition:_optionalChain([e, 'access', _26 => _26.lighting, 'optionalAccess', _27 => _27.sunlightPosition])||new i.Vector3(r.lightDistance,r.lightHeight,r.lightDistance),ambientLightColor:_optionalChain([e, 'access', _28 => _28.lighting, 'optionalAccess', _29 => _29.ambientLightColor])||new i.Color(4210752),ambientLightIntensity:_optionalChain([e, 'access', _30 => _30.lighting, 'optionalAccess', _31 => _31.ambientLightIntensity])||1,sunlightColor:_optionalChain([e, 'access', _32 => _32.lighting, 'optionalAccess', _33 => _33.sunlightColor])||16777215},environment:{hdrPath:_optionalChain([e, 'access', _34 => _34.environment, 'optionalAccess', _35 => _35.hdrPath])||"/baseHDR.hdr",backgroundColor:_optionalChain([e, 'access', _36 => _36.environment, 'optionalAccess', _37 => _37.backgroundColor])||new i.Color(15790320),enableEnvironmentLighting:_nullishCoalesce(_optionalChain([e, 'access', _38 => _38.environment, 'optionalAccess', _39 => _39.enableEnvironmentLighting]), () => (!0)),sceneUp:_optionalChain([e, 'access', _40 => _40.environment, 'optionalAccess', _41 => _41.sceneUp])||V,showEnvironment:_nullishCoalesce(_optionalChain([e, 'access', _42 => _42.environment, 'optionalAccess', _43 => _43.showEnvironment]), () => (!1))},floor:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _44 => _44.floor, 'optionalAccess', _45 => _45.enabled]), () => (!1)),size:_optionalChain([e, 'access', _46 => _46.floor, 'optionalAccess', _47 => _47.size])||r.floorSize,color:_optionalChain([e, 'access', _48 => _48.floor, 'optionalAccess', _49 => _49.color])||new i.Color(8421504),roughness:_optionalChain([e, 'access', _50 => _50.floor, 'optionalAccess', _51 => _51.roughness])||.7,metalness:_optionalChain([e, 'access', _52 => _52.floor, 'optionalAccess', _53 => _53.metalness])||0,receiveShadow:_nullishCoalesce(_optionalChain([e, 'access', _54 => _54.floor, 'optionalAccess', _55 => _55.receiveShadow]), () => (!0))},render:{enableShadows:_nullishCoalesce(_optionalChain([e, 'access', _56 => _56.render, 'optionalAccess', _57 => _57.enableShadows]), () => (!0)),shadowMapSize:_optionalChain([e, 'access', _58 => _58.render, 'optionalAccess', _59 => _59.shadowMapSize])||2048,antialias:_nullishCoalesce(_optionalChain([e, 'access', _60 => _60.render, 'optionalAccess', _61 => _61.antialias]), () => (!0)),pixelRatio:_optionalChain([e, 'access', _62 => _62.render, 'optionalAccess', _63 => _63.pixelRatio])||Math.min(window.devicePixelRatio,2),toneMapping:_optionalChain([e, 'access', _64 => _64.render, 'optionalAccess', _65 => _65.toneMapping])||i.NeutralToneMapping,toneMappingExposure:_optionalChain([e, 'access', _66 => _66.render, 'optionalAccess', _67 => _67.toneMappingExposure])||1,preserveDrawingBuffer:_nullishCoalesce(_optionalChain([e, 'access', _68 => _68.render, 'optionalAccess', _69 => _69.preserveDrawingBuffer]), () => (!1))},controls:{enableDamping:_nullishCoalesce(_optionalChain([e, 'access', _70 => _70.controls, 'optionalAccess', _71 => _71.enableDamping]), () => (!1)),dampingFactor:_optionalChain([e, 'access', _72 => _72.controls, 'optionalAccess', _73 => _73.dampingFactor])||.05,autoRotate:_nullishCoalesce(_optionalChain([e, 'access', _74 => _74.controls, 'optionalAccess', _75 => _75.autoRotate]), () => (!1)),autoRotateSpeed:_optionalChain([e, 'access', _76 => _76.controls, 'optionalAccess', _77 => _77.autoRotateSpeed])||.5,enableZoom:_nullishCoalesce(_optionalChain([e, 'access', _78 => _78.controls, 'optionalAccess', _79 => _79.enableZoom]), () => (!0)),enablePan:_nullishCoalesce(_optionalChain([e, 'access', _80 => _80.controls, 'optionalAccess', _81 => _81.enablePan]), () => (!0)),minDistance:_optionalChain([e, 'access', _82 => _82.controls, 'optionalAccess', _83 => _83.minDistance])||r.minDistance,maxDistance:_optionalChain([e, 'access', _84 => _84.controls, 'optionalAccess', _85 => _85.maxDistance])||1/0},events:{onBackgroundClicked:_optionalChain([e, 'access', _86 => _86.events, 'optionalAccess', _87 => _87.onBackgroundClicked]),onObjectSelected:_optionalChain([e, 'access', _88 => _88.events, 'optionalAccess', _89 => _89.onObjectSelected]),onMeshMetadataClicked:_optionalChain([e, 'access', _90 => _90.events, 'optionalAccess', _91 => _91.onMeshMetadataClicked]),selectionColor:_optionalChain([e, 'access', _92 => _92.events, 'optionalAccess', _93 => _93.selectionColor])||"#ff0000",enableEventHandlers:_nullishCoalesce(_optionalChain([e, 'access', _94 => _94.events, 'optionalAccess', _95 => _95.enableEventHandlers]), () => (!0)),enableKeyboardControls:_nullishCoalesce(_optionalChain([e, 'access', _96 => _96.events, 'optionalAccess', _97 => _97.enableKeyboardControls]), () => (!0)),enableClickToFocus:_nullishCoalesce(_optionalChain([e, 'access', _98 => _98.events, 'optionalAccess', _99 => _99.enableClickToFocus]), () => (!0))}}}function X(e){let n=new i.Scene;n.children.forEach(r=>{r.userData.id!=="floor"&&n.remove(r)});let t=typeof e.environment.backgroundColor=="string"?new i.Color(e.environment.backgroundColor):e.environment.backgroundColor;return n.background=t||null,n}function Q(e,n,t,r){let o=null,a=function(){o=requestAnimationFrame(a),r.enableDamping&&r.update(),e.render(n,t)};return{animate:a,dispose:()=>{o!==null&&(cancelAnimationFrame(o),o=null)}}}function ee(e,n,t){let r=e.parentElement,o,a=null,s=()=>r?{width:r.clientWidth,height:r.clientHeight}:{width:window.innerWidth,height:window.innerHeight},l=()=>{o&&clearTimeout(o),o=setTimeout(()=>{let{width:R,height:h}=s();(n.domElement.width!==R||n.domElement.height!==h)&&(n.setSize(R,h,!1),t.aspect=R/h,t.updateProjectionMatrix())},16)};return r&&typeof ResizeObserver<"u"?(a=new ResizeObserver(l),a.observe(r)):window.addEventListener("resize",l),{resize:l,dispose:()=>{o&&clearTimeout(o),a?a.disconnect():window.removeEventListener("resize",l)}}}function te(e,n){n.environment.enableEnvironmentLighting&&new (0, _RGBELoaderjs.RGBELoader)().load(n.environment.hdrPath||"/baseHDR.hdr",function(t){t.mapping=i.EquirectangularReflectionMapping,e.environment=t,n.environment.showEnvironment&&(e.background=t)},void 0,function(t){_chunkPE2FMBXDcjs.i.call(void 0, ).warn("HDR texture could not be loaded, falling back to basic lighting:",t);let r=new i.AmbientLight(4210752,.4);e.add(r)})}function re(e,n){let t=new i.AmbientLight(n.lighting.ambientLightColor,n.lighting.ambientLightIntensity);if(e.add(t),n.lighting.enableSunlight){let r=new i.DirectionalLight(_nullishCoalesce(n.lighting.sunlightColor, () => (16777215)),n.lighting.sunlightIntensity),o=n.lighting.sunlightPosition;if(o&&r.position.set(o.x,o.y,o.z),n.render.enableShadows){r.castShadow=!0;let a=n.sceneScale==="mm"?.1:n.sceneScale==="cm"?10:100;r.shadow.camera.left=-a,r.shadow.camera.right=a,r.shadow.camera.top=a,r.shadow.camera.bottom=-a;let s=n.sceneScale==="mm"?.001:n.sceneScale==="cm"?.1:.5,l=n.sceneScale==="mm"?1:n.sceneScale==="cm"?100:500;r.shadow.camera.near=s,r.shadow.camera.far=l,r.shadow.mapSize.width=n.render.shadowMapSize||2048,r.shadow.mapSize.height=n.render.shadowMapSize||2048,r.shadow.bias=-1e-4,r.shadow.normalBias=.02}e.add(r)}}function ne(e,n){let t=n.floor.size,r=new i.PlaneGeometry(t,t),o=typeof n.floor.color=="string"?new i.Color(n.floor.color):n.floor.color,a=new i.MeshStandardMaterial({color:o,roughness:n.floor.roughness,metalness:n.floor.metalness,side:i.DoubleSide}),s=new i.Mesh(r,a);s.userData.id="floor",s.name="floor",s.rotation.x=-Math.PI/2,s.position.y=0,n.floor.receiveShadow&&n.render.enableShadows&&(s.receiveShadow=!0),e.add(s)}function oe(e){let t=_optionalChain([document, 'access', _100 => _100.querySelector, 'call', _101 => _101("canvas"), 'optionalAccess', _102 => _102.parentElement]),r=t?t.clientWidth:window.innerWidth,o=t?t.clientHeight:window.innerHeight,a=new i.PerspectiveCamera(e.camera.fov,r/o,e.camera.near,e.camera.far),s=e.camera.position;return s&&a.position.set(s.x,s.y,s.z),a}function ae(e,n){let t=new i.WebGLRenderer({antialias:n.render.antialias,canvas:e,alpha:!0,powerPreference:"high-performance",preserveDrawingBuffer:n.render.preserveDrawingBuffer,logarithmicDepthBuffer:!0}),r=e.parentElement,o=r?r.clientWidth:window.innerWidth,a=r?r.clientHeight:window.innerHeight;return r&&(e.style.width="100%",e.style.height="100%",e.style.display="block"),t.setSize(o,a,!1),t.setPixelRatio(n.render.pixelRatio||Math.min(window.devicePixelRatio,2)),n.render.enableShadows&&(t.shadowMap.enabled=!0,t.shadowMap.type=i.VSMShadowMap),t.toneMapping=n.render.toneMapping||i.ACESFilmicToneMapping,t.toneMappingExposure=n.render.toneMappingExposure||1,t.outputColorSpace=i.SRGBColorSpace,t.sortObjects=!0,t}function se(e,n,t,r,o){let a=new Set,s=new Map,l=new i.Raycaster,c=new i.Vector2,R=new i.Vector2,h=()=>{let d=new i.Box3;if(n.traverse(L=>{L.visible&&L.userData.id!=="floor"&&L instanceof i.Mesh&&d.expandByObject(L)}),d.isEmpty()){_chunkPE2FMBXDcjs.i.call(void 0, ).warn("No objects to fit to view");return}let b=d.getCenter(new i.Vector3),g=d.getSize(new i.Vector3),O=Math.max(g.x,g.y,g.z),y=t.fov*(Math.PI/180),S=O/(2*Math.tan(y/2));S*=1.5;let q=t.position.clone().sub(r.target).normalize();t.position.copy(b.clone().add(q.multiplyScalar(S))),r.target.copy(b),r.update()},u=typeof o.events.selectionColor=="string"?new i.Color(o.events.selectionColor):o.events.selectionColor instanceof i.Color?o.events.selectionColor:new i.Color("#ff0000"),p=()=>{a.forEach(d=>{d instanceof i.Mesh&&s.has(d)&&(d.material=s.get(d),s.delete(d))}),a.clear()},x=d=>{R.set(d.clientX,d.clientY)},f=d=>{let b=new i.Vector2(d.clientX,d.clientY);if(R.distanceTo(b)>5)return;let g=e.getBoundingClientRect();c.x=(d.clientX-g.left)/g.width*2-1,c.y=-((d.clientY-g.top)/g.height)*2+1,l.setFromCamera(c,t);let O=l.intersectObjects(n.children,!0);if(O.length>0){let y=O[0].object;if(!a.has(y)){if(p(),a.add(y),y instanceof i.Mesh&&y.material instanceof i.Material){s.set(y,y.material);let S=y.material.clone();S.emissive=u.clone(),y.material=S}_optionalChain([o, 'access', _103 => _103.events, 'optionalAccess', _104 => _104.onObjectSelected, 'optionalCall', _105 => _105(y)]),y instanceof i.Mesh&&Object.keys(y.userData).length>0&&_optionalChain([o, 'access', _106 => _106.events, 'optionalAccess', _107 => _107.onMeshMetadataClicked, 'optionalCall', _108 => _108(y.userData)])}}else p(),_optionalChain([o, 'access', _109 => _109.events, 'optionalAccess', _110 => _110.onBackgroundClicked, 'optionalCall', _111 => _111({x:c.x,y:c.y})])},v=d=>{if(_optionalChain([o, 'access', _112 => _112.events, 'optionalAccess', _113 => _113.enableKeyboardControls]))switch(d.key.toLowerCase()){case"f":d.preventDefault(),h();break;case"escape":d.preventDefault(),p();break;case" ":d.preventDefault(),h();break}};return _optionalChain([o, 'access', _114 => _114.events, 'optionalAccess', _115 => _115.enableClickToFocus])&&(e.addEventListener("mousedown",x),e.addEventListener("click",f)),_optionalChain([o, 'access', _116 => _116.events, 'optionalAccess', _117 => _117.enableKeyboardControls])&&(e.setAttribute("tabindex","0"),e.addEventListener("keydown",v)),{dispose:()=>{e.removeEventListener("mousedown",x),e.removeEventListener("click",f),e.removeEventListener("keydown",v),p()},fitToView:h,clearSelection:p}}function ie(e,n,t){let r=new (0, _OrbitControlsjs.OrbitControls)(e,n),o=t.camera.target;return o&&r.target.set(o.x,o.y,o.z),r.enableDamping=t.controls.enableDamping||!1,r.dampingFactor=t.controls.dampingFactor||.05,r.autoRotate=t.controls.autoRotate||!1,r.autoRotateSpeed=t.controls.autoRotateSpeed||.5,r.enableZoom=t.controls.enableZoom||!0,r.enablePan=t.controls.enablePan||!0,r.minDistance=t.controls.minDistance||.001,r.maxDistance=t.controls.maxDistance||1/0,r.screenSpacePanning=!1,r.maxPolarAngle=Math.PI,r.update(),r}var H={HUGE_THRESHOLD:1e4,LARGE_THRESHOLD:1e3,SCALE_RATIO_THRESHOLD:100,NEAR_PLANE_FACTOR:{TINY:1e-4,SMALL:.001,NORMAL:.01},FAR_PLANE_FACTOR:{HUGE:100,LARGE:50,NORMAL:20},InitialDistanceMultiplier:4};function G(e,n,t,r,o){if(ce(e),n.length===0)return;n.forEach(h=>{e.add(h)});let a=D(n),s=a.getCenter(new T.Vector3),l=a.getSize(new T.Vector3),c=Math.max(l.x,l.y,l.z);if(c/Math.min(l.x||1,l.y||1,l.z||1)>H.SCALE_RATIO_THRESHOLD||c>H.HUGE_THRESHOLD?(t.near=c*H.NEAR_PLANE_FACTOR.TINY,t.far=c*H.FAR_PLANE_FACTOR.HUGE):c>H.LARGE_THRESHOLD?(t.near=c*H.NEAR_PLANE_FACTOR.SMALL,t.far=c*H.FAR_PLANE_FACTOR.LARGE):(t.near=Math.max(.01,c*H.NEAR_PLANE_FACTOR.NORMAL),t.far=Math.max(2e3,c*H.FAR_PLANE_FACTOR.NORMAL)),t.updateProjectionMatrix(),o)r.minDistance=t.near*2,r.maxDistance=t.far*.9;else{let h=c*H.InitialDistanceMultiplier;t.position.set(s.x+h*.8,s.y+h,s.z+h*1.2),r.target.copy(s),r.minDistance=t.near*2,r.maxDistance=t.far*.9,r.update()}}function I(e){if(!e||typeof e!="string")return _chunkPE2FMBXDcjs.i.call(void 0, ).warn(`Invalid color input: ${e}, using white`),new T.Color(16777215);let n=e.trim();if(n.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(n))try{let t=n.startsWith("#")?n:`#${n}`;return new T.Color(t)}catch (e2){return _chunkPE2FMBXDcjs.i.call(void 0, ).warn(`Invalid hex color: ${e}, using white`),new T.Color(16777215)}if(n.includes(",")){let t=n.split(",").map(r=>parseInt(r.trim(),10));if(t.length===3&&t.every(r=>!isNaN(r)&&r>=0&&r<=255))return new T.Color(t[0]/255,t[1]/255,t[2]/255)}try{return new T.Color(n.toLowerCase())}catch (e3){return _chunkPE2FMBXDcjs.i.call(void 0, ).warn(`Invalid color string: ${e}, using white`),new T.Color(16777215)}}function B(e,n){e.forEach(t=>{t.position.y-=n,t.updateMatrix()})}function D(e){let n=new T.Box3;return e.forEach(t=>{t.updateMatrixWorld(!0);let r=new T.Box3().setFromObject(t);n.union(r)}),n}function ce(e){let n=[];e.traverse(t=>{t instanceof T.Mesh&&t.userData.id!=="floor"&&n.push(t)}),n.forEach(t=>{t instanceof T.Mesh&&(_optionalChain([t, 'access', _118 => _118.geometry, 'optionalAccess', _119 => _119.dispose, 'call', _120 => _120()]),(Array.isArray(t.material)?t.material:[t.material]).forEach(o=>{for(let a in o){let s=o[a];s&&s instanceof T.Texture&&s.dispose()}o.dispose()})),t.removeFromParent()})}var F={};_chunkPE2FMBXDcjs.a.call(void 0, F,{CONCRETE_MATERIAL:()=>de,EMISSIVE_MATERIAL:()=>le,GLASS_MATERIAL:()=>me,METAL_MATERIAL:()=>fe,PLASTIC_MATERIAL:()=>he,RUBBER_MATERIAL:()=>Ee,WOOD_MATERIAL:()=>ue});var le=new m.MeshPhysicalMaterial({color:0,emissive:new m.Color(16777215),emissiveIntensity:5,metalness:0,roughness:.2,clearcoat:.3,clearcoatRoughness:.2,depthWrite:!0,depthTest:!0,transparent:!1,alphaTest:0,polygonOffset:!0,side:m.FrontSide,dithering:!0}),fe=new m.MeshPhysicalMaterial({color:new m.Color(0),metalness:.9,roughness:.3,envMapIntensity:1.2,clearcoat:.3,clearcoatRoughness:.2,reflectivity:1,ior:2.5,thickness:1,depthWrite:!0,transparent:!1,alphaTest:0,depthTest:!0,polygonOffset:!0,side:m.FrontSide,dithering:!0}),de=new m.MeshPhysicalMaterial({color:new m.Color(13421772),metalness:0,roughness:.92,envMapIntensity:.15,clearcoat:.05,clearcoatRoughness:.9,reflectivity:.15,transmission:0,ior:1.45,thickness:0,depthWrite:!0,transparent:!1,alphaTest:.5,depthTest:!0,polygonOffset:!0,side:m.FrontSide,dithering:!0}),he=new m.MeshPhysicalMaterial({color:new m.Color(16777215),metalness:0,roughness:.3,envMapIntensity:.5,clearcoat:.5,clearcoatRoughness:.1,reflectivity:.5,ior:1.4,transmission:0,transparent:!1,depthWrite:!0,side:m.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),me=new m.MeshPhysicalMaterial({color:new m.Color(16777215),metalness:0,roughness:0,transmission:.95,transparent:!0,opacity:.3,envMapIntensity:1,clearcoat:1,clearcoatRoughness:0,ior:1.52,reflectivity:.9,thickness:1,side:m.DoubleSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),Ee=new m.MeshPhysicalMaterial({color:new m.Color(1710618),metalness:0,roughness:.9,envMapIntensity:.2,clearcoat:.1,clearcoatRoughness:.8,reflectivity:.2,ior:1.3,transmission:0,depthWrite:!0,side:m.FrontSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),ue=new m.MeshPhysicalMaterial({color:new m.Color(8934707),metalness:0,roughness:.7,envMapIntensity:.3,clearcoat:.3,clearcoatRoughness:.4,reflectivity:.3,ior:1.3,transmission:0,depthWrite:!0,side:m.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1});var _fflate = require('fflate'); var U = _interopRequireWildcard(_fflate);_chunkPE2FMBXDcjs.h.call(void 0, );async function W(e){return new Promise((n,t)=>{try{let r=()=>{try{let o=_chunkQCHPQ22Ycjs.c.call(void 0, e),a=U.gunzipSync(o),s=pe(a);n(s)}catch(o){t(new (0, _chunkPE2FMBXDcjs.e)(o instanceof _chunkPE2FMBXDcjs.e?o.message:`Failed to decompress batched data: ${o instanceof Error?o.message:String(o)}`,o instanceof _chunkPE2FMBXDcjs.e?o.code:_chunkPE2FMBXDcjs.d.VALIDATION_ERROR,{context:{base64StringLength:e.length},originalError:o instanceof Error?o:new Error(String(o))}))}};"requestIdleCallback"in globalThis?globalThis.requestIdleCallback(r,{timeout:5e3}):setTimeout(r,0)}catch(r){t(new (0, _chunkPE2FMBXDcjs.e)(`Failed to schedule decompression: ${r instanceof Error?r.message:String(r)}`,_chunkPE2FMBXDcjs.d.VALIDATION_ERROR,{originalError:r instanceof Error?r:new Error(String(r))}))}})}function pe(e){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),t=0;if(t+4>n.byteLength)throw new (0, _chunkPE2FMBXDcjs.e)("Insufficient data to read the number of vertex floats.",_chunkPE2FMBXDcjs.d.VALIDATION_ERROR,{context:{expectedBytes:4,availableBytes:n.byteLength,offset:t}});let r=n.getUint32(t,!0);if(t+=4,r%3!==0)throw new (0, _chunkPE2FMBXDcjs.e)("Invalid number of vertex floats; should be divisible by 3.",_chunkPE2FMBXDcjs.d.VALIDATION_ERROR,{context:{numVertexFloats:r,remainder:r%3,totalBytes:n.byteLength}});let o=r*Float32Array.BYTES_PER_ELEMENT;if(t+o>n.byteLength)throw new (0, _chunkPE2FMBXDcjs.e)("Insufficient data to read vertices.",_chunkPE2FMBXDcjs.d.VALIDATION_ERROR,{context:{expectedBytes:o,availableBytes:n.byteLength-t,offset:t}});let a=new Float32Array(e.buffer,e.byteOffset+t,r);if(t+=o,t+4>n.byteLength)throw new (0, _chunkPE2FMBXDcjs.e)("Insufficient data to read the number of face indices.",_chunkPE2FMBXDcjs.d.VALIDATION_ERROR,{context:{expectedBytes:4,availableBytes:n.byteLength-t,offset:t}});let s=n.getUint32(t,!0);t+=4;let l=s*Uint32Array.BYTES_PER_ELEMENT;if(t+l>n.byteLength)throw new (0, _chunkPE2FMBXDcjs.e)("Insufficient data to read face indices.",_chunkPE2FMBXDcjs.d.VALIDATION_ERROR,{context:{expectedBytes:l,availableBytes:n.byteLength-t,offset:t}});let c=new Uint32Array(e.buffer,e.byteOffset+t,s);return{vertices:a,faces:c}}async function z(e,n){let{mergeByMaterial:t=!0,applyTransforms:r=!0,debug:o=!1}=_nullishCoalesce(n, () => ({})),a=o?performance.now():0,s=0;try{let l=performance.now(),c=JSON.parse(e);return s=performance.now()-l,await P(c,{mergeByMaterial:t,applyTransforms:r,debug:o,parseTime:s,perfStart:a})}catch(l){return _chunkPE2FMBXDcjs.i.call(void 0, ).error("Error parsing mesh batch:",l),[]}}async function P(e,n){let{mergeByMaterial:t=!0,applyTransforms:r=!0,scaleFactor:o=1,debug:a=!1,parseTime:s=0,perfStart:l=a?performance.now():0}=_nullishCoalesce(n, () => ({})),c=0,R=0;try{let h=performance.now(),{vertices:u,faces:p}=await W(e.compressedData);c=performance.now()-h;let x=(e.compressedData.length*.75/1024/1024).toFixed(2),f=((u.byteLength+p.byteLength)/1024/1024).toFixed(2),v=((1-parseFloat(x)/parseFloat(f))*100).toFixed(1);a&&(_chunkPE2FMBXDcjs.i.call(void 0, ).debug("Mesh Batch Stats:"),_chunkPE2FMBXDcjs.i.call(void 0, ).debug(` Materials: ${e.materials.length} | Groups: ${e.groups.length}`),_chunkPE2FMBXDcjs.i.call(void 0, ).debug(` Vertices: ${(u.length/3).toLocaleString()} | Faces: ${(p.length/3).toLocaleString()}`),_chunkPE2FMBXDcjs.i.call(void 0, ).debug(` Compressed: ${x} MB | Uncompressed: ${f} MB`),_chunkPE2FMBXDcjs.i.call(void 0, ).debug(` Compression Ratio: ${v}%`)),r&&we(u);let A=performance.now(),d=e.materials.map(ge),b=[];for(let g of e.groups)if(t&&g.meshes.length>1){let O=Re(g,u,p,d);b.push(O)}else{let O=Te(g,u,p,d);b.push(...O)}if(o!==1)for(let g of b)g.scale.set(o,o,o);if(R=performance.now()-A,a){let g=performance.now()-l;_chunkPE2FMBXDcjs.i.call(void 0, ).debug("Performance:"),s>0&&_chunkPE2FMBXDcjs.i.call(void 0, ).debug(` Parse JSON: ${s.toFixed(2)}ms`),_chunkPE2FMBXDcjs.i.call(void 0, ).debug(` Decompress: ${c.toFixed(2)}ms`),_chunkPE2FMBXDcjs.i.call(void 0, ).debug(` Create Meshes: ${R.toFixed(2)}ms`),_chunkPE2FMBXDcjs.i.call(void 0, ).debug(` Total: ${g.toFixed(2)}ms`)}return b}catch(h){return _chunkPE2FMBXDcjs.i.call(void 0, ).error("Error parsing mesh batch object:",h),[]}}function ge(e){let n=I(e.color);return new w.MeshPhysicalMaterial({color:n,metalness:e.metalness,roughness:e.roughness,opacity:e.opacity,transparent:e.transparent,side:w.DoubleSide,polygonOffset:!0,polygonOffsetFactor:.5,polygonOffsetUnits:.5,depthWrite:!0,depthTest:!0})}function Re(e,n,t,r){let o=new w.BufferGeometry,a=0,s=0;for(let f of e.meshes)a+=f.vertexCount,s+=f.faceCount;let l=new Float32Array(a),c=new Uint32Array(s),R=0,h=0;for(let f of e.meshes){l.set(n.subarray(f.vertexOffset,f.vertexOffset+f.vertexCount),R);let v=t.subarray(f.faceOffset,f.faceOffset+f.faceCount),A=Math.floor(f.vertexOffset/3),b=Math.floor(R/3)-A;for(let g=0;g<v.length;g++)c[h+g]=v[g]+b;R+=f.vertexCount,h+=f.faceCount}o.setAttribute("position",new w.BufferAttribute(l,3)),o.setIndex(new w.BufferAttribute(c,1)),o.computeVertexNormals();let u=new w.Mesh(o,r[e.materialId]),p=e.meshes.map(f=>f.name).filter(f=>f&&f.length>0);u.name=p.length>0?p[0]:`merged_material_${e.materialId}`,u.castShadow=!0,u.receiveShadow=!0;let x=e.meshes.map(f=>f.metadata).filter(f=>f);return x.length>0&&(u.userData.mergedMetadata=x),u}function Te(e,n,t,r){let o=[];for(let a of e.meshes){let s=new w.BufferGeometry,l=n.subarray(a.vertexOffset,a.vertexOffset+a.vertexCount),c=t.subarray(a.faceOffset,a.faceOffset+a.faceCount),R=Math.floor(a.vertexOffset/3),h=new Uint32Array(c.length);for(let p=0;p<c.length;p++)h[p]=c[p]-R;s.setAttribute("position",new w.BufferAttribute(l,3)),s.setIndex(new w.BufferAttribute(h,1)),s.computeVertexNormals();let u=new w.Mesh(s,r[e.materialId]);u.name=a.name,a.metadata&&(u.userData={...u.userData,...a.metadata}),u.castShadow=!0,u.receiveShadow=!0,o.push(u)}return o}function we(e){let n=Math.cos(-Math.PI/2),t=Math.sin(-Math.PI/2);for(let r=0;r<e.length;r+=3){let o=e[r],a=e[r+1],s=e[r+2];e[r]=o,e[r+1]=a*n-s*t,e[r+2]=a*t+s*n}}var _={Millimeters:1/1e3,Centimeters:1/100,Meters:1,Inches:1/39.37,Feet:1/3.28084},ye="Display";async function $(e,n){let t=performance.now(),r=[],{allowScaling:o=!0,allowAutoPosition:a=!0,debug:s=!1,parsing:l={}}=_nullishCoalesce(n, () => ({}));try{let c=o?be(e.modelunits):1;return await Me(e,r,c,l,s),a&&xe(r),r}catch(c){throw ve(c,r),c}finally{s&&Ce(t)}}function be(e){return _nullishCoalesce(_[e], () => (1))}async function Me(e,n,t,r,o){for(let a of e.values){let s=a.InnerTree;for(let l in s){let c=s[l];c&&await He(c,n,t,r,o)}}}async function He(e,n,t,r,o){for(let a of e)if(a.type.includes(ye)){let s={mergeByMaterial:!0,applyTransforms:!0,debug:!1,...r},l=await z(a.data,s);if(t!==1)for(let c of l)c.scale.set(t,t,t);n.push(...l),o&&_chunkPE2FMBXDcjs.i.call(void 0, ).debug(`Extracted ${l.length} meshes from batch`)}}function xe(e){if(e.length===0)return;let t=D(e).min.y;B(e,t)}function ve(e,n){_chunkPE2FMBXDcjs.i.call(void 0, ).error("An unexpected error occurred:",e),Oe(n)}function Oe(e){for(let n of e)n.geometry&&n.geometry.dispose(),n.material&&(Array.isArray(n.material)?n.material.forEach(t=>t.dispose()):n.material.dispose())}function Ce(e){let n=performance.now()-e;_chunkPE2FMBXDcjs.i.call(void 0, ).info("Time to process meshes:",`${n.toFixed(2)}ms`)}exports.Materials = F; exports.SCALE_FACTORS = _; exports.getThreeMeshesFromComputeResponse = $; exports.initThree = k; exports.parseMeshBatchObject = P; exports.updateScene = G;
2
2
  //# sourceMappingURL=visualization.cjs.map
@@ -1,6 +1,6 @@
1
1
  import * as THREE from 'three';
2
2
  import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
3
- import { c as GrasshopperComputeResponse } from './schemas-CQEJ5EZy.cjs';
3
+ import { c as GrasshopperComputeResponse } from './schemas-BE5ai7jG.cjs';
4
4
  import { M as MeshExtractionOptions, a as MeshBatch } from './types-r00wVwfo.cjs';
5
5
  export { D as DecompressedMeshData, d as MaterialGroup, b as MeshBatchParsingOptions, c as MeshMetadata, S as SerializableMaterial } from './types-r00wVwfo.cjs';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import * as THREE from 'three';
2
2
  import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
3
- import { c as GrasshopperComputeResponse } from './schemas-CQEJ5EZy.js';
3
+ import { c as GrasshopperComputeResponse } from './schemas-BE5ai7jG.js';
4
4
  import { M as MeshExtractionOptions, a as MeshBatch } from './types-r00wVwfo.js';
5
5
  export { D as DecompressedMeshData, d as MaterialGroup, b as MeshBatchParsingOptions, c as MeshMetadata, S as SerializableMaterial } from './types-r00wVwfo.js';
6
6