@selvajs/compute 3.1.0-beta.6 → 3.1.0-beta.8
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.
- package/dist/chunk-CUQQ3ZBV.cjs.map +1 -1
- package/dist/chunk-GFY3L653.cjs +62 -0
- package/dist/chunk-GFY3L653.cjs.map +1 -0
- package/dist/chunk-MJOXUCDH.js +62 -0
- package/dist/chunk-MJOXUCDH.js.map +1 -0
- package/dist/{chunk-Y5E6RIEH.cjs → chunk-WWD655BZ.cjs} +2 -2
- package/dist/chunk-WWD655BZ.cjs.map +1 -0
- package/dist/{chunk-JNFNLKFO.js → chunk-YREXY7GT.js} +2 -2
- package/dist/core.cjs.map +1 -1
- package/dist/grasshopper.cjs +1 -1
- package/dist/grasshopper.cjs.map +1 -1
- package/dist/grasshopper.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/visualization-4PVR5P7N.js +2 -0
- package/dist/visualization-LS3Z7Q3N.cjs +2 -0
- package/dist/visualization-LS3Z7Q3N.cjs.map +1 -0
- package/dist/visualization.cjs +1 -1
- package/dist/visualization.cjs.map +1 -1
- package/dist/visualization.d.cts +9 -2
- package/dist/visualization.d.ts +9 -2
- package/dist/visualization.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-727SRM4E.cjs +0 -62
- package/dist/chunk-727SRM4E.cjs.map +0 -1
- package/dist/chunk-CWODTGNH.js +0 -62
- package/dist/chunk-CWODTGNH.js.map +0 -1
- package/dist/chunk-Y5E6RIEH.cjs.map +0 -1
- package/dist/visualization-36IV2CVU.cjs +0 -2
- package/dist/visualization-36IV2CVU.cjs.map +0 -1
- package/dist/visualization-QCI36RHC.js +0 -2
- /package/dist/{chunk-JNFNLKFO.js.map → chunk-YREXY7GT.js.map} +0 -0
- /package/dist/{visualization-QCI36RHC.js.map → visualization-4PVR5P7N.js.map} +0 -0
|
@@ -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 _chunkCUQQ3ZBVcjs = require('./chunk-CUQQ3ZBV.cjs');var ne=new Set;function Me(){if(typeof window>"u"||_optionalChain([globalThis, 'access', _2 => _2.process, 'optionalAccess', _3 => _3.versions, 'optionalAccess', _4 => _4.node])!=null)return!1;let e=globalThis.navigator,r=typeof _optionalChain([e, 'optionalAccess', _5 => _5.userAgent])=="string"?e.userAgent:"";return!/jsdom/i.test(r)}function D(t,e){e||Me()&&!ne.has(t)&&(ne.add(t),_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Warning: ${t} is running on the client side. For better performance and security, consider running this on the server side.`))}function T(t){return typeof t=="object"&&!(t instanceof Uint8Array)&&typeof t.key=="string"&&typeof t.load=="function"}var Ge="Unable to load grasshopper definition";function Ve(t){return t instanceof _chunkCUQQ3ZBVcjs.d?t.code===_chunkCUQQ3ZBVcjs.c.DEFINITION_NOT_CACHED||t.message.includes(Ge):!1}function Le(t,e){if(!e)return;let r=_chunkCUQQ3ZBVcjs.q.call(void 0, t,"values");if(!Array.isArray(r)||r.length===0)return;let n=[];for(let s of r){let i=_chunkCUQQ3ZBVcjs.q.call(void 0, s,"innerTree");(!i||Object.keys(i).length===0)&&n.push(_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, s,"paramName"), () => ("<unnamed>")))}if(n.length===0)return;let o=n.length===r.length?"all":`${n.length}/${r.length}`;_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Solve returned empty output(s) (${o}): ${n.join(", ")}. These parameters produced no data \u2014 check the definition's inputs and the branch feeding each.`)}async function E(t,e,r){D("solveGrasshopperDefinition",_nullishCoalesce(r.suppressBrowserWarning, () => (r.suppressClientSideWarning)));let n=await B(e),{response:o}=await N(v(n,t),r);return o}async function oe(t,e,r){D("solveGrasshopperDefinitionWithCacheKey",_nullishCoalesce(r.suppressBrowserWarning, () => (r.suppressClientSideWarning)));let n=await B(e);return N(v(n,t),r)}async function se(t,e,r,n){D("solveByCacheKey",_nullishCoalesce(n.suppressBrowserWarning, () => (n.suppressClientSideWarning)));let o={algo:null,pointer:e,values:t};try{return{...await N(o,n),missed:!1}}catch(s){if(!Ve(s))throw s;let i=await B(r);return{...await N(v(i,t),n),missed:!0}}}async function B(t){if(!T(t))return t;try{return await t.load()}catch(e){throw new (0, _chunkCUQQ3ZBVcjs.d)(`Failed to load definition bytes for ref '${t.key}'`,_chunkCUQQ3ZBVcjs.c.INVALID_INPUT,{context:{definitionKey:t.key},originalError:e instanceof Error?e:new Error(String(e))})}}async function N(t,e){We(t,e);let r=await _chunkCUQQ3ZBVcjs.l.call(void 0, "grasshopper",t,e),{pointer:n,algo:o,...s}=r,i=s;return Le(i,e.debug),{response:i,cacheKey:typeof n=="string"?n:null}}function v(t,e){let r={algo:null,pointer:null,values:e};return t instanceof Uint8Array?r.algo=_chunkCUQQ3ZBVcjs.k.call(void 0, t):/^https?:\/\//i.test(t)?r.pointer=t:r.algo=_nullishCoalesce(_chunkCUQQ3ZBVcjs.i.call(void 0, t), () => (_chunkCUQQ3ZBVcjs.h.call(void 0, t))),r}function We(t,e){e.cachesolve!=null&&(t.cachesolve=e.cachesolve),e.cacheerroredsolves!=null&&(t.cacheerroredsolves=e.cacheerroredsolves),e.modelunits!=null&&(t.modelunits=e.modelunits),e.angletolerance!=null&&(t.angletolerance=e.angletolerance),e.absolutetolerance!=null&&(t.absolutetolerance=e.absolutetolerance),e.dataversion!=null&&(t.dataversion=e.dataversion)}function $(t){let e=new WeakSet,r=n=>{if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="number")return Number.isFinite(n)?String(n):"null";if(typeof n=="string"||typeof n=="boolean")return JSON.stringify(n);if(typeof n=="bigint")return`${n}n`;if(n instanceof Uint8Array)return`{"__u8":${n.length},"hash":"${ue(n)}"}`;if(Array.isArray(n)){if(e.has(n))return'"[Circular]"';e.add(n);let o=[];for(let s=0;s<n.length;s++)o.push(r(n[s]));return e.delete(n),`[${o.join(",")}]`}if(typeof n=="object"){if(e.has(n))return'"[Circular]"';e.add(n);let o;return typeof n.toJSON=="function"?o=r(n.toJSON()):n instanceof Map?o=`{"__map":[${[...n.entries()].map(([i,a])=>`[${r(i)},${r(a)}]`).sort().join(",")}]}`:n instanceof Set?o=`{"__set":[${[...n.values()].map(r).sort().join(",")}]}`:o=`{${Object.keys(n).sort().map(a=>`${JSON.stringify(a)}:${r(n[a])}`).join(",")}}`,e.delete(n),o}return"null"};return r(t)}function ie(t,e){let r=2166136261;for(let n=0;n<t;n++)r^=e(n),r=r+((r<<1)+(r<<4)+(r<<7)+(r<<8)+(r<<24))>>>0;return r.toString(16).padStart(8,"0")}function ae(t){return ie(t.length,e=>t.charCodeAt(e))}function ue(t){return ie(t.length,e=>t[e])}function pe(t,e){return q(R(t),e)}function q(t,e){let r=$(e);return`${t}|t:${r.length}:${ae(r)}`}function R(t){return T(t)?`r:${t.key}`:typeof t=="string"?`s:${t.length}:${ae(t)}`:`u8:${t.length}:${ue(t)}`}var je=100;function Be(t){return typeof t!="string"?!0:!/^https?:\/\//i.test(t)}var I=class{constructor(e,r,n={},o){_chunkCUQQ3ZBVcjs.b.call(void 0, this,"executor");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"baseConfig");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"mode");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"maxConcurrent");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"maxQueueDepth");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"queueWaitMs");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"timeoutMs");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"retry");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"cacheEnabled");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"cacheMax");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"cacheTtl");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"cacheErroredSolves");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"cache",new Map);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"cacheKeyExecutor");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"reuseServerDefinitionCache");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"serverCacheKeys",new Map);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"onStart");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"onSettle");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"onSuperseded");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"subscribers",new Set);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"inFlight",new Set);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"pendingForLatestWins",null);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"fifoQueue",[]);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"_lastResult",null);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"_lastError",null);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"_lastDurationMs",null);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"solveSeq",0);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"lastStateSeq",0);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"disposed",!1);this.executor=e,this.cacheKeyExecutor=o,this.baseConfig=r,this.mode=_nullishCoalesce(n.mode, () => ("latest-wins")),this.maxConcurrent=Math.max(1,_nullishCoalesce(n.maxConcurrent, () => ((this.mode==="parallel"?4:1)))),this.maxQueueDepth=n.maxQueueDepth!==void 0&&n.maxQueueDepth>0?Math.floor(n.maxQueueDepth):void 0,this.queueWaitMs=n.queueWaitMs!==void 0&&n.queueWaitMs>0?n.queueWaitMs:void 0,this.timeoutMs=n.timeoutMs,this.retry=n.retry;let s=n.cache;this.cacheEnabled=s!==void 0&&s!==!1;let i=typeof s=="object"?s:{};this.cacheMax=_nullishCoalesce(i.maxEntries, () => (50)),this.cacheTtl=_nullishCoalesce(i.ttlMs, () => (0)),this.cacheErroredSolves=_nullishCoalesce(i.cacheErroredSolves, () => (!0)),this.reuseServerDefinitionCache=!!o&&(_nullishCoalesce(n.reuseServerDefinitionCache, () => (!0))),this.onStart=n.onStart,this.onSettle=n.onSettle,this.onSuperseded=n.onSuperseded}get isSolving(){return this.inFlight.size>0}get hasPending(){return this.pendingForLatestWins!==null||this.fifoQueue.length>0}get inFlightCount(){return this.inFlight.size}get queueDepth(){return this.fifoQueue.length+(this.pendingForLatestWins?1:0)}get lastResult(){return this._lastResult}get lastError(){return this._lastError}get lastDurationMs(){return this._lastDurationMs}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}notify(){for(let e of this.subscribers)try{e()}catch(r){_chunkCUQQ3ZBVcjs.e.call(void 0, ).error("[SolveScheduler] subscriber threw:",r)}}solve(e,r,n){if(this.disposed)return Promise.reject(new (0, _chunkCUQQ3ZBVcjs.d)("SolveScheduler has been disposed and cannot be used",_chunkCUQQ3ZBVcjs.c.INVALID_STATE));let o=R(e),s=q(o,r),i=++this.solveSeq,a={key:s,enqueuedAt:Date.now(),startedAt:null};if(_optionalChain([n, 'optionalAccess', _6 => _6.signal, 'optionalAccess', _7 => _7.aborted]))return Promise.reject(this.makeAbortError(a));if(this.cacheEnabled){let u=this.readCache(s);if(u){this.mode==="latest-wins"&&this.supersedeCurrent();let d={status:"success",response:u,durationMs:0,fromCache:!0};return this.writeLastState(i,{result:u,durationMs:0}),this.runHook(this.onStart,a),this.runHook(this.onSettle,a,d),this.notify(),Promise.resolve(u)}}return new Promise((u,d)=>{let f={definition:e,dataTree:r,definitionHash:o,ctx:a,seq:i,resolve:u,reject:d,externalSignal:_optionalChain([n, 'optionalAccess', _8 => _8.signal])};f.externalSignal&&(f.queuedAbortHandler=()=>this.abortQueuedItem(f),f.externalSignal.addEventListener("abort",f.queuedAbortHandler,{once:!0})),this.enqueue(f)})}writeLastState(e,r){return e<this.lastStateSeq?!1:(this.lastStateSeq=e,"result"in r?(this._lastResult=r.result,this._lastError=null):this._lastError=r.error,this._lastDurationMs=r.durationMs,!0)}supersedeCurrent(){this.pendingForLatestWins&&(this.supersede(this.pendingForLatestWins),this.pendingForLatestWins=null);for(let e of this.inFlight)this.supersede(e),e.controller.abort()}abortQueuedItem(e){this.pendingForLatestWins===e&&(this.pendingForLatestWins=null);let r=this.fifoQueue.indexOf(e);r>=0&&this.fifoQueue.splice(r,1),this.rejectAsAborted(e),this.notify()}shedAsQueueFull(e){let r=new (0, _chunkCUQQ3ZBVcjs.d)("Solve queue is full; request shed (backpressure)",_chunkCUQQ3ZBVcjs.c.QUEUE_FULL,{statusCode:503,context:{key:e.ctx.key,queueDepth:this.fifoQueue.length,maxQueueDepth:this.maxQueueDepth}});this.settleError(e,r)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:r,durationMs:0}),this.notify()}armQueueWaitTimer(e){if(this.queueWaitMs===void 0)return;let r=this.queueWaitMs;e.queueWaitTimer=setTimeout(()=>{if(e.settled)return;let n=this.fifoQueue.indexOf(e);n>=0&&this.fifoQueue.splice(n,1);let o=new (0, _chunkCUQQ3ZBVcjs.d)(`Solve waited longer than ${r}ms in queue; shed (backpressure)`,_chunkCUQQ3ZBVcjs.c.QUEUE_TIMEOUT,{statusCode:503,context:{key:e.ctx.key,waitedMs:Date.now()-e.ctx.enqueuedAt,queueWaitMs:r}});this.settleError(e,o)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:o,durationMs:0}),this.notify()},r)}clearQueueWaitTimer(e){e.queueWaitTimer!==void 0&&(clearTimeout(e.queueWaitTimer),e.queueWaitTimer=void 0)}enqueue(e){switch(this.mode){case"latest-wins":{this.supersedeCurrent(),this.inFlight.size===0?this.execute(e):this.pendingForLatestWins=e;break}case"queue":case"parallel":{this.inFlight.size<this.maxConcurrent?this.execute(e):this.maxQueueDepth!==void 0&&this.fifoQueue.length>=this.maxQueueDepth?this.shedAsQueueFull(e):(this.armQueueWaitTimer(e),this.fifoQueue.push(e));break}}this.notify()}async execute(e){let r=new AbortController,n=e;n.controller=r,this.inFlight.add(n),e.ctx.startedAt=Date.now(),this.clearQueueWaitTimer(e),this.removeQueuedAbortHandler(e);let o=()=>r.abort();_optionalChain([e, 'access', _9 => _9.externalSignal, 'optionalAccess', _10 => _10.addEventListener, 'call', _11 => _11("abort",o,{once:!0})]),this.runHook(this.onStart,e.ctx),this.notify();let s=performance.now();try{let i={...this.baseConfig,signal:r.signal,...this.timeoutMs!==void 0&&{timeoutMs:this.timeoutMs},...this.retry!==void 0&&{retry:this.retry}},{response:a,definitionReuploaded:u}=await this.runExecutor(e.definition,e.dataTree,e.definitionHash,i),d=performance.now()-s;if(this.cacheEnabled&&this.writeCache(e.ctx.key,a),!this.settleSuccess(e,a))return;this.writeLastState(e.seq,{result:a,durationMs:d}),this.runHook(this.onSettle,e.ctx,{status:"success",response:a,durationMs:d,fromCache:!1,definitionReuploaded:u})}catch(i){let a=performance.now()-s,u=this.normalizeExecutionError(i,n);this.writeLastState(e.seq,{error:u,durationMs:a}),this.settleError(e,u)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:u,durationMs:a})}finally{_optionalChain([e, 'access', _12 => _12.externalSignal, 'optionalAccess', _13 => _13.removeEventListener, 'call', _14 => _14("abort",o)]),this.inFlight.delete(n),this.drainNext(),this.notify()}}async runExecutor(e,r,n,o){if(!this.cacheKeyExecutor||!this.reuseServerDefinitionCache||!Be(e))return{response:await this.executor(e,r,o)};let s=n,i=_nullishCoalesce(this.serverCacheKeys.get(s), () => (null)),a=await this.cacheKeyExecutor(e,r,i,o);if(a.cacheKey)for(this.serverCacheKeys.delete(s),this.serverCacheKeys.set(s,a.cacheKey);this.serverCacheKeys.size>je;){let u=this.serverCacheKeys.keys().next().value;if(u===void 0)break;this.serverCacheKeys.delete(u)}else this.serverCacheKeys.delete(s);return{response:a.response,definitionReuploaded:a.missed}}drainNext(){if(!this.disposed){if(this.mode==="latest-wins"){if(this.pendingForLatestWins&&this.inFlight.size===0){let e=this.pendingForLatestWins;this.pendingForLatestWins=null,this.execute(e)}return}for(;this.fifoQueue.length>0&&this.inFlight.size<this.maxConcurrent;){let e=this.fifoQueue.shift();this.execute(e)}}}supersede(e){let r=new (0, _chunkCUQQ3ZBVcjs.d)("Superseded by newer solve",_chunkCUQQ3ZBVcjs.c.SUPERSEDED,{context:{key:e.ctx.key,enqueuedAt:e.ctx.enqueuedAt}});this.settleError(e,r)&&this.runHook(this.onSuperseded,e.ctx)}makeAbortError(e){return new (0, _chunkCUQQ3ZBVcjs.d)("Request aborted by caller",_chunkCUQQ3ZBVcjs.c.ABORTED,{context:{key:e.key,enqueuedAt:e.enqueuedAt}})}settleError(e,r){return e.settled?!1:(e.settled={error:r},this.clearQueueWaitTimer(e),this.removeQueuedAbortHandler(e),e.reject(r),!0)}settleSuccess(e,r){return e.settled?!1:(e.settled={ok:!0},this.clearQueueWaitTimer(e),this.removeQueuedAbortHandler(e),e.resolve(r),!0)}removeQueuedAbortHandler(e){e.queuedAbortHandler&&e.externalSignal&&e.externalSignal.removeEventListener("abort",e.queuedAbortHandler),e.queuedAbortHandler=void 0}isAbortLikeError(e){if(e instanceof Error){if(e.name==="AbortError")return!0;if(typeof DOMException<"u"&&e instanceof DOMException)return e.name==="AbortError"}return!1}normalizeExecutionError(e,r){return r.settled&&"error"in r.settled?r.settled.error:e instanceof _chunkCUQQ3ZBVcjs.d?e:this.isAbortLikeError(e)?this.makeAbortError(r.ctx):new (0, _chunkCUQQ3ZBVcjs.d)(e instanceof Error?e.message:String(e),_chunkCUQQ3ZBVcjs.c.UNKNOWN_ERROR,{originalError:e instanceof Error?e:new Error(String(e))})}cancelAll(){for(this.pendingForLatestWins&&(this.rejectAsAborted(this.pendingForLatestWins),this.pendingForLatestWins=null);this.fifoQueue.length>0;){let e=this.fifoQueue.shift();this.rejectAsAborted(e)}for(let e of this.inFlight){let r=this.makeAbortError(e.ctx);this.settleError(e,r)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:r,durationMs:e.ctx.startedAt?Date.now()-e.ctx.startedAt:0}),e.controller.abort()}this.notify()}rejectAsAborted(e){let r=this.makeAbortError(e.ctx);this.settleError(e,r)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:r,durationMs:0})}readCache(e){if(!this.cacheEnabled)return null;let r=this.cache.get(e);return r?this.cacheTtl>0&&Date.now()-r.insertedAt>this.cacheTtl?(this.cache.delete(e),null):(this.cache.delete(e),this.cache.set(e,r),r.response):null}writeCache(e,r){if(this.cacheEnabled&&!(!this.cacheErroredSolves&&r.errors&&r.errors.length>0))for(this.cache.set(e,{response:r,insertedAt:Date.now()});this.cache.size>this.cacheMax;){let n=this.cache.keys().next().value;if(n===void 0)break;this.cache.delete(n)}}clearCache(){this.cache.clear()}dispose(){this.disposed||(this.disposed=!0,this.cancelAll(),this.subscribers.clear(),this.cache.clear())}runHook(e,...r){if(e)try{e(...r)}catch(n){_chunkCUQQ3ZBVcjs.e.call(void 0, ).error("[SolveScheduler] hook threw:",n)}}};function le(t){return T(t)?`ref:${t.key}`:typeof t=="string"&&t.length<200?t:"...content..."}function ce(t){return Array.isArray(t)?t.map(e=>{let r=0,n=0,o=_chunkCUQQ3ZBVcjs.q.call(void 0, e,"innerTree");if(o&&typeof o=="object"){for(let s of Object.values(o))if(Array.isArray(s)){r+=s.length;for(let i of s){let a=_optionalChain([i, 'optionalAccess', _15 => _15.data]);typeof a=="string"&&(n+=a.length)}}}return{param:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, e,"paramName"), () => ("<unnamed>")),items:r,bytes:n}}):[]}var A=class t{constructor(e){_chunkCUQQ3ZBVcjs.b.call(void 0, this,"config");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"serverStats");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"disposed",!1);this.config=this.normalizeComputeConfig(e),this.serverStats=new (0, _chunkCUQQ3ZBVcjs.n)(this.config.serverUrl,this.config.apiKey)}static async create(e){let r=new t(e),n=Math.max(1,(_nullishCoalesce(_optionalChain([e, 'access', _16 => _16.retry, 'optionalAccess', _17 => _17.attempts]), () => (2)))+1),o=_nullishCoalesce(_optionalChain([e, 'access', _18 => _18.retry, 'optionalAccess', _19 => _19.baseDelayMs]), () => (250)),s=_nullishCoalesce(_optionalChain([e, 'access', _20 => _20.retry, 'optionalAccess', _21 => _21.maxDelayMs]), () => (1e3));for(let i=0;i<n;i++){if(await r.serverStats.isServerOnline())return r;if(i<n-1){let a=Math.min(o*2**i,s);await new Promise(u=>setTimeout(u,a))}}throw await r.dispose(),new (0, _chunkCUQQ3ZBVcjs.d)("Rhino Compute server is not online",_chunkCUQQ3ZBVcjs.c.NETWORK_ERROR,{context:{serverUrl:r.config.serverUrl,attempts:n}})}getConfig(){return this.ensureNotDisposed(),{...this.config}}async getIO(e){return this.ensureNotDisposed(),M(e,this.config)}async getRawIO(e){return this.ensureNotDisposed(),P(e,this.config)}async solve(e,r,n){this.ensureNotDisposed();try{if(typeof e=="string"&&!_optionalChain([e, 'optionalAccess', _22 => _22.trim, 'call', _23 => _23()]))throw new (0, _chunkCUQQ3ZBVcjs.d)("Definition URL/content is required",_chunkCUQQ3ZBVcjs.c.INVALID_INPUT,{context:{receivedUrl:e}});if(e instanceof Uint8Array&&e.length===0)throw new (0, _chunkCUQQ3ZBVcjs.d)("Definition content is empty",_chunkCUQQ3ZBVcjs.c.INVALID_INPUT);if(T(e)&&!e.key.trim())throw new (0, _chunkCUQQ3ZBVcjs.d)("DefinitionRef key is empty",_chunkCUQQ3ZBVcjs.c.INVALID_INPUT);let o={...this.config,..._optionalChain([n, 'optionalAccess', _24 => _24.signal])!==void 0&&{signal:n.signal},..._optionalChain([n, 'optionalAccess', _25 => _25.timeoutMs])!==void 0&&{timeoutMs:n.timeoutMs},..._optionalChain([n, 'optionalAccess', _26 => _26.retry])!==void 0&&{retry:n.retry}},s=await E(r,e,o);if(_optionalChain([s, 'optionalAccess', _27 => _27.errors])&&s.errors.length>0)throw new (0, _chunkCUQQ3ZBVcjs.d)(s.errors.join("; ")||"Computation failed",_chunkCUQQ3ZBVcjs.c.COMPUTATION_ERROR,{context:{definition:le(e),inputSummary:ce(r),errors:s.errors,warnings:s.warnings,values:s.values}});return s}catch(o){throw this.config.debug&&_chunkCUQQ3ZBVcjs.e.call(void 0, ).error("Compute failed:",o),o instanceof _chunkCUQQ3ZBVcjs.d?o:new (0, _chunkCUQQ3ZBVcjs.d)(o instanceof Error?o.message:String(o),_chunkCUQQ3ZBVcjs.c.COMPUTATION_ERROR,{context:{definition:le(e),inputSummary:ce(r)},originalError:o instanceof Error?o:new Error(String(o))})}}createScheduler(e){this.ensureNotDisposed();let r=(o,s,i)=>E(s,o,i),n=(o,s,i,a)=>i===null?oe(s,o,a).then(u=>({...u,missed:!1})):se(s,i,o,a);return new I(r,this.config,e,n)}async dispose(){this.disposed||(this.disposed=!0,await this.serverStats.dispose())}ensureNotDisposed(){if(this.disposed)throw new (0, _chunkCUQQ3ZBVcjs.d)("GrasshopperClient has been disposed and cannot be used",_chunkCUQQ3ZBVcjs.c.INVALID_STATE)}normalizeComputeConfig(e){return{...e,serverUrl:_chunkCUQQ3ZBVcjs.m.call(void 0, e.serverUrl),apiKey:e.apiKey,authToken:e.authToken,debug:_nullishCoalesce(e.debug, () => (!1)),suppressBrowserWarning:_nullishCoalesce(e.suppressBrowserWarning, () => (e.suppressClientSideWarning))}}};var G=new Map;function de(t,e){G.set(t,e)}de("Rhino.Geometry.Point3d",(t,e)=>{let r=e;return!r||typeof r.X!="number"?null:new t.Point([r.X,r.Y,r.Z])});de("Rhino.Geometry.Line",(t,e)=>{let r=e;return!r||!r.From||!r.To?null:new t.Line([r.From.X,r.From.Y,r.From.Z],[r.To.X,r.To.Y,r.To.Z])});function $e(t){if(G.has(t))return G.get(t);for(let[e,r]of G)if(t.startsWith(e))return r}function qe(t){return!!(t&&typeof t=="object"&&typeof t.data=="string")}function fe(t,e){return{__decodeError:!0,type:t,raw:e}}function me(t,e,r){let n=$e(e),o=!1;if(n)try{let s=n(r,t);if(s!=null)return s}catch(s){_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Failed to decode Rhino type ${e}:`,s),o=!0}try{if(qe(t))return r.CommonObject.decode(t)}catch(s){return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Failed to decode ${e} with CommonObject:`,s),fe(e,t)}return o?fe(e,t):t}function he(t){let e=new WeakSet,r=n=>{if(!n||typeof n!="object"||e.has(n))return;e.add(n);let o=n.delete;if(typeof o=="function"){let i=n.isDeleted;(typeof i!="function"||!i.call(n))&&o.call(n);return}if(Array.isArray(n)){for(let i of n)r(i);return}let s=Object.getPrototypeOf(n);if(s===Object.prototype||s===null)for(let i of Object.values(n))r(i)};r(t)}var x={STRING:"System.String",INT:"System.Int32",DOUBLE:"System.Double",BOOL:"System.Boolean"},Ue="Rhino.Geometry.",ze=["WebDisplay"],_e="FileData";function ye(t){return ze.some(e=>t.includes(e))}function Ke(t){if(typeof t!="string")return t;let e=t.trim();if(!(e.startsWith("{")||e.startsWith("[")||e.startsWith('"')))return t;try{let n=JSON.parse(e);if(typeof n=="string")try{return JSON.parse(n)}catch (e2){return n}return n}catch (e3){return t}}function Qe(t,e,r){switch(e){case x.STRING:return typeof t!="string"?t:t.replace(/^"(.*)"$/,"$1");case x.INT:return Number.parseInt(t,10);case x.DOUBLE:return Number.parseFloat(t);case x.BOOL:return String(t).toLowerCase()==="true";default:return r&&e.startsWith(Ue)?me(t,e,r):t}}var U=new WeakMap;function ge(t){if(U.has(t))return U.get(t);let e=Ke(t.data);return U.set(t,e),e}function be(t,e,r,n){if(typeof t.data!="string")return t.data;let o=r?ge(t):t.data;return Qe(o,e,n)}function He(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.fileName=="string"&&typeof e.fileType=="string"&&"data"in e&&typeof e.isBase64Encoded=="boolean"&&typeof e.subFolder=="string"}function z(t){let e=_chunkCUQQ3ZBVcjs.q.call(void 0, t,"values");return Array.isArray(e)?e:[]}function _(t){return typeof t.type=="string"?t.type:""}function K(t,e){if(!(!t||typeof t!="object")){for(let r of Object.values(t))if(Array.isArray(r))for(let n of r)n&&typeof n=="object"&&e(n)}}function Te(t,e=!1,r={}){let{parseValues:n=!0,rhino:o,stringOnly:s=!1}=r,i={},a=new Set;for(let u of z(t)){let d=_chunkCUQQ3ZBVcjs.q.call(void 0, u,"paramName");K(_chunkCUQQ3ZBVcjs.q.call(void 0, u,"innerTree"),f=>{let m=_(f);if(ye(m)||s&&m!==x.STRING)return;let g=e?f.id:d;if(!g)return;let b=be(f,m,n,o);g in i?a.has(g)?i[g].push(b):(i[g]=[i[g],b],a.add(g)):i[g]=b})}return{values:i,dispose:()=>he(i)}}function Se(t){let e=[];for(let r of z(t))K(_chunkCUQQ3ZBVcjs.q.call(void 0, r,"innerTree"),n=>{if(!_(n).includes(_e))return;let o=ge(n);He(o)&&e.push(o)});return e}function De(t,e,r={}){let{parseValues:n=!0,rhino:o,stringOnly:s=!1}=r;for(let i of z(t)){let a=_chunkCUQQ3ZBVcjs.q.call(void 0, i,"innerTree"),u=!1;if("byName"in e){if(_chunkCUQQ3ZBVcjs.q.call(void 0, i,"paramName")!==e.byName)continue;u=!0}let d=[];if(K(a,f=>{if("byId"in e){if(f.id!==e.byId)return;u=!0}let m=_(f);ye(m)||s&&m!==x.STRING||d.push(be(f,m,n,o))}),u)return d.length===0?void 0:d.length===1?d[0]:d}}var k=class{constructor(e,r=!1){this.response=e;this.debug=r}getValues(e=!1,r={}){return Te(this.response,e,r)}getValue(e,r){return De(this.response,e,r)}async extractMeshesFromResponse(e){let r={debug:this.debug,...e},n;try{({getThreeMeshesFromComputeResponse:n}=await Promise.resolve().then(() => _interopRequireWildcard(require("./visualization-36IV2CVU.cjs"))))}catch(o){throw new (0, _chunkCUQQ3ZBVcjs.d)("Failed to load three.js visualization module. Ensure three.js is installed as a peer dependency.",_chunkCUQQ3ZBVcjs.c.INVALID_STATE,{context:{originalError:o instanceof Error?o.message:String(o)}})}return n(this.response,r)}getFileData(){return Se(this.response)}async getAndDownloadFiles(e,r){let n=this.getFileData();await _chunkCUQQ3ZBVcjs.t.call(void 0, n,e,r)}};var Q=/^\{(-?\d+(?:;-?\d+)*)?\}$/;function C(t){if(typeof t!="object"||t===null||Array.isArray(t))return!1;let e=Object.entries(t);return e.length>0&&e.every(([r,n])=>Q.test(r)&&Array.isArray(n))}function w(t,e,r){if(t==null)return t;if(Array.isArray(t)){let o=t.map(e).filter(s=>s!==null);return o.length>0?o:void 0}let n=e(t);return n!==null?n:r?void 0:t}var V=t=>{if(typeof t=="number")return Number.isFinite(t)?t:null;if(typeof t=="string"){let e=t.trim();if(e===""||/^[+-]?0[xbo]/i.test(e))return null;let r=Number(e);return Number.isFinite(r)?r:null}return null},H=t=>{if(typeof t=="boolean")return t;if(typeof t=="string"){let e=t.trim().toLowerCase();if(e==="true")return!0;if(e==="false")return!1}return null},Je=t=>typeof t=="string"?t.length>=2&&t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t.startsWith('"')?t.slice(1):t:null,Ye=t=>{if(typeof t=="string"){let e=t.trim();return e.startsWith('"')&&e.endsWith('"')&&(e=e.slice(1,-1).trim()),e}return null};function xe(t){return e=>{if(typeof e=="object"&&e!==null)return e;if(typeof e=="string"&&e.trim()!=="")try{let r=JSON.parse(e);return typeof r=="object"&&r!==null?r:(_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Parsed value for input ${t} is not an object`),null)}catch(r){return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Failed to parse object value "${e}" for input ${t}`,r),null}return null}}function Ie(t,e,r){let n=Number(t.toFixed(e));return Math.abs(t-n)<r?n:t}function Xe(t,e){if(!Number.isFinite(t)||t===0)return .1;let r=Math.abs(t);if(r>=1){let g=String(t).split(".")[1];if(g&&g.length>0){let b=Math.min(g.length,12),S=Math.pow(10,-b),Y=Number(S.toFixed(b));return Math.abs(Y-S)<e?Y:S}return 1}let n=String(t),o=n.toLowerCase().match(/e(-?\d+)/);if(o){let m=Number(o[1]);if(m<0||n.toLowerCase().includes("e-")){let g=Math.abs(m),b=Math.pow(10,-g),S=Number(b.toFixed(g));return Math.abs(S-b)<e?S:b}return .1}let s=12,a=r.toFixed(s).replace(/0+$/,""),u=Math.min((a.split(".")[1]||"").length,s);if(u===0)return .1;let d=Math.pow(10,-u),f=Number(d.toFixed(u));return Math.abs(f-d)<e?f:d}function Ce(t){return typeof t.stepSize=="number"&&Number.isFinite(t.stepSize)&&t.stepSize>0?t.stepSize:void 0}function Ze(t,e=1e-8){let r=t.paramType==="Integer",n=Ce(t);if(C(t.default))return{default:t.default,stepSize:_nullishCoalesce(n, () => ((r?1:.1)))};if(typeof t.default=="string"&&t.default.trim()!==""&&V(t.default)===null)throw new (0, _chunkCUQQ3ZBVcjs.d)(`Invalid numeric default "${t.default}" for input "${t.name||"unknown"}"`,_chunkCUQQ3ZBVcjs.c.VALIDATION_ERROR,{context:{inputName:t.name,default:t.default}});let o=w(t.default,V,!0);if(r)return Array.isArray(o)?o=o.map(m=>typeof m=="number"?Math.round(m):m):typeof o=="number"&&(o=Math.round(o)),{default:o,stepSize:_nullishCoalesce(n, () => (1))};let s=Array.isArray(o)?o[0]:o,i;typeof s=="number"&&Number.isFinite(s)&&s!==0?i=s:typeof t.minimum=="number"&&Number.isFinite(t.minimum)&&t.minimum!==0?i=t.minimum:typeof t.maximum=="number"&&Number.isFinite(t.maximum)&&t.maximum!==0&&(i=t.maximum);let a=_nullishCoalesce(n, () => ((i!==void 0?Xe(i,e):.1))),u=0,d=String(a),f=d.toLowerCase().match(/e(-?\d+)/);if(f?u=Math.abs(Number(f[1])):u=_nullishCoalesce(_optionalChain([d, 'access', _28 => _28.split, 'call', _29 => _29("."), 'access', _30 => _30[1], 'optionalAccess', _31 => _31.length]), () => (0)),u===0&&typeof s=="number"&&s!==0&&Math.abs(s)<1){let m=Math.ceil(-Math.log10(Math.abs(s)));Number.isFinite(m)&&m>0&&(u=m)}return u=Math.min(Math.max(u,0),12),Array.isArray(o)?o=o.map(m=>typeof m=="number"?Ie(m,u,e):m):typeof o=="number"&&(o=Ie(o,u,e)),{default:o,stepSize:a}}var et={types:["Number","Integer"],parse(t,e){let{default:r,stepSize:n}=Ze(t);return{...e,paramType:t.paramType,minimum:t.minimum,maximum:t.maximum,atLeast:t.atLeast,atMost:t.atMost,stepSize:n,default:r}},fallback(t,e){let r=(_nullishCoalesce(t.atMost, () => (1)))>1,n=typeof t.minimum=="number"&&Number.isFinite(t.minimum)&&t.minimum>0?t.minimum:0;return{...e,paramType:t.paramType,minimum:t.minimum,maximum:t.maximum,atLeast:t.atLeast,atMost:t.atMost,stepSize:_nullishCoalesce(Ce(t), () => ((t.paramType==="Integer"?1:.1))),default:r?[n]:n}}},tt={types:["Boolean"],parse(t,e){if(C(t.default))return{...e,paramType:"Boolean",default:t.default};let r=w(t.default,H,!1);if(r!=null&&typeof r!="boolean"&&!Array.isArray(r))throw new (0, _chunkCUQQ3ZBVcjs.d)(`Invalid boolean default "${String(r)}" for input "${t.name||"unknown"}"`,_chunkCUQQ3ZBVcjs.c.VALIDATION_ERROR,{context:{inputName:t.name,default:t.default}});return{...e,paramType:"Boolean",default:r}},fallback(t,e){let r=(_nullishCoalesce(t.atMost, () => (1)))>1;return{...e,paramType:"Boolean",default:r?[!1]:!1}}},rt={types:["Text"],parse(t,e){let r=w(t.default,Je,!1);return{...e,paramType:"Text",default:r}},fallback(t,e){let r=(_nullishCoalesce(t.atMost, () => (1)))>1;return{...e,paramType:"Text",default:r?[""]:""}}},nt={types:["ValueList"],parse(t,e){if(!t.values||typeof t.values!="object"||Object.keys(t.values).length===0)throw _chunkCUQQ3ZBVcjs.d.missingValues(t.nickname||"unnamed","ValueList");let r=t.default;if(t.default!==void 0&&t.default!==null){if(typeof t.default=="object")throw new (0, _chunkCUQQ3ZBVcjs.d)(`ValueList input "${t.nickname||"unnamed"}" default is not a string-able value`,_chunkCUQQ3ZBVcjs.c.VALIDATION_ERROR,{context:{inputName:t.name,default:t.default}});let n=String(t.default).toLowerCase(),o=Object.keys(t.values).find(s=>s.toLowerCase()===n);o!==void 0?r=o:_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`ValueList input "${t.nickname||"unnamed"}" default value "${t.default}" is not in available values`)}return{...e,paramType:"ValueList",values:t.values,default:r}},fallback(t,e){return{...e,paramType:"ValueList",values:t.values&&typeof t.values=="object"?t.values:{},default:void 0}}},we={types:["Geometry"],parse(t,e){let r=w(t.default,xe(t.nickname||"unnamed"),!0);return{...e,paramType:"Geometry",default:r}},fallback(t,e){let r=(_nullishCoalesce(t.atMost, () => (1)))>1;return{...e,paramType:"Geometry",default:r?[null]:null}}},ot={types:["File"],parse(t,e){let r=w(t.default,xe(t.nickname||"unnamed"),!0);return{...e,paramType:"File",acceptedFormats:t.acceptedFormats,default:r}},fallback(t,e){let r=(_nullishCoalesce(t.atMost, () => (1)))>1;return{...e,paramType:"File",default:r?[null]:null}}},st={types:["Color"],parse(t,e){let r=w(t.default,Ye,!1);return{...e,paramType:"Color",default:r}},fallback(t,e){let r=(_nullishCoalesce(t.atMost, () => (1)))>1;return{...e,paramType:"Color",default:r?["0, 0, 0"]:"0, 0, 0"}}},it=[et,tt,rt,nt,we,ot,st],J=new Map(it.flatMap(t=>t.types.map(e=>[e,t]))),Ee=we;function ve(t){return _chunkCUQQ3ZBVcjs.q.call(void 0, t,"data")}function at(t){return _chunkCUQQ3ZBVcjs.q.call(void 0, t,"type")}var ut=new Set(["System.Double","System.Single","System.Decimal","System.Int32","System.Int64"]),pt=new Set(["System.Int32","System.Int64"]);function Re(t){if(typeof t.default!="object"||t.default===null)return{schema:t};if(Array.isArray(t.default))return{schema:t};if(!_chunkCUQQ3ZBVcjs.r.call(void 0, t.default,"innerTree")){let n=`Input "${_nullishCoalesce(t.name, () => ("unknown"))}" default had an unrecognized shape (no innerTree key); the default was dropped.`;return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("Unexpected structure in input.default:",t.default),{schema:{...t,default:null},warning:{code:"MALFORMED_DEFAULT",message:n}}}let e=_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t.default,"innerTree"), () => ({}));if(Object.keys(e).length===0)return{schema:{...t,default:void 0}};if(t.treeAccess||t.atMost&&t.atMost>1){let n={},o=[];for(let[i,a]of Object.entries(e)){if(!Array.isArray(a)){let d=`Input "${_nullishCoalesce(t.name, () => ("unknown"))}" default had a non-array innerTree branch ("${i}"); the default was dropped.`;return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("Unexpected structure in input.default innerTree:",t.default),{schema:{...t,default:null},warning:{code:"MALFORMED_DEFAULT",message:d}}}let u=[];for(let d of a){let f=ve(d),m=at(d);if(m&&ut.has(m)){if(typeof f=="string"&&f.trim()==="")continue;let g=V(f);if(g===null){o.push(`"${String(f)}" (${m})`);continue}u.push(pt.has(m)?Math.round(g):g);continue}if(m==="System.Boolean"){let g=H(f);if(g===null){o.push(`"${String(f)}" (${m})`);continue}u.push(g);continue}if(typeof f=="string"&&_optionalChain([m, 'optionalAccess', _32 => _32.startsWith, 'call', _33 => _33("Rhino.Geometry")])){try{u.push(JSON.parse(f))}catch (e4){u.push(f)}continue}u.push(f)}n[i]=u}let s;if(o.length>0){let i=`Input "${_nullishCoalesce(t.name, () => ("unknown"))}" default contained ${o.length} tree value(s) that could not be parsed and were dropped: ${o.join(", ")}.`;_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(i),s={code:"MALFORMED_DEFAULT",message:i}}return{schema:{...t,default:n},...s&&{warning:s}}}let r=[];for(let n of Object.values(e))Array.isArray(n)&&n.forEach(o=>{o&&typeof o=="object"&&_chunkCUQQ3ZBVcjs.r.call(void 0, o,"data")&&r.push(ve(o))});return r.length===0?{schema:{...t,default:void 0}}:r.length===1?{schema:{...t,default:r[0]}}:{schema:{...t,default:r}}}var lt=new Map([...J.keys()].map(t=>[t.toLowerCase(),t]));function ct(t){return _nullishCoalesce(lt.get(_optionalChain([t, 'optionalAccess', _34 => _34.toLowerCase, 'call', _35 => _35()])), () => (t))}function Ae(t){return Pe(t).input}function Pe(t){let e={description:t.description,name:t.name,nickname:t.nickname,treeAccess:t.treeAccess,groupName:_nullishCoalesce(t.groupName, () => (void 0)),id:t.id},r=ct(t.paramType),n={...t,paramType:r},o;try{let{schema:i,warning:a}=Re(n);n=i,o=a&&{inputName:t.name||"unknown",paramType:t.paramType,message:a.message,code:a.code}}catch(i){n={...n,default:null},o={inputName:t.name||"unknown",paramType:t.paramType,message:`Input "${_nullishCoalesce(t.name, () => ("unknown"))}" default could not be normalized and was dropped: ${i instanceof Error?i.message:String(i)}`,code:"MALFORMED_DEFAULT"}}let s=J.get(r);try{if(!s)throw _chunkCUQQ3ZBVcjs.d.unknownParamType(r,t.name);return{input:s.parse(n,e),error:o,...o&&{errors:[o]}}}catch(i){if(i instanceof _chunkCUQQ3ZBVcjs.d){_chunkCUQQ3ZBVcjs.e.call(void 0, ).error(`Validation error for input ${t.name||"unknown"}:`,i.message);let a={inputName:t.name||"unknown",paramType:t.paramType,message:i.message,code:i.code};return{input:(_nullishCoalesce(s, () => (Ee))).fallback(n,e),error:a,errors:o?[o,a]:[a]}}throw new (0, _chunkCUQQ3ZBVcjs.d)(i instanceof Error?i.message:String(i),"VALIDATION_ERROR",{context:{paramName:t.name,paramType:r},originalError:i instanceof Error?i:new Error(String(i))})}}function ke(t){return L(t).inputs}function L(t){let e=[],r=[];for(let n of t){let{input:o,errors:s}=Pe(n);e.push(o),s&&r.push(...s)}return{inputs:e,parseErrors:r}}function Oe(t){let e=_chunkCUQQ3ZBVcjs.q.call(void 0, t,"stepSize");return{id:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"id"), () => ("")),name:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"name"), () => ("")),nickname:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"nickname"), () => (null)),description:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"description"), () => ("")),paramType:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"paramType"), () => ("")),treeAccess:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"treeAccess"), () => (!1)),minimum:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"minimum"), () => (null)),maximum:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"maximum"), () => (null)),atLeast:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"atLeast"), () => (1)),atMost:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"atMost"), () => (1)),stepSize:typeof e=="number"&&Number.isFinite(e)?e:void 0,default:_chunkCUQQ3ZBVcjs.q.call(void 0, t,"default"),values:_chunkCUQQ3ZBVcjs.q.call(void 0, t,"values"),acceptedFormats:_chunkCUQQ3ZBVcjs.q.call(void 0, t,"acceptedFormats"),groupName:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"groupName"), () => (null))}}function Fe(t){return{name:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"name"), () => ("")),nickname:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"nickname"), () => (null)),paramType:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"paramType"), () => ("")),id:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"id"), () => (""))}}async function P(t,e){let r=v(t,[]),n={};if(r.algo&&(n.algo=r.algo),r.pointer&&(n.pointer=r.pointer),!n.algo&&!n.pointer)throw new (0, _chunkCUQQ3ZBVcjs.d)("Definition must resolve to either a URL pointer or base64 algo",_chunkCUQQ3ZBVcjs.c.INVALID_INPUT,{context:{definition:t}});let o=await _chunkCUQQ3ZBVcjs.l.call(void 0, "io",n,e);if(!o||typeof o!="object")throw new (0, _chunkCUQQ3ZBVcjs.d)("Invalid IO response structure",_chunkCUQQ3ZBVcjs.c.INVALID_INPUT,{context:{response:o,definition:t}});let s=Ne(_chunkCUQQ3ZBVcjs.q.call(void 0, o,"warnings")),i=Ne(_chunkCUQQ3ZBVcjs.q.call(void 0, o,"errors")),a=_chunkCUQQ3ZBVcjs.q.call(void 0, o,"inputs"),u=_chunkCUQQ3ZBVcjs.q.call(void 0, o,"outputs");return{inputs:Array.isArray(a)?a.map(Oe):[],outputs:Array.isArray(u)?u.map(Fe):[],...s&&{loadWarnings:s},...i&&{loadErrors:i}}}function Ne(t){if(!Array.isArray(t))return;let e=t.map(ft).filter(r=>r!==void 0);return e.length>0?e:void 0}function ft(t){if(t==null)return;let e;if(typeof t=="string")e=t;else if(typeof t=="object"){let r=_chunkCUQQ3ZBVcjs.q.call(void 0, t,"message");if(typeof r=="string"&&r.trim().length>0)e=r;else try{e=_nullishCoalesce(JSON.stringify(t), () => (String(t)))}catch (e5){e=String(t)}}else e=String(t);return e.trim().length>0?e:void 0}async function M(t,e){D("fetchParsedDefinitionIO",_nullishCoalesce(e.suppressBrowserWarning, () => (e.suppressClientSideWarning)));let{inputs:r,outputs:n,loadWarnings:o,loadErrors:s}=await P(t,e),{inputs:i,parseErrors:a}=L(r);return{inputs:i,outputs:n,...a.length>0&&{parseErrors:a},...o&&{loadWarnings:o},...s&&{loadErrors:s}}}var W=class t{constructor(e){_chunkCUQQ3ZBVcjs.b.call(void 0, this,"innerTree");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"paramName");this.paramName=e,this.innerTree={}}append(e,r){let n=t.formatPathString(e);this.innerTree[n]||(this.innerTree[n]=[]);let o=r.map(s=>({data:t.serializeValue(s)}));return this.innerTree[n].push(...o),this}appendSingle(e,r){return this.append(e,[r])}fromDataTreeDefault(e){this.innerTree={};for(let[r,n]of Object.entries(e)){if(!Array.isArray(n))continue;let o=t.parsePathString(r);this.append(o,n)}return this}appendFlat(e){let r=Array.isArray(e)?e:[e];return this.append([0],r)}flatten(){let e=[];for(let r of Object.values(this.innerTree))if(Array.isArray(r))for(let n of r)e.push(t.deserializeValue(n.data));return e}getPaths(){return Object.keys(this.innerTree)}getPath(e){let r=t.formatPathString(e),n=this.innerTree[r];if(n)return n.map(o=>t.deserializeValue(o.data))}toComputeFormat(){return{ParamName:this.paramName,InnerTree:this.innerTree}}getInnerTree(){return this.innerTree}getParamName(){return this.paramName}static fromInputParams(e){return e.filter(r=>t.hasValidValue(r.default)).map(r=>{let n=new t(r.nickname||"unnamed"),o=r.default;if(r.treeAccess&&C(o))n.fromDataTreeDefault(o),t.isNumericInput(r)&&n.applyNumericConstraints(r.minimum,r.maximum,r.nickname||"unnamed");else{let s=Array.isArray(o)?o:[o],i=t.processValues(s,r);n.appendFlat(i)}return n.toComputeFormat()})}static fromInputParam(e){return t.hasValidValue(e.default)?t.fromInputParams([e])[0]:void 0}static replaceTreeValue(e,r,n){let o=e.length>0&&e[0]instanceof t,s=t.buildFromValue(r,n);if(o){let d=e.slice(),f=d.findIndex(m=>m.getParamName()===r);return f!==-1?d[f]=s:d.push(s),d}let i=e.slice(),a=s.toComputeFormat(),u=i.findIndex(d=>d.ParamName===r);return u!==-1?i[u]=a:i.push(a),i}static buildFromValue(e,r){let n=new t(e);return C(r)?n.fromDataTreeDefault(r):n.appendFlat(r),n}static getTreeValue(e,r){let o=e.length>0&&e[0]instanceof t?t.readFromBuilders(e,r):t.readFromDataTrees(e,r);return o===null||o.length===0?null:o.length===1?o[0]:o}static readFromBuilders(e,r){let n=e.find(o=>o.getParamName()===r);return n?n.flatten():null}static readFromDataTrees(e,r){let n=e.find(i=>i.ParamName===r);if(!_optionalChain([n, 'optionalAccess', _36 => _36.InnerTree]))return null;let o=Object.keys(n.InnerTree)[0];if(!o)return null;let s=n.InnerTree[o];return Array.isArray(s)?s.map(i=>_optionalChain([i, 'optionalAccess', _37 => _37.data])!==void 0?t.deserializeValue(i.data):null):_optionalChain([s, 'optionalAccess', _38 => _38.data])!==void 0?[t.deserializeValue(s.data)]:s!==void 0?[s]:null}static parsePathString(e){let r=e.match(Q);if(!r)throw new Error(`Invalid Grasshopper tree path: "${e}". Expected "{}", "{0}", or "{0;1;2}" (negative indices allowed, no empty segments).`);return r[1]?r[1].split(";").map(Number):[]}static formatPathString(e){return`{${e.join(";")}}`}applyNumericConstraints(e,r,n){for(let o of Object.values(this.innerTree))if(Array.isArray(o))for(let s of o){let i=t.deserializeValue(s.data);if(typeof i=="number"){let a=t.clampValue(i,e,r,n);s.data=t.serializeValue(a)}}}static serializeValue(e){return typeof e=="boolean"||typeof e=="number"||typeof e=="string"?e:typeof e=="object"&&e!==null?JSON.stringify(e):String(e)}static deserializeValue(e){if(typeof e=="boolean"||typeof e=="number"||typeof e!="string")return e;if(e.startsWith("{")||e.startsWith("["))try{return JSON.parse(e)}catch (e6){return e}let r=Number(e);return Number.isFinite(r)&&String(r)===e?r:e==="true"?!0:e==="false"?!1:e}static hasValidValue(e){return e==null?!1:typeof e=="string"?!0:!(Array.isArray(e)&&e.length===0||typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0)}static isNumericInput(e){return e.paramType==="Number"||e.paramType==="Integer"}static processValues(e,r){return e.map(n=>t.isNumericInput(r)&&typeof n=="number"?t.clampValue(n,r.minimum,r.maximum,r.nickname||"unnamed"):n).filter(n=>n!=null)}static clampValue(e,r,n,o){let s=e;return r!=null&&s<r&&(_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`${o}: ${e} below min ${r}, clamping`),s=r),n!=null&&s>n&&(_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`${o}: ${e} above max ${n}, clamping`),s=n),s}};exports.a = T; exports.b = E; exports.c = $; exports.d = pe; exports.e = R; exports.f = I; exports.g = A; exports.h = k; exports.i = Ae; exports.j = ke; exports.k = P; exports.l = M; exports.m = W;
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
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 _chunkCUQQ3ZBVcjs = require('./chunk-CUQQ3ZBV.cjs');var ne=new Set;function Me(){if(typeof window>"u"||_optionalChain([globalThis, 'access', _2 => _2.process, 'optionalAccess', _3 => _3.versions, 'optionalAccess', _4 => _4.node])!=null)return!1;let e=globalThis.navigator,r=typeof _optionalChain([e, 'optionalAccess', _5 => _5.userAgent])=="string"?e.userAgent:"";return!/jsdom/i.test(r)}function D(t,e){e||Me()&&!ne.has(t)&&(ne.add(t),_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Warning: ${t} is running on the client side. For better performance and security, consider running this on the server side.`))}function T(t){return typeof t=="object"&&!(t instanceof Uint8Array)&&typeof t.key=="string"&&typeof t.load=="function"}var Ge="Unable to load grasshopper definition";function Ve(t){return t instanceof _chunkCUQQ3ZBVcjs.d?t.code===_chunkCUQQ3ZBVcjs.c.DEFINITION_NOT_CACHED||t.message.includes(Ge):!1}function Le(t,e){if(!e)return;let r=_chunkCUQQ3ZBVcjs.q.call(void 0, t,"values");if(!Array.isArray(r)||r.length===0)return;let n=[];for(let s of r){let i=_chunkCUQQ3ZBVcjs.q.call(void 0, s,"innerTree");(!i||Object.keys(i).length===0)&&n.push(_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, s,"paramName"), () => ("<unnamed>")))}if(n.length===0)return;let o=n.length===r.length?"all":`${n.length}/${r.length}`;_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Solve returned empty output(s) (${o}): ${n.join(", ")}. These parameters produced no data \u2014 check the definition's inputs and the branch feeding each.`)}async function E(t,e,r){D("solveGrasshopperDefinition",_nullishCoalesce(r.suppressBrowserWarning, () => (r.suppressClientSideWarning)));let n=await B(e),{response:o}=await N(v(n,t),r);return o}async function oe(t,e,r){D("solveGrasshopperDefinitionWithCacheKey",_nullishCoalesce(r.suppressBrowserWarning, () => (r.suppressClientSideWarning)));let n=await B(e);return N(v(n,t),r)}async function se(t,e,r,n){D("solveByCacheKey",_nullishCoalesce(n.suppressBrowserWarning, () => (n.suppressClientSideWarning)));let o={algo:null,pointer:e,values:t};try{return{...await N(o,n),missed:!1}}catch(s){if(!Ve(s))throw s;let i=await B(r);return{...await N(v(i,t),n),missed:!0}}}async function B(t){if(!T(t))return t;try{return await t.load()}catch(e){throw new (0, _chunkCUQQ3ZBVcjs.d)(`Failed to load definition bytes for ref '${t.key}'`,_chunkCUQQ3ZBVcjs.c.INVALID_INPUT,{context:{definitionKey:t.key},originalError:e instanceof Error?e:new Error(String(e))})}}async function N(t,e){We(t,e);let r=await _chunkCUQQ3ZBVcjs.l.call(void 0, "grasshopper",t,e),{pointer:n,algo:o,...s}=r,i=s;return Le(i,e.debug),{response:i,cacheKey:typeof n=="string"?n:null}}function v(t,e){let r={algo:null,pointer:null,values:e};return t instanceof Uint8Array?r.algo=_chunkCUQQ3ZBVcjs.k.call(void 0, t):/^https?:\/\//i.test(t)?r.pointer=t:r.algo=_nullishCoalesce(_chunkCUQQ3ZBVcjs.i.call(void 0, t), () => (_chunkCUQQ3ZBVcjs.h.call(void 0, t))),r}function We(t,e){e.cachesolve!=null&&(t.cachesolve=e.cachesolve),e.cacheerroredsolves!=null&&(t.cacheerroredsolves=e.cacheerroredsolves),e.modelunits!=null&&(t.modelunits=e.modelunits),e.angletolerance!=null&&(t.angletolerance=e.angletolerance),e.absolutetolerance!=null&&(t.absolutetolerance=e.absolutetolerance),e.dataversion!=null&&(t.dataversion=e.dataversion)}function $(t){let e=new WeakSet,r=n=>{if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="number")return Number.isFinite(n)?String(n):"null";if(typeof n=="string"||typeof n=="boolean")return JSON.stringify(n);if(typeof n=="bigint")return`${n}n`;if(n instanceof Uint8Array)return`{"__u8":${n.length},"hash":"${ue(n)}"}`;if(Array.isArray(n)){if(e.has(n))return'"[Circular]"';e.add(n);let o=[];for(let s=0;s<n.length;s++)o.push(r(n[s]));return e.delete(n),`[${o.join(",")}]`}if(typeof n=="object"){if(e.has(n))return'"[Circular]"';e.add(n);let o;return typeof n.toJSON=="function"?o=r(n.toJSON()):n instanceof Map?o=`{"__map":[${[...n.entries()].map(([i,a])=>`[${r(i)},${r(a)}]`).sort().join(",")}]}`:n instanceof Set?o=`{"__set":[${[...n.values()].map(r).sort().join(",")}]}`:o=`{${Object.keys(n).sort().map(a=>`${JSON.stringify(a)}:${r(n[a])}`).join(",")}}`,e.delete(n),o}return"null"};return r(t)}function ie(t,e){let r=2166136261;for(let n=0;n<t;n++)r^=e(n),r=r+((r<<1)+(r<<4)+(r<<7)+(r<<8)+(r<<24))>>>0;return r.toString(16).padStart(8,"0")}function ae(t){return ie(t.length,e=>t.charCodeAt(e))}function ue(t){return ie(t.length,e=>t[e])}function pe(t,e){return q(R(t),e)}function q(t,e){let r=$(e);return`${t}|t:${r.length}:${ae(r)}`}function R(t){return T(t)?`r:${t.key}`:typeof t=="string"?`s:${t.length}:${ae(t)}`:`u8:${t.length}:${ue(t)}`}var je=100;function Be(t){return typeof t!="string"?!0:!/^https?:\/\//i.test(t)}var I=class{constructor(e,r,n={},o){_chunkCUQQ3ZBVcjs.b.call(void 0, this,"executor");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"baseConfig");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"mode");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"maxConcurrent");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"maxQueueDepth");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"queueWaitMs");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"timeoutMs");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"retry");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"cacheEnabled");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"cacheMax");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"cacheTtl");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"cacheErroredSolves");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"cache",new Map);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"cacheKeyExecutor");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"reuseServerDefinitionCache");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"serverCacheKeys",new Map);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"onStart");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"onSettle");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"onSuperseded");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"subscribers",new Set);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"inFlight",new Set);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"pendingForLatestWins",null);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"fifoQueue",[]);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"_lastResult",null);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"_lastError",null);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"_lastDurationMs",null);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"solveSeq",0);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"lastStateSeq",0);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"disposed",!1);this.executor=e,this.cacheKeyExecutor=o,this.baseConfig=r,this.mode=_nullishCoalesce(n.mode, () => ("latest-wins")),this.maxConcurrent=Math.max(1,_nullishCoalesce(n.maxConcurrent, () => ((this.mode==="parallel"?4:1)))),this.maxQueueDepth=n.maxQueueDepth!==void 0&&n.maxQueueDepth>0?Math.floor(n.maxQueueDepth):void 0,this.queueWaitMs=n.queueWaitMs!==void 0&&n.queueWaitMs>0?n.queueWaitMs:void 0,this.timeoutMs=n.timeoutMs,this.retry=n.retry;let s=n.cache;this.cacheEnabled=s!==void 0&&s!==!1;let i=typeof s=="object"?s:{};this.cacheMax=_nullishCoalesce(i.maxEntries, () => (50)),this.cacheTtl=_nullishCoalesce(i.ttlMs, () => (0)),this.cacheErroredSolves=_nullishCoalesce(i.cacheErroredSolves, () => (!0)),this.reuseServerDefinitionCache=!!o&&(_nullishCoalesce(n.reuseServerDefinitionCache, () => (!0))),this.onStart=n.onStart,this.onSettle=n.onSettle,this.onSuperseded=n.onSuperseded}get isSolving(){return this.inFlight.size>0}get hasPending(){return this.pendingForLatestWins!==null||this.fifoQueue.length>0}get inFlightCount(){return this.inFlight.size}get queueDepth(){return this.fifoQueue.length+(this.pendingForLatestWins?1:0)}get lastResult(){return this._lastResult}get lastError(){return this._lastError}get lastDurationMs(){return this._lastDurationMs}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}notify(){for(let e of this.subscribers)try{e()}catch(r){_chunkCUQQ3ZBVcjs.e.call(void 0, ).error("[SolveScheduler] subscriber threw:",r)}}solve(e,r,n){if(this.disposed)return Promise.reject(new (0, _chunkCUQQ3ZBVcjs.d)("SolveScheduler has been disposed and cannot be used",_chunkCUQQ3ZBVcjs.c.INVALID_STATE));let o=R(e),s=q(o,r),i=++this.solveSeq,a={key:s,enqueuedAt:Date.now(),startedAt:null};if(_optionalChain([n, 'optionalAccess', _6 => _6.signal, 'optionalAccess', _7 => _7.aborted]))return Promise.reject(this.makeAbortError(a));if(this.cacheEnabled){let u=this.readCache(s);if(u){this.mode==="latest-wins"&&this.supersedeCurrent();let d={status:"success",response:u,durationMs:0,fromCache:!0};return this.writeLastState(i,{result:u,durationMs:0}),this.runHook(this.onStart,a),this.runHook(this.onSettle,a,d),this.notify(),Promise.resolve(u)}}return new Promise((u,d)=>{let f={definition:e,dataTree:r,definitionHash:o,ctx:a,seq:i,resolve:u,reject:d,externalSignal:_optionalChain([n, 'optionalAccess', _8 => _8.signal])};f.externalSignal&&(f.queuedAbortHandler=()=>this.abortQueuedItem(f),f.externalSignal.addEventListener("abort",f.queuedAbortHandler,{once:!0})),this.enqueue(f)})}writeLastState(e,r){return e<this.lastStateSeq?!1:(this.lastStateSeq=e,"result"in r?(this._lastResult=r.result,this._lastError=null):this._lastError=r.error,this._lastDurationMs=r.durationMs,!0)}supersedeCurrent(){this.pendingForLatestWins&&(this.supersede(this.pendingForLatestWins),this.pendingForLatestWins=null);for(let e of this.inFlight)this.supersede(e),e.controller.abort()}abortQueuedItem(e){this.pendingForLatestWins===e&&(this.pendingForLatestWins=null);let r=this.fifoQueue.indexOf(e);r>=0&&this.fifoQueue.splice(r,1),this.rejectAsAborted(e),this.notify()}shedAsQueueFull(e){let r=new (0, _chunkCUQQ3ZBVcjs.d)("Solve queue is full; request shed (backpressure)",_chunkCUQQ3ZBVcjs.c.QUEUE_FULL,{statusCode:503,context:{key:e.ctx.key,queueDepth:this.fifoQueue.length,maxQueueDepth:this.maxQueueDepth}});this.settleError(e,r)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:r,durationMs:0}),this.notify()}armQueueWaitTimer(e){if(this.queueWaitMs===void 0)return;let r=this.queueWaitMs;e.queueWaitTimer=setTimeout(()=>{if(e.settled)return;let n=this.fifoQueue.indexOf(e);n>=0&&this.fifoQueue.splice(n,1);let o=new (0, _chunkCUQQ3ZBVcjs.d)(`Solve waited longer than ${r}ms in queue; shed (backpressure)`,_chunkCUQQ3ZBVcjs.c.QUEUE_TIMEOUT,{statusCode:503,context:{key:e.ctx.key,waitedMs:Date.now()-e.ctx.enqueuedAt,queueWaitMs:r}});this.settleError(e,o)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:o,durationMs:0}),this.notify()},r)}clearQueueWaitTimer(e){e.queueWaitTimer!==void 0&&(clearTimeout(e.queueWaitTimer),e.queueWaitTimer=void 0)}enqueue(e){switch(this.mode){case"latest-wins":{this.supersedeCurrent(),this.inFlight.size===0?this.execute(e):this.pendingForLatestWins=e;break}case"queue":case"parallel":{this.inFlight.size<this.maxConcurrent?this.execute(e):this.maxQueueDepth!==void 0&&this.fifoQueue.length>=this.maxQueueDepth?this.shedAsQueueFull(e):(this.armQueueWaitTimer(e),this.fifoQueue.push(e));break}}this.notify()}async execute(e){let r=new AbortController,n=e;n.controller=r,this.inFlight.add(n),e.ctx.startedAt=Date.now(),this.clearQueueWaitTimer(e),this.removeQueuedAbortHandler(e);let o=()=>r.abort();_optionalChain([e, 'access', _9 => _9.externalSignal, 'optionalAccess', _10 => _10.addEventListener, 'call', _11 => _11("abort",o,{once:!0})]),this.runHook(this.onStart,e.ctx),this.notify();let s=performance.now();try{let i={...this.baseConfig,signal:r.signal,...this.timeoutMs!==void 0&&{timeoutMs:this.timeoutMs},...this.retry!==void 0&&{retry:this.retry}},{response:a,definitionReuploaded:u}=await this.runExecutor(e.definition,e.dataTree,e.definitionHash,i),d=performance.now()-s;if(this.cacheEnabled&&this.writeCache(e.ctx.key,a),!this.settleSuccess(e,a))return;this.writeLastState(e.seq,{result:a,durationMs:d}),this.runHook(this.onSettle,e.ctx,{status:"success",response:a,durationMs:d,fromCache:!1,definitionReuploaded:u})}catch(i){let a=performance.now()-s,u=this.normalizeExecutionError(i,n);this.writeLastState(e.seq,{error:u,durationMs:a}),this.settleError(e,u)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:u,durationMs:a})}finally{_optionalChain([e, 'access', _12 => _12.externalSignal, 'optionalAccess', _13 => _13.removeEventListener, 'call', _14 => _14("abort",o)]),this.inFlight.delete(n),this.drainNext(),this.notify()}}async runExecutor(e,r,n,o){if(!this.cacheKeyExecutor||!this.reuseServerDefinitionCache||!Be(e))return{response:await this.executor(e,r,o)};let s=n,i=_nullishCoalesce(this.serverCacheKeys.get(s), () => (null)),a=await this.cacheKeyExecutor(e,r,i,o);if(a.cacheKey)for(this.serverCacheKeys.delete(s),this.serverCacheKeys.set(s,a.cacheKey);this.serverCacheKeys.size>je;){let u=this.serverCacheKeys.keys().next().value;if(u===void 0)break;this.serverCacheKeys.delete(u)}else this.serverCacheKeys.delete(s);return{response:a.response,definitionReuploaded:a.missed}}drainNext(){if(!this.disposed){if(this.mode==="latest-wins"){if(this.pendingForLatestWins&&this.inFlight.size===0){let e=this.pendingForLatestWins;this.pendingForLatestWins=null,this.execute(e)}return}for(;this.fifoQueue.length>0&&this.inFlight.size<this.maxConcurrent;){let e=this.fifoQueue.shift();this.execute(e)}}}supersede(e){let r=new (0, _chunkCUQQ3ZBVcjs.d)("Superseded by newer solve",_chunkCUQQ3ZBVcjs.c.SUPERSEDED,{context:{key:e.ctx.key,enqueuedAt:e.ctx.enqueuedAt}});this.settleError(e,r)&&this.runHook(this.onSuperseded,e.ctx)}makeAbortError(e){return new (0, _chunkCUQQ3ZBVcjs.d)("Request aborted by caller",_chunkCUQQ3ZBVcjs.c.ABORTED,{context:{key:e.key,enqueuedAt:e.enqueuedAt}})}settleError(e,r){return e.settled?!1:(e.settled={error:r},this.clearQueueWaitTimer(e),this.removeQueuedAbortHandler(e),e.reject(r),!0)}settleSuccess(e,r){return e.settled?!1:(e.settled={ok:!0},this.clearQueueWaitTimer(e),this.removeQueuedAbortHandler(e),e.resolve(r),!0)}removeQueuedAbortHandler(e){e.queuedAbortHandler&&e.externalSignal&&e.externalSignal.removeEventListener("abort",e.queuedAbortHandler),e.queuedAbortHandler=void 0}isAbortLikeError(e){if(e instanceof Error){if(e.name==="AbortError")return!0;if(typeof DOMException<"u"&&e instanceof DOMException)return e.name==="AbortError"}return!1}normalizeExecutionError(e,r){return r.settled&&"error"in r.settled?r.settled.error:e instanceof _chunkCUQQ3ZBVcjs.d?e:this.isAbortLikeError(e)?this.makeAbortError(r.ctx):new (0, _chunkCUQQ3ZBVcjs.d)(e instanceof Error?e.message:String(e),_chunkCUQQ3ZBVcjs.c.UNKNOWN_ERROR,{originalError:e instanceof Error?e:new Error(String(e))})}cancelAll(){for(this.pendingForLatestWins&&(this.rejectAsAborted(this.pendingForLatestWins),this.pendingForLatestWins=null);this.fifoQueue.length>0;){let e=this.fifoQueue.shift();this.rejectAsAborted(e)}for(let e of this.inFlight){let r=this.makeAbortError(e.ctx);this.settleError(e,r)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:r,durationMs:e.ctx.startedAt?Date.now()-e.ctx.startedAt:0}),e.controller.abort()}this.notify()}rejectAsAborted(e){let r=this.makeAbortError(e.ctx);this.settleError(e,r)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:r,durationMs:0})}readCache(e){if(!this.cacheEnabled)return null;let r=this.cache.get(e);return r?this.cacheTtl>0&&Date.now()-r.insertedAt>this.cacheTtl?(this.cache.delete(e),null):(this.cache.delete(e),this.cache.set(e,r),r.response):null}writeCache(e,r){if(this.cacheEnabled&&!(!this.cacheErroredSolves&&r.errors&&r.errors.length>0))for(this.cache.set(e,{response:r,insertedAt:Date.now()});this.cache.size>this.cacheMax;){let n=this.cache.keys().next().value;if(n===void 0)break;this.cache.delete(n)}}clearCache(){this.cache.clear()}dispose(){this.disposed||(this.disposed=!0,this.cancelAll(),this.subscribers.clear(),this.cache.clear())}runHook(e,...r){if(e)try{e(...r)}catch(n){_chunkCUQQ3ZBVcjs.e.call(void 0, ).error("[SolveScheduler] hook threw:",n)}}};function le(t){return T(t)?`ref:${t.key}`:typeof t=="string"&&t.length<200?t:"...content..."}function ce(t){return Array.isArray(t)?t.map(e=>{let r=0,n=0,o=_chunkCUQQ3ZBVcjs.q.call(void 0, e,"innerTree");if(o&&typeof o=="object"){for(let s of Object.values(o))if(Array.isArray(s)){r+=s.length;for(let i of s){let a=_optionalChain([i, 'optionalAccess', _15 => _15.data]);typeof a=="string"&&(n+=a.length)}}}return{param:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, e,"paramName"), () => ("<unnamed>")),items:r,bytes:n}}):[]}var A=class t{constructor(e){_chunkCUQQ3ZBVcjs.b.call(void 0, this,"config");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"serverStats");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"disposed",!1);this.config=this.normalizeComputeConfig(e),this.serverStats=new (0, _chunkCUQQ3ZBVcjs.n)(this.config.serverUrl,this.config.apiKey)}static async create(e){let r=new t(e),n=Math.max(1,(_nullishCoalesce(_optionalChain([e, 'access', _16 => _16.retry, 'optionalAccess', _17 => _17.attempts]), () => (2)))+1),o=_nullishCoalesce(_optionalChain([e, 'access', _18 => _18.retry, 'optionalAccess', _19 => _19.baseDelayMs]), () => (250)),s=_nullishCoalesce(_optionalChain([e, 'access', _20 => _20.retry, 'optionalAccess', _21 => _21.maxDelayMs]), () => (1e3));for(let i=0;i<n;i++){if(await r.serverStats.isServerOnline())return r;if(i<n-1){let a=Math.min(o*2**i,s);await new Promise(u=>setTimeout(u,a))}}throw await r.dispose(),new (0, _chunkCUQQ3ZBVcjs.d)("Rhino Compute server is not online",_chunkCUQQ3ZBVcjs.c.NETWORK_ERROR,{context:{serverUrl:r.config.serverUrl,attempts:n}})}getConfig(){return this.ensureNotDisposed(),{...this.config}}async getIO(e){return this.ensureNotDisposed(),M(e,this.config)}async getRawIO(e){return this.ensureNotDisposed(),P(e,this.config)}async solve(e,r,n){this.ensureNotDisposed();try{if(typeof e=="string"&&!_optionalChain([e, 'optionalAccess', _22 => _22.trim, 'call', _23 => _23()]))throw new (0, _chunkCUQQ3ZBVcjs.d)("Definition URL/content is required",_chunkCUQQ3ZBVcjs.c.INVALID_INPUT,{context:{receivedUrl:e}});if(e instanceof Uint8Array&&e.length===0)throw new (0, _chunkCUQQ3ZBVcjs.d)("Definition content is empty",_chunkCUQQ3ZBVcjs.c.INVALID_INPUT);if(T(e)&&!e.key.trim())throw new (0, _chunkCUQQ3ZBVcjs.d)("DefinitionRef key is empty",_chunkCUQQ3ZBVcjs.c.INVALID_INPUT);let o={...this.config,..._optionalChain([n, 'optionalAccess', _24 => _24.signal])!==void 0&&{signal:n.signal},..._optionalChain([n, 'optionalAccess', _25 => _25.timeoutMs])!==void 0&&{timeoutMs:n.timeoutMs},..._optionalChain([n, 'optionalAccess', _26 => _26.retry])!==void 0&&{retry:n.retry}},s=await E(r,e,o);if(_optionalChain([s, 'optionalAccess', _27 => _27.errors])&&s.errors.length>0)throw new (0, _chunkCUQQ3ZBVcjs.d)(s.errors.join("; ")||"Computation failed",_chunkCUQQ3ZBVcjs.c.COMPUTATION_ERROR,{context:{definition:le(e),inputSummary:ce(r),errors:s.errors,warnings:s.warnings,values:s.values}});return s}catch(o){throw this.config.debug&&_chunkCUQQ3ZBVcjs.e.call(void 0, ).error("Compute failed:",o),o instanceof _chunkCUQQ3ZBVcjs.d?o:new (0, _chunkCUQQ3ZBVcjs.d)(o instanceof Error?o.message:String(o),_chunkCUQQ3ZBVcjs.c.COMPUTATION_ERROR,{context:{definition:le(e),inputSummary:ce(r)},originalError:o instanceof Error?o:new Error(String(o))})}}createScheduler(e){this.ensureNotDisposed();let r=(o,s,i)=>E(s,o,i),n=(o,s,i,a)=>i===null?oe(s,o,a).then(u=>({...u,missed:!1})):se(s,i,o,a);return new I(r,this.config,e,n)}async dispose(){this.disposed||(this.disposed=!0,await this.serverStats.dispose())}ensureNotDisposed(){if(this.disposed)throw new (0, _chunkCUQQ3ZBVcjs.d)("GrasshopperClient has been disposed and cannot be used",_chunkCUQQ3ZBVcjs.c.INVALID_STATE)}normalizeComputeConfig(e){return{...e,serverUrl:_chunkCUQQ3ZBVcjs.m.call(void 0, e.serverUrl),apiKey:e.apiKey,authToken:e.authToken,debug:_nullishCoalesce(e.debug, () => (!1)),suppressBrowserWarning:_nullishCoalesce(e.suppressBrowserWarning, () => (e.suppressClientSideWarning))}}};var G=new Map;function de(t,e){G.set(t,e)}de("Rhino.Geometry.Point3d",(t,e)=>{let r=e;return!r||typeof r.X!="number"?null:new t.Point([r.X,r.Y,r.Z])});de("Rhino.Geometry.Line",(t,e)=>{let r=e;return!r||!r.From||!r.To?null:new t.Line([r.From.X,r.From.Y,r.From.Z],[r.To.X,r.To.Y,r.To.Z])});function $e(t){if(G.has(t))return G.get(t);for(let[e,r]of G)if(t.startsWith(e))return r}function qe(t){return!!(t&&typeof t=="object"&&typeof t.data=="string")}function fe(t,e){return{__decodeError:!0,type:t,raw:e}}function me(t,e,r){let n=$e(e),o=!1;if(n)try{let s=n(r,t);if(s!=null)return s}catch(s){_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Failed to decode Rhino type ${e}:`,s),o=!0}try{if(qe(t))return r.CommonObject.decode(t)}catch(s){return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Failed to decode ${e} with CommonObject:`,s),fe(e,t)}return o?fe(e,t):t}function he(t){let e=new WeakSet,r=n=>{if(!n||typeof n!="object"||e.has(n))return;e.add(n);let o=n.delete;if(typeof o=="function"){let i=n.isDeleted;(typeof i!="function"||!i.call(n))&&o.call(n);return}if(Array.isArray(n)){for(let i of n)r(i);return}let s=Object.getPrototypeOf(n);if(s===Object.prototype||s===null)for(let i of Object.values(n))r(i)};r(t)}var x={STRING:"System.String",INT:"System.Int32",DOUBLE:"System.Double",BOOL:"System.Boolean"},Ue="Rhino.Geometry.",ze=["WebDisplay"],_e="FileData";function ye(t){return ze.some(e=>t.includes(e))}function Ke(t){if(typeof t!="string")return t;let e=t.trim();if(!(e.startsWith("{")||e.startsWith("[")||e.startsWith('"')))return t;try{let n=JSON.parse(e);if(typeof n=="string")try{return JSON.parse(n)}catch (e2){return n}return n}catch (e3){return t}}function Qe(t,e,r){switch(e){case x.STRING:return typeof t!="string"?t:t.replace(/^"(.*)"$/,"$1");case x.INT:return Number.parseInt(t,10);case x.DOUBLE:return Number.parseFloat(t);case x.BOOL:return String(t).toLowerCase()==="true";default:return r&&e.startsWith(Ue)?me(t,e,r):t}}var U=new WeakMap;function ge(t){if(U.has(t))return U.get(t);let e=Ke(t.data);return U.set(t,e),e}function be(t,e,r,n){if(typeof t.data!="string")return t.data;let o=r?ge(t):t.data;return Qe(o,e,n)}function He(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.fileName=="string"&&typeof e.fileType=="string"&&"data"in e&&typeof e.isBase64Encoded=="boolean"&&typeof e.subFolder=="string"}function z(t){let e=_chunkCUQQ3ZBVcjs.q.call(void 0, t,"values");return Array.isArray(e)?e:[]}function _(t){return typeof t.type=="string"?t.type:""}function K(t,e){if(!(!t||typeof t!="object")){for(let r of Object.values(t))if(Array.isArray(r))for(let n of r)n&&typeof n=="object"&&e(n)}}function Te(t,e=!1,r={}){let{parseValues:n=!0,rhino:o,stringOnly:s=!1}=r,i={},a=new Set;for(let u of z(t)){let d=_chunkCUQQ3ZBVcjs.q.call(void 0, u,"paramName");K(_chunkCUQQ3ZBVcjs.q.call(void 0, u,"innerTree"),f=>{let m=_(f);if(ye(m)||s&&m!==x.STRING)return;let g=e?f.id:d;if(!g)return;let b=be(f,m,n,o);g in i?a.has(g)?i[g].push(b):(i[g]=[i[g],b],a.add(g)):i[g]=b})}return{values:i,dispose:()=>he(i)}}function Se(t){let e=[];for(let r of z(t))K(_chunkCUQQ3ZBVcjs.q.call(void 0, r,"innerTree"),n=>{if(!_(n).includes(_e))return;let o=ge(n);He(o)&&e.push(o)});return e}function De(t,e,r={}){let{parseValues:n=!0,rhino:o,stringOnly:s=!1}=r;for(let i of z(t)){let a=_chunkCUQQ3ZBVcjs.q.call(void 0, i,"innerTree"),u=!1;if("byName"in e){if(_chunkCUQQ3ZBVcjs.q.call(void 0, i,"paramName")!==e.byName)continue;u=!0}let d=[];if(K(a,f=>{if("byId"in e){if(f.id!==e.byId)return;u=!0}let m=_(f);ye(m)||s&&m!==x.STRING||d.push(be(f,m,n,o))}),u)return d.length===0?void 0:d.length===1?d[0]:d}}var k=class{constructor(e,r=!1){this.response=e;this.debug=r}getValues(e=!1,r={}){return Te(this.response,e,r)}getValue(e,r){return De(this.response,e,r)}async extractMeshesFromResponse(e){let r={debug:this.debug,...e},n;try{({getThreeMeshesFromComputeResponse:n}=await Promise.resolve().then(() => _interopRequireWildcard(require("./visualization-LS3Z7Q3N.cjs"))))}catch(o){throw new (0, _chunkCUQQ3ZBVcjs.d)("Failed to load three.js visualization module. Ensure three.js is installed as a peer dependency.",_chunkCUQQ3ZBVcjs.c.INVALID_STATE,{context:{originalError:o instanceof Error?o.message:String(o)}})}return n(this.response,r)}getFileData(){return Se(this.response)}async getAndDownloadFiles(e,r){let n=this.getFileData();await _chunkCUQQ3ZBVcjs.t.call(void 0, n,e,r)}};var Q=/^\{(-?\d+(?:;-?\d+)*)?\}$/;function C(t){if(typeof t!="object"||t===null||Array.isArray(t))return!1;let e=Object.entries(t);return e.length>0&&e.every(([r,n])=>Q.test(r)&&Array.isArray(n))}function w(t,e,r){if(t==null)return t;if(Array.isArray(t)){let o=t.map(e).filter(s=>s!==null);return o.length>0?o:void 0}let n=e(t);return n!==null?n:r?void 0:t}var V=t=>{if(typeof t=="number")return Number.isFinite(t)?t:null;if(typeof t=="string"){let e=t.trim();if(e===""||/^[+-]?0[xbo]/i.test(e))return null;let r=Number(e);return Number.isFinite(r)?r:null}return null},H=t=>{if(typeof t=="boolean")return t;if(typeof t=="string"){let e=t.trim().toLowerCase();if(e==="true")return!0;if(e==="false")return!1}return null},Je=t=>typeof t=="string"?t.length>=2&&t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t.startsWith('"')?t.slice(1):t:null,Ye=t=>{if(typeof t=="string"){let e=t.trim();return e.startsWith('"')&&e.endsWith('"')&&(e=e.slice(1,-1).trim()),e}return null};function xe(t){return e=>{if(typeof e=="object"&&e!==null)return e;if(typeof e=="string"&&e.trim()!=="")try{let r=JSON.parse(e);return typeof r=="object"&&r!==null?r:(_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Parsed value for input ${t} is not an object`),null)}catch(r){return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Failed to parse object value "${e}" for input ${t}`,r),null}return null}}function Ie(t,e,r){let n=Number(t.toFixed(e));return Math.abs(t-n)<r?n:t}function Xe(t,e){if(!Number.isFinite(t)||t===0)return .1;let r=Math.abs(t);if(r>=1){let g=String(t).split(".")[1];if(g&&g.length>0){let b=Math.min(g.length,12),S=Math.pow(10,-b),Y=Number(S.toFixed(b));return Math.abs(Y-S)<e?Y:S}return 1}let n=String(t),o=n.toLowerCase().match(/e(-?\d+)/);if(o){let m=Number(o[1]);if(m<0||n.toLowerCase().includes("e-")){let g=Math.abs(m),b=Math.pow(10,-g),S=Number(b.toFixed(g));return Math.abs(S-b)<e?S:b}return .1}let s=12,a=r.toFixed(s).replace(/0+$/,""),u=Math.min((a.split(".")[1]||"").length,s);if(u===0)return .1;let d=Math.pow(10,-u),f=Number(d.toFixed(u));return Math.abs(f-d)<e?f:d}function Ce(t){return typeof t.stepSize=="number"&&Number.isFinite(t.stepSize)&&t.stepSize>0?t.stepSize:void 0}function Ze(t,e=1e-8){let r=t.paramType==="Integer",n=Ce(t);if(C(t.default))return{default:t.default,stepSize:_nullishCoalesce(n, () => ((r?1:.1)))};if(typeof t.default=="string"&&t.default.trim()!==""&&V(t.default)===null)throw new (0, _chunkCUQQ3ZBVcjs.d)(`Invalid numeric default "${t.default}" for input "${t.name||"unknown"}"`,_chunkCUQQ3ZBVcjs.c.VALIDATION_ERROR,{context:{inputName:t.name,default:t.default}});let o=w(t.default,V,!0);if(r)return Array.isArray(o)?o=o.map(m=>typeof m=="number"?Math.round(m):m):typeof o=="number"&&(o=Math.round(o)),{default:o,stepSize:_nullishCoalesce(n, () => (1))};let s=Array.isArray(o)?o[0]:o,i;typeof s=="number"&&Number.isFinite(s)&&s!==0?i=s:typeof t.minimum=="number"&&Number.isFinite(t.minimum)&&t.minimum!==0?i=t.minimum:typeof t.maximum=="number"&&Number.isFinite(t.maximum)&&t.maximum!==0&&(i=t.maximum);let a=_nullishCoalesce(n, () => ((i!==void 0?Xe(i,e):.1))),u=0,d=String(a),f=d.toLowerCase().match(/e(-?\d+)/);if(f?u=Math.abs(Number(f[1])):u=_nullishCoalesce(_optionalChain([d, 'access', _28 => _28.split, 'call', _29 => _29("."), 'access', _30 => _30[1], 'optionalAccess', _31 => _31.length]), () => (0)),u===0&&typeof s=="number"&&s!==0&&Math.abs(s)<1){let m=Math.ceil(-Math.log10(Math.abs(s)));Number.isFinite(m)&&m>0&&(u=m)}return u=Math.min(Math.max(u,0),12),Array.isArray(o)?o=o.map(m=>typeof m=="number"?Ie(m,u,e):m):typeof o=="number"&&(o=Ie(o,u,e)),{default:o,stepSize:a}}var et={types:["Number","Integer"],parse(t,e){let{default:r,stepSize:n}=Ze(t);return{...e,paramType:t.paramType,minimum:t.minimum,maximum:t.maximum,atLeast:t.atLeast,atMost:t.atMost,stepSize:n,default:r}},fallback(t,e){let r=(_nullishCoalesce(t.atMost, () => (1)))>1,n=typeof t.minimum=="number"&&Number.isFinite(t.minimum)&&t.minimum>0?t.minimum:0;return{...e,paramType:t.paramType,minimum:t.minimum,maximum:t.maximum,atLeast:t.atLeast,atMost:t.atMost,stepSize:_nullishCoalesce(Ce(t), () => ((t.paramType==="Integer"?1:.1))),default:r?[n]:n}}},tt={types:["Boolean"],parse(t,e){if(C(t.default))return{...e,paramType:"Boolean",default:t.default};let r=w(t.default,H,!1);if(r!=null&&typeof r!="boolean"&&!Array.isArray(r))throw new (0, _chunkCUQQ3ZBVcjs.d)(`Invalid boolean default "${String(r)}" for input "${t.name||"unknown"}"`,_chunkCUQQ3ZBVcjs.c.VALIDATION_ERROR,{context:{inputName:t.name,default:t.default}});return{...e,paramType:"Boolean",default:r}},fallback(t,e){let r=(_nullishCoalesce(t.atMost, () => (1)))>1;return{...e,paramType:"Boolean",default:r?[!1]:!1}}},rt={types:["Text"],parse(t,e){let r=w(t.default,Je,!1);return{...e,paramType:"Text",default:r}},fallback(t,e){let r=(_nullishCoalesce(t.atMost, () => (1)))>1;return{...e,paramType:"Text",default:r?[""]:""}}},nt={types:["ValueList"],parse(t,e){if(!t.values||typeof t.values!="object"||Object.keys(t.values).length===0)throw _chunkCUQQ3ZBVcjs.d.missingValues(t.nickname||"unnamed","ValueList");let r=t.default;if(t.default!==void 0&&t.default!==null){if(typeof t.default=="object")throw new (0, _chunkCUQQ3ZBVcjs.d)(`ValueList input "${t.nickname||"unnamed"}" default is not a string-able value`,_chunkCUQQ3ZBVcjs.c.VALIDATION_ERROR,{context:{inputName:t.name,default:t.default}});let n=String(t.default).toLowerCase(),o=Object.keys(t.values).find(s=>s.toLowerCase()===n);o!==void 0?r=o:_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`ValueList input "${t.nickname||"unnamed"}" default value "${t.default}" is not in available values`)}return{...e,paramType:"ValueList",values:t.values,default:r}},fallback(t,e){return{...e,paramType:"ValueList",values:t.values&&typeof t.values=="object"?t.values:{},default:void 0}}},we={types:["Geometry"],parse(t,e){let r=w(t.default,xe(t.nickname||"unnamed"),!0);return{...e,paramType:"Geometry",default:r}},fallback(t,e){let r=(_nullishCoalesce(t.atMost, () => (1)))>1;return{...e,paramType:"Geometry",default:r?[null]:null}}},ot={types:["File"],parse(t,e){let r=w(t.default,xe(t.nickname||"unnamed"),!0);return{...e,paramType:"File",acceptedFormats:t.acceptedFormats,default:r}},fallback(t,e){let r=(_nullishCoalesce(t.atMost, () => (1)))>1;return{...e,paramType:"File",default:r?[null]:null}}},st={types:["Color"],parse(t,e){let r=w(t.default,Ye,!1);return{...e,paramType:"Color",default:r}},fallback(t,e){let r=(_nullishCoalesce(t.atMost, () => (1)))>1;return{...e,paramType:"Color",default:r?["0, 0, 0"]:"0, 0, 0"}}},it=[et,tt,rt,nt,we,ot,st],J=new Map(it.flatMap(t=>t.types.map(e=>[e,t]))),Ee=we;function ve(t){return _chunkCUQQ3ZBVcjs.q.call(void 0, t,"data")}function at(t){return _chunkCUQQ3ZBVcjs.q.call(void 0, t,"type")}var ut=new Set(["System.Double","System.Single","System.Decimal","System.Int32","System.Int64"]),pt=new Set(["System.Int32","System.Int64"]);function Re(t){if(typeof t.default!="object"||t.default===null)return{schema:t};if(Array.isArray(t.default))return{schema:t};if(!_chunkCUQQ3ZBVcjs.r.call(void 0, t.default,"innerTree")){let n=`Input "${_nullishCoalesce(t.name, () => ("unknown"))}" default had an unrecognized shape (no innerTree key); the default was dropped.`;return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("Unexpected structure in input.default:",t.default),{schema:{...t,default:null},warning:{code:"MALFORMED_DEFAULT",message:n}}}let e=_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t.default,"innerTree"), () => ({}));if(Object.keys(e).length===0)return{schema:{...t,default:void 0}};if(t.treeAccess||t.atMost&&t.atMost>1){let n={},o=[];for(let[i,a]of Object.entries(e)){if(!Array.isArray(a)){let d=`Input "${_nullishCoalesce(t.name, () => ("unknown"))}" default had a non-array innerTree branch ("${i}"); the default was dropped.`;return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("Unexpected structure in input.default innerTree:",t.default),{schema:{...t,default:null},warning:{code:"MALFORMED_DEFAULT",message:d}}}let u=[];for(let d of a){let f=ve(d),m=at(d);if(m&&ut.has(m)){if(typeof f=="string"&&f.trim()==="")continue;let g=V(f);if(g===null){o.push(`"${String(f)}" (${m})`);continue}u.push(pt.has(m)?Math.round(g):g);continue}if(m==="System.Boolean"){let g=H(f);if(g===null){o.push(`"${String(f)}" (${m})`);continue}u.push(g);continue}if(typeof f=="string"&&_optionalChain([m, 'optionalAccess', _32 => _32.startsWith, 'call', _33 => _33("Rhino.Geometry")])){try{u.push(JSON.parse(f))}catch (e4){u.push(f)}continue}u.push(f)}n[i]=u}let s;if(o.length>0){let i=`Input "${_nullishCoalesce(t.name, () => ("unknown"))}" default contained ${o.length} tree value(s) that could not be parsed and were dropped: ${o.join(", ")}.`;_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(i),s={code:"MALFORMED_DEFAULT",message:i}}return{schema:{...t,default:n},...s&&{warning:s}}}let r=[];for(let n of Object.values(e))Array.isArray(n)&&n.forEach(o=>{o&&typeof o=="object"&&_chunkCUQQ3ZBVcjs.r.call(void 0, o,"data")&&r.push(ve(o))});return r.length===0?{schema:{...t,default:void 0}}:r.length===1?{schema:{...t,default:r[0]}}:{schema:{...t,default:r}}}var lt=new Map([...J.keys()].map(t=>[t.toLowerCase(),t]));function ct(t){return _nullishCoalesce(lt.get(_optionalChain([t, 'optionalAccess', _34 => _34.toLowerCase, 'call', _35 => _35()])), () => (t))}function Ae(t){return Pe(t).input}function Pe(t){let e={description:t.description,name:t.name,nickname:t.nickname,treeAccess:t.treeAccess,groupName:_nullishCoalesce(t.groupName, () => (void 0)),id:t.id},r=ct(t.paramType),n={...t,paramType:r},o;try{let{schema:i,warning:a}=Re(n);n=i,o=a&&{inputName:t.name||"unknown",paramType:t.paramType,message:a.message,code:a.code}}catch(i){n={...n,default:null},o={inputName:t.name||"unknown",paramType:t.paramType,message:`Input "${_nullishCoalesce(t.name, () => ("unknown"))}" default could not be normalized and was dropped: ${i instanceof Error?i.message:String(i)}`,code:"MALFORMED_DEFAULT"}}let s=J.get(r);try{if(!s)throw _chunkCUQQ3ZBVcjs.d.unknownParamType(r,t.name);return{input:s.parse(n,e),error:o,...o&&{errors:[o]}}}catch(i){if(i instanceof _chunkCUQQ3ZBVcjs.d){_chunkCUQQ3ZBVcjs.e.call(void 0, ).error(`Validation error for input ${t.name||"unknown"}:`,i.message);let a={inputName:t.name||"unknown",paramType:t.paramType,message:i.message,code:i.code};return{input:(_nullishCoalesce(s, () => (Ee))).fallback(n,e),error:a,errors:o?[o,a]:[a]}}throw new (0, _chunkCUQQ3ZBVcjs.d)(i instanceof Error?i.message:String(i),"VALIDATION_ERROR",{context:{paramName:t.name,paramType:r},originalError:i instanceof Error?i:new Error(String(i))})}}function ke(t){return L(t).inputs}function L(t){let e=[],r=[];for(let n of t){let{input:o,errors:s}=Pe(n);e.push(o),s&&r.push(...s)}return{inputs:e,parseErrors:r}}function Oe(t){let e=_chunkCUQQ3ZBVcjs.q.call(void 0, t,"stepSize");return{id:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"id"), () => ("")),name:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"name"), () => ("")),nickname:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"nickname"), () => (null)),description:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"description"), () => ("")),paramType:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"paramType"), () => ("")),treeAccess:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"treeAccess"), () => (!1)),minimum:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"minimum"), () => (null)),maximum:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"maximum"), () => (null)),atLeast:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"atLeast"), () => (1)),atMost:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"atMost"), () => (1)),stepSize:typeof e=="number"&&Number.isFinite(e)?e:void 0,default:_chunkCUQQ3ZBVcjs.q.call(void 0, t,"default"),values:_chunkCUQQ3ZBVcjs.q.call(void 0, t,"values"),acceptedFormats:_chunkCUQQ3ZBVcjs.q.call(void 0, t,"acceptedFormats"),groupName:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"groupName"), () => (null))}}function Fe(t){return{name:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"name"), () => ("")),nickname:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"nickname"), () => (null)),paramType:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"paramType"), () => ("")),id:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"id"), () => (""))}}async function P(t,e){let r=v(t,[]),n={};if(r.algo&&(n.algo=r.algo),r.pointer&&(n.pointer=r.pointer),!n.algo&&!n.pointer)throw new (0, _chunkCUQQ3ZBVcjs.d)("Definition must resolve to either a URL pointer or base64 algo",_chunkCUQQ3ZBVcjs.c.INVALID_INPUT,{context:{definition:t}});let o=await _chunkCUQQ3ZBVcjs.l.call(void 0, "io",n,e);if(!o||typeof o!="object")throw new (0, _chunkCUQQ3ZBVcjs.d)("Invalid IO response structure",_chunkCUQQ3ZBVcjs.c.INVALID_INPUT,{context:{response:o,definition:t}});let s=Ne(_chunkCUQQ3ZBVcjs.q.call(void 0, o,"warnings")),i=Ne(_chunkCUQQ3ZBVcjs.q.call(void 0, o,"errors")),a=_chunkCUQQ3ZBVcjs.q.call(void 0, o,"inputs"),u=_chunkCUQQ3ZBVcjs.q.call(void 0, o,"outputs");return{inputs:Array.isArray(a)?a.map(Oe):[],outputs:Array.isArray(u)?u.map(Fe):[],...s&&{loadWarnings:s},...i&&{loadErrors:i}}}function Ne(t){if(!Array.isArray(t))return;let e=t.map(ft).filter(r=>r!==void 0);return e.length>0?e:void 0}function ft(t){if(t==null)return;let e;if(typeof t=="string")e=t;else if(typeof t=="object"){let r=_chunkCUQQ3ZBVcjs.q.call(void 0, t,"message");if(typeof r=="string"&&r.trim().length>0)e=r;else try{e=_nullishCoalesce(JSON.stringify(t), () => (String(t)))}catch (e5){e=String(t)}}else e=String(t);return e.trim().length>0?e:void 0}async function M(t,e){D("fetchParsedDefinitionIO",_nullishCoalesce(e.suppressBrowserWarning, () => (e.suppressClientSideWarning)));let{inputs:r,outputs:n,loadWarnings:o,loadErrors:s}=await P(t,e),{inputs:i,parseErrors:a}=L(r);return{inputs:i,outputs:n,...a.length>0&&{parseErrors:a},...o&&{loadWarnings:o},...s&&{loadErrors:s}}}var W=class t{constructor(e){_chunkCUQQ3ZBVcjs.b.call(void 0, this,"innerTree");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"paramName");this.paramName=e,this.innerTree={}}append(e,r){let n=t.formatPathString(e);this.innerTree[n]||(this.innerTree[n]=[]);let o=r.map(s=>({data:t.serializeValue(s)}));return this.innerTree[n].push(...o),this}appendSingle(e,r){return this.append(e,[r])}fromDataTreeDefault(e){this.innerTree={};for(let[r,n]of Object.entries(e)){if(!Array.isArray(n))continue;let o=t.parsePathString(r);this.append(o,n)}return this}appendFlat(e){let r=Array.isArray(e)?e:[e];return this.append([0],r)}flatten(){let e=[];for(let r of Object.values(this.innerTree))if(Array.isArray(r))for(let n of r)e.push(t.deserializeValue(n.data));return e}getPaths(){return Object.keys(this.innerTree)}getPath(e){let r=t.formatPathString(e),n=this.innerTree[r];if(n)return n.map(o=>t.deserializeValue(o.data))}toComputeFormat(){return{ParamName:this.paramName,InnerTree:this.innerTree}}getInnerTree(){return this.innerTree}getParamName(){return this.paramName}static fromInputParams(e){return e.filter(r=>t.hasValidValue(r.default)).map(r=>{let n=new t(r.nickname||"unnamed"),o=r.default;if(r.treeAccess&&C(o))n.fromDataTreeDefault(o),t.isNumericInput(r)&&n.applyNumericConstraints(r.minimum,r.maximum,r.nickname||"unnamed");else{let s=Array.isArray(o)?o:[o],i=t.processValues(s,r);n.appendFlat(i)}return n.toComputeFormat()})}static fromInputParam(e){return t.hasValidValue(e.default)?t.fromInputParams([e])[0]:void 0}static replaceTreeValue(e,r,n){let o=e.length>0&&e[0]instanceof t,s=t.buildFromValue(r,n);if(o){let d=e.slice(),f=d.findIndex(m=>m.getParamName()===r);return f!==-1?d[f]=s:d.push(s),d}let i=e.slice(),a=s.toComputeFormat(),u=i.findIndex(d=>d.ParamName===r);return u!==-1?i[u]=a:i.push(a),i}static buildFromValue(e,r){let n=new t(e);return C(r)?n.fromDataTreeDefault(r):n.appendFlat(r),n}static getTreeValue(e,r){let o=e.length>0&&e[0]instanceof t?t.readFromBuilders(e,r):t.readFromDataTrees(e,r);return o===null||o.length===0?null:o.length===1?o[0]:o}static readFromBuilders(e,r){let n=e.find(o=>o.getParamName()===r);return n?n.flatten():null}static readFromDataTrees(e,r){let n=e.find(i=>i.ParamName===r);if(!_optionalChain([n, 'optionalAccess', _36 => _36.InnerTree]))return null;let o=Object.keys(n.InnerTree)[0];if(!o)return null;let s=n.InnerTree[o];return Array.isArray(s)?s.map(i=>_optionalChain([i, 'optionalAccess', _37 => _37.data])!==void 0?t.deserializeValue(i.data):null):_optionalChain([s, 'optionalAccess', _38 => _38.data])!==void 0?[t.deserializeValue(s.data)]:s!==void 0?[s]:null}static parsePathString(e){let r=e.match(Q);if(!r)throw new Error(`Invalid Grasshopper tree path: "${e}". Expected "{}", "{0}", or "{0;1;2}" (negative indices allowed, no empty segments).`);return r[1]?r[1].split(";").map(Number):[]}static formatPathString(e){return`{${e.join(";")}}`}applyNumericConstraints(e,r,n){for(let o of Object.values(this.innerTree))if(Array.isArray(o))for(let s of o){let i=t.deserializeValue(s.data);if(typeof i=="number"){let a=t.clampValue(i,e,r,n);s.data=t.serializeValue(a)}}}static serializeValue(e){return typeof e=="boolean"||typeof e=="number"||typeof e=="string"?e:typeof e=="object"&&e!==null?JSON.stringify(e):String(e)}static deserializeValue(e){if(typeof e=="boolean"||typeof e=="number"||typeof e!="string")return e;if(e.startsWith("{")||e.startsWith("["))try{return JSON.parse(e)}catch (e6){return e}let r=Number(e);return Number.isFinite(r)&&String(r)===e?r:e==="true"?!0:e==="false"?!1:e}static hasValidValue(e){return e==null?!1:typeof e=="string"?!0:!(Array.isArray(e)&&e.length===0||typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0)}static isNumericInput(e){return e.paramType==="Number"||e.paramType==="Integer"}static processValues(e,r){return e.map(n=>t.isNumericInput(r)&&typeof n=="number"?t.clampValue(n,r.minimum,r.maximum,r.nickname||"unnamed"):n).filter(n=>n!=null)}static clampValue(e,r,n,o){let s=e;return r!=null&&s<r&&(_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`${o}: ${e} below min ${r}, clamping`),s=r),n!=null&&s>n&&(_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`${o}: ${e} above max ${n}, clamping`),s=n),s}};exports.a = T; exports.b = E; exports.c = $; exports.d = pe; exports.e = R; exports.f = I; exports.g = A; exports.h = k; exports.i = Ae; exports.j = ke; exports.k = P; exports.l = M; exports.m = W;
|
|
2
|
+
//# sourceMappingURL=chunk-WWD655BZ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["d:\\Coding\\selva-compute\\dist\\chunk-WWD655BZ.cjs"],"names":[],"mappings":"AAAA,2/BAA+H,IAAK,EAAE,CAAC,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,MAAM,CAAC,GAAG,kBAAE,UAAU,qBAAC,OAAO,6BAAE,QAAQ,6BAAE,MAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,uBAAO,CAAC,6BAAE,WAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,iCAAC,CAAE,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,8GAA8G,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,OAAO,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,WAAW,UAAU,CAAC,EAAE,OAAO,CAAC,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC,uCAAuC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,WAAW,mBAAC,CAAC,CAAC,CAAC,IAAI,GAAG,mBAAC,CAAC,qBAAqB,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,iCAAC,CAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,iCAAC,CAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,kBAAC,iCAAC,CAAE,CAAC,WAAW,CAAC,SAAE,aAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAA","file":"D:\\Coding\\selva-compute\\dist\\chunk-WWD655BZ.cjs","sourcesContent":[null]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as l,c as h,d as c,e as y,h as X,i as Z,k as ee,l as O,m as te,n as re,q as p,r as j,t as F}from"./chunk-WPB2LKCD.js";var ne=new Set;function Me(){if(typeof window>"u"||globalThis.process?.versions?.node!=null)return!1;let e=globalThis.navigator,r=typeof e?.userAgent=="string"?e.userAgent:"";return!/jsdom/i.test(r)}function D(t,e){e||Me()&&!ne.has(t)&&(ne.add(t),y().warn(`Warning: ${t} is running on the client side. For better performance and security, consider running this on the server side.`))}function T(t){return typeof t=="object"&&!(t instanceof Uint8Array)&&typeof t.key=="string"&&typeof t.load=="function"}var Ge="Unable to load grasshopper definition";function Ve(t){return t instanceof c?t.code===h.DEFINITION_NOT_CACHED||t.message.includes(Ge):!1}function Le(t,e){if(!e)return;let r=p(t,"values");if(!Array.isArray(r)||r.length===0)return;let n=[];for(let s of r){let i=p(s,"innerTree");(!i||Object.keys(i).length===0)&&n.push(p(s,"paramName")??"<unnamed>")}if(n.length===0)return;let o=n.length===r.length?"all":`${n.length}/${r.length}`;y().warn(`Solve returned empty output(s) (${o}): ${n.join(", ")}. These parameters produced no data \u2014 check the definition's inputs and the branch feeding each.`)}async function E(t,e,r){D("solveGrasshopperDefinition",r.suppressBrowserWarning??r.suppressClientSideWarning);let n=await B(e),{response:o}=await N(v(n,t),r);return o}async function oe(t,e,r){D("solveGrasshopperDefinitionWithCacheKey",r.suppressBrowserWarning??r.suppressClientSideWarning);let n=await B(e);return N(v(n,t),r)}async function se(t,e,r,n){D("solveByCacheKey",n.suppressBrowserWarning??n.suppressClientSideWarning);let o={algo:null,pointer:e,values:t};try{return{...await N(o,n),missed:!1}}catch(s){if(!Ve(s))throw s;let i=await B(r);return{...await N(v(i,t),n),missed:!0}}}async function B(t){if(!T(t))return t;try{return await t.load()}catch(e){throw new c(`Failed to load definition bytes for ref '${t.key}'`,h.INVALID_INPUT,{context:{definitionKey:t.key},originalError:e instanceof Error?e:new Error(String(e))})}}async function N(t,e){We(t,e);let r=await O("grasshopper",t,e),{pointer:n,algo:o,...s}=r,i=s;return Le(i,e.debug),{response:i,cacheKey:typeof n=="string"?n:null}}function v(t,e){let r={algo:null,pointer:null,values:e};return t instanceof Uint8Array?r.algo=ee(t):/^https?:\/\//i.test(t)?r.pointer=t:r.algo=Z(t)??X(t),r}function We(t,e){e.cachesolve!=null&&(t.cachesolve=e.cachesolve),e.cacheerroredsolves!=null&&(t.cacheerroredsolves=e.cacheerroredsolves),e.modelunits!=null&&(t.modelunits=e.modelunits),e.angletolerance!=null&&(t.angletolerance=e.angletolerance),e.absolutetolerance!=null&&(t.absolutetolerance=e.absolutetolerance),e.dataversion!=null&&(t.dataversion=e.dataversion)}function $(t){let e=new WeakSet,r=n=>{if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="number")return Number.isFinite(n)?String(n):"null";if(typeof n=="string"||typeof n=="boolean")return JSON.stringify(n);if(typeof n=="bigint")return`${n}n`;if(n instanceof Uint8Array)return`{"__u8":${n.length},"hash":"${ue(n)}"}`;if(Array.isArray(n)){if(e.has(n))return'"[Circular]"';e.add(n);let o=[];for(let s=0;s<n.length;s++)o.push(r(n[s]));return e.delete(n),`[${o.join(",")}]`}if(typeof n=="object"){if(e.has(n))return'"[Circular]"';e.add(n);let o;return typeof n.toJSON=="function"?o=r(n.toJSON()):n instanceof Map?o=`{"__map":[${[...n.entries()].map(([i,a])=>`[${r(i)},${r(a)}]`).sort().join(",")}]}`:n instanceof Set?o=`{"__set":[${[...n.values()].map(r).sort().join(",")}]}`:o=`{${Object.keys(n).sort().map(a=>`${JSON.stringify(a)}:${r(n[a])}`).join(",")}}`,e.delete(n),o}return"null"};return r(t)}function ie(t,e){let r=2166136261;for(let n=0;n<t;n++)r^=e(n),r=r+((r<<1)+(r<<4)+(r<<7)+(r<<8)+(r<<24))>>>0;return r.toString(16).padStart(8,"0")}function ae(t){return ie(t.length,e=>t.charCodeAt(e))}function ue(t){return ie(t.length,e=>t[e])}function pe(t,e){return q(R(t),e)}function q(t,e){let r=$(e);return`${t}|t:${r.length}:${ae(r)}`}function R(t){return T(t)?`r:${t.key}`:typeof t=="string"?`s:${t.length}:${ae(t)}`:`u8:${t.length}:${ue(t)}`}var je=100;function Be(t){return typeof t!="string"?!0:!/^https?:\/\//i.test(t)}var I=class{constructor(e,r,n={},o){l(this,"executor");l(this,"baseConfig");l(this,"mode");l(this,"maxConcurrent");l(this,"maxQueueDepth");l(this,"queueWaitMs");l(this,"timeoutMs");l(this,"retry");l(this,"cacheEnabled");l(this,"cacheMax");l(this,"cacheTtl");l(this,"cacheErroredSolves");l(this,"cache",new Map);l(this,"cacheKeyExecutor");l(this,"reuseServerDefinitionCache");l(this,"serverCacheKeys",new Map);l(this,"onStart");l(this,"onSettle");l(this,"onSuperseded");l(this,"subscribers",new Set);l(this,"inFlight",new Set);l(this,"pendingForLatestWins",null);l(this,"fifoQueue",[]);l(this,"_lastResult",null);l(this,"_lastError",null);l(this,"_lastDurationMs",null);l(this,"solveSeq",0);l(this,"lastStateSeq",0);l(this,"disposed",!1);this.executor=e,this.cacheKeyExecutor=o,this.baseConfig=r,this.mode=n.mode??"latest-wins",this.maxConcurrent=Math.max(1,n.maxConcurrent??(this.mode==="parallel"?4:1)),this.maxQueueDepth=n.maxQueueDepth!==void 0&&n.maxQueueDepth>0?Math.floor(n.maxQueueDepth):void 0,this.queueWaitMs=n.queueWaitMs!==void 0&&n.queueWaitMs>0?n.queueWaitMs:void 0,this.timeoutMs=n.timeoutMs,this.retry=n.retry;let s=n.cache;this.cacheEnabled=s!==void 0&&s!==!1;let i=typeof s=="object"?s:{};this.cacheMax=i.maxEntries??50,this.cacheTtl=i.ttlMs??0,this.cacheErroredSolves=i.cacheErroredSolves??!0,this.reuseServerDefinitionCache=!!o&&(n.reuseServerDefinitionCache??!0),this.onStart=n.onStart,this.onSettle=n.onSettle,this.onSuperseded=n.onSuperseded}get isSolving(){return this.inFlight.size>0}get hasPending(){return this.pendingForLatestWins!==null||this.fifoQueue.length>0}get inFlightCount(){return this.inFlight.size}get queueDepth(){return this.fifoQueue.length+(this.pendingForLatestWins?1:0)}get lastResult(){return this._lastResult}get lastError(){return this._lastError}get lastDurationMs(){return this._lastDurationMs}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}notify(){for(let e of this.subscribers)try{e()}catch(r){y().error("[SolveScheduler] subscriber threw:",r)}}solve(e,r,n){if(this.disposed)return Promise.reject(new c("SolveScheduler has been disposed and cannot be used",h.INVALID_STATE));let o=R(e),s=q(o,r),i=++this.solveSeq,a={key:s,enqueuedAt:Date.now(),startedAt:null};if(n?.signal?.aborted)return Promise.reject(this.makeAbortError(a));if(this.cacheEnabled){let u=this.readCache(s);if(u){this.mode==="latest-wins"&&this.supersedeCurrent();let d={status:"success",response:u,durationMs:0,fromCache:!0};return this.writeLastState(i,{result:u,durationMs:0}),this.runHook(this.onStart,a),this.runHook(this.onSettle,a,d),this.notify(),Promise.resolve(u)}}return new Promise((u,d)=>{let f={definition:e,dataTree:r,definitionHash:o,ctx:a,seq:i,resolve:u,reject:d,externalSignal:n?.signal};f.externalSignal&&(f.queuedAbortHandler=()=>this.abortQueuedItem(f),f.externalSignal.addEventListener("abort",f.queuedAbortHandler,{once:!0})),this.enqueue(f)})}writeLastState(e,r){return e<this.lastStateSeq?!1:(this.lastStateSeq=e,"result"in r?(this._lastResult=r.result,this._lastError=null):this._lastError=r.error,this._lastDurationMs=r.durationMs,!0)}supersedeCurrent(){this.pendingForLatestWins&&(this.supersede(this.pendingForLatestWins),this.pendingForLatestWins=null);for(let e of this.inFlight)this.supersede(e),e.controller.abort()}abortQueuedItem(e){this.pendingForLatestWins===e&&(this.pendingForLatestWins=null);let r=this.fifoQueue.indexOf(e);r>=0&&this.fifoQueue.splice(r,1),this.rejectAsAborted(e),this.notify()}shedAsQueueFull(e){let r=new c("Solve queue is full; request shed (backpressure)",h.QUEUE_FULL,{statusCode:503,context:{key:e.ctx.key,queueDepth:this.fifoQueue.length,maxQueueDepth:this.maxQueueDepth}});this.settleError(e,r)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:r,durationMs:0}),this.notify()}armQueueWaitTimer(e){if(this.queueWaitMs===void 0)return;let r=this.queueWaitMs;e.queueWaitTimer=setTimeout(()=>{if(e.settled)return;let n=this.fifoQueue.indexOf(e);n>=0&&this.fifoQueue.splice(n,1);let o=new c(`Solve waited longer than ${r}ms in queue; shed (backpressure)`,h.QUEUE_TIMEOUT,{statusCode:503,context:{key:e.ctx.key,waitedMs:Date.now()-e.ctx.enqueuedAt,queueWaitMs:r}});this.settleError(e,o)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:o,durationMs:0}),this.notify()},r)}clearQueueWaitTimer(e){e.queueWaitTimer!==void 0&&(clearTimeout(e.queueWaitTimer),e.queueWaitTimer=void 0)}enqueue(e){switch(this.mode){case"latest-wins":{this.supersedeCurrent(),this.inFlight.size===0?this.execute(e):this.pendingForLatestWins=e;break}case"queue":case"parallel":{this.inFlight.size<this.maxConcurrent?this.execute(e):this.maxQueueDepth!==void 0&&this.fifoQueue.length>=this.maxQueueDepth?this.shedAsQueueFull(e):(this.armQueueWaitTimer(e),this.fifoQueue.push(e));break}}this.notify()}async execute(e){let r=new AbortController,n=e;n.controller=r,this.inFlight.add(n),e.ctx.startedAt=Date.now(),this.clearQueueWaitTimer(e),this.removeQueuedAbortHandler(e);let o=()=>r.abort();e.externalSignal?.addEventListener("abort",o,{once:!0}),this.runHook(this.onStart,e.ctx),this.notify();let s=performance.now();try{let i={...this.baseConfig,signal:r.signal,...this.timeoutMs!==void 0&&{timeoutMs:this.timeoutMs},...this.retry!==void 0&&{retry:this.retry}},{response:a,definitionReuploaded:u}=await this.runExecutor(e.definition,e.dataTree,e.definitionHash,i),d=performance.now()-s;if(this.cacheEnabled&&this.writeCache(e.ctx.key,a),!this.settleSuccess(e,a))return;this.writeLastState(e.seq,{result:a,durationMs:d}),this.runHook(this.onSettle,e.ctx,{status:"success",response:a,durationMs:d,fromCache:!1,definitionReuploaded:u})}catch(i){let a=performance.now()-s,u=this.normalizeExecutionError(i,n);this.writeLastState(e.seq,{error:u,durationMs:a}),this.settleError(e,u)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:u,durationMs:a})}finally{e.externalSignal?.removeEventListener("abort",o),this.inFlight.delete(n),this.drainNext(),this.notify()}}async runExecutor(e,r,n,o){if(!this.cacheKeyExecutor||!this.reuseServerDefinitionCache||!Be(e))return{response:await this.executor(e,r,o)};let s=n,i=this.serverCacheKeys.get(s)??null,a=await this.cacheKeyExecutor(e,r,i,o);if(a.cacheKey)for(this.serverCacheKeys.delete(s),this.serverCacheKeys.set(s,a.cacheKey);this.serverCacheKeys.size>je;){let u=this.serverCacheKeys.keys().next().value;if(u===void 0)break;this.serverCacheKeys.delete(u)}else this.serverCacheKeys.delete(s);return{response:a.response,definitionReuploaded:a.missed}}drainNext(){if(!this.disposed){if(this.mode==="latest-wins"){if(this.pendingForLatestWins&&this.inFlight.size===0){let e=this.pendingForLatestWins;this.pendingForLatestWins=null,this.execute(e)}return}for(;this.fifoQueue.length>0&&this.inFlight.size<this.maxConcurrent;){let e=this.fifoQueue.shift();this.execute(e)}}}supersede(e){let r=new c("Superseded by newer solve",h.SUPERSEDED,{context:{key:e.ctx.key,enqueuedAt:e.ctx.enqueuedAt}});this.settleError(e,r)&&this.runHook(this.onSuperseded,e.ctx)}makeAbortError(e){return new c("Request aborted by caller",h.ABORTED,{context:{key:e.key,enqueuedAt:e.enqueuedAt}})}settleError(e,r){return e.settled?!1:(e.settled={error:r},this.clearQueueWaitTimer(e),this.removeQueuedAbortHandler(e),e.reject(r),!0)}settleSuccess(e,r){return e.settled?!1:(e.settled={ok:!0},this.clearQueueWaitTimer(e),this.removeQueuedAbortHandler(e),e.resolve(r),!0)}removeQueuedAbortHandler(e){e.queuedAbortHandler&&e.externalSignal&&e.externalSignal.removeEventListener("abort",e.queuedAbortHandler),e.queuedAbortHandler=void 0}isAbortLikeError(e){if(e instanceof Error){if(e.name==="AbortError")return!0;if(typeof DOMException<"u"&&e instanceof DOMException)return e.name==="AbortError"}return!1}normalizeExecutionError(e,r){return r.settled&&"error"in r.settled?r.settled.error:e instanceof c?e:this.isAbortLikeError(e)?this.makeAbortError(r.ctx):new c(e instanceof Error?e.message:String(e),h.UNKNOWN_ERROR,{originalError:e instanceof Error?e:new Error(String(e))})}cancelAll(){for(this.pendingForLatestWins&&(this.rejectAsAborted(this.pendingForLatestWins),this.pendingForLatestWins=null);this.fifoQueue.length>0;){let e=this.fifoQueue.shift();this.rejectAsAborted(e)}for(let e of this.inFlight){let r=this.makeAbortError(e.ctx);this.settleError(e,r)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:r,durationMs:e.ctx.startedAt?Date.now()-e.ctx.startedAt:0}),e.controller.abort()}this.notify()}rejectAsAborted(e){let r=this.makeAbortError(e.ctx);this.settleError(e,r)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:r,durationMs:0})}readCache(e){if(!this.cacheEnabled)return null;let r=this.cache.get(e);return r?this.cacheTtl>0&&Date.now()-r.insertedAt>this.cacheTtl?(this.cache.delete(e),null):(this.cache.delete(e),this.cache.set(e,r),r.response):null}writeCache(e,r){if(this.cacheEnabled&&!(!this.cacheErroredSolves&&r.errors&&r.errors.length>0))for(this.cache.set(e,{response:r,insertedAt:Date.now()});this.cache.size>this.cacheMax;){let n=this.cache.keys().next().value;if(n===void 0)break;this.cache.delete(n)}}clearCache(){this.cache.clear()}dispose(){this.disposed||(this.disposed=!0,this.cancelAll(),this.subscribers.clear(),this.cache.clear())}runHook(e,...r){if(e)try{e(...r)}catch(n){y().error("[SolveScheduler] hook threw:",n)}}};function le(t){return T(t)?`ref:${t.key}`:typeof t=="string"&&t.length<200?t:"...content..."}function ce(t){return Array.isArray(t)?t.map(e=>{let r=0,n=0,o=p(e,"innerTree");if(o&&typeof o=="object"){for(let s of Object.values(o))if(Array.isArray(s)){r+=s.length;for(let i of s){let a=i?.data;typeof a=="string"&&(n+=a.length)}}}return{param:p(e,"paramName")??"<unnamed>",items:r,bytes:n}}):[]}var A=class t{constructor(e){l(this,"config");l(this,"serverStats");l(this,"disposed",!1);this.config=this.normalizeComputeConfig(e),this.serverStats=new re(this.config.serverUrl,this.config.apiKey)}static async create(e){let r=new t(e),n=Math.max(1,(e.retry?.attempts??2)+1),o=e.retry?.baseDelayMs??250,s=e.retry?.maxDelayMs??1e3;for(let i=0;i<n;i++){if(await r.serverStats.isServerOnline())return r;if(i<n-1){let a=Math.min(o*2**i,s);await new Promise(u=>setTimeout(u,a))}}throw await r.dispose(),new c("Rhino Compute server is not online",h.NETWORK_ERROR,{context:{serverUrl:r.config.serverUrl,attempts:n}})}getConfig(){return this.ensureNotDisposed(),{...this.config}}async getIO(e){return this.ensureNotDisposed(),M(e,this.config)}async getRawIO(e){return this.ensureNotDisposed(),P(e,this.config)}async solve(e,r,n){this.ensureNotDisposed();try{if(typeof e=="string"&&!e?.trim())throw new c("Definition URL/content is required",h.INVALID_INPUT,{context:{receivedUrl:e}});if(e instanceof Uint8Array&&e.length===0)throw new c("Definition content is empty",h.INVALID_INPUT);if(T(e)&&!e.key.trim())throw new c("DefinitionRef key is empty",h.INVALID_INPUT);let o={...this.config,...n?.signal!==void 0&&{signal:n.signal},...n?.timeoutMs!==void 0&&{timeoutMs:n.timeoutMs},...n?.retry!==void 0&&{retry:n.retry}},s=await E(r,e,o);if(s?.errors&&s.errors.length>0)throw new c(s.errors.join("; ")||"Computation failed",h.COMPUTATION_ERROR,{context:{definition:le(e),inputSummary:ce(r),errors:s.errors,warnings:s.warnings,values:s.values}});return s}catch(o){throw this.config.debug&&y().error("Compute failed:",o),o instanceof c?o:new c(o instanceof Error?o.message:String(o),h.COMPUTATION_ERROR,{context:{definition:le(e),inputSummary:ce(r)},originalError:o instanceof Error?o:new Error(String(o))})}}createScheduler(e){this.ensureNotDisposed();let r=(o,s,i)=>E(s,o,i),n=(o,s,i,a)=>i===null?oe(s,o,a).then(u=>({...u,missed:!1})):se(s,i,o,a);return new I(r,this.config,e,n)}async dispose(){this.disposed||(this.disposed=!0,await this.serverStats.dispose())}ensureNotDisposed(){if(this.disposed)throw new c("GrasshopperClient has been disposed and cannot be used",h.INVALID_STATE)}normalizeComputeConfig(e){return{...e,serverUrl:te(e.serverUrl),apiKey:e.apiKey,authToken:e.authToken,debug:e.debug??!1,suppressBrowserWarning:e.suppressBrowserWarning??e.suppressClientSideWarning}}};var G=new Map;function de(t,e){G.set(t,e)}de("Rhino.Geometry.Point3d",(t,e)=>{let r=e;return!r||typeof r.X!="number"?null:new t.Point([r.X,r.Y,r.Z])});de("Rhino.Geometry.Line",(t,e)=>{let r=e;return!r||!r.From||!r.To?null:new t.Line([r.From.X,r.From.Y,r.From.Z],[r.To.X,r.To.Y,r.To.Z])});function $e(t){if(G.has(t))return G.get(t);for(let[e,r]of G)if(t.startsWith(e))return r}function qe(t){return!!(t&&typeof t=="object"&&typeof t.data=="string")}function fe(t,e){return{__decodeError:!0,type:t,raw:e}}function me(t,e,r){let n=$e(e),o=!1;if(n)try{let s=n(r,t);if(s!=null)return s}catch(s){y().warn(`Failed to decode Rhino type ${e}:`,s),o=!0}try{if(qe(t))return r.CommonObject.decode(t)}catch(s){return y().warn(`Failed to decode ${e} with CommonObject:`,s),fe(e,t)}return o?fe(e,t):t}function he(t){let e=new WeakSet,r=n=>{if(!n||typeof n!="object"||e.has(n))return;e.add(n);let o=n.delete;if(typeof o=="function"){let i=n.isDeleted;(typeof i!="function"||!i.call(n))&&o.call(n);return}if(Array.isArray(n)){for(let i of n)r(i);return}let s=Object.getPrototypeOf(n);if(s===Object.prototype||s===null)for(let i of Object.values(n))r(i)};r(t)}var x={STRING:"System.String",INT:"System.Int32",DOUBLE:"System.Double",BOOL:"System.Boolean"},Ue="Rhino.Geometry.",ze=["WebDisplay"],_e="FileData";function ye(t){return ze.some(e=>t.includes(e))}function Ke(t){if(typeof t!="string")return t;let e=t.trim();if(!(e.startsWith("{")||e.startsWith("[")||e.startsWith('"')))return t;try{let n=JSON.parse(e);if(typeof n=="string")try{return JSON.parse(n)}catch{return n}return n}catch{return t}}function Qe(t,e,r){switch(e){case x.STRING:return typeof t!="string"?t:t.replace(/^"(.*)"$/,"$1");case x.INT:return Number.parseInt(t,10);case x.DOUBLE:return Number.parseFloat(t);case x.BOOL:return String(t).toLowerCase()==="true";default:return r&&e.startsWith(Ue)?me(t,e,r):t}}var U=new WeakMap;function ge(t){if(U.has(t))return U.get(t);let e=Ke(t.data);return U.set(t,e),e}function be(t,e,r,n){if(typeof t.data!="string")return t.data;let o=r?ge(t):t.data;return Qe(o,e,n)}function He(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.fileName=="string"&&typeof e.fileType=="string"&&"data"in e&&typeof e.isBase64Encoded=="boolean"&&typeof e.subFolder=="string"}function z(t){let e=p(t,"values");return Array.isArray(e)?e:[]}function _(t){return typeof t.type=="string"?t.type:""}function K(t,e){if(!(!t||typeof t!="object")){for(let r of Object.values(t))if(Array.isArray(r))for(let n of r)n&&typeof n=="object"&&e(n)}}function Te(t,e=!1,r={}){let{parseValues:n=!0,rhino:o,stringOnly:s=!1}=r,i={},a=new Set;for(let u of z(t)){let d=p(u,"paramName");K(p(u,"innerTree"),f=>{let m=_(f);if(ye(m)||s&&m!==x.STRING)return;let g=e?f.id:d;if(!g)return;let b=be(f,m,n,o);g in i?a.has(g)?i[g].push(b):(i[g]=[i[g],b],a.add(g)):i[g]=b})}return{values:i,dispose:()=>he(i)}}function Se(t){let e=[];for(let r of z(t))K(p(r,"innerTree"),n=>{if(!_(n).includes(_e))return;let o=ge(n);He(o)&&e.push(o)});return e}function De(t,e,r={}){let{parseValues:n=!0,rhino:o,stringOnly:s=!1}=r;for(let i of z(t)){let a=p(i,"innerTree"),u=!1;if("byName"in e){if(p(i,"paramName")!==e.byName)continue;u=!0}let d=[];if(K(a,f=>{if("byId"in e){if(f.id!==e.byId)return;u=!0}let m=_(f);ye(m)||s&&m!==x.STRING||d.push(be(f,m,n,o))}),u)return d.length===0?void 0:d.length===1?d[0]:d}}var k=class{constructor(e,r=!1){this.response=e;this.debug=r}getValues(e=!1,r={}){return Te(this.response,e,r)}getValue(e,r){return De(this.response,e,r)}async extractMeshesFromResponse(e){let r={debug:this.debug,...e},n;try{({getThreeMeshesFromComputeResponse:n}=await import("./visualization-QCI36RHC.js"))}catch(o){throw new c("Failed to load three.js visualization module. Ensure three.js is installed as a peer dependency.",h.INVALID_STATE,{context:{originalError:o instanceof Error?o.message:String(o)}})}return n(this.response,r)}getFileData(){return Se(this.response)}async getAndDownloadFiles(e,r){let n=this.getFileData();await F(n,e,r)}};var Q=/^\{(-?\d+(?:;-?\d+)*)?\}$/;function C(t){if(typeof t!="object"||t===null||Array.isArray(t))return!1;let e=Object.entries(t);return e.length>0&&e.every(([r,n])=>Q.test(r)&&Array.isArray(n))}function w(t,e,r){if(t==null)return t;if(Array.isArray(t)){let o=t.map(e).filter(s=>s!==null);return o.length>0?o:void 0}let n=e(t);return n!==null?n:r?void 0:t}var V=t=>{if(typeof t=="number")return Number.isFinite(t)?t:null;if(typeof t=="string"){let e=t.trim();if(e===""||/^[+-]?0[xbo]/i.test(e))return null;let r=Number(e);return Number.isFinite(r)?r:null}return null},H=t=>{if(typeof t=="boolean")return t;if(typeof t=="string"){let e=t.trim().toLowerCase();if(e==="true")return!0;if(e==="false")return!1}return null},Je=t=>typeof t=="string"?t.length>=2&&t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t.startsWith('"')?t.slice(1):t:null,Ye=t=>{if(typeof t=="string"){let e=t.trim();return e.startsWith('"')&&e.endsWith('"')&&(e=e.slice(1,-1).trim()),e}return null};function xe(t){return e=>{if(typeof e=="object"&&e!==null)return e;if(typeof e=="string"&&e.trim()!=="")try{let r=JSON.parse(e);return typeof r=="object"&&r!==null?r:(y().warn(`Parsed value for input ${t} is not an object`),null)}catch(r){return y().warn(`Failed to parse object value "${e}" for input ${t}`,r),null}return null}}function Ie(t,e,r){let n=Number(t.toFixed(e));return Math.abs(t-n)<r?n:t}function Xe(t,e){if(!Number.isFinite(t)||t===0)return .1;let r=Math.abs(t);if(r>=1){let g=String(t).split(".")[1];if(g&&g.length>0){let b=Math.min(g.length,12),S=Math.pow(10,-b),Y=Number(S.toFixed(b));return Math.abs(Y-S)<e?Y:S}return 1}let n=String(t),o=n.toLowerCase().match(/e(-?\d+)/);if(o){let m=Number(o[1]);if(m<0||n.toLowerCase().includes("e-")){let g=Math.abs(m),b=Math.pow(10,-g),S=Number(b.toFixed(g));return Math.abs(S-b)<e?S:b}return .1}let s=12,a=r.toFixed(s).replace(/0+$/,""),u=Math.min((a.split(".")[1]||"").length,s);if(u===0)return .1;let d=Math.pow(10,-u),f=Number(d.toFixed(u));return Math.abs(f-d)<e?f:d}function Ce(t){return typeof t.stepSize=="number"&&Number.isFinite(t.stepSize)&&t.stepSize>0?t.stepSize:void 0}function Ze(t,e=1e-8){let r=t.paramType==="Integer",n=Ce(t);if(C(t.default))return{default:t.default,stepSize:n??(r?1:.1)};if(typeof t.default=="string"&&t.default.trim()!==""&&V(t.default)===null)throw new c(`Invalid numeric default "${t.default}" for input "${t.name||"unknown"}"`,h.VALIDATION_ERROR,{context:{inputName:t.name,default:t.default}});let o=w(t.default,V,!0);if(r)return Array.isArray(o)?o=o.map(m=>typeof m=="number"?Math.round(m):m):typeof o=="number"&&(o=Math.round(o)),{default:o,stepSize:n??1};let s=Array.isArray(o)?o[0]:o,i;typeof s=="number"&&Number.isFinite(s)&&s!==0?i=s:typeof t.minimum=="number"&&Number.isFinite(t.minimum)&&t.minimum!==0?i=t.minimum:typeof t.maximum=="number"&&Number.isFinite(t.maximum)&&t.maximum!==0&&(i=t.maximum);let a=n??(i!==void 0?Xe(i,e):.1),u=0,d=String(a),f=d.toLowerCase().match(/e(-?\d+)/);if(f?u=Math.abs(Number(f[1])):u=d.split(".")[1]?.length??0,u===0&&typeof s=="number"&&s!==0&&Math.abs(s)<1){let m=Math.ceil(-Math.log10(Math.abs(s)));Number.isFinite(m)&&m>0&&(u=m)}return u=Math.min(Math.max(u,0),12),Array.isArray(o)?o=o.map(m=>typeof m=="number"?Ie(m,u,e):m):typeof o=="number"&&(o=Ie(o,u,e)),{default:o,stepSize:a}}var et={types:["Number","Integer"],parse(t,e){let{default:r,stepSize:n}=Ze(t);return{...e,paramType:t.paramType,minimum:t.minimum,maximum:t.maximum,atLeast:t.atLeast,atMost:t.atMost,stepSize:n,default:r}},fallback(t,e){let r=(t.atMost??1)>1,n=typeof t.minimum=="number"&&Number.isFinite(t.minimum)&&t.minimum>0?t.minimum:0;return{...e,paramType:t.paramType,minimum:t.minimum,maximum:t.maximum,atLeast:t.atLeast,atMost:t.atMost,stepSize:Ce(t)??(t.paramType==="Integer"?1:.1),default:r?[n]:n}}},tt={types:["Boolean"],parse(t,e){if(C(t.default))return{...e,paramType:"Boolean",default:t.default};let r=w(t.default,H,!1);if(r!=null&&typeof r!="boolean"&&!Array.isArray(r))throw new c(`Invalid boolean default "${String(r)}" for input "${t.name||"unknown"}"`,h.VALIDATION_ERROR,{context:{inputName:t.name,default:t.default}});return{...e,paramType:"Boolean",default:r}},fallback(t,e){let r=(t.atMost??1)>1;return{...e,paramType:"Boolean",default:r?[!1]:!1}}},rt={types:["Text"],parse(t,e){let r=w(t.default,Je,!1);return{...e,paramType:"Text",default:r}},fallback(t,e){let r=(t.atMost??1)>1;return{...e,paramType:"Text",default:r?[""]:""}}},nt={types:["ValueList"],parse(t,e){if(!t.values||typeof t.values!="object"||Object.keys(t.values).length===0)throw c.missingValues(t.nickname||"unnamed","ValueList");let r=t.default;if(t.default!==void 0&&t.default!==null){if(typeof t.default=="object")throw new c(`ValueList input "${t.nickname||"unnamed"}" default is not a string-able value`,h.VALIDATION_ERROR,{context:{inputName:t.name,default:t.default}});let n=String(t.default).toLowerCase(),o=Object.keys(t.values).find(s=>s.toLowerCase()===n);o!==void 0?r=o:y().warn(`ValueList input "${t.nickname||"unnamed"}" default value "${t.default}" is not in available values`)}return{...e,paramType:"ValueList",values:t.values,default:r}},fallback(t,e){return{...e,paramType:"ValueList",values:t.values&&typeof t.values=="object"?t.values:{},default:void 0}}},we={types:["Geometry"],parse(t,e){let r=w(t.default,xe(t.nickname||"unnamed"),!0);return{...e,paramType:"Geometry",default:r}},fallback(t,e){let r=(t.atMost??1)>1;return{...e,paramType:"Geometry",default:r?[null]:null}}},ot={types:["File"],parse(t,e){let r=w(t.default,xe(t.nickname||"unnamed"),!0);return{...e,paramType:"File",acceptedFormats:t.acceptedFormats,default:r}},fallback(t,e){let r=(t.atMost??1)>1;return{...e,paramType:"File",default:r?[null]:null}}},st={types:["Color"],parse(t,e){let r=w(t.default,Ye,!1);return{...e,paramType:"Color",default:r}},fallback(t,e){let r=(t.atMost??1)>1;return{...e,paramType:"Color",default:r?["0, 0, 0"]:"0, 0, 0"}}},it=[et,tt,rt,nt,we,ot,st],J=new Map(it.flatMap(t=>t.types.map(e=>[e,t]))),Ee=we;function ve(t){return p(t,"data")}function at(t){return p(t,"type")}var ut=new Set(["System.Double","System.Single","System.Decimal","System.Int32","System.Int64"]),pt=new Set(["System.Int32","System.Int64"]);function Re(t){if(typeof t.default!="object"||t.default===null)return{schema:t};if(Array.isArray(t.default))return{schema:t};if(!j(t.default,"innerTree")){let n=`Input "${t.name??"unknown"}" default had an unrecognized shape (no innerTree key); the default was dropped.`;return y().warn("Unexpected structure in input.default:",t.default),{schema:{...t,default:null},warning:{code:"MALFORMED_DEFAULT",message:n}}}let e=p(t.default,"innerTree")??{};if(Object.keys(e).length===0)return{schema:{...t,default:void 0}};if(t.treeAccess||t.atMost&&t.atMost>1){let n={},o=[];for(let[i,a]of Object.entries(e)){if(!Array.isArray(a)){let d=`Input "${t.name??"unknown"}" default had a non-array innerTree branch ("${i}"); the default was dropped.`;return y().warn("Unexpected structure in input.default innerTree:",t.default),{schema:{...t,default:null},warning:{code:"MALFORMED_DEFAULT",message:d}}}let u=[];for(let d of a){let f=ve(d),m=at(d);if(m&&ut.has(m)){if(typeof f=="string"&&f.trim()==="")continue;let g=V(f);if(g===null){o.push(`"${String(f)}" (${m})`);continue}u.push(pt.has(m)?Math.round(g):g);continue}if(m==="System.Boolean"){let g=H(f);if(g===null){o.push(`"${String(f)}" (${m})`);continue}u.push(g);continue}if(typeof f=="string"&&m?.startsWith("Rhino.Geometry")){try{u.push(JSON.parse(f))}catch{u.push(f)}continue}u.push(f)}n[i]=u}let s;if(o.length>0){let i=`Input "${t.name??"unknown"}" default contained ${o.length} tree value(s) that could not be parsed and were dropped: ${o.join(", ")}.`;y().warn(i),s={code:"MALFORMED_DEFAULT",message:i}}return{schema:{...t,default:n},...s&&{warning:s}}}let r=[];for(let n of Object.values(e))Array.isArray(n)&&n.forEach(o=>{o&&typeof o=="object"&&j(o,"data")&&r.push(ve(o))});return r.length===0?{schema:{...t,default:void 0}}:r.length===1?{schema:{...t,default:r[0]}}:{schema:{...t,default:r}}}var lt=new Map([...J.keys()].map(t=>[t.toLowerCase(),t]));function ct(t){return lt.get(t?.toLowerCase())??t}function Ae(t){return Pe(t).input}function Pe(t){let e={description:t.description,name:t.name,nickname:t.nickname,treeAccess:t.treeAccess,groupName:t.groupName??void 0,id:t.id},r=ct(t.paramType),n={...t,paramType:r},o;try{let{schema:i,warning:a}=Re(n);n=i,o=a&&{inputName:t.name||"unknown",paramType:t.paramType,message:a.message,code:a.code}}catch(i){n={...n,default:null},o={inputName:t.name||"unknown",paramType:t.paramType,message:`Input "${t.name??"unknown"}" default could not be normalized and was dropped: ${i instanceof Error?i.message:String(i)}`,code:"MALFORMED_DEFAULT"}}let s=J.get(r);try{if(!s)throw c.unknownParamType(r,t.name);return{input:s.parse(n,e),error:o,...o&&{errors:[o]}}}catch(i){if(i instanceof c){y().error(`Validation error for input ${t.name||"unknown"}:`,i.message);let a={inputName:t.name||"unknown",paramType:t.paramType,message:i.message,code:i.code};return{input:(s??Ee).fallback(n,e),error:a,errors:o?[o,a]:[a]}}throw new c(i instanceof Error?i.message:String(i),"VALIDATION_ERROR",{context:{paramName:t.name,paramType:r},originalError:i instanceof Error?i:new Error(String(i))})}}function ke(t){return L(t).inputs}function L(t){let e=[],r=[];for(let n of t){let{input:o,errors:s}=Pe(n);e.push(o),s&&r.push(...s)}return{inputs:e,parseErrors:r}}function Oe(t){let e=p(t,"stepSize");return{id:p(t,"id")??"",name:p(t,"name")??"",nickname:p(t,"nickname")??null,description:p(t,"description")??"",paramType:p(t,"paramType")??"",treeAccess:p(t,"treeAccess")??!1,minimum:p(t,"minimum")??null,maximum:p(t,"maximum")??null,atLeast:p(t,"atLeast")??1,atMost:p(t,"atMost")??1,stepSize:typeof e=="number"&&Number.isFinite(e)?e:void 0,default:p(t,"default"),values:p(t,"values"),acceptedFormats:p(t,"acceptedFormats"),groupName:p(t,"groupName")??null}}function Fe(t){return{name:p(t,"name")??"",nickname:p(t,"nickname")??null,paramType:p(t,"paramType")??"",id:p(t,"id")??""}}async function P(t,e){let r=v(t,[]),n={};if(r.algo&&(n.algo=r.algo),r.pointer&&(n.pointer=r.pointer),!n.algo&&!n.pointer)throw new c("Definition must resolve to either a URL pointer or base64 algo",h.INVALID_INPUT,{context:{definition:t}});let o=await O("io",n,e);if(!o||typeof o!="object")throw new c("Invalid IO response structure",h.INVALID_INPUT,{context:{response:o,definition:t}});let s=Ne(p(o,"warnings")),i=Ne(p(o,"errors")),a=p(o,"inputs"),u=p(o,"outputs");return{inputs:Array.isArray(a)?a.map(Oe):[],outputs:Array.isArray(u)?u.map(Fe):[],...s&&{loadWarnings:s},...i&&{loadErrors:i}}}function Ne(t){if(!Array.isArray(t))return;let e=t.map(ft).filter(r=>r!==void 0);return e.length>0?e:void 0}function ft(t){if(t==null)return;let e;if(typeof t=="string")e=t;else if(typeof t=="object"){let r=p(t,"message");if(typeof r=="string"&&r.trim().length>0)e=r;else try{e=JSON.stringify(t)??String(t)}catch{e=String(t)}}else e=String(t);return e.trim().length>0?e:void 0}async function M(t,e){D("fetchParsedDefinitionIO",e.suppressBrowserWarning??e.suppressClientSideWarning);let{inputs:r,outputs:n,loadWarnings:o,loadErrors:s}=await P(t,e),{inputs:i,parseErrors:a}=L(r);return{inputs:i,outputs:n,...a.length>0&&{parseErrors:a},...o&&{loadWarnings:o},...s&&{loadErrors:s}}}var W=class t{constructor(e){l(this,"innerTree");l(this,"paramName");this.paramName=e,this.innerTree={}}append(e,r){let n=t.formatPathString(e);this.innerTree[n]||(this.innerTree[n]=[]);let o=r.map(s=>({data:t.serializeValue(s)}));return this.innerTree[n].push(...o),this}appendSingle(e,r){return this.append(e,[r])}fromDataTreeDefault(e){this.innerTree={};for(let[r,n]of Object.entries(e)){if(!Array.isArray(n))continue;let o=t.parsePathString(r);this.append(o,n)}return this}appendFlat(e){let r=Array.isArray(e)?e:[e];return this.append([0],r)}flatten(){let e=[];for(let r of Object.values(this.innerTree))if(Array.isArray(r))for(let n of r)e.push(t.deserializeValue(n.data));return e}getPaths(){return Object.keys(this.innerTree)}getPath(e){let r=t.formatPathString(e),n=this.innerTree[r];if(n)return n.map(o=>t.deserializeValue(o.data))}toComputeFormat(){return{ParamName:this.paramName,InnerTree:this.innerTree}}getInnerTree(){return this.innerTree}getParamName(){return this.paramName}static fromInputParams(e){return e.filter(r=>t.hasValidValue(r.default)).map(r=>{let n=new t(r.nickname||"unnamed"),o=r.default;if(r.treeAccess&&C(o))n.fromDataTreeDefault(o),t.isNumericInput(r)&&n.applyNumericConstraints(r.minimum,r.maximum,r.nickname||"unnamed");else{let s=Array.isArray(o)?o:[o],i=t.processValues(s,r);n.appendFlat(i)}return n.toComputeFormat()})}static fromInputParam(e){return t.hasValidValue(e.default)?t.fromInputParams([e])[0]:void 0}static replaceTreeValue(e,r,n){let o=e.length>0&&e[0]instanceof t,s=t.buildFromValue(r,n);if(o){let d=e.slice(),f=d.findIndex(m=>m.getParamName()===r);return f!==-1?d[f]=s:d.push(s),d}let i=e.slice(),a=s.toComputeFormat(),u=i.findIndex(d=>d.ParamName===r);return u!==-1?i[u]=a:i.push(a),i}static buildFromValue(e,r){let n=new t(e);return C(r)?n.fromDataTreeDefault(r):n.appendFlat(r),n}static getTreeValue(e,r){let o=e.length>0&&e[0]instanceof t?t.readFromBuilders(e,r):t.readFromDataTrees(e,r);return o===null||o.length===0?null:o.length===1?o[0]:o}static readFromBuilders(e,r){let n=e.find(o=>o.getParamName()===r);return n?n.flatten():null}static readFromDataTrees(e,r){let n=e.find(i=>i.ParamName===r);if(!n?.InnerTree)return null;let o=Object.keys(n.InnerTree)[0];if(!o)return null;let s=n.InnerTree[o];return Array.isArray(s)?s.map(i=>i?.data!==void 0?t.deserializeValue(i.data):null):s?.data!==void 0?[t.deserializeValue(s.data)]:s!==void 0?[s]:null}static parsePathString(e){let r=e.match(Q);if(!r)throw new Error(`Invalid Grasshopper tree path: "${e}". Expected "{}", "{0}", or "{0;1;2}" (negative indices allowed, no empty segments).`);return r[1]?r[1].split(";").map(Number):[]}static formatPathString(e){return`{${e.join(";")}}`}applyNumericConstraints(e,r,n){for(let o of Object.values(this.innerTree))if(Array.isArray(o))for(let s of o){let i=t.deserializeValue(s.data);if(typeof i=="number"){let a=t.clampValue(i,e,r,n);s.data=t.serializeValue(a)}}}static serializeValue(e){return typeof e=="boolean"||typeof e=="number"||typeof e=="string"?e:typeof e=="object"&&e!==null?JSON.stringify(e):String(e)}static deserializeValue(e){if(typeof e=="boolean"||typeof e=="number"||typeof e!="string")return e;if(e.startsWith("{")||e.startsWith("["))try{return JSON.parse(e)}catch{return e}let r=Number(e);return Number.isFinite(r)&&String(r)===e?r:e==="true"?!0:e==="false"?!1:e}static hasValidValue(e){return e==null?!1:typeof e=="string"?!0:!(Array.isArray(e)&&e.length===0||typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0)}static isNumericInput(e){return e.paramType==="Number"||e.paramType==="Integer"}static processValues(e,r){return e.map(n=>t.isNumericInput(r)&&typeof n=="number"?t.clampValue(n,r.minimum,r.maximum,r.nickname||"unnamed"):n).filter(n=>n!=null)}static clampValue(e,r,n,o){let s=e;return r!=null&&s<r&&(y().warn(`${o}: ${e} below min ${r}, clamping`),s=r),n!=null&&s>n&&(y().warn(`${o}: ${e} above max ${n}, clamping`),s=n),s}};export{T as a,E as b,$ as c,pe as d,R as e,I as f,A as g,k as h,Ae as i,ke as j,P as k,M as l,W as m};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{b as l,c as h,d as c,e as y,h as X,i as Z,k as ee,l as O,m as te,n as re,q as p,r as j,t as F}from"./chunk-WPB2LKCD.js";var ne=new Set;function Me(){if(typeof window>"u"||globalThis.process?.versions?.node!=null)return!1;let e=globalThis.navigator,r=typeof e?.userAgent=="string"?e.userAgent:"";return!/jsdom/i.test(r)}function D(t,e){e||Me()&&!ne.has(t)&&(ne.add(t),y().warn(`Warning: ${t} is running on the client side. For better performance and security, consider running this on the server side.`))}function T(t){return typeof t=="object"&&!(t instanceof Uint8Array)&&typeof t.key=="string"&&typeof t.load=="function"}var Ge="Unable to load grasshopper definition";function Ve(t){return t instanceof c?t.code===h.DEFINITION_NOT_CACHED||t.message.includes(Ge):!1}function Le(t,e){if(!e)return;let r=p(t,"values");if(!Array.isArray(r)||r.length===0)return;let n=[];for(let s of r){let i=p(s,"innerTree");(!i||Object.keys(i).length===0)&&n.push(p(s,"paramName")??"<unnamed>")}if(n.length===0)return;let o=n.length===r.length?"all":`${n.length}/${r.length}`;y().warn(`Solve returned empty output(s) (${o}): ${n.join(", ")}. These parameters produced no data \u2014 check the definition's inputs and the branch feeding each.`)}async function E(t,e,r){D("solveGrasshopperDefinition",r.suppressBrowserWarning??r.suppressClientSideWarning);let n=await B(e),{response:o}=await N(v(n,t),r);return o}async function oe(t,e,r){D("solveGrasshopperDefinitionWithCacheKey",r.suppressBrowserWarning??r.suppressClientSideWarning);let n=await B(e);return N(v(n,t),r)}async function se(t,e,r,n){D("solveByCacheKey",n.suppressBrowserWarning??n.suppressClientSideWarning);let o={algo:null,pointer:e,values:t};try{return{...await N(o,n),missed:!1}}catch(s){if(!Ve(s))throw s;let i=await B(r);return{...await N(v(i,t),n),missed:!0}}}async function B(t){if(!T(t))return t;try{return await t.load()}catch(e){throw new c(`Failed to load definition bytes for ref '${t.key}'`,h.INVALID_INPUT,{context:{definitionKey:t.key},originalError:e instanceof Error?e:new Error(String(e))})}}async function N(t,e){We(t,e);let r=await O("grasshopper",t,e),{pointer:n,algo:o,...s}=r,i=s;return Le(i,e.debug),{response:i,cacheKey:typeof n=="string"?n:null}}function v(t,e){let r={algo:null,pointer:null,values:e};return t instanceof Uint8Array?r.algo=ee(t):/^https?:\/\//i.test(t)?r.pointer=t:r.algo=Z(t)??X(t),r}function We(t,e){e.cachesolve!=null&&(t.cachesolve=e.cachesolve),e.cacheerroredsolves!=null&&(t.cacheerroredsolves=e.cacheerroredsolves),e.modelunits!=null&&(t.modelunits=e.modelunits),e.angletolerance!=null&&(t.angletolerance=e.angletolerance),e.absolutetolerance!=null&&(t.absolutetolerance=e.absolutetolerance),e.dataversion!=null&&(t.dataversion=e.dataversion)}function $(t){let e=new WeakSet,r=n=>{if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="number")return Number.isFinite(n)?String(n):"null";if(typeof n=="string"||typeof n=="boolean")return JSON.stringify(n);if(typeof n=="bigint")return`${n}n`;if(n instanceof Uint8Array)return`{"__u8":${n.length},"hash":"${ue(n)}"}`;if(Array.isArray(n)){if(e.has(n))return'"[Circular]"';e.add(n);let o=[];for(let s=0;s<n.length;s++)o.push(r(n[s]));return e.delete(n),`[${o.join(",")}]`}if(typeof n=="object"){if(e.has(n))return'"[Circular]"';e.add(n);let o;return typeof n.toJSON=="function"?o=r(n.toJSON()):n instanceof Map?o=`{"__map":[${[...n.entries()].map(([i,a])=>`[${r(i)},${r(a)}]`).sort().join(",")}]}`:n instanceof Set?o=`{"__set":[${[...n.values()].map(r).sort().join(",")}]}`:o=`{${Object.keys(n).sort().map(a=>`${JSON.stringify(a)}:${r(n[a])}`).join(",")}}`,e.delete(n),o}return"null"};return r(t)}function ie(t,e){let r=2166136261;for(let n=0;n<t;n++)r^=e(n),r=r+((r<<1)+(r<<4)+(r<<7)+(r<<8)+(r<<24))>>>0;return r.toString(16).padStart(8,"0")}function ae(t){return ie(t.length,e=>t.charCodeAt(e))}function ue(t){return ie(t.length,e=>t[e])}function pe(t,e){return q(R(t),e)}function q(t,e){let r=$(e);return`${t}|t:${r.length}:${ae(r)}`}function R(t){return T(t)?`r:${t.key}`:typeof t=="string"?`s:${t.length}:${ae(t)}`:`u8:${t.length}:${ue(t)}`}var je=100;function Be(t){return typeof t!="string"?!0:!/^https?:\/\//i.test(t)}var I=class{constructor(e,r,n={},o){l(this,"executor");l(this,"baseConfig");l(this,"mode");l(this,"maxConcurrent");l(this,"maxQueueDepth");l(this,"queueWaitMs");l(this,"timeoutMs");l(this,"retry");l(this,"cacheEnabled");l(this,"cacheMax");l(this,"cacheTtl");l(this,"cacheErroredSolves");l(this,"cache",new Map);l(this,"cacheKeyExecutor");l(this,"reuseServerDefinitionCache");l(this,"serverCacheKeys",new Map);l(this,"onStart");l(this,"onSettle");l(this,"onSuperseded");l(this,"subscribers",new Set);l(this,"inFlight",new Set);l(this,"pendingForLatestWins",null);l(this,"fifoQueue",[]);l(this,"_lastResult",null);l(this,"_lastError",null);l(this,"_lastDurationMs",null);l(this,"solveSeq",0);l(this,"lastStateSeq",0);l(this,"disposed",!1);this.executor=e,this.cacheKeyExecutor=o,this.baseConfig=r,this.mode=n.mode??"latest-wins",this.maxConcurrent=Math.max(1,n.maxConcurrent??(this.mode==="parallel"?4:1)),this.maxQueueDepth=n.maxQueueDepth!==void 0&&n.maxQueueDepth>0?Math.floor(n.maxQueueDepth):void 0,this.queueWaitMs=n.queueWaitMs!==void 0&&n.queueWaitMs>0?n.queueWaitMs:void 0,this.timeoutMs=n.timeoutMs,this.retry=n.retry;let s=n.cache;this.cacheEnabled=s!==void 0&&s!==!1;let i=typeof s=="object"?s:{};this.cacheMax=i.maxEntries??50,this.cacheTtl=i.ttlMs??0,this.cacheErroredSolves=i.cacheErroredSolves??!0,this.reuseServerDefinitionCache=!!o&&(n.reuseServerDefinitionCache??!0),this.onStart=n.onStart,this.onSettle=n.onSettle,this.onSuperseded=n.onSuperseded}get isSolving(){return this.inFlight.size>0}get hasPending(){return this.pendingForLatestWins!==null||this.fifoQueue.length>0}get inFlightCount(){return this.inFlight.size}get queueDepth(){return this.fifoQueue.length+(this.pendingForLatestWins?1:0)}get lastResult(){return this._lastResult}get lastError(){return this._lastError}get lastDurationMs(){return this._lastDurationMs}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}notify(){for(let e of this.subscribers)try{e()}catch(r){y().error("[SolveScheduler] subscriber threw:",r)}}solve(e,r,n){if(this.disposed)return Promise.reject(new c("SolveScheduler has been disposed and cannot be used",h.INVALID_STATE));let o=R(e),s=q(o,r),i=++this.solveSeq,a={key:s,enqueuedAt:Date.now(),startedAt:null};if(n?.signal?.aborted)return Promise.reject(this.makeAbortError(a));if(this.cacheEnabled){let u=this.readCache(s);if(u){this.mode==="latest-wins"&&this.supersedeCurrent();let d={status:"success",response:u,durationMs:0,fromCache:!0};return this.writeLastState(i,{result:u,durationMs:0}),this.runHook(this.onStart,a),this.runHook(this.onSettle,a,d),this.notify(),Promise.resolve(u)}}return new Promise((u,d)=>{let f={definition:e,dataTree:r,definitionHash:o,ctx:a,seq:i,resolve:u,reject:d,externalSignal:n?.signal};f.externalSignal&&(f.queuedAbortHandler=()=>this.abortQueuedItem(f),f.externalSignal.addEventListener("abort",f.queuedAbortHandler,{once:!0})),this.enqueue(f)})}writeLastState(e,r){return e<this.lastStateSeq?!1:(this.lastStateSeq=e,"result"in r?(this._lastResult=r.result,this._lastError=null):this._lastError=r.error,this._lastDurationMs=r.durationMs,!0)}supersedeCurrent(){this.pendingForLatestWins&&(this.supersede(this.pendingForLatestWins),this.pendingForLatestWins=null);for(let e of this.inFlight)this.supersede(e),e.controller.abort()}abortQueuedItem(e){this.pendingForLatestWins===e&&(this.pendingForLatestWins=null);let r=this.fifoQueue.indexOf(e);r>=0&&this.fifoQueue.splice(r,1),this.rejectAsAborted(e),this.notify()}shedAsQueueFull(e){let r=new c("Solve queue is full; request shed (backpressure)",h.QUEUE_FULL,{statusCode:503,context:{key:e.ctx.key,queueDepth:this.fifoQueue.length,maxQueueDepth:this.maxQueueDepth}});this.settleError(e,r)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:r,durationMs:0}),this.notify()}armQueueWaitTimer(e){if(this.queueWaitMs===void 0)return;let r=this.queueWaitMs;e.queueWaitTimer=setTimeout(()=>{if(e.settled)return;let n=this.fifoQueue.indexOf(e);n>=0&&this.fifoQueue.splice(n,1);let o=new c(`Solve waited longer than ${r}ms in queue; shed (backpressure)`,h.QUEUE_TIMEOUT,{statusCode:503,context:{key:e.ctx.key,waitedMs:Date.now()-e.ctx.enqueuedAt,queueWaitMs:r}});this.settleError(e,o)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:o,durationMs:0}),this.notify()},r)}clearQueueWaitTimer(e){e.queueWaitTimer!==void 0&&(clearTimeout(e.queueWaitTimer),e.queueWaitTimer=void 0)}enqueue(e){switch(this.mode){case"latest-wins":{this.supersedeCurrent(),this.inFlight.size===0?this.execute(e):this.pendingForLatestWins=e;break}case"queue":case"parallel":{this.inFlight.size<this.maxConcurrent?this.execute(e):this.maxQueueDepth!==void 0&&this.fifoQueue.length>=this.maxQueueDepth?this.shedAsQueueFull(e):(this.armQueueWaitTimer(e),this.fifoQueue.push(e));break}}this.notify()}async execute(e){let r=new AbortController,n=e;n.controller=r,this.inFlight.add(n),e.ctx.startedAt=Date.now(),this.clearQueueWaitTimer(e),this.removeQueuedAbortHandler(e);let o=()=>r.abort();e.externalSignal?.addEventListener("abort",o,{once:!0}),this.runHook(this.onStart,e.ctx),this.notify();let s=performance.now();try{let i={...this.baseConfig,signal:r.signal,...this.timeoutMs!==void 0&&{timeoutMs:this.timeoutMs},...this.retry!==void 0&&{retry:this.retry}},{response:a,definitionReuploaded:u}=await this.runExecutor(e.definition,e.dataTree,e.definitionHash,i),d=performance.now()-s;if(this.cacheEnabled&&this.writeCache(e.ctx.key,a),!this.settleSuccess(e,a))return;this.writeLastState(e.seq,{result:a,durationMs:d}),this.runHook(this.onSettle,e.ctx,{status:"success",response:a,durationMs:d,fromCache:!1,definitionReuploaded:u})}catch(i){let a=performance.now()-s,u=this.normalizeExecutionError(i,n);this.writeLastState(e.seq,{error:u,durationMs:a}),this.settleError(e,u)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:u,durationMs:a})}finally{e.externalSignal?.removeEventListener("abort",o),this.inFlight.delete(n),this.drainNext(),this.notify()}}async runExecutor(e,r,n,o){if(!this.cacheKeyExecutor||!this.reuseServerDefinitionCache||!Be(e))return{response:await this.executor(e,r,o)};let s=n,i=this.serverCacheKeys.get(s)??null,a=await this.cacheKeyExecutor(e,r,i,o);if(a.cacheKey)for(this.serverCacheKeys.delete(s),this.serverCacheKeys.set(s,a.cacheKey);this.serverCacheKeys.size>je;){let u=this.serverCacheKeys.keys().next().value;if(u===void 0)break;this.serverCacheKeys.delete(u)}else this.serverCacheKeys.delete(s);return{response:a.response,definitionReuploaded:a.missed}}drainNext(){if(!this.disposed){if(this.mode==="latest-wins"){if(this.pendingForLatestWins&&this.inFlight.size===0){let e=this.pendingForLatestWins;this.pendingForLatestWins=null,this.execute(e)}return}for(;this.fifoQueue.length>0&&this.inFlight.size<this.maxConcurrent;){let e=this.fifoQueue.shift();this.execute(e)}}}supersede(e){let r=new c("Superseded by newer solve",h.SUPERSEDED,{context:{key:e.ctx.key,enqueuedAt:e.ctx.enqueuedAt}});this.settleError(e,r)&&this.runHook(this.onSuperseded,e.ctx)}makeAbortError(e){return new c("Request aborted by caller",h.ABORTED,{context:{key:e.key,enqueuedAt:e.enqueuedAt}})}settleError(e,r){return e.settled?!1:(e.settled={error:r},this.clearQueueWaitTimer(e),this.removeQueuedAbortHandler(e),e.reject(r),!0)}settleSuccess(e,r){return e.settled?!1:(e.settled={ok:!0},this.clearQueueWaitTimer(e),this.removeQueuedAbortHandler(e),e.resolve(r),!0)}removeQueuedAbortHandler(e){e.queuedAbortHandler&&e.externalSignal&&e.externalSignal.removeEventListener("abort",e.queuedAbortHandler),e.queuedAbortHandler=void 0}isAbortLikeError(e){if(e instanceof Error){if(e.name==="AbortError")return!0;if(typeof DOMException<"u"&&e instanceof DOMException)return e.name==="AbortError"}return!1}normalizeExecutionError(e,r){return r.settled&&"error"in r.settled?r.settled.error:e instanceof c?e:this.isAbortLikeError(e)?this.makeAbortError(r.ctx):new c(e instanceof Error?e.message:String(e),h.UNKNOWN_ERROR,{originalError:e instanceof Error?e:new Error(String(e))})}cancelAll(){for(this.pendingForLatestWins&&(this.rejectAsAborted(this.pendingForLatestWins),this.pendingForLatestWins=null);this.fifoQueue.length>0;){let e=this.fifoQueue.shift();this.rejectAsAborted(e)}for(let e of this.inFlight){let r=this.makeAbortError(e.ctx);this.settleError(e,r)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:r,durationMs:e.ctx.startedAt?Date.now()-e.ctx.startedAt:0}),e.controller.abort()}this.notify()}rejectAsAborted(e){let r=this.makeAbortError(e.ctx);this.settleError(e,r)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:r,durationMs:0})}readCache(e){if(!this.cacheEnabled)return null;let r=this.cache.get(e);return r?this.cacheTtl>0&&Date.now()-r.insertedAt>this.cacheTtl?(this.cache.delete(e),null):(this.cache.delete(e),this.cache.set(e,r),r.response):null}writeCache(e,r){if(this.cacheEnabled&&!(!this.cacheErroredSolves&&r.errors&&r.errors.length>0))for(this.cache.set(e,{response:r,insertedAt:Date.now()});this.cache.size>this.cacheMax;){let n=this.cache.keys().next().value;if(n===void 0)break;this.cache.delete(n)}}clearCache(){this.cache.clear()}dispose(){this.disposed||(this.disposed=!0,this.cancelAll(),this.subscribers.clear(),this.cache.clear())}runHook(e,...r){if(e)try{e(...r)}catch(n){y().error("[SolveScheduler] hook threw:",n)}}};function le(t){return T(t)?`ref:${t.key}`:typeof t=="string"&&t.length<200?t:"...content..."}function ce(t){return Array.isArray(t)?t.map(e=>{let r=0,n=0,o=p(e,"innerTree");if(o&&typeof o=="object"){for(let s of Object.values(o))if(Array.isArray(s)){r+=s.length;for(let i of s){let a=i?.data;typeof a=="string"&&(n+=a.length)}}}return{param:p(e,"paramName")??"<unnamed>",items:r,bytes:n}}):[]}var A=class t{constructor(e){l(this,"config");l(this,"serverStats");l(this,"disposed",!1);this.config=this.normalizeComputeConfig(e),this.serverStats=new re(this.config.serverUrl,this.config.apiKey)}static async create(e){let r=new t(e),n=Math.max(1,(e.retry?.attempts??2)+1),o=e.retry?.baseDelayMs??250,s=e.retry?.maxDelayMs??1e3;for(let i=0;i<n;i++){if(await r.serverStats.isServerOnline())return r;if(i<n-1){let a=Math.min(o*2**i,s);await new Promise(u=>setTimeout(u,a))}}throw await r.dispose(),new c("Rhino Compute server is not online",h.NETWORK_ERROR,{context:{serverUrl:r.config.serverUrl,attempts:n}})}getConfig(){return this.ensureNotDisposed(),{...this.config}}async getIO(e){return this.ensureNotDisposed(),M(e,this.config)}async getRawIO(e){return this.ensureNotDisposed(),P(e,this.config)}async solve(e,r,n){this.ensureNotDisposed();try{if(typeof e=="string"&&!e?.trim())throw new c("Definition URL/content is required",h.INVALID_INPUT,{context:{receivedUrl:e}});if(e instanceof Uint8Array&&e.length===0)throw new c("Definition content is empty",h.INVALID_INPUT);if(T(e)&&!e.key.trim())throw new c("DefinitionRef key is empty",h.INVALID_INPUT);let o={...this.config,...n?.signal!==void 0&&{signal:n.signal},...n?.timeoutMs!==void 0&&{timeoutMs:n.timeoutMs},...n?.retry!==void 0&&{retry:n.retry}},s=await E(r,e,o);if(s?.errors&&s.errors.length>0)throw new c(s.errors.join("; ")||"Computation failed",h.COMPUTATION_ERROR,{context:{definition:le(e),inputSummary:ce(r),errors:s.errors,warnings:s.warnings,values:s.values}});return s}catch(o){throw this.config.debug&&y().error("Compute failed:",o),o instanceof c?o:new c(o instanceof Error?o.message:String(o),h.COMPUTATION_ERROR,{context:{definition:le(e),inputSummary:ce(r)},originalError:o instanceof Error?o:new Error(String(o))})}}createScheduler(e){this.ensureNotDisposed();let r=(o,s,i)=>E(s,o,i),n=(o,s,i,a)=>i===null?oe(s,o,a).then(u=>({...u,missed:!1})):se(s,i,o,a);return new I(r,this.config,e,n)}async dispose(){this.disposed||(this.disposed=!0,await this.serverStats.dispose())}ensureNotDisposed(){if(this.disposed)throw new c("GrasshopperClient has been disposed and cannot be used",h.INVALID_STATE)}normalizeComputeConfig(e){return{...e,serverUrl:te(e.serverUrl),apiKey:e.apiKey,authToken:e.authToken,debug:e.debug??!1,suppressBrowserWarning:e.suppressBrowserWarning??e.suppressClientSideWarning}}};var G=new Map;function de(t,e){G.set(t,e)}de("Rhino.Geometry.Point3d",(t,e)=>{let r=e;return!r||typeof r.X!="number"?null:new t.Point([r.X,r.Y,r.Z])});de("Rhino.Geometry.Line",(t,e)=>{let r=e;return!r||!r.From||!r.To?null:new t.Line([r.From.X,r.From.Y,r.From.Z],[r.To.X,r.To.Y,r.To.Z])});function $e(t){if(G.has(t))return G.get(t);for(let[e,r]of G)if(t.startsWith(e))return r}function qe(t){return!!(t&&typeof t=="object"&&typeof t.data=="string")}function fe(t,e){return{__decodeError:!0,type:t,raw:e}}function me(t,e,r){let n=$e(e),o=!1;if(n)try{let s=n(r,t);if(s!=null)return s}catch(s){y().warn(`Failed to decode Rhino type ${e}:`,s),o=!0}try{if(qe(t))return r.CommonObject.decode(t)}catch(s){return y().warn(`Failed to decode ${e} with CommonObject:`,s),fe(e,t)}return o?fe(e,t):t}function he(t){let e=new WeakSet,r=n=>{if(!n||typeof n!="object"||e.has(n))return;e.add(n);let o=n.delete;if(typeof o=="function"){let i=n.isDeleted;(typeof i!="function"||!i.call(n))&&o.call(n);return}if(Array.isArray(n)){for(let i of n)r(i);return}let s=Object.getPrototypeOf(n);if(s===Object.prototype||s===null)for(let i of Object.values(n))r(i)};r(t)}var x={STRING:"System.String",INT:"System.Int32",DOUBLE:"System.Double",BOOL:"System.Boolean"},Ue="Rhino.Geometry.",ze=["WebDisplay"],_e="FileData";function ye(t){return ze.some(e=>t.includes(e))}function Ke(t){if(typeof t!="string")return t;let e=t.trim();if(!(e.startsWith("{")||e.startsWith("[")||e.startsWith('"')))return t;try{let n=JSON.parse(e);if(typeof n=="string")try{return JSON.parse(n)}catch{return n}return n}catch{return t}}function Qe(t,e,r){switch(e){case x.STRING:return typeof t!="string"?t:t.replace(/^"(.*)"$/,"$1");case x.INT:return Number.parseInt(t,10);case x.DOUBLE:return Number.parseFloat(t);case x.BOOL:return String(t).toLowerCase()==="true";default:return r&&e.startsWith(Ue)?me(t,e,r):t}}var U=new WeakMap;function ge(t){if(U.has(t))return U.get(t);let e=Ke(t.data);return U.set(t,e),e}function be(t,e,r,n){if(typeof t.data!="string")return t.data;let o=r?ge(t):t.data;return Qe(o,e,n)}function He(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.fileName=="string"&&typeof e.fileType=="string"&&"data"in e&&typeof e.isBase64Encoded=="boolean"&&typeof e.subFolder=="string"}function z(t){let e=p(t,"values");return Array.isArray(e)?e:[]}function _(t){return typeof t.type=="string"?t.type:""}function K(t,e){if(!(!t||typeof t!="object")){for(let r of Object.values(t))if(Array.isArray(r))for(let n of r)n&&typeof n=="object"&&e(n)}}function Te(t,e=!1,r={}){let{parseValues:n=!0,rhino:o,stringOnly:s=!1}=r,i={},a=new Set;for(let u of z(t)){let d=p(u,"paramName");K(p(u,"innerTree"),f=>{let m=_(f);if(ye(m)||s&&m!==x.STRING)return;let g=e?f.id:d;if(!g)return;let b=be(f,m,n,o);g in i?a.has(g)?i[g].push(b):(i[g]=[i[g],b],a.add(g)):i[g]=b})}return{values:i,dispose:()=>he(i)}}function Se(t){let e=[];for(let r of z(t))K(p(r,"innerTree"),n=>{if(!_(n).includes(_e))return;let o=ge(n);He(o)&&e.push(o)});return e}function De(t,e,r={}){let{parseValues:n=!0,rhino:o,stringOnly:s=!1}=r;for(let i of z(t)){let a=p(i,"innerTree"),u=!1;if("byName"in e){if(p(i,"paramName")!==e.byName)continue;u=!0}let d=[];if(K(a,f=>{if("byId"in e){if(f.id!==e.byId)return;u=!0}let m=_(f);ye(m)||s&&m!==x.STRING||d.push(be(f,m,n,o))}),u)return d.length===0?void 0:d.length===1?d[0]:d}}var k=class{constructor(e,r=!1){this.response=e;this.debug=r}getValues(e=!1,r={}){return Te(this.response,e,r)}getValue(e,r){return De(this.response,e,r)}async extractMeshesFromResponse(e){let r={debug:this.debug,...e},n;try{({getThreeMeshesFromComputeResponse:n}=await import("./visualization-4PVR5P7N.js"))}catch(o){throw new c("Failed to load three.js visualization module. Ensure three.js is installed as a peer dependency.",h.INVALID_STATE,{context:{originalError:o instanceof Error?o.message:String(o)}})}return n(this.response,r)}getFileData(){return Se(this.response)}async getAndDownloadFiles(e,r){let n=this.getFileData();await F(n,e,r)}};var Q=/^\{(-?\d+(?:;-?\d+)*)?\}$/;function C(t){if(typeof t!="object"||t===null||Array.isArray(t))return!1;let e=Object.entries(t);return e.length>0&&e.every(([r,n])=>Q.test(r)&&Array.isArray(n))}function w(t,e,r){if(t==null)return t;if(Array.isArray(t)){let o=t.map(e).filter(s=>s!==null);return o.length>0?o:void 0}let n=e(t);return n!==null?n:r?void 0:t}var V=t=>{if(typeof t=="number")return Number.isFinite(t)?t:null;if(typeof t=="string"){let e=t.trim();if(e===""||/^[+-]?0[xbo]/i.test(e))return null;let r=Number(e);return Number.isFinite(r)?r:null}return null},H=t=>{if(typeof t=="boolean")return t;if(typeof t=="string"){let e=t.trim().toLowerCase();if(e==="true")return!0;if(e==="false")return!1}return null},Je=t=>typeof t=="string"?t.length>=2&&t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t.startsWith('"')?t.slice(1):t:null,Ye=t=>{if(typeof t=="string"){let e=t.trim();return e.startsWith('"')&&e.endsWith('"')&&(e=e.slice(1,-1).trim()),e}return null};function xe(t){return e=>{if(typeof e=="object"&&e!==null)return e;if(typeof e=="string"&&e.trim()!=="")try{let r=JSON.parse(e);return typeof r=="object"&&r!==null?r:(y().warn(`Parsed value for input ${t} is not an object`),null)}catch(r){return y().warn(`Failed to parse object value "${e}" for input ${t}`,r),null}return null}}function Ie(t,e,r){let n=Number(t.toFixed(e));return Math.abs(t-n)<r?n:t}function Xe(t,e){if(!Number.isFinite(t)||t===0)return .1;let r=Math.abs(t);if(r>=1){let g=String(t).split(".")[1];if(g&&g.length>0){let b=Math.min(g.length,12),S=Math.pow(10,-b),Y=Number(S.toFixed(b));return Math.abs(Y-S)<e?Y:S}return 1}let n=String(t),o=n.toLowerCase().match(/e(-?\d+)/);if(o){let m=Number(o[1]);if(m<0||n.toLowerCase().includes("e-")){let g=Math.abs(m),b=Math.pow(10,-g),S=Number(b.toFixed(g));return Math.abs(S-b)<e?S:b}return .1}let s=12,a=r.toFixed(s).replace(/0+$/,""),u=Math.min((a.split(".")[1]||"").length,s);if(u===0)return .1;let d=Math.pow(10,-u),f=Number(d.toFixed(u));return Math.abs(f-d)<e?f:d}function Ce(t){return typeof t.stepSize=="number"&&Number.isFinite(t.stepSize)&&t.stepSize>0?t.stepSize:void 0}function Ze(t,e=1e-8){let r=t.paramType==="Integer",n=Ce(t);if(C(t.default))return{default:t.default,stepSize:n??(r?1:.1)};if(typeof t.default=="string"&&t.default.trim()!==""&&V(t.default)===null)throw new c(`Invalid numeric default "${t.default}" for input "${t.name||"unknown"}"`,h.VALIDATION_ERROR,{context:{inputName:t.name,default:t.default}});let o=w(t.default,V,!0);if(r)return Array.isArray(o)?o=o.map(m=>typeof m=="number"?Math.round(m):m):typeof o=="number"&&(o=Math.round(o)),{default:o,stepSize:n??1};let s=Array.isArray(o)?o[0]:o,i;typeof s=="number"&&Number.isFinite(s)&&s!==0?i=s:typeof t.minimum=="number"&&Number.isFinite(t.minimum)&&t.minimum!==0?i=t.minimum:typeof t.maximum=="number"&&Number.isFinite(t.maximum)&&t.maximum!==0&&(i=t.maximum);let a=n??(i!==void 0?Xe(i,e):.1),u=0,d=String(a),f=d.toLowerCase().match(/e(-?\d+)/);if(f?u=Math.abs(Number(f[1])):u=d.split(".")[1]?.length??0,u===0&&typeof s=="number"&&s!==0&&Math.abs(s)<1){let m=Math.ceil(-Math.log10(Math.abs(s)));Number.isFinite(m)&&m>0&&(u=m)}return u=Math.min(Math.max(u,0),12),Array.isArray(o)?o=o.map(m=>typeof m=="number"?Ie(m,u,e):m):typeof o=="number"&&(o=Ie(o,u,e)),{default:o,stepSize:a}}var et={types:["Number","Integer"],parse(t,e){let{default:r,stepSize:n}=Ze(t);return{...e,paramType:t.paramType,minimum:t.minimum,maximum:t.maximum,atLeast:t.atLeast,atMost:t.atMost,stepSize:n,default:r}},fallback(t,e){let r=(t.atMost??1)>1,n=typeof t.minimum=="number"&&Number.isFinite(t.minimum)&&t.minimum>0?t.minimum:0;return{...e,paramType:t.paramType,minimum:t.minimum,maximum:t.maximum,atLeast:t.atLeast,atMost:t.atMost,stepSize:Ce(t)??(t.paramType==="Integer"?1:.1),default:r?[n]:n}}},tt={types:["Boolean"],parse(t,e){if(C(t.default))return{...e,paramType:"Boolean",default:t.default};let r=w(t.default,H,!1);if(r!=null&&typeof r!="boolean"&&!Array.isArray(r))throw new c(`Invalid boolean default "${String(r)}" for input "${t.name||"unknown"}"`,h.VALIDATION_ERROR,{context:{inputName:t.name,default:t.default}});return{...e,paramType:"Boolean",default:r}},fallback(t,e){let r=(t.atMost??1)>1;return{...e,paramType:"Boolean",default:r?[!1]:!1}}},rt={types:["Text"],parse(t,e){let r=w(t.default,Je,!1);return{...e,paramType:"Text",default:r}},fallback(t,e){let r=(t.atMost??1)>1;return{...e,paramType:"Text",default:r?[""]:""}}},nt={types:["ValueList"],parse(t,e){if(!t.values||typeof t.values!="object"||Object.keys(t.values).length===0)throw c.missingValues(t.nickname||"unnamed","ValueList");let r=t.default;if(t.default!==void 0&&t.default!==null){if(typeof t.default=="object")throw new c(`ValueList input "${t.nickname||"unnamed"}" default is not a string-able value`,h.VALIDATION_ERROR,{context:{inputName:t.name,default:t.default}});let n=String(t.default).toLowerCase(),o=Object.keys(t.values).find(s=>s.toLowerCase()===n);o!==void 0?r=o:y().warn(`ValueList input "${t.nickname||"unnamed"}" default value "${t.default}" is not in available values`)}return{...e,paramType:"ValueList",values:t.values,default:r}},fallback(t,e){return{...e,paramType:"ValueList",values:t.values&&typeof t.values=="object"?t.values:{},default:void 0}}},we={types:["Geometry"],parse(t,e){let r=w(t.default,xe(t.nickname||"unnamed"),!0);return{...e,paramType:"Geometry",default:r}},fallback(t,e){let r=(t.atMost??1)>1;return{...e,paramType:"Geometry",default:r?[null]:null}}},ot={types:["File"],parse(t,e){let r=w(t.default,xe(t.nickname||"unnamed"),!0);return{...e,paramType:"File",acceptedFormats:t.acceptedFormats,default:r}},fallback(t,e){let r=(t.atMost??1)>1;return{...e,paramType:"File",default:r?[null]:null}}},st={types:["Color"],parse(t,e){let r=w(t.default,Ye,!1);return{...e,paramType:"Color",default:r}},fallback(t,e){let r=(t.atMost??1)>1;return{...e,paramType:"Color",default:r?["0, 0, 0"]:"0, 0, 0"}}},it=[et,tt,rt,nt,we,ot,st],J=new Map(it.flatMap(t=>t.types.map(e=>[e,t]))),Ee=we;function ve(t){return p(t,"data")}function at(t){return p(t,"type")}var ut=new Set(["System.Double","System.Single","System.Decimal","System.Int32","System.Int64"]),pt=new Set(["System.Int32","System.Int64"]);function Re(t){if(typeof t.default!="object"||t.default===null)return{schema:t};if(Array.isArray(t.default))return{schema:t};if(!j(t.default,"innerTree")){let n=`Input "${t.name??"unknown"}" default had an unrecognized shape (no innerTree key); the default was dropped.`;return y().warn("Unexpected structure in input.default:",t.default),{schema:{...t,default:null},warning:{code:"MALFORMED_DEFAULT",message:n}}}let e=p(t.default,"innerTree")??{};if(Object.keys(e).length===0)return{schema:{...t,default:void 0}};if(t.treeAccess||t.atMost&&t.atMost>1){let n={},o=[];for(let[i,a]of Object.entries(e)){if(!Array.isArray(a)){let d=`Input "${t.name??"unknown"}" default had a non-array innerTree branch ("${i}"); the default was dropped.`;return y().warn("Unexpected structure in input.default innerTree:",t.default),{schema:{...t,default:null},warning:{code:"MALFORMED_DEFAULT",message:d}}}let u=[];for(let d of a){let f=ve(d),m=at(d);if(m&&ut.has(m)){if(typeof f=="string"&&f.trim()==="")continue;let g=V(f);if(g===null){o.push(`"${String(f)}" (${m})`);continue}u.push(pt.has(m)?Math.round(g):g);continue}if(m==="System.Boolean"){let g=H(f);if(g===null){o.push(`"${String(f)}" (${m})`);continue}u.push(g);continue}if(typeof f=="string"&&m?.startsWith("Rhino.Geometry")){try{u.push(JSON.parse(f))}catch{u.push(f)}continue}u.push(f)}n[i]=u}let s;if(o.length>0){let i=`Input "${t.name??"unknown"}" default contained ${o.length} tree value(s) that could not be parsed and were dropped: ${o.join(", ")}.`;y().warn(i),s={code:"MALFORMED_DEFAULT",message:i}}return{schema:{...t,default:n},...s&&{warning:s}}}let r=[];for(let n of Object.values(e))Array.isArray(n)&&n.forEach(o=>{o&&typeof o=="object"&&j(o,"data")&&r.push(ve(o))});return r.length===0?{schema:{...t,default:void 0}}:r.length===1?{schema:{...t,default:r[0]}}:{schema:{...t,default:r}}}var lt=new Map([...J.keys()].map(t=>[t.toLowerCase(),t]));function ct(t){return lt.get(t?.toLowerCase())??t}function Ae(t){return Pe(t).input}function Pe(t){let e={description:t.description,name:t.name,nickname:t.nickname,treeAccess:t.treeAccess,groupName:t.groupName??void 0,id:t.id},r=ct(t.paramType),n={...t,paramType:r},o;try{let{schema:i,warning:a}=Re(n);n=i,o=a&&{inputName:t.name||"unknown",paramType:t.paramType,message:a.message,code:a.code}}catch(i){n={...n,default:null},o={inputName:t.name||"unknown",paramType:t.paramType,message:`Input "${t.name??"unknown"}" default could not be normalized and was dropped: ${i instanceof Error?i.message:String(i)}`,code:"MALFORMED_DEFAULT"}}let s=J.get(r);try{if(!s)throw c.unknownParamType(r,t.name);return{input:s.parse(n,e),error:o,...o&&{errors:[o]}}}catch(i){if(i instanceof c){y().error(`Validation error for input ${t.name||"unknown"}:`,i.message);let a={inputName:t.name||"unknown",paramType:t.paramType,message:i.message,code:i.code};return{input:(s??Ee).fallback(n,e),error:a,errors:o?[o,a]:[a]}}throw new c(i instanceof Error?i.message:String(i),"VALIDATION_ERROR",{context:{paramName:t.name,paramType:r},originalError:i instanceof Error?i:new Error(String(i))})}}function ke(t){return L(t).inputs}function L(t){let e=[],r=[];for(let n of t){let{input:o,errors:s}=Pe(n);e.push(o),s&&r.push(...s)}return{inputs:e,parseErrors:r}}function Oe(t){let e=p(t,"stepSize");return{id:p(t,"id")??"",name:p(t,"name")??"",nickname:p(t,"nickname")??null,description:p(t,"description")??"",paramType:p(t,"paramType")??"",treeAccess:p(t,"treeAccess")??!1,minimum:p(t,"minimum")??null,maximum:p(t,"maximum")??null,atLeast:p(t,"atLeast")??1,atMost:p(t,"atMost")??1,stepSize:typeof e=="number"&&Number.isFinite(e)?e:void 0,default:p(t,"default"),values:p(t,"values"),acceptedFormats:p(t,"acceptedFormats"),groupName:p(t,"groupName")??null}}function Fe(t){return{name:p(t,"name")??"",nickname:p(t,"nickname")??null,paramType:p(t,"paramType")??"",id:p(t,"id")??""}}async function P(t,e){let r=v(t,[]),n={};if(r.algo&&(n.algo=r.algo),r.pointer&&(n.pointer=r.pointer),!n.algo&&!n.pointer)throw new c("Definition must resolve to either a URL pointer or base64 algo",h.INVALID_INPUT,{context:{definition:t}});let o=await O("io",n,e);if(!o||typeof o!="object")throw new c("Invalid IO response structure",h.INVALID_INPUT,{context:{response:o,definition:t}});let s=Ne(p(o,"warnings")),i=Ne(p(o,"errors")),a=p(o,"inputs"),u=p(o,"outputs");return{inputs:Array.isArray(a)?a.map(Oe):[],outputs:Array.isArray(u)?u.map(Fe):[],...s&&{loadWarnings:s},...i&&{loadErrors:i}}}function Ne(t){if(!Array.isArray(t))return;let e=t.map(ft).filter(r=>r!==void 0);return e.length>0?e:void 0}function ft(t){if(t==null)return;let e;if(typeof t=="string")e=t;else if(typeof t=="object"){let r=p(t,"message");if(typeof r=="string"&&r.trim().length>0)e=r;else try{e=JSON.stringify(t)??String(t)}catch{e=String(t)}}else e=String(t);return e.trim().length>0?e:void 0}async function M(t,e){D("fetchParsedDefinitionIO",e.suppressBrowserWarning??e.suppressClientSideWarning);let{inputs:r,outputs:n,loadWarnings:o,loadErrors:s}=await P(t,e),{inputs:i,parseErrors:a}=L(r);return{inputs:i,outputs:n,...a.length>0&&{parseErrors:a},...o&&{loadWarnings:o},...s&&{loadErrors:s}}}var W=class t{constructor(e){l(this,"innerTree");l(this,"paramName");this.paramName=e,this.innerTree={}}append(e,r){let n=t.formatPathString(e);this.innerTree[n]||(this.innerTree[n]=[]);let o=r.map(s=>({data:t.serializeValue(s)}));return this.innerTree[n].push(...o),this}appendSingle(e,r){return this.append(e,[r])}fromDataTreeDefault(e){this.innerTree={};for(let[r,n]of Object.entries(e)){if(!Array.isArray(n))continue;let o=t.parsePathString(r);this.append(o,n)}return this}appendFlat(e){let r=Array.isArray(e)?e:[e];return this.append([0],r)}flatten(){let e=[];for(let r of Object.values(this.innerTree))if(Array.isArray(r))for(let n of r)e.push(t.deserializeValue(n.data));return e}getPaths(){return Object.keys(this.innerTree)}getPath(e){let r=t.formatPathString(e),n=this.innerTree[r];if(n)return n.map(o=>t.deserializeValue(o.data))}toComputeFormat(){return{ParamName:this.paramName,InnerTree:this.innerTree}}getInnerTree(){return this.innerTree}getParamName(){return this.paramName}static fromInputParams(e){return e.filter(r=>t.hasValidValue(r.default)).map(r=>{let n=new t(r.nickname||"unnamed"),o=r.default;if(r.treeAccess&&C(o))n.fromDataTreeDefault(o),t.isNumericInput(r)&&n.applyNumericConstraints(r.minimum,r.maximum,r.nickname||"unnamed");else{let s=Array.isArray(o)?o:[o],i=t.processValues(s,r);n.appendFlat(i)}return n.toComputeFormat()})}static fromInputParam(e){return t.hasValidValue(e.default)?t.fromInputParams([e])[0]:void 0}static replaceTreeValue(e,r,n){let o=e.length>0&&e[0]instanceof t,s=t.buildFromValue(r,n);if(o){let d=e.slice(),f=d.findIndex(m=>m.getParamName()===r);return f!==-1?d[f]=s:d.push(s),d}let i=e.slice(),a=s.toComputeFormat(),u=i.findIndex(d=>d.ParamName===r);return u!==-1?i[u]=a:i.push(a),i}static buildFromValue(e,r){let n=new t(e);return C(r)?n.fromDataTreeDefault(r):n.appendFlat(r),n}static getTreeValue(e,r){let o=e.length>0&&e[0]instanceof t?t.readFromBuilders(e,r):t.readFromDataTrees(e,r);return o===null||o.length===0?null:o.length===1?o[0]:o}static readFromBuilders(e,r){let n=e.find(o=>o.getParamName()===r);return n?n.flatten():null}static readFromDataTrees(e,r){let n=e.find(i=>i.ParamName===r);if(!n?.InnerTree)return null;let o=Object.keys(n.InnerTree)[0];if(!o)return null;let s=n.InnerTree[o];return Array.isArray(s)?s.map(i=>i?.data!==void 0?t.deserializeValue(i.data):null):s?.data!==void 0?[t.deserializeValue(s.data)]:s!==void 0?[s]:null}static parsePathString(e){let r=e.match(Q);if(!r)throw new Error(`Invalid Grasshopper tree path: "${e}". Expected "{}", "{0}", or "{0;1;2}" (negative indices allowed, no empty segments).`);return r[1]?r[1].split(";").map(Number):[]}static formatPathString(e){return`{${e.join(";")}}`}applyNumericConstraints(e,r,n){for(let o of Object.values(this.innerTree))if(Array.isArray(o))for(let s of o){let i=t.deserializeValue(s.data);if(typeof i=="number"){let a=t.clampValue(i,e,r,n);s.data=t.serializeValue(a)}}}static serializeValue(e){return typeof e=="boolean"||typeof e=="number"||typeof e=="string"?e:typeof e=="object"&&e!==null?JSON.stringify(e):String(e)}static deserializeValue(e){if(typeof e=="boolean"||typeof e=="number"||typeof e!="string")return e;if(e.startsWith("{")||e.startsWith("["))try{return JSON.parse(e)}catch{return e}let r=Number(e);return Number.isFinite(r)&&String(r)===e?r:e==="true"?!0:e==="false"?!1:e}static hasValidValue(e){return e==null?!1:typeof e=="string"?!0:!(Array.isArray(e)&&e.length===0||typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0)}static isNumericInput(e){return e.paramType==="Number"||e.paramType==="Integer"}static processValues(e,r){return e.map(n=>t.isNumericInput(r)&&typeof n=="number"?t.clampValue(n,r.minimum,r.maximum,r.nickname||"unnamed"):n).filter(n=>n!=null)}static clampValue(e,r,n,o){let s=e;return r!=null&&s<r&&(y().warn(`${o}: ${e} below min ${r}, clamping`),s=r),n!=null&&s>n&&(y().warn(`${o}: ${e} above max ${n}, clamping`),s=n),s}};export{T as a,E as b,$ as c,pe as d,R as e,I as f,A as g,k as h,Ae as i,ke as j,P as k,M as l,W as m};
|
|
2
|
+
//# sourceMappingURL=chunk-YREXY7GT.js.map
|
package/dist/core.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["d:\\Coding\\selva-compute\\dist\\core.cjs"],"names":[],"mappings":"AAAA,iIAA8G,wgBAAmP","file":"D:\\Coding\\selva-compute\\dist\\core.cjs"}
|
package/dist/grasshopper.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkWWD655BZcjs = require('./chunk-WWD655BZ.cjs');var _chunkCUQQ3ZBVcjs = require('./chunk-CUQQ3ZBV.cjs');exports.GrasshopperClient = _chunkWWD655BZcjs.g; exports.GrasshopperResponseProcessor = _chunkWWD655BZcjs.h; exports.RhinoComputeError = _chunkCUQQ3ZBVcjs.d; exports.SolveScheduler = _chunkWWD655BZcjs.f; exports.TreeBuilder = _chunkWWD655BZcjs.m; exports.downloadFileData = _chunkCUQQ3ZBVcjs.t; exports.extractFilesFromComputeResponse = _chunkCUQQ3ZBVcjs.s; exports.fetchDefinitionIO = _chunkWWD655BZcjs.k; exports.fetchParsedDefinitionIO = _chunkWWD655BZcjs.l; exports.hashDefinition = _chunkWWD655BZcjs.e; exports.hashSolveInput = _chunkWWD655BZcjs.d; exports.isDefinitionRef = _chunkWWD655BZcjs.a; exports.processInput = _chunkWWD655BZcjs.i; exports.processInputs = _chunkWWD655BZcjs.j; exports.solveGrasshopperDefinition = _chunkWWD655BZcjs.b; exports.stableStringify = _chunkWWD655BZcjs.c;
|
|
2
2
|
//# sourceMappingURL=grasshopper.cjs.map
|
package/dist/grasshopper.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["d:\\Coding\\selva-compute\\dist\\grasshopper.cjs"],"names":[],"mappings":"AAAA,iIAA4H,wDAAuD,0xBAAmY","file":"D:\\Coding\\selva-compute\\dist\\grasshopper.cjs"}
|
package/dist/grasshopper.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as d,b as e,c as f,d as g,e as h,f as i,g as j,h as k,i as l,j as m,k as n,l as o,m as p}from"./chunk-
|
|
1
|
+
import{a as d,b as e,c as f,d as g,e as h,f as i,g as j,h as k,i as l,j as m,k as n,l as o,m as p}from"./chunk-YREXY7GT.js";import{d as a,s as b,t as c}from"./chunk-WPB2LKCD.js";export{j as GrasshopperClient,k as GrasshopperResponseProcessor,a as RhinoComputeError,i as SolveScheduler,p as TreeBuilder,c as downloadFileData,b as extractFilesFromComputeResponse,n as fetchDefinitionIO,o as fetchParsedDefinitionIO,h as hashDefinition,g as hashSolveInput,d as isDefinitionRef,l as processInput,m as processInputs,e as solveGrasshopperDefinition,f as stableStringify};
|
|
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
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkWWD655BZcjs = require('./chunk-WWD655BZ.cjs');var _chunkCUQQ3ZBVcjs = require('./chunk-CUQQ3ZBV.cjs');exports.ComputeServerStats = _chunkCUQQ3ZBVcjs.n; exports.ErrorCodes = _chunkCUQQ3ZBVcjs.c; exports.GrasshopperClient = _chunkWWD655BZcjs.g; exports.GrasshopperResponseProcessor = _chunkWWD655BZcjs.h; exports.RhinoComputeError = _chunkCUQQ3ZBVcjs.d; exports.SolveScheduler = _chunkWWD655BZcjs.f; exports.TreeBuilder = _chunkWWD655BZcjs.m; exports.camelcaseKeys = _chunkCUQQ3ZBVcjs.p; exports.downloadFileData = _chunkCUQQ3ZBVcjs.t; exports.enableDebugLogging = _chunkCUQQ3ZBVcjs.g; exports.extractFilesFromComputeResponse = _chunkCUQQ3ZBVcjs.s; exports.fetchDefinitionIO = _chunkWWD655BZcjs.k; exports.fetchParsedDefinitionIO = _chunkWWD655BZcjs.l; exports.fetchRhinoCompute = _chunkCUQQ3ZBVcjs.l; exports.getLogger = _chunkCUQQ3ZBVcjs.e; exports.hashDefinition = _chunkWWD655BZcjs.e; exports.hashSolveInput = _chunkWWD655BZcjs.d; exports.isDefinitionRef = _chunkWWD655BZcjs.a; exports.processInput = _chunkWWD655BZcjs.i; exports.processInputs = _chunkWWD655BZcjs.j; exports.setLogger = _chunkCUQQ3ZBVcjs.f; exports.solveGrasshopperDefinition = _chunkWWD655BZcjs.b; exports.stableStringify = _chunkWWD655BZcjs.c; exports.toCamelCase = _chunkCUQQ3ZBVcjs.o;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["d:\\Coding\\selva-compute\\dist\\index.cjs"],"names":[],"mappings":"AAAA,iIAA4H,wDAAqG,moCAA4hB","file":"D:\\Coding\\selva-compute\\dist\\index.cjs"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as d,b as g,c as h,d as i,e as j,f as k,g as l,h as n,i as q,j as s,k as u,l as v,m as w}from"./chunk-
|
|
1
|
+
import{a as d,b as g,c as h,d as i,e as j,f as k,g as l,h as n,i as q,j as s,k as u,l as v,m as w}from"./chunk-YREXY7GT.js";import{c as o,d as r,e,f,g as m,l as p,n as t,o as x,p as a,s as b,t as c}from"./chunk-WPB2LKCD.js";export{t as ComputeServerStats,o as ErrorCodes,l as GrasshopperClient,n as GrasshopperResponseProcessor,r as RhinoComputeError,k as SolveScheduler,w as TreeBuilder,a as camelcaseKeys,c as downloadFileData,m as enableDebugLogging,b as extractFilesFromComputeResponse,u as fetchDefinitionIO,v as fetchParsedDefinitionIO,p as fetchRhinoCompute,e as getLogger,j as hashDefinition,i as hashSolveInput,d as isDefinitionRef,q as processInput,s as processInputs,f as setLogger,g as solveGrasshopperDefinition,h as stableStringify,x as toCamelCase};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{A as L,B as S,C as I,D as R,E as D,F as B,G,H as P,I as u,J as F,K as b,L as N,M as V,N as U,a as e,b as r,c as o,d as t,e as a,f as s,g as p,h as i,i as n,j as m,k as l,l as f,m as y,n as x,o as C,p as d,q as h,r as E,s as M,t as _,u as O,v as c,w as A,x as g,y as T,z as j}from"./chunk-MJOXUCDH.js";import"./chunk-WPB2LKCD.js";export{g as BINARY_MESH_MAGIC,j as BINARY_MESH_VERSION,T as COMPRESSED_MESH_MAGIC,n as EDGE_USERDATA_KIND,R as FLAG_DELTA_ENCODED,S as FLAG_FLOAT32,D as FLAG_HAS_UVS,B as FLAG_HAS_VERTEX_COLORS,I as FLAG_UINT16_INDICES,c as LOOKS,L as MIN_SUPPORTED_VERSION,e as Materials,V as SCALE_FACTORS,h as TEXTURE_CACHE_MAX_ENTRIES,P as UV_FORMAT_FLOAT32,G as UV_FORMAT_UINT16,m as addEdges,t as applyOffset,M as clearTextureCache,a as computeCombinedBoundingBox,s as createCameraController,p as createGrid,x as createLabelLayer,d as createMeasureTool,y as createRenderPipeline,i as createViewGizmo,U as getThreeMeshesFromComputeResponse,O as initThree,l as isEdgeOverlay,_ as materialAppearanceForLook,u as parseBinaryMeshBatch,o as parseColor,A as parseDisplayItems,F as parseMeshBatch,N as parseMeshBatchBlob,b as parseMeshBatchObject,f as removeEdges,E as setTextureAnisotropy,C as snapToVertex,r as updateScene};
|
|
2
|
+
//# sourceMappingURL=visualization-4PVR5P7N.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGFY3L653cjs = require('./chunk-GFY3L653.cjs');require('./chunk-CUQQ3ZBV.cjs');exports.BINARY_MESH_MAGIC = _chunkGFY3L653cjs.x; exports.BINARY_MESH_VERSION = _chunkGFY3L653cjs.z; exports.COMPRESSED_MESH_MAGIC = _chunkGFY3L653cjs.y; exports.EDGE_USERDATA_KIND = _chunkGFY3L653cjs.i; exports.FLAG_DELTA_ENCODED = _chunkGFY3L653cjs.D; exports.FLAG_FLOAT32 = _chunkGFY3L653cjs.B; exports.FLAG_HAS_UVS = _chunkGFY3L653cjs.E; exports.FLAG_HAS_VERTEX_COLORS = _chunkGFY3L653cjs.F; exports.FLAG_UINT16_INDICES = _chunkGFY3L653cjs.C; exports.LOOKS = _chunkGFY3L653cjs.v; exports.MIN_SUPPORTED_VERSION = _chunkGFY3L653cjs.A; exports.Materials = _chunkGFY3L653cjs.a; exports.SCALE_FACTORS = _chunkGFY3L653cjs.M; exports.TEXTURE_CACHE_MAX_ENTRIES = _chunkGFY3L653cjs.q; exports.UV_FORMAT_FLOAT32 = _chunkGFY3L653cjs.H; exports.UV_FORMAT_UINT16 = _chunkGFY3L653cjs.G; exports.addEdges = _chunkGFY3L653cjs.j; exports.applyOffset = _chunkGFY3L653cjs.d; exports.clearTextureCache = _chunkGFY3L653cjs.s; exports.computeCombinedBoundingBox = _chunkGFY3L653cjs.e; exports.createCameraController = _chunkGFY3L653cjs.f; exports.createGrid = _chunkGFY3L653cjs.g; exports.createLabelLayer = _chunkGFY3L653cjs.n; exports.createMeasureTool = _chunkGFY3L653cjs.p; exports.createRenderPipeline = _chunkGFY3L653cjs.m; exports.createViewGizmo = _chunkGFY3L653cjs.h; exports.getThreeMeshesFromComputeResponse = _chunkGFY3L653cjs.N; exports.initThree = _chunkGFY3L653cjs.u; exports.isEdgeOverlay = _chunkGFY3L653cjs.k; exports.materialAppearanceForLook = _chunkGFY3L653cjs.t; exports.parseBinaryMeshBatch = _chunkGFY3L653cjs.I; exports.parseColor = _chunkGFY3L653cjs.c; exports.parseDisplayItems = _chunkGFY3L653cjs.w; exports.parseMeshBatch = _chunkGFY3L653cjs.J; exports.parseMeshBatchBlob = _chunkGFY3L653cjs.L; exports.parseMeshBatchObject = _chunkGFY3L653cjs.K; exports.removeEdges = _chunkGFY3L653cjs.l; exports.setTextureAnisotropy = _chunkGFY3L653cjs.r; exports.snapToVertex = _chunkGFY3L653cjs.o; exports.updateScene = _chunkGFY3L653cjs.b;
|
|
2
|
+
//# sourceMappingURL=visualization-LS3Z7Q3N.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["d:\\Coding\\selva-compute\\dist\\visualization-LS3Z7Q3N.cjs"],"names":[],"mappings":"AAAA,iIAAoT,gCAA6B,k5DAA24B","file":"D:\\Coding\\selva-compute\\dist\\visualization-LS3Z7Q3N.cjs"}
|
package/dist/visualization.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGFY3L653cjs = require('./chunk-GFY3L653.cjs');require('./chunk-CUQQ3ZBV.cjs');exports.EDGE_USERDATA_KIND = _chunkGFY3L653cjs.i; exports.LOOKS = _chunkGFY3L653cjs.v; exports.Materials = _chunkGFY3L653cjs.a; exports.SCALE_FACTORS = _chunkGFY3L653cjs.M; exports.addEdges = _chunkGFY3L653cjs.j; exports.applyOffset = _chunkGFY3L653cjs.d; exports.computeCombinedBoundingBox = _chunkGFY3L653cjs.e; exports.createCameraController = _chunkGFY3L653cjs.f; exports.createGrid = _chunkGFY3L653cjs.g; exports.createLabelLayer = _chunkGFY3L653cjs.n; exports.createMeasureTool = _chunkGFY3L653cjs.p; exports.createRenderPipeline = _chunkGFY3L653cjs.m; exports.createViewGizmo = _chunkGFY3L653cjs.h; exports.getThreeMeshesFromComputeResponse = _chunkGFY3L653cjs.N; exports.initThree = _chunkGFY3L653cjs.u; exports.isEdgeOverlay = _chunkGFY3L653cjs.k; exports.parseColor = _chunkGFY3L653cjs.c; exports.parseDisplayItems = _chunkGFY3L653cjs.w; exports.parseMeshBatchBlob = _chunkGFY3L653cjs.L; exports.parseMeshBatchObject = _chunkGFY3L653cjs.K; exports.removeEdges = _chunkGFY3L653cjs.l; exports.snapToVertex = _chunkGFY3L653cjs.o; exports.updateScene = _chunkGFY3L653cjs.b;
|
|
2
2
|
//# sourceMappingURL=visualization.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["d:\\Coding\\selva-compute\\dist\\visualization.cjs"],"names":[],"mappings":"AAAA,iIAAkM,gCAA6B,ujCAA0e","file":"D:\\Coding\\selva-compute\\dist\\visualization.cjs"}
|
package/dist/visualization.d.cts
CHANGED
|
@@ -95,7 +95,14 @@ type RenderConfig = {
|
|
|
95
95
|
* well-lit regardless of the HDR, without washing colour out. The polished "product shot" look.
|
|
96
96
|
* - 'showcase': punchier presentation — ACES, stronger IBL/fill and a touch more exposure.
|
|
97
97
|
*/
|
|
98
|
-
|
|
98
|
+
/**
|
|
99
|
+
* The look values as a runtime array — the single source of truth. {@link Look} is derived from it, so
|
|
100
|
+
* the type and the enumerable list can never drift. Consumers (e.g. a viewer's style picker) iterate
|
|
101
|
+
* this instead of hardcoding the names, so adding or renaming a look here updates them automatically.
|
|
102
|
+
* 'technical' is first because it's the default.
|
|
103
|
+
*/
|
|
104
|
+
declare const LOOKS: readonly ["technical", "studio", "showcase"];
|
|
105
|
+
type Look = (typeof LOOKS)[number];
|
|
99
106
|
/** Crisp boundary/crease edge overlays on meshes. See `addEdges`. */
|
|
100
107
|
type EdgesConfig = {
|
|
101
108
|
/** Auto-attach edge overlays to meshes as they load. Default false (opt-in). */
|
|
@@ -781,4 +788,4 @@ interface DisplayItemParseOptions {
|
|
|
781
788
|
*/
|
|
782
789
|
declare function parseDisplayItems(items: DisplayItem[] | undefined, options?: DisplayItemParseOptions): THREE.Object3D[];
|
|
783
790
|
|
|
784
|
-
export { type CameraConfig, type CameraController, type CameraProjection, type ControlsConfig, DisplayBatch, DisplayItem, type DisplayItemParseOptions, EDGE_USERDATA_KIND, type EdgeOptions, type EdgesConfig, type EnvironmentConfig, type EventConfig, type FloorConfig, type GizmoConfig, type Grid, type GridConfig, type GridOptions, type LabelHandle, type LabelLayer, type LightingConfig, threeMaterials as Materials, type MeasureConfig, type MeasureOptions, type MeasureTool, MeshExtractionOptions, type RenderConfig, type RenderPipeline, type RenderPipelineOptions, SCALE_FACTORS, type ThreeInitializerOptions, type ViewGizmo, type ViewPreset, addEdges, applyOffset, computeCombinedBoundingBox, createCameraController, createGrid, createLabelLayer, createMeasureTool, createRenderPipeline, createViewGizmo, getThreeMeshesFromComputeResponse, initThree, isEdgeOverlay, parseColor, parseDisplayItems, parseMeshBatchBlob, parseMeshBatchObject, removeEdges, snapToVertex, updateScene };
|
|
791
|
+
export { type CameraConfig, type CameraController, type CameraProjection, type ControlsConfig, DisplayBatch, DisplayItem, type DisplayItemParseOptions, EDGE_USERDATA_KIND, type EdgeOptions, type EdgesConfig, type EnvironmentConfig, type EventConfig, type FloorConfig, type GizmoConfig, type Grid, type GridConfig, type GridOptions, LOOKS, type LabelHandle, type LabelLayer, type LightingConfig, type Look, threeMaterials as Materials, type MeasureConfig, type MeasureOptions, type MeasureTool, MeshExtractionOptions, type RenderConfig, type RenderPipeline, type RenderPipelineOptions, SCALE_FACTORS, type ThreeInitializerOptions, type ViewGizmo, type ViewPreset, addEdges, applyOffset, computeCombinedBoundingBox, createCameraController, createGrid, createLabelLayer, createMeasureTool, createRenderPipeline, createViewGizmo, getThreeMeshesFromComputeResponse, initThree, isEdgeOverlay, parseColor, parseDisplayItems, parseMeshBatchBlob, parseMeshBatchObject, removeEdges, snapToVertex, updateScene };
|
package/dist/visualization.d.ts
CHANGED
|
@@ -95,7 +95,14 @@ type RenderConfig = {
|
|
|
95
95
|
* well-lit regardless of the HDR, without washing colour out. The polished "product shot" look.
|
|
96
96
|
* - 'showcase': punchier presentation — ACES, stronger IBL/fill and a touch more exposure.
|
|
97
97
|
*/
|
|
98
|
-
|
|
98
|
+
/**
|
|
99
|
+
* The look values as a runtime array — the single source of truth. {@link Look} is derived from it, so
|
|
100
|
+
* the type and the enumerable list can never drift. Consumers (e.g. a viewer's style picker) iterate
|
|
101
|
+
* this instead of hardcoding the names, so adding or renaming a look here updates them automatically.
|
|
102
|
+
* 'technical' is first because it's the default.
|
|
103
|
+
*/
|
|
104
|
+
declare const LOOKS: readonly ["technical", "studio", "showcase"];
|
|
105
|
+
type Look = (typeof LOOKS)[number];
|
|
99
106
|
/** Crisp boundary/crease edge overlays on meshes. See `addEdges`. */
|
|
100
107
|
type EdgesConfig = {
|
|
101
108
|
/** Auto-attach edge overlays to meshes as they load. Default false (opt-in). */
|
|
@@ -781,4 +788,4 @@ interface DisplayItemParseOptions {
|
|
|
781
788
|
*/
|
|
782
789
|
declare function parseDisplayItems(items: DisplayItem[] | undefined, options?: DisplayItemParseOptions): THREE.Object3D[];
|
|
783
790
|
|
|
784
|
-
export { type CameraConfig, type CameraController, type CameraProjection, type ControlsConfig, DisplayBatch, DisplayItem, type DisplayItemParseOptions, EDGE_USERDATA_KIND, type EdgeOptions, type EdgesConfig, type EnvironmentConfig, type EventConfig, type FloorConfig, type GizmoConfig, type Grid, type GridConfig, type GridOptions, type LabelHandle, type LabelLayer, type LightingConfig, threeMaterials as Materials, type MeasureConfig, type MeasureOptions, type MeasureTool, MeshExtractionOptions, type RenderConfig, type RenderPipeline, type RenderPipelineOptions, SCALE_FACTORS, type ThreeInitializerOptions, type ViewGizmo, type ViewPreset, addEdges, applyOffset, computeCombinedBoundingBox, createCameraController, createGrid, createLabelLayer, createMeasureTool, createRenderPipeline, createViewGizmo, getThreeMeshesFromComputeResponse, initThree, isEdgeOverlay, parseColor, parseDisplayItems, parseMeshBatchBlob, parseMeshBatchObject, removeEdges, snapToVertex, updateScene };
|
|
791
|
+
export { type CameraConfig, type CameraController, type CameraProjection, type ControlsConfig, DisplayBatch, DisplayItem, type DisplayItemParseOptions, EDGE_USERDATA_KIND, type EdgeOptions, type EdgesConfig, type EnvironmentConfig, type EventConfig, type FloorConfig, type GizmoConfig, type Grid, type GridConfig, type GridOptions, LOOKS, type LabelHandle, type LabelLayer, type LightingConfig, type Look, threeMaterials as Materials, type MeasureConfig, type MeasureOptions, type MeasureTool, MeshExtractionOptions, type RenderConfig, type RenderPipeline, type RenderPipelineOptions, SCALE_FACTORS, type ThreeInitializerOptions, type ViewGizmo, type ViewPreset, addEdges, applyOffset, computeCombinedBoundingBox, createCameraController, createGrid, createLabelLayer, createMeasureTool, createRenderPipeline, createViewGizmo, getThreeMeshesFromComputeResponse, initThree, isEdgeOverlay, parseColor, parseDisplayItems, parseMeshBatchBlob, parseMeshBatchObject, removeEdges, snapToVertex, updateScene };
|
package/dist/visualization.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{K as v,L as c,M as j,N as z,a as e,b as r,c as t,d as o,e as i,f as a,g as s,h as p,i as n,j as l,k as f,l as m,m as y,n as u,o as x,p as d,u as C,v as g,w as h}from"./chunk-MJOXUCDH.js";import"./chunk-WPB2LKCD.js";export{n as EDGE_USERDATA_KIND,g as LOOKS,e as Materials,j as SCALE_FACTORS,l as addEdges,o as applyOffset,i as computeCombinedBoundingBox,a as createCameraController,s as createGrid,u as createLabelLayer,d as createMeasureTool,y as createRenderPipeline,p as createViewGizmo,z as getThreeMeshesFromComputeResponse,C as initThree,f as isEdgeOverlay,t as parseColor,h as parseDisplayItems,c as parseMeshBatchBlob,v as parseMeshBatchObject,m as removeEdges,x as snapToVertex,r as updateScene};
|
|
2
2
|
//# sourceMappingURL=visualization.js.map
|