iflow-engine 2.5.1 → 2.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9606,7 +9606,7 @@ ${JSON.stringify(l,null,2)}
9606
9606
  <svg viewBox="0 0 24 24" aria-hidden="true">
9607
9607
  <path d="M19.14 12.94c.04-.31.06-.63.06-.94s-.02-.63-.06-.94l2.03-1.58a.5.5 0 0 0 .12-.64l-1.92-3.32a.5.5 0 0 0-.6-.22l-2.39.96a7.27 7.27 0 0 0-1.63-.94l-.36-2.54A.5.5 0 0 0 13.9 1h-3.8a.5.5 0 0 0-.49.42l-.36 2.54c-.58.23-1.12.54-1.63.94l-2.39-.96a.5.5 0 0 0-.6.22L2.71 7.48a.5.5 0 0 0 .12.64l2.03 1.58c-.04.31-.06.63-.06.94s.02.63.06.94L2.83 14.52a.5.5 0 0 0-.12.64l1.92 3.32c.13.22.39.3.6.22l2.39-.96c.5.4 1.05.71 1.63.94l.36 2.54c.04.24.25.42.49.42h3.8c.24 0 .45-.18.49-.42l.36-2.54c.58-.23 1.12-.54 1.63-.94l2.39.96c.22.09.47 0 .6-.22l1.92-3.32a.5.5 0 0 0-.12-.64l-2.03-1.58zM12 15.5A3.5 3.5 0 1 1 12 8a3.5 3.5 0 0 1 0 7.5z"></path>
9608
9608
  </svg>
9609
- `,this.settingsBtn.addEventListener("click",()=>{this.openSettings()}),u.appendChild(this.clearBtn),u.appendChild(this.settingsBtn),this.mainViewEl.appendChild(u),this.settingsViewEl=this.createSettingsDom(),e.appendChild(this.mainViewEl),e.appendChild(this.settingsViewEl),e}createSettingsDom(){const e=document.createElement("div");e.className="bim-measure-settings";const t=document.createElement("div");t.className="bim-measure-settings-title",t.dataset.i18nKey="measure.settings.title",e.appendChild(t);const i=document.createElement("div");i.className="bim-measure-settings-row";const n=document.createElement("div");n.className="label",n.dataset.i18nKey="measure.settings.unit",this.unitSelectEl=document.createElement("select"),this.unitSelectEl.className="bim-measure-settings-select",this.unitSelectEl.appendChild(this.makeOption("m")),this.unitSelectEl.appendChild(this.makeOption("cm")),this.unitSelectEl.appendChild(this.makeOption("mm")),this.unitSelectEl.appendChild(this.makeOption("km")),i.appendChild(n),i.appendChild(this.unitSelectEl),e.appendChild(i);const r=document.createElement("div");r.className="bim-measure-settings-hint",r.dataset.i18nKey="measure.settings.hint",e.appendChild(r);const a=document.createElement("div");a.className="bim-measure-settings-row";const o=document.createElement("div");o.className="label",o.dataset.i18nKey="measure.settings.precision",this.precisionSelectEl=document.createElement("select"),this.precisionSelectEl.className="bim-measure-settings-select",this.precisionSelectEl.appendChild(this.makePrecisionOption(0)),this.precisionSelectEl.appendChild(this.makePrecisionOption(1)),this.precisionSelectEl.appendChild(this.makePrecisionOption(2)),this.precisionSelectEl.appendChild(this.makePrecisionOption(3)),a.appendChild(o),a.appendChild(this.precisionSelectEl),e.appendChild(a);const l=document.createElement("div");return l.className="bim-measure-settings-actions",this.saveSettingsBtn=document.createElement("button"),this.saveSettingsBtn.type="button",this.saveSettingsBtn.className="bim-measure-settings-save",this.saveSettingsBtn.addEventListener("click",()=>{this.saveSettings()}),this.cancelSettingsBtn=document.createElement("button"),this.cancelSettingsBtn.type="button",this.cancelSettingsBtn.className="bim-measure-settings-cancel",this.cancelSettingsBtn.addEventListener("click",()=>{this.cancelSettings()}),l.appendChild(this.saveSettingsBtn),l.appendChild(this.cancelSettingsBtn),e.appendChild(l),this.syncSettingsFormFromConfig(this.config),e}createModeOptionsDom(){const e=document.createElement("div");e.className="bim-measure-mode-options";const t=document.createElement("div");t.className="bim-measure-radio-group";const i=document.createElement("span");i.className="bim-measure-radio-label",i.dataset.i18nKey="measure.clearHeight.direction";const n=document.createElement("div");n.className="bim-measure-radio-items";const r=this.createRadioItem("measure.clearHeight.directionDown",()=>{this.setClearHeightDirection(0)}),a=this.createRadioItem("measure.clearHeight.directionUp",()=>{this.setClearHeightDirection(1)});this.directionBtns.set(0,r),this.directionBtns.set(1,a),n.appendChild(r),n.appendChild(a),t.appendChild(i),t.appendChild(n),e.appendChild(t);const o=document.createElement("div");o.className="bim-measure-radio-group";const l=document.createElement("span");l.className="bim-measure-radio-label",l.dataset.i18nKey="measure.clearHeight.selectType";const c=document.createElement("div");c.className="bim-measure-radio-items";const h=this.createRadioItem("measure.clearHeight.selectPoint",()=>{this.setClearHeightSelectType("point")}),d=this.createRadioItem("measure.clearHeight.selectElement",()=>{this.setClearHeightSelectType("element")});return this.selectTypeBtns.set("point",h),this.selectTypeBtns.set("element",d),c.appendChild(h),c.appendChild(d),o.appendChild(l),o.appendChild(c),e.appendChild(o),e}createRadioItem(e,t){const i=document.createElement("button");return i.type="button",i.className="bim-measure-radio-item",i.dataset.i18nKey=e,i.textContent=Se(e),i.addEventListener("click",t),i}setClearHeightDirection(e){this.clearHeightDirection!==e&&(this.clearHeightDirection=e,this.applyClearHeightOptionsState(),this.options.onClearHeightDirectionChange?.(e))}setClearHeightSelectType(e){this.clearHeightSelectType!==e&&(this.clearHeightSelectType=e,this.applyClearHeightOptionsState(),this.options.onClearHeightSelectTypeChange?.(e))}applyClearHeightOptionsState(){this.activeMode==="clearHeight"?this.modeOptionsEl.classList.add("is-visible"):this.modeOptionsEl.classList.remove("is-visible");for(const[e,t]of this.directionBtns.entries())e===this.clearHeightDirection?t.classList.add("is-active"):t.classList.remove("is-active");for(const[e,t]of this.selectTypeBtns.entries())e===this.clearHeightSelectType?t.classList.add("is-active"):t.classList.remove("is-active")}makeOption(e){const t=document.createElement("option");return t.value=e,t.textContent=e,t}makePrecisionOption(e){const t=document.createElement("option");return t.value=String(e),t.textContent=e===0?"0":`0.${"0".repeat(e)}`,t}enterSettingsView(){this.draftConfig={...this.config},this.view="settings",this.syncSettingsFormFromConfig(this.config),this.applyViewState()}saveSettings(){const e=this.unitSelectEl.value||this.config.unit,t=Number(this.precisionSelectEl.value),i={unit:e,precision:this.isValidPrecision(t)?t:this.config.precision};this.config=i,this.saveConfigToCache(i),this.draftConfig=null,this.view="main",this.applyViewState(),this.renderResult(),this.options.onConfigSave?.(i),this.options.onExpandedChange?.(this.isExpanded)}cancelSettings(){this.draftConfig&&(this.config={...this.draftConfig}),this.draftConfig=null,this.view="main",this.applyViewState(),this.renderResult(),this.options.onExpandedChange&&this.options.onExpandedChange(this.isExpanded)}syncSettingsFormFromConfig(e){this.unitSelectEl.value=e.unit,this.precisionSelectEl.value=String(e.precision)}applyViewState(){this.view==="settings"?(this.mainViewEl.style.display="none",this.settingsViewEl.style.display="block"):(this.mainViewEl.style.display="block",this.settingsViewEl.style.display="none")}loadConfigFromCache(){try{const e=localStorage.getItem(ed.CONFIG_CACHE_KEY);if(!e)return null;const t=JSON.parse(e);if(!t||typeof t!="object")return null;const i=t.unit,n=t.precision;return!this.isValidUnit(i)||!this.isValidPrecision(n)?null:{unit:i,precision:n}}catch{return null}}saveConfigToCache(e){try{localStorage.setItem(ed.CONFIG_CACHE_KEY,JSON.stringify(e))}catch{}}isValidUnit(e){return e==="m"||e==="cm"||e==="mm"||e==="km"}isValidPrecision(e){return e===0||e===1||e===2||e===3}applyExpandedState(){let e=0;for(const t of this.toolButtons.values())e>=4?t.style.display=this.isExpanded?"":"none":t.style.display="",e++;this.isExpanded?this.toggleBtn.classList.add("is-expanded"):this.toggleBtn.classList.remove("is-expanded")}applyActiveModeState(){for(const[e,t]of this.toolButtons.entries())e===this.activeMode?t.classList.add("is-active"):t.classList.remove("is-active")}renderResult(){if(this.activeMode==="point"){this.mainValueRowEl.style.display="none",this.xyzBoxEl.style.display="";const i=this.result?.xyz;if(!i){this.xyzXEl.textContent="--",this.xyzYEl.textContent="--",this.xyzZEl.textContent="--";return}this.xyzXEl.textContent=this.convertValue("length",i.x)+" "+this.getUnitText("length"),this.xyzYEl.textContent=this.convertValue("length",i.y)+" "+this.getUnitText("length"),this.xyzZEl.textContent=this.convertValue("length",i.z)+" "+this.getUnitText("length");return}this.mainValueRowEl.style.display="",this.mainValueLabelEl.textContent=Se(this.getModeValueLabelI18nKey(this.activeMode));const t=this.result?this.result[dc[this.activeMode].callBackType]:void 0;if(this.activeMode==="slope"||this.activeMode==="angle")this.mainNumberEl.textContent=t??"--",this.mainUnitEl.textContent="";else{const i=R2(this.activeMode);this.mainNumberEl.textContent=this.convertValue(i,t),this.mainUnitEl.textContent=this.getUnitText(i)}this.xyzBoxEl.style.display="none"}getModeI18nKey(e){return`measure.modes.${e}`}getModeValueLabelI18nKey(e){return`measure.labels.value.${e}`}convertValue(e,t){if(t==null||Number.isNaN(t))return"--";const i=this.config.unit,n=this.config.precision;let r;switch(e){case"length":switch(i){case"mm":r=t*1e3;break;case"cm":r=t*100;break;case"km":r=t/1e3;break;default:r=t}break;case"area":switch(i){case"mm":r=t*1e3*1e3;break;case"cm":r=t*100*100;break;case"km":r=t/1e3/1e3;break;default:r=t}break;default:r=t}return r.toFixed(n)}getUnitText(e){const t=this.config.unit;switch(e){case"length":case"point":return t;case"area":return`${t}²`;case"angle":case"percent":return"°";default:return""}}}class B2 extends No{panel=null;config=null;unsubscribeMeasureChanged=null;constructor(e){super(e)}get dialogId(){return"measure-dialog"}get dialogTitle(){return"measure.dialogTitle"}get dialogWidth(){return 250}createContent(){this.panel=new ed({defaultMode:"distance",defaultExpanded:!1,onModeChange:t=>{console.log("[MeasureDialogManager] 当前测量方式已切换:",t),this.engineComponent?.activateMeasure(t)},onClearAll:()=>{console.log("[MeasureDialogManager] 删除全部"),this.engineComponent?.clearAllMeasures()},onSettings:()=>{console.log("[MeasureDialogManager] 打开设置")},onExpandedChange:()=>{this.dialog?.fitHeight(!1)},onConfigSave:t=>{console.log("[MeasureDialogManager] 保存设置:",t),this.engineComponent?.saveMeasureSetting({unit:t.unit,precision:t.precision})},onClearHeightDirectionChange:t=>{console.log("[MeasureDialogManager] 净高朝向切换:",t),this.engineComponent?.setClearHeightDirection(t)},onClearHeightSelectTypeChange:t=>{console.log("[MeasureDialogManager] 净高选择对象切换:",t),this.engineComponent?.setClearHeightSelectType(t)}}),this.panel.init(),this.config=this.panel.getConfig(),this.config&&(console.log("[MeasureDialogManager] 同步缓存设置到引擎:",this.config),this.engineComponent?.saveMeasureSetting({unit:this.config.unit,precision:this.config.precision}));const e=document.createElement("div");return e.style.padding="12px",e.appendChild(this.panel.element),e}onDialogCreated(){this.dialog?.fitHeight(!1),this.engineComponent?.setClearHeightDirection(0),this.engineComponent?.setClearHeightSelectType("point");const e=this.engineComponent;if(e){const t=i=>{console.log("[MeasureDialogManager] 测量值回调:",i),i&&this.panel&&this.handleMeasureChanged(i)};e.onRawEvent("measure-changed",t),e.onRawEvent("measure-click",t),this.unsubscribeMeasureChanged=()=>{e.offRawEvent("measure-changed",t),e.offRawEvent("measure-click",t)}}}handleMeasureChanged(e){if(!this.panel)return;const t=L2(e.type);if(!t){console.warn("[MeasureDialogManager] 未知测量类型:",e.type);return}this.panel.getActiveMode()!==t&&this.panel.switchMode(t,!1);const n=this.convertToMeasureResult(e,t);this.panel.setResult(n)}convertToMeasureResult(e,t){const i=dc[t],n={};return R2(t)==="point"?e.textX!==void 0&&e.textY!==void 0&&e.textZ!==void 0&&(n.xyz={x:e.textX,y:e.textY,z:e.textZ}):n[i.callBackType]=e.text,n}onDialogClose(){this.unsubscribeMeasureChanged&&(this.unsubscribeMeasureChanged(),this.unsubscribeMeasureChanged=null),this.registry.toolbar?.setBtnActive("measure",!1)}onBeforeDestroy(){this.unsubscribeMeasureChanged&&(this.unsubscribeMeasureChanged(),this.unsubscribeMeasureChanged=null),this.engineComponent?.deactivateMeasure(),this.panel&&(this.panel.destroy(),this.panel=null)}getActiveMode(){return this.panel?this.panel.getActiveMode():null}switchMode(e){this.panel&&this.panel.switchMode(e)}setMeasureResult(e){this.panel&&this.panel.setResult(e)}getConfig(){return this.panel&&(this.config=this.panel.getConfig()),this.config?{...this.config}:null}setConfig(e,t=!0){if(this.panel){this.panel.setConfig(e,t),this.config=this.panel.getConfig(),this.dialog?.fitHeight(!1);return}const i=this.config,n={unit:e.unit??i?.unit??"mm",precision:e.precision??i?.precision??2};this.config=n}clearAll(){this.panel&&this.panel.clearAll()}openSettings(){this.panel&&this.panel.openSettings()}}class t9{element;options;isHidden=!1;hideBtn;reverseBtn;resetBtn;hideLabelEl;reverseLabelEl;resetLabelEl;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e={}){this.options=e,this.isHidden=e.defaultHidden??!1,this.element=this.createDom()}setHiddenState(e){this.isHidden=e,this.updateButtonStates()}getHiddenState(){return this.isHidden}updateButtonStates(){this.hideBtn?.classList.toggle("active",this.isHidden)}init(){this.unsubscribeLocale=Zt.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=ct.subscribe(e=>{this.setTheme(e)}),this.setLocales(),this.setTheme(ct.getTheme())}setTheme(e){const t=this.element.style;t.setProperty("--bim-bg-inset",e.bgInset??"#152232"),t.setProperty("--bim-border-default",e.borderDefault??"#334155"),t.setProperty("--bim-border-strong",e.borderStrong??"#475569"),t.setProperty("--bim-primary",e.primary??"#3b82f6"),t.setProperty("--bim-primary-subtle",e.primarySubtle??"rgba(59, 130, 246, 0.15)"),t.setProperty("--bim-icon-default",e.iconDefault??"#ffffff"),t.setProperty("--bim-text-primary",e.textPrimary??"#ffffff"),t.setProperty("--bim-component-bg-hover",e.componentBgHover??"rgba(248, 250, 252, 0.06)")}setLocales(){this.hideLabelEl.textContent=Se("sectionPlane.actions.hide"),this.reverseLabelEl.textContent=Se("sectionPlane.actions.reverse"),this.resetLabelEl.textContent=Se("sectionPlane.actions.reset"),this.hideBtn.title=Se("sectionPlane.actions.hide"),this.reverseBtn.title=Se("sectionPlane.actions.reverse"),this.resetBtn.title=Se("sectionPlane.actions.reset")}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.element.remove()}createDom(){const e=document.createElement("div");return e.className="section-plane-panel",this.hideBtn=this.createButton("hide",Tt("隐藏"),()=>{this.isHidden=!this.isHidden,this.updateButtonStates(),this.options.onHideToggle?.(this.isHidden)}),this.reverseBtn=this.createButton("reverse",Tt("反向"),()=>{this.options.onReverse&&this.options.onReverse()}),this.resetBtn=this.createButton("reset",Tt("重置"),()=>{this.options.onReset&&this.options.onReset()}),e.appendChild(this.hideBtn),e.appendChild(this.reverseBtn),e.appendChild(this.resetBtn),e}createButton(e,t,i){const n=document.createElement("button");n.type="button",n.className="section-plane-btn";const r=document.createElement("div");r.className="section-plane-btn-icon",r.innerHTML=t,n.appendChild(r);const a=document.createElement("div");return a.className="section-plane-btn-label",n.appendChild(a),e==="hide"?this.hideLabelEl=a:e==="reverse"?this.reverseLabelEl=a:this.resetLabelEl=a,n.addEventListener("click",i),n}}class F2 extends No{panel=null;constructor(e){super(e)}get dialogId(){return"section-plane-dialog"}get dialogTitle(){return"sectionPlane.dialogTitle"}get dialogWidth(){return 240}get dialogHeight(){return 120}init(){}getDialogPosition(){const e=this.registry.container;if(!e)return{x:100,y:100};const t=20,i=50,n=e.clientWidth,r=e.clientHeight;return{x:n-this.dialogWidth-t,y:r-this.dialogHeight-i}}createContent(){return this.panel=new t9({defaultHidden:!1,onHideToggle:e=>{console.log("[SectionPlaneDialogManager] 隐藏切换:",e),e?this.engineComponent?.hideSection():this.engineComponent?.recoverSection()},onReverse:()=>{this.engineComponent?.reverseSection()},onReset:()=>{this.engineComponent?.deactivateSection(),this.engineComponent?.activeSection("face")}}),this.panel.init(),this.panel.element}onDialogCreated(){this.engineComponent?.activeSection("face"),this.dialog?.fitHeight(!1)}onDialogClose(){this.registry.toolbar?.setBtnActive("section-plane",!1)}onBeforeDestroy(){this.engineComponent?.deactivateSection(),this.panel&&(this.panel.destroy(),this.panel=null)}}class i9{element;options;isHidden=!1;activeAxis="x";hideBtn;reverseBtn;hideLabelEl;reverseLabelEl;axisXBtn;axisYBtn;axisZBtn;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e={}){this.options=e,this.isHidden=e.defaultHidden??!1,this.activeAxis=e.defaultAxis??"x",this.element=this.createDom()}init(){this.unsubscribeLocale=Zt.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=ct.subscribe(e=>{this.setTheme(e)}),this.setLocales(),this.setTheme(ct.getTheme()),this.updateHideButtonState(),this.updateAxisButtonsState()}setTheme(e){const t=this.element.style;t.setProperty("--bim-bg-inset",e.bgInset??"#152232"),t.setProperty("--bim-border-default",e.borderDefault??"#334155"),t.setProperty("--bim-border-strong",e.borderStrong??"#475569"),t.setProperty("--bim-divider",e.divider??"#334155"),t.setProperty("--bim-primary",e.primary??"#3b82f6"),t.setProperty("--bim-primary-subtle",e.primarySubtle??"rgba(59, 130, 246, 0.15)"),t.setProperty("--bim-icon-default",e.iconDefault??"#ffffff"),t.setProperty("--bim-text-primary",e.textPrimary??"#ffffff"),t.setProperty("--bim-component-bg-hover",e.componentBgHover??"rgba(248, 250, 252, 0.06)")}setLocales(){this.hideLabelEl.textContent=Se("sectionAxis.actions.hide"),this.reverseLabelEl.textContent=Se("sectionAxis.actions.reverse"),this.hideBtn.title=Se("sectionAxis.actions.hide"),this.reverseBtn.title=Se("sectionAxis.actions.reverse"),this.axisXBtn.title=Se("sectionAxis.actions.axisX"),this.axisYBtn.title=Se("sectionAxis.actions.axisY"),this.axisZBtn.title=Se("sectionAxis.actions.axisZ")}setHiddenState(e){this.isHidden=e,this.updateHideButtonState()}getHiddenState(){return this.isHidden}setActiveAxis(e){this.activeAxis=e,this.updateAxisButtonsState()}getActiveAxis(){return this.activeAxis}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.element.remove()}createDom(){const e=document.createElement("div");e.className="section-axis-panel";const t=document.createElement("div");t.className="section-axis-row-1",this.hideBtn=this.createButton("hide",Tt("隐藏"),()=>this.handleHideToggle()),this.reverseBtn=this.createButton("reverse",Tt("反向"),()=>this.handleReverse()),t.appendChild(this.hideBtn),t.appendChild(this.reverseBtn);const i=document.createElement("div");return i.className="section-axis-row-2",this.axisXBtn=this.createAxisButton("axisX","X",()=>this.handleAxisChange("x")),this.axisYBtn=this.createAxisButton("axisY","Y",()=>this.handleAxisChange("y")),this.axisZBtn=this.createAxisButton("axisZ","Z",()=>this.handleAxisChange("z")),i.appendChild(this.axisXBtn),i.appendChild(this.axisYBtn),i.appendChild(this.axisZBtn),e.appendChild(t),e.appendChild(i),e}createButton(e,t,i){const n=document.createElement("button");n.type="button",n.className="section-axis-btn";const r=document.createElement("div");r.className="section-axis-btn-icon",r.innerHTML=t,n.appendChild(r);const a=document.createElement("div");return a.className="section-axis-btn-label",n.appendChild(a),e==="hide"?this.hideLabelEl=a:e==="reverse"&&(this.reverseLabelEl=a),n.addEventListener("click",i),n}createAxisButton(e,t,i){const n=document.createElement("button");n.type="button",n.className="section-axis-btn section-axis-btn-text";const r=document.createElement("div");return r.className="section-axis-btn-label",r.textContent=t,n.appendChild(r),n.addEventListener("click",i),n}handleHideToggle(){this.isHidden=!this.isHidden,this.updateHideButtonState(),this.options.onHideToggle&&this.options.onHideToggle(this.isHidden)}handleReverse(){this.options.onReverse&&this.options.onReverse()}handleAxisChange(e){this.activeAxis!==e&&(this.activeAxis=e,this.updateAxisButtonsState(),this.options.onAxisChange&&this.options.onAxisChange(e))}updateHideButtonState(){this.isHidden?this.hideBtn.classList.add("active"):this.hideBtn.classList.remove("active")}updateAxisButtonsState(){this.axisXBtn.classList.toggle("active",this.activeAxis==="x"),this.axisYBtn.classList.toggle("active",this.activeAxis==="y"),this.axisZBtn.classList.toggle("active",this.activeAxis==="z")}}class z2 extends No{panel=null;constructor(e){super(e)}get dialogId(){return"section-axis-dialog"}get dialogTitle(){return"sectionAxis.dialogTitle"}get dialogWidth(){return 240}getDialogPosition(){const e=this.registry.container;if(!e)return{x:100,y:100};const t=e.clientWidth,i=e.clientHeight;return{x:t-this.dialogWidth-20,y:i-50-200}}createContent(){return this.panel=new i9({defaultAxis:"x",defaultHidden:!1,onHideToggle:e=>{console.log("[SectionAxisDialogManager] 隐藏切换:",e),e?this.engineComponent?.hideSection():this.engineComponent?.recoverSection()},onReverse:()=>{this.engineComponent?.reverseSection()},onAxisChange:e=>{console.log("[SectionAxisDialogManager] 切换轴向:",e),this.engineComponent?.activeSection(e)}}),this.panel.init(),this.panel.element}onDialogCreated(){if(this.dialog?.fitHeight(!1),!this.engineComponent){console.error("[SectionAxisDialogManager] Engine not initialized. Call initEngine() first.");return}this.engineComponent.activeSection("x")}onDialogClose(){this.registry.toolbar?.setBtnActive("section-axis",!1)}onBeforeDestroy(){this.engineComponent?.deactivateSection(),this.panel&&(this.panel.destroy(),this.panel=null)}getHiddenState(){return this.panel?.getHiddenState()??!1}setHiddenState(e){this.panel?.setHiddenState(e)}getActiveAxis(){return this.panel?.getActiveAxis()??"x"}setActiveAxis(e){this.panel?.setActiveAxis(e)}}const H2={x:{min:0,max:100},y:{min:0,max:100},z:{min:0,max:100}};class n9{element;options;isHidden=!1;isReversed=!1;range;hideBtn;fitBtn;resetBtn;hideLabelEl;fitLabelEl;resetLabelEl;xLabelEl;yLabelEl;zLabelEl;unsubscribeLocale=null;unsubscribeTheme=null;xSlider;ySlider;zSlider;xMinHandle;xMaxHandle;yMinHandle;yMaxHandle;zMinHandle;zMaxHandle;dragState={isDragging:!1,axis:null,handleType:null,pointerId:null};constructor(e={}){this.options=e,this.isHidden=e.defaultHidden??!1,this.isReversed=e.defaultReversed??!1,this.range=JSON.parse(JSON.stringify(e.defaultRange??H2))}init(){this.element=this.createPanel(),this.unsubscribeLocale=Zt.subscribe(()=>this.setLocales()),this.unsubscribeTheme=ct.subscribe(e=>this.setTheme(e)),this.setLocales(),this.setTheme(ct.getTheme()),this.updateButtonStates(),this.updateAllSlidersUI(),this.setupDragListeners()}setHiddenState(e){this.isHidden=e,this.updateButtonStates()}getHiddenState(){return this.isHidden}setReversedState(e){this.isReversed=e,this.updateButtonStates()}getReversedState(){return this.isReversed}setRange(e){e.x&&(this.range.x={...this.range.x,...e.x}),e.y&&(this.range.y={...this.range.y,...e.y}),e.z&&(this.range.z={...this.range.z,...e.z}),this.updateAllSlidersUI()}getRange(){return JSON.parse(JSON.stringify(this.range))}reset(){this.isHidden=this.options.defaultHidden??!1,this.isReversed=this.options.defaultReversed??!1,this.range=JSON.parse(JSON.stringify(this.options.defaultRange??H2)),this.updateButtonStates(),this.updateAllSlidersUI(),this.options.onReset?.(),this.options.onRangeChange?.(this.range)}createPanel(){const e=document.createElement("div");e.className="section-box-panel";const t=document.createElement("div");t.className="section-box-row-buttons",this.hideBtn=this.createButton("hide",Se("sectionBox.actions.hide"),()=>{this.isHidden=!this.isHidden,this.updateButtonStates(),this.options.onHideToggle?.(this.isHidden)},"hide"),this.fitBtn=this.createButton("fit",Se("sectionBox.actions.fitToModel"),()=>{this.options.onFitToModel?.()},"fit"),this.resetBtn=this.createButton("reset",Se("sectionBox.actions.reset"),()=>this.reset(),"reset"),[this.hideBtn,this.fitBtn,this.resetBtn].forEach(n=>t.appendChild(n));const i=document.createElement("div");return i.className="section-box-sliders",i.addEventListener("pointerdown",n=>n.stopPropagation()),this.xSlider=this.createSlider("x",Se("sectionBox.axes.x")),this.ySlider=this.createSlider("y",Se("sectionBox.axes.y")),this.zSlider=this.createSlider("z",Se("sectionBox.axes.z")),[this.xSlider,this.ySlider,this.zSlider].forEach(n=>i.appendChild(n)),e.appendChild(t),e.appendChild(i),e}createButton(e,t,i,n){const r=document.createElement("button");r.className="section-box-btn",r.title=t;const a={hide:"隐藏",reverse:"反向",fit:"适应到模型",reset:"重置"},o=document.createElement("div");o.className="section-box-btn-icon",o.innerHTML=Tt(a[e]||e);const l=document.createElement("div");return l.className="section-box-btn-label",l.textContent=t,n==="hide"?this.hideLabelEl=l:n==="fit"?this.fitLabelEl=l:n==="reset"&&(this.resetLabelEl=l),r.appendChild(o),r.appendChild(l),r.addEventListener("click",i),r}createSlider(e,t){const i=document.createElement("div");i.className="section-box-slider";const n=document.createElement("div");n.className="section-box-slider-label",n.textContent=t,e==="x"?this.xLabelEl=n:e==="y"?this.yLabelEl=n:this.zLabelEl=n;const r=document.createElement("div");r.className="section-box-slider-track";const a=document.createElement("div");a.className="section-box-slider-range";const o=document.createElement("div");o.className="section-box-slider-handle",o.setAttribute("data-axis",e),o.setAttribute("data-handle","min");const l=document.createElement("div");return l.className="section-box-slider-handle",l.setAttribute("data-axis",e),l.setAttribute("data-handle","max"),r.append(a,o,l),i.append(n,r),e==="x"?(this.xMinHandle=o,this.xMaxHandle=l):e==="y"?(this.yMinHandle=o,this.yMaxHandle=l):(this.zMinHandle=o,this.zMaxHandle=l),i}setupDragListeners(){[this.xMinHandle,this.xMaxHandle,this.yMinHandle,this.yMaxHandle,this.zMinHandle,this.zMaxHandle].forEach(t=>{t.addEventListener("pointerdown",n=>{n.preventDefault(),n.stopPropagation(),t.setPointerCapture(n.pointerId),this.dragState={isDragging:!0,axis:t.getAttribute("data-axis"),handleType:t.getAttribute("data-handle"),pointerId:n.pointerId},t.classList.add("dragging"),t.closest(".section-box-slider").style.zIndex="100"}),t.addEventListener("pointermove",n=>{this.dragState.isDragging&&this.dragState.pointerId===n.pointerId&&this.onDragging(n)});const i=n=>{this.dragState.isDragging&&this.dragState.pointerId===n.pointerId&&(t.hasPointerCapture(n.pointerId)&&t.releasePointerCapture(n.pointerId),t.closest(".section-box-slider").style.zIndex="",t.classList.remove("dragging"),this.dragState={isDragging:!1,axis:null,handleType:null,pointerId:null})};t.addEventListener("pointerup",i),t.addEventListener("pointercancel",i),t.addEventListener("lostpointercapture",i)})}onDragging(e){const{axis:t,handleType:i}=this.dragState;if(!t||!i)return;const a=(t==="x"?this.xSlider:t==="y"?this.ySlider:this.zSlider).querySelector(".section-box-slider-track").getBoundingClientRect();let o=(e.clientX-a.left)/a.width*100;o=Math.max(0,Math.min(100,o));const l=this.range[t];i==="min"?l.min=Math.min(o,l.max):l.max=Math.max(o,l.min),this.updateSliderUI(t),this.options.onRangeChange?.(this.range)}updateSliderUI(e){const t=this.range[e],i=e==="x"?this.xMinHandle:e==="y"?this.yMinHandle:this.zMinHandle,n=e==="x"?this.xMaxHandle:e==="y"?this.yMaxHandle:this.zMaxHandle,a=(e==="x"?this.xSlider:e==="y"?this.ySlider:this.zSlider).querySelector(".section-box-slider-range");i.style.left=`${t.min}%`,n.style.left=`${t.max}%`,a.style.left=`${t.min}%`,a.style.width=`${t.max-t.min}%`,i.setAttribute("data-value",Math.round(t.min).toString()),n.setAttribute("data-value",Math.round(t.max).toString())}updateAllSlidersUI(){["x","y","z"].forEach(e=>this.updateSliderUI(e))}updateButtonStates(){this.hideBtn&&this.hideBtn.classList.toggle("active",this.isHidden)}setLocales(){this.hideLabelEl&&(this.hideLabelEl.textContent=Se("sectionBox.actions.hide"),this.fitLabelEl.textContent=Se("sectionBox.actions.fitToModel"),this.resetLabelEl.textContent=Se("sectionBox.actions.reset"),this.xLabelEl.textContent=Se("sectionBox.axes.x"),this.yLabelEl.textContent=Se("sectionBox.axes.y"),this.zLabelEl.textContent=Se("sectionBox.axes.z"),this.hideBtn.title=Se("sectionBox.actions.hide"),this.fitBtn.title=Se("sectionBox.actions.fitToModel"),this.resetBtn.title=Se("sectionBox.actions.reset"))}setTheme(e){if(!this.element)return;const t=this.element.style;t.setProperty("--bim-bg-inset",e.bgInset??"#152232"),t.setProperty("--bim-bg-elevated",e.bgElevated??"#1f2d3e"),t.setProperty("--bim-border-default",e.borderDefault??"#334155"),t.setProperty("--bim-border-strong",e.borderStrong??"#475569"),t.setProperty("--bim-divider",e.divider??"#334155"),t.setProperty("--bim-primary",e.primary??"#3b82f6"),t.setProperty("--bim-primary-subtle",e.primarySubtle??"rgba(59, 130, 246, 0.15)"),t.setProperty("--bim-icon-default",e.iconDefault??"#ffffff"),t.setProperty("--bim-text-primary",e.textPrimary??"#ffffff"),t.setProperty("--bim-component-bg-hover",e.componentBgHover??"rgba(248, 250, 252, 0.06)")}destroy(){this.unsubscribeLocale?.(),this.unsubscribeTheme?.(),this.element&&this.element.parentElement&&this.element.parentElement.removeChild(this.element)}}class V2 extends No{panel=null;unsubscribeSectionMove=null;constructor(e){super(e)}get dialogId(){return"section-box-dialog"}get dialogTitle(){return"sectionBox.dialogTitle"}get dialogWidth(){return 280}getDialogPosition(){const e=this.registry.container;if(!e)return{x:100,y:100};const t=e.clientWidth,i=e.clientHeight;return{x:t-this.dialogWidth-20,y:i-50-300}}createContent(){return this.panel=new n9({defaultHidden:!1,defaultReversed:!1,onHideToggle:e=>{console.log("[SectionBoxDialogManager] 隐藏切换:",e),e?this.engineComponent?.hideSection():this.engineComponent?.recoverSection()},onFitToModel:()=>{this.engineComponent?.scaleSectionBox()},onReset:()=>{this.engineComponent?.deactivateSection(),this.engineComponent?.activeSection("box"),this.engineComponent?.recoverSection()},onRangeChange:e=>{this.engineComponent?.setSectionBoxRange(e)}}),this.panel.init(),this.panel.element}onDialogCreated(){this.engineComponent?.activeSection("box"),this.dialog?.fitHeight(!1);const e=this.engineComponent;if(e){const t=i=>{i&&this.panel&&this.panel.setRange(i)};e.onRawEvent("section-move",t),this.unsubscribeSectionMove=()=>e.offRawEvent("section-move",t)}}onDialogClose(){this.unsubscribeSectionMove&&(this.unsubscribeSectionMove(),this.unsubscribeSectionMove=null),this.registry.toolbar?.setBtnActive("section-box",!1)}onBeforeDestroy(){this.unsubscribeSectionMove&&(this.unsubscribeSectionMove(),this.unsubscribeSectionMove=null),this.engineComponent?.deactivateSection(),this.panel&&(this.panel.destroy(),this.panel=null)}getHiddenState(){return this.panel?.getHiddenState()??!1}setHiddenState(e){this.panel?.setHiddenState(e)}getReversedState(){return this.panel?.getReversedState()??!1}setReversedState(e){this.panel?.setReversedState(e)}getRange(){return this.panel?.getRange()??null}setRange(e){this.panel?.setRange(e)}}class G2 extends jn{panel=null;pathManager=null;constructor(e){super(e)}init(){this.pathManager=new O2(this.registry),this.pathManager.init()}show(){this.registry.toolbar?.hide(),console.log("[WalkControl] 打开漫游面板,激活第一人称模式"),this.engineComponent?.activateFirstPersonMode(),this.panel=new k2({onPlanViewToggle:t=>{console.log("[WalkControl] 小地图:",t),this.engineComponent?.toggleMiniMap(),this.registry.toolbar?.setBtnActive("map",t),this.emit("walk:plan-view-toggle",{isActive:t})},onPathModeToggle:t=>{console.log("[WalkControl] 路径漫游:",t),t?this.pathManager?.show():this.pathManager?.hide(),this.emit("walk:path-mode-toggle",{isActive:t})},onWalkModeToggle:t=>{console.log("[WalkControl] 第三人称漫游按钮点击:",t),t&&(this.pathManager?.hide(),alert("第三人称功能开发中")),this.emit("walk:walk-mode-toggle",{isActive:t})},onSpeedChange:t=>{console.log("[WalkControl] 速度变化:",t);const i=t*.1;this.engineComponent?.setWalkSpeed(i),this.emit("walk:speed-change",{speed:t})},onGravityToggle:t=>{console.log("[WalkControl] 重力:",t),this.engineComponent?.setWalkGravity(t),this.emit("walk:gravity-toggle",{enabled:t})},onCollisionToggle:t=>{console.log("[WalkControl] 碰撞:",t),this.engineComponent?.setWalkCollision(t),this.emit("walk:collision-toggle",{enabled:t})},onCharacterModelChange:t=>{console.log("[WalkControl] 角色模型:",t)},onWalkModeChange:t=>{console.log("[WalkControl] 行走模式:",t)},onExit:()=>{this.hide()}}),this.panel.init();const e=this.engineComponent?.getMiniMapState()??!1;this.panel.setPlanViewActive(e),this.registry.container?(this.panel.element.style.position="absolute",this.panel.element.style.bottom="20px",this.panel.element.style.left="50%",this.panel.element.style.transform="translateX(-50%)",this.panel.element.style.zIndex="1000",this.registry.container.appendChild(this.panel.element)):console.warn("[WalkControlManager] Container not found")}hide(){this.pathManager?.hide(),this.engineComponent?.getMiniMapState()&&this.engineComponent.toggleMiniMap(),console.log("[WalkControl] 关闭漫游面板,退出第一人称模式"),this.engineComponent?.deactivateFirstPersonMode(),this.panel&&(this.panel.destroy(),this.panel=null),this.registry.toolbar?.setBtnActive("map",!1),this.registry.toolbar&&this.registry.toolbar.show()}destroy(){this.hide(),this.pathManager?.destroy(),this.pathManager=null,super.destroy()}}class W2 extends No{get dialogId(){return"engine-info-dialog"}get dialogTitle(){return"info.dialogTitle"}get dialogWidth(){return 280}constructor(e){super(e)}init(){}getDialogPosition(){const e=this.registry.container;if(!e)return{x:100,y:100};const t=e.clientWidth,i=e.clientHeight;return{x:(t-this.dialogWidth)/2,y:(i-150)/2}}createContent(){const e=this.engineComponent?.getEngineInfo()??null,t=document.createElement("div");t.className="engine-info-content",t.style.cssText="padding: 16px;";const i=(n,r)=>{const a=document.createElement("div");a.style.cssText="display: flex; justify-content: space-between; margin-bottom: 12px; font-size: 14px;";const o=document.createElement("span");o.style.cssText="color: var(--bim-text-secondary, #94a3b8);",o.textContent=n;const l=document.createElement("span");return l.style.cssText="color: var(--bim-text-primary, #fff); font-weight: 500;",l.textContent=String(r),a.appendChild(o),a.appendChild(l),a};return t.appendChild(i(Se("info.meshCount"),e?.meshCount??"-")),t.appendChild(i(Se("info.totalTriangles"),e?.totalTriangles??"-")),t.appendChild(i(Se("info.totalVertices"),e?.totalVertices??"-")),t}}const oy="font-size: 15px; font-weight: 600; color: var(--bim-text-primary, #0f172a); margin-bottom: 4px;",s9="height: 1px; background: var(--bim-divider, #e2e8f0); margin: 8px 0;",ly="display: flex; align-items: center; justify-content: space-between; gap: 12px;",cy="display: flex; flex-direction: column; gap: 6px;",r9="font-size: 12px; color: var(--bim-text-secondary, #475569); min-width: 32px; text-align: right;",Xn="var(--bim-border-default, #e2e8f0)",hy="var(--bim-bg-inset, #f1f5f9)",ko="var(--bim-primary, #3b82f6)",Oo="var(--bim-text-primary, #0f172a)",uc="var(--bim-text-inverse, #ffffff)",a9="var(--bim-component-bg-hover, rgba(0,0,0,0.04))",X2={render:{mode:"advanced",contrast:50,saturation:50,shadowIntensity:50,lightIntensity:50,gtaoIntensity:50},display:{showEdge:!1,edgeOpacity:30,showGrid:!1,showLevel:!1,showGround:!1,groundId:"0",groundHeight:0},environment:{type:"none",hdrId:"0",hdrIntensity:20,skyPreset:"sunrise_clear",skyParams:{},skyIntensity:20}},o9={ground:[],hdr:[],sky:[]};class Rr extends No{get dialogId(){return"setting-dialog"}get dialogTitle(){return"setting.dialogTitle"}get dialogWidth(){return 420}settings=structuredClone(X2);presetList=[];selectedPresetId=null;presetLists=structuredClone(o9);savedPosition=null;savedScrollTop=null;isDirty=!1;saveAsModalEl=null;deleteConfirmModalEl=null;unsubscribeLocale=null;static INTERNAL_DEFAULT_PRESET_ID="__internal-default-preset__";constructor(e){super(e)}init(){this.ensurePresetListWithInternalDefault(),this.applySelectedPresetFromList(),this.unsubscribeLocale=Zt.subscribe(()=>{this.updateInternalDefaultPresetLabel(),this.isOpen()&&this.reopenAtSamePosition()})}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.closeSaveAsPresetModal(),this.closeDeletePresetConfirmModal(),super.destroy()}ensurePresetListWithInternalDefault(){const e=this.createInternalDefaultPreset(),t=this.presetList.filter(i=>i.id!==Rr.INTERNAL_DEFAULT_PRESET_ID);this.presetList=[...t,e],(!this.selectedPresetId||!this.presetList.some(i=>i.id===this.selectedPresetId))&&(this.selectedPresetId=e.id)}updateInternalDefaultPresetLabel(){const e=this.presetList.findIndex(t=>t.id===Rr.INTERNAL_DEFAULT_PRESET_ID);e<0||(this.presetList[e]={...this.presetList[e],presetName:Se("setting.defaultPresetLabel")},this.ensurePresetListWithInternalDefault())}createInternalDefaultPreset(){return{id:Rr.INTERNAL_DEFAULT_PRESET_ID,presetName:Se("setting.defaultPresetLabel"),isDefault:!0,settings:structuredClone(X2),source:"sdk-default",readonly:!1,allowModify:!1}}setPresetList(e){const t=this.selectedPresetId;this.presetList=this.normalizePresetList(e),this.ensurePresetListWithInternalDefault();const i=!!t&&this.presetList.some(n=>n.id===t);this.selectedPresetId=i?t:this.resolveDefaultPresetId(this.presetList),!this.selectedPresetId&&this.presetList.length>0&&(this.selectedPresetId=this.presetList[0].id),this.applySelectedPresetFromList(),this.isDirty=!1,this.updateUndoRestoreVisibility(),this.isOpen()&&this.reopenAtSamePosition()}getDialogPosition(){if(this.savedPosition){const n=this.savedPosition;return this.savedPosition=null,n}const e=this.registry.container;if(!e)return{x:100,y:100};const t=e.clientWidth,i=e.clientHeight;return{x:(t-this.dialogWidth)/2,y:Math.max(20,(i-560)/2)}}createContent(){this.syncFromEngine(),this.ensureSliderStyle();const e=document.createElement("div");e.style.cssText="height: 600px; display: flex; flex-direction: column;";const t=document.createElement("div");t.className="setting-scroll-body",t.style.cssText="padding: 14px 16px 12px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; flex: 1; min-height: 0;",t.appendChild(this.createRenderModeSection()),t.appendChild(this.createSliderSection(Se("setting.lightIntensity"),this.settings.render.lightIntensity,0,100,n=>this.updateSettings({render:{lightIntensity:n}}))),this.settings.render.mode==="advanced"&&(t.appendChild(this.createSliderSection(Se("setting.contrast"),this.settings.render.contrast,0,100,n=>this.updateSettings({render:{contrast:n}}))),t.appendChild(this.createSliderSection(Se("setting.saturation"),this.settings.render.saturation,0,100,n=>this.updateSettings({render:{saturation:n}})))),t.appendChild(this.createDivider()),t.appendChild(this.createDisplaySection()),t.appendChild(this.createDivider()),t.appendChild(this.createEnvironmentSection());const i=document.createElement("div");return i.style.cssText=`
9609
+ `,this.settingsBtn.addEventListener("click",()=>{this.openSettings()}),u.appendChild(this.clearBtn),u.appendChild(this.settingsBtn),this.mainViewEl.appendChild(u),this.settingsViewEl=this.createSettingsDom(),e.appendChild(this.mainViewEl),e.appendChild(this.settingsViewEl),e}createSettingsDom(){const e=document.createElement("div");e.className="bim-measure-settings";const t=document.createElement("div");t.className="bim-measure-settings-title",t.dataset.i18nKey="measure.settings.title",e.appendChild(t);const i=document.createElement("div");i.className="bim-measure-settings-row";const n=document.createElement("div");n.className="label",n.dataset.i18nKey="measure.settings.unit",this.unitSelectEl=document.createElement("select"),this.unitSelectEl.className="bim-measure-settings-select",this.unitSelectEl.appendChild(this.makeOption("m")),this.unitSelectEl.appendChild(this.makeOption("cm")),this.unitSelectEl.appendChild(this.makeOption("mm")),this.unitSelectEl.appendChild(this.makeOption("km")),i.appendChild(n),i.appendChild(this.unitSelectEl),e.appendChild(i);const r=document.createElement("div");r.className="bim-measure-settings-hint",r.dataset.i18nKey="measure.settings.hint",e.appendChild(r);const a=document.createElement("div");a.className="bim-measure-settings-row";const o=document.createElement("div");o.className="label",o.dataset.i18nKey="measure.settings.precision",this.precisionSelectEl=document.createElement("select"),this.precisionSelectEl.className="bim-measure-settings-select",this.precisionSelectEl.appendChild(this.makePrecisionOption(0)),this.precisionSelectEl.appendChild(this.makePrecisionOption(1)),this.precisionSelectEl.appendChild(this.makePrecisionOption(2)),this.precisionSelectEl.appendChild(this.makePrecisionOption(3)),a.appendChild(o),a.appendChild(this.precisionSelectEl),e.appendChild(a);const l=document.createElement("div");return l.className="bim-measure-settings-actions",this.saveSettingsBtn=document.createElement("button"),this.saveSettingsBtn.type="button",this.saveSettingsBtn.className="bim-measure-settings-save",this.saveSettingsBtn.addEventListener("click",()=>{this.saveSettings()}),this.cancelSettingsBtn=document.createElement("button"),this.cancelSettingsBtn.type="button",this.cancelSettingsBtn.className="bim-measure-settings-cancel",this.cancelSettingsBtn.addEventListener("click",()=>{this.cancelSettings()}),l.appendChild(this.saveSettingsBtn),l.appendChild(this.cancelSettingsBtn),e.appendChild(l),this.syncSettingsFormFromConfig(this.config),e}createModeOptionsDom(){const e=document.createElement("div");e.className="bim-measure-mode-options";const t=document.createElement("div");t.className="bim-measure-radio-group";const i=document.createElement("span");i.className="bim-measure-radio-label",i.dataset.i18nKey="measure.clearHeight.direction";const n=document.createElement("div");n.className="bim-measure-radio-items";const r=this.createRadioItem("measure.clearHeight.directionDown",()=>{this.setClearHeightDirection(0)}),a=this.createRadioItem("measure.clearHeight.directionUp",()=>{this.setClearHeightDirection(1)});this.directionBtns.set(0,r),this.directionBtns.set(1,a),n.appendChild(r),n.appendChild(a),t.appendChild(i),t.appendChild(n),e.appendChild(t);const o=document.createElement("div");o.className="bim-measure-radio-group";const l=document.createElement("span");l.className="bim-measure-radio-label",l.dataset.i18nKey="measure.clearHeight.selectType";const c=document.createElement("div");c.className="bim-measure-radio-items";const h=this.createRadioItem("measure.clearHeight.selectPoint",()=>{this.setClearHeightSelectType("point")}),d=this.createRadioItem("measure.clearHeight.selectElement",()=>{this.setClearHeightSelectType("element")});return this.selectTypeBtns.set("point",h),this.selectTypeBtns.set("element",d),c.appendChild(h),c.appendChild(d),o.appendChild(l),o.appendChild(c),e.appendChild(o),e}createRadioItem(e,t){const i=document.createElement("button");return i.type="button",i.className="bim-measure-radio-item",i.dataset.i18nKey=e,i.textContent=Se(e),i.addEventListener("click",t),i}setClearHeightDirection(e){this.clearHeightDirection!==e&&(this.clearHeightDirection=e,this.applyClearHeightOptionsState(),this.options.onClearHeightDirectionChange?.(e))}setClearHeightSelectType(e){this.clearHeightSelectType!==e&&(this.clearHeightSelectType=e,this.applyClearHeightOptionsState(),this.options.onClearHeightSelectTypeChange?.(e))}applyClearHeightOptionsState(){this.activeMode==="clearHeight"?this.modeOptionsEl.classList.add("is-visible"):this.modeOptionsEl.classList.remove("is-visible");for(const[e,t]of this.directionBtns.entries())e===this.clearHeightDirection?t.classList.add("is-active"):t.classList.remove("is-active");for(const[e,t]of this.selectTypeBtns.entries())e===this.clearHeightSelectType?t.classList.add("is-active"):t.classList.remove("is-active")}makeOption(e){const t=document.createElement("option");return t.value=e,t.textContent=e,t}makePrecisionOption(e){const t=document.createElement("option");return t.value=String(e),t.textContent=e===0?"0":`0.${"0".repeat(e)}`,t}enterSettingsView(){this.draftConfig={...this.config},this.view="settings",this.syncSettingsFormFromConfig(this.config),this.applyViewState()}saveSettings(){const e=this.unitSelectEl.value||this.config.unit,t=Number(this.precisionSelectEl.value),i={unit:e,precision:this.isValidPrecision(t)?t:this.config.precision};this.config=i,this.saveConfigToCache(i),this.draftConfig=null,this.view="main",this.applyViewState(),this.renderResult(),this.options.onConfigSave?.(i),this.options.onExpandedChange?.(this.isExpanded)}cancelSettings(){this.draftConfig&&(this.config={...this.draftConfig}),this.draftConfig=null,this.view="main",this.applyViewState(),this.renderResult(),this.options.onExpandedChange&&this.options.onExpandedChange(this.isExpanded)}syncSettingsFormFromConfig(e){this.unitSelectEl.value=e.unit,this.precisionSelectEl.value=String(e.precision)}applyViewState(){this.view==="settings"?(this.mainViewEl.style.display="none",this.settingsViewEl.style.display="block"):(this.mainViewEl.style.display="block",this.settingsViewEl.style.display="none")}loadConfigFromCache(){try{const e=localStorage.getItem(ed.CONFIG_CACHE_KEY);if(!e)return null;const t=JSON.parse(e);if(!t||typeof t!="object")return null;const i=t.unit,n=t.precision;return!this.isValidUnit(i)||!this.isValidPrecision(n)?null:{unit:i,precision:n}}catch{return null}}saveConfigToCache(e){try{localStorage.setItem(ed.CONFIG_CACHE_KEY,JSON.stringify(e))}catch{}}isValidUnit(e){return e==="m"||e==="cm"||e==="mm"||e==="km"}isValidPrecision(e){return e===0||e===1||e===2||e===3}applyExpandedState(){let e=0;for(const t of this.toolButtons.values())e>=4?t.style.display=this.isExpanded?"":"none":t.style.display="",e++;this.isExpanded?this.toggleBtn.classList.add("is-expanded"):this.toggleBtn.classList.remove("is-expanded")}applyActiveModeState(){for(const[e,t]of this.toolButtons.entries())e===this.activeMode?t.classList.add("is-active"):t.classList.remove("is-active")}renderResult(){if(this.activeMode==="point"){this.mainValueRowEl.style.display="none",this.xyzBoxEl.style.display="";const i=this.result?.xyz;if(!i){this.xyzXEl.textContent="--",this.xyzYEl.textContent="--",this.xyzZEl.textContent="--";return}this.xyzXEl.textContent=this.convertValue("length",i.x)+" "+this.getUnitText("length"),this.xyzYEl.textContent=this.convertValue("length",i.y)+" "+this.getUnitText("length"),this.xyzZEl.textContent=this.convertValue("length",i.z)+" "+this.getUnitText("length");return}this.mainValueRowEl.style.display="",this.mainValueLabelEl.textContent=Se(this.getModeValueLabelI18nKey(this.activeMode));const t=this.result?this.result[dc[this.activeMode].callBackType]:void 0;if(this.activeMode==="slope"||this.activeMode==="angle")this.mainNumberEl.textContent=t??"--",this.mainUnitEl.textContent="";else{const i=R2(this.activeMode);this.mainNumberEl.textContent=this.convertValue(i,t),this.mainUnitEl.textContent=this.getUnitText(i)}this.xyzBoxEl.style.display="none"}getModeI18nKey(e){return`measure.modes.${e}`}getModeValueLabelI18nKey(e){return`measure.labels.value.${e}`}convertValue(e,t){if(t==null||Number.isNaN(t))return"--";const i=this.config.unit,n=this.config.precision;let r;switch(e){case"length":switch(i){case"mm":r=t*1e3;break;case"cm":r=t*100;break;case"km":r=t/1e3;break;default:r=t}break;case"area":switch(i){case"mm":r=t*1e3*1e3;break;case"cm":r=t*100*100;break;case"km":r=t/1e3/1e3;break;default:r=t}break;default:r=t}return r.toFixed(n)}getUnitText(e){const t=this.config.unit;switch(e){case"length":case"point":return t;case"area":return`${t}²`;case"angle":case"percent":return"°";default:return""}}}class B2 extends No{panel=null;config=null;unsubscribeMeasureChanged=null;constructor(e){super(e)}get dialogId(){return"measure-dialog"}get dialogTitle(){return"measure.dialogTitle"}get dialogWidth(){return 250}createContent(){this.panel=new ed({defaultMode:"distance",defaultExpanded:!1,onModeChange:t=>{console.log("[MeasureDialogManager] 当前测量方式已切换:",t),this.engineComponent?.activateMeasure(t)},onClearAll:()=>{console.log("[MeasureDialogManager] 删除全部"),this.engineComponent?.clearAllMeasures()},onSettings:()=>{console.log("[MeasureDialogManager] 打开设置")},onExpandedChange:()=>{this.dialog?.fitHeight(!1)},onConfigSave:t=>{console.log("[MeasureDialogManager] 保存设置:",t),this.engineComponent?.saveMeasureSetting({unit:t.unit,precision:t.precision})},onClearHeightDirectionChange:t=>{console.log("[MeasureDialogManager] 净高朝向切换:",t),this.engineComponent?.setClearHeightDirection(t)},onClearHeightSelectTypeChange:t=>{console.log("[MeasureDialogManager] 净高选择对象切换:",t),this.engineComponent?.setClearHeightSelectType(t)}}),this.panel.init(),this.config=this.panel.getConfig(),this.config&&(console.log("[MeasureDialogManager] 同步缓存设置到引擎:",this.config),this.engineComponent?.saveMeasureSetting({unit:this.config.unit,precision:this.config.precision}));const e=document.createElement("div");return e.style.padding="12px",e.appendChild(this.panel.element),e}onDialogCreated(){this.dialog?.fitHeight(!1),this.engineComponent?.setClearHeightDirection(0),this.engineComponent?.setClearHeightSelectType("point");const e=this.engineComponent;if(e){const t=i=>{console.log("[MeasureDialogManager] 测量值回调:",i),i&&this.panel&&this.handleMeasureChanged(i)};e.onRawEvent("measure-changed",t),e.onRawEvent("measure-click",t),this.unsubscribeMeasureChanged=()=>{e.offRawEvent("measure-changed",t),e.offRawEvent("measure-click",t)}}}handleMeasureChanged(e){if(!this.panel)return;const t=L2(e.type);if(!t){console.warn("[MeasureDialogManager] 未知测量类型:",e.type);return}this.panel.getActiveMode()!==t&&this.panel.switchMode(t,!1);const n=this.convertToMeasureResult(e,t);this.panel.setResult(n)}convertToMeasureResult(e,t){const i=dc[t],n={};return R2(t)==="point"?e.textX!==void 0&&e.textY!==void 0&&e.textZ!==void 0&&(n.xyz={x:e.textX,y:e.textY,z:e.textZ}):n[i.callBackType]=e.text,n}onDialogClose(){this.unsubscribeMeasureChanged&&(this.unsubscribeMeasureChanged(),this.unsubscribeMeasureChanged=null),this.registry.toolbar?.setBtnActive("measure",!1)}onBeforeDestroy(){this.unsubscribeMeasureChanged&&(this.unsubscribeMeasureChanged(),this.unsubscribeMeasureChanged=null),this.engineComponent?.deactivateMeasure(),this.panel&&(this.panel.destroy(),this.panel=null)}getActiveMode(){return this.panel?this.panel.getActiveMode():null}switchMode(e){this.panel&&this.panel.switchMode(e)}setMeasureResult(e){this.panel&&this.panel.setResult(e)}getConfig(){return this.panel&&(this.config=this.panel.getConfig()),this.config?{...this.config}:null}setConfig(e,t=!0){if(this.panel){this.panel.setConfig(e,t),this.config=this.panel.getConfig(),this.dialog?.fitHeight(!1);return}const i=this.config,n={unit:e.unit??i?.unit??"mm",precision:e.precision??i?.precision??2};this.config=n}clearAll(){this.panel&&this.panel.clearAll()}openSettings(){this.panel&&this.panel.openSettings()}}class t9{element;options;isHidden=!1;hideBtn;reverseBtn;resetBtn;hideLabelEl;reverseLabelEl;resetLabelEl;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e={}){this.options=e,this.isHidden=e.defaultHidden??!1,this.element=this.createDom()}setHiddenState(e){this.isHidden=e,this.updateButtonStates()}getHiddenState(){return this.isHidden}updateButtonStates(){this.hideBtn?.classList.toggle("active",this.isHidden)}init(){this.unsubscribeLocale=Zt.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=ct.subscribe(e=>{this.setTheme(e)}),this.setLocales(),this.setTheme(ct.getTheme())}setTheme(e){const t=this.element.style;t.setProperty("--bim-bg-inset",e.bgInset??"#152232"),t.setProperty("--bim-border-default",e.borderDefault??"#334155"),t.setProperty("--bim-border-strong",e.borderStrong??"#475569"),t.setProperty("--bim-primary",e.primary??"#3b82f6"),t.setProperty("--bim-primary-subtle",e.primarySubtle??"rgba(59, 130, 246, 0.15)"),t.setProperty("--bim-icon-default",e.iconDefault??"#ffffff"),t.setProperty("--bim-text-primary",e.textPrimary??"#ffffff"),t.setProperty("--bim-component-bg-hover",e.componentBgHover??"rgba(248, 250, 252, 0.06)")}setLocales(){this.hideLabelEl.textContent=Se("sectionPlane.actions.hide"),this.reverseLabelEl.textContent=Se("sectionPlane.actions.reverse"),this.resetLabelEl.textContent=Se("sectionPlane.actions.reset"),this.hideBtn.title=Se("sectionPlane.actions.hide"),this.reverseBtn.title=Se("sectionPlane.actions.reverse"),this.resetBtn.title=Se("sectionPlane.actions.reset")}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.element.remove()}createDom(){const e=document.createElement("div");return e.className="section-plane-panel",this.hideBtn=this.createButton("hide",Tt("隐藏"),()=>{this.isHidden=!this.isHidden,this.updateButtonStates(),this.options.onHideToggle?.(this.isHidden)}),this.reverseBtn=this.createButton("reverse",Tt("反向"),()=>{this.options.onReverse&&this.options.onReverse()}),this.resetBtn=this.createButton("reset",Tt("重置"),()=>{this.options.onReset&&this.options.onReset()}),e.appendChild(this.hideBtn),e.appendChild(this.reverseBtn),e.appendChild(this.resetBtn),e}createButton(e,t,i){const n=document.createElement("button");n.type="button",n.className="section-plane-btn";const r=document.createElement("div");r.className="section-plane-btn-icon",r.innerHTML=t,n.appendChild(r);const a=document.createElement("div");return a.className="section-plane-btn-label",n.appendChild(a),e==="hide"?this.hideLabelEl=a:e==="reverse"?this.reverseLabelEl=a:this.resetLabelEl=a,n.addEventListener("click",i),n}}class F2 extends No{panel=null;constructor(e){super(e)}get dialogId(){return"section-plane-dialog"}get dialogTitle(){return"sectionPlane.dialogTitle"}get dialogWidth(){return 240}get dialogHeight(){return 120}init(){}getDialogPosition(){const e=this.registry.container;if(!e)return{x:100,y:100};const t=20,i=50,n=e.clientWidth,r=e.clientHeight;return{x:n-this.dialogWidth-t,y:r-this.dialogHeight-i}}createContent(){return this.panel=new t9({defaultHidden:!1,onHideToggle:e=>{console.log("[SectionPlaneDialogManager] 隐藏切换:",e),e?this.engineComponent?.hideSection():this.engineComponent?.recoverSection()},onReverse:()=>{this.engineComponent?.reverseSection()},onReset:()=>{this.engineComponent?.deactivateSection(),this.engineComponent?.activeSection("face")}}),this.panel.init(),this.panel.element}onDialogCreated(){this.engineComponent?.activeSection("face"),this.dialog?.fitHeight(!1)}onDialogClose(){this.registry.toolbar?.setBtnActive("section-plane",!1)}onBeforeDestroy(){this.engineComponent?.deactivateSection(),this.panel&&(this.panel.destroy(),this.panel=null)}}class i9{element;options;isHidden=!1;activeAxis="x";hideBtn;reverseBtn;hideLabelEl;reverseLabelEl;axisXBtn;axisYBtn;axisZBtn;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e={}){this.options=e,this.isHidden=e.defaultHidden??!1,this.activeAxis=e.defaultAxis??"x",this.element=this.createDom()}init(){this.unsubscribeLocale=Zt.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=ct.subscribe(e=>{this.setTheme(e)}),this.setLocales(),this.setTheme(ct.getTheme()),this.updateHideButtonState(),this.updateAxisButtonsState()}setTheme(e){const t=this.element.style;t.setProperty("--bim-bg-inset",e.bgInset??"#152232"),t.setProperty("--bim-border-default",e.borderDefault??"#334155"),t.setProperty("--bim-border-strong",e.borderStrong??"#475569"),t.setProperty("--bim-divider",e.divider??"#334155"),t.setProperty("--bim-primary",e.primary??"#3b82f6"),t.setProperty("--bim-primary-subtle",e.primarySubtle??"rgba(59, 130, 246, 0.15)"),t.setProperty("--bim-icon-default",e.iconDefault??"#ffffff"),t.setProperty("--bim-text-primary",e.textPrimary??"#ffffff"),t.setProperty("--bim-component-bg-hover",e.componentBgHover??"rgba(248, 250, 252, 0.06)")}setLocales(){this.hideLabelEl.textContent=Se("sectionAxis.actions.hide"),this.reverseLabelEl.textContent=Se("sectionAxis.actions.reverse"),this.hideBtn.title=Se("sectionAxis.actions.hide"),this.reverseBtn.title=Se("sectionAxis.actions.reverse"),this.axisXBtn.title=Se("sectionAxis.actions.axisX"),this.axisYBtn.title=Se("sectionAxis.actions.axisY"),this.axisZBtn.title=Se("sectionAxis.actions.axisZ")}setHiddenState(e){this.isHidden=e,this.updateHideButtonState()}getHiddenState(){return this.isHidden}setActiveAxis(e){this.activeAxis=e,this.updateAxisButtonsState()}getActiveAxis(){return this.activeAxis}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.element.remove()}createDom(){const e=document.createElement("div");e.className="section-axis-panel";const t=document.createElement("div");t.className="section-axis-row-1",this.hideBtn=this.createButton("hide",Tt("隐藏"),()=>this.handleHideToggle()),this.reverseBtn=this.createButton("reverse",Tt("反向"),()=>this.handleReverse()),t.appendChild(this.hideBtn),t.appendChild(this.reverseBtn);const i=document.createElement("div");return i.className="section-axis-row-2",this.axisXBtn=this.createAxisButton("axisX","X",()=>this.handleAxisChange("x")),this.axisYBtn=this.createAxisButton("axisY","Y",()=>this.handleAxisChange("y")),this.axisZBtn=this.createAxisButton("axisZ","Z",()=>this.handleAxisChange("z")),i.appendChild(this.axisXBtn),i.appendChild(this.axisYBtn),i.appendChild(this.axisZBtn),e.appendChild(t),e.appendChild(i),e}createButton(e,t,i){const n=document.createElement("button");n.type="button",n.className="section-axis-btn";const r=document.createElement("div");r.className="section-axis-btn-icon",r.innerHTML=t,n.appendChild(r);const a=document.createElement("div");return a.className="section-axis-btn-label",n.appendChild(a),e==="hide"?this.hideLabelEl=a:e==="reverse"&&(this.reverseLabelEl=a),n.addEventListener("click",i),n}createAxisButton(e,t,i){const n=document.createElement("button");n.type="button",n.className="section-axis-btn section-axis-btn-text";const r=document.createElement("div");return r.className="section-axis-btn-label",r.textContent=t,n.appendChild(r),n.addEventListener("click",i),n}handleHideToggle(){this.isHidden=!this.isHidden,this.updateHideButtonState(),this.options.onHideToggle&&this.options.onHideToggle(this.isHidden)}handleReverse(){this.options.onReverse&&this.options.onReverse()}handleAxisChange(e){this.activeAxis!==e&&(this.activeAxis=e,this.updateAxisButtonsState(),this.options.onAxisChange&&this.options.onAxisChange(e))}updateHideButtonState(){this.isHidden?this.hideBtn.classList.add("active"):this.hideBtn.classList.remove("active")}updateAxisButtonsState(){this.axisXBtn.classList.toggle("active",this.activeAxis==="x"),this.axisYBtn.classList.toggle("active",this.activeAxis==="y"),this.axisZBtn.classList.toggle("active",this.activeAxis==="z")}}class z2 extends No{panel=null;constructor(e){super(e)}get dialogId(){return"section-axis-dialog"}get dialogTitle(){return"sectionAxis.dialogTitle"}get dialogWidth(){return 240}getDialogPosition(){const e=this.registry.container;if(!e)return{x:100,y:100};const t=e.clientWidth,i=e.clientHeight;return{x:t-this.dialogWidth-20,y:i-50-200}}createContent(){return this.panel=new i9({defaultAxis:"x",defaultHidden:!1,onHideToggle:e=>{console.log("[SectionAxisDialogManager] 隐藏切换:",e),e?this.engineComponent?.hideSection():this.engineComponent?.recoverSection()},onReverse:()=>{this.engineComponent?.reverseSection()},onAxisChange:e=>{console.log("[SectionAxisDialogManager] 切换轴向:",e),this.engineComponent?.activeSection(e)}}),this.panel.init(),this.panel.element}onDialogCreated(){if(this.dialog?.fitHeight(!1),!this.engineComponent){console.error("[SectionAxisDialogManager] Engine not initialized. Call initEngine() first.");return}this.engineComponent.activeSection("x")}onDialogClose(){this.registry.toolbar?.setBtnActive("section-axis",!1)}onBeforeDestroy(){this.engineComponent?.deactivateSection(),this.panel&&(this.panel.destroy(),this.panel=null)}getHiddenState(){return this.panel?.getHiddenState()??!1}setHiddenState(e){this.panel?.setHiddenState(e)}getActiveAxis(){return this.panel?.getActiveAxis()??"x"}setActiveAxis(e){this.panel?.setActiveAxis(e)}}const H2={x:{min:0,max:100},y:{min:0,max:100},z:{min:0,max:100}};class n9{element;options;isHidden=!1;isReversed=!1;range;hideBtn;fitBtn;resetBtn;hideLabelEl;fitLabelEl;resetLabelEl;xLabelEl;yLabelEl;zLabelEl;unsubscribeLocale=null;unsubscribeTheme=null;xSlider;ySlider;zSlider;xMinHandle;xMaxHandle;yMinHandle;yMaxHandle;zMinHandle;zMaxHandle;dragState={isDragging:!1,axis:null,handleType:null,pointerId:null};constructor(e={}){this.options=e,this.isHidden=e.defaultHidden??!1,this.isReversed=e.defaultReversed??!1,this.range=JSON.parse(JSON.stringify(e.defaultRange??H2))}init(){this.element=this.createPanel(),this.unsubscribeLocale=Zt.subscribe(()=>this.setLocales()),this.unsubscribeTheme=ct.subscribe(e=>this.setTheme(e)),this.setLocales(),this.setTheme(ct.getTheme()),this.updateButtonStates(),this.updateAllSlidersUI(),this.setupDragListeners()}setHiddenState(e){this.isHidden=e,this.updateButtonStates()}getHiddenState(){return this.isHidden}setReversedState(e){this.isReversed=e,this.updateButtonStates()}getReversedState(){return this.isReversed}setRange(e){e.x&&(this.range.x={...this.range.x,...e.x}),e.y&&(this.range.y={...this.range.y,...e.y}),e.z&&(this.range.z={...this.range.z,...e.z}),this.updateAllSlidersUI()}getRange(){return JSON.parse(JSON.stringify(this.range))}reset(){this.isHidden=this.options.defaultHidden??!1,this.isReversed=this.options.defaultReversed??!1,this.range=JSON.parse(JSON.stringify(this.options.defaultRange??H2)),this.updateButtonStates(),this.updateAllSlidersUI(),this.options.onReset?.(),this.options.onRangeChange?.(this.range)}createPanel(){const e=document.createElement("div");e.className="section-box-panel";const t=document.createElement("div");t.className="section-box-row-buttons",this.hideBtn=this.createButton("hide",Se("sectionBox.actions.hide"),()=>{this.isHidden=!this.isHidden,this.updateButtonStates(),this.options.onHideToggle?.(this.isHidden)},"hide"),this.fitBtn=this.createButton("fit",Se("sectionBox.actions.fitToModel"),()=>{this.options.onFitToModel?.()},"fit"),this.resetBtn=this.createButton("reset",Se("sectionBox.actions.reset"),()=>this.reset(),"reset"),[this.hideBtn,this.fitBtn,this.resetBtn].forEach(n=>t.appendChild(n));const i=document.createElement("div");return i.className="section-box-sliders",i.addEventListener("pointerdown",n=>n.stopPropagation()),this.xSlider=this.createSlider("x",Se("sectionBox.axes.x")),this.ySlider=this.createSlider("y",Se("sectionBox.axes.y")),this.zSlider=this.createSlider("z",Se("sectionBox.axes.z")),[this.xSlider,this.ySlider,this.zSlider].forEach(n=>i.appendChild(n)),e.appendChild(t),e.appendChild(i),e}createButton(e,t,i,n){const r=document.createElement("button");r.className="section-box-btn",r.title=t;const a={hide:"隐藏",reverse:"反向",fit:"适应到模型",reset:"重置"},o=document.createElement("div");o.className="section-box-btn-icon",o.innerHTML=Tt(a[e]||e);const l=document.createElement("div");return l.className="section-box-btn-label",l.textContent=t,n==="hide"?this.hideLabelEl=l:n==="fit"?this.fitLabelEl=l:n==="reset"&&(this.resetLabelEl=l),r.appendChild(o),r.appendChild(l),r.addEventListener("click",i),r}createSlider(e,t){const i=document.createElement("div");i.className="section-box-slider";const n=document.createElement("div");n.className="section-box-slider-label",n.textContent=t,e==="x"?this.xLabelEl=n:e==="y"?this.yLabelEl=n:this.zLabelEl=n;const r=document.createElement("div");r.className="section-box-slider-track";const a=document.createElement("div");a.className="section-box-slider-range";const o=document.createElement("div");o.className="section-box-slider-handle",o.setAttribute("data-axis",e),o.setAttribute("data-handle","min");const l=document.createElement("div");return l.className="section-box-slider-handle",l.setAttribute("data-axis",e),l.setAttribute("data-handle","max"),r.append(a,o,l),i.append(n,r),e==="x"?(this.xMinHandle=o,this.xMaxHandle=l):e==="y"?(this.yMinHandle=o,this.yMaxHandle=l):(this.zMinHandle=o,this.zMaxHandle=l),i}setupDragListeners(){[this.xMinHandle,this.xMaxHandle,this.yMinHandle,this.yMaxHandle,this.zMinHandle,this.zMaxHandle].forEach(t=>{t.addEventListener("pointerdown",n=>{n.preventDefault(),n.stopPropagation(),t.setPointerCapture(n.pointerId),this.dragState={isDragging:!0,axis:t.getAttribute("data-axis"),handleType:t.getAttribute("data-handle"),pointerId:n.pointerId},t.classList.add("dragging"),t.closest(".section-box-slider").style.zIndex="100"}),t.addEventListener("pointermove",n=>{this.dragState.isDragging&&this.dragState.pointerId===n.pointerId&&this.onDragging(n)});const i=n=>{this.dragState.isDragging&&this.dragState.pointerId===n.pointerId&&(t.hasPointerCapture(n.pointerId)&&t.releasePointerCapture(n.pointerId),t.closest(".section-box-slider").style.zIndex="",t.classList.remove("dragging"),this.dragState={isDragging:!1,axis:null,handleType:null,pointerId:null})};t.addEventListener("pointerup",i),t.addEventListener("pointercancel",i),t.addEventListener("lostpointercapture",i)})}onDragging(e){const{axis:t,handleType:i}=this.dragState;if(!t||!i)return;const a=(t==="x"?this.xSlider:t==="y"?this.ySlider:this.zSlider).querySelector(".section-box-slider-track").getBoundingClientRect();let o=(e.clientX-a.left)/a.width*100;o=Math.max(0,Math.min(100,o));const l=this.range[t];i==="min"?l.min=Math.min(o,l.max):l.max=Math.max(o,l.min),this.updateSliderUI(t),this.options.onRangeChange?.(this.range)}updateSliderUI(e){const t=this.range[e],i=e==="x"?this.xMinHandle:e==="y"?this.yMinHandle:this.zMinHandle,n=e==="x"?this.xMaxHandle:e==="y"?this.yMaxHandle:this.zMaxHandle,a=(e==="x"?this.xSlider:e==="y"?this.ySlider:this.zSlider).querySelector(".section-box-slider-range");i.style.left=`${t.min}%`,n.style.left=`${t.max}%`,a.style.left=`${t.min}%`,a.style.width=`${t.max-t.min}%`,i.setAttribute("data-value",Math.round(t.min).toString()),n.setAttribute("data-value",Math.round(t.max).toString())}updateAllSlidersUI(){["x","y","z"].forEach(e=>this.updateSliderUI(e))}updateButtonStates(){this.hideBtn&&this.hideBtn.classList.toggle("active",this.isHidden)}setLocales(){this.hideLabelEl&&(this.hideLabelEl.textContent=Se("sectionBox.actions.hide"),this.fitLabelEl.textContent=Se("sectionBox.actions.fitToModel"),this.resetLabelEl.textContent=Se("sectionBox.actions.reset"),this.xLabelEl.textContent=Se("sectionBox.axes.x"),this.yLabelEl.textContent=Se("sectionBox.axes.y"),this.zLabelEl.textContent=Se("sectionBox.axes.z"),this.hideBtn.title=Se("sectionBox.actions.hide"),this.fitBtn.title=Se("sectionBox.actions.fitToModel"),this.resetBtn.title=Se("sectionBox.actions.reset"))}setTheme(e){if(!this.element)return;const t=this.element.style;t.setProperty("--bim-bg-inset",e.bgInset??"#152232"),t.setProperty("--bim-bg-elevated",e.bgElevated??"#1f2d3e"),t.setProperty("--bim-border-default",e.borderDefault??"#334155"),t.setProperty("--bim-border-strong",e.borderStrong??"#475569"),t.setProperty("--bim-divider",e.divider??"#334155"),t.setProperty("--bim-primary",e.primary??"#3b82f6"),t.setProperty("--bim-primary-subtle",e.primarySubtle??"rgba(59, 130, 246, 0.15)"),t.setProperty("--bim-icon-default",e.iconDefault??"#ffffff"),t.setProperty("--bim-text-primary",e.textPrimary??"#ffffff"),t.setProperty("--bim-component-bg-hover",e.componentBgHover??"rgba(248, 250, 252, 0.06)")}destroy(){this.unsubscribeLocale?.(),this.unsubscribeTheme?.(),this.element&&this.element.parentElement&&this.element.parentElement.removeChild(this.element)}}class V2 extends No{panel=null;unsubscribeSectionMove=null;constructor(e){super(e)}get dialogId(){return"section-box-dialog"}get dialogTitle(){return"sectionBox.dialogTitle"}get dialogWidth(){return 280}getDialogPosition(){const e=this.registry.container;if(!e)return{x:100,y:100};const t=e.clientWidth,i=e.clientHeight;return{x:t-this.dialogWidth-20,y:i-50-300}}createContent(){return this.panel=new n9({defaultHidden:!1,defaultReversed:!1,onHideToggle:e=>{console.log("[SectionBoxDialogManager] 隐藏切换:",e),e?this.engineComponent?.hideSection():this.engineComponent?.recoverSection()},onFitToModel:()=>{this.engineComponent?.scaleSectionBox()},onReset:()=>{this.engineComponent?.deactivateSection(),this.engineComponent?.activeSection("box"),this.engineComponent?.recoverSection()},onRangeChange:e=>{this.engineComponent?.setSectionBoxRange(e)}}),this.panel.init(),this.panel.element}onDialogCreated(){this.engineComponent?.activeSection("box"),this.dialog?.fitHeight(!1);const e=this.engineComponent;if(e){const t=i=>{i&&this.panel&&this.panel.setRange(i)};e.onRawEvent("section-move",t),this.unsubscribeSectionMove=()=>e.offRawEvent("section-move",t)}}onDialogClose(){this.unsubscribeSectionMove&&(this.unsubscribeSectionMove(),this.unsubscribeSectionMove=null),this.registry.toolbar?.setBtnActive("section-box",!1)}onBeforeDestroy(){this.unsubscribeSectionMove&&(this.unsubscribeSectionMove(),this.unsubscribeSectionMove=null),this.engineComponent?.deactivateSection(),this.panel&&(this.panel.destroy(),this.panel=null)}getHiddenState(){return this.panel?.getHiddenState()??!1}setHiddenState(e){this.panel?.setHiddenState(e)}getReversedState(){return this.panel?.getReversedState()??!1}setReversedState(e){this.panel?.setReversedState(e)}getRange(){return this.panel?.getRange()??null}setRange(e){this.panel?.setRange(e)}}class G2 extends jn{panel=null;pathManager=null;constructor(e){super(e)}init(){this.pathManager=new O2(this.registry),this.pathManager.init()}show(){this.registry.toolbar?.hide(),console.log("[WalkControl] 打开漫游面板,激活第一人称模式"),this.engineComponent?.activateFirstPersonMode(),this.panel=new k2({onPlanViewToggle:t=>{console.log("[WalkControl] 小地图:",t),this.engineComponent?.toggleMiniMap(),this.registry.toolbar?.setBtnActive("map",t),this.emit("walk:plan-view-toggle",{isActive:t})},onPathModeToggle:t=>{console.log("[WalkControl] 路径漫游:",t),t?this.pathManager?.show():this.pathManager?.hide(),this.emit("walk:path-mode-toggle",{isActive:t})},onWalkModeToggle:t=>{console.log("[WalkControl] 第三人称漫游按钮点击:",t),t&&(this.pathManager?.hide(),alert("第三人称功能开发中")),this.emit("walk:walk-mode-toggle",{isActive:t})},onSpeedChange:t=>{console.log("[WalkControl] 速度变化:",t);const i=t*.1;this.engineComponent?.setWalkSpeed(i),this.emit("walk:speed-change",{speed:t})},onGravityToggle:t=>{console.log("[WalkControl] 重力:",t),this.engineComponent?.setWalkGravity(t),this.emit("walk:gravity-toggle",{enabled:t})},onCollisionToggle:t=>{console.log("[WalkControl] 碰撞:",t),this.engineComponent?.setWalkCollision(t),this.emit("walk:collision-toggle",{enabled:t})},onCharacterModelChange:t=>{console.log("[WalkControl] 角色模型:",t)},onWalkModeChange:t=>{console.log("[WalkControl] 行走模式:",t)},onExit:()=>{this.hide()}}),this.panel.init();const e=this.engineComponent?.getMiniMapState()??!1;this.panel.setPlanViewActive(e),this.registry.container?(this.panel.element.style.position="absolute",this.panel.element.style.bottom="20px",this.panel.element.style.left="50%",this.panel.element.style.transform="translateX(-50%)",this.panel.element.style.zIndex="1000",this.registry.container.appendChild(this.panel.element)):console.warn("[WalkControlManager] Container not found")}hide(){this.pathManager?.hide(),this.engineComponent?.getMiniMapState()&&this.engineComponent.toggleMiniMap(),console.log("[WalkControl] 关闭漫游面板,退出第一人称模式"),this.engineComponent?.deactivateFirstPersonMode(),this.panel&&(this.panel.destroy(),this.panel=null),this.registry.toolbar?.setBtnActive("map",!1),this.registry.toolbar&&this.registry.toolbar.show()}destroy(){this.hide(),this.pathManager?.destroy(),this.pathManager=null,super.destroy()}}class W2 extends No{get dialogId(){return"engine-info-dialog"}get dialogTitle(){return"info.dialogTitle"}get dialogWidth(){return 280}constructor(e){super(e)}init(){}getDialogPosition(){const e=this.registry.container;if(!e)return{x:100,y:100};const t=e.clientWidth,i=e.clientHeight;return{x:(t-this.dialogWidth)/2,y:(i-150)/2}}createContent(){const e=this.engineComponent?.getEngineInfo()??null,t=document.createElement("div");t.className="engine-info-content",t.style.cssText="padding: 16px;";const i=(n,r)=>{const a=document.createElement("div");a.style.cssText="display: flex; justify-content: space-between; margin-bottom: 12px; font-size: 14px;";const o=document.createElement("span");o.style.cssText="color: var(--bim-text-secondary, #94a3b8);",o.textContent=n;const l=document.createElement("span");return l.style.cssText="color: var(--bim-text-primary, #fff); font-weight: 500;",l.textContent=String(r),a.appendChild(o),a.appendChild(l),a};return t.appendChild(i(Se("info.meshCount"),e?.meshCount??"-")),t.appendChild(i(Se("info.totalTriangles"),e?.totalTriangles??"-")),t.appendChild(i(Se("info.totalVertices"),e?.totalVertices??"-")),t}}const oy="font-size: 15px; font-weight: 600; color: var(--bim-text-primary, #0f172a); margin-bottom: 4px;",s9="height: 1px; background: var(--bim-divider, #e2e8f0); margin: 8px 0;",ly="display: flex; align-items: center; justify-content: space-between; gap: 12px;",cy="display: flex; flex-direction: column; gap: 6px;",r9="font-size: 12px; color: var(--bim-text-secondary, #475569); min-width: 32px; text-align: right;",Xn="var(--bim-border-default, #e2e8f0)",hy="var(--bim-bg-inset, #f1f5f9)",ko="var(--bim-primary, #3b82f6)",Oo="var(--bim-text-primary, #0f172a)",uc="var(--bim-text-inverse, #ffffff)",a9="var(--bim-component-bg-hover, rgba(0,0,0,0.04))",X2={render:{mode:"advanced",contrast:50,saturation:50,shadowIntensity:50,lightIntensity:50,gtaoIntensity:50},display:{showEdge:!1,edgeOpacity:30,showGrid:!1,showLevel:!1,showGround:!1,groundId:"0",groundHeight:0},environment:{type:"none",hdrId:"0",hdrIntensity:20,skyPreset:"sunrise_clear",skyParams:{},skyIntensity:20}},o9={ground:[],hdr:[],sky:[]};class Rr extends No{get dialogId(){return"setting-dialog"}get dialogTitle(){return"setting.dialogTitle"}get dialogWidth(){return 420}settings=structuredClone(X2);presetList=[];selectedPresetId=null;presetLists=structuredClone(o9);savedPosition=null;savedScrollTop=null;isDirty=!1;saveAsModalEl=null;deleteConfirmModalEl=null;unsubscribeLocale=null;static INTERNAL_DEFAULT_PRESET_ID="__internal-default-preset__";constructor(e){super(e)}init(){this.ensurePresetListWithInternalDefault(),this.applySelectedPresetFromList(),this.unsubscribeLocale=Zt.subscribe(()=>{this.updateInternalDefaultPresetLabel(),this.isOpen()&&this.reopenAtSamePosition()})}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.closeSaveAsPresetModal(),this.closeDeletePresetConfirmModal(),super.destroy()}ensurePresetListWithInternalDefault(){const e=this.presetList.filter(n=>n.id!==Rr.INTERNAL_DEFAULT_PRESET_ID),t=e.some(n=>n.isDefault),i=this.createInternalDefaultPreset(!t);this.presetList=[...e,i],(!this.selectedPresetId||!this.presetList.some(n=>n.id===this.selectedPresetId))&&(this.selectedPresetId=i.id)}updateInternalDefaultPresetLabel(){const e=this.presetList.findIndex(t=>t.id===Rr.INTERNAL_DEFAULT_PRESET_ID);e<0||(this.presetList[e]={...this.presetList[e],presetName:Se("setting.defaultPresetLabel")},this.ensurePresetListWithInternalDefault())}createInternalDefaultPreset(e=!0){return{id:Rr.INTERNAL_DEFAULT_PRESET_ID,presetName:Se("setting.defaultPresetLabel"),isDefault:e,settings:structuredClone(X2),source:"sdk-default",readonly:!1,allowModify:!1}}setPresetList(e){this.presetList=this.normalizePresetList(e),this.ensurePresetListWithInternalDefault(),this.selectedPresetId=this.resolveDefaultPresetId(this.presetList),!this.selectedPresetId&&this.presetList.length>0&&(this.selectedPresetId=this.presetList[0].id),this.applySelectedPresetFromList(),this.isDirty=!1,this.updateUndoRestoreVisibility(),this.isOpen()&&this.reopenAtSamePosition()}getDialogPosition(){if(this.savedPosition){const n=this.savedPosition;return this.savedPosition=null,n}const e=this.registry.container;if(!e)return{x:100,y:100};const t=e.clientWidth,i=e.clientHeight;return{x:(t-this.dialogWidth)/2,y:Math.max(20,(i-560)/2)}}createContent(){this.syncFromEngine(),this.ensureSliderStyle();const e=document.createElement("div");e.style.cssText="height: 600px; display: flex; flex-direction: column;";const t=document.createElement("div");t.className="setting-scroll-body",t.style.cssText="padding: 14px 16px 12px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; flex: 1; min-height: 0;",t.appendChild(this.createRenderModeSection()),t.appendChild(this.createSliderSection(Se("setting.lightIntensity"),this.settings.render.lightIntensity,0,100,n=>this.updateSettings({render:{lightIntensity:n}}))),this.settings.render.mode==="advanced"&&(t.appendChild(this.createSliderSection(Se("setting.contrast"),this.settings.render.contrast,0,100,n=>this.updateSettings({render:{contrast:n}}))),t.appendChild(this.createSliderSection(Se("setting.saturation"),this.settings.render.saturation,0,100,n=>this.updateSettings({render:{saturation:n}})))),t.appendChild(this.createDivider()),t.appendChild(this.createDisplaySection()),t.appendChild(this.createDivider()),t.appendChild(this.createEnvironmentSection());const i=document.createElement("div");return i.style.cssText=`
9610
9610
  padding: 12px 16px 14px 16px;
9611
9611
  border-top: 1px solid ${Xn};
9612
9612
  background: var(--bim-bg-elevated, #fff);
@@ -9688,7 +9688,7 @@ ${JSON.stringify(l,null,2)}
9688
9688
  background-repeat: no-repeat;
9689
9689
  background-position: right 10px center;
9690
9690
  padding-right: 28px;
9691
- `;for(const r of e){const a=document.createElement("option");a.value=r.value,a.textContent=r.label,r.value===t&&(a.selected=!0),n.appendChild(a)}return n.addEventListener("change",()=>i(n.value)),n.addEventListener("focus",()=>{n.style.borderColor=ko}),n.addEventListener("blur",()=>{n.style.borderColor=Xn}),n}async applyPresetById(e){const t=this.presetList.find(i=>i.id===e);t&&(this.selectedPresetId=e,await this.engineComponent?.setSettings(t.settings),this.settings=structuredClone(t.settings),this.isDirty=!1,this.logCurrentSettings("apply-preset"),this.updateUndoRestoreVisibility(),this.emit("setting:preset-changed",{preset:structuredClone(t),timestamp:Date.now()}),this.reopenAtSamePosition())}async updateSettings(e,t=!1){const i=this.mergeSettings(this.settings,e);try{await this.engineComponent?.setSettings(e)}catch(n){console.warn("[SettingDialogManager] Failed to apply settings patch, keep local state in sync.",n)}this.settings=i,this.isDirty=this.getCurrentSettingsDirtyState(i),this.logCurrentSettings("update-settings"),this.updateUndoRestoreVisibility(),t&&this.reopenAtSamePosition()}logCurrentSettings(e){console.log("[SettingDialogManager] current settings",{source:e,settings:structuredClone(this.settings)})}mergeSettings(e,t){return{render:{...e.render,...t.render},display:{...e.display,...t.display},environment:{...e.environment,...t.environment,skyParams:{...e.environment.skyParams,...t.environment?.skyParams}}}}getCurrentSettingsDirtyState(e){const t=this.presetList.find(i=>i.id===this.selectedPresetId);return t?JSON.stringify(t.settings)!==JSON.stringify(e):!1}getLocalizedPresetName(e,t){if(!Array.isArray(e)||e.length===0)return t;const i=Zt.getLocale();return i==="zh-CN"?e[0]||e[1]||e[2]||t:i==="zh-TW"?e[1]||e[0]||e[2]||t:e[2]||e[0]||e[1]||t}updateUndoRestoreVisibility(){const e=document.getElementById(this.dialogId);if(!e)return;const t=e.querySelector(`#${this.dialogId}-undo-btn`);t instanceof HTMLElement&&(t.style.display=this.isDirty&&this.selectedPresetId?"block":"none")}handleSaveCurrentPreset(){if(!this.isSelectedPresetAllowModify())return;if(!this.selectedPresetId){window.alert(Se("setting.selectPresetFirst"));return}const e=this.presetList.findIndex(r=>r.id===this.selectedPresetId);if(e<0){window.alert(Se("setting.selectPresetFirst"));return}const t=this.selectedPresetId,i=this.engineComponent?.getSettings()??structuredClone(this.settings),n={...this.presetList[e],settings:structuredClone(i)};this.presetList=this.presetList.map((r,a)=>a===e?n:r),this.ensurePresetListWithInternalDefault(),this.selectedPresetId=t,this.settings=structuredClone(i),this.isDirty=!1,this.updateUndoRestoreVisibility(),this.emit("setting:preset-saved",{preset:structuredClone(n),currentSettings:structuredClone(i),timestamp:Date.now()}),this.reopenAtSamePosition()}saveAsPresetWithName(e){const t=e.trim();if(!t)return window.alert(Se("setting.presetNameRequired")),!1;if(this.presetList.some(o=>o.presetName.toLowerCase()===t.toLowerCase()))return window.alert(Se("setting.presetNameDuplicate")),!1;const n=this.engineComponent?.getSettings()??structuredClone(this.settings),r={id:`user-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,presetName:t,isDefault:!1,settings:structuredClone(n),source:"user",readonly:!1},a=this.presetList.filter(o=>o.id!==Rr.INTERNAL_DEFAULT_PRESET_ID);return this.presetList=[...a,r],this.ensurePresetListWithInternalDefault(),this.selectedPresetId=r.id,this.settings=structuredClone(n),this.isDirty=!1,this.updateUndoRestoreVisibility(),this.emit("setting:preset-saved",{preset:structuredClone(r),currentSettings:structuredClone(n),timestamp:Date.now()}),this.reopenAtSamePosition(),!0}openDeletePresetConfirmModal(){if(!this.isSelectedPresetAllowModify()||!this.isSelectedPresetDeletable())return;this.closeDeletePresetConfirmModal();const e=document.getElementById(this.dialogId);if(!e)return;const t=document.createElement("div");t.style.cssText=`
9691
+ `;for(const r of e){const a=document.createElement("option");a.value=r.value,a.textContent=r.label,r.value===t&&(a.selected=!0),n.appendChild(a)}return n.addEventListener("change",()=>i(n.value)),n.addEventListener("focus",()=>{n.style.borderColor=ko}),n.addEventListener("blur",()=>{n.style.borderColor=Xn}),n}async applyPresetById(e){const t=this.presetList.find(i=>i.id===e);t&&(this.selectedPresetId=e,await this.engineComponent?.setSettings(t.settings),this.settings=structuredClone(t.settings),this.isDirty=!1,this.logCurrentSettings("apply-preset"),this.updateUndoRestoreVisibility(),this.emit("setting:preset-changed",{preset:structuredClone(t),timestamp:Date.now()}),this.reopenAtSamePosition())}async updateSettings(e,t=!1){const i=this.mergeSettings(this.settings,e);try{await this.engineComponent?.setSettings(e)}catch(n){console.warn("[SettingDialogManager] Failed to apply settings patch, keep local state in sync.",n)}this.settings=i,this.isDirty=this.getCurrentSettingsDirtyState(i),this.logCurrentSettings("update-settings"),this.updateUndoRestoreVisibility(),t&&this.reopenAtSamePosition()}logCurrentSettings(e){console.log("[SettingDialogManager] current settings",{source:e,settings:structuredClone(this.settings)})}mergeSettings(e,t){return{render:{...e.render,...t.render},display:{...e.display,...t.display},environment:{...e.environment,...t.environment,skyParams:{...e.environment.skyParams,...t.environment?.skyParams}}}}getCurrentSettingsDirtyState(e){const t=this.presetList.find(i=>i.id===this.selectedPresetId);return t?JSON.stringify(t.settings)!==JSON.stringify(e):!1}getLocalizedPresetName(e,t){if(!Array.isArray(e)||e.length===0)return t;const i=Zt.getLocale();return i==="zh-CN"?e[0]||e[1]||e[2]||t:i==="zh-TW"?e[1]||e[0]||e[2]||t:e[2]||e[0]||e[1]||t}updateUndoRestoreVisibility(){const e=document.getElementById(this.dialogId);if(!e)return;const t=e.querySelector(`#${this.dialogId}-undo-btn`);t instanceof HTMLElement&&(t.style.display=this.isDirty&&this.selectedPresetId?"block":"none")}handleSaveCurrentPreset(){if(!this.isSelectedPresetAllowModify())return;if(!this.selectedPresetId){window.alert(Se("setting.selectPresetFirst"));return}const e=this.presetList.findIndex(r=>r.id===this.selectedPresetId);if(e<0){window.alert(Se("setting.selectPresetFirst"));return}const t=this.selectedPresetId,i=this.engineComponent?.getSettings()??structuredClone(this.settings),n={...this.presetList[e],settings:structuredClone(i),isDefault:!0};this.presetList=this.presetList.map((r,a)=>({...a===e?n:r,isDefault:a===e})),this.ensurePresetListWithInternalDefault(),this.selectedPresetId=t,this.settings=structuredClone(i),this.isDirty=!1,this.updateUndoRestoreVisibility(),this.emit("setting:preset-saved",{preset:structuredClone(n),currentSettings:structuredClone(i),timestamp:Date.now()}),this.reopenAtSamePosition()}saveAsPresetWithName(e){const t=e.trim();if(!t)return window.alert(Se("setting.presetNameRequired")),!1;if(this.presetList.some(o=>o.presetName.toLowerCase()===t.toLowerCase()))return window.alert(Se("setting.presetNameDuplicate")),!1;const n=this.engineComponent?.getSettings()??structuredClone(this.settings),r={id:`user-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,presetName:t,isDefault:!0,settings:structuredClone(n),source:"user",readonly:!1},a=this.presetList.filter(o=>o.id!==Rr.INTERNAL_DEFAULT_PRESET_ID);return this.presetList=[...a.map(o=>({...o,isDefault:!1})),r],this.ensurePresetListWithInternalDefault(),this.selectedPresetId=r.id,this.settings=structuredClone(n),this.isDirty=!1,this.updateUndoRestoreVisibility(),this.emit("setting:preset-saved",{preset:structuredClone(r),currentSettings:structuredClone(n),timestamp:Date.now()}),this.reopenAtSamePosition(),!0}openDeletePresetConfirmModal(){if(!this.isSelectedPresetAllowModify()||!this.isSelectedPresetDeletable())return;this.closeDeletePresetConfirmModal();const e=document.getElementById(this.dialogId);if(!e)return;const t=document.createElement("div");t.style.cssText=`
9692
9692
  position: absolute; inset: 0;
9693
9693
  background: rgba(15, 23, 42, 0.35);
9694
9694
  display: flex; align-items: center; justify-content: center;
@@ -9881,7 +9881,7 @@ ${JSON.stringify(l,null,2)}
9881
9881
  <span class="bim-ai-qa-answer">${this.escapeHtml(i||"")}</span>
9882
9882
  </div>
9883
9883
  </div>
9884
- `}bindQuestionEvents(){this.messagesContainer?.querySelectorAll(".bim-ai-option").forEach(e=>{e.addEventListener("click",t=>{const i=t.currentTarget,n=i.dataset.questionId,r=i.dataset.optionId;if(n&&r){const a=this.messages.find(o=>o.id===n);a&&!a.answered&&(a.selectedOptionId=r,this.renderMessages())}})}),this.messagesContainer?.querySelectorAll(".bim-ai-option-input").forEach(e=>{e.addEventListener("input",t=>{const i=t.target,n=i.dataset.questionId;if(n){const r=this.messages.find(a=>a.id===n);r&&(r.customAnswer=i.value)}})}),this.messagesContainer?.querySelectorAll(".bim-ai-question-submit").forEach(e=>{e.addEventListener("click",t=>{const n=t.currentTarget.dataset.questionId;if(n){const r=this.messages.find(a=>a.id===n);r&&r.selectedOptionId&&(r.answered=!0,this.renderMessages(),this.options.onQuestionSubmit?.(n,r.selectedOptionId,r.customAnswer))}})})}scrollToBottom(){this.messagesContainer&&(this.messagesContainer.scrollTop=this.messagesContainer.scrollHeight)}escapeHtml(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}destroy(){this._isDestroyed||(this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.element.remove(),this._isDestroyed=!0)}}class q2{aiChat=null;registry;initialized=!1;constructor(e){this.registry=e}init(){if(this.initialized)return;const e=this.registry.wrapper;if(!e){console.warn("[AiChatManager] wrapper 不存在,无法初始化");return}this.aiChat=new h9({container:e,width:440,title:"aiChat.title",placeholder:"aiChat.placeholder",quickPrompts:[{id:"summarize",label:"aiChat.quickPrompt.summarize"},{id:"explain",label:"aiChat.quickPrompt.explain"},{id:"generate",label:"aiChat.quickPrompt.generate"}],onSend:t=>{console.log("[AiChatManager] 用户发送消息:",t),this.aiChat?.addUserMessage(t),this.registry.emit("aiChat:message-sent",{message:t})},onQuestionSubmit:(t,i,n)=>{console.log("[AiChatManager] 用户回答问题:",{questionId:t,optionId:i,customAnswer:n}),this.registry.emit("aiChat:question-answered",{questionId:t,optionId:i,customAnswer:n})},onNewChat:()=>{console.log("[AiChatManager] 新建对话"),this.registry.emit("aiChat:new-chat",{})},onHistory:()=>{console.log("[AiChatManager] 打开历史"),this.registry.emit("aiChat:history-opened",{})},onSettings:()=>{console.log("[AiChatManager] 打开设置"),this.registry.emit("aiChat:settings-opened",{})},onClose:()=>{console.log("[AiChatManager] 关闭 AI 聊天"),this.registry.emit("aiChat:closed",{}),this.registry.toolbar?.setBtnActive("aiChat",!1)}}),this.initialized=!0}show(){this.aiChat||this.init(),this.aiChat?.show(),this.registry.emit("aiChat:opened",{}),this.registry.toolbar?.setBtnActive("aiChat",!0)}hide(){this.aiChat?.hide(),this.registry.emit("aiChat:closed",{}),this.registry.toolbar?.setBtnActive("aiChat",!1)}toggle(){this.aiChat?.isVisible()?this.hide():this.show()}isVisible(){return this.aiChat?.isVisible()??!1}addUserMessage(e){return this.aiChat?.addUserMessage(e)??""}addAiMessage(e){return this.aiChat?.addAiMessage(e)??""}addStepMessage(e,t){return this.aiChat?.addStepMessage(e,t)??""}addThinkingMessage(){return this.aiChat?.addThinkingMessage()??""}addQuestionMessage(e,t,i){return this.aiChat?.addQuestionMessage(e,t,i)??""}updateMessage(e,t){this.aiChat?.updateMessage(e,t)}removeMessage(e){this.aiChat?.removeMessage(e)}clearMessages(){this.aiChat?.clearMessages()}destroy(){this.aiChat&&(this.aiChat.destroy(),this.aiChat=null),this.initialized=!1}}class d9{container;options;groups=[];activeBtnIds=new Set;btnRefs=new Map;dropdownElement=null;hoverTimeout=null;customColors=new Set;unsubscribeLocale=null;unsubscribeTheme=null;DEFAULT_ICON='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect></svg>';constructor(e){const t=typeof e.container=="string"?document.getElementById(e.container):e.container;if(!t)throw new Error("Container not found");this.container=t,this.options={showLabel:!0,visibility:{},direction:"row",position:"static",align:"vertical",expand:"down",...e},["backgroundColor","btnBackgroundColor","btnHoverColor","btnActiveColor","iconColor","iconActiveColor","textColor","textActiveColor"].forEach(n=>{e[n]&&this.customColors.add(n)}),this.initContainer(),this.applyStyles()}emit(e,t){this.options.registry?.emit(e,t)}initContainer(){this.container.innerHTML="",this.container.classList.add("bim-btn-group-root"),this.options.direction==="column"?this.container.classList.add("dir-column"):this.container.classList.add("dir-row"),this.options.className&&this.container.classList.add(this.options.className),this.options.type&&this.options.type!=="default"&&this.container.classList.add(`type-${this.options.type}`),this.updatePosition(),this.setupEventInterception(this.container)}setupEventInterception(e){const t=n=>{n.stopPropagation()};["click","dblclick","contextmenu","wheel","mousedown","mouseup","mousemove","touchstart","touchend","touchmove","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointerover","pointerout"].forEach(n=>{e.addEventListener(n,t,{passive:!1})})}updatePosition(){const e=this.options.position,t=this.container.style;if(t.top="",t.bottom="",t.left="",t.right="",t.transform="",e==="static"){this.container.classList.add("static");return}if(this.container.classList.remove("static"),this.container.style.position="absolute",typeof e=="object"&&"x"in e)t.left=`${e.x}px`,t.top=`${e.y}px`;else{const i="20px";switch(e){case"top-left":t.top=i,t.left=i;break;case"top-center":t.top=i,t.left="50%",t.transform="translateX(-50%)";break;case"top-right":t.top=i,t.right=i;break;case"bottom-left":t.bottom=i,t.left=i;break;case"bottom-center":t.bottom=i,t.left="50%",t.transform="translateX(-50%)";break;case"bottom-right":t.bottom=i,t.right=i;break;case"left-center":t.left=i,t.top="50%",t.transform="translateY(-50%)";break;case"right-center":t.right=i,t.top="50%",t.transform="translateY(-50%)";break;case"center":t.top="50%",t.left="50%",t.transform="translate(-50%, -50%)";break}}}applyStyles(){const e=this.container.style;this.options.backgroundColor&&e.setProperty("--bim-btn-group-section-bg",this.options.backgroundColor),this.options.btnBackgroundColor&&e.setProperty("--bim-btn-bg",this.options.btnBackgroundColor),this.options.btnHoverColor&&e.setProperty("--bim-btn-hover-bg",this.options.btnHoverColor),this.options.btnActiveColor&&e.setProperty("--bim-btn-active-bg",this.options.btnActiveColor),this.options.iconColor&&e.setProperty("--bim-icon-color",this.options.iconColor),this.options.iconActiveColor&&e.setProperty("--bim-icon-active-color",this.options.iconActiveColor),this.options.textColor&&e.setProperty("--bim-btn-text-color",this.options.textColor),this.options.textActiveColor&&e.setProperty("--bim-btn-text-active-color",this.options.textActiveColor),document.querySelectorAll(".opt-btn-dropdown").forEach(i=>{const n=i.style;this.options.iconColor&&n.setProperty("--bim-icon-color",this.options.iconColor),this.options.iconActiveColor&&n.setProperty("--bim-icon-active-color",this.options.iconActiveColor),this.options.textColor&&n.setProperty("--bim-btn-text-color",this.options.textColor),this.options.textActiveColor&&n.setProperty("--bim-btn-text-active-color",this.options.textActiveColor),this.options.btnBackgroundColor&&n.setProperty("--bim-btn-bg",this.options.btnBackgroundColor),this.options.btnHoverColor&&n.setProperty("--bim-btn-hover-bg",this.options.btnHoverColor),this.options.btnActiveColor&&n.setProperty("--bim-btn-active-bg",this.options.btnActiveColor)})}setPrimaryColor(e){this.container.style.setProperty("--bim-primary-color",e),document.querySelectorAll(".opt-btn-dropdown").forEach(i=>{i.style.setProperty("--bim-primary-color",e)})}setTheme(e){const t={backgroundColor:e.bgElevated,btnBackgroundColor:e.componentBg,btnHoverColor:e.componentBgHover,btnActiveColor:e.componentBgActive,iconColor:e.iconDefault,iconActiveColor:e.iconActive,textColor:e.textSecondary,textActiveColor:e.textPrimary};Object.entries(t).forEach(([i,n])=>{const r=i;this.customColors.has(r)||(this.options[r]=n)}),this.container.classList.remove("theme-dark","theme-light"),this.container.classList.add(`theme-${e.name}`),this.applyStyles(),this.setPrimaryColor(e.primary),this.applyThemeCssVars(e)}applyThemeCssVars(e){const t=this.container.style;t.setProperty("--bim-primary",e.primary),t.setProperty("--bim-primary-hover",e.primaryHover),t.setProperty("--bim-primary-active",e.primaryActive),t.setProperty("--bim-bg-glass",e.bgGlass),t.setProperty("--bim-bg-glass-blur",e.bgGlassBlur),t.setProperty("--bim-bg-elevated",e.bgElevated),t.setProperty("--bim-bg-overlay",e.bgOverlay),t.setProperty("--bim-bg-inset",e.bgInset),t.setProperty("--bim-text-primary",e.textPrimary),t.setProperty("--bim-text-secondary",e.textSecondary),t.setProperty("--bim-text-tertiary",e.textTertiary),t.setProperty("--bim-text-inverse",e.textInverse),t.setProperty("--bim-icon-default",e.iconDefault),t.setProperty("--bim-icon-hover",e.iconHover),t.setProperty("--bim-icon-active",e.iconActive),t.setProperty("--bim-icon-inverse",e.iconInverse),t.setProperty("--bim-border-default",e.borderDefault),t.setProperty("--bim-border-subtle",e.borderSubtle),t.setProperty("--bim-component-bg-hover",e.componentBgHover),t.setProperty("--bim-component-bg-active",e.componentBgActive),t.setProperty("--bim-shadow-sm",e.shadowSm),t.setProperty("--bim-shadow-md",e.shadowMd),t.setProperty("--bim-shadow-lg",e.shadowLg),t.setProperty("--bim-shadow-glow",e.shadowGlow),t.setProperty("--bim-floating-bg",e.floatingBg),t.setProperty("--bim-floating-border",e.floatingBorder),t.setProperty("--bim-floating-shadow",e.floatingShadow),t.setProperty("--bim-floating-btn-bg",e.floatingBtnBg),t.setProperty("--bim-floating-btn-border",e.floatingBtnBorder),t.setProperty("--bim-floating-btn-shadow",e.floatingBtnShadow),t.setProperty("--bim-floating-btn-bg-hover",e.floatingBtnBgHover),t.setProperty("--bim-floating-btn-shadow-hover",e.floatingBtnShadowHover),t.setProperty("--bim-floating-icon-color",e.floatingIconColor),t.setProperty("--bim-floating-icon-color-hover",e.floatingIconColorHover),this.syncDropdownCssVars(e)}syncDropdownCssVars(e){document.querySelectorAll(".opt-btn-dropdown").forEach(i=>{const n=i.style;n.setProperty("--bim-primary",e.primary),n.setProperty("--bim-bg-overlay",e.bgOverlay),n.setProperty("--bim-border-default",e.borderDefault),n.setProperty("--bim-text-primary",e.textPrimary),n.setProperty("--bim-text-inverse",e.textInverse),n.setProperty("--bim-shadow-lg",e.shadowLg),n.setProperty("--bim-floating-btn-bg",e.floatingBtnBg),n.setProperty("--bim-floating-btn-bg-hover",e.floatingBtnBgHover),n.setProperty("--bim-floating-icon-color",e.floatingIconColor)})}setColors(e){this.options={...this.options,...e},Object.keys(e).forEach(t=>{this.customColors.add(t)}),this.applyStyles()}async init(){this.render(),this.unsubscribeLocale=Zt.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=ct.subscribe(e=>{this.setTheme(e)})}setLocales(){this.render()}addGroup(e,t){if(this.groups.some(n=>n.id===e))return;const i={id:e,buttons:[]};if(t){const n=this.groups.findIndex(r=>r.id===t);n!==-1?this.groups.splice(n,0,i):this.groups.push(i)}else this.groups.push(i)}addButton(e){const{groupId:t,parentId:i}=e,n=this.groups.find(a=>a.id===t);if(!n)return;const r={...e,children:e.children||[]};if(i){const a=this.findButton(n.buttons,i);a&&(a.children||(a.children=[]),a.children.push(r))}else n.buttons.push(r)}findButton(e,t){for(const i of e){if(i.id===t)return i;if(i.children){const n=this.findButton(i.children,t);if(n)return n}}}render(){this.container.innerHTML="",this.btnRefs.clear(),this.groups.forEach((e,t)=>{const i=this.renderGroup(e,t,this.groups.length);this.container.appendChild(i)})}renderGroup(e,t,i){const n=document.createElement("div");return n.className="bim-btn-group-section",t<i-1&&n.classList.add("has-divider"),e.buttons.forEach(r=>{if(this.isVisible(r.id)){const a=this.renderButton(r);n.appendChild(a)}}),n}renderButton(e){const t=document.createElement("div");t.className="opt-btn-wrapper";const i=document.createElement("div");i.className="opt-btn",e.isActive&&this.activeBtnIds.add(e.id),(e.align||this.options.align||"vertical")==="horizontal"?i.classList.add("align-horizontal"):i.classList.add("align-vertical"),this.activeBtnIds.has(e.id)&&i.classList.add("active"),e.disabled&&i.classList.add("disabled"),this.options.showLabel&&e.label||(i.classList.add("no-label"),e.label&&(i.title=Se(e.label)));const a=e.iconSize||32,o=e.minWidth||50;i.style.minWidth=`${o}px`;const l=document.createElement("div");l.className="opt-btn-icon",l.style.width=`${a}px`,l.style.height=`${a}px`,l.innerHTML=this.getIcon(e.icon),i.appendChild(l);const c=document.createElement("div");if(c.className="opt-btn-text-wrapper",this.options.showLabel&&e.label){const h=document.createElement("span");h.className="opt-btn-label",h.textContent=Se(e.label),c.appendChild(h)}return c.hasChildNodes()&&i.appendChild(c),i.addEventListener("click",()=>this.handleClick(e)),i.addEventListener("mouseenter",()=>this.handleMouseEnter(e,i)),i.addEventListener("mouseleave",()=>this.handleMouseLeave()),this.btnRefs.set(e.id,i),t.appendChild(i),t}setBtnActive(e,t){const i=this.findButtonById(e);if(!i)return;const n=t!==void 0?t:!this.activeBtnIds.has(e);n?this.activeBtnIds.add(e):this.activeBtnIds.delete(e),i.isActive=n,this.updateButtonState(e)}handleClick(e){if(!e.disabled&&(!e.children||e.children.length===0)){if(e.keepActive){const i=!this.activeBtnIds.has(e.id);this.setBtnActive(e.id,i),i&&e.exclusive&&e.groupId&&this.deactivateExclusiveSiblings(e)}this.closeDropdown(),e.onClick&&e.onClick(e)}}deactivateExclusiveSiblings(e){const t=this.groups.find(i=>i.id===e.groupId);if(t){if(e.parentId){const n=this.findButton(t.buttons,e.parentId)?.children||[];for(const r of n)r&&r.id!==e.id&&r.parentId===e.parentId&&r.groupId===e.groupId&&this.activeBtnIds.has(r.id)&&(this.setBtnActive(r.id,!1),r.onClick&&r.onClick(r));return}for(const i of t.buttons)i.id!==e.id&&i.groupId===e.groupId&&(i.parentId||this.activeBtnIds.has(i.id)&&(this.setBtnActive(i.id,!1),i.onClick&&i.onClick(i)))}}handleMouseEnter(e,t){this.hoverTimeout&&clearTimeout(this.hoverTimeout),e.children&&e.children.length>0?this.showDropdown(e,t):this.closeDropdown()}handleMouseLeave(){this.hoverTimeout=window.setTimeout(()=>this.closeDropdown(),200)}showDropdown(e,t){if(this.closeDropdown(),!e.children)return;const i=document.createElement("div");i.className="opt-btn-dropdown",this.options.backgroundColor&&i.style.setProperty("--bim-toolbar-bg",this.options.backgroundColor);const n=i.style;this.options.iconColor&&n.setProperty("--bim-icon-color",this.options.iconColor),this.options.iconActiveColor&&n.setProperty("--bim-icon-active-color",this.options.iconActiveColor),this.options.textColor&&n.setProperty("--bim-btn-text-color",this.options.textColor),this.options.textActiveColor&&n.setProperty("--bim-btn-text-active-color",this.options.textActiveColor),this.options.btnBackgroundColor&&n.setProperty("--bim-btn-bg",this.options.btnBackgroundColor),this.options.btnHoverColor&&n.setProperty("--bim-btn-hover-bg",this.options.btnHoverColor),this.options.btnActiveColor&&n.setProperty("--bim-btn-active-bg",this.options.btnActiveColor);const r=t.getBoundingClientRect(),a=this.options.expand||"down";this.options.direction==="row"?i.style.flexDirection="column":i.style.flexDirection="row",this.options.type&&this.options.type!=="default"&&i.classList.add(`type-${this.options.type}`);const o=ct.getTheme();i.classList.add(`theme-${o.name}`),n.setProperty("--bim-primary",o.primary),n.setProperty("--bim-bg-overlay",o.bgOverlay),n.setProperty("--bim-border-default",o.borderDefault),n.setProperty("--bim-text-primary",o.textPrimary),n.setProperty("--bim-text-inverse",o.textInverse),n.setProperty("--bim-shadow-lg",o.shadowLg),n.setProperty("--bim-floating-btn-bg",o.floatingBtnBg),n.setProperty("--bim-floating-btn-bg-hover",o.floatingBtnBgHover),n.setProperty("--bim-floating-icon-color",o.floatingIconColor),document.body.appendChild(i),this.setupEventInterception(i),e.children.forEach(c=>{if(this.isVisible(c.id)){const h=this.renderDropdownItem(c);i.appendChild(h)}});const l=i.getBoundingClientRect();a==="up"?(i.style.bottom=window.innerHeight-r.top+8+"px",i.style.left=r.left+(r.width-l.width)/2+"px"):a==="down"?(i.style.top=r.bottom+8+"px",i.style.left=r.left+(r.width-l.width)/2+"px"):a==="right"?(i.style.top=r.top+(r.height-l.height)/2+"px",i.style.left=r.right+8+"px"):a==="left"&&(i.style.top=r.top+(r.height-l.height)/2+"px",i.style.right=window.innerWidth-r.left+8+"px"),i.addEventListener("mouseenter",()=>{this.hoverTimeout&&clearTimeout(this.hoverTimeout)}),i.addEventListener("mouseleave",()=>this.handleMouseLeave()),this.dropdownElement=i}renderDropdownItem(e){const t=document.createElement("div");t.className="opt-btn-dropdown-item",(e.align||"horizontal")==="horizontal"?t.classList.add("align-horizontal"):t.classList.add("align-vertical"),(this.activeBtnIds.has(e.id)||e.isActive)&&t.classList.add("active");const n=e.iconSize||32,r=e.minWidth;r&&(t.style.minWidth=`${r}px`);const a=document.createElement("div");if(a.className="opt-btn-icon",a.style.width=`${n}px`,a.style.height=`${n}px`,a.innerHTML=this.getIcon(e.icon),t.appendChild(a),this.options.showLabel&&e.label){const o=document.createElement("span");o.className="opt-btn-dropdown-label",o.textContent=Se(e.label),t.appendChild(o)}else e.label&&(t.title=Se(e.label));return t.addEventListener("click",o=>{o.stopPropagation(),this.handleClick(e)}),t}closeDropdown(){this.dropdownElement&&(this.dropdownElement.remove(),this.dropdownElement=null),this.btnRefs.forEach(e=>{const t=e.querySelector(".opt-btn-arrow");t&&t.classList.remove("rotated")})}updateButtonState(e){const t=this.btnRefs.get(e);t&&(this.activeBtnIds.has(e)?t.classList.add("active"):t.classList.remove("active"))}getIcon(e){return e||this.DEFAULT_ICON}updateButtonIcon(e,t){const i=this.btnRefs.get(e);if(!i)return;const n=i.querySelector(".opt-btn-icon");n&&(n.innerHTML=this.getIcon(t));const r=this.findButtonById(e);r&&(r.icon=t)}updateButtonVisibility(e,t){this.options.visibility||(this.options.visibility={}),this.options.visibility[e]=t,this.render()}setShowLabel(e){this.options.showLabel=e,this.updateLabelsVisibility()}updateLabelsVisibility(){this.btnRefs.forEach((e,t)=>{const i=this.findButtonById(t);if(!i)return;this.options.showLabel&&i.label?(e.classList.remove("no-label"),e.removeAttribute("title")):(e.classList.add("no-label"),i.label&&(e.title=Se(i.label)))})}findButtonById(e){for(const t of this.groups){const i=this.findButton(t.buttons,e);if(i)return i}}setBackgroundColor(e){this.setColors({backgroundColor:e})}isVisible(e){return this.options.visibility?.[e]!==!1}setType(e){this.container.classList.remove("type-default","type-glass-pill"),this.options.type=e,e&&e!=="default"&&this.container.classList.add(`type-${e}`),this.render()}getType(){return this.options.type||"default"}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.closeDropdown(),this.container.innerHTML="",this.btnRefs.clear()}}var ni=(s=>(s[s.Unchecked=0]="Unchecked",s[s.Checked=1]="Checked",s[s.Indeterminate=2]="Indeterminate",s))(ni||{});class u9{config;element;children=[];parent=null;checkState=ni.Unchecked;contentEl;switcherEl;checkboxEl=null;titleEl;actionsEl;childrenContainer;onExpandChange;onCheckChange;onNodeClick;renderActions;constructor(e,t,i){this.config=e,this.onExpandChange=i.onExpand,this.onCheckChange=i.onCheck,this.onNodeClick=i.onClick,this.renderActions=t.renderActions,this.checkState=e.checked?ni.Checked:ni.Unchecked,this.element=this.createDom(t)}createDom(e){const t=document.createElement("div");t.className="bim-tree-node",this.config.disabled&&t.classList.add("is-disabled"),this.contentEl=document.createElement("div"),this.contentEl.className="bim-tree-node-content",this.switcherEl=document.createElement("span"),this.switcherEl.className="bim-tree-switcher",this.switcherEl.innerHTML='<svg viewBox="0 0 1024 1024"><path d="M288 192l448 320-448 320z"></path></svg>';const i=this.config.children&&this.config.children.length>0;if(i?this.config.expanded&&this.switcherEl.classList.add("is-expanded"):this.switcherEl.classList.add("is-hidden"),this.switcherEl.addEventListener("click",r=>{r.stopPropagation(),this.toggleExpand()}),this.contentEl.appendChild(this.switcherEl),e.checkable!==!1&&(this.checkboxEl=document.createElement("span"),this.checkboxEl.className="bim-tree-checkbox",this.updateCheckboxUI(),this.checkboxEl.addEventListener("click",r=>{r.stopPropagation(),!this.config.disabled&&this.toggleCheck()}),this.contentEl.appendChild(this.checkboxEl)),this.config.icon){const r=document.createElement("span");r.className="bim-tree-icon",r.innerHTML=this.config.icon.includes("<svg")?this.config.icon:`<img src="${this.config.icon}" />`,this.contentEl.appendChild(r)}this.titleEl=document.createElement("span"),this.titleEl.className="bim-tree-title",this.updateLabel(),this.contentEl.appendChild(this.titleEl),this.actionsEl=document.createElement("div"),this.actionsEl.className="bim-tree-node-actions",this.actionsEl.addEventListener("click",r=>{r.stopPropagation()}),this.contentEl.appendChild(this.actionsEl),this.contentEl.addEventListener("click",r=>{if(r.stopPropagation(),this.config.disabled)return;(this.config.clickAction||"select")==="expand"?this.toggleExpand():this.onNodeClick(this)}),t.appendChild(this.contentEl),this.childrenContainer=document.createElement("div"),this.childrenContainer.className="bim-tree-children";const n=e.indent||24;return this.childrenContainer.style.paddingLeft=`${n}px`,this.config.expanded&&i&&this.childrenContainer.classList.add("is-visible"),t.appendChild(this.childrenContainer),t}setSelected(e){if(e){if(this.contentEl.classList.add("is-selected"),this.renderActions){const t=this.renderActions(this.config);this.actionsEl.innerHTML="",typeof t=="string"?this.actionsEl.innerHTML=t:t instanceof HTMLElement&&this.actionsEl.appendChild(t)}}else this.contentEl.classList.remove("is-selected"),this.actionsEl.innerHTML=""}updateLabel(){this.titleEl&&(this.titleEl.textContent=this.config.label)}toggleExpand(e){if(!this.config.children||this.config.children.length===0)return;const t=e!==void 0?e:!this.config.expanded;this.config.expanded=t,t?(this.switcherEl.classList.add("is-expanded"),this.childrenContainer.classList.add("is-visible")):(this.switcherEl.classList.remove("is-expanded"),this.childrenContainer.classList.remove("is-visible")),e===void 0&&this.onExpandChange(this)}toggleCheck(){const e=this.checkState!==ni.Checked;this.setChecked(e?ni.Checked:ni.Unchecked,!0)}setChecked(e,t=!1,i=!1){!i&&this.checkState===e||(this.checkState=e,this.config.checked=e===ni.Checked,this.updateCheckboxUI(),t&&this.onCheckChange(this))}updateCheckboxUI(){this.checkboxEl&&(this.checkboxEl.classList.remove("is-checked","is-indeterminate"),this.checkState===ni.Checked?this.checkboxEl.classList.add("is-checked"):this.checkState===ni.Indeterminate&&this.checkboxEl.classList.add("is-indeterminate"))}appendChild(e){e.parent=this,this.children.push(e),this.childrenContainer.appendChild(e.element),this.children.length===1&&this.switcherEl.classList.remove("is-hidden")}destroy(){this.children.forEach(e=>e.destroy()),this.children=[],this.element.remove(),this.parent=null}}class p9{element;contentElement;searchInput=null;searchResults=null;options;nodeMap=new Map;rootNodes=[];selectedNode=null;lastRevealedNodeId=null;unsubscribeLocale=null;unsubscribeTheme=null;clickOutsideHandler=null;onNodeCheck;onNodeSelect;onNodeDeselect;onNodeExpand;constructor(e){this.options={checkable:!0,checkStrictly:!0,indent:24,defaultExpandAll:!0,enableSearch:!1,searchPlaceholder:"tree.searchPlaceholder",...e},this.element=document.createElement("div"),this.element.className="bim-tree",this.options.enableSearch&&this.createSearchDOM(),this.contentElement=document.createElement("div"),this.contentElement.className="bim-tree-content",this.element.appendChild(this.contentElement),e.onNodeCheck&&(this.onNodeCheck=e.onNodeCheck),e.onNodeSelect&&(this.onNodeSelect=e.onNodeSelect),e.onNodeDeselect&&(this.onNodeDeselect=e.onNodeDeselect),e.onNodeExpand&&(this.onNodeExpand=e.onNodeExpand)}createSearchDOM(){const e=document.createElement("div");e.className="bim-tree-search";const t=document.createElement("div");t.className="bim-tree-search-wrapper";const i=document.createElement("span");i.className="bim-tree-search-icon",i.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="m21 21l-4.343-4.343m0 0A8 8 0 1 0 5.343 5.343a8 8 0 0 0 11.314 11.314"/></svg>',t.appendChild(i),this.searchInput=document.createElement("input"),this.searchInput.className="bim-tree-search-input",this.searchInput.type="text",this.searchInput.placeholder=Se(this.options.searchPlaceholder||"搜索..."),this.searchInput.addEventListener("input",n=>{const r=n.target.value;this.handleSearch(r)}),t.appendChild(this.searchInput),e.appendChild(t),this.searchResults=document.createElement("div"),this.searchResults.className="bim-tree-search-results",e.appendChild(this.searchResults),this.element.appendChild(e),this.clickOutsideHandler=n=>{this.searchResults&&!this.searchResults.contains(n.target)&&!this.searchInput?.contains(n.target)&&this.searchResults.classList.remove("is-visible")},document.addEventListener("click",this.clickOutsideHandler)}init(){this.render(),this.unsubscribeLocale=Zt.subscribe(()=>this.setLocales()),this.unsubscribeTheme=ct.subscribe(e=>this.setTheme(e)),this.setTheme(ct.getTheme())}handleSearch(e){if(!this.searchResults)return;if(!e.trim()){this.searchResults.classList.remove("is-visible"),this.searchResults.innerHTML="";return}const t=[],i=e.toLowerCase();this.nodeMap.forEach(n=>{const r=n.config.label;r.toLowerCase().includes(i)&&t.push({node:n,label:r,path:this.getNodePath(n)})}),this.renderSearchResults(t)}getNodePath(e){const t=[];let i=e.parent;for(;i;)t.unshift(i.config.label),i=i.parent;return t.join(" > ")}renderSearchResults(e){if(this.searchResults){if(this.searchResults.innerHTML="",e.length===0){const t=document.createElement("div");t.className="bim-tree-search-item",t.style.cursor="default",t.style.color="#999",t.textContent="No results",this.searchResults.appendChild(t)}else e.forEach(t=>{const i=document.createElement("div");i.className="bim-tree-search-item";const n=document.createElement("span");n.className="bim-tree-search-item-title",n.textContent=t.label;const r=document.createElement("span");r.className="bim-tree-search-item-path",r.textContent=t.path,i.appendChild(n),t.path&&i.appendChild(r),i.addEventListener("click",()=>{this.revealNode(t.node)}),this.searchResults.appendChild(i)});this.searchResults.classList.add("is-visible")}}revealNode(e){if(this.lastRevealedNodeId===e.config.id&&this.isNodeFullyVisible(e))return;this.lastRevealedNodeId=e.config.id,this.searchResults&&(this.searchResults.classList.remove("is-visible"),this.searchInput&&(this.searchInput.value=""));let t=e.parent;for(;t;)t.toggleExpand(!0),t=t.parent;this.handleNodeSelect(e),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.scrollNodeIntoContentCenter(e)})})}isNodeFullyVisible(e){const t=this.contentElement;if(!t||!e?.element?.isConnected)return!1;const i=t.getBoundingClientRect(),n=e.element.getBoundingClientRect();return n.top>=i.top&&n.bottom<=i.bottom}scrollNodeIntoContentCenter(e){const t=this.contentElement;if(!t||!e?.element?.isConnected)return;const i=t.getBoundingClientRect(),n=e.element.getBoundingClientRect();if(n.top>=i.top&&n.bottom<=i.bottom)return;const r=n.top-i.top+t.scrollTop,a=Math.max(0,r-(t.clientHeight-n.height)/2);t.scrollTo({top:a,behavior:"auto"})}setTheme(e){const t=this.element.style;t.setProperty("--bim-primary",e.primary),t.setProperty("--bim-bg-elevated",e.bgElevated),t.setProperty("--bim-text-primary",e.textPrimary),t.setProperty("--bim-text-secondary",e.textSecondary),t.setProperty("--bim-text-tertiary",e.textTertiary),t.setProperty("--bim-text-disabled",e.textDisabled),t.setProperty("--bim-text-inverse",e.textInverse),t.setProperty("--bim-border-default",e.borderDefault),t.setProperty("--bim-border-disabled",e.borderDisabled),t.setProperty("--bim-component-bg-hover",e.componentBgHover),t.setProperty("--bim-component-bg-selected",e.componentBgSelected),t.setProperty("--bim-component-bg-disabled",e.componentBgDisabled),t.setProperty("--bim-shadow-md",e.shadowMd),t.setProperty("--bim-focus-ring",e.focusRing)}setLocales(){this.nodeMap.forEach(e=>e.updateLabel()),this.searchInput&&(this.searchInput.placeholder=Se(this.options.searchPlaceholder||"tree.searchPlaceholder"))}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null),this.rootNodes.forEach(e=>e.destroy()),this.rootNodes=[],this.nodeMap.clear(),this.lastRevealedNodeId=null,this.element.remove(),this.selectedNode=null}render(){this.contentElement.innerHTML="",this.nodeMap.clear(),this.rootNodes=[],this.options.data.forEach(e=>{this.createNodeRecursively(e,null)})}createNodeRecursively(e,t){e.expanded===void 0&&(e.expanded=this.options.defaultExpandAll);const i=new u9(e,this.options,{onExpand:n=>{this.onNodeExpand&&this.onNodeExpand(n)},onCheck:n=>this.handleNodeCheck(n),onClick:n=>this.handleNodeSelect(n)});this.nodeMap.set(e.id,i),t?t.appendChild(i):(this.rootNodes.push(i),this.contentElement.appendChild(i.element)),e.children&&e.children.length>0&&e.children.forEach(n=>{this.createNodeRecursively(n,i)})}handleNodeSelect(e){if(this.selectedNode===e){e.setSelected(!1),this.selectedNode=null,this.onNodeDeselect&&this.onNodeDeselect(e);return}this.selectedNode&&this.selectedNode.setSelected(!1),e.setSelected(!0),this.selectedNode=e,this.onNodeSelect&&this.onNodeSelect(e)}handleNodeCheck(e){const t=e.checkState===ni.Checked;if(this.onNodeCheck&&this.onNodeCheck(e),this.options.checkStrictly===!1)return;const i=(r,a)=>{r.children.forEach(o=>{o.config.disabled||(o.setChecked(a,!1),i(o,a))})};t?i(e,ni.Checked):i(e,ni.Unchecked);let n=e.parent;for(;n;){if(n.config.disabled){n=n.parent;continue}const r=n.children,a=r.every(l=>l.checkState===ni.Checked),o=r.every(l=>l.checkState===ni.Unchecked);a?n.setChecked(ni.Checked,!1):o?n.setChecked(ni.Unchecked,!1):n.setChecked(ni.Indeterminate,!1),n=n.parent}}getNode(e){return this.nodeMap.get(e)}checkNode(e,t){const i=this.nodeMap.get(e);i&&i.setChecked(t?ni.Checked:ni.Unchecked,!0)}expandAll(e){this.nodeMap.forEach(t=>t.toggleExpand(e))}checkAllNodes(e){const t=e?ni.Checked:ni.Unchecked;this.nodeMap.forEach(i=>i.setChecked(t,!1,!0))}getCheckedNodes(e=!1){const t=[];return this.nodeMap.forEach(i=>{(i.checkState===ni.Checked||e&&i.checkState===ni.Indeterminate)&&t.push(i.config)}),t}}class f9{element;navElement;contentElement;options;activeId;tabMap=new Map;panelMap=new Map;panelTreeScrollTopMap=new Map;unsubscribeLocale=null;unsubscribeTheme=null;navClickHandler=null;constructor(e){this.options=e,this.activeId=e.activeId||(e.tabs[0]?.id??null),e.tabs.forEach(t=>this.tabMap.set(t.id,t)),this.element=document.createElement("div"),this.element.className="bim-tab",this.navElement=document.createElement("div"),this.navElement.className="bim-tab__nav",this.navElement.setAttribute("role","tablist"),this.element.appendChild(this.navElement),this.contentElement=document.createElement("div"),this.contentElement.className="bim-tab__content",this.element.appendChild(this.contentElement),this.options.container.appendChild(this.element)}init(){this.renderNav(),this.renderPanels(),this.setLocales(),this.setTheme(ct.getTheme()),this.unsubscribeLocale=Zt.subscribe(()=>this.setLocales()),this.unsubscribeTheme=ct.subscribe(e=>this.setTheme(e))}renderNav(){this.navElement.innerHTML="",this.navClickHandler=e=>{const t=e.target.closest(".bim-tab__item");if(!t)return;const i=t.dataset.id;!i||this.tabMap.get(i)?.disabled||this.activateTab(i)},this.navElement.addEventListener("click",this.navClickHandler),this.options.tabs.forEach(e=>{const t=document.createElement("button");if(t.type="button",t.className="bim-tab__item",t.dataset.id=e.id,t.setAttribute("role","tab"),t.id=`tab-${e.id}`,t.setAttribute("aria-selected",`${e.id===this.activeId}`),e.disabled&&(t.disabled=!0,t.setAttribute("aria-disabled","true"),t.classList.add("is-disabled")),e.icon){const n=document.createElement("span");n.className="bim-tab__icon",n.innerHTML=e.icon,t.appendChild(n)}const i=document.createElement("span");i.className="bim-tab__title",i.textContent=this.resolveTitle(e.title),t.appendChild(i),e.id===this.activeId&&t.classList.add("is-active"),this.navElement.appendChild(t)})}renderPanels(){this.contentElement.innerHTML="",this.panelMap.clear(),this.options.tabs.forEach(e=>{const t=document.createElement("div");t.className="bim-tab__panel",t.dataset.id=e.id,t.setAttribute("role","tabpanel"),t.setAttribute("aria-labelledby",`tab-${e.id}`),e.content instanceof HTMLElement?t.appendChild(e.content):typeof e.content=="string"&&(t.innerHTML=e.content),e.id===this.activeId?t.classList.add("is-active"):t.style.display="none",this.panelMap.set(e.id,t),this.contentElement.appendChild(t)})}activateTab(e){if(this.activeId===e)return;const t=this.tabMap.get(e);if(!t||t.disabled)return;this.activeId=e,this.navElement.querySelectorAll(".bim-tab__item").forEach(n=>{const r=n.dataset.id===e;n.classList.toggle("is-active",r),n.setAttribute("aria-selected",`${r}`)}),this.panelMap.forEach((n,r)=>{const a=r===e;a||this.savePanelTreeScrollTop(r,n),n.classList.toggle("is-active",a),n.style.display=a?"":"none",a&&this.restorePanelTreeScrollTop(r,n)}),this.options.onChange&&this.options.onChange(e,t)}setTheme(e){const t=this.element.style;t.setProperty("--bim-tab-bg",e.bgElevated),t.setProperty("--bim-tab-nav-bg",e.bgElevated),t.setProperty("--bim-tab-text",e.textPrimary),t.setProperty("--bim-tab-text-secondary",e.textSecondary),t.setProperty("--bim-tab-text-active",e.primary),t.setProperty("--bim-tab-border",e.borderDefault),t.setProperty("--bim-tab-hover-bg",e.componentBgHover),t.setProperty("--bim-tab-active-bg",e.componentBgActive),t.setProperty("--bim-tab-icon",e.iconDefault)}setLocales(){this.navElement.querySelectorAll(".bim-tab__item").forEach(t=>{const i=t.dataset.id;if(!i)return;const n=this.tabMap.get(i);if(!n)return;const r=t.querySelector(".bim-tab__title");r&&(r.textContent=this.resolveTitle(n.title))})}destroy(){this.navClickHandler&&(this.navElement.removeEventListener("click",this.navClickHandler),this.navClickHandler=null),this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.panelMap.clear(),this.panelTreeScrollTopMap.clear(),this.tabMap.clear(),this.element.remove()}savePanelTreeScrollTop(e,t){const i=t.querySelector(".bim-tree-content");i&&this.panelTreeScrollTopMap.set(e,i.scrollTop)}restorePanelTreeScrollTop(e,t){const i=this.panelTreeScrollTopMap.get(e);if(i===void 0)return;const n=t.querySelector(".bim-tree-content");n&&requestAnimationFrame(()=>{n.scrollTop=i})}resolveTitle(e){try{return Se(e)||e}catch{return e}}}function Z2(s,e){let t=e>>>0;for(let i=0;i<s.length;i++){const n=s.charCodeAt(i);t^=n&255,t=Math.imul(t,16777619),t^=n>>>8&255,t=Math.imul(t,16777619)}return t>>>0}async function m9(s){const e=JSON.stringify(s),t=Z2(e,2166136261),i=Z2(e,522970236);return`${t.toString(16).padStart(8,"0")}${i.toString(16).padStart(8,"0")}`}function Y2(s){const e=new Map,t=n=>{const r=n.config.data,a=r?._modelUrl;if(a&&r?.ids?.length){let o=e.get(a);o||(o=new Set,e.set(a,o));for(const l of r.ids){const c=Number(l);Number.isFinite(c)&&o.add(c)}}for(const o of n.children||[])t(o)};t(s);const i=[];for(const[n,r]of e)r.size>0&&i.push({url:n,ids:Array.from(r)});return i}let g9=0;async function v9(s){if(!s||s.length===0)return[];const e=async(t,i)=>{const n=t.children&&t.children.length>0;let r;return t.ids?.length?r=await m9(t.ids):t.id?r=t.id:r=`node_${++g9}`,{id:r,label:t.name||"未命名",expanded:!1,checked:!0,children:n?await Promise.all(t.children.map(a=>e(a,i))):void 0,data:{...t,_modelUrl:i}}};return Promise.all(s.map(async t=>{const i=t.children&&t.children.length>0,n=t.url;return{id:n,label:t.name||"模型",expanded:!0,checked:!0,children:i?await Promise.all(t.children.map(r=>e(r,n))):void 0,data:{_modelUrl:n}}}))}class y9 extends jn{toolbar=null;toolbarContainer=null;container;dialog=null;constructor(e,t){super(t),this.container=e,this.init()}init(){this.toolbarContainer=document.createElement("div"),this.toolbarContainer.id="bim-construct-tree",this.container.appendChild(this.toolbarContainer),this.toolbar=new d9({container:this.toolbarContainer,showLabel:!1,direction:"column",position:"top-left",align:"vertical",expand:"up",registry:this.registry}),this.toolbar.init(),this.toolbar.addGroup("construct-tree"),this.toolbar.addButton({id:"construct-tree-btn",groupId:"construct-tree",type:"button",label:"construct-tree",icon:Tt("目录树"),onClick:()=>{this.openConstructTreeDialog()}}),this.toolbar.render()}async openConstructTreeDialog(){this.setVisible(!1);const e=this.engineComponent?.getLevelTreeData()??[],t=this.engineComponent?.getTypeTreeData()??[],i=this.engineComponent?.getMajorTreeData()??[];console.log("[ConstructTree] 原始数据 (Level):",e),console.log("[ConstructTree] 原始数据 (Type):",t),console.log("[ConstructTree] 原始数据 (Major):",i);const n=async(g,m)=>{const f=await v9(g);console.log(`[ConstructTree] 转换后数据 (${m}):`,f);const y=new p9({data:f,checkable:!0,indent:0,enableSearch:!0,checkStrictly:!0,defaultExpandAll:!0,onNodeCheck:x=>{const _=Y2(x);_.length&&(x.checkState===ni.Checked?this.engineComponent?.showModel(_):this.engineComponent?.hideModels(_))},onNodeSelect:x=>{const _=Y2(x);_.length&&(this.engineComponent?.unhighlightAllModels(),this.engineComponent?.highlightModel(_),this.engineComponent?.viewScaleToModel(_))},onNodeDeselect:()=>{this.engineComponent?.unhighlightAllModels()},onNodeExpand:()=>{this.dialog?.fitWidth()}});return y.init(),y},r=await n(e,"Level"),a=await n(t,"Type"),o=await n(i,"Major"),l=document.createElement("div");l.className="construct-tab__panel-content",l.appendChild(r.element);const c=document.createElement("div");c.className="construct-tab__panel-content",c.appendChild(a.element);const h=document.createElement("div");h.className="construct-tab__panel-content",h.appendChild(o.element);const d=document.createElement("div");d.className="construct-tab__container",d.style.height="100%",d.style.overflow="hidden";const p=()=>{this.engineComponent?.showAllModels(),r.checkAllNodes(!0),a.checkAllNodes(!0),o.checkAllNodes(!0)},u=new f9({container:d,tabs:[{id:"component",title:"tab.component",content:l},{id:"type",title:"tab.type",content:c},{id:"major",title:"tab.major",content:h}],activeId:"component",onChange:()=>{this.dialog?.fitWidth()}});u.init(),p();const v=this.registry.on("menu:show-all",()=>{p()});this.dialog=this.registry.dialog.create({title:"constructTree.title",minWidth:320,height:600,content:d,position:{x:20,y:20},resizable:!1,onClose:()=>{v(),u.destroy(),r.destroy(),a.destroy(),o.destroy(),this.setVisible(!0)}}),this.dialog?.fitWidth()}refresh(){this.toolbar?.render()}destroy(){this.toolbar?.destroy(),this.toolbar=null,super.destroy()}addGroup(e,t){this.toolbar?.addGroup(e,t),this.toolbar?.render()}addButton(e){this.toolbar?.addButton(e),this.toolbar?.render()}setButtonVisibility(e,t){this.toolbar?.updateButtonVisibility(e,t)}setShowLabel(e){this.toolbar?.setShowLabel(e)}setVisible(e){this.toolbarContainer&&(this.toolbarContainer.style.visibility=e?"visible":"hidden")}setBackgroundColor(e){this.toolbar?.setBackgroundColor(e)}setColors(e){this.toolbar?.setColors(e)}}class x9{events=new Map;on(e,t){return this.events.has(e)||this.events.set(e,[]),this.events.get(e).push(t),()=>this.off(e,t)}off(e,t){const i=this.events.get(e);if(!i)return;const n=i.indexOf(t);n!==-1&&i.splice(n,1)}emit(e,t){const i=this.events.get(e);i&&i.forEach(n=>{try{n(t)}catch(r){console.error(`[EventEmitter] Error in listener for event "${e}":`,r)}})}clear(){this.events.clear()}}class Sm{eventEmitter=new x9;container=null;wrapper=null;toolbar=null;dialog=null;engine3d=null;buttonGroup=null;rightKey=null;constructTree=null;measure=null;walkControl=null;sectionPlane=null;sectionAxis=null;sectionBox=null;walkPath=null;walkPlanView=null;engineInfo=null;componentDetail=null;aiChat=null;setting=null;radialToolbar=null;bottomDock=null;measureDock=null;sectionDock=null;walkDock=null;constructor(){}reset(){this.eventEmitter.clear(),this.container=null,this.wrapper=null,this.toolbar=null,this.dialog=null,this.engine3d=null,this.buttonGroup=null,this.rightKey=null,this.constructTree=null,this.measure=null,this.walkControl=null,this.sectionPlane=null,this.sectionAxis=null,this.sectionBox=null,this.walkPath=null,this.walkPlanView=null,this.engineInfo=null,this.componentDetail=null,this.aiChat=null,this.setting=null,this.radialToolbar=null,this.bottomDock=null,this.measureDock=null,this.sectionDock=null,this.walkDock=null}emit(e,t){this.eventEmitter.emit(e,t)}on(e,t){return this.eventEmitter.on(e,t)}off(e,t){this.eventEmitter.off(e,t)}clearEvents(){this.eventEmitter.clear()}}class _9{container;wrapper=null;sizeEl=null;resizeObserver=null;lastSyncedWidth=-1;lastSyncedHeight=-1;registry;dialog=null;engine=null;rightKey=null;radialToolbar=null;bottomDock=null;measureDock=null;sectionDock=null;walkDock=null;measure=null;sectionPlane=null;sectionAxis=null;sectionBox=null;walkControl=null;engineInfo=null;componentDetail=null;aiChat=null;setting=null;constructTreeBtn=null;handleWindowResize=()=>{this.updateClientSizeDisplay()};constructor(e,t){const i=typeof e=="string"?document.getElementById(e):e;if(!i)throw new Error("Container not found");this.container=i,this.registry=new Sm,t?.locale&&Zt.setLocale(t.locale),t?.theme&&(t.theme==="custom"?console.warn("Custom theme should be set via setCustomTheme()."):ct.setTheme(t.theme)),this.init()}emit(e,t){this.registry.emit(e,t)}on(e,t){return this.registry.on(e,t)}setLocale(e){Zt.setLocale(e)}getLocale(){return Zt.getLocale()}setTheme(e){ct.setTheme(e)}setCustomTheme(e){ct.setCustomTheme(e)}init(){this.container.innerHTML="",this.wrapper=document.createElement("div"),this.wrapper.className="bim-engine-wrapper",this.container.appendChild(this.wrapper);const e=document.createElement("div");e.className="bim-engine-version",e.textContent="v2.5.1",this.wrapper.appendChild(e),this.sizeEl=document.createElement("div"),this.sizeEl.className="bim-engine-size",this.wrapper.appendChild(this.sizeEl),this.updateClientSizeDisplay(),this.bindSizeObserver(),this.registry.container=this.container,this.registry.wrapper=this.wrapper,this.engine=new E2(this.wrapper,this.registry),this.dialog=new gy(this.wrapper,this.registry),this.rightKey=new ay(this.wrapper,this.registry),this.bottomDock=new A2(this.wrapper,this.registry),this.registry.bottomDock=this.bottomDock,this.measureDock=new D2(this.registry),this.registry.measureDock=this.measureDock,this.measureDock.init(),this.sectionDock=new N2(this.registry),this.registry.sectionDock=this.sectionDock,this.sectionDock.init(),this.walkDock=new U2(this.registry),this.registry.walkDock=this.walkDock,this.walkDock.init(),this.radialToolbar=new C2(this.wrapper,this.registry),this.measure=new B2(this.registry),this.sectionPlane=new F2(this.registry),this.sectionAxis=new z2(this.registry),this.sectionBox=new V2(this.registry),this.walkControl=new G2(this.registry),this.walkControl.init(),this.engineInfo=new W2(this.registry),this.engineInfo.init(),this.registry.engine3d=this.engine,this.registry.dialog=this.dialog,this.registry.rightKey=this.rightKey,this.registry.radialToolbar=this.radialToolbar,this.registry.measure=this.measure,this.registry.sectionPlane=this.sectionPlane,this.registry.sectionAxis=this.sectionAxis,this.registry.sectionBox=this.sectionBox,this.registry.walkControl=this.walkControl,this.registry.engineInfo=this.engineInfo,this.componentDetail=new j2(this.registry),this.registry.componentDetail=this.componentDetail,this.componentDetail.init(),this.aiChat=new q2(this.registry),this.registry.aiChat=this.aiChat,this.aiChat.init(),this.constructTreeBtn=new y9(this.wrapper,this.registry),this.registry.constructTree=this.constructTreeBtn,this.setting=new Rr(this.registry),this.registry.setting=this.setting,this.setting.init(),this.updateTheme(ct.getTheme()),ct.subscribe(t=>{this.updateTheme(t)})}updateTheme(e){this.wrapper&&(this.wrapper.style.color=e.textPrimary)}updateClientSizeDisplay(){const e=this.container.clientWidth,t=this.container.clientHeight;this.sizeEl&&(this.sizeEl.textContent=`${e}px x ${t}px`),this.syncEngineSize(e,t)}syncEngineSize(e,t){e<=0||t<=0||e===this.lastSyncedWidth&&t===this.lastSyncedHeight||(this.lastSyncedWidth=e,this.lastSyncedHeight=t,this.engine?.getEngineComponent()?.resize(e,t))}bindSizeObserver(){if(typeof ResizeObserver<"u"){this.resizeObserver=new ResizeObserver(()=>{this.updateClientSizeDisplay()}),this.resizeObserver.observe(this.container);return}window.addEventListener("resize",this.handleWindowResize)}unbindSizeObserver(){if(this.resizeObserver){this.resizeObserver.disconnect(),this.resizeObserver=null;return}window.removeEventListener("resize",this.handleWindowResize)}destroy(){this.unbindSizeObserver(),this.radialToolbar?.destroy(),this.measureDock?.destroy(),this.sectionDock?.destroy(),this.walkDock?.destroy(),this.bottomDock?.destroy(),this.engine?.destroy(),this.dialog?.destroy(),this.rightKey?.destroy(),this.measure?.destroy(),this.sectionPlane?.destroy(),this.sectionAxis?.destroy(),this.sectionBox?.destroy(),this.walkControl?.destroy(),this.constructTreeBtn?.destroy(),this.aiChat?.destroy(),this.setting?.destroy(),this.sizeEl=null,this.lastSyncedWidth=-1,this.lastSyncedHeight=-1,this.container.innerHTML="",this.registry.reset()}}class b9{container;wrapper=null;sizeEl=null;resizeObserver=null;lastSyncedWidth=-1;lastSyncedHeight=-1;unsubscribeTheme=null;registry;dialog=null;engine=null;rightKey=null;radialToolbar=null;bottomDock=null;measureDock=null;sectionDock=null;walkDock=null;measure=null;sectionPlane=null;sectionAxis=null;sectionBox=null;walkControl=null;engineInfo=null;componentDetail=null;aiChat=null;setting=null;handleWindowResize=()=>{this.updateClientSizeDisplay()};constructor(e,t){const i=typeof e=="string"?document.getElementById(e):e;if(!i)throw new Error("Container not found");this.container=i,this.registry=new Sm,t?.locale&&Zt.setLocale(t.locale),t?.theme&&(t.theme==="custom"?console.warn("Custom theme should be set via setCustomTheme()."):ct.setTheme(t.theme)),this.init()}emit(e,t){this.registry.emit(e,t)}on(e,t){return this.registry.on(e,t)}setLocale(e){Zt.setLocale(e)}getLocale(){return Zt.getLocale()}setTheme(e){ct.setTheme(e)}setCustomTheme(e){ct.setCustomTheme(e)}init(){this.container.innerHTML="",this.wrapper=document.createElement("div"),this.wrapper.className="bim-engine-wrapper",this.container.appendChild(this.wrapper);const e=document.createElement("div");e.className="bim-engine-version",e.textContent="v2.5.1",this.wrapper.appendChild(e),this.sizeEl=document.createElement("div"),this.sizeEl.className="bim-engine-size",this.wrapper.appendChild(this.sizeEl),this.updateClientSizeDisplay(),this.bindSizeObserver(),this.registry.container=this.container,this.registry.wrapper=this.wrapper,this.engine=new E2(this.wrapper,this.registry),this.dialog=new gy(this.wrapper,this.registry),this.rightKey=new ay(this.wrapper,this.registry),this.bottomDock=new A2(this.wrapper,this.registry),this.registry.bottomDock=this.bottomDock,this.registry.engine3d=this.engine,this.registry.dialog=this.dialog,this.registry.rightKey=this.rightKey,this.measureDock=new D2(this.registry),this.registry.measureDock=this.measureDock,this.measureDock.init(),this.sectionDock=new N2(this.registry),this.registry.sectionDock=this.sectionDock,this.sectionDock.init(),this.walkDock=new U2(this.registry),this.registry.walkDock=this.walkDock,this.walkDock.init(),this.radialToolbar=new C2(this.wrapper,this.registry),this.measure=new B2(this.registry),this.sectionPlane=new F2(this.registry),this.sectionAxis=new z2(this.registry),this.sectionBox=new V2(this.registry),this.walkControl=new G2(this.registry),this.walkControl.init(),this.engineInfo=new W2(this.registry),this.engineInfo.init(),this.registry.radialToolbar=this.radialToolbar,this.registry.measure=this.measure,this.registry.sectionPlane=this.sectionPlane,this.registry.sectionAxis=this.sectionAxis,this.registry.sectionBox=this.sectionBox,this.registry.walkControl=this.walkControl,this.registry.engineInfo=this.engineInfo,this.componentDetail=new j2(this.registry),this.registry.componentDetail=this.componentDetail,this.componentDetail.init(),this.aiChat=new q2(this.registry),this.registry.aiChat=this.aiChat,this.aiChat.init(),this.setting=new Rr(this.registry),this.registry.setting=this.setting,this.setting.init(),this.updateTheme(ct.getTheme()),this.unsubscribeTheme=ct.subscribe(t=>{this.updateTheme(t)})}updateTheme(e){this.wrapper&&(this.wrapper.style.color=e.textPrimary)}updateClientSizeDisplay(){const e=this.container.clientWidth,t=this.container.clientHeight;this.sizeEl&&(this.sizeEl.textContent=`${e}px x ${t}px`),this.syncEngineSize(e,t)}syncEngineSize(e,t){e<=0||t<=0||e===this.lastSyncedWidth&&t===this.lastSyncedHeight||(this.lastSyncedWidth=e,this.lastSyncedHeight=t,this.engine?.getEngineComponent()?.resize(e,t))}bindSizeObserver(){if(typeof ResizeObserver<"u"){this.resizeObserver=new ResizeObserver(()=>{this.updateClientSizeDisplay()}),this.resizeObserver.observe(this.container);return}window.addEventListener("resize",this.handleWindowResize)}unbindSizeObserver(){if(this.resizeObserver){this.resizeObserver.disconnect(),this.resizeObserver=null;return}window.removeEventListener("resize",this.handleWindowResize)}destroy(){this.unbindSizeObserver(),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.radialToolbar?.destroy(),this.measureDock?.destroy(),this.sectionDock?.destroy(),this.walkDock?.destroy(),this.bottomDock?.destroy(),this.engine?.destroy(),this.dialog?.destroy(),this.rightKey?.destroy(),this.measure?.destroy(),this.sectionPlane?.destroy(),this.sectionAxis?.destroy(),this.sectionBox?.destroy(),this.walkControl?.destroy(),this.aiChat?.destroy(),this.setting?.destroy(),this.sizeEl=null,this.lastSyncedWidth=-1,this.lastSyncedHeight=-1,this.container.innerHTML="",this.registry.reset()}}class M9{engine=null;registry;container;containerId;options;_isInitialized=!1;_isDestroyed=!1;unsubscribeTheme=null;constructor(e,t){this.registry=t,this.container=e.container,this.container.id?this.containerId=this.container.id:(this.containerId=`engine2d-container-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,this.container.id=this.containerId),this.options={backgroundColor:e.backgroundColor??1710618,gridEnabled:e.gridEnabled??!0,axesEnabled:e.axesEnabled??!0,selectionColor:e.selectionColor,highlightColor:e.highlightColor,enablePerformanceMonitoring:e.enablePerformanceMonitoring??!0}}init(){if(this._isInitialized){console.warn("[Engine2d] Engine already initialized.");return}if(this._isDestroyed){console.error("[Engine2d] Cannot initialize destroyed engine.");return}try{const e={containerId:this.containerId,backgroundColor:this.options.backgroundColor,gridEnabled:this.options.gridEnabled,axesEnabled:this.options.axesEnabled};if(this.options.selectionColor!==void 0&&(e.selectionColor=this.options.selectionColor),this.options.highlightColor!==void 0&&(e.highlightColor=this.options.highlightColor),this.options.enablePerformanceMonitoring!==void 0&&(e.enablePerformanceMonitoring=this.options.enablePerformanceMonitoring),console.log("[Engine2d] 引擎配置信息:",e),this.engine=Fz(e),!this.engine)throw new Error("Failed to create 2D engine instance");this._isInitialized=!0,this.unsubscribeTheme=ct.subscribe(t=>{this.setTheme(t)}),this.setTheme(ct.getTheme()),this.engine.events&&(this.engine.events.on("entity-click",t=>{console.log("[Engine2d] 实体点击:",t),this.registry.emit("engine2d:entity-clicked",{data:t})}),this.engine.events.on("layer-visibility-changed",t=>{console.log("[Engine2d] 图层可见性变更:",t),this.registry.emit("engine2d:layer-changed",{data:t})}))}catch(e){throw console.error("[Engine2d] Failed to initialize 2D engine:",e),this._isInitialized=!1,e}}setTheme(e){}setLocales(){}isInitialized(){return this._isInitialized}async loadDrawing(e,t){if(!this._isInitialized||!this.engine){console.error("[Engine2d] Engine not initialized. Please call init() first.");return}if(!e){console.error("[Engine2d] Drawing URL is required.");return}try{console.log("[Engine2d] 开始加载图纸:",e),await this.engine.loadModel(e,t),console.log("[Engine2d] 图纸加载完成:",e),this.registry.emit("engine2d:drawing-loaded",{url:e})}catch(i){throw console.error("[Engine2d] 图纸加载失败:",i),i}}getLayers(){if(!this._isInitialized||!this.engine)return[];try{return this.engine.getLayers?.()??[]}catch(e){return console.warn("[Engine2d] Failed to get layers:",e),[]}}setLayerVisible(e,t){if(!this._isInitialized||!this.engine){console.warn("[Engine2d] Engine not initialized.");return}try{this.engine.setLayerVisible?.(e,t)}catch(i){console.warn("[Engine2d] Failed to set layer visibility:",i)}}resetView(){if(!(!this._isInitialized||!this.engine))try{this.engine.resetView?.()}catch(e){console.warn("[Engine2d] Failed to reset view:",e)}}fitToView(){if(!(!this._isInitialized||!this.engine))try{this.engine.fitToView?.()}catch(e){console.warn("[Engine2d] Failed to fit to view:",e)}}setZoom(e){!this._isInitialized||!this.engine||this.engine.setZoom?.(e)}getZoom(){return!this._isInitialized||!this.engine?1:this.engine.getZoom?.()??1}setBackgroundColor(e){!this._isInitialized||!this.engine||this.engine.setBackgroundColor?.(e)}clearScene(){!this._isInitialized||!this.engine||this.engine.clearScene?.()}resize(){!this._isInitialized||!this.engine||this.engine.resize?.()}onRawEvent(e,t){this.engine?.events?.on(e,t)}offRawEvent(e,t){this.engine?.events?.off(e,t)}destroy(){if(!this._isDestroyed){if(this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.engine){try{this.engine.dispose?.()}catch(e){console.warn("[Engine2d] Error during dispose:",e)}this.engine=null}this.container.innerHTML="",this._isDestroyed=!0,this._isInitialized=!1}}}class S9{container;registry;engineComponent=null;constructor(e,t){const i=typeof e=="string"?document.getElementById(e):e;if(!i)throw new Error("Container not found");this.container=i,this.registry=new Sm,t?.locale&&Zt.setLocale(t.locale),t?.theme&&t.theme!=="custom"&&ct.setTheme(t.theme),this.engineComponent=new M9({container:this.container,backgroundColor:t?.backgroundColor,gridEnabled:t?.gridEnabled,axesEnabled:t?.axesEnabled,selectionColor:t?.selectionColor,highlightColor:t?.highlightColor,enablePerformanceMonitoring:t?.enablePerformanceMonitoring},this.registry),this.engineComponent.init()}async loadDrawing(e,t){return this.engineComponent?.loadDrawing(e,t)}getLayers(){return this.engineComponent?.getLayers()??[]}setLayerVisible(e,t){this.engineComponent?.setLayerVisible(e,t)}resetView(){this.engineComponent?.resetView()}fitToView(){this.engineComponent?.fitToView()}setZoom(e){this.engineComponent?.setZoom(e)}getZoom(){return this.engineComponent?.getZoom()??1}setTheme(e){ct.setTheme(e)}on(e,t){return this.registry.on(e,t)}off(e,t){this.registry.off(e,t)}onRawEvent(e,t){this.engineComponent?.onRawEvent(e,t)}offRawEvent(e,t){this.engineComponent?.offRawEvent(e,t)}destroy(){this.engineComponent?.destroy(),this.engineComponent=null,this.registry.reset()}}class w9{engine=null;registry;container;containerId;options;_isInitialized=!1;_isDestroyed=!1;unsubscribeTheme=null;constructor(e,t){this.registry=t,this.container=e.container,this.container.id?this.containerId=this.container.id:(this.containerId=`engine720-container-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,this.container.id=this.containerId),this.options={fov:e.fov??75,enableZoom:e.enableZoom??!0,enableRotate:e.enableRotate??!0,sphereRadius:e.sphereRadius??500,rotateSpeed:e.rotateSpeed,zoomSpeed:e.zoomSpeed,enableDamping:e.enableDamping,dampingFactor:e.dampingFactor,minFov:e.minFov,maxFov:e.maxFov}}init(){if(this._isInitialized){console.warn("[Engine720] Engine already initialized.");return}if(this._isDestroyed){console.error("[Engine720] Cannot initialize destroyed engine.");return}try{const e={containerId:this.containerId,fov:this.options.fov,enableZoom:this.options.enableZoom,enableRotate:this.options.enableRotate,sphereRadius:this.options.sphereRadius};if(this.options.rotateSpeed!==void 0&&(e.rotateSpeed=this.options.rotateSpeed),this.options.zoomSpeed!==void 0&&(e.zoomSpeed=this.options.zoomSpeed),this.options.enableDamping!==void 0&&(e.enableDamping=this.options.enableDamping),this.options.dampingFactor!==void 0&&(e.dampingFactor=this.options.dampingFactor),this.options.minFov!==void 0&&(e.minFov=this.options.minFov),this.options.maxFov!==void 0&&(e.maxFov=this.options.maxFov),console.log("[Engine720] 引擎配置信息:",e),this.engine=zz(e),!this.engine)throw new Error("Failed to create 720 engine instance");this._isInitialized=!0,this.unsubscribeTheme=ct.subscribe(t=>{this.setTheme(t)}),this.setTheme(ct.getTheme()),this.engine.events&&(this.engine.events.on("panorama-loaded",t=>{console.log("[Engine720] 全景加载完成:",t),this.registry.emit("engine720:panorama-loaded",{data:t})}),this.engine.events.on("panorama-load-error",t=>{console.error("[Engine720] 全景加载失败:",t),this.registry.emit("engine720:load-error",{data:t})}),this.engine.events.on("annotation-click",t=>{console.log("[Engine720] 标注点击:",t),this.registry.emit("engine720:annotation-click",{data:t})}),this.engine.events.on("view-angle-changed",t=>{this.registry.emit("engine720:view-changed",{data:t})}))}catch(e){throw console.error("[Engine720] Failed to initialize 720 engine:",e),this._isInitialized=!1,e}}setTheme(e){!this._isInitialized||this.engine}setLocales(){}isInitialized(){return this._isInitialized}async loadPanorama(e,t){if(!this._isInitialized||!this.engine){console.error("[Engine720] Engine not initialized. Please call init() first.");return}if(!e){console.error("[Engine720] Panorama URL is required.");return}try{console.log("[Engine720] 开始加载全景图:",e),await this.engine.loadPanorama(e),console.log("[Engine720] 全景图加载完成:",e)}catch(i){throw console.error("[Engine720] 全景图加载失败:",i),i}}async preloadPanoramas(e){if(!(!this._isInitialized||!this.engine))try{await this.engine.preloadPanoramas?.(e)}catch(t){console.warn("[Engine720] Failed to preload panoramas:",t)}}setFov(e){!this._isInitialized||!this.engine||this.engine.setFov?.(e)}getFov(){return!this._isInitialized||!this.engine?75:this.engine.getFov?.()??75}lookAt(e,t,i){!this._isInitialized||!this.engine||this.engine.lookAt?.(e,t,i)}resetView(){if(!(!this._isInitialized||!this.engine))try{this.engine.lookAt?.(0,0,!0),this.engine.setFov?.(75)}catch(e){console.warn("[Engine720] Failed to reset view:",e)}}pauseRendering(){!this._isInitialized||!this.engine||this.engine.pauseRendering?.()}resumeRendering(){!this._isInitialized||!this.engine||this.engine.resumeRendering?.()}resize(e,t){!this._isInitialized||!this.engine||this.engine.resize?.(e,t)}onRawEvent(e,t){this.engine?.events?.on(e,t)}offRawEvent(e,t){this.engine?.events?.off(e,t)}destroy(){if(!this._isDestroyed){if(this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.engine){try{this.engine.dispose?.()}catch(e){console.warn("[Engine720] Error during dispose:",e)}this.engine=null}this.container.innerHTML="",this._isDestroyed=!0,this._isInitialized=!1}}}class E9{container;registry;engineComponent=null;constructor(e,t){const i=typeof e=="string"?document.getElementById(e):e;if(!i)throw new Error("Container not found");this.container=i,this.registry=new Sm,t?.locale&&Zt.setLocale(t.locale),t?.theme&&t.theme!=="custom"&&ct.setTheme(t.theme),this.engineComponent=new w9({container:this.container,fov:t?.fov,enableZoom:t?.enableZoom,enableRotate:t?.enableRotate,sphereRadius:t?.sphereRadius,rotateSpeed:t?.rotateSpeed,zoomSpeed:t?.zoomSpeed,enableDamping:t?.enableDamping,dampingFactor:t?.dampingFactor,minFov:t?.minFov,maxFov:t?.maxFov},this.registry),this.engineComponent.init()}async loadPanorama(e,t){return this.engineComponent?.loadPanorama(e,t)}async preloadPanoramas(e){return this.engineComponent?.preloadPanoramas(e)}setFov(e){this.engineComponent?.setFov(e)}getFov(){return this.engineComponent?.getFov()??75}lookAt(e,t,i){this.engineComponent?.lookAt(e,t,i)}resetView(){this.engineComponent?.resetView()}setTheme(e){ct.setTheme(e)}on(e,t){return this.registry.on(e,t)}off(e,t){this.registry.off(e,t)}onRawEvent(e,t){this.engineComponent?.onRawEvent(e,t)}offRawEvent(e,t){this.engineComponent?.offRawEvent(e,t)}destroy(){this.engineComponent?.destroy(),this.engineComponent=null,this.registry.reset()}}const T9=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM引擎AI助手 - 需求分析与步骤规划专家\r
9884
+ `}bindQuestionEvents(){this.messagesContainer?.querySelectorAll(".bim-ai-option").forEach(e=>{e.addEventListener("click",t=>{const i=t.currentTarget,n=i.dataset.questionId,r=i.dataset.optionId;if(n&&r){const a=this.messages.find(o=>o.id===n);a&&!a.answered&&(a.selectedOptionId=r,this.renderMessages())}})}),this.messagesContainer?.querySelectorAll(".bim-ai-option-input").forEach(e=>{e.addEventListener("input",t=>{const i=t.target,n=i.dataset.questionId;if(n){const r=this.messages.find(a=>a.id===n);r&&(r.customAnswer=i.value)}})}),this.messagesContainer?.querySelectorAll(".bim-ai-question-submit").forEach(e=>{e.addEventListener("click",t=>{const n=t.currentTarget.dataset.questionId;if(n){const r=this.messages.find(a=>a.id===n);r&&r.selectedOptionId&&(r.answered=!0,this.renderMessages(),this.options.onQuestionSubmit?.(n,r.selectedOptionId,r.customAnswer))}})})}scrollToBottom(){this.messagesContainer&&(this.messagesContainer.scrollTop=this.messagesContainer.scrollHeight)}escapeHtml(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}destroy(){this._isDestroyed||(this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.element.remove(),this._isDestroyed=!0)}}class q2{aiChat=null;registry;initialized=!1;constructor(e){this.registry=e}init(){if(this.initialized)return;const e=this.registry.wrapper;if(!e){console.warn("[AiChatManager] wrapper 不存在,无法初始化");return}this.aiChat=new h9({container:e,width:440,title:"aiChat.title",placeholder:"aiChat.placeholder",quickPrompts:[{id:"summarize",label:"aiChat.quickPrompt.summarize"},{id:"explain",label:"aiChat.quickPrompt.explain"},{id:"generate",label:"aiChat.quickPrompt.generate"}],onSend:t=>{console.log("[AiChatManager] 用户发送消息:",t),this.aiChat?.addUserMessage(t),this.registry.emit("aiChat:message-sent",{message:t})},onQuestionSubmit:(t,i,n)=>{console.log("[AiChatManager] 用户回答问题:",{questionId:t,optionId:i,customAnswer:n}),this.registry.emit("aiChat:question-answered",{questionId:t,optionId:i,customAnswer:n})},onNewChat:()=>{console.log("[AiChatManager] 新建对话"),this.registry.emit("aiChat:new-chat",{})},onHistory:()=>{console.log("[AiChatManager] 打开历史"),this.registry.emit("aiChat:history-opened",{})},onSettings:()=>{console.log("[AiChatManager] 打开设置"),this.registry.emit("aiChat:settings-opened",{})},onClose:()=>{console.log("[AiChatManager] 关闭 AI 聊天"),this.registry.emit("aiChat:closed",{}),this.registry.toolbar?.setBtnActive("aiChat",!1)}}),this.initialized=!0}show(){this.aiChat||this.init(),this.aiChat?.show(),this.registry.emit("aiChat:opened",{}),this.registry.toolbar?.setBtnActive("aiChat",!0)}hide(){this.aiChat?.hide(),this.registry.emit("aiChat:closed",{}),this.registry.toolbar?.setBtnActive("aiChat",!1)}toggle(){this.aiChat?.isVisible()?this.hide():this.show()}isVisible(){return this.aiChat?.isVisible()??!1}addUserMessage(e){return this.aiChat?.addUserMessage(e)??""}addAiMessage(e){return this.aiChat?.addAiMessage(e)??""}addStepMessage(e,t){return this.aiChat?.addStepMessage(e,t)??""}addThinkingMessage(){return this.aiChat?.addThinkingMessage()??""}addQuestionMessage(e,t,i){return this.aiChat?.addQuestionMessage(e,t,i)??""}updateMessage(e,t){this.aiChat?.updateMessage(e,t)}removeMessage(e){this.aiChat?.removeMessage(e)}clearMessages(){this.aiChat?.clearMessages()}destroy(){this.aiChat&&(this.aiChat.destroy(),this.aiChat=null),this.initialized=!1}}class d9{container;options;groups=[];activeBtnIds=new Set;btnRefs=new Map;dropdownElement=null;hoverTimeout=null;customColors=new Set;unsubscribeLocale=null;unsubscribeTheme=null;DEFAULT_ICON='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect></svg>';constructor(e){const t=typeof e.container=="string"?document.getElementById(e.container):e.container;if(!t)throw new Error("Container not found");this.container=t,this.options={showLabel:!0,visibility:{},direction:"row",position:"static",align:"vertical",expand:"down",...e},["backgroundColor","btnBackgroundColor","btnHoverColor","btnActiveColor","iconColor","iconActiveColor","textColor","textActiveColor"].forEach(n=>{e[n]&&this.customColors.add(n)}),this.initContainer(),this.applyStyles()}emit(e,t){this.options.registry?.emit(e,t)}initContainer(){this.container.innerHTML="",this.container.classList.add("bim-btn-group-root"),this.options.direction==="column"?this.container.classList.add("dir-column"):this.container.classList.add("dir-row"),this.options.className&&this.container.classList.add(this.options.className),this.options.type&&this.options.type!=="default"&&this.container.classList.add(`type-${this.options.type}`),this.updatePosition(),this.setupEventInterception(this.container)}setupEventInterception(e){const t=n=>{n.stopPropagation()};["click","dblclick","contextmenu","wheel","mousedown","mouseup","mousemove","touchstart","touchend","touchmove","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointerover","pointerout"].forEach(n=>{e.addEventListener(n,t,{passive:!1})})}updatePosition(){const e=this.options.position,t=this.container.style;if(t.top="",t.bottom="",t.left="",t.right="",t.transform="",e==="static"){this.container.classList.add("static");return}if(this.container.classList.remove("static"),this.container.style.position="absolute",typeof e=="object"&&"x"in e)t.left=`${e.x}px`,t.top=`${e.y}px`;else{const i="20px";switch(e){case"top-left":t.top=i,t.left=i;break;case"top-center":t.top=i,t.left="50%",t.transform="translateX(-50%)";break;case"top-right":t.top=i,t.right=i;break;case"bottom-left":t.bottom=i,t.left=i;break;case"bottom-center":t.bottom=i,t.left="50%",t.transform="translateX(-50%)";break;case"bottom-right":t.bottom=i,t.right=i;break;case"left-center":t.left=i,t.top="50%",t.transform="translateY(-50%)";break;case"right-center":t.right=i,t.top="50%",t.transform="translateY(-50%)";break;case"center":t.top="50%",t.left="50%",t.transform="translate(-50%, -50%)";break}}}applyStyles(){const e=this.container.style;this.options.backgroundColor&&e.setProperty("--bim-btn-group-section-bg",this.options.backgroundColor),this.options.btnBackgroundColor&&e.setProperty("--bim-btn-bg",this.options.btnBackgroundColor),this.options.btnHoverColor&&e.setProperty("--bim-btn-hover-bg",this.options.btnHoverColor),this.options.btnActiveColor&&e.setProperty("--bim-btn-active-bg",this.options.btnActiveColor),this.options.iconColor&&e.setProperty("--bim-icon-color",this.options.iconColor),this.options.iconActiveColor&&e.setProperty("--bim-icon-active-color",this.options.iconActiveColor),this.options.textColor&&e.setProperty("--bim-btn-text-color",this.options.textColor),this.options.textActiveColor&&e.setProperty("--bim-btn-text-active-color",this.options.textActiveColor),document.querySelectorAll(".opt-btn-dropdown").forEach(i=>{const n=i.style;this.options.iconColor&&n.setProperty("--bim-icon-color",this.options.iconColor),this.options.iconActiveColor&&n.setProperty("--bim-icon-active-color",this.options.iconActiveColor),this.options.textColor&&n.setProperty("--bim-btn-text-color",this.options.textColor),this.options.textActiveColor&&n.setProperty("--bim-btn-text-active-color",this.options.textActiveColor),this.options.btnBackgroundColor&&n.setProperty("--bim-btn-bg",this.options.btnBackgroundColor),this.options.btnHoverColor&&n.setProperty("--bim-btn-hover-bg",this.options.btnHoverColor),this.options.btnActiveColor&&n.setProperty("--bim-btn-active-bg",this.options.btnActiveColor)})}setPrimaryColor(e){this.container.style.setProperty("--bim-primary-color",e),document.querySelectorAll(".opt-btn-dropdown").forEach(i=>{i.style.setProperty("--bim-primary-color",e)})}setTheme(e){const t={backgroundColor:e.bgElevated,btnBackgroundColor:e.componentBg,btnHoverColor:e.componentBgHover,btnActiveColor:e.componentBgActive,iconColor:e.iconDefault,iconActiveColor:e.iconActive,textColor:e.textSecondary,textActiveColor:e.textPrimary};Object.entries(t).forEach(([i,n])=>{const r=i;this.customColors.has(r)||(this.options[r]=n)}),this.container.classList.remove("theme-dark","theme-light"),this.container.classList.add(`theme-${e.name}`),this.applyStyles(),this.setPrimaryColor(e.primary),this.applyThemeCssVars(e)}applyThemeCssVars(e){const t=this.container.style;t.setProperty("--bim-primary",e.primary),t.setProperty("--bim-primary-hover",e.primaryHover),t.setProperty("--bim-primary-active",e.primaryActive),t.setProperty("--bim-bg-glass",e.bgGlass),t.setProperty("--bim-bg-glass-blur",e.bgGlassBlur),t.setProperty("--bim-bg-elevated",e.bgElevated),t.setProperty("--bim-bg-overlay",e.bgOverlay),t.setProperty("--bim-bg-inset",e.bgInset),t.setProperty("--bim-text-primary",e.textPrimary),t.setProperty("--bim-text-secondary",e.textSecondary),t.setProperty("--bim-text-tertiary",e.textTertiary),t.setProperty("--bim-text-inverse",e.textInverse),t.setProperty("--bim-icon-default",e.iconDefault),t.setProperty("--bim-icon-hover",e.iconHover),t.setProperty("--bim-icon-active",e.iconActive),t.setProperty("--bim-icon-inverse",e.iconInverse),t.setProperty("--bim-border-default",e.borderDefault),t.setProperty("--bim-border-subtle",e.borderSubtle),t.setProperty("--bim-component-bg-hover",e.componentBgHover),t.setProperty("--bim-component-bg-active",e.componentBgActive),t.setProperty("--bim-shadow-sm",e.shadowSm),t.setProperty("--bim-shadow-md",e.shadowMd),t.setProperty("--bim-shadow-lg",e.shadowLg),t.setProperty("--bim-shadow-glow",e.shadowGlow),t.setProperty("--bim-floating-bg",e.floatingBg),t.setProperty("--bim-floating-border",e.floatingBorder),t.setProperty("--bim-floating-shadow",e.floatingShadow),t.setProperty("--bim-floating-btn-bg",e.floatingBtnBg),t.setProperty("--bim-floating-btn-border",e.floatingBtnBorder),t.setProperty("--bim-floating-btn-shadow",e.floatingBtnShadow),t.setProperty("--bim-floating-btn-bg-hover",e.floatingBtnBgHover),t.setProperty("--bim-floating-btn-shadow-hover",e.floatingBtnShadowHover),t.setProperty("--bim-floating-icon-color",e.floatingIconColor),t.setProperty("--bim-floating-icon-color-hover",e.floatingIconColorHover),this.syncDropdownCssVars(e)}syncDropdownCssVars(e){document.querySelectorAll(".opt-btn-dropdown").forEach(i=>{const n=i.style;n.setProperty("--bim-primary",e.primary),n.setProperty("--bim-bg-overlay",e.bgOverlay),n.setProperty("--bim-border-default",e.borderDefault),n.setProperty("--bim-text-primary",e.textPrimary),n.setProperty("--bim-text-inverse",e.textInverse),n.setProperty("--bim-shadow-lg",e.shadowLg),n.setProperty("--bim-floating-btn-bg",e.floatingBtnBg),n.setProperty("--bim-floating-btn-bg-hover",e.floatingBtnBgHover),n.setProperty("--bim-floating-icon-color",e.floatingIconColor)})}setColors(e){this.options={...this.options,...e},Object.keys(e).forEach(t=>{this.customColors.add(t)}),this.applyStyles()}async init(){this.render(),this.unsubscribeLocale=Zt.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=ct.subscribe(e=>{this.setTheme(e)})}setLocales(){this.render()}addGroup(e,t){if(this.groups.some(n=>n.id===e))return;const i={id:e,buttons:[]};if(t){const n=this.groups.findIndex(r=>r.id===t);n!==-1?this.groups.splice(n,0,i):this.groups.push(i)}else this.groups.push(i)}addButton(e){const{groupId:t,parentId:i}=e,n=this.groups.find(a=>a.id===t);if(!n)return;const r={...e,children:e.children||[]};if(i){const a=this.findButton(n.buttons,i);a&&(a.children||(a.children=[]),a.children.push(r))}else n.buttons.push(r)}findButton(e,t){for(const i of e){if(i.id===t)return i;if(i.children){const n=this.findButton(i.children,t);if(n)return n}}}render(){this.container.innerHTML="",this.btnRefs.clear(),this.groups.forEach((e,t)=>{const i=this.renderGroup(e,t,this.groups.length);this.container.appendChild(i)})}renderGroup(e,t,i){const n=document.createElement("div");return n.className="bim-btn-group-section",t<i-1&&n.classList.add("has-divider"),e.buttons.forEach(r=>{if(this.isVisible(r.id)){const a=this.renderButton(r);n.appendChild(a)}}),n}renderButton(e){const t=document.createElement("div");t.className="opt-btn-wrapper";const i=document.createElement("div");i.className="opt-btn",e.isActive&&this.activeBtnIds.add(e.id),(e.align||this.options.align||"vertical")==="horizontal"?i.classList.add("align-horizontal"):i.classList.add("align-vertical"),this.activeBtnIds.has(e.id)&&i.classList.add("active"),e.disabled&&i.classList.add("disabled"),this.options.showLabel&&e.label||(i.classList.add("no-label"),e.label&&(i.title=Se(e.label)));const a=e.iconSize||32,o=e.minWidth||50;i.style.minWidth=`${o}px`;const l=document.createElement("div");l.className="opt-btn-icon",l.style.width=`${a}px`,l.style.height=`${a}px`,l.innerHTML=this.getIcon(e.icon),i.appendChild(l);const c=document.createElement("div");if(c.className="opt-btn-text-wrapper",this.options.showLabel&&e.label){const h=document.createElement("span");h.className="opt-btn-label",h.textContent=Se(e.label),c.appendChild(h)}return c.hasChildNodes()&&i.appendChild(c),i.addEventListener("click",()=>this.handleClick(e)),i.addEventListener("mouseenter",()=>this.handleMouseEnter(e,i)),i.addEventListener("mouseleave",()=>this.handleMouseLeave()),this.btnRefs.set(e.id,i),t.appendChild(i),t}setBtnActive(e,t){const i=this.findButtonById(e);if(!i)return;const n=t!==void 0?t:!this.activeBtnIds.has(e);n?this.activeBtnIds.add(e):this.activeBtnIds.delete(e),i.isActive=n,this.updateButtonState(e)}handleClick(e){if(!e.disabled&&(!e.children||e.children.length===0)){if(e.keepActive){const i=!this.activeBtnIds.has(e.id);this.setBtnActive(e.id,i),i&&e.exclusive&&e.groupId&&this.deactivateExclusiveSiblings(e)}this.closeDropdown(),e.onClick&&e.onClick(e)}}deactivateExclusiveSiblings(e){const t=this.groups.find(i=>i.id===e.groupId);if(t){if(e.parentId){const n=this.findButton(t.buttons,e.parentId)?.children||[];for(const r of n)r&&r.id!==e.id&&r.parentId===e.parentId&&r.groupId===e.groupId&&this.activeBtnIds.has(r.id)&&(this.setBtnActive(r.id,!1),r.onClick&&r.onClick(r));return}for(const i of t.buttons)i.id!==e.id&&i.groupId===e.groupId&&(i.parentId||this.activeBtnIds.has(i.id)&&(this.setBtnActive(i.id,!1),i.onClick&&i.onClick(i)))}}handleMouseEnter(e,t){this.hoverTimeout&&clearTimeout(this.hoverTimeout),e.children&&e.children.length>0?this.showDropdown(e,t):this.closeDropdown()}handleMouseLeave(){this.hoverTimeout=window.setTimeout(()=>this.closeDropdown(),200)}showDropdown(e,t){if(this.closeDropdown(),!e.children)return;const i=document.createElement("div");i.className="opt-btn-dropdown",this.options.backgroundColor&&i.style.setProperty("--bim-toolbar-bg",this.options.backgroundColor);const n=i.style;this.options.iconColor&&n.setProperty("--bim-icon-color",this.options.iconColor),this.options.iconActiveColor&&n.setProperty("--bim-icon-active-color",this.options.iconActiveColor),this.options.textColor&&n.setProperty("--bim-btn-text-color",this.options.textColor),this.options.textActiveColor&&n.setProperty("--bim-btn-text-active-color",this.options.textActiveColor),this.options.btnBackgroundColor&&n.setProperty("--bim-btn-bg",this.options.btnBackgroundColor),this.options.btnHoverColor&&n.setProperty("--bim-btn-hover-bg",this.options.btnHoverColor),this.options.btnActiveColor&&n.setProperty("--bim-btn-active-bg",this.options.btnActiveColor);const r=t.getBoundingClientRect(),a=this.options.expand||"down";this.options.direction==="row"?i.style.flexDirection="column":i.style.flexDirection="row",this.options.type&&this.options.type!=="default"&&i.classList.add(`type-${this.options.type}`);const o=ct.getTheme();i.classList.add(`theme-${o.name}`),n.setProperty("--bim-primary",o.primary),n.setProperty("--bim-bg-overlay",o.bgOverlay),n.setProperty("--bim-border-default",o.borderDefault),n.setProperty("--bim-text-primary",o.textPrimary),n.setProperty("--bim-text-inverse",o.textInverse),n.setProperty("--bim-shadow-lg",o.shadowLg),n.setProperty("--bim-floating-btn-bg",o.floatingBtnBg),n.setProperty("--bim-floating-btn-bg-hover",o.floatingBtnBgHover),n.setProperty("--bim-floating-icon-color",o.floatingIconColor),document.body.appendChild(i),this.setupEventInterception(i),e.children.forEach(c=>{if(this.isVisible(c.id)){const h=this.renderDropdownItem(c);i.appendChild(h)}});const l=i.getBoundingClientRect();a==="up"?(i.style.bottom=window.innerHeight-r.top+8+"px",i.style.left=r.left+(r.width-l.width)/2+"px"):a==="down"?(i.style.top=r.bottom+8+"px",i.style.left=r.left+(r.width-l.width)/2+"px"):a==="right"?(i.style.top=r.top+(r.height-l.height)/2+"px",i.style.left=r.right+8+"px"):a==="left"&&(i.style.top=r.top+(r.height-l.height)/2+"px",i.style.right=window.innerWidth-r.left+8+"px"),i.addEventListener("mouseenter",()=>{this.hoverTimeout&&clearTimeout(this.hoverTimeout)}),i.addEventListener("mouseleave",()=>this.handleMouseLeave()),this.dropdownElement=i}renderDropdownItem(e){const t=document.createElement("div");t.className="opt-btn-dropdown-item",(e.align||"horizontal")==="horizontal"?t.classList.add("align-horizontal"):t.classList.add("align-vertical"),(this.activeBtnIds.has(e.id)||e.isActive)&&t.classList.add("active");const n=e.iconSize||32,r=e.minWidth;r&&(t.style.minWidth=`${r}px`);const a=document.createElement("div");if(a.className="opt-btn-icon",a.style.width=`${n}px`,a.style.height=`${n}px`,a.innerHTML=this.getIcon(e.icon),t.appendChild(a),this.options.showLabel&&e.label){const o=document.createElement("span");o.className="opt-btn-dropdown-label",o.textContent=Se(e.label),t.appendChild(o)}else e.label&&(t.title=Se(e.label));return t.addEventListener("click",o=>{o.stopPropagation(),this.handleClick(e)}),t}closeDropdown(){this.dropdownElement&&(this.dropdownElement.remove(),this.dropdownElement=null),this.btnRefs.forEach(e=>{const t=e.querySelector(".opt-btn-arrow");t&&t.classList.remove("rotated")})}updateButtonState(e){const t=this.btnRefs.get(e);t&&(this.activeBtnIds.has(e)?t.classList.add("active"):t.classList.remove("active"))}getIcon(e){return e||this.DEFAULT_ICON}updateButtonIcon(e,t){const i=this.btnRefs.get(e);if(!i)return;const n=i.querySelector(".opt-btn-icon");n&&(n.innerHTML=this.getIcon(t));const r=this.findButtonById(e);r&&(r.icon=t)}updateButtonVisibility(e,t){this.options.visibility||(this.options.visibility={}),this.options.visibility[e]=t,this.render()}setShowLabel(e){this.options.showLabel=e,this.updateLabelsVisibility()}updateLabelsVisibility(){this.btnRefs.forEach((e,t)=>{const i=this.findButtonById(t);if(!i)return;this.options.showLabel&&i.label?(e.classList.remove("no-label"),e.removeAttribute("title")):(e.classList.add("no-label"),i.label&&(e.title=Se(i.label)))})}findButtonById(e){for(const t of this.groups){const i=this.findButton(t.buttons,e);if(i)return i}}setBackgroundColor(e){this.setColors({backgroundColor:e})}isVisible(e){return this.options.visibility?.[e]!==!1}setType(e){this.container.classList.remove("type-default","type-glass-pill"),this.options.type=e,e&&e!=="default"&&this.container.classList.add(`type-${e}`),this.render()}getType(){return this.options.type||"default"}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.closeDropdown(),this.container.innerHTML="",this.btnRefs.clear()}}var ni=(s=>(s[s.Unchecked=0]="Unchecked",s[s.Checked=1]="Checked",s[s.Indeterminate=2]="Indeterminate",s))(ni||{});class u9{config;element;children=[];parent=null;checkState=ni.Unchecked;contentEl;switcherEl;checkboxEl=null;titleEl;actionsEl;childrenContainer;onExpandChange;onCheckChange;onNodeClick;renderActions;constructor(e,t,i){this.config=e,this.onExpandChange=i.onExpand,this.onCheckChange=i.onCheck,this.onNodeClick=i.onClick,this.renderActions=t.renderActions,this.checkState=e.checked?ni.Checked:ni.Unchecked,this.element=this.createDom(t)}createDom(e){const t=document.createElement("div");t.className="bim-tree-node",this.config.disabled&&t.classList.add("is-disabled"),this.contentEl=document.createElement("div"),this.contentEl.className="bim-tree-node-content",this.switcherEl=document.createElement("span"),this.switcherEl.className="bim-tree-switcher",this.switcherEl.innerHTML='<svg viewBox="0 0 1024 1024"><path d="M288 192l448 320-448 320z"></path></svg>';const i=this.config.children&&this.config.children.length>0;if(i?this.config.expanded&&this.switcherEl.classList.add("is-expanded"):this.switcherEl.classList.add("is-hidden"),this.switcherEl.addEventListener("click",r=>{r.stopPropagation(),this.toggleExpand()}),this.contentEl.appendChild(this.switcherEl),e.checkable!==!1&&(this.checkboxEl=document.createElement("span"),this.checkboxEl.className="bim-tree-checkbox",this.updateCheckboxUI(),this.checkboxEl.addEventListener("click",r=>{r.stopPropagation(),!this.config.disabled&&this.toggleCheck()}),this.contentEl.appendChild(this.checkboxEl)),this.config.icon){const r=document.createElement("span");r.className="bim-tree-icon",r.innerHTML=this.config.icon.includes("<svg")?this.config.icon:`<img src="${this.config.icon}" />`,this.contentEl.appendChild(r)}this.titleEl=document.createElement("span"),this.titleEl.className="bim-tree-title",this.updateLabel(),this.contentEl.appendChild(this.titleEl),this.actionsEl=document.createElement("div"),this.actionsEl.className="bim-tree-node-actions",this.actionsEl.addEventListener("click",r=>{r.stopPropagation()}),this.contentEl.appendChild(this.actionsEl),this.contentEl.addEventListener("click",r=>{if(r.stopPropagation(),this.config.disabled)return;(this.config.clickAction||"select")==="expand"?this.toggleExpand():this.onNodeClick(this)}),t.appendChild(this.contentEl),this.childrenContainer=document.createElement("div"),this.childrenContainer.className="bim-tree-children";const n=e.indent||24;return this.childrenContainer.style.paddingLeft=`${n}px`,this.config.expanded&&i&&this.childrenContainer.classList.add("is-visible"),t.appendChild(this.childrenContainer),t}setSelected(e){if(e){if(this.contentEl.classList.add("is-selected"),this.renderActions){const t=this.renderActions(this.config);this.actionsEl.innerHTML="",typeof t=="string"?this.actionsEl.innerHTML=t:t instanceof HTMLElement&&this.actionsEl.appendChild(t)}}else this.contentEl.classList.remove("is-selected"),this.actionsEl.innerHTML=""}updateLabel(){this.titleEl&&(this.titleEl.textContent=this.config.label)}toggleExpand(e){if(!this.config.children||this.config.children.length===0)return;const t=e!==void 0?e:!this.config.expanded;this.config.expanded=t,t?(this.switcherEl.classList.add("is-expanded"),this.childrenContainer.classList.add("is-visible")):(this.switcherEl.classList.remove("is-expanded"),this.childrenContainer.classList.remove("is-visible")),e===void 0&&this.onExpandChange(this)}toggleCheck(){const e=this.checkState!==ni.Checked;this.setChecked(e?ni.Checked:ni.Unchecked,!0)}setChecked(e,t=!1,i=!1){!i&&this.checkState===e||(this.checkState=e,this.config.checked=e===ni.Checked,this.updateCheckboxUI(),t&&this.onCheckChange(this))}updateCheckboxUI(){this.checkboxEl&&(this.checkboxEl.classList.remove("is-checked","is-indeterminate"),this.checkState===ni.Checked?this.checkboxEl.classList.add("is-checked"):this.checkState===ni.Indeterminate&&this.checkboxEl.classList.add("is-indeterminate"))}appendChild(e){e.parent=this,this.children.push(e),this.childrenContainer.appendChild(e.element),this.children.length===1&&this.switcherEl.classList.remove("is-hidden")}destroy(){this.children.forEach(e=>e.destroy()),this.children=[],this.element.remove(),this.parent=null}}class p9{element;contentElement;searchInput=null;searchResults=null;options;nodeMap=new Map;rootNodes=[];selectedNode=null;lastRevealedNodeId=null;unsubscribeLocale=null;unsubscribeTheme=null;clickOutsideHandler=null;onNodeCheck;onNodeSelect;onNodeDeselect;onNodeExpand;constructor(e){this.options={checkable:!0,checkStrictly:!0,indent:24,defaultExpandAll:!0,enableSearch:!1,searchPlaceholder:"tree.searchPlaceholder",...e},this.element=document.createElement("div"),this.element.className="bim-tree",this.options.enableSearch&&this.createSearchDOM(),this.contentElement=document.createElement("div"),this.contentElement.className="bim-tree-content",this.element.appendChild(this.contentElement),e.onNodeCheck&&(this.onNodeCheck=e.onNodeCheck),e.onNodeSelect&&(this.onNodeSelect=e.onNodeSelect),e.onNodeDeselect&&(this.onNodeDeselect=e.onNodeDeselect),e.onNodeExpand&&(this.onNodeExpand=e.onNodeExpand)}createSearchDOM(){const e=document.createElement("div");e.className="bim-tree-search";const t=document.createElement("div");t.className="bim-tree-search-wrapper";const i=document.createElement("span");i.className="bim-tree-search-icon",i.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="m21 21l-4.343-4.343m0 0A8 8 0 1 0 5.343 5.343a8 8 0 0 0 11.314 11.314"/></svg>',t.appendChild(i),this.searchInput=document.createElement("input"),this.searchInput.className="bim-tree-search-input",this.searchInput.type="text",this.searchInput.placeholder=Se(this.options.searchPlaceholder||"搜索..."),this.searchInput.addEventListener("input",n=>{const r=n.target.value;this.handleSearch(r)}),t.appendChild(this.searchInput),e.appendChild(t),this.searchResults=document.createElement("div"),this.searchResults.className="bim-tree-search-results",e.appendChild(this.searchResults),this.element.appendChild(e),this.clickOutsideHandler=n=>{this.searchResults&&!this.searchResults.contains(n.target)&&!this.searchInput?.contains(n.target)&&this.searchResults.classList.remove("is-visible")},document.addEventListener("click",this.clickOutsideHandler)}init(){this.render(),this.unsubscribeLocale=Zt.subscribe(()=>this.setLocales()),this.unsubscribeTheme=ct.subscribe(e=>this.setTheme(e)),this.setTheme(ct.getTheme())}handleSearch(e){if(!this.searchResults)return;if(!e.trim()){this.searchResults.classList.remove("is-visible"),this.searchResults.innerHTML="";return}const t=[],i=e.toLowerCase();this.nodeMap.forEach(n=>{const r=n.config.label;r.toLowerCase().includes(i)&&t.push({node:n,label:r,path:this.getNodePath(n)})}),this.renderSearchResults(t)}getNodePath(e){const t=[];let i=e.parent;for(;i;)t.unshift(i.config.label),i=i.parent;return t.join(" > ")}renderSearchResults(e){if(this.searchResults){if(this.searchResults.innerHTML="",e.length===0){const t=document.createElement("div");t.className="bim-tree-search-item",t.style.cursor="default",t.style.color="#999",t.textContent="No results",this.searchResults.appendChild(t)}else e.forEach(t=>{const i=document.createElement("div");i.className="bim-tree-search-item";const n=document.createElement("span");n.className="bim-tree-search-item-title",n.textContent=t.label;const r=document.createElement("span");r.className="bim-tree-search-item-path",r.textContent=t.path,i.appendChild(n),t.path&&i.appendChild(r),i.addEventListener("click",()=>{this.revealNode(t.node)}),this.searchResults.appendChild(i)});this.searchResults.classList.add("is-visible")}}revealNode(e){if(this.lastRevealedNodeId===e.config.id&&this.isNodeFullyVisible(e))return;this.lastRevealedNodeId=e.config.id,this.searchResults&&(this.searchResults.classList.remove("is-visible"),this.searchInput&&(this.searchInput.value=""));let t=e.parent;for(;t;)t.toggleExpand(!0),t=t.parent;this.handleNodeSelect(e),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.scrollNodeIntoContentCenter(e)})})}isNodeFullyVisible(e){const t=this.contentElement;if(!t||!e?.element?.isConnected)return!1;const i=t.getBoundingClientRect(),n=e.element.getBoundingClientRect();return n.top>=i.top&&n.bottom<=i.bottom}scrollNodeIntoContentCenter(e){const t=this.contentElement;if(!t||!e?.element?.isConnected)return;const i=t.getBoundingClientRect(),n=e.element.getBoundingClientRect();if(n.top>=i.top&&n.bottom<=i.bottom)return;const r=n.top-i.top+t.scrollTop,a=Math.max(0,r-(t.clientHeight-n.height)/2);t.scrollTo({top:a,behavior:"auto"})}setTheme(e){const t=this.element.style;t.setProperty("--bim-primary",e.primary),t.setProperty("--bim-bg-elevated",e.bgElevated),t.setProperty("--bim-text-primary",e.textPrimary),t.setProperty("--bim-text-secondary",e.textSecondary),t.setProperty("--bim-text-tertiary",e.textTertiary),t.setProperty("--bim-text-disabled",e.textDisabled),t.setProperty("--bim-text-inverse",e.textInverse),t.setProperty("--bim-border-default",e.borderDefault),t.setProperty("--bim-border-disabled",e.borderDisabled),t.setProperty("--bim-component-bg-hover",e.componentBgHover),t.setProperty("--bim-component-bg-selected",e.componentBgSelected),t.setProperty("--bim-component-bg-disabled",e.componentBgDisabled),t.setProperty("--bim-shadow-md",e.shadowMd),t.setProperty("--bim-focus-ring",e.focusRing)}setLocales(){this.nodeMap.forEach(e=>e.updateLabel()),this.searchInput&&(this.searchInput.placeholder=Se(this.options.searchPlaceholder||"tree.searchPlaceholder"))}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null),this.rootNodes.forEach(e=>e.destroy()),this.rootNodes=[],this.nodeMap.clear(),this.lastRevealedNodeId=null,this.element.remove(),this.selectedNode=null}render(){this.contentElement.innerHTML="",this.nodeMap.clear(),this.rootNodes=[],this.options.data.forEach(e=>{this.createNodeRecursively(e,null)})}createNodeRecursively(e,t){e.expanded===void 0&&(e.expanded=this.options.defaultExpandAll);const i=new u9(e,this.options,{onExpand:n=>{this.onNodeExpand&&this.onNodeExpand(n)},onCheck:n=>this.handleNodeCheck(n),onClick:n=>this.handleNodeSelect(n)});this.nodeMap.set(e.id,i),t?t.appendChild(i):(this.rootNodes.push(i),this.contentElement.appendChild(i.element)),e.children&&e.children.length>0&&e.children.forEach(n=>{this.createNodeRecursively(n,i)})}handleNodeSelect(e){if(this.selectedNode===e){e.setSelected(!1),this.selectedNode=null,this.onNodeDeselect&&this.onNodeDeselect(e);return}this.selectedNode&&this.selectedNode.setSelected(!1),e.setSelected(!0),this.selectedNode=e,this.onNodeSelect&&this.onNodeSelect(e)}handleNodeCheck(e){const t=e.checkState===ni.Checked;if(this.onNodeCheck&&this.onNodeCheck(e),this.options.checkStrictly===!1)return;const i=(r,a)=>{r.children.forEach(o=>{o.config.disabled||(o.setChecked(a,!1),i(o,a))})};t?i(e,ni.Checked):i(e,ni.Unchecked);let n=e.parent;for(;n;){if(n.config.disabled){n=n.parent;continue}const r=n.children,a=r.every(l=>l.checkState===ni.Checked),o=r.every(l=>l.checkState===ni.Unchecked);a?n.setChecked(ni.Checked,!1):o?n.setChecked(ni.Unchecked,!1):n.setChecked(ni.Indeterminate,!1),n=n.parent}}getNode(e){return this.nodeMap.get(e)}checkNode(e,t){const i=this.nodeMap.get(e);i&&i.setChecked(t?ni.Checked:ni.Unchecked,!0)}expandAll(e){this.nodeMap.forEach(t=>t.toggleExpand(e))}checkAllNodes(e){const t=e?ni.Checked:ni.Unchecked;this.nodeMap.forEach(i=>i.setChecked(t,!1,!0))}getCheckedNodes(e=!1){const t=[];return this.nodeMap.forEach(i=>{(i.checkState===ni.Checked||e&&i.checkState===ni.Indeterminate)&&t.push(i.config)}),t}}class f9{element;navElement;contentElement;options;activeId;tabMap=new Map;panelMap=new Map;panelTreeScrollTopMap=new Map;unsubscribeLocale=null;unsubscribeTheme=null;navClickHandler=null;constructor(e){this.options=e,this.activeId=e.activeId||(e.tabs[0]?.id??null),e.tabs.forEach(t=>this.tabMap.set(t.id,t)),this.element=document.createElement("div"),this.element.className="bim-tab",this.navElement=document.createElement("div"),this.navElement.className="bim-tab__nav",this.navElement.setAttribute("role","tablist"),this.element.appendChild(this.navElement),this.contentElement=document.createElement("div"),this.contentElement.className="bim-tab__content",this.element.appendChild(this.contentElement),this.options.container.appendChild(this.element)}init(){this.renderNav(),this.renderPanels(),this.setLocales(),this.setTheme(ct.getTheme()),this.unsubscribeLocale=Zt.subscribe(()=>this.setLocales()),this.unsubscribeTheme=ct.subscribe(e=>this.setTheme(e))}renderNav(){this.navElement.innerHTML="",this.navClickHandler=e=>{const t=e.target.closest(".bim-tab__item");if(!t)return;const i=t.dataset.id;!i||this.tabMap.get(i)?.disabled||this.activateTab(i)},this.navElement.addEventListener("click",this.navClickHandler),this.options.tabs.forEach(e=>{const t=document.createElement("button");if(t.type="button",t.className="bim-tab__item",t.dataset.id=e.id,t.setAttribute("role","tab"),t.id=`tab-${e.id}`,t.setAttribute("aria-selected",`${e.id===this.activeId}`),e.disabled&&(t.disabled=!0,t.setAttribute("aria-disabled","true"),t.classList.add("is-disabled")),e.icon){const n=document.createElement("span");n.className="bim-tab__icon",n.innerHTML=e.icon,t.appendChild(n)}const i=document.createElement("span");i.className="bim-tab__title",i.textContent=this.resolveTitle(e.title),t.appendChild(i),e.id===this.activeId&&t.classList.add("is-active"),this.navElement.appendChild(t)})}renderPanels(){this.contentElement.innerHTML="",this.panelMap.clear(),this.options.tabs.forEach(e=>{const t=document.createElement("div");t.className="bim-tab__panel",t.dataset.id=e.id,t.setAttribute("role","tabpanel"),t.setAttribute("aria-labelledby",`tab-${e.id}`),e.content instanceof HTMLElement?t.appendChild(e.content):typeof e.content=="string"&&(t.innerHTML=e.content),e.id===this.activeId?t.classList.add("is-active"):t.style.display="none",this.panelMap.set(e.id,t),this.contentElement.appendChild(t)})}activateTab(e){if(this.activeId===e)return;const t=this.tabMap.get(e);if(!t||t.disabled)return;this.activeId=e,this.navElement.querySelectorAll(".bim-tab__item").forEach(n=>{const r=n.dataset.id===e;n.classList.toggle("is-active",r),n.setAttribute("aria-selected",`${r}`)}),this.panelMap.forEach((n,r)=>{const a=r===e;a||this.savePanelTreeScrollTop(r,n),n.classList.toggle("is-active",a),n.style.display=a?"":"none",a&&this.restorePanelTreeScrollTop(r,n)}),this.options.onChange&&this.options.onChange(e,t)}setTheme(e){const t=this.element.style;t.setProperty("--bim-tab-bg",e.bgElevated),t.setProperty("--bim-tab-nav-bg",e.bgElevated),t.setProperty("--bim-tab-text",e.textPrimary),t.setProperty("--bim-tab-text-secondary",e.textSecondary),t.setProperty("--bim-tab-text-active",e.primary),t.setProperty("--bim-tab-border",e.borderDefault),t.setProperty("--bim-tab-hover-bg",e.componentBgHover),t.setProperty("--bim-tab-active-bg",e.componentBgActive),t.setProperty("--bim-tab-icon",e.iconDefault)}setLocales(){this.navElement.querySelectorAll(".bim-tab__item").forEach(t=>{const i=t.dataset.id;if(!i)return;const n=this.tabMap.get(i);if(!n)return;const r=t.querySelector(".bim-tab__title");r&&(r.textContent=this.resolveTitle(n.title))})}destroy(){this.navClickHandler&&(this.navElement.removeEventListener("click",this.navClickHandler),this.navClickHandler=null),this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.panelMap.clear(),this.panelTreeScrollTopMap.clear(),this.tabMap.clear(),this.element.remove()}savePanelTreeScrollTop(e,t){const i=t.querySelector(".bim-tree-content");i&&this.panelTreeScrollTopMap.set(e,i.scrollTop)}restorePanelTreeScrollTop(e,t){const i=this.panelTreeScrollTopMap.get(e);if(i===void 0)return;const n=t.querySelector(".bim-tree-content");n&&requestAnimationFrame(()=>{n.scrollTop=i})}resolveTitle(e){try{return Se(e)||e}catch{return e}}}function Z2(s,e){let t=e>>>0;for(let i=0;i<s.length;i++){const n=s.charCodeAt(i);t^=n&255,t=Math.imul(t,16777619),t^=n>>>8&255,t=Math.imul(t,16777619)}return t>>>0}async function m9(s){const e=JSON.stringify(s),t=Z2(e,2166136261),i=Z2(e,522970236);return`${t.toString(16).padStart(8,"0")}${i.toString(16).padStart(8,"0")}`}function Y2(s){const e=new Map,t=n=>{const r=n.config.data,a=r?._modelUrl;if(a&&r?.ids?.length){let o=e.get(a);o||(o=new Set,e.set(a,o));for(const l of r.ids){const c=Number(l);Number.isFinite(c)&&o.add(c)}}for(const o of n.children||[])t(o)};t(s);const i=[];for(const[n,r]of e)r.size>0&&i.push({url:n,ids:Array.from(r)});return i}let g9=0;async function v9(s){if(!s||s.length===0)return[];const e=async(t,i)=>{const n=t.children&&t.children.length>0;let r;return t.ids?.length?r=await m9(t.ids):t.id?r=t.id:r=`node_${++g9}`,{id:r,label:t.name||"未命名",expanded:!1,checked:!0,children:n?await Promise.all(t.children.map(a=>e(a,i))):void 0,data:{...t,_modelUrl:i}}};return Promise.all(s.map(async t=>{const i=t.children&&t.children.length>0,n=t.url;return{id:n,label:t.name||"模型",expanded:!0,checked:!0,children:i?await Promise.all(t.children.map(r=>e(r,n))):void 0,data:{_modelUrl:n}}}))}class y9 extends jn{toolbar=null;toolbarContainer=null;container;dialog=null;constructor(e,t){super(t),this.container=e,this.init()}init(){this.toolbarContainer=document.createElement("div"),this.toolbarContainer.id="bim-construct-tree",this.container.appendChild(this.toolbarContainer),this.toolbar=new d9({container:this.toolbarContainer,showLabel:!1,direction:"column",position:"top-left",align:"vertical",expand:"up",registry:this.registry}),this.toolbar.init(),this.toolbar.addGroup("construct-tree"),this.toolbar.addButton({id:"construct-tree-btn",groupId:"construct-tree",type:"button",label:"construct-tree",icon:Tt("目录树"),onClick:()=>{this.openConstructTreeDialog()}}),this.toolbar.render()}async openConstructTreeDialog(){this.setVisible(!1);const e=this.engineComponent?.getLevelTreeData()??[],t=this.engineComponent?.getTypeTreeData()??[],i=this.engineComponent?.getMajorTreeData()??[];console.log("[ConstructTree] 原始数据 (Level):",e),console.log("[ConstructTree] 原始数据 (Type):",t),console.log("[ConstructTree] 原始数据 (Major):",i);const n=async(g,m)=>{const f=await v9(g);console.log(`[ConstructTree] 转换后数据 (${m}):`,f);const y=new p9({data:f,checkable:!0,indent:0,enableSearch:!0,checkStrictly:!0,defaultExpandAll:!0,onNodeCheck:x=>{const _=Y2(x);_.length&&(x.checkState===ni.Checked?this.engineComponent?.showModel(_):this.engineComponent?.hideModels(_))},onNodeSelect:x=>{const _=Y2(x);_.length&&(this.engineComponent?.unhighlightAllModels(),this.engineComponent?.highlightModel(_),this.engineComponent?.viewScaleToModel(_))},onNodeDeselect:()=>{this.engineComponent?.unhighlightAllModels()},onNodeExpand:()=>{this.dialog?.fitWidth()}});return y.init(),y},r=await n(e,"Level"),a=await n(t,"Type"),o=await n(i,"Major"),l=document.createElement("div");l.className="construct-tab__panel-content",l.appendChild(r.element);const c=document.createElement("div");c.className="construct-tab__panel-content",c.appendChild(a.element);const h=document.createElement("div");h.className="construct-tab__panel-content",h.appendChild(o.element);const d=document.createElement("div");d.className="construct-tab__container",d.style.height="100%",d.style.overflow="hidden";const p=()=>{this.engineComponent?.showAllModels(),r.checkAllNodes(!0),a.checkAllNodes(!0),o.checkAllNodes(!0)},u=new f9({container:d,tabs:[{id:"component",title:"tab.component",content:l},{id:"type",title:"tab.type",content:c},{id:"major",title:"tab.major",content:h}],activeId:"component",onChange:()=>{this.dialog?.fitWidth()}});u.init(),p();const v=this.registry.on("menu:show-all",()=>{p()});this.dialog=this.registry.dialog.create({title:"constructTree.title",minWidth:320,height:600,content:d,position:{x:20,y:20},resizable:!1,onClose:()=>{v(),u.destroy(),r.destroy(),a.destroy(),o.destroy(),this.setVisible(!0)}}),this.dialog?.fitWidth()}refresh(){this.toolbar?.render()}destroy(){this.toolbar?.destroy(),this.toolbar=null,super.destroy()}addGroup(e,t){this.toolbar?.addGroup(e,t),this.toolbar?.render()}addButton(e){this.toolbar?.addButton(e),this.toolbar?.render()}setButtonVisibility(e,t){this.toolbar?.updateButtonVisibility(e,t)}setShowLabel(e){this.toolbar?.setShowLabel(e)}setVisible(e){this.toolbarContainer&&(this.toolbarContainer.style.visibility=e?"visible":"hidden")}setBackgroundColor(e){this.toolbar?.setBackgroundColor(e)}setColors(e){this.toolbar?.setColors(e)}}class x9{events=new Map;on(e,t){return this.events.has(e)||this.events.set(e,[]),this.events.get(e).push(t),()=>this.off(e,t)}off(e,t){const i=this.events.get(e);if(!i)return;const n=i.indexOf(t);n!==-1&&i.splice(n,1)}emit(e,t){const i=this.events.get(e);i&&i.forEach(n=>{try{n(t)}catch(r){console.error(`[EventEmitter] Error in listener for event "${e}":`,r)}})}clear(){this.events.clear()}}class Sm{eventEmitter=new x9;container=null;wrapper=null;toolbar=null;dialog=null;engine3d=null;buttonGroup=null;rightKey=null;constructTree=null;measure=null;walkControl=null;sectionPlane=null;sectionAxis=null;sectionBox=null;walkPath=null;walkPlanView=null;engineInfo=null;componentDetail=null;aiChat=null;setting=null;radialToolbar=null;bottomDock=null;measureDock=null;sectionDock=null;walkDock=null;constructor(){}reset(){this.eventEmitter.clear(),this.container=null,this.wrapper=null,this.toolbar=null,this.dialog=null,this.engine3d=null,this.buttonGroup=null,this.rightKey=null,this.constructTree=null,this.measure=null,this.walkControl=null,this.sectionPlane=null,this.sectionAxis=null,this.sectionBox=null,this.walkPath=null,this.walkPlanView=null,this.engineInfo=null,this.componentDetail=null,this.aiChat=null,this.setting=null,this.radialToolbar=null,this.bottomDock=null,this.measureDock=null,this.sectionDock=null,this.walkDock=null}emit(e,t){this.eventEmitter.emit(e,t)}on(e,t){return this.eventEmitter.on(e,t)}off(e,t){this.eventEmitter.off(e,t)}clearEvents(){this.eventEmitter.clear()}}class _9{container;wrapper=null;sizeEl=null;resizeObserver=null;lastSyncedWidth=-1;lastSyncedHeight=-1;registry;dialog=null;engine=null;rightKey=null;radialToolbar=null;bottomDock=null;measureDock=null;sectionDock=null;walkDock=null;measure=null;sectionPlane=null;sectionAxis=null;sectionBox=null;walkControl=null;engineInfo=null;componentDetail=null;aiChat=null;setting=null;constructTreeBtn=null;handleWindowResize=()=>{this.updateClientSizeDisplay()};constructor(e,t){const i=typeof e=="string"?document.getElementById(e):e;if(!i)throw new Error("Container not found");this.container=i,this.registry=new Sm,t?.locale&&Zt.setLocale(t.locale),t?.theme&&(t.theme==="custom"?console.warn("Custom theme should be set via setCustomTheme()."):ct.setTheme(t.theme)),this.init()}emit(e,t){this.registry.emit(e,t)}on(e,t){return this.registry.on(e,t)}setLocale(e){Zt.setLocale(e)}getLocale(){return Zt.getLocale()}setTheme(e){ct.setTheme(e)}setCustomTheme(e){ct.setCustomTheme(e)}init(){this.container.innerHTML="",this.wrapper=document.createElement("div"),this.wrapper.className="bim-engine-wrapper",this.container.appendChild(this.wrapper);const e=document.createElement("div");e.className="bim-engine-version",e.textContent="v2.5.2",this.wrapper.appendChild(e),this.sizeEl=document.createElement("div"),this.sizeEl.className="bim-engine-size",this.wrapper.appendChild(this.sizeEl),this.updateClientSizeDisplay(),this.bindSizeObserver(),this.registry.container=this.container,this.registry.wrapper=this.wrapper,this.engine=new E2(this.wrapper,this.registry),this.dialog=new gy(this.wrapper,this.registry),this.rightKey=new ay(this.wrapper,this.registry),this.bottomDock=new A2(this.wrapper,this.registry),this.registry.bottomDock=this.bottomDock,this.measureDock=new D2(this.registry),this.registry.measureDock=this.measureDock,this.measureDock.init(),this.sectionDock=new N2(this.registry),this.registry.sectionDock=this.sectionDock,this.sectionDock.init(),this.walkDock=new U2(this.registry),this.registry.walkDock=this.walkDock,this.walkDock.init(),this.radialToolbar=new C2(this.wrapper,this.registry),this.measure=new B2(this.registry),this.sectionPlane=new F2(this.registry),this.sectionAxis=new z2(this.registry),this.sectionBox=new V2(this.registry),this.walkControl=new G2(this.registry),this.walkControl.init(),this.engineInfo=new W2(this.registry),this.engineInfo.init(),this.registry.engine3d=this.engine,this.registry.dialog=this.dialog,this.registry.rightKey=this.rightKey,this.registry.radialToolbar=this.radialToolbar,this.registry.measure=this.measure,this.registry.sectionPlane=this.sectionPlane,this.registry.sectionAxis=this.sectionAxis,this.registry.sectionBox=this.sectionBox,this.registry.walkControl=this.walkControl,this.registry.engineInfo=this.engineInfo,this.componentDetail=new j2(this.registry),this.registry.componentDetail=this.componentDetail,this.componentDetail.init(),this.aiChat=new q2(this.registry),this.registry.aiChat=this.aiChat,this.aiChat.init(),this.constructTreeBtn=new y9(this.wrapper,this.registry),this.registry.constructTree=this.constructTreeBtn,this.setting=new Rr(this.registry),this.registry.setting=this.setting,this.setting.init(),this.updateTheme(ct.getTheme()),ct.subscribe(t=>{this.updateTheme(t)})}updateTheme(e){this.wrapper&&(this.wrapper.style.color=e.textPrimary)}updateClientSizeDisplay(){const e=this.container.clientWidth,t=this.container.clientHeight;this.sizeEl&&(this.sizeEl.textContent=`${e}px x ${t}px`),this.syncEngineSize(e,t)}syncEngineSize(e,t){e<=0||t<=0||e===this.lastSyncedWidth&&t===this.lastSyncedHeight||(this.lastSyncedWidth=e,this.lastSyncedHeight=t,this.engine?.getEngineComponent()?.resize(e,t))}bindSizeObserver(){if(typeof ResizeObserver<"u"){this.resizeObserver=new ResizeObserver(()=>{this.updateClientSizeDisplay()}),this.resizeObserver.observe(this.container);return}window.addEventListener("resize",this.handleWindowResize)}unbindSizeObserver(){if(this.resizeObserver){this.resizeObserver.disconnect(),this.resizeObserver=null;return}window.removeEventListener("resize",this.handleWindowResize)}destroy(){this.unbindSizeObserver(),this.radialToolbar?.destroy(),this.measureDock?.destroy(),this.sectionDock?.destroy(),this.walkDock?.destroy(),this.bottomDock?.destroy(),this.engine?.destroy(),this.dialog?.destroy(),this.rightKey?.destroy(),this.measure?.destroy(),this.sectionPlane?.destroy(),this.sectionAxis?.destroy(),this.sectionBox?.destroy(),this.walkControl?.destroy(),this.constructTreeBtn?.destroy(),this.aiChat?.destroy(),this.setting?.destroy(),this.sizeEl=null,this.lastSyncedWidth=-1,this.lastSyncedHeight=-1,this.container.innerHTML="",this.registry.reset()}}class b9{container;wrapper=null;sizeEl=null;resizeObserver=null;lastSyncedWidth=-1;lastSyncedHeight=-1;unsubscribeTheme=null;registry;dialog=null;engine=null;rightKey=null;radialToolbar=null;bottomDock=null;measureDock=null;sectionDock=null;walkDock=null;measure=null;sectionPlane=null;sectionAxis=null;sectionBox=null;walkControl=null;engineInfo=null;componentDetail=null;aiChat=null;setting=null;handleWindowResize=()=>{this.updateClientSizeDisplay()};constructor(e,t){const i=typeof e=="string"?document.getElementById(e):e;if(!i)throw new Error("Container not found");this.container=i,this.registry=new Sm,t?.locale&&Zt.setLocale(t.locale),t?.theme&&(t.theme==="custom"?console.warn("Custom theme should be set via setCustomTheme()."):ct.setTheme(t.theme)),this.init()}emit(e,t){this.registry.emit(e,t)}on(e,t){return this.registry.on(e,t)}setLocale(e){Zt.setLocale(e)}getLocale(){return Zt.getLocale()}setTheme(e){ct.setTheme(e)}setCustomTheme(e){ct.setCustomTheme(e)}init(){this.container.innerHTML="",this.wrapper=document.createElement("div"),this.wrapper.className="bim-engine-wrapper",this.container.appendChild(this.wrapper);const e=document.createElement("div");e.className="bim-engine-version",e.textContent="v2.5.2",this.wrapper.appendChild(e),this.sizeEl=document.createElement("div"),this.sizeEl.className="bim-engine-size",this.wrapper.appendChild(this.sizeEl),this.updateClientSizeDisplay(),this.bindSizeObserver(),this.registry.container=this.container,this.registry.wrapper=this.wrapper,this.engine=new E2(this.wrapper,this.registry),this.dialog=new gy(this.wrapper,this.registry),this.rightKey=new ay(this.wrapper,this.registry),this.bottomDock=new A2(this.wrapper,this.registry),this.registry.bottomDock=this.bottomDock,this.registry.engine3d=this.engine,this.registry.dialog=this.dialog,this.registry.rightKey=this.rightKey,this.measureDock=new D2(this.registry),this.registry.measureDock=this.measureDock,this.measureDock.init(),this.sectionDock=new N2(this.registry),this.registry.sectionDock=this.sectionDock,this.sectionDock.init(),this.walkDock=new U2(this.registry),this.registry.walkDock=this.walkDock,this.walkDock.init(),this.radialToolbar=new C2(this.wrapper,this.registry),this.measure=new B2(this.registry),this.sectionPlane=new F2(this.registry),this.sectionAxis=new z2(this.registry),this.sectionBox=new V2(this.registry),this.walkControl=new G2(this.registry),this.walkControl.init(),this.engineInfo=new W2(this.registry),this.engineInfo.init(),this.registry.radialToolbar=this.radialToolbar,this.registry.measure=this.measure,this.registry.sectionPlane=this.sectionPlane,this.registry.sectionAxis=this.sectionAxis,this.registry.sectionBox=this.sectionBox,this.registry.walkControl=this.walkControl,this.registry.engineInfo=this.engineInfo,this.componentDetail=new j2(this.registry),this.registry.componentDetail=this.componentDetail,this.componentDetail.init(),this.aiChat=new q2(this.registry),this.registry.aiChat=this.aiChat,this.aiChat.init(),this.setting=new Rr(this.registry),this.registry.setting=this.setting,this.setting.init(),this.updateTheme(ct.getTheme()),this.unsubscribeTheme=ct.subscribe(t=>{this.updateTheme(t)})}updateTheme(e){this.wrapper&&(this.wrapper.style.color=e.textPrimary)}updateClientSizeDisplay(){const e=this.container.clientWidth,t=this.container.clientHeight;this.sizeEl&&(this.sizeEl.textContent=`${e}px x ${t}px`),this.syncEngineSize(e,t)}syncEngineSize(e,t){e<=0||t<=0||e===this.lastSyncedWidth&&t===this.lastSyncedHeight||(this.lastSyncedWidth=e,this.lastSyncedHeight=t,this.engine?.getEngineComponent()?.resize(e,t))}bindSizeObserver(){if(typeof ResizeObserver<"u"){this.resizeObserver=new ResizeObserver(()=>{this.updateClientSizeDisplay()}),this.resizeObserver.observe(this.container);return}window.addEventListener("resize",this.handleWindowResize)}unbindSizeObserver(){if(this.resizeObserver){this.resizeObserver.disconnect(),this.resizeObserver=null;return}window.removeEventListener("resize",this.handleWindowResize)}destroy(){this.unbindSizeObserver(),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.radialToolbar?.destroy(),this.measureDock?.destroy(),this.sectionDock?.destroy(),this.walkDock?.destroy(),this.bottomDock?.destroy(),this.engine?.destroy(),this.dialog?.destroy(),this.rightKey?.destroy(),this.measure?.destroy(),this.sectionPlane?.destroy(),this.sectionAxis?.destroy(),this.sectionBox?.destroy(),this.walkControl?.destroy(),this.aiChat?.destroy(),this.setting?.destroy(),this.sizeEl=null,this.lastSyncedWidth=-1,this.lastSyncedHeight=-1,this.container.innerHTML="",this.registry.reset()}}class M9{engine=null;registry;container;containerId;options;_isInitialized=!1;_isDestroyed=!1;unsubscribeTheme=null;constructor(e,t){this.registry=t,this.container=e.container,this.container.id?this.containerId=this.container.id:(this.containerId=`engine2d-container-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,this.container.id=this.containerId),this.options={backgroundColor:e.backgroundColor??1710618,gridEnabled:e.gridEnabled??!0,axesEnabled:e.axesEnabled??!0,selectionColor:e.selectionColor,highlightColor:e.highlightColor,enablePerformanceMonitoring:e.enablePerformanceMonitoring??!0}}init(){if(this._isInitialized){console.warn("[Engine2d] Engine already initialized.");return}if(this._isDestroyed){console.error("[Engine2d] Cannot initialize destroyed engine.");return}try{const e={containerId:this.containerId,backgroundColor:this.options.backgroundColor,gridEnabled:this.options.gridEnabled,axesEnabled:this.options.axesEnabled};if(this.options.selectionColor!==void 0&&(e.selectionColor=this.options.selectionColor),this.options.highlightColor!==void 0&&(e.highlightColor=this.options.highlightColor),this.options.enablePerformanceMonitoring!==void 0&&(e.enablePerformanceMonitoring=this.options.enablePerformanceMonitoring),console.log("[Engine2d] 引擎配置信息:",e),this.engine=Fz(e),!this.engine)throw new Error("Failed to create 2D engine instance");this._isInitialized=!0,this.unsubscribeTheme=ct.subscribe(t=>{this.setTheme(t)}),this.setTheme(ct.getTheme()),this.engine.events&&(this.engine.events.on("entity-click",t=>{console.log("[Engine2d] 实体点击:",t),this.registry.emit("engine2d:entity-clicked",{data:t})}),this.engine.events.on("layer-visibility-changed",t=>{console.log("[Engine2d] 图层可见性变更:",t),this.registry.emit("engine2d:layer-changed",{data:t})}))}catch(e){throw console.error("[Engine2d] Failed to initialize 2D engine:",e),this._isInitialized=!1,e}}setTheme(e){}setLocales(){}isInitialized(){return this._isInitialized}async loadDrawing(e,t){if(!this._isInitialized||!this.engine){console.error("[Engine2d] Engine not initialized. Please call init() first.");return}if(!e){console.error("[Engine2d] Drawing URL is required.");return}try{console.log("[Engine2d] 开始加载图纸:",e),await this.engine.loadModel(e,t),console.log("[Engine2d] 图纸加载完成:",e),this.registry.emit("engine2d:drawing-loaded",{url:e})}catch(i){throw console.error("[Engine2d] 图纸加载失败:",i),i}}getLayers(){if(!this._isInitialized||!this.engine)return[];try{return this.engine.getLayers?.()??[]}catch(e){return console.warn("[Engine2d] Failed to get layers:",e),[]}}setLayerVisible(e,t){if(!this._isInitialized||!this.engine){console.warn("[Engine2d] Engine not initialized.");return}try{this.engine.setLayerVisible?.(e,t)}catch(i){console.warn("[Engine2d] Failed to set layer visibility:",i)}}resetView(){if(!(!this._isInitialized||!this.engine))try{this.engine.resetView?.()}catch(e){console.warn("[Engine2d] Failed to reset view:",e)}}fitToView(){if(!(!this._isInitialized||!this.engine))try{this.engine.fitToView?.()}catch(e){console.warn("[Engine2d] Failed to fit to view:",e)}}setZoom(e){!this._isInitialized||!this.engine||this.engine.setZoom?.(e)}getZoom(){return!this._isInitialized||!this.engine?1:this.engine.getZoom?.()??1}setBackgroundColor(e){!this._isInitialized||!this.engine||this.engine.setBackgroundColor?.(e)}clearScene(){!this._isInitialized||!this.engine||this.engine.clearScene?.()}resize(){!this._isInitialized||!this.engine||this.engine.resize?.()}onRawEvent(e,t){this.engine?.events?.on(e,t)}offRawEvent(e,t){this.engine?.events?.off(e,t)}destroy(){if(!this._isDestroyed){if(this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.engine){try{this.engine.dispose?.()}catch(e){console.warn("[Engine2d] Error during dispose:",e)}this.engine=null}this.container.innerHTML="",this._isDestroyed=!0,this._isInitialized=!1}}}class S9{container;registry;engineComponent=null;constructor(e,t){const i=typeof e=="string"?document.getElementById(e):e;if(!i)throw new Error("Container not found");this.container=i,this.registry=new Sm,t?.locale&&Zt.setLocale(t.locale),t?.theme&&t.theme!=="custom"&&ct.setTheme(t.theme),this.engineComponent=new M9({container:this.container,backgroundColor:t?.backgroundColor,gridEnabled:t?.gridEnabled,axesEnabled:t?.axesEnabled,selectionColor:t?.selectionColor,highlightColor:t?.highlightColor,enablePerformanceMonitoring:t?.enablePerformanceMonitoring},this.registry),this.engineComponent.init()}async loadDrawing(e,t){return this.engineComponent?.loadDrawing(e,t)}getLayers(){return this.engineComponent?.getLayers()??[]}setLayerVisible(e,t){this.engineComponent?.setLayerVisible(e,t)}resetView(){this.engineComponent?.resetView()}fitToView(){this.engineComponent?.fitToView()}setZoom(e){this.engineComponent?.setZoom(e)}getZoom(){return this.engineComponent?.getZoom()??1}setTheme(e){ct.setTheme(e)}on(e,t){return this.registry.on(e,t)}off(e,t){this.registry.off(e,t)}onRawEvent(e,t){this.engineComponent?.onRawEvent(e,t)}offRawEvent(e,t){this.engineComponent?.offRawEvent(e,t)}destroy(){this.engineComponent?.destroy(),this.engineComponent=null,this.registry.reset()}}class w9{engine=null;registry;container;containerId;options;_isInitialized=!1;_isDestroyed=!1;unsubscribeTheme=null;constructor(e,t){this.registry=t,this.container=e.container,this.container.id?this.containerId=this.container.id:(this.containerId=`engine720-container-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,this.container.id=this.containerId),this.options={fov:e.fov??75,enableZoom:e.enableZoom??!0,enableRotate:e.enableRotate??!0,sphereRadius:e.sphereRadius??500,rotateSpeed:e.rotateSpeed,zoomSpeed:e.zoomSpeed,enableDamping:e.enableDamping,dampingFactor:e.dampingFactor,minFov:e.minFov,maxFov:e.maxFov}}init(){if(this._isInitialized){console.warn("[Engine720] Engine already initialized.");return}if(this._isDestroyed){console.error("[Engine720] Cannot initialize destroyed engine.");return}try{const e={containerId:this.containerId,fov:this.options.fov,enableZoom:this.options.enableZoom,enableRotate:this.options.enableRotate,sphereRadius:this.options.sphereRadius};if(this.options.rotateSpeed!==void 0&&(e.rotateSpeed=this.options.rotateSpeed),this.options.zoomSpeed!==void 0&&(e.zoomSpeed=this.options.zoomSpeed),this.options.enableDamping!==void 0&&(e.enableDamping=this.options.enableDamping),this.options.dampingFactor!==void 0&&(e.dampingFactor=this.options.dampingFactor),this.options.minFov!==void 0&&(e.minFov=this.options.minFov),this.options.maxFov!==void 0&&(e.maxFov=this.options.maxFov),console.log("[Engine720] 引擎配置信息:",e),this.engine=zz(e),!this.engine)throw new Error("Failed to create 720 engine instance");this._isInitialized=!0,this.unsubscribeTheme=ct.subscribe(t=>{this.setTheme(t)}),this.setTheme(ct.getTheme()),this.engine.events&&(this.engine.events.on("panorama-loaded",t=>{console.log("[Engine720] 全景加载完成:",t),this.registry.emit("engine720:panorama-loaded",{data:t})}),this.engine.events.on("panorama-load-error",t=>{console.error("[Engine720] 全景加载失败:",t),this.registry.emit("engine720:load-error",{data:t})}),this.engine.events.on("annotation-click",t=>{console.log("[Engine720] 标注点击:",t),this.registry.emit("engine720:annotation-click",{data:t})}),this.engine.events.on("view-angle-changed",t=>{this.registry.emit("engine720:view-changed",{data:t})}))}catch(e){throw console.error("[Engine720] Failed to initialize 720 engine:",e),this._isInitialized=!1,e}}setTheme(e){!this._isInitialized||this.engine}setLocales(){}isInitialized(){return this._isInitialized}async loadPanorama(e,t){if(!this._isInitialized||!this.engine){console.error("[Engine720] Engine not initialized. Please call init() first.");return}if(!e){console.error("[Engine720] Panorama URL is required.");return}try{console.log("[Engine720] 开始加载全景图:",e),await this.engine.loadPanorama(e),console.log("[Engine720] 全景图加载完成:",e)}catch(i){throw console.error("[Engine720] 全景图加载失败:",i),i}}async preloadPanoramas(e){if(!(!this._isInitialized||!this.engine))try{await this.engine.preloadPanoramas?.(e)}catch(t){console.warn("[Engine720] Failed to preload panoramas:",t)}}setFov(e){!this._isInitialized||!this.engine||this.engine.setFov?.(e)}getFov(){return!this._isInitialized||!this.engine?75:this.engine.getFov?.()??75}lookAt(e,t,i){!this._isInitialized||!this.engine||this.engine.lookAt?.(e,t,i)}resetView(){if(!(!this._isInitialized||!this.engine))try{this.engine.lookAt?.(0,0,!0),this.engine.setFov?.(75)}catch(e){console.warn("[Engine720] Failed to reset view:",e)}}pauseRendering(){!this._isInitialized||!this.engine||this.engine.pauseRendering?.()}resumeRendering(){!this._isInitialized||!this.engine||this.engine.resumeRendering?.()}resize(e,t){!this._isInitialized||!this.engine||this.engine.resize?.(e,t)}onRawEvent(e,t){this.engine?.events?.on(e,t)}offRawEvent(e,t){this.engine?.events?.off(e,t)}destroy(){if(!this._isDestroyed){if(this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.engine){try{this.engine.dispose?.()}catch(e){console.warn("[Engine720] Error during dispose:",e)}this.engine=null}this.container.innerHTML="",this._isDestroyed=!0,this._isInitialized=!1}}}class E9{container;registry;engineComponent=null;constructor(e,t){const i=typeof e=="string"?document.getElementById(e):e;if(!i)throw new Error("Container not found");this.container=i,this.registry=new Sm,t?.locale&&Zt.setLocale(t.locale),t?.theme&&t.theme!=="custom"&&ct.setTheme(t.theme),this.engineComponent=new w9({container:this.container,fov:t?.fov,enableZoom:t?.enableZoom,enableRotate:t?.enableRotate,sphereRadius:t?.sphereRadius,rotateSpeed:t?.rotateSpeed,zoomSpeed:t?.zoomSpeed,enableDamping:t?.enableDamping,dampingFactor:t?.dampingFactor,minFov:t?.minFov,maxFov:t?.maxFov},this.registry),this.engineComponent.init()}async loadPanorama(e,t){return this.engineComponent?.loadPanorama(e,t)}async preloadPanoramas(e){return this.engineComponent?.preloadPanoramas(e)}setFov(e){this.engineComponent?.setFov(e)}getFov(){return this.engineComponent?.getFov()??75}lookAt(e,t,i){this.engineComponent?.lookAt(e,t,i)}resetView(){this.engineComponent?.resetView()}setTheme(e){ct.setTheme(e)}on(e,t){return this.registry.on(e,t)}off(e,t){this.registry.off(e,t)}onRawEvent(e,t){this.engineComponent?.onRawEvent(e,t)}offRawEvent(e,t){this.engineComponent?.offRawEvent(e,t)}destroy(){this.engineComponent?.destroy(),this.engineComponent=null,this.registry.reset()}}const T9=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM引擎AI助手 - 需求分析与步骤规划专家\r
9885
9885
  \r
9886
9886
  ## 角色定位\r
9887
9887
  \r