(()=>{"use strict";var e={2986:function(e,t,r){r.d(t,{XY:()=>XY,Cy:()=>isPropertyChanged,PY:()=>et,NB:()=>Node,gT:()=>Constants,oc:()=>k,yG:()=>Matrix4,pS:()=>PubSub,_f:()=>Quaternion,ei:()=>P,JO:()=>Plane,io:()=>SelectableItems,uu:()=>CancelableCommand,xE:()=>Texture,gc:()=>gc,vZ:()=>readFileAsync,DE:()=>Z,EK:()=>ShapeNode,bj:()=>R,qV:()=>A,tR:()=>eh,Ay:()=>History,Gq:()=>G,G$:()=>EdgeMeshDataBuilder,Yd:()=>Logger,mn:()=>V,i5:()=>ea,W7:()=>I,OI:()=>$,Cs:()=>H,R3:()=>GeometryNode,Vl:()=>er,gC:()=>EditableShapeNode,wK:()=>PathBinding,yx:()=>PhysicalMaterial,wV:()=>T,_J:()=>ShapeNodeFilter,cx:()=>eo,h3:()=>readFilesAsync,Gc:()=>C,Id:()=>Id,gR:()=>ParameterShapeNode,ud:()=>DeepObserver,y$:()=>Observable,x4:()=>Result,F5:()=>Material,Vt:()=>FacebaseNode,ND:()=>z,hQ:()=>Combobox,qE:()=>ec,mY:()=>N,v7:()=>ee,Rr:()=>MultiShapeNode,Hm:()=>NodeLinkedListHistoryRecord,YO:()=>M,zp:()=>E,DY:()=>O,JF:()=>PhongMaterial,SP:()=>ei,bR:()=>MeshNode,ax:()=>en,s4:()=>L,zH:()=>Ray,LR:()=>download,Ds:()=>debounce,YW:()=>Transaction,S3:()=>VisualNode,H7:()=>arrayNeedsUint32,WD:()=>decarator_command,iM:()=>ed,n4:()=>PlaneAngle,vY:()=>XYZ,De:()=>Config,Op:()=>AsyncController,Vn:()=>ObservableCollection,Z9:()=>D,KX:()=>Binding,YT:()=>FolderNode,Gw:()=>GroupNode,Rl:()=>x,wB:()=>F,AH:()=>es,M8:()=>MathUtils});let AsyncController=class AsyncController{_failListeners=new Set;_successListeners=new Set;_result;get result(){return this._result}fail=e=>{this.notifyListeners(this._failListeners,"fail",e)};cancel=e=>{this.notifyListeners(this._failListeners,"cancel",e)};success=e=>{this.notifyListeners(this._successListeners,"success",e)};notifyListeners(e,t,r){void 0===this._result&&(this._result={status:t,message:r},e.forEach(e=>e(this._result)))}onCancelled(e){this._failListeners.add(e)}onCompleted(e){this._successListeners.add(e)}dispose(){this._failListeners.clear(),this._successListeners.clear()}};let i=new FinalizationRegistry(e=>{e.removeBinding()});let PathBinding=class PathBinding{source;path;converter;_target;_oldPathObjects;_actualSource;constructor(e,t,r){this.source=e,this.path=t,this.converter=r,this.handleAllPathPropertyChanged=(e,t)=>{this.shouldUpdateHandler(e,t)&&(this.removePropertyChangedHandler(),this.addPropertyChangedHandler())},this.handlePropertyChanged=(e,t)=>{this.path.endsWith(e)&&this._target&&this.setValue(t,e)}}setBinding(e,t){if(this._target)throw Error("Binding already set");this._target={element:new WeakRef(e),property:t},i.register(e,this),this.addPropertyChangedHandler()}removeBinding(){let e=this._target?.element.deref();e&&i.unregister(e),this._target=void 0,this.removePropertyChangedHandler()}handleAllPathPropertyChanged;handlePropertyChanged;shouldUpdateHandler(e,t){return!!(void 0===this._oldPathObjects||this._oldPathObjects.some(r=>r.property===e&&r.source===t))||!this._actualSource&&this.path.includes(e)}addPropertyChangedHandler(){let e=this.path.split("."),t=this.source;this._oldPathObjects=[];for(let r=0;re.source.removePropertyChanged(this.handleAllPathPropertyChanged)),this._actualSource?.source.removePropertyChanged(this.handlePropertyChanged),this._actualSource=void 0,this._oldPathObjects=void 0)}setValue(e,t){if(!this._target)return;let r=this._target.element.deref();if(!r)return;let i=e[t];if(this.converter){let e=this.converter.convert(i);e.isOk&&(r[this._target.property]=e.value)}else r[this._target.property]=i}getPropertyValue(){return this._actualSource?this._actualSource.source[this._actualSource.property]:void 0}};let Binding=class Binding extends PathBinding{constructor(e,t,r){super(e,t.toString(),r)}};var a,s,n,o,l,c,d,h,p,u,m,g,f,y,v,_,b,w,P,x,S,C,D,T,N,k,O,M,E,R,z,A,F,j,V=((b={})[b.add=0]="add",b[b.remove=1]="remove",b[b.move=2]="move",b[b.replace=3]="replace",b);let ObservableCollection=class ObservableCollection{_callbacks=new Set;_items;constructor(...e){this._items=[...e]}push(...e){0!==e.length&&(this._items.push(...e),this.notifyChange({action:0,items:e}))}remove(...e){if(0===e.length)return;let t=new Set(e);this._items=this._items.filter(e=>!t.has(e)),this.notifyChange({action:1,items:e})}move(e,t){if(!this.isValidMove(e,t))return;let r=this._items.splice(e,1);this._items.splice(e=0&&e=0&&t=0&&et(e))}forEach(e){this.items.forEach(e)}map(e){return this.items.map(e)}get items(){return[...this._items]}[Symbol.iterator](){return this.items[Symbol.iterator]()}item(e){return this._items[e]}at(e){return this._items.at(e)}filter(e){return this._items.filter(e)}find(e){return this._items.find(e)}indexOf(e,t){return this._items.indexOf(e,t)}contains(e){return -1!==this._items.indexOf(e)}get count(){return this._items.length}onCollectionChanged(e){this._callbacks.add(e)}removeCollectionChanged(e){this._callbacks.delete(e)}dispose(){this._callbacks.clear(),this._items.length=0}};var I=((a={})[a.check=0]="check",a[a.radio=1]="radio",a[a.combo=2]="combo",a);let SelectableItems=class SelectableItems{mode;items;selectedItems;get selectedIndexes(){let e=[];return this.selectedItems.forEach(t=>{let r=this.items.indexOf(t);r>-1&&e.push(r)}),e}firstSelectedItem(){return this.selectedItems.values().next().value}constructor(e,t=1,r){this.mode=t,this.items=e,this.selectedItems=new Set(r??[])}};let History=class History{_undos=[];_redos=[];disabled=!1;undoLimits=50;dispose(){this._redos.forEach(e=>e.dispose()),this._undos.forEach(e=>e.dispose()),this.clear()}clear(){this._undos.length=0,this._redos.length=0}add(e){if(!this.disabled&&(this._redos.length=0,this._undos.push(e),this._undos.length>this.undoLimits)){let e=this._undos.shift();e?.dispose()}}undoCount(){return this._undos.length}redoCount(){return this._redos.length}undo(){this.tryOperate(()=>{let e=this._undos.pop();e&&(e.undo(),this._redos.push(e))})}redo(){this.tryOperate(()=>{let e=this._redos.pop();e&&(e.redo(),this._undos.push(e))})}tryOperate(e){let t=this.disabled;this.disabled=!0;try{e()}finally{this.disabled=t}}};let PropertyHistoryRecord=class PropertyHistoryRecord{object;property;oldValue;newValue;name;constructor(e,t,r,i){this.object=e,this.property=t,this.oldValue=r,this.newValue=i,this.name=`change ${String(t)} property`}dispose(){}undo(){this.object[this.property]=this.oldValue}redo(){this.object[this.property]=this.newValue}};var L=((s={})[s.add=0]="add",s[s.remove=1]="remove",s[s.move=2]="move",s[s.insertAfter=3]="insertAfter",s[s.insertBefore=4]="insertBefore",s);let NodeLinkedListHistoryRecord=class NodeLinkedListHistoryRecord{records;name;constructor(e){this.records=e,this.name="change node"}dispose(){this.records.forEach(e=>{1===e.action&&e.node.dispose()}),this.records.length=0}handleUndo(e){switch(e.action){case 0:case 3:case 4:e.newParent?.remove(e.node);break;case 1:e.oldParent?.add(e.node);break;case 2:e.newParent?.move(e.node,e.oldParent,e.oldPrevious)}}handleRedo(e){switch(e.action){case 0:e.newParent?.add(e.node);break;case 1:e.oldParent?.remove(e.node);break;case 2:e.oldParent?.move(e.node,e.newParent,e.newPrevious);break;case 3:e.newParent?.insertAfter(e.newPrevious,e.node);break;case 4:e.newParent?.insertBefore(e.newPrevious?.nextSibling,e.node)}}undo(){for(let e=this.records.length-1;e>=0;e--)this.handleUndo(this.records[e])}redo(){this.records.forEach(e=>this.handleRedo(e))}};let ArrayRecord=class ArrayRecord{name;records;constructor(e){this.name=e,this.records=[]}dispose(){this.records.forEach(e=>e.dispose())}undo(){for(let e=this.records.length-1;e>=0;e--)this.records[e].undo()}redo(){for(let e of this.records)e.redo()}};let Logger=class Logger{static debug(e,...t){console.log(e,...t)}static info(e,...t){console.log(e,...t)}static warn(e,...t){console.warn(e,...t)}static error(e,...t){console.error(e,...t)}};Logger.info=console.log,Logger.warn=console.warn,Logger.debug=console.log,Logger.error=console.error;let Transaction=class Transaction{document;name;static _transactionMap=new WeakMap;constructor(e,t){this.document=e,this.name=t}static add(e,t){if(e.history.disabled)return;let r=Transaction._transactionMap.get(e);void 0!==r?r.records.push(t):Transaction.addToHistory(e,t)}static addToHistory(e,t){e.history.add(t),Logger.info(`history added ${t.name}`)}static execute(e,t,r){let i=new Transaction(e,t);i.start();try{r(),i.commit()}catch(e){throw i.rollback(),e}}static async executeAsync(e,t,r){let i=new Transaction(e,t);i.start();try{await r(),i.commit()}catch(e){throw i.rollback(),e}}start(e){let t=e??this.name;if(Transaction._transactionMap.has(this.document))throw Error(`The document has started a transaction ${this.name}`);Transaction._transactionMap.set(this.document,new ArrayRecord(t))}commit(){let e=Transaction._transactionMap.get(this.document);if(!e)throw Error("Transaction has not started");e.records.length>0&&Transaction.addToHistory(this.document,e),Transaction._transactionMap.delete(this.document)}rollback(){Transaction._transactionMap.get(this.document)?.undo(),Transaction._transactionMap.delete(this.document)}};function isPropertyChanged(e){return e&&"function"==typeof e.onPropertyChanged&&"function"==typeof e.removePropertyChanged}let Observable=class Observable{propertyChangedHandlers=new Set;_isDisposed=!1;getPrivateKey(e){return`_${String(e)}`}getPrivateValue(e,t){let r=this.getPrivateKey(e);return r in this?this[r]:this.initializeDefaultValue(e,t)}initializeDefaultValue(e,t){if(void 0===t){Logger.warn(`${this.constructor.name}: The property "${String(e)}" is not initialized, and no default value is provided`);return}return this[this.getPrivateKey(e)]=t,t}setPrivateValue(e,t){this[this.getPrivateKey(e)]=t}setProperty(e,t,r,i){let a=this[e];return!this.isEuqals(a,t,i)&&(this.setPrivateValue(e,t),r?.(e,a),this.emitPropertyChanged(e,a),!0)}isEuqals(e,t,r){return r?r.equals(e,t):e===t}emitPropertyChanged(e,t){Array.from(this.propertyChangedHandlers).forEach(r=>r(e,this,t))}onPropertyChanged(e){this.propertyChangedHandlers.add(e)}removePropertyChanged(e){this.propertyChangedHandlers.delete(e)}clearPropertyChanged(){this.propertyChangedHandlers.clear()}dispose=()=>{this._isDisposed||(this._isDisposed=!0,this.disposeInternal())};disposeInternal(){this.propertyChangedHandlers.clear()}};let HistoryObservable=class HistoryObservable extends Observable{_document;get document(){return this._document}constructor(e){super(),this._document=e}setProperty(e,t,r,i){return super.setProperty(e,t,(e,i)=>{r?.(e,i),Transaction.add(this.document,new PropertyHistoryRecord(this,e,i,t))},i)}disposeInternal(){super.disposeInternal(),this._document=null}};let Y=new Map;!function(e){function save(e,t){if(Y.has(e))throw Error(`Class ${e} already registered`);Y.set(e,t)}function getClass(e){let t=Y.get(e);if(t)return t;throw Error(`Type ${e} is not find, please add the @Serializer.register decorator.`)}e.save=save,e.getClass=getClass}(w||(w={}));let W=new Map,B=new Map;function _ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}!function(e){function serialze(){return(e,t)=>{let r=W.get(e);void 0===r&&(r=new Set,W.set(e,r)),r.add(t)}}function register(e,t,r){return i=>{w.save(i.name,i),B.set(i.name,{ctor:i,ctorParamNames:e,serialize:r,deserialize:t})}}e.serialze=serialze,e.register=register}(P||(P={})),function(e){function deserializeObject(e,t){let r=deserializeInstance(e,t.classKey,t.properties);return deserializeProperties(e,r,t),r}function deserializeInstance(e,t,r){if(!B.has(t))throw Error(`${t} cannot be deserialize. Did you forget to add the decorator @Serializer.register?`);let{ctor:i,ctorParamNames:a,deserialize:s}=B.get(t),n=deserilizeParameters(e,a,r,t);return s?s(...a.map(e=>n[e])):new i(...a.map(e=>n[e]))}function deserilizeParameters(e,t,r,i){let a={};for(let s of(a.document=e,t))s in r?void 0!==r[s]&&(a[s]=deserialValue(e,r[s])):"document"!==s&&(a[s]=void 0,console.warn(`${i} constructor parameter ${s} is missing`));return a}function deserialValue(e,t){return void 0===t?void 0:Array.isArray(t)?t.map(t=>"object"==typeof t?deserializeObject(e,t):t):t.classKey?deserializeObject(e,t):t}function deserializeProperties(e,t,r,i){let{ctorParamNames:a}=B.get(r.classKey);for(let s of Object.keys(r.properties).filter(e=>!a.includes(e)&&!i?.includes(e)))t[s]=deserialValue(e,r.properties[s])}e.deserializeObject=deserializeObject}(P||(P={})),function(e){function serializeObject(e){let t=e.constructor.name;if(!B.has(t))throw console.log(e),Error(`Type ${e.constructor.name} is not registered, please add the @Serializer.register decorator.`);let r=B.get(t);return{classKey:t,properties:r.serialize?.(e)??serializeProperties(e)}}function serializeProperties(e){let t={};for(let r of getAllKeysOfPrototypeChain(e,W)){let i=e[r];Array.isArray(i)?t[r]=i.map(e=>serializePropertyValue(e)):t[r]=serializePropertyValue(i)}return t}function serializePropertyValue(e){let t=typeof e;if("object"===t)return serializeObject(e);if("function"!==t&&"symbol"!==t)return e;throw Error(`Unsupported serialized object: ${e}`)}function getAllKeysOfPrototypeChain(e,t){let r=[],i=Object.getPrototypeOf(e);for(;null!==i;){let e=t.get(i);e&&r.push(...e.values()),i=Object.getPrototypeOf(i)}return new Set(r)}e.serializeObject=serializeObject,e.serializeProperties=serializeProperties}(P||(P={}));let Result=class Result{#e;#t;#r;get isOk(){return this.#e}get value(){return this.#e||Logger.warn("Result is error"),this.#t}get error(){return this.#e&&Logger.warn("Result is ok"),this.#r}constructor(e,t,r){this.#e=e,this.#t=t,this.#r=r}parse(){return Result.err(this.#r)}isOkAnd(e){return this.#e&&e(this.#t)}isErrorOr(e){return!this.#e||e(this.#t)}unchecked(){return this.#t}static ok(e){return new Result(!0,e,void 0)}static err(e){return new Result(!1,void 0,e)}};_ts_decorate([P.serialze()],Result.prototype,"isOk",null),_ts_decorate([P.serialze()],Result.prototype,"value",null),_ts_decorate([P.serialze()],Result.prototype,"error",null),Result=_ts_decorate([P.register(["isOk","value","error"])],Result);let DeepObserver=class DeepObserver{static handlers=new Map;static getPathValue(e,t){let r=t.split("."),i=e;for(let e=0;e{e.source.removePropertyChanged(i.handler)}),r.delete(t),0===r.size&&this.handlers.delete(e)}static getOrInitHandler(e,t){let r=DeepObserver.handlers.get(e);r||(r=new Map,DeepObserver.handlers.set(e,r));let i=r.get(t);return i&&i.sources.forEach(e=>{e.source.removePropertyChanged(i.handler)}),i=this.initSourceHandler(e,t),r.set(t,i),i}static initSourceHandler(e,t){return{handler:(r,i,a)=>{let s=this.handlers.get(e)?.get(t);if(!s)return;let n=s.sources.find(e=>e.source===i);if(!n)return;let o=n.prefix?`${n.prefix}.${r}`:r;this.updateHandlers(s,i,r,o),t(o,e,a)},sources:[]}}static updateHandlers(e,t,r,i){let a=t[r];if(void 0===a&&void 0!=i){let t=[];for(let r of e.sources)r.prefix?.startsWith(i)?r.source.removePropertyChanged(e.handler):t.push(r);e.sources=t;return}isPropertyChanged(a)&&this.deepHandlePropertyChanged(e,a,i)}};!function(e){function isDisposable(e){return null!=e&&"object"==typeof e&&"dispose"in e&&"function"==typeof e.dispose&&0===e.dispose.length}e.isDisposable=isDisposable}(x||(x={})),function(e){function isDeletable(e){return"function"==typeof e?.delete&&0===e.delete.length}e.isDeletable=isDeletable}(S||(S={}));let gc=e=>{let t=new Set;try{return e(e=>(t.add(e),e))}finally{for(let e of t)S.isDeletable(e)?e.delete():x.isDisposable(e)&&e.dispose();t.clear()}};let Id=class Id{static generate(e=21){let t="",r=e;for(;r--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return t}};var H=((n={})[n.info=0]="info",n[n.warn=1]="warn",n[n.error=2]="error",n);(o=C||(C={})).Distance=1e-7,o.Angle=.001,o.Float=1e-7;let PubSub=class PubSub{static default=new PubSub;events=new Map;dispose(){this.events.forEach(e=>e.clear()),this.events.clear()}sub(e,t){let r=this.events.get(e)??new Set;r.add(t),this.events.set(e,r)}pub(e,...t){this.events.get(e)?.forEach(e=>e(...t))}remove(e,t){this.events.get(e)?.delete(t)}removeAll(e){this.events.get(e)?.clear()}};let debounce=(e,t)=>{let r;return(...i)=>{r&&clearTimeout(r),r=window.setTimeout(()=>{e(...i),r=void 0},t)}};function download(e,t){let r=new Blob(e),i=document.createElement("a");i.style.visibility="hidden",i.href=URL.createObjectURL(r),i.download=t,i.click()}async function readFilesAsync(e,t){return new Promise(r=>{let i=document.createElement("input");i.type="file",i.multiple=t,i.accept=e,i.style.visibility="hidden";let cleanup=()=>document.body.removeChild(i);i.onchange=()=>{cleanup(),r(i.files?Result.ok(i.files):Result.err("no files selected"))},i.oncancel=()=>{cleanup(),r(Result.err("cancel"))},document.body.appendChild(i),i.click()})}async function readFileAsync(e,t,r="readAsText"){let i=await readFilesAsync(e,t);return i.isOk?readInputedFiles(i.value,r):i.parse()}async function readInputedFiles(e,t){let r=Array.from(e).map(async e=>{let r=await readFileDataAsync(e,t);if(!r)throw Error(`Error occurred reading file: ${e.name}`);return{fileName:e.name,data:r}});try{let e=await Promise.all(r);return Result.ok(e)}catch(e){return Result.err(e.message)}}function readFileDataAsync(e,t){return new Promise(r=>{let i=new FileReader;i.onload=e=>{e.target?.readyState===FileReader.DONE&&r(e.target.result)},i.onerror=()=>r(null),i[t](e)})}let q=new Map;function command_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}!function(e){function define(e,t){return(r,i)=>{q.has(r)||q.set(r,new Map),q.get(r)?.set(i,{display:e,name:i,...t})}}function getProperties(e,t){let r=[];return getAllKeysOfPrototypeChain(e,r,t),r}function getOwnProperties(e){let t=q.get(e);return t?[...t.values()]:[]}function getAllKeysOfPrototypeChain(e,t,r){e&&e!==r&&(q.has(e)&&t.splice(0,0,...q.get(e).values()),getAllKeysOfPrototypeChain(Object.getPrototypeOf(e),t,r))}function getProperty(e,t){if(!e)return;let r=q.get(e);return r?.has(t)?r.get(t):getProperty(Object.getPrototypeOf(e),t)}e.define=define,e.getProperties=getProperties,e.getOwnProperties=getOwnProperties,e.getProperty=getProperty}(D||(D={})),function(e){function isCancelableCommand(e){return"cancel"in e}e.isCancelableCommand=isCancelableCommand}(T||(T={}));let CancelableCommand=class CancelableCommand extends Observable{static _propertiesCache=new Map;_isCompleted=!1;get isCompleted(){return this._isCompleted}_application;get application(){if(!this._application)throw Error("application is not set");return this._application}get document(){return this.application.activeView?.document}#i;get controller(){return this.#i}set controller(e){this.#i!==e&&(this.#i?.dispose(),this.#i=e)}async cancel(){for(this.controller?.cancel();!this._isCompleted;)await new Promise(e=>setTimeout(e,30))}async execute(e){if(e.activeView?.document){this._application=e;try{this.beforeExecute(),await this.executeAsync()}finally{this.afterExecute()}}}beforeExecute(){this.readProperties(),PubSub.default.pub("openCommandContext",this)}afterExecute(){this.saveProperties(),PubSub.default.pub("closeCommandContext"),this.controller?.dispose(),this._isCompleted=!0}readProperties(){D.getProperties(this).forEach(e=>{let t=this.cacheKeyOfProperty(e);CancelableCommand._propertiesCache.has(t)&&(this[t]=CancelableCommand._propertiesCache.get(t))})}saveProperties(){D.getProperties(this).forEach(e=>{let t=this.cacheKeyOfProperty(e),r=this[t];"function"!=typeof r&&CancelableCommand._propertiesCache.set(t,r)})}cacheKeyOfProperty(e){return e.name}};command_ts_decorate([D.define("common.cancel")],CancelableCommand.prototype,"cancel",null);let X=new Map;function decarator_command(e){return t=>{X.set(e.name,t),t.prototype.data=e}}!function(e){function getData(e){if("string"==typeof e){let t=X.get(e);return t?.prototype.data}return("function"==typeof e?e.prototype:Object.getPrototypeOf(e)).data}function get(e){return X.get(e)}e.getData=getData,e.get=get}(N||(N={}));var Z=((l={})[l.none=0]="none",l[l.endPoint=1]="endPoint",l[l.midPoint=2]="midPoint",l[l.center=4]="center",l[l.angle=8]="angle",l[l.intersection=16]="intersection",l[l.perpendicular=32]="perpendicular",l[l.extension=64]="extension",l[l.parallel=128]="parallel",l[l.special=256]="special",l[l.nearest=512]="nearest",l[l.vertex=1024]="vertex",l[l.grid=2048]="grid",l);!function(e){function has(e,t){return(e&t)===t}function add(e,t){return e|t}function remove(e,t){return e&~t}e.has=has,e.add=add,e.remove=remove}(Z||(Z={}));let $={defaultEdgeColor:1118481,defaultFaceColor:0xdedede,highlightEdgeColor:4474060,highlightFaceColor:4474060,selectedEdgeColor:255,selectedFaceColor:255,editVertexSize:7,editVertexColor:255,hintVertexSize:5,hintVertexColor:255,trackingVertexSize:7,trackingVertexColor:255,temporaryVertexSize:5,temporaryVertexColor:255,temporaryEdgeColor:255};let Config=class Config extends Observable{static #a=new Config;static get instance(){return this.#a}get snapType(){return this.getPrivateValue("snapType",Z.midPoint|Z.endPoint|Z.center|Z.perpendicular|Z.intersection|Z.nearest)}set snapType(e){this.setProperty("snapType",e)}get enableSnapTracking(){return this.getPrivateValue("enableSnapTracking",!0)}set enableSnapTracking(e){this.setProperty("enableSnapTracking",e)}get enableSnap(){return this.getPrivateValue("enableSnap",!0)}set enableSnap(e){this.setProperty("enableSnap",e)}get dynamicWorkplane(){return this.getPrivateValue("dynamicWorkplane",!0)}set dynamicWorkplane(e){this.setProperty("dynamicWorkplane",e)}SnapDistance=5;constructor(){super()}};let Constants=class Constants{static DBName="chili3d-db";static DocumentTable="documents";static RecentTable="recents"};let G=".cd",U={display:"English",code:"en",translation:{"arc.angle":"Angle","arc.start":"Start","axis.x":"X Axis","axis.y":"Y Axis","axis.z":"Z Axis","body.arc":"Arc","body.bolean":"Boolean","body.box":"Box","body.circle":"Circle","body.face":"Face","body.fuse":"Fuse","body.imported":"Imported","body.line":"Line","body.polygon":"Polygon","body.prism":"Prism","body.rect":"Rectangle","body.revol":"Revolve","body.sweep":"Sweep","body.wire":"Wire","box.dx":"Length","box.dy":"Width","box.dz":"Height","body.editableShape":"Editable Shape","body.meshNode":"Mesh Node","body.multiShape":"Multi Shape","circle.center":"Center","circle.radius":"Radius","command.arc":"Arc","command.array":"Array","command.bezier":"Bezier","command.boolean.common":"Common","command.boolean.cut":"Cut","command.boolean.fuse":"Fuse","command.box":"Box","command.break":"Break","command.circle":"Circle","command.copy":"Copy","command.delete":"Delete","command.document.new":"New Document","command.document.open":"Open Document","command.document.save":"Save","command.document.saveAs":"Save As","command.document.saveToFile":"Save To File","command.export":"Export","command.faceable.isFace":"Face","command.fuse":"Fuse","command.import":"Import","command.line.isConnected":"Connected","command.line":"Line","command.mirror":"Mirror","command.mode.repeat":"Repeat","command.move":"Move","command.newFolder":"New Folder","command.newGroup":"New Group","command.offset":"Offset","command.polygon":"Polygon","command.prism":"Prism","command.rect":"Rectangle","command.redo":"Redo","command.revol":"Revol","command.rotate":"Rotate","command.section":"Section","command.split":"Split","command.sweep":"Sweep","command.thickSolid":"Thick Solid","command.toFace":"To Face","command.toWire":"To Wire","command.trim":"Trim","command.undo":"Undo","common.angle":"Angle","common.back":"Back","common.cancel":"Cancel","common.clone":"Clone","common.color":"Color","common.confirm":"Confirm","common.general":"General","common.length":"Length","common.material":"Material","common.matrix":"Matrix","common.name":"Name","common.normal":"Normal","common.opacity":"Opacity","common.thickness":"Thickness","common.type":"Type","entity.editable":"Editable Entity","entity.parameter":"Parameter Entity","error.default:{0}":"error: {0}","error.input.cannotInputANumber":"Overlap with reference point, 1 number cannot be entered","error.input.invalidNumber":"Please enter a valid number, separated by ,","error.input.threeNumberCanBeInput":"Reference point is empty, only 3 numbers can be entered","error.input.unsupportedInputs":"Exceeds the maximum number of inputs","error.import.unsupportedFileType:{0}":"Unsupported file type: {0}","error.export.noNodeCanBeExported":"No node can be exported","file.format":"Format","home.recent":"Recent","home.welcome":"Welcome to chili3d","items.header":"Items","items.tool.delete":"Delete","items.tool.expandAll":"Expand All","items.tool.newFolder":"New Folder","items.tool.unexpandAll":"Unexpand all","line.end":"End","line.start":"Start","line.type.line":"Line","line.type.xline":"XLine","material.texture.image":"Image","material.texture.rotation":"Rotation","material.texture.wrapS":"Wrap S","material.texture.wrapT":"Wrap T","material.texture.repeat":"Repeat","material.texture.offset":"Offset","material.map":"Map","material.specular":"Specular","material.shininess":"Shininess","material.emissive":"Emissive","material.specularMap":"Specular Map","material.normalMap":"Normal Map","material.bumpMap":"BumpMap","material.roughnessMap":"Roughness Map","material.emissiveMap":"Emissive Map","material.metalness":"Metalness","material.metalnessMap":"Metalness Map","material.roughness":"Roughness","model.visible":"Visible","operate.pickCircleCenter":"pick center, ESC key to cancel","operate.pickFistPoint":"Pick first point, ESC key to cancel","operate.pickNextPoint":"pick next point, ESC key to cancel","operate.pickRadius":"input radius, ESC key to cancel","polygon.points":"Points","prompt.default":"Middle mouse button to pan the view, Shift + Middle button to rotate the view, Middle button to scroll the zoom view","prompt.deleteDocument{0}":"Do you want to delete {0}?","prompt.polygon.close":"Close","prompt.saveDocument{0}":"Do you want to save the changes to {0}?","prompt.select.edges":"Please select edges","prompt.select.faces":"Please select faces","prompt.select.models":"Please select models","prompt.select.noModelSelected":"No model selected","prompt.select.shape":"Please select shape","prompt.select.vertexs":"Please select vertexs","prompt.select.wires":"Please select wires","properties.group.transform":"Transform","properties.header":"Properties","properties.multivalue":"Multi Value","rect.dx":"Length","rect.dy":"Width","ribbon.group.boolean":"Boolean","ribbon.group.converter":"Converter","ribbon.group.draw":"Drawing","ribbon.group.importExport":"Import/Export","ribbon.group.modify":"Modify","ribbon.group.selection":"Selection","ribbon.group.tools":"Tools","ribbon.group.workingPlane":"Working Plane","ribbon.tab.draw":"Drawing","ribbon.tab.file":"File","ribbon.tab.startup":"Startup","snap.center":"Center","snap.end":"End","snap.intersection":"Intersection","snap.mid":"Middle","snap.perpendicular":"Perpendicular","snap.nearest":"Nearest","statusBar.snap":"Snap","statusBar.tracking":"Tracking","toast.command.{0}excuting":"Command {0} is runing","toast.converter.error":"Converter error","toast.converter.invalidColor":"The color is invalid","toast.delete{0}Objects":"Deleted {0} objects","toast.document.noActived":"No document actived","toast.document.saved":"Document saved","toast.downloading":"Downloading","toast.excuting{0}":"Excuting {0}","toast.fail":"Fail","toast.read.error":"Read error","toast.select.noSelected":"No selected","toast.success":"Success","transform.rotation":"Rotation","transform.scale":"Scale","transform.translation":"Translation","vertex.point":"Point","workingPlane.dynamic":"Dynamic Plane","workingPlane.alignToPlane":"Align to plane","workingPlane.set":"Set workplane","test.performace":"Performace test"}},K={display:"简体中文",code:"zh-CN",translation:{"arc.angle":"角度","arc.start":"起点","axis.x":"X 轴","axis.y":"Y 轴","axis.z":"Z 轴","body.arc":"圆弧","body.bolean":"布尔","body.box":"立方体","body.circle":"圆形","body.face":"面","body.fuse":"合并","body.imported":"导入的模型","body.line":"直线","body.polygon":"多边形","body.prism":"拉伸","body.rect":"矩形","body.revol":"旋转","body.sweep":"扫略","body.wire":"线框","body.editableShape":"可编辑的形状","body.meshNode":"网格节点","body.multiShape":"多形状","box.dx":"长","box.dy":"宽","box.dz":"高","circle.center":"圆心","circle.radius":"半径","command.arc":"圆弧","command.array":"阵列","command.bezier":"贝塞尔","command.boolean.common":"相交","command.boolean.cut":"剪切","command.boolean.fuse":"融合","command.box":"立方体","command.break":"打断","command.circle":"圆","command.copy":"复制","command.delete":"删除","command.document.new":"新建文档","command.document.open":"打开文档","command.document.save":"保存文档","command.document.saveAs":"另存为","command.document.saveToFile":"保存到文件","command.export":"导出","command.faceable.isFace":"面","command.fuse":"合并","command.import":"导入","command.line.isConnected":"相连","command.line":"直线","command.mirror":"镜像","command.mode.repeat":"重复","command.move":"移动","command.newFolder":"新建文件夹","command.newGroup":"新建组","command.offset":"偏移","command.polygon":"多边形","command.prism":"拉伸","command.rect":"矩形","command.redo":"重做","command.revol":"旋转","command.rotate":"旋转","command.section":"相交线","command.split":"分割","command.sweep":"扫略","command.thickSolid":"抽壳","command.toFace":"转面","command.toWire":"转多段线","command.trim":"修剪","command.undo":"撤销","common.angle":"角度","common.back":"返回","common.cancel":"取消","common.clone":"复制对象","common.color":"颜色","common.confirm":"确定","common.general":"常规","common.length":"长度","common.material":"材质","common.matrix":"矩阵","common.name":"名称","common.normal":"法向量","common.opacity":"不透明度","common.thickness":"厚度","common.type":"类型","entity.editable":"可编辑实体","entity.parameter":"参数化实体","error.default:{0}":"错误: {0}","error.input.cannotInputANumber":"与参照点重合,无法输入 1 个数","error.input.invalidNumber":"输入错误,请输入有效的数字,以,分开","error.input.threeNumberCanBeInput":"参照点为空,只能输入 3 个数","error.input.unsupportedInputs":"超过最大输入数","error.import.unsupportedFileType:{0}":"不支持的文件类型: {0}","error.export.noNodeCanBeExported":"没有可导出的节点","file.format":"文件格式","home.recent":"最近使用","home.welcome":"欢迎使用 chili3d","items.header":"项目","items.tool.delete":"删除","items.tool.expandAll":"展开所有","items.tool.newFolder":"文件夹","items.tool.unexpandAll":"折叠所有","line.end":"终点","line.start":"起点","line.type.line":"直线","line.type.xline":"构造线","material.texture.image":"图片","material.texture.rotation":"旋转","material.texture.wrapS":"Wrap S","material.texture.wrapT":"Wrap T","material.texture.repeat":"重复","material.texture.offset":"偏移","material.map":"贴图","material.specular":"高光","material.shininess":"高光强度","material.emissive":"自发光","material.specularMap":"高光贴图","material.normalMap":"法线贴图","material.bumpMap":"凹凸贴图","material.roughnessMap":"粗糙度贴图","material.emissiveMap":"自发光贴图","material.metalness":"金属度","material.metalnessMap":"金属度贴图","material.roughness":"粗糙度","model.visible":"可见","operate.pickCircleCenter":"请选择圆心 按 ESC 键取消","operate.pickFistPoint":"请选择第一个点, 按 ESC 键取消","operate.pickNextPoint":"请选择下一个点, 按 ESC 键取消","operate.pickRadius":"请选择半径, 按 ESC 键取消","polygon.points":"点","prompt.default":"鼠标中键平移视图,Shift + 中键旋转视图,中键滚动缩放视图","prompt.deleteDocument{0}":"是否删除 {0} ?","prompt.polygon.close":"闭合","prompt.saveDocument{0}":"是否保存对 {0} 的更改?","prompt.select.edges":"请选择边","prompt.select.faces":"请选择面","prompt.select.models":"请选择模型","prompt.select.noModelSelected":"未选择任何模型","prompt.select.shape":"选择形状","prompt.select.vertexs":"请选择点","prompt.select.wires":"请选择线","properties.group.transform":"转换","properties.header":"属性","properties.multivalue":"多个值","rect.dx":"长","rect.dy":"宽","ribbon.group.boolean":"布尔运算","ribbon.group.converter":"转换","ribbon.group.draw":"绘制","ribbon.group.importExport":"导入/导出","ribbon.group.modify":"修改","ribbon.group.selection":"选择","ribbon.group.tools":"工具","ribbon.group.workingPlane":"工作平面","ribbon.tab.draw":"绘图","ribbon.tab.file":"文件","ribbon.tab.startup":"开始","snap.center":"圆心","snap.end":"端点","snap.intersection":"交点","snap.mid":"中点","snap.perpendicular":"垂点","snap.nearest":"最近点","statusBar.snap":"捕捉","statusBar.tracking":"追踪","toast.command.{0}excuting":"{0}命令正在执行","toast.converter.error":"转换错误","toast.converter.invalidColor":"无效的颜色","toast.delete{0}Objects":"删除了 {0} 个对象","toast.document.noActived":"未打开任何文档","toast.document.saved":"文档已保存","toast.downloading":"正在下载","toast.excuting{0}":"正在执行{0}","toast.fail":"失败","toast.read.error":"读取错误","toast.select.noSelected":"未选择任何对象","toast.success":"成功","transform.rotation":"旋转","transform.scale":"缩放","transform.translation":"位移","vertex.point":"点","workingPlane.dynamic":"动态平面","workingPlane.alignToPlane":"对齐到平面","workingPlane.set":"设置工作平面","test.performace":"性能测试"}},J="chili18n",Q=new WeakMap;!function(e){e.languages=new Map([["en",U],["zh-CN",K]]);let t="zh-CN";function currentLanguage(){return t}function combineTranslation(t,r){let i=e.languages.get(t);i&&(i.translation={...i.translation,...r})}function translate(r,...i){let a=e.languages.get(t).translation[r]??e.languages.get("zh-CN").translation[r];return i.length>0&&(a=a.replace(/\{(\d+)\}/g,(e,t)=>i[t])),a}function set(e,t,...r){e.textContent=translate(t,...r),e.dataset[J]=t,r.length>0&&Q.set(e,r)}function changeLanguage(r){if(r<0||r>=e.languages.size)return;let i=Array.from(e.languages.keys())[r];i!==t&&(t=i,document.querySelectorAll(`[data-${J}]`).forEach(e=>{let t=e?.dataset[J];if(void 0===t)return;let r=Q.get(e)??[];e.textContent=translate(t,...r)}))}e.currentLanguage=currentLanguage,e.combineTranslation=combineTranslation,e.translate=translate,e.set=set,e.changeLanguage=changeLanguage}(k||(k={}));let BoundingBox=class BoundingBox{min;max;constructor(e,t){this.min=e,this.max=t}static isValid(e){return e.min.x<=e.max.x&&e.min.y<=e.max.y&&e.min.z<=e.max.z}static expandByPoint(e,t){let{min:r,max:i}=e;r.x=Math.min(r.x,t.x),r.y=Math.min(r.y,t.y),r.z=Math.min(r.z,t.z),i.x=Math.max(i.x,t.x),i.y=Math.max(i.y,t.y),i.z=Math.max(i.z,t.z)}static fromNumbers(e){let t={x:1/0,y:1/0,z:1/0},r={x:-1/0,y:-1/0,z:-1/0};for(let i=0;iMath.abs(e)Math.abs(e)r)throw Error("min must be less than max");return er?r:e}static minMax(e){if(0===e.length)return;let t=e[0],r=e[0];for(let i=1;ir&&(r=a)}return{min:t,max:r}}};let Quaternion=class Quaternion{w;x;y;z;constructor(e=1,t=0,r=0,i=0){this.w=e,this.x=t,this.y=r,this.z=i}add(e){return new Quaternion(this.w+e.w,this.x+e.x,this.y+e.y,this.z+e.z)}subtract(e){return new Quaternion(this.w-e.w,this.x-e.x,this.y-e.y,this.z-e.z)}multiply(e){let{w:t,x:r,y:i,z:a}=this,{w:s,x:n,y:o,z:l}=e;return new Quaternion(t*s-r*n-i*o-a*l,t*n+r*s+i*l-a*o,t*o-r*l+i*s+a*n,t*l+r*o-i*n+a*s)}conjugate(){return new Quaternion(this.w,-this.x,-this.y,-this.z)}magnitude(){return Math.sqrt(this.w*this.w+this.x*this.x+this.y*this.y+this.z*this.z)}normalize(){let e=this.magnitude();if(0===e)return new Quaternion;let t=1/e;return new Quaternion(this.w*t,this.x*t,this.y*t,this.z*t)}toEuler(){let e=Math.atan2(2*(this.w*this.x+this.y*this.z),1-2*(this.x*this.x+this.y*this.y)),t=2*(this.w*this.y-this.z*this.x);return{x:e,y:Math.abs(t)>=1?Math.PI/2*Math.sign(t):Math.asin(t),z:Math.atan2(2*(this.w*this.z+this.x*this.y),1-2*(this.y*this.y+this.z*this.z))}}toMatrix4(){let e=this.x*this.x,t=this.y*this.y,r=this.z*this.z,i=this.x*this.y,a=this.x*this.z,s=this.y*this.z,n=this.x*this.w,o=this.y*this.w,l=this.z*this.w;return Matrix4.fromArray([1-2*(t+r),2*(i-l),2*(a+o),0,2*(i+l),1-2*(e+r),2*(s-n),0,2*(a-o),2*(s+n),1-2*(e+t),0,0,0,0,1])}static fromEuler(e,t,r){let i=.5*e,a=.5*t,s=.5*r,n=Math.cos(i),o=Math.sin(i),l=Math.cos(a),c=Math.sin(a),d=Math.cos(s),h=Math.sin(s);return new Quaternion(n*l*d+o*c*h,o*l*d-n*c*h,n*c*d+o*l*h,n*l*h-o*c*d)}};function xyz_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}let XYZ=class XYZ{static zero=new XYZ(0,0,0);static unitX=new XYZ(1,0,0);static unitY=new XYZ(0,1,0);static unitZ=new XYZ(0,0,1);static one=new XYZ(1,1,1);x;y;z;constructor(e,t,r){this.x=e,this.y=t,this.z=r}toString(){return`${this.x}, ${this.y}, ${this.z}`}cross(e){return new XYZ(this.y*e.z-this.z*e.y,this.z*e.x-this.x*e.z,this.x*e.y-this.y*e.x)}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}divided(e){if(!(Math.abs(e)=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}xyz_ts_decorate([P.serialze()],XYZ.prototype,"x",void 0),xyz_ts_decorate([P.serialze()],XYZ.prototype,"y",void 0),xyz_ts_decorate([P.serialze()],XYZ.prototype,"z",void 0),XYZ=xyz_ts_decorate([P.register(["x","y","z"])],XYZ);let Matrix4=class Matrix4{_array=new Float32Array(16);get array(){return[...this._array]}determinant(){let[e,t,r,i]=[this._array[0],this._array[1],this._array[2],this._array[3]],[a,s,n,o]=[this._array[4],this._array[5],this._array[6],this._array[7]],[l,c,d,h]=[this._array[8],this._array[9],this._array[10],this._array[11]],[p,u,m,g]=[this._array[12],this._array[13],this._array[14],this._array[15]],f=e*s-t*a,y=e*n-r*a,v=t*n-r*s,_=l*u-c*p,b=l*m-d*p,w=c*m-d*u;return o*(e*w-t*b+r*_)-i*(a*w-s*b+n*_)+g*(l*v-c*y+d*f)-h*(p*v-u*y+m*f)}toArray(){return[...this._array]}add(e){let t=new Matrix4;for(let r=0;r<16;r++)t._array[r]=this._array[r]+e._array[r];return t}invert(){let[e,t,r,i]=[this._array[0],this._array[1],this._array[2],this._array[3]],[a,s,n,o]=[this._array[4],this._array[5],this._array[6],this._array[7]],[l,c,d,h]=[this._array[8],this._array[9],this._array[10],this._array[11]],[p,u,m,g]=[this._array[12],this._array[13],this._array[14],this._array[15]],f=e*s-t*a,y=e*n-r*a,v=e*o-i*a,_=t*n-r*s,b=t*o-i*s,w=r*o-i*n,P=l*u-c*p,x=l*m-d*p,S=l*g-h*p,C=c*m-d*u,D=c*g-h*u,T=d*g-h*m,N=f*T-y*D+v*C+_*S-b*x+w*P;if(0!==N)return N=1/N,Matrix4.fromArray([(s*T-n*D+o*C)*N,(r*D-t*T-i*C)*N,(u*w-m*b+g*_)*N,(d*b-c*w-h*_)*N,(n*S-a*T-o*x)*N,(e*T-r*S+i*x)*N,(m*v-p*w-g*y)*N,(l*w-d*v+h*y)*N,(a*D-s*S+o*P)*N,(t*S-e*D-i*P)*N,(p*b-u*v+g*f)*N,(c*v-l*b-h*f)*N,(s*x-a*C-n*P)*N,(e*C-t*x+r*P)*N,(u*y-p*_-m*f)*N,(l*_-c*y+d*f)*N])}position(e,t,r){let i=this.clone();return i._array[12]=e,i._array[13]=t,i._array[14]=r,i}getPosition(){return new XYZ(this._array[12],this._array[13],this._array[14])}scale(e,t,r){let i=this.clone();return i._array[0]=e,i._array[5]=t,i._array[10]=r,i}getScale(){let e=this._array[0],t=this._array[1],r=this._array[2],i=this._array[4],a=this._array[5],s=this._array[6],n=this._array[8],o=this._array[9],l=this._array[10],c=Math.sqrt(e*e+t*t+r*r);return 0>this.determinant()&&(c=-c),new XYZ(c,Math.sqrt(i*i+a*a+s*s),Math.sqrt(n*n+o*o+l*l))}eulerAngles(e,t,r){let i=this.clone(),a=Math.sin(e),s=Math.cos(e),n=Math.sin(t),o=Math.cos(t),l=Math.sin(r),c=Math.cos(r);return i._array[0]=o*c+n*a*l,i._array[1]=s*l,i._array[2]=-n*c+o*a*l,i._array[4]=o*l-n*a*c,i._array[5]=s*c,i._array[6]=n*l+o*a*c,i._array[8]=n*s,i._array[9]=-a,i._array[10]=o*s,i}getEulerAngles(){let e=-Math.asin(this._array[9]),t=0,r=0;return this._array[9]<1?this._array[9]>-1?(t=Math.atan2(this._array[8],this._array[10]),r=Math.atan2(this._array[1],this._array[5])):(t=-Math.atan2(-this._array[2],this._array[0]),r=0):(t=Math.atan2(-this._array[2],this._array[0]),r=0),{pitch:e,yaw:t,roll:r}}getRotation(){let e,t,r,i,a;let[s,n,o]=[this._array[0],this._array[4],this._array[8]],[l,c,d]=[this._array[1],this._array[5],this._array[9]],[h,p,u]=[this._array[2],this._array[6],this._array[10]],m=s+c+u;return m>0?(a=.25/(e=.5/Math.sqrt(m+1)),t=(p-d)*e,r=(o-h)*e,i=(l-n)*e):s>c&&s>u?(a=(p-d)/(e=2*Math.sqrt(1+s-c-u)),t=.25*e,r=(n+l)/e,i=(o+h)/e):c>u?(a=(o-h)/(e=2*Math.sqrt(1+c-s-u)),t=(n+l)/e,r=.25*e,i=(d+p)/e):(a=(l-n)/(e=2*Math.sqrt(1+u-s-c)),t=(o+h)/e,r=(d+p)/e,i=.25*e),new Quaternion(t,r,i,a)}multiply(e){let t=Array(16).fill(0);for(let r=0;r<4;r++)for(let i=0;i<4;i++)for(let a=0;a<4;a++)t[4*r+i]+=this._array[4*r+a]*e._array[4*a+i];return Matrix4.fromArray(t)}equals(e){for(let t=0;t<16;t++)if(!MathUtils.almostEqual(this._array[t],e._array[t]))return!1;return!0}clone(){return Matrix4.fromArray([...this._array])}static fromArray(e){let t=new Matrix4;for(let r=0;r<16;r++)t._array[r]=e[r];return t}static identity(){return Matrix4.fromArray([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}static zero(){return Matrix4.fromArray(Array(16).fill(0))}static compose(e,t,r){let i=new Matrix4,{x:a,y:s,z:n,w:o}=t,l=a+a,c=s+s,d=n+n,h=a*l,p=a*c,u=a*d,m=s*c,g=s*d,f=n*d,y=o*l,v=o*c,_=o*d,b=r.x,w=r.y,P=r.z;return i._array[0]=(1-(m+f))*b,i._array[1]=(p+_)*b,i._array[2]=(u-v)*b,i._array[4]=(p-_)*w,i._array[5]=(1-(h+f))*w,i._array[6]=(g+y)*w,i._array[8]=(u+v)*P,i._array[9]=(g-y)*P,i._array[10]=(1-(h+m))*P,i._array[12]=e.x,i._array[13]=e.y,i._array[14]=e.z,i._array[15]=1,i}static createRotationAt(e,t,r){let i=t.normalize();if(void 0===i)throw TypeError("invalid vector");let{x:a,y:s,z:n}=i,o=Math.sin(-r),l=Math.cos(-r),c=1-l,d=[c*a*a+l,c*a*s-n*o,c*a*n+s*o,0,c*a*s+n*o,c*s*s+l,c*s*n-a*o,0,c*a*n-s*o,c*s*n+a*o,c*n*n+l,0,0,0,0,1];return d[12]=e.x-e.x*d[0]-e.y*d[4]-e.z*d[8],d[13]=e.y-e.x*d[1]-e.y*d[5]-e.z*d[9],d[14]=e.z-e.x*d[2]-e.y*d[6]-e.z*d[10],Matrix4.fromArray(d)}static createScale(e,t,r){return Matrix4.fromArray([e,0,0,0,0,t,0,0,0,0,r,0,0,0,0,1])}static createTranslation(e,t,r){return Matrix4.fromArray([1,0,0,0,0,1,0,0,0,0,1,0,e,t,r,1])}static createMirrorWithPlane(e){let t=-e.origin.dot(e.normal),r=e.normal.x,i=e.normal.y,a=e.normal.z,s=-2*r,n=-2*i,o=-2*a;return Matrix4.fromArray([s*r+1,n*r,o*r,0,s*i,n*i+1,o*i,0,s*a,n*a,o*a+1,0,s*t,n*t,o*t,1])}transpose(){let e=new Matrix4;return e._array[0]=this._array[0],e._array[1]=this._array[4],e._array[2]=this._array[8],e._array[3]=this._array[12],e._array[4]=this._array[1],e._array[5]=this._array[5],e._array[6]=this._array[9],e._array[7]=this._array[13],e._array[8]=this._array[2],e._array[9]=this._array[6],e._array[10]=this._array[10],e._array[11]=this._array[14],e._array[12]=this._array[3],e._array[13]=this._array[7],e._array[14]=this._array[11],e._array[15]=this._array[15],e}ofPoints(e){let t=[];for(let r=0;r=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}matrix4_ts_decorate([P.serialze()],Matrix4.prototype,"array",null),Matrix4=matrix4_ts_decorate([P.register(["array"],e=>Matrix4.fromArray(e))],Matrix4);let Plane=class Plane{static XY=new Plane(XYZ.zero,XYZ.unitZ,XYZ.unitX);static YZ=new Plane(XYZ.zero,XYZ.unitX,XYZ.unitY);static ZX=new Plane(XYZ.zero,XYZ.unitY,XYZ.unitZ);origin;normal;xvec;yvec;constructor(e,t,r){this.origin=e;let i=t.normalize(),a=r.normalize();if(void 0===i||i.isEqualTo(XYZ.zero))throw Error("normal can not be zero");if(void 0===a||a.isEqualTo(XYZ.zero))throw Error("xDirector can not be zero");if(i.isParallelTo(a))throw Error("xDirector can not parallel normal");this.normal=i,this.xvec=a,this.yvec=i.cross(a).normalize()}translateTo(e){return new Plane(e,this.normal,this.xvec)}project(e){let t=e.sub(this.origin),r=t.dot(this.normal);return this.origin.add(t.sub(this.normal.multiply(r)))}transformed(e){let t=e.ofPoint(this.origin),r=e.ofVector(this.xvec),i=e.ofVector(this.normal);return new Plane(t,i,r)}intersect(e,t=!0){let r=this.origin.sub(e.location);if(r.isEqualTo(XYZ.zero))return this.origin;let i=r.dot(this.normal),a=e.direction.dot(this.normal);if(MathUtils.almostEqual(a,0))return MathUtils.almostEqual(i,0)?e.location:void 0;let s=i/a;if(t||!(s<0))return e.location.add(e.direction.multiply(s))}};plane_ts_decorate([P.serialze()],Plane.prototype,"origin",void 0),plane_ts_decorate([P.serialze()],Plane.prototype,"normal",void 0),plane_ts_decorate([P.serialze()],Plane.prototype,"xvec",void 0),Plane=plane_ts_decorate([P.register(["origin","normal","xvec"])],Plane);let PlaneAngle=class PlaneAngle{plane;lastX;lastY;isNegativeRotation;currentAngle;get angle(){return this.currentAngle}constructor(e){this.plane=e,this.lastX=1,this.lastY=0,this.isNegativeRotation=!1,this.currentAngle=0}movePoint(e){let t=e.sub(this.plane.origin),r=t.dot(this.plane.xvec),i=t.dot(this.plane.yvec);this.isCrossingPositiveXAxis(r,i)&&(this.isNegativeRotation=!this.isNegativeRotation),this.currentAngle=this.calculateAngle(t),this.updateLastProjections(r,i)}calculateAngle(e){let t=180*this.plane.xvec.angleOnPlaneTo(e,this.plane.normal)/Math.PI;return this.isNegativeRotation?t-360:t}isCrossingPositiveXAxis(e,t){let r=this.lastY<-C.Distance&&t>C.Distance,i=this.lastY>-C.Distance&&t<-C.Distance;return(r&&this.currentAngle-C.Angle)&&this.lastX>0&&e>0}updateLastProjections(e,t){Math.abs(e)>C.Distance&&(this.lastX=e),Math.abs(t)>C.Distance&&(this.lastY=t)}};function ray_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}let Ray=class Ray{location;direction;constructor(e,t){this.location=e;let r=t.normalize();if(void 0===r||r.isEqualTo(XYZ.zero))throw Error("direction can not be zero");this.direction=r}intersect(e){if(this.direction.isParallelTo(e.direction))return;let t=this.nearestTo(e);return t.sub(e.location).isParallelTo(e.direction)?t:void 0}nearestTo(e){let t=e.direction.cross(this.direction).normalize();if(void 0===t)return this.nearestToPoint(e.location);let r=t.cross(e.direction).normalize();return new Plane(e.location,r,t).intersect(this)}nearestToPoint(e){let t=e.sub(this.location).dot(this.direction);return this.location.add(this.direction.multiply(t))}};function xy_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}ray_ts_decorate([P.serialze()],Ray.prototype,"location",void 0),ray_ts_decorate([P.serialze()],Ray.prototype,"direction",void 0),Ray=ray_ts_decorate([P.register(["location","direction"])],Ray);let XY=class XY{static zero=new XY(0,0);static unitX=new XY(1,0);static unitY=new XY(0,1);x;y;constructor(e,t){this.x=e,this.y=t}cross(e){return this.x*e.y-this.y*e.x}dot(e){return this.x*e.x+this.y*e.y}divided(e){return Math.abs(e)=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}xy_ts_decorate([P.serialze()],XY.prototype,"x",void 0),xy_ts_decorate([P.serialze()],XY.prototype,"y",void 0),XY=xy_ts_decorate([P.register(["x","y"])],XY);let Texture=class Texture extends HistoryObservable{get image(){return this.getPrivateValue("image","")}set image(e){this.setProperty("image",e)}get wrapS(){return this.getPrivateValue("wrapS",1e3)}set wrapS(e){this.setProperty("wrapS",e)}get wrapT(){return this.getPrivateValue("wrapT",1e3)}set wrapT(e){this.setProperty("wrapT",e)}get rotation(){return this.getPrivateValue("rotation",0)}set rotation(e){this.setProperty("rotation",e)}get offset(){return this.getPrivateValue("offset",new XY(0,0))}set offset(e){this.setProperty("offset",e)}get repeat(){return this.getPrivateValue("repeat",new XY(1,1))}set repeat(e){this.setProperty("repeat",e)}center=new XY(.5,.5)};material_ts_decorate([P.serialze(),D.define("material.texture.image")],Texture.prototype,"image",null),material_ts_decorate([P.serialze()],Texture.prototype,"wrapS",null),material_ts_decorate([P.serialze()],Texture.prototype,"wrapT",null),material_ts_decorate([P.serialze(),D.define("material.texture.rotation")],Texture.prototype,"rotation",null),material_ts_decorate([P.serialze(),D.define("material.texture.offset")],Texture.prototype,"offset",null),material_ts_decorate([P.serialze(),D.define("material.texture.repeat")],Texture.prototype,"repeat",null),material_ts_decorate([P.serialze()],Texture.prototype,"center",void 0),Texture=material_ts_decorate([P.register(["document"])],Texture);let Material=class Material extends HistoryObservable{vertexColors=!1;transparent=!0;id;get name(){return this.getPrivateValue("name")}set name(e){this.setProperty("name",e)}get color(){return this.getPrivateValue("color")}set color(e){this.setProperty("color",e)}get opacity(){return this.getPrivateValue("opacity",1)}set opacity(e){this.setProperty("opacity",e)}get map(){return this.getPrivateValue("map",new Texture(this.document))}set map(e){this.setProperty("map",e)}constructor(e,t,r,i=Id.generate()){super(e),this.id=i,this.setPrivateValue("name",t?.length>0?t:"unnamed"),this.setPrivateValue("color",r)}clone(){let e=new Material(this.document,`${this.name} clone`,this.color);return e.setPrivateValue("map",this.map),e}};material_ts_decorate([P.serialze()],Material.prototype,"vertexColors",void 0),material_ts_decorate([P.serialze()],Material.prototype,"transparent",void 0),material_ts_decorate([P.serialze()],Material.prototype,"id",void 0),material_ts_decorate([P.serialze(),D.define("common.name")],Material.prototype,"name",null),material_ts_decorate([P.serialze(),D.define("common.color",{type:"color"})],Material.prototype,"color",null),material_ts_decorate([P.serialze(),D.define("common.opacity")],Material.prototype,"opacity",null),material_ts_decorate([P.serialze(),D.define("material.map")],Material.prototype,"map",null),Material=material_ts_decorate([P.register(["document","name","color","id"])],Material);let PhongMaterial=class PhongMaterial extends Material{get specular(){return this.getPrivateValue("specular",1118481)}set specular(e){this.setProperty("specular",e)}get shininess(){return this.getPrivateValue("shininess",30)}set shininess(e){this.setProperty("shininess",e)}get emissive(){return this.getPrivateValue("emissive",0)}set emissive(e){this.setProperty("emissive",e)}get specularMap(){return this.getPrivateValue("specularMap",new Texture(this.document))}set specularMap(e){this.setProperty("specularMap",e)}get bumpMap(){return this.getPrivateValue("bumpMap",new Texture(this.document))}set bumpMap(e){this.setProperty("bumpMap",e)}get normalMap(){return this.getPrivateValue("normalMap",new Texture(this.document))}set normalMap(e){this.setProperty("normalMap",e)}get emissiveMap(){return this.getPrivateValue("emissiveMap",new Texture(this.document))}set emissiveMap(e){this.setProperty("emissiveMap",e)}};material_ts_decorate([P.serialze(),D.define("material.specular",{type:"color"})],PhongMaterial.prototype,"specular",null),material_ts_decorate([P.serialze(),D.define("material.shininess")],PhongMaterial.prototype,"shininess",null),material_ts_decorate([P.serialze(),D.define("material.emissive",{type:"color"})],PhongMaterial.prototype,"emissive",null),material_ts_decorate([P.serialze(),D.define("material.specularMap")],PhongMaterial.prototype,"specularMap",null),material_ts_decorate([P.serialze(),D.define("material.bumpMap")],PhongMaterial.prototype,"bumpMap",null),material_ts_decorate([P.serialze(),D.define("material.normalMap")],PhongMaterial.prototype,"normalMap",null),material_ts_decorate([P.serialze(),D.define("material.emissiveMap")],PhongMaterial.prototype,"emissiveMap",null),PhongMaterial=material_ts_decorate([P.register(["document","name","color","id"])],PhongMaterial);let PhysicalMaterial=class PhysicalMaterial extends Material{get metalness(){return this.getPrivateValue("metalness",0)}set metalness(e){this.setProperty("metalness",e)}get metalnessMap(){return this.getPrivateValue("metalnessMap",new Texture(this.document))}set metalnessMap(e){this.setProperty("metalnessMap",e)}get roughness(){return this.getPrivateValue("roughness",1)}set roughness(e){this.setProperty("roughness",e)}get roughnessMap(){return this.getPrivateValue("roughnessMap",new Texture(this.document))}set roughnessMap(e){this.setProperty("roughnessMap",e)}get emissive(){return this.getPrivateValue("emissive",0)}set emissive(e){this.setProperty("emissive",e)}get bumpMap(){return this.getPrivateValue("bumpMap",new Texture(this.document))}set bumpMap(e){this.setProperty("bumpMap",e)}get normalMap(){return this.getPrivateValue("normalMap",new Texture(this.document))}set normalMap(e){this.setProperty("normalMap",e)}get emissiveMap(){return this.getPrivateValue("emissiveMap",new Texture(this.document))}set emissiveMap(e){this.setProperty("emissiveMap",e)}};material_ts_decorate([P.serialze(),D.define("material.metalness")],PhysicalMaterial.prototype,"metalness",null),material_ts_decorate([P.serialze(),D.define("material.metalnessMap")],PhysicalMaterial.prototype,"metalnessMap",null),material_ts_decorate([P.serialze(),D.define("material.roughness")],PhysicalMaterial.prototype,"roughness",null),material_ts_decorate([P.serialze(),D.define("material.roughnessMap")],PhysicalMaterial.prototype,"roughnessMap",null),material_ts_decorate([P.serialze(),D.define("material.emissive",{type:"color"})],PhysicalMaterial.prototype,"emissive",null),material_ts_decorate([P.serialze(),D.define("material.bumpMap")],PhysicalMaterial.prototype,"bumpMap",null),material_ts_decorate([P.serialze(),D.define("material.normalMap")],PhysicalMaterial.prototype,"normalMap",null),material_ts_decorate([P.serialze(),D.define("material.emissiveMap")],PhysicalMaterial.prototype,"emissiveMap",null),PhysicalMaterial=material_ts_decorate([P.register(["document","name","color","id"])],PhysicalMaterial);var ee=((c={})[c.Line=0]="Line",c[c.Circle=1]="Circle",c[c.Ellipse=2]="Ellipse",c[c.Hyperbola=3]="Hyperbola",c[c.Parabola=4]="Parabola",c[c.BezierCurve=5]="BezierCurve",c[c.BSplineCurve=6]="BSplineCurve",c[c.OffsetCurve=7]="OffsetCurve",c[c.OtherCurve=8]="OtherCurve",c[c.TrimmedCurve=9]="TrimmedCurve",c),et=((d={})[d.C0=0]="C0",d[d.G1=1]="G1",d[d.C1=2]="C1",d[d.G2=3]="G2",d[d.C2=4]="C2",d[d.C3=5]="C3",d[d.CN=6]="CN",d);!function(e){function isConic(e){return void 0!==e.axis}function isCircle(e){return void 0!==e.center&&void 0!==e.radius}function isLine(e){return void 0!==e.direction}e.isConic=isConic,e.isCircle=isCircle,e.isLine=isLine}(O||(O={}));var er=((h={})[h.Curve=0]="Curve",h[h.Surface=1]="Surface",h),ei=((p={})[p.Solid=0]="Solid",p[p.Dash=1]="Dash",p);function meshData_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}let MeshGroup=class MeshGroup{start;count;materialId;constructor(e,t,r){this.start=e,this.count=t,this.materialId=r}};meshData_ts_decorate([P.serialze()],MeshGroup.prototype,"start",void 0),meshData_ts_decorate([P.serialze()],MeshGroup.prototype,"count",void 0),meshData_ts_decorate([P.serialze()],MeshGroup.prototype,"materialId",void 0),MeshGroup=meshData_ts_decorate([P.register(["start","count","materialId"])],MeshGroup);let Mesh=class Mesh{static createSurface(){let e=new Mesh;return e.meshType="surface",e.normal=[],e.uv=[],e}meshType="line";position=[];normal=void 0;index=void 0;color=4095;uv=void 0;groups=[]};function arrayNeedsUint32(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}meshData_ts_decorate([P.serialze()],Mesh.prototype,"meshType",void 0),meshData_ts_decorate([P.serialze()],Mesh.prototype,"position",void 0),meshData_ts_decorate([P.serialze()],Mesh.prototype,"normal",void 0),meshData_ts_decorate([P.serialze()],Mesh.prototype,"index",void 0),meshData_ts_decorate([P.serialze()],Mesh.prototype,"color",void 0),meshData_ts_decorate([P.serialze()],Mesh.prototype,"uv",void 0),meshData_ts_decorate([P.serialze()],Mesh.prototype,"groups",void 0),Mesh=meshData_ts_decorate([P.register([])],Mesh),function(e){function isVertex(e){return e?.size!==void 0}function isEdge(e){return e?.lineType!==void 0}function isFace(e){return e?.indices!==void 0}e.isVertex=isVertex,e.isEdge=isEdge,e.isFace=isFace}(M||(M={})),function(e){function from(e,t,r){return{positions:new Float32Array([e.x,e.y,e.z]),groups:[],color:r,size:t}}e.from=from}(E||(E={})),function(e){function from(e,t,r,i){return{positions:new Float32Array([e.x,e.y,e.z,t.x,t.y,t.z]),color:r,lineType:i,groups:[]}}e.from=from}(R||(R={}));let MeshDataBuilder=class MeshDataBuilder{_positions=[];_groups=[];_color;_vertexColor;setColor(e){this._color=e}addColor(e,t,r){return void 0===this._vertexColor&&(this._vertexColor=[]),this._vertexColor.push(e,t,r),this}getColor(){let e=this._vertexColor;return this._vertexColor?.length!==this._positions.length&&(e=this._color),e}};let EdgeMeshDataBuilder=class EdgeMeshDataBuilder extends MeshDataBuilder{_positionStart=0;_previousVertex=void 0;_lineType=ei.Solid;constructor(){super(),this._color=$.defaultEdgeColor}setType(e){this._lineType=e}newGroup(){return this._positionStart=this._positions.length,this._previousVertex=void 0,this}endGroup(e){return this._groups.push({start:this._positionStart/3,count:(this._positions.length-this._positionStart)/3,shape:e}),this}addPosition(e,t,r){return this._previousVertex&&this._positions.push(...this._previousVertex,e,t,r),this._previousVertex=[e,t,r],this}build(){let e=this.getColor();return{positions:new Float32Array(this._positions),groups:this._groups,lineType:this._lineType,color:e}}};var ea=((u={})[u.FORWARD=0]="FORWARD",u[u.REVERSED=1]="REVERSED",u[u.INTERNAL=2]="INTERNAL",u[u.EXTERNAL=3]="EXTERNAL",u),es=((m={})[m.arc=0]="arc",m[m.tangent=1]="tangent",m[m.intersection=2]="intersection",m),en=((g={})[g.Shape=0]="Shape",g[g.Compound=1]="Compound",g[g.CompoundSolid=2]="CompoundSolid",g[g.Solid=4]="Solid",g[g.Shell=8]="Shell",g[g.Face=16]="Face",g[g.Wire=32]="Wire",g[g.Edge=64]="Edge",g[g.Vertex=128]="Vertex",g);!function(e){function isWhole(e){return 0===e||1===e||2===e||4===e}function hasCompound(e){return(1&e)!=0}function hasCompoundSolid(e){return(2&e)!=0}function hasSolid(e){return(4&e)!=0}function hasShell(e){return(8&e)!=0}function hasFace(e){return(16&e)!=0}function hasWire(e){return(32&e)!=0}function hasEdge(e){return(64&e)!=0}function hasVertex(e){return(128&e)!=0}e.isWhole=isWhole,e.hasCompound=hasCompound,e.hasCompoundSolid=hasCompoundSolid,e.hasSolid=hasSolid,e.hasShell=hasShell,e.hasFace=hasFace,e.hasWire=hasWire,e.hasEdge=hasEdge,e.hasVertex=hasVertex}(en||(en={}));var eo=((f={})[f.Plate=0]="Plate",f[f.Bezier=1]="Bezier",f[f.BSpline=2]="BSpline",f[f.RectangularTrimmed=3]="RectangularTrimmed",f[f.Conical=4]="Conical",f[f.Cylinder=5]="Cylinder",f[f.Plane=6]="Plane",f[f.Spherical=7]="Spherical",f[f.Toroidal=8]="Toroidal",f[f.Revolution=9]="Revolution",f[f.Extrusion=10]="Extrusion",f[f.Offset=11]="Offset",f[f.Composite=12]="Composite",f);function node_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}!function(e){function isLinkedListNode(e){return void 0!==e.add}e.isLinkedListNode=isLinkedListNode}(z||(z={}));let Node=class Node extends HistoryObservable{parent;previousSibling;nextSibling;id;constructor(e,t,r){super(e),this.id=r,this.setPrivateValue("name",t||"untitled")}get name(){return this.getPrivateValue("name")}set name(e){this.setProperty("name",e)}get visible(){return this.getPrivateValue("visible",!0)}set visible(e){this.setProperty("visible",e,()=>this.onVisibleChanged())}get parentVisible(){return this.getPrivateValue("parentVisible",!0)}set parentVisible(e){this.setProperty("parentVisible",e,()=>this.onParentVisibleChanged())}disposeInternal(){this.document.visual.context.removeNode([this]),super.disposeInternal()}clone(){let e=P.serializeObject(this);e.properties.id=Id.generate(),e.properties.name=`${this.name}_copy`;let t=P.deserializeObject(this.document,e);return this.parent?.add(t),t}};node_ts_decorate([P.serialze()],Node.prototype,"id",void 0),node_ts_decorate([P.serialze(),D.define("common.name")],Node.prototype,"name",null),node_ts_decorate([P.serialze()],Node.prototype,"visible",null),function(e){function getNodesBetween(e,t){if(e===t)return[e];let r=[],i=getPathToRoot(e),a=getPathToRoot(t),s=getCommonParentIndex(i,a),n=i.at(1-s);if(n===a[0]||n===i[0]){let e=n===a[0]?i[0]:a[0];getNodesFromParentToChild(r,n,e)}else currentAtBack(i.at(-s),a.at(-s))?getNodesFromPath(r,i,a,s):getNodesFromPath(r,a,i,s);return r}function getNodesFromPath(e,t,r,i){nodeOrChildrenAppendToNodes(e,t[0]),path1ToCommonNodes(e,t,i),commonToPath2Nodes(e,t,r,i)}function path1ToCommonNodes(t,r,i){for(let a=0;a{this.onTransformChanged(e,r)},{equals:(e,t)=>e.equals(t)})}onVisibleChanged(){this.document.visual.context.setVisible(this,this.visible&&this.parentVisible)}onParentVisibleChanged(){this.document.visual.context.setVisible(this,this.visible&&this.parentVisible)}onTransformChanged(e,t){}};node_ts_decorate([P.serialze()],VisualNode.prototype,"transform",null);let MeshNode=class MeshNode extends VisualNode{display(){return"body.meshNode"}get materialId(){return this.getPrivateValue("materialId")}set materialId(e){this.setProperty("materialId",e)}_mesh;get mesh(){return this._mesh}set mesh(e){this.setProperty("mesh",e)}constructor(e,t,r,i,a=Id.generate()){super(e,r,a),this._mesh=t,this.setPrivateValue("materialId",i??e.materials.at(0)?.id??"")}boundingBox(){let e=this.transform.ofPoints(this.mesh.position);return BoundingBox.fromNumbers(e)}};node_ts_decorate([P.serialze(),D.define("common.material",{type:"materialId"})],MeshNode.prototype,"materialId",null),node_ts_decorate([P.serialze()],MeshNode.prototype,"mesh",null),MeshNode=node_ts_decorate([P.register(["document","mesh","name","id"])],MeshNode);let GeometryNode=class GeometryNode extends VisualNode{get materialId(){return this.getPrivateValue("materialId")}set materialId(e){this.setProperty("materialId",e)}constructor(e,t,r,i=Id.generate()){super(e,t,i),this.setPrivateValue("materialId",r??e.materials.at(0)?.id??"")}_mesh;get mesh(){return void 0===this._mesh&&(this._mesh=this.createMesh()),this._mesh}_boundingBox;boundingBox(){if(void 0===this._boundingBox){let e=this.mesh.faces?.positions??this.mesh.edges?.positions??[];return e=this.transform.ofPoints(e),BoundingBox.fromNumbers(e)}return this._boundingBox}disposeInternal(){super.disposeInternal(),this._mesh=void 0}};function shapeNode_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}node_ts_decorate([P.serialze(),D.define("common.material",{type:"materialId"})],GeometryNode.prototype,"materialId",null),function(e){function serialize(e){let t=[];return serializeNodeToArray(t,e,void 0),t}function serializeNodeToArray(e,t,r){let i=P.serializeObject(t);return r&&(i.parentId=r),e.push(i),z.isLinkedListNode(t)&&t.firstChild&&serializeNodeToArray(e,t.firstChild,t.id),t.nextSibling&&serializeNodeToArray(e,t.nextSibling,r),e}async function deserialize(e,t){let r=new Map;return t.forEach(t=>{let i=P.deserializeObject(e,t);z.isLinkedListNode(i)&&r.set(t.properties.id,i);let a=t.parentId;a&&(r.has(a)?r.get(a).add(i):console.warn("parent not found: "+a))}),Promise.resolve(r.get(t[0].properties.id))}e.serialize=serialize,e.deserialize=deserialize}(A||(A={}));let ShapeNode=class ShapeNode extends GeometryNode{_shape=Result.err(el);get shape(){return this._shape}setShape(e){if(this._shape.isOk&&this._shape.value.isEqual(e.value))return;if(!e.isOk){PubSub.default.pub("displayError",e.error);return}let t=this._shape;this._shape=e,this._mesh=void 0,this._boundingBox=void 0,this._shape.value.matrix=this.transform,this.emitPropertyChanged("shape",t),t.unchecked()?.dispose()}onTransformChanged(e){this.shape.isOk&&(this.shape.value.matrix=e)}createMesh(){if(!this.shape.isOk)throw Error(this.shape.error);return this.shape.value.mesh}disposeInternal(){super.disposeInternal(),this._shape.unchecked()?.dispose(),this._shape=null}};let ManyMesh=class ManyMesh{shapes;_edges;_faces;get edges(){return this._edges.positions.length>0?this._edges:void 0}get faces(){return this._faces.positions.length>0?this._faces:void 0}constructor(e){for(let t of(this.shapes=e,this._edges={lineType:ei.Solid,positions:new Float32Array,groups:[],color:$.defaultEdgeColor},this._faces={indices:new Uint16Array,normals:new Float32Array,positions:new Float32Array,uvs:new Float32Array,groups:[],color:$.defaultFaceColor},e))this.combineShape(t)}combineShape(e){let{mesh:t,matrix:r}=e;t.faces&&this.combineFace(t.faces,r),t.edges&&this.combineEdge(t.edges,r)}combineFace(e,t){if(!e)return;let r=this._faces.positions.length/3;this._faces.indices=this.combineUintArray(this._faces.indices,e.indices),this._faces.normals=this.combineFloat32Array(this._faces.normals,t.ofVectors(e.normals)),this._faces.uvs=this.combineFloat32Array(this._faces.uvs,e.uvs),this._faces.positions=this.combineFloat32Array(this._faces.positions,t.ofPoints(e.positions)),this._faces.groups=this._faces.groups.concat(e.groups.map(e=>({start:e.start+r,shape:e.shape,count:e.count})))}combineFloat32Array(e,t){let r=new Float32Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}combineUintArray(e,t){let r;return e instanceof Uint16Array&&t instanceof Uint16Array?r=new Uint16Array(e.length+t.length):r=new Uint32Array(e.length+t.length),r.set(e),r.set(t,e.length),r}combineEdge(e,t){if(!e)return;let r=this._edges.positions.length/3;this._edges.positions=this.combineFloat32Array(this._edges.positions,e.positions),this._edges.groups=this._edges.groups.concat(e.groups.map(e=>({start:e.start+r,shape:e.shape,count:e.count})))}updateMeshShape(){}};let MultiShapeNode=class MultiShapeNode extends GeometryNode{_shapes;get shapes(){return this._shapes}constructor(e,t,r,i,a=Id.generate()){super(e,t,i,a),this._shapes=r}createMesh(){return new ManyMesh(this._shapes)}display(){return"body.multiShape"}};shapeNode_ts_decorate([P.serialze()],MultiShapeNode.prototype,"shapes",null),MultiShapeNode=shapeNode_ts_decorate([P.register(["document","name","shapes","materialId","id"])],MultiShapeNode);let el="Shape not initialized";let ParameterShapeNode=class ParameterShapeNode extends ShapeNode{get shape(){return this._shape.isOk||this._shape.error!==el||(this._shape=this.generateShape()),this._shape}setPropertyEmitShapeChanged(e,t,r,i){return!!this.setProperty(e,t,r,i)&&(this.setShape(this.generateShape()),!0)}constructor(e,t,r){super(e,void 0,t,r),this.setPrivateValue("name",k.translate(this.display()))}};let EditableShapeNode=class EditableShapeNode extends ShapeNode{display(){return"body.editableShape"}get shape(){return this._shape}set shape(e){this.setShape(e)}constructor(e,t,r,i,a){super(e,t,i,a),this._shape=r instanceof Result?r:Result.ok(r),this.setPrivateValue("transform",this._shape.value.matrix)}};function facebaseNode_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}shapeNode_ts_decorate([P.serialze()],EditableShapeNode.prototype,"shape",null),EditableShapeNode=shapeNode_ts_decorate([P.register(["document","name","shape","materialId","id"])],EditableShapeNode);let FacebaseNode=class FacebaseNode extends ParameterShapeNode{get isFace(){return this.getPrivateValue("isFace",!1)}set isFace(e){this.setProperty("isFace",e)}};function folderNode_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}facebaseNode_ts_decorate([P.serialze(),D.define("command.faceable.isFace")],FacebaseNode.prototype,"isFace",null);let FolderNode=class FolderNode extends Node{_count=0;_firstChild;_lastChild;get firstChild(){return this._firstChild}get lastChild(){return this._lastChild}get count(){return this._count}size(){return this._count}constructor(e,t,r=Id.generate()){super(e,t,r)}add(...e){let t=e.map(e=>({action:L.add,node:e,oldParent:void 0,oldPrevious:void 0,newParent:this,newPrevious:this._lastChild}));e.forEach(e=>{this.initNode(e)&&this.addToLast(e),this._count++}),this.document.notifyNodeChanged(t)}initNode(e){return e.parent=this,!!this._firstChild||(this._firstChild=this._lastChild=e,e.previousSibling=e.nextSibling=void 0,!1)}addToLast(e){this._lastChild.nextSibling=e,e.previousSibling=this._lastChild,e.nextSibling=void 0,this._lastChild=e}remove(...e){let t=e.filter(e=>this.validateChild(e)).map(e=>({action:L.remove,node:e,newParent:void 0,newPrevious:void 0,oldParent:this,oldPrevious:e.previousSibling}));t.forEach(e=>this.removeNode(e.node,!0)),this.document.notifyNodeChanged(t)}validateChild(e){return e.parent===this||(Logger.warn(`${e.name} is not a child node of the ${this.name} node`),!1)}removeNode(e,t){t&&(e.parent=void 0),e===this._firstChild?this.removeFirstNode(e):e===this._lastChild?this.removeLastNode(e):this.removeMiddleNode(e),this._count--}removeFirstNode(e){e===this._lastChild?this._firstChild=this._lastChild=void 0:(this._firstChild=e.nextSibling,this._firstChild.previousSibling=void 0,e.nextSibling=void 0)}removeLastNode(e){this._lastChild=e.previousSibling,this._lastChild.nextSibling=void 0,e.previousSibling=void 0}removeMiddleNode(e){e.previousSibling.nextSibling=e.nextSibling,e.nextSibling.previousSibling=e.previousSibling,e.previousSibling=e.nextSibling=void 0}insertBefore(e,t){if(e&&!this.validateChild(e))return;let r={action:L.insertBefore,node:t,oldParent:void 0,oldPrevious:void 0,newParent:this,newPrevious:e?.previousSibling};this.initNode(t)&&(e&&e!==this._firstChild?this.insertBetweenNodes(e.previousSibling,t,e):this.insertAsFirst(t)),this._count++,this.document.notifyNodeChanged([r])}insertAsFirst(e){this._firstChild.previousSibling=e,e.nextSibling=this._firstChild,this._firstChild=e}insertBetweenNodes(e,t,r){e.nextSibling=t,t.previousSibling=e,t.nextSibling=r,r.previousSibling=t}insertAfter(e,t){if(e&&!this.validateChild(e))return;let r={action:L.insertAfter,oldParent:void 0,oldPrevious:void 0,newParent:this,newPrevious:e,node:t};this.initNode(t)&&(e?e===this._lastChild?this.addToLast(t):this.insertBetweenNodes(e,t,e.nextSibling):this.insertAsFirst(t)),this._count++,this.document.notifyNodeChanged([r])}move(e,t,r){if(r&&r.parent!==t){Logger.warn(`${r.name} is not a child node of the ${t.name} node`);return}let i={action:L.move,oldParent:e.parent,oldPrevious:e.previousSibling,newParent:t,newPrevious:r,node:e};this.removeNode(e,!1),t.initNode(e)&&(r?r===t._lastChild?t.addToLast(e):t.insertBetweenNodes(r,e,r.nextSibling):t.insertAsFirst(e)),t._count++,this.document.notifyNodeChanged([i])}disposeInternal(){this.disposeNodes(this._firstChild),super.disposeInternal()}disposeNodes=e=>{e instanceof FolderNode&&this.disposeNodes(e.firstChild);let t=e?.nextSibling;for(e&&(e.nextSibling=null);t;){let e=t.nextSibling;t.previousSibling=null,t.nextSibling=null,t.dispose(),t=e}e?.dispose()};onVisibleChanged(){this.setChildrenParentVisible()}onParentVisibleChanged(){this.setChildrenParentVisible()}setChildrenParentVisible(){let e=this._firstChild;for(;void 0!==e;)e.parentVisible=this.visible&&this.parentVisible,e=e.nextSibling}};function groupNode_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}FolderNode=folderNode_ts_decorate([P.register(["document","name","id"])],FolderNode);let GroupNode=class GroupNode extends FolderNode{get transform(){return this.getPrivateValue("transform",Matrix4.identity())}set transform(e){this.setProperty("transform",e,void 0,{equals:(e,t)=>e.equals(t)})}};groupNode_ts_decorate([P.serialze()],GroupNode.prototype,"transform",null),GroupNode=groupNode_ts_decorate([P.register(["document","name","id"])],GroupNode);let ShapeNodeFilter=class ShapeNodeFilter{allow(e){return e instanceof ShapeNode}};var ec=((y={})[y.large=0]="large",y[y.small=1]="small",y);let Combobox=class Combobox extends Observable{converter;constructor(e){super(),this.converter=e,this.items=new ObservableCollection}get selectedIndex(){return this.getPrivateValue("selectedIndex",0)}set selectedIndex(e){!(e<0)&&!(e>=this.items.length)&&this.setProperty("selectedIndex",e)}get selectedItem(){return this.items.at(this.selectedIndex)}items};var ed=((v={})[v.perspective=0]="perspective",v[v.orthographic=1]="orthographic",v);!function(e){function screenDistance(e,t,r,i){let a=e.worldToScreen(i),s=a.x-t,n=a.y-r;return Math.sqrt(s*s+n*n)}e.screenDistance=screenDistance}(F||(F={})),function(e){function isGeometry(e){return void 0!==e.geometryNode}e.isGeometry=isGeometry}(j||(j={}));var eh=((_={})[_.normal=0]="normal",_[_.highlighter=1]="highlighter",_[_.selected=2]="selected",_);!function(e){function addState(e,t){return e|t}function removeState(e,t){return e&t^e}function hasState(e,t){return(e&t)===t}e.addState=addState,e.removeState=removeState,e.hasState=hasState}(eh||(eh={}))},8715:function(e,t,r){r.d(t,{S:()=>GeoUtils,j:()=>MeshUtils});var i=r(2986);let MeshUtils=class MeshUtils{static subFace(e,t){let r=e?.groups[t];if(!r)return;let a=e.indices.slice(r.start,r.start+r.count),{min:s,max:n}=i.M8.minMax(a),[o,l]=[s,n+1];return{positions:e.positions.slice(3*o,3*l),normals:e.normals.slice(3*o,3*l),indices:a.map(e=>e-o),uvs:e.uvs.slice(2*o,2*l),groups:[],color:e.color}}static subFaceOutlines(e,t){let r=this.subFace(e,t);if(r)return this.faceOutline(r)}static addEdge(e,t,r,i){let a=r1===e.count).flatMap(e=>e.points))}static subEdge(e,t){let r=e?.groups[t];if(r)return e.positions.slice(3*r.start,(r.start+r.count)*3)}};let GeoUtils=class GeoUtils{static nearestPoint(e,t){let r,a=Number.MAX_VALUE;for(let s of e.findSubShapes(i.ax.Edge)){let e=s.curve().nearestFromPoint(t);e.distance{let i=e.intersect(t);i.length>0&&r.push(...i)}),r}}},492:function(e,t,r){r.d(t,{zK:()=>SubshapeSelectionHandler,b3:()=>ViewUtils,t:()=>NodeSelectionHandler,k8:()=>ShapeSelectionHandler});var i=r(2986);let a=` border: 1px solid #55aaff; background-color: rgba(75, 160, 255, 0.3); position: absolute; pointer-events: none; display: none; left: 0px; right: 0px; width: 0px; height: 0px; `;let SelectionHandler=class SelectionHandler{document;multiMode;controller;rect;mouse;constructor(e,t,r){this.document=e,this.multiMode=t,this.controller=r,this.mouse={isDown:!1,x:0,y:0},r?.onCancelled(t=>{this.clearSelected(e),this.cleanHighlights()})}dispose(){}pointerDown(e,t){t.preventDefault(),0===t.button&&(this.mouse={isDown:!0,x:t.offsetX,y:t.offsetY},this.multiMode&&(this.rect=this.initRect(t)))}initRect(e){let t=document.createElement("div");return t.style.cssText=a,document.body.appendChild(t),{element:t,clientX:e.clientX,clientY:e.clientY}}updateRect(e,t){e.element.style.display="block";let[r,i]=[Math.min(e.clientX,t.clientX),Math.min(e.clientY,t.clientY)],[a,s]=[Math.max(e.clientX,t.clientX),Math.max(e.clientY,t.clientY)];Object.assign(e.element.style,{left:`${r}px`,top:`${i}px`,width:`${a-r}px`,height:`${s-i}px`})}pointerOut(e,t){this.mouse.isDown=!1,this.removeRect(e),this.cleanHighlights()}pointerUp(e,t){if(t.preventDefault(),this.mouse.isDown&&0===t.button){this.mouse.isDown=!1,this.removeRect(e);let r=this.select(e,t);this.cleanHighlights(),e.update(),r>0&&!this.multiMode&&this.controller?.success()}}removeRect(e){this.rect?.element.remove(),this.rect=void 0}keyDown(e,t){"Escape"===t.key?(this.controller?this.controller.cancel():this.clearSelected(e.document.visual.document),this.cleanHighlights()):"Enter"===t.key?(this.cleanHighlights(),this.controller?.success()):"Tab"===t.key&&(t.preventDefault(),this.highlightNext(e))}};let ShapeSelectionHandler=class ShapeSelectionHandler extends SelectionHandler{shapeType;filter;_highlights;_detectAtMouse;_lockDetected;constructor(e,t,r,i,a){super(e,r,i),this.shapeType=t,this.filter=a}pointerMove(e,t){if(4===t.buttons)return;this._detectAtMouse=void 0,this.rect&&this.updateRect(this.rect,t);let r=this.getDetecteds(e,t);this.setHighlight(e,r)}getDetecteds(e,t){if(this.rect&&this.mouse.x!==t.offsetX&&this.mouse.y!==t.offsetY)return e.detectShapesRect(this.shapeType,this.mouse.x,this.mouse.y,t.offsetX,t.offsetY,this.filter);this._detectAtMouse=e.detectShapes(this.shapeType,t.offsetX,t.offsetY,this.filter);let r=this.getDetecting();return r?[r]:[]}setHighlight(e,t){this.cleanHighlights(),t.forEach(t=>{e.document.visual.highlighter.addState(t.owner,i.tR.highlighter,this.shapeType,...t.indexes)}),this._highlights=t,e.update()}cleanHighlights(){this._highlights?.forEach(e=>{e.owner.geometryNode.document.visual.highlighter.removeState(e.owner,i.tR.highlighter,this.shapeType,...e.indexes)}),this._highlights=void 0}highlightNext(e){if(this._detectAtMouse&&this._detectAtMouse.length>1){let t=this._lockDetected?(this.getDetcedtingIndex()+1)%this._detectAtMouse.length:1;this._lockDetected=this._detectAtMouse[t].shape;let r=this.getDetecting();r&&this.setHighlight(e,[r])}}getDetecting(){if(this._detectAtMouse){let e=this._lockDetected?this.getDetcedtingIndex():0;return this._detectAtMouse[e]}}getDetcedtingIndex(){return this._detectAtMouse?.findIndex(e=>this._lockDetected===e.shape)??-1}};let NodeSelectionHandler=class NodeSelectionHandler extends SelectionHandler{filter;_highlights;_detectAtMouse;_lockDetected;nodes(){return this.document.selection.getSelectedNodes()}constructor(e,t,r,i){super(e,t,r),this.filter=i}select(e,t){if(!this._highlights?.length)return this.clearSelected(this.document),0;let r=this._highlights.map(t=>e.document.visual.context.getNode(t)).filter(e=>void 0!==e);return this.document.selection.setSelection(r,t.shiftKey),r.length}pointerMove(e,t){if(4===t.buttons)return;this._detectAtMouse=void 0,this.rect&&this.updateRect(this.rect,t);let r=this.getDetecteds(e,t);this.setHighlight(e,r)}getDetecteds(e,t){if(this.rect&&this.mouse.x!==t.offsetX&&this.mouse.y!==t.offsetY)return e.detectVisualRect(this.mouse.x,this.mouse.y,t.offsetX,t.offsetY,this.filter);this._detectAtMouse=e.detectVisual(t.offsetX,t.offsetY,this.filter);let r=this.getDetecting();return r?[r]:[]}getDetecting(){if(!this._detectAtMouse)return;let e=this._lockDetected?this.getDetcedtingIndex():0;return this._detectAtMouse[e]||void 0}getDetcedtingIndex(){if(!this._detectAtMouse)return -1;for(let e=0;e{e.document.visual.highlighter.addState(t,i.tR.highlighter,i.ax.Shape)}),this._highlights=t,e.update()}cleanHighlights(){this._highlights?.forEach(e=>{this.document.visual.highlighter.removeState(e,i.tR.highlighter,i.ax.Shape)}),this._highlights=void 0}highlightNext(e){if(this._detectAtMouse&&this._detectAtMouse.length>1){let t=this._lockDetected?(this.getDetcedtingIndex()+1)%this._detectAtMouse.length:1;this._lockDetected=this._detectAtMouse[t];let r=this.getDetecting();r&&this.setHighlight(e,[r])}}clearSelected(e){e.selection.clearSelection()}};let SubshapeSelectionHandler=class SubshapeSelectionHandler extends ShapeSelectionHandler{_shapes=new Set;shapes(){return[...this._shapes]}clearSelected(e){let t=e.visual.highlighter;for(let e of this._shapes.values())t.removeState(e.owner,i.tR.selected,e.shape.shapeType,...e.indexes);this._shapes.clear()}select(e,t){let r=e.document.visual.document;return t.shiftKey?this._highlights?.forEach(e=>this._shapes.has(e)?this.removeSelected(e):this.addSelected(e)):(this.clearSelected(r),this._highlights?.forEach(this.addSelected.bind(this))),this._shapes.size}removeSelected(e){this._shapes.delete(e),e.owner.geometryNode.document.visual.highlighter.removeState(e.owner,i.tR.selected,e.shape.shapeType,...e.indexes)}addSelected(e){e.owner.geometryNode.document.visual.highlighter.addState(e.owner,i.tR.selected,this.shapeType,...e.indexes),this._shapes.add(e)}};let ViewUtils=class ViewUtils{static rayFromEye(e,t){let r=e.cameraPosition,a=t.sub(r);if(e.cameraType!==i.iM.orthographic)return new i.zH(r,a);{let r=e.direction(),s=a.dot(r),n=t.sub(r.multiply(s));return new i.zH(n,r)}}static directionAt(e,t){let r=e.cameraPosition,a=t.sub(r);return e.cameraType===i.iM.orthographic?e.direction():a}static raycastClosestPlane(e,t,r){let a=ViewUtils.rayFromEye(e,r),s=[new i.JO(t,i.vY.unitZ,i.vY.unitX),new i.JO(t,i.vY.unitX,i.vY.unitY),new i.JO(t,i.vY.unitY,i.vY.unitZ)],n=s.map(e=>e.intersect(a)?.distanceTo(t)),o=[s[0],n[0]];for(let e=1;e{var e={},t="chili3d:";__webpack_require__.l=function(r,i,a,s){if(e[r]){e[r].push(i);return}if(void 0!==a)for(var n,o,l=document.getElementsByTagName("script"),c=0;c{__webpack_require__.g.importScripts&&(e=__webpack_require__.g.location+"");var e,t=__webpack_require__.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var i=r.length-1;i>-1&&(!e||!/^http(s?):/.test(e));)e=r[i--].src}if(!e)throw Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),__webpack_require__.p=e})(),(()=>{var e={},t="chili3d",loadCssChunkData=(t,r)=>{e[r]=0},r="data-webpack-loading",loadStylesheet=function(e,i,a,s,n){var o,l,c="chunk-"+e;if(!s){for(var d=document.getElementsByTagName("link"),h=0;h{__webpack_require__.b=document.baseURI||self.location.href;var e={909:0};__webpack_require__.f.j=function(t,r){var i=__webpack_require__.o(e,t)?e[t]:void 0;if(0!==i){if(i)r.push(i[2]);else{var a=new Promise(function(r,a){i=e[t]=[r,a]});r.push(i[2]=a);var s=__webpack_require__.p+__webpack_require__.u(t),n=Error();__webpack_require__.l(s,function(r){if(__webpack_require__.o(e,t)&&(0!==(i=e[t])&&(e[t]=void 0),i)){var a=r&&("load"===r.type?"missing":r.type),s=r&&r.target&&r.target.src;n.message="Loading chunk "+t+" failed.\n("+a+": "+s+")",n.name="ChunkLoadError",n.type=a,n.request=s,i[1](n)}},"chunk-"+t,t)}}};var webpackJsonpCallback=function(t,r){var i,a,s=r[0],n=r[1],o=r[2],l=0;if(s.some(function(t){return 0!==e[t]})){for(i in n)__webpack_require__.o(n,i)&&(__webpack_require__.m[i]=n[i]);o&&o(__webpack_require__)}for(t&&t(r);l{let e;var t,r=__webpack_require__(2986),i=__webpack_require__(492);let Selection=class Selection{document;_selectedNodes;_unselectedNodes;shapeType;shapeFilter;nodeFilter;constructor(e){this.document=e,this._selectedNodes=[],this._unselectedNodes=[],this.shapeType=r.ax.Shape,this.shapeNodeFilter=e=>{if(e instanceof r.EK){let t=e.shape.value;return!t||!this.shapeFilter||this.shapeFilter.allow(t)}return!this.nodeFilter||this.nodeFilter.allow(e)}}async pickShape(e,t,r){let a=new i.zK(this.document,this.shapeType,r,t,this.shapeFilter);return await this.pickAsync(a,e,t,r),a.shapes()}async pickNode(e,t,r){let a=new i.t(this.document,r,t,this.nodeFilter);return await this.pickAsync(a,e,t,r),a.nodes()}async pickAsync(e,t,i,a,s="select.default"){let n=this.document.visual.eventHandler;this.document.visual.eventHandler=e,r.pS.default.pub("viewCursor",s),r.pS.default.pub("statusBarTip",t),a&&r.pS.default.pub("showSelectionControl",i);try{await new Promise((e,t)=>{i.onCompleted(e),i.onCancelled(t)})}catch(e){r.Yd.debug("pick status: ",e)}finally{a&&r.pS.default.pub("clearSelectionControl"),r.pS.default.pub("clearStatusBarTip"),this.document.visual.eventHandler=n,r.pS.default.pub("viewCursor","default")}}dispose(){this._selectedNodes.length=0,this._unselectedNodes.length=0}getSelectedNodes(){return this._selectedNodes}setSelection(e,t){return e=e.filter(this.shapeNodeFilter),t?this.toggleSelectPublish(e,!0):(this.removeSelectedPublish(this._selectedNodes,!1),this.addSelectPublish(e,!0)),this._selectedNodes.length}shapeNodeFilter;deselect(e){this.removeSelectedPublish(e,!0)}clearSelection(){this.removeSelectedPublish(this._selectedNodes,!0)}updateSelection(){this.document.visual.update(),r.pS.default.pub("selectionChanged",this.document,this._selectedNodes,this._unselectedNodes)}toggleSelectPublish(e,t){let r=e.filter(e=>this._selectedNodes.includes(e)),i=e.filter(e=>!this._selectedNodes.includes(e));this.removeSelectedPublish(r,!1),this.addSelectPublish(i,t)}addSelectPublish(e,t){e.forEach(e=>{if(e instanceof r.S3){let t=this.document.visual.context.getVisual(e);t&&this.document.visual.highlighter.addState(t,r.tR.selected,r.ax.Shape)}}),this._selectedNodes.push(...e),t&&this.updateSelection()}removeSelectedPublish(e,t){for(let t of e)if(t instanceof r.S3){let e=this.document.visual.context.getVisual(t);e&&this.document.visual.highlighter.removeState(e,r.tR.selected,r.ax.Shape)}this._selectedNodes=this._selectedNodes.filter(t=>!e.includes(t)),this._unselectedNodes=e,t&&this.updateSelection()}};function _ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}let Document=class Document extends r.y${application;id;visual;history;selection;materials;_nodeChangedObservers;static version="0.4.3";get name(){return this.getPrivateValue("name")}set name(e){this.name!==e&&(this.setProperty("name",e),this._rootNode&&(this._rootNode.name=e))}_rootNode;get rootNode(){return void 0===this._rootNode&&this.setRootNode(this.initRootNode()),this._rootNode}set rootNode(e){this.setRootNode(e)}setRootNode(e){this._rootNode!==e&&(this._rootNode?.removePropertyChanged(this.handleRootNodeNameChanged),this._rootNode=e??new r.YT(this,this.name),this._rootNode.onPropertyChanged(this.handleRootNodeNameChanged))}_currentNode;get currentNode(){return this._currentNode}set currentNode(e){this.setProperty("currentNode",e)}constructor(e,t,i=r.Id.generate()){super(),this.application=e,this.id=i,this.materials=new r.Vn,this._nodeChangedObservers=new Set,this.handleRootNodeNameChanged=e=>{"name"===e&&(this.name=this.rootNode.name)},this.handleMaterialChanged=e=>{e.action===r.mn.add?r.YW.add(this,{name:"MaterialChanged",dispose(){},undo:()=>this.materials.remove(...e.items),redo:()=>this.materials.push(...e.items)}):e.action===r.mn.remove&&r.YW.add(this,{name:"MaterialChanged",dispose(){},undo:()=>this.materials.push(...e.items),redo:()=>this.materials.remove(...e.items)})},this.setPrivateValue("name",t),this.history=new r.Ay,this.visual=e.visualFactory.create(this),this.selection=new Selection(this),this.materials.onCollectionChanged(this.handleMaterialChanged),e.documents.add(this),r.Yd.info(`new document: ${t}`)}handleRootNodeNameChanged;initRootNode(){return new r.YT(this,this.name)}serialize(){return{classKey:"Document",version:"0.4.3",properties:{id:this.id,name:this.name,nodes:r.qV.serialize(this.rootNode),materials:this.materials.map(e=>r.ei.serializeObject(e))}}}disposeInternal(){super.disposeInternal(),this._nodeChangedObservers.clear(),this._rootNode?.removePropertyChanged(this.handleRootNodeNameChanged),this._rootNode?.dispose(),this.visual.dispose(),this.history.dispose(),this.selection.dispose(),this.materials.forEach(e=>e.dispose()),this.materials.clear(),this._rootNode=void 0,this._currentNode=void 0}async save(){let e=this.serialize();await this.application.storage.put(r.gT.DBName,r.gT.DocumentTable,this.id,e);let t=this.application.activeView?.toImage();await this.application.storage.put(r.gT.DBName,r.gT.RecentTable,this.id,{id:this.id,name:this.name,date:Date.now(),image:t})}async close(){window.confirm(r.oc.translate("prompt.saveDocument{0}",this.name))&&await this.save();let e=this.application.views.filter(e=>e.document===this);this.application.views.remove(...e),this.application.activeView=this.application.views.at(0),this.application.documents.delete(this),this.materials.removeCollectionChanged(this.handleMaterialChanged),r.pS.default.pub("documentClosed",this),r.Yd.info(`document: ${this.name} closed`),this.dispose()}static async open(e,t){let i=await e.storage.get(r.gT.DBName,r.gT.DocumentTable,t);if(void 0===i){r.Yd.warn(`document: ${t} not find`);return}let a=await this.load(e,i);return void 0!==a&&r.Yd.info(`document: ${a.name} opened`),a}static async load(e,t){if("0.4.3"!==t.version){alert("The file version has been upgraded, no compatibility treatment was done in the development phase");return}let i=new Document(e,t.properties.name,t.properties.id);i.history.disabled=!0,i.materials.push(...t.properties.materials.map(e=>r.ei.deserializeObject(i,e)));let a=await r.qV.deserialize(i,t.properties.nodes);return i.setRootNode(a),i.history.disabled=!1,i}handleMaterialChanged;addNodeObserver(e){this._nodeChangedObservers.add(e)}removeNodeObserver(e){this._nodeChangedObservers.delete(e)}notifyNodeChanged(e){r.YW.add(this,new r.Hm(e)),this._nodeChangedObservers.forEach(t=>t.handleNodeChanged(e))}addNode(...e){(this.currentNode??this.rootNode).add(...e)}};async function importFiles(e,t){let i=e.activeView?.document??await e.newDocument("Untitled");r.pS.default.pub("showPermanent",async()=>{await r.YW.executeAsync(i,"import model",async()=>{await i.application.dataExchange.import(i,t)}),await i.application.activeView?.fitContent()},"toast.excuting{0}",r.oc.translate("command.import"))}_ts_decorate([r.ei.serialze()],Document.prototype,"rootNode",null);let Application=class Application{dataExchange;visualFactory;shapeFactory;services;storage;mainWindow;views=new r.Vn;documents=new Set;executingCommand;_activeView;get activeView(){return this._activeView}set activeView(e){this._activeView!==e&&(this._activeView=e,r.pS.default.pub("activeViewChanged",e))}constructor(t){if(void 0!==e)throw Error("Only one application can be created");e=this,this.visualFactory=t.visualFactory,this.shapeFactory=t.shapeFactory,this.services=t.services,this.storage=t.storage,this.dataExchange=t.dataExchange,this.mainWindow=t.mainWindow,this.services.forEach(e=>e.register(this)),this.services.forEach(e=>e.start()),this.initWindowEvents()}initWindowEvents(){window.onbeforeunload=this.handleWindowUnload,window.addEventListener("dragstart",e=>{e.preventDefault()},!1),window.addEventListener("dragover",e=>{e.stopPropagation(),e.preventDefault(),e.dataTransfer.dropEffect="copy"},!1),window.addEventListener("drop",e=>{e.stopPropagation(),e.preventDefault(),this.importFiles(e.dataTransfer?.files)},!1)}handleWindowUnload=e=>{this.activeView&&(e.preventDefault(),e.returnValue="")};async importFiles(e){if(!e||0===e.length)return;let{opens:t,imports:r}=this.groupFiles(e);this.loadDocumentsWithLoading(t),importFiles(this,r)}loadDocumentsWithLoading(e){r.pS.default.pub("showPermanent",async()=>{for(let t of e){let e=JSON.parse(await t.text());await this.loadDocument(e),await this.activeView?.fitContent()}},"toast.excuting{0}",r.oc.translate("command.document.open"))}groupFiles(e){let t=[],i=[];for(let a of e)a.name.endsWith(r.Gq)?t.push(a):i.push(a);return{opens:t,imports:i}}async openDocument(e){let t=await Document.open(this,e);return await this.createActiveView(t),t}async newDocument(e){let t=new Document(this,e),i=new r.F5(t,"LightGray",0xdedede),a=new r.F5(t,"DeepGray",9013641);return t.materials.push(i,a),await this.createActiveView(t),t}async loadDocument(e){let t=await Document.load(this,e);return await this.createActiveView(t),t}async createActiveView(e){if(void 0===e)return;let t=e.visual.createView("3d",r.JO.XY);this.activeView=t}};function box_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}let BoxNode=class BoxNode extends r.gR{display(){return"body.box"}get dx(){return this.getPrivateValue("dx")}set dx(e){this.setPropertyEmitShapeChanged("dx",e)}get dy(){return this.getPrivateValue("dy")}set dy(e){this.setPropertyEmitShapeChanged("dy",e)}get dz(){return this.getPrivateValue("dz")}set dz(e){this.setPropertyEmitShapeChanged("dz",e)}get plane(){return this.getPrivateValue("plane")}constructor(e,t,r,i,a){super(e),this.setPrivateValue("plane",t),this.setPrivateValue("dx",r),this.setPrivateValue("dy",i),this.setPrivateValue("dz",a)}generateShape(){return this.document.application.shapeFactory.box(this.plane,this.dx,this.dy,this.dz)}};function circle_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}box_ts_decorate([r.ei.serialze(),r.Z9.define("box.dx")],BoxNode.prototype,"dx",null),box_ts_decorate([r.ei.serialze(),r.Z9.define("box.dy")],BoxNode.prototype,"dy",null),box_ts_decorate([r.ei.serialze(),r.Z9.define("box.dz")],BoxNode.prototype,"dz",null),box_ts_decorate([r.ei.serialze()],BoxNode.prototype,"plane",null),BoxNode=box_ts_decorate([r.ei.register(["document","plane","dx","dy","dz"])],BoxNode);let CircleNode=class CircleNode extends r.Vt{display(){return"body.circle"}get center(){return this.getPrivateValue("center")}set center(e){this.setPropertyEmitShapeChanged("center",e)}get radius(){return this.getPrivateValue("radius")}set radius(e){this.setPropertyEmitShapeChanged("radius",e)}get normal(){return this.getPrivateValue("normal")}constructor(e,t,r,i){super(e),this.setPrivateValue("normal",t),this.setPrivateValue("center",r),this.setPrivateValue("radius",i)}generateShape(){let e=this.document.application.shapeFactory.circle(this.normal,this.center,this.radius);if(!e.isOk||!this.isFace)return e;let t=this.document.application.shapeFactory.wire([e.value]);return t.isOk?t.value.toFace():e}};function line_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}circle_ts_decorate([r.ei.serialze(),r.Z9.define("circle.center")],CircleNode.prototype,"center",null),circle_ts_decorate([r.ei.serialze(),r.Z9.define("circle.radius")],CircleNode.prototype,"radius",null),circle_ts_decorate([r.ei.serialze()],CircleNode.prototype,"normal",null),CircleNode=circle_ts_decorate([r.ei.register(["document","normal","center","radius"])],CircleNode);let LineNode=class LineNode extends r.gR{display(){return"body.line"}get start(){return this.getPrivateValue("start")}set start(e){this.setPropertyEmitShapeChanged("start",e)}get end(){return this.getPrivateValue("end")}set end(e){this.setPropertyEmitShapeChanged("end",e)}constructor(e,t,r){super(e),this.setPrivateValue("start",t),this.setPrivateValue("end",r)}generateShape(){return this.document.application.shapeFactory.line(this.start,this.end)}};function polygon_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}line_ts_decorate([r.ei.serialze(),r.Z9.define("line.start")],LineNode.prototype,"start",null),line_ts_decorate([r.ei.serialze(),r.Z9.define("line.end")],LineNode.prototype,"end",null),LineNode=line_ts_decorate([r.ei.register(["document","start","end"])],LineNode);let PolygonNode=class PolygonNode extends r.Vt{display(){return"body.polygon"}get points(){return this.getPrivateValue("points")}set points(e){this.setPropertyEmitShapeChanged("points",e)}constructor(e,t){super(e),this.setPrivateValue("points",t)}generateShape(){let e=this.document.application.shapeFactory.polygon(this.points);return e.isOk&&this.isFace?e.value.toFace():e}};polygon_ts_decorate([r.ei.serialze(),r.Z9.define("polygon.points")],PolygonNode.prototype,"points",null),PolygonNode=polygon_ts_decorate([r.ei.register(["document","points"])],PolygonNode);var a=__webpack_require__(8715);function prism_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}let PrismNode=class PrismNode extends r.gR{display(){return"body.prism"}get section(){return this.getPrivateValue("section")}set section(e){this.setPropertyEmitShapeChanged("section",e)}get length(){return this.getPrivateValue("length")}set length(e){this.setPropertyEmitShapeChanged("length",e)}constructor(e,t,r){super(e),this.setPrivateValue("section",t),this.setPrivateValue("length",r)}generateShape(){let e=a.S.normal(this.section).multiply(this.length);return this.document.application.shapeFactory.prism(this.section,e)}};function rect_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}prism_ts_decorate([r.ei.serialze()],PrismNode.prototype,"section",null),prism_ts_decorate([r.ei.serialze(),r.Z9.define("common.length")],PrismNode.prototype,"length",null),PrismNode=prism_ts_decorate([r.ei.register(["document","section","length"])],PrismNode);let RectNode=class RectNode extends r.Vt{display(){return"body.rect"}get dx(){return this.getPrivateValue("dx")}set dx(e){this.setPropertyEmitShapeChanged("dx",e)}get dy(){return this.getPrivateValue("dy")}set dy(e){this.setPropertyEmitShapeChanged("dy",e)}get plane(){return this.getPrivateValue("plane")}constructor(e,t,r,i){super(e),this.setPrivateValue("plane",t),this.setPrivateValue("dx",r),this.setPrivateValue("dy",i)}generateShape(){let e=RectNode.points(this.plane,this.dx,this.dy),t=this.document.application.shapeFactory.polygon(e);return t.isOk&&this.isFace?t.value.toFace():t}static points(e,t,r){let i=e.origin;return[i,i.add(e.xvec.multiply(t)),i.add(e.xvec.multiply(t)).add(e.yvec.multiply(r)),i.add(e.yvec.multiply(r)),i]}};function revolve_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}rect_ts_decorate([r.ei.serialze(),r.Z9.define("rect.dx")],RectNode.prototype,"dx",null),rect_ts_decorate([r.ei.serialze(),r.Z9.define("rect.dy")],RectNode.prototype,"dy",null),rect_ts_decorate([r.ei.serialze()],RectNode.prototype,"plane",null),RectNode=rect_ts_decorate([r.ei.register(["document","plane","dx","dy"])],RectNode);let RevolvedNode=class RevolvedNode extends r.gR{display(){return"body.revol"}get profile(){return this.getPrivateValue("profile")}set profile(e){this.setPropertyEmitShapeChanged("profile",e)}get axis(){return this.getPrivateValue("axis")}set axis(e){this.setPropertyEmitShapeChanged("axis",e)}get angle(){return this.getPrivateValue("angle")}set angle(e){this.setPropertyEmitShapeChanged("angle",e)}constructor(e,t,r,i){super(e),this.setPrivateValue("profile",t),this.setPrivateValue("axis",r),this.setPrivateValue("angle",i)}generateShape(){return this.document.application.shapeFactory.revolve(this.profile,this.axis,this.angle)}};function sweep_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}revolve_ts_decorate([r.ei.serialze()],RevolvedNode.prototype,"profile",null),revolve_ts_decorate([r.ei.serialze()],RevolvedNode.prototype,"axis",null),revolve_ts_decorate([r.ei.serialze()],RevolvedNode.prototype,"angle",null),RevolvedNode=revolve_ts_decorate([r.ei.register(["document","profile","axis","angle"])],RevolvedNode);let SweepedNode=class SweepedNode extends r.gR{display(){return"body.sweep"}get profile(){return this.getPrivateValue("profile")}set profile(e){this.setPropertyEmitShapeChanged("profile",e)}get path(){return this.getPrivateValue("path")}set path(e){this.setPropertyEmitShapeChanged("path",e)}constructor(e,t,r){super(e),this.setPrivateValue("profile",t),this.setPrivateValue("path",this.ensureWire(r))}ensureWire(e){let t=e;return e.shapeType!==r.ax.Wire&&(t=this.document.application.shapeFactory.wire([e]).value),t}generateShape(){return this.document.application.shapeFactory.sweep(this.profile,this.path)}};function newDocument_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}sweep_ts_decorate([r.ei.serialze()],SweepedNode.prototype,"profile",null),sweep_ts_decorate([r.ei.serialze()],SweepedNode.prototype,"path",null),SweepedNode=sweep_ts_decorate([r.ei.register(["document","profile","path"])],SweepedNode);let s=1;let NewDocument=class NewDocument{async execute(e){await e.newDocument(`undefined ${s++}`)}};function openDocument_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}NewDocument=newDocument_ts_decorate([(0,r.WD)({name:"doc.new",display:"command.document.new",icon:"icon-new"})],NewDocument);let OpenDocument=class OpenDocument{async execute(e){r.pS.default.pub("showPermanent",async()=>{let t=await (0,r.vZ)(".cd",!1);if(t.isOk){let r=JSON.parse(t.value[0].data),i=await e.loadDocument(r);await i?.application.activeView?.fitContent()}},"toast.excuting{0}",r.oc.translate("command.document.open"))}};function performanceTest_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}OpenDocument=openDocument_ts_decorate([(0,r.WD)({name:"doc.open",display:"command.document.open",icon:"icon-open"})],OpenDocument);let PerformanceTestCommand=class PerformanceTestCommand{size=10;gap=1;rowCols=20;async execute(e){let t=await e.newDocument("OCC Performace Test"),i=performance.now(),a=this.gap+this.size;for(let e=0;e=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}OccPerformanceTestCommand=performanceTest_ts_decorate([(0,r.WD)({name:"test.performace",display:"test.performace",icon:""})],OccPerformanceTestCommand);let SaveDocument=class SaveDocument{async execute(e){e.activeView?.document&&r.pS.default.pub("showPermanent",async()=>{await e.activeView?.document.save(),r.pS.default.pub("showToast","toast.document.saved")},"toast.excuting{0}",r.oc.translate("command.document.save"))}};function toFile_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}SaveDocument=saveDocument_ts_decorate([(0,r.WD)({name:"doc.save",display:"command.document.save",icon:"icon-save"})],SaveDocument);let SaveDocumentToFile=class SaveDocumentToFile{async execute(e){e.activeView?.document&&r.pS.default.pub("showPermanent",async()=>{await new Promise((e,t)=>{setTimeout(e,100)});let t=e.activeView?.document.serialize();r.pS.default.pub("showToast","toast.downloading"),(0,r.LR)([JSON.stringify(t)],`${e.activeView?.document.name}${r.Gq}`)},"toast.excuting{0}",r.oc.translate("command.document.saveToFile"))}};function toggleDynamicWorkplane_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}SaveDocumentToFile=toFile_ts_decorate([(0,r.WD)({name:"doc.saveToFile",display:"command.document.saveToFile",icon:"icon-download"})],SaveDocumentToFile);let ToggleDynamicWorkplaneCommand=class ToggleDynamicWorkplaneCommand{async execute(e){r.De.instance.dynamicWorkplane=!r.De.instance.dynamicWorkplane}};function boolean_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}ToggleDynamicWorkplaneCommand=toggleDynamicWorkplane_ts_decorate([(0,r.WD)({name:"workingPlane.toggleDynamic",display:"workingPlane.dynamic",toggle:new r.KX(r.De.instance,"dynamicWorkplane"),icon:"icon-dynamicPlane"})],ToggleDynamicWorkplaneCommand);let BooleanNode=class BooleanNode extends r.gR{display(){return"body.bolean"}get booleanShape(){return this.getPrivateValue("booleanShape")}constructor(e,t){super(e),this.setPrivateValue("booleanShape",t)}generateShape(){return r.x4.ok(this.booleanShape)}};boolean_ts_decorate([r.ei.serialze()],BooleanNode.prototype,"booleanShape",null),BooleanNode=boolean_ts_decorate([r.ei.register(["document","booleanShape"])],BooleanNode);var n=function(e){return e[e.None=0]="None",e[e.D1=1]="D1",e[e.D2=2]="D2",e[e.D3=4]="D3",e[e.D1D2=3]="D1D2",e[e.D1D2D3=7]="D1D2D3",e}({});!function(e){function contains(e,t){return 0!==t&&(e&t)===t}function from(e){return({1:1,2:2,3:4})[e]||0}e.contains=contains,e.from=from}(n||(n={}));let AxisSnap=class AxisSnap{point;direction;_tempLines;constructor(e,t){this.point=e,this.direction=t}snap(e){let t=e.view.up().cross(e.view.direction()).normalize(),i=t?.cross(this.direction).normalize();if(!i)return;let a=new r.JO(this.point,i,t),s=e.view.rayAt(e.mx,e.my),n=a.intersect(s,!0);if(!n)return;let o=n.sub(this.point).dot(this.direction),l=this.point.add(this.direction.multiply(o));return this.showTempLine(e.view,o),{view:e.view,point:l,distance:o,shapes:[]}}showTempLine(e,t){let i=1e-6>Math.abs(t)?1e15:1e15*t,a=r.bj.from(this.point,this.point.add(this.direction.multiply(i)),r.OI.temporaryEdgeColor,r.SP.Dash),s=e.document.visual.context.displayMesh(a);this._tempLines=[e,s]}removeDynamicObject(){this._tempLines?.[0].document.visual.context.removeMesh(this._tempLines[1])}clear(){this.removeDynamicObject()}};let BaseSnap=class BaseSnap{referencePoint;_tempMeshIds;_highlightedShapes;constructor(e){this.referencePoint=e,this._tempMeshIds=new Map,this._highlightedShapes=[]}removeDynamicObject(){this.clearTempMeshes(),this.unhighlight()}clear(){this.removeDynamicObject()}clearTempMeshes(){this._tempMeshIds.forEach((e,t)=>{e.forEach(e=>t.document.visual.context.removeMesh(e))}),this._tempMeshIds.clear()}addTempMesh(e,t){let r=this._tempMeshIds.get(e);r||(r=[],this._tempMeshIds.set(e,r)),r.push(t)}highlight(e){e.forEach(e=>{e.owner.geometryNode.document.visual.highlighter.addState(e.owner,r.tR.highlighter,e.shape.shapeType,...e.indexes)}),this._highlightedShapes.push(...e)}unhighlight(){this._highlightedShapes.forEach(e=>{e.owner.geometryNode.document.visual.highlighter.removeState(e.owner,r.tR.highlighter,e.shape.shapeType,...e.indexes)}),this._highlightedShapes.length=0}calculateDistance(e){return this.referencePoint?this.referencePoint().distanceTo(e):void 0}};let FeaturePointStrategy=class FeaturePointStrategy{_snapType;_featureInfos;constructor(e){this._snapType=e,this._featureInfos=new Map}getFeaturePoints(e,t){if(this._featureInfos.has(t))return this._featureInfos.get(t);let i=[];return t.shape.shapeType===r.ax.Edge&&this.getEdgeFeaturePoints(e,t,i),this._featureInfos.set(t,i),i}getEdgeFeaturePoints(e,t,i){let a=t.shape.curve(),s=a.value(a.firstParameter()),n=a.value(a.lastParameter()),addPoint=(r,a)=>i.push({view:e,point:r,info:a,shapes:[t]});r.DE.has(this._snapType,r.DE.endPoint)&&(addPoint(s,r.oc.translate("snap.end")),addPoint(n,r.oc.translate("snap.end"))),r.DE.has(this._snapType,r.DE.midPoint)&&addPoint(a.value((a.firstParameter()+a.lastParameter())*.5),r.oc.translate("snap.mid"))}clear(){this._featureInfos.clear()}updateSnapType(e){this._snapType=e,this.clear()}};let ObjectSnap=class ObjectSnap extends BaseSnap{_snapType;_featureStrategy;_intersectionInfos;_invisibleInfos;_lastDetected;_hintVertex;constructor(e,t){super(t),this._snapType=e,this.handleSnaped=(e,t)=>{t?.shapes.length===0&&this._lastDetected&&(this.displayHint(this._lastDetected[0],this._lastDetected[1]),this._lastDetected=void 0)},this.onSnapTypeChanged=e=>{("snapType"===e||"enableSnap"===e)&&(this._snapType=r.De.instance.snapType,this._featureStrategy.updateSnapType(this._snapType),this._intersectionInfos.clear())},this._featureStrategy=new FeaturePointStrategy(e),this._intersectionInfos=new Map,this._invisibleInfos=new Map,r.De.instance.onPropertyChanged(this.onSnapTypeChanged)}clear(){super.clear(),this._invisibleInfos.forEach(e=>{e.displays.forEach(t=>e.view.document.visual.context.removeMesh(t))}),this.removeHint(),this._featureStrategy.clear(),r.De.instance.removePropertyChanged(this.onSnapTypeChanged)}handleSnaped;onSnapTypeChanged;removeDynamicObject(){super.removeDynamicObject(),this.removeHint()}removeHint(){void 0!==this._hintVertex&&(this._hintVertex[0].removeMesh(this._hintVertex[1]),this._hintVertex=void 0)}snap(e){let t;if(r.De.instance.enableSnap)return e.shapes.length>0?(this.showInvisibleSnaps(e.view,e.shapes[0]),t=this.snapOnShape(e.view,e.mx,e.my,e.shapes)):t=this.snapeInvisible(e.view,e.mx,e.my),this.referencePoint&&t?.point&&(t.distance=this.referencePoint().distanceTo(t.point)),t}snapOnShape(e,t,i,a){let s=this._featureStrategy.getFeaturePoints(e,a[0]),n=[...s,...this.findPerpendicular(e,a[0]),...this.getIntersections(e,a[0],a)].sort((r,a)=>this.sortSnaps(e,t,i,r,a));if(0!==n.length){if(r.wB.screenDistance(e,t,i,n[0].point){n.snaps.forEach(n=>{let o=r.wB.screenDistance(e,t,i,n.point);o{if(i===t||i.shape.shapeType!==r.ax.Edge)return;let s=this.getIntersectionKey(t,i),n=this._intersectionInfos.get(s);void 0===n&&(n=this.findIntersections(e,t,i),this._intersectionInfos.set(s,n)),a.push(...n)}),a}getIntersectionKey(e,t){return e.shape.id({view:e,point:a.point,info:r.oc.translate("snap.intersection"),shapes:[t,i]}))}};let PlaneSnapBase=class PlaneSnapBase{refPoint;removeDynamicObject(){}clear(){}constructor(e){this.refPoint=e}snapAtPlane(e,t){let r=t.view.rayAt(t.mx,t.my),i=e.intersect(r);if(!i)return;let a=this.refPoint?this.refPoint().distanceTo(i):void 0;return{view:t.view,point:i,distance:a,shapes:[]}}};let WorkplaneSnap=class WorkplaneSnap extends PlaneSnapBase{snap(e){return this.snapAtPlane(e.view.workplane,e)}};let PlaneSnap=class PlaneSnap extends PlaneSnapBase{plane;constructor(e,t){super(t),this.plane=e}snap(e){let t=e.view.screenToWorld(e.mx,e.my),r=this.plane(t),i=this.snapAtPlane(r,e);return i&&(i.plane=r),i}};let PointOnCurveSnap=class PointOnCurveSnap{pointData;constructor(e){this.pointData=e}snap(e){let t=e.view.rayAt(e.mx,e.my),r=this.pointData.curve.nearestExtrema(t);if(r)return{view:e.view,point:r.p1,shapes:[]}}removeDynamicObject(){}clear(){}};let Axis=class Axis extends r.zH{name;constructor(e,t,r){super(e,t),this.name=r}static getAxiesAtPlane(e,t,i){let createAxis=(t,i)=>new Axis(e,t,r.oc.translate(i)),a=[createAxis(t.xvec,"axis.x"),createAxis(t.xvec.reverse(),"axis.x"),createAxis(t.yvec,"axis.y"),createAxis(t.yvec.reverse(),"axis.y")];return i&&a.push(createAxis(t.normal,"axis.z"),createAxis(t.normal.reverse(),"axis.z")),a}};let TrackingBase=class TrackingBase{trackingZ;tempMeshes;isCleared;constructor(e){this.trackingZ=e,this.tempMeshes=new Map,this.isCleared=!1}clear(){this.clearTempMeshes(),this.isCleared=!0}clearTempMeshes(){this.tempMeshes.forEach((e,t)=>{e.forEach(e=>t.visual.context.removeMesh(e))}),this.tempMeshes.clear()}addTempMesh(e,t){let r=this.tempMeshes.get(e);r||(r=[],this.tempMeshes.set(e,r)),r.push(t)}displayPoint(e,t,i,a){let s=r.zp.from(t.point,i,a),n=e.visual.context.displayMesh(s);return this.addTempMesh(e,n),n}};let AxisTracking=class AxisTracking extends TrackingBase{axies=new Map;constructor(e){super(e)}getAxes(e,t,r){return this.axies.has(e)||this.axies.set(e,this.initAxes(e.workplane,t,r)),this.axies.get(e)}initAxes(e,t,i){if(void 0===i)return Axis.getAxiesAtPlane(t,e,this.trackingZ);let a=[],s=0;for(;s<360;){let r=e.xvec.rotate(e.normal,s/180*Math.PI);a.push(new Axis(t,r,`${s} \xb0`)),s+=i}return this.trackingZ&&(a.push(new Axis(t,e.normal,r.oc.translate("axis.z"))),a.push(new Axis(t,e.normal.reverse(),r.oc.translate("axis.z")))),a}clear(){super.clear(),this.axies.clear()}};let ObjectTracking=class ObjectTracking extends TrackingBase{timer;snapping;trackings=new Map;constructor(e){super(e)}clear(){this.clearTimer(),super.clear(),this.trackings.clear()}getTrackingRays(e){let t=[];return this.trackings.get(e.document)?.map(r=>{let i=Axis.getAxiesAtPlane(r.snap.point,e.workplane,this.trackingZ);t.push({axes:i,objectName:r.snap.info})}),t}showTrackingAtTimeout(e,t){(void 0===t||this.snapping!==t)&&(this.snapping=t,this.clearTimer(),t&&(this.timer=window.setTimeout(()=>this.switchTrackingPoint(e,t),600)))}clearTimer(){void 0!==this.timer&&(clearTimeout(this.timer),this.timer=void 0)}switchTrackingPoint(e,t){if(this.isCleared||0===t.shapes.length)return;this.trackings.has(e)||this.trackings.set(e,[]);let r=this.trackings.get(e),i=r.find(e=>e.snap.point.isEqualTo(t.point));i?this.removeTrackingPoint(e,i,r):this.addTrackingPoint(t,e,r),e.visual.update()}removeTrackingPoint(e,t,r){e.visual.context.removeMesh(t.shapeId),this.trackings.set(e,r.filter(e=>e!==t))}addTrackingPoint(e,t,i){let a=this.displayPoint(t,e,r.OI.trackingVertexSize,r.OI.trackingVertexColor);i.push({shapeId:a,snap:e})}};let TrackingSnap=class TrackingSnap{referencePoint;_axisTracking;_objectTracking;_tempLines;constructor(e,t){this.referencePoint=e,this._tempLines=new Map,this.handleSnaped=(e,t)=>{r.De.instance.enableSnapTracking&&this._objectTracking.showTrackingAtTimeout(e,t)},this.onSnapTypeChanged=e=>{("snapType"===e||"enableSnapTracking"===e||"enableSnap"===e)&&(this.removeDynamicObject(),this._objectTracking.clear(),this._axisTracking.clear())},this._axisTracking=new AxisTracking(t),this._objectTracking=new ObjectTracking(t),r.De.instance.onPropertyChanged(this.onSnapTypeChanged)}handleSnaped;snap(e){if(!r.De.instance.enableSnapTracking)return;let t=this.detectTracking(e.view,e.mx,e.my);if(0===t.length)return;t.sort(e=>e.distance);let i=this.shapeIntersectTracking(e,t);return void 0!==i?i:1===t.length?this.getSnapedAndShowTracking(e.view,t[0].point,[t[0]]):this.trackingIntersectTracking(e.view,t)??this.getSnapedAndShowTracking(e.view,t[0].point,[t[0]])}trackingIntersectTracking(e,t){let r=t[0].axis.intersect(t[1].axis);return r?this.getSnapedAndShowTracking(e,r,[t[0],t[1]]):void 0}getSnapedAndShowTracking(e,t,i){let a,s;let n=i.map(r=>this.showTempLine(e,r.axis.location,t)).filter(e=>void 0!==e);return this._tempLines.set(e,n),1===i.length?(s=t.distanceTo(i[0].axis.location),a=i[0].axis.name):2===i.length&&(a=r.oc.translate("snap.intersection")),{view:e,point:t,info:a,shapes:[],refPoint:i[0].axis.location,distance:s}}showTempLine(e,t,i){let a=i.sub(t),s=a.normalize();if(!s)return;let n=Math.min(1e10*a.length(),1e20),o=t.add(s.multiply(n)),l=r.bj.from(t,o,r.OI.temporaryEdgeColor,r.SP.Dash);return e.document.visual.context.displayMesh(l)}shapeIntersectTracking(e,t){if(0===e.shapes.length||e.shapes[0].shape.shapeType!==r.ax.Edge)return;let i=this.findIntersection(e,t);if(!i)return;let a=this.showTempLine(e.view,i.location,i.intersect);if(void 0!==a)return this._tempLines.set(e.view,[a]),{view:e.view,point:i.intersect,info:r.oc.translate("snap.intersection"),shapes:[e.shapes[0]]}}findIntersection(e,t){let i=e.shapes[0].shape,a=[];return t.forEach(e=>{i.intersect(e.axis).forEach(t=>{a.push({intersect:t.point,location:e.axis.location})})}),a.sort(t=>r.wB.screenDistance(e.view,e.mx,e.my,t.intersect)),a.at(0)}detectTracking(e,t,r){let i=[];if(this.referencePoint){let a=this._axisTracking.getAxes(e,this.referencePoint());i.push(...this.getSnapedFromAxes(a,e,t,r))}return this._objectTracking.getTrackingRays(e).forEach(a=>{i.push(...this.getSnapedFromAxes(a.axes,e,t,r,a.objectName))}),i}getSnapedFromAxes(e,t,i,a,s){let n=[];for(let o of e){let e=this.rayDistanceAtScreen(t,i,a,o);if(el.sub(o.location).dot(o.direction))continue;n.push({axis:o,distance:e,point:l,info:s??o.name,isObjectTracking:void 0!==s})}}return n}rayDistanceAtScreen(e,t,i,a){let s=e.worldToScreen(a.location),n=new r.XY(t-s.x,i-s.y);if(n.isEqualTo(r.XY.zero))return 0;let o=e.worldToScreen(a.location.add(a.direction.multiply(1e5)));if(s.distanceTo(o){e.forEach(e=>{t.document.visual.context.removeMesh(e)})}),this._tempLines.clear()}onSnapTypeChanged;clear(){this.removeDynamicObject(),this._axisTracking.clear(),this._objectTracking.clear(),r.De.instance.removePropertyChanged(this.onSnapTypeChanged)}};let SnapEventHandler=class SnapEventHandler{document;controller;snaps;data;_tempPoint;_tempShapes;_snaped;_state;constructor(e,t,r,i){this.document=e,this.controller=t,this.snaps=r,this.data=i,this._state=0,this.showTempShape(void 0),t.onCancelled(()=>this.handleCancel())}get snaped(){return this._snaped}get state(){return this._state}dispose(){this._snaped=void 0,this._state=0}handleSuccess(){this._state=0,this.controller.success(),this.cleanupResources()}handleCancel(){3!==this._state&&(this._state=3,this.controller.cancel(),this.cleanupResources())}cleanupResources(){this.clearSnapTip(),this.clearInput(),this.removeTempVisuals(),this.snaps.forEach(e=>e.clear())}clearInput(){r.pS.default.pub("clearInput")}pointerMove(e,t){this._state=1,this.removeTempVisuals(),this.updateSnapPoint(e,t),this.updateVisualFeedback(e)}updateSnapPoint(e,t){this.setSnaped(e,t),this._snaped?this.showSnapPrompt(this.formatPrompt(this._snaped)):this.clearSnapTip()}updateVisualFeedback(e){this.showTempShape(this._snaped?.point),e.document.visual.update()}formatPrompt(e){let t=this.data.prompt?.(e);if(!t){let r=e.distance??e.refPoint?.distanceTo(e.point);r&&(t=`${r.toFixed(2)}`)}return[e.info,t].filter(e=>void 0!==e).join(" -> ")}setSnaped(e,t){this.trySnapToFeaturePoint(e,t)||(this._snaped=this.findSnapPoint(r.ax.Edge,e,t),this.snaps.forEach(t=>t.handleSnaped?.(e.document.visual.document,this._snaped)))}trySnapToFeaturePoint(e,t){let r=this.findNearestFeaturePoint(e,t);return!!r&&(this._snaped={view:e,point:r.point,info:r.prompt,shapes:[]},!0)}findNearestFeaturePoint(e,t){let i,a=Number.MAX_VALUE;for(let s of this.data.featurePoints||[]){if(s.when&&!s.when())continue;let n=r.wB.screenDistance(e,t.offsetX,t.offsetY,s.point);ne.removeDynamicObject())}showTempShape(e){if(e){let t=r.zp.from(e,r.OI.temporaryVertexSize,r.OI.temporaryVertexColor);this._tempPoint=this.document.visual.context.displayMesh(t)}this._tempShapes=this.data.preview?.(e)?.map(e=>this.document.visual.context.displayMesh(e))}removeTempShapes(){this._tempPoint&&(this.document.visual.context.removeMesh(this._tempPoint),this._tempPoint=void 0),this._tempShapes?.forEach(e=>{this.document.visual.context.removeMesh(e)}),this.document.visual.update(),this._tempShapes=void 0}pointerDown(e,t){0===t.button&&this.handleSuccess()}pointerUp(e,t){}mouseWheel(e,t){e.update()}keyDown(e,t){switch(t.key){case"Escape":this._snaped=void 0,this.handleCancel();break;case"Enter":this._snaped=void 0,this.handleSuccess();break;default:this.handleNumericInput(e,t)}}handleNumericInput(e,t){["-","0","1","2","3","4","5","6","7","8","9"].includes(t.key)&&(this._state=2,r.pS.default.pub("showInput",t.key,t=>{let i=this.inputError(t);return i?r.x4.err(i):(this._snaped=this.getPointFromInput(e,t),this.handleSuccess(),r.x4.ok(t))}))}};let AngleSnapEventHandler=class AngleSnapEventHandler extends SnapEventHandler{center;planeAngle;plane;constructor(e,t,i,a,s){if(!s.plane)throw Error("AngleSnapEventHandler: no plane");let n=new ObjectSnap(r.De.instance.snapType,s.refPoint);super(e,t,[n,new TrackingSnap(i,!1),new PlaneSnap(s.plane,i)],s),this.center=i,this.formatAnglePrompt=e=>e?.point?(this.planeAngle.movePoint(e.point),`${this.planeAngle.angle.toFixed(2)} \xb0`):"";let o=a.sub(i()).normalize();this.plane=new r.JO(i(),s.plane().normal,o),this.planeAngle=new r.n4(this.plane),s.prompt??=this.formatAnglePrompt}formatAnglePrompt;inputError(e){return isNaN(Number.parseFloat(e))?"error.input.invalidNumber":void 0}getPointFromInput(e,t){let r=Number.parseFloat(t)*Math.PI/180,i=this.plane.xvec.rotate(this.plane.normal,r);return{point:this.center().add(i),view:e,shapes:[],plane:this.plane}}};let SnapLengthAtAxisHandler=class SnapLengthAtAxisHandler extends SnapEventHandler{constructor(e,t,i){super(e,t,[new ObjectSnap(r.De.instance.snapType,()=>i.point),new AxisSnap(i.point,i.direction)],i)}getPointFromInput(e,t){let r=this.calculateDistance(Number(t));return{view:e,point:this.calculatePoint(r),distance:r,shapes:[]}}calculateDistance(e){return this.shouldReverse()?-e:e}calculatePoint(e){return this.data.point.add(this.data.direction.multiply(e))}shouldReverse(){return this._snaped?.point&&this._snaped.point.sub(this.data.point).dot(this.data.direction)<-r.Gc.Distance}inputError(e){return Number.isNaN(Number(e))?"error.input.invalidNumber":void 0}};let SnapLengthAtPlaneHandler=class SnapLengthAtPlaneHandler extends SnapEventHandler{lengthData;workplane;constructor(e,t,i){let a=new ObjectSnap(r.De.instance.snapType,i.point);super(e,t,[a,new TrackingSnap(i.point,!1),new PlaneSnap(i.plane,i.point)],i),this.lengthData=i}setSnaped(e,t){super.setSnaped(e,t),this.updateWorkplane()}updateWorkplane(){this._snaped&&(this.workplane=this.lengthData.plane(this._snaped.point),this._snaped.plane=this.workplane)}getPointFromInput(e,t){let r=this.workplane??e.workplane;return{point:this.calculatePoint(t,r),view:e,shapes:[],plane:r}}calculatePoint(e,t){let r=e.split(",").map(Number);return 1===r.length?this.calculatePointFromDistance(r[0]):this.calculatePointFromCoordinates(r,t)}calculatePointFromDistance(e){let t=this._snaped?.point.sub(this.data.point()).normalize();return this.data.point().add(t.multiply(e))}calculatePointFromCoordinates(e,t){return this.data.point().add(t.xvec.multiply(e[0])).add(t.yvec.multiply(e[1]))}inputError(e){let t=e.split(",").map(Number);if(t.some(Number.isNaN)||1!==t.length&&2!==t.length)return"error.input.invalidNumber"}};let PointSnapEventHandler=class PointSnapEventHandler extends SnapEventHandler{constructor(e,t,i){let a=new ObjectSnap(r.De.instance.snapType,i.refPoint);super(e,t,[a,new TrackingSnap(i.refPoint,!0),i.plane?new PlaneSnap(i.plane,i.refPoint):new WorkplaneSnap(i.refPoint)],i)}getPointFromInput(e,t){let i=this.parseInputDimensions(t),a=this.getRefPoint()??r.vY.zero,s={point:a,view:e,shapes:[]};return 1===i.length&&this._snaped?.point?s.point=this.calculatePointFromDistance(a,i[0]):i.length>1&&(s.point=this.calculatePointFromCoordinates(a,i)),s}parseInputDimensions(e){return e.split(",").map(Number)}calculatePointFromDistance(e,t){let r=this._snaped.point.sub(e).normalize();return e.add(r.multiply(t))}calculatePointFromCoordinates(e,t){let r=this.data.plane?.()??this.snaped.view.workplane,i=e.add(r.xvec.multiply(t[0])).add(r.yvec.multiply(t[1]));return 3===t.length&&(i=i.add(r.normal.multiply(t[2]))),i}inputError(e){let t=this.parseInputDimensions(e),r=n.from(t.length);return this.isValidDimension(r)?this.hasInvalidNumbers(t)?"error.input.invalidNumber":this.requiresThreeNumbers(t)?"error.input.threeNumberCanBeInput":this.isInvalidSingleNumber(t)?"error.input.cannotInputANumber":void 0:"error.input.unsupportedInputs"}isValidDimension(e){return n.contains(this.data.dimension,e)}hasInvalidNumbers(e){return e.some(Number.isNaN)}requiresThreeNumbers(e){return void 0===this.getRefPoint()&&3!==e.length}isInvalidSingleNumber(e){let t=this.getRefPoint();return 1===e.length&&t&&(!this._snaped||this._snaped.point.isEqualTo(t))}getRefPoint(){return this.data.refPoint?.()??this._snaped?.refPoint}};let SnapPointOnCurveEventHandler=class SnapPointOnCurveEventHandler extends SnapEventHandler{constructor(e,t,i){let a=new ObjectSnap(r.De.instance.snapType);super(e,t,[a,new PointOnCurveSnap(i),new WorkplaneSnap],i)}getPointFromInput(e,t){let r=this.data.curve.length(),i=Number(t)/r;return{point:this.data.curve.value(i),view:e,shapes:[]}}inputError(e){return Number.isNaN(Number(e))?"error.input.invalidNumber":void 0}};let Step=class Step{tip;handleStepData;constructor(e,t){this.tip=e,this.handleStepData=t}async execute(e,t){let r=this.handleStepData();this.setValidator(r);let i=this.getEventHandler(e,t,r);return await e.selection.pickAsync(i,this.tip,t,!1,"draw"),t.result?.status==="success"?i.snaped:void 0}setValidator(e){let t=e.validator;e.validator=r=>t?t(r)&&this.validator(e,r):this.validator(e,r)}};function defaultSnapedData(){return{dimension:n.D1D2D3}}let AngleStep=class AngleStep extends Step{handleCenter;handleP1;constructor(e,t,r,i=defaultSnapedData){super(e,i),this.handleCenter=t,this.handleP1=r}getEventHandler(e,t,r){return new AngleSnapEventHandler(e,t,this.handleCenter,this.handleP1(),r)}validator(e,t){return void 0===e.refPoint||e.refPoint().distanceTo(t)>r.Gc.Distance}};let LengthAtAxisStep=class LengthAtAxisStep extends Step{getEventHandler(e,t,r){return new SnapLengthAtAxisHandler(e,t,r)}validator(e,t){return Math.abs(t.sub(e.point).dot(e.direction))>r.Gc.Distance}};let LengthAtPlaneStep=class LengthAtPlaneStep extends Step{getEventHandler(e,t,r){return new SnapLengthAtPlaneHandler(e,t,r)}validator(e,t){return e.plane(t).project(t).distanceTo(e.point())>r.Gc.Distance}};function pointStep_defaultSnapedData(){return{dimension:n.D1|n.D1D2D3}}let PointStep=class PointStep extends Step{constructor(e,t=pointStep_defaultSnapedData){super(e,t)}getEventHandler(e,t,r){return new PointSnapEventHandler(e,t,r)}validator(e,t){return void 0===e.refPoint||e.refPoint().distanceTo(t)>r.Gc.Distance}};let PointOnCurveStep=class PointOnCurveStep extends Step{constructor(e,t){super(e,t)}validator(e,t){return!0}getEventHandler(e,t,r){return new SnapPointOnCurveEventHandler(e,t,r)}};let SelectStep=class SelectStep{snapeType;prompt;multiple;filter;constructor(e,t,r=!1,i){this.snapeType=e,this.prompt=t,this.multiple=r,this.filter=i}async execute(e,t){let{shapeType:r,shapeFilter:i,nodeFilter:a}=e.selection;e.selection.shapeType=this.snapeType,e.selection.shapeFilter=this.filter;try{return await this.select(e,t)}finally{e.selection.shapeType=r,e.selection.shapeFilter=i,e.selection.nodeFilter=a}}};let SelectShapeStep=class SelectShapeStep extends SelectStep{async select(e,t){let r=await e.selection.pickShape(this.prompt,t,this.multiple);if(0!==r.length)return{view:e.application.activeView,shapes:r}}};let SelectShapeNodeStep=class SelectShapeNodeStep extends SelectStep{constructor(e,t,i){super(r.ax.Shape,e,t,i)}async select(e,t){e.selection.nodeFilter=new r._J;let i=await e.selection.pickNode(this.prompt,t,this.multiple);if(0!==i.length)return{view:e.application.activeView,shapes:[],nodes:i}}};let SelectNodeStep=class SelectNodeStep{prompt;multiple;filter;constructor(e,t=!1,r){this.prompt=e,this.multiple=t,this.filter=r}async execute(e,t){let r=e.selection.nodeFilter;e.selection.nodeFilter=this.filter;try{e.selection.nodeFilter=this.filter;let r=await e.selection.pickNode(this.prompt,t,this.multiple);if(0===r.length)return;return{view:e.application.activeView,shapes:[],nodes:r}}finally{e.selection.nodeFilter=r}}};function multistepCommand_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}let multistepCommand_MultistepCommand=class multistepCommand_MultistepCommand extends r.uu{stepDatas=[];get repeatOperation(){return this.getPrivateValue("repeatOperation",!1)}set repeatOperation(e){this.setProperty("repeatOperation",e)}canExcute(){return Promise.resolve(!0)}async executeAsync(){await this.canExcute()&&await this.executeSteps()&&(this.executeMainTask(),this.repeatOperation&&(this.resetSteps(),await this.executeAsync()))}async executeSteps(){let e=this.getSteps();try{for(;this.stepDatas.length=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}multistepCommand_ts_decorate([r.Z9.define("command.mode.repeat")],multistepCommand_MultistepCommand.prototype,"repeatOperation",null);let CreateCommand=class CreateCommand extends multistepCommand_MultistepCommand{executeMainTask(){r.YW.execute(this.document,`excute ${Object.getPrototypeOf(this).data.name}`,()=>{let e=this.geometryNode();this.document.addNode(e),this.document.visual.update()})}findPlane=(e,t,a)=>void 0!==a&&r.De.instance.dynamicWorkplane?i.b3.raycastClosestPlane(e,t,a):e.workplane.translateTo(t)};let CreateFaceableCommand=class CreateFaceableCommand extends CreateCommand{_isFace=!1;get isFace(){return this._isFace}set isFace(e){this.setProperty("isFace",e)}};function commands_boolean_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}createCommand_ts_decorate([r.Z9.define("command.faceable.isFace")],CreateFaceableCommand.prototype,"isFace",null);let BooleanOperate=class BooleanOperate extends CreateCommand{geometryNode(){let e=this.stepDatas[0].nodes?.[0]?.shape.value,t=this.stepDatas[1].nodes?.[0]?.shape.value,r=this.getBooleanOperateType(),i=this.getBooleanShape(r,e,t),a=new BooleanNode(this.document,i.value);return this.stepDatas.forEach(e=>e.nodes?.[0]?.parent?.remove(e.nodes[0])),a}getBooleanShape(e,t,r){switch(e){case"common":return this.application.shapeFactory.booleanCommon(t,r);case"cut":return this.application.shapeFactory.booleanCut(t,r);default:return this.application.shapeFactory.booleanFuse(t,r)}}getSteps(){return[new SelectShapeNodeStep("prompt.select.shape",!1),new SelectShapeNodeStep("prompt.select.shape",!1,{allow:e=>!this.stepDatas[0].nodes?.map(e=>e.shape.value).includes(e)})]}};let BooleanCommon=class BooleanCommon extends BooleanOperate{getBooleanOperateType(){return"common"}};BooleanCommon=commands_boolean_ts_decorate([(0,r.WD)({name:"boolean.common",display:"command.boolean.common",icon:"icon-booleanCommon"})],BooleanCommon);let BooleanCut=class BooleanCut extends BooleanOperate{getBooleanOperateType(){return"cut"}};BooleanCut=commands_boolean_ts_decorate([(0,r.WD)({name:"boolean.cut",display:"command.boolean.cut",icon:"icon-booleanCut"})],BooleanCut);let BooleanFuse=class BooleanFuse extends BooleanOperate{getBooleanOperateType(){return"fuse"}};function arc_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}BooleanFuse=commands_boolean_ts_decorate([(0,r.WD)({name:"boolean.fuse",display:"command.boolean.fuse",icon:"icon-booleanFuse"})],BooleanFuse);let ArcNode=class ArcNode extends r.gR{display(){return"body.arc"}get center(){return this.getPrivateValue("center")}set center(e){this.setPropertyEmitShapeChanged("center",e)}get start(){return this.getPrivateValue("start")}get normal(){return this.getPrivateValue("normal")}get angle(){return this.getPrivateValue("angle")}set angle(e){this.setPropertyEmitShapeChanged("angle",e)}constructor(e,t,r,i,a){super(e),this.setPrivateValue("normal",t),this.setPrivateValue("center",r),this.setPrivateValue("start",i),this.setPrivateValue("angle",a)}generateShape(){return this.document.application.shapeFactory.arc(this.normal,this.center,this.start,this.angle)}};function create_arc_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}arc_ts_decorate([r.ei.serialze(),r.Z9.define("circle.center")],ArcNode.prototype,"center",null),arc_ts_decorate([r.ei.serialze(),r.Z9.define("arc.start")],ArcNode.prototype,"start",null),arc_ts_decorate([r.ei.serialze()],ArcNode.prototype,"normal",null),arc_ts_decorate([r.ei.serialze(),r.Z9.define("arc.angle")],ArcNode.prototype,"angle",null),ArcNode=arc_ts_decorate([r.ei.register(["document","normal","center","start","angle"])],ArcNode);let Arc=class Arc extends CreateCommand{_planeAngle;getSteps(){return[new PointStep("operate.pickCircleCenter"),new LengthAtPlaneStep("operate.pickRadius",this.getRadiusData),new AngleStep("operate.pickNextPoint",()=>this.stepDatas[0].point,()=>this.stepDatas[1].point,this.getAngleData)]}getRadiusData=()=>{let{point:e,view:t}=this.stepDatas[0];return{point:()=>e,preview:this.circlePreview,plane:r=>this.findPlane(t,e,r),validator:t=>!(t.distanceTo(e){let[e,t]=[this.stepDatas[0].point,this.stepDatas[1].point],i=this.stepDatas[1].plane??this.findPlane(this.stepDatas[1].view,e,t),a=[this.previewPoint(e),this.previewPoint(t)];return this._planeAngle=new r.n4(new r.JO(e,i.normal,t.sub(e))),{dimension:n.D1D2,preview:r=>this.anglePreview(r,e,t,a),plane:()=>i,validators:[this.angleValidator(e,i)]}};anglePreview(e,t,i,a){e=e??i,this._planeAngle.movePoint(e);let s=[...a];return Math.abs(this._planeAngle.angle)>r.Gc.Angle&&s.push(this.application.shapeFactory.arc(this._planeAngle.plane.normal,t,i,this._planeAngle.angle).value.mesh.edges),s}angleValidator(e,t){return i=>i.distanceTo(e)>=r.Gc.Distance&&!i.sub(e).isParallelTo(t.normal)}geometryNode(){let[e,t]=[this.stepDatas[0].point,this.stepDatas[1].point],r=this.stepDatas[1].plane??this.findPlane(this.stepDatas[1].view,e,t);return this._planeAngle?.movePoint(this.stepDatas[2].point),new ArcNode(this.document,r.normal,e,t,this._planeAngle.angle)}circlePreview=e=>{let t=this.previewPoint(this.stepDatas[0].point);if(!e)return[t];let{point:r,view:i}=this.stepDatas[0],a=this.findPlane(i,r,e);return[t,this.previewLine(this.stepDatas[0].point,e),this.application.shapeFactory.circle(a.normal,r,this.getDistanceAtPlane(a,r,e)).value.mesh.edges]};getDistanceAtPlane(e,t,r){let i=e.project(t),a=e.project(r);return i.distanceTo(a)}};function bezier_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}Arc=create_arc_ts_decorate([(0,r.WD)({name:"create.arc",display:"command.arc",icon:"icon-arc"})],Arc);let BezierCommand=class BezierCommand extends CreateCommand{geometryNode(){let e=this.application.shapeFactory.bezier(this.stepDatas.map(e=>e.point));return new r.gC(this.document,r.oc.translate("command.bezier"),e.value)}async executeSteps(){let e=this.getSteps(),t=!0;for(;;){let i=t?e[0]:e[1];t&&(t=!1),this.controller=new r.Op;let a=await i.execute(this.document,this.controller);if(void 0===a)return this.controller.result?.status==="success";this.stepDatas.push(a)}}getSteps(){return[new PointStep("operate.pickFistPoint"),new PointStep("operate.pickNextPoint",this.getNextData)]}getNextData=()=>({refPoint:()=>this.stepDatas.at(-1).point,dimension:n.D1D2D3,validator:this.validator,preview:this.preview});preview=e=>{let t=this.stepDatas.map(e=>this.previewPoint(e.point)),r=this.stepDatas.map(e=>e.point);if(e&&r.push(e),r.length>1){t.push(...this.previewLines(r));let e=this.application.shapeFactory.bezier(r);t.push(e.value.mesh.edges)}return t};previewLines=e=>{if(e.length<2)return[];let t=[];for(let r=1;r{for(let t of this.stepDatas)if(.001>e.distanceTo(t.point))return!1;return!0}};function create_rect_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}BezierCommand=bezier_ts_decorate([(0,r.WD)({name:"create.bezier",display:"command.bezier",icon:"icon-bezier"})],BezierCommand),function(e){function get(e,t,i){let a=new r.JO(t,e.normal,e.xvec),s=i.sub(t),n=s.dot(a.xvec),o=s.dot(a.yvec);return{plane:a,dx:n,dy:o,p1:t,p2:i}}e.get=get}(t||(t={}));let RectCommandBase=class RectCommandBase extends CreateCommand{getSteps(){return[new PointStep("operate.pickFistPoint"),new LengthAtPlaneStep("operate.pickNextPoint",this.nextSnapData)]}nextSnapData=()=>{let{point:e,view:t}=this.stepDatas[0];return{point:()=>e,preview:this.previewRect,plane:r=>this.findPlane(t,e,r),validator:this.handleValid,prompt:e=>{let t=this.tmpPoint2RectData(e.point);return`${t.dx.toFixed(2)}, ${t.dy.toFixed(2)}`}}};handleValid=e=>{let t=this.tmpPoint2RectData(e);return void 0!==t&&!r.M8.anyEqualZero(t.dx,t.dy)};previewRect=e=>{let t=this.previewPoint(this.stepDatas[0].point);if(void 0===e)return[t];let r=this.tmpPoint2RectData(e);return[t,this.previewPoint(e),this.application.shapeFactory.rect(r.plane,r.dx,r.dy).value.mesh.edges]};tmpPoint2RectData(e){let[r,a]=[this.stepDatas[0].point,e],s=i.b3.raycastClosestPlane(this.stepDatas[0].view,r,a);return t.get(s,r,a)}point2RectData(){let e;return this.stepDatas[1].plane?t.get(this.stepDatas[1].plane,this.stepDatas[0].point,this.stepDatas[1].point):this.tmpPoint2RectData(this.stepDatas[1].point)}};let Rect=class Rect extends RectCommandBase{get isFace(){return this.getPrivateValue("isFace",!1)}set isFace(e){this.setProperty("isFace",e)}geometryNode(){let e=this.point2RectData(),t=new RectNode(this.document,e.plane,e.dx,e.dy);return t.isFace=this.isFace,t}};function create_box_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}create_rect_ts_decorate([r.Z9.define("command.faceable.isFace")],Rect.prototype,"isFace",null),Rect=create_rect_ts_decorate([(0,r.WD)({name:"create.rect",display:"command.rect",icon:"icon-rect"})],Rect);let Box=class Box extends RectCommandBase{getSteps(){return[...super.getSteps(),new LengthAtAxisStep("operate.pickNextPoint",this.getHeightStepData)]}getHeightStepData=()=>{let e=this.stepDatas[1].plane;if(void 0===e)throw Error("plane is undefined, please report bug");return{point:this.stepDatas[1].point,direction:e.normal,preview:this.previewBox}};previewBox=e=>{let t=this.stepDatas[0].point,r=this.stepDatas[1].point;if(!e)return this.previewRect(r);let i=this.previewPoint(t),a=this.previewPoint(r),s=this.point2RectData();return[i,a,this.application.shapeFactory.box(s.plane,s.dx,s.dy,this.getHeight(s.plane,e)).value.mesh.edges]};geometryNode(){let e=this.point2RectData(),t=this.getHeight(e.plane,this.stepDatas[2].point);return new BoxNode(this.document,e.plane,e.dx,e.dy,t)}getHeight(e,t){let i=t.sub(this.stepDatas[1].point).dot(e.normal);return Math.abs(i)=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}Box=create_box_ts_decorate([(0,r.WD)({name:"create.box",display:"command.box",icon:"icon-box"})],Box);let Circle=class Circle extends CreateFaceableCommand{getSteps(){return[new PointStep("operate.pickCircleCenter"),new LengthAtPlaneStep("operate.pickRadius",this.getRadiusData)]}getRadiusData=()=>{let{point:e,view:t}=this.stepDatas[0];return{point:()=>e,preview:this.circlePreview,plane:r=>this.findPlane(t,e,r),validator:t=>!(t.distanceTo(e){let t=this.previewPoint(this.stepDatas[0].point);if(!e)return[t];let{point:r,view:i}=this.stepDatas[0],a=this.findPlane(i,r,e);return[t,this.previewLine(r,e),this.application.shapeFactory.circle(a.normal,r,this.getDistanceAtPlane(a,r,e)).value.mesh.edges]};getDistanceAtPlane(e,t,r){let i=e.project(t),a=e.project(r);return i.distanceTo(a)}};function face_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}Circle=create_circle_ts_decorate([(0,r.WD)({name:"create.circle",display:"command.circle",icon:"icon-circle"})],Circle);let FaceNode=class FaceNode extends r.gR{display(){return"body.face"}get shapes(){return this.getPrivateValue("shapes")}set shapes(e){this.setPropertyEmitShapeChanged("shapes",e)}constructor(e,t){super(e),this.setPrivateValue("shapes",t)}isAllClosed(){return this.shapes.every(e=>e.isClosed()||e.shapeType===r.ax.Wire)}getWires(){let e=[];this.isAllClosed()?this.addClosedEdges(e,this.shapes):this.addUnclosedEdges(e,this.shapes);for(let t=1;t=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}face_ts_decorate([r.ei.serialze()],FaceNode.prototype,"shapes",null),FaceNode=face_ts_decorate([r.ei.register(["document","shapes"])],FaceNode);let WireNode=class WireNode extends r.gR{display(){return"body.wire"}get edges(){return this.getPrivateValue("edges")}set edges(e){this.setPropertyEmitShapeChanged("edges",e)}constructor(e,t){super(e),this.setPrivateValue("edges",t)}generateShape(){return this.document.application.shapeFactory.wire(this.edges)}};function converter_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}wire_ts_decorate([r.ei.serialze()],WireNode.prototype,"edges",null),WireNode=wire_ts_decorate([r.ei.register(["document","edges"])],WireNode);let ConvertCommand=class ConvertCommand extends r.uu{async executeAsync(){let e=await this.getOrPickModels(this.document);if(!e){r.pS.default.pub("showToast","toast.select.noSelected");return}r.YW.execute(this.document,`excute ${Object.getPrototypeOf(this).data.name}`,()=>{let t=this.create(this.document,e);t.isOk?(this.document.addNode(t.value),this.document.visual.update(),r.pS.default.pub("showToast","toast.success")):r.pS.default.pub("showToast","toast.converter.error")})}async getOrPickModels(e){let t={allow:e=>e.shapeType===r.ax.Edge||e.shapeType===r.ax.Wire},i=this._getSelectedModels(e,t);if(e.selection.clearSelection(),i.length>0)return i;let a=new SelectShapeNodeStep("prompt.select.models",!0,t);this.controller=new r.Op;let s=await a.execute(e,this.controller);return e.selection.clearSelection(),s?.nodes}_getSelectedModels(e,t){return e.selection.getSelectedNodes().map(e=>e).filter(e=>{if(void 0===e)return!1;let r=e.shape.value;return!!(void 0!==r&&(void 0===t||t.allow(r)))})}};let ConvertToWire=class ConvertToWire extends ConvertCommand{create(e,t){let i=t.map(e=>e.shape.value),a=new WireNode(e,i),s=a.generateShape();return s.isOk?(t.forEach(e=>e.parent?.remove(e)),r.x4.ok(a)):r.x4.err(s.error)}};ConvertToWire=converter_ts_decorate([(0,r.WD)({name:"convert.toWire",display:"command.toWire",icon:"icon-toPoly"})],ConvertToWire);let ConvertToFace=class ConvertToFace extends ConvertCommand{create(e,t){let i=t.map(e=>e.shape.value),a=new FaceNode(e,i),s=a.generateShape();return s.isOk?(t.forEach(e=>e.parent?.remove(e)),r.x4.ok(a)):r.x4.err(s.error)}};function fuse_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}ConvertToFace=converter_ts_decorate([(0,r.WD)({name:"convert.toFace",display:"command.toFace",icon:"icon-toFace"})],ConvertToFace);let Fuse=class Fuse extends CreateCommand{geometryNode(){let e=this.stepDatas[0].shapes[0].shape,[t,r]=e.normal(0,0),i=this.stepDatas[1].point.sub(t).dot(r);return new PrismNode(this.document,e,i)}getSteps(){return[new SelectShapeStep(r.ax.Face,"prompt.select.faces",!1),new LengthAtAxisStep("operate.pickNextPoint",this.getLengthStepData)]}getLengthStepData=()=>{let e=this.stepDatas[0].shapes[0].shape,[t,i]=e.normal(0,0);return{point:t,direction:i,preview:a=>{if(!a)return[];let s=a.sub(t).dot(i);if(Math.abs(s)=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}Fuse=fuse_ts_decorate([(0,r.WD)({name:"convert.fuse",display:"command.fuse",icon:"icon-circle"})],Fuse);let Line=class Line extends CreateCommand{get isContinue(){return this.getPrivateValue("isContinue",!1)}set isContinue(e){this.setProperty("isContinue",e)}geometryNode(){return new LineNode(this.document,this.stepDatas[0].point,this.stepDatas[1].point)}getSteps(){return[new PointStep("operate.pickFistPoint"),new PointStep("operate.pickNextPoint",this.getSecondPointData)]}resetSteps(){this.isContinue?(this.stepDatas[0]=this.stepDatas[1],this.stepDatas.length=1):this.stepDatas.length=0}getSecondPointData=()=>({refPoint:()=>this.stepDatas[0].point,dimension:n.D1D2D3,validator:e=>this.stepDatas[0].point.distanceTo(e)>r.Gc.Distance,preview:this.linePreview});linePreview=e=>{let t=this.previewPoint(this.stepDatas[0].point);return e?[t,this.application.shapeFactory.line(this.stepDatas[0].point,e).value.mesh.edges]:[t]}};function offset_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}create_line_ts_decorate([r.Z9.define("command.line.isConnected",{dependencies:[{property:"repeatOperation",value:!0}]})],Line.prototype,"isContinue",null),Line=create_line_ts_decorate([(0,r.WD)({name:"create.line",display:"command.line",icon:"icon-line"})],Line);let OffsetCommand=class OffsetCommand extends CreateCommand{geometryNode(){let e=this.getAxis().normal,t=this.createOffsetShape(e,this.stepDatas[1].distance);return new r.gC(this.document,r.oc.translate("command.offset"),t.value)}getSteps(){return[new SelectShapeStep(r.ax.Edge|r.ax.Wire|r.ax.Face,"prompt.select.shape",!1),new LengthAtAxisStep("common.length",()=>{let e=this.getAxis();return{point:e.point,direction:e.direction,preview:t=>this.previewShape(e,t)}})]}previewShape(e,t){let r=[this.previewPoint(e.point)];if(void 0!==t){r.push(this.previewLine(e.point,t));let i=t.sub(e.point).dot(e.direction),a=this.createOffsetShape(e.normal,i);a.isOk&&r.push(a.value.mesh.edges)}return r}getAxis(){let e=this.stepDatas[0].shapes[0].point,t=this.stepDatas[0].shapes[0].shape;return t.shapeType===r.ax.Edge?this.getEdgeAxis(t,e):this.getFaceOrWireAxis(t,e)}getFaceOrWireAxis(e,t){let i=e;e.shapeType===r.ax.Wire&&(i=e.toFace().value);let a=i.normal(0,0)[1],{nearest:s,direction:n}=this.getNearstPointAndDirection(e,t,a);return{point:s.point,normal:a,direction:n.cross(a).normalize()}}getEdgeAxis(e,t){let r=e.curve(),i=r.dn(r.parameter(t,.001),1),s=a.S.normal(e);return{point:t,normal:s,direction:i.cross(s).normalize()}}getNearstPointAndDirection(e,t,i){let s=e;e.shapeType===r.ax.Face&&(s=e.outerWire());let n=a.S.nearestPoint(s,t),o=a.S.findNextEdge(s,n.edge).value,l=n.edge.curve().dn(0,1),c=n.edge.orientation()===o.orientation()?1:-1,d=o.curve().dn(0,1).multiply(c);return l.cross(d).normalize()?.isOppositeTo(i)&&(l=l.multiply(-1)),{nearest:n,direction:l}}createOffsetShape(e,t){let i=this.stepDatas[0].shapes[0].shape;if(i.shapeType===r.ax.Edge)return i.offset(t,e);let a=i;return i.shapeType===r.ax.Face&&(a=i.outerWire()),a.offset(t,r.AH.intersection)}};function create_polygon_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}OffsetCommand=offset_ts_decorate([(0,r.WD)({name:"create.offset",display:"command.offset",icon:"icon-offset"})],OffsetCommand);let Polygon=class Polygon extends CreateFaceableCommand{geometryNode(){let e=new PolygonNode(this.document,this.stepDatas.map(e=>e.point));return e.isFace=this.isFace,e}async executeSteps(){let e=this.getSteps(),t=!0;for(;;){let i=t?e[0]:e[1];t&&(t=!1),this.controller=new r.Op;let a=await i.execute(this.document,this.controller);if(void 0===a)return this.controller.result?.status==="success";if(this.stepDatas.push(a),this.isClose(a))return!0}}isClose(e){return this.stepDatas.length>1&&this.stepDatas[0].point.distanceTo(e.point)<=r.Gc.Distance}getSteps(){return[new PointStep("operate.pickFistPoint"),new PointStep("operate.pickNextPoint",this.getNextData)]}getNextData=()=>({refPoint:()=>this.stepDatas.at(-1).point,dimension:n.D1D2D3,validator:this.validator,preview:this.preview,featurePoints:[{point:this.stepDatas.at(0).point,prompt:r.oc.translate("prompt.polygon.close"),when:()=>this.stepDatas.length>2}]});preview=e=>{let t=this.stepDatas.map(e=>this.previewPoint(e.point)),i=new r.G$;return this.stepDatas.forEach(e=>i.addPosition(e.point.x,e.point.y,e.point.z)),e&&i.addPosition(e.x,e.y,e.z),[...t,i.build()]};validator=e=>{for(let t of this.stepDatas)if(.001>e.distanceTo(t.point))return!1;return!0}};function create_prism_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}Polygon=create_polygon_ts_decorate([(0,r.WD)({name:"create.polygon",display:"command.polygon",icon:"icon-polygon"})],Polygon);let Prism=class Prism extends CreateCommand{geometryNode(){let e=this.stepDatas[0].shapes[0].shape,{point:t,normal:r}=this.getAxis(),i=this.stepDatas[1].point.sub(t).dot(r);return new PrismNode(this.document,e,i)}getSteps(){return[new SelectShapeStep(r.ax.Face|r.ax.Edge|r.ax.Wire,"prompt.select.shape",!1),new LengthAtAxisStep("operate.pickNextPoint",this.getLengthStepData)]}getLengthStepData=()=>{let{point:e,normal:t}=this.getAxis();return{point:e,direction:t,preview:i=>{if(!i)return[];let a=i.sub(e).dot(t);if(Math.abs(a)=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}Prism=create_prism_ts_decorate([(0,r.WD)({name:"convert.prism",display:"command.prism",icon:"icon-prism"})],Prism);let Revolve=class Revolve extends CreateCommand{get angle(){return this.getPrivateValue("angle",360)}set angle(e){this.setProperty("angle",e)}geometryNode(){let e=this.stepDatas[0].shapes[0].shape,t=this.stepDatas[1].shapes[0].shape.curve().basisCurve(),i=new r.zH(t.value(0),t.direction);return new RevolvedNode(this.document,e,i,this.angle)}getSteps(){return[new SelectShapeStep(r.ax.Edge|r.ax.Face|r.ax.Wire,"prompt.select.shape",!1),new SelectShapeStep(r.ax.Edge,"prompt.select.edges",!1,new LineFilter)]}};create_revolve_ts_decorate([r.Z9.define("common.angle")],Revolve.prototype,"angle",null),Revolve=create_revolve_ts_decorate([(0,r.WD)({name:"convert.revol",display:"command.revol",icon:"icon-revolve"})],Revolve);let LineFilter=class LineFilter{allow(e){if(e.shapeType===r.ax.Edge){let t=e.curve().basisCurve();return r.DY.isLine(t)}return!1}};function section_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}let Section=class Section extends CreateCommand{geometryNode(){let e=this.stepDatas[0].shapes[0].shape,t=this.stepDatas[1].shapes[0].shape,i=e.section(t);return new r.gC(this.document,r.oc.translate("command.section"),i)}getSteps(){return[new SelectShapeStep(r.ax.Shape,"prompt.select.shape",!1),new SelectShapeStep(r.ax.Shape,"prompt.select.shape",!1)]}};function create_sweep_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}Section=section_ts_decorate([(0,r.WD)({name:"create.section",display:"command.section",icon:"icon-section"})],Section);let Sweep=class Sweep extends CreateCommand{geometryNode(){let e=this.stepDatas[0].shapes[0].shape,t=this.stepDatas[1].shapes[0].shape;return new SweepedNode(this.document,e,t)}getSteps(){return[new SelectShapeStep(r.ax.Edge|r.ax.Wire|r.ax.Face,"prompt.select.shape",!1),new SelectShapeStep(r.ax.Edge|r.ax.Wire,"prompt.select.edges",!1)]}};function thickSolid_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}Sweep=create_sweep_ts_decorate([(0,r.WD)({name:"convert.sweep",display:"command.sweep",icon:"icon-sweep"})],Sweep);let ThickSolidCommand=class ThickSolidCommand extends CreateCommand{get thickness(){return this.getPrivateValue("thickness",10)}set thickness(e){this.setProperty("thickness",e)}geometryNode(){let e=this.stepDatas[0].shapes[0].shape,t=this.application.shapeFactory.makeThickSolidBySimple(e,this.thickness);return new r.gC(this.document,r.oc.translate("command.thickSolid"),t.value)}getSteps(){return[new SelectShapeStep(r.ax.Shape,"prompt.select.shape",!1)]}};function delete_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}thickSolid_ts_decorate([r.Z9.define("command.thickSolid")],ThickSolidCommand.prototype,"thickness",null),ThickSolidCommand=thickSolid_ts_decorate([(0,r.WD)({name:"create.thickSolid",display:"command.thickSolid",icon:"icon-thickSolid"})],ThickSolidCommand);let Delete=class Delete{async execute(e){let t=e.activeView?.document;if(!t)return;let i=t.selection.getSelectedNodes();t.currentNode&&i.includes(t.currentNode)&&(t.currentNode=t.rootNode),t.selection.clearSelection(),i.forEach(e=>e.parent?.remove(e)),t.visual.update(),r.pS.default.pub("showToast","toast.delete{0}Objects",i.length)}};function folder_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}Delete=delete_ts_decorate([(0,r.WD)({name:"modify.delete",display:"command.delete",icon:"icon-delete"})],Delete);let o=1;let NewFolder=class NewFolder{async execute(e){let t=e.activeView?.document,i=new r.YT(t,`Folder${o++}`);t.addNode(i)}};function importExport_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}NewFolder=folder_ts_decorate([(0,r.WD)({name:"create.folder",display:"command.newFolder",icon:"icon-folder-plus"})],NewFolder);let Import=class Import{async execute(e){let t=e.dataExchange.importFormats().join(","),i=await (0,r.h3)(t,!0);if(!i.isOk||0===i.value.length){alert(i.error);return}importFiles(e,i.value)}};Import=importExport_ts_decorate([(0,r.WD)({name:"file.import",display:"command.import",icon:"icon-import"})],Import);let Export=class Export extends r.uu{get formats(){return this.getPrivateValue("formats",this.initCombobox())}set formats(e){this.setProperty("formats",e)}initCombobox(){let e=new r.hQ;return e.items.push(...this.application.dataExchange.exportFormats()),e}async executeAsync(){let e=await this.selectNodesAsync();if(!e||0===e.length){r.pS.default.pub("showToast","toast.select.noSelected");return}r.pS.default.pub("showPermanent",async()=>{let t=this.formats.selectedItem;if(void 0===t)return;let i=await this.application.dataExchange.export(t,e);i&&(r.pS.default.pub("showToast","toast.downloading"),(0,r.LR)(i,`${e[0].name}${t}`))},"toast.excuting{0}",r.oc.translate("command.export"))}async selectNodesAsync(){this.controller=new r.Op;let e=new SelectNodeStep("prompt.select.models",!0),t=await e.execute(this.application.activeView?.document,this.controller);if(!t?.nodes){r.pS.default.pub("showToast","prompt.select.noModelSelected");return}return t.nodes}};function break_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}importExport_ts_decorate([r.Z9.define("file.format")],Export.prototype,"formats",null),Export=importExport_ts_decorate([(0,r.WD)({name:"file.export",display:"command.export",icon:"icon-export"})],Export);let Break=class Break extends multistepCommand_MultistepCommand{executeMainTask(){r.YW.execute(this.document,`excute ${Object.getPrototypeOf(this).data.name}`,()=>{let e=this.stepDatas[0].shapes[0].shape,t=e.curve(),i=this.stepDatas[1].point,a=t.parameter(i,.001);if(void 0===a)return;let s=t.trim(a,t.lastParameter());t.setTrim(t.firstParameter(),a);let n=this.document.visual.context.getNode(this.stepDatas[0].shapes[0].owner);n.parent?.remove(n),e.update(t);let o=new r.gC(this.document,`${n.name}_1`,e),l=new r.gC(this.document,`${n.name}_2`,s.makeEdge());this.document.addNode(o,l),this.document.visual.update()})}getSteps(){return[new SelectShapeStep(r.ax.Edge,"prompt.select.edges",!1),new PointOnCurveStep("operate.pickFistPoint",()=>({curve:this.stepDatas[0].shapes[0].shape.curve(),dimension:n.D1,preview:e=>{if(!e)return[];let t=this.stepDatas[0].shapes[0].shape.curve().project(e).at(0);return[this.previewPoint(t??e)]}}))]}};function transformedCommand_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}Break=break_ts_decorate([(0,r.WD)({name:"modify.break",display:"command.break",icon:"icon-break"})],Break);let TransformedCommand=class TransformedCommand extends multistepCommand_MultistepCommand{models;positions;get isClone(){return this.getPrivateValue("isClone",!1)}set isClone(e){this.setProperty("isClone",e)}transformPreview=e=>({positions:new Float32Array(this.transfrom(e).ofPoints(this.positions)),lineType:r.SP.Solid,color:r.OI.defaultEdgeColor,groups:[]});async ensureSelectedModels(){return this.models=this.document.selection.getSelectedNodes().filter(e=>e instanceof r.S3),this.models.length>0||(this.controller=new r.Op,this.models=await this.document.selection.pickNode("prompt.select.models",this.controller,!0),this.models.length>0||(this.controller.result?.status==="success"&&r.pS.default.pub("showToast","toast.select.noSelected"),!1))}async canExcute(){return!!await this.ensureSelectedModels()&&(this.positions=this.models.flatMap(e=>e instanceof r.bR?e.mesh.position?e.transform.ofPoints(e.mesh.position):[]:e instanceof r.R3&&e.mesh.edges?.positions?e.transform.ofPoints(e.mesh.edges.positions):[]),!0)}getTempLineData(e,t){return r.bj.from(e,t,r.OI.temporaryEdgeColor,r.SP.Solid)}executeMainTask(){r.YW.execute(this.document,`excute ${Object.getPrototypeOf(this).data.name}`,()=>{let e=this.isClone?this.models?.map(e=>e.clone()):this.models,t=this.transfrom(this.stepDatas.at(-1).point);e?.forEach(e=>{e.transform=e.transform.multiply(t)}),this.document.visual.update()})}};function mirror_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}transformedCommand_ts_decorate([r.Z9.define("common.clone")],TransformedCommand.prototype,"isClone",null);let Mirror=class Mirror extends TransformedCommand{transfrom(e){let t=this.stepDatas[0].point,i=this.stepDatas[0].view.workplane.normal,a=e.sub(t).cross(i),s=new r.JO(t,a,i);return r.yG.createMirrorWithPlane(s)}getSteps(){return[new PointStep("operate.pickFistPoint"),new PointStep("operate.pickNextPoint",this.getSecondPointData)]}getSecondPointData=()=>({refPoint:()=>this.stepDatas[0].point,dimension:n.D1D2,preview:this.mirrorPreview,validator:e=>{let t=e.sub(this.stepDatas[0].point);return t.length()>.001&&!t.isParallelTo(this.stepDatas[0].view.workplane.normal)}});mirrorPreview=e=>{let t=this.previewPoint(this.stepDatas[0].point);if(!e)return[t];let r=this.transformPreview(e),i=e.sub(this.stepDatas[0].point).normalize().multiply(1e6);return[t,r,this.getTempLineData(this.stepDatas[0].point.sub(i),e.add(i))]}};function move_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}Mirror=mirror_ts_decorate([(0,r.WD)({name:"modify.mirror",display:"command.mirror",icon:"icon-mirror"})],Mirror);let Move=class Move extends TransformedCommand{getSteps(){return[new PointStep("operate.pickFistPoint"),new PointStep("operate.pickNextPoint",this.getSecondPointData)]}getSecondPointData=()=>({refPoint:()=>this.stepDatas[0].point,dimension:n.D1D2D3,preview:this.movePreview});movePreview=e=>{let t=this.previewPoint(this.stepDatas[0].point);return e?[t,this.transformPreview(e),this.getTempLineData(this.stepDatas[0].point,e)]:[t]};transfrom(e){let{x:t,y:i,z:a}=e.sub(this.stepDatas[0].point);return r.yG.createTranslation(t,i,a)}};function rotate_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}Move=move_ts_decorate([(0,r.WD)({name:"modify.move",display:"command.move",icon:"icon-move"})],Move);let Rotate=class Rotate extends TransformedCommand{transfrom(e){let t=this.stepDatas[0].view.workplane.normal,i=this.stepDatas[0].point,a=this.stepDatas[1].point.sub(i),s=e.sub(i),n=a.angleOnPlaneTo(s,t);return r.yG.createRotationAt(i,t,n)}getSteps(){return[new PointStep("operate.pickFistPoint"),new PointStep("operate.pickNextPoint",this.getSecondPointData),new AngleStep("operate.pickNextPoint",()=>this.stepDatas[0].point,()=>this.stepDatas[1].point,this.getThirdPointData)]}getSecondPointData=()=>({refPoint:()=>this.stepDatas[0].point,dimension:n.D1D2D3,plane:()=>this.stepDatas[0].view.workplane.translateTo(this.stepDatas[0].point),preview:this.linePreview,validator:e=>e.distanceTo(this.stepDatas[0].point)>1e-6});getThirdPointData=()=>({dimension:n.D1D2,preview:this.rotatePreview,plane:()=>this.stepDatas[0].view.workplane.translateTo(this.stepDatas[0].point),validator:e=>e.distanceTo(this.stepDatas[0].point)>.001&&e.distanceTo(this.stepDatas[1].point)>.001});rotatePreview=e=>{let t=[this.previewPoint(this.stepDatas[0].point),this.getRayData(this.stepDatas[1].point),this.previewPoint(this.stepDatas[1].point)];if(e){let r=this.transformPreview(e),i=this.getRayData(e);t.push(i,r)}return t};getRayData(e){let t=this.stepDatas[0].point,r=t.add(e.sub(t).normalize().multiply(1e6));return this.getTempLineData(t,r)}linePreview=e=>{let t=this.previewPoint(this.stepDatas[0].point);return e?[t,this.getTempLineData(this.stepDatas[0].point,e)]:[t]}};function split_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}Rotate=rotate_ts_decorate([(0,r.WD)({name:"modify.rotate",display:"command.rotate",icon:"icon-rotate"})],Rotate);let Split=class Split extends multistepCommand_MultistepCommand{splitedShape(){let e=this.stepDatas[0].shapes[0].shape,t=this.stepDatas[1].shapes.map(e=>e.shape);return e.split(t)}executeMainTask(){r.YW.execute(this.document,`excute ${Object.getPrototypeOf(this).data.name}`,()=>{let e=this.document.visual.context.getNode(this.stepDatas[0].shapes[0].owner),t=this.splitedShape();if(e instanceof r.gC)e.shape=r.x4.ok(t);else if(e instanceof r.R3){let i=new r.gC(this.document,e.name,t);i.transform=e.transform,this.removeModels(this.stepDatas[0].shapes[0].owner,...this.stepDatas[1].shapes.map(e=>e.owner)),this.document.addNode(i)}this.document.visual.update()})}removeModels(...e){e.forEach(e=>{let t=this.document.visual.context.getNode(e);t?.parent?.remove(t)})}getSteps(){return[new SelectShapeStep(r.ax.Shape,"prompt.select.shape",!1),new SelectShapeStep(r.ax.Wire|r.ax.Edge,"prompt.select.shape",!0)]}};function trim_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}Split=split_ts_decorate([(0,r.WD)({name:"modify.split",display:"command.split",icon:"icon-split"})],Split);let Trim=class Trim extends r.uu{async executeAsync(){let e=new r.YW(this.document,r.oc.translate("command.trim"));e.start();try{await this.trimAsync()}catch(t){throw e.rollback(),t}e.commit()}async trimAsync(){for(;!this.isCompleted;){this.controller=new r.Op;let e=new PickTrimEdgeEventHandler(this.document,this.controller);if(await this.document.selection.pickAsync(e,"prompt.select.edges",this.controller,!1,"select.default"),this.controller.result?.status!=="success"||!e.selected)break;this.trimEdge(e.selected)}}trimEdge(e){let t=this.document.visual.context.getNode(e.edge.owner),i=t?.materialId;e.segments.retainSegments.forEach(a=>{let s=e.curve.trim(a.start,a.end).makeEdge();t?.parent?.add(new r.gC(this.document,t.name,s,i))}),t?.parent?.remove(t)}};Trim=trim_ts_decorate([(0,r.WD)({name:"modify.trim",display:"command.trim",icon:"icon-trim"})],Trim);let EdgeFilter=class EdgeFilter{allow(e){return e.shapeType===r.ax.Edge}};let PickTrimEdgeEventHandler=class PickTrimEdgeEventHandler extends i.k8{selected;highlightedEdge;highlight;constructor(e,t){super(e,r.ax.Shape,!1,t,new EdgeFilter)}setHighlight(e,t){if(this.cleanHighlights(),1!==t.length||t[0].shape.shapeType!==r.ax.Edge)return;let i=t[0].shape,a=i.curve(),s=findSegments(a,i,findEdges(t,e),t),n=i.trim(s.deleteSegment.start,s.deleteSegment.end).mesh.edges;n.color=r.OI.highlightEdgeColor,n.lineWidth=2,this.highlightedEdge=e.document.visual.highlighter.highlightMesh(n),this.highlight={edge:t[0],segments:s,curve:a},e.update()}cleanHighlights(){void 0!==this.highlightedEdge&&(this.document.visual.highlighter.removeHighlightMesh(this.highlightedEdge),this.highlightedEdge=void 0,this.highlight=void 0,this.document.application.activeView?.update())}clearSelected(e){this.selected=void 0}select(e,t){return this.selected=this.highlight,+!!this.selected}};function findEdges(e,t){let r=e[0].owner.boundingBox();return t.document.visual.context.boundingBoxIntersectFilter(r,new EdgeFilter).map(e=>e?.geometryNode?.shape.value).filter(t=>void 0!==t&&t.id!==e[0].shape.id)}function findSegments(e,t,r,i){let s=a.S.intersects(t,r).map(e=>e.parameter);if(s.push(e.firstParameter(),e.lastParameter()),2===(s=[...new Set(s)].sort((e,t)=>e-t)).length)return allSegment(s);let n=e.parameter(i[0].point,.001);for(let e=1;e=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}let Redo=class Redo{async execute(e){let t=e.activeView?.document;t?.history.redo(),t?.visual.update()}};function undo_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}Redo=redo_ts_decorate([(0,r.WD)({name:"edit.redo",display:"command.redo",icon:"icon-redo"})],Redo);let Undo=class Undo{async execute(e){let t=e.activeView?.document;t?.history.undo(),t?.visual.update()}};function workingPlane_ts_decorate(e,t,r,i){var a,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s<3?a(n):s>3?a(t,r,n):a(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}Undo=undo_ts_decorate([(0,r.WD)({name:"edit.undo",display:"command.undo",icon:"icon-undo"})],Undo);let WorkingPlaneViewModel=class WorkingPlaneViewModel extends r.y${planes=new r.io(["XOY","YOZ","ZOX"],r.W7.radio,["XOY"])};workingPlane_ts_decorate([r.Z9.define("workingPlane.set")],WorkingPlaneViewModel.prototype,"planes",void 0);let SetWorkplane=class SetWorkplane{async execute(e){let t=e.activeView;if(!t)return;let i=new WorkingPlaneViewModel;r.pS.default.pub("showDialog","workingPlane.set",i,()=>{let e=[r.JO.XY,r.JO.YZ,r.JO.ZX];t.workplane=e[i.planes.selectedIndexes[0]]})}};SetWorkplane=workingPlane_ts_decorate([(0,r.WD)({name:"workingPlane.set",display:"workingPlane.set",icon:"icon-setWorkingPlane"})],SetWorkplane);let AlignToPlane=class AlignToPlane{async execute(e){let t=e.activeView;if(!t)return;t.document.selection.clearSelection();let i=new r.Op,a=await new SelectShapeStep(r.ax.Face,"prompt.select.faces",!1).execute(t.document,i);if(i.dispose(),!a||0===a.shapes.length)return;t.document.visual.highlighter.clear();let[s,n]=a.shapes[0].shape.normal(0,0),o=r.vY.unitX;n.isParallelTo(r.vY.unitZ)||(o=r.vY.unitZ.cross(n).normalize()),t.workplane=new r.JO(s,n,o)}};AlignToPlane=workingPlane_ts_decorate([(0,r.WD)({name:"workingPlane.alignToPlane",display:"workingPlane.alignToPlane",icon:"icon-alignWorkingPlane"})],AlignToPlane);let EditEventHandler=class EditEventHandler extends i.t{selectedNodes;constructor(e,t){super(e,!0),this.selectedNodes=t,r.pS.default.pub("showProperties",e,t)}dispose(){r.pS.default.pub("showProperties",this.document,[]),super.dispose()}};let l=["doc.new","doc.open","doc.save"];let CommandService=class CommandService{_lastCommand;_checking=!1;_app;get app(){if(void 0===this._app)throw Error("Executor is not initialized");return this._app}start(){r.pS.default.sub("executeCommand",this.executeCommand),r.pS.default.sub("activeViewChanged",this.onActiveViewChanged),r.Yd.info(`${CommandService.name} started`)}stop(){r.pS.default.remove("executeCommand",this.executeCommand),r.pS.default.remove("activeViewChanged",this.onActiveViewChanged),r.Yd.info(`${CommandService.name} stoped`)}register(e){this._app=e,r.Yd.info(`${CommandService.name} registed`)}onActiveViewChanged=async e=>{this.app.executingCommand&&r.wV.isCancelableCommand(this.app.executingCommand)&&await this.app.executingCommand.cancel()};executeCommand=async e=>{let t="special.last"===e?this._lastCommand:e;t&&await this.canExecute(t)&&(r.Yd.info(`executing command ${t}`),await this.executeAsync(t))};async executeAsync(e){let t=new(r.mY.get(e));this.app.executingCommand=t,r.pS.default.pub("showProperties",this.app.activeView?.document,[]);try{await t.execute(this.app)}catch(e){r.pS.default.pub("displayError",e),r.Yd.error(e)}finally{this._lastCommand=e,this.app.executingCommand=void 0}}async canExecute(e){if(this._checking)return!1;this._checking=!0;let t=await this.checking(e);return this._checking=!1,t}async checking(e){return r.mY.get(e)?l.includes(e)||void 0!==this.app.activeView?!this.app.executingCommand||(r.mY.getData(this.app.executingCommand)?.name===e?(r.pS.default.pub("showToast","toast.command.{0}excuting",e),!1):!!r.wV.isCancelableCommand(this.app.executingCommand)&&(await this.app.executingCommand.cancel(),!0)):(r.Yd.error("No active document"),!1):(r.Yd.error(`Can not find ${e} command`),!1)}};let EditorService=class EditorService{factory;editHandler;constructor(e){this.factory=e,this.handleSelectionChanged=(e,t)=>{this.editHandler?.dispose(),this.editHandler=void 0,e.application.executingCommand||(t.length>0?(this.editHandler=this.factory(e,t),e.visual.eventHandler=this.editHandler):e.visual.resetEventHandler())}}register(e){r.Yd.info(`${EditorService.name} registed`)}start(){r.pS.default.sub("selectionChanged",this.handleSelectionChanged),r.Yd.info(`${EditorService.name} started`)}stop(){r.pS.default.remove("selectionChanged",this.handleSelectionChanged),r.Yd.info(`${EditorService.name} stopped`)}handleSelectionChanged};let c={Delete:"modify.delete",Backspace:"modify.delete"," ":"special.last",Enter:"special.last","ctrl+z":"edit.undo","ctrl+y":"edit.redo"};let HotkeyService=class HotkeyService{app;_keyMap=new Map;constructor(){this.addMap(c)}register(e){this.app=e,r.Yd.info(`${HotkeyService.name} registed`)}start(){window.addEventListener("keydown",this.interactiveKeyDown),window.addEventListener("keydown",this.commandKeyDown),window.addEventListener("keyup",this.interactiveHandlerKeyUp),r.Yd.info(`${HotkeyService.name} started`)}stop(){window.removeEventListener("keydown",this.interactiveKeyDown),window.removeEventListener("keydown",this.commandKeyDown),window.removeEventListener("keyup",this.interactiveHandlerKeyUp),r.Yd.info(`${HotkeyService.name} stoped`)}interactiveKeyDown=e=>{e.preventDefault();let t=this.app?.activeView;t&&(t.onKeyDown(e),t.document?.visual.eventHandler.keyDown(t,e),this.app?.executingCommand&&e.stopImmediatePropagation())};interactiveHandlerKeyUp=e=>{e.preventDefault(),this.app?.activeView?.onKeyUp(e),this.app?.executingCommand&&e.stopImmediatePropagation()};commandKeyDown=e=>{e.preventDefault();let t=this.getCommand(e);void 0!==t&&r.pS.default.pub("executeCommand",t)};getKey(e){let t=e.key;return e.ctrlKey&&(t="ctrl+"+t),e.shiftKey&&(t="shift+"+t),e.altKey&&(t="alt+"+t),t}map(e,t){let r=this.getKey(t);this._keyMap.set(r,e)}getCommand(e){let t=this.getKey(e);return this._keyMap.get(t)}addMap(e){Object.keys(e).forEach(t=>{this._keyMap.set(t,e[t])})}};async function importBrep(e,t){let i=e.application.shapeFactory.converter.convertFromBrep(await t.text());return i.isOk?r.x4.ok(new r.gC(e,t.name,i.value)):r.x4.err(i.error)}async function exportBrep(e,t){let i=e.application.shapeFactory.combine(t);return i.isOk?e.application.shapeFactory.converter.convertToBrep(i.value):r.x4.err(i.error)}let DefaultDataExchange=class DefaultDataExchange{importFormats(){return[".step",".stp",".iges",".igs",".brep"]}exportFormats(){return[".step",".iges",".brep"]}async import(e,t){for(let r of t)await this.handleSingleFileImport(e,r)}async handleSingleFileImport(e,t){let r=t.name.endsWith(".brep")?await importBrep(e,t):await this.handleStepIgesImport(e,t);if(!r?.isOk)return;let i=r.value;i.name=t.name,e.addNode(i),e.visual.update()}async handleStepIgesImport(e,t){console.log(t);let i=new Uint8Array(await t.arrayBuffer());return this.isStepFile(t.name)?e.application.shapeFactory.converter.convertFromSTEP(e,i):this.isIgesFile(t.name)?e.application.shapeFactory.converter.convertFromIGES(e,i):void alert(r.oc.translate("error.import.unsupportedFileType:{0}",t.name))}async export(e,t){if(!this.validateExportType(e))return;let r=this.getExportShapes(t);if(!r.length)return;let i=await this.convertShapes(e,t[0].document,r);return this.handleExportResult(i)}validateExportType(e){let t=this.exportFormats().includes(e);return t||r.pS.default.pub("showToast","error.import.unsupportedFileType:{0}",e),t}getExportShapes(e){let t=e.filter(e=>e instanceof r.EK).map(e=>e.shape.value);return t.length||r.pS.default.pub("showToast","error.export.noNodeCanBeExported"),t}async convertShapes(e,t,r){return".step"===e?this.handleStepExport(t,r):".iges"===e?this.handleIgesExport(t,r):exportBrep(t,r)}handleStepExport(e,t){return e.application.shapeFactory.converter.convertToSTEP(...t)}handleIgesExport(e,t){return e.application.shapeFactory.converter.convertToIGES(...t)}handleExportResult(e){if(!e?.isOk){r.pS.default.pub("showToast","error.default:{0}",e?.error);return}return[e.value]}isStepFile(e){return e.endsWith(".step")||e.endsWith(".stp")}isIgesFile(e){return e.endsWith(".iges")||e.endsWith(".igs")}};let AppBuilder=class AppBuilder{_inits=[];_additionalModules=[];_storage;_visualFactory;_shapeFactory;_window;useIndexedDB(){return this._inits.push(async()=>{r.Yd.info("initializing IndexedDBStorage");let e=await __webpack_require__.e("392").then(__webpack_require__.bind(__webpack_require__,2702));this._storage=new e.IndexedDBStorage}),this}useWasmOcc(){return this._inits.push(async()=>{r.Yd.info("initializing wasm occ");let e=await __webpack_require__.e("33").then(__webpack_require__.bind(__webpack_require__,584));await e.initWasm(),this._shapeFactory=new e.ShapeFactory}),this}useThree(){return this._inits.push(async()=>{r.Yd.info("initializing three");let e=await Promise.all([__webpack_require__.e("323"),__webpack_require__.e("697")]).then(__webpack_require__.bind(__webpack_require__,8025));this._visualFactory=new e.ThreeVisulFactory}),this}useUI(){return this._inits.push(async()=>{r.Yd.info("initializing MainWindow"),this.loadAdditionalI18n();let e=await __webpack_require__.e("657").then(__webpack_require__.bind(__webpack_require__,891));this._window=new e.MainWindow(await this.getRibbonTabs())}),this}addAdditionalModules(...e){return this._additionalModules.push(...e),this}async getRibbonTabs(){return(await __webpack_require__.e("962").then(__webpack_require__.bind(__webpack_require__,9052))).DefaultRibbon}async build(){for(let e of this._inits)await e();this.ensureNecessary();let e=this.createApp();this._window?.init(e),window.MyApp=e,this.loadAdditionalCommands(),r.Yd.info("Application build completed")}createApp(){return new Application({storage:this._storage,shapeFactory:this._shapeFactory,visualFactory:this._visualFactory,services:this.getServices(),mainWindow:this._window,dataExchange:this.initDataExchange()})}initDataExchange(){return new DefaultDataExchange}ensureNecessary(){if(void 0===this._shapeFactory)throw Error("ShapeFactory not set");if(void 0===this._visualFactory)throw Error("VisualFactory not set");if(void 0===this._storage)throw Error("storage has not been initialized")}loadAdditionalI18n(){for(let e of this._additionalModules)e.i18n().forEach(e=>{r.oc.combineTranslation(e.code,e.translation)})}loadAdditionalCommands(){for(let e of this._additionalModules)this._window&&e.ribbonCommands().forEach(e=>{this._window.registerRibbonCommand(e.tabName,e.groupName,e.command)})}getServices(){return[new CommandService,new HotkeyService,new EditorService((e,t)=>new EditEventHandler(e,t))]}};let Loading=class Loading extends HTMLElement{constructor(){super(),this.initSpinner(),this.initLabel(),this.initAnimation(),this.style.cssText=` position: fixed; display: block; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999; background-color: rgba(0, 0, 0, 0.5); `}initSpinner(){let e=document.createElement("div");e.style.cssText=` position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%); width: 50px; height: 50px; border-radius: 50%; border: 5px solid #fff; border-top-color: #000; animation: spin 1s infinite linear; `,this.appendChild(e)}initAnimation(){let e=document.createElement("style");e.innerHTML=` @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } `,document.head.appendChild(e)}initLabel(){let e=document.createElement("div");e.innerText="Loading...",e.style.cssText=` color: white; font-size: 16px; position: relative; top: calc(40% + 100px); left: calc(50% + 25px); transform: translate(-50%, -50%); width: 50px; height: 50px; `,this.appendChild(e)}};customElements.define("chili-loading",Loading);let d=new Loading;document.body.appendChild(d),new AppBuilder().useIndexedDB().useWasmOcc().useThree().useUI().build().then(e=>{document.body.removeChild(d)}).catch(e=>{r.Yd.error(e)})})()})(); //# sourceMappingURL=main.js.map