brep-io-kernel 1.0.251 → 1.0.252

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/apiExamples/BREP_Booleans.html +2 -2
  2. package/dist/apiExamples/BREP_Export.html +2 -2
  3. package/dist/apiExamples/BREP_Primitives.html +2 -2
  4. package/dist/apiExamples/BREP_Transforms.html +2 -2
  5. package/dist/apiExamples/Embeded_2D_Sketcher.html +2 -2
  6. package/dist/apiExamples/Embeded_CAD.html +2 -2
  7. package/dist/apiExamples/Embeded_CAD_Integration_Test.html +2 -2
  8. package/dist/assembly-constraint-capture.html +5 -5
  9. package/dist/assets/{AnnotationRegistry-DxnuBVib.js → AnnotationRegistry-61-QTIl6.js} +1 -1
  10. package/dist/assets/{AssemblyConstraintRegistry-DHKMQSj6.js → AssemblyConstraintRegistry-DDhkhKoR.js} +1 -1
  11. package/dist/assets/{FeatureRegistry-C9h4q68e.js → FeatureRegistry-CyK8O2Ca.js} +3 -3
  12. package/dist/assets/{PartHistory-4fqTqe8m.js → PartHistory-CYHQ9__L.js} +1 -1
  13. package/dist/assets/{annUtils-C1gESzsQ.js → annUtils-B86URBT5.js} +1 -1
  14. package/dist/assets/{apiExample_BREP_Booleans-B1xVAOyX.js → apiExample_BREP_Booleans-DdWlLKsQ.js} +1 -1
  15. package/dist/assets/{apiExample_BREP_Export-CHD3cpsa.js → apiExample_BREP_Export-AUY7EeHW.js} +1 -1
  16. package/dist/assets/{apiExample_BREP_Primitives-Cxgt1-u1.js → apiExample_BREP_Primitives-g6bMwZLj.js} +1 -1
  17. package/dist/assets/{apiExample_BREP_Transforms-CZ-klSeH.js → apiExample_BREP_Transforms-DH3-Y9FI.js} +1 -1
  18. package/dist/assets/{apiExample_Embeded_2D_Sketcher-Bpi0fqAV.js → apiExample_Embeded_2D_Sketcher-B8EeF-Gj.js} +1 -1
  19. package/dist/assets/{apiExample_Embeded_CAD-B_SPpcLZ.js → apiExample_Embeded_CAD-7roRFtt7.js} +1 -1
  20. package/dist/assets/{apiExample_Embeded_CAD_Integration_Test-DjKBLQ49.js → apiExample_Embeded_CAD_Integration_Test-Pb0iBwIv.js} +1 -1
  21. package/dist/assets/{assemblyConstraintDialogs-8hg4PlL4.js → assemblyConstraintDialogs-BJX50LIF.js} +1 -1
  22. package/dist/assets/{brep-kernel-QpBwDdca.js → brep-kernel-BaJWJnmy.js} +1 -1
  23. package/dist/assets/{browserTests-CfVrmhte.js → browserTests-DxakKnoa.js} +1 -1
  24. package/dist/assets/{dialogCapturePageFactory-C9unVBhR.js → dialogCapturePageFactory-B5p-TYIP.js} +1 -1
  25. package/dist/assets/{featureDialogs-Cx7p1XpK.js → featureDialogs-CnBa1DyN.js} +1 -1
  26. package/dist/assets/{featureDialogs-D7xm3LIj.js → featureDialogs-DbmvJ-NA.js} +1 -1
  27. package/dist/assets/{index.es-Due8Wdrm.js → index.es-kd2D9M8K.js} +1 -1
  28. package/dist/assets/{javascript-CvgRKapH.js → javascript-CAvRMK4c.js} +1 -1
  29. package/dist/assets/{main-cad-DtMN0iSg.js → main-cad-Dojzs8d6.js} +6 -6
  30. package/dist/assets/{pmiDialogs-Bxu3FGJy.js → pmiDialogs-DQBW7aoF.js} +1 -1
  31. package/dist/assets/{test-Ccoy9ITq.js → test-ByMinHh_.js} +3 -3
  32. package/dist/cad.html +7 -7
  33. package/dist/feature-dialog-capture.html +4 -4
  34. package/dist/pmi-dialog-capture.html +5 -5
  35. package/dist/test.html +1 -1
  36. package/dist/viewer.html +7 -7
  37. package/dist-kernel/brep-kernel.js +1 -1
  38. package/package.json +1 -1
  39. package/src/BREP/SolidMethods/manifoldOps.js +5 -0
@@ -1,4 +1,4 @@
1
- var ve=Object.defineProperty;var Oe=s=>{throw TypeError(s)};var Cn=(s,t,e)=>t in s?ve(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var l=(s,t)=>ve(s,"name",{value:t,configurable:!0});var rt=(s,t,e)=>Cn(s,typeof t!="symbol"?t+"":t,e),xn=(s,t,e)=>t.has(s)||Oe("Cannot "+e);var Wt=(s,t,e)=>t.has(s)?Oe("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,e);var _=(s,t,e)=>(xn(s,t,"access private method"),e);import{r as Nn,F as Dn,A as it}from"./FeatureRegistry-C9h4q68e.js";import{Q as Qt,V as E,q as Pn,b6 as Bt,z as bt,X as kt,ah as ke,b7 as ze,ae as Fn,b2 as Rn,b as Xt}from"./featureDialogs-Cx7p1XpK.js";import{A as qe}from"./AssemblyConstraintRegistry-DHKMQSj6.js";import{d as O}from"./deepClone-Dj59xCHB.js";import{L as Ke}from"./ListEntityBase-DIaWtqmZ.js";import{e as vn,o as On}from"./browserStorage-CvgF8ovw.js";function kn(s,t){if(t==null)return null;if(typeof t=="number")return Number.isFinite(t)?t:null;let e=null;try{s&&typeof s.evaluateExpression=="function"&&(e=s.evaluateExpression(t))}catch{e=null}if(typeof e=="number"&&Number.isFinite(e))return e;const n=Number(e);if(Number.isFinite(n))return n;const r=Number(t);return Number.isFinite(r)?r:null}l(kn,"evaluateConstraintNumericValue");function G(s){return s===0?"0":s?String(s).trim():""}l(G,"normalizeTypeString");const zn=new Set(["type","persistentData","__open"]);function Tn(s,t){if(s===t)return!0;if(!Array.isArray(s)||!Array.isArray(t)||s.length!==t.length)return!1;for(let e=0;e<s.length;e+=1)if(s[e]!==t[e])return!1;return!0}l(Tn,"shallowArrayEqual");function Te(s){const t={};if(!s||typeof s!="object")return t;for(const e in s){if(!Object.prototype.hasOwnProperty.call(s,e)||zn.has(e))continue;const n=s[e]?s[e].default_value:void 0;t[e]=O(n)}return t}l(Te,"extractDefaults");function Me(s){return`Unknown constraint type: ${s!=null?String(s):"unknown"}`}l(Me,"formatUnknownConstraintMessage");const Mn=new Map([["touch_align","touch_align"],["touch-align","touch_align"],["touchalign","touch_align"],["touch align","touch_align"],["touch align constraint","touch_align"],["touchalignconstraint","touch_align"],["touch","touch_align"],["distance","distance"],["distance constraint","distance"],["distanceconstraint","distance"],["angle","angle"],["angle constraint","angle"],["angleconstraint","angle"]]),je={touch_align:"Touch Align",distance:"Distance",angle:"Angle"},Ee=1e-6,te=1,jn=.5,En=.5,Hn=Math.max(1,te),lt="Constraint disabled.";function ft(s,t){const e=Number(s);return Number.isFinite(e)?e:t}l(ft,"toFiniteNumber$5");function $n(s){const t=Math.floor(ft(s,te));return!Number.isFinite(t)||t<1?te:t}l($n,"clampIterations");function He(s,t){const e=ft(s,t);return Number.isFinite(e)?e<0?0:e>1?1:e:t}l(He,"clampGain");function Ln(s){if(!s||typeof s.traverse!="function")return;const t=[],e=["parallel-constraint-normal-","distance-constraint-normal-","touch-align-normal-"];s.traverse(n=>{!n||typeof n.name!="string"||e.some(r=>n.name.startsWith(r))&&t.push(n)});for(const n of t)try{n.parent?.remove?.(n)}catch{}}l(Ln,"removeExistingDebugArrows");function Ze(s){let t=s;for(;t;){if(t.isAssemblyComponent||t.type==="COMPONENT")return t;t=t.parent||null}return null}l(Ze,"resolveComponentFromObject");function Vn(s){return Ze(s)?1:0}l(Vn,"scoreObjectForComponent");function Un(s){if(!s)return null;if(s instanceof E)return s.clone();if(typeof s=="object"){const{x:t,y:e,z:n}=s,r=Number.isFinite(t)?t:0,i=Number.isFinite(e)?e:0,o=Number.isFinite(n)?n:0;return new E(r,i,o)}return null}l(Un,"vectorFrom");function xt(s,t=null){if(!s)return t;const e=s.inputParams||{},n=e.id??e.constraintID??s.id??t;return n==null?t:String(n)}l(xt,"resolveConstraintEntryId");function St(s){return G(xt(s))}l(St,"normalizeConstraintEntryId");var C,Je,Nt,ne,Qe,re,tn,ot,ie,en,nn,_t,se,Dt,B;const _e=class _e{constructor(t=null,e=null){Wt(this,C);this.partHistory=t||null,this.registry=e||new qe,this.constraints=[],this.idCounter=0,this._listeners=new Set,this._autoRunScheduled=!1,this._autoRunActive=!1,this._autoRunOptions=null}setPartHistory(t){this.partHistory=t||null,this.partHistory&&this.constraints.length&&_(this,C,ot).call(this)}setRegistry(t){this.registry=t||this.registry}addListener(t){return typeof t!="function"?()=>{}:(this._listeners.add(t),()=>{this._listeners.delete(t)})}removeListener(t){typeof t=="function"&&this._listeners.delete(t)}onChange(t){if(typeof t!="function")return()=>{};const e=l(()=>{try{t(this)}catch{}},"wrapped");return this.addListener(e)}list(){return this.entries}get entries(){return this.constraints}set entries(t){Array.isArray(t)?this.constraints=t:this.constraints=[]}get size(){return this.constraints.length}findById(t){const e=G(t);return e&&this.constraints.find(n=>St(n)===e)||null}async addConstraint(t,e=null){const n=_(this,C,Dt).call(this,t);if(!n)throw new Error(`Constraint type "${t}" is not registered.`);const r=n.inputParamsSchema||{},i=Te(r),o=G(n.constraintType||t||n.name),f={type:o,inputParams:{...i},persistentData:{isNewConstraint:!0},__open:!0,enabled:!0};Object.defineProperty(f,"constraintClass",{value:n,configurable:!0,writable:!0,enumerable:!1});const d=n?.shortName||n?.constraintShortName||o||"CONST",a=this.generateId(d),y=f.inputParams.id??f.inputParams.constraintID;return f.inputParams.id=y||a,_(this,C,Nt).call(this,f),e&&typeof e=="object"&&Object.assign(f.inputParams,O(e)),f.inputParams.applyImmediately=!0,_(this,C,ne).call(this,f),this.constraints.push(f),_(this,C,B).call(this,"add",f),this.checkConstraintErrors(this.partHistory),_(this,C,ot).call(this),f}removeConstraint(t){const e=G(t);if(!e)return!1;const n=this.constraints.findIndex(i=>St(i)===e);if(n<0)return!1;const[r]=this.constraints.splice(n,1);return _(this,C,B).call(this,"remove",r||null),this.checkConstraintErrors(this.partHistory),_(this,C,ot).call(this),!0}moveConstraint(t,e){const n=G(t);if(!n)return!1;const r=this.constraints.findIndex(i=>St(i)===n);return r<0?!1:this.moveConstraintToIndex(n,r+e)}moveConstraintToIndex(t,e){const n=G(t);if(!n)return!1;const r=this.constraints.findIndex(f=>St(f)===n);if(r<0)return!1;const i=Number.isFinite(e)?Math.max(0,Math.min(this.constraints.length-1,e)):r;if(i===r)return!1;const[o]=this.constraints.splice(r,1);return this.constraints.splice(i,0,o),_(this,C,B).call(this,"reorder",o||null),_(this,C,ot).call(this),!0}updateConstraintParams(t,e){const n=this.findById(t);return!n||typeof e!="function"?!1:(e(n.inputParams),_(this,C,Nt).call(this,n),_(this,C,B).call(this,"update",n),this.checkConstraintErrors(this.partHistory),_(this,C,ot).call(this),!0)}setConstraintEnabled(t,e){const n=this.findById(t);if(!n)return!1;const r=e!==!1;if(n.enabled!==!1===r){if(n.enabled!==r&&(n.enabled=r),!r&&n.persistentData?.status!=="disabled"){const f={...n.persistentData||{}};f.status="disabled",f.message||(f.message=lt),n.persistentData=f,_(this,C,B).call(this,"update",n)}return!1}n.enabled=r;const o={...n.persistentData||{}};return r?(o.status==="disabled"&&(o.status="pending",o.message===lt&&delete o.message,n.persistentData=o),_(this,C,B).call(this,"update",n),this.checkConstraintErrors(this.partHistory),_(this,C,ot).call(this),!0):(o.status="disabled",o.message||(o.message=lt),n.persistentData=o,_(this,C,B).call(this,"update",n),this.checkConstraintErrors(this.partHistory),_(this,C,ot).call(this),!0)}setOpenState(t,e){const n=this.findById(t);if(!n)return!1;const r=e!==!1;if(n.__open!==!1===r)return!1;const o=n.inputParams||{};if(Object.prototype.hasOwnProperty.call(o,"__open"))try{o.__open=r}catch{n.__open=r}else n.__open=r;return(!n.runtimeAttributes||typeof n.runtimeAttributes!="object")&&(n.runtimeAttributes={}),n.runtimeAttributes.__open=r,_(this,C,B).call(this,"open-state",n),!0}setExclusiveOpen(t){const e=G(t);if(!e)return!1;let n=!1;for(const r of this.constraints){if(!r)continue;const o=St(r)===e;if(r.__open!==!1!==o){const d=r.inputParams||{};if(Object.prototype.hasOwnProperty.call(d,"__open"))try{d.__open=o}catch{r.__open=o}else r.__open=o;(!r.runtimeAttributes||typeof r.runtimeAttributes!="object")&&(r.runtimeAttributes={}),r.runtimeAttributes.__open=o,n=!0}}return n&&_(this,C,B).call(this,"open-state",this.findById(t)),n}clear(){this.constraints=[],this.idCounter=0,_(this,C,B).call(this,"clear")}snapshot(){return{idCounter:this.idCounter,constraints:this.constraints.map(t=>({type:t?.type||null,inputParams:O(t?.inputParams)||{},persistentData:O(t?.persistentData)||{},open:t?.__open!==!1,enabled:t?.enabled!==!1}))}}async replaceAll(t=[],e=0){const n=[],r=Array.isArray(t)?t:[];let i=Number.isFinite(Number(e))?Number(e):0;for(const o of r){const f=_(this,C,Je).call(this,o);if(!f)continue;const d=f.type||f.constraintType||null,a=_(this,C,Dt).call(this,d);if(!a)continue;const y=Te(a.inputParamsSchema),c=G(a.constraintType||d||a.name),u={type:c,inputParams:{...y,...O(f.inputParams||{})},persistentData:O(f.persistentData||{}),__open:f.open!==!1,enabled:f.enabled!==!1},g=u.inputParams.id??u.inputParams.constraintID;if(g){const p=String(g).match(/(\d+)$/);if(p){const h=Number(p[1]);Number.isFinite(h)&&(i=Math.max(i,h))}u.inputParams.id=g}else{const p=(a?.shortName||a?.constraintShortName||c||"CONST").replace(/[^a-z0-9]/gi,"").toUpperCase()||"CONST";i+=1,u.inputParams.id=`${p}${i}`}_(this,C,Nt).call(this,u),u.inputParams.applyImmediately=!0,Object.defineProperty(u,"constraintClass",{value:a,configurable:!0,writable:!0,enumerable:!1}),_(this,C,ne).call(this,u),n.push(u)}this.idCounter=i,this.constraints=n,_(this,C,B).call(this,"replace"),this.constraints.length&&(this.checkConstraintErrors(this.partHistory),_(this,C,ot).call(this))}async deserialize(t){const e=t&&typeof t=="object"?t:{},n=Array.isArray(e.constraints)?e.constraints:Array.isArray(t)?t:[],r=Number.isFinite(Number(e.idCounter))?Number(e.idCounter):void 0;await this.replaceAll(n,r)}generateId(t="CONST"){const e=G(t).replace(/[^a-z0-9]/gi,"").toUpperCase()||"CONST";return this.idCounter+=1,`${e}${this.idCounter}`}checkConstraintErrors(t=this.partHistory,e={}){const n=e&&typeof e=="object"?e:{},r=n.emit!==!1,i=n.updatePersistentData!==!1,o=t||this.partHistory||null;o&&(this.partHistory=o);const f=_(this,C,re).call(this),d=[];let a=!1;const y=l((c,u)=>{const g=c?.persistentData&&typeof c.persistentData=="object"?c.persistentData:{},p={...g};let h=!1;const m=l((S,A)=>{const x=p[S];if(A===void 0){Object.prototype.hasOwnProperty.call(p,S)&&(delete p[S],h=!0);return}if(Array.isArray(x)&&Array.isArray(A)){if(Tn(x,A))return}else if(x===A)return;p[S]=A,h=!0},"set"),b=l(S=>{Object.prototype.hasOwnProperty.call(p,S)&&(delete p[S],h=!0)},"remove");try{u({set:m,remove:b,data:p,previous:g})}catch(S){console.warn("[AssemblyConstraintHistory] Failed to update persistent data:",S)}return h&&(c.persistentData=p),h},"mutatePersistentData");for(const c of this.constraints){if(!c)continue;const u=xt(c),g=c?.type||null,p={id:u,constraintID:u,type:g,status:"ok",message:"",duplicateConstraintIDs:null,duplicateSignature:null};if(c.enabled===!1){p.status="disabled",p.message=lt,i&&(a=y(c,({set:b,remove:S,previous:A})=>{b("status","disabled"),(!A.message||A.message===lt)&&b("message",lt),b("satisfied",!1),S("duplicateConstraintIDs"),S("duplicateSignature")})||a),d.push(p);continue}const h=_(this,C,Dt).call(this,g),m=f.get(c);if(!h){const b=Me(g);p.status="error",p.message=b,i&&(a=y(c,({set:S,remove:A})=>{S("status","error"),S("message",b),S("satisfied",!1),A("duplicateConstraintIDs"),A("duplicateSignature")})||a),d.push(p);continue}if(m){const b=Array.isArray(m.relatedIds)?m.relatedIds.filter(Boolean):[],S=m.signature||null;p.status="duplicate",p.message=m.message||"Duplicate constraint selections.",p.duplicateConstraintIDs=b.length?b:null,p.duplicateSignature=S,i&&(a=y(c,({set:A,remove:x})=>{A("status","duplicate"),A("message",p.message),A("satisfied",!1),p.duplicateConstraintIDs?A("duplicateConstraintIDs",p.duplicateConstraintIDs):x("duplicateConstraintIDs"),S?A("duplicateSignature",S):x("duplicateSignature")})||a),d.push(p);continue}i&&(a=y(c,({set:b,remove:S,previous:A})=>{A.status==="duplicate"&&(b("status","pending"),typeof A.message=="string"&&A.message.startsWith("Duplicate constraint selections")&&S("message")),A.status==="error"&&typeof A.message=="string"&&A.message.startsWith("Unknown constraint type:")&&(b("status","pending"),S("message")),S("duplicateConstraintIDs"),S("duplicateSignature")})||a),d.push(p)}return i&&a&&r&&_(this,C,B).call(this,"update"),d}async runAll(t=this.partHistory,e={}){const n=t||this.partHistory;if(!n)return[];this.partHistory=n,this.checkConstraintErrors(n,{emit:!1});const r=Math.abs(ft(e?.tolerance,Ee))||Ee,i=$n(e?.iterations),o=He(e?.translationGain,jn),f=He(e?.rotationGain,En),d=e?.debugMode===!0,a=d?500:0,y=ft(e?.delayMs??e?.iterationDelayMs,a),c=Math.max(0,Number.isFinite(y)?y:a),u=e?.viewer||n.viewer||null,g=l(()=>{try{u?.render?.()}catch{}try{u?.requestRender?.()}catch{}},"renderScene"),p=e?.controller&&typeof e.controller=="object"?e.controller:null,h=p?.signal||e?.signal||null;let m=!1;const b=l(()=>h?.aborted?(m=!0,!0):!1,"shouldAbort"),S=p?.hooks||e?.hooks,A=S&&typeof S=="object"?S:{},x=l(async(I,P={})=>{const v=A?.[I];if(typeof v=="function")try{await v({controller:p,signal:h,aborted:m,...P})}catch(D){console.warn(`[AssemblyConstraintHistory] hook "${I}" failed:`,D)}},"safeCallHook"),w=n.scene||null,N=Array.isArray(n.features)?n.features.filter(Boolean):[],F=new Map;for(const I of N){const P=G(I?.inputParams?.featureID);P&&F.set(P,I)}const M=new Set,V=l(I=>Nn(w,I,{scoreFn:Vn,allowJson:!1,allowUuidString:!1,allowUuidObject:!0,allowFuzzyName:!1,allowNameContains:!1,allowPath:!1,allowReference:!1,allowTarget:!1,allowSelectionName:!1,arrayMode:"first"}),"resolveObject"),$=l(I=>{const P=V(I);return Ze(P)},"resolveComponent"),X=l(I=>{if(!I)return null;const P=G(I.owningFeatureID);return P&&F.get(P)||null},"getFeatureForComponent"),L=l(I=>!!(!I||I.fixed||I.userData?.fixedByConstraint||X(I)?.inputParams?.isFixed),"isComponentFixed"),J=l(I=>{I&&M.add(I)},"markUpdated"),H={partHistory:n,scene:w,tolerance:r,translationGain:o,rotationGain:f,resolveObject:V,resolveComponent:$,applyTranslation:l((I,P)=>{const v=Un(P);return!I||!v||v.lengthSq()===0?!1:(I.position.add(v),I.updateMatrixWorld?.(!0),J(I),!0)},"applyTranslation"),applyRotation:l((I,P)=>{if(!I||!P)return!1;let v;if(P instanceof Qt)v=P.clone();else{const D=ft(P?.x,0),ct=ft(P?.y,0),z=ft(P?.z,0),W=Number.isFinite(P?.w)?P.w:1;v=new Qt(D,ct,z,W)}return!Number.isFinite(v.x)||!Number.isFinite(v.y)||!Number.isFinite(v.z)||!Number.isFinite(v.w)?!1:(Math.abs(1-v.lengthSq())>1e-6&&v.normalize(),I.quaternion.premultiply(v),I.updateMatrixWorld?.(!0),J(I),!0)},"applyRotation"),isComponentFixed:L,getFeatureForComponent:X,markUpdated:J,viewer:u,renderScene:g,debugMode:d};Ln(w);const wn=_(this,C,re).call(this),yt=this.constraints.map(I=>{const P=xt(I);if(I?.enabled===!1)return{entry:I,instance:null,result:{id:P,ok:!0,status:"disabled",message:lt,applied:!1,satisfied:!1,iteration:0,constraintID:P},skipReason:"disabled"};const v=wn.get(I);if(v){const U=Array.isArray(v.relatedIds)?v.relatedIds.slice():[],K={id:P,ok:!1,status:"duplicate",message:v.message,applied:!1,satisfied:!1,iteration:0,constraintID:P,duplicateConstraintIDs:U,duplicateSignature:v.signature};return{entry:I,instance:null,result:K,skipReason:"duplicate"}}const D=_(this,C,Dt).call(this,I.type);if(!D){const U=Me(I.type);return I.persistentData={status:"error",message:U,lastRunAt:Date.now(),lastIteration:0},{entry:I,instance:null,result:{id:P,ok:!1,status:"error",message:U,applied:!1,satisfied:!1,iteration:0,constraintID:P},skipReason:"unregistered"}}const ct=O(I.inputParams)||{},z=O(I.inputParams)||{},W=new D(n);_(this,C,Qe).call(this,z,D.inputParamsSchema||{});try{W.inputParams=z}catch{W.inputParams={...z}}try{Object.assign(W.persistentData,O(I.persistentData))}catch{W.persistentData={...I.persistentData||{}}}return{entry:I,instance:W,result:null,originalInputParams:ct}});for(const I of yt)I.instance?.clearDebugArrows?.({scene:w});await x("onStart",{maxIterations:i,constraintCount:yt.length});let Re=0;const _n=yt.length;t:for(let I=0;I<i&&!(b()||(await x("onIterationStart",{iteration:I,maxIterations:i}),b()));I+=1){let P=!1;for(let v=0;v<yt.length;v+=1){if(b())break t;const D=yt[v],ct=xt(D?.entry),z=D?.entry?.type||null,W={iteration:I,index:v,id:ct,constraintID:ct,constraintType:z,totalConstraints:_n};if(!D.instance){await x("onConstraintSkipped",{...W,skipReason:D.skipReason||null});continue}if(await x("onConstraintStart",W),b())break t;const U={...H,iteration:I,maxIterations:i};let K;try{typeof D.instance.solve=="function"?K=await D.instance.solve(U):K=await D.instance.run(U)}catch(gt){console.warn("[AssemblyConstraintHistory] Constraint solve failed:",gt),K={ok:!1,status:"error",message:gt?.message||"Constraint evaluation failed.",error:gt},D.instance.persistentData=D.instance.persistentData||{},D.instance.persistentData.status="error",D.instance.persistentData.message=K.message}if(D.result=_(this,C,se).call(this,D.instance,K,I),D.result.applied&&(P=!0),await x("onConstraintEnd",{...W,result:D.result}),b())break t}if(typeof H.renderScene=="function")try{H.renderScene()}catch{}if(c>0&&await new Promise(v=>setTimeout(v,c)),b()||(Re=I+1,await x("onIterationComplete",{iteration:I,maxIterations:i,applied:P}),b())||!P)break}m=m||h?.aborted||!1;const In=Date.now(),Ut=[];for(const I of yt){const{entry:P,instance:v}=I,D=I.result||_(this,C,se).call(this,v,{ok:!1,status:"pending",message:"Constraint was not evaluated."},Math.max(0,i-1)),z={...v?.persistentData&&Object.keys(v.persistentData).length?v.persistentData:P.persistentData||{}};if(D.status&&(z.status=D.status),D.message!==void 0&&(D.message?z.message=D.message:z.message&&delete z.message),z.satisfied=!!D.satisfied,typeof D.error=="number"&&Number.isFinite(D.error)&&(z.error=D.error),z.lastRunAt=In,z.lastIteration=D.iteration,z.lastRequestedIterations=i,D.status==="duplicate"?(Array.isArray(D.duplicateConstraintIDs)&&D.duplicateConstraintIDs.length?z.duplicateConstraintIDs=D.duplicateConstraintIDs.slice():z.duplicateConstraintIDs&&delete z.duplicateConstraintIDs,D.duplicateSignature?z.duplicateSignature=D.duplicateSignature:z.duplicateSignature&&delete z.duplicateSignature):(z.duplicateConstraintIDs&&delete z.duplicateConstraintIDs,z.duplicateSignature&&delete z.duplicateSignature),P.persistentData=z,I.originalInputParams){const U=O(I.originalInputParams)||{};D.persistInputParams&&typeof D.persistInputParams=="object"&&Object.assign(U,O(D.persistInputParams));const K=P.inputParams&&typeof P.inputParams=="object"?P.inputParams:{};for(const gt of Object.keys(K))Object.prototype.hasOwnProperty.call(U,gt)||delete K[gt];Object.assign(K,U),P.inputParams=K}else{const U={...P.inputParams||{}};D.persistInputParams&&typeof D.persistInputParams=="object"&&Object.assign(U,O(D.persistInputParams)),P.inputParams=U}const W=xt(P);Ut.push({id:W,constraintID:W,type:P?.type||null,...D})}try{n.syncAssemblyComponentTransforms?.()}catch(I){console.warn("[AssemblyConstraintHistory] Failed to sync component transforms:",I)}return _(this,C,B).call(this,"solve"),await x("onComplete",{results:Ut.slice(),aborted:m,iterationsCompleted:Re,maxIterations:i}),Ut}};C=new WeakSet,Je=l(function(t){if(!t||typeof t!="object")return t;const e={...t},n=t.inputParams&&typeof t.inputParams=="object"?t.inputParams:null;if(n){const i={...n},o=Object.prototype.hasOwnProperty.call(i,"constraintID")?i.constraintID:void 0;(i.id==null||i.id==="")&&o!=null&&(i.id=o),Object.prototype.hasOwnProperty.call(i,"constraintID")&&delete i.constraintID,e.inputParams=i}const r=Object.prototype.hasOwnProperty.call(e,"constraintID")?e.constraintID:void 0;return(e.id==null||e.id==="")&&r!=null&&(e.id=r),Object.prototype.hasOwnProperty.call(e,"constraintID")&&delete e.constraintID,(e.id==null||e.id==="")&&e.inputParams?.id!=null&&(e.id=e.inputParams.id),e},"#runConstraintEntryMigrations"),Nt=l(function(t){if(!t||!t.inputParams)return;const e=t.inputParams,n=e.id??e.constraintID??t.id;if(!n)return;const r=String(n);e.id=r,t.id=r},"#syncEntryIds"),ne=l(function(t){if(!t||typeof t!="object")return;(!t.inputParams||typeof t.inputParams!="object")&&(t.inputParams={});const e=t.inputParams,n={configurable:!0,enumerable:!1};_(this,C,Nt).call(this,t);const r=Object.prototype.hasOwnProperty.call(e,"constraintID")?e.constraintID:void 0;if(r!=null&&(e.id==null||e.id==="")&&(e.id=r),Object.prototype.hasOwnProperty.call(e,"constraintID"))try{delete e.constraintID}catch{}Object.getOwnPropertyDescriptor(e,"constraintID")||Object.defineProperty(e,"constraintID",{...n,get:l(()=>e.id,"get"),set:l(a=>{if(a==null){e.id=a,t.id=a;return}const y=String(a);e.id=y,t.id=y},"set")});const i=Object.prototype.hasOwnProperty.call(e,"__open")?e.__open:t.__open;if(Object.prototype.hasOwnProperty.call(e,"__open"))try{delete e.__open}catch{}const o=i!==!1;t.__open=o;const f=t.runtimeAttributes&&typeof t.runtimeAttributes=="object"?t.runtimeAttributes:{};f.__open=o;try{Object.defineProperty(t,"runtimeAttributes",{value:f,configurable:!0,writable:!0,enumerable:!1})}catch{t.runtimeAttributes=f}Object.prototype.hasOwnProperty.call(e,"__entityRef")||Object.defineProperty(e,"__entityRef",{...n,value:t});let d;if(Object.prototype.hasOwnProperty.call(e,"persistentData")){d=e.persistentData;try{delete e.persistentData}catch{}}d&&typeof d=="object"?t.persistentData=O(d):(!t.persistentData||typeof t.persistentData!="object")&&(t.persistentData={}),Object.defineProperty(e,"persistentData",{...n,get:l(()=>t.persistentData||(t.persistentData={}),"get"),set:l(a=>{const y=a&&typeof a=="object"?a:{};t.persistentData=y},"set")}),Object.defineProperty(e,"__open",{...n,get:l(()=>t.runtimeAttributes.__open!==!1,"get"),set:l(a=>{const y=a!==!1;t.runtimeAttributes.__open=y,t.__open=y},"set")}),t.type&&!e.type&&(e.type=t.type),t.entityType=t.type||e.type||t.entityType||null},"#linkEntryParams"),Qe=l(function(t,e){if(!(!t||!e))for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const r=e[n];if(!r||r.type!=="number")continue;const i=kn(this.partHistory,t[n]);i!=null&&(t[n]=i)}},"#applyNumericExpressions"),re=l(function(){const t=new Map;for(const n of this.constraints){if(!n)continue;const r=_(this,C,tn).call(this,n?.type);if(!r)continue;const i=_(this,C,en).call(this,n?.inputParams);if(!i)continue;t.has(i)||t.set(i,[]);const o=St(n)||null,f=je[r]||r;t.get(i).push({entry:n,type:r,typeLabel:f,id:o})}const e=new Map;for(const[n,r]of t.entries()){if(!Array.isArray(r)||r.length<=1)continue;const i=new Map;for(const o of r)i.has(o.type)||i.set(o.type,[]),i.get(o.type).push(o);for(const o of r){const f=(i.get(o.type)||[]).filter(g=>g!==o),d=[];for(const[g,p]of i.entries())g!==o.type&&d.push({type:g,entries:p});const a=l((g,p)=>{const h=Array.from(new Set(p.map(b=>b&&b.trim()?b.trim():null).filter(Boolean)));if(h.length===0)return`${g} constraint`;const m=h.length>1?"constraints":"constraint";return`${g} ${m} ${h.join(", ")}`},"formatConstraintPhrase"),y=[];if(f.length){const g=f.map(p=>p.id);y.push(a(`shares selections with ${o.typeLabel}`,g))}for(const g of d){const p=je[g.type]||g.type,h=g.entries.map(m=>m.id);y.push(a(`conflicts with ${p}`,h))}const c=y.length?`Duplicate constraint selections: ${y.join(". ")}.`:"Duplicate constraint selections.",u=r.filter(g=>g!==o).map(g=>g.id).filter(Boolean);e.set(o.entry,{message:c,signature:n,relatedIds:Array.from(new Set(u)),type:o.type})}}return e},"#detectDuplicateConstraints"),tn=l(function(t){const e=G(t).toLowerCase();return e&&Mn.get(e)||null},"#normalizeDuplicateConstraintType"),ot=l(function(t=null){if(!this.partHistory)return;const e=t&&typeof t=="object"?{...t}:null;this._autoRunOptions=e,!this._autoRunScheduled&&(this._autoRunScheduled=!0,Promise.resolve().then(()=>{try{_(this,C,ie).call(this)}catch(n){console.warn("[AssemblyConstraintHistory] Failed to schedule auto run:",n)}}))},"#scheduleAutoRun"),ie=l(async function(){if(!this._autoRunScheduled||this._autoRunActive)return;const t=this._autoRunOptions?{...this._autoRunOptions}:{};this._autoRunOptions=null,this._autoRunScheduled=!1;const e=Number(t.iterations),n=Number.isFinite(e)&&e>=1?Math.floor(e):Hn,r=this.partHistory;if(r){this._autoRunActive=!0;try{await this.runAll(r,{...t,iterations:n})}catch(i){console.warn("[AssemblyConstraintHistory] Auto run failed:",i)}finally{this._autoRunActive=!1,this._autoRunScheduled&&Promise.resolve().then(()=>{try{_(this,C,ie).call(this)}catch(i){console.warn("[AssemblyConstraintHistory] Failed to re-run auto cycle:",i)}})}}},"#executeAutoRun"),en=l(function(t){if(!t||typeof t!="object")return null;const e=_(this,C,nn).call(this,t);if(!e)return null;const n=[];for(const r of e){const i=_(this,C,_t).call(this,r,0,new Set);if(!i)return null;n.push(i)}return n.length!==2?null:(n.sort(),`${n[0]}|${n[1]}`)},"#buildSelectionSignature"),nn=l(function(t){const e=Array.isArray(t?.elements)?t.elements:[],n=[];for(const r of e)if(r!=null&&(n.push(r),n.length>=2))break;return n.length>=2?n.slice(0,2):null},"#extractSelectionPair"),_t=l(function(t,e=0,n=new Set){if(t==null||e>5)return null;if(Array.isArray(t)){for(const i of t){const o=_(this,C,_t).call(this,i,e+1,n);if(o)return o}return null}const r=typeof t;if(r==="string"||r==="number"||r==="boolean")return`${r}:${String(t)}`;if(r!=="object"||n.has(t))return null;n.add(t);try{if(t.isObject3D&&typeof t.uuid=="string"&&t.uuid)return`uuid:${t.uuid}`;const i=["selectionID","selectionId","fullName","fullPath","pathKey","pathId","pathID","id","uuid","entityUUID","brepId","brepID","objectUUID","objectId","objectID"];for(const a of i){const y=t[a];if(typeof y=="string"&&y.trim())return`${a}:${y.trim()}`}const o=["name","label","displayName","componentName","faceName","edgeName","vertexName","reference","refName"];for(const a of o){const y=t[a];if(typeof y=="string"&&y.trim())return`${a}:${y.trim()}`}if(Array.isArray(t.path)&&t.path.length){const a=t.path.map(y=>String(y)).join("/");if(a)return`path:${a}`}if(t.component&&typeof t.component=="object"){const a=_(this,C,_t).call(this,t.component,e+1,n);if(a)return`component:${a}`}if(t.object&&typeof t.object=="object"){const a=_(this,C,_t).call(this,t.object,e+1,n);if(a)return`object:${a}`}const f=Object.keys(t).filter(a=>a!=="__proto__").sort(),d=[];for(const a of f){const y=t[a];if(y==null||typeof y=="function"||typeof y=="symbol")continue;let c=null;if(typeof y=="object"){const u=_(this,C,_t).call(this,y,e+1,n);u&&(c=u)}else c=`${typeof y}:${String(y)}`;if(c&&(d.push(`${a}=${c}`),d.length>=8))break}return d.length?`obj:${d.join(",")}`:null}finally{n.delete(t)}},"#selectionKey"),se=l(function(t,e,n){const r=e&&typeof e=="object"?e:{},i=!!r.satisfied,o=!!r.applied,f=r.ok!==!1,d=typeof r.message=="string"?r.message:"";let a=typeof r.status=="string"&&r.status.trim()?r.status.trim():null;a||(f?i?a="satisfied":o?a="adjusted":a="pending":a="error");const y=Number.isFinite(r.error)?r.error:null,c=r.persistInputParams&&typeof r.persistInputParams=="object"?O(r.persistInputParams):null;return t&&(t.persistentData=t.persistentData||{},t.persistentData.status||(t.persistentData.status=a),d&&!t.persistentData.message&&(t.persistentData.message=d),t.persistentData.satisfied=i,y!=null&&(t.persistentData.error=y),t.persistentData.isNewConstraint===!0&&f&&o&&(t.persistentData.isNewConstraint=!1)),{ok:f,status:a,satisfied:i,applied:o,error:y,message:d,iteration:n,diagnostics:r.diagnostics||null,persistInputParams:c}},"#finalizeConstraintResult"),Dt=l(function(t){const e=G(t);if(!e)return null;if(this.registry&&typeof this.registry.getSafe=="function"){const n=this.registry.getSafe(e);if(n)return n}if(this.registry&&typeof this.registry.get=="function")try{return this.registry.get(e)}catch{return null}return null},"#resolveConstraint"),B=l(function(t="update",e=null,n=null){if(!(this._listeners instanceof Set)||this._listeners.size===0)return;const r={...n&&typeof n=="object"?n:{},history:this,entry:e||null,reason:t||"update"};for(const i of Array.from(this._listeners))try{i({...r})}catch{}},"#emitChange"),l(_e,"AssemblyConstraintHistory");let ee=_e;const Ie=class Ie{constructor(){this.metadata={}}getMetadata(t){const e=this.metadata[t]||{};return e.inheritsFrom?{...this.getMetadata(e.inheritsFrom),...e}:e}getOwnMetadata(t){const e=this.metadata[t];return e?{...e}:{}}setMetadata(t,e,n){this.metadata[t]||(this.metadata[t]={}),this.metadata[t][e]=n}setMetadataObject(t,e){e&&Object.keys(e).length>0?this.metadata[t]={...e}:delete this.metadata[t]}deleteMetadataKey(t,e){const n=this.metadata[t];n&&(delete n[e],Object.keys(n).length===0&&delete this.metadata[t])}clearMetadata(t){delete this.metadata[t]}};l(Ie,"MetadataManager");let Ht=Ie;const Ce=class Ce{constructor(t){this.partHistory=t||null,this.views=[],this._listeners=new Set}reset(){this.views=[],this._emit()}getViews(){return this._normalizeViewsArray(this.views),this.views}setViews(t){const e=Array.isArray(t)?Array.from(t):[];return this.views=e,this._normalizeViewsArray(this.views),this._emit(),this.views}addView(t){const e=this.getViews(),n=this._normalizeView(t,e.length);return e.push(n),this._emit(),n}updateView(t,e){const n=this.getViews(),r=Number(t);if(!Number.isInteger(r)||r<0||r>=n.length)return null;const i=n[r];let o=i;if(typeof e=="function")try{const f=e(i);f&&typeof f=="object"&&(o=f)}catch{}else e&&typeof e=="object"&&e!==i&&(o=Object.assign({},i,e));return o!==i&&(n[r]=o),n[r]=this._normalizeView(n[r],r),this._emit(),n[r]}removeView(t){const e=this.getViews(),n=Number(t);if(!Number.isInteger(n)||n<0||n>=e.length)return null;const[r]=e.splice(n,1);for(let i=0;i<e.length;i++)e[i]=this._normalizeView(e[i],i);return this._emit(),r||null}addListener(t){return typeof t!="function"?()=>{}:(this._listeners.add(t),()=>{try{this._listeners.delete(t)}catch{}})}removeListener(t){if(typeof t=="function")try{this._listeners.delete(t)}catch{}}notifyChanged(){this._emit()}toSerializable(){return this.getViews().map(t=>O(t))}_normalizeViewsArray(t){if(!Array.isArray(t))return this.views=[],this.views;for(let e=0;e<t.length;e++)t[e]=this._normalizeView(t[e],e);return t}_normalizeView(t,e){const n=Number.isInteger(e)?e:0,r=t&&typeof t=="object"?t:{},i=typeof r.name=="string"?r.name.trim():"",f=(typeof r.viewName=="string"?r.viewName.trim():"")||i||`View ${n+1}`;if(r.viewName=f,r.name=f,Array.isArray(r.annotations)||(r.annotations=[]),(!r.camera||typeof r.camera!="object")&&(r.camera={}),r.camera.viewport&&typeof r.camera.viewport=="object"){const y=Number(r.camera.viewport.width),c=Number(r.camera.viewport.height);y>0&&c>0?r.camera.viewport={width:y,height:c}:delete r.camera.viewport}(!r.viewSettings||typeof r.viewSettings!="object")&&(r.viewSettings={});const d=Number(r.viewSettings?.pmiTextSizePt);Number.isFinite(d)&&d>0?r.viewSettings.pmiTextSizePt=Math.max(1,Math.min(288,d)):delete r.viewSettings.pmiTextSizePt;const a=Array.isArray(r.viewSettings?.visibilityState?.hidden)?r.viewSettings.visibilityState.hidden.map(y=>({key:String(y?.key||""),count:Math.max(1,Math.round(Number(y?.count)||1))})).filter(y=>y.key):[];return a.length?r.viewSettings.visibilityState={hidden:a}:delete r.viewSettings.visibilityState,r.annotationHistory&&typeof r.annotationHistory!="object"&&delete r.annotationHistory,r}_emit(){if(!this._listeners||this._listeners.size===0)return;const t=this.getViews();for(const e of Array.from(this._listeners))try{e(t,this.partHistory||null)}catch{}}};l(Ce,"PMIViewsManager");let oe=Ce;const xe=class xe{constructor(){this.entityClasses=new Map}register(t){if(!t)return;const e=t.shortName;if(!e)throw new Error("EntityClass must declare static entityType (or type/name).");this.entityClasses.set(e,t)}resolve(t){const e=t;return e&&this.entityClasses.get(e)||null}};l(xe,"entityClassRegistry");let ae=xe;const Ne=class Ne{constructor({viewer:t=null,registry:e=null}={}){this.viewer=t||null,this.registry=e||null,this.entries=[],this.registry=new ae,this._listeners=new Set,this._idCounter=0}serializableData(){return this.entries.map(t=>({id:t.id,type:t.type,inputParams:t.inputParams,persistentData:t.persistentData}))}};l(Ne,"HistoryCollectionBase");let ue=Ne;const Wn={id:{type:"string",default_value:null,hint:"Unique identifier for this linear motion."},solid:{type:"reference_selection",selectionFilter:["SOLID"],multiple:!1,default_value:null,hint:"Select the solid to drive."},axis:{type:"reference_selection",selectionFilter:["EDGE"],multiple:!1,default_value:null,hint:"Select an edge or centerline to use as the travel direction."},speed:{type:"number",default_value:10,hint:"Linear speed in scene units per second."},distance:{type:"number",default_value:0,hint:"Optional travel distance. Leave blank to move continuously."}},pt=class pt extends Ke{onIdChanged(){}onParamsChanged(){}onPersistentDataChanged(){}};l(pt,"LinearMotionEntity"),rt(pt,"entityType","linear"),rt(pt,"shortName","LIN"),rt(pt,"longName","Linear Motion"),rt(pt,"inputParamsSchema",Wn);let $t=pt;const Bn={id:{type:"string",default_value:null,hint:"Unique identifier for this rotation motion."},solid:{type:"reference_selection",selectionFilter:["SOLID"],multiple:!1,default_value:null,hint:"Select the solid to drive."},axis:{type:"reference_selection",selectionFilter:["EDGE"],multiple:!1,default_value:null,hint:"Select an edge or centerline to rotate about."},speed:{type:"number",default_value:90,hint:"Rotation speed in degrees per second."},angle:{type:"number",default_value:0,hint:"Optional total angle in degrees. Leave blank to rotate continuously."}},ht=class ht extends Ke{onIdChanged(){}onParamsChanged(){}onPersistentDataChanged(){}};l(ht,"RotationMotionEntity"),rt(ht,"entityType","rotation"),rt(ht,"shortName","ROT"),rt(ht,"longName","Rotation Motion"),rt(ht,"inputParamsSchema",Bn);let Lt=ht;const At="rotation",$e=new Set(["type","persistentData","__open"]),De=class De extends ue{constructor(t){super({viewer:null}),this.partHistory=t||null,this._registerAvailableEntries()}getMotions(){return this.entries}createMotion(t=At,e=null){const n=this._resolveHandler(t);if(!n)return null;const r=new n({history:this,registry:this.registry});r.type=n.entityType||n.type||At,r.entityType=r.type;const i=this._defaultsFromSchema(n),o=O(e||{});r.setParams({...i,...o,type:r.type}),r.setPersistentData(o.persistentData||{}),delete r.inputParams.persistentData;const f=r.inputParams.id||this.generateId(r.shortName||r.type||"SIM");return r.setId(f),r.runtimeAttributes.__open=!0,this._linkInputParams(r),this.entries.push(r),this._bumpIdCounterFrom(r),this.notifyListeners({reason:"add",entry:r,history:this}),r}loadSerializable(t){this.entries=[],this._idCounter=0;const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{motions:t},n=Array.isArray(e.motions)?e.motions:[];for(const r of n){const i=this._hydrateEntity(r);i&&(this.entries.push(i),this._bumpIdCounterFrom(i),this._linkInputParams(i))}return this.notifyListeners({reason:"load",history:this}),this.entries}toSerializable(){return{motions:this.entries.map(t=>{const e=!!t.runtimeAttributes?.__open,n=O(t.inputParams||{});return n&&typeof n=="object"&&(delete n.persistentData,delete n.__open,delete n.__entityRef),{type:t.type||At,inputParams:n,persistentData:O(t.persistentData||{}),__open:e||void 0}})}}reset(){this.entries=[],this._idCounter=0,this.notifyListeners({reason:"clear",history:this})}generateId(t="SIM"){const e=String(t||"SIM").replace(/[^a-z0-9]/gi,"").toUpperCase()||"SIM",n=new Set(this.entries.map((i,o)=>{const f=i?.inputParams;return f?.id?String(f.id):i?.id!=null?String(i.id):`SIM${o+1}`}));let r="";do this._idCounter+=1,r=`${e}${this._idCounter}`;while(n.has(r));return r}addListener(t){return typeof t!="function"?()=>{}:(this._listeners.add(t),()=>{try{this._listeners.delete(t)}catch{}})}removeListener(t){if(typeof t=="function")try{this._listeners.delete(t)}catch{}}notifyListeners(t={}){if(this._listeners instanceof Set)for(const e of Array.from(this._listeners))try{e(t,this)}catch{}}_registerAvailableEntries(){for(const t of[Lt,$t])try{this.registry.register(t)}catch{}}_resolveHandler(t){return String(t||"").trim().toLowerCase()==="linear"?$t:Lt}_defaultsFromSchema(t){const e={},n=t?.inputParamsSchema;if(!n||typeof n!="object")return e;for(const r of Object.keys(n)){if($e.has(r))continue;const i=n[r];!i||typeof i!="object"||Object.prototype.hasOwnProperty.call(i,"default_value")&&(e[r]=O(i.default_value))}return e}_hydrateEntity(t){const e=t&&typeof t=="object"?t:{},n=this._resolveHandler(e.type||e.inputParams?.type||At);if(!n)return null;const r=new n({history:this,registry:this.registry});r.type=n.entityType||n.type||At,r.entityType=r.type;const i=this._cloneWithoutReserved(e.inputParams||e);i.type||(i.type=r.type),r.setParams(i),r.setPersistentData(O(e.persistentData||{})),delete r.inputParams.persistentData;const o=r.inputParams.id||e.id||this.generateId(r.shortName||r.type);return r.setId(o),r.runtimeAttributes.__open=!!e.__open,this._linkInputParams(r),r}_cloneWithoutReserved(t){const e={};if(!t||typeof t!="object")return e;for(const n of Object.keys(t))$e.has(n)||(e[n]=O(t[n]));return e}_linkInputParams(t){if(!t)return;(!t.runtimeAttributes||typeof t.runtimeAttributes!="object")&&(t.runtimeAttributes={});const e=t.inputParams||{},n={configurable:!0,enumerable:!1};Object.prototype.hasOwnProperty.call(e,"__entityRef")||Object.defineProperty(e,"__entityRef",{...n,value:t}),Object.prototype.hasOwnProperty.call(e,"persistentData")||Object.defineProperty(e,"persistentData",{...n,get:l(()=>t.persistentData,"get"),set:l(r=>{const i=r&&typeof r=="object"?r:{};t.setPersistentData(i)},"set")}),Object.prototype.hasOwnProperty.call(e,"__open")||Object.defineProperty(e,"__open",{...n,get:l(()=>!!t.runtimeAttributes.__open,"get"),set:l(r=>{t.runtimeAttributes.__open=!!r},"set")}),e.type=t.type||e.type||At,e.id==null&&t.id!=null&&(e.id=t.id)}_bumpIdCounterFrom(t){const e=t?.inputParams?.id||t?.id;if(!e)return;const n=String(e).match(/(\d+)$/);if(!n)return;const r=parseInt(n[1],10);Number.isFinite(r)&&r>this._idCounter&&(this._idCounter=r)}};l(De,"SimulationStateManager");let ce=De;const wt=96,rn=1;function Xn(s,t=0){const e=Number(s);return Number.isFinite(e)?e:t}l(Xn,"toFiniteNumber$4");function le(s,t){return Math.max(rn,Xn(s,t))}l(le,"clampCustomSheetSize");function Le(s){const t=Math.round(le(s,rn)*100)/100;return String(t).replace(/(\.\d*?[1-9])0+$/u,"$1").replace(/\.0+$/u,"")}l(Le,"formatSheetDimension");const fe=Object.freeze({A:Object.freeze({key:"A",label:"A (8.5 x 11 in)",widthIn:8.5,heightIn:11}),B:Object.freeze({key:"B",label:"B (11 x 17 in)",widthIn:11,heightIn:17}),C:Object.freeze({key:"C",label:"C (17 x 22 in)",widthIn:17,heightIn:22}),D:Object.freeze({key:"D",label:"D (22 x 34 in)",widthIn:22,heightIn:34}),E:Object.freeze({key:"E",label:"E (34 x 44 in)",widthIn:34,heightIn:44}),A4:Object.freeze({key:"A4",label:"A4 (210 x 297 mm)",widthIn:8.27,heightIn:11.69}),A3:Object.freeze({key:"A3",label:"A3 (297 x 420 mm)",widthIn:11.69,heightIn:16.54}),A2:Object.freeze({key:"A2",label:"A2 (420 x 594 mm)",widthIn:16.54,heightIn:23.39}),A1:Object.freeze({key:"A1",label:"A1 (594 x 841 mm)",widthIn:23.39,heightIn:33.11}),A0:Object.freeze({key:"A0",label:"A0 (841 x 1189 mm)",widthIn:33.11,heightIn:46.81}),CUSTOM:Object.freeze({key:"CUSTOM",label:"Custom",widthIn:36,heightIn:24})}),Yn=Object.freeze(["A","B","C","D","E","A4","A3","A2","A1","A0","CUSTOM"]);function sn(s){return String(s??"").trim().toLowerCase()==="portrait"?"portrait":"landscape"}l(sn,"normalizeSheetOrientation");function on(s){const t=String(s??"").trim().toUpperCase();return fe[t]||fe.A}l(on,"getSheetSizeByKey");function xr(){return Yn.map(s=>fe[s]).filter(Boolean)}l(xr,"listSheetSizes");function Gn(s,t="landscape",e=null){const n=on(s),r=sn(t);if(n.key==="CUSTOM"){const d=le(e?.customWidthIn??e?.widthIn,n.widthIn),a=le(e?.customHeightIn??e?.heightIn,n.heightIn),y=r==="landscape",c=y?Math.max(d,a):Math.min(d,a),u=y?Math.min(d,a):Math.max(d,a);return{key:n.key,label:`Custom (${Le(c)} x ${Le(u)} in)`,orientation:r,units:"in",widthIn:c,heightIn:u,widthPx:c*wt,heightPx:u*wt,pxPerInch:wt,customWidthIn:c,customHeightIn:u}}const i=r==="landscape",o=i?Math.max(n.widthIn,n.heightIn):Math.min(n.widthIn,n.heightIn),f=i?Math.min(n.widthIn,n.heightIn):Math.max(n.widthIn,n.heightIn);return{key:n.key,label:n.label,orientation:r,units:"in",widthIn:o,heightIn:f,widthPx:o*wt,heightPx:f*wt,pxPerInch:wt}}l(Gn,"resolveSheetDimensions");function vt(s,t=0){const e=Number(s);return Number.isFinite(e)?e:t}l(vt,"toFiniteNumber$3");function tt(s,t,e){return Math.max(t,Math.min(e,s))}l(tt,"clamp$1");function ut(s,t=""){return typeof s=="string"?s:s==null?t:String(s)}l(ut,"sanitizeText$1");function qn(s,t=null){const e=String(s??"").trim();return e&&(/^#[\da-fA-F]{3,8}$/.test(e)||/^[a-zA-Z]+$/.test(e)||/^(rgb|rgba|hsl|hsla)\([^)]+\)$/i.test(e))?e:t}l(qn,"sanitizeColor$1");function j(s,t=1){return Math.max(1,Math.round(vt(s,t)))}l(j,"clampPositiveInt");function Z(s,t=0){return Math.max(0,Math.round(vt(s,t)))}l(Z,"clampIndex");function Kn(s,t=null){if(s==null)return t;const e=String(s).trim().toLowerCase();return e==="middle"||e==="center"?"center":e==="end"||e==="right"?"right":e==="left"?"left":t}l(Kn,"normalizeTextAlign$1");function Zn(s,t=null){if(s==null)return t;const e=String(s).trim().toLowerCase();return e==="center"?"middle":e==="bottom"?"bottom":e==="middle"||e==="top"?e:t}l(Zn,"normalizeVerticalAlign$1");function Jn(s,t=null){if(s==null)return t;const e=String(s).trim();return e==="bold"?"700":e==="normal"?"400":/^\d{3}$/.test(e)?e:t}l(Jn,"normalizeFontWeight");function Qn(s,t=null){return s==null?t:String(s).trim().toLowerCase()==="italic"?"italic":"normal"}l(Qn,"normalizeFontStyle");function tr(s,t=null){return s==null?t:String(s).trim().toLowerCase()==="underline"?"underline":"none"}l(tr,"normalizeTextDecoration");function we(s){if(!s||typeof s!="object"||Array.isArray(s))return{};const t={},e=ut(s.fontFamily,"").trim();e&&(t.fontFamily=e);const n=vt(s.fontSize,Number.NaN);Number.isFinite(n)&&n>0&&(t.fontSize=tt(n,.08,3));const r=Jn(s.fontWeight??(s.bold?"700":null));r&&(t.fontWeight=r);const i=Qn(s.fontStyle??(s.italic?"italic":null));i&&(t.fontStyle=i);const o=tr(s.textDecoration);o&&(t.textDecoration=o);const f=Kn(s.textAlign??s.textAnchor);f&&(t.textAlign=f);const d=Zn(s.verticalAlign??s.verticalAnchor);d&&(t.verticalAlign=d);const a=qn(s.color??s.textColor,null);return a&&(t.color=a),t}l(we,"normalizeTableCellStyle");function an(s=""){return{text:ut(s,""),rowSpan:1,colSpan:1,mergedInto:null,style:{}}}l(an,"createTableCell");function mt(s,t){const e=Math.max(1,j(t,1)),n=Array.isArray(s)?s.slice(0,e):[],r=[];for(let o=0;o<e;o+=1)r.push(Math.max(1e-4,vt(n[o],1)));const i=r.reduce((o,f)=>o+f,0);return!Number.isFinite(i)||i<=0?Array.from({length:e},()=>1/e):r.map(o=>o/i)}l(mt,"normalizeTableFractions");function It(s,t=0){return Array.isArray(s?.cells)&&s.cells.length>0?s.cells.length:Array.isArray(s?.rowFractions)&&s.rowFractions.length>0?s.rowFractions.length:Math.max(0,j(t,0))}l(It,"getTableRowCount");function Ct(s,t=0){const e=Array.isArray(s?.cells)?s.cells:[];let n=0;for(const r of e)Array.isArray(r)&&(n=Math.max(n,r.length));return n>0?n:Array.isArray(s?.colFractions)&&s.colFractions.length>0?s.colFractions.length:Math.max(0,j(t,0))}l(Ct,"getTableColumnCount");function un(s=3,t=3){const e=Math.max(1,j(s,3)),n=Math.max(1,j(t,3));return{rowFractions:mt(null,e),colFractions:mt(null,n),cells:Array.from({length:e},()=>Array.from({length:n},()=>an()))}}l(un,"createTableData");function Ot(s,t=3,e=3){const n=Math.max(1,It(s,t)),r=Math.max(1,Ct(s,e)),i=un(n,r);i.rowFractions=mt(s?.rowFractions,n),i.colFractions=mt(s?.colFractions,r);const o=Array.isArray(s?.cells)?s.cells:[],f=[];for(let a=0;a<n;a+=1)for(let y=0;y<r;y+=1){const c=Array.isArray(o[a])?o[a][y]:null,u=i.cells[a][y];c&&typeof c=="object"&&!Array.isArray(c)?(u.text=ut(c.text,ut(c.value,"")),u.style=we(c.style&&typeof c.style=="object"?c.style:c),f.push({row:a,col:y,rowSpan:j(c.rowSpan,1),colSpan:j(c.colSpan,1)})):(u.text=ut(c,""),u.style={}),u.rowSpan=1,u.colSpan=1,u.mergedInto=null}const d=Array.from({length:n},()=>Array.from({length:r},()=>!1));for(const a of f){const y=tt(a.rowSpan,1,n-a.row),c=tt(a.colSpan,1,r-a.col);if(y===1&&c===1)continue;let u=!1;for(let p=a.row;p<a.row+y&&!u;p+=1)for(let h=a.col;h<a.col+c;h+=1)if(!(p===a.row&&h===a.col)&&d[p][h]){u=!0;break}if(u)continue;const g=i.cells[a.row][a.col];g.rowSpan=y,g.colSpan=c;for(let p=a.row;p<a.row+y;p+=1)for(let h=a.col;h<a.col+c;h+=1)p===a.row&&h===a.col||(d[p][h]=!0,i.cells[p][h]={text:"",rowSpan:1,colSpan:1,mergedInto:{row:a.row,col:a.col},style:{}})}return i}l(Ot,"normalizeTableData");function Rt(s,t,e){return Array.isArray(s?.cells?.[t])&&s.cells[t][e]||null}l(Rt,"getTableCell");function cn(s,t,e){const n=Rt(s,t,e);if(!n)return null;const r=n?.mergedInto;if(r&&Number.isInteger(r.row)&&Number.isInteger(r.col)){const i=Rt(s,r.row,r.col);if(i)return{row:r.row,col:r.col,cell:i}}return{row:t,col:e,cell:n}}l(cn,"resolveTableCellAnchor");function Nr(s){if(!s)return null;const t=[s.anchorRow,s.focusRow].map(n=>Z(n,0)),e=[s.anchorCol,s.focusCol].map(n=>Z(n,0));return{minRow:Math.min(...t),maxRow:Math.max(...t),minCol:Math.min(...e),maxCol:Math.max(...e)}}l(Nr,"getTableSelectionRect");function Vt(s,t=3,e=3){const n=Ot(s,t,e);return{rowFractions:n.rowFractions.slice(),colFractions:n.colFractions.slice(),cells:n.cells.map(r=>r.map(i=>({text:ut(i?.text,""),rowSpan:j(i?.rowSpan,1),colSpan:j(i?.colSpan,1),mergedInto:i?.mergedInto&&Number.isInteger(i.mergedInto.row)&&Number.isInteger(i.mergedInto.col)?{row:i.mergedInto.row,col:i.mergedInto.col}:null,style:we(i?.style)})))}}l(Vt,"cloneTableData");function er(s,t){if(typeof t!="function")return;const e=Ot(s),n=It(e,0),r=Ct(e,0);for(let i=0;i<n;i+=1)for(let o=0;o<r;o+=1){const f=Rt(e,i,o);!f||f?.mergedInto||t(f,i,o,e)}}l(er,"forEachTableAnchor");function Dr(s,t,e,n){const r=Vt(s),i=cn(r,Z(t,0),Z(e,0));return i?.cell&&(i.cell.text=ut(n,"")),r}l(Dr,"setTableCellText");function nr(s,t){const e=Ot(s),n=t||null;if(!n)return!1;const r=It(e,0),i=Ct(e,0),o=tt(n.minRow,0,Math.max(0,r-1)),f=tt(n.maxRow,o,Math.max(0,r-1)),d=tt(n.minCol,0,Math.max(0,i-1)),a=tt(n.maxCol,d,Math.max(0,i-1));if(o===f&&d===a)return!1;for(let y=o;y<=f;y+=1)for(let c=d;c<=a;c+=1){const u=Rt(e,y,c);if(!u||u?.mergedInto||j(u.rowSpan,1)!==1||j(u.colSpan,1)!==1)return!1}return!0}l(nr,"canMergeTableCells");function Pr(s,t){const e=Vt(s),n=t||null;if(!n||!nr(e,n))return e;const r=Z(n.minRow,0),i=Math.max(r,Z(n.maxRow,r)),o=Z(n.minCol,0),f=Math.max(o,Z(n.maxCol,o)),d=Rt(e,r,o);if(!d)return e;d.rowSpan=i-r+1,d.colSpan=f-o+1,d.mergedInto=null;for(let a=r;a<=i;a+=1)for(let y=o;y<=f;y+=1)a===r&&y===o||(e.cells[a][y]={text:"",rowSpan:1,colSpan:1,mergedInto:{row:r,col:o},style:{}});return e}l(Pr,"mergeTableCells");function Fr(s,t,e){const n=Vt(s),r=cn(n,Z(t,0),Z(e,0));if(!r?.cell)return n;const i=j(r.cell.rowSpan,1),o=j(r.cell.colSpan,1);if(i===1&&o===1)return n;r.cell.rowSpan=1,r.cell.colSpan=1,r.cell.mergedInto=null;for(let f=r.row;f<r.row+i;f+=1)for(let d=r.col;d<r.col+o;d+=1)f===r.row&&d===r.col||(n.cells[f][d]=an(""));return n}l(Fr,"unmergeTableCell");function Ve(s,t){const e=Array.isArray(s)?s.slice():[1],n=e.length;if(n<=0)return[1];const r=tt(t,0,n),i=tt(r===n?n-1:r,0,n-1),o=Math.max(1e-4,vt(e[i],1/n)),f=Math.max(1e-4,o*.5);return e[i]=Math.max(1e-4,o-f),e.splice(r,0,f),mt(e,e.length)}l(Ve,"splitFractionList");function ln(s,{rowInsertIndex:t=null,colInsertIndex:e=null}={}){const n=Ot(s),r=It(n,1),i=Ct(n,1),o=t==null?r:r+1,f=e==null?i:i+1,d=t==null?-1:tt(t,0,r),a=e==null?-1:tt(e,0,i),y=un(o,f);return y.rowFractions=t==null?mt(n.rowFractions,r):Ve(n.rowFractions,d),y.colFractions=e==null?mt(n.colFractions,i):Ve(n.colFractions,a),er(n,(c,u,g)=>{const p=d>=0&&u>=d?u+1:u,h=a>=0&&g>=a?g+1:g,m=d>=0&&u<d&&u+j(c.rowSpan,1)>d?j(c.rowSpan,1)+1:j(c.rowSpan,1),b=a>=0&&g<a&&g+j(c.colSpan,1)>a?j(c.colSpan,1)+1:j(c.colSpan,1);y.cells[p][h]={text:ut(c.text,""),rowSpan:m,colSpan:b,mergedInto:null,style:we(c.style)};for(let S=p;S<p+m;S+=1)for(let A=h;A<h+b;A+=1)S===p&&A===h||(y.cells[S][A]={text:"",rowSpan:1,colSpan:1,mergedInto:{row:p,col:h},style:{}})}),y}l(ln,"buildInsertedTable");function rr(s,t){return ln(s,{rowInsertIndex:Z(t,0)})}l(rr,"insertTableRow");function ir(s,t){return ln(s,{colInsertIndex:Z(t,0)})}l(ir,"insertTableColumn");function Rr(s,t=1,e=1){let n=Vt(s,t,e);const r=Math.max(1,j(t,1)),i=Math.max(1,j(e,1));for(;It(n,0)<r;)n=rr(n,It(n,0));for(;Ct(n,0)<i;)n=ir(n,Ct(n,0));return n}l(Rr,"ensureTableSize");function k(s,t=0){const e=Number(s);return Number.isFinite(e)?e:t}l(k,"toFiniteNumber$2");function Y(s,t=""){return typeof s=="string"?s:s==null?t:String(s)}l(Y,"sanitizeText");function et(s,t){const e=String(s??"").trim();return e&&(/^#[\da-fA-F]{3,8}$/.test(e)||/^[a-zA-Z]+$/.test(e)||/^(rgb|rgba|hsl|hsla)\([^)]+\)$/i.test(e))?e:t}l(et,"sanitizeColor");function T(s,t,e){return Math.max(t,Math.min(e,s))}l(T,"clamp");function Yt(s,t="left"){const e=String(s||t).trim().toLowerCase();return e==="middle"||e==="center"?"center":e==="end"||e==="right"?"right":"left"}l(Yt,"normalizeTextAlign");function Gt(s,t="top"){const e=String(s||t).trim().toLowerCase();return e==="center"?"middle":e==="bottom"?"bottom":e==="middle"?"middle":"top"}l(Gt,"normalizeVerticalAlign");function sr(s,t="c"){const e=String(s||t).trim().toLowerCase();return["nw","n","ne","w","c","e","sw","s","se"].includes(e)?e:t}l(sr,"normalizePmiAnchor");function Ue(s,t="bottom"){const e=String(s||t).trim().toLowerCase();return["top","bottom","none"].includes(e)?e:t}l(Ue,"normalizePmiLabelPosition");function or(s,t="shaded"){const e=String(s||t).trim().toLowerCase();return["shaded","monochrome"].includes(e)?e:t}l(or,"normalizePmiRenderMode");function ar(s,t="solid"){const e=String(s||t).trim();return["none","solid","dotted","dashed","dashDot","longDash","dashDotDot"].includes(e)?e:t}l(ar,"normalizeLineStyle");function st(s){return["rect","ellipse","triangle","diamond","pentagon","hexagon","parallelogram","trapezoid"].includes(String(s||""))}l(st,"isShapeElementType");function fn(s){return["parallelogram","trapezoid"].includes(String(s||""))}l(fn,"shapeSupportsAdjustHandle");function ur(s){return fn(s)?.18:0}l(ur,"getDefaultShapeAdjust");function cr(s,t){return fn(s)?T(k(t,ur(s)),0,.45):0}l(cr,"clampShapeAdjust");function lr(s){const t=String(s??"").trim().toLowerCase();return t==="rect"?"rect":t==="ellipse"?"ellipse":t==="triangle"?"triangle":t==="diamond"?"diamond":t==="pentagon"?"pentagon":t==="hexagon"?"hexagon":t==="parallelogram"?"parallelogram":t==="trapezoid"?"trapezoid":t==="table"?"table":t==="image"?"image":t==="line"?"line":t==="pmiinset"||t==="pmi_inset"||t==="pmi"||t==="pmiview"?"pmiInset":"text"}l(lr,"normalizeElementType");const Pe=class Pe{constructor(t){this.partHistory=t||null,this.sheets=[],this._listeners=new Set}reset(){this.sheets=[],this._emit()}getSheets(){return this._normalizeSheetsArray(this.sheets),this.sheets}getSheetById(t){const e=String(t??"").trim();return e&&this.getSheets().find(n=>String(n?.id||"")===e)||null}setSheets(t){const e=Array.isArray(t)?Array.from(t):[];return this.sheets=e,this._normalizeSheetsArray(this.sheets),this._emit(),this.sheets}createSheet(t={}){const e=this.getSheets(),n=Date.now(),r=this._normalizeSheet({...t,id:t?.id||this._generateSheetId(),metadata:{...t?.metadata&&typeof t.metadata=="object"?t.metadata:{},createdAt:Number.isFinite(Number(t?.metadata?.createdAt))?Number(t.metadata.createdAt):n,updatedAt:Number.isFinite(Number(t?.metadata?.updatedAt))?Number(t.metadata.updatedAt):n}},e.length);return e.push(r),this._emit(),r}duplicateSheet(t){const e=this._resolveSheetIndex(t);if(e<0)return null;const n=this.getSheets()[e],r=O(n)||{};r.id=this._generateSheetId(),r.name=`${Y(n?.name,"Sheet")} Copy`,r.elements=Array.isArray(r.elements)?r.elements.map(o=>({...o||{},id:this._generateElementId(r.id)})):[];const i=this._normalizeSheet(r,this.sheets.length);return this.sheets.push(i),this._emit(),i}updateSheet(t,e){const n=this._resolveSheetIndex(t);if(n<0)return null;const r=this.sheets[n];let i=r;if(typeof e=="function")try{const f=e(O(r));f&&typeof f=="object"&&(i=f)}catch{i=r}else e&&typeof e=="object"&&(i={...r,...e});const o=this._normalizeSheet(i,n,r?.id);return o.metadata={...o.metadata||{},createdAt:Number.isFinite(Number(r?.metadata?.createdAt))?Number(r.metadata.createdAt):o.metadata?.createdAt,updatedAt:Date.now()},this.sheets[n]=o,this._emit(),this.sheets[n]}moveSheet(t,e){const n=this._resolveSheetIndex(t);if(n<0)return null;const r=this.getSheets(),i=T(Math.round(k(e,n)),0,Math.max(0,r.length-1));if(i===n)return r[n]||null;const[o]=r.splice(n,1);return o?(r.splice(i,0,o),this._normalizeSheetsArray(r),this._emit(),o):null}removeSheet(t){const e=this._resolveSheetIndex(t);if(e<0)return null;const[n]=this.sheets.splice(e,1);return this._normalizeSheetsArray(this.sheets),this._emit(),n||null}addListener(t){return typeof t!="function"?()=>{}:(this._listeners.add(t),()=>{try{this._listeners.delete(t)}catch{}})}removeListener(t){if(typeof t=="function")try{this._listeners.delete(t)}catch{}}notifyChanged(){this._emit()}toSerializable(){return this.getSheets().map(t=>O(t))}_resolveSheetIndex(t){if(Number.isInteger(t)){const n=Number(t);return n>=0&&n<this.getSheets().length?n:-1}const e=String(t??"").trim();return e?this.getSheets().findIndex(n=>String(n?.id||"")===e):-1}_generateSheetId(){const t=new Set(this.getSheets().map(n=>String(n?.id||"")));let e=1;for(;t.has(`sheet-${e}`);)e+=1;return`sheet-${e}`}_generateElementId(t="sheet"){return`${String(t||"sheet").replace(/[^A-Za-z0-9_-]/g,"_")}:el:${Date.now().toString(36)}:${Math.random().toString(36).slice(2,7)}`}_normalizeSheetsArray(t){if(!Array.isArray(t))return this.sheets=[],this.sheets;for(let e=0;e<t.length;e++){const n=t[e]?.id;t[e]=this._normalizeSheet(t[e],e,n)}return t}_normalizeSheet(t,e,n=null){const r=t&&typeof t=="object"?t:{},i=on(r.sizeKey),o=sn(r.orientation),f=Math.max(1,k(r.customWidthIn??r.widthIn,i.widthIn)),d=Math.max(1,k(r.customHeightIn??r.heightIn,i.heightIn)),a=Gn(i.key,o,{customWidthIn:f,customHeightIn:d}),y=Y(n||r.id||this._generateSheetId(),"").trim()||this._generateSheetId(),c=Y(r.name,"").trim()||`Sheet ${e+1}`,u=Array.isArray(r.elements)?r.elements:[],g=[],p=new Set;for(let h=0;h<u.length;h++){const m=this._normalizeElement(u[h],h,y,a);m&&(p.has(m.id)&&(m.id=this._generateElementId(y)),p.add(m.id),g.push(m))}return{id:y,name:c,sizeKey:a.key,sizeLabel:a.label,orientation:a.orientation,units:a.units,widthIn:a.widthIn,heightIn:a.heightIn,customWidthIn:a.key==="CUSTOM"?a.widthIn:void 0,customHeightIn:a.key==="CUSTOM"?a.heightIn:void 0,widthPx:a.widthPx,heightPx:a.heightPx,pxPerInch:a.pxPerInch,background:et(r.background,"#ffffff"),elements:g,metadata:{createdAt:Number.isFinite(Number(r?.metadata?.createdAt))?Number(r.metadata.createdAt):Date.now(),updatedAt:Number.isFinite(Number(r?.metadata?.updatedAt))?Number(r.metadata.updatedAt):Number.isFinite(Number(r?.metadata?.createdAt))?Number(r.metadata.createdAt):Date.now()}}}_normalizeElement(t,e,n,r){const i=t&&typeof t=="object"?t:{},o=lr(i.type),f=Math.max(.1,k(r?.widthIn,11)),d=Math.max(.1,k(r?.heightIn,8.5)),a=-f*2,y=-d*2,c=f*3,u=d*3,g=T(k(i.x,f*.1),a,c),p=T(k(i.y,d*.1),y,u),h=Y(i.id,"").trim()||this._generateElementId(n),m=Number.isInteger(i.z)?i.z:Number.isInteger(i.layer)?i.layer:e,b={id:h,type:o,groupId:Y(i.groupId,"").trim()||void 0,formboard:i.formboard&&typeof i.formboard=="object"?O(i.formboard):void 0,x:g,y:p,rotationDeg:k(i.rotationDeg,0),z:Number.isFinite(Number(m))?Number(m):e,fill:et(i.fill,o==="text"||o==="pmiInset"?"transparent":o==="table"?"#ffffff":"#dbeafe"),stroke:et(i.stroke,o==="table"?"#0f172a":"#1d4ed8"),strokeWidth:T(k(i.strokeWidth,.02),.002,1),lineStyle:ar(i.lineStyle,"solid"),opacity:T(k(i.opacity,1),0,1)};if(o==="line"){const nt=T(k(i.x2,g+1),a,c),H=T(k(i.y2,p),y,u);return{...b,x2:nt,y2:H,strokeWidth:T(k(i.strokeWidth,.035),.002,1)}}const S=Number.isFinite(Number(i.w)),A=Number.isFinite(Number(i.h)),x=k(S?i.w:i.width??(i.radiusX!=null?k(i.radiusX,.8)*2:1.4),1.4),w=k(A?i.h:i.height??(i.radiusY!=null?k(i.radiusY,.55)*2:.9),.9),N=T(x,.05,f*8),F=T(w,.05,d*8),M=!S&&!A&&Number.isFinite(Number(i.width))&&Number.isFinite(Number(i.height)),V=!S&&!A&&Number.isFinite(Number(i.radiusX))&&Number.isFinite(Number(i.radiusY)),$=T(M||V?k(i.x,f*.5)-N*.5:g,a,c),X=T(M||V?k(i.y,d*.5)-F*.5:p,y,u);if(o==="table"){const nt=String(i.fontStyle||(i.italic?"italic":"normal")).toLowerCase()==="italic"?"italic":"normal",H=String(i.fontWeight||(i.bold?"700":"400"));return{...b,x:$,y:X,w:T(x,.4,f*8),h:T(w,.3,d*8),tableData:Ot(i.tableData,i.rows??3,i.cols??4),fontSize:T(k(i.fontSize,.22),.08,3),fontFamily:Y(i.fontFamily,"Arial, Helvetica, sans-serif"),fontWeight:/^\d{3}$/.test(H)?H:H==="bold"?"700":"400",fontStyle:nt,textDecoration:String(i.textDecoration||"none").toLowerCase()==="underline"?"underline":"none",textAlign:Yt(i.textAlign||i.textAnchor,"left"),verticalAlign:Gt(i.verticalAlign||i.verticalAnchor,"middle"),color:et(i.color,et(i.textColor,"#111111"))}}if(st(o)||o==="image"||o==="pmiInset"){const nt=String(i.fontStyle||(i.italic?"italic":"normal")).toLowerCase()==="italic"?"italic":"normal",H=String(i.fontWeight||(i.bold?"700":"400"));return{...b,x:$,y:X,w:N,h:F,cornerRadius:T(k(i.cornerRadius,o==="rect"?.1:0),0,Math.min(N,F)*.5),shapeAdjust:cr(o,i.shapeAdjust),src:o==="image"||o==="pmiInset"?Y(i.src,""):void 0,mediaScale:o==="image"||o==="pmiInset"?T(k(i.mediaScale,1),1,10):void 0,mediaOffsetX:o==="image"||o==="pmiInset"?T(k(i.mediaOffsetX,0),-1,1):void 0,mediaOffsetY:o==="image"||o==="pmiInset"?T(k(i.mediaOffsetY,0),-1,1):void 0,pmiViewIndex:o==="pmiInset"?Number.isInteger(i.pmiViewIndex)?i.pmiViewIndex:-1:void 0,pmiViewName:o==="pmiInset"?Y(i.pmiViewName,"PMI View"):void 0,pmiImageRevision:o==="pmiInset"?Number.isInteger(i.pmiImageRevision)?i.pmiImageRevision:0:void 0,pmiModelRevision:o==="pmiInset"?Number.isInteger(i.pmiModelRevision)?i.pmiModelRevision:-1:void 0,pmiImageCaptureKey:o==="pmiInset"?Y(i.pmiImageCaptureKey,""):void 0,showTitle:o==="pmiInset"?Ue(i.pmiLabelPosition,i.showTitle!==!1?"bottom":"none")!=="none":void 0,pmiLabelPosition:o==="pmiInset"?Ue(i.pmiLabelPosition,i.showTitle!==!1?"bottom":"none"):void 0,pmiRenderMode:o==="pmiInset"?or(i.pmiRenderMode,"shaded"):void 0,pmiShowCenterLines:o==="pmiInset"?i.pmiShowCenterLines===!0:void 0,pmiAnchor:o==="pmiInset"?sr(i.pmiAnchor,"c"):void 0,text:st(o)?Y(i.text,""):void 0,fontSize:st(o)?T(k(i.fontSize,.28),.08,3):void 0,fontFamily:st(o)?Y(i.fontFamily,"Arial, Helvetica, sans-serif"):void 0,fontWeight:st(o)?/^\d{3}$/.test(H)?H:H==="bold"?"700":"400":void 0,fontStyle:st(o)?nt:void 0,textAlign:st(o)?Yt(i.textAlign||i.textAnchor,"center"):void 0,verticalAlign:st(o)?Gt(i.verticalAlign||i.verticalAnchor,"middle"):void 0,color:st(o)?et(i.color,et(i.textColor,"#0f172a")):void 0}}const L=Yt(i.textAlign||i.textAnchor,"left"),J=String(i.fontStyle||(i.italic?"italic":"normal")).toLowerCase()==="italic"?"italic":"normal",Q=String(i.fontWeight||(i.bold?"700":"400"));return{...b,w:T(k(S?i.w:i.width,3.2),.1,f*8),h:T(k(A?i.h:i.height,1.1),.1,d*8),text:Y(i.text,`Text ${e+1}`),fontSize:T(k(i.fontSize,.32),.08,3),fontFamily:Y(i.fontFamily,"Arial, Helvetica, sans-serif"),fontWeight:/^\d{3}$/.test(Q)?Q:Q==="bold"?"700":"400",fontStyle:J,textAlign:L,verticalAlign:Gt(i.verticalAlign||i.verticalAnchor,"top"),color:et(i.color,et(i.textColor,et(i.fill,"#111111")))}}_emit(){if(!this._listeners||this._listeners.size===0)return;const t=this.getSheets();for(const e of Array.from(this._listeners))try{e(t,this.partHistory||null)}catch{}}};l(Pe,"Sheet2DManager");let pe=Pe;function Ft(s,t=0){const e=Number(s);return Number.isFinite(e)?e:t}l(Ft,"toFiniteNumber$1");function q(s,t=""){return String(s??"").trim()||t}l(q,"normalizeText");function qt(s,t=0){const e=s&&typeof s=="object"?s:{},n=Number.isInteger(t)?t+1:1;return{id:q(e.id,`wire-${n}`),name:q(e.name,`Wire ${n}`),from:q(e.from,""),to:q(e.to,""),diameter:Math.max(.01,Ft(e.diameter,1))}}l(qt,"normalizeConnection");function fr(s){return!Array.isArray(s)||s.length<3?null:[Ft(s[0],0),Ft(s[1],0),Ft(s[2],0)]}l(fr,"normalizePointArray");function We(s){return Array.isArray(s)?s.map(t=>q(t,"")).filter(Boolean):[]}l(We,"normalizeStringArray");function pr(s,t=new Map){const e=s&&typeof s=="object"?s:{},n=q(e.connectionId,""),r=t.get(n)||null,i=!!e.feasible;return{connectionId:n,connectionName:q(e.connectionName,r?.name||n||"Wire"),feasible:i,error:q(e.error,i?"":"No route found through the harness network."),distance:Number.isFinite(Number(e.distance))?Number(e.distance):null,polyline:(Array.isArray(e.polyline)?e.polyline:[]).map(o=>fr(o)).filter(Boolean),segmentIds:We(e.segmentIds),nodePath:We(e.nodePath),reusesHarnessPoint:!!e.reusesHarnessPoint,diameter:Math.max(.01,Ft(e.diameter,r?.diameter||1)),from:q(e.from,r?.from||""),to:q(e.to,r?.to||"")}}l(pr,"normalizeRouteResult");const Fe=class Fe{constructor(t){this.partHistory=t||null,this.connections=[],this.routeResults=[],this._pendingRestoredRouteResults=null,this._listeners=new Set}reset(){this.connections=[],this.routeResults=[],this._pendingRestoredRouteResults=null,this._emit()}getConnections(){return this._normalizeConnectionsArray(this.connections),this.connections}setConnections(t){const e=Array.isArray(t)?Array.from(t):[];return this.connections=e,this._normalizeConnectionsArray(this.connections),this._pendingRestoredRouteResults=null,this._emit(),this.connections}addConnection(t={}){const e=this.getConnections(),n=qt({id:t?.id||this._generateConnectionId(),...t},e.length);return e.push(n),this._emit(),n}updateConnection(t,e){const n=this.getConnections(),r=q(t,""),i=n.findIndex(d=>String(d?.id||"")===r);if(i<0)return null;const o=n[i];let f=o;if(typeof e=="function")try{const d=e(O(o));d&&typeof d=="object"&&(f=d)}catch{f=o}else e&&typeof e=="object"&&(f={...o,...e});return n[i]=qt(f,i),n[i].id||(n[i].id=o.id),this._emit(),n[i]}removeConnection(t){const e=this.getConnections(),n=q(t,""),r=e.findIndex(o=>String(o?.id||"")===n);if(r<0)return null;const[i]=e.splice(r,1);return this.routeResults=this.routeResults.filter(o=>String(o?.connectionId||"")!==n),this._normalizeConnectionsArray(e),this._emit(),i||null}getRouteResults(){return this._normalizeRouteResultsArray(this.routeResults),Array.isArray(this.routeResults)?this.routeResults:[]}setRouteResults(t,e={}){const n=!!e?.preservePendingRestore,r=!!e?.markPendingRestore;return this.routeResults=Array.isArray(t)?t.map(i=>({...i||{}})):[],this._normalizeRouteResultsArray(this.routeResults),r?this._pendingRestoredRouteResults=this.routeResults.map(i=>O(i)):n||(this._pendingRestoredRouteResults=null),this._emit(),this.routeResults}clearRouteResults(t={}){this.routeResults=[],t?.preservePendingRestore||(this._pendingRestoredRouteResults=null),this._emit()}getRouteResultMap(){const t=new Map;for(const e of this.getRouteResults()){const n=q(e?.connectionId,"");n&&t.set(n,e)}return t}addListener(t){return typeof t!="function"?()=>{}:(this._listeners.add(t),()=>{try{this._listeners.delete(t)}catch{}})}removeListener(t){if(typeof t=="function")try{this._listeners.delete(t)}catch{}}notifyChanged(){this._emit()}toSerializable(){return{connections:this.getConnections().map(t=>O(t)),routeResults:this.getRouteResults().map(t=>O(t))}}loadSerializable(t){const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{connections:t,routeResults:[]};return this.connections=Array.isArray(e.connections)?Array.from(e.connections):[],this._normalizeConnectionsArray(this.connections),this.routeResults=Array.isArray(e.routeResults)?Array.from(e.routeResults):[],this._normalizeRouteResultsArray(this.routeResults),this._pendingRestoredRouteResults=this.routeResults.length?this.routeResults.map(n=>O(n)):null,this._emit(),this.toSerializable()}consumePendingRestoredRouteResults(){const t=Array.isArray(this._pendingRestoredRouteResults)?this._pendingRestoredRouteResults.map(e=>O(e)):null;return this._pendingRestoredRouteResults=null,t}_generateConnectionId(){const t=new Set(this.getConnections().map(n=>String(n?.id||"")));let e=1;for(;t.has(`wire-${e}`);)e+=1;return`wire-${e}`}_normalizeConnectionsArray(t){if(!Array.isArray(t))return this.connections=[],this.connections;for(let e=0;e<t.length;e+=1)t[e]=qt(t[e],e);return t}_normalizeRouteResultsArray(t){if(!Array.isArray(t))return this.routeResults=[],this.routeResults;const e=new Map(this.getConnections().map(n=>[String(n?.id||""),n]));for(let n=0;n<t.length;n+=1)t[n]=pr(t[n],e);return t}_emit(){if(!this._listeners||this._listeners.size===0)return;const t={connections:this.getConnections(),routeResults:this.getRouteResults(),manager:this,partHistory:this.partHistory||null};for(const e of Array.from(this._listeners))try{e(t)}catch{}}};l(Fe,"WireHarnessManager");let he=Fe;const hr=new Set(["slider","number","select","string"]),pn=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function dt(s,t=null){const e=Number(s);return Number.isFinite(e)?e:t}l(dt,"toFiniteNumber");function de(s){const t=[],e=new Set;for(const n of s){const r=String(n??"").trim();!r||e.has(r)||(e.add(r),t.push(r))}return t}l(de,"uniqueStrings");function me(){return{fields:[],values:{}}}l(me,"createEmptyConfiguratorState");function vr(s){return pn.test(String(s??"").trim())}l(vr,"isConfiguratorFieldNameValid");function dr(s){const t=String(s??"").replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\s+/g," ").trim();return t?t.charAt(0).toUpperCase()+t.slice(1):"Field"}l(dr,"prettyConfiguratorLabel");function mr(s,t=0,e=new Set){let n=String(s??"").trim();n=n.replace(/\s+/g,"_").replace(/[^A-Za-z0-9_$]/g,"_").replace(/_+/g,"_"),n||(n=`field${t+1}`),/^[A-Za-z_$]/.test(n)||(n=`_${n}`),pn.test(n)||(n=`field${t+1}`);let r=n,i=2;for(;e.has(r);)r=`${n}_${i}`,i+=1;return e.add(r),r}l(mr,"normalizeConfiguratorFieldName");function yr(s){return Array.isArray(s)?de(s):typeof s!="string"?[]:de(s.split(/\r?\n|,/g))}l(yr,"parseConfiguratorOptions");function gr(s){const t=String(s??"").trim().toLowerCase();return t==="options"||t==="dropdown"?"select":hr.has(t)?t:"number"}l(gr,"normalizeConfiguratorType");function Kt(s,t){const e=String(s?.type??"").trim().toLowerCase();if(e==="slider"||e==="number"){let n=dt(t,dt(s?.defaultValue,0));const r=dt(s?.min,null),i=dt(s?.max,null);return Number.isFinite(r)&&(n=Math.max(r,n)),Number.isFinite(i)&&(n=Math.min(i,n)),n}if(e==="select"){const n=Array.isArray(s?.options)?de(s.options):[];if(!n.length)return"";const r=String(t??s?.defaultValue??n[0]??"");return n.includes(r)?r:n[0]}return String(t??s?.defaultValue??"")}l(Kt,"normalizeConfiguratorValue");function Zt(s){const t=me(),e=Array.isArray(s?.fields)?s.fields:[],n=s?.values&&typeof s.values=="object"&&!Array.isArray(s.values)?s.values:{},r=new Set;for(let i=0;i<e.length;i+=1){const o=e[i]&&typeof e[i]=="object"?e[i]:{},f=gr(o.type),d=mr(o.name??o.key??o.fieldName,i,r),a={name:d,label:String(o.label??"").trim()||dr(d),type:f};if(f==="slider"||f==="number"){let c=dt(o.min,f==="slider"?0:null),u=dt(o.max,f==="slider"?100:null);if(Number.isFinite(c)&&Number.isFinite(u)&&c>u){const p=c;c=u,u=p}let g=dt(o.step,1);(!Number.isFinite(g)||g<=0)&&(g=1),a.min=c,a.max=u,a.step=g,a.defaultValue=Kt(a,o.defaultValue??o.value)}else f==="select"?(a.options=yr(o.options),a.options.length||(a.options=["Option"]),a.defaultValue=Kt(a,o.defaultValue??o.value)):a.defaultValue=String(o.defaultValue??o.value??"");const y=Object.prototype.hasOwnProperty.call(n,d)?n[d]:a.defaultValue;t.fields.push(a),t.values[d]=Kt(a,y)}return t}l(Zt,"normalizeConfiguratorState");const Be=!1,Xe=new Set(["__open"]),hn=`resolution = 32;
1
+ var ve=Object.defineProperty;var Oe=s=>{throw TypeError(s)};var Cn=(s,t,e)=>t in s?ve(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var l=(s,t)=>ve(s,"name",{value:t,configurable:!0});var rt=(s,t,e)=>Cn(s,typeof t!="symbol"?t+"":t,e),xn=(s,t,e)=>t.has(s)||Oe("Cannot "+e);var Wt=(s,t,e)=>t.has(s)?Oe("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,e);var _=(s,t,e)=>(xn(s,t,"access private method"),e);import{r as Nn,F as Dn,A as it}from"./FeatureRegistry-CyK8O2Ca.js";import{Q as Qt,V as E,q as Pn,b6 as Bt,z as bt,X as kt,ah as ke,b7 as ze,ae as Fn,b2 as Rn,b as Xt}from"./featureDialogs-CnBa1DyN.js";import{A as qe}from"./AssemblyConstraintRegistry-DDhkhKoR.js";import{d as O}from"./deepClone-Dj59xCHB.js";import{L as Ke}from"./ListEntityBase-DIaWtqmZ.js";import{e as vn,o as On}from"./browserStorage-CvgF8ovw.js";function kn(s,t){if(t==null)return null;if(typeof t=="number")return Number.isFinite(t)?t:null;let e=null;try{s&&typeof s.evaluateExpression=="function"&&(e=s.evaluateExpression(t))}catch{e=null}if(typeof e=="number"&&Number.isFinite(e))return e;const n=Number(e);if(Number.isFinite(n))return n;const r=Number(t);return Number.isFinite(r)?r:null}l(kn,"evaluateConstraintNumericValue");function G(s){return s===0?"0":s?String(s).trim():""}l(G,"normalizeTypeString");const zn=new Set(["type","persistentData","__open"]);function Tn(s,t){if(s===t)return!0;if(!Array.isArray(s)||!Array.isArray(t)||s.length!==t.length)return!1;for(let e=0;e<s.length;e+=1)if(s[e]!==t[e])return!1;return!0}l(Tn,"shallowArrayEqual");function Te(s){const t={};if(!s||typeof s!="object")return t;for(const e in s){if(!Object.prototype.hasOwnProperty.call(s,e)||zn.has(e))continue;const n=s[e]?s[e].default_value:void 0;t[e]=O(n)}return t}l(Te,"extractDefaults");function Me(s){return`Unknown constraint type: ${s!=null?String(s):"unknown"}`}l(Me,"formatUnknownConstraintMessage");const Mn=new Map([["touch_align","touch_align"],["touch-align","touch_align"],["touchalign","touch_align"],["touch align","touch_align"],["touch align constraint","touch_align"],["touchalignconstraint","touch_align"],["touch","touch_align"],["distance","distance"],["distance constraint","distance"],["distanceconstraint","distance"],["angle","angle"],["angle constraint","angle"],["angleconstraint","angle"]]),je={touch_align:"Touch Align",distance:"Distance",angle:"Angle"},Ee=1e-6,te=1,jn=.5,En=.5,Hn=Math.max(1,te),lt="Constraint disabled.";function ft(s,t){const e=Number(s);return Number.isFinite(e)?e:t}l(ft,"toFiniteNumber$5");function $n(s){const t=Math.floor(ft(s,te));return!Number.isFinite(t)||t<1?te:t}l($n,"clampIterations");function He(s,t){const e=ft(s,t);return Number.isFinite(e)?e<0?0:e>1?1:e:t}l(He,"clampGain");function Ln(s){if(!s||typeof s.traverse!="function")return;const t=[],e=["parallel-constraint-normal-","distance-constraint-normal-","touch-align-normal-"];s.traverse(n=>{!n||typeof n.name!="string"||e.some(r=>n.name.startsWith(r))&&t.push(n)});for(const n of t)try{n.parent?.remove?.(n)}catch{}}l(Ln,"removeExistingDebugArrows");function Ze(s){let t=s;for(;t;){if(t.isAssemblyComponent||t.type==="COMPONENT")return t;t=t.parent||null}return null}l(Ze,"resolveComponentFromObject");function Vn(s){return Ze(s)?1:0}l(Vn,"scoreObjectForComponent");function Un(s){if(!s)return null;if(s instanceof E)return s.clone();if(typeof s=="object"){const{x:t,y:e,z:n}=s,r=Number.isFinite(t)?t:0,i=Number.isFinite(e)?e:0,o=Number.isFinite(n)?n:0;return new E(r,i,o)}return null}l(Un,"vectorFrom");function xt(s,t=null){if(!s)return t;const e=s.inputParams||{},n=e.id??e.constraintID??s.id??t;return n==null?t:String(n)}l(xt,"resolveConstraintEntryId");function St(s){return G(xt(s))}l(St,"normalizeConstraintEntryId");var C,Je,Nt,ne,Qe,re,tn,ot,ie,en,nn,_t,se,Dt,B;const _e=class _e{constructor(t=null,e=null){Wt(this,C);this.partHistory=t||null,this.registry=e||new qe,this.constraints=[],this.idCounter=0,this._listeners=new Set,this._autoRunScheduled=!1,this._autoRunActive=!1,this._autoRunOptions=null}setPartHistory(t){this.partHistory=t||null,this.partHistory&&this.constraints.length&&_(this,C,ot).call(this)}setRegistry(t){this.registry=t||this.registry}addListener(t){return typeof t!="function"?()=>{}:(this._listeners.add(t),()=>{this._listeners.delete(t)})}removeListener(t){typeof t=="function"&&this._listeners.delete(t)}onChange(t){if(typeof t!="function")return()=>{};const e=l(()=>{try{t(this)}catch{}},"wrapped");return this.addListener(e)}list(){return this.entries}get entries(){return this.constraints}set entries(t){Array.isArray(t)?this.constraints=t:this.constraints=[]}get size(){return this.constraints.length}findById(t){const e=G(t);return e&&this.constraints.find(n=>St(n)===e)||null}async addConstraint(t,e=null){const n=_(this,C,Dt).call(this,t);if(!n)throw new Error(`Constraint type "${t}" is not registered.`);const r=n.inputParamsSchema||{},i=Te(r),o=G(n.constraintType||t||n.name),f={type:o,inputParams:{...i},persistentData:{isNewConstraint:!0},__open:!0,enabled:!0};Object.defineProperty(f,"constraintClass",{value:n,configurable:!0,writable:!0,enumerable:!1});const d=n?.shortName||n?.constraintShortName||o||"CONST",a=this.generateId(d),y=f.inputParams.id??f.inputParams.constraintID;return f.inputParams.id=y||a,_(this,C,Nt).call(this,f),e&&typeof e=="object"&&Object.assign(f.inputParams,O(e)),f.inputParams.applyImmediately=!0,_(this,C,ne).call(this,f),this.constraints.push(f),_(this,C,B).call(this,"add",f),this.checkConstraintErrors(this.partHistory),_(this,C,ot).call(this),f}removeConstraint(t){const e=G(t);if(!e)return!1;const n=this.constraints.findIndex(i=>St(i)===e);if(n<0)return!1;const[r]=this.constraints.splice(n,1);return _(this,C,B).call(this,"remove",r||null),this.checkConstraintErrors(this.partHistory),_(this,C,ot).call(this),!0}moveConstraint(t,e){const n=G(t);if(!n)return!1;const r=this.constraints.findIndex(i=>St(i)===n);return r<0?!1:this.moveConstraintToIndex(n,r+e)}moveConstraintToIndex(t,e){const n=G(t);if(!n)return!1;const r=this.constraints.findIndex(f=>St(f)===n);if(r<0)return!1;const i=Number.isFinite(e)?Math.max(0,Math.min(this.constraints.length-1,e)):r;if(i===r)return!1;const[o]=this.constraints.splice(r,1);return this.constraints.splice(i,0,o),_(this,C,B).call(this,"reorder",o||null),_(this,C,ot).call(this),!0}updateConstraintParams(t,e){const n=this.findById(t);return!n||typeof e!="function"?!1:(e(n.inputParams),_(this,C,Nt).call(this,n),_(this,C,B).call(this,"update",n),this.checkConstraintErrors(this.partHistory),_(this,C,ot).call(this),!0)}setConstraintEnabled(t,e){const n=this.findById(t);if(!n)return!1;const r=e!==!1;if(n.enabled!==!1===r){if(n.enabled!==r&&(n.enabled=r),!r&&n.persistentData?.status!=="disabled"){const f={...n.persistentData||{}};f.status="disabled",f.message||(f.message=lt),n.persistentData=f,_(this,C,B).call(this,"update",n)}return!1}n.enabled=r;const o={...n.persistentData||{}};return r?(o.status==="disabled"&&(o.status="pending",o.message===lt&&delete o.message,n.persistentData=o),_(this,C,B).call(this,"update",n),this.checkConstraintErrors(this.partHistory),_(this,C,ot).call(this),!0):(o.status="disabled",o.message||(o.message=lt),n.persistentData=o,_(this,C,B).call(this,"update",n),this.checkConstraintErrors(this.partHistory),_(this,C,ot).call(this),!0)}setOpenState(t,e){const n=this.findById(t);if(!n)return!1;const r=e!==!1;if(n.__open!==!1===r)return!1;const o=n.inputParams||{};if(Object.prototype.hasOwnProperty.call(o,"__open"))try{o.__open=r}catch{n.__open=r}else n.__open=r;return(!n.runtimeAttributes||typeof n.runtimeAttributes!="object")&&(n.runtimeAttributes={}),n.runtimeAttributes.__open=r,_(this,C,B).call(this,"open-state",n),!0}setExclusiveOpen(t){const e=G(t);if(!e)return!1;let n=!1;for(const r of this.constraints){if(!r)continue;const o=St(r)===e;if(r.__open!==!1!==o){const d=r.inputParams||{};if(Object.prototype.hasOwnProperty.call(d,"__open"))try{d.__open=o}catch{r.__open=o}else r.__open=o;(!r.runtimeAttributes||typeof r.runtimeAttributes!="object")&&(r.runtimeAttributes={}),r.runtimeAttributes.__open=o,n=!0}}return n&&_(this,C,B).call(this,"open-state",this.findById(t)),n}clear(){this.constraints=[],this.idCounter=0,_(this,C,B).call(this,"clear")}snapshot(){return{idCounter:this.idCounter,constraints:this.constraints.map(t=>({type:t?.type||null,inputParams:O(t?.inputParams)||{},persistentData:O(t?.persistentData)||{},open:t?.__open!==!1,enabled:t?.enabled!==!1}))}}async replaceAll(t=[],e=0){const n=[],r=Array.isArray(t)?t:[];let i=Number.isFinite(Number(e))?Number(e):0;for(const o of r){const f=_(this,C,Je).call(this,o);if(!f)continue;const d=f.type||f.constraintType||null,a=_(this,C,Dt).call(this,d);if(!a)continue;const y=Te(a.inputParamsSchema),c=G(a.constraintType||d||a.name),u={type:c,inputParams:{...y,...O(f.inputParams||{})},persistentData:O(f.persistentData||{}),__open:f.open!==!1,enabled:f.enabled!==!1},g=u.inputParams.id??u.inputParams.constraintID;if(g){const p=String(g).match(/(\d+)$/);if(p){const h=Number(p[1]);Number.isFinite(h)&&(i=Math.max(i,h))}u.inputParams.id=g}else{const p=(a?.shortName||a?.constraintShortName||c||"CONST").replace(/[^a-z0-9]/gi,"").toUpperCase()||"CONST";i+=1,u.inputParams.id=`${p}${i}`}_(this,C,Nt).call(this,u),u.inputParams.applyImmediately=!0,Object.defineProperty(u,"constraintClass",{value:a,configurable:!0,writable:!0,enumerable:!1}),_(this,C,ne).call(this,u),n.push(u)}this.idCounter=i,this.constraints=n,_(this,C,B).call(this,"replace"),this.constraints.length&&(this.checkConstraintErrors(this.partHistory),_(this,C,ot).call(this))}async deserialize(t){const e=t&&typeof t=="object"?t:{},n=Array.isArray(e.constraints)?e.constraints:Array.isArray(t)?t:[],r=Number.isFinite(Number(e.idCounter))?Number(e.idCounter):void 0;await this.replaceAll(n,r)}generateId(t="CONST"){const e=G(t).replace(/[^a-z0-9]/gi,"").toUpperCase()||"CONST";return this.idCounter+=1,`${e}${this.idCounter}`}checkConstraintErrors(t=this.partHistory,e={}){const n=e&&typeof e=="object"?e:{},r=n.emit!==!1,i=n.updatePersistentData!==!1,o=t||this.partHistory||null;o&&(this.partHistory=o);const f=_(this,C,re).call(this),d=[];let a=!1;const y=l((c,u)=>{const g=c?.persistentData&&typeof c.persistentData=="object"?c.persistentData:{},p={...g};let h=!1;const m=l((S,A)=>{const x=p[S];if(A===void 0){Object.prototype.hasOwnProperty.call(p,S)&&(delete p[S],h=!0);return}if(Array.isArray(x)&&Array.isArray(A)){if(Tn(x,A))return}else if(x===A)return;p[S]=A,h=!0},"set"),b=l(S=>{Object.prototype.hasOwnProperty.call(p,S)&&(delete p[S],h=!0)},"remove");try{u({set:m,remove:b,data:p,previous:g})}catch(S){console.warn("[AssemblyConstraintHistory] Failed to update persistent data:",S)}return h&&(c.persistentData=p),h},"mutatePersistentData");for(const c of this.constraints){if(!c)continue;const u=xt(c),g=c?.type||null,p={id:u,constraintID:u,type:g,status:"ok",message:"",duplicateConstraintIDs:null,duplicateSignature:null};if(c.enabled===!1){p.status="disabled",p.message=lt,i&&(a=y(c,({set:b,remove:S,previous:A})=>{b("status","disabled"),(!A.message||A.message===lt)&&b("message",lt),b("satisfied",!1),S("duplicateConstraintIDs"),S("duplicateSignature")})||a),d.push(p);continue}const h=_(this,C,Dt).call(this,g),m=f.get(c);if(!h){const b=Me(g);p.status="error",p.message=b,i&&(a=y(c,({set:S,remove:A})=>{S("status","error"),S("message",b),S("satisfied",!1),A("duplicateConstraintIDs"),A("duplicateSignature")})||a),d.push(p);continue}if(m){const b=Array.isArray(m.relatedIds)?m.relatedIds.filter(Boolean):[],S=m.signature||null;p.status="duplicate",p.message=m.message||"Duplicate constraint selections.",p.duplicateConstraintIDs=b.length?b:null,p.duplicateSignature=S,i&&(a=y(c,({set:A,remove:x})=>{A("status","duplicate"),A("message",p.message),A("satisfied",!1),p.duplicateConstraintIDs?A("duplicateConstraintIDs",p.duplicateConstraintIDs):x("duplicateConstraintIDs"),S?A("duplicateSignature",S):x("duplicateSignature")})||a),d.push(p);continue}i&&(a=y(c,({set:b,remove:S,previous:A})=>{A.status==="duplicate"&&(b("status","pending"),typeof A.message=="string"&&A.message.startsWith("Duplicate constraint selections")&&S("message")),A.status==="error"&&typeof A.message=="string"&&A.message.startsWith("Unknown constraint type:")&&(b("status","pending"),S("message")),S("duplicateConstraintIDs"),S("duplicateSignature")})||a),d.push(p)}return i&&a&&r&&_(this,C,B).call(this,"update"),d}async runAll(t=this.partHistory,e={}){const n=t||this.partHistory;if(!n)return[];this.partHistory=n,this.checkConstraintErrors(n,{emit:!1});const r=Math.abs(ft(e?.tolerance,Ee))||Ee,i=$n(e?.iterations),o=He(e?.translationGain,jn),f=He(e?.rotationGain,En),d=e?.debugMode===!0,a=d?500:0,y=ft(e?.delayMs??e?.iterationDelayMs,a),c=Math.max(0,Number.isFinite(y)?y:a),u=e?.viewer||n.viewer||null,g=l(()=>{try{u?.render?.()}catch{}try{u?.requestRender?.()}catch{}},"renderScene"),p=e?.controller&&typeof e.controller=="object"?e.controller:null,h=p?.signal||e?.signal||null;let m=!1;const b=l(()=>h?.aborted?(m=!0,!0):!1,"shouldAbort"),S=p?.hooks||e?.hooks,A=S&&typeof S=="object"?S:{},x=l(async(I,P={})=>{const v=A?.[I];if(typeof v=="function")try{await v({controller:p,signal:h,aborted:m,...P})}catch(D){console.warn(`[AssemblyConstraintHistory] hook "${I}" failed:`,D)}},"safeCallHook"),w=n.scene||null,N=Array.isArray(n.features)?n.features.filter(Boolean):[],F=new Map;for(const I of N){const P=G(I?.inputParams?.featureID);P&&F.set(P,I)}const M=new Set,V=l(I=>Nn(w,I,{scoreFn:Vn,allowJson:!1,allowUuidString:!1,allowUuidObject:!0,allowFuzzyName:!1,allowNameContains:!1,allowPath:!1,allowReference:!1,allowTarget:!1,allowSelectionName:!1,arrayMode:"first"}),"resolveObject"),$=l(I=>{const P=V(I);return Ze(P)},"resolveComponent"),X=l(I=>{if(!I)return null;const P=G(I.owningFeatureID);return P&&F.get(P)||null},"getFeatureForComponent"),L=l(I=>!!(!I||I.fixed||I.userData?.fixedByConstraint||X(I)?.inputParams?.isFixed),"isComponentFixed"),J=l(I=>{I&&M.add(I)},"markUpdated"),H={partHistory:n,scene:w,tolerance:r,translationGain:o,rotationGain:f,resolveObject:V,resolveComponent:$,applyTranslation:l((I,P)=>{const v=Un(P);return!I||!v||v.lengthSq()===0?!1:(I.position.add(v),I.updateMatrixWorld?.(!0),J(I),!0)},"applyTranslation"),applyRotation:l((I,P)=>{if(!I||!P)return!1;let v;if(P instanceof Qt)v=P.clone();else{const D=ft(P?.x,0),ct=ft(P?.y,0),z=ft(P?.z,0),W=Number.isFinite(P?.w)?P.w:1;v=new Qt(D,ct,z,W)}return!Number.isFinite(v.x)||!Number.isFinite(v.y)||!Number.isFinite(v.z)||!Number.isFinite(v.w)?!1:(Math.abs(1-v.lengthSq())>1e-6&&v.normalize(),I.quaternion.premultiply(v),I.updateMatrixWorld?.(!0),J(I),!0)},"applyRotation"),isComponentFixed:L,getFeatureForComponent:X,markUpdated:J,viewer:u,renderScene:g,debugMode:d};Ln(w);const wn=_(this,C,re).call(this),yt=this.constraints.map(I=>{const P=xt(I);if(I?.enabled===!1)return{entry:I,instance:null,result:{id:P,ok:!0,status:"disabled",message:lt,applied:!1,satisfied:!1,iteration:0,constraintID:P},skipReason:"disabled"};const v=wn.get(I);if(v){const U=Array.isArray(v.relatedIds)?v.relatedIds.slice():[],K={id:P,ok:!1,status:"duplicate",message:v.message,applied:!1,satisfied:!1,iteration:0,constraintID:P,duplicateConstraintIDs:U,duplicateSignature:v.signature};return{entry:I,instance:null,result:K,skipReason:"duplicate"}}const D=_(this,C,Dt).call(this,I.type);if(!D){const U=Me(I.type);return I.persistentData={status:"error",message:U,lastRunAt:Date.now(),lastIteration:0},{entry:I,instance:null,result:{id:P,ok:!1,status:"error",message:U,applied:!1,satisfied:!1,iteration:0,constraintID:P},skipReason:"unregistered"}}const ct=O(I.inputParams)||{},z=O(I.inputParams)||{},W=new D(n);_(this,C,Qe).call(this,z,D.inputParamsSchema||{});try{W.inputParams=z}catch{W.inputParams={...z}}try{Object.assign(W.persistentData,O(I.persistentData))}catch{W.persistentData={...I.persistentData||{}}}return{entry:I,instance:W,result:null,originalInputParams:ct}});for(const I of yt)I.instance?.clearDebugArrows?.({scene:w});await x("onStart",{maxIterations:i,constraintCount:yt.length});let Re=0;const _n=yt.length;t:for(let I=0;I<i&&!(b()||(await x("onIterationStart",{iteration:I,maxIterations:i}),b()));I+=1){let P=!1;for(let v=0;v<yt.length;v+=1){if(b())break t;const D=yt[v],ct=xt(D?.entry),z=D?.entry?.type||null,W={iteration:I,index:v,id:ct,constraintID:ct,constraintType:z,totalConstraints:_n};if(!D.instance){await x("onConstraintSkipped",{...W,skipReason:D.skipReason||null});continue}if(await x("onConstraintStart",W),b())break t;const U={...H,iteration:I,maxIterations:i};let K;try{typeof D.instance.solve=="function"?K=await D.instance.solve(U):K=await D.instance.run(U)}catch(gt){console.warn("[AssemblyConstraintHistory] Constraint solve failed:",gt),K={ok:!1,status:"error",message:gt?.message||"Constraint evaluation failed.",error:gt},D.instance.persistentData=D.instance.persistentData||{},D.instance.persistentData.status="error",D.instance.persistentData.message=K.message}if(D.result=_(this,C,se).call(this,D.instance,K,I),D.result.applied&&(P=!0),await x("onConstraintEnd",{...W,result:D.result}),b())break t}if(typeof H.renderScene=="function")try{H.renderScene()}catch{}if(c>0&&await new Promise(v=>setTimeout(v,c)),b()||(Re=I+1,await x("onIterationComplete",{iteration:I,maxIterations:i,applied:P}),b())||!P)break}m=m||h?.aborted||!1;const In=Date.now(),Ut=[];for(const I of yt){const{entry:P,instance:v}=I,D=I.result||_(this,C,se).call(this,v,{ok:!1,status:"pending",message:"Constraint was not evaluated."},Math.max(0,i-1)),z={...v?.persistentData&&Object.keys(v.persistentData).length?v.persistentData:P.persistentData||{}};if(D.status&&(z.status=D.status),D.message!==void 0&&(D.message?z.message=D.message:z.message&&delete z.message),z.satisfied=!!D.satisfied,typeof D.error=="number"&&Number.isFinite(D.error)&&(z.error=D.error),z.lastRunAt=In,z.lastIteration=D.iteration,z.lastRequestedIterations=i,D.status==="duplicate"?(Array.isArray(D.duplicateConstraintIDs)&&D.duplicateConstraintIDs.length?z.duplicateConstraintIDs=D.duplicateConstraintIDs.slice():z.duplicateConstraintIDs&&delete z.duplicateConstraintIDs,D.duplicateSignature?z.duplicateSignature=D.duplicateSignature:z.duplicateSignature&&delete z.duplicateSignature):(z.duplicateConstraintIDs&&delete z.duplicateConstraintIDs,z.duplicateSignature&&delete z.duplicateSignature),P.persistentData=z,I.originalInputParams){const U=O(I.originalInputParams)||{};D.persistInputParams&&typeof D.persistInputParams=="object"&&Object.assign(U,O(D.persistInputParams));const K=P.inputParams&&typeof P.inputParams=="object"?P.inputParams:{};for(const gt of Object.keys(K))Object.prototype.hasOwnProperty.call(U,gt)||delete K[gt];Object.assign(K,U),P.inputParams=K}else{const U={...P.inputParams||{}};D.persistInputParams&&typeof D.persistInputParams=="object"&&Object.assign(U,O(D.persistInputParams)),P.inputParams=U}const W=xt(P);Ut.push({id:W,constraintID:W,type:P?.type||null,...D})}try{n.syncAssemblyComponentTransforms?.()}catch(I){console.warn("[AssemblyConstraintHistory] Failed to sync component transforms:",I)}return _(this,C,B).call(this,"solve"),await x("onComplete",{results:Ut.slice(),aborted:m,iterationsCompleted:Re,maxIterations:i}),Ut}};C=new WeakSet,Je=l(function(t){if(!t||typeof t!="object")return t;const e={...t},n=t.inputParams&&typeof t.inputParams=="object"?t.inputParams:null;if(n){const i={...n},o=Object.prototype.hasOwnProperty.call(i,"constraintID")?i.constraintID:void 0;(i.id==null||i.id==="")&&o!=null&&(i.id=o),Object.prototype.hasOwnProperty.call(i,"constraintID")&&delete i.constraintID,e.inputParams=i}const r=Object.prototype.hasOwnProperty.call(e,"constraintID")?e.constraintID:void 0;return(e.id==null||e.id==="")&&r!=null&&(e.id=r),Object.prototype.hasOwnProperty.call(e,"constraintID")&&delete e.constraintID,(e.id==null||e.id==="")&&e.inputParams?.id!=null&&(e.id=e.inputParams.id),e},"#runConstraintEntryMigrations"),Nt=l(function(t){if(!t||!t.inputParams)return;const e=t.inputParams,n=e.id??e.constraintID??t.id;if(!n)return;const r=String(n);e.id=r,t.id=r},"#syncEntryIds"),ne=l(function(t){if(!t||typeof t!="object")return;(!t.inputParams||typeof t.inputParams!="object")&&(t.inputParams={});const e=t.inputParams,n={configurable:!0,enumerable:!1};_(this,C,Nt).call(this,t);const r=Object.prototype.hasOwnProperty.call(e,"constraintID")?e.constraintID:void 0;if(r!=null&&(e.id==null||e.id==="")&&(e.id=r),Object.prototype.hasOwnProperty.call(e,"constraintID"))try{delete e.constraintID}catch{}Object.getOwnPropertyDescriptor(e,"constraintID")||Object.defineProperty(e,"constraintID",{...n,get:l(()=>e.id,"get"),set:l(a=>{if(a==null){e.id=a,t.id=a;return}const y=String(a);e.id=y,t.id=y},"set")});const i=Object.prototype.hasOwnProperty.call(e,"__open")?e.__open:t.__open;if(Object.prototype.hasOwnProperty.call(e,"__open"))try{delete e.__open}catch{}const o=i!==!1;t.__open=o;const f=t.runtimeAttributes&&typeof t.runtimeAttributes=="object"?t.runtimeAttributes:{};f.__open=o;try{Object.defineProperty(t,"runtimeAttributes",{value:f,configurable:!0,writable:!0,enumerable:!1})}catch{t.runtimeAttributes=f}Object.prototype.hasOwnProperty.call(e,"__entityRef")||Object.defineProperty(e,"__entityRef",{...n,value:t});let d;if(Object.prototype.hasOwnProperty.call(e,"persistentData")){d=e.persistentData;try{delete e.persistentData}catch{}}d&&typeof d=="object"?t.persistentData=O(d):(!t.persistentData||typeof t.persistentData!="object")&&(t.persistentData={}),Object.defineProperty(e,"persistentData",{...n,get:l(()=>t.persistentData||(t.persistentData={}),"get"),set:l(a=>{const y=a&&typeof a=="object"?a:{};t.persistentData=y},"set")}),Object.defineProperty(e,"__open",{...n,get:l(()=>t.runtimeAttributes.__open!==!1,"get"),set:l(a=>{const y=a!==!1;t.runtimeAttributes.__open=y,t.__open=y},"set")}),t.type&&!e.type&&(e.type=t.type),t.entityType=t.type||e.type||t.entityType||null},"#linkEntryParams"),Qe=l(function(t,e){if(!(!t||!e))for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const r=e[n];if(!r||r.type!=="number")continue;const i=kn(this.partHistory,t[n]);i!=null&&(t[n]=i)}},"#applyNumericExpressions"),re=l(function(){const t=new Map;for(const n of this.constraints){if(!n)continue;const r=_(this,C,tn).call(this,n?.type);if(!r)continue;const i=_(this,C,en).call(this,n?.inputParams);if(!i)continue;t.has(i)||t.set(i,[]);const o=St(n)||null,f=je[r]||r;t.get(i).push({entry:n,type:r,typeLabel:f,id:o})}const e=new Map;for(const[n,r]of t.entries()){if(!Array.isArray(r)||r.length<=1)continue;const i=new Map;for(const o of r)i.has(o.type)||i.set(o.type,[]),i.get(o.type).push(o);for(const o of r){const f=(i.get(o.type)||[]).filter(g=>g!==o),d=[];for(const[g,p]of i.entries())g!==o.type&&d.push({type:g,entries:p});const a=l((g,p)=>{const h=Array.from(new Set(p.map(b=>b&&b.trim()?b.trim():null).filter(Boolean)));if(h.length===0)return`${g} constraint`;const m=h.length>1?"constraints":"constraint";return`${g} ${m} ${h.join(", ")}`},"formatConstraintPhrase"),y=[];if(f.length){const g=f.map(p=>p.id);y.push(a(`shares selections with ${o.typeLabel}`,g))}for(const g of d){const p=je[g.type]||g.type,h=g.entries.map(m=>m.id);y.push(a(`conflicts with ${p}`,h))}const c=y.length?`Duplicate constraint selections: ${y.join(". ")}.`:"Duplicate constraint selections.",u=r.filter(g=>g!==o).map(g=>g.id).filter(Boolean);e.set(o.entry,{message:c,signature:n,relatedIds:Array.from(new Set(u)),type:o.type})}}return e},"#detectDuplicateConstraints"),tn=l(function(t){const e=G(t).toLowerCase();return e&&Mn.get(e)||null},"#normalizeDuplicateConstraintType"),ot=l(function(t=null){if(!this.partHistory)return;const e=t&&typeof t=="object"?{...t}:null;this._autoRunOptions=e,!this._autoRunScheduled&&(this._autoRunScheduled=!0,Promise.resolve().then(()=>{try{_(this,C,ie).call(this)}catch(n){console.warn("[AssemblyConstraintHistory] Failed to schedule auto run:",n)}}))},"#scheduleAutoRun"),ie=l(async function(){if(!this._autoRunScheduled||this._autoRunActive)return;const t=this._autoRunOptions?{...this._autoRunOptions}:{};this._autoRunOptions=null,this._autoRunScheduled=!1;const e=Number(t.iterations),n=Number.isFinite(e)&&e>=1?Math.floor(e):Hn,r=this.partHistory;if(r){this._autoRunActive=!0;try{await this.runAll(r,{...t,iterations:n})}catch(i){console.warn("[AssemblyConstraintHistory] Auto run failed:",i)}finally{this._autoRunActive=!1,this._autoRunScheduled&&Promise.resolve().then(()=>{try{_(this,C,ie).call(this)}catch(i){console.warn("[AssemblyConstraintHistory] Failed to re-run auto cycle:",i)}})}}},"#executeAutoRun"),en=l(function(t){if(!t||typeof t!="object")return null;const e=_(this,C,nn).call(this,t);if(!e)return null;const n=[];for(const r of e){const i=_(this,C,_t).call(this,r,0,new Set);if(!i)return null;n.push(i)}return n.length!==2?null:(n.sort(),`${n[0]}|${n[1]}`)},"#buildSelectionSignature"),nn=l(function(t){const e=Array.isArray(t?.elements)?t.elements:[],n=[];for(const r of e)if(r!=null&&(n.push(r),n.length>=2))break;return n.length>=2?n.slice(0,2):null},"#extractSelectionPair"),_t=l(function(t,e=0,n=new Set){if(t==null||e>5)return null;if(Array.isArray(t)){for(const i of t){const o=_(this,C,_t).call(this,i,e+1,n);if(o)return o}return null}const r=typeof t;if(r==="string"||r==="number"||r==="boolean")return`${r}:${String(t)}`;if(r!=="object"||n.has(t))return null;n.add(t);try{if(t.isObject3D&&typeof t.uuid=="string"&&t.uuid)return`uuid:${t.uuid}`;const i=["selectionID","selectionId","fullName","fullPath","pathKey","pathId","pathID","id","uuid","entityUUID","brepId","brepID","objectUUID","objectId","objectID"];for(const a of i){const y=t[a];if(typeof y=="string"&&y.trim())return`${a}:${y.trim()}`}const o=["name","label","displayName","componentName","faceName","edgeName","vertexName","reference","refName"];for(const a of o){const y=t[a];if(typeof y=="string"&&y.trim())return`${a}:${y.trim()}`}if(Array.isArray(t.path)&&t.path.length){const a=t.path.map(y=>String(y)).join("/");if(a)return`path:${a}`}if(t.component&&typeof t.component=="object"){const a=_(this,C,_t).call(this,t.component,e+1,n);if(a)return`component:${a}`}if(t.object&&typeof t.object=="object"){const a=_(this,C,_t).call(this,t.object,e+1,n);if(a)return`object:${a}`}const f=Object.keys(t).filter(a=>a!=="__proto__").sort(),d=[];for(const a of f){const y=t[a];if(y==null||typeof y=="function"||typeof y=="symbol")continue;let c=null;if(typeof y=="object"){const u=_(this,C,_t).call(this,y,e+1,n);u&&(c=u)}else c=`${typeof y}:${String(y)}`;if(c&&(d.push(`${a}=${c}`),d.length>=8))break}return d.length?`obj:${d.join(",")}`:null}finally{n.delete(t)}},"#selectionKey"),se=l(function(t,e,n){const r=e&&typeof e=="object"?e:{},i=!!r.satisfied,o=!!r.applied,f=r.ok!==!1,d=typeof r.message=="string"?r.message:"";let a=typeof r.status=="string"&&r.status.trim()?r.status.trim():null;a||(f?i?a="satisfied":o?a="adjusted":a="pending":a="error");const y=Number.isFinite(r.error)?r.error:null,c=r.persistInputParams&&typeof r.persistInputParams=="object"?O(r.persistInputParams):null;return t&&(t.persistentData=t.persistentData||{},t.persistentData.status||(t.persistentData.status=a),d&&!t.persistentData.message&&(t.persistentData.message=d),t.persistentData.satisfied=i,y!=null&&(t.persistentData.error=y),t.persistentData.isNewConstraint===!0&&f&&o&&(t.persistentData.isNewConstraint=!1)),{ok:f,status:a,satisfied:i,applied:o,error:y,message:d,iteration:n,diagnostics:r.diagnostics||null,persistInputParams:c}},"#finalizeConstraintResult"),Dt=l(function(t){const e=G(t);if(!e)return null;if(this.registry&&typeof this.registry.getSafe=="function"){const n=this.registry.getSafe(e);if(n)return n}if(this.registry&&typeof this.registry.get=="function")try{return this.registry.get(e)}catch{return null}return null},"#resolveConstraint"),B=l(function(t="update",e=null,n=null){if(!(this._listeners instanceof Set)||this._listeners.size===0)return;const r={...n&&typeof n=="object"?n:{},history:this,entry:e||null,reason:t||"update"};for(const i of Array.from(this._listeners))try{i({...r})}catch{}},"#emitChange"),l(_e,"AssemblyConstraintHistory");let ee=_e;const Ie=class Ie{constructor(){this.metadata={}}getMetadata(t){const e=this.metadata[t]||{};return e.inheritsFrom?{...this.getMetadata(e.inheritsFrom),...e}:e}getOwnMetadata(t){const e=this.metadata[t];return e?{...e}:{}}setMetadata(t,e,n){this.metadata[t]||(this.metadata[t]={}),this.metadata[t][e]=n}setMetadataObject(t,e){e&&Object.keys(e).length>0?this.metadata[t]={...e}:delete this.metadata[t]}deleteMetadataKey(t,e){const n=this.metadata[t];n&&(delete n[e],Object.keys(n).length===0&&delete this.metadata[t])}clearMetadata(t){delete this.metadata[t]}};l(Ie,"MetadataManager");let Ht=Ie;const Ce=class Ce{constructor(t){this.partHistory=t||null,this.views=[],this._listeners=new Set}reset(){this.views=[],this._emit()}getViews(){return this._normalizeViewsArray(this.views),this.views}setViews(t){const e=Array.isArray(t)?Array.from(t):[];return this.views=e,this._normalizeViewsArray(this.views),this._emit(),this.views}addView(t){const e=this.getViews(),n=this._normalizeView(t,e.length);return e.push(n),this._emit(),n}updateView(t,e){const n=this.getViews(),r=Number(t);if(!Number.isInteger(r)||r<0||r>=n.length)return null;const i=n[r];let o=i;if(typeof e=="function")try{const f=e(i);f&&typeof f=="object"&&(o=f)}catch{}else e&&typeof e=="object"&&e!==i&&(o=Object.assign({},i,e));return o!==i&&(n[r]=o),n[r]=this._normalizeView(n[r],r),this._emit(),n[r]}removeView(t){const e=this.getViews(),n=Number(t);if(!Number.isInteger(n)||n<0||n>=e.length)return null;const[r]=e.splice(n,1);for(let i=0;i<e.length;i++)e[i]=this._normalizeView(e[i],i);return this._emit(),r||null}addListener(t){return typeof t!="function"?()=>{}:(this._listeners.add(t),()=>{try{this._listeners.delete(t)}catch{}})}removeListener(t){if(typeof t=="function")try{this._listeners.delete(t)}catch{}}notifyChanged(){this._emit()}toSerializable(){return this.getViews().map(t=>O(t))}_normalizeViewsArray(t){if(!Array.isArray(t))return this.views=[],this.views;for(let e=0;e<t.length;e++)t[e]=this._normalizeView(t[e],e);return t}_normalizeView(t,e){const n=Number.isInteger(e)?e:0,r=t&&typeof t=="object"?t:{},i=typeof r.name=="string"?r.name.trim():"",f=(typeof r.viewName=="string"?r.viewName.trim():"")||i||`View ${n+1}`;if(r.viewName=f,r.name=f,Array.isArray(r.annotations)||(r.annotations=[]),(!r.camera||typeof r.camera!="object")&&(r.camera={}),r.camera.viewport&&typeof r.camera.viewport=="object"){const y=Number(r.camera.viewport.width),c=Number(r.camera.viewport.height);y>0&&c>0?r.camera.viewport={width:y,height:c}:delete r.camera.viewport}(!r.viewSettings||typeof r.viewSettings!="object")&&(r.viewSettings={});const d=Number(r.viewSettings?.pmiTextSizePt);Number.isFinite(d)&&d>0?r.viewSettings.pmiTextSizePt=Math.max(1,Math.min(288,d)):delete r.viewSettings.pmiTextSizePt;const a=Array.isArray(r.viewSettings?.visibilityState?.hidden)?r.viewSettings.visibilityState.hidden.map(y=>({key:String(y?.key||""),count:Math.max(1,Math.round(Number(y?.count)||1))})).filter(y=>y.key):[];return a.length?r.viewSettings.visibilityState={hidden:a}:delete r.viewSettings.visibilityState,r.annotationHistory&&typeof r.annotationHistory!="object"&&delete r.annotationHistory,r}_emit(){if(!this._listeners||this._listeners.size===0)return;const t=this.getViews();for(const e of Array.from(this._listeners))try{e(t,this.partHistory||null)}catch{}}};l(Ce,"PMIViewsManager");let oe=Ce;const xe=class xe{constructor(){this.entityClasses=new Map}register(t){if(!t)return;const e=t.shortName;if(!e)throw new Error("EntityClass must declare static entityType (or type/name).");this.entityClasses.set(e,t)}resolve(t){const e=t;return e&&this.entityClasses.get(e)||null}};l(xe,"entityClassRegistry");let ae=xe;const Ne=class Ne{constructor({viewer:t=null,registry:e=null}={}){this.viewer=t||null,this.registry=e||null,this.entries=[],this.registry=new ae,this._listeners=new Set,this._idCounter=0}serializableData(){return this.entries.map(t=>({id:t.id,type:t.type,inputParams:t.inputParams,persistentData:t.persistentData}))}};l(Ne,"HistoryCollectionBase");let ue=Ne;const Wn={id:{type:"string",default_value:null,hint:"Unique identifier for this linear motion."},solid:{type:"reference_selection",selectionFilter:["SOLID"],multiple:!1,default_value:null,hint:"Select the solid to drive."},axis:{type:"reference_selection",selectionFilter:["EDGE"],multiple:!1,default_value:null,hint:"Select an edge or centerline to use as the travel direction."},speed:{type:"number",default_value:10,hint:"Linear speed in scene units per second."},distance:{type:"number",default_value:0,hint:"Optional travel distance. Leave blank to move continuously."}},pt=class pt extends Ke{onIdChanged(){}onParamsChanged(){}onPersistentDataChanged(){}};l(pt,"LinearMotionEntity"),rt(pt,"entityType","linear"),rt(pt,"shortName","LIN"),rt(pt,"longName","Linear Motion"),rt(pt,"inputParamsSchema",Wn);let $t=pt;const Bn={id:{type:"string",default_value:null,hint:"Unique identifier for this rotation motion."},solid:{type:"reference_selection",selectionFilter:["SOLID"],multiple:!1,default_value:null,hint:"Select the solid to drive."},axis:{type:"reference_selection",selectionFilter:["EDGE"],multiple:!1,default_value:null,hint:"Select an edge or centerline to rotate about."},speed:{type:"number",default_value:90,hint:"Rotation speed in degrees per second."},angle:{type:"number",default_value:0,hint:"Optional total angle in degrees. Leave blank to rotate continuously."}},ht=class ht extends Ke{onIdChanged(){}onParamsChanged(){}onPersistentDataChanged(){}};l(ht,"RotationMotionEntity"),rt(ht,"entityType","rotation"),rt(ht,"shortName","ROT"),rt(ht,"longName","Rotation Motion"),rt(ht,"inputParamsSchema",Bn);let Lt=ht;const At="rotation",$e=new Set(["type","persistentData","__open"]),De=class De extends ue{constructor(t){super({viewer:null}),this.partHistory=t||null,this._registerAvailableEntries()}getMotions(){return this.entries}createMotion(t=At,e=null){const n=this._resolveHandler(t);if(!n)return null;const r=new n({history:this,registry:this.registry});r.type=n.entityType||n.type||At,r.entityType=r.type;const i=this._defaultsFromSchema(n),o=O(e||{});r.setParams({...i,...o,type:r.type}),r.setPersistentData(o.persistentData||{}),delete r.inputParams.persistentData;const f=r.inputParams.id||this.generateId(r.shortName||r.type||"SIM");return r.setId(f),r.runtimeAttributes.__open=!0,this._linkInputParams(r),this.entries.push(r),this._bumpIdCounterFrom(r),this.notifyListeners({reason:"add",entry:r,history:this}),r}loadSerializable(t){this.entries=[],this._idCounter=0;const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{motions:t},n=Array.isArray(e.motions)?e.motions:[];for(const r of n){const i=this._hydrateEntity(r);i&&(this.entries.push(i),this._bumpIdCounterFrom(i),this._linkInputParams(i))}return this.notifyListeners({reason:"load",history:this}),this.entries}toSerializable(){return{motions:this.entries.map(t=>{const e=!!t.runtimeAttributes?.__open,n=O(t.inputParams||{});return n&&typeof n=="object"&&(delete n.persistentData,delete n.__open,delete n.__entityRef),{type:t.type||At,inputParams:n,persistentData:O(t.persistentData||{}),__open:e||void 0}})}}reset(){this.entries=[],this._idCounter=0,this.notifyListeners({reason:"clear",history:this})}generateId(t="SIM"){const e=String(t||"SIM").replace(/[^a-z0-9]/gi,"").toUpperCase()||"SIM",n=new Set(this.entries.map((i,o)=>{const f=i?.inputParams;return f?.id?String(f.id):i?.id!=null?String(i.id):`SIM${o+1}`}));let r="";do this._idCounter+=1,r=`${e}${this._idCounter}`;while(n.has(r));return r}addListener(t){return typeof t!="function"?()=>{}:(this._listeners.add(t),()=>{try{this._listeners.delete(t)}catch{}})}removeListener(t){if(typeof t=="function")try{this._listeners.delete(t)}catch{}}notifyListeners(t={}){if(this._listeners instanceof Set)for(const e of Array.from(this._listeners))try{e(t,this)}catch{}}_registerAvailableEntries(){for(const t of[Lt,$t])try{this.registry.register(t)}catch{}}_resolveHandler(t){return String(t||"").trim().toLowerCase()==="linear"?$t:Lt}_defaultsFromSchema(t){const e={},n=t?.inputParamsSchema;if(!n||typeof n!="object")return e;for(const r of Object.keys(n)){if($e.has(r))continue;const i=n[r];!i||typeof i!="object"||Object.prototype.hasOwnProperty.call(i,"default_value")&&(e[r]=O(i.default_value))}return e}_hydrateEntity(t){const e=t&&typeof t=="object"?t:{},n=this._resolveHandler(e.type||e.inputParams?.type||At);if(!n)return null;const r=new n({history:this,registry:this.registry});r.type=n.entityType||n.type||At,r.entityType=r.type;const i=this._cloneWithoutReserved(e.inputParams||e);i.type||(i.type=r.type),r.setParams(i),r.setPersistentData(O(e.persistentData||{})),delete r.inputParams.persistentData;const o=r.inputParams.id||e.id||this.generateId(r.shortName||r.type);return r.setId(o),r.runtimeAttributes.__open=!!e.__open,this._linkInputParams(r),r}_cloneWithoutReserved(t){const e={};if(!t||typeof t!="object")return e;for(const n of Object.keys(t))$e.has(n)||(e[n]=O(t[n]));return e}_linkInputParams(t){if(!t)return;(!t.runtimeAttributes||typeof t.runtimeAttributes!="object")&&(t.runtimeAttributes={});const e=t.inputParams||{},n={configurable:!0,enumerable:!1};Object.prototype.hasOwnProperty.call(e,"__entityRef")||Object.defineProperty(e,"__entityRef",{...n,value:t}),Object.prototype.hasOwnProperty.call(e,"persistentData")||Object.defineProperty(e,"persistentData",{...n,get:l(()=>t.persistentData,"get"),set:l(r=>{const i=r&&typeof r=="object"?r:{};t.setPersistentData(i)},"set")}),Object.prototype.hasOwnProperty.call(e,"__open")||Object.defineProperty(e,"__open",{...n,get:l(()=>!!t.runtimeAttributes.__open,"get"),set:l(r=>{t.runtimeAttributes.__open=!!r},"set")}),e.type=t.type||e.type||At,e.id==null&&t.id!=null&&(e.id=t.id)}_bumpIdCounterFrom(t){const e=t?.inputParams?.id||t?.id;if(!e)return;const n=String(e).match(/(\d+)$/);if(!n)return;const r=parseInt(n[1],10);Number.isFinite(r)&&r>this._idCounter&&(this._idCounter=r)}};l(De,"SimulationStateManager");let ce=De;const wt=96,rn=1;function Xn(s,t=0){const e=Number(s);return Number.isFinite(e)?e:t}l(Xn,"toFiniteNumber$4");function le(s,t){return Math.max(rn,Xn(s,t))}l(le,"clampCustomSheetSize");function Le(s){const t=Math.round(le(s,rn)*100)/100;return String(t).replace(/(\.\d*?[1-9])0+$/u,"$1").replace(/\.0+$/u,"")}l(Le,"formatSheetDimension");const fe=Object.freeze({A:Object.freeze({key:"A",label:"A (8.5 x 11 in)",widthIn:8.5,heightIn:11}),B:Object.freeze({key:"B",label:"B (11 x 17 in)",widthIn:11,heightIn:17}),C:Object.freeze({key:"C",label:"C (17 x 22 in)",widthIn:17,heightIn:22}),D:Object.freeze({key:"D",label:"D (22 x 34 in)",widthIn:22,heightIn:34}),E:Object.freeze({key:"E",label:"E (34 x 44 in)",widthIn:34,heightIn:44}),A4:Object.freeze({key:"A4",label:"A4 (210 x 297 mm)",widthIn:8.27,heightIn:11.69}),A3:Object.freeze({key:"A3",label:"A3 (297 x 420 mm)",widthIn:11.69,heightIn:16.54}),A2:Object.freeze({key:"A2",label:"A2 (420 x 594 mm)",widthIn:16.54,heightIn:23.39}),A1:Object.freeze({key:"A1",label:"A1 (594 x 841 mm)",widthIn:23.39,heightIn:33.11}),A0:Object.freeze({key:"A0",label:"A0 (841 x 1189 mm)",widthIn:33.11,heightIn:46.81}),CUSTOM:Object.freeze({key:"CUSTOM",label:"Custom",widthIn:36,heightIn:24})}),Yn=Object.freeze(["A","B","C","D","E","A4","A3","A2","A1","A0","CUSTOM"]);function sn(s){return String(s??"").trim().toLowerCase()==="portrait"?"portrait":"landscape"}l(sn,"normalizeSheetOrientation");function on(s){const t=String(s??"").trim().toUpperCase();return fe[t]||fe.A}l(on,"getSheetSizeByKey");function xr(){return Yn.map(s=>fe[s]).filter(Boolean)}l(xr,"listSheetSizes");function Gn(s,t="landscape",e=null){const n=on(s),r=sn(t);if(n.key==="CUSTOM"){const d=le(e?.customWidthIn??e?.widthIn,n.widthIn),a=le(e?.customHeightIn??e?.heightIn,n.heightIn),y=r==="landscape",c=y?Math.max(d,a):Math.min(d,a),u=y?Math.min(d,a):Math.max(d,a);return{key:n.key,label:`Custom (${Le(c)} x ${Le(u)} in)`,orientation:r,units:"in",widthIn:c,heightIn:u,widthPx:c*wt,heightPx:u*wt,pxPerInch:wt,customWidthIn:c,customHeightIn:u}}const i=r==="landscape",o=i?Math.max(n.widthIn,n.heightIn):Math.min(n.widthIn,n.heightIn),f=i?Math.min(n.widthIn,n.heightIn):Math.max(n.widthIn,n.heightIn);return{key:n.key,label:n.label,orientation:r,units:"in",widthIn:o,heightIn:f,widthPx:o*wt,heightPx:f*wt,pxPerInch:wt}}l(Gn,"resolveSheetDimensions");function vt(s,t=0){const e=Number(s);return Number.isFinite(e)?e:t}l(vt,"toFiniteNumber$3");function tt(s,t,e){return Math.max(t,Math.min(e,s))}l(tt,"clamp$1");function ut(s,t=""){return typeof s=="string"?s:s==null?t:String(s)}l(ut,"sanitizeText$1");function qn(s,t=null){const e=String(s??"").trim();return e&&(/^#[\da-fA-F]{3,8}$/.test(e)||/^[a-zA-Z]+$/.test(e)||/^(rgb|rgba|hsl|hsla)\([^)]+\)$/i.test(e))?e:t}l(qn,"sanitizeColor$1");function j(s,t=1){return Math.max(1,Math.round(vt(s,t)))}l(j,"clampPositiveInt");function Z(s,t=0){return Math.max(0,Math.round(vt(s,t)))}l(Z,"clampIndex");function Kn(s,t=null){if(s==null)return t;const e=String(s).trim().toLowerCase();return e==="middle"||e==="center"?"center":e==="end"||e==="right"?"right":e==="left"?"left":t}l(Kn,"normalizeTextAlign$1");function Zn(s,t=null){if(s==null)return t;const e=String(s).trim().toLowerCase();return e==="center"?"middle":e==="bottom"?"bottom":e==="middle"||e==="top"?e:t}l(Zn,"normalizeVerticalAlign$1");function Jn(s,t=null){if(s==null)return t;const e=String(s).trim();return e==="bold"?"700":e==="normal"?"400":/^\d{3}$/.test(e)?e:t}l(Jn,"normalizeFontWeight");function Qn(s,t=null){return s==null?t:String(s).trim().toLowerCase()==="italic"?"italic":"normal"}l(Qn,"normalizeFontStyle");function tr(s,t=null){return s==null?t:String(s).trim().toLowerCase()==="underline"?"underline":"none"}l(tr,"normalizeTextDecoration");function we(s){if(!s||typeof s!="object"||Array.isArray(s))return{};const t={},e=ut(s.fontFamily,"").trim();e&&(t.fontFamily=e);const n=vt(s.fontSize,Number.NaN);Number.isFinite(n)&&n>0&&(t.fontSize=tt(n,.08,3));const r=Jn(s.fontWeight??(s.bold?"700":null));r&&(t.fontWeight=r);const i=Qn(s.fontStyle??(s.italic?"italic":null));i&&(t.fontStyle=i);const o=tr(s.textDecoration);o&&(t.textDecoration=o);const f=Kn(s.textAlign??s.textAnchor);f&&(t.textAlign=f);const d=Zn(s.verticalAlign??s.verticalAnchor);d&&(t.verticalAlign=d);const a=qn(s.color??s.textColor,null);return a&&(t.color=a),t}l(we,"normalizeTableCellStyle");function an(s=""){return{text:ut(s,""),rowSpan:1,colSpan:1,mergedInto:null,style:{}}}l(an,"createTableCell");function mt(s,t){const e=Math.max(1,j(t,1)),n=Array.isArray(s)?s.slice(0,e):[],r=[];for(let o=0;o<e;o+=1)r.push(Math.max(1e-4,vt(n[o],1)));const i=r.reduce((o,f)=>o+f,0);return!Number.isFinite(i)||i<=0?Array.from({length:e},()=>1/e):r.map(o=>o/i)}l(mt,"normalizeTableFractions");function It(s,t=0){return Array.isArray(s?.cells)&&s.cells.length>0?s.cells.length:Array.isArray(s?.rowFractions)&&s.rowFractions.length>0?s.rowFractions.length:Math.max(0,j(t,0))}l(It,"getTableRowCount");function Ct(s,t=0){const e=Array.isArray(s?.cells)?s.cells:[];let n=0;for(const r of e)Array.isArray(r)&&(n=Math.max(n,r.length));return n>0?n:Array.isArray(s?.colFractions)&&s.colFractions.length>0?s.colFractions.length:Math.max(0,j(t,0))}l(Ct,"getTableColumnCount");function un(s=3,t=3){const e=Math.max(1,j(s,3)),n=Math.max(1,j(t,3));return{rowFractions:mt(null,e),colFractions:mt(null,n),cells:Array.from({length:e},()=>Array.from({length:n},()=>an()))}}l(un,"createTableData");function Ot(s,t=3,e=3){const n=Math.max(1,It(s,t)),r=Math.max(1,Ct(s,e)),i=un(n,r);i.rowFractions=mt(s?.rowFractions,n),i.colFractions=mt(s?.colFractions,r);const o=Array.isArray(s?.cells)?s.cells:[],f=[];for(let a=0;a<n;a+=1)for(let y=0;y<r;y+=1){const c=Array.isArray(o[a])?o[a][y]:null,u=i.cells[a][y];c&&typeof c=="object"&&!Array.isArray(c)?(u.text=ut(c.text,ut(c.value,"")),u.style=we(c.style&&typeof c.style=="object"?c.style:c),f.push({row:a,col:y,rowSpan:j(c.rowSpan,1),colSpan:j(c.colSpan,1)})):(u.text=ut(c,""),u.style={}),u.rowSpan=1,u.colSpan=1,u.mergedInto=null}const d=Array.from({length:n},()=>Array.from({length:r},()=>!1));for(const a of f){const y=tt(a.rowSpan,1,n-a.row),c=tt(a.colSpan,1,r-a.col);if(y===1&&c===1)continue;let u=!1;for(let p=a.row;p<a.row+y&&!u;p+=1)for(let h=a.col;h<a.col+c;h+=1)if(!(p===a.row&&h===a.col)&&d[p][h]){u=!0;break}if(u)continue;const g=i.cells[a.row][a.col];g.rowSpan=y,g.colSpan=c;for(let p=a.row;p<a.row+y;p+=1)for(let h=a.col;h<a.col+c;h+=1)p===a.row&&h===a.col||(d[p][h]=!0,i.cells[p][h]={text:"",rowSpan:1,colSpan:1,mergedInto:{row:a.row,col:a.col},style:{}})}return i}l(Ot,"normalizeTableData");function Rt(s,t,e){return Array.isArray(s?.cells?.[t])&&s.cells[t][e]||null}l(Rt,"getTableCell");function cn(s,t,e){const n=Rt(s,t,e);if(!n)return null;const r=n?.mergedInto;if(r&&Number.isInteger(r.row)&&Number.isInteger(r.col)){const i=Rt(s,r.row,r.col);if(i)return{row:r.row,col:r.col,cell:i}}return{row:t,col:e,cell:n}}l(cn,"resolveTableCellAnchor");function Nr(s){if(!s)return null;const t=[s.anchorRow,s.focusRow].map(n=>Z(n,0)),e=[s.anchorCol,s.focusCol].map(n=>Z(n,0));return{minRow:Math.min(...t),maxRow:Math.max(...t),minCol:Math.min(...e),maxCol:Math.max(...e)}}l(Nr,"getTableSelectionRect");function Vt(s,t=3,e=3){const n=Ot(s,t,e);return{rowFractions:n.rowFractions.slice(),colFractions:n.colFractions.slice(),cells:n.cells.map(r=>r.map(i=>({text:ut(i?.text,""),rowSpan:j(i?.rowSpan,1),colSpan:j(i?.colSpan,1),mergedInto:i?.mergedInto&&Number.isInteger(i.mergedInto.row)&&Number.isInteger(i.mergedInto.col)?{row:i.mergedInto.row,col:i.mergedInto.col}:null,style:we(i?.style)})))}}l(Vt,"cloneTableData");function er(s,t){if(typeof t!="function")return;const e=Ot(s),n=It(e,0),r=Ct(e,0);for(let i=0;i<n;i+=1)for(let o=0;o<r;o+=1){const f=Rt(e,i,o);!f||f?.mergedInto||t(f,i,o,e)}}l(er,"forEachTableAnchor");function Dr(s,t,e,n){const r=Vt(s),i=cn(r,Z(t,0),Z(e,0));return i?.cell&&(i.cell.text=ut(n,"")),r}l(Dr,"setTableCellText");function nr(s,t){const e=Ot(s),n=t||null;if(!n)return!1;const r=It(e,0),i=Ct(e,0),o=tt(n.minRow,0,Math.max(0,r-1)),f=tt(n.maxRow,o,Math.max(0,r-1)),d=tt(n.minCol,0,Math.max(0,i-1)),a=tt(n.maxCol,d,Math.max(0,i-1));if(o===f&&d===a)return!1;for(let y=o;y<=f;y+=1)for(let c=d;c<=a;c+=1){const u=Rt(e,y,c);if(!u||u?.mergedInto||j(u.rowSpan,1)!==1||j(u.colSpan,1)!==1)return!1}return!0}l(nr,"canMergeTableCells");function Pr(s,t){const e=Vt(s),n=t||null;if(!n||!nr(e,n))return e;const r=Z(n.minRow,0),i=Math.max(r,Z(n.maxRow,r)),o=Z(n.minCol,0),f=Math.max(o,Z(n.maxCol,o)),d=Rt(e,r,o);if(!d)return e;d.rowSpan=i-r+1,d.colSpan=f-o+1,d.mergedInto=null;for(let a=r;a<=i;a+=1)for(let y=o;y<=f;y+=1)a===r&&y===o||(e.cells[a][y]={text:"",rowSpan:1,colSpan:1,mergedInto:{row:r,col:o},style:{}});return e}l(Pr,"mergeTableCells");function Fr(s,t,e){const n=Vt(s),r=cn(n,Z(t,0),Z(e,0));if(!r?.cell)return n;const i=j(r.cell.rowSpan,1),o=j(r.cell.colSpan,1);if(i===1&&o===1)return n;r.cell.rowSpan=1,r.cell.colSpan=1,r.cell.mergedInto=null;for(let f=r.row;f<r.row+i;f+=1)for(let d=r.col;d<r.col+o;d+=1)f===r.row&&d===r.col||(n.cells[f][d]=an(""));return n}l(Fr,"unmergeTableCell");function Ve(s,t){const e=Array.isArray(s)?s.slice():[1],n=e.length;if(n<=0)return[1];const r=tt(t,0,n),i=tt(r===n?n-1:r,0,n-1),o=Math.max(1e-4,vt(e[i],1/n)),f=Math.max(1e-4,o*.5);return e[i]=Math.max(1e-4,o-f),e.splice(r,0,f),mt(e,e.length)}l(Ve,"splitFractionList");function ln(s,{rowInsertIndex:t=null,colInsertIndex:e=null}={}){const n=Ot(s),r=It(n,1),i=Ct(n,1),o=t==null?r:r+1,f=e==null?i:i+1,d=t==null?-1:tt(t,0,r),a=e==null?-1:tt(e,0,i),y=un(o,f);return y.rowFractions=t==null?mt(n.rowFractions,r):Ve(n.rowFractions,d),y.colFractions=e==null?mt(n.colFractions,i):Ve(n.colFractions,a),er(n,(c,u,g)=>{const p=d>=0&&u>=d?u+1:u,h=a>=0&&g>=a?g+1:g,m=d>=0&&u<d&&u+j(c.rowSpan,1)>d?j(c.rowSpan,1)+1:j(c.rowSpan,1),b=a>=0&&g<a&&g+j(c.colSpan,1)>a?j(c.colSpan,1)+1:j(c.colSpan,1);y.cells[p][h]={text:ut(c.text,""),rowSpan:m,colSpan:b,mergedInto:null,style:we(c.style)};for(let S=p;S<p+m;S+=1)for(let A=h;A<h+b;A+=1)S===p&&A===h||(y.cells[S][A]={text:"",rowSpan:1,colSpan:1,mergedInto:{row:p,col:h},style:{}})}),y}l(ln,"buildInsertedTable");function rr(s,t){return ln(s,{rowInsertIndex:Z(t,0)})}l(rr,"insertTableRow");function ir(s,t){return ln(s,{colInsertIndex:Z(t,0)})}l(ir,"insertTableColumn");function Rr(s,t=1,e=1){let n=Vt(s,t,e);const r=Math.max(1,j(t,1)),i=Math.max(1,j(e,1));for(;It(n,0)<r;)n=rr(n,It(n,0));for(;Ct(n,0)<i;)n=ir(n,Ct(n,0));return n}l(Rr,"ensureTableSize");function k(s,t=0){const e=Number(s);return Number.isFinite(e)?e:t}l(k,"toFiniteNumber$2");function Y(s,t=""){return typeof s=="string"?s:s==null?t:String(s)}l(Y,"sanitizeText");function et(s,t){const e=String(s??"").trim();return e&&(/^#[\da-fA-F]{3,8}$/.test(e)||/^[a-zA-Z]+$/.test(e)||/^(rgb|rgba|hsl|hsla)\([^)]+\)$/i.test(e))?e:t}l(et,"sanitizeColor");function T(s,t,e){return Math.max(t,Math.min(e,s))}l(T,"clamp");function Yt(s,t="left"){const e=String(s||t).trim().toLowerCase();return e==="middle"||e==="center"?"center":e==="end"||e==="right"?"right":"left"}l(Yt,"normalizeTextAlign");function Gt(s,t="top"){const e=String(s||t).trim().toLowerCase();return e==="center"?"middle":e==="bottom"?"bottom":e==="middle"?"middle":"top"}l(Gt,"normalizeVerticalAlign");function sr(s,t="c"){const e=String(s||t).trim().toLowerCase();return["nw","n","ne","w","c","e","sw","s","se"].includes(e)?e:t}l(sr,"normalizePmiAnchor");function Ue(s,t="bottom"){const e=String(s||t).trim().toLowerCase();return["top","bottom","none"].includes(e)?e:t}l(Ue,"normalizePmiLabelPosition");function or(s,t="shaded"){const e=String(s||t).trim().toLowerCase();return["shaded","monochrome"].includes(e)?e:t}l(or,"normalizePmiRenderMode");function ar(s,t="solid"){const e=String(s||t).trim();return["none","solid","dotted","dashed","dashDot","longDash","dashDotDot"].includes(e)?e:t}l(ar,"normalizeLineStyle");function st(s){return["rect","ellipse","triangle","diamond","pentagon","hexagon","parallelogram","trapezoid"].includes(String(s||""))}l(st,"isShapeElementType");function fn(s){return["parallelogram","trapezoid"].includes(String(s||""))}l(fn,"shapeSupportsAdjustHandle");function ur(s){return fn(s)?.18:0}l(ur,"getDefaultShapeAdjust");function cr(s,t){return fn(s)?T(k(t,ur(s)),0,.45):0}l(cr,"clampShapeAdjust");function lr(s){const t=String(s??"").trim().toLowerCase();return t==="rect"?"rect":t==="ellipse"?"ellipse":t==="triangle"?"triangle":t==="diamond"?"diamond":t==="pentagon"?"pentagon":t==="hexagon"?"hexagon":t==="parallelogram"?"parallelogram":t==="trapezoid"?"trapezoid":t==="table"?"table":t==="image"?"image":t==="line"?"line":t==="pmiinset"||t==="pmi_inset"||t==="pmi"||t==="pmiview"?"pmiInset":"text"}l(lr,"normalizeElementType");const Pe=class Pe{constructor(t){this.partHistory=t||null,this.sheets=[],this._listeners=new Set}reset(){this.sheets=[],this._emit()}getSheets(){return this._normalizeSheetsArray(this.sheets),this.sheets}getSheetById(t){const e=String(t??"").trim();return e&&this.getSheets().find(n=>String(n?.id||"")===e)||null}setSheets(t){const e=Array.isArray(t)?Array.from(t):[];return this.sheets=e,this._normalizeSheetsArray(this.sheets),this._emit(),this.sheets}createSheet(t={}){const e=this.getSheets(),n=Date.now(),r=this._normalizeSheet({...t,id:t?.id||this._generateSheetId(),metadata:{...t?.metadata&&typeof t.metadata=="object"?t.metadata:{},createdAt:Number.isFinite(Number(t?.metadata?.createdAt))?Number(t.metadata.createdAt):n,updatedAt:Number.isFinite(Number(t?.metadata?.updatedAt))?Number(t.metadata.updatedAt):n}},e.length);return e.push(r),this._emit(),r}duplicateSheet(t){const e=this._resolveSheetIndex(t);if(e<0)return null;const n=this.getSheets()[e],r=O(n)||{};r.id=this._generateSheetId(),r.name=`${Y(n?.name,"Sheet")} Copy`,r.elements=Array.isArray(r.elements)?r.elements.map(o=>({...o||{},id:this._generateElementId(r.id)})):[];const i=this._normalizeSheet(r,this.sheets.length);return this.sheets.push(i),this._emit(),i}updateSheet(t,e){const n=this._resolveSheetIndex(t);if(n<0)return null;const r=this.sheets[n];let i=r;if(typeof e=="function")try{const f=e(O(r));f&&typeof f=="object"&&(i=f)}catch{i=r}else e&&typeof e=="object"&&(i={...r,...e});const o=this._normalizeSheet(i,n,r?.id);return o.metadata={...o.metadata||{},createdAt:Number.isFinite(Number(r?.metadata?.createdAt))?Number(r.metadata.createdAt):o.metadata?.createdAt,updatedAt:Date.now()},this.sheets[n]=o,this._emit(),this.sheets[n]}moveSheet(t,e){const n=this._resolveSheetIndex(t);if(n<0)return null;const r=this.getSheets(),i=T(Math.round(k(e,n)),0,Math.max(0,r.length-1));if(i===n)return r[n]||null;const[o]=r.splice(n,1);return o?(r.splice(i,0,o),this._normalizeSheetsArray(r),this._emit(),o):null}removeSheet(t){const e=this._resolveSheetIndex(t);if(e<0)return null;const[n]=this.sheets.splice(e,1);return this._normalizeSheetsArray(this.sheets),this._emit(),n||null}addListener(t){return typeof t!="function"?()=>{}:(this._listeners.add(t),()=>{try{this._listeners.delete(t)}catch{}})}removeListener(t){if(typeof t=="function")try{this._listeners.delete(t)}catch{}}notifyChanged(){this._emit()}toSerializable(){return this.getSheets().map(t=>O(t))}_resolveSheetIndex(t){if(Number.isInteger(t)){const n=Number(t);return n>=0&&n<this.getSheets().length?n:-1}const e=String(t??"").trim();return e?this.getSheets().findIndex(n=>String(n?.id||"")===e):-1}_generateSheetId(){const t=new Set(this.getSheets().map(n=>String(n?.id||"")));let e=1;for(;t.has(`sheet-${e}`);)e+=1;return`sheet-${e}`}_generateElementId(t="sheet"){return`${String(t||"sheet").replace(/[^A-Za-z0-9_-]/g,"_")}:el:${Date.now().toString(36)}:${Math.random().toString(36).slice(2,7)}`}_normalizeSheetsArray(t){if(!Array.isArray(t))return this.sheets=[],this.sheets;for(let e=0;e<t.length;e++){const n=t[e]?.id;t[e]=this._normalizeSheet(t[e],e,n)}return t}_normalizeSheet(t,e,n=null){const r=t&&typeof t=="object"?t:{},i=on(r.sizeKey),o=sn(r.orientation),f=Math.max(1,k(r.customWidthIn??r.widthIn,i.widthIn)),d=Math.max(1,k(r.customHeightIn??r.heightIn,i.heightIn)),a=Gn(i.key,o,{customWidthIn:f,customHeightIn:d}),y=Y(n||r.id||this._generateSheetId(),"").trim()||this._generateSheetId(),c=Y(r.name,"").trim()||`Sheet ${e+1}`,u=Array.isArray(r.elements)?r.elements:[],g=[],p=new Set;for(let h=0;h<u.length;h++){const m=this._normalizeElement(u[h],h,y,a);m&&(p.has(m.id)&&(m.id=this._generateElementId(y)),p.add(m.id),g.push(m))}return{id:y,name:c,sizeKey:a.key,sizeLabel:a.label,orientation:a.orientation,units:a.units,widthIn:a.widthIn,heightIn:a.heightIn,customWidthIn:a.key==="CUSTOM"?a.widthIn:void 0,customHeightIn:a.key==="CUSTOM"?a.heightIn:void 0,widthPx:a.widthPx,heightPx:a.heightPx,pxPerInch:a.pxPerInch,background:et(r.background,"#ffffff"),elements:g,metadata:{createdAt:Number.isFinite(Number(r?.metadata?.createdAt))?Number(r.metadata.createdAt):Date.now(),updatedAt:Number.isFinite(Number(r?.metadata?.updatedAt))?Number(r.metadata.updatedAt):Number.isFinite(Number(r?.metadata?.createdAt))?Number(r.metadata.createdAt):Date.now()}}}_normalizeElement(t,e,n,r){const i=t&&typeof t=="object"?t:{},o=lr(i.type),f=Math.max(.1,k(r?.widthIn,11)),d=Math.max(.1,k(r?.heightIn,8.5)),a=-f*2,y=-d*2,c=f*3,u=d*3,g=T(k(i.x,f*.1),a,c),p=T(k(i.y,d*.1),y,u),h=Y(i.id,"").trim()||this._generateElementId(n),m=Number.isInteger(i.z)?i.z:Number.isInteger(i.layer)?i.layer:e,b={id:h,type:o,groupId:Y(i.groupId,"").trim()||void 0,formboard:i.formboard&&typeof i.formboard=="object"?O(i.formboard):void 0,x:g,y:p,rotationDeg:k(i.rotationDeg,0),z:Number.isFinite(Number(m))?Number(m):e,fill:et(i.fill,o==="text"||o==="pmiInset"?"transparent":o==="table"?"#ffffff":"#dbeafe"),stroke:et(i.stroke,o==="table"?"#0f172a":"#1d4ed8"),strokeWidth:T(k(i.strokeWidth,.02),.002,1),lineStyle:ar(i.lineStyle,"solid"),opacity:T(k(i.opacity,1),0,1)};if(o==="line"){const nt=T(k(i.x2,g+1),a,c),H=T(k(i.y2,p),y,u);return{...b,x2:nt,y2:H,strokeWidth:T(k(i.strokeWidth,.035),.002,1)}}const S=Number.isFinite(Number(i.w)),A=Number.isFinite(Number(i.h)),x=k(S?i.w:i.width??(i.radiusX!=null?k(i.radiusX,.8)*2:1.4),1.4),w=k(A?i.h:i.height??(i.radiusY!=null?k(i.radiusY,.55)*2:.9),.9),N=T(x,.05,f*8),F=T(w,.05,d*8),M=!S&&!A&&Number.isFinite(Number(i.width))&&Number.isFinite(Number(i.height)),V=!S&&!A&&Number.isFinite(Number(i.radiusX))&&Number.isFinite(Number(i.radiusY)),$=T(M||V?k(i.x,f*.5)-N*.5:g,a,c),X=T(M||V?k(i.y,d*.5)-F*.5:p,y,u);if(o==="table"){const nt=String(i.fontStyle||(i.italic?"italic":"normal")).toLowerCase()==="italic"?"italic":"normal",H=String(i.fontWeight||(i.bold?"700":"400"));return{...b,x:$,y:X,w:T(x,.4,f*8),h:T(w,.3,d*8),tableData:Ot(i.tableData,i.rows??3,i.cols??4),fontSize:T(k(i.fontSize,.22),.08,3),fontFamily:Y(i.fontFamily,"Arial, Helvetica, sans-serif"),fontWeight:/^\d{3}$/.test(H)?H:H==="bold"?"700":"400",fontStyle:nt,textDecoration:String(i.textDecoration||"none").toLowerCase()==="underline"?"underline":"none",textAlign:Yt(i.textAlign||i.textAnchor,"left"),verticalAlign:Gt(i.verticalAlign||i.verticalAnchor,"middle"),color:et(i.color,et(i.textColor,"#111111"))}}if(st(o)||o==="image"||o==="pmiInset"){const nt=String(i.fontStyle||(i.italic?"italic":"normal")).toLowerCase()==="italic"?"italic":"normal",H=String(i.fontWeight||(i.bold?"700":"400"));return{...b,x:$,y:X,w:N,h:F,cornerRadius:T(k(i.cornerRadius,o==="rect"?.1:0),0,Math.min(N,F)*.5),shapeAdjust:cr(o,i.shapeAdjust),src:o==="image"||o==="pmiInset"?Y(i.src,""):void 0,mediaScale:o==="image"||o==="pmiInset"?T(k(i.mediaScale,1),1,10):void 0,mediaOffsetX:o==="image"||o==="pmiInset"?T(k(i.mediaOffsetX,0),-1,1):void 0,mediaOffsetY:o==="image"||o==="pmiInset"?T(k(i.mediaOffsetY,0),-1,1):void 0,pmiViewIndex:o==="pmiInset"?Number.isInteger(i.pmiViewIndex)?i.pmiViewIndex:-1:void 0,pmiViewName:o==="pmiInset"?Y(i.pmiViewName,"PMI View"):void 0,pmiImageRevision:o==="pmiInset"?Number.isInteger(i.pmiImageRevision)?i.pmiImageRevision:0:void 0,pmiModelRevision:o==="pmiInset"?Number.isInteger(i.pmiModelRevision)?i.pmiModelRevision:-1:void 0,pmiImageCaptureKey:o==="pmiInset"?Y(i.pmiImageCaptureKey,""):void 0,showTitle:o==="pmiInset"?Ue(i.pmiLabelPosition,i.showTitle!==!1?"bottom":"none")!=="none":void 0,pmiLabelPosition:o==="pmiInset"?Ue(i.pmiLabelPosition,i.showTitle!==!1?"bottom":"none"):void 0,pmiRenderMode:o==="pmiInset"?or(i.pmiRenderMode,"shaded"):void 0,pmiShowCenterLines:o==="pmiInset"?i.pmiShowCenterLines===!0:void 0,pmiAnchor:o==="pmiInset"?sr(i.pmiAnchor,"c"):void 0,text:st(o)?Y(i.text,""):void 0,fontSize:st(o)?T(k(i.fontSize,.28),.08,3):void 0,fontFamily:st(o)?Y(i.fontFamily,"Arial, Helvetica, sans-serif"):void 0,fontWeight:st(o)?/^\d{3}$/.test(H)?H:H==="bold"?"700":"400":void 0,fontStyle:st(o)?nt:void 0,textAlign:st(o)?Yt(i.textAlign||i.textAnchor,"center"):void 0,verticalAlign:st(o)?Gt(i.verticalAlign||i.verticalAnchor,"middle"):void 0,color:st(o)?et(i.color,et(i.textColor,"#0f172a")):void 0}}const L=Yt(i.textAlign||i.textAnchor,"left"),J=String(i.fontStyle||(i.italic?"italic":"normal")).toLowerCase()==="italic"?"italic":"normal",Q=String(i.fontWeight||(i.bold?"700":"400"));return{...b,w:T(k(S?i.w:i.width,3.2),.1,f*8),h:T(k(A?i.h:i.height,1.1),.1,d*8),text:Y(i.text,`Text ${e+1}`),fontSize:T(k(i.fontSize,.32),.08,3),fontFamily:Y(i.fontFamily,"Arial, Helvetica, sans-serif"),fontWeight:/^\d{3}$/.test(Q)?Q:Q==="bold"?"700":"400",fontStyle:J,textAlign:L,verticalAlign:Gt(i.verticalAlign||i.verticalAnchor,"top"),color:et(i.color,et(i.textColor,et(i.fill,"#111111")))}}_emit(){if(!this._listeners||this._listeners.size===0)return;const t=this.getSheets();for(const e of Array.from(this._listeners))try{e(t,this.partHistory||null)}catch{}}};l(Pe,"Sheet2DManager");let pe=Pe;function Ft(s,t=0){const e=Number(s);return Number.isFinite(e)?e:t}l(Ft,"toFiniteNumber$1");function q(s,t=""){return String(s??"").trim()||t}l(q,"normalizeText");function qt(s,t=0){const e=s&&typeof s=="object"?s:{},n=Number.isInteger(t)?t+1:1;return{id:q(e.id,`wire-${n}`),name:q(e.name,`Wire ${n}`),from:q(e.from,""),to:q(e.to,""),diameter:Math.max(.01,Ft(e.diameter,1))}}l(qt,"normalizeConnection");function fr(s){return!Array.isArray(s)||s.length<3?null:[Ft(s[0],0),Ft(s[1],0),Ft(s[2],0)]}l(fr,"normalizePointArray");function We(s){return Array.isArray(s)?s.map(t=>q(t,"")).filter(Boolean):[]}l(We,"normalizeStringArray");function pr(s,t=new Map){const e=s&&typeof s=="object"?s:{},n=q(e.connectionId,""),r=t.get(n)||null,i=!!e.feasible;return{connectionId:n,connectionName:q(e.connectionName,r?.name||n||"Wire"),feasible:i,error:q(e.error,i?"":"No route found through the harness network."),distance:Number.isFinite(Number(e.distance))?Number(e.distance):null,polyline:(Array.isArray(e.polyline)?e.polyline:[]).map(o=>fr(o)).filter(Boolean),segmentIds:We(e.segmentIds),nodePath:We(e.nodePath),reusesHarnessPoint:!!e.reusesHarnessPoint,diameter:Math.max(.01,Ft(e.diameter,r?.diameter||1)),from:q(e.from,r?.from||""),to:q(e.to,r?.to||"")}}l(pr,"normalizeRouteResult");const Fe=class Fe{constructor(t){this.partHistory=t||null,this.connections=[],this.routeResults=[],this._pendingRestoredRouteResults=null,this._listeners=new Set}reset(){this.connections=[],this.routeResults=[],this._pendingRestoredRouteResults=null,this._emit()}getConnections(){return this._normalizeConnectionsArray(this.connections),this.connections}setConnections(t){const e=Array.isArray(t)?Array.from(t):[];return this.connections=e,this._normalizeConnectionsArray(this.connections),this._pendingRestoredRouteResults=null,this._emit(),this.connections}addConnection(t={}){const e=this.getConnections(),n=qt({id:t?.id||this._generateConnectionId(),...t},e.length);return e.push(n),this._emit(),n}updateConnection(t,e){const n=this.getConnections(),r=q(t,""),i=n.findIndex(d=>String(d?.id||"")===r);if(i<0)return null;const o=n[i];let f=o;if(typeof e=="function")try{const d=e(O(o));d&&typeof d=="object"&&(f=d)}catch{f=o}else e&&typeof e=="object"&&(f={...o,...e});return n[i]=qt(f,i),n[i].id||(n[i].id=o.id),this._emit(),n[i]}removeConnection(t){const e=this.getConnections(),n=q(t,""),r=e.findIndex(o=>String(o?.id||"")===n);if(r<0)return null;const[i]=e.splice(r,1);return this.routeResults=this.routeResults.filter(o=>String(o?.connectionId||"")!==n),this._normalizeConnectionsArray(e),this._emit(),i||null}getRouteResults(){return this._normalizeRouteResultsArray(this.routeResults),Array.isArray(this.routeResults)?this.routeResults:[]}setRouteResults(t,e={}){const n=!!e?.preservePendingRestore,r=!!e?.markPendingRestore;return this.routeResults=Array.isArray(t)?t.map(i=>({...i||{}})):[],this._normalizeRouteResultsArray(this.routeResults),r?this._pendingRestoredRouteResults=this.routeResults.map(i=>O(i)):n||(this._pendingRestoredRouteResults=null),this._emit(),this.routeResults}clearRouteResults(t={}){this.routeResults=[],t?.preservePendingRestore||(this._pendingRestoredRouteResults=null),this._emit()}getRouteResultMap(){const t=new Map;for(const e of this.getRouteResults()){const n=q(e?.connectionId,"");n&&t.set(n,e)}return t}addListener(t){return typeof t!="function"?()=>{}:(this._listeners.add(t),()=>{try{this._listeners.delete(t)}catch{}})}removeListener(t){if(typeof t=="function")try{this._listeners.delete(t)}catch{}}notifyChanged(){this._emit()}toSerializable(){return{connections:this.getConnections().map(t=>O(t)),routeResults:this.getRouteResults().map(t=>O(t))}}loadSerializable(t){const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{connections:t,routeResults:[]};return this.connections=Array.isArray(e.connections)?Array.from(e.connections):[],this._normalizeConnectionsArray(this.connections),this.routeResults=Array.isArray(e.routeResults)?Array.from(e.routeResults):[],this._normalizeRouteResultsArray(this.routeResults),this._pendingRestoredRouteResults=this.routeResults.length?this.routeResults.map(n=>O(n)):null,this._emit(),this.toSerializable()}consumePendingRestoredRouteResults(){const t=Array.isArray(this._pendingRestoredRouteResults)?this._pendingRestoredRouteResults.map(e=>O(e)):null;return this._pendingRestoredRouteResults=null,t}_generateConnectionId(){const t=new Set(this.getConnections().map(n=>String(n?.id||"")));let e=1;for(;t.has(`wire-${e}`);)e+=1;return`wire-${e}`}_normalizeConnectionsArray(t){if(!Array.isArray(t))return this.connections=[],this.connections;for(let e=0;e<t.length;e+=1)t[e]=qt(t[e],e);return t}_normalizeRouteResultsArray(t){if(!Array.isArray(t))return this.routeResults=[],this.routeResults;const e=new Map(this.getConnections().map(n=>[String(n?.id||""),n]));for(let n=0;n<t.length;n+=1)t[n]=pr(t[n],e);return t}_emit(){if(!this._listeners||this._listeners.size===0)return;const t={connections:this.getConnections(),routeResults:this.getRouteResults(),manager:this,partHistory:this.partHistory||null};for(const e of Array.from(this._listeners))try{e(t)}catch{}}};l(Fe,"WireHarnessManager");let he=Fe;const hr=new Set(["slider","number","select","string"]),pn=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function dt(s,t=null){const e=Number(s);return Number.isFinite(e)?e:t}l(dt,"toFiniteNumber");function de(s){const t=[],e=new Set;for(const n of s){const r=String(n??"").trim();!r||e.has(r)||(e.add(r),t.push(r))}return t}l(de,"uniqueStrings");function me(){return{fields:[],values:{}}}l(me,"createEmptyConfiguratorState");function vr(s){return pn.test(String(s??"").trim())}l(vr,"isConfiguratorFieldNameValid");function dr(s){const t=String(s??"").replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\s+/g," ").trim();return t?t.charAt(0).toUpperCase()+t.slice(1):"Field"}l(dr,"prettyConfiguratorLabel");function mr(s,t=0,e=new Set){let n=String(s??"").trim();n=n.replace(/\s+/g,"_").replace(/[^A-Za-z0-9_$]/g,"_").replace(/_+/g,"_"),n||(n=`field${t+1}`),/^[A-Za-z_$]/.test(n)||(n=`_${n}`),pn.test(n)||(n=`field${t+1}`);let r=n,i=2;for(;e.has(r);)r=`${n}_${i}`,i+=1;return e.add(r),r}l(mr,"normalizeConfiguratorFieldName");function yr(s){return Array.isArray(s)?de(s):typeof s!="string"?[]:de(s.split(/\r?\n|,/g))}l(yr,"parseConfiguratorOptions");function gr(s){const t=String(s??"").trim().toLowerCase();return t==="options"||t==="dropdown"?"select":hr.has(t)?t:"number"}l(gr,"normalizeConfiguratorType");function Kt(s,t){const e=String(s?.type??"").trim().toLowerCase();if(e==="slider"||e==="number"){let n=dt(t,dt(s?.defaultValue,0));const r=dt(s?.min,null),i=dt(s?.max,null);return Number.isFinite(r)&&(n=Math.max(r,n)),Number.isFinite(i)&&(n=Math.min(i,n)),n}if(e==="select"){const n=Array.isArray(s?.options)?de(s.options):[];if(!n.length)return"";const r=String(t??s?.defaultValue??n[0]??"");return n.includes(r)?r:n[0]}return String(t??s?.defaultValue??"")}l(Kt,"normalizeConfiguratorValue");function Zt(s){const t=me(),e=Array.isArray(s?.fields)?s.fields:[],n=s?.values&&typeof s.values=="object"&&!Array.isArray(s.values)?s.values:{},r=new Set;for(let i=0;i<e.length;i+=1){const o=e[i]&&typeof e[i]=="object"?e[i]:{},f=gr(o.type),d=mr(o.name??o.key??o.fieldName,i,r),a={name:d,label:String(o.label??"").trim()||dr(d),type:f};if(f==="slider"||f==="number"){let c=dt(o.min,f==="slider"?0:null),u=dt(o.max,f==="slider"?100:null);if(Number.isFinite(c)&&Number.isFinite(u)&&c>u){const p=c;c=u,u=p}let g=dt(o.step,1);(!Number.isFinite(g)||g<=0)&&(g=1),a.min=c,a.max=u,a.step=g,a.defaultValue=Kt(a,o.defaultValue??o.value)}else f==="select"?(a.options=yr(o.options),a.options.length||(a.options=["Option"]),a.defaultValue=Kt(a,o.defaultValue??o.value)):a.defaultValue=String(o.defaultValue??o.value??"");const y=Object.prototype.hasOwnProperty.call(n,d)?n[d]:a.defaultValue;t.fields.push(a),t.values[d]=Kt(a,y)}return t}l(Zt,"normalizeConfiguratorState");const Be=!1,Xe=new Set(["__open"]),hn=`resolution = 32;
2
2
  `,Ye=`//Examples:
3
3
  x = 10 + 6;
4
4
  y = x * 2;
@@ -1 +1 @@
1
- var U=Object.defineProperty;var c=(t,e)=>U(t,"name",{value:e,configurable:!0});import{d as R,L as Y,e as H,b8 as B,s as k,f as G,V as b,Q as I,u as Z,a1 as J,m as C,M as T,b as E}from"./featureDialogs-Cx7p1XpK.js";const S=Object.freeze({lineColor:9684477,dotColor:9684477,arrowColor:9684477,arrowLengthPx:12,arrowWidthPx:4,leaderDotRadiusPx:6,noteDotRadius:.08,noteDotColor:9684477});let A={...S};function D(){return A}c(D,"getPMIStyle");function st(t={}){return!t||typeof t!="object"||(A={...A,...t}),A}c(st,"setPMIStyle");function at(t={}){const e={...S},n=c((i,s)=>{const r=t[i];if(Number.isFinite(r))e[i]=r;else if(typeof r=="string"&&i.toLowerCase().includes("color")){const f=parseInt(r.replace("#",""),16);Number.isFinite(f)&&(e[i]=f)}else r!=null&&(e[i]=s)},"assign");return n("lineColor",S.lineColor),n("dotColor",S.dotColor),n("arrowColor",S.arrowColor),n("arrowLengthPx",S.arrowLengthPx),n("arrowWidthPx",S.arrowWidthPx),n("leaderDotRadiusPx",S.leaderDotRadiusPx),n("lineWidth",S.lineWidth||1),n("noteDotRadius",S.noteDotRadius),n("noteDotColor",S.noteDotColor),e}c(at,"sanitizePMIStyle");function q(t){try{return JSON.parse(JSON.stringify(t))}catch{return{}}}c(q,"safeCloneJSON");function X(t){return t?t.isPerspectiveCamera?"PerspectiveCamera":t.isOrthographicCamera?"OrthographicCamera":"Camera":"Camera"}c(X,"resolveCameraType");function W(t){if(!t)return null;if(Array.isArray(t)&&t.length===3)return[Number(t[0])||0,Number(t[1])||0,Number(t[2])||0];if(typeof t=="object"){const{x:e,y:n,z:i}=t;if([e,n,i].every(s=>Number.isFinite(s)))return[e,n,i]}return null}c(W,"extractVector3");function _(t){if(!t||typeof t!="object")return null;const e=Number(t.width),n=Number(t.height);return!(e>0)||!(n>0)?null:{width:e,height:n}}c(_,"normalizeViewportMetrics");function Q(t,e,n,i,s){if(!e)return;const r=i?.controlsState;if(r&&typeof e.setStateFromJSON=="function"){const x=Array.isArray(r.target)?r.target:n,o={arcballState:{target:Array.isArray(x)?x:[t.target?.x||0,t.target?.y||0,t.target?.z||0],cameraMatrix:{elements:Array.isArray(r.cameraMatrix)&&r.cameraMatrix.length===16?r.cameraMatrix:Array.from(t.matrix.elements)},cameraUp:r.cameraUp||{x:t.up.x,y:t.up.y,z:t.up.z},cameraNear:Number.isFinite(r.cameraNear)?r.cameraNear:t.near,cameraFar:Number.isFinite(r.cameraFar)?r.cameraFar:t.far,cameraZoom:Number.isFinite(r.cameraZoom)?r.cameraZoom:t.zoom,gizmoMatrix:{elements:Array.isArray(r.gizmoMatrix)&&r.gizmoMatrix.length===16?r.gizmoMatrix:Array.from((e._gizmos?.matrix||new T).elements)}}},l=Number.isFinite(r.cameraFov)?r.cameraFov:i?.projection?.fov;t.isPerspectiveCamera&&Number.isFinite(l)&&(o.arcballState.cameraFov=l);try{e.setStateFromJSON(JSON.stringify(o))}catch(g){console.warn("ArcballControls setStateFromJSON failed; falling back to manual sync",g),L(t,e,n,i),O(e,s);return}O(e,s);return}L(t,e,n,i),O(e,s)}c(Q,"syncArcballControls");function L(t,e,n,i){const s=Array.isArray(n)&&n.length===3?n:e.target?[e.target.x,e.target.y,e.target.z]:[0,0,0],r=new b(s[0],s[1],s[2]);try{typeof e.setTarget=="function"?e.setTarget(r.x,r.y,r.z):e.target?.set?e.target.set(r.x,r.y,r.z):e.target&&(e.target.x=r.x,e.target.y=r.y,e.target.z=r.z)}catch{}try{e._currentTarget?.copy&&e._currentTarget.copy(r),e._target0?.copy&&e._target0.copy(r)}catch{}const f=e._gizmos;if(f){try{f.position.copy(r),f.updateMatrix(),f.updateMatrixWorld(!0)}catch{}if(typeof e.calculateTbRadius=="function")try{e._tbRadius=e.calculateTbRadius(t)}catch{}if(typeof e.makeGizmos=="function")try{e.makeGizmos(r,e._tbRadius||1)}catch{}}try{e._cameraMatrixState?.copy?.(t.matrix),e._cameraMatrixState0?.copy?.(t.matrix),f?.matrix&&(e._gizmoMatrixState?.copy?.(f.matrix),e._gizmoMatrixState0?.copy?.(f.matrix)),e._cameraProjectionState?.copy?.(t.projectionMatrix),typeof e._zoomState=="number"&&(e._zoomState=t.zoom),typeof e._zoom0=="number"&&(e._zoom0=t.zoom),typeof e._fovState=="number"&&Number.isFinite(i?.projection?.fov??t.fov)&&(e._fovState=i?.projection?.fov??t.fov),typeof e._fov0=="number"&&Number.isFinite(i?.projection?.fov??t.fov)&&(e._fov0=i?.projection?.fov??t.fov),typeof e._nearPos=="number"&&(e._nearPos=Number.isFinite(i?.near)?i.near:t.near),typeof e._farPos=="number"&&(e._farPos=Number.isFinite(i?.far)?i.far:t.far),e._up0?.copy?.(t.up)}catch{}try{typeof e.updateTbState=="function"&&e.STATE?.IDLE?e.updateTbState(e.STATE.IDLE,!1):"_state"in e&&e.STATE?.IDLE&&(e._state=e.STATE.IDLE)}catch{}}c(L,"manualArcballSync");function O(t,e){try{if(typeof t._animationId=="number"&&t._animationId!==-1){const n=typeof cancelAnimationFrame=="function"?cancelAnimationFrame:typeof window<"u"&&typeof window.cancelAnimationFrame=="function"?window.cancelAnimationFrame.bind(window):null;n&&n(t._animationId)}t._animationId=-1,typeof t._timeStart=="number"&&(t._timeStart=-1)}catch{}try{t.updateMatrixState?.()}catch{}if(e)try{t.update?.()}catch{}}c(O,"finalizeArcballSync");function K(t){if(!t)return null;if(t.isPerspectiveCamera){const e=t.view&&t.view.enabled?{enabled:!0,fullWidth:t.view.fullWidth,fullHeight:t.view.fullHeight,offsetX:t.view.offsetX,offsetY:t.view.offsetY,width:t.view.width,height:t.view.height}:{enabled:!1};return{kind:"perspective",aspect:Number.isFinite(t.aspect)&&t.aspect>0?t.aspect:void 0,fov:t.fov,near:t.near,far:t.far,zoom:t.zoom??1,filmGauge:t.filmGauge??35,filmOffset:t.filmOffset??0,view:e}}if(t.isOrthographicCamera){const e=t.view&&t.view.enabled?{enabled:!0,fullWidth:t.view.fullWidth,fullHeight:t.view.fullHeight,offsetX:t.view.offsetX,offsetY:t.view.offsetY,width:t.view.width,height:t.view.height}:{enabled:!1};return{kind:"orthographic",aspect:Number.isFinite(t.top-t.bottom)&&Math.abs(t.top-t.bottom)>1e-9?(t.right-t.left)/(t.top-t.bottom):void 0,left:t.left,right:t.right,top:t.top,bottom:t.bottom,near:t.near,far:t.far,zoom:t.zoom??1,view:e}}return{kind:"generic",near:t.near??.1,far:t.far??2e3}}c(K,"captureProjection");function $(t,e=null,n=null,i=null){try{if(!t?.isPerspectiveCamera)return;const s=_(n);if(!s)return;const r=s.width/s.height;if(!(r>1e-9))return;t.aspect=r;const f=_(i),x=f?f.width/f.height:Number.isFinite(e?.aspect)&&e.aspect>1e-9?e.aspect:null;if(!(x>1e-9)||r>=x)return;const o=Number.isFinite(e?.fov)?e.fov:t.fov,l=Number.isFinite(e?.zoom)&&e.zoom>0?e.zoom:Number.isFinite(t.zoom)&&t.zoom>0?t.zoom:1;if(!(o>0)||o>=179)return;const m=Math.tan(E.degToRad(o)*.5)/l*x/r;if(!(m>0))return;const w=E.radToDeg(2*Math.atan(m*l));Number.isFinite(w)&&w>o&&(t.fov=Math.min(179,w))}catch{}}c($,"fitPerspectiveProjection");function j(t,e,n=null){if(!(!t||!e)){if(t.isPerspectiveCamera&&e.kind==="perspective"){Number.isFinite(e.fov)&&(t.fov=e.fov),Number.isFinite(e.near)&&(t.near=e.near),Number.isFinite(e.far)&&(t.far=e.far),Number.isFinite(e.zoom)&&(t.zoom=e.zoom),Number.isFinite(e.filmGauge)&&(t.filmGauge=e.filmGauge),Number.isFinite(e.filmOffset)&&(t.filmOffset=e.filmOffset),n!=null&&Number.isFinite(n)&&(t.aspect=n),e.view&&e.view.enabled&&t.setViewOffset?t.setViewOffset(e.view.fullWidth,e.view.fullHeight,e.view.offsetX,e.view.offsetY,e.view.width,e.view.height):t.clearViewOffset&&t.clearViewOffset();return}if(t.isOrthographicCamera&&e.kind==="orthographic"){const i=["left","right","top","bottom","near","far","zoom"];for(const s of i)Number.isFinite(e[s])&&(t[s]=e[s]);e.view&&e.view.enabled&&t.setViewOffset?t.setViewOffset(e.view.fullWidth,e.view.fullHeight,e.view.offsetX,e.view.offsetY,e.view.width,e.view.height):t.clearViewOffset&&t.clearViewOffset();return}Number.isFinite(e.near)&&(t.near=e.near),Number.isFinite(e.far)&&(t.far=e.far),Number.isFinite(e.zoom)&&(t.zoom=e.zoom)}}c(j,"applyProjection");function ft(t,{controls:e=null,viewport:n=null}={}){if(!t||!t.isCamera)return null;try{t.updateMatrixWorld(!0)}catch{}const i={version:3,type:X(t),worldMatrix:t.matrixWorld?.toArray?.()??null,projection:K(t),position:{x:t.position.x,y:t.position.y,z:t.position.z},quaternion:{x:t.quaternion.x,y:t.quaternion.y,z:t.quaternion.z,w:t.quaternion.w},up:{x:t.up.x,y:t.up.y,z:t.up.z},zoom:Number.isFinite(t.zoom)?t.zoom:1,near:Number.isFinite(t.near)?t.near:void 0,far:Number.isFinite(t.far)?t.far:void 0};if(t.layers?.mask!==void 0&&(i.layers=t.layers.mask),e?.target&&typeof e.target=="object"){i.target={x:e.target.x,y:e.target.y,z:e.target.z};try{const r=e._gizmos?.matrix;r&&(i.controlsState={target:[e.target.x,e.target.y,e.target.z],cameraMatrix:Array.from(t.matrix.elements),cameraUp:{x:t.up.x,y:t.up.y,z:t.up.z},cameraNear:t.near,cameraFar:t.far,cameraZoom:t.zoom,cameraFov:t.isPerspectiveCamera?t.fov:void 0,gizmoMatrix:Array.from(r.elements)})}catch{}}!i.target&&t.target&&typeof t.target=="object"&&(i.target={x:t.target.x,y:t.target.y,z:t.target.z}),t.userData&&typeof t.userData=="object"&&(i.userData=q(t.userData));const s=_(n);return s&&(i.viewport=s),i}c(ft,"captureCameraSnapshot");function ut(t,e,{controls:n=null,respectParent:i=!0,strictType:s=!1,overrideAspect:r=null,syncControls:f=!0,viewport:x=null}={}){if(!t||!t.isCamera||!e)return!1;let o=e;if(typeof o=="string")try{o=JSON.parse(o)}catch{return!1}if(!o||typeof o!="object")return!1;const l=o.type||null;if(s&&l){const p=X(t);if(l!==p)return!1}try{j(t,o.projection,r)}catch{}$(t,o?.projection,x,o?.viewport||null),tt(t,o?.projection,x),typeof o.layers=="number"&&t.layers&&(t.layers.mask=o.layers);const g=W(o.up)||W(o.upVector);g&&t.up.set(g[0],g[1],g[2]),o.userData&&typeof o.userData=="object"&&(t.userData=q(o.userData));let u=!1,m=!1;const w=Array.isArray(o.worldMatrix)&&o.worldMatrix.length===16?o.worldMatrix:null;if(w)try{const p=new T().fromArray(w),F=t.parent||null,M=new b,a=new I,d=new b;if(i&&F){F.updateMatrixWorld?.(!0);const z=new T().copy(F.matrixWorld).invert();new T().multiplyMatrices(z,p).decompose(M,a,d)}else p.decompose(M,a,d);const y=t.matrixAutoUpdate;t.matrixAutoUpdate=!1,t.position.copy(M),t.quaternion.copy(a),t.scale.copy(d),t.updateMatrix(),t.updateMatrixWorld(!0),t.matrixAutoUpdate=y,u=!0,m=!0}catch{u=!1}if(!u){const p=W(o.position);let F=!1;p&&(t.position.set(p[0],p[1],p[2]),F=!0);const M=o.quaternion;if(M&&typeof M=="object"){const{x:a,y:d,z:y,w:z}=M;[a,d,y,z].every(N=>Number.isFinite(N))&&(t.quaternion.set(a,d,y,z),F=!0)}Number.isFinite(o.zoom)&&(t.zoom=o.zoom,F=!0),Number.isFinite(o.near)&&(t.near=o.near,F=!0),Number.isFinite(o.far)&&(t.far=o.far,F=!0),F&&(t.updateMatrixWorld?.(!0),m=!0)}if(!m){try{t.updateProjectionMatrix?.()}catch{}if(n){try{n.update?.()}catch{}try{n.updateMatrixState?.()}catch{}}return!1}try{t.updateProjectionMatrix?.()}catch{}const v=o.target||o.controlsTarget,h=W(v);return n?Q(t,n,h,o,f):h&&t.target&&typeof t.target.set=="function"&&t.target.set(h[0],h[1],h[2]),!0}c(ut,"applyCameraSnapshot");function tt(t,e=null,n=null){try{if(!t?.isOrthographicCamera)return;const i=e||{},s=Number.isFinite(i.top)?i.top:t.top,r=Number.isFinite(i.bottom)?i.bottom:t.bottom,f=Number.isFinite(i.left)?i.left:t.left,x=Number.isFinite(i.right)?i.right:t.right,o=Number.isFinite(s)&&Number.isFinite(r)?s-r:t.top-t.bottom,l=Number.isFinite(f)&&Number.isFinite(x)?x-f:t.right-t.left;if(!Number.isFinite(o)||Math.abs(o)<1e-9||!Number.isFinite(l)||Math.abs(l)<1e-9)return;const g=Number.isFinite(s)&&Number.isFinite(r)?(s+r)*.5:(t.top+t.bottom)*.5,u=Number.isFinite(f)&&Number.isFinite(x)?(f+x)*.5:(t.left+t.right)*.5,m=_(n);let w=m?m.width/m.height:null;w>1e-9||(w=Number.isFinite(i.aspect)&&i.aspect>1e-9?i.aspect:l/o),(!Number.isFinite(w)||w<=1e-9)&&(w=1);const v=Math.abs(o)*.5,h=Math.abs(l)*.5,p=Math.max(h,v*w),F=Math.max(v,h/w),M=o>=0?1:-1;t.top=g+F*M,t.bottom=g-F*M,t.left=u-p,t.right=u+p,t.updateProjectionMatrix()}catch{}}c(tt,"adjustOrthographicFrustum");function V(t,e,n=void 0){const i=D(),s=n??i.lineColor??9684477,r=new R().setFromPoints([t.clone(),e.clone()]),f=new Y({color:s,linewidth:i.lineWidth||1});return f.depthTest=!1,f.depthWrite=!1,f.transparent=!0,new H(r,f)}c(V,"makeOverlayLine");function lt(t,e,n=void 0,i={}){const s=D(),{viewer:r=null,dashPixels:f=10,gapPixels:x=10}=i||{},o=t.distanceTo(e);if(!(o>1e-6))return V(t,e,n??s.lineColor??9684477);const l=e.clone().sub(t).normalize(),g=t.clone().add(e).multiplyScalar(.5),u=et(r,g),m=it(u*f,o),w=nt(u*x,o),v=[];let h=0,p=t.clone();for(;h<o-1e-6;){const d=Math.min(m,o-h),y=p.clone().addScaledVector(l,d);if(v.push(p.clone(),y.clone()),h+=d,h>=o)break;const z=Math.min(w,o-h);p=y.clone().addScaledVector(l,z),h+=z}if(v.length<2)return V(t,e,n??s.lineColor??9684477);const F=new R().setFromPoints(v),M=new Y({color:n??s.lineColor??9684477,linewidth:s.lineWidth||1});M.depthTest=!1,M.depthWrite=!1,M.transparent=!0;const a=new J(F,M);return a.renderOrder=9994,a}c(lt,"makeOverlayDashedLine");function et(t,e){try{const n=t?.camera,i=t?.renderer;if(!n||!i)return .01;const s=i.domElement,r=Math.max(1,s?.clientHeight||s?.height||600);if(n.isOrthographicCamera)return(n.top-n.bottom)/Math.max(1e-6,n.zoom||1)/r;const f=n.getWorldPosition(new b),x=e?e.clone():n.getWorldDirection(new b).add(f),o=f.distanceTo(x),l=(n.fov||50)*Math.PI/180;return 2*Math.tan(l/2)*o/r}catch{return .01}}c(et,"worldUnitsPerPixelAtPoint");function it(t,e){if(!Number.isFinite(t)||t<=0)return e*.25;const n=Math.max(1e-4,e*.5);return Math.max(1e-4,Math.min(t,n))}c(it,"clampDashLength");function nt(t,e){if(!Number.isFinite(t)||t<0)return e*.25;const n=Math.max(1e-4,e*.5);return Math.max(1e-4,Math.min(t,n))}c(nt,"clampGapLength");function dt(t,e=void 0){const n=D(),i=e??n.dotColor??16777215,s=new Z(t,12,8),r=new k({color:i});return r.depthTest=!1,r.depthWrite=!1,r.transparent=!0,new G(s,r)}c(dt,"makeOverlaySphere");function pt(t,e,n,i,s,r){try{const f=D(),x=new B(s,i,8),o=new k({color:r??f.arrowColor??9684477,depthTest:!1,depthWrite:!1,transparent:!0}),l=new G(x,o),g=e.clone().addScaledVector(n,-i*.5);l.position.copy(g);const u=new b(0,1,0),m=new I;return m.setFromUnitVectors(u,n.clone().normalize()),l.setRotationFromQuaternion(m),l.renderOrder=9996,t.add(l),l}catch{return null}}c(pt,"addArrowCone");function gt(t,e=1){try{const n=t?.renderer?.domElement?.getBoundingClientRect?.()||{width:800,height:600},i=t?.camera,s=Math.max(1,n.height||600);if(i&&i.isOrthographicCamera){const f=(i.top-i.bottom)/Math.max(1e-6,i.zoom||1)/s;return Math.max(1e-4,f*(e||1))}if(i&&i.isPerspectiveCamera){const r=(i.fov||50)*Math.PI/180,f=i.position.length(),o=2*Math.tan(r/2)*f/s;return Math.max(1e-4,o*(e||1))}return .01*(e||1)}catch{return .01*(e||1)}}c(gt,"screenSizeWorld");function ct(t,e){try{if(!e)return null;const n=e.userData||{},i=String(e.type||"").toUpperCase(),s=String(n.type||n.brepType||"").toUpperCase(),f=i==="FACE"||i==="PLANE"||!(i==="FACE"||i==="EDGE"||i==="PLANE")&&(s==="FACE"||s==="PLANE"),x=i==="EDGE"||!f&&(s==="EDGE"||e.isLine||e.isLine2||e.isLineSegments||e.isLineLoop);if(f){if(typeof e.getAverageNormal=="function"){const u=e.getAverageNormal();e.updateMatrixWorld(!0);const m=new C().getNormalMatrix(e.matrixWorld);return u.applyMatrix3(m).normalize()}const o=e.geometry;if(o){if(o.attributes&&o.attributes.normal){const u=o.attributes.normal.array;if(u.length>=3){const m=new b,w=u.length/3;for(let h=0;h<w;h++){const p=h*3;m.add(new b(u[p],u[p+1],u[p+2]))}m.divideScalar(w),e.updateMatrixWorld(!0);const v=new C().getNormalMatrix(e.matrixWorld);return m.applyMatrix3(v).normalize()}}if(o.attributes&&o.attributes.position){const u=o.attributes.position.array;if(u.length>=9){const m=new b;let w=0;const v=new b,h=new b,p=new b;e.updateMatrixWorld(!0);const F=Math.min(5,Math.floor(u.length/9));for(let M=0;M<F;M++){const a=M*9;if(a+8<u.length){v.set(u[a],u[a+1],u[a+2]).applyMatrix4(e.matrixWorld),h.set(u[a+3],u[a+4],u[a+5]).applyMatrix4(e.matrixWorld),p.set(u[a+6],u[a+7],u[a+8]).applyMatrix4(e.matrixWorld);const d=h.clone().sub(v).cross(p.clone().sub(v));d.lengthSq()>1e-10&&(d.normalize(),m.add(d),w++)}}if(w>0)return m.divideScalar(w).normalize()}}}const l=new b(0,0,1);e.updateMatrixWorld(!0);const g=new C().getNormalMatrix(e.matrixWorld);return l.applyMatrix3(g).normalize()}else if(x){const l=e.geometry;e.updateMatrixWorld(!0);const g=e.matrixWorld,u=c((a,d=!1)=>{if(!a)return null;let y=null;if(Array.isArray(a)&&a.length>=3)y=new b(a[0],a[1],a[2]);else if(typeof a=="object"){const z=Number(a.x),N=Number(a.y),P=Number(a.z);Number.isFinite(z)&&Number.isFinite(N)&&Number.isFinite(P)&&(y=new b(z,N,P))}return y?(d&&g&&y.applyMatrix4(g),y):null},"parsePoint"),m=c((a,d=!1)=>{if(!Array.isArray(a)||a.length<2)return null;let y=u(a[0],d);for(let z=1;z<a.length;z++){const N=u(a[z],d);if(!y||!N){y=N||y;continue}const P=N.clone().sub(y);if(P.lengthSq()>1e-12)return P.normalize();y=N}return null},"directionFromPointList");try{if(typeof e.points=="function"){const a=e.points(!0),d=m(a,!1);if(d)return d}}catch{}const w=Array.isArray(e?.userData?.polylineLocal)?e.userData.polylineLocal:null;if(w){const a=m(w,!0);if(a)return a}const v=l?.attributes?.instanceStart,h=l?.attributes?.instanceEnd;if(v&&h){const a=Math.min(v.count||0,h.count||0);for(let d=0;d<a;d++){const y=new b(v.getX(d),v.getY(d),v.getZ(d)),z=new b(h.getX(d),h.getY(d),h.getZ(d));g&&(y.applyMatrix4(g),z.applyMatrix4(g));const N=z.sub(y);if(N.lengthSq()>1e-12)return N.normalize()}}const p=l?.getAttribute?.("position");if(p&&p.itemSize===3&&p.count>=2){const a=new b,d=new b;a.set(p.getX(0),p.getY(0),p.getZ(0)),g&&a.applyMatrix4(g);for(let y=1;y<p.count;y++){d.set(p.getX(y),p.getY(y),p.getZ(y)),g&&d.applyMatrix4(g);const z=d.clone().sub(a);if(z.lengthSq()>1e-12)return z.normalize();a.copy(d)}}const F=new b(1,0,0),M=new C().getNormalMatrix(e.matrixWorld);return F.applyMatrix3(M).normalize()}return null}catch{return null}}c(ct,"getElementDirection");function ht(t,e){try{if(!e)return null;const n=e.geometry;if(n){if(typeof e.getWorldPosition=="function"){const s=n.attributes&&n.attributes.position?n.attributes.position.array:null;if(s&&s.length>=3){let r=0,f=0,x=0,o=0;const l=new b;e.updateMatrixWorld(!0);for(let g=0;g<s.length;g+=3)l.set(s[g],s[g+1],s[g+2]).applyMatrix4(e.matrixWorld),r+=l.x,f+=l.y,x+=l.z,o++;if(o>0)return new b(r/o,f/o,x/o)}}n.computeBoundingBox?.();const i=n.boundingBox;if(i)return i.getCenter(new b).applyMatrix4(e.matrixWorld)}return e.getWorldPosition(new b)}catch{return null}}c(ht,"objectRepresentativePoint");export{at as a,gt as b,ct as c,pt as d,ft as e,ut as f,D as g,tt as h,V as i,lt as j,dt as m,ht as o,st as s};
1
+ var U=Object.defineProperty;var c=(t,e)=>U(t,"name",{value:e,configurable:!0});import{d as R,L as Y,e as H,b8 as B,s as k,f as G,V as b,Q as I,u as Z,a1 as J,m as C,M as T,b as E}from"./featureDialogs-CnBa1DyN.js";const S=Object.freeze({lineColor:9684477,dotColor:9684477,arrowColor:9684477,arrowLengthPx:12,arrowWidthPx:4,leaderDotRadiusPx:6,noteDotRadius:.08,noteDotColor:9684477});let A={...S};function D(){return A}c(D,"getPMIStyle");function st(t={}){return!t||typeof t!="object"||(A={...A,...t}),A}c(st,"setPMIStyle");function at(t={}){const e={...S},n=c((i,s)=>{const r=t[i];if(Number.isFinite(r))e[i]=r;else if(typeof r=="string"&&i.toLowerCase().includes("color")){const f=parseInt(r.replace("#",""),16);Number.isFinite(f)&&(e[i]=f)}else r!=null&&(e[i]=s)},"assign");return n("lineColor",S.lineColor),n("dotColor",S.dotColor),n("arrowColor",S.arrowColor),n("arrowLengthPx",S.arrowLengthPx),n("arrowWidthPx",S.arrowWidthPx),n("leaderDotRadiusPx",S.leaderDotRadiusPx),n("lineWidth",S.lineWidth||1),n("noteDotRadius",S.noteDotRadius),n("noteDotColor",S.noteDotColor),e}c(at,"sanitizePMIStyle");function q(t){try{return JSON.parse(JSON.stringify(t))}catch{return{}}}c(q,"safeCloneJSON");function X(t){return t?t.isPerspectiveCamera?"PerspectiveCamera":t.isOrthographicCamera?"OrthographicCamera":"Camera":"Camera"}c(X,"resolveCameraType");function W(t){if(!t)return null;if(Array.isArray(t)&&t.length===3)return[Number(t[0])||0,Number(t[1])||0,Number(t[2])||0];if(typeof t=="object"){const{x:e,y:n,z:i}=t;if([e,n,i].every(s=>Number.isFinite(s)))return[e,n,i]}return null}c(W,"extractVector3");function _(t){if(!t||typeof t!="object")return null;const e=Number(t.width),n=Number(t.height);return!(e>0)||!(n>0)?null:{width:e,height:n}}c(_,"normalizeViewportMetrics");function Q(t,e,n,i,s){if(!e)return;const r=i?.controlsState;if(r&&typeof e.setStateFromJSON=="function"){const x=Array.isArray(r.target)?r.target:n,o={arcballState:{target:Array.isArray(x)?x:[t.target?.x||0,t.target?.y||0,t.target?.z||0],cameraMatrix:{elements:Array.isArray(r.cameraMatrix)&&r.cameraMatrix.length===16?r.cameraMatrix:Array.from(t.matrix.elements)},cameraUp:r.cameraUp||{x:t.up.x,y:t.up.y,z:t.up.z},cameraNear:Number.isFinite(r.cameraNear)?r.cameraNear:t.near,cameraFar:Number.isFinite(r.cameraFar)?r.cameraFar:t.far,cameraZoom:Number.isFinite(r.cameraZoom)?r.cameraZoom:t.zoom,gizmoMatrix:{elements:Array.isArray(r.gizmoMatrix)&&r.gizmoMatrix.length===16?r.gizmoMatrix:Array.from((e._gizmos?.matrix||new T).elements)}}},l=Number.isFinite(r.cameraFov)?r.cameraFov:i?.projection?.fov;t.isPerspectiveCamera&&Number.isFinite(l)&&(o.arcballState.cameraFov=l);try{e.setStateFromJSON(JSON.stringify(o))}catch(g){console.warn("ArcballControls setStateFromJSON failed; falling back to manual sync",g),L(t,e,n,i),O(e,s);return}O(e,s);return}L(t,e,n,i),O(e,s)}c(Q,"syncArcballControls");function L(t,e,n,i){const s=Array.isArray(n)&&n.length===3?n:e.target?[e.target.x,e.target.y,e.target.z]:[0,0,0],r=new b(s[0],s[1],s[2]);try{typeof e.setTarget=="function"?e.setTarget(r.x,r.y,r.z):e.target?.set?e.target.set(r.x,r.y,r.z):e.target&&(e.target.x=r.x,e.target.y=r.y,e.target.z=r.z)}catch{}try{e._currentTarget?.copy&&e._currentTarget.copy(r),e._target0?.copy&&e._target0.copy(r)}catch{}const f=e._gizmos;if(f){try{f.position.copy(r),f.updateMatrix(),f.updateMatrixWorld(!0)}catch{}if(typeof e.calculateTbRadius=="function")try{e._tbRadius=e.calculateTbRadius(t)}catch{}if(typeof e.makeGizmos=="function")try{e.makeGizmos(r,e._tbRadius||1)}catch{}}try{e._cameraMatrixState?.copy?.(t.matrix),e._cameraMatrixState0?.copy?.(t.matrix),f?.matrix&&(e._gizmoMatrixState?.copy?.(f.matrix),e._gizmoMatrixState0?.copy?.(f.matrix)),e._cameraProjectionState?.copy?.(t.projectionMatrix),typeof e._zoomState=="number"&&(e._zoomState=t.zoom),typeof e._zoom0=="number"&&(e._zoom0=t.zoom),typeof e._fovState=="number"&&Number.isFinite(i?.projection?.fov??t.fov)&&(e._fovState=i?.projection?.fov??t.fov),typeof e._fov0=="number"&&Number.isFinite(i?.projection?.fov??t.fov)&&(e._fov0=i?.projection?.fov??t.fov),typeof e._nearPos=="number"&&(e._nearPos=Number.isFinite(i?.near)?i.near:t.near),typeof e._farPos=="number"&&(e._farPos=Number.isFinite(i?.far)?i.far:t.far),e._up0?.copy?.(t.up)}catch{}try{typeof e.updateTbState=="function"&&e.STATE?.IDLE?e.updateTbState(e.STATE.IDLE,!1):"_state"in e&&e.STATE?.IDLE&&(e._state=e.STATE.IDLE)}catch{}}c(L,"manualArcballSync");function O(t,e){try{if(typeof t._animationId=="number"&&t._animationId!==-1){const n=typeof cancelAnimationFrame=="function"?cancelAnimationFrame:typeof window<"u"&&typeof window.cancelAnimationFrame=="function"?window.cancelAnimationFrame.bind(window):null;n&&n(t._animationId)}t._animationId=-1,typeof t._timeStart=="number"&&(t._timeStart=-1)}catch{}try{t.updateMatrixState?.()}catch{}if(e)try{t.update?.()}catch{}}c(O,"finalizeArcballSync");function K(t){if(!t)return null;if(t.isPerspectiveCamera){const e=t.view&&t.view.enabled?{enabled:!0,fullWidth:t.view.fullWidth,fullHeight:t.view.fullHeight,offsetX:t.view.offsetX,offsetY:t.view.offsetY,width:t.view.width,height:t.view.height}:{enabled:!1};return{kind:"perspective",aspect:Number.isFinite(t.aspect)&&t.aspect>0?t.aspect:void 0,fov:t.fov,near:t.near,far:t.far,zoom:t.zoom??1,filmGauge:t.filmGauge??35,filmOffset:t.filmOffset??0,view:e}}if(t.isOrthographicCamera){const e=t.view&&t.view.enabled?{enabled:!0,fullWidth:t.view.fullWidth,fullHeight:t.view.fullHeight,offsetX:t.view.offsetX,offsetY:t.view.offsetY,width:t.view.width,height:t.view.height}:{enabled:!1};return{kind:"orthographic",aspect:Number.isFinite(t.top-t.bottom)&&Math.abs(t.top-t.bottom)>1e-9?(t.right-t.left)/(t.top-t.bottom):void 0,left:t.left,right:t.right,top:t.top,bottom:t.bottom,near:t.near,far:t.far,zoom:t.zoom??1,view:e}}return{kind:"generic",near:t.near??.1,far:t.far??2e3}}c(K,"captureProjection");function $(t,e=null,n=null,i=null){try{if(!t?.isPerspectiveCamera)return;const s=_(n);if(!s)return;const r=s.width/s.height;if(!(r>1e-9))return;t.aspect=r;const f=_(i),x=f?f.width/f.height:Number.isFinite(e?.aspect)&&e.aspect>1e-9?e.aspect:null;if(!(x>1e-9)||r>=x)return;const o=Number.isFinite(e?.fov)?e.fov:t.fov,l=Number.isFinite(e?.zoom)&&e.zoom>0?e.zoom:Number.isFinite(t.zoom)&&t.zoom>0?t.zoom:1;if(!(o>0)||o>=179)return;const m=Math.tan(E.degToRad(o)*.5)/l*x/r;if(!(m>0))return;const w=E.radToDeg(2*Math.atan(m*l));Number.isFinite(w)&&w>o&&(t.fov=Math.min(179,w))}catch{}}c($,"fitPerspectiveProjection");function j(t,e,n=null){if(!(!t||!e)){if(t.isPerspectiveCamera&&e.kind==="perspective"){Number.isFinite(e.fov)&&(t.fov=e.fov),Number.isFinite(e.near)&&(t.near=e.near),Number.isFinite(e.far)&&(t.far=e.far),Number.isFinite(e.zoom)&&(t.zoom=e.zoom),Number.isFinite(e.filmGauge)&&(t.filmGauge=e.filmGauge),Number.isFinite(e.filmOffset)&&(t.filmOffset=e.filmOffset),n!=null&&Number.isFinite(n)&&(t.aspect=n),e.view&&e.view.enabled&&t.setViewOffset?t.setViewOffset(e.view.fullWidth,e.view.fullHeight,e.view.offsetX,e.view.offsetY,e.view.width,e.view.height):t.clearViewOffset&&t.clearViewOffset();return}if(t.isOrthographicCamera&&e.kind==="orthographic"){const i=["left","right","top","bottom","near","far","zoom"];for(const s of i)Number.isFinite(e[s])&&(t[s]=e[s]);e.view&&e.view.enabled&&t.setViewOffset?t.setViewOffset(e.view.fullWidth,e.view.fullHeight,e.view.offsetX,e.view.offsetY,e.view.width,e.view.height):t.clearViewOffset&&t.clearViewOffset();return}Number.isFinite(e.near)&&(t.near=e.near),Number.isFinite(e.far)&&(t.far=e.far),Number.isFinite(e.zoom)&&(t.zoom=e.zoom)}}c(j,"applyProjection");function ft(t,{controls:e=null,viewport:n=null}={}){if(!t||!t.isCamera)return null;try{t.updateMatrixWorld(!0)}catch{}const i={version:3,type:X(t),worldMatrix:t.matrixWorld?.toArray?.()??null,projection:K(t),position:{x:t.position.x,y:t.position.y,z:t.position.z},quaternion:{x:t.quaternion.x,y:t.quaternion.y,z:t.quaternion.z,w:t.quaternion.w},up:{x:t.up.x,y:t.up.y,z:t.up.z},zoom:Number.isFinite(t.zoom)?t.zoom:1,near:Number.isFinite(t.near)?t.near:void 0,far:Number.isFinite(t.far)?t.far:void 0};if(t.layers?.mask!==void 0&&(i.layers=t.layers.mask),e?.target&&typeof e.target=="object"){i.target={x:e.target.x,y:e.target.y,z:e.target.z};try{const r=e._gizmos?.matrix;r&&(i.controlsState={target:[e.target.x,e.target.y,e.target.z],cameraMatrix:Array.from(t.matrix.elements),cameraUp:{x:t.up.x,y:t.up.y,z:t.up.z},cameraNear:t.near,cameraFar:t.far,cameraZoom:t.zoom,cameraFov:t.isPerspectiveCamera?t.fov:void 0,gizmoMatrix:Array.from(r.elements)})}catch{}}!i.target&&t.target&&typeof t.target=="object"&&(i.target={x:t.target.x,y:t.target.y,z:t.target.z}),t.userData&&typeof t.userData=="object"&&(i.userData=q(t.userData));const s=_(n);return s&&(i.viewport=s),i}c(ft,"captureCameraSnapshot");function ut(t,e,{controls:n=null,respectParent:i=!0,strictType:s=!1,overrideAspect:r=null,syncControls:f=!0,viewport:x=null}={}){if(!t||!t.isCamera||!e)return!1;let o=e;if(typeof o=="string")try{o=JSON.parse(o)}catch{return!1}if(!o||typeof o!="object")return!1;const l=o.type||null;if(s&&l){const p=X(t);if(l!==p)return!1}try{j(t,o.projection,r)}catch{}$(t,o?.projection,x,o?.viewport||null),tt(t,o?.projection,x),typeof o.layers=="number"&&t.layers&&(t.layers.mask=o.layers);const g=W(o.up)||W(o.upVector);g&&t.up.set(g[0],g[1],g[2]),o.userData&&typeof o.userData=="object"&&(t.userData=q(o.userData));let u=!1,m=!1;const w=Array.isArray(o.worldMatrix)&&o.worldMatrix.length===16?o.worldMatrix:null;if(w)try{const p=new T().fromArray(w),F=t.parent||null,M=new b,a=new I,d=new b;if(i&&F){F.updateMatrixWorld?.(!0);const z=new T().copy(F.matrixWorld).invert();new T().multiplyMatrices(z,p).decompose(M,a,d)}else p.decompose(M,a,d);const y=t.matrixAutoUpdate;t.matrixAutoUpdate=!1,t.position.copy(M),t.quaternion.copy(a),t.scale.copy(d),t.updateMatrix(),t.updateMatrixWorld(!0),t.matrixAutoUpdate=y,u=!0,m=!0}catch{u=!1}if(!u){const p=W(o.position);let F=!1;p&&(t.position.set(p[0],p[1],p[2]),F=!0);const M=o.quaternion;if(M&&typeof M=="object"){const{x:a,y:d,z:y,w:z}=M;[a,d,y,z].every(N=>Number.isFinite(N))&&(t.quaternion.set(a,d,y,z),F=!0)}Number.isFinite(o.zoom)&&(t.zoom=o.zoom,F=!0),Number.isFinite(o.near)&&(t.near=o.near,F=!0),Number.isFinite(o.far)&&(t.far=o.far,F=!0),F&&(t.updateMatrixWorld?.(!0),m=!0)}if(!m){try{t.updateProjectionMatrix?.()}catch{}if(n){try{n.update?.()}catch{}try{n.updateMatrixState?.()}catch{}}return!1}try{t.updateProjectionMatrix?.()}catch{}const v=o.target||o.controlsTarget,h=W(v);return n?Q(t,n,h,o,f):h&&t.target&&typeof t.target.set=="function"&&t.target.set(h[0],h[1],h[2]),!0}c(ut,"applyCameraSnapshot");function tt(t,e=null,n=null){try{if(!t?.isOrthographicCamera)return;const i=e||{},s=Number.isFinite(i.top)?i.top:t.top,r=Number.isFinite(i.bottom)?i.bottom:t.bottom,f=Number.isFinite(i.left)?i.left:t.left,x=Number.isFinite(i.right)?i.right:t.right,o=Number.isFinite(s)&&Number.isFinite(r)?s-r:t.top-t.bottom,l=Number.isFinite(f)&&Number.isFinite(x)?x-f:t.right-t.left;if(!Number.isFinite(o)||Math.abs(o)<1e-9||!Number.isFinite(l)||Math.abs(l)<1e-9)return;const g=Number.isFinite(s)&&Number.isFinite(r)?(s+r)*.5:(t.top+t.bottom)*.5,u=Number.isFinite(f)&&Number.isFinite(x)?(f+x)*.5:(t.left+t.right)*.5,m=_(n);let w=m?m.width/m.height:null;w>1e-9||(w=Number.isFinite(i.aspect)&&i.aspect>1e-9?i.aspect:l/o),(!Number.isFinite(w)||w<=1e-9)&&(w=1);const v=Math.abs(o)*.5,h=Math.abs(l)*.5,p=Math.max(h,v*w),F=Math.max(v,h/w),M=o>=0?1:-1;t.top=g+F*M,t.bottom=g-F*M,t.left=u-p,t.right=u+p,t.updateProjectionMatrix()}catch{}}c(tt,"adjustOrthographicFrustum");function V(t,e,n=void 0){const i=D(),s=n??i.lineColor??9684477,r=new R().setFromPoints([t.clone(),e.clone()]),f=new Y({color:s,linewidth:i.lineWidth||1});return f.depthTest=!1,f.depthWrite=!1,f.transparent=!0,new H(r,f)}c(V,"makeOverlayLine");function lt(t,e,n=void 0,i={}){const s=D(),{viewer:r=null,dashPixels:f=10,gapPixels:x=10}=i||{},o=t.distanceTo(e);if(!(o>1e-6))return V(t,e,n??s.lineColor??9684477);const l=e.clone().sub(t).normalize(),g=t.clone().add(e).multiplyScalar(.5),u=et(r,g),m=it(u*f,o),w=nt(u*x,o),v=[];let h=0,p=t.clone();for(;h<o-1e-6;){const d=Math.min(m,o-h),y=p.clone().addScaledVector(l,d);if(v.push(p.clone(),y.clone()),h+=d,h>=o)break;const z=Math.min(w,o-h);p=y.clone().addScaledVector(l,z),h+=z}if(v.length<2)return V(t,e,n??s.lineColor??9684477);const F=new R().setFromPoints(v),M=new Y({color:n??s.lineColor??9684477,linewidth:s.lineWidth||1});M.depthTest=!1,M.depthWrite=!1,M.transparent=!0;const a=new J(F,M);return a.renderOrder=9994,a}c(lt,"makeOverlayDashedLine");function et(t,e){try{const n=t?.camera,i=t?.renderer;if(!n||!i)return .01;const s=i.domElement,r=Math.max(1,s?.clientHeight||s?.height||600);if(n.isOrthographicCamera)return(n.top-n.bottom)/Math.max(1e-6,n.zoom||1)/r;const f=n.getWorldPosition(new b),x=e?e.clone():n.getWorldDirection(new b).add(f),o=f.distanceTo(x),l=(n.fov||50)*Math.PI/180;return 2*Math.tan(l/2)*o/r}catch{return .01}}c(et,"worldUnitsPerPixelAtPoint");function it(t,e){if(!Number.isFinite(t)||t<=0)return e*.25;const n=Math.max(1e-4,e*.5);return Math.max(1e-4,Math.min(t,n))}c(it,"clampDashLength");function nt(t,e){if(!Number.isFinite(t)||t<0)return e*.25;const n=Math.max(1e-4,e*.5);return Math.max(1e-4,Math.min(t,n))}c(nt,"clampGapLength");function dt(t,e=void 0){const n=D(),i=e??n.dotColor??16777215,s=new Z(t,12,8),r=new k({color:i});return r.depthTest=!1,r.depthWrite=!1,r.transparent=!0,new G(s,r)}c(dt,"makeOverlaySphere");function pt(t,e,n,i,s,r){try{const f=D(),x=new B(s,i,8),o=new k({color:r??f.arrowColor??9684477,depthTest:!1,depthWrite:!1,transparent:!0}),l=new G(x,o),g=e.clone().addScaledVector(n,-i*.5);l.position.copy(g);const u=new b(0,1,0),m=new I;return m.setFromUnitVectors(u,n.clone().normalize()),l.setRotationFromQuaternion(m),l.renderOrder=9996,t.add(l),l}catch{return null}}c(pt,"addArrowCone");function gt(t,e=1){try{const n=t?.renderer?.domElement?.getBoundingClientRect?.()||{width:800,height:600},i=t?.camera,s=Math.max(1,n.height||600);if(i&&i.isOrthographicCamera){const f=(i.top-i.bottom)/Math.max(1e-6,i.zoom||1)/s;return Math.max(1e-4,f*(e||1))}if(i&&i.isPerspectiveCamera){const r=(i.fov||50)*Math.PI/180,f=i.position.length(),o=2*Math.tan(r/2)*f/s;return Math.max(1e-4,o*(e||1))}return .01*(e||1)}catch{return .01*(e||1)}}c(gt,"screenSizeWorld");function ct(t,e){try{if(!e)return null;const n=e.userData||{},i=String(e.type||"").toUpperCase(),s=String(n.type||n.brepType||"").toUpperCase(),f=i==="FACE"||i==="PLANE"||!(i==="FACE"||i==="EDGE"||i==="PLANE")&&(s==="FACE"||s==="PLANE"),x=i==="EDGE"||!f&&(s==="EDGE"||e.isLine||e.isLine2||e.isLineSegments||e.isLineLoop);if(f){if(typeof e.getAverageNormal=="function"){const u=e.getAverageNormal();e.updateMatrixWorld(!0);const m=new C().getNormalMatrix(e.matrixWorld);return u.applyMatrix3(m).normalize()}const o=e.geometry;if(o){if(o.attributes&&o.attributes.normal){const u=o.attributes.normal.array;if(u.length>=3){const m=new b,w=u.length/3;for(let h=0;h<w;h++){const p=h*3;m.add(new b(u[p],u[p+1],u[p+2]))}m.divideScalar(w),e.updateMatrixWorld(!0);const v=new C().getNormalMatrix(e.matrixWorld);return m.applyMatrix3(v).normalize()}}if(o.attributes&&o.attributes.position){const u=o.attributes.position.array;if(u.length>=9){const m=new b;let w=0;const v=new b,h=new b,p=new b;e.updateMatrixWorld(!0);const F=Math.min(5,Math.floor(u.length/9));for(let M=0;M<F;M++){const a=M*9;if(a+8<u.length){v.set(u[a],u[a+1],u[a+2]).applyMatrix4(e.matrixWorld),h.set(u[a+3],u[a+4],u[a+5]).applyMatrix4(e.matrixWorld),p.set(u[a+6],u[a+7],u[a+8]).applyMatrix4(e.matrixWorld);const d=h.clone().sub(v).cross(p.clone().sub(v));d.lengthSq()>1e-10&&(d.normalize(),m.add(d),w++)}}if(w>0)return m.divideScalar(w).normalize()}}}const l=new b(0,0,1);e.updateMatrixWorld(!0);const g=new C().getNormalMatrix(e.matrixWorld);return l.applyMatrix3(g).normalize()}else if(x){const l=e.geometry;e.updateMatrixWorld(!0);const g=e.matrixWorld,u=c((a,d=!1)=>{if(!a)return null;let y=null;if(Array.isArray(a)&&a.length>=3)y=new b(a[0],a[1],a[2]);else if(typeof a=="object"){const z=Number(a.x),N=Number(a.y),P=Number(a.z);Number.isFinite(z)&&Number.isFinite(N)&&Number.isFinite(P)&&(y=new b(z,N,P))}return y?(d&&g&&y.applyMatrix4(g),y):null},"parsePoint"),m=c((a,d=!1)=>{if(!Array.isArray(a)||a.length<2)return null;let y=u(a[0],d);for(let z=1;z<a.length;z++){const N=u(a[z],d);if(!y||!N){y=N||y;continue}const P=N.clone().sub(y);if(P.lengthSq()>1e-12)return P.normalize();y=N}return null},"directionFromPointList");try{if(typeof e.points=="function"){const a=e.points(!0),d=m(a,!1);if(d)return d}}catch{}const w=Array.isArray(e?.userData?.polylineLocal)?e.userData.polylineLocal:null;if(w){const a=m(w,!0);if(a)return a}const v=l?.attributes?.instanceStart,h=l?.attributes?.instanceEnd;if(v&&h){const a=Math.min(v.count||0,h.count||0);for(let d=0;d<a;d++){const y=new b(v.getX(d),v.getY(d),v.getZ(d)),z=new b(h.getX(d),h.getY(d),h.getZ(d));g&&(y.applyMatrix4(g),z.applyMatrix4(g));const N=z.sub(y);if(N.lengthSq()>1e-12)return N.normalize()}}const p=l?.getAttribute?.("position");if(p&&p.itemSize===3&&p.count>=2){const a=new b,d=new b;a.set(p.getX(0),p.getY(0),p.getZ(0)),g&&a.applyMatrix4(g);for(let y=1;y<p.count;y++){d.set(p.getX(y),p.getY(y),p.getZ(y)),g&&d.applyMatrix4(g);const z=d.clone().sub(a);if(z.lengthSq()>1e-12)return z.normalize();a.copy(d)}}const F=new b(1,0,0),M=new C().getNormalMatrix(e.matrixWorld);return F.applyMatrix3(M).normalize()}return null}catch{return null}}c(ct,"getElementDirection");function ht(t,e){try{if(!e)return null;const n=e.geometry;if(n){if(typeof e.getWorldPosition=="function"){const s=n.attributes&&n.attributes.position?n.attributes.position.array:null;if(s&&s.length>=3){let r=0,f=0,x=0,o=0;const l=new b;e.updateMatrixWorld(!0);for(let g=0;g<s.length;g+=3)l.set(s[g],s[g+1],s[g+2]).applyMatrix4(e.matrixWorld),r+=l.x,f+=l.y,x+=l.z,o++;if(o>0)return new b(r/o,f/o,x/o)}}n.computeBoundingBox?.();const i=n.boundingBox;if(i)return i.getCenter(new b).applyMatrix4(e.matrixWorld)}return e.getWorldPosition(new b)}catch{return null}}c(ht,"objectRepresentativePoint");export{at as a,gt as b,ct as c,pt as d,ft as e,ut as f,D as g,tt as h,V as i,lt as j,dt as m,ht as o,st as s};
@@ -1,2 +1,2 @@
1
- var E=Object.defineProperty;var o=(e,t)=>E(e,"name",{value:t,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{BREP as i}from"./brep-kernel-QpBwDdca.js";import"./preload-helper-ZNr0Qq7Q.js";const m=document.getElementById("status"),b=document.getElementById("log"),f=document.getElementById("btn-run"),c=o((e,t)=>{m.textContent=e,m.className=`status ${t}`},"setStatus"),g=o(e=>Number(e).toFixed(6),"fmt"),u=o((...e)=>{const t=e.map(r=>typeof r=="string"?r:JSON.stringify(r)).join(" ");b.textContent+=`${t}
1
+ var E=Object.defineProperty;var o=(e,t)=>E(e,"name",{value:t,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{BREP as i}from"./brep-kernel-BaJWJnmy.js";import"./preload-helper-ZNr0Qq7Q.js";const m=document.getElementById("status"),b=document.getElementById("log"),f=document.getElementById("btn-run"),c=o((e,t)=>{m.textContent=e,m.className=`status ${t}`},"setStatus"),g=o(e=>Number(e).toFixed(6),"fmt"),u=o((...e)=>{const t=e.map(r=>typeof r=="string"?r:JSON.stringify(r)).join(" ");b.textContent+=`${t}
2
2
  `,console.log(...e)},"write"),s=o(e=>({volume:e.volume(),surfaceArea:e.surfaceArea(),triangles:e.getTriangleCount()}),"summarize"),d=o(()=>{b.textContent="",c("Running...","pending");const e=new i.Cube({x:2.2,y:2.2,z:2.2,name:"Cube"}),t=new i.Sphere({r:1.35,resolution:40,name:"Sphere"}),r=e.union(t),h=e.subtract(t),p=e.intersect(t),n={cube:s(e),sphere:s(t),union:s(r),subtract:s(h),intersect:s(p)};u("--- Boolean Results ---");for(const[v,l]of Object.entries(n))u(`${v.padEnd(10)} volume=${g(l.volume)} area=${g(l.surfaceArea)} triangles=${l.triangles}`);const a=1e-6;if(n.union.volume+a<Math.max(n.cube.volume,n.sphere.volume))throw new Error("Union volume is unexpectedly smaller than both source solids.");if(n.intersect.volume-a>Math.min(n.cube.volume,n.sphere.volume))throw new Error("Intersection volume is unexpectedly larger than a source solid.");if(n.subtract.volume-a>n.cube.volume)throw new Error("Subtract volume is unexpectedly larger than the original cube.");c("Completed","ok")},"runExample");f.addEventListener("click",()=>{try{d()}catch(e){console.error(e),u("ERROR:",e?.stack||e?.message||String(e)),c("Failed","err")}});try{d()}catch(e){console.error(e),u("ERROR:",e?.stack||e?.message||String(e)),c("Failed","err")}
@@ -1,4 +1,4 @@
1
- var g=Object.defineProperty;var r=(t,n)=>g(t,"name",{value:n,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{BREP as c}from"./brep-kernel-QpBwDdca.js";import"./preload-helper-ZNr0Qq7Q.js";const l=document.getElementById("status"),d=document.getElementById("log"),p=document.getElementById("btn-run"),s=r((t,n)=>{l.textContent=t,l.className=`status ${n}`},"setStatus"),e=r((...t)=>{const n=t.map(o=>typeof o=="string"?o:JSON.stringify(o)).join(" ");d.textContent+=`${n}
1
+ var g=Object.defineProperty;var r=(t,n)=>g(t,"name",{value:n,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{BREP as c}from"./brep-kernel-BaJWJnmy.js";import"./preload-helper-ZNr0Qq7Q.js";const l=document.getElementById("status"),d=document.getElementById("log"),p=document.getElementById("btn-run"),s=r((t,n)=>{l.textContent=t,l.className=`status ${n}`},"setStatus"),e=r((...t)=>{const n=t.map(o=>typeof o=="string"?o:JSON.stringify(o)).join(" ");d.textContent+=`${n}
2
2
  `,console.log(...t)},"write"),u=r((t,n=8)=>t.split(`
3
3
  `).slice(0,n).join(`
4
4
  `),"firstLines"),m=r(()=>{d.textContent="",s("Running...","pending");const t=new c.Cylinder({radius:1,height:3,resolution:48,name:"Shaft"}).bakeTRS({position:[0,0,.6],rotationEuler:[90,0,0],scale:[1,1,1]}),n=new c.Cone({radius:1.55,height:1.6,resolution:48,name:"Head"}).bakeTRS({position:[0,1.65,.6],rotationEuler:[-90,0,0],scale:[1,1,1]}),o=t.union(n),i=o.toSTL("api_example_part",4),a=o.toSTEP("api_example_part",{precision:4});if(e("--- Export Summary ---"),e("Volume:",o.volume()),e("Surface area:",o.surfaceArea()),e("Triangles:",o.getTriangleCount()),e("STL characters:",i.length),e("STEP characters:",a.length),e(""),e("--- STL Preview ---"),e(u(i)),e(""),e("--- STEP Preview ---"),e(u(a)),!i.startsWith("solid"))throw new Error('STL output did not start with "solid".');if(!a.includes("ISO-10303-21"))throw new Error("STEP output did not contain expected ISO header.");s("Completed","ok")},"runExample");p.addEventListener("click",()=>{try{m()}catch(t){console.error(t),e("ERROR:",t?.stack||t?.message||String(t)),s("Failed","err")}});try{m()}catch(t){console.error(t),e("ERROR:",t?.stack||t?.message||String(t)),s("Failed","err")}
@@ -1,2 +1,2 @@
1
- var g=Object.defineProperty;var n=(e,t)=>g(e,"name",{value:t,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{BREP as o}from"./brep-kernel-QpBwDdca.js";import"./preload-helper-ZNr0Qq7Q.js";const m=document.getElementById("status"),u=document.getElementById("log"),y=document.getElementById("btn-run"),s=n((e,t)=>{m.textContent=e,m.className=`status ${t}`},"setStatus"),l=n(e=>Number(e).toFixed(6),"fmt"),a=n((...e)=>{const t=e.map(r=>typeof r=="string"?r:JSON.stringify(r)).join(" ");u.textContent+=`${t}
1
+ var g=Object.defineProperty;var n=(e,t)=>g(e,"name",{value:t,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{BREP as o}from"./brep-kernel-BaJWJnmy.js";import"./preload-helper-ZNr0Qq7Q.js";const m=document.getElementById("status"),u=document.getElementById("log"),y=document.getElementById("btn-run"),s=n((e,t)=>{m.textContent=e,m.className=`status ${t}`},"setStatus"),l=n(e=>Number(e).toFixed(6),"fmt"),a=n((...e)=>{const t=e.map(r=>typeof r=="string"?r:JSON.stringify(r)).join(" ");u.textContent+=`${t}
2
2
  `,console.log(...e)},"write"),C=n(e=>({volume:e.volume(),area:e.surfaceArea(),triangles:e.getTriangleCount()}),"summarize"),c=n(()=>{u.textContent="",s("Running...","pending");const e=[["Cube",()=>new o.Cube({x:2,y:3,z:4,name:"Cube"})],["Sphere",()=>new o.Sphere({r:1.2,resolution:32,name:"Sphere"})],["Cylinder",()=>new o.Cylinder({radius:1,height:2.4,resolution:48,name:"Cylinder"})],["Cone",()=>new o.Cone({radius:1.1,height:2.1,resolution:48,name:"Cone"})],["Torus",()=>new o.Torus({mR:2,tR:.55,resolution:64,name:"Torus"})],["Pyramid",()=>new o.Pyramid({bL:2,s:4,h:2.7,name:"Pyramid"})]];a("--- Primitive Summary ---");for(const[t,r]of e){const d=r(),i=C(d);a(`${t.padEnd(10)} volume=${l(i.volume)} area=${l(i.area)} triangles=${i.triangles}`)}s("Completed","ok")},"runExample");y.addEventListener("click",()=>{try{c()}catch(e){console.error(e),a("ERROR:",e?.stack||e?.message||String(e)),s("Failed","err")}});try{c()}catch(e){console.error(e),a("ERROR:",e?.stack||e?.message||String(e)),s("Failed","err")}
@@ -1,2 +1,2 @@
1
- var u=Object.defineProperty;var n=(e,t)=>u(e,"name",{value:t,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{BREP as g}from"./brep-kernel-QpBwDdca.js";import"./preload-helper-ZNr0Qq7Q.js";const c=document.getElementById("status"),l=document.getElementById("log"),b=document.getElementById("btn-run"),s=n((e,t)=>{c.textContent=e,c.className=`status ${t}`},"setStatus"),i=n(e=>Number(e).toFixed(6),"fmt"),m=n((...e)=>{const t=e.map(o=>typeof o=="string"?o:JSON.stringify(o)).join(" ");l.textContent+=`${t}
1
+ var u=Object.defineProperty;var n=(e,t)=>u(e,"name",{value:t,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{BREP as g}from"./brep-kernel-BaJWJnmy.js";import"./preload-helper-ZNr0Qq7Q.js";const c=document.getElementById("status"),l=document.getElementById("log"),b=document.getElementById("btn-run"),s=n((e,t)=>{c.textContent=e,c.className=`status ${t}`},"setStatus"),i=n(e=>Number(e).toFixed(6),"fmt"),m=n((...e)=>{const t=e.map(o=>typeof o=="string"?o:JSON.stringify(o)).join(" ");l.textContent+=`${t}
2
2
  `,console.log(...e)},"write"),r=n((e,t)=>{m(`${e.padEnd(16)} volume=${i(t.volume())} area=${i(t.surfaceArea())} triangles=${t.getTriangleCount()}`)},"describe"),d=n(()=>{l.textContent="",s("Running...","pending");const e=new g.Cube({x:2.2,y:1.4,z:1,name:"BaseCube"}),t=e.clone().bakeTRS({position:[2,.4,.3],rotationEuler:[0,35,20],scale:[1.1,.85,1.25]}),o=t.mirrorAcrossPlane([0,0,0],[1,0,0]),a=t.union(o);if(m("--- Transform Summary ---"),r("base",e),r("moved",t),r("mirrored",o),r("combined",a),a.volume()<=t.volume())throw new Error("Combined solid volume should be greater than a single moved solid.");s("Completed","ok")},"runExample");b.addEventListener("click",()=>{try{d()}catch(e){console.error(e),m("ERROR:",e?.stack||e?.message||String(e)),s("Failed","err")}});try{d()}catch(e){console.error(e),m("ERROR:",e?.stack||e?.message||String(e)),s("Failed","err")}
@@ -1,4 +1,4 @@
1
- var H=Object.defineProperty;var s=(e,o)=>H(e,"name",{value:o,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{Sketcher2DEmbed as J}from"./brep-kernel-QpBwDdca.js";import"./preload-helper-ZNr0Qq7Q.js";const k=document.getElementById("btn-create"),C=document.getElementById("btn-destroy"),I=document.getElementById("btn-apply-css"),w=document.getElementById("btn-apply-theme"),B=document.getElementById("btn-export-svg"),$=document.getElementById("btn-export-dxf"),r=document.getElementById("btn-download-dxf"),D=document.getElementById("btn-export-polylines"),F=document.getElementById("geometry-color"),L=document.getElementById("point-color"),N=document.getElementById("constraint-color"),G=document.getElementById("background-color"),T=document.getElementById("point-size-px"),A=document.getElementById("curve-thickness-px"),f=document.getElementById("sidebar-expanded"),u=document.getElementById("grid-visible"),V=document.getElementById("grid-spacing"),W=document.getElementById("curve-resolution"),R=document.getElementById("css-input"),Y=document.getElementById("sketch-status"),q=document.getElementById("sketch-host"),d=document.getElementById("event-output"),g=document.getElementById("svg-preview"),O=document.getElementById("path-output"),P=document.getElementById("dxf-output"),M=document.getElementById("polyline-output");let t=null,i=null,m=0,h=0,y=0,c=null;const K=6,n=s(e=>{Y.textContent=e},"setSketchStatus"),b=s(()=>{c&&(URL.revokeObjectURL(c),c=null)},"revokeDxfDownload"),Q=s(e=>{if(b(),typeof e!="string"||!e.length){r.disabled=!0;return}const o=new Blob([e],{type:"application/dxf"});c=URL.createObjectURL(o),r.disabled=!1},"setDxfDownload"),E=s(e=>{k.disabled=e,C.disabled=!e,I.disabled=!e,w.disabled=!e,B.disabled=!e,$.disabled=!e,D.disabled=!e,r.disabled=!e||!c},"setSketchButtons"),p=s((e,o=null)=>{const a=new Date().toLocaleTimeString(),X=o==null?`[${a}] ${e}`:`[${a}] ${e} ${JSON.stringify(o)}`,z=d.textContent==="(No sketch events yet)"?[]:d.textContent.split(`
1
+ var H=Object.defineProperty;var s=(e,o)=>H(e,"name",{value:o,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{Sketcher2DEmbed as J}from"./brep-kernel-BaJWJnmy.js";import"./preload-helper-ZNr0Qq7Q.js";const k=document.getElementById("btn-create"),C=document.getElementById("btn-destroy"),I=document.getElementById("btn-apply-css"),w=document.getElementById("btn-apply-theme"),B=document.getElementById("btn-export-svg"),$=document.getElementById("btn-export-dxf"),r=document.getElementById("btn-download-dxf"),D=document.getElementById("btn-export-polylines"),F=document.getElementById("geometry-color"),L=document.getElementById("point-color"),N=document.getElementById("constraint-color"),G=document.getElementById("background-color"),T=document.getElementById("point-size-px"),A=document.getElementById("curve-thickness-px"),f=document.getElementById("sidebar-expanded"),u=document.getElementById("grid-visible"),V=document.getElementById("grid-spacing"),W=document.getElementById("curve-resolution"),R=document.getElementById("css-input"),Y=document.getElementById("sketch-status"),q=document.getElementById("sketch-host"),d=document.getElementById("event-output"),g=document.getElementById("svg-preview"),O=document.getElementById("path-output"),P=document.getElementById("dxf-output"),M=document.getElementById("polyline-output");let t=null,i=null,m=0,h=0,y=0,c=null;const K=6,n=s(e=>{Y.textContent=e},"setSketchStatus"),b=s(()=>{c&&(URL.revokeObjectURL(c),c=null)},"revokeDxfDownload"),Q=s(e=>{if(b(),typeof e!="string"||!e.length){r.disabled=!0;return}const o=new Blob([e],{type:"application/dxf"});c=URL.createObjectURL(o),r.disabled=!1},"setDxfDownload"),E=s(e=>{k.disabled=e,C.disabled=!e,I.disabled=!e,w.disabled=!e,B.disabled=!e,$.disabled=!e,D.disabled=!e,r.disabled=!e||!c},"setSketchButtons"),p=s((e,o=null)=>{const a=new Date().toLocaleTimeString(),X=o==null?`[${a}] ${e}`:`[${a}] ${e} ${JSON.stringify(o)}`,z=d.textContent==="(No sketch events yet)"?[]:d.textContent.split(`
2
2
  `).filter(Boolean),S=[X,...z].slice(0,K);d.textContent=S.length?S.join(`
3
3
  `):"(No sketch events yet)"},"pushEvent"),U=s(()=>({geometryColor:F.value,pointColor:L.value,constraintColor:N.value,backgroundColor:G.value,pointSizePx:Math.max(1,Number(T.value)||10),curveThicknessPx:Math.max(.5,Number(A.value)||2)}),"currentTheme"),x=s(()=>{const e=Number(V.value);return Number.isFinite(e)&&e>0?e:1},"currentGridSpacing"),v=s(()=>{const e=Number(W.value);return Number.isFinite(e)?Math.max(3,Math.min(2048,Math.floor(e))):64},"currentCurveResolution"),Z=s(async()=>{t||(t=new J({cssText:R.value,...U(),sidebarExpanded:f.checked,gridVisible:u.checked,gridSpacing:x(),onChange:s(e=>{i=e,m+=1;const o=Array.isArray(e?.geometries)?e.geometries.length:0;n(`Sketch updated (${m}). Geometries: ${o}`),p("onChange",{geometries:o})},"onChange"),onFinished:s(e=>{i=e,h+=1;const o=Array.isArray(e?.geometries)?e.geometries.length:0;n(`Sketch finished (${h}). Geometries: ${o}`),p("onFinished",{geometries:o}),j().catch(a=>{console.error(a),n(`Failed to export SVG after Finish: ${a?.message||String(a)}`)})},"onFinished"),onCancelled:s(()=>{y+=1,n(`Sketch cancelled (${y}).`),p("onCancelled")},"onCancelled")}),await t.mount(q),i=await t.getSketch(),E(!0),n("Sketcher iframe mounted. Draw geometry and run any export action."))},"attachSketcher"),_=s(async()=>{t&&(await t.destroy(),t=null,i=null,m=0,h=0,y=0,E(!1),n("Sketcher destroyed."),d.textContent="(No sketch events yet)",g.innerHTML="",O.textContent="(No SVG exported yet)",P.textContent="(No DXF exported yet)",M.textContent="(No 3D polylines exported yet)",b())},"detachSketcher"),ee=s(async()=>{t&&(await t.setCss(R.value),n("Custom CSS applied to iframe."))},"applySketchCss"),l=s(async()=>{t&&(await t.setTheme(U()),await t.setSidebarExpanded(f.checked),typeof t.setGrid=="function"?await t.setGrid({visible:u.checked,spacing:x()}):(typeof t.setGridVisible=="function"&&await t.setGridVisible(u.checked),typeof t.setGridSpacing=="function"&&await t.setGridSpacing(x())),n("Theme + sidebar + grid state applied to iframe."))},"applySketchTheme"),j=s(async()=>{if(!t)return;const e=await t.exportSVG({flipY:!0,precision:3,stroke:"#111111",strokeWidth:1.5,fill:"none",padding:12,curveResolution:v()});i=await t.getSketch({preferCached:!0}),g.innerHTML=e.svg,O.textContent=e.paths.length?e.paths.map(o=>`id=${o.id} type=${o.type} d="${o.d}"`).join(`
4
4
  `):"(No sketch geometry to export)",n(`Exported ${e.paths.length} SVG paths.`),g.scrollIntoView({behavior:"smooth",block:"start"})},"exportSvg"),te=s(async()=>{if(!t)return;const e=await t.exportDXF({units:"mm",curveResolution:v(),includeConstruction:!1});P.textContent=e?.dxf||"(No DXF payload returned)",Q(e?.dxf||""),n(`Exported DXF with ${e?.polylines?.length||0} polylines.`)},"exportDxf"),ne=s(async()=>{if(!t)return;const e=await t.export3DPolylines({curveResolution:v(),includeConstruction:!1,origin:[0,0,0],xAxis:[1,0,0],yAxis:[0,1,0]});M.textContent=JSON.stringify(e,null,2),n(`Exported ${e?.polylines?.length||0} 3D polylines.`)},"export3DPolylines");k.addEventListener("click",()=>{Z().catch(e=>{console.error(e),n(`Failed to create sketcher: ${e?.message||String(e)}`)})});C.addEventListener("click",()=>{_().catch(e=>{console.error(e),n(`Failed to destroy sketcher: ${e?.message||String(e)}`)})});I.addEventListener("click",()=>{ee().catch(e=>{console.error(e),n(`Failed to apply CSS: ${e?.message||String(e)}`)})});w.addEventListener("click",()=>{l().catch(e=>{console.error(e),n(`Failed to apply theme: ${e?.message||String(e)}`)})});B.addEventListener("click",()=>{j().catch(e=>{console.error(e),n(`Failed to export SVG: ${e?.message||String(e)}`)})});$.addEventListener("click",()=>{te().catch(e=>{console.error(e),n(`Failed to export DXF: ${e?.message||String(e)}`)})});r.addEventListener("click",()=>{if(!c)return;const e=document.createElement("a");e.href=c,e.download="sketch-export.dxf",e.click()});D.addEventListener("click",()=>{ne().catch(e=>{console.error(e),n(`Failed to export 3D polylines: ${e?.message||String(e)}`)})});[F,L,N,G,T,A].forEach(e=>{e.addEventListener("input",()=>{t&&l().catch(o=>{console.error(o),n(`Failed to apply theme: ${o?.message||String(o)}`)})})});f.addEventListener("change",()=>{t&&l().catch(e=>{console.error(e),n(`Failed to apply sidebar state: ${e?.message||String(e)}`)})});u.addEventListener("change",()=>{t&&l().catch(e=>{console.error(e),n(`Failed to apply grid visibility: ${e?.message||String(e)}`)})});V.addEventListener("input",()=>{t&&l().catch(e=>{console.error(e),n(`Failed to apply grid spacing: ${e?.message||String(e)}`)})});window.addEventListener("beforeunload",()=>{t&&t.destroy().catch(()=>{}),b()});E(!1);i&&!Array.isArray(i?.geometries)&&console.warn("Unexpected sketch payload shape",i);
@@ -1,3 +1,3 @@
1
- var B=Object.defineProperty;var n=(t,o)=>B(t,"name",{value:o,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{CADEmbed as v}from"./brep-kernel-QpBwDdca.js";import"./preload-helper-ZNr0Qq7Q.js";const u=document.getElementById("btn-create"),y=document.getElementById("btn-destroy"),p=document.getElementById("btn-state"),g=document.getElementById("btn-history"),b=document.getElementById("btn-sample"),h=document.getElementById("btn-reset"),E=document.getElementById("btn-css"),S=document.getElementById("viewer-only"),i=document.getElementById("sidebar-expanded"),x=document.getElementById("model-path"),w=document.getElementById("model-source"),$=document.getElementById("model-repo"),k=document.getElementById("model-branch"),C=document.getElementById("css-input"),F=document.getElementById("cad-status"),H=document.getElementById("cad-host"),I=document.getElementById("state-output"),f=document.getElementById("history-output");let e=null;const D={features:[{type:"Primitive Cube",inputParams:{id:"sample_cube_1",sizeX:24,sizeY:18,sizeZ:14,transform:{position:[0,0,0],rotationEuler:[0,0,0],scale:[1,1,1]},boolean:{targets:[],operation:"NONE"}},persistentData:{},timestamp:null}],idCounter:1,expressions:`//Examples:
1
+ var B=Object.defineProperty;var n=(t,o)=>B(t,"name",{value:o,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{CADEmbed as v}from"./brep-kernel-BaJWJnmy.js";import"./preload-helper-ZNr0Qq7Q.js";const u=document.getElementById("btn-create"),y=document.getElementById("btn-destroy"),p=document.getElementById("btn-state"),g=document.getElementById("btn-history"),b=document.getElementById("btn-sample"),h=document.getElementById("btn-reset"),E=document.getElementById("btn-css"),S=document.getElementById("viewer-only"),i=document.getElementById("sidebar-expanded"),x=document.getElementById("model-path"),w=document.getElementById("model-source"),$=document.getElementById("model-repo"),k=document.getElementById("model-branch"),C=document.getElementById("css-input"),F=document.getElementById("cad-status"),H=document.getElementById("cad-host"),I=document.getElementById("state-output"),f=document.getElementById("history-output");let e=null;const D={features:[{type:"Primitive Cube",inputParams:{id:"sample_cube_1",sizeX:24,sizeY:18,sizeZ:14,transform:{position:[0,0,0],rotationEuler:[0,0,0],scale:[1,1,1]},boolean:{targets:[],operation:"NONE"}},persistentData:{},timestamp:null}],idCounter:1,expressions:`//Examples:
2
2
  x = 10 + 6;
3
3
  y = x * 2;`,pmiViews:[],metadata:{},assemblyConstraints:[],assemblyConstraintIdCounter:0},s=n(t=>{F.textContent=t},"setStatus"),r=n(t=>{u.disabled=t,y.disabled=!t,p.disabled=!t,g.disabled=!t,b.disabled=!t,h.disabled=!t,E.disabled=!t,S.disabled=t},"setButtons"),L=n(()=>{const t=String(x.value||"").trim();if(!t)return null;const o=String(w.value||"local").trim()||"local",a=String($.value||"").trim(),d=String(k.value||"").trim(),l={modelPath:t,source:o};return a&&(l.repoFull=a),d&&(l.branch=d),l},"currentModelRequest"),c=n((t,o="State updated")=>{I.textContent=JSON.stringify(t||{},null,2);const a=Number(t?.featureCount||0),d=t?.model?.name||"(unsaved/new)";s(`${o}. Features: ${a}. Model: ${d}`)},"renderState"),N=n(async()=>{if(e)return;const t=L();e=new v({mountTo:H,viewerOnlyMode:S.checked,sidebarExpanded:i.checked,cssText:C.value,initialModel:t,onReady:n(a=>{c(a,"CAD ready")},"onReady"),onHistoryChanged:n(a=>{c(a,`History changed (${a?.reason||"update"})`)},"onHistoryChanged")}),await e.mount(),r(!0);const o=await e.getState();c(o,"CAD iframe mounted")},"createCad"),O=n(async()=>{e&&(await e.destroy(),e=null,r(!1),s("CAD iframe destroyed."),I.textContent="(No state yet)",f.textContent="(No history exported yet)")},"destroyCad"),m=n(async()=>{if(!e)return;const t=await e.getState();c(t,"State fetched")},"refreshState"),A=n(async()=>{if(!e)return;const t=await e.getPartHistoryJSON();f.textContent=t||"(History is empty)",s(`History exported (${t?t.length:0} chars).`)},"exportHistory"),M=n(async()=>{e&&(await e.setPartHistory(D),await m(),s("Sample cube history loaded."))},"loadSampleCube"),P=n(async()=>{e&&(await e.reset(),await m(),s("Model reset complete."))},"resetModel"),R=n(async()=>{e&&(await e.setCss(C.value),await e.setSidebarExpanded(i.checked),s("Custom CSS and sidebar state applied."))},"applyCss");u.addEventListener("click",()=>{N().catch(t=>{console.error(t),s(`Failed to create CAD iframe: ${t?.message||String(t)}`)})});y.addEventListener("click",()=>{O().catch(t=>{console.error(t),s(`Failed to destroy CAD iframe: ${t?.message||String(t)}`)})});p.addEventListener("click",()=>{m().catch(t=>{console.error(t),s(`Failed to get state: ${t?.message||String(t)}`)})});g.addEventListener("click",()=>{A().catch(t=>{console.error(t),s(`Failed to export history: ${t?.message||String(t)}`)})});b.addEventListener("click",()=>{M().catch(t=>{console.error(t),s(`Failed to load sample history: ${t?.message||String(t)}`)})});h.addEventListener("click",()=>{P().catch(t=>{console.error(t),s(`Failed to reset model: ${t?.message||String(t)}`)})});E.addEventListener("click",()=>{R().catch(t=>{console.error(t),s(`Failed to apply CSS: ${t?.message||String(t)}`)})});i.addEventListener("change",()=>{e&&e.setSidebarExpanded(i.checked).catch(t=>{console.error(t),s(`Failed to set sidebar state: ${t?.message||String(t)}`)})});r(!1);
@@ -1,4 +1,4 @@
1
- var O=Object.defineProperty;var i=(t,s)=>O(t,"name",{value:s,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{CADEmbed as S}from"./brep-kernel-QpBwDdca.js";import"./preload-helper-ZNr0Qq7Q.js";const h=document.getElementById("btn-run"),u=document.getElementById("btn-destroy"),P=document.getElementById("viewer-only"),H=document.getElementById("sidebar-expanded"),M=document.getElementById("model-path"),A=document.getElementById("model-source"),j=document.getElementById("model-repo"),B=document.getElementById("model-branch"),x=document.getElementById("css-input"),R=document.getElementById("run-status"),$=document.getElementById("cad-host"),C=document.getElementById("results"),g=document.getElementById("log-output");let n=null,w=!1;const v={features:[{type:"Primitive Cube",inputParams:{id:"integration_sample_cube_1",sizeX:16,sizeY:12,sizeZ:10,transform:{position:[0,0,0],rotationEuler:[0,0,0],scale:[1,1,1]},boolean:{targets:[],operation:"NONE"}},persistentData:{},timestamp:null}],idCounter:1,expressions:`//Examples:
1
+ var O=Object.defineProperty;var i=(t,s)=>O(t,"name",{value:s,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{CADEmbed as S}from"./brep-kernel-BaJWJnmy.js";import"./preload-helper-ZNr0Qq7Q.js";const h=document.getElementById("btn-run"),u=document.getElementById("btn-destroy"),P=document.getElementById("viewer-only"),H=document.getElementById("sidebar-expanded"),M=document.getElementById("model-path"),A=document.getElementById("model-source"),j=document.getElementById("model-repo"),B=document.getElementById("model-branch"),x=document.getElementById("css-input"),R=document.getElementById("run-status"),$=document.getElementById("cad-host"),C=document.getElementById("results"),g=document.getElementById("log-output");let n=null,w=!1;const v={features:[{type:"Primitive Cube",inputParams:{id:"integration_sample_cube_1",sizeX:16,sizeY:12,sizeZ:10,transform:{position:[0,0,0],rotationEuler:[0,0,0],scale:[1,1,1]},boolean:{targets:[],operation:"NONE"}},persistentData:{},timestamp:null}],idCounter:1,expressions:`//Examples:
2
2
  x = 10 + 6;
3
3
  y = x * 2;`,pmiViews:[],metadata:{},assemblyConstraints:[],assemblyConstraintIdCounter:0};function l(t){const a=`[${new Date().toLocaleTimeString()}] ${t}`,o=g.textContent==="(No logs yet)"?[]:g.textContent.split(`
4
4
  `).filter(Boolean);o.unshift(a),g.textContent=o.slice(0,120).join(`
@@ -1 +1 @@
1
- var c=Object.defineProperty;var o=(t,r)=>c(t,"name",{value:r,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";import{A as m}from"./AssemblyConstraintRegistry-DHKMQSj6.js";import{r as s}from"./dialogCapturePageFactory-C9unVBhR.js";import"./featureDialogs-Cx7p1XpK.js";import"./browserStorage-CvgF8ovw.js";import"./preload-helper-ZNr0Qq7Q.js";import"./annUtils-C1gESzsQ.js";const p=new m,f=p.list().filter(Boolean).map(t=>{const r=a(t.longName,t.constraintName,t.name,"Constraint"),e=a(t.shortName,t.constraintShortName,t.constraintType,r,"Constraint"),n=t&&typeof t.inputParamsSchema=="object"?t.inputParamsSchema:{},i=u(n,e);return{displayName:r,shortName:e,captureName:r,schema:n,initialParams:i}});s({title:"Assembly Constraint Dialog Reference",description:"Dialogs for built-in assembly constraints captured from the constraint registry.",entries:f});function a(...t){for(const r of t){if(r==null&&r!==0)continue;const e=String(r).trim();if(e.length)return e}return"Constraint"}o(a,"pickName");function u(t,r){if(!t||typeof t!="object")return{};const e=Object.keys(t).find(i=>i.toLowerCase()==="constraintid");if(!e)return{};const n=String(r||"constraint").replace(/[^a-z0-9._-]+/gi,"_");return{[e]:`${n}-constraint`}}o(u,"buildConstraintParams");
1
+ var c=Object.defineProperty;var o=(t,r)=>c(t,"name",{value:r,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";import{A as m}from"./AssemblyConstraintRegistry-DDhkhKoR.js";import{r as s}from"./dialogCapturePageFactory-B5p-TYIP.js";import"./featureDialogs-CnBa1DyN.js";import"./browserStorage-CvgF8ovw.js";import"./preload-helper-ZNr0Qq7Q.js";import"./annUtils-B86URBT5.js";const p=new m,f=p.list().filter(Boolean).map(t=>{const r=a(t.longName,t.constraintName,t.name,"Constraint"),e=a(t.shortName,t.constraintShortName,t.constraintType,r,"Constraint"),n=t&&typeof t.inputParamsSchema=="object"?t.inputParamsSchema:{},i=u(n,e);return{displayName:r,shortName:e,captureName:r,schema:n,initialParams:i}});s({title:"Assembly Constraint Dialog Reference",description:"Dialogs for built-in assembly constraints captured from the constraint registry.",entries:f});function a(...t){for(const r of t){if(r==null&&r!==0)continue;const e=String(r).trim();if(e.length)return e}return"Constraint"}o(a,"pickName");function u(t,r){if(!t||typeof t!="object")return{};const e=Object.keys(t).find(i=>i.toLowerCase()==="constraintid");if(!e)return{};const n=String(r||"constraint").replace(/[^a-z0-9._-]+/gi,"_");return{[e]:`${n}-constraint`}}o(u,"buildConstraintParams");