1"use strict";(self.webpackChunkspacefit=self.webpackChunkspacefit||[]).push([[170],{3015:(tt,me,P)=>{P.d(me,{I:()=>E});var e=P(36929);class E extends e.Z{constructor(O){super(O),this.updateModel(O)}updateModel(O){this.setFromJson("id",O),this.setFromJson("projectId",O),this.setFromJson("name",O),this.setFromJson("projectName",O),this.setFromJson("city",O),this.setFromJson("officeDeskOptionIndex",O),this.setFromJson("openspaceDeskOptionIndex",O),this.setFromJson("globalFlexRate",O),this.setFromJson("recap",O),this.setFromJson("rawFormData",O),this.setFromJson("scenarios",O),this.setFromJson("requirements",O)}}},8846:(tt,me,P)=>{P.d(me,{m:()=>e});var e=function(X){return X.SUP_ADD_FORMAL="sup_add_formal",X.SUP_ADD_CASUAL="sup_add_casual",X.SUP_ADD_WORKSTATIONS="sup_add_workstations",X.SUP_DEDENSIFY_WORKSTATIONS="sup_dedensify_workstations",X.SUS_ADD_FORMAL="sus_add_formal",X.SUS_ADD_CASUAL="sus_add_casual",X.SUS_LESS_FORMAL="sus_less_formal",X.SUS_LESS_CASUAL="sus_less_casual",X}(e||{})},93524:(tt,me,P)=>{P.d(me,{m:()=>g});var e=P(56095),E=P(21449),X=P(35934),O=P(78376),v=P(91955),h=P(68385);class g{constructor(){this._pmIdOrDepName=null}get floor(){return this._floor}get areaUid(){return this._areaUid}get pmIdOrDepName(){return this._pmIdOrDepName}get corridorSpace(){return this._corridorSpace}get isInDepartment(){return this._pmIdOrDepName instanceof O.v}get isInModule(){return this._pmIdOrDepName instanceof v.P||this._pmIdOrDepName instanceof h.p}get isAlone(){return!this._pmIdOrDepName}static fromJson(a,n){const l=new g;return l._floor=n.getStringKeyRef(X.O.JKEY,X.O.createStringKey(a.floor)),l._areaUid=E.ph.fromJson(a.areaUid),l._pmIdOrDepName=a.pmIdOrDepName?"string"==typeof a.pmIdOrDepName?n.getStringKeyRef(O.v.JKEY,a.pmIdOrDepName):"program"===a.pmIdOrDepName[1]?n.getStringKeyRef(v.P.JKEY,a.pmIdOrDepName[0]):n.getStringKeyRef(h.p.JKEY,-a.pmIdOrDepName[0]):null,l._corridorSpace=e.mg.fromJson(a.corridorSpace),l}static toJson(a){return{floor:{floorIndex:a._floor.floorIndex(),buildingIndexes:a._floor.buildingIndexes()},areaUid:E.ph.toJson(a._areaUid),pmIdOrDepName:a._pmIdOrDepName instanceof O.v?a._pmIdOrDepName.name:a._pmIdOrDepName instanceof v.P?[a._pmIdOrDepName.id,"program"]:a._pmIdOrDepName instanceof h.p?[Math.abs(a._pmIdOrDepName.id),"feasability"]:void 0,corridorSpace:e.mg.toJson(a._corridorSpace)}}dispose(){this._floor=null,this._pmIdOrDepName=null}}},27986:(tt,me,P)=>{P.d(me,{W:()=>O});var e=P(56095),E=P(21449),X=P(35934);class O{get floor(){return this._floor}get indirectLightUid(){return this._indirectLightUid}get gridUid(){return this._gridUid}get gridRect(){return this._gridRect}get corridorSpace(){return this._corridorSpace}static fromJson(h,g){const r=new O;return r._floor=g.getStringKeyRef(X.O.JKEY,X.O.createStringKey(h.floor)),r._indirectLightUid=E.ph.fromJson(h.indirectLightUid),r._gridUid=E.ph.fromJson(h.gridUid),r._gridRect=h.gridRect,r._corridorSpace=e.mg.fromJson(h.corridorSpace),r}static toJson(h){return{floor:{floorIndex:h._floor.floorIndex(),buildingIndexes:h._floor.buildingIndexes()},indirectLightUid:E.ph.toJson(h._indirectLightUid),gridUid:E.ph.toJson(h._gridUid),gridRect:h._gridRect,corridorSpace:e.mg.toJson(h._corridorSpace)}}dispose(){this._floor=null}}},89418:(tt,me,P)=>{P.d(me,{O:()=>v});var e=P(28395),E=P(42893),X=P(93524),O=P(27986);class v{constructor(){this._placedDepartmentFloorInfos=[],this._placedModuleInfos=[],this._directCorridorInfos=[],this._indirectCorridorInfos=[]}get placedDepartmentFloorInfos(){return this._placedDepartmentFloorInfos}get placedModuleInfos(){return this._placedModuleInfos}get directCorridorInfos(){return this._directCorridorInfos}get indirectCorridorInfos(){return this._indirectCorridorInfos}dispose(){this._placedDepartmentFloorInfos.forEach(g=>g.dispose()),this._placedDepartmentFloorInfos=[],this._placedModuleInfos.forEach(g=>g.dispose()),this._placedModuleInfos=[],this._directCorridorInfos.forEach(g=>g.dispose()),this._directCorridorInfos=[],this._indirectCorridorInfos.forEach(g=>g.dispose()),this._indirectCorridorInfos=[]}isEquivalent(g){return this._placedDepartmentFloorInfos.length===g._placedDepartmentFloorInfos.length&&this._placedModuleInfos.length===g._placedModuleInfos.length&&this._placedDepartmentFloorInfos.every(r=>{const a=g._placedDepartmentFloorInfos.find(n=>n.department===r.department&&n.floor===r.floor);return!!a&&a.isEquivalent(r)})&&this._placedModuleInfos.every(r=>!!g._placedModuleInfos.find(n=>n.isEquivalent(r)))}static fromJson(g,r){const a=new v;return a._placedDepartmentFloorInfos=g.placedDepartmentFloorInfos.map(n=>e.O.fromJson(n,r)),a._placedModuleInfos=g.placedModuleInfos.map(n=>E.l.fromJson(n,r)).filter(n=>n&&n.programModule),a._directCorridorInfos=g.directCorridorInfos?.map(n=>X.m.fromJson(n,r))??[],a._indirectCorridorInfos=g.indirectCorridorInfos?.map(n=>O.W.fromJson(n,r))??[],a}static toJson(g){return{placedDepartmentFloorInfos:g._placedDepartmentFloorInfos.map(r=>e.O.toJson(r)),placedModuleInfos:g._placedModuleInfos.map(r=>E.l.toJson(r)),directCorridorInfos:g._directCorridorInfos.map(r=>X.m.toJson(r)),indirectCorridorInfos:g._indirectCorridorInfos.map(r=>O.W.toJson(r))}}}},9693:(tt,me,P)=>{P.d(me,{R:()=>h});var e=P(68385),E=P(41118);class X{constructor(){this._floors=[]}get shouldSerialize(){return this._floors.some(r=>r.shouldSerialize)}get floors(){return this._floors}pickOrCreateFloor(r){let a=this._floors.find(n=>n.floor.id===r.id);return a||(a=new E.X(r),this._floors.push(a)),a}static fromJson(r,a){const n=new X;return!r||!r.floors||(n._floors=r.floors.filter(l=>!!l).map(l=>E.X.fromJson(l,a))),n}static toJson(r){return{floors:r._floors.map(a=>E.X.toJson(a))}}
1dispose(){this._floors.forEach(r=>r.dispose()),this._floors=[]}}var O=P(8846),v=P(89418);class h{parseDragDropInfo(r){this._dragDropRaw&&(this._dragDropInfo&&this._dragDropInfo.dispose(),this._dragDropInfo=v.O.fromJson(this._dragDropRaw,r))}static fromJson(r,a){const n=new h;return n._id=r.id,n._selectedLotIds=r.selectedLotIds||[],n._moduleAdjustments=r.moduleAdjustments.map(l=>e.p.fromJson(l,a)),n._floorIdSupAreaIdxDepartmentsActivatedDynamicIdxes=r.floorIdSupAreaIdxDepartmentsActivatedDynamicIdxes||{},n._hasFailed=r.hasFailed||!1,n._supUsed=r.supUsed||0,n._supTotal=r.supTotal||0,n._failedDepartmentArea=r.failedDepartmentArea||0,n._susUsed=r.susUsed||0,n._susTotal=r.susTotal||0,n._failedSusArea=r.failedSusArea||0,n._receptionInSus=r.receptionInSus||!1,n._canHaveDepartmentInSus=r.canHaveDepartmentInSus||!1,n._departmentUsedSup=r.departmentUsedSup||0,n._departmentUsedSus=r.departmentUsedSus||0,n._modelizationStrategies=(r.modelizationStrategies||[]).map(l=>O.m[l.toUpperCase()]),n._stackingPlan=r.stackingPlan?X.fromJson(r.stackingPlan,a):new X,n._dragDropRaw=r.dragDropInfo||null,n._fireRegulationOverrideCountryCode=r.fireRegulationOverrideCountryCode||null,n}static toJson(r){const a={id:r._id||void 0,selectedLotIds:r._selectedLotIds,moduleAdjustments:r._moduleAdjustments.map(n=>e.p.toJson(n)),floorIdSupAreaIdxDepartmentsActivatedDynamicIdxes:r._floorIdSupAreaIdxDepartmentsActivatedDynamicIdxes,hasFailed:r._hasFailed,supUsed:r._supUsed,supTotal:r._supTotal,failedDepartmentArea:r._failedDepartmentArea,susUsed:r._susUsed,susTotal:r._susTotal,failedSusArea:r._failedSusArea,receptionInSus:r._receptionInSus,canHaveDepartmentInSus:r._canHaveDepartmentInSus,departmentUsedSup:r._departmentUsedSup,departmentUsedSus:r._departmentUsedSus,modelizationStrategies:r._modelizationStrategies.map(n=>n.toString().toLowerCase()),stackingPlan:r._stackingPlan.shouldSerialize?X.toJson(r._stackingPlan):void 0,dragDropInfo:r._dragDropInfo?v.O.toJson(r._dragDropInfo):null,fireRegulationOverrideCountryCode:r._fireRegulationOverrideCountryCode||void 0};return console.debug("[Feasability.toJson] instance._id:",r._id,"-> result.id:",a.id),a}get id(){return this._id}setId(r){this._id=r}setIdForOverride(r){console.debug("[Feasability] setIdForOverride called with:",r,"- current id:",this._id),this._id=r,console.debug("[Feasability] After setIdForOverride, id is now:",this._id)}get selectedLotIds(){return this._selectedLotIds}get moduleAdjustments(){return this._moduleAdjustments}get floorIdSupAreaIdxDepartmentsActivatedDynamicIdxes(){return this._floorIdSupAreaIdxDepartmentsActivatedDynamicIdxes}get hasFailed(){return this._hasFailed}get supUsed(){return this._supUsed}get supTotal(){return this._supTotal}get programArea(){return this._programArea}get failedDepartmentArea(){return this._failedDepartmentArea}get susUsed(){return this._susUsed}get susTotal(){return this._susTotal}get failedSusArea(){return this._failedSusArea}get receptionInSus(){return this._receptionInSus}get canHaveDepartmentInSus(){return this._canHaveDepartmentInSus}get departmentUsedSup(){return this._departmentUsedSup}get departmentUsedSus(){return this._departmentUsedSus}get modelizationStrategies(){return this._modelizationStrategies}setModelizationStrategies(r){this._modelizationStrategies=r}get stackingPlan(){return this._stackingPlan}get dragDropInfo(){return this._dragDropInfo}get hasDragDropInfo(){return null!==this._dragDropInfo||!!this._dragDropRaw}constructor(r=[],a=null){this._id=0,this._selectedLotIds=[],this._moduleAdjustments=[],this._floorIdSupAreaIdxDepartmentsActivatedDynamicIdxes={},this._hasFailed=!1,this._supUsed=0,this._supTotal=0,this._failedDepartmentArea=0,this._programArea=0,this._susUsed=0,this._susTotal=0,this._failedSusArea=0,this._receptionInSus=!1,this._canHaveDepartmentInSus=!1,this._departmentUsedSup=0,this._departmentUsedSus=0,this._fireRegulationOverrideCountryCode=null,this._modelizationStrategies=[],this._stackingPlan=new X,this._dragDropRaw=null,this._dragDropInfo=null,this._selectedLotIds=r,this._fireRegulationOverrideCountryCode=a}
1dispose(){this._moduleAdjustments.forEach(r=>r.dispose()),this._moduleAdjustments=[],this._stackingPlan?.dispose(),this._stackingPlan=null,this._dragDropInfo?.dispose(),this._dragDropInfo=null}static fromRunResponse(r,a){const n=new h(a._selectedLotIds,a._fireRegulationOverrideCountryCode);return n._moduleAdjustments=[...a._moduleAdjustments],n._floorIdSupAreaIdxDepartmentsActivatedDynamicIdxes=r.floors.reduce((l,p)=>(l[p.floorId]=p.supAreaIdxDepartmentsActivatedDynamicIdxes||{},l),{}),n._hasFailed=r.hasFailed,n._supUsed=r.supUsed,n._supTotal=r.supTotal,n._failedDepartmentArea=r.failedDepartmentArea,n._susUsed=r.susUsed,n._susTotal=r.susTotal,n._receptionInSus=r.receptionInSus,n._canHaveDepartmentInSus=r.canHaveDepartmentInSus,n._departmentUsedSup=r.departmentUsedSup,n._departmentUsedSus=r.departmentUsedSus,n._id=a._id,n}static fromRunResponseJS(r,a,n){const l=new h(a._selectedLotIds,a._fireRegulationOverrideCountryCode);l._moduleAdjustments=[...a._moduleAdjustments],l._floorIdSupAreaIdxDepartmentsActivatedDynamicIdxes={},l._hasFailed=r.hasFailed,l._receptionInSus=r.receptionInSus,l._canHaveDepartmentInSus=r.canHaveDepartmentInSus,l._departmentUsedSup=r.departmentUsedSup,l._departmentUsedSus=r.departmentUsedSus,l._id=a._id;let p=0,y=0,D=0;const Y=[];let H=0,ne=0,K=0,k=0,x=0,f=0,J=0;r.floors.forEach(ke=>{const Xe=n.floorViewModels[ke.id];if(!Xe)return;let te={},ye={},Ae={};if(Xe.supAreasVMs.forEach(Ee=>{const[q,oe,ee,Z]=Ee.directLightInfo.fullUid.getFloorAndLotPartOrMinusOne();Ae[ee]=(Ae[ee]||0)+Ee.coveredSpaceArea}
1),Xe.floor.lots.forEach(Ee=>{te[Ee.lotIndex]=Ee,Ae[Ee.lotIndex]=1e4*Ee.sup/(Ae[Ee.lotIndex]||1)}),ke.supAreas.forEach(Ee=>{const q=Xe.supAreasVMs.find(he=>he.id===Ee.id);if(!q)return;const[oe,ee,Z,Q]=q.directLightInfo.fullUid.getFloorAndLotPartOrMinusOne(),V=te[Z];if(!V)return;ye[Z]=V;const U=Ae[Z]||1,re=V.sua/V.sun,de=(q.totalCapacity-Math.max(0,Ee.leftCapacity))/q.totalCapacity*q.coveredSpaceArea*U;H+=de*re,Ee.leftCapacity<0&&(k+=-Ee.leftCapacity/q.totalCapacity*q.coveredSpaceArea*U*re),Ee.splitFailedTiles>0&&(K+=Ee.splitFailedTiles/q.totalCapacity*q.coveredSpaceArea*U*re)}),ke.failedWidth>0){let Ee=0;if(Xe.supAreasVMs.forEach(q=>Ee+=q.totalTileWidth),Ee>0){const q=ke.failedWidth/Ee;Xe.supAreasVMs.forEach(oe=>{const[ee,Z,Q,V]=oe.directLightInfo.fullUid.getFloorAndLotPartOrMinusOne(),U=te[Q];U&&oe.totalTileWidth&&(k+=q*oe.coveredSpaceArea*(Ae[Q]||1)*(U.sua/U.sun))})}}Object.values(ye).forEach(Ee=>{const q=Ee.sua/Ee.sun,oe=1e4*(Ee.sun-Ee.sup);p+=1e4*Ee.sup,y+=oe,D+=1e4*Ee.sua,ne+=1e4*Ee.sup*q,f+=oe*q,Y.push([oe,q])})});const L=r.susTotal>0&&y>0,ce=L?y/r.susTotal:0;if(L)x=0,J=0,Y.forEach(([ke,Xe])=>{const te=ke/y;x+=r.susUsed*ce*te*Xe,J+=r.failedSus*ce*te*Xe});else{x=0;const ke=p+y;J=r.failedSus*(ke>0?D/ke:1)}if(K>0&&console.debug("Feasability: department area stranded outside its own cluster:",Math.round(K/1e4),"m2 (SUA)"),r.programArea>0){const ke=H+k+x+J,Xe=Math.max(0,r.programArea-(r.coreRoomArea||0)),te=Xe>0?(ke-Xe)/Xe:0;Xe>0&&Math.abs(te)>.05&&console.warn("Feasability: need",Math.round(ke/1e4),"m2 (SUA) against a program of",Math.round(Xe/1e4),"m2 --",(100*te).toFixed(1)+"%.",te<0?"Below the program: demand is being lost somewhere.":"Above the program: either genuine waste, or double-counting.",{supUsedNia:H,failedSupNia:k,susUsedNia:x,failedSusNia:J,coreRoomArea:r.coreRoomArea||0})}return l._programArea=r.programArea||0,l._supUsed=H,l._supTotal=ne,l._failedDepartmentArea=k,l._failedSusArea=J,l._susUsed=x,l._susTotal=f,l}fromSaveResponse(r){const a=this._id!==r.id;return this._id=r.id,r.moduleAdjustments.forEach((n,l)=>{this._moduleAdjustments[l]?.fromSaveResponse(n)}),a}tryUpdateDragDropIfNew(r){return this._dragDropInfo?!this._dragDropInfo.isEquivalent(r)&&(this._dragDropInfo.dispose(),this._dragDropInfo=r,!0):(this._dragDropInfo=r,!0)}}},68385:(tt,me,P)=>{P.d(me,{p:()=>X});var e=P(52800),E=P(91955);let X=(()=>{class O extends e.r{static#e=this.JKEY="feasabilityModuleAdjustment";setId(h){this._id=h}static fromJson(h,g){const r=new O;return e.r.baseFromJson(r,h,g),g.setStringKeyRef(O.JKEY,r.id,r),r}static toJson(h){return{...e.r.baseToJson(h)}}dispose(){super.dispose()}toProgramModule(){const h=new E.P;return this._baseClone(h),h}static fromModule(h){const g=new O;g._module=h,g._count=0;const r=h.furniturePickers[0];return g._furnitureShape=r.shape,g._furnitureSize=r.size,g}fromSaveResponse(h){this._id=h.id}}return O})()},20483:(tt,me,P)=>{P.d(me,{j:()=>E});var e=P(71115);class E{get a(){return this._a}get b(){return this._b}get result(){return this._result}static fromJson(O,v){const h=new E;return h._a=v.getStringKeyRef(e.C.JKEY,O.a),h._b=v.getStringKeyRef(e.C.JKEY,O.b),h._result=v.getStringKeyRef(e.C.JKEY,O.result),h}static toJson(O){return{a:O._a.type,b:O._b.type,result:O._result.type}}dispose(){this._a=null,this._b=null,this._result=null}}},52800:(tt,me,P)=>{P.d(me,{r:()=>g});var e=P(37609),E=P(69519),X=P(5398),O=P(42400),v=P(33495),h=P(55656);class g{constructor(){this._origin="program",this._count=0,this._customName=null,this._customArea=null,this._customCapacity=null,this._furnitureShape=null,this._furnitureSize=null,this._settingId=null,this._pickedFurniturePickers=[],this._dimensions=[]}areEquivalent(a){return(this._furnitureSize||null)===(a._furnitureSize||null)&&(this._furnitureShape||null)===(a._furnitureShape||null)&&this._module.id===a._module.id&&(!this._module.isCustom||(this._module.category.type===O.G9.COLLABORATIVE?this._customArea===a._customArea:this._customName===a._customName))}getSettings(){for(const a of this._pickedFurniturePickers){const n=a.getSettings(this._settingId);if(n)return n}return h.t.createDefault()}_pickFurniturePickers(){if(this._module.isCustom)return void(this._pickedFurniturePickers=[...this._module.furniturePickers]);const a=this._furnitureSize||null,n=this._furnitureShape||null;this._pickedFurniturePickers=this._module.furniturePickers.filter(l=>a===(l.size||null)&&n===(l.shape||null))}computeDimensions(a){if((!this._pickedFurniturePickers||0===this._pickedFurniturePickers.length)&&this._pickFurniturePickers(),this._dimensions.length>0)return;a.module=this._module;const n=this._module.isCustom;let l=0;if(n)if(null!==this._customArea)l=1e4*(this._customArea||0);else{let y=null;for(const D of this._pickedFurniturePickers)if(!D.size&&!D.shape&&D.layouts.length){y=D.layouts[0];break}if(y||(y=this._pickedFurniturePickers.flatMap(D=>D.layouts).reduce((D,Y)=>{const H=D?Math.min(...D.dimensions.map(K=>K[0]*K[1])):1/0;return(Y?Math.min(...Y.dimensions.map(K=>K[0]*K[1])):1/0)<H?Y:D},null)),y){const D=y.dimensions.length>0?y.dimensions.reduce((Y,H)=>H[0]*H[1]<(Y?Y[0]*Y[1]:1/0)?H:Y,null):[0,0];l=(this._customCapacity||1)*D[0]*D[1]}}const p=[];
1if(this._pickedFurniturePickers.forEach(y=>{y.layouts.forEach(D=>{let Y=(0,v.L)(D,a);if(n){let H=!0;const ne=D.blockRules.length>0;Y=Y.map(K=>{const k=K[0]/K[1],x=K[0]*K[1],f=[Math.sqrt(l*k),Math.sqrt(l/k),K[2]];return ne&&f[0]*f[1]<x&&(H=!1),f}),H&&p.push(new X.nP(y,D,Y))}else this._dimensions.push(new X.nP(y,D,Y))})}),p.length>0){let y=null,D=1/0;for(const Y of p)for(const H of Y.layout.dimensions){const K=l-H[0]*H[1];(0<=K&&K<D||null===y)&&(D=K>=0?K:D,y=Y)}null!==y&&this._dimensions.push(y)}a.module=null}static baseFromJson(a,n,l){return a._id=n.id,a._count=n.count,a._origin=n.origin||"program",a._customName=n.customName??null,a._customArea=n.customArea??null,a._customCapacity=n.customCapacity??null,a._furnitureShape=n.furnitureShapeId?l.getStringKeyRef(e.O.JKEY,n.furnitureShapeId):null,a._furnitureSize=n.furnitureSizeId?l.getStringKeyRef(E.O.JKEY,n.furnitureSizeId):null,a._settingId=n.settingId??null,a._module=l.getStringKeyRef(X.Yl.JKEY,n.moduleId),a}static baseToJson(a){return{id:a._id||void 0,origin:a._origin,count:a._count,customName:a._customName,customArea:a._customArea,customCapacity:a._customCapacity,furnitureShapeId:a._furnitureShape?.id||void 0,furnitureSizeId:a._furnitureSize?.id||void 0,settingId:a._settingId||void 0,moduleId:a._module.id}}get id(){return this._id}get origin(){return this._origin}get count(){return this._count}setCount(a){this._count=Math.max(0,a)}get customName(){return this._customName}get customArea(){return this._customArea}get furnitureShape(){return this._furnitureShape}get furnitureSize(){return this._furnitureSize}get module(){return this._module}get pickedFurniturePickers(){return this._pickedFurniturePickers}get dimensions(){return this._dimensions}get unitSqMeters(){return this._module.getPicker(this.furnitureSize,this.furnitureShape)?.theoricalArea||this._module.unitSqMeters}get customOrCapacity(){return this._customCapacity??this._module.capacity}get customCapacity(){return this._module.isCustom&&this._customCapacity||null}get settingId(){return this._settingId}dispose(){this._furnitureShape=null,this._furnitureSize=null,this._module=null,this._pickedFurniturePickers=[],this._dimensions.forEach(a=>a.dispose()),this._dimensions=[]}_baseClone(a){return a._id=this._id,a._origin=this._origin,a._count=this._count,a._customName=this._customName,a._customArea=this._customArea,a._customCapacity=this._customCapacity,a._furnitureShape=this._furnitureShape,a._furnitureSize=this._furnitureSize,a._settingId=this._settingId,a._module=this._module,a._pickedFurniturePickers=this._pickedFurniturePickers,a._dimensions=this._dimensions,a}}},78376:(tt,me,P)=>{P.d(me,{v:()=>X});var e=P(91955),E=P(21449);let X=(()=>{class O{static#e=this.JKEY="ProgramDepartment";constructor(){this._growth=null,this._flexRatio=null,this._offices=[]}uidInPackage(){return E.ph.create([E.TE.PROGRAM_DEPARTMENT,this.elementId()])}elementType(){return E.TE.PROGRAM_DEPARTMENT}elementId(){return this._id}static fromJson(h,g){const r=new O;return r._id=h.id,r._name=h.name,r._inputOrder=h.inputOrder,r._color=h.color,r._workforce=h.workforce,r._growth=h.growth??null,r._flexRatio=h.flexRatio??null,r._offices=h.offices.map(a=>e.P.fromJson(a,g)),r._openspace=e.P.fromJson(h.openspace,g),r._offices.forEach(a=>a._department=r),r._openspace._department=r,g.setStringKeyRef(O.JKEY,r._name,r),r}static toJson(h){return{id:h._id||void 0,name:h._name,inputOrder:h._inputOrder,color:h._color,workforce:h._workforce,growth:h._growth,flexRatio:h._flexRatio,offices:h._offices.map(g=>e.P.toJson(g)),openspace:e.P.toJson(h._openspace)}}clone(){const h=new O;return h._id=this._id,h._name=this._name,h._inputOrder=this._inputOrder,h._color=this._color,h._workforce=this._workforce,h._growth=this._growth,h._flexRatio=this._flexRatio,h._offices=this._offices.map(g=>g.clone()),h._openspace=this._openspace?.clone(),h._offices.forEach(g=>g._department=h),h._openspace&&(h._openspace._department=h),h}get id(){return this._id}get name(){return this._name}get inputOrder(){return this._inputOrder}get color(){return this._color}get workforce(){return this._workforce}get growth(){return this._growth}get flexRatio(){return this._flexRatio}
1get offices(){return this._offices}get openspace(){return this._openspace}dispose(){this._offices.forEach(h=>h.dispose()),this._offices=[],this._openspace?.dispose(),this._openspace=void 0}}return O})()},91955:(tt,me,P)=>{P.d(me,{P:()=>O});var e=P(52800),E=P(21449),X=P(68385);let O=(()=>{class v extends e.r{constructor(){super(...arguments),this._department=null}static#e=this.JKEY="programModule";uidInPackage(){return E.ph.create([E.TE.PROGRAM_DEPARTMENT,this._department?.elementId()||-1],[E.TE.PROGRAM_MODULE,this.elementId()])}elementType(){return E.TE.PROGRAM_MODULE}elementId(){return this._id}static fromJson(g,r){const a=new v;return e.r.baseFromJson(a,g,r),"program"===a._origin?r.setStringKeyRef(v.JKEY,a.id,a):r.setStringKeyRef(X.p.JKEY,-a.id,a),a}static toJson(g){return{...e.r.baseToJson(g)}}get department(){return this._department}get thumbnail(){return this._pickedFurniturePickers[0]?.thumbnail||this._module.thumbnail}dispose(){super.dispose(),this._department=null}clone(){const g=new v;return this._baseClone(g),g._department=this._department,g}}return v})()},91408:(tt,me,P)=>{P.d(me,{l:()=>r});var e=P(78376);class E{constructor(){}static fromJson(n,l){const p=new E;return p._priorityOrder=n.priorityOrder,p._departmentA=l.getStringKeyRef(e.v.JKEY,n.departmentA),p._departmentB=l.getStringKeyRef(e.v.JKEY,n.departmentB),p}static toJson(n){return{priorityOrder:n._priorityOrder,departmentA:n._departmentA.name,departmentB:n._departmentB.name}}get priorityOrder(){return this._priorityOrder}get departmentA(){return this._departmentA}get departmentB(){return this._departmentB}dispose(){this._departmentA=null,this._departmentB=null}}var X=P(91955),O=P(21449),v=P(42400),h=P(4516),g=P(68385);class r extends O.Vz{constructor(){super(...arguments),this._departments=[],this._departmentLinks=[],this._modules=[],this._reception=null,this._meetings=[],this._utilities=[],this._customMeetings=[],this._customUtilities=[],this._isTestFit=!1}computeDimensions(n){this._departments.forEach(l=>{l.offices.forEach(p=>p.computeDimensions(n)),l.openspace&&l.openspace.computeDimensions(n)}),this._modules.forEach(l=>{l.computeDimensions(n)})}computeDummyRequirements(n,l){let p=-1,y={};[...n.modules,...n.receptionModules].forEach(Y=>{if(Y.isCustom)return;const H=new h.bI;Y.furniturePickers.forEach(ne=>{H.add([ne.shape,ne.size])}),y[Y.id]=H}),this._modules.forEach(Y=>{const H=y[Y.module.id];H&&H.delete([Y.furnitureShape,Y.furnitureSize])}),Object.entries(y).forEach(([Y,H])=>{const ne=parseInt(Y);H.forEach(([K,k])=>{const x={id:p--,count:0,moduleId:ne,furnitureShapeId:K?.id||null,furnitureSizeId:k?.id||null},f=X.P.fromJson(x,l);this._modules.push(f)})})}feedInContext(n){this._modules.forEach(l=>{"program"===l.origin?n.setStringKeyRef(X.P.JKEY,l.id,l):n.setStringKeyRef(g.p.JKEY,-l.id,l)})}_finalize(){this._modules.forEach(n=>{n.module.isReception&&n.id>0?this._reception=n:n.module.category.type===v.G9.COLLABORATIVE?n.module.isCustom?this._customMeetings.push(n):this._meetings.push(n):n.module.category.type===v.G9.UTILITY&&(n.module.isCustom?this._customUtilities.push(n):this._utilities.push(n))}),this._isTestFit=this._departments.length<=1}static fromJson(n,l){const p=new r;return p._departments=n.departments.map(y=>e.v.fromJson(y,l)),p._departmentLinks=n.departmentLinks.map(y=>E.fromJson(y,l)),p._modules=n.modules.map(y=>X.P.fromJson(y,l)),p._finalize(),p}static toJson(n){return{departments:n._departments.map(l=>e.v.toJson(l)),departmentLinks:n._departmentLinks.map(l=>E.toJson(l)),modules:n._modules.map(l=>X.P.toJson(l))}}dispose(){this._departments.forEach(n=>n.dispose()),this._departmentLinks.forEach(n=>n.dispose()),this._modules.forEach(n=>n.dispose()),this._departments=[],this._departmentLinks=[],this._modules=[],this._reception=null,this._meetings=[],this._utilities=[],this._customMeetings=[],this._customUtilities=[]}get departments(){return this._departments}get departmentLinks(){return this._departmentLinks}get modules(){return this._modules}get reception(){return this._reception}get meetings(){return this._meetings}get utilities(){return this._utilities}get customMeetings(){return this._customMeetings}get customUtilities(){return this._customUtilities}get isTestFit(){return this._isTestFit}static createAdjusted(n,l,p,y){const D=new r;let Y;return D._departments=n._departments.map(H=>H.clone()),D._departmentLinks=[...n._departmentLinks],D._modules=n._modules.map(H=>
1H.clone()),l.moduleAdjustments.forEach(H=>{const ne=D._modules.find(K=>K.areEquivalent(H));ne?ne.setCount(H.count):D._modules.push(H.toProgramModule())}),p&&(Y=p.clone(),D._modules.forEach(H=>{"program"===H.origin?Y.setStringKeyRef(X.P.JKEY,H.id,H):Y.setStringKeyRef(g.p.JKEY,-H.id,H)})),y&&y(D,Y),D._finalize(),D}getElement(n){if(!n.isNull()&&n.parts[0].elementType===O.TE.PROGRAM_DEPARTMENT){let l;const p=n.parts[0].id;for(const y of this._departments)if(y.elementId()===p){l=y;break}if(1===n.parts.length)return l??null;if(2===n.parts.length){if(l){const D=n.parts[1].id;if(l.openspace.elementId()===D)return l.openspace;for(const Y of l.offices)if(Y.elementId()===D)return Y}const y=n.asElementId();for(const D of this._modules)if(D.elementId()===y)return D}}return null}findRegularRequirement(n,l,p,y,D,Y){return l=l||null,p=p||null,this._modules.find(H=>{if(H.module.id!==n||(H.furnitureSize||null)!==l||(H.furnitureShape||null)!==p)return!1;let ne="number"==typeof y&&"number"==typeof H.customCapacity;if(ne&&y!==H.customCapacity)return!1;let K="number"!=typeof y&&"number"!=typeof H.customCapacity;return!(!ne&&!K||(ne="number"==typeof Y&&"number"==typeof H.customArea,ne&&Y!==H.customArea)||(K="number"!=typeof Y&&"number"!=typeof H.customArea,!ne&&!K))&&("string"!=typeof D&&"string"!=typeof H.customName||"string"==typeof D&&"string"==typeof H.customName&&H.customName===D)})||null}}},84322:(tt,me,P)=>{P.d(me,{nv:()=>a.nv,hL:()=>e.hL,kK:()=>a.kK,GY:()=>e.GY,Eb:()=>a.Eb,Zo:()=>e.Zo,im:()=>a.im,IH:()=>e.kK,_e:()=>a._e,BL:()=>e.BL,XX:()=>a.XX,BA:()=>e.BA,Tl:()=>a.Tl,od:()=>e.od,lj:()=>a.lj,iF:()=>e.iF,J2:()=>r,SQ:()=>g,q$:()=>h,DY:()=>v,ze:()=>a.ze,UM:()=>e.UM,ev:()=>a.ev,xi:()=>e.xi,as:()=>a.as,EE:()=>e.EE,J9:()=>a.J9,EX:()=>e.EX});var e=P(56220),E=P(21449),X=P(4516),O=P(56095);class v{constructor(){this._uidInPackage=new E.ph,this.line=new E.ph,this.offsetOnLine=0}elementType(){return E.TE.NETWORK_NODE_LINE_LINK_INFO}elementId(){return this._uidInPackage.asElementId()}uidInPackage(){return this._uidInPackage}getRequiredElementUids(){return new Map([[E.TE.LINE_INFO,new X.bI([this.line])]])}equals(l){return null!=l&&this._uidInPackage===l._uidInPackage}hashCode(){return this._uidInPackage.hashCode()}static fromJson(l){const p=new v;return p._uidInPackage=E.ph.fromJson(l.uidInPackage),p.node=O.E9.fromJson(l.node),p.line=E.ph.fromJson(l.line),p.offsetOnLine=l.offsetOnLine,p}static toJson(l){return{uidInPackage:E.ph.toJson(l._uidInPackage),node:O.E9.toJson(l.node),line:E.ph.toJson(l.line),offsetOnLine:l.offsetOnLine}}}class h{constructor(){this._uidInPackage=new E.ph,this.lineA=new E.ph,this.lineB=new E.ph,this.lineAStartOffset=0,this.lineAEndOffset=0,this.lineBStartOffset=0,this.lineBEndOffset=0,this.isSameDirection=!0}elementType(){return E.TE.NETWORK_LINE_LINE_LINK_INFO}elementId(){return this._uidInPackage.asElementId()}uidInPackage(){return this._uidInPackage}getRequiredElementUids(){return new Map([[E.TE.LINE_INFO,new X.bI([this.lineA,this.lineB])]])}equals(l){return null!=l&&this._uidInPackage===l._uidInPackage}hashCode(){return this._uidInPackage.hashCode()}static fromJson(l){const p=new h;return p._uidInPackage=E.ph.fromJson(l.uidInPackage),p.lineA=E.ph.fromJson(l.lineA),p.lineB=E.ph.fromJson(l.lineB),p.lineAStartOffset=l.lineAStartOffset,p.lineAEndOffset=l.lineAEndOffset,p.lineBStartOffset=l.lineBStartOffset,p.lineBEndOffset=l.lineBEndOffset,p}static toJson(l){return{uidInPackage:E.ph.toJson(l._uidInPackage),lineA:E.ph.toJson(l.lineA),lineB:E.ph.toJson(l.lineB),lineAStartOffset:l.lineAStartOffset,lineAEndOffset:l.lineAEndOffset,lineBStartOffset:l.lineBStartOffset,lineBEndOffset:l.lineBEndOffset}}}class g{constructor(){this._uidInPackage=new E.ph,this.floorAndLotPartAFullUid=new E.ph,this.floorAndLotPartBFullUid=new E.ph,this.distance=0}elementType(){return E.TE.NETWORK_DOOR_LINK_INFO}elementId(){return this._uidInPackage.asElementId()}uidInPackage(){return this._uidInPackage}getRequiredElementUids(){return new Map}equals(l){return null!=l&&this._uidInPackage===l._uidInPackage}hashCode(){return this._uidInPackage.hashCode()}static fromJson(l){const p=new g;return p._uidInPackage=E.ph.fromJson(l.uidInPackage),p.doorNodeA=O.E9.fromJson(l.doorNodeA),p.doorNodeB=O.E9.fromJson(l.doorNodeB),p.floorAndLotPartAFullUid=E.ph.fromJson(l.floorAndLotPartAFullUid),p.floorAndLotPartBFullUid=E.ph.fromJson(l.floorAndLotPartBFullUid),p.distance=l.distance,p}static toJson(l){return{uidInPackage:E.ph.toJson(l._uidInPackage),doorNodeA:O.E9.toJson(l.doorNodeA),doorNodeB:O.E9.toJson(l.doorNodeB),floorAndLotPartAFullUid:E.ph.toJson(l.floorAndLotPartAFullUid),floorAndLotPartBFullUid:E.ph.toJson(l.floorAndLotPartBFullUid),distance:l.distance}}}
1class r{constructor(){this._uidInPackage=new E.ph,this.doorUid=new E.ph,this.circulationNodeA=new E.ph,this.circulationNodeB=new E.ph,this.distance=0}elementType(){return E.TE.NETWORK_COMPARTIMENT_DOOR_LINK_INFO}elementId(){return this._uidInPackage.asElementId()}uidInPackage(){return this._uidInPackage}getRequiredElementUids(){return new Map}equals(l){return null!=l&&this._uidInPackage===l._uidInPackage}hashCode(){return this._uidInPackage.hashCode()}static fromJson(l){const p=new r;return p._uidInPackage=E.ph.fromJson(l.uidInPackage),p.circulationNodeA=E.ph.fromJson(l.circulationNodeA),p.circulationNodeB=E.ph.fromJson(l.circulationNodeB),p.doorPosition=O.E9.fromJson(l.doorPosition),p.doorUid=E.ph.fromJson(l.doorUid),p.distance=l.distance,p}static toJson(l){return{uidInPackage:E.ph.toJson(l._uidInPackage),circulationNodeA:E.ph.toJson(l.circulationNodeA),circulationNodeB:E.ph.toJson(l.circulationNodeB),doorPosition:O.E9.toJson(l.doorPosition),doorUid:E.ph.toJson(l.doorUid),distance:l.distance}}}var a=P(95627)},95627:(tt,me,P)=>{P.d(me,{Eb:()=>a,J9:()=>r,Tl:()=>H,XX:()=>p,_e:()=>D,as:()=>y,ev:()=>K,im:()=>k,kK:()=>ne,lj:()=>Y,nv:()=>n,ze:()=>l});var e=P(21449),E=P(38976),X=P(4516),O=P(56095);class v{constructor(){this.material_id=0,this.door=null,this.offset=0,this.length=0}static fromJson(f){const J=new v;return J.material_id=f.material_id,J.door=f.door,J.offset=f.offset,J.length=f.length,J}static toJson(f){return{material_id:f.material_id,door:f.door,offset:f.offset,length:f.length}}}class h{constructor(){this.targetCorridorLine=new e.ph,this.corridorStartOffset=0,this.corridorEndOffset=0,this.circulationStartOffset=0,this.circulationEndOffset=0,this.normalDistance=0}static fromJson(f){const J=new h;return J.targetCorridorLine=e.ph.fromJson(f.targetCorridorLine),J.corridorStartOffset=f.corridorStartOffset,J.corridorEndOffset=f.corridorEndOffset,J.circulationStartOffset=f.circulationStartOffset,J.circulationEndOffset=f.circulationEndOffset,J}static toJson(f){return{targetCorridorLine:e.ph.toJson(f.targetCorridorLine),corridorStartOffset:f.corridorStartOffset,corridorEndOffset:f.corridorEndOffset,circulationStartOffset:f.circulationStartOffset,circulationEndOffset:f.circulationEndOffset}}}class g{constructor(){this._uidInPackage=new e.ph,this.startNode=new e.ph,this.endNode=new e.ph,this.curve=new e.ph}elementType(){return e.TE.LINE_INFO}static ElementType(){return e.TE.LINE_INFO}elementId(){return this._uidInPackage.asElementId()}uidInPackage(){return this._uidInPackage}isLine(){return!0}isNode(){return!1}getRequiredElementUids(){return new Map([[e.TE.NODE_INFO,new X.bI([this.startNode,this.endNode])]])}equals(f){return null!=f&&this._uidInPackage===f._uidInPackage}hashCode(){return this._uidInPackage.hashCode()}static fromJson(f,J){return f._uidInPackage=e.ph.fromJson(J.uidInPackage),f.p2Line=O.x1.fromJson(J.p2Line),f.startNode=e.ph.fromJson(J.startNode),f.endNode=e.ph.fromJson(J.endNode),f.curve=e.ph.fromJson(J.curve),f}static toJson(f){return{uidInPackage:e.ph.toJson(f._uidInPackage),p2Line:O.x1.toJson(f.p2Line),startNode:e.ph.toJson(f.startNode),endNode:e.ph.toJson(f.endNode),curve:e.ph.toJson(f.curve)}}}class r extends g{constructor(){super(...arguments),this.lineSpans=[],this.spanFlags=0}lineType(){return E.gb.WALL}static fromJson(f){const J=new r;return g.fromJson(J,f),J.lineSpans=f.lineSpans.map(L=>e.Uq.fromJson(L)),J}static toJson(f){const J=g.toJson(f);return J.lineSpans=f.lineSpans.map(L=>e.Uq.toJson(L)),J}}class a extends g{lineType(){return E.gb.CORRIDOR}static fromJson(f){const J=new a;return g.fromJson(J,f),J}static toJson(f){return g.toJson(f)}}class n extends g{constructor(){super(...arguments),this.corridorLinks=[]}lineType(){return E.gb.CIRCULATION}static fromJson(f){const J=new n;return g.fromJson(J,f),J.corridorLinks=f.corridorLinks.map(L=>h.fromJson(L)),J}static toJson(f){const J=g.toJson(f);return J.corridorLinks=f.corridorLinks.map(L=>h.toJson(L)),J}}class l extends g{constructor(){super(...arguments),this.obstacleType=e.xe.POST}lineType(){return E.gb.OBSTACLE}static fromJson(f){const J=new l;return g.fromJson(J,f),J.obstacleType=e.xe[f.obstacleType.toUpperCase()],J}static toJson(f){const J=g.toJson(f);return J.obstacleType=f.obstacleType.toLowerCase(),J}}class p extends g{lineType(){return E.gb.LIGHT}static fromJson(f){const J=new p;return g.fromJson(J,f),J}static toJson(f){return g.toJson(f)}}class y extends g{constructor(){super(...arguments),this.facadeNode=new e.ph}lineType(){return E.gb.PARTITIONABLE}static fromJson(f){const J=new y;return g.fromJson(J,f),J.facadeNode=e.ph.fromJson(f.facadeNode),J.hitPosition=O.E9.fromJson(f.hitPosition),J}static toJson(f){const J=g.toJson(f);return J.facadeNode=e.ph.toJson(f.facadeNode),J.hitPosition=O.E9.toJson(f.hitPosition),J}}class D extends g{constructor(){super(...arguments),this.alignment=D.AlongAxisE.NONE,this.index=0}lineType(){return E.gb.GRID}static fromJson(f){const J=new D;return g.fromJson(J,f),J.index=f.index,J}static toJson(f){const J=g.toJson(f);return J.index=f.index,J}}!function(x){let f;var J;(J=f=x.AlongAxisE||(x.AlongAxisE={})).NONE="none",J.HORIZONTAL="horizontal",J.VERTICAL="vertical"}(D||(D={}));class Y extends g{lineType(){return E.gb.MODULE}static fromJson(f){const J=new Y;return g.fromJson(J,f),J}static toJson(f){return g.toJson(f)}}class H extends g{lineType(){return E.gb.MODULE_CATEGORY}static fromJson(f){const J=new H;return g.fromJson(J,f),J}static toJson(f){return g.toJson(f)}}class ne extends g{constructor(){super(...arguments),this.index=0}lineType(){return E.gb.CONSTRUCTION}static fromJson(f){const J=new ne;return g.fromJson(J,f),J.index=f.index,J}static toJson(f){const J=g.toJson(f);return J.index=f.index,J}}class K extends g{constructor(){super(...arguments),this.partitionSpans=[]}lineType(){return E.gb.PARTITION}static fromJson(f){const J=new K;return g.fromJson(J,f),J.partitionSpans=f.partitionSpans.map(L=>v.fromJson(L)),J}static toJson(f){let J=g.toJson(f);return J.partitionSpans=f.partitionSpans.map(L=>v.toJson(L)),J}}class k extends g{lineType(){return E.gb.FURNITURE}static fromJson(f){const J=new k;return g.fromJson(J,f),J}static toJson(f){return g.toJson(f)}}},56220:(tt,me,P)=>{P.d(me,{BA:()=>n,BL:()=>p,EE:()=>l,EX:()=>h,GY:()=>Y,UM:()=>a,Zo:()=>g,hL:()=>r,iF:()=>y,kK:()=>ne,od:()=>D,xi:()=>H});var e=P(21449),E=P(38976),X=P(4516),O=P(56095);class v{constructor(){this._uidInPackage=new e.ph,this.previousLine=new e.ph,this.nextLine=new e.ph,this.curve=new e.ph}elementType(){return e.TE.NODE_INFO}static ElementType(){return e.TE.NODE_INFO}elementId(){return this._uidInPackage.asElementId()}uidInPackage(){return this._uidInPackage}isNode(){return!0}isLine(){return!1}isCurved(){return!this.curve.isNull()}getRequiredElementUids(){return new Map([[e.TE.LINE_INFO,new X.bI([this.previousLine,this.nextLine])]])}equals(k){return null!=k&&this._uidInPackage===k._uidInPackage}hashCode(){return this._uidInPackage.hashCode()}static fromJson(k,x){return k._uidInPackage=e.ph.fromJson(x.uidInPackage),k.position=O.E9.fromJson(x.position),k.previousLine=e.ph.fromJson(x.previousLine),k.nextLine=e.ph.fromJson(x.nextLine),k.normalToInside=O.
1E9.fromJson(x.normalToInside),k.curve=e.ph.fromJson(x.curve),k}static toJson(k){return{uidInPackage:e.ph.toJson(k._uidInPackage),position:O.E9.toJson(k.position),previousLine:e.ph.toJson(k.previousLine),nextLine:e.ph.toJson(k.nextLine),normalToInside:O.E9.toJson(k.normalToInside),curve:e.ph.toJson(k.curve)}}}class h extends v{constructor(){super(...arguments),this.isMullion=!1,this.mayPartition=!1}nodeType(){return E.Mq.WALL}static fromJson(k){const x=new h;return v.fromJson(x,k),x.isMullion=k.isMullion,x.mayPartition=k.mayPartition,x}static toJson(k){const x=v.toJson(k);return x.isMullion=k.isMullion,x.mayPartition=k.mayPartition,x}}class g extends v{nodeType(){return E.Mq.CORRIDOR}static fromJson(k){const x=new g;return v.fromJson(x,k),x}static toJson(k){return v.toJson(k)}}class r extends v{constructor(){super(...arguments),this.circulableType=e.Pv.NODE,this.circulable=new e.ph}nodeType(){return E.Mq.CIRCULATION}static fromJson(k){const x=new r;return v.fromJson(x,k),x.circulableType=e.Pv[k.circulableType.toUpperCase()],x.circulable=e.ph.fromJson(k.circulable),x}static toJson(k){const x=v.toJson(k);return x.circulableType=k.circulableType.toLowerCase(),x.circulable=e.ph.toJson(k.circulable),x}}class a extends v{constructor(){super(...arguments),this.obstacleType=e.xe.POST}nodeType(){return E.Mq.OBSTACLE}static fromJson(k){const x=new a;return v.fromJson(x,k),x.obstacleType=e.xe[k.obstacleType.toUpperCase()],x}static toJson(k){const x=v.toJson(k);return x.obstacleType=k.obstacleType.toLowerCase(),x}}class n extends v{constructor(){super(...arguments),this.lightType=e.CL.INDIRECT}nodeType(){return E.Mq.LIGHT}static fromJson(k){const x=new n;return v.fromJson(x,k),x.lightType=k.lightType,x}static toJson(k){const x=v.toJson(k);return x.lightType=k.lightType,x}}class l extends v{nodeType(){return E.Mq.PARTITIONABLE}static fromJson(k){const x=new l;return v.fromJson(x,k),x}static toJson(k){return v.toJson(k)}}class p extends v{nodeType(){return E.Mq.GRID}static fromJson(k){const x=new p;return v.fromJson(x,k),x}static toJson(k){return v.toJson(k)}}class y extends v{nodeType(){return E.Mq.MODULE}static fromJson(k){const x=new y;return v.fromJson(x,k),x}static toJson(k){return v.toJson(k)}}class D extends v{nodeType(){return E.Mq.MODULE_CATEGORY}static fromJson(k){const x=new D;return v.fromJson(x,k),x}static toJson(k){return v.toJson(k)}}class Y extends v{nodeType(){return E.Mq.CONSTRUCTION}static fromJson(k){const x=new Y;return v.fromJson(x,k),x}static toJson(k){return v.toJson(k)}}class H extends v{constructor(){super(...arguments),this.cornerMaterial_id=0,this.cornerRotation=0}nodeType(){return E.Mq.PARTITION}static fromJson(k){const x=new H;return v.fromJson(x,k),x}static toJson(k){return v.toJson(k)}}class ne extends v{nodeType(){return E.Mq.FURNITURE}static fromJson(k){const x=new ne;return v.fromJson(x,k),x}static toJson(k){return v.toJson(k)}}},70524:(tt,me,P)=>{P.d(me,{F:()=>X});var e=P(21449),E=P(4516);class X{constructor(){this.startNode=new e.ph,this.endNode=new e.ph,this.line=new e.ph}getRequiredElementUids(){return new Map([[e.TE.NODE_INFO,new E.bI([this.startNode,this.endNode])],[e.TE.LINE_INFO,new E.bI([this.line])]])}static fromJson(v){const h=new X;return h.startNode=e.ph.fromJson(v.startNode),h.endNode=e.ph.fromJson(v.endNode),h.line=e.ph.fromJson(v.line),h}static toJson(v){return{startNode:e.ph.toJson(v.startNode),endNode:e.ph.toJson(v.endNode),line:e.ph.toJson(v.line)}}}},92380:(tt,me,P)=>{P.d(me,{CZ:()=>e.CZ,Fn:()=>X.F,TX:()=>e.TX,Uh:()=>e.Uh,Wc:()=>e.Wc,Wm:()=>e.Wm,bK:()=>e.bK,dz:()=>E.d,k4:()=>e.k4,mx:()=>e.mx,un:()=>e.un});var e=P(66430),E=P(75110),X=P(70524)},75110:(tt,me,P)=>{P.d(me,{d:()=>O});var e=P(21449),E=P(70524),X=P(4516);class O{constructor(){this._uidInPackage=new e.ph,this.shapeA=new e.ph,this.shapeB=new e.ph,this.intersectionEdges=[]}elementType(){return e.TE.SHAPE_INTERSECTION_INFO}elementId(){return this._uidInPackage.asElementId()}uidInPackage(){return this._uidInPackage}getRequiredElementUids(){const h=new Map;h.set(e.TE.SHAPE_INFO,new X.bI([this.shapeA,this.shapeB]));for(const g of this.intersectionEdges)h.has(e.TE.NODE_INFO)||h.set(e.TE.NODE_INFO,new X.bI),h.get(e.TE.NODE_INFO).add(g.startNode),h.get(e.TE.NODE_INFO).add(g.endNode),h.has(e.TE.LINE_INFO)||h.set(e.TE.LINE_INFO,new X.bI),h.get(e.TE.LINE_INFO).add(g.line);return h}equals(h){return null!=h&&this._uidInPackage===h._uidInPackage}hashCode(){return this._uidInPackage.hashCode()}static fromJson(h){const g=new O;return g._uidInPackage=e.ph.fromJson(h.uidInPackage),g.shapeA=e.ph.fromJson(h.shapeA),g.shapeB=e.ph.fromJson(h.shapeB),g.intersectionEdges=h.intersectionEdges.map(r=>E.F.fromJson(r)),g}static toJson(h){return{uidInPackage:e.ph.toJson(h._uidInPackage),shapeA:e.ph.toJson(h.shapeA),shapeB:e.ph.toJson(h.shapeB),intersectionEdges:h.intersectionEdges.map(g=>E.F.toJson(g))}}}},66430:(tt,me,P)=>{P.d(me,{CZ:()=>D,TX:()=>a,Uh:()=>p,Wc:()=>H,Wm:()=>Y,bK:()=>l,k4:()=>r,mx:()=>n,un:()=>y});var e=P(21449),E=P(70524),X=P(38976),O=P(4516),v=P(47318),h=P(56095);class g{constructor(){this.startOffset=0,this.endOffset=0,this.isWindow=!1,this.irrigableLength=0}length(){return this.endOffset-this.startOffset}toString(){return`${this.isWindow?"w":"s"}(${this.length()})${this.startOffset}-${this.endOffset}[${this.irrigableLength}]`}static fromJson(K){const k=new g;return k.startOffset=K[0],k.endOffset=K[1],k.isWindow=K[2],k.irrigableLength=K.length>3?K[3]:0,k}static toJson(K){return[K.startOffset,K.endOffset,K.isWindow,K.irrigableLength]}}
1class r{constructor(){this._uidInPackage=new e.ph,this.outerPath=[],this.innerPaths=[],this.overlappingElementUids=[]}elementType(){return e.TE.SHAPE_INFO}static ElementType(){return e.TE.SHAPE_INFO}elementId(){return this._uidInPackage.asElementId()}uidInPackage(){return this._uidInPackage}getRequiredElementUids(){const K=new Map,k=x=>{for(const f of x)K.has(e.TE.NODE_INFO)||K.set(e.TE.NODE_INFO,new O.bI),K.get(e.TE.NODE_INFO).add(f.startNode),K.get(e.TE.NODE_INFO).add(f.endNode),K.has(e.TE.LINE_INFO)||K.set(e.TE.LINE_INFO,new O.bI),K.get(e.TE.LINE_INFO).add(f.line)};k(this.outerPath);for(const x of this.innerPaths)k(x);for(const x of this.overlappingElementUids)K[x.parts[x.parts.length-1].elementType]=K[x.parts[x.parts.length-1].elementType]||new Set,K[x.parts[x.parts.length-1].elementType].add(x);return K}equals(K){return null!=K&&this._uidInPackage===K._uidInPackage}hashCode(){return this._uidInPackage.hashCode()}static fromJson(K,k){function x(f){return f.map(J=>E.F.fromJson(J))}return K._uidInPackage=e.ph.fromJson(k.uidInPackage),K.outerPath=x(k.outerPath),K.innerPaths=k.innerPathes.map(f=>x(f)),K}static toJson(K){function k(x){return x.map(f=>E.F.toJson(f))}return{uidInPackage:e.ph.toJson(K._uidInPackage),outerPath:k(K.outerPath),innerPathes:K.innerPaths.map(x=>k(x))}}}class a extends r{constructor(){super(...arguments),this.corridorType=e.Wr.PRIMARY}shapeType(){return X.xR.CORRIDOR}static fromJson(K){const k=new a;return r.fromJson(k,K),k.corridorType=e.Wr[K.corridorType.toUpperCase()],k}static toJson(K){const k=r.toJson(K);return k.corridorType=K.corridorType.toString().toLowerCase(),k}}class n extends r{constructor(){super(...arguments),this.obstacleUid=new e.ph}shapeType(){return X.xR.OBSTACLE}static fromJson(K){const k=new n;return r.fromJson(k,K),k.obstacleUid=e.ph.fromJson(K.obstacleUid),k}static toJson(K){const k=r.toJson(K);return k.obstacleUid=e.ph.toJson(K.obstacleUid),k}}class l extends r{constructor(){super(...arguments),this.isDirectLight=!1}shapeType(){return X.xR.LIGHT}static fromJson(K){const k=new l;return r.fromJson(k,K),k.isDirectLight=K.isDirectLight,k}static toJson(K){const k=r.toJson(K);return k.isDirectLight=K.isDirectLight,k}}let p=(()=>{class ne extends r{constructor(){super(...arguments),this.type=X.W5.STRAIGHT,this.width=0,this.height=0,this.isReceptionFriendly=!1,this.partitionableSpans=[],this.startPerpLineUid=new e.ph,this.endPerpLineUid=new e.ph,this.startPerpDir=null,this.endPerpDir=null,this.corridorWidth=0,this.overlappingPartitionableShapeUids=[]}static#e=this.JKEY="PartitionableShapeInfo";shapeType(){return X.xR.PARTITIONABLE}isIrrigated(){return this.corridorWidth>1}get isCorner(){return this.type===X.W5.CORNER}get isStraight(){return this.type===X.W5.STRAIGHT}static fromJson(k,x){const f=new ne;return r.fromJson(f,k),f.type=X.W5[k.partitionableType.toUpperCase()],f.width=k.width||1,f.height=k.height||1,f.isReceptionFriendly=k.isReceptionFriendly??!1,f.corridorWidth=k.corridorWidth,f.overlappingPartitionableShapeUids=k.overlappingPartitionableShapeUids.map(J=>e.ph.fromJson(J)),f.startPerpLineUid=e.ph.fromJson(k.startPerpLineUid),f.endPerpLineUid=e.ph.fromJson(k.endPerpLineUid),f.startPerpDir=k.startPerpDir?h.E9.fromJson(k.startPerpDir):null,f.endPerpDir=k.endPerpDir?h.E9.fromJson(k.endPerpDir):null,f.partitionableSpans=k.partitionableSpans.map(J=>g.fromJson(J)),x?.setStringKeyRef(ne.JKEY,f._uidInPackage.toString(),f),f}static toJson(k){const x=r.toJson(k);return Object.assign(x,{partitionableType:k.type.toString().toLowerCase(),width:k.width,height:k.height,corridorWidth:k.corridorWidth,overlappingPartitionableShapeUids:k.overlappingPartitionableShapeUids.map(f=>e.ph.toJson(f)),startPerpLineUid:e.ph.toJson(k.startPerpLineUid),endPerpLineUid:e.ph.toJson(k.endPerpLineUid),startPerpDir:k.startPerpDir?h.E9.toJson(k.startPerpDir):void 0,endPerpDir:k.endPerpDir?h.E9.toJson(k.endPerpDir):void 0,partitionableSpans:k.partitionableSpans.map(f=>g.toJson(f))}),k.isReceptionFriendly&&(x.isReceptionFriendly=k.isReceptionFriendly),x}}return ne})();class y extends r{constructor(){super(...arguments),this.hasOrientation=!0,this.worldToLocalMtx=[],this.gridLineUids=[],this.cellCount=0,this.columns=0,this.rows=0,this.irrigatedCoords=[],this.wallCoords=[],this.laneConfigurations=[],this.laneClusters=[],this.receptionFriendlyCells=[]}shapeType(){return X.xR.GRID}static fromJson(K){const k=new y;return r.fromJson(k,K),k.hasOrientation=K.hasOrientation,k.worldToLocalMtx=K.worldToLocalMtx,k.gridLineUids=K.gridLineUids.map(x=>
1e.ph.fromJson(x)),k.cellCount=K.cellCount,k.columns=K.columns,k.rows=K.rows,k.irrigatedCoords=K.irrigatedCoords,k.wallCoords=K.wallCoords,k.laneConfigurations=K?.laneConfigurations?.map(x=>y.LaneConfiguration.fromJson(x))||[],k.laneClusters=K?.laneClusters?.map(x=>y.LaneClusterInfo.fromJson(x))||[],k.receptionFriendlyCells=K?.receptionFriendlyCells||[],k}static toJson(K){const k=r.toJson(K);return k.hasOrientation=K.hasOrientation,k.worldToLocalMtx=K.worldToLocalMtx,k.gridLineUids=K.gridLineUids.map(x=>e.ph.toJson(x)),k.cellCount=K.cellCount,k.columns=K.columns,k.rows=K.rows,k.irrigatedCoords=K.irrigatedCoords,k.wallCoords=K.wallCoords,k.laneConfigurations=K.laneConfigurations.map(x=>y.LaneConfiguration.toJson(x)),k.laneClusters=K.laneClusters.map(x=>y.LaneClusterInfo.toJson(x)),k.receptionFriendlyCells=K.receptionFriendlyCells,k}getPointCoord(K,k=60,x=!1,f=!0){const J=v.Uf(K,this.worldToLocalMtx);let L=x?J.getX()/k:Math.floor(J.getX()/k),ce=x?J.getY()/k:Math.floor(J.getY()/k);return f&&(L=Math.max(0,Math.min(this.columns-1,L)),ce=Math.max(0,Math.min(this.rows-1,ce))),[L,ce]}createPoint(K,k=60){const x=v.Pu(K[0]*k+k/2,K[1]*k+k/2);return v.Uf(x,v.Pk(this.worldToLocalMtx))}createPolygon(K,k,x=60){const f=v.p([{x:K[0]*x,y:K[1]*x},{x:K[0]*x,y:(k[1]+1)*x},{x:(k[0]+1)*x,y:(k[1]+1)*x},{x:(k[0]+1)*x,y:K[1]*x}]);return v.Uf(f,v.Pk(this.worldToLocalMtx))}getRectangleCoords(K,k=60){const x=v.Uf(K,this.worldToLocalMtx),f=this.columns,J=this.rows,L=x.getEnvelopeInternal(),ce=L.getMinX(),ke=L.getMinY(),Xe=L.getMaxX(),te=L.getMaxY();return[[Math.max(0,Math.min(f,Math.floor(ce/k))),Math.max(0,Math.min(J,Math.floor(ke/k)))],[Math.max(0,Math.min(f,Math.floor(Xe/k))),Math.max(0,Math.min(J,Math.floor(te/k)))]]}computeCentroidP2l(K,k,x,f,J=60){const L=this.createPoint(K,J);let ce=null,ke=null;"t"===k?(ce=[K[0],f[1]],ke=[K[0],x[1]]):"b"===k?(ce=[K[0],x[1]],ke=[K[0],f[1]]):"l"===k?(ce=[x[0],K[1]],ke=[f[0],K[1]]):(ce=[f[0],K[1]],ke=[x[0],K[1]]);const Xe=this.createPoint(ce,J),te=this.createPoint(ke,J);return[L,v.uM(Xe,te)]}}!function(ne){class K{constructor(){this.isAlongHorizontal=!0,this.forbiddenLaneFullIdx=[],this.rect=[[0,0],[0,0]]}get cellArea(){return(this.rect[1][0]-this.rect[0][0])*(this.rect[1][1]-this.rect[0][1])}static fromJson(L){const ce=new K;return ce.isAlongHorizontal=L.isAlongHorizontal,ce.forbiddenLaneFullIdx=L.forbiddenLaneFullIdx,ce.rect=L.rect,ce}static toJson(L){return{isAlongHorizontal:L.isAlongHorizontal,forbiddenLaneFullIdx:L.forbiddenLaneFullIdx,rect:L.rect}}}ne.LaneInfo=K;class k{constructor(){this.parentClusterIdxes=[],this.lanes=[],this.middleLaneIdx=0,this.hitPrimary=!1}get isRoot(){return 0===this.parentClusterIdxes.length}get middleLane(){return 0<=this.middleLaneIdx&&this.middleLaneIdx<this.lanes.length?this.lanes[this.middleLaneIdx]:this.lanes[0]}static fromJson(L){const ce=new k;return ce.parentClusterIdxes=L.parentClusterIdxes,ce.lanes=L.lanes.map(ke=>K.fromJson(ke)),ce.middleLaneIdx=L.middleLaneIdx,ce.hitPrimary=L.hitPrimary,ce}static toJson(L){return{parentClusterIdxes:L.parentClusterIdxes,lanes:L.lanes.map(ce=>K.toJson(ce)),middleLaneIdx:L.middleLaneIdx,hitPrimary:L.hitPrimary}}}ne.LaneClusterInfo=k;class x{constructor(){this.rect=[[0,0],[0,0]],this.left=new ne.ConfigurationRect.Side,this.right=new ne.ConfigurationRect.Side,this.top=new ne.ConfigurationRect.Side,this.bottom=new ne.ConfigurationRect.Side,this.distToEntrance=null,this.distToCore=null,this.distToDirectLight=null}width(L=!1){return this.rect[1][0]-this.rect[0][0]+1+(L?this.left.extraCells:0)+(L?this.right.extraCells:0)}height(L=!1){return this.rect[1][1]-this.rect[0][1]+1+(L?this.top.extraCells:0)+(L?this.bottom.extraCells:0)}hasCoord(L){return this.rect[0][0]<=L[0]&&L[0]<=this.rect[1][0]&&this.rect[0][1]<=L[1]&&L[1]<=this.rect[1][1]}static fromJson(L){const ce=new x;return ce.rect=L.rect,ce.left=ne.ConfigurationRect.Side.fromJson(L.left),ce.right=ne.ConfigurationRect.Side.fromJson(L.right),ce.top=ne.ConfigurationRect.Side.fromJson(L.top),ce.bottom=ne.ConfigurationRect.Side.fromJson(L.bottom),ce.distToEntrance=L.distToEntrance,ce.distToCore=L.distToCore,ce.distToDirectLight=L.distToDirectLight,ce}static toJson(L){return{rect:L.rect,left:ne.ConfigurationRect.Side.toJson(L.left),right:ne.ConfigurationRect.Side.toJson(L.right),top:ne.ConfigurationRect.Side.toJson(L.top),bottom:ne.ConfigurationRect.Side.toJson(L.bottom),distToEntrance:L.distToEntrance,distToCore:L.distToCore,distToDirectLight:L.distToDirectLight}}}ne.ConfigurationRect=x,function(J){class L{constructor(){this.irrigation=null,this._extraCells=null,this.hitWall=!1,this.partialLength=null}get extraCells(){return null!==this._extraCells?this._extraCells:0}static fromJson(ke){const Xe=new L;return Xe.irrigation=ke.irrigation,Xe._extraCells=ke._extraCells,Xe.hitWall=ke.hitWall,Xe.partialLength=ke.partialLength,Xe}static toJson(ke){return{irrigation:ke.irrigation,_extraCells:ke._extraCells,hitWall:ke.hitWall,partialLength:ke.partialLength}}}J.Side=L}(x=ne.ConfigurationRect||(ne.ConfigurationRect={}));class f{constructor(){this.usedClusterIdxes=[],this.rects=[]}static fromJson(L){const ce=new f;return ce.usedClusterIdxes=L.usedClusterIdxes,ce.rects=L.rects.map(ke=>ne.ConfigurationRect.fromJson(ke)),ce}static toJson(L){return{usedClusterIdxes:L.usedClusterIdxes,rects:L.rects.map(ce=>ne.ConfigurationRect.toJson(ce))}}}ne.LaneConfiguration=f}(y||(y={}));class D extends r{constructor(){super(...arguments),this.moduleOrProgramModuleUid=new e.ph,this.isProgramModule=!0,this.overtakerDepartmentUid=new e.ph}shapeType(){return X.xR.MODULE}static fromJson(K){const k=new D;return r.fromJson(k,K),k.moduleOrProgramModuleUid=e.ph.fromJson(K.moduleUid),k.isProgramModule=k.moduleOrProgramModuleUid.asElementType()===e.TE.PROGRAM_MODULE,k.overtakerDepartmentUid=K.overtakerDepartmentUid?e.ph.fromJson(K.overtakerDepartmentUid):new e.ph,k}static toJson(K){const k=r.toJson(K);return k.moduleUid=e.ph.toJson(K.moduleOrProgramModuleUid),K.overtakerDepartmentUid.isNull()||(k.overtakerDepartmentUid=e.ph.toJson(K.overtakerDepartmentUid)),k}}class Y extends r{constructor(){super(...arguments),this.moduleCategoryIdOrDepartmentName=0,this.useTypeOrDepartmentWorkforce=0}
1shapeType(){return X.xR.MODULE_CATEGORY}isDepartment(){return"string"==typeof this.moduleCategoryIdOrDepartmentName&&""!==this.moduleCategoryIdOrDepartmentName}static fromJson(K){const k=new Y;return r.fromJson(k,K),k.moduleCategoryIdOrDepartmentName=K.catIdOrDepName,k.useTypeOrDepartmentWorkforce=K.typeOrWorkforce,k}static toJson(K){const k=r.toJson(K);return k.catIdOrDepName=K.moduleCategoryIdOrDepartmentName,k.typeOrWorkforce=K.useTypeOrDepartmentWorkforce,k}}class H extends r{constructor(){super(...arguments),this.furnitureUri="",this.orientation=0}shapeType(){return X.xR.FURNITURE}static fromJson(K){const k=new H;return r.fromJson(k,K),k.furnitureUri=K.furnitureUri,k.orientation=K.orientation,k}static toJson(K){const k=r.toJson(K);return k.furnitureUri=K.furnitureUri,k.orientation=K.orientation,k}}},38976:(tt,me,P)=>{P.d(me,{yO:()=>a,gb:()=>X,nD:()=>g,Mq:()=>E,W5:()=>e.W,xR:()=>e.x,g2:()=>r});var e=P(96038),E=function(n){return n.WALL="wall",n.CORRIDOR="corridor",n.CIRCULATION="circulation",n.LIGHT="light",n.PARTITIONABLE="partitionable",n.GRID="grid",n.MODULE="module",n.MODULE_CATEGORY="module_category",n.OBSTACLE="obstacle",n.CONSTRUCTION="construction",n.PARTITION="partition",n.FURNITURE="furniture",n.NAVIGABLE="navigable",n}(E||{}),X=function(n){return n.WALL="wall",n.CORRIDOR="corridor",n.CIRCULATION="circulation",n.LIGHT="light",n.PARTITIONABLE="partitionable",n.GRID="grid",n.MODULE="module",n.MODULE_CATEGORY="module_category",n.OBSTACLE="obstacle",n.CONSTRUCTION="construction",n.PARTITION="partition",n.FURNITURE="furniture",n.NAVIGABLE="navigable",n}(X||{}),O=P(52901),v=P(56557),h=P(76274);class g{constructor(l){this.TInfo=l}}class r{constructor(l=null){this._uidInPackage=null,this._uidInPackage=l}uidInPackage(){return this._uidInPackage}buildUid(l,p){return(!this._uidInPackage||this._uidInPackage.isNull())&&(this._uidInPackage=l.append(new O.g(this.Tpl().TInfo.ElementType(),h.LM.generateId(this.Tpl().TInfo.ElementType(),p?v.XW.GENERATE_NEGATIVE:v.XW.GENERATE_POSITIVE)))),this._uidInPackage}}class a{constructor(){this._refCount=0,this._linkedNavigable=null}clone(l){return l._refCount=this._refCount,l._linkedNavigable=this._linkedNavigable,l}equals(l){return this.uidInPackage().equals(l.uidInPackage())}refCount(){return this._refCount}templatedLinkedNavigable(){return this._linkedNavigable}linkedNavigable(){return this._linkedNavigable}uidInPackage(){return this.linkedLayerElementInfo().uidInPackage()}increment(){this._refCount+=1}decrement(){return this._refCount-=1,this._refCount<=0}setNavigable(l){this._linkedNavigable=l}canBeRemoved(l,p){let y=0;for(const D of p)y+=D.countLinksToParsed(this,!0);for(const D of l)y+=this.countLinksToPackageElement(D,!1);return this._refCount-y<=0}countLinksToParsed(l,p){return 0}countLinksToPackageElement(l,p){return 0}dispose(){this._linkedNavigable=null}}},96038:(tt,me,P)=>{P.d(me,{W:()=>E,x:()=>e});var e=function(X){return X.CORRIDOR="corridor",X.OBSTACLE="obstacle",X.LIGHT="light",X.PARTITIONABLE="partitionable",X.GRID="grid",X.MODULE="module",X.MODULE_CATEGORY="module_category",X.FURNITURE="furniture",X.NAVIGABLE="navigable",X}(e||{}),E=function(X){return X.STRAIGHT="straight",X.CURVED="curved",X.CORNER="corner",X}(E||{})},14960:(tt,me,P)=>{P.d(me,{j5:()=>p,bx:()=>y,Hh:()=>n,dd:()=>E,VA:()=>l,Dw:()=>e,nh:()=>g,gb:()=>D.gb,Mq:()=>D.Mq,W5:()=>D.W5,xR:()=>D.xR});var e=function(Y){return Y.NETWORK_WALL="network_wall",Y.NETWORK_CORRIDOR="network_corridor",Y.NETWORK_CIRCULATION="network_circulation",Y.NETWORK_LIGHT="network_light",Y.NETWORK_PARTITIONABLE="network_partitionable",Y.NETWORK_GRID="network_grid",Y.NETWORK_MODULE="network_module",Y.NETWORK_MODULE_CATEGORY="network_module_category",Y.NETWORK_OBSTACLE="network_obstacle",Y.NETWORK_CONSTRUCTION="network_construction",Y.NETWORK_PARTITION="network_partition",Y.NETWORK_FURNITURE="network_furniture",Y.SHAPE_CORRIDOR="shape_corridor",Y.SHAPE_LIGHT="shape_light",Y.SHAPE_PARTITIONABLE="shape_partitionable",Y.SHAPE_GRID="shape_grid",Y.SHAPE_OBSTACLE="shape_obstacle",Y.SHAPE_MODULE="shape_module",Y.SHAPE_MODULE_CATEGORY="shape_module_category",Y.SHAPE_FURNITURE="shape_furniture",Y}(e||{}),E=function(Y){return Y[Y.NETWORK=0]="NETWORK",Y[Y.SHAPE=1]="SHAPE",Y}(E||{}),X=P(52901),O=P(4516);class v{constructor(){this.canApply=!1,this.willRemoveParsedElement=null,this.removeClbk=null}isAlreadyRemoved(){return null==this.willRemoveParsedElement||!this.removeClbk}}class h{constructor(){this.canApply=!0,this.willRemoveParsedElementsMap=new Map,this.removeClbk=null}willRemoveParsedElements(){let H=[];for(const ne of this.willRemoveParsedElementsMap.values())H=H.concat(ne);return H}}class g{constructor(){this.currentSubStateFullUid=new X.p,this.lowerDirectory=null,this.currentDirectory=null,this.currentLayer=null,this.currentDirectoryFullLutClbks=[],this.subStateFullUidElementLutMap=new O.me,this.subStateFullUidElementProviderMap=new O.me}currentSubStateLuts(){return this.subStateFullUidElementLutMap.has(this.currentSubStateFullUid)||this.subStateFullUidElementLutMap.set(this.currentSubStateFullUid,new Map),this.subStateFullUidElementLutMap.get(this.currentSubStateFullUid)}currentDirectoryLut(){const H=this.currentSubStateLuts();return H.has(this.currentDirectory.directoryType())||H.set(this.currentDirectory.directoryType(),new O.nI),H.get(this.currentDirectory.directoryType())}lowerDirectoryLut(){if(!this.lowerDirectory)return new O.nI;const H=this.currentSubStateLuts();return H.has(this.lowerDirectory.directoryType())||H.set(this.lowerDirectory.directoryType(),new O.nI),H.get(this.lowerDirectory.directoryType())}currentElementProvider(){return this.subStateFullUidElementProviderMap.get(this.currentSubStateFullUid)}}(g||(g={})).LutK=class H{constructor(K=new X.p,k=new X.p){if(this.initial=K,this.actual=k,"string"==typeof K||"string"==typeof k)throw console.error("LutK should not be initialized with string UIDs",this),new Error("LutK should not be initialized with string UIDs")}isLessThan(K){return this.actual.isNull()||K.actual.isNull()?this.initial.asElementId()<K.initial.asElementId():this.actual.asElementId()<K.actual.asElementId()}equals(K){return this.actual.isNull()||K.actual.isNull()?this.initial.equals(K.initial):this.actual.equals(K.actual)}toString(){return`LayeringAddClbkArg.LutK(initial=${this.initial}, actual=${this.actual})`}};
1class r{constructor(H,ne){this.layer=null,this.requiredElementUids=new Map,this.addClbk=null,this.layer=H,this.requiredElementUids=ne}}(r||(r={})).AddClbkResult=class H{constructor(){this.fromLayer=e.NETWORK_WALL,this.wasInfoRectified=!1,this.wasParsedActuallyAdded=!1,this.initialInfoUid=new X.p,this.elementInfo=null,this.parsedElement=null}};class a{constructor(){this.directory=null,this.requiredElementUids=new Map,this.addClbk=null}}!function(Y){class H{constructor(){this.directoryType=E.NETWORK,this.hasActuallyAdded=!1,this.addedElements=new Map}}Y.AddClbkResult=H,(H=Y.AddClbkResult||(Y.AddClbkResult={})).Item=class K{constructor(x,f){this.wasNavigableActuallyAdded=!1,this.elementInfo=null,this.parsedElement=null,this.navigable=null,this.fromLayer=x,this.wasInfoRectified=f.wasInfoRectified,this.wasParsedActuallyAdded=f.wasParsedActuallyAdded,this.initialInfoUid=f.initialInfoUid,this.elementInfo=f.elementInfo,this.parsedElement=f.parsedElement}}}(a||(a={}));class n{constructor(){this.canApply=!1,this.removeClbk=null,this.addClbk=null,this.willRemoveParsedElementsMap=new Map}}!function(Y){class H{constructor(){this.hasActuallyAdded=!1,this.addedElementsMap=new Map}}Y.AddClbkResult=H,(H=Y.AddClbkResult||(Y.AddClbkResult={})).Item=class K{constructor(x,f){this.elementInfo=null,this.parsedElement=null,this.navigable=null,this.fromDirectory=x,this.fromLayer=f.fromLayer,this.wasInfoRectified=f.wasInfoRectified,this.wasParsedActuallyAdded=f.wasParsedActuallyAdded,this.wasNavigableActuallyAdded=f.wasNavigableActuallyAdded,this.initialInfoUid=f.initialInfoUid,this.elementInfo=f.elementInfo,this.parsedElement=f.parsedElement,this.navigable=f.navigable}}}(n||(n={}));class l{constructor(){this.elementProvider=null,this.fullUidParsedElementMap=new O.me,this.fullUidElementInfoMap=new O.me,this.navigableNetworkNodeMap=new O.WK,this.elementUidNavigableMap=new O.me}getElementInfoOrDefault(H){return this.fullUidElementInfoMap.get(H.uidInPackage())??H}getParsedElementOrError(H){if(!this.fullUidParsedElementMap.has(H.uidInPackage()))throw new Error("Parsed element not found in fullUidParsedElementMap");return this.fullUidParsedElementMap.get(H.uidInPackage())}}class p{tplTryAddElement(H,ne,K,k){const x=new r(this,k.getRequiredElementUids());return x.addClbk=f=>{const J=new r.AddClbkResult;if(J.fromLayer=this.layerType(),J.initialInfoUid=k.uidInPackage(),K.has(k.uidInPackage())){const L=K.get(k.uidInPackage());J.elementInfo=L.linkedLayerElementInfo(),J.parsedElement=L,J.wasParsedActuallyAdded=!1,J.wasInfoRectified=!1}else{const L=ne.create(ne,k,f),ce=L[0];K.set(k.uidInPackage(),ce),L[1]&&f.currentDirectoryFullLutClbks.push(ke=>L[1](ce,ke)),J.parsedElement=ce,J.elementInfo=k,J.wasParsedActuallyAdded=!0,J.wasInfoRectified=!1}return J},x}tplTryRemoveElement(H,ne,K,k){const x=new v;if(!H.has(ne.uidInPackage()))return x.canApply=!0,x;const f=H.get(ne.uidInPackage());
1return x.willRemoveParsedElement=f,f.canBeRemoved(K,k)?(x.canApply=!0,x.removeClbk=()=>{H.has(ne.uidInPackage())&&(f.dispose(),H.delete(ne.uidInPackage()))},x):(x.canApply=!1,x)}lt(H){return this.layerType()<H.layerType()}equals(H){return H instanceof p&&this.layerType()===H.layerType()}toString(){return`AbstractLayer(layerType=${this.layerType()})`}hash(){return this.layerType().toString().length}}class y{constructor(){this._parentRootDirectory=null}rootDirectory(){return this._parentRootDirectory}setRootDirectory(H){this._parentRootDirectory=H}directoryOrder(){return this.directoryType().toString().length}tryRemoveElements(H,ne){const K=new h,k=this._dispatchElements(H),x=[],f=[];for(const[J,L]of k.layerElementsMap.entries()){const ce=Array.from(L.orderElementsMap.keys()).sort((ke,Xe)=>Xe-ke);for(const ke of ce){for(const Xe of L.orderElementsMap.get(ke)){const te=L.layer.tryRemoveElement(Xe,H,ne);if(!(te.isAlreadyRemoved&&te.isAlreadyRemoved()||(K.canApply=te.canApply,K.willRemoveParsedElementsMap||(K.willRemoveParsedElementsMap=new Map),K.willRemoveParsedElementsMap.has(L.layer.layerType())||K.willRemoveParsedElementsMap.set(L.layer.layerType(),[]),K.willRemoveParsedElementsMap.get(L.layer.layerType()).push(te.willRemoveParsedElement),f.push(te.willRemoveParsedElement),x.push(te.removeClbk),K.canApply)))break}if(!K.canApply)break}if(!K.canApply)break}return K.canApply&&(K.removeClbk=()=>{this._breakLinksAndMayRemoveNavigables(f,ne);for(const J of x)J()}),K}tryAddElements(H){const ne=new a;ne.directory=this;const K=this._dispatchElements(H),k=[];for(const[f,J]of K.layerElementsMap.entries())for(const L of J.orderElementsMap.values())for(const ce of L)k.push(J.layer.tryAddElement(ce));for(const f of k)for(const[J,L]of f.requiredElementUids.entries()){ne.requiredElementUids||(ne.requiredElementUids=new Map),ne.requiredElementUids.has(J)||ne.requiredElementUids.set(J,new O.bI);for(const ce of L)ne.requiredElementUids.get(J).add(ce)}const x=K.directoryElements;for(const f of x.values())for(const J of f){const L=J.getRequiredElementUids();for(const[ce,ke]of L.entries()){ne.requiredElementUids.has(ce)||ne.requiredElementUids.set(ce,new O.bI);for(const Xe of ke)ne.requiredElementUids.get(ce).add(Xe)}}return ne.addClbk=f=>{const J=new a.AddClbkResult;J.directoryType=this.directoryType();const L=f.currentDirectoryLut();for(const ce of k){f.currentLayer=ce.layer;const ke=ce.addClbk(f);if(L.set(new g.LutK(ke.initialInfoUid,ke.elementInfo.uidInPackage()),ke.parsedElement),ke.wasParsedActuallyAdded){J.hasActuallyAdded=!0;const Xe=this._createOrLinkNavigable(ke.parsedElement),te=new a.AddClbkResult.Item(ke.fromLayer,ke);te.wasNavigableActuallyAdded=Xe[0],te.navigable=Xe[1],J.addedElements||(J.addedElements=new Map),J.addedElements.has(ke.fromLayer)||J.addedElements.set(ke.fromLayer,[]),J.addedElements.get(ke.fromLayer).push(te)}}for(const ce of f.currentDirectoryFullLutClbks)ce(f);return f.currentDirectoryFullLutClbks=[],f.currentLayer=null,this._finalizeAddCallback(k,f,x),J},ne}addRequiredElementsToLookupTable(H,ne){const K=ne.currentDirectoryLut(),k=this._getLayers(),x=this.manageInfoTypes();for(const[f,J]of H.entries())if(x.includes(f))for(const L of J)for(const ce of k){const ke=ce.tryGetParsedElement(f,L);if(null!=ke){K.set(new g.LutK(L,ke.uidInPackage()),ke);break}}}_dispatchElements(H){const ne=new y.DispatchResult,K=this._getLayers();for(const k of H){let x=null;for(const f of K)if(f.canHandleElement(k)){x=f;break}null!=x?(ne.layerElementsMap.has(x)||ne.layerElementsMap.set(x,new y.DispatchResult.Item(x)),ne.layerElementsMap.get(x).add(k)):(ne.directoryElements.has(k.elementType())||ne.directoryElements.set(k.elementType(),[]),ne.directoryElements.get(k.elementType()).push(k))}return ne}dispose(){this._parentRootDirectory=null,this._getLayers().forEach(H=>H?.dispose())}}!function(Y){class H{constructor(){this.layerElementsMap=new O.nI,this.directoryElements=new Map}}Y.DispatchResult=H,(H=Y.DispatchResult||(Y.DispatchResult={})).Item=class K{constructor(x){this.orderElementsMap=new Map,this.layer=x}add(x){const f=this.layer.getElementAddOrder(x);this.orderElementsMap.has(f)||this.orderElementsMap.set(f,[]),this.orderElementsMap.get(f).push(x)}}}(y||(y={}));var D=P(38976)},73636:(tt,me,P)=>{P.d(me,{m:()=>X});var O,e=P(14960);class E{constructor(){this.canApply=!0,this.subApplyerFullUidWillRemoveParsedElementsMap=new Map}absorb(v){this.canApply=this.canApply&&v.canApply;for(const[h,g]of v.subApplyerFullUidWillRemoveParsedElementsMap.entries())this.subApplyerFullUidWillRemoveParsedElementsMap.set(h,g)}absorbFromApplyer(v,h){this.canApply=this.canApply&&h.canApply,this.subApplyerFullUidWillRemoveParsedElementsMap.set(v.applyerFullUid(),h.willRemoveParsedElementsMap)}}class X{constructor(){this.canApply=!1,this.willRemoveArg=new E,this.addResult=new X.AddResult,this.packageManagerApplyClbks=[],this.removeClbks=[],this.addClbks=[],this.finalizeClbks=[]}absorb(v){return this.canApply=this.canApply&&v.canApply,this.packageManagerApplyClbks.push(...v.packageManagerApplyClbks),this.removeClbks.push(...v.removeClbks),this.addClbks.push(...v.addClbks),this.finalizeClbks.push(...v.finalizeClbks),this.willRemoveArg.absorb(v.willRemoveArg),this}absorbFromApplyer(v,h,g){this.canApply=this.canApply&&h.canApply,this.removeClbks.push(h.removeClbk),this.willRemoveArg.absorbFromApplyer(v,h);const r=h.addClbk,a=v.applyerFullUid();return this.addClbks.push(l=>(l.currentSubStateFullUid=a,l.subStateFullUidElementProviderMap.set(a,g),new X.AddClbkResult(a,r(l)))),this}}(O=X||(X={})).AddClbkResult=class v{constructor(r,a){this.subStateFullUid=r,this.rootResult=a}},O.AddResult=class h{constructor(){this.fullSubStateUidAddResultMap=new Map,this.lut=new e.nh}absorb(r){this.fullSubStateUidAddResultMap.set(r.subStateFullUid,r.rootResult)}}},43109:(tt,me,P)=>{P.d(me,{q:()=>X});var e=P(59693),E=P(21449);let X=(()=>{class O extends e.wP{constructor(){super(...arguments),this.fullUid=new E.ph,this._parentProvider=null,this._removeUids=[],this._requiredPackageUids=[],this._forbiddenPackageUids=[]}static#e=this.JKEY="AbstractParametricPackage";elementId(){return this.fullUid.asElementId()}parentProvider(){return this._parentProvider}requiredPackageUids(){return this._requiredPackageUids}
1forbiddenPackageUids(){return this._forbiddenPackageUids}getToRemoveElements(){const h=[];for(const g of this._removeUids){if(g.isNull())continue;const r=g.getPackageIdOrZero(),a=this.parentProvider()?.getPackage(r).package;if(a){const n=a.getElement(g.parts[g.parts.length-1].elementType,g.parts[g.parts.length-1].id);n&&h.push(n)}}return h}dispose(){this._parentProvider=null}static fromJson(h,g,r){return r&&(h.fullUid=E.ph.fromJson(r.fullUid),h._removeUids=(r.removeUids||[]).map(a=>E.ph.fromJson(a)),h._requiredPackageUids=(r.requiredPackageUids||[]).slice(),h._forbiddenPackageUids=(r.forbiddenPackageUids||[]).slice(),g?.setStringKeyRef(O.JKEY,h.fullUid.toString(),h)),h}static toJson(h){return{fullUid:E.ph.toJson(h.fullUid),removeUids:(h._removeUids||[]).map(g=>E.ph.toJson(g)),requiredPackageUids:h._requiredPackageUids,forbiddenPackageUids:h._forbiddenPackageUids,packageType:h.packageType().toString().toLowerCase()}}}return O})()},59693:(tt,me,P)=>{P.d(me,{IA:()=>g,Si:()=>O,Ss:()=>h,Uq:()=>v,WA:()=>E,wP:()=>X});var e=P(21449),E=function(r){return r.NONE="none",r.COMPOSITE="composite",r.ROOT_PROPERTY="root_property",r.ROOT_FLOOR="root_floor",r.ROOT_LOT="root_lot",r.PARAMETRIC_INITIAL="parametric_initial",r.PARAMETRIC_DIRECT_LIGHT_SECONDARY_CORRIDOR="parametric_direct_light_secondary_corridor",r.PARAMETRIC_DIRECT_LIGHT_CORNER_TERTIARY_CORRIDOR="parametric_direct_light_corner_tertiary_corridor",r.PARAMETRIC_INDIRECT_LIGHT_MANDATORY_CORRIDOR="parametric_indirect_light_mandatory_corridor",r.MACRO_PROPERTY="macro_property",r.MACRO_FLOOR="macro_floor",r.MICRO_PROPERTY="micro_property",r.MICRO_FLOOR="micro_floor",r.USER_PROPERTY="user_property",r.USER_FLOOR="user_floor",r.SCENARIO_PROPERTY="scenario_property",r.SCENARIO_FLOOR="scenario_floor",r}(E||{});class X extends e.LM{elementType(){return e.TE.PACKAGE}isPackageProvider(){return!1}transformToElements(a,n){for(const l of a)n.push(l)}}class O extends X{isPackageProvider(){return!0}}class v{constructor(){this.fullPathUid=new e.ph,this.package=null}}class h{constructor(){this.subStatePackages=[]}}(h||(h={})).Item=class a{constructor(){this.subStateUid=new e.ph,this.packages=[]}};class g extends X{constructor(){super(...arguments),this._parentProvider=null}elementId(){return 0}packageType(){return E.NONE}parentProvider(){return this._parentProvider}requiredPackageUids(){return[]}forbiddenPackageUids(){return[]}getToRemoveElements(){return[]}getToAddElements(){return[]}getElement(a,n){return null}dispose(){this._parentProvider=null}}},81640:(tt,me,P)=>{P.d(me,{Si:()=>e.Si,Uq:()=>e.Uq,Ss:()=>e.Ss,WA:()=>e.WA,BJ:()=>p,ET:()=>k});var e=P(59693),E=P(43109),X=P(56095),O=P(47318),v=P(21449),h=P(84322),g=P(92380);class r extends E.q{constructor(){super(),this.lightNodeInfos=[],this.lightLineInfos=[],this.lightShapeInfos=[],this.partitionableNodeInfos=[],this.partitionableLineInfos=[],this.partitionableShapeInfos=[],this.gridNodeInfos=[],this.gridLineInfos=[],this.gridShapeInfos=[],this.networkNodeLineLinkInfos=[],this.networkLineLineLinkInfos=[],this.shapeIntersectionInfos=[],this.directLightSpaces=O.lD(),this.indirectLightSpaces=O.lD()}packageType(){return e.WA.PARAMETRIC_INITIAL}getToAddElements(){return[...this.lightNodeInfos,...this.lightLineInfos,...this.lightShapeInfos,...this.partitionableNodeInfos,...this.partitionableLineInfos,...this.partitionableShapeInfos,...this.gridNodeInfos,...this.gridLineInfos,...this.gridShapeInfos,...this.networkNodeLineLinkInfos,...this.networkLineLineLinkInfos,...this.shapeIntersectionInfos]}getElement(f,J){if(f===v.TE.NODE_INFO){for(const L of[...this.lightNodeInfos,...this.partitionableNodeInfos,...this.gridNodeInfos])if(L.elementId()===J)return L}else if(f===v.TE.LINE_INFO){for(const L of[...this.lightLineInfos,...this.partitionableLineInfos,...this.gridLineInfos])if(L.elementId()===J)return L}else if(f===v.TE.SHAPE_INFO){for(const L of[...this.lightShapeInfos,...this.partitionableShapeInfos,...this.gridShapeInfos])if(L.elementId()===J)return L}else if(f===v.TE.NETWORK_NODE_LINE_LINK_INFO){for(const L of this.networkNodeLineLinkInfos)if(L.elementId()===J)return L}else if(f===v.TE.NETWORK_LINE_LINE_LINK_INFO){for(const L of this.networkLineLineLinkInfos)if(L.elementId()===J)return L}else if(f===v.TE.SHAPE_INTERSECTION_INFO)for(const L of this.shapeIntersectionInfos)if(L.elementId()===J)return L;return null}static fromJson(f,J,L){if(L=L||new r,E.q.fromJson(L,J,f),!L.fullUid||"function"!=typeof L.fullUid.asElementId)throw new TypeError("Invalid type for fullUid: "+typeof L.fullUid);return L.directLightSpaces=X.Kk.fromJson(f.directLightSpaces),L.indirectLightSpaces=X.Kk.fromJson(f.indirectLightSpaces),L.lightNodeInfos=(f.lightNodeInfos||[]).map(ce=>h.BA.fromJson(ce)),L.lightLineInfos=(f.lightLineInfos||[]).map(ce=>h.XX.fromJson(ce)),L.lightShapeInfos=(f.lightShapeInfos||[]).map(ce=>g.bK.fromJson(ce)),L.partitionableNodeInfos=(f.partitionableNodeInfos||[]).map(ce=>h.EE.fromJson(ce)),L.partitionableLineInfos=(f.partitionableLineInfos||[]).map(ce=>h.as.fromJson(ce)),L.partitionableShapeInfos=(f.partitionableShapeInfos||[]).map(ce=>g.Uh.fromJson(ce,J)),L.gridNodeInfos=(f.gridNodeInfos||[]).map(ce=>h.BL.fromJson(ce)),L.gridLineInfos=(f.gridLineInfos||[]).map(ce=>h._e.fromJson(ce)),L.gridShapeInfos=(f.gridShapeInfos||[]).map(ce=>g.un.fromJson(ce)),L.networkNodeLineLinkInfos=(f.networkNodeLineLinkInfos||[]).map(ce=>h.DY.fromJson(ce)),L.networkLineLineLinkInfos=(f.networkLineLineLinkInfos||[]).map(ce=>h.q$.fromJson(ce)),L.shapeIntersectionInfos=(f.shapeIntersectionInfos||[]).map(ce=>g.dz.fromJson(ce)),L}static toJson(f){const J=E.q.toJson(f);return Object.assign(J,{directLightSpaces:X.Kk.toJson(f.directLightSpaces),indirectLightSpaces:X.Kk.toJson(f.indirectLightSpaces),lightNodeInfos:(f.lightNodeInfos||[]).map(L=>h.BA.toJson(L)),lightLineInfos:(f.lightLineInfos||[]).map(L=>h.XX.toJson(L)),lightShapeInfos:(f.lightShapeInfos||[]).map(L=>g.bK.toJson(L)),partitionableNodeInfos:(f.partitionableNodeInfos||[]).map(L=>h.EE.toJson(L)),partitionableLineInfos:(f.partitionableLineInfos||[]).map(L=>h.as.toJson(L)),partitionableShapeInfos:(f.partitionableShapeInfos||[]).map(L=>g.Uh.toJson(L)),gridNodeInfos:(f.gridNodeInfos||[]).map(L=>h.BL.toJson(L)),gridLineInfos:(f.gridLineInfos||[]).map(L=>h._e.toJson(L)),gridShapeInfos:(f.gridShapeInfos||[]).map(L=>g.un.toJson(L)),networkNodeLineLinkInfos:(f.networkNodeLineLinkInfos||[]).map(L=>h.DY.toJson(L)),networkLineLineLinkInfos:(f.networkLineLineLinkInfos||[]).map(L=>h.q$.toJson(L)),shapeIntersectionInfos:(f.shapeIntersectionInfos||[]).map(L=>g.dz.toJson(L))}),J}}class a extends r{constructor(){super(...arguments),this.corridorNodeInfos=[],this.corridorLineInfos=[],this.corridorShapeInfo=null,this.circulationNodeInfos=[],this.circulationLineInfos=[]}packageType(){return e.WA.PARAMETRIC_DIRECT_LIGHT_SECONDARY_CORRIDOR}getToAddElements(){const f=super.getToAddElements();return f.push(...this.corridorNodeInfos),f.push(...this.corridorLineInfos),this.corridorShapeInfo&&f.push(this.corridorShapeInfo),f.push(...this.circulationNodeInfos),f.push(...this.circulationLineInfos),f}getElement(f,J){if(f===v.TE.NODE_INFO){for(const L of[...this.corridorNodeInfos,...this.circulationNodeInfos])if(L.elementId()===J)return L}else if(f===v.TE.LINE_INFO){for(const L of[...this.corridorLineInfos,...this.circulationLineInfos])if(L.elementId()===J)return L}else if(f===v.TE.SHAPE_INFO&&this.corridorShapeInfo&&this.corridorShapeInfo.elementId()===J)return this.corridorShapeInfo;return super.getElement(f,J)}static fromJson(f,J){const L=new a;
1return r.fromJson(f,J,L),L.corridorSpace=X.mg.fromJson(f.corridorSpace),L.corridorNodeInfos=(f.corridorNodeInfos||[]).map(ce=>h.Zo.fromJson(ce)),L.corridorLineInfos=(f.corridorLineInfos||[]).map(ce=>h.Eb.fromJson(ce)),L.corridorShapeInfo=g.TX.fromJson(f.corridorShapeInfo),L.circulationNodeInfos=(f.circulationNodeInfos||[]).map(ce=>h.hL.fromJson(ce)),L.circulationLineInfos=(f.circulationLineInfos||[]).map(ce=>h.nv.fromJson(ce)),L}static toJson(f){const J=r.toJson(f);return Object.assign(J,{corridorSpace:X.mg.toJson(f.corridorSpace),corridorNodeInfos:(f.corridorNodeInfos||[]).map(L=>h.Zo.toJson(L)),corridorLineInfos:(f.corridorLineInfos||[]).map(L=>h.Eb.toJson(L)),corridorShapeInfo:g.TX.toJson(f.corridorShapeInfo),circulationNodeInfos:(f.circulationNodeInfos||[]).map(L=>h.hL.toJson(L)),circulationLineInfos:(f.circulationLineInfos||[]).map(L=>h.nv.toJson(L))}),J}}class n extends a{packageType(){return e.WA.PARAMETRIC_DIRECT_LIGHT_CORNER_TERTIARY_CORRIDOR}}class l extends E.q{constructor(){super(...arguments),this.corridorNodeInfos=[],this.corridorLineInfos=[],this.corridorShapeInfos=[],this.circulationNodeInfos=[],this.circulationLineInfos=[],this.gridNodeInfos=[],this.gridLineInfos=[],this.gridShapeInfos=[],this.networkNodeLineLinkInfos=[],this.networkLineLineLinkInfos=[],this.shapeIntersectionInfos=[]}packageType(){return e.WA.PARAMETRIC_INDIRECT_LIGHT_MANDATORY_CORRIDOR}getToAddElements(){return[...this.corridorNodeInfos,...this.corridorLineInfos,...this.corridorShapeInfos,...this.circulationNodeInfos,...this.circulationLineInfos,...this.gridNodeInfos,...this.gridLineInfos,...this.gridShapeInfos,...this.networkNodeLineLinkInfos,...this.networkLineLineLinkInfos,...this.shapeIntersectionInfos]}getElement(f,J){if(f===v.TE.NODE_INFO){for(const L of[...this.corridorNodeInfos,...this.circulationNodeInfos,...this.gridNodeInfos])if(L.elementId()===J)return L}else if(f===v.TE.LINE_INFO){for(const L of[...this.corridorLineInfos,...this.circulationLineInfos,...this.gridLineInfos])if(L.elementId()===J)return L}else if(f===v.TE.SHAPE_INFO){for(const L of[...this.corridorShapeInfos,...this.gridShapeInfos])if(L.elementId()===J)return L}else if(f===v.TE.NETWORK_NODE_LINE_LINK_INFO){for(const L of this.networkNodeLineLinkInfos)if(L.elementId()===J)return L}else if(f===v.TE.NETWORK_LINE_LINE_LINK_INFO){for(const L of this.networkLineLineLinkInfos)if(L.elementId()===J)return L}else if(f===v.TE.SHAPE_INTERSECTION_INFO)for(const L of this.shapeIntersectionInfos)if(L.elementId()===J)return L;return null}static fromJson(f,J){const L=new l;return E.q.fromJson(L,J,f),L.corridorSpace=X.mg.fromJson(f.corridorSpace),L.corridorNodeInfos=(f.corridorNodeInfos||[]).map(ce=>h.Zo.fromJson(ce)),L.corridorLineInfos=(f.corridorLineInfos||[]).map(ce=>h.Eb.fromJson(ce)),L.corridorShapeInfos=(f.corridorShapeInfos||[]).map(ce=>g.TX.fromJson(ce)),L.circulationNodeInfos=(f.circulationNodeInfos||[]).map(ce=>h.hL.fromJson(ce)),L.circulationLineInfos=(f.circulationLineInfos||[]).map(ce=>h.nv.fromJson(ce)),L.gridNodeInfos=(f.gridNodeInfos||[]).map(ce=>h.BL.fromJson(ce)),L.gridLineInfos=(f.gridLineInfos||[]).map(ce=>h._e.fromJson(ce)),L.gridShapeInfos=(f.gridShapeInfos||[]).map(ce=>g.un.fromJson(ce)),L.networkNodeLineLinkInfos=(f.networkNodeLineLinkInfos||[]).map(ce=>h.DY.fromJson(ce)),L.networkLineLineLinkInfos=(f.networkLineLineLinkInfos||[]).map(ce=>h.q$.fromJson(ce)),L.shapeIntersectionInfos=(f.shapeIntersectionInfos||[]).map(ce=>g.dz.fromJson(ce)),L}static toJson(f){const J=E.q.toJson(f);return Object.assign(J,{corridorSpace:X.mg.toJson(f.corridorSpace),corridorNodeInfos:(f.corridorNodeInfos||[]).map(L=>h.Zo.toJson(L)),corridorLineInfos:(f.corridorLineInfos||[]).map(L=>h.Eb.toJson(L)),corridorShapeInfos:(f.corridorShapeInfos||[]).map(L=>g.TX.toJson(L)),circulationNodeInfos:(f.circulationNodeInfos||[]).map(L=>h.hL.toJson(L)),circulationLineInfos:(f.circulationLineInfos||[]).map(L=>h.nv.toJson(L)),gridNodeInfos:(f.gridNodeInfos||[]).map(L=>h.BL.toJson(L)),gridLineInfos:(f.gridLineInfos||[]).map(L=>h._e.toJson(L)),gridShapeInfos:(f.gridShapeInfos||[]).map(L=>g.un.toJson(L)),networkNodeLineLinkInfos:(f.networkNodeLineLinkInfos||[]).map(L=>h.DY.toJson(L)),networkLineLineLinkInfos:(f.networkLineLineLinkInfos||[]).map(L=>h.q$.toJson(L)),shapeIntersectionInfos:(f.shapeIntersectionInfos||[]).map(L=>g.dz.toJson(L))}),J}}class p extends e.Si{constructor(f){super(),this.initialPackage=new r,this.secondaryCorridorPackages=[],this.cornerTertiaryCorridorPackages=[],this.mandatoryCorridorPackages=[],this.targetL
1otPart=f}elementId(){return 0}packageType(){return e.WA.NONE}parentProvider(){return this}requiredPackageUids(){return[]}forbiddenPackageUids(){return[]}getToRemoveElements(){return[]}getToAddElements(){return[]}getElement(f,J){throw new Error("Cannot get element in PackageProvider")}hasPackageId(f){return this.initialPackage.elementId()===f||this.secondaryCorridorPackages.some(J=>J.elementId()===f)||this.cornerTertiaryCorridorPackages.some(J=>J.elementId()===f)||this.mandatoryCorridorPackages.some(J=>J.elementId()===f)}getPackages(){const f=new e.Ss,J=new e.Ss.Item;return J.subStateUid=this.targetLotPart.createUid(!0),J.packages.push(this.initialPackage),J.packages.push(...this.secondaryCorridorPackages),J.packages.push(...this.cornerTertiaryCorridorPackages),J.packages.push(...this.mandatoryCorridorPackages),f.subStatePackages.push(J),f}getPackage(f){const J=new e.Uq;if(J.fullPathUid=this.targetLotPart.createUid(!0),this.initialPackage.elementId()===f)J.package=this.initialPackage;else for(const L of[this.secondaryCorridorPackages,this.cornerTertiaryCorridorPackages,this.mandatoryCorridorPackages])for(const ce of L)if(ce.elementId()===f)return J.package=ce,J;return J}getChildrenPackages(f){const J=[];for(const L of[this.secondaryCorridorPackages,this.cornerTertiaryCorridorPackages,this.mandatoryCorridorPackages])for(const ce of L)f.elementId()in ce.requiredPackageUids()&&J.push(ce);return f.elementId()in this.initialPackage.requiredPackageUids()&&J.push(this.initialPackage),J}addPackage(f){return f instanceof a?this.secondaryCorridorPackages.push(f):f instanceof n?this.cornerTertiaryCorridorPackages.push(f):f instanceof l?this.mandatoryCorridorPackages.push(f):f instanceof r&&(this.initialPackage=f),f._parentProvider=this,f}dispose(){this.targetLotPart=null,this.initialPackage.dispose(),this.secondaryCorridorPackages.forEach(f=>f.dispose()),this.cornerTertiaryCorridorPackages.forEach(f=>f.dispose()),this.mandatoryCorridorPackages.forEach(f=>f.dispose()),this.initialPackage=null,this.secondaryCorridorPackages=[],this.cornerTertiaryCorridorPackages=[],this.mandatoryCorridorPackages=[]}static fromJson(f,J,L){const ce=new p(f);return ce.initialPackage=r.fromJson(J.initialPackage,L),ce.secondaryCorridorPackages=J.secondaryCorridorPackages.map(ke=>a.fromJson(ke,L)),ce.cornerTertiaryCorridorPackages=J.cornerTertiaryCorridorPackages.map(ke=>n.fromJson(ke,L)),ce.mandatoryCorridorPackages=J.mandatoryCorridorPackages.map(ke=>l.fromJson(ke,L)),ce}}var y=P(56557);class D extends e.wP{constructor(){super(...arguments),this._parentFloorPackage=null,this.lotPartIdx=0,this.wallNodeInfos=[],this.wallLineInfos=[],this.primaryCorridorNodeInfos=[],this.primaryCorridorLineInfos=[],this.primaryCorridorShapeInfos=[],this.primaryCirculationNodeInfos=[],this.primaryCirculationLineInfos=[],this.obstacleNodeInfos=[],this.obstacleLineInfos=[],this.obstacleShapeInfos=[],this.directLightNodeInfos=[],this.directLightLineInfos=[],this.networkNodeLineLinkInfos=[],this.networkLineLineLinkInfos=[],this.networkDoorLinkInfos=[]}get parentFloorPackage(){return this._parentFloorPackage}set parentFloorPackage(f){this._parentFloorPackage=f}elementId(){return this.lotPartIdx}packageType(){return e.WA.ROOT_LOT}parentProvider(){return this.parentFloorPackage}requiredPackageUids(){return[]}forbiddenPackageUids(){return[]}getToRemoveElements(){return[]}getToAddElements(){const f=[];return f.push(...this.wallNodeInfos),f.push(...this.wallLineInfos),f.push(...this.primaryCorridorNodeInfos),f.push(...this.primaryCorridorLineInfos),f.push(...this.primaryCorridorShapeInfos),f.push(...this.primaryCirculationNodeInfos),f.push(...this.primaryCirculationLineInfos),f.push(...this.obstacleNodeInfos),f.push(...this.obstacleLineInfos),f.push(...this.obstacleShapeInfos),f.push(...this.directLightNodeInfos),f.push(...this.directLightLineInfos),f.push(...this.networkNodeLineLinkInfos),f.push(...this.networkLineLineLinkInfos),f.push(...this.networkDoorLinkInfos),f}getElement(f,J){let L=[];f===y.TE.NODE_INFO?L=[this.wallNodeInfos,this.primaryCorridorNodeInfos,this.primaryCirculationNodeInfos,this.obstacleNodeInfos,this.directLightNodeInfos]:f===y.TE.LINE_INFO?L=[this.wallLineInfos,this.primaryCorridorLineInfos,this.primaryCirculationLineInfos,this.obstacleLineInfos,this.directLightLineInfos]:f===y.TE.SHAPE_INFO?L=[this.primaryCorridorShapeInfos,this.obstacleShapeInfos]:f===y.TE.NETWORK_NODE_LINE_LINK_INFO?L=[this.networkNodeLineLinkInfos]:f===y.TE.NETWORK_LINE_LINE_LINK_INFO?L=[this.networkLineLineLinkInfos]:f===y.TE.NETWORK_DOOR_LINK_INFO&&(L=[this.networkDoorLinkInfos]);for(const ce of L)for(const ke of ce)if(ke.elementId&&ke.elementId()===J)return ke;return null}dispose(){this._parentFloorPackage=null}static fromJson(f,J){const L=new D;return L.lotPartIdx=f.lotPartIdx,L.wallNodeInfos=(f.wallNodeInfos||[]).map(ce=>h.EX.fromJson(ce)),L.wallLineInfos=(f.wallLineInfos||[]).map(ce=>h.J9.fromJson(ce)),L.primaryCirculationNodeInfos=(f.primaryCirculationNodeInfos||[]).map(ce=>h.hL.fromJson(ce)),L.primaryCirculationLineInfos=(f.primaryCirculationLineInfos||[]).map(ce=>h.nv.fromJson(ce)),L.primaryCorridorNodeInfos=(f.primaryCorridorNodeInfos||[]).map(ce=>h.Zo.fromJson(ce)),L.primaryCorridorLineInfos=(f.primaryCorridorLineInfos||[]).map(ce=>h.Eb.fromJson(ce)),L.primaryCorridorShapeInfos=(f.primaryCorridorShapeInfos||[]).map(ce=>g.TX.fromJson(ce)),L.obstacleNodeInfos=(f.obstacleNodeInfos||[]).map(ce=>h.UM.fromJson(ce)),L.obstacleLineInfos=(f.obstacleLineInfos||[]).map(ce=>h.ze.fromJson(ce)),L.obstacleShapeInfos=(f.obstacleShapeInfos||[]).map(ce=>g.mx.fromJson(ce)),L.directLightNodeInfos=(f.directLightNodeInfos||[]).map(ce=>h.BA.fromJson(ce)),L.directLightLineInfos=(f.directLightLineInfos||[]).map(ce=>h.XX.fromJson(ce)),L.networkNodeLineLinkInfos=(f.networkNodeLineLinkInfos||[]).map(ce=>h.DY.fromJson(ce)),L.networkLineLineLinkInfos=(f.networkLineLineLinkInfos||[]).map(ce=>h.q$.fromJson(ce)),L.networkDoorLinkInfos=(f.networkDoorLinkInfos||[]).map(ce=>h.SQ.fromJson(ce)),L.parentFloorPackage=J,L}static toJson(f){return{lotPartIdx:f.lotPartIdx,wallNodeInfos:(f.wallNodeInfos||[]).map(J=>h.EX.toJson(J)),wallLineInfos:(f.wallLineInfos||[]).map(J=>h.J9.toJson(J)),primaryCirculationNodeInfos:(f.primaryCirculationNodeInfos||[]).map(J=>h.hL.toJson(J)),primaryCirculationLineInfos:(f.primaryCirculationLineInfos||[]).map(J=>h.nv.toJson(J)),primaryCorridorNodeInfos:(f.primaryCorridorNodeInfos||[]).map(J=>h.Zo.toJson(J)),primaryCorridorLineInfos:(f.primaryCorridorLineInfos||[]).map(J=>h.Eb.toJson(J)),primaryCorridorShapeInfos:(f.primaryCorridorShapeInfos||[]).map(J=>g.TX.toJson(J)),obstacleNodeInfos:(f.obstacleNodeInfos||[]).map(J=>h.UM.toJson(J)),obstacleLineInfos:(f.obstacleLineInfos||[]).map(J=>h.ze.toJson(J)),obstacleShapeInfos:(f.obstacleShapeInfos||[]).map(J=>g.mx.toJson(J)),directLightNodeInfos:(f.directLightNodeInfos||[]).map(J=>h.BA.toJson(J)),directLightLineInfos:(f.directLightLineInfos||[]).map(J=>h.XX.toJson(J)),networkNodeLineLinkInfos:(f.networkNodeLineLinkInfos||[]).map(J=>h.DY.toJson(J)),networkLineLineLinkInfos:(f.networkLineLineLinkInfos||[]).map(J=>h.q$.toJson(J)),networkDoorLinkInfos:(f.networkDoorLinkInfos||[]).map(J=>h.SQ.toJson(J))}}}var Y=P(4516);class H extends e.Si{constructor(){super(...arguments),this._parentRootPackage=null,this.lotUidPackageMap=new Y.nI,this.interLotNetworkDoorLinkInfos=[]}get parentRootPackage(){return this._parentRootPackage}set parentRootPackage(f){this._parentRootPackage=f}elementId(){return 0}packageType(){return e.WA.ROOT_FLOOR}parentProvider(){return this.parentRootPackage}requiredPackageUids(){return[]}
1forbiddenPackageUids(){return[]}getToRemoveElements(){return[]}getToAddElements(){return this.interLotNetworkDoorLinkInfos}getPackages(){const f=new e.Ss;for(const[J,L]of this.lotUidPackageMap.entries()){const ce=new e.Ss.Item;ce.subStateUid=J.uid,ce.packages.push(L),f.subStatePackages.push(ce)}return f}getPackage(f){const J=new e.Uq;for(const[L,ce]of this.lotUidPackageMap.entries())if(L.eid===f){J.package=ce,J.fullPathUid=L.uid;break}return J}getChildrenPackages(f){const J=[];for(const[L,ce]of this.lotUidPackageMap.entries())ce.requiredPackageUids().includes(f.elementId())&&J.push(ce);return J}getElement(f,J){if(f===y.TE.NETWORK_COMPARTIMENT_DOOR_LINK_INFO)for(const L of this.interLotNetworkDoorLinkInfos)if(L.elementId&&L.elementId()===J)return L;return null}getLotPackageAsList(){return Array.from(this.lotUidPackageMap.values())}dispose(){this._parentRootPackage=null,this.lotUidPackageMap.forEach(f=>f.dispose()),this.lotUidPackageMap.clear()}static fromJson(f,J){const L=new H;return L.interLotNetworkDoorLinkInfos=(f.interLotNetworkDoorLinkInfos||[]).map(ce=>h.J2.fromJson(ce)),L.lotUidPackageMap=new Y.nI,(f.lotUIdPackageMap||[]).forEach(ce=>{L.lotUidPackageMap.set(K.fromJson(ce.key),D.fromJson(ce.value,L))}),L.parentRootPackage=J,L}static toJson(f){return{interLotNetworkDoorLinkInfos:(f.interLotNetworkDoorLinkInfos||[]).map(J=>h.J2.toJson(J)),lotUIdPackageMap:Array.from((f.lotUidPackageMap||new Y.nI).entries()).map(([J,L])=>({key:K.toJson(J),value:D.toJson(L)}))}}}var ne=P(52901);class K{constructor(f=null,J=0){this.uid=f||new ne.p,this.eid=null==f?J:f.isNull()?0:f.parts[f.parts.length-1].id}equals(f){return this.uid.equals(f.uid)&&this.eid===f.eid}toString(){return this.uid.toString()+` (eid=${this.eid})`}static fromJson(f){return new K(ne.p.fromJson(f))}static toJson(f){return ne.p.toJson(f.uid)}}class k extends e.Si{constructor(){super(...arguments),this.floorUidPackageMap=new Y.nI,this.interFloorNetworkDoorLinkInfos=[]}elementId(){return 0}packageType(){return e.WA.ROOT_PROPERTY}parentProvider(){return this}requiredPackageUids(){return[]}forbiddenPackageUids(){return[]}getToRemoveElements(){return[]}getToAddElements(){return this.interFloorNetworkDoorLinkInfos}getPackages(){const f=new e.Ss;for(const[J,L]of this.floorUidPackageMap.entries()){const ce=new e.Ss.Item;ce.subStateUid=J.uid,ce.packages.push(L),f.subStatePackages.push(ce)}return f}getPackage(f){const J=new e.Uq;for(const[L,ce]of this.floorUidPackageMap.entries())if(L.eid===f){J.package=ce,J.fullPathUid=L.uid;break}return J}getChildrenPackages(f){return[]}getElement(f,J){if(f===y.TE.NETWORK_DOOR_LINK_INFO)for(const L of this.interFloorNetworkDoorLinkInfos)if(L.elementId&&L.elementId()===J)return L;return null}dispose(){this.floorUidPackageMap.forEach(f=>f.dispose()),this.floorUidPackageMap.clear()}static fromJson(f){const J=new k;return J.interFloorNetworkDoorLinkInfos=(f.interFloorNetworkDoorLinkInfos||[]).map(L=>h.SQ.fromJson(L)),J.floorUidPackageMap=new Y.nI,(f.floorUIdPackageMap||[]).forEach(L=>{J.floorUidPackageMap.set(K.fromJson(L.key),H.fromJson(L.value,J))}),J}static toJson(f){return{interFloorNetworkDoorLinkInfos:(f.interFloorNetworkDoorLinkInfos||[]).map(J=>h.SQ.toJson(J)),floorUIdPackageMap:Array.from((f.floorUidPackageMap||new Y.nI).entries()).map(([J,L])=>({key:K.toJson(J),value:H.toJson(L)}))}}}},35934:(tt,me,P)=>{P.d(me,{O:()=>Ae});var e=P(47318),E=P(21449),X=P(56095);class O{constructor(){this._coveredSpace=null,this.fullUid=null}uidInPackage(){return this.fullUid}elementType(){return E.TE.POST}elementId(){return this.fullUid.asElementId()}coveredSpace(){return this._coveredSpace}obstacleType(){return E.xe.POST}static fromJson(q,oe){const ee=new O;return ee._coveredSpace=X.mg.fromJson(q.coveredSpace??[]),ee.fullUid=E.ph.fromJson(q.fullUid??{}),ee}static toJson(q){return{coveredSpace:X.mg.toJson(q._coveredSpace),fullUid:E.ph.toJson(q.fullUid)}}}class v{constructor(){this._coveredSpace=null,this.fullUid=null}uidInPackage(){return this.fullUid}elementType(){return E.TE.EXISTING_PARTITION}elementId(){return this.fullUid.asElementId()}coveredSpace(){return this._coveredSpace}obstacleType(){return E.xe.EXISTING_PARTITION}static fromJson(q,oe){const ee=new v;return ee._coveredSpace=X.mg.fromJson(q.coveredSpace??[]),ee.fullUid=E.ph.fromJson(q.fullUid??{}),ee}static toJson(q){return{coveredSpace:X.mg.toJson(q._coveredSpace),fullUid:E.ph.toJson(q.fullUid)}}}class h{constructor(){this.p2Line=null,this.fullUid=null}elementType(){return E.TE.WINDOW}elementId(){return this.fullUid.asElementId()}static fromJson(q,oe){const ee=new h;return ee.p2Line=X.xl.fromJson(q.p2Line??[]),ee.fullUid=E.ph.fromJson(q.fullUid??{}),ee}static toJson(q){return{p2Line:X.xl.toJson(q.p2Line),fullUid:E.ph.toJson(q.fullUid)}}}class g{constructor(){this.fullUid=null,this.center=null,this.lines=null}
1elementType(){return E.TE.CURVE}elementId(){return this.fullUid.asElementId()}getDirection(q){return e.hX(e.uM(q,this.center))}static fromJson(q,oe){const ee=new g;return ee.fullUid=new E.ph,ee.center=X.E9.fromJson(q.center),ee.lines=X.g6.fromJson(q.lines??[]),ee}static toJson(q){return{fullUid:E.ph.toJson(q.fullUid),center:X.E9.toJson(q.center),lines:X.g6.toJson(q.lines)}}}class r{constructor(){this.p2Line=null,this.fullUid=null,this.isEntrance=!1}doorType(){return E.Ng.OTHER}elementType(){return E.TE.DOOR}elementId(){return this.fullUid.asElementId()}uidInPackage(){return this.fullUid}circulableType(){return E.Pv.PROPERTY_DOOR}getCenter(){return this.p2Line?e.Sc(this.p2Line):null}dispose(){}static fromJson(q,oe,ee){return(ee=ee??new r).p2Line=X.xl.fromJson(q.p2Line??[]),ee.fullUid=E.ph.fromJson(q.fullUid??{}),ee.isEntrance=q.isEntrance??!1,ee}static toJson(q){return{p2Line:X.xl.toJson(q.p2Line),fullUid:E.ph.toJson(q.fullUid),isEntrance:q.isEntrance}}}class a extends r{constructor(){super(...arguments),this._coreSpace=null}doorType(){return E.Ng.CORE}get coreSpace(){return this._coreSpace}set coreSpace(q){this._coreSpace=q}dispose(){this._coreSpace=null}static fromJson(q,oe){const ee=new a;return r.fromJson(q,oe,ee),ee.coreSpace=oe.coreSpaceMap.get(E.ph.fromJson(q.coreSpace??{})),ee}static toJson(q){const oe=r.toJson(q);return oe.coreSpace=q.coreSpace?E.ph.toJson(q.coreSpace.fullUid):null,oe}}class n extends r{constructor(){super(...arguments),this._terraceSpace=null}doorType(){return E.Ng.TERRACE}get terraceSpace(){return this._terraceSpace}set terraceSpace(q){this._terraceSpace=q}dispose(){this._terraceSpace=null}static fromJson(q,oe){const ee=new n;return r.fromJson(q,oe,ee),ee.terraceSpace=oe.terraceSpaceMap.get(E.ph.fromJson(q.terraceSpace??{})),ee}static toJson(q){const oe=r.toJson(q);return oe.terraceSpace=q.terraceSpace?E.ph.toJson(q.terraceSpace.fullUid):null,oe}}class l extends r{constructor(){super(...arguments),this._controlRoom=null}doorType(){return E.Ng.CONTROL_ROOM}get controlRoom(){return this._controlRoom}set controlRoom(q){this._controlRoom=q}dispose(){this._controlRoom=null}static fromJson(q,oe){const ee=new l;return r.fromJson(q,oe,ee),ee.controlRoom=oe.controlRoomMap.get(E.ph.fromJson(q.controlRoom??{})),ee}static toJson(q){const oe=r.toJson(q);return oe.controlRoom=q.controlRoom?E.ph.toJson(q.controlRoom.fullUid):null,oe}}class p extends r{constructor(){super(...arguments),this._existingRoom=null}doorType(){return E.Ng.EXISTING_ROOM}get existingRoom(){return this._existingRoom}set existingRoom(q){this._existingRoom=q}dispose(){this._existingRoom=null}static fromJson(q,oe){const ee=new p;return r.fromJson(q,oe,ee),ee.existingRoom=oe.existingRoomMap.get(E.ph.fromJson(q.existingRoom??{})),ee}static toJson(q){const oe=r.toJson(q);return oe.existingRoom=q.existingRoom?E.ph.toJson(q.existingRoom.fullUid):null,oe}}class y extends r{doorType(){return E.Ng.COMPARTIMENT}static fromJson(q,oe){const ee=new y;return r.fromJson(q,oe,ee),ee}static toJson(q){return r.toJson(q)}}class D{constructor(){this.fullUid=null,this._coveredSpace=null,this._door=null}uidInPackage(){return this.fullUid}elementType(){return E.TE.CONTROL_ROOM}elementId(){return this.fullUid.asElementId()}coveredSpace(){return this._coveredSpace}obstacleType(){return E.xe.CONTROL_ROOM}get door(){return this._door}set door(q){this._door=q}dispose(){this._door=null}static fromJson(q,oe){const ee=new D;return ee.fullUid=E.ph.fromJson(q.fullUid??{}),ee._coveredSpace=X.mg.fromJson(q.coveredSpace??[]),ee}static toJson(q){return{fullUid:E.ph.toJson(q.fullUid),coveredSpace:X.mg.toJson(q._coveredSpace)}}}class Y{constructor(){this.fullUid=null,this._coveredSpace=null,this._door=null}uidInPackage(){return this.fullUid}elementType(){return E.TE.EXISTING_ROOM}elementId(){return this.fullUid.asElementId()}coveredSpace(){return this._coveredSpace}obstacleType(){return E.xe.EXISTING_ROOM}get door(){return this._door}set door(q){this._door=q}dispose(){this._door=null}static fromJson(q,oe){const ee=new Y;return ee.fullUid=E.ph.fromJson(q.fullUid??{}),ee._coveredSpace=X.mg.fromJson(q.coveredSpace??[]),ee}static toJson(q){return{fullUid:E.ph.toJson(q.fullUid),coveredSpace:X.mg.toJson(q._coveredSpace)}}}class H{constructor(){this.fullUid=null,this.coveredSpace=null,this.doors=[]}
1elementType(){return E.TE.CORE_SPACE}elementId(){return this.fullUid.asElementId()}dispose(){this.doors=[]}static fromJson(q,oe){const ee=new H;return ee.fullUid=E.ph.fromJson(q.fullUid??{}),ee.coveredSpace=X.mg.fromJson(q.coveredSpace??[]),ee}static toJson(q){return{fullUid:E.ph.toJson(q.fullUid),coveredSpace:X.mg.toJson(q.coveredSpace)}}}class ne{constructor(){this.fullUid=null,this.coveredSpace=null,this.doors=[]}elementType(){return E.TE.TERRACE_SPACE}elementId(){return this.fullUid.asElementId()}dispose(){this.doors=[]}static fromJson(q,oe){const ee=new ne;return ee.fullUid=E.ph.fromJson(q.fullUid??{}),ee.coveredSpace=X.mg.fromJson(q.coveredSpace??[]),ee}static toJson(q){return{fullUid:E.ph.toJson(q.fullUid),coveredSpace:X.mg.toJson(q.coveredSpace)}}}class K{constructor(q){this._lotIndex=0,this._partIndex=0,this._posts=[],this._existingPartitions=[],this._controlRooms=[],this._existingRooms=[],this._windows=[],this._otherDoors=[],this._coreDoors=[],this._terraceDoors=[],this._controlRoomDoors=[],this._existingRoomDoors=[],this._curves=[],this._parentFloor=q}parentFloor(){return this._parentFloor}lotIndex(){return this._lotIndex}partIndex(){return this._partIndex}fullFreeSpace(){return this._fullFreeSpace}corridorSpaces(){return this._corridorSpaces}freeSpaces(){return this._freeSpaces}posts(){return this._posts}existingPartitions(){return this._existingPartitions}controlRooms(){return this._controlRooms}existingRooms(){return this._existingRooms}windows(){return this._windows}otherDoors(){return this._otherDoors}coreDoors(){return this._coreDoors}terraceDoors(){return this._terraceDoors}curves(){return this._curves}interiorWalls(){return this._interiorWalls}mullions(){return this._mullions}compartimentWalls(){return this._compartimentWalls}directLightLines(){return this._directLightLines}hasId(q,oe){return this._lotIndex===q&&this._partIndex===oe}equals(q){return this._lotIndex===q._lotIndex&&this._partIndex===q._partIndex}toString(){return this.createUid(!0).toString()}createUid(q){const oe=new E.ph;if(oe.parts.push(new E.gI(E.TE.UID_PART,this._lotIndex)),oe.parts.push(new E.gI(E.TE.UID_PART,this._partIndex)),q){oe.parts.unshift(new E.gI(E.TE.UID_SEPARATOR,1));const ee=this.parentFloor().createUid();oe.parts=ee.parts.concat(oe.parts)}return oe}getElement(q){if(q.isNull())return null;const oe=q.parts[q.parts.length-1].elementType,ee=q.asElementId();if(oe===E.TE.POST)return this._posts.find(Z=>Z.elementId()===ee)||null;if(oe===E.TE.EXISTING_PARTITION)return this._existingPartitions.find(Z=>Z.elementId()===ee)||null;if(oe===E.TE.CONTROL_ROOM)return this._controlRooms.find(Z=>Z.elementId()===ee)||null;if(oe===E.TE.EXISTING_ROOM)return this._existingRooms.find(Z=>Z.elementId()===ee)||null;if(oe===E.TE.WINDOW)return this._windows.find(Z=>Z.elementId()===ee)||null;if(oe===E.TE.DOOR){for(const Z of[this._otherDoors,this._coreDoors,this._terraceDoors]){const Q=Z.find(V=>V.elementId()===ee);if(Q)return Q}return null}return oe===E.TE.CURVE&&this._curves.find(Z=>Z.elementId()===ee)||null}dispose(){this._parentFloor=null,this._terraceDoors.forEach(q=>q.dispose()),this._terraceDoors=[],this._controlRoomDoors.forEach(q=>q.dispose()),this._controlRoomDoors=[],this._existingRoomDoors.forEach(q=>q.dispose()),this._existingRoomDoors=[],this._coreDoors.forEach(q=>q.dispose()),this._coreDoors=[],this._otherDoors.forEach(q=>q.dispose()),this._otherDoors=[],this._existingRooms.forEach(q=>q.dispose()),this._existingRooms=[],this._controlRooms.forEach(q=>q.dispose()),this._controlRooms=[]}static fromJson(q,oe,ee){const Z=new K(oe);return Z._lotIndex=q.lotIndex??0,Z._partIndex=q.partIndex??0,Z._fullFreeSpace=X.mg.fromJson(q.fullFreeSpace??[]),Z._corridorSpaces=X.Kk.fromJson(q.corridorSpaces??[]),Z._freeSpaces=X.Kk.fromJson(q.freeSpaces??[]),Z._posts=(q.posts??[]).map(Q=>O.fromJson(Q,ee)),Z._existingPartitions=(q.existingPartitions??[]).map(Q=>v.fromJson(Q,ee)),Z._controlRooms=(q.controlRooms??[]).map(Q=>D.fromJson(Q,ee)),Z._existingRooms=(q.existingRooms??[]).map(Q=>Y.fromJson(Q,ee)),Z._windows=(q.windows??[]).map(Q=>h.fromJson(Q,ee)),Z._otherDoors=(q.otherDoors??[]).map(Q=>r.fromJson(Q,ee)),Z._coreDoors=(q.coreDoors??[]).map(Q=>a.fromJson(Q,ee)),Z._terraceDoors=(q.terraceDoors??[]).map(Q=>n.fromJson(Q,ee)),Z._controlRoomDoors=(q.controlRoomDoors??[]).map(Q=>l.fromJson(Q,ee)),Z._existingRoomDoors=(q.existingRoomDoors??[]).map(Q=>p.fromJson(Q,ee)),Z._curves=(q.curves??[]).map(Q=>g.fromJson(Q,ee)),Z._interiorWalls=X.g6.fromJson(q.interiorWalls??[]),Z._mullions=X.g6.fromJson(q.mullions??[]),Z._compartimentWalls=X.Kk.fromJson(q.compartimentWalls??[]),Z._exteriorWalls=X.g6.fromJson(q.exteriorWalls??[]),Z._directLightLines=X.g6.fromJson(q.directLightLines??[]),Z}static toJson(q){return{lotIndex:q._lotIndex,partIndex:q._partIndex,fullFreeSpace:X.mg.toJson(q._fullFreeSpace),corridorSpaces:X.Kk.toJson(q._corridorSpaces),freeSpaces:X.Kk.toJson(q._freeSpaces),posts:q._posts.map(oe=>O.toJson(oe)),existingPartitions:q._existingPartitions.map(oe=>v.toJson(oe)),controlRooms:q._controlRooms.map(oe=>D.toJson(oe)),existingRooms:q._existingRooms.map(oe=>Y.toJson(oe)),windows:q._windows.map(oe=>h.toJson(oe)),otherDoors:q._otherDoors.map(oe=>r.toJson(oe)),coreDoors:q._coreDoors.map(oe=>a.toJson(oe)),terraceDoors:q._terraceDoors.map(oe=>n.toJson(oe)),controlRoomDoors:q._controlRoomDoors.map(oe=>l.toJson(oe)),existingRoomDoors:q._existingRoomDoors.map(oe=>p.toJson(oe)),curves:q._curves.map(oe=>g.toJson(oe)),interiorWalls:X.g6.toJson(q._interiorWalls),mullions:X.g6.toJson(q._mullions),compartimentWalls:X.Kk.toJson(q._compartimentWalls),exteriorWalls:X.g6.toJson(q._exteriorWalls),directLightLines:X.g6.toJson(q._directLightLines)}}}
1var k=P(72558),ye=(P(17734),P(36974),P(16534),P(87190),P(12738),P(53897),P(53906),P(51567),P(95904));let Ae=(()=>{class Ee{static#e=this.JKEY="Floor";static createStringKey(oe){return`${oe.floorIndex}:${[...oe.buildingIndexes].sort().join(",")}`}createIFloorUid(){return{floorIndex:this._floorIndex,buildingIndexes:this._buildingIndexes}}constructor(oe){this._lotParts=[],this._floorIndex=0,this._buildingIndexes=[],this._coreSpaces=[],this._terraceSpaces=[],this._compartimentDoors=[],this._stackingPlanInfo=new k.W,this._model2d="",this._model3d="",this._subl=0,this._sua=0,this._sun=0,this._sup=0,this._selectionSua=0,this._selectionSun=0,this._selectionSup=0,this._parentProperty=oe}get subl(){return this._subl}get sua(){return this._sua}get sun(){return this._sun}get sup(){return this._sup}get floorId(){return this._floorId}get selectionSua(){return this._selectionSua}get selectionSun(){return this._selectionSun}get selectionSup(){return this._selectionSup}parentProperty(){return this._parentProperty}lotParts(){return this._lotParts}floorIndex(){return this._floorIndex}buildingIndexes(){return this._buildingIndexes}coreSpaces(){return this._coreSpaces}terraceSpaces(){return this._terraceSpaces}compartimentDoors(){return this._compartimentDoors}stackingPlanInfo(){return this._stackingPlanInfo}get model2d(){return this._model2d}get model3d(){return this._model3d}hasId(oe,ee){if(oe!==this._floorIndex||this._buildingIndexes.length!==ee.length)return!1;for(const Z of this._buildingIndexes)if(!ee.includes(Z))return!1;return!0}createUid(){const oe=new E.ph;oe.parts.push(new E.gI(E.TE.UID_PART,this._floorIndex));for(const ee of this._buildingIndexes)oe.parts.push(new E.gI(E.TE.UID_PART,ee));return oe}getElement(oe){function ee(){const ae=oe.parts[oe.parts.length-1].elementType,de=oe.asElementId();return ae===E.TE.CORE_SPACE?this._coreSpaces.find(he=>he.elementId()===de)||null:ae===E.TE.TERRACE_SPACE?this._terraceSpaces.find(he=>he.elementId()===de)||null:ae===E.TE.DOOR&&this._compartimentDoors.find(he=>he.elementId()===de)||null}const Z=oe.consumeUidParts(),Q=Z[1];if(2!==Q.length)return ee.call(this);const[V,U]=Q,re=this._lotParts.find(ae=>ae.lotIndex()===V&&ae.partIndex()===U);return re?re.getElement(Z[0]):ee.call(this)}fullFreeSpaces(){return e.jG(e.lD(this._lotParts.map(oe=>oe.fullFreeSpace())))}corridorSpaces(){let oe=e.lD();return this._lotParts.forEach(ee=>{oe=e.Y7(oe,ee.corridorSpaces())}),oe}freeSpaces(){let oe=e.lD();return this._lotParts.forEach(ee=>{oe=e.Y7(oe,ee.freeSpaces())}),oe}postSpaces(){let oe=e.lD();return this._lotParts.forEach(ee=>
1{ee.posts().forEach(Z=>{oe=e.Y7(oe,Z.coveredSpace())})}),oe}lessThan(oe){if(!(oe instanceof Ee))throw new Error("Cannot compare Floor with non-Floor type");if(this._floorIndex!==oe._floorIndex)return this._floorIndex<oe._floorIndex;const ee=Math.min(...this._buildingIndexes),Z=Math.min(...oe._buildingIndexes);return ee!==Z?ee<Z:this._buildingIndexes.length<oe._buildingIndexes.length}toString(){return this.createUid().toString()}equals(oe){return oe instanceof Ee&&this.createUid().equals(oe.createUid())}dispose(){this._parentProperty=null,this._lotParts.forEach(oe=>oe.dispose()),this._lotParts=[],this._coreSpaces.forEach(oe=>oe.dispose()),this._coreSpaces=[],this._terraceSpaces.forEach(oe=>oe.dispose()),this._terraceSpaces=[],this._compartimentDoors.forEach(oe=>oe.dispose()),this._compartimentDoors=[],this._stackingPlanInfo.dispose(),this._stackingPlanInfo=null}static fromJson(oe,ee,Z){const Q=new Ee(ee);return Q._floorIndex=oe.floorIndex||0,Q._buildingIndexes=oe.buildingIndexes||[],Q._coreSpaces=(oe.coreSpaces||[]).map(V=>H.fromJson(V,Z)),Q._terraceSpaces=(oe.terraceSpaces||[]).map(V=>ne.fromJson(V,Z)),Q._compartimentDoors=(oe.compartimentDoors||[]).map(V=>y.fromJson(V,Z)),Q._lotParts=(oe.lotParts||[]).filter(V=>Z.canDeserialize(V,!1)).map(V=>K.fromJson(V,Q,Z)),Q._model2d=oe.model2d??"",Q._model3d=oe.model3d??"",Q._stackingPlanInfo=oe.stackingPlanInfo?k.W.fromJson(oe.stackingPlanInfo,new ye.m):null,Q._subl=oe.subl??0,Q._sua=oe.sua??0,Q._sun=oe.sun??0,Q._sup=oe.sup??0,Q._selectionSua=oe.selectionSua??0,Q._selectionSun=oe.selectionSun??0,Q._selectionSup=oe.selectionSup??0,Q._floorId=oe.id||void 0,Z.jctx.setStringKeyRef(Ee.JKEY,Ee.createStringKey(Q.createIFloorUid()),Q),Q}static toJson(oe,ee=!1){return{floorIndex:oe._floorIndex,buildingIndexes:oe._buildingIndexes,coreSpaces:oe._coreSpaces.map(Z=>H.toJson(Z)),terraceSpaces:oe._terraceSpaces.map(Z=>ne.toJson(Z)),compartimentDoors:oe._compartimentDoors.map(Z=>y.toJson(Z)),lotParts:ee?[]:oe._lotParts.map(Z=>K.toJson(Z))}}}return Ee})()},17734:(tt,me,P)=>{P.d(me,{A:()=>h});var e=P(51567),E=P(12738),X=P(53906),O=P(52901),v=P(56095);class h{constructor(){this._isReceptionFriendly=!1,this._staticSections=[],this._dynamicSections=[],this._sectionLinks=[],this._extremityShapes=[],this._firstQuartileWidth=null,this._firstQuartileHeight=null,this._thirdQuartileWidth=null,this._thirdQuartileHeight=null,this._medianWidth=null,this._medianHeight=null,this._exitDoorDistances={},this._exitDoorLotDistancesPatches={},this._cornerCount=0,this._tileWidths={},this._tileHeights={}}computeAverageTileSize(r=!1){let a=0,n=0,l=0;for(const K of this._staticSections)a+=K.totalWidth,n+=K.totalHeight,l+=K.shapeUids.length;if(!r)return l>0?[a/l,n/l]:[0,0];const p=(K,k,x)=>{if(!K||K>=k)return null;const f=K*l;return(f/l>0?f/l:1)<x?f/l>0?f/l:1:null},y=l>0?a/l:1,D=l>0?n/l:1,Y=(K,k,x)=>{let f=[K,k,x];return f=f.filter(J=>null!==J),f.length>0?f.reduce((J,L)=>J+L,0)/f.length:null};let H=[p(this._firstQuartileWidth,y,a),p(this._thirdQuartileWidth,y,a),p(this._medianWidth,y,a),p(Y(this._firstQuartileWidth,this._thirdQuartileWidth,this._medianWidth),y,a)],ne=[p(this._firstQuartileHeight,D,n),p(this._thirdQuartileHeight,D,n),p(this._medianHeight,D,n),p(Y(this._firstQuartileHeight,this._thirdQuartileHeight,this._medianHeight),D,n)];return H=H.filter(K=>null!==K),ne=ne.filter(K=>null!==K),[H.length>0?Math.max(...H)||1:y||1,ne.length>0?Math.max(...ne)||1:D||1]}computeMaxCapacity(r=!0){return this._dynamicSections.reduce((a,n)=>{const[l,p]=n.computeMaxCapacity(r);return[a[0]+l,a[1]+p]},this._staticSections.reduce((a,n)=>[a[0]+n.shapeUids.length,a[1]+n.totalWidth],[0,0]))}get fullUid(){return this._fullUid}get coveredSpace(){return this._coveredSpace}get isReceptionFriendly(){return this._isReceptionFriendly}get staticSections(){return this._staticSections}get dynamicSections(){return this._dynamicSections}get sectionLinks(){return this._sectionLinks}get extremityShapes(){return this._extremityShapes}get firstQuartileWidth(){return this._firstQuartileWidth}get firstQuartileHeight(){return this._firstQuartileHeight}get thirdQuartileWidth(){return this._thirdQuartileWidth}get thirdQuartileHeight(){return this._thirdQuartileHeight}get medianWidth(){return this._medianWidth}get medianHeight(){return this._medianHeight}get cornerCount(){return this._cornerCount}get tileWidths(){return this._tileWidths}get tileHeights(){return this._tileHeights}computeToofarTiles(r,a){if(a<=0)return 0;a*=100;let n={...this._exitDoorDistances};return r.forEach(l=>{const p=this._exitDoorLotDistancesPatches[l];if(p)for(const[y,D]of Object.entries(p))n[y]||(n[y]=0),n[y]+=D}),Object.entries(n).filter(([l,p])=>parseFloat(l)>=a).reduce((l,[,p])=>l+p,0)}static fromJson(r,a){const n=new h;return n._fullUid=O.p.fromJson(r.fullUid),n._coveredSpace=v.mg.fromJson(r.coveredSpace),n._isReceptionFriendly=r.isReceptionFriendly||!1,n._staticSections=(r.staticSections||[]).map(l
1=>e.C.fromJson(l,a)),n._dynamicSections=(r.dynamicSections||[]).map(l=>E.F.fromJson(l,a)),n._sectionLinks=(r.sectionLinks||[]).map(l=>X.v.fromJson(l,a)),n._extremityShapes=(r.extremityShapes||[]).map(([l,p,y])=>[l,p,O.p.fromJson(y)]),n._firstQuartileWidth=r.firstQuartileWidth??null,n._firstQuartileHeight=r.firstQuartileHeight??null,n._thirdQuartileWidth=r.thirdQuartileWidth??null,n._thirdQuartileHeight=r.thirdQuartileHeight??null,n._medianWidth=r.medianWidth??null,n._medianHeight=r.medianHeight??null,n._exitDoorDistances=r.exitDoorDistances||{},n._exitDoorLotDistancesPatches=r.exitDoorLotDistancesPatches||{},n._cornerCount=r.cornerCount||0,n._tileWidths=r.tileWidths||{},n._tileHeights=r.tileHeights||{},n._quickFix(),n}static toJson(r){return{fullUid:O.p.toJson(r._fullUid),coveredSpace:v.mg.toJson(r._coveredSpace),isReceptionFriendly:r._isReceptionFriendly,staticSections:r._staticSections.map(a=>e.C.toJson(a)),dynamicSections:r._dynamicSections.map(a=>E.F.toJson(a)),sectionLinks:r._sectionLinks.map(a=>X.v.toJson(a)),extremityShapes:r._extremityShapes.map(([a,n,l])=>[a,n,O.p.toJson(l)]),firstQuartileWidth:r._firstQuartileWidth??void 0,firstQuartileHeight:r._firstQuartileHeight??void 0,thirdQuartileWidth:r._thirdQuartileWidth??void 0,thirdQuartileHeight:r._thirdQuartileHeight??void 0,medianWidth:r._medianWidth??void 0,medianHeight:r._medianHeight??void 0,exitDoorDistances:r._exitDoorDistances,exitDoorLotDistancesPatches:r._exitDoorLotDistancesPatches,cornerCount:r._cornerCount,tileWidths:r._tileWidths,tileHeights:r._tileHeights}}dispose(){this._staticSections.forEach(r=>r.dispose()),this._dynamicSections.forEach(r=>r.dispose()),this._sectionLinks.forEach(r=>r.dispose()),this._staticSections=[],this._dynamicSections=[],this._sectionLinks=[],this._extremityShapes=[],this._coveredSpace=null,this._fullUid=null,this._exitDoorDistances={},this._exitDoorLotDistancesPatches={}}_quickFix(){if(this._dynamicSections.length<=1)return;const r=(Y,H)=>{for(const ne of Y)if(H.has(ne))return!0;return!1},a=new Set;for(let Y=0;Y<this._dynamicSections.length;Y++){const H=new Set(this._dynamicSections[Y].involvedPackageIds),ne=H.size;for(let K=Y+1;K<this._dynamicSections.length;K++){const k=new Set(this._dynamicSections[K].involvedPackageIds);r(H,k)&&a.add(ne>=k.size?Y:K)}}Array.from(a).sort((Y,H)=>Y-H);const l={};let p=0;for(let Y=0;Y<this._dynamicSections.length;Y++)l[Y]=p,a.has(Y)&&(p+=1);this._dynamicSections=this._dynamicSections.filter((Y,H)=>!a.has(H));const y=[];for(const Y of this._sectionLinks)a.has(Y.dynamicSectionIdx)||(Y._dynamicSectionIdx-=l[Y.dynamicSectionIdx],y.push(Y));this._sectionLinks=y;const D=[];for(const Y of this._extremityShapes)Y[0]&&a.has(Y[1])||D.push(Y[0]?[Y[0],Y[1]-l[Y[1]],Y[2]]:Y);this._extremityShapes=D}}},36974:(tt,me,P)=>{P.d(me,{E:()=>E});var e=P(52901);class E{constructor(){this._distance=0}get directAreaA(){return this._directAreaA}get directAreaB(){return this._directAreaB}get partitionableShapeA(){return this._partitionableShapeA}get partitionableShapeB(){return this._partitionableShapeB}get distance(){return this._distance}static asLutKey(O,v){const h=new E;return h._directAreaA=O,h._partitionableShapeA=v,h}static fromJson(O,v){const h=new E;return h._directAreaA=e.p.fromJson(O.directAreaA),h._directAreaB=e.p.fromJson(O.directAreaB),h._partitionableShapeA=e.p.fromJson(O.partitionableShapeA),h._partitionableShapeB=e.p.fromJson(O.partitionableShapeB),h._distance=O.distance,h}static toJson(O){return{directAreaA:e.p.toJson(O._directAreaA),directAreaB:e.p.toJson(O._directAreaB),partitionableShapeA:e.p.toJson(O._partitionableShapeA),partitionableShapeB:e.p.toJson(O._partitionableShapeB),distance:O._distance}}dispose(){this._directAreaA=null,this._directAreaB=null,this._partitionableShapeA=null,this._partitionableShapeB=null}equals(O){return O._directAreaA&&!O._directAreaB?this._directAreaA.equals(O._directAreaA)&&this._partitionableShapeA.equals(O._partitionableShapeA)||this._directAreaB.equals(O._directAreaA)&&this._partitionableShapeB.equals(O._partitionableShapeA):this._directAreaA.equals(O._directAreaA)&&this._partitionableShapeA.equals(O._partitionableShapeA)&&this._directAreaB.equals(O._directAreaB)&&this._partitionableShapeB.equals(O._partitionableShapeB)}toString(){return`Link[${this._directAreaA.toString()} (${this._partitionableShapeA.toString()}) <-> ${this._directAreaB.toString()} (${this._partitionableShapeB.toString()})]`}}},16534:(tt,me,P)=>{P.d(me,{O:()=>E});var e=P(52901);class E{constructor(){this._selectedLotIdxes=[],this._unselectedLotIdxes=[],this._directLightAreaUids=[],this._extremitiesAreaShapes=[]}isSelected(O){return this._selectedLotIdxes.every(v=>O.includes(v))&&!this._unselectedLotIdxes.some(v=>O.includes(v))}get fullUid(){return this._fullUid}get selectedLotIdxes(){return this._selectedLotIdxes}get unselectedLotIdxes(){return this._unselectedLotIdxes}get directLightAreaUids(){return this._directLightAreaUids}get extremitiesAreaShapes(){return this._extremitiesAreaShapes}static fromJson(O,v){const h=new E;return h._fullUid=e.p.fromJson(O.fullUid),h._selectedLotIdxes=O.selectedLotIdxes,h._unselectedLotIdxes=O.unselectedLotIdxes,h._directLightAreaUids=O.directLightAreaUids.map(g=>e.p.fromJson(g)),h._extremitiesAreaShapes=O.extremitiesAreaShapes.map(([g,r])=>[e.p.fromJson(g),e.p.fromJson(r)]),h}static toJson(O){return{fullUid:e.p.toJson(O._fullUid),selectedLotIdxes:O._selectedLotIdxes,unselectedLotIdxes:O._unselectedLotIdxes,directLightAreaUids:O._directLightAreaUids.map(v
1=>e.p.toJson(v)),extremitiesAreaShapes:O._extremitiesAreaShapes.map(([v,h])=>[e.p.toJson(v),e.p.toJson(h)])}}dispose(){this._directLightAreaUids=[],this._extremitiesAreaShapes=[],this._selectedLotIdxes=[],this._unselectedLotIdxes=[],this._fullUid=null}}},87190:(tt,me,P)=>{P.d(me,{U:()=>E});var e=P(52901);class E{constructor(){this._distance=0}get directClusterA(){return this._directClusterA}get directClusterB(){return this._directClusterB}get directAreaA(){return this._directAreaA}get directAreaB(){return this._directAreaB}get partitionableShapeA(){return this._partitionableShapeA}get partitionableShapeB(){return this._partitionableShapeB}get distance(){return this._distance}static fromJson(O,v){const h=new E;return h._directClusterA=e.p.fromJson(O.directClusterA),h._directClusterB=e.p.fromJson(O.directClusterB),h._directAreaA=e.p.fromJson(O.directAreaA),h._directAreaB=e.p.fromJson(O.directAreaB),h._partitionableShapeA=e.p.fromJson(O.partitionableShapeA),h._partitionableShapeB=e.p.fromJson(O.partitionableShapeB),h._distance=O.distance,h}static toJson(O){return{directClusterA:e.p.toJson(O._directClusterA),directClusterB:e.p.toJson(O._directClusterB),directAreaA:e.p.toJson(O._directAreaA),directAreaB:e.p.toJson(O._directAreaB),partitionableShapeA:e.p.toJson(O._partitionableShapeA),partitionableShapeB:e.p.toJson(O._partitionableShapeB),distance:O._distance}}dispose(){this._directClusterA=null,this._directClusterB=null,this._directAreaA=null,this._directAreaB=null,this._partitionableShapeA=null,this._partitionableShapeB=null}}},12738:(tt,me,P)=>{P.d(me,{F:()=>E});var e=P(53897);class E{constructor(){this._involvedPackageIds=[],this._items=[]}get involvedPackageIds(){return this._involvedPackageIds}get items(){return this._items}isDynamic(){return!0}computeMaxCapacity(O=!0){const v=this._items.map(h=>[h.shapeUids.length,h.totalWidth]);return O?v.reduce((h,g)=>h[0]<=g[0]?h:g,[Number.MAX_SAFE_INTEGER,0]):v.reduce((h,g)=>h[0]>=g[0]?h:g,[0,0])}static fromJson(O,v){const h=new E;return h._involvedPackageIds=O.involvedPackageIds,h._items=(O.items||[]).map(g=>e.H.fromJson(g,v)),h}static toJson(O){return{involvedPackageIds:O._involvedPackageIds,items:O._items.map(v=>e.H.toJson(v))}}dispose(){this._items.forEach(O=>O.dispose()),this._items=[],this._involvedPackageIds=[]}}},53897:(tt,me,P)=>{P.d(me,{H:()=>X});var e=P(56095),E=P(52901);class X{constructor(){this._appliedPackageId=0,this._shapeUids=[],this._extremityShapeUids=[],this._corridorSpace=null,this._peakCirculationNodePosition=null,this._totalWidth=0,this._totalHeight=0,this._firstQuartileWidth=null,this._firstQuartileHeight=null,this._thirdQuartileWidth=null,this._thirdQuartileHeight=null,this._medianWidth=null,this._medianHeight=null}get appliedPackageId(){return this._appliedPackageId}get shapeUids(){return this._shapeUids}get extremityShapeUids(){return this._extremityShapeUids}get corridorSpace(){return this._corridorSpace}get peakCirculationNodePosition(){return this._peakCirculationNodePosition}get totalWidth(){return this._totalWidth}get totalHeight(){return this._totalHeight}get firstQuartileWidth(){return this._firstQuartileWidth}get firstQuartileHeight(){return this._firstQuartileHeight}get thirdQuartileWidth(){return this._thirdQuartileWidth}get thirdQuartileHeight(){return this._thirdQuartileHeight}get medianWidth(){return this._medianWidth}get medianHeight(){return this._medianHeight}isLoop(){return 0===this._extremityShapeUids.length}static fromJson(v,h){const g=new X;return g._appliedPackageId=v.appliedPackageId,g._shapeUids=v.shapeUids.map(r=>E.p.fromJson(r)),g._extremityShapeUids=v.extremityShapeUids.map(r=>E.p.fromJson(r)),g._corridorSpace=v.corridorSpace?e.mg.fromJson(v.corridorSpace):null,g._peakCirculationNodePosition=v.peakCirculationNodePosition?e.E9.fromJson(v.peakCirculationNodePosition):null,g._totalWidth=v.totalWidth,g._totalHeight=v.totalHeight,g._firstQuartileWidth=v.firstQuartileWidth??null,g._firstQuartileHeight=v.firstQuartileHeight??null,g._thirdQuartileWidth=v.thirdQuartileWidth??null,g._thirdQuartileHeight=v.thirdQuartileHeight??null,g._medianWidth=v.medianWidth??null,g._medianHeight=v.medianHeight??null,g}static toJson(v){return{appliedPackageId:v._appliedPackageId,shapeUids:v._shapeUids.map(h=>E.p.toJson(h)),extremityShapeUids:v._extremityShapeUids.map(h=>
1E.p.toJson(h)),corridorSpace:v._corridorSpace?e.mg.toJson(v._corridorSpace):void 0,peakCirculationNodePosition:v._peakCirculationNodePosition?e.E9.toJson(v._peakCirculationNodePosition):void 0,totalWidth:v._totalWidth,totalHeight:v._totalHeight,firstQuartileWidth:v._firstQuartileWidth??void 0,firstQuartileHeight:v._firstQuartileHeight??void 0,thirdQuartileWidth:v._thirdQuartileWidth??void 0,thirdQuartileHeight:v._thirdQuartileHeight??void 0,medianWidth:v._medianWidth??void 0,medianHeight:v._medianHeight??void 0}}dispose(){this._shapeUids=[],this._extremityShapeUids=[]}}},53906:(tt,me,P)=>{P.d(me,{v:()=>E});var e=P(52901);class E{constructor(){this._dynamicSectionIdx=0,this._staticSectionIdx=0}get dynamicSectionIdx(){return this._dynamicSectionIdx}get staticSectionIdx(){return this._staticSectionIdx}get dynamicPartitionableShape(){return this._dynamicPartitionableShape}get staticPartitionableShape(){return this._staticPartitionableShape}static fromJson(O,v){const h=new E;return h._dynamicSectionIdx=O.dynamicSectionIdx,h._staticSectionIdx=O.staticSectionIdx,h._dynamicPartitionableShape=e.p.fromJson(O.dynamicPartitionableShape),h._staticPartitionableShape=e.p.fromJson(O.staticPartitionableShape),h}static toJson(O){return{dynamicSectionIdx:O._dynamicSectionIdx,staticSectionIdx:O._staticSectionIdx,dynamicPartitionableShape:e.p.toJson(O._dynamicPartitionableShape),staticPartitionableShape:e.p.toJson(O._staticPartitionableShape)}}dispose(){this._dynamicPartitionableShape=null,this._staticPartitionableShape=null}}},51567:(tt,me,P)=>{P.d(me,{C:()=>E});var e=P(52901);class E{constructor(){this._shapeUids=[],this._extremityShapeUids=[],this._totalWidth=0,this._totalHeight=0,this._firstQuartileWidth=null,this._firstQuartileHeight=null,this._thirdQuartileWidth=null,this._thirdQuartileHeight=null,this._medianWidth=null,this._medianHeight=null,this._cornerCount=0,this._tileWidths={},this._tileHeights={},this._exitDoorDistances=null,this._exitDoorLotDistancesPatches=null}get shapeUids(){return this._shapeUids}get extremityShapeUids(){return this._extremityShapeUids}get totalWidth(){return this._totalWidth}get totalHeight(){return this._totalHeight}get firstQuartileWidth(){return this._firstQuartileWidth}get firstQuartileHeight(){return this._firstQuartileHeight}get thirdQuartileWidth(){return this._thirdQuartileWidth}get thirdQuartileHeight(){return this._thirdQuartileHeight}get medianWidth(){return this._medianWidth}get medianHeight(){return this._medianHeight}get cornerCount(){return this._cornerCount}get tileWidths(){return this._tileWidths}get tileHeights(){return this._tileHeights}isDynamic(){return!1}isLoop(){return 0===this._extremityShapeUids.length}computeToofarTiles(O,v){if(!this._exitDoorDistances||!this._exitDoorLotDistancesPatches)return-1;if(v<=0)return 0;v*=100;let h={...this._exitDoorDistances};return O.forEach(g=>{const r=this._exitDoorLotDistancesPatches[g];if(r)for(const[a,n]of Object.entries(r))h[a]||(h[a]=0),h[a]+=n}),Object.entries(h).filter(([g,r])=>parseFloat(g)>=v).reduce((g,[,r])=>g+r,0)}static fromJson(O,v){const h=new E;return h._shapeUids=O.shapeUids.map(g=>e.p.fromJson(g)),h._extremityShapeUids=O.extremityShapeUids.map(g=>e.p.fromJson(g)),h._totalWidth=O.totalWidth,h._totalHeight=O.totalHeight,h._firstQuartileWidth=O.firstQuartileWidth??null,h._firstQuartileHeight=O.firstQuartileHeight??null,h._thirdQuartileWidth=O.thirdQuartileWidth??null,h._thirdQuartileHeight=O.thirdQuartileHeight??null,h._medianWidth=O.medianWidth??null,h._medianHeight=O.medianHeight??null,h._cornerCount=O.cornerCount??0,h._tileWidths=O.tileWidths??{},h._tileHeights=O.tileHeights??{},h._exitDoorDistances=O.exitDoorDistances||null,h._exitDoorLotDistancesPatches=O.exitDoorLotDistancesPatches||null,h}static toJson(O){return{shapeUids:O._shapeUids.map(v=>e.p.toJson(v)),extremityShapeUids:O._extremityShapeUids.map(v=>e.p.toJson(v)),totalWidth:O._totalWidth,totalHeight:O._totalHeight,firstQuartileWidth:O._firstQuartileWidth??void 0,firstQuartileHeight:O._firstQuartileHeight??void 0,thirdQuartileWidth:O._thirdQuartileWidth??void 0,thirdQuartileHeight:O._thirdQuartileHeight??void 0,medianWidth:O._medianWidth??void 0,medianHeight:O._medianHeight??void 0,cornerCount:O._cornerCount,tileWidths:O._tileWidths,tileHeights:O._tileHeights,exitDoorDistances:O._exitDoorDistances||void 0,exitDoorLotDistancesPatches:O._exitDoorLotDistancesPatches||void 0}}dispose(){this._shapeUids=[],this._extremityShapeUids=[]}}},72558:(tt,me,P)=>{P.d(me,{W:()=>r});var a,e=P(17734),E=P(16534),X=P(36974),O=P(87190),v=P(47286),h=P(52901);class g{constructor(){this._lotPartIdx=-1}get lotPartIdx(){return this._lotPartIdx}get directArea(){return this._directArea}get gridArea(){return this._gridArea}get indirectArea(){return this._indirectArea}get items(){return this._items}static fromJson(n,l){const p=new g;return p._lotPartIdx=n.lotPartIdx,p._directArea=h.p.fromJson(n.directArea),p._indirectArea=n.indirectArea?h.p.fromJson(n.indirectArea):null,p._gridArea=h.p.fromJson(n.gridArea),p._items=(n.items||[]).map(y=>g.Item.fromJson(y,l)),p}static toJson(n){return{lotPartIdx:n._lotPartIdx,directArea:h.p.toJson(n._directArea),indirectArea:h.p.toJson(n._indirectArea),gridArea:h.p.toJson(n._gridArea),items:(n._items||[]).map(l
1=>g.Item.toJson(l))}}dispose(){this._directArea=null,this._indirectArea=null,this._gridArea=null,this._items?.forEach(n=>n.dispose()),this._items=null}equals(n){return this._lotPartIdx===n._lotPartIdx&&this._directArea.equals(n._directArea)&&this._indirectArea.equals(n._indirectArea)&&this._gridArea.equals(n._gridArea)&&this._items.length===n._items.length&&this._items.every((l,p)=>l.equals(n._items[p]))}}(a=g||(g={})).Item=class n{constructor(){}get partitionableShape(){return this._partitionableShape}get cellCoord(){return this._cellCoord}static fromJson(p,y){const D=new a.Item;return D._partitionableShape=h.p.fromJson(p.partitionableShape),D._cellCoord=p.cellCoord,D}static toJson(p){return{partitionableShape:h.p.toJson(p._partitionableShape),cellCoord:p._cellCoord}}dispose(){this._partitionableShape=null,this._cellCoord=null}equals(p){return this._partitionableShape.equals(p._partitionableShape)&&this._cellCoord[0]===p._cellCoord[0]&&this._cellCoord[1]===p._cellCoord[1]}toString(){return`Link[${this._partitionableShape.toString()} (${this._cellCoord[0]}, ${this._cellCoord[1]})]`}};class r{constructor(){this._directLightAreas=[],this._directLightClusters=[],this._directLightAreaLinks=[],this._directLightClusterLinks=[],this._indirectLightAreas=[],this._directIndirectLightAreaLinks=[],this._cellSize=0}get directLightAreas(){return this._directLightAreas}get directLightClusters(){return this._directLightClusters}get directLightAreaLinks(){return this._directLightAreaLinks}get directLightClusterLinks(){return this._directLightClusterLinks}get indirectLightAreas(){return this._indirectLightAreas}get directIndirectLightAreaLinks(){return this._directIndirectLightAreaLinks}get cellSize(){return this._cellSize}static fromJson(n,l){const p=new r;return p._directLightAreas=(n.directLightAreas||[]).map(y=>e.A.fromJson(y,l)),p._directLightClusters=(n.directLightClusters||[]).map(y=>E.O.fromJson(y,l)),p._directLightAreaLinks=(n.directLightAreaLinks||[]).map(y=>X.E.fromJson(y,l)),p._directLightClusterLinks=(n.directLightClusterLinks||[]).map(y=>O.U.fromJson(y,l)),p._indirectLightAreas=(n.indirectLightAreas||[]).map(y=>v.p.fromJson(y,l)),p._directIndirectLightAreaLinks=(n.directIndirectLightAreaLinks||[]).map(y=>g.fromJson(y,l)),p._cellSize=n.cellSize||60,p}static toJson(n){return{directLightAreas:n._directLightAreas.map(l=>e.A.toJson(l)),directLightClusters:n._directLightClusters.map(l=>E.O.toJson(l)),directLightAreaLinks:n._directLightAreaLinks.map(l=>X.E.toJson(l)),directLightClusterLinks:n._directLightClusterLinks.map(l=>O.U.toJson(l)),indirectLightAreas:n._indirectLightAreas.map(l=>v.p.toJson(l)),directIndirectLightAreaLinks:n._directIndirectLightAreaLinks.map(l=>g.toJson(l)),cellSize:n._cellSize}}dispose(){this._directLightAreas.forEach(n=>n.dispose()),this._directLightClusters.forEach(n=>n.dispose()),this._directLightAreaLinks.forEach(n=>n.dispose()),this._directLightClusterLinks.forEach(n=>n.dispose()),this._directLightAreas=[],this._directLightClusters=[],this._directLightAreaLinks=[],this._directLightClusterLinks=[],this._indirectLightAreas.forEach(n=>n.dispose()),this._indirectLightAreas=[],this._directIndirectLightAreaLinks.forEach(n=>n.dispose()),this._directIndirectLightAreaLinks=[]}}},47286:(tt,me,P)=>{P.d(me,{p:()=>X});var O,e=P(52901),E=P(56095);class X{constructor(){this._gridShapeUids=[],this._cellCount=0,this._corridorCells=0,this._isReceptionFriendly=!1}get fullUid(){return this._fullUid}get coveredSpace(){return this._coveredSpace}get indirectLightShapeUid(){return this._indirectLightShapeUid}get gridShapeUids(){return this._gridShapeUids}get cellCount(){return this._cellCount}get corridorCells(){return this._corridorCells}get isReceptionFriendly(){return this._isReceptionFriendly}get rectConfigurations(){return this._rectConfigurations}static fromJson(v,h){const g=new X;return g._fullUid=e.p.fromJson(v.fullUid),g._coveredSpace=E.mg.fromJson(v.coveredSpace),g._indirectLightShapeUid=e.p.fromJson(v.indirectLightShapeUid),g._gridShapeUids=(v.gridShapeUids||[]).map(r=>e.p.fromJson(r)),g._cellCount=v.cellCount||0,g._corridorCells=v.corridorCells||0,g._isReceptionFriendly=v.isReceptionFriendly||!1,g._rectConfigurations=(v.rectConfigurations||[]).map(r=>(r||[]).map(a=>X.Rect.fromJson(a,h))),g}static toJson(v){return{fullUid:e.p.toJson(v._fullUid),coveredSpace:E.mg.toJson(v._coveredSpace),indirectLightShapeUid:e.p.toJson(v._indirectLightShapeUid),gridShapeUids:v._gridShapeUids.map(h=>e.p.toJson(h)),cellCount:v._cellCount,corridorCells:v._corridorCells,isReceptionFriendly:v._isReceptionFriendly,rectConfigurations:v._rectConfigurations?.map(h=>h.map(g=>X.Rect.toJson(g)))}}dispose(){this._gridShapeUids=[],this._indirectLightShapeUid=null,this._coveredSpace=null,this._fullUid=null}}(O=X||(X={})).Rect=class v{constructor(){}get rect(){return this._rect}get irrigatedSides(){return this._irrigatedSides}static fromJson(g,r){const a=new O.Rect;return a._rect=g.rect,a._irrigatedSides=g.irrigatedSides||"",a}static toJson(g){return{rect:g._rect,irrigatedSides:g._irrigatedSides||void 0}}}},4516:(tt,me,P)=>{P.d(me,{Es:()=>h,WK:()=>O,bI:()=>v,me:()=>E,nI:()=>X});var e=P(47318);class E{constructor(){this._map=new Map}get size(){return this._map.size}serialize(r){return r.toString()}set(r,a){this._map.set(this.serialize(r),[r,a])}get(r){return this._map.get(this.serialize(r))?.[1]}has(r){return this._map.has(this.serialize(r))}delete(r){return this._map.delete(this.serialize(r))}clear(){this._map.clear()}values(){const r=[];
1return this._map.forEach(a=>r.push(a[1])),r}forEach(r){this._map.forEach(([a,n])=>{r(n,a)})}map(r){const a=new E;return this._map.forEach(([n,l])=>{const p=r(l,n);a.set(n,p)}),a}mapArray(r){const a=[];return this._map.forEach(([n,l])=>{const p=r(l,n);a.push(p)}),a}[Symbol.iterator](){return this._map.values()}}class X{constructor(){this._map=new Map}serialize(r){return r.toString()}tryGet(r){for(const[a,[n,l]]of this._map.entries())if(n.equals(r))return l}get(r){return this.tryGet(r)}set(r,a,n=!1){this.has(r)?n&&r.dispose?.():this._map.set(this.serialize(r),[r,a])}has(r){return void 0!==this.tryGet(r)}delete(r,a=!1){const n=a?Array.from(this._map.values()).find(l=>l[0].equals(r))[0]||void 0:r;return!!n&&this._map.delete(this.serialize(n))}entries(){return this._map.values()}values(){const r=[];return this._map.forEach(a=>r.push(a[1])),r}clear(){this._map.clear()}forEach(r){this._map.forEach(a=>r(a[1],a[0]))}[Symbol.iterator](){return this._map.values()}}class O{constructor(){this._entries=[]}tryGet(r){let a=0;for(const[n,l]of this._entries){if(e.fS(n,r))return[a,l];a++}}get(r){const a=this.tryGet(r);return a?a[1]:void 0}set(r,a){const n=this.tryGet(r);n?this._entries[n[0]][1]=a:this._entries.push([r,a])}has(r){return void 0!==this.get(r)}delete(r){const a=this.tryGet(r);return!!a&&(this._entries.splice(a[0],1),!0)}entries(){return this._entries.values()}clear(){this._entries=[]}forEach(r){this._entries.forEach(([a,n])=>r(n,a))}map(r){const a=new O;for(const[n,l]of this._entries){const p=r(l,n);a.set(n,p)}return a}[Symbol.iterator](){return this.entries()}}class v{constructor(r){if(this.set=new Map,r)for(const a of r)this.add(a)}serialize(r){return r.toString()}add(r){this.set.set(this.serialize(r),r)}has(r){return this.set.has(this.serialize(r))}delete(r){return this.set.delete(this.serialize(r))}clear(){this.set.clear()}size(){return this.set.size}forEach(r){this.set.forEach(a=>r(a))}values(){const r=[];return this.set.forEach(a=>r.push(a)),r}isEmpty(){return 0===this.set.size}[Symbol.iterator](){const r=this.set.values();return{next:()=>{const a=r.next();return a.done?{done:!0,value:void 0}:{done:!1,value:a.value}}}}}class h{constructor(r){if(this.set=new Map,r){if(r instanceof h)return void r.forEach(a=>this.add(a));for(const a of r)this.add(a)}}serialize(r){return r.toString()}add(r,a=!1){this.has(r)?a&&r.dispose?.():this.set.set(this.serialize(r),r)}has(r){return this.set.has(this.serialize(r))}delete(r){return this.set.delete(this.serialize(r))}clear(){this.set.clear()}size(){return this.set.size}forEach(r){this.set.forEach(a=>r(a))}values(){return Array.from(this.set.values())}isEmpty(){return 0===this.set.size}[Symbol.iterator](){return this.set.values()}}},14847:(tt,me,P)=>{P.d(me,{Z_:()=>q});var e=P(56095),E=P(47318),X=P(9568),O=P(91408),v=P(78615),h=P(21449);class g extends h.Vz{get parentContext(){return this._parentContext}get categories(){return this._categories}get modules(){return this._modules}get receptionModules(){return this._receptionModules}get closetModules(){return this._closetModules}get lockerModules(){return this._lockerModules}constructor(ee,Z,Q){super(),this._customModules=[],this._parentContext=ee||null,this._categories=Z||[],this._modules=Q||[],this._receptionModules=[],this._closetModules=[],this._lockerModules=[]}_finalize(){this._receptionModules=this._modules.filter(ee=>ee.isReception),this._closetModules=this._modules.filter(ee=>ee.category.isCloset),this._lockerModules=this._modules.filter(ee=>ee.category.isLocker),this._customModules=this._modules.filter(ee=>ee.isCustom)}buildDimensions(ee){this._modules.forEach(Z=>Z.computeDimensions(ee))}getClosetWidth(){const ee=[];for(const Z of this._closetModules)for(const Q of Z.dimensions)for(const V of Q.dimensions)Q.hasLegacyRule||ee.push(V[0]);return ee.sort((Z,Q)=>Q-Z),ee.length>0?ee[0]:0}dispose(ee){this._parentContext=null,ee&&(this._categories.forEach(Z=>Z.dispose()),this._modules.forEach(Z=>Z.dispose()),this._categories=[],this._modules=[],this._receptionModules=[],this._closetModules=[],this._lockerModules=[])}static fromProvider(ee,Z){const Q=new g;return Q._parentContext=Z,Q._categories=ee.moduleCategories,Q._modules=ee.modules,Q._finalize(),Q}getElement(ee){if(!ee.isNull()&&ee.parts[0].elementType===h.TE.MODULE)for(const Z of this.modules)if(Z.uidInPackage()===ee)return Z;return null}}var r=P(81640),a=P(4516),n=P(35934);class l{constructor(){this.coreSpaceMap=new a.me,this.terraceSpaceMap=new a.me,this.controlRoomMap=new a.me,this.existingRoomMap=new a.me}canDeserialize(ee,Z){return this.currentFloorJson&&Object.assign(ee,{...this.currentFloorJson,...ee}),!this._canDeserializeFn||this._canDeserializeFn(ee,Z)}}var p=P(95904);class y{constructor(){this._floors=[],this._rootPackage=new r.ET,this._buildingNameByIndex={}}get buildingNameByIndex(){return this._buildingNameByIndex}floors(){return this._floors}rootPackage(){return this._rootPackage}getElement(ee){const Z=ee.consumeUidParts(),Q=Z[1];if(Q.length<2)return null;const V=Q.shift(),U=this._floors.find(re=>re.floorIndex()===V);return U?U.getElement(Z[0]):null}
1dispose(){this._floors.forEach(ee=>ee.dispose()),this._floors=[],this._rootPackage.dispose(),this._rootPackage=null}static fromJson(ee,Z,Q,V){const U=new l;U.jctx=Q??new p.m,U._canDeserializeFn=V;for(const re of Z.floors??[]){if(!U.canDeserialize(re,!0))continue;U.currentFloorJson=re;const ae=n.O.fromJson(re,ee,U);ee._floors.push(ae),U.currentFloorJson=null}return ee._rootPackage=r.ET.fromJson(Z.rootPackage??{}),ee._buildingNameByIndex=Z.buildingNameByIndex??{},ee}static toJson(ee){return{schemaVersion:1,schemaType:"topology",rootPackage:r.ET.toJson(ee._rootPackage),floors:ee._floors.map(Z=>n.O.toJson(Z))}}static fromPropertyResponse(ee,Z,Q){const V=new y;let U={rootPackage:{floorUIdPackageMap:[]},floors:[],buildingNameByIndex:{}};const re=Te=>{const Je=["u",Te.floorIndex];return Te.topologyJson.buildingIndexes.forEach(Qe=>{Je.push("u",Qe)}),Je},ae=(Te,Je,Qe)=>{const st=Qe?re(Te):[];return Qe&&st.push("s",1),st.push("u",Je.lotIndex,"u",Je.partIndex),st};let de={},he={};ee.buildings.forEach(Te=>{he[Te.index]=Te,Te.floors.forEach(Je=>{de[Je.id]=Je})});let ve=[];for(let Te in de)ve.push(de[parseInt(Te)]);ve=ve.filter(Te=>!!(Te.rootPackage&&Te.lotParts&&Te.floorParameters&&Te.topologyJson)&&Te.lotParts.some(Je=>Je.topologyJson&&Je.rootPackageJson&&Je.parametricPackagesJson)),ve.sort((Te,Je)=>Te.floorIndex-Je.floorIndex);let be=new Set;ve.forEach(Te=>{Te.buildingIndexes.forEach(Je=>be.add(Je))}),Array.from(be).map(Te=>he[Te]).filter(Te=>!!Te).forEach(Te=>U.buildingNameByIndex[Te.index]=Te.name);const Ye=[];return ve.forEach(Te=>{const Je=new Set;Te.lotParts?.forEach(i=>{!i.parametricPackagesJson||!i.rootPackageJson||!i.topologyJson||Je.add(i.lotIndex)});let Qe=0,st=0,et=0;(Te.lots||[]).forEach(i=>{Je.has(i.lotIndex)&&(Qe+=i.sua,st+=i.sun,et+=i.sup)});let Et={...Te.topologyJson,lotParts:[],model2d:Te.model2d,model3d:Te.model3d,stackingPlanInfo:Te.floorParameters,subl:Te.subl,sua:Te.suaFloor,sup:Te.supFloor,selectionSua:Qe,selectionSun:st,selectionSup:et,id:Te.id},lt={...Te.rootPackage,lotUIdPackageMap:[]};Te.lotParts.forEach(i=>{!i.parametricPackagesJson||!i.rootPackageJson||!i.topologyJson||(Et.lotParts.push(i.topologyJson),lt.lotUIdPackageMap.push({key:ae(Te,i,!1),value:i.rootPackageJson}),Ye.push(i.parametricPackagesJson))}),U.floors.push(Et),U.rootPackage.floorUIdPackageMap.push({key:re(Te),value:lt})}),{property:y.fromJson(V,U,Z,Q),parametricPackages:Ye}}}var D=P(9693),Y=P(5959),H=P(34965),ne=P(69519),K=P(37609),k=P(71884),x=P(5398),f=P(42400),J=P(70285),L=P(83575),ce=P(79372),ke=P(71115),Xe=P(20483),te=P(88872);class ye{constructor(ee){this.isReceptionHub=ee?.isReceptionHub??!1,this.isReceptionFilterVisitors=ee?.isReceptionFilterVisitors??!1}}class Ae{get targetLotPart(){return this._targetLotPart}get parametricPackageProvider(){return this._parametricPackageProvider}constructor(ee,Z,Q){this._targetLotPart=ee,this._parametricPackageProvider=r.BJ.fromJson(ee,Z,Q)}dispose(){this._targetLotPart=null,this._parametricPackageProvider?.dispose(),this._parametricPackageProvider=null}}class Ee extends r.Si{get targetFloor(){return this._targetFloor}get lotPartInputMap(){return this._lotPartInputMap}get unselectedLotCoveredSpaces(){return this._unselectedLotCoveredSpaces}constructor(ee,Z,Q,V){super(),this._lotPartInputMap=new a.nI,this._targetFloor=ee,this._unselectedLotCoveredSpaces=Q,ee.lotParts().forEach(re=>{const ae=Z.find(de=>de.lotIndex===re.lotIndex()&&de.partIndex===re.partIndex());ae&&this._lotPartInputMap.set(re,new Ae(re,ae,V))})}dispose(){this._targetFloor=null,this._lotPartInputMap.forEach(ee=>ee.dispose()),this._lotPartInputMap.clear()}getAllParametricPackages(){const ee=new r.Ss;return this._lotPartInputMap.forEach(Z=>{ee.subStatePackages.push(...Z.parametricPackageProvider.getPackages().subStatePackages)}),ee}getInitialPackagesIds(){const ee=[];return this._lotPartInputMap.forEach(Z=>{ee.push(Z.parametricPackageProvider.initialPackage.elementId())}),ee}elementId(){return 0}packageType(){return r.WA.NONE}parentProvider(){return this}requiredPackageUids(){return[]}forbiddenPackageUids(){return[]}getToRemoveElements(){return[]}getToAddElements(){return[]}getElement(ee,Z){throw new Error("Cannot get element in ModelizationContextFloor")}getElementByFullUid(ee){const[Z,Q]=ee.consumeUidParts(),V=Q.shift();if(!this._targetFloor.hasId(V,Q))return null;const[U,re]=Z.consumeUidParts(),ae=re.shift(),de=re.shift(),he=U.getPackagePartOrNone()?.id||null,ve=U.asElementType(),be=U.asElementId();if("number"!=typeof he){const Le=this._targetFloor.parentProperty().rootPackage();for(const[Ye,Te]of Le.floorUidPackageMap.entries())if(ee.startsWith(Ye.uid))for(const[Je,Qe]of Te.lotUidPackageMap.entries())if(Je.eid===de)return Qe.getElement(ve,be)}else for(const[Le,Ye]of this._lotPartInputMap.entries()){if(!Le.hasId(ae,de))continue;const Te=Ye.parametricPackageProvider.getPackage(he)?.package?.getElement(ve,be);if(Te)return Te}return null}getPackages(){const ee=new r.Ss;
1return this._lotPartInputMap.forEach(Z=>{const Q=Z.parametricPackageProvider.getPackages();ee.subStatePackages.push(...Q.subStatePackages)}),ee}getPackage(ee){for(const[Z,Q]of this._lotPartInputMap.entries())if(Q.parametricPackageProvider.hasPackageId(ee))return Q.parametricPackageProvider.getPackage(ee);return new r.Uq}getChildrenPackages(ee){const Z=[];for(const[Q,V]of this._lotPartInputMap.entries()){const U=V.parametricPackageProvider.getChildrenPackages(ee);Z.push(...U)}return Z}}class q{constructor(){this._floorContextMap=new a.nI}get furnitureManager(){return this._furnitureManager}get partitionManager(){return this._partitionManager}get moduleManager(){return this._moduleManager}get program(){return this._program}get property(){return this._property}get feasability(){return this._feasability}get floorContextMap(){return this._floorContextMap}get extra(){return this._extra}hydrateTarget(ee){ee._furnitureManager=this._furnitureManager,ee._partitionManager=this._partitionManager,ee._moduleManager=this._moduleManager,ee._program=this._program,ee._property=this._property,ee._feasability=this._feasability,ee._floorContextMap=this._floorContextMap,ee._extra=this._extra}dispose(ee){this._furnitureManager?.dispose(ee),this._partitionManager?.dispose(ee),this._moduleManager.dispose(ee),this._property?.dispose(),this._program?.dispose(),ee&&this._feasability?.dispose(),this._furnitureManager=null,this._partitionManager=null,this._moduleManager=null,this._program=null,this._property=null,this._feasability=null,this._extra=null}static prepareFromFeasability(ee,Z,Q,V){const U=V;U._extra=new ye(Q.extra);const re=[];let ae=null,de=null,he=null,ve=null;return re.push({clbk:()=>{const Le=y.fromPropertyResponse(Z,Q.jsonDeserializationContext);ae=Le.property,de=Le.parametricPackages,U._property=ae},label:"Parse property"},{clbk:()=>
1{ae.floors().forEach(Le=>{U._floorContextMap.set(Le,new Ee(Le,de.filter(Ye=>Le.hasId(Ye.floorIndex,Ye.buildingIndexes)),(Le=>{let Ye=E.lD();const Te=new Set;Le.lotParts().forEach(st=>{Te.add(st.lotIndex())});const Je=Z.buildings.find(st=>Le.buildingIndexes().includes(st.index));if(!Je)return Ye;const Qe=Je.floors.find(st=>st.floorIndex===Le.floorIndex());return Qe?((Qe.lots||[]).forEach(st=>{Te.has(st.lotIndex)||(Ye=E.Y7(Ye,st.rawJson.coveredSpaces.length&&Array.isArray(st.rawJson.coveredSpaces[0][0])?e.Kk.fromJson(st.rawJson.coveredSpaces):e.mg.fromJson(st.rawJson.coveredSpaces)))}),E.lE(Ye,.01)):Ye})(Le),Q.jsonDeserializationContext))})},label:"Create floor contexts"},{clbk:()=>{U._furnitureManager=v.w.fromProvider(Q,U),U._partitionManager=L.l.fromProvider(Q,U),U._moduleManager=g.fromProvider(Q,U)},label:"Create furniture, partition and module managers"},{clbk:()=>{U._program=O.l.createAdjusted(Q.programRequirements,ee,Q.jsonDeserializationContext,(Le,Ye)=>{ve=Ye,Le.computeDummyRequirements(U._moduleManager,ve)})},label:"Create program and parameters"},{clbk:()=>{he=new J.o(null),U._furnitureManager.buildDimensions(he)},label:"Build furniture dimensions"},{clbk:()=>{U._moduleManager.buildDimensions(he)},label:"Build module dimensions"},{clbk:()=>{U._program.computeDimensions(he)},label:"Compute program dimensions"},{clbk:()=>{U._feasability=ee,U._feasability.parseDragDropInfo(ve)},label:"Parse drag and drop"}),re}static prepareFromScenarioContext(ee,Z,Q,V){if(!Z.partitionMaterials||0===Z.partitionMaterials.length){const he=L.l.createDefault();Z.partitionMaterials=he.materials,Z.partitionLayouts=he.layouts,Z.partitionCombos=he.combos}const U={furnitureTypes:Z.furnitureTypes.map(he=>te.S.fromJson(he,Q)),moduleCategories:Z.moduleCategories.map(he=>f.nL.fromJson(he,Q)),furnitureShapes:Z.furnitureShapes.map(he=>K.O.fromJson(he,Q)),furnitureSizes:Z.furnitureSizes.map(he=>ne.O.fromJson(he,Q)),furnitureBlocks:Z.furnitureBlocks.map(he=>Y.z.fromJson(he,Q)),furnitureLayouts:Z.furnitureLayouts.map(he=>H.j.fromJson(he,Q)),furnitures:Z.furnitures.map(he=>k.l.fromJson(he,Q)),partitionMaterials:Z.partitionMaterials.map(he=>ce.k.fromJson(he,Q)),partitionLayouts:Z.partitionLayouts.map(he=>ke.C.fromJson(he,Q)),partitionCombos:Z.partitionCombos.map(he=>Xe.j.fromJson(he,Q)),modules:Z.modules.map(he=>x.Yl.fromJson(he,Q)),programRequirements:null,jsonDeserializationContext:Q},re=O.l.fromJson(ee.requirements,Q);U.programRequirements=re;const ae=D.R.fromJson(Z.feasability,Q),de=new X.T(Z.property);return q.prepareFromFeasability(ae,de,U,V)}_applyDragAndDrop(ee,Z,Q,V,U=!0){ee.placedDepartmentFloorInfos.forEach(re=>{this._placeDepartmentFloor(re,Z,Q)}),ee.placedModuleInfos.forEach(re=>{this._placeModule(re,Z,Q)}),ee.indirectCorridorInfos.forEach(re=>{const ae=Z.floors.find(de=>de.targetFloor===re.floor);ae&&ae.indirectCorridorInfos.push(re)}),ee.directCorridorInfos.forEach(re=>{const ae=Z.floors.find(de=>de.targetFloor===re.floor);ae&&ae.directCorridorInfos.push(re)}),U&&V&&V.mainEditionStateHistory.notifyHandlersAndConcludeDirty()}_applyMicroUnpackeds(ee,Z){const Q=new a.me;Z.floors.forEach(V=>Q.set(V.targetFloor.createUid(),V)),ee.forEach(([V,U])=>{const re=Q.get(V);re&&this._applyMicroUnpacked(U,re)})}_applyMicroUnpacked(ee,Z){Z._microUnpacked=ee,ee.departments.forEach(Q=>{const V=Z.placedDepartments.find(U=>U.departmentRequirement===Q.department);V&&(V._microUnpackedAreas=Q.areas,V._microPlacedWorkstations=Q.microPlacedWorkstations)}),ee.modules.forEach(Q=>{if(Q.overtakerDepartment){const V=Z.placedDepartments.find(U=>U.departmentRequirement===Q.overtakerDepartment);if(!V)return;V._microUnpackedSubRegulars.push(Q)}else{const V=Z.placedModules.filter(ae=>ae.moduleRequirement===Q.programModule),U=Q.coveredSpace,re=V.map(ae=>{const de=E.m0(U,ae.coveredSpace);return{pm:ae,area:E.SO(de)}}).sort((ae,de)=>de.area-ae.area)[0]||null;re&&re.area>0&&(re.pm._microUnpacked=Q)}})}_placeDepartmentFloor(ee,Z,Q){const V=Z.placeDepartmentFloor(ee);Z.updatePlacedAppliedPackages(ee.floor,!0,"suparea",V),Z.programState.placeDepartmentFloor(ee),Q?.updateDepartment(ee.department),console.debug("Placed Department Floor",ee,this)}_placeModule(ee,Z,Q){const V=Z.placeModule(ee);V&&Z.updatePlacedAppliedPackages(ee.floor,!0,"suparea",V),Z.programState.placeModule(ee)}}},83575:(tt,me,P)=>{P.d(me,{l:()=>r});var e=P(10347),E=P(74617),X=P(7610),O=P(79372),v=P(71115),h=P(20483),g=P(69932);
1class r{constructor(){this._materials=[],this._layouts=[],this._combos=[],this._querier2d=null,this._querier3d=null}get parentContext(){return this._parentContext}get materials(){return this._materials}get layouts(){return this._layouts}get combos(){return this._combos}set querier2d(n){this._querier2d=n}set querier3d(n){this._querier3d=n}static fromProvider(n,l){const p=new r;return p._parentContext=l,p._materials=n.partitionMaterials||[],p._layouts=n.partitionLayouts||[],p._combos=n.partitionCombos||[],p}static toJson(n){return{materials:n._materials.map(l=>O.k.toJson(l)),layouts:n._layouts.map(l=>v.C.toJson(l)),combos:n._combos.map(l=>h.j.toJson(l))}}dispose(n){this._parentContext=null,this._querier2d=null,this._querier3d=null,n&&(this._materials.forEach(l=>l.dispose()),this._layouts.forEach(l=>l.dispose()),this._combos.forEach(l=>l.dispose()),this._materials=[],this._layouts=[],this._combos=[])}static createDefault(){const n=new r;let l=1,p=1;for(const ne of["glass","plain"]){const K=new O.k;K._id=l++,K._material=ne;const k=`assets/viewer/wall_panel_${ne}.`,x=new X.Z;x._id=p++,x._length=90,x._svg=k.replace("panel","door")+"svg",x._d3=k.replace("panel","door")+"fbx",x._svgPivotOffset={x:0,y:5},K._door=x;const f=new X.Z;f._id=p++,f._length=100,f._svg=k+"svg",f._d3=k+"fbx",K._main=f;const J=new X.Z;J._id=p++,J._length=10,J._svg=k.replace("panel","corner")+"svg",J._d3=k.replace("panel","corner")+"fbx",K._corner=J,n._materials.push(K);const L=new v.C;L._type=ne,L._core=K,n._layouts.push(L)}const y=new v.C;y._type="hybrid",y._core=n._materials[1];const D=new v.Z;D._length=50,D._material=n._materials[0],y._begin=D,y._end=D,n._layouts.push(y);const Y=[[0,0,2],[1,0,1],[0,2,1],[2,0,2],[2,2,1]];for(const[ne,K,k]of Y){const x=new h.j;x._a=n._layouts[ne],x._b=n._layouts[K],x._result=n._layouts[k],n._combos.push(x)}const H=r.toJson(n);return n.dispose(!0),H}createCorner2d(n,l){this._querier2d.queryPartitionPanel(n.material.corner.id,p=>{if(p){let y=new e.G({class:"svg-partition-corner"});y.attr("pointer-events","all"),y.node.addEventListener("mouseover",Y=>{!y.node.contains(Y.relatedTarget)&&!y.node.__sfSelected&&((0,g.E)(y.node.ownerSVGElement),y.node.setAttribute("filter","url(#sf-glow-blue)"))}),y.node.addEventListener("mouseout",Y=>{!y.node.contains(Y.relatedTarget)&&!y.node.__sfSelected&&y.node.removeAttribute("filter")}),y.svg(p.svg()),y.node.__sfCorner=n;const D={x:Number.parseFloat(p.width().toString(10))/2,y:Number.parseFloat(p.height().toString(10))/2};y.transform({originX:D.x,originY:D.y,rotate:Math.atan2(-n.rotation.getY(),n.rotation.getX())/Math.PI*180,translateX:n.position.getX()-D.x,translateY:-n.position.getY()-D.y}),y.addTo(l)}})}createCorner3d(n){let l={position:new E.Pa4(n.position.getX(),0,n.position.getY()),rotationY:Math.atan2(n.rotation.getY(),n.rotation.getX())};return this._querier3d.queryPartitionPanel(n.material.corner.id,p=>{p&&(l.model=p,p.set(l.position.clone(),l.rotationY))}),l}createWall2d(n,l,p,y){const D_x=n.endPosition.getX()-n.startPosition.getX(),D_y=-1*(n.endPosition.getY()-n.startPosition.getY()),Y=Math.sqrt(D_x*D_x+D_y*D_y),H={x:D_x/Y,y:D_y/Y},ne=Math.atan2(H.y,H.x);let K={x:n.startPosition.getX(),y:-1*n.startPosition.getY()};n.spans.forEach(k=>{0!=k.offset&&(K.x+=k.offset*H.x,K.y+=k.offset*H.y);const x=null!=k.door,f=x?k.material.door.length:k.material.main.length,J=x?k.material.door.svgPivotOffset:k.material.main.svgPivotOffset,L=J?{x:J.x??0,y:J.y??0}:null,ce=k.length/f,ke=x&&k.door?ne+Math.PI:ne,Xe=x&&k.door?{x:H.x*f,y:H.y*f}:{x:0,y:0},te_x=K.x+Xe.x,te_y=K.y+Xe.y;this._querier2d.queryPartitionPanel((x?k.material.door:k.material.main).id,ye=>{if(!ye)return;const Ee=x?"sf-glow-green":"sf-glow-blue";let q=new e.G({class:x?"svg-partition-wall svg-partition-door":"svg-partition-wall"});q.attr("pointer-events","all"),q.node.addEventListener("mouseover",ee=>{!q.node.contains(ee.relatedTarget)&&!q.node.__sfSelected&&((0,g.E)(q.node.ownerSVGElement),q.node.setAttribute("filter",`url(#${Ee})`))}),q.node.addEventListener("mouseout",ee=>{!q.node.contains(ee.relatedTarget)&&!q.node.__sfSelected&&q.node.removeAttribute("filter")}
1),q.addTo(l),q.svg(ye.svg()),q.node.__sfPartition=n,q.node.__sfSpan=k,x&&(q.node.__sfDoor=k);const oe={x:L?L.x:0,y:L?L.y:Number.parseFloat(ye.height().toString(10))/2};if(q.transform({scaleX:ce,originX:oe.x,originY:oe.y,rotate:ke/Math.PI*180,translateX:te_x-oe.x,translateY:te_y-oe.y}),!x&&y){let ee=!1,Z=0,Q=0,V=[];q.node.addEventListener("pointerdown",U=>{0===U.button&&(U.stopPropagation(),ee=!0,Z=U.clientX,Q=U.clientY,V=Array.from(l.node.children).filter(re=>re.__sfPartition===n).map(re=>({node:re,orig:re.getAttribute("transform")||""})),q.node.setPointerCapture(U.pointerId))}),q.node.addEventListener("pointermove",U=>{if(!ee)return;const re=q.node.ownerSVGElement;if(!re)return;const ae=re.getScreenCTM();if(!ae)return;const de=(Ye,Te)=>{const Je=re.createSVGPoint();return Je.x=Ye,Je.y=Te,Je.matrixTransform(ae.inverse())},he=de(Z,Q),ve=de(U.clientX,U.clientY),be=ve.x-he.x,Le=ve.y-he.y;for(const{node:Ye,orig:Te}of V)Ye.setAttribute("transform",`translate(${be} ${Le}) ${Te}`.trim())}),q.node.addEventListener("pointerup",U=>{if(!ee)return;ee=!1,q.node.releasePointerCapture(U.pointerId);const re=q.node.ownerSVGElement;if(!re)return;const ae=re.getScreenCTM();if(!ae)return;const de=(Ye,Te)=>{const Je=re.createSVGPoint();return Je.x=Ye,Je.y=Te,Je.matrixTransform(ae.inverse())},he=de(Z,Q),ve=de(U.clientX,U.clientY),be=ve.x-he.x,Le=ve.y-he.y;if(Math.abs(be)<2&&Math.abs(Le)<2)for(const{node:Ye,orig:Te}of V)Te?Ye.setAttribute("transform",Te):Ye.removeAttribute("transform");else y(be,Le)})}if(x&&p){const ee={x:H.x,y:H.y};let Z=!1,Q=0,V=0,U=k.offset,re="";q.node.addEventListener("pointerdown",ae=>{0===ae.button&&(ae.stopPropagation(),Z=!0,Q=ae.clientX,V=ae.clientY,U=k.offset,re=q.node.getAttribute("transform")||"",q.node.setPointerCapture(ae.pointerId))}),q.node.addEventListener("pointermove",ae=>{if(!Z)return;const de=q.node.ownerSVGElement;if(!de)return;const he=de.getScreenCTM();if(!he)return;const ve=(Te,Je)=>{const Qe=de.createSVGPoint();return Qe.x=Te,Qe.y=Je,Qe.matrixTransform(he.inverse())},be=ve(Q,V),Le=ve(ae.clientX,ae.clientY),Ye=(Le.x-be.x)*ee.x+(Le.y-be.y)*ee.y;q.node.setAttribute("transform",`translate(${Ye*ee.x} ${Ye*ee.y}) ${re}`.trim())}),q.node.addEventListener("pointerup",ae=>{if(!Z)return;Z=!1,q.node.releasePointerCapture(ae.pointerId);const de=q.node.ownerSVGElement;if(!de)return;const he=de.getScreenCTM();if(!he)return;const ve=(Je,Qe)=>{const st=de.createSVGPoint();return st.x=Je,st.y=Qe,st.matrixTransform(he.inverse())},be=ve(Q,V),Le=ve(ae.clientX,ae.clientY),Ye=(Le.x-be.x)*ee.x+(Le.y-be.y)*ee.y;if(Math.abs(Ye)<2)return void q.node.setAttribute("transform",re);const Te=U+Ye;k._offset=Te,p(k,U,Te)})}}),K.x+=k.length*H.x,K.y+=k.length*H.y})}createWall3d(n){let l=[];const p_x=n.endPosition.getX()-n.startPosition.getX(),p_y=n.endPosition.getY()-n.startPosition.getY(),y=Math.sqrt(p_x*p_x+p_y*p_y),D={x:p_x/y,y:p_y/y},Y=Math.atan2(D.y,D.x);let H={x:n.startPosition.getX(),y:n.startPosition.getY()};return n.spans.forEach(ne=>{0!=ne.offset&&(H.x+=ne.offset*D.x,H.y+=ne.offset*D.y);const K=null!=ne.door,k=K?ne.material.door.length:ne.material.main.length,x=ne.length/k,f=K&&ne.door?Y+Math.PI:Y,J=K&&ne.door?{x:D.x*k,y:D.y*k}:{x:0,y:0},L={x:H.x+J.x,y:H.y+J.y};let ce={position:new E.Pa4(L.x,0,L.y),rotationY:f,scale:new E.Pa4(x,1,1)};l.push(ce),this._querier3d.queryPartitionPanel((K?ne.material.door:ne.material.main).id,ke=>{ke&&(ce.model=ke,ke.set(new E.Pa4(L.x,0,L.y),ce.rotationY,ce.scale))}),H.x+=ne.length*D.x,H.y+=ne.length*D.y}),l}}},21026:(tt,me,P)=>{P.d(me,{j:()=>fs,P:()=>Bi});var e=P(47318),E=P(21449),X=P(73636),O=P(92380);class v{constructor(t,c,N){this.startNode=null,this.endNode=null,this.line=null,t&&"isLine"in t&&t.isLine()?(this.startNode=t.startNode_(),this.endNode=t.endNode_(),this.line=t):(this.startNode=t||null,this.endNode=c||null,this.line=N||null)}static fromLineBuilder(t){return new v(t.startNode_(),t.endNode_(),t)}asP2Line(){return e.uM(this.startNode.position(),this.endNode.position())}isSameOrientation(){return e.rz(e.hX(this.asP2Line()),e.hX(this.line.p2Line()))>0}curve(){return this.line?this.line.curve:null}reverse(){const t=this.startNode;return this.startNode=this.endNode,this.endNode=t,this}getLineSpans(){let t=0;const c=[],N=this.line.getLineSpans(),[z,ie,pe,we]=e.AN(this.line.p2Line(),this.startNode.position(),this.endNode.position());for(const fe of N)if(fe.startOffset<ie&&fe.endOffset>z){const We=new E.Uq(fe);We.startOffset=Math.max(fe.startOffset,z),We.endOffset=Math.min(fe.endOffset,ie),c.push(We),t|=We.spanFlags}return[t,c]}buildElement(){const t=new O.Fn;return t.startNode=this.startNode.uidInPackage(),t.endNode=this.endNode.uidInPackage(),t.line=this.line.uidInPackage(),t}static toPath(t){if(!t.length)return e.CK();const c=[t[0].startNode.position(),...t.map(N=>N.endNode.position())];return e.CK(c)}static toRing(t){return e.I$(v.toPath(t).getCoordinates())}static toPolygon(t){if(!t.length)return e.p();const c=[t[0].startNode.position(),...t.map(N=>N.endNode.position())];return e.p(c)}static isValidRing(t){const c=v.toPath(t);return c.getCoordinates().length>3&&(!(c.getCoordinates().length>4)||c.getCoordinateN(0)===c.getCoordinateN(c.getCoordinates().length-1))}static correctOrientation(t,c=!1){if(!t.length)return t;let N=0;for(const ie of t){const pe=ie.startNode.position(),we=ie.endNode.position();N+=(we.getX()-pe.getX())*(we.getY()+pe.getY())}return c===N>0?t.slice().reverse().map(pe=>pe.reverse()):t}dispose(){this.startNode=null,this.endNode=null,this.line=null}}var h=P(66430),g=P(38976);class a extends g.g2{constructor(){super(...arguments),this._uidInPackage=new E.ph,this.outerPath=[],this.innerPaths=[],this.overlappingElements=[]}uidInPackage(){return this._uidInPackage}getAllRings(){return[this.outerPath,...this.innerPaths]}asPolygon(){const t=v.toRing(this.outerPath),c=this.innerPaths.map(N=>v.toRing(N));return e.p(t,c)}buildElement(){const t=this.Tpl().TInfo();t._uidInPackage=this._uidInPackage,t.overlappingElementUids=this.overlappingElements.map(c=>c.uidInPackage()),t.outerPath=this.outerPath.map(c=>c.buildElement());for(const c of this.innerPaths){const N=c.map(z=>z.buildElement());t.innerPaths.push(N)}return this.finalizeInfo(t),t}finalizeInfo(t){}static _tplFromParsed(t,c){const N=new t;return N._uidInPackage=c.uidInPackage(),N}static fromParsed(t,c){return this._tplFromParsed(t,c)}dispose(){this.outerPath.forEach(t=>t.dispose()),this.outerPath=[],this.innerPaths.forEach(t=>{t.forEach(c=>c.dispose())}),this.innerPaths=[]}}class n extends a{constructor(){super(...arguments),this.corridorType=E.Wr.PRIMARY}static#e=this._TPL=new g.nD({TInfo:h.TX});Tpl(){return n._TPL}shapeType(){return g.xR.CORRIDOR}finalizeInfo(t){t.corridorType=this.corridorType}static fromParsed(t){const c=a._tplFromParsed(n,t);
1return c.corridorType=t.corridorType(),c}}class l extends a{constructor(){super(...arguments),this.obstacle=null}static#e=this._TPL=new g.nD({TInfo:h.mx});Tpl(){return l._TPL}shapeType(){return g.xR.OBSTACLE}finalizeInfo(t){t.obstacleUid=this.obstacle.uidInPackage()}static fromParsed(t){const c=a._tplFromParsed(l,t);return c.obstacle=t.obstacle(),c}}class p extends a{constructor(){super(...arguments),this.isDirectLight=!1}static#e=this._TPL=new g.nD({TInfo:h.bK});Tpl(){return p._TPL}shapeType(){return g.xR.LIGHT}finalizeInfo(t){t.isDirectLight=this.isDirectLight}static fromParsed(t){const c=a._tplFromParsed(p,t);return c.isDirectLight=t.isDirectLight(),c}}class y extends a{constructor(){super(...arguments),this.type=g.W5.STRAIGHT,this.width=0,this.height=0,this.isReceptionFriendly=!1,this.partitionableSpans=[],this.corridorWidth=0,this.corridorPart=[],this.wallPart=[],this.startPerpLine=null,this.endPerpLine=null}static#e=this._TPL=new g.nD({TInfo:h.Uh});Tpl(){return y._TPL}shapeType(){return g.xR.PARTITIONABLE}finalizeInfo(t){t.type=this.type,t.width=this.width,t.height=this.height,t.isReceptionFriendly=this.isReceptionFriendly,t.partitionableSpans=this.partitionableSpans.map(c=>c.buildElement()),t.corridorWidth=this.corridorWidth,t.startPerpLineUid=this.startPerpLine?this.startPerpLine.uidInPackage():new E.ph,t.endPerpLineUid=this.endPerpLine?this.endPerpLine.uidInPackage():new E.ph}isIrrigated(){return this.corridorWidth>1}dispose(){super.dispose(),this.startPerpLine=null,this.endPerpLine=null}}class D extends a{constructor(){super(...arguments),this.hasOrientation=!0,this.worldToLocalMtx=[0,0,0,0,0,0],this.gridLines=[],this.cellCount=0,this.columns=0,this.rows=0,this.irrigatedCoords=[],this.wallCoords=[]}static#e=this._TPL=new g.nD({TInfo:h.un});Tpl(){return D._TPL}shapeType(){return g.xR.GRID}finalizeInfo(t){t.hasOrientation=this.hasOrientation,t.worldToLocalMtx=this.worldToLocalMtx,t.gridLineUids=this.gridLines.map(c=>c.uidInPackage()),t.cellCount=this.cellCount,t.columns=this.columns,t.rows=this.rows,t.irrigatedCoords=this.irrigatedCoords,t.wallCoords=this.wallCoords}static fromParsed(t){const c=a._tplFromParsed(D,t);return c.hasOrientation=t.hasOrientation(),c.worldToLocalMtx=t.worldToLocalMtx(),c.cellCount=t.cellCount(),c.columns=t.columns(),c.rows=t.rows(),c.irrigatedCoords=t.irrigatedCoords().slice(),c.wallCoords=t.wallCoords().slice(),c}}class Y extends a{constructor(){super(...arguments),this.moduleOrProgramModule=null,this.overtakerDepartment=null}static#e=this._TPL=new g.nD({TInfo:h.CZ});Tpl(){return Y._TPL}shapeType(){return g.xR.MODULE}finalizeInfo(t){t.moduleOrProgramModuleUid=this.moduleOrProgramModule.uidInPackage(),t.overtakerDepartmentUid=this.overtakerDepartment?this.overtakerDepartment.uidInPackage():new E.ph}dispose(){super.dispose(),this.moduleOrProgramModule=null,this.overtakerDepartment=null}}class H extends a{constructor(){super(...arguments),this.moduleCategoryIdOrDepartmentName=0,this.useTypeOrDepartmentWorkforce=0}static#e=this._TPL=new g.nD({TInfo:h.Wm});Tpl(){return H._TPL}shapeType(){return g.xR.MODULE_CATEGORY}finalizeInfo(t){t.moduleCategoryIdOrDepartmentName=this.moduleCategoryIdOrDepartmentName,t.useTypeOrDepartmentWorkforce=this.useTypeOrDepartmentWorkforce}}class ne extends a{constructor(){super(...arguments),this.furnitureUri="",this.orientation=0}static#e=this._TPL=new g.nD({TInfo:h.Wc});Tpl(){return ne._TPL}shapeType(){return g.xR.FURNITURE}finalizeInfo(t){t.furnitureUri=this.furnitureUri,t.orientation=this.orientation}static fromParsed(t){const c=a._tplFromParsed(ne,t);return c.furnitureUri=t.furnitureUri(),c.orientation=t.orientation(),c}}P(75110);var f=P(59693);class J extends f.IA{get addedPackages(){return this._addedPackages}constructor(t,c){super(),this._parentProvider=null,this._addElementsByType=new Map,this._removeElementByUids=new Map,this._addedPackageIds=new Set,this._addedPackages=new Set,this._parentProvider=t,this._isUnapplying=c}addPackage(t){if(this._addedPackageIds.has(t.elementId()))return;this._addedPackageIds.add(t.elementId()),this._addedPackages.add(t);const c=this._isUnapplying?t.getToAddElements():t.getToRemoveElements();for(const z of c)this._removeElementByUids.set(z.uidInPackage(),z);const N=this._isUnapplying?t.getToRemoveElements():t.getToAddElements();for(const z of N){const ie=this._addElementsByType.get(z.elementType())||[];ie.push(z),this._addElementsByType.set(z.elementType(),ie)}}conclude(){for(const[t,c]of this._addElementsByType.entries())this._addElementsByType.set(t,c.filter(N=>!this._removeElementByUids.has(N.uidInPackage())))}getToRemoveElements(){return Array.from(this._removeElementByUids.values())}getToAddElements(){let t=[];for(const c of this._addElementsByType.values())t=t.concat(c);return t}getElement(t,c){const N=this._addElementsByType.get(t);if(N)for(const z of N)if(z.elementId()===c)return z;return null}}class L{_isFrozen(){return[f.WA.ROOT_LOT,f.WA.PARAMETRIC_INITIAL].includes(this.targetPackage.packageType())}constructor(t=null,c=[]){this._boundSupAreaUids=new Set,this._boundModuleUids=new Set,this.targetPackage=t,this.childrenIds=c}updatePlacedAppliedPackages(t,c,N){const z="suparea"===c?this._boundSupAreaUids:this._boundModuleUids;
1return N.forEach(t?ie=>z.add(ie):ie=>z.delete(ie)),!this._isFrozen()&&!this._boundSupAreaUids.size&&!this._boundModuleUids.size}}class ce{constructor(){this.canApply=!1,this.toApplyPackages=[]}}class ke{constructor(){this._appliedPackages=new Map,this._forbiddenPackageIdCounterMap=new Map}updatePlacedAppliedPackages(t,c,N){const z=[];let ie={};for(const[pe,we]of Object.entries(N)){const fe=parseInt(pe);we.forEach(We=>{ie[We]||(ie[We]=[]),ie[We].push(fe)})}for(const[pe,we]of Object.entries(ie)){const fe=this._appliedPackages.get(parseInt(pe));fe&&fe.updatePlacedAppliedPackages(t,c,we)&&z.push(parseInt(pe))}return t?[]:z}getPackageRequirements(t){const c=new ce;if(t.isPackageProvider())return c;const N=new Set,z=new Set,ie=[t];for(const we of this._forbiddenPackageIdCounterMap.keys())z.add(we);let pe=100;for(;ie.length&&pe>0;){pe--;const we=ie.shift();if(z.has(we.elementId()))return c;for(const fe of we.forbiddenPackageUids())if(this._appliedPackages.has(fe))return c;c.toApplyPackages.push(we);for(const fe of we.forbiddenPackageUids())z.add(fe);for(const fe of we.requiredPackageUids())if(!this._appliedPackages.has(fe)&&!N.has(fe)){N.add(fe);const We=we.parentProvider(),je=We?We.getPackage(fe).package:null;if(!je||je.isPackageProvider())continue;ie.push(je)}}return c.canApply=c.toApplyPackages.length>0,c.toApplyPackages.sort((we,fe)=>we.elementId()-fe.elementId()),c}applyPackage(t){if([f.WA.ROOT_LOT,f.WA.NONE].includes(t.packageType()))return;if(t.packageType()===f.WA.COMPOSITE)return void t.addedPackages.forEach(ie=>this.applyPackage(ie));for(const ie of t.forbiddenPackageUids())this._forbiddenPackageIdCounterMap.set(ie,(this._forbiddenPackageIdCounterMap.get(ie)||0)+1);const c=t.parentProvider(),N=c?c.getChildrenPackages(t):[],z=new L(t);z.childrenIds=N.map(ie=>ie.elementId()),this._appliedPackages.set(t.elementId(),z)}unapplyPackage(t){if(t.packageType()!==f.WA.COMPOSITE){if(this._appliedPackages.get(t.elementId())){this._appliedPackages.delete(t.elementId());for(const N of t.forbiddenPackageUids()){const z=(this._forbiddenPackageIdCounterMap.get(N)||1)-1;z<=0?this._forbiddenPackageIdCounterMap.delete(N):this._forbiddenPackageIdCounterMap.set(N,z)}}}else t.addedPackages.forEach(N=>this.unapplyPackage(N))}getAppliedPackageIds(){return Array.from(this._appliedPackages.keys())}copyFrom(t,c){this._forbiddenPackageIdCounterMap=new Map(t._forbiddenPackageIdCounterMap);for(const[N,z]of t._appliedPackages.entries()){const ie=c?c.getPackage(N).package:z.targetPackage;this._appliedPackages.set(N,new L(ie,z.childrenIds))}}tryApplyPackage(t){const c=new X.m,N=this.getPackageRequirements(t);if(!N.canApply)return[c,null];let z=null;if(N.toApplyPackages.length>1){z=new J(t.parentProvider(),!1);for(const ie of N.toApplyPackages)z.addPackage(ie);z.conclude()}return c.canApply=!0,c.packageManagerApplyClbks.push(()=>N.toApplyPackages.forEach(ie=>this.applyPackage(ie))),[c,z]}tryUnapplyPackage(t){const c=new X.m,N=this._appliedPackages.get(t.elementId());if(!N||N.targetPackage!==t)return[c,null];const z=[N],ie=new Set([t.elementId()]);let pe=[],we=100;for(;z.length&&we>0;){we--;const We=z.shift();pe.push(We.targetPackage);for(const je of We.childrenIds){if(ie.has(je))continue;ie.add(je);const _t=this._appliedPackages.get(je);_t&&z.push(_t)}}pe=pe.sort((We,je)=>je.elementId()-We.elementId()),c.canApply=!0,c.packageManagerApplyClbks.push(()=>pe.forEach(We=>this.unapplyPackage(We)));let fe=null;if(pe.length>1){fe=new J(t.parentProvider(),!0);for(const We of pe)fe.addPackage(We);fe.conclude()}return[c,fe]}dispose(){this._appliedPackages.clear(),this._forbiddenPackageIdCounterMap.clear()}}var Xe=P(81640),te=P(14960),ye=P(56220);class Ae extends g.yO{clone(t=null){if(!t)throw new Error("Clone must be provided by subclass");return super.clone(t),t._previousLine=this._previousLine,t._nextLine=this._nextLine,t._curve=this._curve,t}isNode(){return!0}isLine(){return!1}elementType(){return E.TE.NODE_PARSED}previousLine(){return this._previousLine}nextLine(){return this._nextLine}curve(){return this._curve}dispose(){this._previousLine&&this._previousLine.detach(this),this._nextLine&&this._nextLine.detach(this),this._previousLine=void 0,this._nextLine=void 0}detach(t){t&&t.isLine?t===this._previousLine?(this._previousLine=void 0,this._refCount--):t===this._nextLine&&(this._nextLine=void 0,this._refCount--):(this._linkedNavigable.removeWatchingParsedShape(t),this.decrement
1())}attach(t){this._linkedNavigable.addWatchingParsedShape(t),this.increment()}countLinksToParsed(t,c){return c?0:(this._previousLine&&t===this._previousLine?1:0)+(this._nextLine&&t===this._nextLine?1:0)}countLinksToPackageElement(t,c){if(c)return 0;const N=t.uidInPackage();return(this._previousLine&&N===this._previousLine.linkedLayerElementInfo().uidInPackage()?1:0)+(this._nextLine&&N===this._nextLine.linkedLayerElementInfo().uidInPackage()?1:0)}}class Ee{constructor(t){this.TInfo=t.TInfo}}class q extends Ae{clone(t){return super.clone(t),t._targetNodeInfo=this._targetNodeInfo,t}elementId(){return this._targetNodeInfo?.elementId()??0}position(){return this._targetNodeInfo?.position}normalToInside(){return this._targetNodeInfo?.normalToInside}nodeType(){return this._targetNodeInfo?.nodeType()??g.Mq.WALL}linkedLayerElementInfo(){return this._targetNodeInfo}_tplCopyFrom(t,c){this._targetNodeInfo=c.getElementInfoOrDefault(t._targetNodeInfo),t._curve&&(this._curve=c.elementProvider.getElement(t._curve.fullUid)),t._previousLine&&(this._previousLine=c.getParsedElementOrError(t._previousLine)),t._nextLine&&(this._nextLine=c.getParsedElementOrError(t._nextLine)),this._linkedNavigable=void 0}static create(t,c,N){const z=new t;return z._targetNodeInfo=c,z._curve=N.currentElementProvider().getElement(c.curve),[z,function ie(pe,we){const fe=we.currentDirectoryLut();if(!pe._targetNodeInfo.previousLine.isNull()){const We=new te.nh.LutK(pe._targetNodeInfo.previousLine);fe.has(We)&&(pe._previousLine=fe.get(We),pe._previousLine.increment())}if(!pe._targetNodeInfo.nextLine.isNull()){const We=new te.nh.LutK(pe._targetNodeInfo.nextLine);fe.has(We)&&(pe._nextLine=fe.get(We),pe._nextLine.increment())}}]}copyFrom(t,c){this._tplCopyFrom(t,c)}}class oe extends q{static#e=this._TPL=new Ee({TInfo:ye.EX});Tpl(){return oe._TPL}isMullion(){return this._targetNodeInfo?.isMullion??!1}mayPartition(){return this._targetNodeInfo?.mayPartition??!1}clone(){const t=new oe;return super.clone(t),t}}class ee extends q{static#e=this._TPL=new Ee({TInfo:ye.Zo});Tpl(){return ee._TPL}clone(){const t=new ee;return super.clone(t),t}}class Z extends q{static#e=this._TPL=new Ee({TInfo:ye.hL});Tpl(){return Z._TPL}circulable(){return this._circulable}hasCirculable(){return void 0!==this._circulable}maybeCirculableDoor(){return this.hasCirculable()&&this._circulable?.circulableType()===E.Pv.PROPERTY_DOOR}clone(){const t=new Z;return super.clone(t),t._circulable=this._circulable,t}static _createHydrate(t,c){t._circulable=c.currentElementProvider().getElement(t._targetNodeInfo.circulable)}copyFrom(t,c){super.copyFrom(t,c),t.circulable()&&(this._circulable=c.elementProvider.getElement(t.circulable().uidInPackage()))}}class Q extends q{static#e=this._TPL=new Ee({TInfo:ye.UM});Tpl(){return Q._TPL}obstacleType(){return this._targetNodeInfo?.obstacleType??E.xe.POST}clone(){const t=new Q;return super.clone(t),t}}class V extends q{static#e=this._TPL=new Ee({TInfo:ye.BA});Tpl(){return V._TPL}clone(){const t=new V;return super.clone(t),t}}class U extends q{static#e=this._TPL=new Ee({TInfo:ye.EE});Tpl(){return U._TPL}clone(){const t=new U;return super.clone(t),t}}class re extends q{static#e=this._TPL=new Ee({TInfo:ye.BL});Tpl(){return re._TPL}clone(){const t=new re;return super.clone(t),t}}class ae extends q{static#e=this._TPL=new Ee({TInfo:ye.iF});Tpl(){return ae._TPL}clone(){const t=new ae;return super.clone(t),t}}class de extends q{static#e=this._TPL=new Ee({TInfo:ye.od});Tpl(){return de._TPL}clone(){const t=new de;return super.clone(t),t}}class he extends q{static#e=this._TPL=new Ee({TInfo:ye.GY});Tpl(){return he._TPL}clone(){const t=new he;return super.clone(t),t}}class ve extends q{static#e=this._TPL=new Ee({TInfo:ye.xi});Tpl(){return ve._TPL}clone(){const t=new ve;return super.clone(t),t}}class be extends q{static#e=this._TPL=new Ee({TInfo:ye.kK});Tpl(){return be._TPL}clone(){const t=new be;return super.clone(t),t}}var Le=P(95627);class Te extends g.yO{isNode(){return!1}isLine(){return!0}clone(t=null){if(!t)throw new Error("Clone must be provided by subclass");return super.clone(t),t._startNode=this._startNode,t._endNode=this._endNode,t._curve=this._curve,t}elementType(){return E.TE.LINE_PARSED}startNode(){return this._startNode}endNode(){return this._endNode}curve(){return this._curve}dispose(){this._startNode&&this._startNode.detach(this),this._endNode&&this._endNode.detach(this),this._startNode=void 0,this._endNode=void 0,this._curve=void 0}detach(t){t&&t.isNode?t===this._startNode?(this._startNode=void 0,this._refCount--):t===this._endNode&&(this._endNode=void 0,this._refCount--):(this._linkedNavigable.removeWatchingParsedShape(t),this.decrement
1())}attach(t){this._linkedNavigable.addWatchingParsedShape(t),this.increment()}countLinksToParsed(t,c){return c?0:(this._startNode&&t===this._startNode?1:0)+(this._endNode&&t===this._endNode?1:0)}countLinksToPackageElement(t,c){if(c)return 0;const N=t.uidInPackage();return(this._startNode&&N===this._startNode.linkedLayerElementInfo().uidInPackage()?1:0)+(this._endNode&&N===this._endNode.linkedLayerElementInfo().uidInPackage()?1:0)}}class Je{constructor(t={}){this.TInfo=t.TInfo}}class Qe extends Te{elementId(){return this._targetLineInfo?.elementId()}p2Line(){return this._targetLineInfo?.p2Line}normalToInside(){return e.ih(e.hX(this.p2Line()))}lineType(){return this._targetLineInfo?.lineType()}linkedLayerElementInfo(){return this._targetLineInfo}clone(t){return super.clone(t),t._targetLineInfo=this._targetLineInfo,t}_tplCopyFrom(t,c){this._targetLineInfo=c.getElementInfoOrDefault(t._targetLineInfo),t._curve&&(this._curve=c.elementProvider.getElement(t._curve.fullUid)),t._startNode&&(this._startNode=c.getParsedElementOrError(t._startNode)),t._endNode&&(this._endNode=c.getParsedElementOrError(t._endNode)),this._linkedNavigable=void 0}static create(t,c,N){const z=new t;return z._targetLineInfo=c,z._curve=N.currentElementProvider().getElement(c.curve),[z,function ie(pe,we){const fe=we.currentDirectoryLut();if(!pe._targetLineInfo.startNode.isNull()){const We=new te.nh.LutK(pe._targetLineInfo.startNode);fe.has(We)&&(pe._startNode=fe.get(We),pe._startNode.increment())}if(!pe._targetLineInfo.endNode.isNull()){const We=new te.nh.LutK(pe._targetLineInfo.endNode);fe.has(We)&&(pe._endNode=fe.get(We),pe._endNode.increment())}}]}copyFrom(t,c){this._tplCopyFrom(t,c)}}class st extends Qe{static#e=this._TPL=new Je({TInfo:Le.J9});Tpl(){return st._TPL}lineSpans(){return this._targetLineInfo?.lineSpans??[]}spanFlags(){return this._targetLineInfo?.spanFlags??0}clone(){const t=new st;return super.clone(t),t}}class et extends Qe{static#e=this._TPL=new Je({TInfo:Le.Eb});Tpl(){return et._TPL}clone(){const t=new et;return super.clone(t),t}}class Et extends Qe{static#e=this._TPL=new Je({TInfo:Le.nv});Tpl(){return Et._TPL}clone(){const t=new Et;return super.clone(t),t}}class lt extends Qe{static#e=this._TPL=new Je({TInfo:Le.ze});Tpl(){return lt._TPL}obstacleType(){return this._targetLineInfo?.obstacleType??E.xe.POST}clone(){const t=new lt;return super.clone(t),t}}class i extends Qe{static#e=this._TPL=new Je({TInfo:Le.XX});Tpl(){return i._TPL}clone(){const t=new i;return super.clone(t),t}}class d extends Qe{static#e=this._TPL=new Je({TInfo:Le.as});Tpl(){return d._TPL}clone(){const t=new d;return super.clone(t),t}}class I extends Qe{static#e=this._TPL=new Je({TInfo:Le._e});Tpl(){return I._TPL}index(){return this._targetLineInfo?.index??0}alignment(){return this._targetLineInfo?.alignment??void 0}clone(){const t=new I;return super.clone(t),t}}class w extends Qe{static#e=this._TPL=new Je({TInfo:Le.lj});Tpl(){return w._TPL}clone(){const t=new w;return super.clone(t),t}}class _ extends Qe{static#e=this._TPL=new Je({TInfo:Le.Tl});Tpl(){return _._TPL}clone(){const t=new _;return super.clone(t),t}}class o extends Qe{static#e=this._TPL=new Je({TInfo:Le.kK});Tpl(){return o._TPL}index(){return this._targetLineInfo?.index??0}clone(){const t=new o;return super.clone(t),t}}class s extends Qe{static#e=this._TPL=new Je({TInfo:Le.ev});Tpl(){return s._TPL}clone(){const t=new s;return super.clone(t),t}}class u extends Qe{static#e=this._TPL=new Je({TInfo:Le.im});Tpl(){return u._TPL}clone(){const t=new u;return super.clone(t),t}}var S=P(84322),T=P(4516);class F{constructor(t=g.Mq.WALL,c=null,N=null,z=g.gb.WALL,ie=null,pe=null){this.nodeType=t,this.lineType=z,this.tNodeInfo=c,this.tParsedNode=N,this.tLineInfo=ie,this.tParsedLine=pe}}class $ extends te.j5{constructor(){super(...arguments),this._parsedNodes=new T.me,this._parsedLines=new T.me}_tplCopyFrom(t,c,N){if(N){this._parsedNodes=t._parsedNodes.map(z=>z.clone()),this._parsedLines=t._parsedLines.map(z=>z.clone());for(const[z,ie]of this._parsedNodes)c.fullUidParsedElementMap.set(z,ie);for(const[z,ie]of this._parsedLines)c.fullUidParsedElementMap.set(z,ie)}
1else this._parsedNodes.values().forEach(z=>z.copyFrom(z,c)),this._parsedLines.values().forEach(z=>z.copyFrom(z,c))}copyFrom(t,c,N){this._tplCopyFrom(t,c,N)}parsedNodes(){return this._parsedNodes}parsedLines(){return this._parsedLines}tryAddNode(t){return this.tplTryAddElement(this.tpl().tNodeInfo,this.tpl().tParsedNode,this._parsedNodes,t)}tryRemoveNode(t,c,N){return this.tplTryRemoveElement(this._parsedNodes,t,c,N)}tryAddLine(t){return this.tplTryAddElement(this.tpl().tLineInfo,this.tpl().tParsedLine,this._parsedLines,t)}tryRemoveLine(t,c,N){return this.tplTryRemoveElement(this._parsedLines,t,c,N)}manageNodeType(){return this.tpl().nodeType}manageLineType(){return this.tpl().lineType}canHandleElement(t){return t.elementType()===E.TE.NODE_INFO&&t.nodeType()===this.manageNodeType()||t.elementType()===E.TE.LINE_INFO&&t.lineType()===this.manageLineType()}getElementAddOrder(t){return t.isNode()?0:1}tryRemoveElement(t,c,N){return t.isNode()?this.tryRemoveNode(t,c,N):this.tryRemoveLine(t,c,N)}tryAddElement(t){return t.isNode()?this.tryAddNode(t):this.tryAddLine(t)}tryGetParsedElement(t,c){return t===E.TE.NODE_INFO?this._parsedNodes.get(c)??null:t===E.TE.LINE_INFO?this._parsedLines.get(c)??null:null}computeMultipoint(){return e.H3(Object.values(this._parsedNodes).map(t=>t.position()))}computeMultiline(){return e.aJ(Object.values(this._parsedLines).map(t=>t.p2Line()))}getClosestNode(t){let c=1/0,N=null;for(const z of this._parsedNodes.values()){const ie=e.TE(t,z.position());ie<c&&(c=ie,N=z)}return[c,N]}getClosestLine(t){let c=1/0,N=null;for(const z of this._parsedLines.values()){const ie=e.TE(t,z.p2Line());ie<c&&(c=ie,N=z)}return[c,N]}tryGetExactMatchLine(t){for(const c of this._parsedLines.values())if(e.fS(t,c.p2Line()))return c;return null}
1dispose(){this._parsedNodes.values().forEach(t=>t.dispose()),this._parsedLines.values().forEach(t=>t.dispose()),this._parsedNodes.clear(),this._parsedLines.clear()}}class ue extends ${static#e=this._TPL=new F(g.Mq.WALL,S.EX,oe,g.gb.WALL,S.J9,st);layerType(){return te.Dw.NETWORK_WALL}tpl(){return ue._TPL}}class Ie extends ${static#e=this._TPL=new F(g.Mq.CORRIDOR,S.Zo,ee,g.gb.CORRIDOR,S.Eb,et);layerType(){return te.Dw.NETWORK_CORRIDOR}tpl(){return Ie._TPL}}class Pe extends ${static#e=this._TPL=new F(g.Mq.CIRCULATION,S.hL,Z,g.gb.CIRCULATION,S.nv,Et);layerType(){return te.Dw.NETWORK_CIRCULATION}tpl(){return Pe._TPL}}class Ce extends ${static#e=this._TPL=new F(g.Mq.LIGHT,S.BA,V,g.gb.LIGHT,S.XX,i);layerType(){return te.Dw.NETWORK_LIGHT}tpl(){return Ce._TPL}}class Ue extends ${static#e=this._TPL=new F(g.Mq.PARTITIONABLE,S.EE,U,g.gb.PARTITIONABLE,S.as,d);layerType(){return te.Dw.NETWORK_PARTITIONABLE}tpl(){return Ue._TPL}}class Re extends ${static#e=this._TPL=new F(g.Mq.GRID,S.BL,re,g.gb.GRID,S._e,I);layerType(){return te.Dw.NETWORK_GRID}tpl(){return Re._TPL}}class ge extends ${static#e=this._TPL=new F(g.Mq.MODULE,S.iF,ae,g.gb.MODULE,S.lj,w);layerType(){return te.Dw.NETWORK_MODULE}tpl(){return ge._TPL}}class De extends ${static#e=this._TPL=new F(g.Mq.MODULE_CATEGORY,S.od,de,g.gb.MODULE_CATEGORY,S.Tl,_);layerType(){return te.Dw.NETWORK_MODULE_CATEGORY}tpl(){return De._TPL}}class He extends ${static#e=this._TPL=new F(g.Mq.OBSTACLE,S.UM,Q,g.gb.OBSTACLE,S.ze,lt);layerType(){return te.Dw.NETWORK_OBSTACLE}tpl(){return He._TPL}}class rt extends ${static#e=this._TPL=new F(g.Mq.CONSTRUCTION,S.GY,he,g.gb.CONSTRUCTION,S.kK,o);layerType(){return te.Dw.NETWORK_CONSTRUCTION}tpl(){return rt._TPL}}class Ge extends ${static#e=this._TPL=new F(g.Mq.PARTITION,S.xi,ve,g.gb.PARTITION,S.ev,s);layerType(){return te.Dw.NETWORK_PARTITION}tpl(){return Ge._TPL}}class mt extends ${static#e=this._TPL=new F(g.Mq.FURNITURE,S.IH,be,g.gb.FURNITURE,S.im,u);layerType(){return te.Dw.NETWORK_FURNITURE}tpl(){return mt._TPL}}class dt{constructor(t=null,c=null,N=0){this._node=null,this._line=null,this.offsetOnLine=0,this._node=t,this._line=c,this.offsetOnLine=N}get node(){return this._node}set node(t){this._node=t}get line(){return this._line}set line(t){this._line=t}lessThan(t){return this.node<t.node||this.node===t.node&&this.line<t.line}equals(t){return this.node.equals(t.node)&&this.line.equals(t.line)}dispose(){this._node=null,this._line=null}}class kt{constructor(t=null,c=null,N=0,z=0,ie=0,pe=0){this._lineA=null,this._lineB=null,this.lineAStartOffset=0,this.lineAEndOffset=0,this.lineBStartOffset=0,this.lineBEndOffset=0,this._lineA=t,this._lineB=c,this.lineAStartOffset=N,this.lineAEndOffset=z,this.lineBStartOffset=ie,this.lineBEndOffset=pe}get lineA(){return this._lineA}set lineA(t){this._lineA=t}get lineB(){return this._lineB}set lineB(t){this._lineB=t}lessThan(t){return this.lineA<t.lineA||this.lineA===t.lineA&&this.lineB<t.lineB}equals(t){return this.lineA.equals(t.lineA)&&this.lineB.equals(t.lineB)}dispose(){this._lineA=null,this._lineB=null}}class ti{constructor(t=null,c=null,N=0,z=!0,ie=0){this._nodeA=null,this._nodeB=null,this.distance=0,this.isSameLot=!0,this.floorDelta=0,this._nodeA=t,this._nodeB=c,this.distance=N,this.isSameLot=z,this.floorDelta=ie}get nodeA(){return this._nodeA}set nodeA(t){this._nodeA=t}get nodeB(){return this._nodeB}set nodeB(t){this._nodeB=t}has(t){return this.nodeA===t||this.nodeB===t}lessThan(t){return this.nodeA<t.nodeA||this.nodeA===t.nodeA&&this.nodeB<t.nodeB}equals(t){return this.nodeA.equals(t.nodeA)&&this.nodeB.equals(t.nodeB)}dispose(){this._nodeA=null,this._nodeB=null}}class qt{constructor(t=null,c=null){this._node=null,this._line=null,this._node=t,this._line=c}get node(){return this._node}set node(t){this._node=t}get line(){return this._line}set line(t){this._line=t}has(t){return t.isNode&&t.isNode()?this.node.equals(t):!(!t.isLine||!t.isLine())&&this.line.equals(t)}lessThan(t){return this.node<t.node||this.node===t.node&&this.line<t.line}equals(t){return this.node.equals(t.node)&&this.line.equals(t.line)}toString(){return`NavigableNodeLineK(node=${this.node.position()}, line=${this.line.parsedLine().uidInPackage()})`}dispose(){this._node=null,this._line=null}}class zt{constructor(t=null,c=null){this._lineA=null,this._lineB=null,this._lineA=t,this._lineB=c}get lineA(){return this._lineA}set lineA(t){this._lineA=t}get lineB(){return this._lineB}set lineB(t){this._lineB=t}has(t){return this.lineA.equals(t)||this.lineB.equals(t)}lessThan(t){return this.lineA<t.lineA||this.lineA===t.lineA&&this.lineB<t.lineB}equals(t){return this.lineA.equals(t.lineA)&&this.lineB.equals(t.lineB)}toString(){return`NavigableLineLineK(lineA=${this.lineA.parsedLine().uidInPackage()}, lineB=${this.lineB.parsedLine().uidInPackage()})`}dispose(){this._lineA=null,this._lineB=null}}class Pt{constructor(t=null,c=null){this._nodeA=null,this._nodeB=null,this._nodeA=t,this._nodeB=c}get nodeA(){return this._nodeA}set nodeA(t){this._nodeA=t}get nodeB(){return this._nodeB}set nodeB(t){this._nodeB=t}soloOrNull(){return null==this.nodeA?this.nodeB:null==this.nodeB?this.nodeA:null}has(t){return this.nodeA.equals(t)||this.nodeB.equals(t)}lessThan(t){const c=this.soloOrNull(),N=t.soloOrNull();return null!=c&&null!=N?c<N:null!=c?c<t.nodeA:null!=N?this.nodeA<N:this.nodeA<t.nodeA||this.nodeA===t.nodeA&&this.nodeB<t.nodeB}equals(t){return this.nodeA.equals(t.nodeA)&&this.nodeB.equals(t.nodeB)}toString(){return`NavigableNodeNodeK(nodeA=${this.nodeA.position()}, nodeB=${this.nodeB.position()})`}dispose(){this._nodeA=null,this._nodeB=null}}let xt=(()=>{class nt{constructor(c,N){this._nodeLinks=new T.Es,this._lineLinks=new T.Es,this._watchingParsedShapes=new T.Es,this._parentDirectory=c,this._parsedLine=N}clone(){const c=new nt(this._parentDirectory,this._parsedLine);return c._nodeLinks=new T.Es(this._nodeLinks),c._lineLinks=new T.Es(this._lineLinks),c._watchingParsedShapes=new T.Es(this._watchingParsedShapes),c}isNode(){return!1}isLine(){return!0}p2Line(){return this._parsedLine.p2Line()}normalToInside(){return this._parsedLine.normalToInside()}elementType(){return E.TE.LINE_NAVIGABLE}elementId(){return 0}lineType(){return te.gb.NAVIGABLE}parsedLine(){return this._parsedLine}nodeLinks(){return this._nodeLinks}lineLinks(){return this._lineLinks}watchingParsedShapes(){return this._watchingParsedShapes}parentDirectory(){return this._parentDirectory}shouldBeRemoved(c){return c.includes(this._parsedLine)}dropLinksToUpperDirectoryParsedElements(c){}addWatchingParsedShape(c){this._watchingParsedShapes.add(c)}removeWatchingParsedShape(c){this._watchingParsedShapes.delete(c)}addLink(c){if(c instanceof dt)this._nodeLinks.add(c);else{if(!(c instanceof kt))throw new Error("Unsupported link type");this._lineLinks.add(c)}}dropLinks(c){for(const N of c)N instanceof dt?this._nodeLinks.delete(N):N instanceof kt&&this._lineLinks.delete(N)}static#e=this.GetNodeLinkResult=class{constructor(c=!1,N=0,z=null){this.isSuccess=c,this.offset=N,this.link=z}isAtExtremity(){return null==this.link}};tryGetNodeLink(c){for(const N of this._nodeLinks)if(N.node===c)return new nt.GetNodeLinkResult(!0,N.offsetOnLine,N);return this._parsedLine.startNode().templatedLinkedNavigable()===c?new nt.GetNodeLinkResult(!0,0,null):this._parsedLine.endNode().templatedLinkedNavigable()===c?new nt.GetNodeLinkResult(!0,e.kE(this.p2Line()
1),null):new nt.GetNodeLinkResult(!1,0,null)}concludeCopy(c,N){this._parentDirectory=c,this._parsedLine=N.getParsedElementOrError(this._parsedLine),this._parsedLine.setNavigable(this),this._nodeLinks.clear();for(const[ie,pe]of c.nodeLineLinks())ie.line===this&&this._nodeLinks.add(pe);this._lineLinks.clear();for(const[ie,pe]of c.lineLineLinks())ie.has(this)&&this._lineLinks.add(pe);const z=new T.Es;for(const ie of this._watchingParsedShapes)z.add(N.getParsedElementOrError(ie));this._watchingParsedShapes=z}equals(c){return null!==c&&this.elementType()===c.elementType()&&this._parsedLine.equals(c._parsedLine)}dispose(){this._nodeLinks.clear(),this._lineLinks.clear(),this._watchingParsedShapes.clear(),this._parentDirectory=null,this._parsedLine=null}}return nt})();class Jt{constructor(t,c){this._parsedNodes=new Map,this._lineLinks=new T.Es,this._watchingParsedShapes=new T.Es,this._parentDirectory=t,this._position=c}clone(){const t=new Jt(this._parentDirectory,this._position);return t._parsedNodes=new Map(this._parsedNodes),t._lineLinks=new T.Es(this._lineLinks),t._watchingParsedShapes=new T.Es(this._watchingParsedShapes),t}position(){return this._position}elementType(){return E.TE.NODE_NAVIGABLE}elementId(){return 0}isNode(){return!0}isLine(){return!1}nodeType(){return g.Mq.NAVIGABLE}parsedNodes(){return this._parsedNodes}lineLinks(){return this._lineLinks}watchingParsedShapes(){return this._watchingParsedShapes}tryGetParsedNode(t){return this._parsedNodes.get(t)??null}parentDirectory(){return this._parentDirectory}shouldBeRemoved(t){let c=0;for(const N of t)N.linkedNavigable?.()===this&&c++;return c>=this._parsedNodes.size}dropLinksToUpperDirectoryParsedElements(t){}addParsedNode(t){this._parsedNodes.set(t.nodeType(),t)}removeParsedNode(t){const c=t.nodeType();this._parsedNodes.has(c)&&this._parsedNodes.delete(c)}dropWillRemoveParsedNodes(t){const c=[];for(const[N,z]of this._parsedNodes.entries())t.includes(z)&&c.push(N);for(const N of c)this._parsedNodes.delete(N)}addWatchingParsedShape(t){this._watchingParsedShapes.add(t)}removeWatchingParsedShape(t){this._watchingParsedShapes.delete(t)}addLink(t){this._lineLinks.add(t)}dropLinks(t){for(const c of t)this._lineLinks.delete(c)}concludeCopy(t,c){this._parentDirectory=t;for(const[z,ie]of this._parsedNodes.entries()){const pe=c.getParsedElementOrError(ie);pe.setNavigable(this),this._parsedNodes.set(z,pe)}this._lineLinks.clear();for(const[z,ie]of t.nodeLineLinks().entries())z.node===this&&this._lineLinks.add(ie);const N=new T.Es;for(const z of this._watchingParsedShapes)N.add(c.getParsedElementOrError(z));this._watchingParsedShapes=N}equals(t){return null!==t&&this.elementType()===t.elementType()&&e.fS(this._position,t._position)}dispose(){this._parsedNodes.clear(),this._lineLinks.clear(),this._watchingParsedShapes.clear(),this._parentDirectory=null}}class $t extends te.bx{constructor(){super(...arguments),this._wallLayer=new ue,this._corridorLayer=new Ie,this._circulationLayer=new Pe,this._lightLayer=new Ce,this._partitionableLayer=new Ue,this._gridLayer=new Re,this._moduleLayer=new ge,this._moduleCategoryLayer=new De,this._obstacleLayer=new He,this._constructionLayer=new rt,this._partitionLayer=new Ge,this._furnitureLayer=new mt,this._navigableNodes=new T.WK,this._navigableLines=new T.me,this._nodeLineLinks=new T.nI,this._lineLineLinks=new T.nI,this._doorNodeLinks=new T.nI}directoryType(){return te.dd.NETWORK}manageInfoTypes(){return[E.TE.NODE_INFO,E.TE.LINE_INFO,E.TE.NETWORK_NODE_LINE_LINK_INFO,E.TE.NETWORK_LINE_LINE_LINK_INFO,E.TE.NETWORK_DOOR_LINK_INFO]}wallLayer(){return this._wallLayer}corridorLayer(){return this._corridorLayer}circulationLayer(){return this._circulationLayer}lightLayer(){return this._lightLayer}partitionableLayer(){return this._partitionableLayer}gridLayer(){return this._gridLayer}moduleLayer(){return this._moduleLayer}moduleCategoryLayer(){return this._moduleCategoryLayer}obstacleLayer(){return this._obstacleLayer}constructionLayer(){return this._constructionLayer}partitionLayer(){return this._partitionLayer}furnitureLayer(){return this._furnitureLayer}
1_getLayers(){return[this._wallLayer,this._corridorLayer,this._circulationLayer,this._lightLayer,this._partitionableLayer,this._gridLayer,this._moduleLayer,this._moduleCategoryLayer,this._obstacleLayer,this._constructionLayer,this._partitionLayer,this._furnitureLayer]}getLayer(t){for(const c of this._getLayers())if(c instanceof t)return c;throw new Error(`Layer ${t} not found in NetworkLayerDirectory`)}nodeLineLinks(){return this._nodeLineLinks}lineLineLinks(){return this._lineLineLinks}doorNodeLinks(){return this._doorNodeLinks}dispose(){this._getLayers().forEach(t=>t.dispose());for(let[t,c]of this._navigableNodes)c.dispose();this._navigableLines.values().forEach(t=>t.dispose()),this._navigableNodes.clear(),this._navigableLines.clear();for(let[t,c]of this._nodeLineLinks.entries())c.dispose(),t.dispose();for(let[t,c]of this._lineLineLinks.entries())c.dispose(),t.dispose();for(let[t,c]of this._doorNodeLinks.entries())c.dispose(),t.dispose();this._nodeLineLinks.clear(),this._lineLineLinks.clear(),this._doorNodeLinks.clear()}_createOrLinkNavigable(t){if(t.elementType()===E.TE.NODE_PARSED){const c=t,N=c.position();let z=!1;this._navigableNodes.has(N)||(this._navigableNodes.set(N,new Jt(this,N)),z=!0);const ie=this._navigableNodes.get(N);return ie.addParsedNode(c),t.setNavigable(ie),[z,ie]}{const c=t,N=c.uidInPackage();let z=!1;this._navigableLines.has(N)||(this._navigableLines.set(N,new xt(this,c)),z=!0);const ie=this._navigableLines.get(N);return t.setNavigable(ie),[z,ie]}}_breakLinksAndMayRemoveNavigables(t,c){const N=[],z=[],ie=new T.Es,pe=new T.Es,we=new T.Es;for(const[fe,We]of this._navigableNodes)We.shouldBeRemoved(t)?N.push(We):(We.dropLinksToUpperDirectoryParsedElements(c),We.dropWillRemoveParsedNodes(t));for(const[fe,We]of this._navigableLines)We.shouldBeRemoved(t)?z.push(We):We.dropLinksToUpperDirectoryParsedElements(c);for(const fe of N){for(const[We,je]of this._nodeLineLinks)We.has(fe)&&!ie.has(je)&&ie.add(je);for(const[We,je]of this._doorNodeLinks)We.has(fe)&&!we.has(We)&&we.add(We)}for(const fe of z){for(const[We,je]of this._nodeLineLinks)We.has(fe)&&!ie.has(je)&&ie.add(je);for(const[We,je]of this._lineLineLinks)We.has(fe)&&!pe.has(je)&&pe.add(je)}for(const[fe,We]of this._nodeLineLinks)ie.has(We)&&this._nodeLineLinks.delete(fe);for(const[fe,We]of this._lineLineLinks)pe.has(We)&&this._lineLineLinks.delete(fe);for(const fe of we)this._doorNodeLinks.delete(fe);for(const fe of N)this._navigableNodes.delete(fe.position());for(const fe of z)this._navigableLines.delete(fe.parsedLine().uidInPackage());this._navigableNodes.forEach(fe=>fe.dropLinks(ie));for(const fe of this._navigableLines)fe[1].dropLinks(pe)}_finalizeAddCallback(t,c,N){for(const[z,ie]of N.entries())switch(z){case E.TE.NETWORK_NODE_LINE_LINK_INFO:for(const pe of ie){const we=pe,fe=new dt(this._navigableNodes.get(we.node),this._navigableLines.get(we.line),we.offsetOnLine),We=new qt(fe.node,fe.line);this._nodeLineLinks.has(We)||(this._nodeLineLinks.set(We,fe),fe.node.addLink(fe),fe.line.addLink(fe))}break;case E.TE.NETWORK_LINE_LINE_LINK_INFO:for(const pe of ie){const we=pe,fe=new kt(this._navigableLines.get(we.lineA),this._navigableLines.get(we.lineB),we.lineAStartOffset,we.lineAEndOffset,we.lineBStartOffset,we.lineBEndOffset),We=new zt(fe.lineA,fe.lineB);this._lineLineLinks.has(We)||(this._lineLineLinks.set(We,fe),fe.lineA.addLink(fe),fe.lineB.addLink(fe))}break;case E.TE.NETWORK_DOOR_LINK_INFO:for(const pe of ie){const we=pe,fe=new ti(this._navigableNodes.get(we.doorNodeA),this._navigableNodes.get(we.doorNodeB),we.distance),We=new Pt(fe.nodeA,fe.nodeB);this._doorNodeLinks.set(We,fe)}break;default:throw new Error("NetworkLayerDirectory::TryAddElements unsupported directory element")}}copyFrom(t,c,N){if(N){this._wallLayer.copyFrom(t._wallLayer,c,!0),this._corridorLayer.copyFrom(t._corridorLayer,c,!0),this._circulationLayer.copyFrom(t._circulationLayer,c,!0),this._lightLayer.copyFrom(t._lightLayer,c,!0),this._partitionableLayer.copyFrom(t._partitionableLayer,c,!0),this._gridLayer.copyFrom(t._gridLayer,c,!0),this._moduleLayer.copyFrom(t._moduleLayer,c,!0),this._module
1CategoryLayer.copyFrom(t._moduleCategoryLayer,c,!0),this._obstacleLayer.copyFrom(t._obstacleLayer,c,!0),this._constructionLayer.copyFrom(t._constructionLayer,c,!0),this._partitionLayer.copyFrom(t._partitionLayer,c,!0),this._furnitureLayer.copyFrom(t._furnitureLayer,c,!0),this._navigableNodes=t._navigableNodes.map(z=>z.clone()),this._navigableLines=t._navigableLines.map(z=>z.clone());for(const[z,ie]of this._navigableNodes)c.navigableNetworkNodeMap.set(z,ie);for(const[z,ie]of this._navigableLines)c.elementUidNavigableMap.set(z,ie);for(const[z,ie]of t._nodeLineLinks){const pe=new dt(this._navigableNodes.get(ie.node.position()),this._navigableLines.get(ie.line.parsedLine().uidInPackage()),ie.offsetOnLine);this._nodeLineLinks.set(new qt(pe.node,pe.line),pe)}for(const[z,ie]of t._lineLineLinks){const pe=new kt(this._navigableLines.get(ie.lineA.parsedLine().uidInPackage()),this._navigableLines.get(ie.lineB.parsedLine().uidInPackage()),ie.lineAStartOffset,ie.lineAEndOffset,ie.lineBStartOffset,ie.lineBEndOffset);this._lineLineLinks.set(new zt(pe.lineA,pe.lineB),pe)}for(const[z,ie]of t._doorNodeLinks){const pe=new ti(this._navigableNodes.get(ie.nodeA.position()),this._navigableNodes.get(ie.nodeB.position()),ie.distance);this._doorNodeLinks.set(new Pt(pe.nodeA,pe.nodeB),pe)}}else{this._wallLayer.copyFrom(t._wallLayer,c,!1),this._corridorLayer.copyFrom(t._corridorLayer,c,!1),this._circulationLayer.copyFrom(t._circulationLayer,c,!1),this._lightLayer.copyFrom(t._lightLayer,c,!1),this._partitionableLayer.copyFrom(t._partitionableLayer,c,!1),this._gridLayer.copyFrom(t._gridLayer,c,!1),this._moduleLayer.copyFrom(t._moduleLayer,c,!1),this._moduleCategoryLayer.copyFrom(t._moduleCategoryLayer,c,!1),this._obstacleLayer.copyFrom(t._obstacleLayer,c,!1),this._constructionLayer.copyFrom(t._constructionLayer,c,!1),this._partitionLayer.copyFrom(t._partitionLayer,c,!1),this._furnitureLayer.copyFrom(t._furnitureLayer,c,!1),this._navigableNodes.forEach(z=>z.concludeCopy(this,c));for(const z of this._navigableLines)z[1].concludeCopy(this,c)}}}class Wt{constructor(t=null,c=null,N=null){this.startNode=t,this.endNode=c,this.line=N}clone(){return new Wt(this.startNode,this.endNode,this.line)}asP2Line(){return e.uM(this.startNode.position(),this.endNode.position())}reverse(){const t=this.startNode;return this.startNode=this.endNode,this.endNode=t,this}isSameDirectionAsLine(){return e.rz(e.hX(this.asP2Line()),e.hX(this.line.p2Line()))>0}direction(){return e.hX(this.asP2Line())}normalToInside(){return e.ih(this.direction())}curve(){return this.line?this.line.curve():null}static toPath(t){if(!t.length)return e.CK();const c=[t[0].startNode.position(),...t.map(N=>N.endNode.position())];return e.CK(c)}static toRing(t){return e.I$(Wt.toPath(t).getCoordinates())}static toPolygon(t){const c=Wt.toRing(t);return e.p(c)}static isValidRing(t){const c=Wt.toPath(t);return c.getCoordinates().length>3&&(!(c.getCoordinates().length>4)||c.getCoordinateN(0)===c.getCoordinateN(c.getCoordinates().length-1))}static correctOrientation(t,c){if(!t.length)return t;let N=0;for(const ie of t){const pe=ie.startNode.position(),we=ie.endNode.position();N+=(we.getX()-pe.getX())*(we.getY()+pe.getY())}return c===N>0?t.slice().reverse().map(ie=>ie.reverse()):t}isNeighbour(t){return this.startNode.position()===t.startNode.position()?-2:this.startNode.position()===t.endNode.position()?1:this.endNode.position()===t.startNode.position()?-1:this.endNode.position()===t.endNode.position()?2:0}dispose(){this.startNode=null,this.endNode=null,this.line=null}}class Vt{constructor(t,c){this._info=c,this._parent=t}get parent(){return this._parent}get startOffset(){return this._info.startOffset}get endOffset(){return this._info.endOffset}get isWindow(){return this._info.isWindow}get irrigableLength(){return this._info.irrigableLength}length(){return this._info.length()}dispose(){this._parent=null,this._info=null}}class Ft extends g.yO{constructor(){super(...arguments),this._outerPath=[],this._innerPaths=[],this._overlappingElements=[],this.__cachedPolygon=null}clone(t=null){if(!t)throw new Error("Clone must be provided by subclass");return super.clone(t),t._outerPath=this._outerPath.map(c=>c.clone()),t._innerPaths=this._innerPaths.map(c=>c.map(N=>N.clone())),t._overlappingElements=[...this._overlappingElements],t}elementType(){return E.TE.SHAPE_PARSED}outerPath(){return this._outerPath}innerPaths(){return this._innerPaths}overlappingElements(){return this._overlappingElements}getAllRings(){return[this._outerPath,...this._innerPaths]}asPolygon(){if(this.__cachedPolygon)return this.__cachedPolygon;const t=Wt.toRing(this._outerPath),c=this._innerPaths.map(N=>Wt.toRing(N));if(this.__cachedPolygon=e.p(t,c),!e.JY(this.__cachedPolygon)){const[N,z]=e.eX(this.__cachedPolygon);z&&(this.__cachedPolygon=N)}return this.__cachedPolygon}dispose(){const t=c=>{for(const N of c)N.endNode.detach(this),N.startNode.detach(this),N.line.detach(this),N.dispose()};t(this._outerPath);for(const c of this._innerPaths)t(c);this._outerPath=[],this._innerPaths=[]}countLinksToParsed(t,c){if(!c)return 0;const N=ie=>ie.filter(pe=>pe.endNode===t||pe.startNode===t||pe.line===t).length;let z=N(this._outerPath);for(const ie of this._innerPaths)z+=N(ie);return z}countLinksToPackageElement(t,c){if(!c)return 0;const N=t.uidInPackage(),z=pe=>pe.filter(we=>we.endNode.uidInPackage()===N||we.startNode.uidInPackage()===N||we.line.uidInPackage()===N).length;let ie=z(this._outerPath);for(const pe of this._innerPaths)ie+=z(pe);return ie}}class Zt{constructor(t){this.TInfo=t.TInfo}}class Bt extends Ft{constructor(){super(...arguments),this._targetShapeInfo=null}elementId(){return this._targetShapeInfo?this._targetShapeInfo.elementId():0}uidInPackage(){return this._targetShapeInfo?this._targetShapeInfo.uidInPackage():new E.ph}linkedShapeInfo(){return this._targetShapeInfo}linkedLayerElementInfo(){return this._targetShapeInfo}shapeType(){return this._targetShapeInfo.shapeType()}clone(t){return super.clone(t),t._targetShapeInfo=this._targetShapeInfo,t}_tplCopyFrom(t,c){this._targetShapeInfo=c.getElementInfoOrDefault(t._targetShapeInfo);const N=z=>{for(const ie of z)ie.line=c.getParsedElementOrError(ie.line),ie.startNode=c.getParsedElementOrError(ie.startNode),ie.endNode=c.getParsedElementOrError(ie.endNode)};this._outerPath=JSON.parse(JSON.stringify(t._outerPath)),this._innerPaths=t._innerPaths.map(z=>JSON.parse(JSON.stringify(z))),N(this._outerPath);for(const z of this._innerPaths)N(z);this._overlappingElements=t._overlappingElements.map(z=>c.elementProvider.getElement(z.uidInPackage()))}static _createHydrate(t,c){}static _createFinalize(t,c){}static create(t,c,N){const z=new t;return z._targetShapeInfo=c,t._createHydrate(z,N),[z,function ie(pe,we){const fe=we.lowerDirectoryLut(),We=je=>je.map(_t=>{const yt=new Wt(fe.get(new te.nh.LutK(_t.startNode)),fe.get(new te.nh.LutK(_t.endNode)),fe.get(new te.nh.LutK(_t.line)));return yt.line.attach(z),yt.startNode.attach(z),yt.endNode.attach(z),yt});pe._outerPath=We(c.outerPath),pe._innerPaths=c.innerPaths.map(je=>We(je)),t._createFinalize(pe,we)}]}copyFrom(t,c){this._tplCopyFrom(t,c)}}class li extends Bt{static#e=this._TPL=new Zt({TInfo:h.TX});Tpl(){return li._TPL}corridorType(){return this._targetShapeInfo.corridorType}clone(){const t=new li;return super.clone(t),t}}class Mi extends Bt{constructor(){super(...arguments),this._obstacle=null}static#e=this._TPL=new Zt({TInfo:h.mx});Tpl(){return Mi._TPL}obstacle(){return this._obstacle}debugStyle(){return"fill:rgb(124,75,2);stroke:rgb(24,150,200);stroke-width:1.5"}static _createHydrate(t,c){t._obstacle=c.currentElementProvider().getElement(t._targetShapeInfo.obstacleUid)}copyFrom(t,c){super.copyFrom(t,c),this._obstacle=c.elementProvider.getElement(t._obstacle.uidInPackage())}clone(){const t=new Mi;return super.clone(t),t._obstacle=this._obstacle,t}dispose(){super.dispose(),this._obstacle=null}}class mi extends Bt{static#e=this._TPL=new Zt({TInfo:h.bK});Tpl(){return mi._TPL}isDirectLight(){return this._targetShapeInfo.isDirectLight}clone(){const t=new mi;return super.clone(t),t}}class ft extends Bt{constructor(){super(...arguments),this._parsedSpans=[]}static#e=this._TPL=new Zt({TInfo:h.Uh});Tpl(){return ft._TPL}type(){return this._targetShapeInfo.type}isStraight(){return this._targetShapeInfo.type===g.W5.STRAIGHT}isCorner(){return this._targetShapeInfo.type===g.W5.CORNER}isCurved(){return this._targetShapeInfo.type===g.W5.CURVED}width(){return this._targetShapeInfo.width}height(){return this._targetShapeInfo.height}isReceptionFriendly(){return this._targetShapeInfo.isReceptionFriendly}parsedSpans(){return this._parsedSpans}corridorWidth(){return this._targetShapeInfo.corridorWidth}isIrrigated(){return this._targetShapeInfo.isIrrigated()}startPerpLineUid(){return this._targetShapeInfo.startPerpLineUid}endPerpLineUid(){return this._targetShapeInfo.endPerpLineUid}overlappingPartitionableShapeUids(){return this._targetShapeInfo.overlappingPartitionableShapeUids}hasOverlappingPartitionableShapes(){return(this._targetShapeInfo.overlappingPartitionableShapeUids||[]).length>0}static _createHydrate(t,c){t._parsedSpans=(t._targetShapeInfo.partitionableSpans||[]).map(N=>
1new Vt(t,N))}copyFrom(t,c){super.copyFrom(t,c),this._parsedSpans=(t._targetShapeInfo.partitionableSpans||[]).map(N=>new Vt(this,N))}clone(){const t=new ft;return super.clone(t),t._parsedSpans=this._parsedSpans.map(c=>new Vt(t,c._info)),t}dispose(){super.dispose(),this._parsedSpans.forEach(t=>t.dispose()),this._parsedSpans=[]}}class wi extends Bt{constructor(){super(...arguments),this._gridLines=[]}static#e=this._TPL=new Zt({TInfo:h.un});Tpl(){return wi._TPL}hasOrientation(){return this._targetShapeInfo.hasOrientation}worldToLocalMtx(){return this._targetShapeInfo.worldToLocalMtx}gridLines(){return this._gridLines}cellCount(){return this._targetShapeInfo.cellCount}columns(){return this._targetShapeInfo.columns}rows(){return this._targetShapeInfo.rows}irrigatedCoords(){return this._targetShapeInfo.irrigatedCoords}wallCoords(){return this._targetShapeInfo.wallCoords}dispose(){for(const t of this._gridLines)t.detach(this);super.dispose()}countLinksToParsed(t,c){if(!c)return 0;let N=super.countLinksToParsed(t,c);return N+=this._gridLines.filter(z=>z===t).length,N}countLinksToPackageElement(t,c){if(!c)return 0;const N=t.uidInPackage();let z=super.countLinksToPackageElement(t,c);return z+=this._gridLines.filter(ie=>ie.uidInPackage()===N).length,z}static _createFinalize(t,c){const N=c.lowerDirectoryLut();for(const z of t._targetShapeInfo.gridLineUids){const ie=N.get(new te.nh.LutK(z));ie.attach(t),t._gridLines.push(ie)}}copyFrom(t,c){super.copyFrom(t,c),this._gridLines=t._gridLines.map(N=>c.getParsedElementOrError(N));for(const N of this._gridLines)N.attach(this)}clone(){const t=new wi;return super.clone(t),t._gridLines=this._gridLines.map(c=>c.clone()),t}}class ni extends Bt{constructor(){super(...arguments),this._moduleOrProgramModule=null,this._overtakerDepartment=null}static#e=this._TPL=new Zt({TInfo:h.CZ});Tpl(){return ni._TPL}isProgramModule(){return this._targetShapeInfo.isProgramModule}moduleOrProgramModule(){return this._moduleOrProgramModule}overtakerDepartment(){return this._overtakerDepartment}static _createHydrate(t,c){t._moduleOrProgramModule=c.currentElementProvider().getElement(t._targetShapeInfo.moduleOrProgramModuleUid),t._overtakerDepartment=c.currentElementProvider().getElement(t._targetShapeInfo.overtakerDepartmentUid)}copyFrom(t,c){super.copyFrom(t,c),this._moduleOrProgramModule=c.elementProvider.getElement(t._moduleOrProgramModule.uidInPackage()),this._overtakerDepartment=t._overtakerDepartment?c.elementProvider.getElement(t._overtakerDepartment.uidInPackage()):null}clone(){const t=new ni;return super.clone(t),t._moduleOrProgramModule=this._moduleOrProgramModule,t._overtakerDepartment=this._overtakerDepartment,t}dispose(){super.dispose(),this._moduleOrProgramModule=null,this._overtakerDepartment=null}}class ii extends Bt{constructor(){super(...arguments),this._moduleCategoryOrDepartment=null}static#e=this._TPL=new Zt({TInfo:h.Wm});Tpl(){return ii._TPL}moduleCategoryOrDepartment(){return this._moduleCategoryOrDepartment}useTypeOrDepartmentWorkforce(){return this._targetShapeInfo.useTypeOrDepartmentWorkforce}static _createHydrate(t,c){}copyFrom(t,c){super.copyFrom(t,c)}clone(){const t=new ii;return super.clone(t),t._moduleCategoryOrDepartment=this._moduleCategoryOrDepartment,t}}class hi extends Bt{static#e=this._TPL=new Zt({TInfo:h.Wc});Tpl(){return hi._TPL}furnitureUri(){return this._targetShapeInfo.furnitureUri}orientation(){return this._targetShapeInfo.orientation}clone(){const t=new hi;return super.clone(t),t}}class di{constructor(t={}){this.ShapeType=t.ShapeType??g.xR.CORRIDOR,this.TInfo=t.TInfo,this.TParsedShape=t.TParsedShape}}class fi extends te.j5{constructor(){super(...arguments),this._parsedShapes=new T.me}_tplCopyFrom(t,c,N){if(N){this._parsedShapes=t._parsedShapes.map(z=>z.clone());for(const[z,ie]of this._parsedShapes)c.fullUidParsedElementMap.set(z,ie)}else for(const[z,ie]of this._parsedShapes)ie.copyFrom(this._parsedShapes.get(z),c)}copyFrom(t,c,N){this._tplCopyFrom(t,c,N)}parsedShapes(){return this._parsedShapes}tryAddShape(t){return this.tplTryAddElement(this.Tpl().TInfo,this.Tpl().TParsedShape,this._parsedShapes,t)}tryRemoveShape(t,c,N){return this.tplTryRemoveElement(this._parsedShapes,t,c,N)}manageShapeType(){return this.Tpl().ShapeType}canHandleElement(t){return t.elementType()===E.TE.SHAPE_INFO&&t instanceof O.k4&&t.shapeType()===this.manageShapeType()}getElementAddOrder(t){return 0}tryRemoveElement(t,c,N){return this.tryRemoveShape(t,c,N)}tryAddElement(t){return this.tryAddShape(t)}tryGetParsedElement(t,c){return t===E.TE.SHAPE_INFO?this._parsedShapes.get(c)??null:null}computeMultiPolygon(t=!0){let c=t?e.lD():[];for(const[N,z]of this._parsedShapes)t?c=e.Y7(z.asPolygon(),c):c.push(z.asPolygon());return t?c:e.lD(c)}
1dispose(){this._parsedShapes.values().forEach(t=>t.dispose()),this._parsedShapes.clear()}}class Ni extends fi{static#e=this._TPL=new di({ShapeType:g.xR.CORRIDOR,TInfo:O.TX,TParsedShape:li});Tpl(){return Ni._TPL}manageShapeType(){return g.xR.CORRIDOR}layerType(){return te.Dw.SHAPE_CORRIDOR}}class Yi extends fi{static#e=this._TPL=new di({ShapeType:g.xR.LIGHT,TInfo:O.bK,TParsedShape:mi});Tpl(){return Yi._TPL}manageShapeType(){return g.xR.LIGHT}layerType(){return te.Dw.SHAPE_LIGHT}}class Ki extends fi{static#e=this._TPL=new di({ShapeType:g.xR.PARTITIONABLE,TInfo:O.Uh,TParsedShape:ft});Tpl(){return Ki._TPL}manageShapeType(){return g.xR.PARTITIONABLE}layerType(){return te.Dw.SHAPE_PARTITIONABLE}}class $i extends fi{static#e=this._TPL=new di({ShapeType:g.xR.GRID,TInfo:O.un,TParsedShape:wi});Tpl(){return $i._TPL}manageShapeType(){return g.xR.GRID}layerType(){return te.Dw.SHAPE_GRID}}class Xi extends fi{static#e=this._TPL=new di({ShapeType:g.xR.OBSTACLE,TInfo:O.mx,TParsedShape:Mi});Tpl(){return Xi._TPL}manageShapeType(){return g.xR.OBSTACLE}layerType(){return te.Dw.SHAPE_OBSTACLE}}class Gi extends fi{static#e=this._TPL=new di({ShapeType:g.xR.MODULE,TInfo:O.CZ,TParsedShape:ni});Tpl(){return Gi._TPL}manageShapeType(){return g.xR.MODULE}layerType(){return te.Dw.SHAPE_MODULE}}class qi extends fi{static#e=this._TPL=new di({ShapeType:g.xR.MODULE_CATEGORY,TInfo:O.Wm,TParsedShape:ii});Tpl(){return qi._TPL}manageShapeType(){return g.xR.MODULE_CATEGORY}layerType(){return te.Dw.SHAPE_MODULE_CATEGORY}}class Vi extends fi{static#e=this._TPL=new di({ShapeType:g.xR.FURNITURE,TInfo:O.Wc,TParsedShape:hi});Tpl(){return Vi._TPL}manageShapeType(){return g.xR.FURNITURE}layerType(){return te.Dw.SHAPE_FURNITURE}}class Zi{constructor(t=null,c=null){this._shapeA=null,this._shapeB=null,this.intersectionEdges=[],this._shapeA=t,this._shapeB=c}get shapeA(){return this._shapeA}set shapeA(t){this._shapeA=t}get shapeB(){return this._shapeB}set shapeB(t){this._shapeB=t}getOther(t){return t===this.shapeA?this.shapeB:this.shapeA}lessThan(t){return this.shapeA<t.shapeA||this.shapeA===t.shapeA&&this.shapeB<t.shapeB}equals(t){return this.shapeA.equals(t.shapeA)&&this.shapeB.equals(t.shapeB)}dispose(){this._shapeA=null,this._shapeB=null,this.intersectionEdges.forEach(t=>t.dispose()),this.intersectionEdges=[]}}class Qi{constructor(t=null,c=null){this._shapeA=null,this._shapeB=null,this._shapeA=t,this._shapeB=c}get shapeA(){return this._shapeA}set shapeA(t){this._shapeA=t}get shapeB(){return this._shapeB}set shapeB(t){this._shapeB=t}has(t){return this.shapeA.equals(t)||this.shapeB.equals(t)}lessThan(t){return this.shapeA<t.shapeA||this.shapeA===t.shapeA&&this.shapeB<t.shapeB}equals(t){return this.shapeA.equals(t.shapeA)&&this.shapeB.equals(t.shapeB)}toString(){return`NavigableShapeShapeK(shapeA=${this.shapeA.parsedShape().uidInPackage()}, shapeB=${this.shapeB.parsedShape().uidInPackage()})`}dispose(){this._shapeA=null,this._shapeB=null}}class ji{constructor(t,c){this._intersections=new T.Es,this._parentDirectory=t,this._parsedShape=c}clone(){const t=new ji(this._parentDirectory,this._parsedShape);return t._intersections=new T.Es(this._intersections),t}dispose(){this._parentDirectory=null,this._parsedShape=null,this._intersections.clear()}elementType(){return E.TE.SHAPE_NAVIGABLE}elementId(){return 0}shapeType(){return te.xR.NAVIGABLE}parsedShape(){return this._parsedShape}intersections(){return this._intersections}parentDirectory(){return this._parentDirectory}shouldBeRemoved(t){return t.includes(this._parsedShape)}dropLinksToUpperDirectoryParsedElements(t){}addIntersection(t){this._intersections.add(t)}dropIntersections(t){for(const c of t)this._intersections.delete(c)}concludeCopy(t,c){this._parentDirectory=t,this._parsedShape=c.getParsedElementOrError(this._parsedShape),this._parsedShape.setNavigable(this),this._intersections.clear();for(const[N,z]of t.intersections)N.has(this)&&this._intersections.add(z)}equals(t){return null!==t&&this.elementType()===t.elementType()&&this._parsedShape.equals(t._parsedShape)}}class Ss extends te.bx{constructor(){super(...arguments),this._corri
1dorLayer=new Ni,this._lightLayer=new Yi,this._partitionableLayer=new Ki,this._gridLayer=new $i,this._obstacleLayer=new Xi,this._moduleLayer=new Gi,this._moduleCategoryLayer=new qi,this._furnitureLayer=new Vi,this._navigableShapes=new T.me,this._intersections=new T.nI}directoryType(){return te.dd.SHAPE}manageInfoTypes(){return[E.TE.SHAPE_INFO,E.TE.SHAPE_INTERSECTION_INFO]}get corridorLayer(){return this._corridorLayer}get lightLayer(){return this._lightLayer}get partitionableLayer(){return this._partitionableLayer}get gridLayer(){return this._gridLayer}get obstacleLayer(){return this._obstacleLayer}get moduleLayer(){return this._moduleLayer}get moduleCategoryLayer(){return this._moduleCategoryLayer}get furnitureLayer(){return this._furnitureLayer}get navigableShapes(){return this._navigableShapes}get intersections(){return this._intersections}_createOrLinkNavigable(t){const c=t;let N=!1;this._navigableShapes.has(c.uidInPackage())||(this._navigableShapes.set(c.uidInPackage(),new ji(this,c)),N=!0);const z=this._navigableShapes.get(c.uidInPackage());return t.setNavigable(z),[N,z]}_breakLinksAndMayRemoveNavigables(t,c){const N=[],z=new T.Es,ie=new T.Es;for(const[pe,we]of this._navigableShapes)we.shouldBeRemoved(t)?N.push(pe):we.dropLinksToUpperDirectoryParsedElements(c);for(const pe of N)for(const[we,fe]of this._intersections)we.has(this._navigableShapes.get(pe))&&(z.add(we),ie.add(fe));for(const pe of z)this._intersections.delete(pe);for(const pe of N)this._navigableShapes.delete(pe);for(const[pe,we]of this._navigableShapes)we.dropIntersections(ie)}_getLayers(){return[this._corridorLayer,this._lightLayer,this._partitionableLayer,this._gridLayer,this._obstacleLayer,this._moduleLayer,this._moduleCategoryLayer,this._furnitureLayer]}getLayer(t){for(const c of this._getLayers())if(c instanceof t)return c;throw new Error(`Layer ${t} not found in ShapeLayerDirectory`)}dispose(){this._getLayers().forEach(t=>
1t.dispose()),this._navigableShapes.values().forEach(t=>t.dispose()),this._navigableShapes.clear();for(let[t,c]of this._intersections.entries())c.dispose(),t.dispose();this._intersections.clear()}_finalizeAddCallback(t,c,N){const z=c.lowerDirectoryLut();for(const[ie,pe]of N)if(ie===E.TE.SHAPE_INTERSECTION_INFO)for(const we of pe){const fe=we,We=new Zi(this._navigableShapes.get(fe.shapeA),this._navigableShapes.get(fe.shapeB));We.intersectionEdges=fe.intersectionEdges.map(_t=>new Wt(z.get(new te.nh.LutK(_t.startNode)),z.get(new te.nh.LutK(_t.endNode)),z.get(new te.nh.LutK(_t.line))));const je=new Qi(We.shapeA,We.shapeB);this._intersections.set(je,We),We.shapeA.addIntersection(We),We.shapeB.addIntersection(We)}}copyFrom(t,c,N){if(N){this._corridorLayer.copyFrom(t._corridorLayer,c,!0),this._lightLayer.copyFrom(t._lightLayer,c,!0),this._partitionableLayer.copyFrom(t._partitionableLayer,c,!0),this._gridLayer.copyFrom(t._gridLayer,c,!0),this._obstacleLayer.copyFrom(t._obstacleLayer,c,!0),this._moduleLayer.copyFrom(t._moduleLayer,c,!0),this._moduleCategoryLayer.copyFrom(t._moduleCategoryLayer,c,!0),this._furnitureLayer.copyFrom(t._furnitureLayer,c,!0),this._navigableShapes=t._navigableShapes.map(z=>z.clone());for(const[z,ie]of this._navigableShapes)c.elementUidNavigableMap.set(z,ie);for(const[z,ie]of t._intersections){const pe=new Zi;pe.intersectionEdges=ie.intersectionEdges.map(we=>we.clone()),pe.shapeA=this._navigableShapes.get(ie.shapeA.parsedShape().uidInPackage()),pe.shapeB=this._navigableShapes.get(ie.shapeB.parsedShape().uidInPackage()),this._intersections.set(new Qi(pe.shapeA,pe.shapeB),pe)}}else{this._corridorLayer.copyFrom(t._corridorLayer,c,!1),this._lightLayer.copyFrom(t._lightLayer,c,!1),this._partitionableLayer.copyFrom(t._partitionableLayer,c,!1),this._gridLayer.copyFrom(t._gridLayer,c,!1),this._obstacleLayer.copyFrom(t._obstacleLayer,c,!1),this._moduleLayer.copyFrom(t._moduleLayer,c,!1),this._moduleCategoryLayer.copyFrom(t._moduleCategoryLayer,c,!1),this._furnitureLayer.copyFrom(t._furnitureLayer,c,!1);for(const z of this._navigableShapes)z[1].concludeCopy(this,c);for(const[z,ie]of this._intersections)for(const pe of ie.intersectionEdges)pe.line=c.getParsedElementOrError(pe.line),pe.startNode=c.getParsedElementOrError(pe.startNode),pe.endNode=c.getParsedElementOrError(pe.endNode)}}}class as{constructor(t,c){this.dispatchMap=[];for(const N of t.getDirectoriesInAddOrder())this.dispatchMap.push([N.manageInfoTypes(),N,[]]);for(const N of c)for(const[z,ie,pe]of this.dispatchMap)if(z.includes(N.elementType())){pe.push(N);break}}getResult(t){let c=[];for(const[N,z,ie]of this.dispatchMap)c.push([z,ie]);return c=c.sort(t?(N,z)=>N[0].directoryOrder()-z[0].directoryOrder():(N,z)=>z[0].directoryOrder()-N[0].directoryOrder()),c}}class vs{constructor(){this._parentState=null,this._networkDirectory=new $t,this._shapeDirectory=new Ss}get parentState(){return this._parentState?this._parentState():null}get networkDirectory(){return this._networkDirectory}get shapeDirectory(){return this._shapeDirectory}initialize(t){this._parentState=t,this._networkDirectory.setRootDirectory(this),this._shapeDirectory.setRootDirectory(this)}getDirectoriesInAddOrder(){return[this._networkDirectory,this._shapeDirectory]}_tryExecutePackage(t,c){const N=new te.Hh;if(t.isPackageProvider())return N;const z=new as(this,c?t.getToAddElements():t.getToRemoveElements()),ie=[];let pe=[];for(const je of z.getResult(!1)){const _t=je[0].tryRemoveElements(je[1],pe);if(N.canApply=_t.canApply,!N.canApply)return N;ie.push(_t.removeClbk),pe=_t.willRemoveParsedElements(),N.willRemoveParsedElementsMap||(N.willRemoveParsedElementsMap=new Map),N.willRemoveParsedElementsMap.set(je[0].directoryType(),_t.willRemoveParsedElementsMap)}if(!N.canApply)return N;const we=new as(this,c?t.getToRemoveElements():t.getToAddElements()),fe=[];for(const je of we.getResult(!0))fe.push(je[0].tryAddElements(je[1]));const We=new Map;for(const je of fe)for(const _t of je.requiredElementUids.keys()){We.has(_t)||We.set(_t,new T.bI);for(const yt of je.requiredElementUids.get(_t))We.get(_t).add(yt)}return N.addClbk=je=>{const _t=new te.Hh.AddClbkResult;for(const yt of fe){je.currentDirectory=yt.directory,yt.directory.addRequiredElementsToLookupTable(We,je);const St=yt.addClbk(je);_t.hasActuallyAdded=_t.hasActuallyAdded||St.hasActuallyAdded,_t.addedElementsMap||(_t.addedElementsMap=new Map);
1const ut=_t.addedElementsMap[St.directoryType]??=new Map;for(const[At,Ut]of St.addedElements.entries())ut[At]=(ut[At]||[]).concat(Ut.map(wt=>({directoryType:St.directoryType,value:wt})));je.lowerDirectory=je.currentDirectory}return je.currentDirectory=null,je.lowerDirectory=null,_t},N.removeClbk=()=>{for(const je of ie)je()},N}tryApplyPackage(t){return this._tryExecutePackage(t,!1)}tryUnapplyPackage(t){return this._tryExecutePackage(t,!0)}copyFrom(t,c){this._networkDirectory.copyFrom(t._networkDirectory,c,!0),this._shapeDirectory.copyFrom(t._shapeDirectory,c,!0),this._networkDirectory.copyFrom(t._networkDirectory,c,!1),this._shapeDirectory.copyFrom(t._shapeDirectory,c,!1)}dispose(){this._networkDirectory.dispose(),this._shapeDirectory.dispose(),this._parentState=null}}P(9614);var vi=P(91668),bi=P(11831),es=P(76314);function Ps(nt,t,c){const N=function Es(nt,t,c){const N=[];t.outerPath.forEach(we=>{const fe=c.getElementByFullUid(we.line);fe&&fe.lineType()===te.gb.PARTITIONABLE&&N.push(fe.p2Line)});const z=nt.startPerpNode,ie=nt.endPerpNode;if(!z||!ie)return null;const pe=function us(nt,t,c,N){const z=N.map(oi=>[e.TE(t.position,oi),e.kE(oi),oi]);if(z.sort((oi,Li)=>oi[0]-Li[0]),z.length<=1)return null;const[,ie,pe]=z[0],[,we,fe]=z[z.length-1],We=e.Pu(pe.getCoordinateN(0)),je=e.Pu(pe.getCoordinateN(1)),_t=e.Pu(fe.getCoordinateN(0)),yt=e.Pu(fe.getCoordinateN(1)),[St,ut]=e.TE(t.position,We)<e.TE(t.position,je)?[We,je]:[je,We],[At,Ut]=e.TE(c.position,_t)<e.TE(c.position,yt)?[_t,yt]:[yt,_t],wt=e.TE(At,St)<e.TE(Ut,ut),It=e.ih(e.hX(pe)),Rt=e.ih(e.hX(fe)),Tt=(oi,Li)=>{const Ai=e.K8(oi,It,10),Ji=e.K8(Li,Rt,10);return e.Y8(Ai,Ji)},Lt=Tt(St,At),jt=Tt(ut,Ut);if(!Lt||!jt)return z;const _i=e.AZ(nt);let ci=null;const gi=2*e.kE(_i),ui=(oi,Li,Ai,Ji=!1)=>{const Os=e.uM(e.QH(oi,Li,-gi),e.QH(oi,Li,gi)),Wi=e.pB(Os,Ji?ci:_i),Hi=Wi&&!e.xb(Wi)?Array.from({length:Wi.getNumGeometries()},(Ri,zi)=>{const _s=Wi.getGeometryN(zi);return[e.TE(Ai,_s),_s]}):[];if(!Hi.length){if(Ji)return null;if(!ci){const Ri=e.hq(nt,5);ci=e.AZ(Ri)}return ui(oi,Li,Ai,!0)}return Hi.sort((Ri,zi)=>zi[0]-Ri[0]),e.uM(oi,Hi[0][1])},[ri,Ei]=wt?[Lt,jt]:[jt,Lt],[Pi,Ti]=wt?[St,ut]:[ut,St],[is,Ci]=wt?[At,Ut]:[Ut,At],Oi=ui(ri,It,Ti),Ii=ui(ri,Rt,Ci);if(!Oi||!Ii)return z;const yi=e.TE(ri,Pi),ss=e.TE(ri,is),ns=e.FU(Ei,Oi)[1],ps=e.FU(Ei,Ii)[1],gs=e.TE(ri,ns),ms=e.TE(ri,ps);return{startWidth:Math.min(gs,e.kE(Oi))+yi,endWidth:Math.min(ms,e.kE(Ii))+ss,startHeight:ie,endHeight:we,startSideWidth:ss,endSideWidth:yi,startLimit:gs,endLimit:ms,startPartLine:pe,endPartLine:fe,
1startConstCorrLine:Oi,endConstCorrLine:Ii,startConstLimitPt:ns,endConstLimitPt:ps,realCoorPt:ri,realWallPt:Ei,isInterior:wt}}(nt.coveredSpace,z,ie,N);return!pe||Array.isArray(pe)?pe:(nt._startWidth=pe.startWidth,nt._endWidth=pe.endWidth,nt._startHeight=pe.startHeight,nt._endHeight=pe.endHeight,nt._startSideWidth=pe.startSideWidth,nt._endSideWidth=pe.endSideWidth,nt._startConstructionLine=e.ix(pe.startConstCorrLine,10),nt._endConstructionLine=e.ix(pe.endConstCorrLine,10),nt._cornerCentroid=pe.realWallPt,nt._cornerIsInterior=pe.isInterior,null)}(nt,t,c);null!==N&&function bs(nt,t){nt._startWidth=t[t.length-1][1],nt._endWidth=t[0][1],nt._startHeight=t[0][1],nt._endHeight=t[t.length-1][1];const c=e.Y8(t[0][2],t[t.length-1][2]);c&&(nt._startSideWidth=e.TE(t[0][2],c),nt._endSideWidth=e.TE(t[t.length-1][2],c),nt._startConstructionLine=e.ix(t[t.length-1][2],10),nt._endConstructionLine=e.ix(t[0][2],10),nt._cornerCentroid=e.Sc(e.H3([e.Sc(t[t.length-1][2]).getCoordinate(),e.Sc(t[0][2]).getCoordinate()])))}(nt,N)}class Ui{get isFree(){return this._isFree}setIsFree(t){this._isFree=t}
1get coveredSpace(){return this._coveredSpace}get tileInfos(){return this._tileInfos}get beginTileInfo(){return this._beginTileInfo}get endTileInfo(){return this._endTileInfo}constructor(t,c){this._isFree=!0,this._tileInfos=[],this._isFree=t,this._tileInfos=c,this._coveredSpace=e.p(),this._tileInfos.forEach(N=>N.parentDirectLightFragmentStates.push(this)),this.updateExtremities()}dispose(){this._tileInfos=[],this._beginTileInfo=null,this._endTileInfo=null}updateCoveredSpace(){let t=e.lD();this._tileInfos.forEach(c=>{c.coveredSpace.isEmpty()||bi.a.isGeometryValid(c.coveredSpace)&&(t=e.Y7(t,c.coveredSpace))}),t=e.lE(t),this._coveredSpace=e.b3(t)}updateExtremities(){if(!this._tileInfos.length)return this._beginTileInfo=null,this._endTileInfo=null,void this.updateCoveredSpace();if(1===this._tileInfos.length)return this._beginTileInfo=this._tileInfos[0],this._endTileInfo=this._tileInfos[0],void this.updateCoveredSpace();const c=this._tileInfos.map(N=>{const z=ie=>ie.filter(pe=>pe.parentDirectLightFragmentStates.includes(this));return[N,z(N.beginNeighbours),z(N.endNeighbours)]}).filter(([N,z,ie])=>!z.length||!ie.length).map(([N,z,ie])=>N);c.sort((N,z)=>Math.min(N.partitionableShapeInfo.startPerpLineUid.asElementId(),N.partitionableShapeInfo.endPerpLineUid.asElementId())-Math.min(z.partitionableShapeInfo.startPerpLineUid.asElementId(),z.partitionableShapeInfo.endPerpLineUid.asElementId())),this._beginTileInfo=c[0]||null,this._endTileInfo=c[c.length-1]||null,this.updateCoveredSpace()}die(){this._tileInfos.forEach(t=>{const c=t.parentDirectLightFragmentStates.indexOf(this);c>=0&&t.parentDirectLightFragmentStates.splice(c,1)}),this.dispose()}removeTiles(t){return this._tileInfos=this._tileInfos.filter(c=>!t.includes(c)),t.forEach(c=>{c.parentDirectLightFragmentStates.includes(this)&&c.parentDirectLightFragmentStates.splice(c.parentDirectLightFragmentStates.indexOf(this),1)}),this.updateExtremities(),0===this._tileInfos.length}addTiles(t){t.forEach(c=>{this._tileInfos.includes(c)||(this._tileInfos.push(c),c.parentDirectLightFragmentStates.push(this))}),this.updateExtremities()}tryAbsorb(t){return!(!t.beginNeighbours.some(c=>c===this._beginTileInfo)&&!t.endNeighbours.some(c=>c===this._endTileInfo)||(t.parentDirectLightFragmentStates.push(this),this._tileInfos.push(t),this.updateExtremities(),0))}tryMerge(t){if(this._isFree!==t.isFree)return!1;const c=(N,z)=>N&&z&&(N===z||N.beginNeighbours.includes(z)||N.endNeighbours.includes(z)||z.beginNeighbours.includes(N)||z.endNeighbours.includes(N));return!!(c(this._beginTileInfo,t.beginTileInfo)||c(this._endTileInfo,t.endTileInfo)||c(this._beginTileInfo,t.endTileInfo)||c(this._endTileInfo,t.beginTileInfo))&&(this._tileInfos.push(...t.tileInfos),t.tileInfos.forEach(N=>N.parentDirectLightFragmentStates.push(this)),t.die(),this.updateExtremities(),!0)}}class Ts{get itemStates(){return this._itemStates}constructor(t,c,N){this._itemStates=[],t.items.forEach((z,ie)=>{const pe=new T.me;let we={tileStates:[],extremityTileStates:[],corridorExtremityTiles:[],secondaryCorridors:z.corridorSpace||null,peakCirculationNodePosition:z.peakCirculationNodePosition||null};z.shapeUids.forEach(We=>{const je=c.tileStates.find(_t=>_t.partitionableShapeInfo.uidInPackage().equals(We));je&&(pe.set(We,je),we.tileStates.push(je))}),z.extremityShapeUids.forEach(We=>{const je=pe.get(We)||c.tileStates.find(_t=>_t.partitionableShapeInfo.uidInPackage().equals(We));je&&we.extremityTileStates.push(je)}),(()=>{const We=we.peakCirculationNodePosition,je=we.secondaryCorridors;if(!We||e.xb(We)||!je||e.xb(je))return;const _t=we.extremityTileStates.map(wt=>({dist:e.TE(We,wt.coveredSpace),tile:wt}));if(_t.sort((wt,It)=>wt.dist-It.dist),0===_t.length)return;const yt=_t[0].tile,St=[yt],ut=e.Sc(yt.coveredSpace);for(let wt=1;wt<_t.length;wt++){const It=_t[wt].tile,Rt=e.uM(e.Sc(It.coveredSpace),ut);if(e.kK(je,Rt)){St.push(It);break}}const At=e.hq(je,5),Ut=St.map(wt=>{const It=e.m0(wt.coveredSpace,At);return{area:It?e.SO(It):0,tile:wt}});Ut.sort((wt,It)=>It.area-wt.area),Ut.forEach((wt,It)=>{we.corridorExtremityTiles.push([wt.tile,0===It])})})(),this._itemStates.push(we)})}
1setupCorners(){this._itemStates.forEach(t=>{let c=t.corridorExtremityTiles.find(we=>!we[1])?.[0];if(!c)return;const N=new Set([c]),z=we=>we.find(fe=>!N.has(fe)&&t.tileStates.includes(fe));let ie=c.width,pe=t.tileStates.length+1;for(;ie<650&&c&&pe>0;)pe--,c=z(c._beginNeighbours)||z(c._endNeighbours),c&&(N.add(c),ie+=c.width);N.forEach(we=>we.isInCorner=!0)})}dispose(){this._itemStates.forEach(t=>{t.tileStates=[],t.extremityTileStates=[]}),this._itemStates=[]}}class ts{get directLight(){return this._directLightInfo}get fragmentStates(){return this._fragmentStates}get coveredSpace(){return this._coveredSpace}get freeLinks(){return this._freeLinks}get tileStates(){return this._tileStates}get extremityTileStates(){return this._extremityTileStates}get dynamicSectionLockers(){return this._dynamicSectionLockers}get dynamicSectionItemIdx(){return this._dynamicSectionItemIdx}get dynamicSectionStates(){return this._dynamicSectionStates}get allowedDynamicItem0ByOtherItem(){return this._allowedDynamicItem0ByOtherItem}constructor(t,c){this._fragmentStates=[],this._freeLinks=[],this._coveredSpace=e.p(),this._tileStates=[],this._extremityTileStates=[],this._dynamicSectionLockers={},this._dynamicSectionItemIdx={},this._dynamicSectionStates={},this._allowedDynamicItem0ByOtherItem={},this._directLightInfo=t;const N=e.hq(c.targetFloor.corridorSpaces(),5),z=c.targetFloor.postSpaces(),ie=(fe,We)=>{if(!fe)return null;const je=e.m0(fe.coveredSpace,z);if(e.xb(je))return fe;const _t=e.m0(fe.coveredSpace,We),yt=(St,ut,At)=>{let Ut=!0,wt=fe.getRefP2l(At);if(!wt||e.xb(wt)){if(e.xb(_t))return[];const Lt=_t.getEnvelopeInternal();if(wt=e.uM(e.Pu(Lt.getMinX(),Lt.getMinY()),e.Pu(Lt.getMaxX(),Lt.getMaxY())),e.xb(wt))return[];const jt=fe.computeOffsetDir(At);e.rz(jt,e.hX(wt))<0&&(wt=e.uM(wt.getCoordinateN(1),wt.getCoordinateN(0))),Ut=!1}const It=Lt=>Ut?Math.max(0,ut-e.TE(Lt,wt)):e.TE(Lt,_t),Rt=Lt=>e.rj(wt,e.FU(Lt,wt)[1],!0)[0],Tt=[];for(let Lt=0,jt=je.getNumGeometries();Lt<jt;Lt++){const ci=je.getGeometryN(Lt).getEnvelopeInternal(),gi=e.Pu(ci.getMinX(),ci.getMinY()),ui=e.Pu(ci.getMaxX(),ci.getMaxY());let ri=Number.POSITIVE_INFINITY,Ei=Number.NEGATIVE_INFINITY,Pi=Number.POSITIVE_INFINITY,Ti=Number.NEGATIVE_INFINITY;if([[gi.getX(),gi.getY()],[gi.getX(),ui.getY()],[ui.getX(),gi.getY()],[ui.getX(),ui.getY()]].forEach(Ci=>{const Oi=e.Pu(Ci[0],Ci[1]),Ii=It(Oi),yi=Rt(Oi);yi<ri&&(ri=yi),yi>Ei&&(Ei=yi),Ii<Pi&&(Pi=Ii),Ii>Ti&&(Ti=Ii)}),Math.abs(Ei-ri)<2||Math.abs(Ti-Pi)<2)continue;let is={x:ri,length:Ei-ri,y:Pi,height:Ti-Pi,offsetH:fe.getClosestFittingOffset(ri,!0,!0,At)||0};Tt.push(is)}return Tt};return fe.isCorner?(fe._postInfos=yt(0,fe.startHeight,!0),fe._endPostInfos=yt(0,fe.endHeight,!1)):fe._postInfos=yt(0,fe.partitionableShapeInfo.height,null),fe._currentHeight=es.vC.height(fe),fe},pe=(fe,We=-1,je=-1)=>{const _t=c.getElementByFullUid(fe);if(_t){const yt=new es.vC(_t,We,je),St=c.getElementByFullUid(_t.startPerpLineUid);St&&(yt._startPerpNode=St);const ut=c.getElementByFullUid(_t.endPerpLineUid);if(ut&&(yt._endPerpNode=ut),St&&ut&&St.nodeType()===ut.nodeType())yt._duoPerpNodeWidth=e.TE(St.position,ut.position);else{const Ut=St&&St.nodeType()===te.Mq.WALL?St:ut&&ut.nodeType()===te.Mq.WALL?ut:St||ut;yt._soloPerpNode=Ut}const At=Ut=>Ut.map(wt=>c.getElementByFullUid(wt.startNode).position);if(yt._coveredSpace=e.p(At(_t.outerPath),_t.innerPaths.map(At)),!e.JY(yt.coveredSpace)){const[Ut,wt]=e.eX(yt.coveredSpace);wt&&(yt._coveredSpace=Ut)}return yt.__isFree=!0,this._tileStates.push(yt),t.extremityShapes.some(([Ut,wt,It])=>It.equals(fe))&&this._extremityTileStates.push(yt),_t.isCorner&&Ps(yt,_t,c),yt}return null};t.staticSections.forEach(fe=>{fe.shapeUids.forEach(We=>ie(pe(We),N))}),t.dynamicSections.forEach((fe,We)=>{let je={};const _t=new T.me;fe.items[0].shapeUids.forEach(yt=>{const St=ie(pe(yt,We,0),N);St&&_t.set(yt,St)}),fe.items.slice(1).forEach((yt,St)=>{St++;const ut=new Set;let At=N;e.xb(yt.corridorSpace)||(At=e.Y7(At,e.hq(yt.corridorSpace,5))),yt.shapeUids.forEach(Ut=>{const wt=_t.get(Ut);wt?ut.add(wt):ie(pe(Ut,We,St),At)}),je[St]=ut}),this.updateDynamicSectionItem(We,0),this._dynamicSectionStates[We]=new Ts(fe,this,c),this._allowedDynamicItem0ByOtherItem[We]=je}),this._dynamicSectionItemIdx={},this._dynamicSectionLockers={}
1,this._tileStates.forEach((fe,We,je)=>{if(!(fe.dynamicItemIdx>0))for(let St=We+1;St<je.length;St++){const ut=je[St];if(!(ut.dynamicItemIdx>0))if(fe.partitionableShapeInfo.startPerpLineUid.equals(ut.partitionableShapeInfo.startPerpLineUid))fe._beginNeighbours.push(ut),ut._beginNeighbours.push(fe);else if(fe.partitionableShapeInfo.endPerpLineUid.equals(ut.partitionableShapeInfo.startPerpLineUid))fe._endNeighbours.push(ut),ut._beginNeighbours.push(fe);else if(fe.partitionableShapeInfo.startPerpLineUid.equals(ut.partitionableShapeInfo.endPerpLineUid))fe._beginNeighbours.push(ut),ut._endNeighbours.push(fe);else if(fe.partitionableShapeInfo.endPerpLineUid.equals(ut.partitionableShapeInfo.endPerpLineUid))fe._endNeighbours.push(ut),ut._endNeighbours.push(fe);else{const At=fe.startPerpNode?e.TE(fe.startPerpNode.position,ut.coveredSpace):1/0,Ut=fe.endPerpNode?e.TE(fe.endPerpNode.position,ut.coveredSpace):1/0,wt=ut.startPerpNode?e.TE(ut.startPerpNode.position,fe.coveredSpace):1/0,It=ut.endPerpNode?e.TE(ut.endPerpNode.position,fe.coveredSpace):1/0;let Rt=!1,Tt=!1;At<.25&&((ut.startPerpNode?e.TE(fe.startPerpNode.position,ut.startPerpNode.position):1/0)<(ut.endPerpNode?e.TE(fe.startPerpNode.position,ut.endPerpNode.position):1/0)?(fe._beginNeighbours.push(ut),ut._beginNeighbours.push(fe),Rt=!0):(fe._beginNeighbours.push(ut),ut._endNeighbours.push(fe),Rt=!0)),Ut<.25&&((ut.startPerpNode?e.TE(fe.endPerpNode.position,ut.startPerpNode.position):1/0)<(ut.endPerpNode?e.TE(fe.endPerpNode.position,ut.endPerpNode.position):1/0)?(fe._endNeighbours.push(ut),ut._beginNeighbours.push(fe),Tt=!0):(fe._endNeighbours.push(ut),ut._endNeighbours.push(fe),Tt=!0)),Rt&&Tt||(wt<.25&&((fe.startPerpNode?e.TE(ut.startPerpNode.position,fe.startPerpNode.position):1/0)<(fe.endPerpNode?e.TE(ut.startPerpNode.position,fe.endPerpNode.position):1/0)?Rt||(ut._beginNeighbours.push(fe),fe._beginNeighbours.push(ut),Rt=!0):Tt||(ut._beginNeighbours.push(fe),fe._endNeighbours.push(ut),Tt=!0)),It<.25&&((fe.startPerpNode?e.TE(ut.endPerpNode.position,fe.startPerpNode.position):1/0)<(fe.endPerpNode?e.TE(ut.endPerpNode.position,fe.endPerpNode.position):1/0)?Rt||(ut._endNeighbours.push(fe),fe._beginNeighbours.push(ut),Rt=!0):Tt||(ut._endNeighbours.push(fe),fe._endNeighbours.push(ut),Tt=!0)))}}}),this._tileStates.forEach(fe=>{const We=fe.dynamicSectionIdx,je=fe.dynamicItemIdx,_t=yt=>yt.length<=1?yt:(yt=yt.filter(St=>St.dynamicSectionIdx<=0)).map(St=>({ts:St,s:(fe.dynamicSectionIdx===We?20:fe.dynamicSectionIdx<0?10:0)+(fe.dynamicItemIdx===je?2:fe.dynamicItemIdx<0?1:0)})).sort((St,ut)=>ut.s-St.s).map(St=>St.ts);fe._beginNeighbours=_t(fe._beginNeighbours),fe._endNeighbours=_t(fe._endNeighbours),es.q_&&fe.partitionableShapeInfo.isStraight&&(!fe._beginNeighbours||!fe._endNeighbours)&&(fe._beginNeighbours?fe._endNeighbours||(fe._endPerpNode=null):fe._startPerpNode=null)}),Object.values(this._dynamicSectionStates).forEach(fe=>fe.setupCorners());const we=new Ui(!0,this._tileStates);this._fragmentStates.push(we)}isEmpty(){return!this._tileStates.length}concludeInitialization(t){const c=t.shapeDirectory;this._tileStates.forEach(z=>z.tryPickCoveredSpace(c)),this._fragmentStates.forEach(z=>z.updateCoveredSpace());let N=e.lD();this._fragmentStates.forEach(z=>{bi.a.isGeometryValid(z.coveredSpace)?N=e.Y7(N,z.coveredSpace):(console.debug("\u26a0\ufe0f Skipping invalid fragment geometry in concludeInitialization"),bi.a.debugGeometry(z.coveredSpace,"Invalid Fragment"))}),N=e.lE(N),this._coveredSpace=e.b3(N)}tryUpdateCoveredSpaces(t){}updateDynamicSectionItem(t,c,N=!1){const z=this._directLightInfo.dynamicSections[t];let ie=!1;N?this._dynamicSectionLockers[t]?(this._dynamicSectionLockers[t]--,this._dynamicSectionLockers[t]<=0&&(ie=!0,delete this._dynamicSectionLockers[t],delete this._dynamicSectionItemIdx[t])):ie=!0:(this._dynamicSectionLockers[t]||(this._dynamicSectionLockers[t]=0),this._dynamicSectionLockers[t]++,this._dynamicSectionItemIdx[t]=c);const pe=ie?z?.items[0]:z?.items[c];if(!pe)return 0;const we=z.items.flatMap(We=>We.shapeUids.map(je=>je.toString())),fe=pe.shapeUids.map(We=>We.toString());
1return this._tileStates.forEach(We=>{we.includes(We.partitionableShapeInfo.uidInPackage().toString())&&We.setIsActive(fe.includes(We.partitionableShapeInfo.uidInPackage().toString()))}),ie?z.items[c]?.appliedPackageId||0:pe.appliedPackageId}dispose(){this._directLightInfo=null,this._fragmentStates.forEach(t=>t.dispose()),this._fragmentStates=[],this._freeLinks.forEach(t=>t.dispose()),this._freeLinks=[],this._tileStates.forEach(t=>t.dispose()),this._tileStates=[]}_updateTiles(t,c){const N=[];return c.forEach(z=>{if(z instanceof E.ph){const ie=this._tileStates.find(pe=>pe.partitionableShapeInfo.uidInPackage().equals(z));ie&&(t?ie.blit():ie.unblit(),N.push(ie))}else{const ie=this._tileStates.find(pe=>pe.partitionableShapeInfo.uidInPackage().equals(z.tileUid));ie&&(t?ie.blit(z.startOffset,z.endOffset):ie.unblit(z.startOffset,z.endOffset),N.push(ie))}}),this._fragmentStates=ts.updateFragments(t,c,this._tileStates,this._fragmentStates).allFragments,N}consumeTiles(t){return this._updateTiles(!0,t)}restoreTiles(t){return this._updateTiles(!1,t)}static updateFragments(t,c,N,z){const ie=[],pe=[],we=[];c.forEach(It=>{N.find(It instanceof E.ph?Tt=>Tt.partitionableShapeInfo.uidInPackage().equals(It):Tt=>Tt.partitionableShapeInfo.uidInPackage().equals(It.tileUid))}),t?we.push(...ie):pe.push(...ie);const fe=new Set(ie.flatMap(It=>It.parentDirectLightFragmentStates));fe.forEach(It=>{const Rt=It.isFree;It.tileInfos.forEach(Tt=>{ie.includes(Tt)||(Rt?pe.push(Tt):we.push(Tt))}),It.die()}),z=z.filter(It=>!fe.has(It));const We=[],je=[];z.forEach(It=>{It.isFree?We.push(It):je.push(It)});const _t=(It,Rt)=>{const Tt=[];return It.forEach(Lt=>{let jt=!1;for(const _i of Rt)if(_i.tryAbsorb(Lt)){jt=!0;break}jt||Tt.push(Lt)}),[Tt,Tt.length!==It.length]};let yt=!0,St=100,ut=pe,At=we;for(;yt&&St>0;){St--,yt=!1;const[It,Rt]=_t(ut,We);yt=yt||Rt,ut=It;const[Tt,Lt]=_t(At,je);yt=yt||Lt,At=Tt}const Ut=(It,Rt,Tt)=>{const Lt=new Ui(It,[Rt]);z.push(Lt);let jt=Tt,_i=!0,ci=100;for(;_i&&ci>0;){ci--,_i=!1;let gi=[];jt.forEach(ui=>{Lt.tryAbsorb(ui)?_i=!0:gi.push(ui)}),jt=gi}return jt};for(;ut.length>0;){const It=ut.shift();It&&(ut=Ut(!0,It,ut))}for(;At.length>0;){const It=At.shift();It&&(At=Ut(!1,It,At))}z.forEach(It=>It.updateExtremities());const wt=[];for(let It=0;It<z.length;It++){const Rt=z[It];if(!wt.includes(Rt))for(let Tt=It+1;Tt<z.length;Tt++){const Lt=z[Tt];Rt.tryMerge(Lt)&&wt.push(Lt)}}return(z=z.filter(It=>!wt.includes(It))).forEach(It=>It.updateExtremities()),{allFragments:z,createdFragments:z.filter(It=>It.tileInfos.some(Rt=>ie.includes(Rt)))}}}class pi{get gridInfo(){return this._gridInfo}get coveredSpace(){return this._coveredSpace}get cells(){return this._cells}get cellSize(){return this._cellSize}get ltwMtx(){return this._ltwMtx}get wtlMtx(){return this._wtlMtx}get irrigatedCells(){return this._irrigatedCells}get contourCells(){return this._contourCells}constructor(t,c,N,z){this._cells=new T.me,this._irrigatedCells=new Set,this._contourCells=new Set,this._gridInfo=N,this._coveredSpace=z,this._cellSize=t,(!e.JY(this._coveredSpace)||e.xb(this._coveredSpace))&&(this._coveredSpace=e.D1(this._coveredSpace,c)),this._wtlMtx=e.wz(N.worldToLocalMtx),this._ltwMtx=e.Pk(this._wtlMtx);const ie=e.Uf(this._coveredSpace,this._wtlMtx),we=this._cellSize*(.1*this._cellSize);for(let St=0,ut=this._gridInfo.columns;St<=ut;St++)for(let At=0,Ut=this._gridInfo.rows;At<=Ut;At++){const wt=e.p([{x:St*this._cellSize,y:At*this._cellSize},{x:St*this._cellSize,y:(At+1)*this._cellSize},{x:(St+1)*this._cellSize,y:(At+1)*this._cellSize},{x:(St+1)*this._cellSize,y:At*this._cellSize}]),It=e.m0(ie,wt);if(!e.xb(It)&&e.SO(It)>=we){const Rt=[St,At];if(e.SO(It)<.99*e.SO(wt)){const Tt=It.getEnvelopeInternal();if(Tt){let Lt=Tt.getMaxX()-Tt.getMinX(),jt=Tt.getMaxY()-Tt.getMinY();Lt+2>t&&(Lt=void 0),jt+2>t&&(jt=void 0),this._cells.set(Rt,new ds(Rt,Lt,jt))}}else this._cells.set(Rt,new ds(Rt))}}N.irrigatedCoords.forEach(([St,ut,At])=>{const Ut=this._cells.get([St,ut]);if(Ut)switch(this._irrigatedCells.add(Ut),At){case"b":Ut.setIb(0);break;case"t":Ut.setIt(0);break;case"l":Ut.setIl(0);break;case"r":Ut.setIr(0)}}),this._updateFlags();let fe=-1,We=null,je=null;const _t=()=>{We&&je&&(this._contourCells.add(We),this._contourCells.add(je)),We=null,je=null},yt=(St,ut)=>{St.majorCoord!==fe&&(_t(),fe=St.majorCoord,St.cells.length&&(We=St.cells[0])),St.cells.length&&(je=St.cells[St.cells.length-1]),ut&&_t()};pi.StreakScanner.execute(this,{majorAxisIsHHorizontal:!0},yt),pi.StreakScanner.execute(this,{majorAxisIsHHorizontal:!1},yt)}blit(t,c){for(let N=t[0];N<=c[0];N++)for(let z=t[1];z<=c[1];z++)this._cells.get([N,z])?.setIsFree(!1);this._updateFlags({bl:t,tr:c})}
1unblit(t,c){for(let N=t[0];N<=c[0];N++)for(let z=t[1];z<=c[1];z++)this._cells.get([N,z])?.setIsFree(!0);this._updateFlags({bl:t,tr:c})}createPolygon(t,c){const N=e.p([{x:t[0]*this._cellSize,y:t[1]*this._cellSize},{x:t[0]*this._cellSize,y:(c[1]+1)*this._cellSize},{x:(c[0]+1)*this._cellSize,y:(c[1]+1)*this._cellSize},{x:(c[0]+1)*this._cellSize,y:t[1]*this._cellSize}]);return e.b3(e.m0(this._coveredSpace,e.Uf(N,this._ltwMtx)))}tryPickCell(t){const c=e.Uf(t,this._wtlMtx),N=Math.floor(c.x/this._cellSize),z=Math.floor(c.y/this._cellSize);return this._cells.get([N,z])||null}dispose(){this._gridInfo=null,this._coveredSpace=null,this._cells=null,this._ltwMtx=null,this._wtlMtx=null}_updateFlags(t){const c=N=>{N.cells.forEach(z=>{const ie=N.asMajorMinor(z.coords[0],z.coords[1])[1];if(void 0!==N.negativeIrrigatedCoord?N.setFlag(z,!1,"i",ie-N.negativeIrrigatedCoord):N.getFlag(z,!1,"i")>0&&N.setFlag(z,!1,"i",void 0),void 0!==N.positiveIrrigatedCoord){const we=ie-N.positiveIrrigatedCoord;we>0&&N.setFlag(z,!0,"i",we)}else N.getFlag(z,!0,"i")>0&&N.setFlag(z,!0,"i",void 0);const pe=ie-N.startMinorCoord;N.setFlag(z,!1,"f",pe),N.setFlag(z,!0,"f",N.minorStreak-pe)})};pi.StreakScanner.execute(this,{majorAxisIsHHorizontal:!0,majorStart:t?.bl[0],majorEnd:t?.tr[0]}
1,c),pi.StreakScanner.execute(this,{majorAxisIsHHorizontal:!1,majorStart:t?.bl[1],majorEnd:t?.tr[1]},c)}scan(t,c){const N=t.majorAxisIsHHorizontal,ie=t.majorEnd??(N?this._gridInfo.columns:this._gridInfo.rows),pe=N?this._gridInfo.rows:this._gridInfo.columns;for(let we=t.majorStart??0;we<=ie;we++){let fe=0;for(let We=0;We<=pe;We++){const je=N?we:We,_t=N?We:we,yt=this._cells.get([je,_t]);yt&&yt.isFree?(c({majorCoord:we,minorCoord:We,x:je,y:_t,minorStreak:fe,cell:yt}),fe++):fe=0}}}}!function(nt){class t{asXY(N,z){return this.scanArg.majorAxisIsHHorizontal?[z??this.majorCoord,N]:[N,z??this.majorCoord]}asMajorMinor(N,z){return this.scanArg.majorAxisIsHHorizontal?[N,z]:[z,N]}getFlag(N,z,ie){let pe="t";return pe=this.scanArg.majorAxisIsHHorizontal?z?"t":"b":z?"r":"l",N[ie+pe]}setFlag(N,z,ie,pe){let we="t";we=this.scanArg.majorAxisIsHHorizontal?z?"t":"b":z?"r":"l",N[`set${ie.toUpperCase()+we}`](pe)}static execute(N,z,ie){new t(N,z,ie)._conclude()}constructor(N,z,ie){this.gridState=N,this.scanArg=z,this.onStreak=ie,this.cells=[],this.majorCoord=0,this.startMinorCoord=0,this.endMinorCoord=0,this.minorStreak=0,N.scan(z,pe=>this._onScan(pe))}_onScan(N){if(this.majorCoord!==N.majorCoord&&(this.cells.length&&this.onStreak(this),this.majorCoord=N.majorCoord,this.startMinorCoord=N.minorCoord,this.endMinorCoord=N.minorCoord,this.cells=[],this.minorStreak=0,this.negativeIrrigatedCoord=void 0,this.positiveIrrigatedCoord=void 0),0===N.minorStreak){this.cells.length&&this.onStreak(this),this.startMinorCoord=N.minorCoord,this.endMinorCoord=N.minorCoord,this.cells=[],this.minorStreak=0,this.negativeIrrigatedCoord=void 0,this.positiveIrrigatedCoord=void 0;const ie=this.getFlag(N.cell,!1,"i");"number"==typeof ie&&ie<=0&&(this.negativeIrrigatedCoord=N.minorCoord)}this.endMinorCoord=N.minorCoord,this.cells.push(N.cell),this.minorStreak=N.minorStreak;const z=this.getFlag(N.cell,!0,"i");"number"==typeof z&&z<=0&&(this.positiveIrrigatedCoord=N.minorCoord)}_conclude(){this.cells.length&&this.onStreak(this,!0),this.cells=[],this.gridState=null,this.scanArg=null,this.onStreak=null}}nt.StreakScanner=t}(pi||(pi={}));class ds{constructor(t,c,N){this._coords=t,this._isFree=!0,this._hl=c,this._vl=N}get coords(){return this._coords}get isFree(){return this._isFree}setIsFree(t){this._isFree=t}get hl(){return this._hl}get vl(){return this._vl}get ib(){return this._ib}setIb(t){this._ib=t}get it(){return this._it}setIt(t){this._it=t}get il(){return this._il}setIl(t){this._il=t}get ir(){return this._ir}setIr(t){this._ir=t}get wb(){return this._wb}setWb(t){this._wb=t}get wt(){return this._wt}setWt(t){this._wt=t}get wl(){return this._wl}setWl(t){this._wl=t}get wr(){return this._wr}setWr(t){this._wr=t}get fb(){return this._fb}setFb(t){this._fb=t}get ft(){return this._ft}setFt(t){this._ft=t}get fl(){return this._fl}setFl(t){this._fl=t}get fr(){return this._fr}setFr(t){this._fr=t}}class Cs{get lightShapeUid(){return this._lightShapeUid}get gridStates(){return this._gridStates}get coveredSpace(){return this._coveredSpace}constructor(t,c,N,z){this._gridStates=new T.me,this._lightShapeUid=N;let ie=e.lD();z.forEach(([pe,we])=>{const fe=new pi(t,c,pe,we);this._gridStates.set(pe.uidInPackage(),fe),ie=e.Y7(ie,we)}),this._coveredSpace=e.b3(e.lE(ie,1)),(!e.JY(this._coveredSpace)||e.xb(this._coveredSpace))&&(this._coveredSpace=e.D1(this._coveredSpace,c))}isEmpty(){return!this._gridStates.size}tryPickCell(t){for(const c of this._gridStates.values()){const N=c.tryPickCell(t);if(N)return[c,N]}return null}blit(...t){t.forEach(([c,N,z])=>{this._gridStates.get(c)?.blit(N,z)})}unblit(...t){t.forEach(([c,N,z])=>{this._gridStates.get(c)?.unblit(N,z)})}dispose(){this._lightShapeUid=null,this._gridStates.values().forEac
1h(t=>t.dispose()),this._gridStates=null,this._coveredSpace=null}}class Bi{constructor(){this._isAvailable=!0,this._width=0,this._height=0}get width(){return this._width}get height(){return this._height}get isAvailable(){return this._isAvailable}setIsAvailable(t){this._isAvailable=t}static createStates(t){return t.lotParts().flatMap(c=>c.controlRooms().map(N=>{const z=new Bi;z.targetCoreRoom=N;const pe=N.coveredSpace().getEnvelopeInternal();return z._width=pe.getWidth(),z._height=pe.getHeight(),z}))}}class fs{get microUnpacked(){return this._microUnpacked}get directCorridorInfos(){return this._directCorridorInfos}get indirectCorridorInfos(){return this._indirectCorridorInfos}get directLightAreaStates(){return this._directLightAreaStates}get indirectLightAreaStates(){return this._indirectLightAreaStates}get stackingPlanInfo(){return this._targetFloorInput.targetFloor.stackingPlanInfo()}get unselectedLotCoveredSpaces(){return this._targetFloorInput.unselectedLotCoveredSpaces}get newDirtyables(){return this._newDirtyables}get placedAeas(){return this._placedAeas}get placedModules(){return this._placedModules}get placedDepartments(){return this._placedDepartments}constructor(t=null){this._parentPropertyState=null,this._layerDirectoryRoot=new vs,this._packageManager=new ke,this._directLightAreaStates=[],this._indirectLightAreaStates=[],this._microUnpacked=null,this._directCorridorInfos=[],this._indirectCorridorInfos=[],this._newDirtyables=[],this._placedAeas=[],this._placedModules=[],this._placedDepartments=[],this._targetFloorInput=t}concludeDirty(){const t=c=>c.map(N=>N.dirtyState===vi.w.DELETE?(N.dispose(),null):(N.dirtyState=vi.w.IDLE,N)).filter(N=>!!N);this._placedModules=t(this._placedModules),this._placedAeas=t(this._placedAeas),this._placedDepartments=t(this._placedDepartments),this._newDirtyables=[]}updatePlacedAppliedPackages(t,c,N){if(t){let ie=new Set;Object.values(N).forEach(pe=>pe.forEach(we=>ie.add(we))),this._packageManager.updatePlacedAppliedPackages(t,c,N),this._directLightAreaStates.forEach(pe=>pe.tryUpdateCoveredSpaces(this._layerDirectoryRoot))}else if(!this._packageManager.updatePlacedAppliedPackages(t,c,N).length)return}get model2d(){return this._targetFloorInput.targetFloor.model2d}get model3d(){return this._targetFloorInput.targetFloor.model3d}get lotIndexes(){const t=[];return this._targetFloorInput.lotPartInputMap.forEach(c=>t.push(c.targetLotPart.lotIndex())),t}get floorIndex(){return this._targetFloorInput.targetFloor.floorIndex()}get buildingIndexes(){return this._targetFloorInput.targetFloor.buildingIndexes()}dispose(){this._parentPropertyState=null,this._targetFloorInput=null,this._layerDirectoryRoot?.dispose(),this._packageManager?.dispose(),this._layerDirectoryRoot=null,this._packageManager=null,this._directLightAreaStates.forEach(t=>t.dispose()),this._directLightAreaStates=null,this._indirectLightAreaStates.forEach(t=>t.dispose()),this._indirectLightAreaStates=null,this._placedAeas.forEach(t=>t.dispose()),this._placedDepartments.forEach(t=>t.dispose()),this._placedModules.forEach(t=>t.dispose()),this._placedAeas=null,this._placedDepartments=null,this._placedModules=null,this._newDirtyables=null}copyFrom(t,c,N){this._parentPropertyState=c,this._targetFloorInput=t._targetFloorInput,this._packageManager.copyFrom(t._packageManager,N.packageProvider);const z=new te.VA;z.elementProvider=c,this._layerDirectoryRoot.initialize(this),this._layerDirectoryRoot.copyFrom(t._layerDirectoryRoot,z),N.floorFullUidNavigableNetworkNodeMap.set(this.applyerFullUid(),z.navigableNetworkNodeMap)}prepareInitialize(t){this._parentPropertyState=t;const c=[{clbk:()=>this._layerDirectoryRoot.initialize(this),label:"Initialize layer directory root"}],N=this._targetFloorInput.targetFloor.stackingPlanInfo();if(!N)return c;c.push(...(N?.directLightAreas||[]).map(we=>({clbk:()=>{const fe=new ts(we,this._targetFloorInput);this._directLightAreaStates.push(fe)},label:"Create direct light area state"})));const z=this._targetFloorInput.targetFloor.stackingPlanInfo()?.cellSize||60,ie=this._targetFloorInput.targetFloor.freeSpaces(),pe=we=>{const fe=this._targetFloorInput.getElementByFullUid(we);if(!fe)return null;const We=je=>je.map(_t=>this._targetFloorInput.getElementByFullUid(_t.startNode).position);return[fe,e.p(We(fe.outerPath),fe.innerPaths.map(We))]};return c.push(...(N?.indirectLightAreas||[]).map(we=>({clbk:()=>{this._indirectLightAreaStates.push(new Cs(z,ie,we.indirectLightShapeUid,we.gridShapeUids.map(pe).filter(fe=>!!fe)))},label:"Create indirect light area state"}))),c}shouldConcludeInitialization(){return!(this._directLightAreaStates.every(t=>t.isEmpty())&&this._indirectLightAreaStates.every(t=>t.isEmpty()))}prepareConcludeInitialization(){const t=[];
1this._directLightAreaStates.forEach(N=>{N.isEmpty()?N.dispose():t.push(N)}),this._directLightAreaStates=t;const c=[];return this._indirectLightAreaStates.forEach(N=>{N.isEmpty()?N.dispose():c.push(N)}),this._indirectLightAreaStates=c,this._directLightAreaStates.map(N=>({clbk:()=>N.concludeInitialization(this._layerDirectoryRoot),label:"Conclude direct light area state initialization"}))}get parentPropertyState(){return this._parentPropertyState}get targetFloorInput(){return this._targetFloorInput}get targetFloor(){return this._targetFloorInput?this._targetFloorInput.targetFloor:null}get layerDirectoryRoot(){return this._layerDirectoryRoot}get packageManager(){return this._packageManager}hasId(t,c){return!(!this._targetFloorInput||!this._targetFloorInput.targetFloor)&&this._targetFloorInput.targetFloor.hasId(t,c)}applyerFullUid(){return this._targetFloorInput&&this._targetFloorInput.targetFloor?this._targetFloorInput.targetFloor.createUid():new E.ph}tryApplyPackage(t,c=null,N=null,z=!1){if(t.packageType()===Xe.WA.ROOT_FLOOR){const we=new J(t.parentProvider(),!1);for(const fe of t.getLotPackageAsList())we.addPackage(fe);we.conclude(),t=we}const[ie,pe]=this._packageManager.tryApplyPackage(t);if(!ie.canApply||(ie.absorbFromApplyer(this,this._layerDirectoryRoot.tryApplyPackage(pe??t),this._parentPropertyState),z))return ie;if(c&&(ie.willRemoveArg.canApply=ie.willRemoveArg.canApply&&ie.canApply,!c(ie.willRemoveArg)))return ie.canApply=!1,ie;for(const we of ie.removeClbks)we();for(const we of ie.addClbks)ie.addResult.absorb(we(ie.addResult.lut));for(const we of ie.packageManagerApplyClbks)we();for(const we of ie.finalizeClbks)we(ie);return ie}tryUnapplyPackage(t,c=null,N=null,z=!1){const[ie,pe]=this._packageManager.tryUnapplyPackage(t);if(!ie.canApply||(ie.absorbFromApplyer(this,this._layerDirectoryRoot.tryUnapplyPackage(pe??t),this._parentPropertyState),z))return ie;if(c&&(ie.willRemoveArg.canApply=ie.willRemoveArg.canApply&&ie.canApply,!c(ie.willRemoveArg)))return ie.canApply=!1,ie;for(const we of ie.removeClbks)we();for(const we of ie.addClbks)ie.addResult.absorb(we(ie.addResult.lut));for(const we of ie.packageManagerApplyClbks)we();for(const we of ie.finalizeClbks)we(ie);return ie}}},96286:(tt,me,P)=>{P.d(me,{S:()=>v});var e=P(21449),E=P(73636),X=P(4516);class O{constructor(){this.packageProvider=null,this.floorFullUidNavigableNetworkNodeMap=new X.me}}class v{constructor(g=null){this._floors=[],this._globalLocked=!1,this._inputData=g}dispose(){this._inputData=null,this._floors.forEach(g=>g.dispose()),this._floors=[],this._programState?.dispose(),this._programState=null}updatePlacedAppliedPackages(g,r,a,n){const l=this._floors.find(p=>p.targetFloor===g);l&&l.updatePlacedAppliedPackages(r,a,n)}concludeDirty(){this._programState.concludeDirty();for(const g of this._floors)g.concludeDirty()}prepareInitialize(g,r){const a=[];return a.push({clbk:()=>{const n=[];this._programState=this._createProgramState();for(const[l,p]of this._inputData.floorContextMap){if(0===p.targetFloor.lotParts().length)continue;const y=this._createFloorState(p);this._floors.push(y),n.push(...y.prepareInitialize(this))}return n},label:"Initialize program and floors"},{clbk:()=>{},label:"Apply Root package"},{clbk:()=>{const n=[];return this._floors.forEach(l=>{l.stackingPlanInfo&&l.shouldConcludeInitialization()?n.push(l):l.dispose()}),this._floors=n,this._floors.map(l=>({clbk:()=>l.prepareConcludeInitialization()}))},label:"Conclude floor initialization"}),g&&a.push({clbk:()=>{},label:"Apply macro package"},{clbk:()=>{},label:"Finalize macro package application"}),a}_consumeSubPackageUid(g){if(g.isNull())return[g,null];const r=new e.ph(g),a=[];let n=1e3;for(;!r.isNull()&&r.parts[0].elementType===e.TE.UID_PART&&n>0;)n-=1,a.push(Number(r.parts[0].id)),r.parts.shift();if(!a.length)return[g,null];const l=a.shift();for(const p of this._floors)if(p.hasId(l,a))return[r,p];return[g,null]}copyFrom(g){this._inputData=g._inputData;const r=new O;for(const a of g._floors){const n=this._createFloorState(a.targetFloorInput);this._floors.push(n),n.copyFrom(a,this,r)}}get inputData(){return this._inputData}get targetProperty(){return this._inputData?.property??null}get floors(){return this._floors}get programState(){return this._programState}get globalLocked(){return this._globalLocked}set globalLocked(g){this._globalLocked=!!g}applyerFullUid(){return new e.ph}tryApplyPackage(g,r=null,a=null){return this._tryApplyPackage(g,r,!0,a)}tryUnapplyPackage(g,r=null,a=null){return this._tryApplyPackage(g,r,!1,a)}_tryApplyPackage(g,r,a,n){const l=new E.m;if(l.canApply=!0,!g.isPackageProvider())throw new Error("UploadPropertyState::try_apply_package can only check package providers");const p=g.getPackages();for(const y of p.subStatePackages){if(y.subStateUid.isNull())continue;const D=this._consumeSubPackageUid(y.subStateUid);if(D[1])for(const Y of y.packages)if(l.absorb(a?D[1].tryApplyPackage(Y,r,void 0,!0):D[1].tryUnapplyPackage(Y,r,void 0,!0)),!l.canApply)return l}if(r&&(l.willRemoveArg.canApply=l.willRemoveArg.canApply&&l.canApply,!r(l.willRemoveArg)))return l.canApply=!1,l;for(const y of l.removeClbks)y();for(const y of l.addClbks)l.addResult.absorb(y(l.addResult.lut));for(const y of l.packageManagerApplyClbks)y();for(const y of l.finalizeClbks)y(l);return l}getElement(g){if(g.isNull())return null;let r=this.targetProperty?.getElement(g);return r??(g.parts[0].elementType===e.TE.PROGRAM_DEPARTMENT||g.parts[0].elementType===e.TE.PROGRAM_MODULE?this._inputData.program.getElement(g):g.parts[0].elementType===e.TE.MODULE?this._inputData.moduleManager.getElement(g):null)}}},76314:(tt,me,P)=>{P.d(me,{q_:()=>v,vC:()=>g});var e=P(47318),E=P(96038);const v=!0;function h(r,a){return r.getX()+r.getY()>.1?r:a}class g{get elementId(){return this._partitionableShapeInfo?.uidInPackage().asElementId()||0}get isFree(){return this._isFreeNoOffsets&&this._isFreeOffsetSet}get isFreeAndActive(){return this.isFree&&this._isActive}get isFullyFree(){return this.isFree&&"number"!=typeof this._beginOffset&&"number"!=typeof this._endOffset}get postInfos(){return this._postInfos}get coveredSpace(){return this._coveredSpace}get startPerpNode(){return this._startPerpNode}get endPerpNode(){return this._endPerpNode}get flowingFromBeginToEndIsPositiveDirection(){return v?this.partitionableShapeInfo.startPerpLineUid.isNull()||this.partitionableShapeInfo.endPerpLineUid.isNull()?!this._startPerpNode:this.partitionableShapeInfo.startPerpLineUid.asElementId()<=this.partitionableShapeInfo.endPerpLineUid.asElementId():this._startPerpNode&&this._endPerpNode?this._startPerpNode.elementId()<=this._endPerpNode.elementId():!this._startPerpNode}get partitionableShapeInfo(){return this._partitionableShapeInfo}get parentDirectLightFragmentStates(){return this._parentDirectLightFragmentStates}get isActive(){return this._isActive}setIsActive(a){this._isActive=a}get beginOffset(){return this._beginOffset}get endOffset(){return this._endOffset}get beginNeighbours(){return this._beginOffset?[]:this._beginNeighbours}get endNeighbours(){return this._endOffset?[]:this._endNeighbours}get width(){return this._partitionableShapeInfo.width-(this._beginOffset||0)-("number"==typeof this._endOffset?this._partitionableShapeInfo.width-this._endOffset:0)}get currentHeight(){return this._currentHeight}get isCorner(){return this._partitionableShapeInfo.type===E.W.CORNER}get sideIsStart(){return this._sideIsStart}get startWidth(){return this._startWidth}get endWidth(){return this._endWidth}get startHeight(){return this._startHeight}get endHeight(){return this._endHeight}get endPostInfos(){return this._endPostInfos}get startSideWidth(){return this._startSideWidth}get endSideWidth(){return this._endSideWidth}get cornerCentroid(){return this._cornerCentroid}get cornerIsInterior(){return this._cornerIsInterior}get startConstructionLine(){return this._startConstructionLine}get endConstructionLine(){return this._endConstructionLine}constructor(a,n,l,p=!1){this.dynamicSectionIdx=n,this.dynamicItemIdx=l,this.isInCorner=p,this._parentDirectLightFragmentStates=[],this._soloPerpNode=null,this._duoPerpNodeWidth=null,this._postInfos=[],this._currentHeight=0,this._isActive=!0,this._beginOffset=null,this._endOffset=null,this._beginNeighbours=[],this._endNeighbours=[],this._isFreeNoOffsets=!0,this._isFreeOffsetSet=!0,this._sideIsStart=null,this._startWidth=null,this._endWidth=null,this._startHeight=null,this._endHeight=null,this._endPostInfos=[],this._startSideWidth=null,this._endSideWidth=null,this._cornerCentroid=null,this._cornerIsInterior=!1,this._startConstructionLine=null,this._endConstructionLine=null,this._flowingFromBeginToEndIsPositiveDirection=!1,this._partitionableShapeInfo=a,this._coveredSpace=e.p()}static width(a,n,l,p){const y="boolean"!=typeof p?a.partitionableShapeInfo.width:p?a._startWidth:a._endWidth;return y-(n||0)-("number"==typeof l?y-l:0)}static height(a,n,l){const p="number"==typeof n?n:0,y=a.partitionableShapeInfo.width-("number"==typeof l?l:0);let D=0,Y=a.partitionableShapeInfo.height;return a._postInfos.forEach(H=>{if(H.offsetH+H.length>=p&&H.offsetH<=y){const ne=Math.abs(H.y-D),K=Math.abs(H.y-Y);ne<K&&H.y>D?D=H.y+H.height:K<ne&&H.y<Y&&(Y=H.y)}}),Math.max(0,Y-D)}static postHeight(a,n){let l=0,p=a;
1return n.forEach(y=>{const D=Math.abs(y.y-l),Y=Math.abs(y.y-p);D<Y&&y.y>l?l=y.y+y.height:Y<D&&y.y<p&&(p=y.y)}),Math.max(0,p-l)}blit(a,n,l=null){if("number"!=typeof a&&"number"!=typeof n)return this._beginOffset=null,this._endOffset=null,this._isFreeNoOffsets=!1,void this._checkFreedom();"number"==typeof a&&a>this._beginOffset&&(this._beginOffset=a),"number"==typeof n&&(null===this._endOffset||n<this._endOffset)&&(this._endOffset=n),this._sideIsStart="boolean"!=typeof this._sideIsStart?l:this._sideIsStart,this._checkFreedom()}unblit(a,n,l=null){if("number"!=typeof a&&"number"!=typeof n)return this._beginOffset=null,this._endOffset=null,this._isFreeNoOffsets=!0,void this._checkFreedom();"number"==typeof a&&(this._beginOffset=null),"number"==typeof n&&(this._endOffset=null),"number"!=typeof this.beginOffset&&"number"!=typeof this.endOffset&&(this._sideIsStart=null),this._checkFreedom()}_checkFreedom(){this._isFreeOffsetSet=!("number"==typeof this._beginOffset&&"number"==typeof this._endOffset||this.width<=.001),this._currentHeight=g.height(this,this._beginOffset,this._endOffset)}isOtherCloseToBegin(a){return a?(this._startPerpNode?e.TE(this._startPerpNode.position,a.coveredSpace):Number.MAX_VALUE)<(this._endPerpNode?e.TE(this._endPerpNode.position,a.coveredSpace):Number.MAX_VALUE):!this.beginNeighbours.length}tryPickCoveredSpace(a){if(this._coveredSpace.isEmpty())for(const[n,l]of a.partitionableLayer.parsedShapes())if(n.equals(this._partitionableShapeInfo.uidInPackage()))return void(this._coveredSpace=l.asPolygon())}dispose(){this._partitionableShapeInfo=null,this._parentDirectLightFragmentStates=[],this._beginNeighbours=[],this._endNeighbours=[]}static _getDuoOffsetRefLine(a,n){if(!a||!n)return null;const l=e.ih(a.normalToInside,!0),p=e.K8(a.position,l,10),y=e.K8(n.position,n.normalToInside,10),D=e.Y8(p,y);if(!D||e.xb(D))return e.uM(a.position,n.position);const Y=e.uM(a.position,D),H=e.uM(a.position,n.position);return e.kE(Y)<e.kE(H)?Y:H}_soloOrDuoSelection(a,n,l,p=null){if(this._partitionableShapeInfo.type===E.W.CORNER){let y="number"==typeof n;return"boolean"==typeof p?p?this._startPerpNode||this._endPerpNode:this._endPerpNode||this._startPerpNode:y==("number"==typeof l)&&"boolean"!=typeof p?this._startPerpNode&&this._endPerpNode&&this._duoPerpNodeWidth&&e.uF(this._startPerpNode.normalToInside,this._endPerpNode.normalToInside,.07)?null:this._soloPerpNode||this._startPerpNode||this._endPerpNode:y?this._startPerpNode||this._endPerpNode:this._endPerpNode||this._startPerpNode}return this._partitionableShapeInfo.type===E.W.CURVED?this._startPerpNode&&this._endPerpNode&&this._duoPerpNodeWidth?null:this._soloPerpNode:this._startPerpNode&&this._endPerpNode&&this._duoPerpNodeWidth&&e.uF(this._startPerpNode.normalToInside,this._endPerpNode.normalToInside,.997)?null:this._soloPerpNode||this._startPerpNode||this._endPerpNode}computePartialCoveredSpace(a,n,l,p,y=!1){const D="boolean"!=typeof p?null:p?this._startWidth:this._endWidth,Y="number"==typeof D?D:Math.max(0,...this._partitionableShapeInfo.partitionableSpans.map(L=>L.endOffset));if(Y<=0)return y?[this._coveredSpace,this._coveredSpace]:this._coveredSpace;const H=this._soloOrDuoSelection(a,n,l,p),ne=H,k="boolean"!=typeof p?null:p?[this._startConstructionLine,this._cornerCentroid]:[this._endConstructionLine,this._cornerCentroid],x=1e6,f=1e6,J=(L,ce,ke)=>{const Xe=e.uI(L,e.SB(ce,f)),te=e.uI(L,e.SB(ce,-f)),ye=e.uI(te,e.SB(ke,x)),Ae=e.uI(Xe,e.SB(ke,x));return e.p([Xe,te,ye,Ae])};if("number"==typeof(H?null:this._duoPerpNodeWidth)){const L=g._getDuoOffsetRefLine(this._startPerpNode,this._endPerpNode),ce=e.kE(L),ke=e.hX(L),Xe=h(this._partitionableShapeInfo.startPerpDir,this._startPerpNode.normalToInside),te=h(this._partitionableShapeInfo.endPerpDir,this._endPerpNode.normalToInside),ye=ee=>e.uI(this._startPerpNode.position,e.SB(ke,ee/Y*ce)),Ae=ee=>{const Z=ee/Y,Q=1-Z;return e.Pu(Xe.x*Q+te.x*Z,Xe.y*Q+te.y*Z)};let Ee=e.lD();if("number"==typeof n){const ee=ye(n),Z=Ae(n);let Q=e.ih(Z,!0);e.rz(Q,ke)>0&&(Q=e.SB(Q,-1));const V=J(ee,Z,Q);Ee=e.Y7(Ee,V)}if("number"==typeof l){const ee=ye(l),Z=Ae(l);let Q=e.ih(Z,!1);e.rz(Q,ke)<0&&(Q=e.SB(Q,-1));const V=J(ee,Z,Q);Ee=e.xb(Ee)?e.Y7(Ee,V):e.m0(Ee,V)}const q=e.oo(this._coveredSpace,Ee),oe=e.b3(a?e.oo(this._coveredSpace,q):q);return y?[oe,oe]:oe}if(ne){const L=e.Sc(this._coveredSpace);let ce=e.hX(e.uM(ne.position,L));const ke="boolean"==typeof p?1:this._partitionableShapeInfo.width/(Y||1);let Xe=null,te=null,ye=null,Ae=null;ne===this._startPerpNode?(ye=h(this._partitionableShapeInfo.startPerpDir,ne.normalToInside),Ae=e.ih(ye,!0),e.rz(Ae,ce)<0&&(Ae=e.SB(Ae,-1)),Xe=ee=>e.uI(ne.position,e.SB(Ae,ee*ke)),te=Ae):(ye=h(this._partitionableShapeInfo.endPerpDir,ne.normalToInside),Ae=e.ih(ye,!0),e.rz(Ae,ce)<0&&(Ae=e.SB(Ae,-1)),Xe=ee=>e.uI(ne.position,e.SB(Ae,(Y-ee)*ke)),te=Ae,v&&!this._startPerpNode&&!this.partitionableShapeInfo.startPerpLineUid.isNull()&&(ce=e.SB(ce,-1)));let Ee=e.lD();if("number"==typeof n){const Q=J(Xe(n),ye,e.rz(te,ce)<0?te:e.SB(te,-1));Ee=e.Y7(Ee,Q)}if("number"==typeof l){const Q=J(Xe(l),ye,e.rz(te,ce)>0?te:e.SB(te,-1));Ee=e.xb(Ee)?e.Y7(Ee,Q):e.m0(Ee,Q)}const q=e.oo(this._coveredSpace,Ee),oe=e.b3(a?e.oo(this._coveredSpace,q):q);if(k){const ee=e.D1(k[1],e.$h(oe,k[0]));return y?[ee,oe]:ee}return y?[oe,oe]:oe}return y?[this._coveredSpace,this._coveredSpace]:this._coveredSpace}getClosestFittingOffset(a,n,l,p=null){if("boolean"==typeof p){const ne=p?this._startWidth:this._endWidth;
1if("number"==typeof ne)return n?a:ne-a}const y=this.partitionableShapeInfo.partitionableSpans,D=Math.max(0,...y.map(ne=>ne.endOffset));if(D<=0)return null;const Y=this._partitionableShapeInfo.width/(D||1),H=n?a/Y:D-a/Y;if(n){for(let ne of y)if((!ne.isWindow||l)&&H<ne.endOffset)return H>=ne.startOffset?H:ne.startOffset}else{const ne=[...y].reverse();for(let K of ne)if((!K.isWindow||l)&&H>=K.startOffset)return H<=K.endOffset?H:K.endOffset}return null}getPostsInRange(a,n,l,p=null){if(!l){const y=a=this.width-a;a=n=this.width-n,n=y}return(!1===p?this._endPostInfos:this._postInfos).filter(y=>{const D=y.x,Y=y.x+y.length;return D>=a&&D<=n||Y>=a&&Y<=n}).map(y=>({...y,inter:Math.min(y.x+y.length,n)-Math.max(y.x,a),bl:y.x-a,el:n-(y.x+y.length)}))}computeOffsetDir(a=null){const n=this._soloOrDuoSelection(!1,this.beginOffset,this.endOffset,a),l=n;if("number"==typeof(n?null:this._duoPerpNodeWidth)){const y=g._getDuoOffsetRefLine(this._startPerpNode,this._endPerpNode);return e.hX(y)}if(l){const y=e.Sc(this._coveredSpace),D=e.hX(e.uM(l.position,y));let Y=null,H=null;return l===this._startPerpNode?(Y=h(this._partitionableShapeInfo.startPerpDir,l.normalToInside),H=e.ih(Y,!0),e.rz(H,D)<0&&(H=e.SB(H,-1))):(Y=h(this._partitionableShapeInfo.endPerpDir,l.normalToInside),H=e.ih(Y,!0),e.rz(H,D)<0&&(H=e.SB(H,-1))),H}return e.Pu(1,0)}getRefP2l(a){const n=this._partitionableShapeInfo,l=this._soloOrDuoSelection(!1,this._beginOffset,this._endOffset,a),p=l?null:this._duoPerpNodeWidth,y=l;let D=Math.max(0,...n.partitionableSpans.map(H=>H.endOffset));D<=0&&(D=n.width);let Y=n.width;if("boolean"==typeof a&&(Y=a?this._startWidth:this._endWidth,"number"!=typeof Y?Y=n.width:D=Y),"number"==typeof p)return g._getDuoOffsetRefLine(this._startPerpNode,this._endPerpNode);if(y){const H=e.ih(y.normalToInside,!0),ne=e.SB(H,-1),K=e.QH(y.position,H,Math.max(D,Y)),k=e.QH(y.position,ne,Math.max(D,Y)),x=e.TE(K,this._coveredSpace),f=e.TE(k,this._coveredSpace);return e.uM(y.position,x<f?e.QH(y.position,H,Math.max(D,Y)-x):e.QH(y.position,ne,Math.max(D,Y)-f))}return null}computeCentroidAndNormalLine(a,n,l,p){const y=this._soloOrDuoSelection(!1,l,p),D=this._partitionableShapeInfo,Y=y?null:this._duoPerpNodeWidth,H=this._startPerpNode,ne=this._endPerpNode,K=y,k=Math.max(0,...D.partitionableSpans.map(ce=>ce.endOffset));if(k<=0)return null;const x=3*D.height,f=this._coveredSpace,J=e.AZ(f),L=(ce,ke)=>{const Xe=e.ix(e.K8(ce,ke,10),x),te=e.pB(Xe,J);let ye=-1,Ae=null;for(let oe=0,ee=te.getNumGeometries();oe<ee;oe++){const Z=te.getGeometryN(oe),Q=e.TE(ce,Z);Q>ye&&(ye=Q,Ae=Z)}if(!Ae)return null;const Ee=e.uM(Ae,ce);if(e.xb(Ee))return null;const q=e.hX(Ee);return[e.uI(Ae,n>0?e.SB(q,n):Ae),Ee]};if("number"==typeof Y){const ce=g._getDuoOffsetRefLine(this._startPerpNode,this._endPerpNode),ke=e.kE(ce),Xe=e.hX(ce),te=h(D.startPerpDir,H.normalToInside),ye=h(D.endPerpDir,ne.normalToInside),Ee=Z=>{const Q=Z/k,V=1-Q;return e.Pu(te.getX()*V+ye.getX()*Q,te.getY()*V+ye.getY()*Q)},ee=L(e.uI(H.position,e.SB(Xe,a/k*ke)),Ee(a));return ee?[...ee,"gray"]:null}if(K){const ce=e.Sc(f),ke=e.hX(e.uM(K.position,ce)),Xe=D.width/(k||1);let te=null,ye=null,Ae=null;if(K===H){ye=h(D.startPerpDir,K.normalToInside),Ae=e.ih(ye,!0),e.rz(Ae,ke)<0&&(Ae=e.SB(Ae,-1)),te=q=>e.uI(K.position,e.SB(Ae,q*Xe));const Ee=L(te(a),ye);return Ee?[...Ee,"red"]:null}{ye=h(D.endPerpDir,K.normalToInside),Ae=e.ih(ye,!0),e.rz(Ae,ke)<0&&(Ae=e.SB(Ae,-1)),te=q=>e.uI(K.position,e.SB(Ae,(k-q)*Xe));const Ee=L(te(a),ye);return Ee?[...Ee,"blue"]:null}}return null}}},51542:(tt,me,P)=>{P.d(me,{Z:()=>E});var e=P(91668);class E{get dirtyState(){return this._dirtyState}set dirtyState(O){this._dirtyState=O}get uid(){return this._uid}get isUserLocked(){return this._isUserLocked}set isUserLocked(O){O!==this._isUserLocked&&(this._isUserLocked=O,this._dirtyState=e.w.DIRTY)}constructor(O){this._dirtyState=e.w.IDLE,this._isUserLocked=!1,this._uid=O}dispose(){}}},52933:(tt,me,P)=>{P.d(me,{Z:()=>E});var e=P(61474);class E extends e.Z{get moduleRequirement(){return this._moduleRequirement}get isPartitioned(){return this._moduleRequirement.module.isPartitioned}constructor(O,v,h){super(O,h),this._moduleRequirement=v}dispose(){this._moduleRequirement=null,super.dispose()}}},61474:(tt,me,P)=>{P.d(me,{Z:()=>E}
1);var e=P(51542);class E extends e.Z{get coveredSpace(){return this._coveredSpace}constructor(O,v){super(O),this._coveredSpace=v}dispose(){super.dispose()}}},91250:(tt,me,P)=>{function e(g,r){const a=r.indirectLightAreaStates.find(n=>n.lightShapeUid.equals(g.indirectLightUid));return a?a.gridStates.get(g.gridUid)??null:null}function E(g,r){const a=[];for(const y of g.getAllSupFragments()){const D=r.directLightAreaStates.find(Y=>Y.directLight.fullUid.equals(y.supAreaFullUid));if(!D)return null;a.push({fragment:y,area:D})}const n=[];for(const y of g.getAllSusFragments()){const D=e(y,r);if(!D)return null;const Y=D.createPolygon(y.bottomLeft,y.topRight);if(!Y)return null;n.push({fragment:y,grid:D,coveredSpace:Y})}let p,l=null;return g.isCoreRoom&&(l=r.coreRoomStates.find(y=>y.isAvailable&&y.targetCoreRoom===g.coreRoom)??null,!l)||!a.length&&!n.length&&!l?null:(p=g.isCoreRoom?g.coreRoom.coveredSpace():g.isSusInfo?n[0].coveredSpace:g.coveredSpace,{supFragments:a,susFragments:n,coreRoomState:l,coveredSpace:p})}function X(g,r){const a=[];for(const p of g.getAllSupFragments()){const y=r.directLightAreaStates.find(D=>D.directLight.fullUid.equals(p.supAreaFullUid));y&&a.push({fragment:p,area:y})}const n=[];for(const p of g.getAllSusFragments()){const y=e(p,r);y&&n.push({fragment:p,grid:y,coveredSpace:null})}let l=null;return g.isCoreRoom&&(l=r.coreRoomStates.find(p=>p.targetCoreRoom===g.coreRoom)??null),{supFragments:a,susFragments:n,coreRoomState:l,coveredSpace:null}}function O(g,r){const a={};for(const{fragment:n,area:l}of g.supFragments){const p=[];for(const y in n.dynamicSectionItemIdxes){const D=n.dynamicSectionItemIdxes[parseInt(y)];p.push(r?l.updateDynamicSectionItem(parseInt(y),D):l.updateDynamicSectionItem(parseInt(y),D,!0))}p.length>0&&(a[n.uid]=p)}return a}function v(g){for(const{fragment:r,area:a}of g.supFragments)a.consumeTiles(r.tileInfos);for(const{fragment:r,grid:a}of g.susFragments)a.blit(r.bottomLeft,r.topRight);return g.coreRoomState?.setIsAvailable(!1),O(g,!0)}function h(g){for(const{fragment:r,area:a}of g.supFragments)a.restoreTiles(r.tileInfos);for(const{fragment:r,grid:a}of g.susFragments)a.unblit(r.bottomLeft,r.topRight);return g.coreRoomState?.setIsAvailable(!0),O(g,!1)}P.d(me,{II:()=>E,Ie:()=>v,M$:()=>h,w1:()=>X})},67399:(tt,me,P)=>{P.d(me,{Z:()=>E});var e=P(91668);class E{get staticOption(){return this._staticOption}get state(){return this._state}get dirtyState(){return this._state?.dirtyState??e.w.IDLE}get name(){return this._staticOption.name}get color(){return this._staticOption.color}get order(){return this._staticOption.order}get requiredCount(){return this._requiredCount}get remainCount(){return this._cachedRemainCount}get requiredSurface(){return this._requiredSurface}get remainingSurface(){return this._cachedRemainingSurface}constructor(O,v){this._staticOption=O,this._state=v,this._state?(this._requiredCount=this._state.officeStates.reduce((h,g)=>h+g.requiredCount*(g.targetRequirement.module.capacity||1),0)+(this._state.openspaceState?.requiredCount||0),this._requiredSurface=this._state.computeRequiredTheoricalArea(),this._updateRemainCount(),this._updateRemainingSurface()):(this._requiredCount=0,this._cachedRemainCount=0,this._requiredSurface=0,this._cachedRemainingSurface=0)}_updateRemainCount(){this._cachedRemainCount=this._state?this._state.officeStates.reduce((O,v)=>O+v.remainingCount*(v.targetRequirement.module.capacity||1),0)+(this._state.openspaceState?.remainingCount||0):0}_updateRemainingSurface(){this._cachedRemainingSurface=this._state?this._state.computeRemainingTheoricalArea():0}update(){this._updateRemainCount(),this._updateRemainingSurface()}dispose(){this._staticOption=null,this._state=null}}},68442:(tt,me,P)=>{P.d(me,{f:()=>v});class e{get staticOption(){return this._staticOption}get type(){return this._staticOption.type}get color(){return this._staticOption.color}constructor(g){this._staticOption=g}dispose(){this._staticOption=null}}var E=P(67399),X=P(36511),O=P(60565);class v{get parentEditionCtx(){return this._parentEditionCtx}get staticOptions(){return this._staticOptions}get newDirtyables(){return this._newDirtyables}get areaOptionStates(){return this._areaOptionStates}get departmentOptionStates(){return this._departmentOptionStates}get meetingOptionStates(){return this._meetingOptionStates}get utilityOptionStates(){return this._utilityOptionStates}updateDepartment(g){const r=this._departmentOptionStates.find(a=>a.staticOption.departmentRequirement.name===g.name);
1r&&r.update()}concludeDirty(){const g=r=>r.map(a=>a.dirtyState===O.w.DELETE?(a.dispose(),null):a).filter(a=>!!a);this._departmentOptionStates=g(this._departmentOptionStates),this._utilityOptionStates=g(this._utilityOptionStates),this._newDirtyables=[]}constructor(g){this._newDirtyables=[],this._areaOptionStates=[],this._departmentOptionStates=[],this._meetingOptionStates=[],this._utilityOptionStates=[],console.debug("[ModelizationOptionManagerState] Creating with parentCtx:",g),console.debug("[ModelizationOptionManagerState] optionManager:",g.optionManager),console.debug("[ModelizationOptionManagerState] optionManager.departmentOptions:",g.optionManager?.departmentOptions),console.debug("[ModelizationOptionManagerState] optionManager.departmentOptions count:",g.optionManager?.departmentOptions?.length),this._parentEditionCtx=g,this._staticOptions=g.optionManager,this._areaOptionStates=this._staticOptions.areaOptions.map(l=>new e(l)),this._departmentOptionStates=this._staticOptions.departmentOptions.map(l=>new E.Z(l,(l=>{const p=g.requirementState.departmentStates.find(y=>y.targetRequirement.name===l.departmentRequirement.name);return console.debug("[ModelizationOptionManagerState] pickDepartmentState for",l.name,":",p),p})(l))),console.debug("[ModelizationOptionManagerState] Created departmentOptionStates:",this._departmentOptionStates.length),this._meetingOptionStates=this._staticOptions.meetingOptions.map(l=>new X.Z(l,(l=>l.isCustom?g.requirementState.customMeetingStates.find(p=>p.targetRequirement.customCapacity===l.customCapacity):g.requirementState.meetingStates.find(p=>p.targetRequirement.module.id===l.moduleDefinition.id))(l))),this._utilityOptionStates=this._staticOptions.utilityOptions.map(l=>new X.Z(l,(l=>l.moduleDefinition.id===g.requirementState.receptionState?.targetRequirement?.module?.id?g.requirementState.receptionState:l.isCustom?g.requirementState.customUtilityStates.find(p=>p.targetRequirement.customName===l.customName||p.targetRequirement.customCapacity===l.customCapacity||p.targetRequirement.customArea===l.customArea):g.requirementState.utilityStates.find(p=>p.targetRequirement.module.id===l.moduleDefinition.id))(l)))}dispose(){this._parentEditionCtx=null,this._staticOptions=null,this._areaOptionStates.forEach(g=>g.dispose()),this._departmentOptionStates.forEach(g=>g.dispose()),this._meetingOptionStates.forEach(g=>g.dispose()),this._utilityOptionStates.forEach(g=>g.dispose()),this._areaOptionStates=null,this._departmentOptionStates=null,this._meetingOptionStates=null,this._utilityOptionStates=null}}},36511:(tt,me,P)=>{P.d(me,{Z:()=>E});var e=P(91668);class E{get staticOption(){return this._staticOption}get state(){return this._state}get dirtyState(){return this._state?.dirtyState??e.w.IDLE}get category(){return this._staticOption.category}get subCategory(){return this._staticOption.subCategory}get customName(){return this._staticOption.customName}get isCustom(){return this._staticOption.isCustom}get moduleName(){return this._staticOption.moduleName}get customOrModuleName(){return this._staticOption.customOrModuleName}get svgId(){return this._staticOption.svgId}get placedCount(){return this._state?.placedCount??0}get requiredCount(){return this._state?.requiredCount??0}get remainCount(){return this._state?.remainingCount??0}get furnitureSize(){return this._staticOption.furnitureSize}get furnitureShape(){return this._staticOption.furnitureShape}constructor(O,v){this._staticOption=O,this._state=v}dispose(){this._staticOption=null,this._state=null}}},22781:(tt,me,P)=>{P.d(me,{Z:()=>E});var e=P(60565);class E{get departmentA(){return this._departmentA}get departmentB(){return this._departmentB}get order(){return this._order}setOrder(O){this._order=O}constructor(O,v){this.dirtyState=e.w.IDLE,this._order=O.priorityOrder,this._departmentA=v.find(h=>h.name===O.departmentA.name),this._departmentB=v.find(h=>h.name===O.departmentB.name)}dispose(){this._departmentA=null,this._departmentB=null}}},38916:(tt,me,P)=>{P.d(me,{Z:()=>E});var e=P(91668);class E{get parentRequirementState(){return this._parentRequirementState}
1get targetRequirement(){return this._targetRequirement}get officeStates(){return this._officeStates}get openspaceState(){return this._openspaceState}get name(){return this._targetRequirement.name}computePlacedWorkstations(O=!1){const v=this._openspaceState?this._openspaceState.placedCount*this._openspaceState.capacity:0,h=this._openspaceState?this._openspaceState.requiredCount*this._openspaceState.capacity:0;return this._officeStates.reduce((g,r)=>{const a=r.placedCount*r.capacity;return g+(O?a:Math.min(a,r.requiredCount*r.capacity))},0)+(O?v:Math.min(v,h))}computeRequiredTheoricalArea(){return this._officeStates.reduce((O,v)=>O+v.requiredTheoricalSqMeters,0)+(this._openspaceState?.requiredTheoricalSqMeters||0)}computeRemainingTheoricalArea(){return this._officeStates.reduce((O,v)=>O+v.remainTheoricalSqMeters,0)+(this._openspaceState?.remainTheoricalSqMeters||0)}constructor(O,v){this.dirtyState=e.w.IDLE,this._officeStates=[],this._openspaceState=null,this._parentRequirementState=v,this._targetRequirement=O,this._officeStates=O.offices.map(h=>this._createOfficeState(h)),this._openspaceState=O.openspace?this._createOpenspaceState(O.openspace):null}dispose(){this._parentRequirementState=null,this._targetRequirement=null,this._openspaceState?.dispose(),this._openspaceState=null,this._officeStates.forEach(O=>O.dispose()),this._officeStates=null}}},48664:(tt,me,P)=>{P.d(me,{Z:()=>E});var e=P(60565);class E{get parentRequirementState(){return this._parentRequirementState}get targetRequirement(){return this._targetRequirement}get capacity(){return this._targetRequirement.module.capacity}get customName(){return this._targetRequirement.customName}get isPartitioned(){return this._targetRequirement.module.isPartitioned}get placedCount(){return this._placedCount}get requiredCount(){return this._targetRequirement.count}get remainingCount(){return Math.max(0,this.requiredCount-this._placedCount)}get requiredTheoricalSqMeters(){return this.requiredCount*(this._targetRequirement.customArea||this._targetRequirement.unitSqMeters)}get remainTheoricalSqMeters(){return this.remainingCount*(this._targetRequirement.customArea||this._targetRequirement.unitSqMeters)}constructor(O,v){this.dirtyState=e.w.IDLE,this._placedCount=0,this._parentRequirementState=v,this._targetRequirement=O}dispose(){this._parentRequirementState=null,this._targetRequirement=null}}},80490:(tt,me,P)=>{P.d(me,{k:()=>E});var e=P(91668);class E{get departmentStates(){return this._departmentStates}get departmentLinkStates(){return this._departmentLinkStates}get receptionState(){return this._receptionState}get meetingStates(){return this._meetingStates}get utilityStates(){return this._utilityStates}get customMeetingStates(){return this._customMeetingStates}get customUtilityStates(){return this._customUtilityStates}get parentPropertyState(){return this._parentPropertyState}get targetProgram(){return this._targetProgram}constructor(O,v){this._departmentStates=[],this._departmentLinkStates=[],this._receptionState=null,this._meetingStates=[],this._utilityStates=[],this._customMeetingStates=[],this._customUtilityStates=[],this._parentPropertyState=O,this._targetProgram=v,this._departmentStates=v.departments.map(h=>this._createDepartmentRequirementState(h)),this._departmentLinkStates=v.departmentLinks.map(h=>this._createDepartmentLinkState(h,this._departmentStates)),v.reception&&(this._receptionState=this._createModuleRequirementState(v.reception)),this._meetingStates=v.meetings.map(h=>this._createModuleRequirementState(h)),this._utilityStates=v.utilities.map(h=>this._createModuleRequirementState(h)),this._customMeetingStates=v.customMeetings.map(h=>this._createModuleRequirementState(h)),this._customUtilityStates=v.customUtilities.map(h=>this._createModuleRequirementState(h))}dispose(){this._parentPropertyState=null,this._targetProgram=null,this._departmentStates.forEach(O=>O.dispose()),this._departmentLinkStates.forEach(O=>O.dispose()),this._receptionState?.dispose(),this._meetingStates.forEach(O=>O.dispose()),this._utilityStates.forEach(O=>
1O.dispose()),this._customMeetingStates.forEach(O=>O.dispose()),this._customUtilityStates.forEach(O=>O.dispose()),this._departmentStates=[],this._departmentLinkStates=[],this._receptionState=null,this._meetingStates=[],this._utilityStates=[],this._customMeetingStates=[],this._customUtilityStates=[]}copyFrom(O,v){this._targetProgram=O._targetProgram,this._parentPropertyState=v}concludeDirty(){const O=v=>v.map(h=>h.dirtyState===e.w.DELETE?(h.dispose(),h):(h.dirtyState=e.w.IDLE,h)).filter(h=>!!h);this._departmentStates=O(this._departmentStates),this._departmentLinkStates=O(this._departmentLinkStates),this._customUtilityStates=O(this._customUtilityStates),this._departmentLinkStates.forEach((v,h)=>v.setOrder(h))}}},36626:(tt,me,P)=>{P.d(me,{Z:()=>X,c:()=>E});var e=P(62831),E=function(O){return O.twoD="2d",O.threeD="3d",O.fourD="4d",O}(E||{});class X{get mode(){return this._mode}constructor(v,h,g,r,a,n,l="macro"){this._mode=l,this._viewer3d=null,this._shownViewer=E.twoD,this._currentFloor=null}show(v){(v=v||(this._shownViewer==E.twoD?E.threeD:E.twoD))==E.twoD?(this._viewer2d.show(),this._viewer3d?.hide()):(this._viewer3d||(this._createViewer3dClbk(),this._createViewer3dClbk=null),this._viewer3d.show(),this._viewer2d.hide()),this._shownViewer=v}switchMode(v){this._mode=v,this._getAllViewerWithShownFirst().forEach(h=>h?.switchMode(v))}switchFloor(v){return this._currentFloor&&e.d.areFloorUIDEquals(v,this._currentFloor)?new Promise(h=>h()):(this._currentFloor=v,this._getAllViewerWithShownFirst().reduceRight((h,g)=>g?(g.switchMode(this._mode),g.switchFloor(v)):h,null))}isFloorActive(v){return this._currentFloor&&e.d.areFloorUIDEquals(this._currentFloor,v)}getFloor(){return this._currentFloor}dispose(){this._getAllViewerWithShownFirst().forEach(v=>v?.dispose())}_getShownViewer(){return this._shownViewer===E.twoD?this._viewer2d:this._viewer3d}_getAllViewerWithShownFirst(){return this._shownViewer==E.twoD?[this._viewer2d,this._viewer3d]:[this._viewer3d,this._viewer2d]}}},61369:(tt,me,P)=>{P.d(me,{Z:()=>E});var e=P(10347);class E{get floorUid(){return this._floorUid}get svg(){return this._svg}get loader(){return this._loader}constructor(O,v){this._svg=new e.G({id:"svg-floor-root"}),this._loader=v,this._floorUid={floorIndex:O.floorIndex,buildingIndexes:O.buildingIndexes,lotIndexes:O?.lotIndexes||[]}}getOrLoad(){return new Promise((O,v)=>{this._svg.children().length?(this._onSvgQueried(this._svg,!1),O(this._svg)):this._loader.queryFloorPlan(this._floorUid).then(h=>{this._onSvgQueried(h,!0),O(this._svg)}).catch(v)})}removeFromParent(){this._svg?.remove()}dispose(){this.removeFromParent()}}},69635:(tt,me,P)=>{P.d(me,{Z:()=>h});var e=P(10347),E=P(47318),X=P(6852),O=P(72569),v=P(82703);class h extends v.Z{get macroSvg(){return this._macroSvg}get microSvg(){return this._microSvg}get microBackgroundSvg(){return this._microBackgroundSvg}constructor(r,a,n=!0){super(a),this._translationService=r,this._macroSvg=new e.G,this._microSvg=new e.G,this._microBackgroundSvg=new e.G,this._svg.add(this._microBackgroundSvg),this._svg.add(this._macroSvg),this._svg.add(this._microSvg),n&&this._draw(!1)}handleDirty(r){this._draw()}_concludeDraw(r){}_drawMacro(r=!0){r&&this._macroSvg.clear();const a=new e.G;a.css("cursor","pointer"),a.attr("data-sf-type","module");try{a.attr("data-node-id",this._moduleUi.placedElementState.uid)}catch{}let n,l=null,p=this._moduleUi.placedElementState.coveredSpace;try{const q=E.ry(this._moduleUi.placedElementState.coveredSpace,E.ZW);"function"==typeof q?.getExteriorRing&&(p=q),"function"==typeof q?.getNumGeometries&&q.getNumGeometries()>0&&"function"!=typeof q.getExteriorRing?(l=E.kW(q,void 0,30),l.addTo(a).fill(this._moduleUi.color)):(n=E.ep(q,30),n.fill(this._moduleUi.color),n.addTo(a))}catch(q){console.warn("drawRoundedPolygon2d failed, using drawPolygon2d",q);const oe=E.ry(this._moduleUi.placedElementState.coveredSpace,E.ZW);"function"==typeof oe?.getNumGeometries&&oe.getNumGeometries()>0&&"function"!=typeof oe.getExteriorRing?(l=E.kW(oe,void 0,30),l.addTo(a).fill(this._moduleUi.color)):(n=E.ep(oe,30),n.fill(this._moduleUi.color),n.addTo(a))}const y=this._moduleUi.placedElementState.moduleRequirement.customName||X.P.transname(this._moduleUi.placedElementState.moduleRequirement.module.names,this._translationService).replace("{customCapacity}",this._moduleUi.placedElementState.moduleRequirement.customCapacity?.toString()),D=E.y3(p),Y=D.getX(),H=D.getY(),ne=this._toRings(this._moduleUi.placedElementState.coveredSpace),K=ne.length?this._polygonAreaRings(ne):0,k=Math.max(0,Math.round(K/1e4)),x=k>0?`${O.l.format(K/1e4)} ${O.l.label}`:"",f=(q,oe,ee,Z,Q,V)=>{let U=ee,re=Z,ae=Q-ee,de=V-Z;if(0!==ae||0!==de){const he=((q-ee)*ae+(oe-Z)*de)/(ae*ae+de*de);he>1?(U=Q,re=V):he>0&&(U=ee+ae*he,re=Z+de*he)}return ae=q-U,de=oe-re,Math.hypot(ae,de)};let J=Number.POSITIVE_INFINITY;if(ne.length)for(let q=0;q<ne.length;q++){const oe=ne[q];for(let ee=0,Z=oe.length-1;ee<oe.length;Z=ee++){const Q=oe[Z],V=oe[ee],U=f(Y,H,Q.x,Q.y,V.x,V.y);U<J&&(J=U)}}const L=Math.max(20,2*(isFinite(J)?J:10)),ce=new e.G,te=(new e.xv).text(y).font({anchor:"middle",fill:"#161411",family:"Space Grotesk",weight:500,size:75});ce.add(te);let ye=null;if(x){const q=k>0?`${O.l.format(K/1e4)} ${O.l.labelBase}`:"";ye=new e.xv,q?(ye.build(!0),ye.tspan(q).font({size:50}),O.l.hasSuperscript&&ye.tspan("2").font({size:Math.round(32.5)}).attr("baseline-shift","super").dy(-7.5),ye.build(!1)):ye.text(x),ye.font({anchor:"middle",fill:"#161411",family:"Space Grotesk",weight:300,size:50}),ce.add(ye)}ce.addTo(a);if(L<350&&ye){const q=-H,oe=(new e.x1).plot(Y-50,q,Y+50,q).stroke({color:"#161411",width:2,opacity:.35});ce.add(oe),te.center(Y,-H-.7*86.25),ye.center(Y,.7*86.25-H)}else te.center(Y,-H-(ye?43.125:0)),ye&&ye.center(Y,43.125-H);a.addTo(this._macroSvg),this._concludeDraw({svg:a,shape:n,multiShape:l})}
1_drawMicroBackground(r=!0){}updateMode(r){switch(r){case"macro":this._macroSvg.show(),this._microBackgroundSvg.hide(),this._microSvg.hide();break;case"micro":this._macroSvg.hide(),this._microBackgroundSvg.show(),this._microSvg.show();break;case"full":this._macroSvg.hide(),this._microBackgroundSvg.hide(),this._microSvg.show()}}_drawMicro(r=!0){}_draw(r=!0){this._drawMacro(r),this._drawMicroBackground(r),this._drawMicro(r)}_toRings(r){const a=n=>({x:Number(n.x??n[0]??0),y:Number(n.y??n[1]??0)});if(!r)return[];if(Array.isArray(r)){if(r.length&&Array.isArray(r[0])&&Array.isArray(r[0][0]))return r[0].map(l=>l.map(a));if(r.length&&Array.isArray(r[0]))return r.map(n=>n.map(a))}return"Polygon"===r?.type&&Array.isArray(r.coordinates)?r.coordinates.map(n=>n.map(a)):[]}_bboxOfRings(r){let a=1/0,n=1/0,l=-1/0,p=-1/0;for(const y of r)for(const D of y)D.x<a&&(a=D.x),D.y<n&&(n=D.y),D.x>l&&(l=D.x),D.y>p&&(p=D.y);return{x:a,y:n,width:Math.max(0,l-a),height:Math.max(0,p-n)}}_polygonAreaRings(r){const a=l=>{let p=0;for(let y=0,D=l.length-1;y<l.length;D=y++)p+=l[D].x*l[y].y-l[y].x*l[D].y;return Math.abs(p)/2};if(!r.length)return 0;let n=a(r[0]);for(let l=1;l<r.length;l++)n-=a(r[l]);return Math.max(0,n)}_pointInRings(r,a){const n=(p,y)=>{let D=!1;for(let Y=0,H=y.length-1;Y<y.length;H=Y++){const ne=y[Y].x,K=y[Y].y,x=y[H].y;K>p.y!=x>p.y&&p.x<(y[H].x-ne)*(p.y-K)/(x-K||1e-12)+ne&&(D=!D)}return D};if(!n(r,a[0]))return!1;for(let p=1;p<a.length;p++)if(n(r,a[p]))return!1;return!0}_rasterizeInside(r,a,n,l){const p=l.width/a,y=l.height/n,D=Array.from({length:n},()=>new Array(a).fill(0));for(let Y=0;Y<n;Y++)for(let H=0;H<a;H++)D[Y][H]=this._pointInRings({x:l.x+(H+.5)*p,y:l.y+(Y+.5)*y},r)?1:0;return{grid:D,dx:p,dy:y}}_largestRectangleInBinary(r){const a=r.length;if(!a)return null;const n=r[0].length;if(!n)return null;const l=new Array(n).fill(0);let p=null;for(let y=0;y<a;y++){for(let Y=0;Y<n;Y++)l[Y]=r[y][Y]?l[Y]+1:0;const D=[];for(let Y=0;Y<=n;Y++){const H=Y===n?0:l[Y];let ne=Y;for(;D.length&&D[D.length-1].height>H;){const{height:K,index:k}=D.pop(),f=K*(Y-k);(!p||f>p.area)&&(p={area:f,top:y-K+1,bottom:y,left:k,right:Y-1}),ne=k}D.push({height:H,index:ne})}}return p}dispose(){super.dispose(),this._translationService=null}}},59851:(tt,me,P)=>{P.d(me,{Z:()=>Q});var e=P(10347),E=function(){return E=Object.assign||function(U){for(var re,ae=1,de=arguments.length;ae<de;ae++)for(var he in re=arguments[ae])Object.prototype.hasOwnProperty.call(re,he)&&(U[he]=re[he]);return U},E.apply(this,arguments)};function X(V,U){for(var re=V.length;re--;)if(V[re].pointerId===U.pointerId)return re;return-1}function O(V,U){var re;if(U.touches){re=0;for(var ae=0,de=U.touches;ae<de.length;ae++){var he=de[ae];he.pointerId=re++,O(V,he)}}else(re=X(V,U))>-1&&V.splice(re,1),V.push(U)}function h(V){for(var re,U=(V=V.slice(0)).pop();re=V.pop();)U={clientX:(re.clientX-U.clientX)/2+U.clientX,clientY:(re.clientY-U.clientY)/2+U.clientY};return U}function g(V){if(V.length<2)return 0;var U=V[0],re=V[1];return Math.sqrt(Math.pow(Math.abs(re.clientX-U.clientX),2)+Math.pow(Math.abs(re.clientY-U.clientY),2))}typeof window<"u"&&(window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),"function"!=typeof window.CustomEvent&&(window.CustomEvent=function(U,re){re=re||{bubbles:!1,cancelable:!1,detail:null};var ae=document.createEvent("CustomEvent");return ae.initCustomEvent(U,re.bubbles,re.cancelable,re.detail),ae}));var r={down:"mousedown",move:"mousemove",up:"mouseup mouseleave"};function a(V,U,re,ae){r[V].split(" ").forEach(function(de){U.addEventListener(de,re,ae)})}function n(V,U,re){r[V].split(" ").forEach(function(ae){U.removeEventListener(ae,re)})}typeof window<"u"&&("function"==typeof window.PointerEvent?r={down:"pointerdown",move:"pointermove",up:"pointerup pointerleave pointercancel"}:"function"==typeof window.TouchEvent&&(r={down:"touchstart",move:"touchmove",up:"touchend touchcancel"}));var p,l=typeof document<"u"&&!!document.documentMode,D=["webkit","moz","ms"],Y={};function H(V){if(Y[V])return Y[V];var U=function y(){return p||(p=document.createElement("div").style)}();if(V in U)return Y[V]=V;for(var re=V[0].toUpperCase()+V.slice(1),ae=D.length;ae--;){var de="".concat(D[ae]).concat(re);if(de in U)return Y[V]=de}}function ne(V,U){return parseFloat(U[H(V)])||0}function K(V,U,re){void 0===re&&(re=window.getComputedStyle(V));var ae="border"===U?"Width":"";return{left:ne("".concat(U,"Left").concat(ae),re),right:ne("".concat(U,"Right").concat(ae),re),top:ne("".concat(U,"Top").concat(ae),re),bottom:ne("".concat(U,"Bottom").concat(ae),re)}}function k(V,U,re){V.style[H(U)]=re}function J(V){var U=V.parentNode,re=window.getComputedStyle(V),ae=window.getComputedStyle(U),de=V.getBoundingClientRect(),he=U.getBoundingClientRect();return{elem:{style:re,width:de.width,height:de.height,top:de.top,bottom:de.bottom,left:de.left,right:de.right,margin:K(V,"margin",re),border:K(V,"border",re)},parent:{style:ae,width:he.width,height:he.height,top:he.top,bottom:he.bottom,left:he.left,right:he.right,padding:K(U,"padding",ae),border:K(U,"border",ae)}}}function ke(V,U){return 1===V.nodeType&&" ".concat(function ce(V){return(V.getAttribute("class")||"").trim()}(V)," ").indexOf(" ".concat(U," "))>-1}var te=/^http:[\w\.\/]+svg$/,Ee={animate:!1,canvas:!1,cursor:"move",disablePan:!1,disableZoom:!1,disableXAxis:!1,disableYAxis:!1,duration:200,easing:"ease-in-out",exclude:[],excludeClass:"panzoom-exclude",handleStartEvent:function(V){V.preventDefault(),V.stopPropagation()},maxScale:4,minScale:.125,overflow:"hidden",panOnlyWhenZoomed:!1,pinchAndPan:!1,relative:!1,setTransform:function f(V,U,re){var ae=U.x,de=U.y,ve=U.isSVG;if(k(V,"transform","scale(".concat(U.scale,") translate(").concat(ae,"px, ").concat(de,"px)")),ve&&l){var be=window.getComputedStyle(V).getPropertyValue("transform");V.setAttribute("transform",be)}},startX:0,startY:0,startScale:1,step:.3,touchAction:"none"};function q(V,U){if(!V)throw new Error("Panzoom requires an element as an argument");
1if(1!==V.nodeType)throw new Error("Panzoom requires an element with a nodeType of 1");if(!function L(V){var U=V.ownerDocument,re=V.parentNode;return U&&re&&9===U.nodeType&&1===re.nodeType&&U.documentElement.contains(re)}(V))throw new Error("Panzoom should be called on elements that have been attached to the DOM");U=E(E({},Ee),U);var re=function ye(V){return te.test(V.namespaceURI)&&"svg"!==V.nodeName.toLowerCase()}(V),ae=V.parentNode;ae.style.overflow=U.overflow,ae.style.userSelect="none",ae.style.touchAction=U.touchAction,(U.canvas?ae:V).style.cursor=U.cursor,V.style.userSelect="none",V.style.touchAction=U.touchAction,k(V,"transformOrigin","string"==typeof U.origin?U.origin:re?"0 0":"50% 50%");var ve=0,be=0,Le=1,Ye=!1;function Te(ge,De,He){if(!He.silent){var rt=new CustomEvent(ge,{detail:De});V.dispatchEvent(rt)}}function Je(ge,De,He){var rt={x:ve,y:be,scale:Le,isSVG:re,originalEvent:He};return requestAnimationFrame(function(){"boolean"==typeof De.animate&&(De.animate?function x(V,U){var re=H("transform");k(V,"transition","".concat(re," ").concat(U.duration,"ms ").concat(U.easing))}(V,De):k(V,"transition","none")),De.setTransform(V,rt,De),Te(ge,rt,De),Te("panzoomchange",rt,De)}),rt}function Qe(ge,De,He,rt){var Ge=E(E({},U),rt),mt={x:ve,y:be,opts:Ge};if(!Ge.force&&(Ge.disablePan||Ge.panOnlyWhenZoomed&&Le===Ge.startScale))return mt;if(ge=parseFloat(ge),De=parseFloat(De),Ge.disableXAxis||(mt.x=(Ge.relative?ve:0)+ge),Ge.disableYAxis||(mt.y=(Ge.relative?be:0)+De),Ge.contain){var dt=J(V),kt=dt.elem.width/Le,ti=dt.elem.height/Le,qt=kt*He,zt=ti*He,Pt=(qt-kt)/2,xt=(zt-ti)/2;if("inside"===Ge.contain){var Jt=(-dt.elem.margin.left-dt.parent.padding.left+Pt)/He,$t=(dt.parent.width-qt-dt.parent.padding.left-dt.elem.margin.left-dt.parent.border.left-dt.parent.border.right+Pt)/He;mt.x=Math.max(Math.min(mt.x,$t),Jt);var Wt=(-dt.elem.margin.top-dt.parent.padding.top+xt)/He,Vt=(dt.parent.height-zt-dt.parent.padding.top-dt.elem.margin.top-dt.parent.border.top-dt.parent.border.bottom+xt)/He;mt.y=Math.max(Math.min(mt.y,Vt),Wt)}else"outside"===Ge.contain&&(Jt=(-(qt-dt.parent.width)-dt.parent.padding.left-dt.parent.border.left-dt.parent.border.right+Pt)/He,$t=(Pt-dt.parent.padding.left)/He,mt.x=Math.max(Math.min(mt.x,$t),Jt),Wt=(-(zt-dt.parent.height)-dt.parent.padding.top-dt.parent.border.top-dt.parent.border.bottom+xt)/He,Vt=(xt-dt.parent.padding.top)/He,mt.y=Math.max(Math.min(mt.y,Vt),Wt))}return Ge.roundPixels&&(mt.x=Math.round(mt.x),mt.y=Math.round(mt.y)),mt}function st(ge,De){var He=E(E({},U),De),rt={scale:Le,opts:He};if(!He.force&&He.disableZoom)return rt;var Ge=U.minScale,mt=U.maxScale;if(He.contain){var dt=J(V),kt=dt.elem.width/Le,ti=dt.elem.height/Le;if(kt>1&&ti>1){var Pt=(dt.parent.width-dt.parent.border.left-dt.parent.border.right)/kt,xt=(dt.parent.height-dt.parent.border.top-dt.parent.border.bottom)/ti;"inside"===U.contain?mt=Math.min(mt,Pt,xt):"outside"===U.contain&&(Ge=Math.max(Ge,Pt,xt))}}return rt.scale=Math.min(Math.max(ge,Ge),mt),rt}function et(ge,De,He,rt){var Ge=Qe(ge,De,Le,He);return ve!==Ge.x||be!==Ge.y?(ve=Ge.x,be=Ge.y,Je("panzoompan",Ge.opts,rt)):{x:ve,y:be,scale:Le,isSVG:re,originalEvent:rt}}function Et(ge,De,He){var rt=st(ge,De),Ge=rt.opts;if(Ge.force||!Ge.disableZoom){ge=rt.scale;var mt=ve,dt=be;if(Ge.focal){var kt=Ge.focal;mt=(kt.x/ge-kt.x/Le+ve*ge)/ge,dt=(kt.y/ge-kt.y/Le+be*ge)/ge}var ti=Qe(mt,dt,ge,{relative:!1,force:!0});return ve=ti.x,be=ti.y,Le=ge,Je("panzoomzoom",Ge,He)}}function lt(ge,De){var He=E(E(E({},U),{animate:!0}),De);return Et(Le*Math.exp((ge?1:-1)*He.step),He)}function I(ge,De,He,rt){var Ge=J(V),mt_width=Ge.parent.width-Ge.parent.padding.left-Ge.parent.padding.right-Ge.parent.border.left-Ge.parent.border.right,mt_height=Ge.parent.height-Ge.parent.padding.top-Ge.parent.padding.bottom-Ge.parent.border.top-Ge.parent.border.bottom,dt=De.clientX-Ge.parent.left-Ge.parent.padding.left-Ge.parent.border.left-Ge.elem.margin.left,kt=De.clientY-Ge.parent.top-Ge.parent.padding.top-Ge.parent.border.top-Ge.elem.margin.top;re||(dt-=Ge.elem.width/Le/2,kt-=Ge.elem.height/Le/2);var ti={x:dt/mt_width*(mt_width*ge),y:kt/mt_height*(mt_height*ge)};return Et(ge,E(E({},He),{animate:!1,focal:ti}),rt)}Et(U.startScale,{animate:!1,force:!0}),setTimeout(function(){et(U.startX,U.startY,{animate:!1,force:!0})});var o,s,u,S,T,F,$=[];function ue(ge){if(!function Xe(V,U){for(var re=V;null!=re;re=re.parentNode)if(ke(re,U.excludeClass)||U.exclude.indexOf(re)>-1)return!0;return!1}(ge.target,U)){O($,ge),Ye=!0,U.handleStartEvent(ge),o=ve,s=be,Te("panzoomstart",{x:ve,y:be,scale:Le,isSVG:re,originalEvent:ge},U);var De=h($);u=De.clientX,S=De.clientY,T=Le,F=g($)}}function Ie(ge){if(Ye&&void 0!==o&&void 0!==s&&void 0!==u&&void 0!==S){O($,ge);var De=h($),He=$.length>1,rt=Le;He&&(0===F&&(F=g($)),I(rt=st((g($)-F)*U.step/80+T).scale,De,{animate:!1},ge)),(!He||U.pinchAndPan)&&et(o+(De.clientX-u)/rt,s+(De.clientY-S)/rt,{animate:!1},ge)}}function Pe(ge){1===$.length&&Te("panzoomend",{x:ve,y:be,scale:Le,isSVG:re,originalEvent:ge},U),function v(V,U){if(U.touches)for(;V.length;)V.pop();else{var re=X(V,U);re>-1&&V.splice(re,1)}}($,ge),Ye&&(Ye=!1,o=s=u=S=void 0)}var Ce=!1;function Ue(){Ce||(Ce=!0,a("down",U.canvas?ae:V,ue),a("move",document,Ie,{passive:!0}),a("up",document,Pe,{passive:!0}))}return U.noBind||Ue(),{bind:Ue,destroy:function Re(){Ce=!1,n("down",U.canvas?ae:V,ue),n("move",document,Ie),n("up",document,Pe)},eventNames:r,getPan:function(){return{x:ve,y:be}},getScale:function(){return Le},getOptions:function(){return function Ae(V){var U={};for(var re in V)V.hasOwnProperty(re)&&(U[re]=V[re]);return U}(U)},handleDown:ue,handleMove:Ie,handleUp:Pe,pan:et,reset:function _(ge){var De=E(E(E({},U),{animate:!0,force:!0}),ge);Le=st(De.startScale,De).scale;var He=Qe(De.startX,De.startY,Le,De);return ve=He.x,be=He.y,Je("panzoomreset",De)},resetStyle:function de(){ae.style.overflow="",ae.style.userSelect="",ae.style.touchAction="",ae.style.cursor="",V.style.cursor="",V.style.userSelect="",V.style.touchAction="",k(V,"transformOrigin","")},setOptions:function he(ge){for(var De in void 0===ge&&(ge={}),ge)ge.hasOwnProperty(De)&&(U[De]=ge[De]);(ge.hasOwnProperty("cursor")||ge.hasOwnProperty("canvas"))&&(ae.style.cursor=V.style.cursor="",(U.canvas?ae:V).style.cursor=U.cursor),ge.hasOwnProperty("overflow")&&(ae.style.overflow=ge.overflow),ge.hasOwnProperty("touchAction")&&(ae.style.touchAction=ge.touchAction,V.style.touchAction=ge.touchAction)},setStyle:function(ge,De){return k(V,ge,De)},zoom:Et,zoomIn:function i(ge){return lt(!0,ge)},zoomOut:function d(ge){return lt(!1,ge)},zoomToPoint:I,zoomWithWheel:function w(ge,De){ge.preventDefault();var He=E(E(E({},U),De),{animate:!1});return I(st(Le*Math.exp(((0===ge.deltaY&&ge.deltaX?ge.deltaX:ge.deltaY)<0?1:-1)*He.step/3),He).scale,ge,He,ge)}}}q.defaultOptions=Ee;class oe{constructor(U,re,ae=!0,de=!0){this._svgTarget=U,this._svgContainer=re,this._canPan=ae,this._canZoom=de,this._panzoom=q(this._svgTarget.node,{excludeClass:"svg-shape",animate:!0,cursor:void 0,disablePan:!this._canPan,disableZoom:!this._canZoom,maxScale:10,minScale:.1,step:.25}),this._svgContainer.addEventListener("wheel",this._panzoom.zoomWithWheel)}onDragStart(U){}onDragMove(U){}onDragEnd(U){}onMouseWheel(U,re){}centerOnBbox(U){if(!U||U.width<=0||U.height<=0)return;const re=this._svgTarget.node;let ae=re.viewBox?.baseVal;if(!ae||ae.width<=0||ae.height<=0){const lt=re.querySelector("svg[viewBox]");lt&&(ae=lt.viewBox?.baseVal)}if(!ae||ae.width<=0||ae.height<=0)try{const lt=re.getBBox();lt.width>0&<.height>0&&(ae=lt)}catch{}const de=this._svgContainer.getBoundingClientRect();if(!ae||ae.width<=0||ae.height<=0)return;
1const Ye=Math.min(de.width/ae.width,de.height/ae.height);this._panzoom.pan((ae.x+ae.width/2-(U.x+U.width/2))*Ye,(ae.y+ae.height/2-(U.y+U.height/2))*Ye,{animate:!0})}reset(){this._panzoom.reset({animate:!0})}}var ee=P(62831);class Q{_preSetup(U){}get hatchPattern(){return this._hatchPattern}constructor(U,re,ae,de,he,ve){this._isShowing=!0,this._floors=[],this._preSetup(he),this._domRoot=de,this._domRootDisplay=de.style.display,this._svgRoot=e.Wj(),this._hatchPattern=this._svgRoot.pattern(50,50,be=>{be.rect(50,50).fill("white").opacity(.5),be.line(-5,-5,55,55).stroke({color:"rgba(157, 157, 157, 1)",linecap:"flat",width:4.5})}),this._svgRoot.addTo(de).size("100%","100%"),this._camera=new oe(this._svgRoot,de,ve?.canPan||!1,ve?.canZoom||!1),this._svgRoot.on("mousedown",be=>this._camera.onDragStart(be)).on("touchstart",be=>this._camera.onDragStart(be)).on("mouseup",be=>this._camera.onDragEnd(be)).on("mouseupoutside",be=>this._camera.onDragEnd(be)).on("touchend",be=>this._camera.onDragEnd(be)).on("touchendoutside",be=>this._camera.onDragEnd(be)).on("mousemove",be=>this._camera.onDragMove(be)).on("touchmove",be=>this._camera.onDragMove(be)).on("mouseleave",be=>this._camera.onDragEnd(be)),de.addEventListener("wheel",be=>this._camera.onMouseWheel(be),!0),this._loader=this._createLoader(re,ae,U,he),this._floors=this._createFloors(re,ae,U,he),this._currentFloor=this._floors[0],this.hide()}show(){this._isShowing||(this._domRoot.style.display=this._domRootDisplay),this._isShowing=!0}hide(){this._isShowing&&(this._domRoot.style.display="none"),this._isShowing=!1}dispose(){this._svgRoot.remove(),this._loader?.dispose(),this._loader=null}switchFloor(U){return new Promise((re,ae)=>{let de=null;for(let he of this._floors)if(ee.d.areFloorUIDEquals(he.floorUid,U)){de=he;break}de?de.getOrLoad().then(he=>{this._currentFloor.removeFromParent(),this._currentFloor=de,he.addTo(this._svgRoot),re()}).catch(ae):ae()})}getSvgRoot(){return this._svgRoot}centerOnBbox(U){this._camera?.centerOnBbox(U)}resetCamera(){this._camera?.reset()}}},31071:(tt,me,P)=>{P.d(me,{Z:()=>O});var e=P(10347),E=P(62831);class X{get url(){return this._url}get shouldLoad(){return!this._isLoading&&!this._isLoaded}constructor(h,g,r,a=!1){this._url=h,this._isRemote=g,this._httpService=r,this._observers=[],this._svg=null,this._isLoading=!1,this._isLoaded=!1,a&&this.load()}load(){this.shouldLoad&&(this._isLoading=!0,this._httpService.fetch2dSvg(this._url,this._isRemote).then(h=>{let g=h;if(h){const r=h.indexOf("<svg");-1!==r&&(g=h.substring(r))}this._svg=e.Wj(g),this._observers.forEach(r=>r(this._svg)),this._observers=[],this._isLoaded=!0,this._isLoading=!1}).catch(h=>{console.error(`Error while loading: ${this._url}: ${h}`,this),this._observers.forEach(g=>g(this._svg)),this._observers=[],this._isLoaded=!0,this._isLoading=!1}))}bindObserver(h){this._isLoaded?h(this._svg):this._observers.push(h)}}let O=(()=>{class v{static#e=this.Binding=X;constructor(g,r,a,n=null,l=null){this._httpService=g,this._floorPlans=[],this._furnitureProps={},this._partitions={},r.forEach(p=>{console.debug("Creating binding for floor",p);let y=new X(p.model2d,!0,this._httpService,E.d.areFloorUIDEquals(a,p));this._floorPlans.push({floorUid:p,binding:y})}),n&&n.furnitures.forEach(p=>{this._furnitureProps[p.id]=new v.Binding(p.model2d.url,!0,this._httpService)}),l&&l.materials.forEach(p=>{this._partitions[p.corner.id]=new v.Binding(p.corner.svg,!1,this._httpService),this._partitions[p.door.id]=new v.Binding(p.door.svg,!1,this._httpService),this._partitions[p.main.id]=new v.Binding(p.main.svg,!1,this._httpService)})}queryFloorPlan(g){return new Promise((r,a)=>{for(let n of this._floorPlans)if(E.d.areFloorUIDEquals(n.floorUid,g)){n.binding.bindObserver(l=>{l?r(l):a()}),n.binding.shouldLoad&&n.binding.load();break}})}queryFurnitureProp(g,r){const a=this._furnitureProps[g];a?(a.bindObserver(r),a.shouldLoad&&a.load()):console.error("Cannot query non-existing prop",g)}queryPartitionPanel(g,r){const a=this._partitions[g];a?(a.bindObserver(r),a.shouldLoad&&a.load()):console.error("Cannot query non-existing partition",g)}dispose(){}}return v})()},82657:(tt,me,P)=>{P.d(me,{Z:()=>X});var e=P(74617),E=P(47318);class X{get floorUid(){return this._floorUid}get controlsTargetPoint(){return this._controlsTargetPoint}get controlsTargetSize(){return this._controlsTargetSize}get entranceDoorPerp(){return this._entranceDoorPerp}get entranceRayOrigin(){return this._entranceRayOrigin}get unselectedLotCoveredSpaces(){return this._unselectedLotCoveredSpaces}updateControlsTargetFromModel(v){const h=(new e.ZzF).setFromObject(v);h.isEmpty()||(h.getCenter(this._controlsTargetPoint),this._controlsTargetPoint.y=0,h.getSize(this._controlsTargetSize))}updateInstanceMatrixes(){}displayMacroView(){}displayMicroView(){}displayFullView(){}constructor(v,h){this._model=null,this._controlsTargetPoint=new e.Pa4,this._controlsTargetSize=new e.Pa4(10,10,10),this._entranceDoorPerp=null,this._entranceRayOrigin=null,this._unselectedLotCoveredSpaces=E.lD(),this._loader3d=h,this._floorUid={floorIndex:v.floorIndex,buildingIndexes:v.buildingIndexes,lotIndexes:v.lotIndexes||[]}}getOrLoad(){return new Promise((v,h)=>{this._loader3d.queryFloorPlan(this._floorUid).then(([g,r])=>{this._model?this._onModelQueried(g,!1):(this._onModelQueried(g,!0),this._model=g),v([g,r])}).catch(h)})}removeFromParent(){this._model?.removeFromParent()}dispose(){this._model=null}}},26905:(tt,me,P)=>{P.d(me,{Z:()=>w});var e=P(74617),E=P(47318),X=function(){var o=0,s=document.createElement("div");function u(Ce){return s.appendChild(Ce.dom),Ce}function S(Ce){for(var Ue=0;Ue<s.children.length;Ue++)s.children[Ue].style.display=Ue===Ce?"block":"none";o=Ce}s.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",s.addEventListener("click",function(Ce){Ce.preventDefault(),S(++o%s.children.length)},!1);var T=(performance||Date).now(),F=T,$=0,ue=u(new X.Panel("FPS","#0ff","#002")),Ie=u(new X.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var Pe=u(new X.Panel("MB","#f08","#201"));return S(0),{REVISION:16,dom:s,addPanel:u,showPanel:S,begin:function(){T=(performance||Date).now()},end:function(){$++;var Ce=(performance||Date).now();if(Ie.update(Ce-T,200),Ce>=F+1e3&&(ue.update(1e3*$/(Ce-F),100),F=Ce,$=0,Pe)){var Ue=performance.memory;Pe.update(Ue.usedJSHeapSize/1048576,Ue.jsHeapSizeLimit/1048576)}return Ce},update:function(){T=this.end()},domElement:s,setMode:S}};X.Panel=function(o,s,u){var S=1/0,T=0,F=Math.round,$=F(window.devicePixelRatio||1),ue=80*$,Ie=48*$,Pe=3*$,Ce=2*$,Ue=3*$,Re=15*$,ge=74*$,De=30*$,He=document.createElement("canvas");He.width=ue,He.height=Ie,He.style.cssText="width:80px;height:48px";var rt=He.getContext("2d");return rt.font="bold "+9*$+"px Helvetica,Arial,sans-serif",rt.textBaseline="top",rt.fillStyle=u,rt.fillRect(0,0,ue,Ie),rt.fillStyle=s,rt.fillText(o,Pe,Ce),rt.fillRect(Ue,Re,ge,De),rt.fillStyle=u,rt.globalAlpha=.9,rt.fillRect(Ue,Re,ge,De),{dom:He,update:function(Ge,mt){S=Math.min(S,Ge),T=Math.max(T,Ge),rt.fillStyle=u,rt.globalAlpha=1,rt.fillRect(0,0,ue,Re),rt.fillStyle=s,rt.fillText(F(Ge)+" "+o+" ("+F(S)+"-"+F(T)+")",Pe,Ce),rt.drawImage(He,Ue+$,Re,ge-$,De,Ue,Re,ge-$,De),rt.fillRect(Ue+ge-$,Re,$,De),rt.fillStyle=u,rt.globalAlpha=.9,rt.fillRect(Ue+ge-$,Re,$,F((1-Ge/mt)*De))}}};const O=X;var o,v=Object.freeze({Linear:Object.freeze({None:function(o){return o},In:function(o){return o},Out:function(o){return o},InOut:function(o){return o}}),Quadratic:Object.freeze({In:function(o){return o*o},Out:function(o){return o*(2-o)},InOut:function(o){return(o*=2)<1?.5*o*o:-.5*(--o*(o-2)-1)}}),Cubic:Object.freeze({In:function(o){return o*o*o},Out:function(o){return--o*o*o+1},InOut:function(o){return(o*=2)<1?.5*o*o*o:.5*((o-=2)*o*o+2)}}),Quartic:Object.freeze({In:function(o){return o*o*o*o},Out:function(o){return 1- --o*o*o*o},InOut:function(o){return(o*=2)<1?.5*o*o*o*o:-.5*((o-=2)*o*o*o-2)}}),Quintic:Object.freeze({In:function(o){return o*o*o*o*o},Out:function(o){return--o*o*o*o*o+1},InOut:function(o){return(o*=2)<1?.5*o*o*o*o*o:.5*((o-=2)*o*o*o*o+2)}}),Sinusoidal:Object.freeze({In:function(o){return 1-Math.sin((1-o)*Math.PI/2)},Out:function(o){return Math.sin(o*Math.PI/2)},InOut:function(o){return.5*(1-Math.sin(Math.PI*(.5-o)))}}),Exponential:Object.freeze({In:function(o){return 0===o?0:Math.pow(1024,o-1)}
1,Out:function(o){return 1===o?1:1-Math.pow(2,-10*o)},InOut:function(o){return 0===o?0:1===o?1:(o*=2)<1?.5*Math.pow(1024,o-1):.5*(2-Math.pow(2,-10*(o-1)))}}),Circular:Object.freeze({In:function(o){return 1-Math.sqrt(1-o*o)},Out:function(o){return Math.sqrt(1- --o*o)},InOut:function(o){return(o*=2)<1?-.5*(Math.sqrt(1-o*o)-1):.5*(Math.sqrt(1-(o-=2)*o)+1)}}),Elastic:Object.freeze({In:function(o){return 0===o?0:1===o?1:-Math.pow(2,10*(o-1))*Math.sin(5*(o-1.1)*Math.PI)},Out:function(o){return 0===o?0:1===o?1:Math.pow(2,-10*o)*Math.sin(5*(o-.1)*Math.PI)+1},InOut:function(o){return 0===o?0:1===o?1:(o*=2)<1?-.5*Math.pow(2,10*(o-1))*Math.sin(5*(o-1.1)*Math.PI):.5*Math.pow(2,-10*(o-1))*Math.sin(5*(o-1.1)*Math.PI)+1}}),Back:Object.freeze({In:function(o){var s=1.70158;return 1===o?1:o*o*((s+1)*o-s)},Out:function(o){var s=1.70158;return 0===o?0:--o*o*((s+1)*o+s)+1},InOut:function(o){var s=2.5949095;return(o*=2)<1?o*o*((s+1)*o-s)*.5:.5*((o-=2)*o*((s+1)*o+s)+2)}}),Bounce:Object.freeze({In:function(o){return 1-v.Bounce.Out(1-o)},Out:function(o){return o<1/2.75?7.5625*o*o:o<2/2.75?7.5625*(o-=1.5/2.75)*o+.75:o<2.5/2.75?7.5625*(o-=2.25/2.75)*o+.9375:7.5625*(o-=2.625/2.75)*o+.984375},InOut:function(o){return o<.5?.5*v.Bounce.In(2*o):.5*v.Bounce.Out(2*o-1)+.5}}),generatePow:function(o){return void 0===o&&(o=4),o=(o=o<Number.EPSILON?Number.EPSILON:o)>1e4?1e4:o,{In:function(s){return Math.pow(s,o)},Out:function(s){return 1-Math.pow(1-s,o)},InOut:function(s){return s<.5?Math.pow(2*s,o)/2:(1-Math.pow(2-2*s,o))/2+.5}}}}),h=function(){return performance.now()},g=function(){function o(){this._tweens={},this._tweensAddedDuringUpdate={}}return o.prototype.getAll=function(){var s=this;return Object.keys(this._tweens).map(function(u){return s._tweens[u]})},o.prototype.removeAll=function(){this._tweens={}},o.prototype.add=function(s){this._tweens[s.getId()]=s,this._tweensAddedDuringUpdate[s.getId()]=s},o.prototype.remove=function(s){delete this._tweens[s.getId()],delete this._tweensAddedDuringUpdate[s.getId()]},o.prototype.update=function(s,u){void 0===s&&(s=h()),void 0===u&&(u=!1);var S=Object.keys(this._tweens);if(0===S.length)return!1;for(;S.length>0;){this._tweensAddedDuringUpdate={};for(var T=0;T<S.length;T++){var F=this._tweens[S[T]];F&&!1===F.update(s,!u)&&!u&&delete this._tweens[S[T]]}S=Object.keys(this._tweensAddedDuringUpdate)}return!0},o}(),r={Linear:function(o,s){var u=o.length-1,S=u*s,T=Math.floor(S),F=r.Utils.Linear;return s<0?F(o[0],o[1],S):s>1?F(o[u],o[u-1],u-S):F(o[T],o[T+1>u?u:T+1],S-T)},Bezier:function(o,s){for(var u=0,S=o.length-1,T=Math.pow,F=r.Utils.Bernstein,$=0;$<=S;$++)u+=T(1-s,S-$)*T(s,$)*o[$]*F(S,$);return u},CatmullRom:function(o,s){var u=o.length-1,S=u*s,T=Math.floor(S),F=r.Utils.CatmullRom;return o[0]===o[u]?(s<0&&(T=Math.floor(S=u*(1+s))),F(o[(T-1+u)%u],o[T],o[(T+1)%u],o[(T+2)%u],S-T)):s<0?o[0]-(F(o[0],o[0],o[1],o[1],-S)-o[0]):s>1?o[u]-(F(o[u],o[u],o[u-1],o[u-1],S-u)-o[u]):F(o[T?T-1:0],o[T],o[u<T+1?u:T+1],o[u<T+2?u:T+2],S-T)},Utils:{Linear:function(o,s,u){return(s-o)*u+o},Bernstein:function(o,s){var u=r.Utils.Factorial;return u(o)/u(s)/u(o-s)},Factorial:(o=[1],function(s){var u=1;if(o[s])return o[s];for(var S=s;S>1;S--)u*=S;return o[s]=u,u}),CatmullRom:function(o,s,u,S,T){var F=.5*(u-o),$=.5*(S-s),ue=T*T;return(2*s-2*u+F+$)*(T*ue)+(-3*s+3*u-2*F-$)*ue+F*T+s}}},a=function(){function o(){}return o.nextId=function(){return o._nextId++},o._nextId=0,o}(),n=new g,l=function(){function o(s,u){void 0===u&&(u=n),this._object=s,this._group=u,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=v.Linear.None,this._interpolationFunction=r.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=a.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return o.prototype.getId=function(){return this._id},o.prototype.isPlaying=function(){return this._isPlaying},o.prototype.isPaused=function(){return this._isPaused},o.prototype.getDuration=function(){return this._duration},o.prototype.to=function(s,u){if(void 0===u&&(u=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=s,this._propertiesAreSetUp=!1,this._duration=u<0?0:u,this},o.prototype.duration=function(s){return void 0===s&&(s=1e3),this._duration=s<0?0:s,this},o.prototype.dynamic=function(s){return void 0===s&&(s=!1),this._isDynamic=s,this},o.prototype.start=function(s,u){if(void 0===s&&(s=h()),void 0===u&&(u=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed)for(var S in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(S),this._valuesStart[S]=this._valuesStartRepeat[S];if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=s,this._startTime+=this._delayTime,!this._propertiesAreSetUp||u){if(this._propertiesAreSetUp=!0,!this._isDynamic){var T={};for(var F in this._valuesEnd)T[F]=this._valuesEnd[F];this._valuesEnd=T}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,u)}return this},o.prototype.startFromCurrentValues=function(s){return this.start(s,!0)},o.prototype._setupProperties=function(s,u,S,T,F){for(var $ in S){var ue=s[$],Ie=Array.isArray(ue),Pe=Ie?"array":typeof ue,Ce=!Ie&&Array.isArray(S[$]);if("undefined"!==Pe&&"function"!==Pe){if(Ce){if(0===(Ue=S[$]).length)continue;for(var Re=[ue],ge=0,De=Ue.length;ge<De;ge+=1){var He=this._handleRelativeValue(ue,Ue[ge]);if(isNaN(He)){Ce=!1,console.warn("Found invalid interpolation list. Skipping.");break}Re.push(He)}Ce&&(S[$]=Re)}if("object"!==Pe&&!Ie||!ue||Ce)(typeof u[$]>"u"||F)&&(u[$]=ue),Ie||(u[$]*=1),T[$]=Ce?S[$].slice().reverse():u[$]||0;else{u[$]=Ie?[]:{};var rt=ue;for(var Ge in rt)u[$][Ge]=rt[Ge];T[$]=Ie?[]:{};var Ue=S[$];if(!this._isDynamic){var mt={};for(var Ge in Ue)mt[Ge]=Ue[Ge];S[$]=Ue=mt}this._setupProperties(rt,u[$],Ue,T[$],F)}}}},o.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},o.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},o.prototype.pause=function(s){return void 0===s&&(s=h()),this._isPaused||!this._isPlaying||(this._isPaused=!0,this._pauseStart=s,this._group&&this._group.remove(this)),this},o.prototype.resume=function(s){return void 0===s&&(s=h()),this._isPaused&&this._isPlaying?(this._isPaused=!1,this._startTime+=s-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this):this},o.prototype.stopChainedTweens=function(){for(var s=0,u=this._chainedTweens.length;s<u;s++)this._chainedTweens[s].stop();return this},o.prototype.group=function(s){return void 0===s&&(s=n),this._group=s,this},o.prototype.delay=function(s){return void 0===s&&(s=0),this._delayTime=s,this},o.prototype.repeat=function(s){return void 0===s&&(s=0),this._initialRepeat=s,this._repeat=s,this},o.prototype.repeatDelay=function(s){return this._repeatDelayTime=s,this},o.prototype.yoyo=function(s){return void 0===s&&(s=!1),this._yoyo=s,this},o.prototype.easing=function(s){return void 0===s&&(s=v.Linear.None),this._easingFunction=s,this},o.prototype.interpolation=function(s){return void 0===s&&(s=r.Linear),this._interpolationFunction=s,this},o.prototype.chain=function(){for(var s=[],u=0;u<arguments.length;u++)s[u]=arguments[u];return this._chainedTweens=s,this},o.prototype.onStart=function(s){return this._onStartCallback=s,this},o.prototype.onEveryStart=function(s){return this._onEveryStartCallback=s,this},o.prototype.onUpdate=function(s){return this._onUpdateCallback=s,this},o.prototype.onRepeat=function(s){return this._onRepeatCallback=s,this},o.prototype.onComplete=function(s){return this._onCompleteCallback=s,this},o.prototype.onStop=function(s){return this._onStopCallback=s,this},o.prototype.update=function(s,u){var S;if(void 0===s&&(s=h()),void 0===u&&(u=!0),this._isPaused)return!0;
1if(!this._goToEnd&&!this._isPlaying){if(s>this._startTime+this._duration)return!1;u&&this.start(s,!0)}if(this._goToEnd=!1,s<this._startTime)return!0;!1===this._onStartCallbackFired&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),!1===this._onEveryStartCallbackFired&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var F=s-this._startTime,$=this._duration+(null!==(S=this._repeatDelayTime)&&void 0!==S?S:this._delayTime),Ie=this._calculateElapsedPortion(F,$,this._duration+this._repeat*$),Pe=this._easingFunction(Ie),Ce=this._calculateCompletionStatus(F,$);if("repeat"===Ce&&this._processRepetition(F,$),this._updateProperties(this._object,this._valuesStart,this._valuesEnd,Pe),"about-to-repeat"===Ce&&this._processRepetition(F,$),this._onUpdateCallback&&this._onUpdateCallback(this._object,Ie),"repeat"===Ce||"about-to-repeat"===Ce)this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1;else if("completed"===Ce){this._isPlaying=!1,this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var Ue=0,Re=this._chainedTweens.length;Ue<Re;Ue++)this._chainedTweens[Ue].start(this._startTime+this._duration,!1)}return"completed"!==Ce},o.prototype._calculateElapsedPortion=function(s,u,S){if(0===this._duration||s>S)return 1;var F=Math.min(s%u/this._duration,1);return 0===F&&0!==s&&s%this._duration==0?1:F},o.prototype._calculateCompletionStatus=function(s,u){return 0!==this._duration&&s<this._duration?"playing":this._repeat<=0?"completed":s===this._duration?"about-to-repeat":"repeat"},o.prototype._processRepetition=function(s,u){var S=Math.min(Math.trunc((s-this._duration)/u)+1,this._repeat);for(var T in isFinite(this._repeat)&&(this._repeat-=S),this._valuesStartRepeat){var F=this._valuesEnd[T];!this._yoyo&&"string"==typeof F&&(this._valuesStartRepeat[T]=this._valuesStartRepeat[T]+parseFloat(F)),this._yoyo&&this._swapEndStartRepeatValues(T),this._valuesStart[T]=this._valuesStartRepeat[T]}this._yoyo&&(this._reversed=!this._reversed),this._startTime+=u*S},o.prototype._updateProperties=function(s,u,S,T){for(var F in S)if(void 0!==u[F]){var $=u[F]||0,ue=S[F],Ie=Array.isArray(s[F]),Pe=Array.isArray(ue);!Ie&&Pe?s[F]=this._interpolationFunction(ue,T):"object"==typeof ue&&ue?this._updateProperties(s[F],$,ue,T):"number"==typeof(ue=this._handleRelativeValue($,ue))&&(s[F]=$+(ue-$)*T)}},o.prototype._handleRelativeValue=function(s,u){return"string"!=typeof u?u:"+"===u.charAt(0)||"-"===u.charAt(0)?s+parseFloat(u):parseFloat(u)},o.prototype._swapEndStartRepeatValues=function(s){var u=this._valuesStartRepeat[s],S=this._valuesEnd[s];this._valuesStartRepeat[s]="string"==typeof S?this._valuesStartRepeat[s]+parseFloat(S):this._valuesEnd[s],this._valuesEnd[s]=u},o}(),D=n,k=(D.getAll.bind(D),D.removeAll.bind(D),D.add.bind(D),D.remove.bind(D),D.update.bind(D)),f=P(56424),J=P(90234);class L{constructor(s,u,S,T,F="div"){this.parent=s,this.object=u,this.property=S,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement("div"),this.domElement.classList.add("controller"),this.domElement.classList.add(T),this.$name=document.createElement("div"),this.$name.classList.add("name"),L.nextNameID=L.nextNameID||0,this.$name.id="lil-gui-name-"+ ++L.nextNameID,this.$widget=document.createElement(F),this.$widget.classList.add("widget"),this.$disable=this.$widget,this.domElement.appendChild(this.$name),this.domElement.appendChild(this.$widget),this.parent.children.push(this),this.parent.controllers.push(this),this.parent.$children.appendChild(this.domElement),this._listenCallback=this._listenCallback.bind(this),this.name(S)}name(s){return this._name=s,this.$name.innerHTML=s,this}onChange(s){return this._onChange=s,this}_callOnChange(){this.parent._callOnChange(this),void 0!==this._onChange&&this._onChange.call(this,this.getValue()),this._changed=!0}onFinishChange(s){return this._onFinishChange=s,this}_callOnFinishChange(){this._changed&&(this.parent._callOnFinishChange(this),void 0!==this._onFinishChange&&this._onFinishChange.call(this,this.getValue())),this._changed=!1}reset(){return this.setValue(this.initialValue),this._callOnFinishChange(),this}enable(s=!0){return this.disable(!s)}disable(s=!0){return s===this._disabled||(this._disabled=s,this.domElement.classList.toggle("disabled",s),this.$disable.toggleAttribute("disabled",s)),this}show(s=!0){return this._hidden=!s,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}options(s){const u=this.parent.add(this.object,this.property,s);return u.name(this._name),this.destroy(),u}min(s){return this}max(s){return this}step(s){return this}decimals(s){return this}listen(s=!0){return this._listening=s,void 0!==this._listenCallbackID&&(cancelAnimationFrame(this._listenCallbackID),this._listenCallbackID=void 0),this._listening&&this._listenCallback(),this}_listenCallback(){this._listenCallbackID=requestAnimationFrame(this._listenCallback);const s=this.save();s!==this._listenPrevValue&&this.updateDisplay(),this._listenPrevValue=s}getValue(){return this.object[this.property]}setValue(s){return this.object[this.property]=s,this._callOnChange(),this.updateDisplay(),this}updateDisplay(){return this}load(s){return this.setValue(s),this._callOnFinishChange(),this}save(){return this.getValue()}destroy(){this.listen(!1),this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.controllers.splice(this.parent.controllers.indexOf(this),1),this.parent.$children.removeChild(this.domElement)}}class ce extends L{constructor(s,u,S){super(s,u,S,"boolean","label"),this.$input
vendor: 4,238 bytes, line 1
1=document.createElement("input"),this.$input.setAttribute("type","checkbox"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$input.addEventListener("change",()=>{this.setValue(this.$input.checked),this._callOnFinishChange()}),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.checked=this.getValue(),this}}function ke(o){let s,u;return(s=o.match(/(#|0x)?([a-f0-9]{6})/i))?u=s[2]:(s=o.match(/rgb\(\s*(\d*)\s*,\s*(\d*)\s*,\s*(\d*)\s*\)/))?u=parseInt(s[1]).toString(16).padStart(2,0)+parseInt(s[2]).toString(16).padStart(2,0)+parseInt(s[3]).toString(16).padStart(2,0):(s=o.match(/^#?([a-f0-9])([a-f0-9])([a-f0-9])$/i))&&(u=s[1]+s[1]+s[2]+s[2]+s[3]+s[3]),!!u&&"#"+u}const Xe={isPrimitive:!0,match:o=>"string"==typeof o,fromHexString:ke,toHexString:ke},te={isPrimitive:!0,match:o=>"number"==typeof o,fromHexString:o=>parseInt(o.substring(1),16),toHexString:o=>"#"+o.toString(16).padStart(6,0)},ye={isPrimitive:!1,match:Array.isArray,fromHexString(o,s,u=1){const S=te.fromHexString(o);s[0]=(S>>16&255)/255*u,s[1]=(S>>8&255)/255*u,s[2]=(255&S)/255*u},toHexString:([o,s,u],S=1)=>te.toHexString(o*(S=255/S)<<16^s*S<<8^u*S<<0)},Ae={isPrimitive:!1,match:o=>Object(o)===o,fromHexString(o,s,u=1){const S=te.fromHexString(o);s.r=(S>>16&255)/255*u,s.g=(S>>8&255)/255*u,s.b=(255&S)/255*u},toHexString:({r:o,g:s,b:u},S=1)=>te.toHexString(o*(S=255/S)<<16^s*S<<8^u*S<<0)},Ee=[Xe,te,ye,Ae];class q extends L{constructor(s,u,S,T){var F;super(s,u,S,"color"),this.$input=document.createElement("input"),this.$input.setAttribute("type","color"),this.$input.setAttribute("tabindex",-1),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$text=document.createElement("input"),this.$text.setAttribute("type","text"),this.$text.setAttribute("spellcheck","false"),this.$text.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$display.appendChild(this.$input),this.$widget.appendChild(this.$display),this.$widget.appendChild(this.$text),this._format=(F=this.initialValue,Ee.find($=>$.match(F))),this._rgbScale=T,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener("input",()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$text.addEventListener("input",()=>{const $=ke(this.$text.value);$&&this._setValueFromHexString($)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(s){if(this._format.isPrimitive){const u=this._format.fromHexString(s);this.setValue(u)}else this._format.fromHexString(s,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(s){return this._setValueFromHexString(s),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}}class oe extends L{constructor(s,u,S){super(s,u,S,"function"),this.$button=document.createElement("button"),this.$button.appendChild(this.$name),this.$widget.appendChild(this.$button),this.$button.addEventListener("click",T=>{T.preventDefault(),this.getValue().call(this.object)}),this.$button.addEventListener("touchstart",()=>{},{passive:!0}),this.$disable=this.$button}}class ee extends L{constructor(s,u,S,T,F,$){super(s,u,S,"number"),this._initInput(),this.min(T),this.max(F);const ue=void 0!==$;this.step(ue?$:this._getImplicitStep(),ue),this.updateDisplay()}decimals(s){return this._decimals=s,this.updateDisplay(),this}min(s){return this._min=s,this._onUpdateMinMax(),this}max(s){return this._max=s,this._onUpdateMinMax(),this}step(s,u=!0){return this._step=s,this._stepExplicit=u,this}updateDisplay(){const s=this.getValue();
1if(this._hasSlider){let u=(s-this._min)/(this._max-this._min);u=Math.max(0,Math.min(u,1)),this.$fill.style.width=100*u+"%"}return this._inputFocused||(this.$input.value=void 0===this._decimals?s:s.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$disable=this.$input;const s=Ce=>{const Ue=parseFloat(this.$input.value);isNaN(Ue)||(this._snapClampSetValue(Ue+Ce),this.$input.value=this.getValue())};let u,S,T,F,$,ue=!1;const Ie=Ce=>{if(ue){const Ue=Ce.clientX-u;Math.abs(Ce.clientY-S)>5?(Ce.preventDefault(),this.$input.blur(),ue=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(Ue)>5&&Pe()}ue||($-=(Ce.clientY-T)*this._step*this._arrowKeyMultiplier(Ce),F+$>this._max?$=this._max-F:F+$<this._min&&($=this._min-F),this._snapClampSetValue(F+$)),T=Ce.clientY},Pe=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",Ie),window.removeEventListener("mouseup",Pe)};this.$input.addEventListener("input",()=>{let Ce=parseFloat(this.$input.value);isNaN(Ce)||(this._stepExplicit&&(Ce=this._snap(Ce)),this.setValue(this._clamp(Ce)))}),this.$input.addEventListener("keydown",Ce=>{"Enter"===Ce.code&&this.$input.blur(),"ArrowUp"===Ce.code&&(Ce.preventDefault(),s(this._step*this._arrowKeyMultiplier(Ce))),"ArrowDown"===Ce.code&&(Ce.preventDefault(),s(this._step*this._arrowKeyMultiplier(Ce)*-1))}),this.$input.addEventListener("wheel",Ce=>{this._inputFocused&&(Ce.preventDefault(),s(this._step*this._normalizeMouseWheel(Ce)))},{passive:!1}),this.$input.addEventListener("mousedown",Ce=>{u=Ce.clientX,S=T=Ce.clientY,ue=!0,F=this.getValue(),$=0,window.addEventListener("mousemove",Ie),window.addEventListener("mouseup",Pe)}),this.$input.addEventListener("focus",()=>{this._inputFocused=!0}),this.$input.addEventListener("blur",()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()})}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const s=Re=>{const ge=this.$slider.getBoundingClientRect();let De=(Re-(rt=ge.left))/(ge.right-rt)*(this._max-(mt=this._min))+mt;var rt,mt;this._snapClampSetValue(De)},u=Re=>{s(Re.clientX)},S=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",u),window.removeEventListener("mouseup",S)};let T,F,$=!1;const ue=Re=>{Re.preventDefault(),this._setDraggingStyle(!0),s(Re.touches[0].clientX),$=!1},Ie=Re=>{if($){const De=Re.touches[0].clientY-F;Math.abs(Re.touches[0].clientX-T)>Math.abs(De)?ue(Re):(window.removeEventListener("touchmove",Ie),window.removeEventListener("touchend",Pe))}else Re.preventDefault(),s(Re.touches[0].clientX)},Pe=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",Ie),window.removeEventListener("touchend",Pe)},Ce=this._callOnFinishChange.bind(this);let Ue;this.$slider.addEventListener("mousedown",Re=>{this._setDraggingStyle(!0),s(Re.clientX),window.addEventListener("mousemove",u),window.addEventListener("mouseup",S)}),this.$slider.addEventListener("touchstart",Re=>{Re.touches.length>1||(this._hasScrollBar?(T=Re.touches[0].clientX,F=Re.touches[0].clientY,$=!0):ue(Re),window.addEventListener("touchmove",Ie,{passive:!1}),window.addEventListener("touchend",Pe))},{passive:!1}),this.$slider.addEventListener("wheel",Re=>{if(Math.abs(Re.deltaX)<Math.abs(Re.deltaY)&&this._hasScrollBar)return;Re.preventDefault();const ge=this._normalizeMouseWheel(Re)*this._step;this._snapClampSetValue(this.getValue()+ge),this.$input.value=this.getValue(),clearTimeout(Ue),Ue=setTimeout(Ce,400)},{passive:!1})}_setDraggingStyle(s,u="horizontal"){this.$slider&&this.$slider.classList.toggle("active",s),document.body.classList.toggle("lil-gui-dragging",s),document.body.classList.toggle("lil-gui-"+u,s)}_getImplicitStep(){return this._hasMin&&this._hasMax?(this._max-this._min)/1e3:.1}
vendor: 5,436 bytes, line 1
1_onUpdateMinMax(){!this._hasSlider&&this._hasMin&&this._hasMax&&(this._stepExplicit||this.step(this._getImplicitStep(),!1),this._initSlider(),this.updateDisplay())}_normalizeMouseWheel(s){let{deltaX:u,deltaY:S}=s;return Math.floor(s.deltaY)!==s.deltaY&&s.wheelDelta&&(u=0,S=-s.wheelDelta/120,S*=this._stepExplicit?1:10),u+-S}_arrowKeyMultiplier(s){let u=this._stepExplicit?1:10;return s.shiftKey?u*=10:s.altKey&&(u/=10),u}_snap(s){const u=Math.round(s/this._step)*this._step;return parseFloat(u.toPrecision(15))}_clamp(s){return s<this._min&&(s=this._min),s>this._max&&(s=this._max),s}_snapClampSetValue(s){this.setValue(this._clamp(this._snap(s)))}get _hasScrollBar(){const s=this.parent.root.$children;return s.scrollHeight>s.clientHeight}get _hasMin(){return void 0!==this._min}get _hasMax(){return void 0!==this._max}}class Z extends L{constructor(s,u,S,T){super(s,u,S,"option"),this.$select=document.createElement("select"),this.$select.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this._values=Array.isArray(T)?T:Object.values(T),this._names=Array.isArray(T)?T:Object.keys(T),this._names.forEach(F=>{const $=document.createElement("option");$.innerHTML=F,this.$select.appendChild($)}),this.$select.addEventListener("change",()=>{this.setValue(this._values[this.$select.selectedIndex]),this._callOnFinishChange()}),this.$select.addEventListener("focus",()=>{this.$display.classList.add("focus")}),this.$select.addEventListener("blur",()=>{this.$display.classList.remove("focus")}),this.$widget.appendChild(this.$select),this.$widget.appendChild(this.$display),this.$disable=this.$select,this.updateDisplay()}updateDisplay(){const s=this.getValue(),u=this._values.indexOf(s);return this.$select.selectedIndex=u,this.$display.innerHTML=-1===u?s:this._names[u],this}}class Q extends L{constructor(s,u,S){super(s,u,S,"string"),this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$input.addEventListener("input",()=>{this.setValue(this.$input.value)}),this.$input.addEventListener("keydown",T=>{"Enter"===T.code&&this.$input.blur()}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$widget.appendChild(this.$input),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.value=this.getValue(),this}}let V=!1;class U{constructor({parent:s,autoPlace:u=void 0===s,container:S,width:T,title:F="Controls",injectStyles:$=!0,touchStyles:ue=!0}={}){if(this.parent=s,this.root=s?s.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",Ie=>{"Enter"!==Ie.code&&"Space"!==Ie.code||(Ie.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(F),ue&&this.domElement.classList.add("allow-touch-styles"),this.parent)return this.parent.children.push(this),this.parent.folders.push(this),void this.parent.$children.appendChild(this.domElement);this.domElement.classList.add("root"),!V&&$&&(function(Ie){const Pe=document.createElement("style");Pe.innerHTML='.lil-gui{--background-color:#1f1f1f;--text-color:#ebebeb;--title-background-color:#111;--title-text-color:#ebebeb;--widget-color:#424242;--hover-color:#4f4f4f;--focus-color:#595959;--number-color:#2cc9ff;--string-color:#a2db3c;--font-size:11px;--input-font-size:11px;--font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;--font-family-mono:Menlo,Monaco,Consolas,"Droid Sans Mono",monospace;--padding:4px;--spacing:4px;--widget-height:20px;--name-width:45%;--slider-knob-width:2px;--slider-input-width:27%;--color-input-width:27%;--slider-input-min-width:45px;--color-input-min-width:45px;--folder-indent:7px;--widget-padding:0 0 0 3px;--widget-border-radius:2px;--checkbox-size:calc(var(--widget-height)*0.75);--scrollbar-width:5px;background-color:var(--background-color);color:var(--text-color);font-family:var(--font-family);font-size:var(--font-size);font-style:normal;font-weight:400;line-height:1;text-align:left;touch-action:manipulation;user-select:none;-webkit-user-select:none}.lil-gui,.lil-gui *{box-sizing:border-box;margin:0;padding:0}.lil-gui.root{display:flex;flex-direction:column;width:var(--width,245px)}.lil-gui.root>.title{background:var(--title-background-color);color:var(--title-text-color)}.lil-gui.root>.children{overflow-x:hidden;overflow-y:auto}.lil-gui.root>.children::-webkit-scrollbar{background:var(--background-color);height:var(--scrollbar-width);width:var(--scrollbar-width)}.lil-gui.root>.children::-webkit-scrollbar-thumb{background:var(--focus-color);border-radius:var(--scrollbar-width)}.lil-gui.force-touch-styles{--widget-height:28px;--padding:6px;--spacing:6px;--font-size:13px;--input-font-size:16px;--folder-indent:10px;
1--scrollbar-width:7px;--slider-input-min-width:50px;--color-input-min-width:65px}.lil-gui.autoPlace{max-height:100%;position:fixed;right:15px;top:0;z-index:1001}.lil-gui .controller{align-items:center;display:flex;margin:var(--spacing) 0;padding:0 var(--padding)}.lil-gui .controller.disabled{opacity:.5}.lil-gui .controller.disabled,.lil-gui .controller.disabled *{pointer-events:none!important}.lil-gui .controller>.name{flex-shrink:0;line-height:var(--widget-height);min-width:var(--name-width);padding-right:var(--spacing);white-space:pre}.lil-gui .controller .widget{align-items:center;display:flex;min-height:var(--widget-height);position:relative;width:100%}.lil-gui .controller.string input{color:var(--string-color)}.lil-gui .controller.boolean .widget{cursor:pointer}.lil-gui .controller.color .display{border-radius:var(--widget-border-radius);height:var(--widget-height);position:relative;width:100%}.lil-gui .controller.color input[type=color]{cursor:pointer;height:100%;opacity:0;width:100%}.lil-gui .controller.color input[type=text]{flex-shrink:0;font-family:var(--font-family-mono);margin-left:var(--spacing);min-width:var(--color-input-min-width);width:var(--color-input-width)}.lil-gui .controller.option select{max-width:100%;opacity:0;position:absolute;width:100%}.lil-gui .controller.option .display{background:var(--widget-color);border-radius:var(--widget-border-radius);height:var(--widget-height);line-height:var(--widget-height);max-width:100%;overflow:hidden;padding-left:.55em;padding-right:1.75em;pointer-events:none;position:relative;word-break:break-all}.lil-gui .controller.option .display.active{background:var(--focus-color)}.lil-gui .controller.option .display:after{bottom:0;content:"\u2195";font-family:lil-gui;padding-right:.375em;position:absolute;right:0;top:0}.lil-gui .controller.option .widget,.lil-gui .controller.option select{cursor:pointer}.lil-gui .controller.number input{color:var(--number-color)}.lil-gui .controller.number.hasSlider input{flex-shrink:0;margin-left:var(--spacing);min-width:var(--slider-input-min-width);width:var(--slider-input-width)}.lil-gui .controller.number .slider{background-color:var(--widget-color);border-radius:var(--widget-border-radius);cursor:ew-resize;height:var(--widget-height);overflow:hidden;padding-right:var(--slider-knob-width);touch-action:pan-y;width:100%}.lil-gui .controller.number .slider.active{background-color:var(--focus-color)}.lil-gui .controller.number .slider.active .fill{opacity:.95}.lil-gui .controller.number .fill{border-right:var(--slider-knob-width) solid var(--number-color);box-sizing:content-box;height:100%}.lil-gui-dragging .lil-gui{--hover-color:var(--widget-color)}.lil-gui-dragging *{cursor:ew-resize!important}.lil-gui-dragging.lil-gui-vertical *{cursor:ns-resize!important}.lil-gui .title{--title-height:calc(var(--widget-height) + var(--spacing)*1.25);-webkit-tap-highlight-color:transparent;text-decoration-skip:objects;cursor:pointer;font-weight:600;height:var(--title-height);line-height:calc(var(--title-height) - 4px);outline:none;padding:0 var(--padding)}.lil-gui .title:before{content:"\u25be";display:inline-block;font-family:lil-gui;padding-right:2px}.lil-gui .title:active{background:var(--title-background-color);opacity:.75}.lil-gui.root>.title:focus{text-decoration:none!important}.lil-gui.closed>.title:before{content:"\u25b8"}.lil-gui.closed>.children{opacity:0;transform:translateY(-7px)}.lil-gui.closed:not(.transition)>.children{display:none}.lil-gui.transition>.children{overflow:hidden;pointer-events:none;transition-duration:.3s;transition-property:height,opacity,transform;transition-timing-function:cubic-bezier(.2,.6,.35,1)}.lil-gui .children:empty:before{content:"Empty";display:block;font-style:italic;height:var(--widget-height);line-height:var(--widget-height);margin:var(--spacing) 0;opacity:.5;padding:0 var(--padding)}.lil-gui.root>.children>.lil-gui>.title{border-width:0;border-bottom:1px solid var(--widget-color);border-left:0 solid var(--widget-color);border-right:0 solid var(--widget-color);border-top:1px solid var(--widget-color);transition:border-color .3s}.lil-gui.root>.children>.lil-gui.closed>.title{border-bottom-color:transparent}.lil-gui+.controller{border-top:1px solid var(--widget-color);margin-top:0;padding-top:var(--spacing)}.lil-gui .lil-gui .lil-gui>.title{border:none}.lil-gui .lil-gui .lil-gui>.children{border:none;border-left:2px solid var(--widget-color);margin-left:var(--folder-indent)}.lil-gui .lil-gui .controller{border:none}.lil-gui input{-webkit-tap-highlight-color:transparent;background:var(--widget-color);border:0;border-radius:var(--widget-border-radius);color:var(--text-color);font-family:var(--font-family);font-size:var(--input-font-size);height:var(--widget-height);outline:none;width:100%}.lil-gui input:disabled{opacity:1}.lil-gui input[type=number],.lil-gui input[type=text]{padding:var(--widget-padding)}.lil-gui input[type=number]:focus,.lil-gui input[type=text]:focus{background:var(--focus-color)}.lil-gui input::-webkit-inner-spin-button,.lil-gui input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.lil-gui input[type=number]{-moz-appearance:textfield}.lil-gui input[type=checkbox]{appearance:none;-webkit-appearance:none;border-radius:var(--widget-border-radius);cursor:pointer;height:var(--checkbox-size);text-align:center;width:var(--checkbox-size)}.lil-gui input[type=checkbox]:checked:before{content:"\u2713";font-family:lil-gui;font-size:var(--checkbox-size);line-height:var(--checkbox-size)}.lil-gui button{-webkit-tap-highlight-color:transparent;background:var(--widget-color);border:1px solid var(--widget-color);border-radius:var(--widget-border-radius);color:var(--text-color);cursor:pointer;font-family:var(--font-family);font-size:var(--font-size);height:var(--widget-height);line-height:calc(var(--widget-height) - 4px);outline:none;text-align:center;text-transform:none;width:100%}.lil-gui button:active{background:var(--focus-color)}@font-face{font-family:lil-gui;src:url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y
17HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff")}@media (pointer:coarse){.lil-gui.allow-touch-styles{--widget-height:28px;--padding:6px;--spacing:6px;--font-size:13px;--input-font-size:16px;--folder-indent:10px;--scrollbar-width:7px;--slider-input-min-width:50px;--color-input-min-width:65px}}@media (hover:hover){.lil-gui .controller.color .display:hover:before{border:1px solid #fff9;border-radius:var(--widget-border-radius);bottom:0;content:" ";display:block;left:0;position:absolute;right:0;top:0}.lil-gui .controller.option .display.focus{background:var(--focus-color)}.lil-gui .controller.option .widget:hover .display{background:var(--hover-color)}.lil-gui .controller.number .slider:hover{background-color:var(--hover-color)}body:not(.lil-gui-dragging) .lil-gui .title:hover{background:var(--title-background-color);opacity:.85}.lil-gui .title:focus{text-decoration:underline var(--focus-color)}.lil-gui input:hover{background:var(--hover-color)}.lil-gui input:active{background:var(--focus-color)}.lil-gui input[type=checkbox]:focus{box-shadow:inset 0 0 0 1px var(--focus-color)}.lil-gui button:hover{background:var(--hover-color);border-color:var(--hover-color)}.lil-gui button:focus{border-color:var(--focus-color)}}';const Ce=document.querySelector("head link[rel=stylesheet], head style");Ce?document.head.insertBefore(Pe,Ce):document.head.appendChild(Pe)}(),V=!0),S?S.appendChild(this.domElement):u&&(this.domElement.classList.add("autoPlace"),document.body.appendChild(this.domElement)),T&&this.domElement.style.setProperty("--width",T+"px"),this.domElement.addEventListener("keydown",Ie=>Ie.stopPropagation()),this.domElement.addEventListener("keyup",Ie=>Ie.stopPropagation())}add(s,u,S,T,F){if(Object(S)===S)return new Z(this,s,u,S);const $=s[u];switch(typeof $){case"number":return new ee(this,s,u,S,T,F);case"boolean":return new ce(this,s,u);case"string":return new Q(this,s,u);case"function":return new oe(this,s,u)}console.error("gui.add failed\n\tproperty:",u,"\n\tobject:",s,"\n\tvalue:",$)}addColor(s,u,S=1){return new q(this,s,u,S)}addFolder(s){return new U({parent:this,title:s})}load(s,u=!0){return s.controllers&&this.controllers.forEach(S=>{S instanceof oe||S._name in s.controllers&&S.load(s.controllers[S._name])}),u&&s.folders&&this.folders.forEach(S=>{S._title in s.folders&&S.load(s.folders[S._title])}),this}save(s=!0){const u={controllers:{},folders:{}};return this.controllers.forEach(S=>{if(!(S instanceof oe)){if(S._name in u.controllers)throw new Error(`Cannot save GUI with duplicate property "${S._name}"`);u.controllers[S._name]=S.save()}}),s&&this.folders.forEach(S=>{if(S._title in u.folders)throw new Error(`Cannot save GUI with duplicate folder "${S._title}"`);u.folders[S._title]=S.save()}),u}open(s=!0){return this._closed=!s,this.$title.setAttribute("aria-expanded",!this._closed),this.domElement.classList.toggle("closed",this._closed),this}close(){return this.open(!1)}show(s=!0){return this._hidden=!s,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}openAnimated(s=!0){return this._closed=!s,this.$title.setAttribute("aria-expanded",!this._closed),requestAnimationFrame(()=>{this.$children.style.height=this.$children.clientHeight+"px",this.domElement.classList.add("transition");const S=F=>{F.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",S))};this.$children.addEventListener("transitionend",S);const T=s?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!s),requestAnimationFrame(()=>{this.$children.style.height=T+"px"})}),this}title(s){return this._title=s,this.$title.innerHTML=s,this}reset(s=!0){return(s?this.controllersRecursive():this.controllers).forEac
1h(u=>u.reset()),this}onChange(s){return this._onChange=s,this}_callOnChange(s){this.parent&&this.parent._callOnChange(s),void 0!==this._onChange&&this._onChange.call(this,{object:s.object,property:s.property,value:s.getValue(),controller:s})}onFinishChange(s){return this._onFinishChange=s,this}_callOnFinishChange(s){this.parent&&this.parent._callOnFinishChange(s),void 0!==this._onFinishChange&&this._onFinishChange.call(this,{object:s.object,property:s.property,value:s.getValue(),controller:s})}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(s=>s.destroy())}controllersRecursive(){let s=Array.from(this.controllers);return this.folders.forEach(u=>{s=s.concat(u.controllersRecursive())}),s}foldersRecursive(){let s=Array.from(this.folders);return this.folders.forEach(u=>{s=s.concat(u.foldersRecursive())}),s}}const ae=new e.vBJ({color:9498256,transparent:!0,opacity:.8});class de{get active(){return this._active}constructor(s){this._active=s,this.envFolder=null,this._active&&(this.ui=new U({width:300}),this.ui.close(),this.envFolder=this.ui.addFolder("Environment Settings"))}dispose(){this.ui?.destroy(),this.ui=null,this.envFolder=null}addRendererDebug(s){const u=this.ui.addFolder("Renderer Settings");u.add(s,"outputColorSpace",{sRGB:e.KI_,Linear:e.GUF}).name("output Color Space"),u.add(s,"toneMapping",{None:e.uL9,Linear:e.EoG,Reinhard:e.CdI,Cineon:e.YGz,ACESFilmic:e.LY2,AgX:e.Bgp,Neutral:e.ORg}).name("Tone Mapping"),u.add(s,"toneMappingExposure",-10,10,.1).name("Tone Mapping Exposure"),u.add(s.shadowMap,"type",{Basic:e._MY,PCF:e._iA,PCFSoft:e.ntZ,VSM:e.dwk}).name("Shadow Map Type"),u.open()}addMouseRaycasterDebug(s,u,S,T){const F=new e.FM8;let $=null,ue=null;const Ie=()=>{$&&ue&&($.material=ue),$=null,ue=null},Pe=Ue=>{const Re=s.getBoundingClientRect();return 0!==Re.width&&0!==Re.height&&(F.x=(Ue.clientX-Re.left)/Re.width*2-1,F.y=-(Ue.clientY-Re.top)/Re.height*2+1,!0)},Ce=Ue=>{if(Ue&&!Pe(Ue))return null;u.setFromCamera(F,S);const Re=u.intersectObjects(T.children,!0);return 0===Re.length?null:Re[0].object};window.addEventListener("pointermove",Ue=>{if(!Pe(Ue))return;if(!Ue.ctrlKey)return void Ie();const Re=Ce();Re&&Re.material?($&&ue&&($.material=ue),$=Re,ue=Re.material,Re.material=ae):Ie()}),window.addEventListener("keydown",Ue=>{if("Delete"!==Ue.key&&"Del"!==Ue.key&&"Delete"!==Ue.code)return;const Re=$??Ce();!Re||!Re.parent||($===Re&&Ie(),Re.parent.remove(Re))}),window.addEventListener("pointerdown",Ue=>{if(!Ue.shiftKey)return;const Re=s.getBoundingClientRect();if(0===Re.width||0===Re.height)return;F.x=(Ue.clientX-Re.left)/Re.width*2-1,F.y=-(Ue.clientY-Re.top)/Re.height*2+1,u.setFromCamera(F,S);const ge=u.intersectObjects(T.children,!0);if(ge.length>0){const De=ge[0],He=De.object;console.group("Mesh Debug Info"),console.log(He),console.log("Name:",He.name||"unnamed"),console.log("UUID:",He.uuid),console.log("Type:",He.type),console.log("Position:",He.position),console.log("Rotation:",He.rotation),console.log("Scale:",He.scale),console.log("Material:",He.material),He.geometry&&(console.log("Geometry type:",He.geometry.type),console.log("Vertices:",He.geometry.getAttribute("position").count||0)),console.log("Parent:",He.parent?.name||"none"),console.log("Children count:",He.children.length),console.log("Distance from camera:",De.distance),console.log("Hit point:",De.point),console.log("Hit face index:",De.faceIndex),console.groupEnd()}})}createDirectionalLightDebugControls(s,u,S){const T=u[S],F=T.getLight(),$=new e.cBI(F,500,65280);s.add($);const ue={[`light${S}Color`]:F.color.getHex()},Ie={[`removeLight${S}`]:()=>{try{F.shadow?.map?.dispose&&F.shadow.map.dispose()}catch{}T.disposeGuiControllers(),s.remove(F),s.remove(F.target),s.remove($);const mt=u.indexOf(T);-1!==mt&&u.splice(mt,1)}},Pe=this.envFolder.addColor(ue,`light${S}Color`).onChange(()=>{F.color.set(ue[`light${S}Color`])});T.addGuiController(Pe);const Ce=this.envFolder.add(Ie,`removeLight${S}`).name(`Remove dirLight ${S}`);T.addGuiController(Ce);const Ue=this.envFolder.add(F,"intensity").name(`dirLight${S}Intensity`).min(0).max(10).step(.001);T.addGuiController(Ue);const Re=this.envFolder.add(F.position,"x").name(`dirLight${S}X`).min(-2e4).max(2e4).step(1);T.addGuiController(Re);const ge=this.envFolder.add(F.position,"y").name(`dirLight${S}Y`).min(-2e4).max(2e4).step(1);T.addGuiController(ge);const De=this.envFolder.add(F.position,"z").name(`dirLight${S}Z`).min(-2e4).max(2e4).step(1);T.addGuiController(De);const He=this.envFolder.add(F.target.position,"x").name(`dirLight${S}TargetX`).min(-15e3).max(15e3).step(1);T.addGuiController(He);const rt=this.envFolder.add(F.target.position,"y").name(`dirLight${S}TargetY`).min(-15e3).max(15e3).step(1);T.addGuiController(rt);const Ge=this.envFolder.add(F.target.position,"z").name(`dirLight${S}TargetZ`).min(-15e3).max(15e3).step(1);if(T.addGuiController(Ge),0===S){const mt=new e.Rki(F.shadow.camera);s.add(mt);const dt=this.envFolder.add(F.shadow.camera,"near").name(`dirLight${S}ShadowNear`).min(1).max(3e4).step(1).onChange(()=>
1{F.shadow.camera.updateProjectionMatrix(),mt.update()});T.addGuiController(dt);const kt=this.envFolder.add(F.shadow.camera,"far").name(`dirLight${S}ShadowFar`).min(1e3).max(3e4).step(1).onChange(()=>{F.shadow.camera.updateProjectionMatrix(),mt.update()});T.addGuiController(kt)}}}class he extends e.pBf{get width(){return this._width}get height(){return this._height}get pixelRatio(){return this._pixelRatio}constructor(s){super(),this._domRoot=s;const u=this._domRoot.getBoundingClientRect();this._width=u.width,this._height=u.height,this._pixelRatio=Math.min(window.devicePixelRatio,2),new ResizeObserver(T=>{for(const F of T)F.target===this._domRoot&&(this._width=F.contentRect.width,this._height=F.contentRect.height,this._pixelRatio=Math.min(window.devicePixelRatio,2),this.dispatchEvent({type:"resize"}))}).observe(this._domRoot),window.addEventListener("resize",()=>{this._pixelRatio=Math.min(window.devicePixelRatio,2),this.dispatchEvent({type:"resize"})})}}class ve{constructor(s,u,S,T,F){this._raycaster=S,this._scene=T,this._camera=F,this._onMouseMove=$=>{this._updateNormalizedPosition($)},this._onMouseDown=$=>{this._initialMousePosition={x:$.clientX,y:$.clientY},this._updateNormalizedPosition($)},this._onMouseUp=$=>{const ue_y=$.clientY;this._movedDistanceAfterMouseDown=Math.sqrt(Math.pow($.clientX-this._initialMousePosition.x,2)+Math.pow(ue_y-this._initialMousePosition.y,2)),this._updateNormalizedPosition($)},this._onClick=$=>{if(this.didMouseDrag())return;this._updateNormalizedPosition($),this._raycaster.setFromCamera(this._normalizedPosition,this._camera);const ue=this._raycaster.ray.direction.multiplyScalar(1e3),Ie=new Float32Array([this._raycaster.ray.origin.x,this._raycaster.ray.origin.y,this._raycaster.ray.origin.z,this._raycaster.ray.origin.x+ue.x,this._raycaster.ray.origin.y+ue.y,this._raycaster.ray.origin.z+ue.z]);this._rayLine.geometry.setAttribute("position",new e.TlE(Ie,3)),this._rayLine.visible=!0,setTimeout(()=>{this._rayLine.visible=!1},5e3);const Pe=this._raycaster.intersectObjects(this._scene.children,!0);Pe.length>0&&console.log("Ray hit:",Pe[0].object.name||"unnamed object")},this._domRoot=s,this._initialMousePosition={x:0,y:0},this._movedDistanceAfterMouseDown=0,this._dragThresholdInPixels=5,this._normalizedPosition=new e.FM8,s.addEventListener("mousedown",this._onMouseDown),s.addEventListener("mousemove",this._onMouseMove),s.addEventListener("mouseup",this._onMouseUp)}_updateNormalizedPosition(s){const u=this._domRoot.getBoundingClientRect();0===u.width||0===u.height||(this._normalizedPosition.x=(s.clientX-u.left)/u.width*2-1,this._normalizedPosition.y=-(s.clientY-u.top)/u.height*2+1)}getNormalizedPosition(){return this._normalizedPosition.clone()}didMouseDrag(){return this._movedDistanceAfterMouseDown>this._dragThresholdInPixels}dispose(){this._domRoot.removeEventListener("mousedown",this._onMouseDown),this._domRoot.removeEventListener("mousemove",this._onMouseMove),this._domRoot.removeEventListener("mouseup",this._onMouseUp),this._domRoot.removeEventListener("click",this._onClick),this._scene.remove(this._rayLine),this._rayLine.geometry.dispose(),this._rayLine.material.dispose()}}var be=P(5873);class Le{get instance(){return this._instance}get controlsTarget(){return this._controls.target}constructor(s,u,S=!1){this._sizes=u,this._setInstance(),this._setControls(s,S)}_setInstance(){this._instance=new e.cPb(30,this._sizes.width/this._sizes.height,5,1e5)}_setControls(s,u){this._controls=new be.z(this._instance,s),this._controls.maxPolarAngle=u?Math.PI:.5*Math.PI,this._controls.minPolarAngle=0,this._controls.zoomSpeed=1.2,this._controls.minDistance=5,this._controls.maxDistance=u?3e4:1e4,this._controls.enableDamping=!0,this._controls.dampingFactor=.125,this._controls.rotateSpeed=.8}resize(){this._instance.aspect=this._sizes.width/this._sizes.height,this._instance.updateProjectionMatrix()}update(){this._controls.update()}dispose(){this._instance=null,this._controls=null}toggleOrbitControls(s){this._controls.enabled=s}setControlsTarget(s){this._controls.target.copy(s),this._controls.update()}updateSettingstoFit(s){this._instance.far=4*s,this._instance.updateProjectionMatrix(),this._controls.maxDistance=2*s,this._controls.update()}}var Ye=P(60725);class Te extends e.yxD{constructor(s){super(s),this.type=e.cLu}parse(s){const $=function(Pt,xt){switch(Pt){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(xt||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(xt||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(xt||""));default:throw new Error("THREE.RGBELoader: Memory Error: "+(xt||""))}},Ue=function(Pt,xt,Jt){xt=xt||1024;let Wt=Pt.pos,Vt=-1,Ft=0,Zt="",Bt=String.fromCharCode.apply(null,new Uint16Array(Pt.subarray(Wt,Wt+128)));for(;0>(Vt=Bt.indexOf("\n"))&&Ft<xt&&Wt<Pt.byteLength;)Zt+=Bt,Ft+=Bt.length,Wt+=128,Bt+=String.fromCharCode.apply(null,new Uint16Array(Pt.subarray(Wt,Wt+128)));return-1<Vt&&(!1!==Jt&&(Pt.pos+=Ft+Vt+1),Zt+Bt.slice(0,Vt))},De=function(Pt,xt,Jt,$t){const Vt=Math.pow(2,Pt[xt+3]-128)/255;Jt[$t+0]=Pt[xt+0]*Vt,Jt[$t+1]=Pt[xt+1]*Vt,Jt[$t+2]=Pt[xt+2]*Vt,Jt[$t+3]=1},He=function(Pt,xt,Jt,$t){const Vt=Math.pow(2,Pt[xt+3]-128)/255;Jt[$t+0]=e.A5E.toHalfFloat(Math.min(Pt[xt+0]*Vt,65504)),Jt[$t+1]=e.A5E.toHalfFloat(Math.min(Pt[xt+1]*Vt,65504)),Jt[$t+2]=e.A5E.toHalfFloat(Math.min(Pt[xt+2]*Vt,65504)),Jt[$t+3]=e.A5E.toHalfFloat(1)},rt=new Uint8Array(s);rt.pos=0;const Ge=function(Pt){const xt=/^#\?(\S+)/,Jt=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,$t=/^\s*EXPOSURE\s*=\s
1*(\d+(\.\d+)?)\s*$/,Wt=/^\s*FORMAT=(\S+)\s*$/,Vt=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,Ft={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let Zt,Bt;for((Pt.pos>=Pt.byteLength||!(Zt=Ue(Pt)))&&$(1,"no header found"),(Bt=Zt.match(xt))||$(3,"bad initial token"),Ft.valid|=1,Ft.programtype=Bt[1],Ft.string+=Zt+"\n";Zt=Ue(Pt),!1!==Zt;)if(Ft.string+=Zt+"\n","#"!==Zt.charAt(0)){if((Bt=Zt.match(Jt))&&(Ft.gamma=parseFloat(Bt[1])),(Bt=Zt.match($t))&&(Ft.exposure=parseFloat(Bt[1])),(Bt=Zt.match(Wt))&&(Ft.valid|=2,Ft.format=Bt[1]),(Bt=Zt.match(Vt))&&(Ft.valid|=4,Ft.height=parseInt(Bt[1],10),Ft.width=parseInt(Bt[2],10)),2&Ft.valid&&4&Ft.valid)break}else Ft.comments+=Zt+"\n";return 2&Ft.valid||$(3,"missing format specifier"),4&Ft.valid||$(3,"missing image size specifier"),Ft}(rt),mt=Ge.width,dt=Ge.height,kt=function(Pt,xt,Jt){const $t=xt;if($t<8||$t>32767||2!==Pt[0]||2!==Pt[1]||128&Pt[2])return new Uint8Array(Pt);$t!==(Pt[2]<<8|Pt[3])&&$(3,"wrong scanline width");const Wt=new Uint8Array(4*xt*Jt);Wt.length||$(4,"unable to allocate buffer space");let Vt=0,Ft=0;const Zt=4*$t,Bt=new Uint8Array(4),li=new Uint8Array(Zt);let Mi=Jt;for(;Mi>0&&Ft<Pt.byteLength;){Ft+4>Pt.byteLength&&$(1),Bt[0]=Pt[Ft++],Bt[1]=Pt[Ft++],Bt[2]=Pt[Ft++],Bt[3]=Pt[Ft++],(2!=Bt[0]||2!=Bt[1]||(Bt[2]<<8|Bt[3])!=$t)&&$(3,"bad rgbe scanline format");let ft,mi=0;for(;mi<Zt&&Ft<Pt.byteLength;){ft=Pt[Ft++];const ni=ft>128;if(ni&&(ft-=128),(0===ft||mi+ft>Zt)&&$(3,"bad scanline data"),ni){const ii=Pt[Ft++];for(let hi=0;hi<ft;hi++)li[mi++]=ii}else li.set(Pt.subarray(Ft,Ft+ft),mi),mi+=ft,Ft+=ft}const wi=$t;for(let ni=0;ni<wi;ni++){let ii=0;Wt[Vt]=li[ni+ii],ii+=$t,Wt[Vt+1]=li[ni+ii],ii+=$t,Wt[Vt+2]=li[ni+ii],ii+=$t,Wt[Vt+3]=li[ni+ii],Vt+=4}Mi--}return Wt}(rt.subarray(rt.pos),mt,dt);let ti,qt,zt;switch(this.type){case e.VzW:zt=kt.length/4;const Pt=new Float32Array(4*zt);for(let Jt=0;Jt<zt;Jt++)De(kt,4*Jt,Pt,4*Jt);ti=Pt,qt=e.VzW;break;case e.cLu:zt=kt.length/4;const xt=new Uint16Array(4*zt);for(let Jt=0;Jt<zt;Jt++)He(kt,4*Jt,xt,4*Jt);ti=xt,qt=e.cLu;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:mt,height:dt,data:ti,header:Ge.string,gamma:Ge.gamma,exposure:Ge.exposure,type:qt}}setDataType(s){return this.type=s,this}load(s,u,S,T){return super.load(s,function F($,ue){switch($.type){case e.VzW:case e.cLu:$.colorSpace=e.GUF,$.minFilter=e.wem,$.magFilter=e.wem,$.generateMipmaps=!1,$.flipY=!0}u&&u($,ue)},S,T)}}class Je extends e.Kj0{constructor(){const s=Je.SkyShader,u=new e.jyz({name:s.name,uniforms:e.rDY.clone(s.uniforms),vertexShader:s.vertexShader,fragmentShader:s.fragmentShader,side:e._Li,depthWrite:!1});super(new e.DvJ(1,1,1),u),this.isSky=!0}}Je.SkyShader={name:"SkyShader",uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new e.Pa4},up:{value:new e.Pa4(0,1,0)}},vertexShader:"\n\t\tuniform vec3 sunPosition;\n\t\tuniform float rayleigh;\n\t\tuniform float turbidity;\n\t\tuniform float mieCoefficient;\n\t\tuniform vec3 up;\n\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\t// constants for atmospheric scattering\n\t\tconst float e = 2.71828182845904523536028747135266249775724709369995957;\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\t// wavelength of used primaries, according to preetham\n\t\tconst vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );\n\t\t// this pre-calculation replaces older TotalRayleigh(vec3 lambda) function:\n\t\t// (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn))\n\t\tconst vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );\n\n\t\t// mie stuff\n\t\t// K coefficient for the primaries\n\t\tconst float v = 4.0;\n\t\tconst vec3 K = vec3( 0.686, 0.678, 0.666 );\n\t\t// MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K\n\t\tconst vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );\n\n\t\t// earth shadow hack\n\t\t// cutoffAngle = pi / 1.95;\n\t\tconst float cutoffAngle = 1.6110731556870734;\n\t\tconst float steepness = 1.5;\n\t\tconst float EE = 1000.0;\n\n\t\tfloat sunIntensity( float zenithAngleCos ) {\n\t\t\tzenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );\n\t\t\treturn EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepne
1ss ) ) );\n\t\t}\n\n\t\tvec3 totalMie( float T ) {\n\t\t\tfloat c = ( 0.2 * T ) * 10E-18;\n\t\t\treturn 0.434 * c * MieConst;\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n\t\t\tvWorldPosition = worldPosition.xyz;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\tgl_Position.z = gl_Position.w; // set z to camera.far\n\n\t\t\tvSunDirection = normalize( sunPosition );\n\n\t\t\tvSunE = sunIntensity( dot( vSunDirection, up ) );\n\n\t\t\tvSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );\n\n\t\t\tfloat rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );\n\n\t\t\t// extinction (absorption + out scattering)\n\t\t\t// rayleigh coefficients\n\t\t\tvBetaR = totalRayleigh * rayleighCoefficient;\n\n\t\t\t// mie coefficients\n\t\t\tvBetaM = totalMie( turbidity ) * mieCoefficient;\n\n\t\t}",fragmentShader:"\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\tuniform float mieDirectionalG;\n\t\tuniform vec3 up;\n\n\t\t// constants for atmospheric scattering\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\tconst float n = 1.0003; // refractive index of air\n\t\tconst float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius)\n\n\t\t// optical length at zenith for molecules\n\t\tconst float rayleighZenithLength = 8.4E3;\n\t\tconst float mieZenithLength = 1.25E3;\n\t\t// 66 arc seconds -> degrees, and the cosine of that\n\t\tconst float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;\n\n\t\t// 3.0 / ( 16.0 * pi )\n\t\tconst float THREE_OVER_SIXTEENPI = 0.05968310365946075;\n\t\t// 1.0 / ( 4.0 * pi )\n\t\tconst float ONE_OVER_FOURPI = 0.07957747154594767;\n\n\t\tfloat rayleighPhase( float cosTheta ) {\n\t\t\treturn THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );\n\t\t}\n\n\t\tfloat hgPhase( float cosTheta, float g ) {\n\t\t\tfloat g2 = pow( g, 2.0 );\n\t\t\tfloat inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );\n\t\t\treturn ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec3 direction = normalize( vWorldPosition - cameraPosition );\n\n\t\t\t// optical length\n\t\t\t// cutoff angle at 90 to avoid singularity in next formula.\n\t\t\tfloat zenithAngle = acos( max( 0.0, dot( up, direction ) ) );\n\t\t\tfloat inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );\n\t\t\tfloat sR = rayleighZenithLength * inverse;\n\t\t\tfloat sM = mieZenithLength * inverse;\n\n\t\t\t// combined extinction factor\n\t\t\tvec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );\n\n\t\t\t// in scattering\n\t\t\tfloat cosTheta = dot( direction, vSunDirection );\n\n\t\t\tfloat rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );\n\t\t\tvec3 betaRTheta = vBetaR * rPhase;\n\n\t\t\tfloat mPhase = hgPhase( cosTheta, mieDirectionalG );\n\t\t\tvec3 betaMTheta = vBetaM * mPhase;\n\n\t\t\tvec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );\n\t\t\tLin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );\n\n\t\t\t// nightsky\n\t\t\tfloat theta = acos( direction.y ); // elevation --\x3e y-axis, [-pi/2, pi/2]\n\t\t\tfloat phi = atan( direction.z, direction.x ); // azimuth --\x3e x-axis [-pi/2, pi/2]\n\t\t\tvec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );\n\t\t\tvec3 L0 = vec3( 0.1 ) * Fex;\n\n\t\t\t// composition + solar disc\n\t\t\tfloat sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );\n\t\t\tL0 += ( vSunE * 19000.0 * Fex ) * sundisk;\n\n\t\t\tvec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );\n\n\t\t\tvec3 retColor = pow( texColor, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );\n\n\t\t\tgl_FragColor = vec4( retColor, 1.0 );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <colorspace_fragment>\n\n\t\t}"};const Qe=[{x:1,y:1,z:1,i:6,shadows:!0,color:16579053},{x:1,y:1,z:1,i:.25,shadows:!1,color:16777215},{x:-1,y:1,z:1,i:.25,shadows:!1,color:16777215},{x:0,y:0,z:1,i:.75,shadows:!1,color:16777215},{x:-5,y:0,z:-5,i:1,shadows:!0,color:16777215}];class st{get distanceToModelCenter(){return this._distanceToModelCenter}constructor(s,u){this._data=s,this._guiControllers=[],this._distanceToModelCenter=0,this._light=new e.Ox3(this._data.color||16579053,this._data.i),this._data.shadows&&(this._light.castShadow=this._data.shadows,this._light.shadow.camera.lookAt(0,0,0),this._light.shadow.camera.near=5e3,this._light.shadow.camera.far=22e3,this._light.shadow.camera.left=-5e3,this._light.shadow.camera.right=5e3,this._light.shadow.camera.top=5e3,this._light.shadow.camera.bottom=-
15e3,this._light.shadow.mapSize.set(4096,4096),this._light.shadow.bias=-1e-4,this._light.shadow.normalBias=10,this._light.shadow.camera.updateProjectionMatrix(),this._light.shadow.camera.updateMatrixWorld(!0)),u.add(this._light)}getLight(){return this._light}addGuiController(s){s&&this._guiControllers.push(s)}disposeGuiControllers(){for(const s of this._guiControllers)try{"function"==typeof s.destroy?s.destroy():"function"==typeof s.remove&&s.remove()}catch{}this._guiControllers=[]}set(s,u,S){const T=new e.Pa4(this._data.x,this._data.y,this._data.z);0===T.lengthSq()&&T.set(0,1,0),T.normalize();const $=Math.max(S.x,S.y,S.z,1)*(this._data.shadows?1.5:1),ue=Math.max(1e4,$);this._distanceToModelCenter=ue;const Ie=u.clone().add(T.clone().multiplyScalar(ue));if(this._light.castShadow){const Pe=.2*Math.PI;this._light.position.set(u.x+Math.cos(Pe)*ue,u.y+Math.sin(Pe)*ue,Ie.z);const Ce=.5*S.x,Ue=.5*S.y,Re=.5*S.z,De=2.2*Math.sqrt(Ce*Ce+Ue*Ue);this._light.shadow.camera.near=Math.max(1,ue-2*Re),this._light.shadow.camera.far=2*ue,this._light.shadow.camera.left=-De,this._light.shadow.camera.right=De,this._light.shadow.camera.top=De,this._light.shadow.camera.bottom=-De,this._light.shadow.camera.updateProjectionMatrix()}else this._light.position.copy(Ie);this._light.target.position.copy(u),s.add(this._light.target)}}class et{get sunLight(){return this._directionalLights[0]}get directionalLights(){return this._directionalLights}constructor(s,u,S){if(this._scene=s,this._debug=S,this._rgbeLoader=new Te,this._directionalLights=[],this._ambientGuiControllers=[],this.currentAtmosphereMaterial=new e.jyz,this._ambientLight=new e.Mig(16579053,1.25),this._scene.add(this._ambientLight),this.setDirLights(),this._createSkyAtmosphere(),this._debug.active){this._debug.envFolder.add({addDirLight:()=>{this.addDirectionalLight(),this._debug.createDirectionalLightDebugControls(this._scene,this._directionalLights,this._directionalLights.length-1)}},"addDirLight").name("Add A New Directional Light");const T={ambientColor:this._ambientLight.color.getHex()},F=this._debug.envFolder.addColor(T,"ambientColor").name("Ambient Color").onChange(()=>{try{this._ambientLight.color.set(T.ambientColor)}catch{}});this._ambientGuiControllers.push(F);const $=this._debug.envFolder.add(this._ambientLight,"intensity").name("Ambient Intensity").min(0).max(10).step(.01);this._ambientGuiControllers.push($)}}setDirLights(){for(let s=0;s<Qe.length;s++)this.addDirectionalLight(Qe[s])}addDirectionalLight(s){const S=new st(s||{x:0,y:1,z:0,i:1,shadows:!1,color:"ffffff"},this._scene);this._directionalLights.push(S)}_setsky(s){const u=new Je;u.scale.setScalar(15e3),this._scene.add(u);const S=new e.Pa4,T={turbidity:20,rayleigh:1,mieCoefficient:.001,mieDirectionalG:.8,elevation:30,azimuth:55,exposure:s.toneMappingExposure},F=()=>{const $=u.material.uniforms;$.turbidity.value=T.turbidity,$.rayleigh.value=T.rayleigh,$.mieCoefficient.value=T.mieCoefficient,$.mieDirectionalG.value=T.mieDirectionalG;const ue=e.M8C.degToRad(90-T.elevation),Ie=e.M8C.degToRad(T.azimuth);S.setFromSphericalCoords(1,ue,Ie),$.sunPosition.value.copy(S),this._directionalLights[0].getLight().position.copy(S.clone().multiplyScalar(15e3)),s.shadowMap.needsUpdate=!0,s.toneMappingExposure=T.exposure};this._debug.active&&(this._debug.envFolder.add(T,"turbidity",0,20,.1).onChange(F),this._debug.envFolder.add(T,"rayleigh",0,4,.001).onChange(F),this._debug.envFolder.add(T,"mieCoefficient",0,.1,.001).onChange(F),this._debug.envFolder.add(T,"mieDirectionalG",0,1,.001).onChange(F),this._debug.envFolder.add(T,"elevation",30,150,.1).onChange(F),this._debug.envFolder.add(T,"azimuth",-180,180,.1).onChange(F),this._debug.envFolder.add(T,"exposure",0,1.5,1e-4).onChange(F)),F()}_createSkyAtmosphere(){const S=new e.jyz({vertexShader:"\n varying vec3 vWorldPosition;\n \n void main() {\n vec4 worldPosition = modelMatrix * vec4(position, 1.0);\n vWorldPosition = worldPosition.xyz;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform vec3 topColor;\n uniform vec3 bottomColor;\n uniform float offset;\n uniform float exponent;
1\n varying vec3 vWorldPosition;\n \n void main() {\n float h = normalize(vWorldPosition + offset).y;\n float t = smoothstep(-1.0, 1.0, h);\n t = pow(t, exponent);\n gl_FragColor = vec4(mix(bottomColor, topColor, t), 1.0);\n }\n ",uniforms:{topColor:{value:new e.Ilk(13231359)},bottomColor:{value:new e.Ilk(14013133)},offset:{value:0},exponent:{value:.5}},side:e._Li});this.currentAtmosphereMaterial=S;const T=new e.xo$(15e3,32,32),F=new e.Kj0(T,this.currentAtmosphereMaterial);F.name="skySphere",this._scene.add(F)}adjustSkySphereRadiusTo(s,u){const S=this._scene.getObjectByName("skySphere");if(!S)return;const F=1.5*Math.max(u.x,u.y,u.z,1);S.geometry.dispose(),S.geometry=new e.xo$(F,32,32),S.position.copy(s)}generateEnvMapFromAtmosphere(s,u=512){const S=this._scene.getObjectByName("skySphere");if(!S)return;if(S.layers.set(1),!this._envCubeCamera){const ue=new e.oAp(u,{generateMipmaps:!0,minFilter:e.D1R});this._envCubeCamera=new e._am(.1,1e5,ue),this._scene.add(this._envCubeCamera),this._envCubeCamera.layers.set(1)}this._pmremGenerator||(this._pmremGenerator=new Ye.anP(s),this._pmremGenerator.compileCubemapShader());const F=this._scene.overrideMaterial,$=this._scene.background;try{this._envCubeCamera.update(s,this._scene);const ue=this._pmremGenerator.fromCubemap(this._envCubeCamera.renderTarget.texture),Ie=ue.texture;this._scene.environment=Ie,this._scene.traverse(Pe=>{const Ce=Pe.material;Ce&&(Ce.isMeshStandardMaterial||Ce.isMeshPhysicalMaterial)&&(Ce.envMap=Ie,Ce.envMapIntensity=Ce.envMapIntensity??1,Ce.needsUpdate=!0)}),ue.dispose()}finally{this._scene.overrideMaterial=F,this._scene.background=$}}disposeEnvMapResources(){try{this._pmremGenerator&&(this._pmremGenerator.dispose(),this._pmremGenerator=void 0),this._envCubeCamera&&(this._envCubeCamera.renderTarget.dispose(),this._scene.remove(this._envCubeCamera),this._envCubeCamera=void 0),this._scene.environment?.dispose()}catch{}}_setEnvironmentMap(){this._rgbeLoader.load("/assets/hdr/puresky.hdr",s=>{s.minFilter=e.D1R,s.magFilter=e.wem,s.generateMipmaps=!0,s.mapping=e.dSO,this._scene.environment=s})}}class Et{get instance(){return this._instance}constructor(s,u,S){this._sizes=s,this._scene=u,this._camera=S,this._setInstance()}_setInstance(){this._instance=new Ye.CP7({antialias:!0,powerPreference:"high-performance",logarithmicDepthBuffer:!0,preserveDrawingBuffer:!0}),this._instance.outputColorSpace=e.KI_,this._instance.toneMapping=e.CdI,this._instance.toneMappingExposure=2,this._instance.shadowMap.enabled=!0,this._instance.shadowMap.type=e.ntZ,this._instance.shadowMap.autoUpdate=!1,this._instance.setClearColor(16777215,.5),this._instance.setSize(this._sizes.width,this._sizes.height),this._instance.setPixelRatio(this._sizes.pixelRatio)}resize(){this._instance.setSize(this._sizes.width,this._sizes.height),this._instance.setPixelRatio(this._sizes.pixelRatio)}update(){this._instance.render(this._scene,this._camera)}dispose(){this._instance.setAnimationLoop(null),this._instance.domElement&&this._instance.domElement.parentNode&&this._instance.domElement.parentNode.removeChild(this._instance.domElement),this._instance.dispose(),this._instance=null}}var lt=P(26565),i=P(62831);const d=new e.Wid({color:3355443,roughness:.7,metalness:.1,flatShading:!1}),I=new e.Wid({color:5592405,roughness:.65,metalness:.05,flatShading:!1});class w{get rendererInstance(){return this._renderer.instance}get cameraInstance(){return this._camera.instance}get scene(){return this._scene}_preSetup(s){}constructor(s,u,S,T,F,$){this._scene=new e.xsS,this._raycaster=new e.iMs,this._cameraStateWatcher=new _(!1),this._previousFreeCameraPosition=new e.Pa4,this._previousFreeCameraRotation=new e.USm,this._previousFreeCameraLookPoint=new e.Pa4,this._isPedestrian=!1,this._initialMousePosition=new e.FM8,this._isDragging=!1,this._isLeftClicking=!1,this._keysPressed={},this._isMovingForward=!1,this._isMovingBackward=!1,this._isRotatingLeft=!1,this._isRotatingRight=!1,this._HEAD_LEVEL=175,this._hoverRing=null,this._hoverRingRadius=30,this._targetFPS=30,this._interval=1e3/this._targetFPS,this._lastTime=0,this._viewMode="macro",this._floors=[],this._isShowing=!0,this._frameRenderedCallback=null,this._loadingOverlay=null,this._loadingOverlayProgress=null,this._loadingOverlayLabel=null,this._loadingOverlayHideTimeout=null,this._cameraAnimationDelayTimer=null,this._pendingCameraAnimation=null,this._originalDomRootPosition=null,this._preSetup(F),this._domRoot=S,this._domRootDisplay=S.style.display;const ue=new e.lLk;this._loader=this._createLoader(s,u,T,ue),this._createLoadingOverlay(ue),this._floors=this._createFloors(s,u,T),this._currentFloor=this._floors[0],this._loader.concludeInitialization(),this._debug=new de($?.isDebug||!1),this._sizes=new he(S),this._camera=new Le(S,this._sizes,this._debug.active),this._scene.add(this._camera.instance),this._mouse=new ve(S,this._debug.active,this._raycaster,this._scene,this._camera.instance),this._onDoubleClickHandler=this.onDoubleClick.bind(this),S.addEventListener("dblclick",this._onDoubleClickHandler),this._renderer=new Et(this._sizes,this._scene,this._camera.instance),this._environment=new et(this._scene,this._renderer.instance,this._debug),this._pedestrianCameraStart=new e.Pa4(0,this._HEAD_LEVEL,0),this._previousFreeCameraPosition.copy(this._camera.instance.position),this._previousFreeCameraRotation.copy(this._camera.instance.rotation),this._previousFreeCameraLookPoint.copy(this._camera.controlsTarget),this._previousPedestrianCameraPosition=new e.Pa4,this._previousPedestrianCameraPosition.copy(this._pedestrianCameraStart),this._previousPedestrianCameraRotation=new e.USm,this._previousPedestrianCameraLookPoint=new e.Pa4(this._previousPedestrianCameraPosition.x,this._previousPedestrianCameraPosition.y,this._previousPedestrianCameraPosition.z),this._debug.active&&(this._scene.add(new e.y8_(500)),this._debug.addRendererDebug(this._renderer.instance),this._debug.addMouseRaycasterDebug(S,this._raycaster,this._camera.instance,this._scene),this._stats=new O,this._stats.dom.style.position="absolute",this._stats.dom.style.top="0px",S.appendChild(this._stats.dom)),S.append(this._renderer.instance.domElement),this._sizes.addEventListener("resize",()=>{this._resize()}),this._isShowing?this.show(!0):this.hide(!0)}_resize(){this._camera.resize(),this._renderer.resize()}show(s){(!this._isShowing||s)&&(this._domRoot.style.display=this._domRootDisplay,this._renderer.instance.setAnimationLoop(this._render.bind(this))),this._isShowing=!0}hide(s){(this._isShowing||s)&&(this._domRoot.style.display="none",this._renderer.instance.setAnimationLoop(null)),this._isShowing=!1}_showLoadingOverlay(){this._loadingOverlay&&(null!==this._loadingOverlayHideTimeout&&(window.clearTimeout(this._loadingOverlayHideTimeout),this._loadingOverlayHideTimeout=null),this._loadingOverlay.style.visibility="visible",this._loadingOverlay.style.opacity="1")}_hideLoadingOverlay(s=200){this._loadingOverlay&&(null!==this._loadingOverlayHideTimeout&&window.clearTimeout(this._loadingOverlayHideTimeout),this._loadingOverlayHideTimeout=window.setTimeout(()=>{this._loadingOverlay&&(this._loadingOverlay.style.opacity="0",this._loadingOverlay.style.visibility="hidden"),this._loadingOverlayHideTimeout=null,this._startPendingCameraAnimationAfterTinyDelay()},s))}_updateLoadingOverlay(s,u){if(!this._loadingOverlayProgress||!this._loadingOverlayLabel)return;const S=u>0,T=S?Math.round(s/u*100):0;this._loadingOverlayProgress.style.width=`${S?T:0}%`,this._loadingOverlayLabel.textContent=S?`Loading 3d scene \u2014 ${T}%`:s>0?`Loading 3d scene \u2014 ${s} asset${1===s?"":"s"}`:"Loading 3d scene"}_createLoadingOverlay(s){"static"===window.getComputedStyle(this._domRoot).position&&(this._originalDomRootPosition=this._domRoot.style.position||"",this._domRoot.style.position="relative");const S=document.createElement("div");
1S.style.cssText=["position:absolute","inset:0","background:rgba(0, 0, 0, 0.78)","backdrop-filter: blur(12px)","-webkit-backdrop-filter: blur(12px)","display:flex","flex-direction:column","align-items:center","justify-content:center","gap:14px","padding:28px","box-sizing:border-box","z-index:10000","pointer-events:auto","opacity:0","visibility:hidden","transition:opacity 0.2s ease, visibility 0.2s ease"].join(";");const T=document.createElement("div");T.style.cssText=["color:#ffffff",'font-family:"sofia pro", sans-serif',"font-size:12px","font-weight:600","letter-spacing:0.14em","text-transform:none","text-align:center","white-space:pre-wrap","max-width:100%"].join(";"),T.textContent="Loading 3d scene";const F=document.createElement("div");F.style.cssText=["width:280px","max-width:100%","height:6px","background:rgba(255,255,255,0.14)","border-radius:4px","overflow:hidden"].join(";");const $=document.createElement("div");$.style.cssText=["width:0%","height:100%","background:linear-gradient(90deg,#7CEBB6 0%,#2EBB7A 100%)","transition:width 0.2s ease"].join(";"),F.appendChild($),S.appendChild(T),S.appendChild(F),this._domRoot.appendChild(S),this._loadingOverlay=S,this._loadingOverlayLabel=T,this._loadingOverlayProgress=$,s.onStart=(ue,Ie,Pe)=>{this._showLoadingOverlay(),this._updateLoadingOverlay(Ie,Pe)},s.onProgress=(ue,Ie,Pe)=>{this._updateLoadingOverlay(Ie,Pe)},s.onLoad=()=>{this._updateLoadingOverlay(1,1),this._hideLoadingOverlay(120)},s.onError=ue=>{this._loadingOverlayLabel&&(this._loadingOverlayLabel.textContent="Loading 3d scene \u2014 error"),this._showLoadingOverlay()}}_destroyLoadingOverlay(){this._loadingOverlay&&(this._loadingOverlay.remove(),this._loadingOverlay=null,this._loadingOverlayProgress=null,this._loadingOverlayLabel=null),null!==this._originalDomRootPosition&&(this._domRoot.style.position=this._originalDomRootPosition,this._originalDomRootPosition=null)}dispose(){this._scene.clear(),this._destroyHoverRing(),this._stats&&(this._stats.dom.remove(),this._stats=null),this._debug&&(this._debug.dispose?.(),this._debug=null),this._renderer.dispose(),this._loader.dispose(),this._camera.dispose(),this._floors.forEach(s=>s.dispose()),this._destroyLoadingOverlay(),this._scene.background&&(this._scene.background instanceof e.xEZ||this._scene.background instanceof e.BtG)&&this._scene.background.dispose(),this._onDoubleClickHandler&&this._domRoot.removeEventListener("dblclick",this._onDoubleClickHandler),this._scene=null,this._renderer=null,this._render=null,this._domRoot=null}_render(s){const u=s-this._lastTime;u>=this._interval&&(this._lastTime=s-u%this._interval,k(),this._renderer.update(
1),this._frameRenderedCallback?.(),this._camera.update(),this._stats?.update())}setFrameRenderedCallback(s){this._frameRenderedCallback=s}hideHoverRingForEnhancement(){this._hoverRing&&(this._hoverRing.visible=!1)}restoreHoverRingAfterEnhancement(){this._isPedestrian&&this.updateHoverRingPosition(0,0)}moveCameraToWorldPosition(s){if(!this._camera?.instance)return;const u=s.clone();u.y=this._HEAD_LEVEL;const S=this._camera.instance.position.clone(),T=this._camera.controlsTarget.clone(),F=(new e.Pa4).subVectors(T,S);F.lengthSq()<1e-6?F.set(0,0,-1):(F.y=0,F.normalize());const $=u.clone().add(F.multiplyScalar(300));$.y=T.y,this._animateCamera(u,$,this._isPedestrian)}_computeFrontCameraPositions(s,u,S){const T=Math.abs(u.max.z)>=Math.abs(u.min.z)?1:-1,F=1.15*Math.max(S.x,S.z,1),$=1.5*F,ue=1.25*Math.max(S.x,S.z,1),Ie=.55*Math.max(S.y,1)+1800,Pe=.45*Math.max(S.y,1)+1400,Ce=new e.Pa4(s.x,s.y+Ie,s.z+T*$),Ue=new e.Pa4(s.x+ue,s.y+Pe,s.z+ue);return{startPosition:Ce,startLookpoint:s.clone().add(new e.Pa4(0,0,T*Math.max(10,.35*F))),finalPosition:Ue}}updateSunPositionAndColor(s){const u=.01*s*Math.PI,S=this._environment.sunLight.distanceToModelCenter,T=this._currentFloor.controlsTargetPoint,F=this._environment.sunLight.getLight();F.position.set(T.x+Math.cos(u)*S,T.y+Math.sin(u)*S,F.position.z),F.target.position.copy(T);const $=Math.max(0,Math.min(1,.01*s)),ue=new e.Ilk(16770484),Ie=new e.Ilk(16777215),Pe=new e.Ilk(16729344),Ce=new e.Ilk(1585241),Ue=new e.Ilk(1730303),Re=new e.Ilk(1711150),ge=new e.Ilk(16751243),De=new e.Ilk(13426687),He=new e.Ilk(16739125),rt=new e.Ilk,Ge=new e.Ilk,mt=new e.Ilk;if($<.5){const dt=2*$;rt.copy(ue).lerp(Ie,dt),Ge.copy(Ce).lerp(Ue,dt),mt.copy(ge).lerp(De,dt)}else{const dt=2*($-.5);rt.copy(Ie).lerp(Pe,dt),Ge.copy(Ue).lerp(Re,dt),mt.copy(De).lerp(He,dt)}F.color.set(rt),this._environment.currentAtmosphereMaterial&&(this._environment.currentAtmosphereMaterial.uniforms.topColor.value.copy(Ge),this._environment.currentAtmosphereMaterial.uniforms.bottomColor.value.copy(mt)),this._environment.directionalLights.slice(1).forEach(dt=>{dt.getLight().color.set(rt)}),this._renderer.instance.shadowMap.needsUpdate=!0}switchFloor(s){return new Promise((u,S)=>{let T=null;for(let F of this._floors)if(i.d.areFloorUIDEquals(F.floorUid,s)){T=F;break}T?T.getOrLoad().then(([F,$])=>{this._currentFloor.removeFromParent(),this._currentFloor=T,F.traverse(ge=>{if(ge instanceof e.Kj0){if(ge.geometry&&!ge.geometry.attributes.normal&&ge.geometry.computeVertexNormals(),!ge.name.includes("Floor")&&!ge.name.includes("Corridor"))if(ge.name.includes("FreeSpaceWall"))ge.material=d;else if(!ge.name.includes("CoreSpaceWall"))if(ge.name.includes("CoreSpaceCeiling"))ge.material=I;else if(ge.name.includes("FreeSpaceCeiling")||ge.name.startsWith("Ceiling"))return void(ge.visible=!1);ge.receiveShadow=!0,ge.material instanceof e.F5T&&!lt.U(ge.material)?ge.castShadow=!0:ge.material.depthWrite=!1}}),this._scene.add(F),F.updateMatrixWorld(!0),this.switchMode(this._viewMode);const ue=this._currentFloor.entranceDoorPerp||null;let Ie=this._currentFloor.entranceRayOrigin||null;if(ue&&Ie)try{const ge=new e.iMs,De=.25*Math.PI;let He=null,rt=null;for(const Ge of[ue.clone(),ue.clone().negate()]){const mt=Ge.clone().multiplyScalar(Math.cos(De)),dt=new e.Pa4(mt.x,-Math.sin(De),mt.z).normalize(),kt=Ie.clone().add(Ge.clone().multiplyScalar(5));ge.set(kt,dt);const ti=ge.intersectObjects(this._scene.children,!0);for(const qt of ti)if(qt.object.name.includes("Corridor")){He=Ge.clone(),rt=qt.point.clone();break}if(He)break}if(He&&rt){const Ge=rt.clone();Ge.y=this._HEAD_LEVEL;let mt=He.clone().normalize();mt.y=0,this._pedestrianCameraStart.copy(Ge),this._previousPedestrianCameraPosition.copy(Ge);const dt=3;this._previousPedestrianCameraLookPoint.copy(Ge).add(mt.clone().multiplyScalar(dt))}}catch{}const Pe=(new e.ZzF).setFromObject(F),Ce=new e.Pa4;Pe.getSize(Ce);const Ue=Math.max(Ce.x,Ce.y,Ce.z,1);this._camera.updateSettingstoFit(Ue),T.updateControlsTargetFromModel(F);const Re=T.controlsTargetPoint.clone();if(!this._isPedestrian){const{startPosition:ge,startLookpoint:De,finalPosition:He}=this._computeFrontCameraPositions(Re,Pe,Ce);this._camera.instance.position.copy(ge),this._camera.setControlsTarget(De),this._animateCamera(He,Re,!1)}
1if(this._environment.directionalLights.forEach(ge=>ge.set(this._scene,T.controlsTargetPoint,Ce)),this._environment.adjustSkySphereRadiusTo(T.controlsTargetPoint,Ce),this._renderer.instance.shadowMap.needsUpdate=!0,this._debug.active){const ge=this._environment.directionalLights.length;for(let De=0;De<ge;De++)this._debug.createDirectionalLightDebugControls(this._scene,this._environment.directionalLights,De)}T.updateInstanceMatrixes(),$(),console.log("Vertices rendered:",3*this._renderer.instance.info.render.triangles),u()}).catch(S):S()})}switchMode(s){switch(s){case"macro":this._currentFloor.displayMacroView();break;case"micro":this._currentFloor.displayMicroView();break;case"full":this._currentFloor.displayFullView()}this._viewMode=s,this._renderer.instance.shadowMap.needsUpdate=!0}createOrUpdateHoverRing(){if(!this._hoverRing){const s=new e.o8S(.7*this._hoverRingRadius,this._hoverRingRadius,32),u=new e.vBJ({color:16777215,transparent:!0,opacity:.7,side:e.ehD,depthTest:!1,depthWrite:!1});this._hoverRing=new e.Kj0(s,u),this._hoverRing.rotation.x=.5*-Math.PI,this._hoverRing.name="HoverRing",this._scene.add(this._hoverRing)}}updateHoverRingPosition(s,u){if(!this._isPedestrian)return;this._raycaster.setFromCamera(this._mouse.getNormalizedPosition(),this._camera.instance);const S=this._raycaster.intersectObjects(this._scene.children,!0);let T=!1;if(S.length>0){const F=S.find($=>$.object.name.includes("Corridor")||$.object.name.includes("Floor"));if(F){const $=new e.Pa4(F.point.x,0,F.point.z);this._isPointInsideUnselectedLot($)||(T=!0,this.createOrUpdateHoverRing(),this._hoverRing.position.set($.x,.1,$.z),this._hoverRing.visible=!0)}}!T&&this._hoverRing&&(this._hoverRing.visible=!1)}_destroyHoverRing(){this._hoverRing&&(this._scene.remove(this._hoverRing),this._hoverRing.geometry.dispose(),this._hoverRing.material.dispose(),this._hoverRing=null)}_isPointInsideUnselectedLot(s){const u=this._currentFloor?.unselectedLotCoveredSpaces;if(!u||E.xb(u))return!1;const S=E.Pu(s.x,-s.z);try{return E.uh(S,u)||E.kK(S,u)}catch{return!1}}_getNormalizedPositionFromEvent(s){const u=this._domRoot.getBoundingClientRect();return 0===u.width||0===u.height?new e.FM8:new e.FM8((s.clientX-u.left)/u.width*2-1,-(s.clientY-u.top)/u.height*2+1)}_getRoomCenterFromObject(s){let u=s,S=null,T=Number.POSITIVE_INFINITY;for(;u;){const F=(new e.ZzF).setFromObject(u);if(!F.isEmpty()){const $=new e.Pa4;F.getSize($);const ue=$.x*$.x+$.y*$.y+$.z*$.z;if(ue<T){T=ue;const Ie=new e.Pa4;F.getCenter(Ie),S=Ie}}u=u.parent}return S}onDoubleClick(s){if(this._isPedestrian||0!==s.button)return;const u=this._getNormalizedPositionFromEvent(s);this._raycaster.setFromCamera(u,this._camera.instance);const S=this._raycaster.intersectObjects(this._scene.children,!0);if(0===S.length)return;const T=S.find(Ie=>Ie.object.name.includes("Corridor")||Ie.object.name.includes("Floor"));if(!T)return;const F=T.point.clone(),$=this._getRoomCenterFromObject(T.object),ue=$?new e.Pa4($.x,this._HEAD_LEVEL,$.z):F.clone().setY(this._HEAD_LEVEL);this._pedestrianCameraStart.set(F.x,this._HEAD_LEVEL,F.z),this._previousPedestrianCameraPosition.copy(this._pedestrianCameraStart),this._previousPedestrianCameraLookPoint.copy(ue),this.onFloorDoubleClick?this.onFloorDoubleClick(F):this.switchView(J.H.pedestrian)}onMouseDown(s){this._cameraStateWatcher.value=!0,this._initialMousePosition.set(s.clientX,s.clientY),this._isDragging=!1,0===s.button&&(this._isLeftClicking=!0,this._hoverRing&&(this._hoverRing.visible=!1))}onMouseMove(s){const S=(this._initialMousePosition.x-s.clientX)/800,T=(this._initialMousePosition.y-s.clientY)/800;if((Math.abs(S)>2/800||Math.abs(T)>2/800)&&(this._isDragging=!0,this._hoverRing&&(this._hoverRing.visible=!1)),this._isPedestrian&&!this._isLeftClicking&&this.updateHoverRingPosition(s.clientX,s.clientY),this._isLeftClicking&&this._isPedestrian){const F=this._camera.instance.position,$=this._camera.controlsTarget,ue=(new e.Pa4).subVectors($,F),Ie=ue.length(),Pe=(new e.$V).setFromVector3(ue),Ce=1.25;Pe.theta-=S*Ce,Pe.phi+=T*Ce;const Re=Math.PI-.1;Pe.phi=Math.max(.1,Math.min(Re,Pe.phi)),ue.setFromSpherical(Pe);const ge=F.clone().add(ue.normalize().multiplyScalar(Ie));this._camera.setControlsTarget(ge),this._initialMousePosition.set(s.clientX,s.clientY)}}onMouseUp(s){this._cameraStateWatcher.value=!1,this._isDragging||this.onFloorClickOnDesktop(s),0===s.button&&(this._isLeftClicking=!1,this.updateHoverRingPosition(s.clientX,s.clientY))}onTouchStart(s){const u=s.touches[0];this._initialMousePosition.set(u.clientX,u.clientY),this._isDragging=!1,this._hoverRing&&(this._hoverRing.visible=!1)}onTouchMove(s){const u=s.touches[0],T=u.clientY-this._initialMousePosition.y;(Math.abs(u.clientX-this._initialMousePosition.x)>5||Math.abs(T)>5)&&(this._isDragging=!0)}onTouchEnd(s){if(!this._isDragging){const u=s.changedTouches[0];this.onFloorClick(u.clientX,u.clientY)}s.changedTouches.length>0&&this.updateHoverRingPosition(s.changedTouches[0].clientX,s.changedTouches[0].clientY)}onFloorClickOnDesktop(s){this.onFloorClick(s.clientX,s.clientY)}onFloorClick(s,u){if(!this._isPedestrian)return;this._raycaster.setFromCamera(this._mouse.getNormalizedPosition(),this._camera.instance);const S=this._raycaster.intersectObjects(this._scene.children,!0);if(S.length>0){const T=S.find(F=>F.object.name.includes("Corridor")||F.object.name.includes("Floor"));if(T){const F=new e.Pa4(T.point.x,this._camera.instance.position.y,T.point.z);if(this._isPointInsideUnselectedLot(F))return;const $=this._camera.controlsTarget,ue=$.clone().add(F.clone().sub(this._camera.instance.position));this._cameraStateWatcher.value=!0,new l(this._camera.instance.position).to(F,1e3).easing(v.Quadratic.InOut).onUpdate(()=>{this._camera.instance.position.copy(this._camera.instance.position)}).start().onComplete(()=>{this._cameraStateWatcher.value=!1}),new l($).to(ue,1e3).easing(v.Quadratic.InOut).onUpdate(()=>{this._camera.setControlsTarget($)}).start()}}}_onKeyDown(s){if(this._isPedestrian)switch(s.key.toLowerCase()){case"z":case"w":case"arrowup":!this._isMovingForward&&!this._isRotatingLeft&&!this._isRotatingRight&&(this._cameraStateWatcher.value=!0,this._isMovingForward=!0,this._updateMovement());break;case"s":case"arrowdown":!this._isMovingBackward&&!this._isRotatingLeft&&!this._isRotatingRight&&(this._cameraStateWatcher.value=!0,this._isMovingBackward=!0,this._updateMovement());break;case"q":case"a":case"arrowleft":!this._isRotatingLeft&&!this._isMovingForward&&!this._isMovingBackward&&(this._cameraStateWatcher.value=!0,this._isRotatingLeft=!0,this._updateMovement());break;case"d":case"arrowright":!this._isRotatingRight&&!this._isMovingForward&&!this._isMovingBackward&&(this._cameraStateWatcher.value=!0,this._isRotatingRight=!0,this._updateMovement())}}_onKeyUp(s){const u=s.key.toLowerCase();("z"===u||"w"===u||"arrowup"===u)&&(this._isMovingForward=!1,this._cameraStateWatcher.value=!1),("s"===u||"arrowdown"===u)&&(this._isMovingBackward=!1,this._cameraStateWatcher.value=!1),("q"===u||"a"===u||"arrowleft"===u)&&(this._isRotatingLeft=!1,this._cameraStateWatcher.value=!1),("d"===u||"arrowright"===u)&&(this._isRotatingRight=!1,this._cameraStateWatcher.value=!1)}_updateMovement(){this._isMovingForward&&this.moveCameraForwardBackward(!0),this._isMovingBackward&&this.moveCameraForwardBackward(!1),this._isRotatingLeft&&this._rotateLookpoint(-.02),this._isRotatingRight&&this._rotateLookpoint(.02),(this._isMovingForward||this._isMovingBackward||this._isRotatingLeft||this._isRotatingRight)&&requestAnimationFrame(()=>this._updateMovement())}moveCameraForwardBackward(s){const u=s?5:-5,S=this._camera.instance.getWorldDirection(new e.Pa4),T=this._camera.instance.position.clone().add(S.multiplyScalar(u));T.y=this._camera.instance.position.y;const $=this._camera.controlsTarget.clone().add(T.clone().sub(this._camera.instance.position));this._camera.instance.position.set(T.x,T.y,T.z),this._camera.setControlsTarget($)}_rotateLookpoint(s){const u=this._camera.instance.position,S=this._camera.controlsTarget,F=(S.distanceTo(u),S.x-u.x),$=S.z-u.z,ue=Math.cos(s)*F-Math.sin(s)*$,Ie=Math.sin(s)*F+Math.cos(s)*$;S.set(u.x+ue,S.y,u.z+Ie),this._camera.setControlsTarget(S)}
1switchView(s){s==J.H.pedestrian?this._isPedestrian||(this._previousFreeCameraPosition.copy(this._camera.instance.position),this._previousFreeCameraRotation.copy(this._camera.instance.rotation),this._previousFreeCameraLookPoint.copy(this._camera.controlsTarget),this._animateCamera(new e.Pa4(this._previousPedestrianCameraPosition.x,this._previousPedestrianCameraPosition.y,this._previousPedestrianCameraPosition.z),new e.Pa4(this._previousPedestrianCameraLookPoint.x,this._previousPedestrianCameraLookPoint.y,this._previousPedestrianCameraLookPoint.z),!0),this._camera.toggleOrbitControls(!1),this._domRoot.addEventListener("mousedown",this.onMouseDown.bind(this)),this._domRoot.addEventListener("mousemove",this.onMouseMove.bind(this)),this._domRoot.addEventListener("mouseup",this.onMouseUp.bind(this)),this._domRoot.addEventListener("touchstart",this.onTouchStart.bind(this)),this._domRoot.addEventListener("touchmove",this.onTouchMove.bind(this)),this._domRoot.addEventListener("touchend",this.onTouchEnd.bind(this)),window.addEventListener("keydown",this._onKeyDown.bind(this)),window.addEventListener("keyup",this._onKeyUp.bind(this))):s==J.H.free&&this._isPedestrian&&(this._previousPedestrianCameraPosition.copy(this._camera.instance.position),this._previousPedestrianCameraRotation.copy(this._camera.instance.rotation),this._previousPedestrianCameraLookPoint.copy(this._camera.controlsTarget),this._animateCamera(new e.Pa4(this._previousFreeCameraPosition.x,this._previousFreeCameraPosition.y,this._previousFreeCameraPosition.z),new e.Pa4(this._previousFreeCameraLookPoint.x,this._previousFreeCameraLookPoint.y,this._previousFreeCameraLookPoint.z),!1),this._camera.toggleOrbitControls(!0),this._scene.traverse(u=>{u.name.startsWith("FreeSpaceCeiling")&&(u.visible=!1)}),this._domRoot.removeEventListener("mousedown",this.onMouseDown.bind(this)),this._domRoot.removeEventListener("mousemove",this.onMouseMove.bind(this)),this._domRoot.removeEventListener("mouseup",this.onMouseUp.bind(this)),this._domRoot.removeEventListener("touchstart",this.onTouchStart.bind(this)),this._domRoot.removeEventListener("touchmove",this.onTouchMove.bind(this)),this._domRoot.removeEventListener("touchend",this.onTouchEnd.bind(this)),window.removeEventListener("keydown",this._onKeyDown.bind(this)),window.removeEventListener("keyup",this._onKeyUp.bind(this)),this._destroyHoverRing())}_animateCamera(s,u,S){this._loadingOverlay&&"visible"===this._loadingOverlay.style.visibility?this._pendingCameraAnimation={targetPosition:s.clone(),targetLookpoint:u.clone(),isForPedestrian:S}:this._animateCameraInternal(s,u,S)}_animateCameraInternal(s,u,S){const T=this._camera.instance.position,F=this._camera.controlsTarget;this._cameraStateWatcher.value=!0,new l(T).to(s,2e3).easing(v.Quadratic.InOut).onUpdate(()=>{this._camera.instance.position.copy(T)}).start(),new l(F).to(u,2e3).easing(v.Quadratic.InOut).onUpdate(()=>{this._camera.setControlsTarget(new e.Pa4(F.x,F.y,F.z))}).start().onComplete($=>{this._cameraStateWatcher.value=!1,S?(this._camera.toggleOrbitControls(!1),this._isPedestrian=!0,this._scene.traverse(ue=>{ue.name.includes("FreeSpaceCeiling")&&(ue.visible=!0,ue.castShadow=!1)})):this._isPedestrian=!1})}_startPendingCameraAnimationAfterTinyDelay(){this._pendingCameraAnimation&&(null!==this._cameraAnimationDelayTimer&&window.clearTimeout(this._cameraAnimationDelayTimer),this._cameraAnimationDelayTimer=window.setTimeout(()=>{if(!this._pendingCameraAnimation)return;const s=this._pendingCameraAnimation;this._pendingCameraAnimation=null,this._cameraAnimationDelayTimer=null,this._animateCameraInternal(s.targetPosition,s.targetLookpoint,s.isForPedestrian)},80))}getUserPosition(){return this._camera&&this._camera.instance?new e.FM8(this._camera.instance.position.x,this._camera.instance.position.z):new e.FM8(0,0)}getUserRotationInDegres(){if(this._camera&&this._camera.instance){const s=new e.Pa4;return this._camera.instance.getWorldDirection(s),Math.atan2(s.x,-s.z)*(180/Math.PI)}return 0}}class _{constructor(s){this._cameraMovingSubject=new f.X(s)}get value(){return this._cameraMovingSubject.value}set value(s){this._cameraMovingSubject.value!==s&&this._cameraMovingSubject.next(s)}get changes(){return this._cameraMovingSubject.asObservable()}}},89416:(tt,me,P)=>{P.d(me,{ZP:()=>n});var e=P(8239),E=P(74617),X=P(28381),O=P(62831),v=P(26565);class h{constructor(p,y){this._mesh=p,this._boundingBox=y}get boundingBox(){return this._boundingBox}get position(){return this._mesh.position}set position(p){this._mesh.position.copy(p),this._mesh.updateMatrix(),this._mesh.updateMatrixWorld()}get rotatitonY(){return this._mesh.rotation.y}set rotatitonY(p){this._mesh.rotation.y=p,this._mesh.updateMatrix(),this._mesh.updateMatrixWorld()}get scale(){return this._mesh.scale}set scale(p){this._mesh.scale.copy(p),this._mesh.updateMatrix(),this._mesh.updateMatrixWorld()}set visible(p){this._mesh.visible=p}set(p,y,D){p&&this._mesh.position.copy(p),null!=y&&(this._mesh.rotation.y=y),D&&this._mesh.scale.copy(D),this._mesh.updateMatrix(),this._mesh.updateMatrixWorld()}}class g{constructor(p,y,D){this._parts=p,this._instanceIdx=y,this._boundingBox=D,this._translation=new E.Pa4(0,0,0),this._rotation=new E.USm,this._scale=new E.Pa4(1,1,1)}get boundingBox(){return this._boundingBox}get position(){return this._translation}get rotatitonY(){return this._rotation.y}set position(p){this._translation.copy(p).setZ(-p.z),this._updateMatrix()}set rotatitonY(p){this._rotation.y=p,this._updateMatrix()}get scale(){return this._scale}set scale(p){this._scale.copy(p),this._updateMatrix()}
1set visible(p){this._parts.forEach(y=>y.instanceMesh.visible=p)}set(p,y,D){p&&this._translation.copy(p).setZ(-p.z),null!=y&&(this._rotation.y=y),D&&this._scale.copy(D),this._updateMatrix()}_updateMatrix(){const p=(new E.yGw).makeScale(this._scale.x,this._scale.y,this._scale.z),y=(new E.yGw).makeRotationFromEuler(this._rotation),D=(new E.yGw).makeTranslation(this._translation);this._parts.forEach(Y=>{const H=new E.yGw;H.multiplyMatrices(p,Y.matrixWorld).multiplyMatrices(y,H).multiplyMatrices(D,H),Y.instanceMesh.setMatrixAt(this._instanceIdx,H),Y.instanceMesh.instanceMatrix.needsUpdate=!0})}}class r{get shouldLoad(){return this._modelBinding.shouldLoad}constructor(p,y,D){this._onLoadedClbk=D,this._boundingBox=null,this._maxInstanceCount=0,this._currentMaxInstanceCount=0,this._modelPartInfos=[],this._observers=[[]],this._modelBinding=new a(p,y),this._modelBinding.bindObserver(this._onModelLoaded.bind(this))}initMaxCount(p){this._modelBinding.shouldLoad&&(this._maxInstanceCount=p)}setCurrentMaxCount(p){this._modelPartInfos.length&&this._modelPartInfos.forEach(y=>y.instanceMesh.count=p),this._currentMaxInstanceCount=p}_onModelLoaded(p){if(!p)return this._observers.forEach(Y=>Y.forEach(H=>H(null))),void(this._observers=[]);this._boundingBox=(new E.ZzF).setFromObject(p),console.log(p.name);const y=this;(function D(Y,H){Y.matrixAutoUpdate=!1,Y.matrixWorldAutoUpdate=!1;const ne=(new E.yGw).multiplyMatrices(H,Y.matrix);if(Y instanceof E.Kj0){let K=!1;("reception_small"===Y.name||"reception_medium"===Y.name||"reception_large"===Y.name||"separator_140"===Y.name||"separator_160"===Y.name||"separator_180"===Y.name||"separator_200"===Y.name)&&(K=!0);const k=new E.SPe(Y.geometry,Y.material,y._maxInstanceCount);k.matrixAutoUpdate=!1,k.matrixWorldAutoUpdate=!1;const x=(new E.yGw).makeScale(0,0,0);for(let f=0;f<y._maxInstanceCount;f++)k.setMatrixAt(f,x);k.instanceMatrix.needsUpdate=!0,k.receiveShadow=!0,k.castShadow=!0,k.userData={...k.userData,shouldBeLighted:K},k.count=y._currentMaxInstanceCount,y._modelPartInfos.push({instanceMesh:k,matrixWorld:ne})}Y.children.forEach(K=>D(K,ne))})(p,new E.yGw),this._onLoadedClbk(this._modelPartInfos.map(Y=>Y.instanceMesh)),this._observers.forEach(Y=>{Y.forEach((H,ne)=>{H(new g(this._modelPartInfos,ne,this._boundingBox))})}),this._observers=[]}load(p){this._modelBinding.shouldLoad&&this._modelBinding.load(p)}bindObserver(p,y){if(this._modelPartInfos.length){if(this._currentMaxInstanceCount<this._maxInstanceCount){const D=new g(this._modelPartInfos,this._currentMaxInstanceCount,this._boundingBox);this.setCurrentMaxCount(this._currentMaxInstanceCount+1),p(D)}else{const D=this._modelBinding.cloneModel();D?(y.add(D),p(new h(D,this._boundingBox))):p(null)}return this._currentMaxInstanceCount}return this._modelBinding.shouldLoad?(this._observers[0].push(p),this._currentMaxInstanceCount<this._maxInstanceCount&&this.setCurrentMaxCount(this._currentMaxInstanceCount+1),this._currentMaxInstanceCount):(p(null),0)}unshifthNewObserverList(){this._observers.unshift([])}updateMatrix(){this._modelPartInfos.forEach(p=>p.instanceMesh.instanceMatrix.needsUpdate=!0)}dispose(){this._modelBinding.dispose(),this._modelPartInfos.forEach(p=>{p.instanceMesh.dispose(),p.instanceMesh=null,p.matrixWorld=null})}}class a{get url(){return this._url}get shouldLoad(){return!this._isLoading&&!this._isLoaded}constructor(p,y,D){this._url=p,this._isRemote=y,this._observers=[],this._isLoading=!1,this._isLoaded=!1,this._model=null,D&&this.load(D)}load(p,y){var D=this;return(0,e.Z)(function*(){if(!D.shouldLoad)return;D._isLoading=!0;const Y=yield p.load(D._url,D._isRemote,y);D._model=Y,Y&&Y.traverse(H=>{H.matrixAutoUpdate=!1,H.matrixWorldAutoUpdate=!1,H instanceof E.Kj0&&(H.receiveShadow=!0,v.U(H.material)?H.material.depthWrite=!1:H.castShadow=!0)}),D._observers.forEach(H=>H(Y)),D._isLoading=!1,D._isLoaded=!0,D._observers=[]})()}bindObserver(p){this._isLoaded?p(this._model):this._observers.push(p)}cloneModel(){const p=this._model?.clone(!0)||null;return p&&p.traverse(y=>{y.matrixAutoUpdate=!1,y.matrixWorldAutoUpdate=!1}),p}dispose(){this._model?.traverse(function(p){p instanceof E.Kj0&&(p.geometry.dispose(),p.material instanceof Array?(p.material.forEach(y=>v.N(y)),p.material=[]):(v.N(p.material),p.material=null))}),this._model=null}}class n{_updateInstancedMatrixes(){for(let p in this._partitions)this._partitions[parseInt(p)].updateMatrix();for(let p in this._furnitureProps)this._furnitureProps[parseInt(p)].updateMatrix()}_onFloorPlanQueried(p,y){}_setupFloorInfo(p,y){return{floorUid:{floorIndex:p.floorIndex,buildingIndexes:p.buildingIndexes},instanceCounts:{},binding:new a(p.model3d,!0)}}constructor(p,y,D,Y,H=null,ne=new E.lLk){this._rootScene=y,this._isInitializing=!0,this._loadQueue=[],this._floorPlans=[],this._furnitureProps={},this._partitions={},this._currentFloorItem=null,this._texturePromises={},this._textureCache={},this.loadingManager=ne,this._modelLoader=new X.h(p,this.loadingManager),this._textureLoader=new E.dpR,this._textureLoader.manager=this.loadingManager;const K=this._rootScene;if(!H||!H.scenarioMicroPackage)return void(this._floorPlans=D.map(L=>this._setupFloorInfo(L,null)));
1function k(L){L.forEach(ce=>K.add(ce))}H.partitionManager.materials.forEach(L=>{this._partitions[L.corner.id]=new r(L.corner.d3,!1,k),this._partitions[L.main.id]=new r(L.main.d3,!1,k),this._partitions[L.door.id]=new r(L.door.d3,!1,k)}),H.furnitureManager.furnitures.forEach(L=>{this._furnitureProps[L.id]=new r(L.model3d.url,!0,k)});const f=H.furnitureManager;D.forEach(L=>{const ce=function x(L){for(let ce of H.scenarioMicroPackage.floorUidPackageMap.values()){const ke=ce.fullUid.getFloorAndLotPartOrMinusOne();if(O.d.areFloorUIDEquals({floorIndex:ke[0],buildingIndexes:ke[1]},L))return ce.unpacked}return null}(L.targetFloor.createIFloorUid());if(!ce)return void this._floorPlans.push({floorUid:L.targetFloor.createIFloorUid(),instanceCounts:{},binding:new a(L.model3d,!0)});let ke={floorUid:L.targetFloor.createIFloorUid(),instanceCounts:{},binding:new a(L.model3d,!0)};if(ce.partitions.forEach(Xe=>{Xe.spans.forEach(te=>{const ye=-("boolean"==typeof te.door?te.material.door.id:te.material.main.id);ye in ke.instanceCounts||(ke.instanceCounts[ye]={isPartition:!0,maxCount:0}),ke.instanceCounts[ye].maxCount++})}),ce.partitionCorners.forEach(Xe=>{const te=-Xe.material.corner.id;te in ke.instanceCounts||(ke.instanceCounts[te]={isPartition:!0,maxCount:0}),ke.instanceCounts[te].maxCount++}),ce.decorativeFurnitures.forEach(Xe=>{const te=f._queryFurniture(null,Xe)?.id;te&&(te in ke.instanceCounts||(ke.instanceCounts[te]={isPartition:!1,maxCount:0}),ke.instanceCounts[te].maxCount++)}),L.hasMicro){const Xe=te=>{te.placedFurnitureAndAccesses.forEach(ye=>{if(ye.isFurniture){const Ae=ye.furniture.id;Ae in ke.instanceCounts||(ke.instanceCounts[Ae]={isPartition:!1,maxCount:0}),ke.instanceCounts[Ae].maxCount++}})};L.placedDepartments.forEach(te=>{te.coveredSpaceGroups.forEach(ye=>{ye.osFurnitureBlocks.forEach(Xe),ye.officeStates.forEach(Ae=>{Ae.furnitureBlocks.forEach(Xe)})})}),L.placedModules.forEach(te=>{te.furnitureBlocks.forEach(Xe)})}else ce.departments.forEach(Xe=>{Xe.areas.forEach(te=>{te.modules.forEach(ye=>{ye.furnitures.forEach(Ae=>{const Ee=f._queryFurniture(ye.programModule.module,Ae)?.id;Ee&&(Ee in ke.instanceCounts||(ke.instanceCounts[Ee]={isPartition:!1,maxCount:0}),ke.instanceCounts[Ee].maxCount++)})})})}),ce.modules.forEach(Xe=>{Xe.furnitures.forEach(te=>{const ye=f._queryFurniture(Xe.programModule.module,te)?.id;ye&&(ye in ke.instanceCounts||(ke.instanceCounts[ye]={isPartition:!1,maxCount:0}),ke.instanceCounts[ye].maxCount++)})});this._floorPlans.push(ke)});let J={};this._floorPlans.forEach(L=>{for(let ce in L.instanceCounts){const ke=parseInt(ce),Xe=L.instanceCounts[ke];ke in J?Xe.maxCount>J[ke].maxCount&&(J[ke].maxCount=Xe.maxCount):J[ke]={...Xe}}});for(let L in J){const ce=parseInt(L),ke=J[ce];ke.isPartition?this._partitions[-ce]?.initMaxCount(ke.maxCount):this._furnitureProps[ce]?.initMaxCount(ke.maxCount)}}initNewFloor(){for(let p in this._partitions)this._partitions[parseInt(p)].unshifthNewObserverList();for(let p in this._furnitureProps)this._furnitureProps[parseInt(p)].unshifthNewObserverList()}loadTexture(p){if(this._textureCache[p])return Promise.resolve(this._textureCache[p]);if(this._texturePromises[p])return this._texturePromises[p];const y=new Promise((D,Y)=>{const H=this._textureLoader.load(p,ne=>{ne.needsUpdate=!0,this._textureCache[p]=ne,D(ne)},void 0,ne=>{console.error(`Failed to load texture ${p}`,ne),Y(ne)});H&&(this._textureCache[p]=H)});return this._texturePromises[p]=y,y}concludeInitialization(){this._isInitializing=!1,this._loadQueue.forEach(p=>p.load(this._modelLoader)),this._loadQueue=[]}isInitializing(){return this._isInitializing}dispose(){this._floorPlans.forEach(p=>p.binding.dispose()),this._floorPlans=[];for(let p in this._partitions)this._partitions[parseInt(p)].dispose(),this._partitions[parseInt(p)]=null;for(let p in this._furnitureProps)this._furnitureProps[parseInt(p)].dispose(),this._furnitureProps[parseInt(p)]=null;Object.values(this._textureCache).forEach(p=>p.dispose()),this._textureCache={},this._texturePromises={},this._modelLoader.dispose(),this._rootScene=null}queryFurnitureProp(p,y){const D=this._furnitureProps[p];if(!D)return void console.error("Cannot query non-existing prop",p);const Y=D.bindObserver(y,this._rootScene);this._isInitializing&&this._loadQueue.push(D),this._currentFloorItem&&Y>this._currentFloorItem.instanceCounts[p].maxCount&&(this._currentFloorItem.instanceCounts[p].maxCount=Y)}queryPartitionPanel(p,y){const D=this._partitions[p];if(!D)return void console.error("Cannot query non-existing partition",p);const Y=D.bindObserver(y,this._rootScene);this._isInitializing&&this._loadQueue.push(D),this._currentFloorItem&&Y>this._currentFloorItem.instanceCounts[-p].maxCount&&(this._currentFloorItem.instanceCounts[-p].maxCount=Y)}queryFloorPlan(p){return new Promise((y,D)=>{const Y=H=>ne=>{if(ne){this._currentFloorItem=H;for(let K in this._partitions)this._partitions[parseInt(K)].setCurrentMaxCount(H.instanceCounts[-parseInt(K)]?.maxCount||0);for(let K in this._furnitureProps)this._furnitureProps[parseInt(K)].setCurrentMaxCount(H.instanceCounts[parseInt(K)]?.maxCount||0);y([ne,this._updateInstancedMatrixes.bind(this)])}else D()};for(let H of this._floorPlans)if(O.d.areFloorUIDEquals(H.floorUid,p)){H.binding.bindObserver(Y(H)),H.binding.shouldLoad&&H.binding.load(this._modelLoader);break}})}}},82703:(tt,me,P)=>{P.d(me,{Z:()=>E}
1);var e=P(10347);class E{get moduleUi(){return this._moduleUi}get svg(){return this._svg}constructor(O){this._svg=new e.G,this._moduleUi=O}dispose(){this._moduleUi=null,this._svg.remove()}}},90234:(tt,me,P)=>{P.d(me,{H:()=>e});var e=function(E){return E[E.free=0]="free",E[E.pedestrian=1]="pedestrian",E}(e||{})},25876:(tt,me,P)=>{P.d(me,{Z:()=>e});class e{constructor(X,O,v,h){this.targetType=X,this.targetFloor=O,this.infoUid=v,this.isLocked=h}_pickTarget(X){const O=X.propertyState.floors.find(v=>v.targetFloor===this.targetFloor);return O?"module"===this.targetType?O.placedModules.find(v=>v.info.uid===this.infoUid)||null:"departmentFloor"===this.targetType&&O.placedDepartments.find(h=>h.uid===this.infoUid)||null:null}do(X){const O=this._pickTarget(X);return O&&(O.isUserLocked=this.isLocked),!0}undo(X){const O=this._pickTarget(X);return O&&(O.isUserLocked=!this.isLocked),!0}dispose(){this.targetFloor=null}}},13084:(tt,me,P)=>{P.d(me,{Z:()=>E});var e=P(45250);class E{get commandType(){return"MoveRegularModuleCommand"}constructor(O,v){this._placeInfo=O,!this._placeInfo.uid&&0!==this._placeInfo.uid&&(this._placeInfo._uid=e.Z.generateRegularUid()),this._removeInfo=v,!this._removeInfo.uid&&0!==this._removeInfo.uid&&(this._removeInfo._uid=e.Z.generateRegularUid())}do(O){return O.removeModule(this._removeInfo),O.placeModule(this._placeInfo),!0}undo(O){return O.removeModule(this._placeInfo),O.placeModule(this._removeInfo),!0}dispose(){this._placeInfo?.dispose(),this._placeInfo=null,this._removeInfo?.dispose(),this._removeInfo=null}}},47875:(tt,me,P)=>{P.d(me,{Z:()=>E});var e=P(45250);class E{get commandType(){return"PlaceRegularModuleCommand"}constructor(O){this._info=O,!this._info.uid&&0!==this._info.uid&&(this._info._uid=e.Z.generateRegularUid())}do(O){return O.placeModule(this._info),!0}undo(O){return O.removeModule(this._info),!0}dispose(){this._info?.dispose(),this._info=null}}},42081:(tt,me,P)=>{P.d(me,{Z:()=>E});var e=P(45250);class E{get commandType(){return"RemoveDepartmentCommand"}constructor(O){this._info=O,!this._info.uid&&0!==this._info.uid&&(this._info._uid=e.Z.generateDepartmentFloorUid(),this._info.supAreaInfos.forEach(v=>v._uid=e.Z.generateDepartmentSupAreaUid()))}do(O){return console.debug("RemoveModuleCommand do",this),O.removeDepartmentFloor(this._info),!0}undo(O){return console.debug("RemoveModuleCommand undo",this),O.placeDepartmentFloor(this._info),!0}dispose(){this._info?.dispose(),this._info=null}}},33487:(tt,me,P)=>{P.d(me,{Z:()=>E});var e=P(45250);class E{get commandType(){return"RemoveRegularModuleCommand"}constructor(O){this._info=O,!this._info.uid&&0!==this._info.uid&&(this._info._uid=e.Z.generateRegularUid())}do(O){return O.removeModule(this._info),!0}undo(O){return O.placeModule(this._info),!0}dispose(){this._info?.dispose(),this._info=null}}},57152:(tt,me,P)=>{P.d(me,{Z:()=>e});class e{get commandType(){return"SwapDepartmentsCommand"}constructor(X,O,v,h){this._aRemoveInfo=X,this._aPlaceInfo=O,this._bRemoveInfo=v,this._bPlaceInfo=h}do(X){return X.removeDepartmentFloor(this._aRemoveInfo),X.removeDepartmentFloor(this._bRemoveInfo),X.placeDepartmentFloor(this._aPlaceInfo),X.placeDepartmentFloor(this._bPlaceInfo),!0}undo(X){return X.removeDepartmentFloor(this._aPlaceInfo),X.removeDepartmentFloor(this._bPlaceInfo),X.placeDepartmentFloor(this._aRemoveInfo),X.placeDepartmentFloor(this._bRemoveInfo),!0}dispose(){this._aRemoveInfo?.dispose(),this._aRemoveInfo=null,this._aPlaceInfo?.dispose(),this._aPlaceInfo=null,this._bRemoveInfo?.dispose(),this._bRemoveInfo=null,this._bPlaceInfo?.dispose(),this._bPlaceInfo=null}}},45250:(tt,me,P)=>{P.d(me,{Z:()=>r});let e=0,E=0,X=0,O=0,v=0,h=0,g=0;class r{static generateAreaUid(){const n=e;return e++,n}static generateRegularUid(){const n=E;return E++,n}static generateDepartmentFloorUid(){const n=X;return X++,n}static generateDepartmentSupAreaUid(){const n=O;return O++,n}static generateModuleSupAreaUid(){const n=v;return v++,n}static generateDepartmentModuleUid(){const n=h;return h++,n}static generateFurnitureBlockUid(){const n=g;return g++,n}}},96695:(tt,me,P)=>{P.d(me,{Z:()=>e});class e{get canUndo(){return this._cursorIdx>0&&this._commands.length>0}get canRedo(){return this._cursorIdx<this._commands.length}get cursorIndex(){return this._cursorIdx}constructor(X,O){this._sourceType=O,this._dirtyHandlers=[],this._commands=[],this._cursorIdx=0,this._targetState=X}do(X){X.do(this._targetState,!0),this._commands.splice(this._cursorIdx),this._commands.push(X),this._cursorIdx=this._commands.length,this.notifyHandlersAndConcludeDirty()}undo(){return!(!this.canUndo||!this._commands[this._cursorIdx-1].undo(this._targetState)||(this._cursorIdx--,this.notifyHandlersAndConcludeDirty(),0
1))}redo(){return!(!this.canRedo||!this._commands[this._cursorIdx].do(this._targetState,!1)||(this._cursorIdx++,this.notifyHandlersAndConcludeDirty(),0))}addDirtyHandler(X){this._dirtyHandlers.push(X),this._dirtyHandlers.sort((O,v)=>O.handlerPriority>v.handlerPriority?-1:O.handlerPriority<v.handlerPriority?1:0)}notifyHandlersAndConcludeDirty(){this._dirtyHandlers.forEach(X=>X.handleDirty(this._sourceType)),console.debug("Dirty handlers notified",this),this._targetState.concludeDirty()}dispose(){this._targetState=null,this._dirtyHandlers=null,this._commands.forEach(X=>X.dispose()),this._commands=null}}},74725:(tt,me,P)=>{P.d(me,{Xy:()=>E,pL:()=>e,wI:()=>X});const e=100,E=10;var X=function(O){return O[O.EditionState=0]="EditionState",O}(X||{})},91668:(tt,me,P)=>{P.d(me,{w:()=>e});var e=function(E){return E[E.IDLE=0]="IDLE",E[E.DIRTY=1]="DIRTY",E[E.DELETE=2]="DELETE",E}(e||{})},29283:(tt,me,P)=>{P.d(me,{m:()=>e});var e=function(E){return E.DELETE_ALL="DELETE_ALL",E.LOCK_ALL="LOCK_ALL",E.LOCK="LOCK",E.REMOVE="REMOVE",E}(e||{})},82445:(tt,me,P)=>{P.d(me,{R:()=>g});var e=P(56095),E=P(91955),X=P(45250),O=P(7425),v=P(34965),h=P(68385);class g{get uid(){return this._uid}get coveredSpace(){return this._coveredSpace}dispose(){this.programModule=null,this.pickedDimension=null,this._coveredSpace=null}clone(a){const n=a||new g;return n._uid=this._uid,n.programModule=this.programModule,n.pickedDimension=this.pickedDimension,n._coveredSpace=this._coveredSpace,n}baseBuildDragDropInfo(a){const n=a||new g;return n._uid=this._uid,n.programModule=this.programModule,n.pickedDimension=this.pickedDimension,n._coveredSpace=this._coveredSpace?this._coveredSpace:void 0,n}static fromJson(a,n,l){const p=l||new g;p._uid=X.Z.generateRegularUid();const y=a.programModuleOrigin||"program";if(a.dummyPMId&&a.programModuleId<=0){const D=a.dummyPMId[2]??null,Y=a.dummyPMId[1]??null,H=a.dummyPMId[0];Math.round(a.dummyPMId[3]||0),p.programModule=Object.values(n.getRefs(E.P.JKEY)).find(x=>!(x.module.id!==H||(x.furnitureShape?.id||null)!==Y||(x.furnitureSize?.id||null)!==D))||Object.values(n.getRefs(E.P.JKEY)).find(x=>x.module.id===H)}else"program"===y?(p.programModule=n.getStringKeyRef(E.P.JKEY,a.programModuleId),p.programModule||(p.programModule=n.getStringKeyRef(h.p.JKEY,-a.programModuleId))):(p.programModule=n.getStringKeyRef(h.p.JKEY,-a.programModuleId),p.programModule||(p.programModule=n.getStringKeyRef(E.P.JKEY,a.programModuleId)));return p.pickedDimension=a.pickedDimension?[n.getStringKeyRef(O.U.JKEY,a.pickedDimension[0]),n.getStringKeyRef(v.j.JKEY,a.pickedDimension[1]),[a.pickedDimension[2][0],a.pickedDimension[2][1],a.pickedDimension[2][2]]]:[null,null,[0,0]],p._coveredSpace=a.coveredSpace?e.mg.fromJson(a.coveredSpace):void 0,p}static toJson(a){let n={programModuleId:a.programModule.id,programModuleOrigin:a.programModule.origin,pickedDimension:a.pickedDimension[0]&&a.pickedDimension[1]?[a.pickedDimension[0].id,a.pickedDimension[1].id,[a.pickedDimension[2][0],a.pickedDimension[2][1],a.pickedDimension[2][2]||0]]:[0,0,[0,0]],coveredSpace:a._coveredSpace?e.mg.toJson(a._coveredSpace):void 0};return a.programModule.id<=0&&(n.dummyPMId=[a.programModule.module.id,a.programModule.furnitureShape?.id||null,a.programModule.furnitureSize?.id||null,a.programModule.customCapacity||null,a.programModule.customName||null,a.programModule.customArea||null]),n}}},28395:(tt,me,P)=>{P.d(me,{O:()=>l});var e=P(56095),E=P(78376),X=P(91955),O=P(21449),v=P(35934),h=P(45250),g=P(7425),r=P(34965),a=P(82445),n=P(56786);class l{get uid(){return this._uid}constructor(y=!1){this.supAreaInfos=[],this.susAreaInfos=[],y||(this._uid=h.Z.generateDepartmentFloorUid())}clone(){const y=new l(!0);return y._uid=this._uid,y.department=this.department,y.floor=this.floor,y.supAreaInfos=this.supAreaInfos.map(D=>D.clone()),y.susAreaInfos=this.susAreaInfos.map(D=>D.clone()),y}dispose(){this.department=null,this.supAreaInfos?.forEach(y=>y.dispose()),this.supAreaInfos=null,this.susAreaInfos?.forEach(y=>y.dispose()),this.susAreaInfos=null,this.floor=null}isEquivalent(y){return this.department===y.department&&this.floor===y.floor&&this.supAreaInfos.length===y.supAreaInfos.length&&this.supAreaInfos.every(D=>y.supAreaInfos.some(Y=>Y.isEquivalent(D)))&&this.susAreaInfos.every(D=>y.susAreaInfos.some(Y=>Y.isEquivalent(D)))}static fromJson(y,D,Y){const H=new l;return H.department=D.getStringKeyRef(E.v.JKEY,y.department),H.floor=D.getStringKeyRef(v.O.JKEY,v.O.createStringKey(y.floor)),H.supAreaInfos=y.supAreaInfos.map(ne=>l.SupAreaInfo.fromJson(ne,D)),H.susAreaInfos=y.susAreaInfos?.map(ne=>l.SusAreaInfo.fromJson(ne,D))??[],H.microPlacedWorkstations=Y?.departmentWorkstations?.[H.department.name],H}static toJson(y){return{department:y.department.name,floor:y.floor.createI
1FloorUid(),supAreaInfos:y.supAreaInfos.map(D=>l.SupAreaInfo.toJson(D)),susAreaInfos:y.susAreaInfos?.map(D=>l.SusAreaInfo.toJson(D))??[]}}}!function(p){class y{dispose(){this.gridUid=null}clone(){const x=new y;return x.gridUid=this.gridUid,x.bottomLeft=[...this.bottomLeft],x.topRight=[...this.topRight],x.furnitureCentroid=this.furnitureCentroid?[...this.furnitureCentroid]:void 0,x.corridorSide=this.corridorSide,x}static fromJson(x,f){const J=new y;return J.gridUid=O.ph.fromJson(x.gridUid),J.bottomLeft=[...x.bottomLeft],J.topRight=[...x.topRight],J.furnitureCentroid=x.furnitureCentroid?[...x.furnitureCentroid]:void 0,J.corridorSide=x.corridorSide,J}static toJson(x){return{gridUid:O.ph.toJson(x.gridUid),bottomLeft:[...x.bottomLeft],topRight:[...x.topRight],furnitureCentroid:x.furnitureCentroid?[...x.furnitureCentroid]:void 0,corridorSide:x.corridorSide}}}p.SupExtraSus=y;class D{get uid(){return this._uid}constructor(x=!1){this.dynamicSectionItemIdxes={},this.tileInfos=[],this.programModules=[],this.susExtras=[],this.isUserLocked=!1,this.openspaceFurnitureBlocks=[],x||(this._uid=h.Z.generateDepartmentSupAreaUid())}clone(){const x=new D(!0);return x._uid=this._uid,x.supAreaFullUid=new O.ph(this.supAreaFullUid),x.dynamicSectionItemIdxes={...this.dynamicSectionItemIdxes},x.tileInfos=this.tileInfos.map(f=>f instanceof O.ph?new O.ph(f):{tileUid:new O.ph(f.tileUid),startOffset:f.startOffset,endOffset:f.endOffset,sideIsStart:f.sideIsStart}),x.coveredSpace=this.coveredSpace,x.programModules=this.programModules.map(f=>f.clone()),x.susExtras=this.susExtras.map(f=>f.clone()),x.isUserLocked=this.isUserLocked,x.openspaceFurnitureBlocks=this.openspaceFurnitureBlocks.map(f=>f.clone()),x}isEquivalent(x){return!!(this.supAreaFullUid.equals(x.supAreaFullUid)&&this.tileInfos.length===x.tileInfos.length&&Object.values(this.dynamicSectionItemIdxes).length===Object.values(x.dynamicSectionItemIdxes).length&&this.programModules.length===x.programModules.length&&Object.entries(this.dynamicSectionItemIdxes).every(([f,J])=>{const L=x.dynamicSectionItemIdxes[Number(f)];return!(void 0===L||L!==J)})&&this.programModules.every(f=>x.programModules.some(J=>J.isEquivalent(f))))&&this.tileInfos.every(f=>{const J=f instanceof O.ph;return x.tileInfos.some(L=>J&&L instanceof O.ph?f.equals(L):!J&&"object"==typeof L&&"tileUid"in L&&f.tileUid.equals(L.tileUid)&&f.startOffset===L.startOffset&&f.endOffset===L.endOffset&&(f.sideIsStart??null)===(L.sideIsStart??null))})}dispose(){this.supAreaFullUid=null,this.dynamicSectionItemIdxes=null,this.tileInfos=null,this.coveredSpace=null,this.programModules?.forEach(x=>x.programModule=null),this.programModules=null,this.susExtras?.forEach(x=>x.dispose()),this.susExtras=null,this.openspaceFurnitureBlocks?.forEach(x=>x.dispose()),this.openspaceFurnitureBlocks=null}static fromJson(x,f){const J=new D;return J.supAreaFullUid=O.ph.fromJson(x.supAreaFullUid),J.dynamicSectionItemIdxes="object"==typeof x.dynamicSectionItemIdxes?Object.entries(x.dynamicSectionItemIdxes).reduce((L,[ce,ke])=>(L[Number(ce)]=ke,L),{}):{},J.tileInfos=x.tileInfos.map(L=>Array.isArray(L)?O.ph.fromJson(L):{tileUid:O.ph.fromJson(L.tileUid),startOffset:L.startOffset,endOffset:L.endOffset,sideIsStart:L.sideIsStart}),J.coveredSpace=e.mg.fromJson(x.coveredSpace),J.programModules=x.programModules.map(L=>ne.fromJson(L,f)),J.susExtras=x.susExtras?.map(L=>y.fromJson(L,f))??[],J.isUserLocked=!!x.isLocked,J.openspaceFurnitureBlocks=x.openspaceMicroInfo?x.opensp
1aceMicroInfo.map(L=>n.j7.fromJson(L,f)):[],J}static toJson(x){return{supAreaFullUid:O.ph.toJson(x.supAreaFullUid),dynamicSectionItemIdxes:x.dynamicSectionItemIdxes,tileInfos:x.tileInfos.map(f=>f instanceof O.ph?O.ph.toJson(f):{tileUid:O.ph.toJson(f.tileUid),startOffset:f.startOffset,endOffset:f.endOffset,sideIsStart:f.sideIsStart}),coveredSpace:e.mg.toJson(x.coveredSpace),programModules:x.programModules.map(f=>ne.toJson(f)),susExtras:x.susExtras?.length>0?x.susExtras.map(f=>y.toJson(f)):void 0,isLocked:x.isUserLocked||void 0,openspaceMicroInfo:x.openspaceFurnitureBlocks.length>0?x.openspaceFurnitureBlocks.map(f=>n.j7.toJson(f)):void 0}}}p.SupAreaInfo=D;class Y{constructor(){this.programModules=[],this.isUserLocked=!1,this.openspaceFurnitureBlocks=[]}get uid(){return this._uid}clone(){const x=new Y;return x._uid=this._uid,x.indirectLightUid=new O.ph(this.indirectLightUid),x.gridUid=new O.ph(this.gridUid),x.rects=[...this.rects],x.coveredSpace=this.coveredSpace,x.programModules=this.programModules.map(f=>f.clone()),x.openspaceFurnitureBlocks=this.openspaceFurnitureBlocks.map(f=>f.clone()),x.isUserLocked=this.isUserLocked,x}isEquivalent(x){if(!this.gridUid.equals(x.gridUid)||this.rects.length!==x.rects.length||this.programModules.length!==x.programModules.length)return!1;const f=(ce,ke)=>ce[0][0]-ke[0][0]||ce[0][1]-ke[0][1]||ce[1][0]-ke[1][0]||ce[1][1]-ke[1][1],J=[...this.rects].sort(f),L=[...x.rects].sort(f);return!(!J.every((ce,ke)=>ce[0][0]===L[ke][0][0]&&ce[0][1]===L[ke][0][1]&&ce[1][0]===L[ke][1][0]&&ce[1][1]===L[ke][1][1])||!this.programModules.every(ce=>x.programModules.some(ke=>ke.isEquivalent(ce))))}dispose(){this.indirectLightUid=null,this.gridUid=null,this.coveredSpace=null,this.programModules?.forEach(x=>x.programModule=null),this.programModules=null,this.openspaceFurnitureBlocks.forEach(x=>x.dispose()),this.openspaceFurnitureBlocks=[]}static fromJson(x,f){const J=new Y;return J._uid=h.Z.generateDepartmentSupAreaUid(),J.indirectLightUid=O.ph.fromJson(x.indirectLightUid),J.gridUid=O.ph.fromJson(x.gridUid),J.rects=x.rects,J.coveredSpace=e.mg.fromJson(x.coveredSpace),J.programModules=x.programModules.map(L=>K.fromJson(L,f)),J.isUserLocked=!!x.isLocked,J.openspaceFurnitureBlocks=x.openspaceMicroInfo?x.opensp
1aceMicroInfo.map(L=>n.j7.fromJson(L,f)):[],J}static toJson(x){return{indirectLightUid:O.ph.toJson(x.indirectLightUid),gridUid:O.ph.toJson(x.gridUid),rects:x.rects,coveredSpace:e.mg.toJson(x.coveredSpace),programModules:x.programModules.map(f=>K.toJson(f)),isLocked:x.isUserLocked||void 0,openspaceMicroInfo:x.openspaceFurnitureBlocks.length>0?x.openspaceFurnitureBlocks.map(f=>n.j7.toJson(f)):void 0}}}p.SusAreaInfo=Y;class H{get uid(){return this._uid}constructor(x=!1){this.coveredSpace=null,this.subRegularInfo=null,this.isCloset=!1,this.furnitureBlocks=[],x||(this._uid=h.Z.generateDepartmentModuleUid())}clone(x){const f=x||new H(!0);return f._uid=this._uid,f.programModule=this.programModule,f.placedCount=this.placedCount,f.pickedDimension=this.pickedDimension,f.coveredSpace=this.coveredSpace,f.subRegularInfo=this.subRegularInfo?.clone()||null,f.isCloset=this.isCloset,f.furnitureBlocks=this.furnitureBlocks.map(J=>J.clone()),f}isEquivalent(x){return this.programModule===x.programModule&&this.placedCount===x.placedCount}static fromJson(x,f,J){const L=J||new H;return L.programModule=f.getStringKeyRef(X.P.JKEY,x.programModuleId),L.placedCount=x.placedCount,L.coveredSpace=x.coveredSpace?e.mg.fromJson(x.coveredSpace):null,L.pickedDimension=x.pickedDimension?[f.getStringKeyRef(g.U.JKEY,x.pickedDimension[0]),f.getStringKeyRef(r.j.JKEY,x.pickedDimension[1]),[x.pickedDimension[2][0],x.pickedDimension[2][1],x.pickedDimension[2][2]]]:[null,null,[0,0]],x.subRegularInfo&&(L.subRegularInfo=a.R.fromJson(x.subRegularInfo,f)),L.isCloset=!!x.isCloset,x.microInfo&&(L.furnitureBlocks=x.microInfo.map(ce=>n.j7.fromJson(ce,f))),L}static toJson(x){let f={programModuleId:x.programModule?.id||0,placedCount:x.placedCount,pickedDimension:x.pickedDimension?x.pickedDimension[0]&&x.pickedDimension[1]?[x.pickedDimension[0].id,x.pickedDimension[1].id,[x.pickedDimension[2][0],x.pickedDimension[2][1],x.pickedDimension[2][2]||0]]:[0,0,[0,0]]:void 0,coveredSpace:x.coveredSpace?e.mg.toJson(x.coveredSpace):null,subRegularInfo:x.subRegularInfo?a.R.toJson(x.subRegularInfo):void 0};return f.isCloset=x.isCloset||void 0,x.furnitureBlocks.length>0&&(f.microInfo=x.furnitureBlocks.map(J=>n.j7.toJson(J))),f}}p.BaseProgramModuleInfo=H;class ne extends H{constructor(){super(...arguments),this.tileInfos=[],this.furnitureCentroidTile=null,this.furnitureCentroidOffsetX=null,this.furnitureCentroidDepth=null,this.extraSus=null}clone(){const x=new ne;return super.clone(x),x.tileInfos=this.tileInfos,x.furnitureCentroidTile=this.furnitureCentroidTile,x.furnitureCentroidOffsetX=this.furnitureCentroidOffsetX,x.furnitureCentroidDepth=this.furnitureCentroidDepth,x.extraSus=this.extraSus?.clone()||null,x}static fromJson(x,f){const J=new ne;return super.fromJson(x,f,J),J.tileInfos=x.tileInfos.map(L=>Array.isArray(L)?O.ph.fromJson(L):{tileUid:O.ph.fromJson(L.tileUid),startOffset:L.startOffset,endOffset:L.endOffset,sideIsStart:L.sideIsStart}),J.furnitureCentroidTile=x.furnitureCentroidTile?O.ph.fromJson(x.furnitureCentroidTile):null,J.furnitureCentroidOffsetX=x.furnitureCentroidOffsetX??null,J.furnitureCentroidDepth=x.furnitureCentroidDepth??null,J.extraSus=x.extraSus?y.fromJson(x.extraSus,f):null,J}static toJson(x){let f={...super.toJson(x),tileInfos:x.tileInfos.map(J=>J instanceof O.ph?O.ph.toJson(J):{tileUid:O.ph.toJson(J.tileUid),startOffset:J.startOffset,endOffset:J.endOffset,sideIsStart:J.sideIsStart})};return x.furnitureCentroidTile&&(f.furnitureCentroidTile=O.ph.toJson(x.furnitureCentroidTile),f.furnitureCentroidOffsetX=x.furnitureCentroidOffsetX,f.furnitureCentroidDepth=x.furnitureCentroidDepth),x.extraSus&&(f.extraSus=y.toJson(x.extraSus)),f}}p.SupProgramModuleInfo=ne;class K extends H{clone(){const x=new K;return super.clone(x),x.bottomLeft=[this.bottomLeft[0],this.bottomLeft[1]],x.topRight=[this.topRight[0],this.topRight[1]],x.furnitureCentroid=this.furnitureCentroid?[this.furnitureCentroid[0],this.furnitureCentroid[1]]:void 0,x.corridorSide=this.corridorSide,x}static fromJson(x,f){const J=new K;return super.fromJson(x,f,J),J.bottomLeft=x.bottomLeft,J.topRight=x.topRight,J.furnitureCentroid=x.furnitureCentroid,J.corridorSide=x.corridorSide,J}static toJson(x){return{...super.toJson(x),bottomLeft:x.bottomLeft,topRight:x.topRight,furnitureCentroid:x.furnitureCentroid,corridorSide:x.corridorSide}}}p.SusProgramModuleInfo=K}(l||(l={}))},42893:(tt,me,P)=>{P.d(me,{l:()=>r});var e=P(47318),E=P(56095),X=P(21449),O=P(35934),v=P(82445),h=P(56786),g=P(45250);class r extends v.R{constructor(){super(...arguments),this.supFragments=[],this.susFragments=[],this.corridorFragments=null,this.angle=null,this.isUserLocked=!1,this.furnitureBlocks=[]}_ensureSusFragment(){return this._susFragment??=new r.SusAreaInfo}get indirectLightUid(){return this._susFragment?.indirectLightUid}set indirectLightUid(n){null!=n?this._ensureSusFragment().indirectLightUid=n:this._susFragment&&(this._susFragment.indirectLightUid=n)}get gridUid(){return this._susFragment?.gridUid}set gridUid(n){null!=n?this._ensureSusFragment().gridUid=n:this._susFragment&&(this._susFragment.gridUid=n)}get bottomLeft(){return this._susFragment?.bottomLeft}set bottomLeft(n){null!=n?this._ensureSusFragment().bottomLeft=n:this._susFragment&&(this._susFragment.bottomLeft=n)}get topRight(){return this._susFragment?.topRight}set topRight(n){null!=n?this._ensureSusFragment().topRight=n:this._susFragment&&(this._susFragment.topRight=n)}get isMultiInfo(){return this.supFragments.length+this.susFragments.length>0}get isCoreRoom(){return!!this.coreRoom&&!this.isMultiInfo}get isSupInfo(){return!!this.supAreaInfo&&!this.isMultiInfo}get isSusInfo(){return!!this._susFragment&&!this.isMultiInfo}getAllSupFragments(){return this.isMultiInfo?this.supFragments:this.supAreaInfo?[this.supAreaInfo]:[]}getAllSusFragments(){return this.isMultiInfo?this.susFragments:this._susFragment?[this._susFragment]:[]}get coveredSpace(){return this._coveredSpace||this.supAreaInfo?.coveredSpace||this.coreRoom?.coveredSpace()||null}get actualArea(){const n=this.coveredSpace;if(!n)return 0;const l=e.SO(n);return!this.corridorFragments||e.xb(this.corridorFragments)?l:l-e.SO(this.corridorFragments)}clone(){const n=new r;return this.baseBuildDragDropInfo(n),n.floor=this.floor,n.coreRoom=this.coreRoom,n._susFragment=this._susFragment?this._susFragment.clone():void 0,n.supAreaInfo=this.supAreaInfo?this.supAreaInfo.clone():void 0,n.supFragments=this.supFragments.map(l
1=>l.clone()),n.susFragments=this.susFragments.map(l=>l.clone()),n.corridorFragments=this.corridorFragments,n.angle=this.angle,n.isUserLocked=this.isUserLocked,n.furnitureBlocks=this.furnitureBlocks.map(l=>l.clone()),n}dispose(){super.dispose(),this.floor=null,this.coreRoom=null,this._susFragment?.dispose(),this._susFragment=null,this.supAreaInfo?.dispose(),this.supAreaInfo=null,this.supFragments?.forEach(n=>n.dispose()),this.supFragments=[],this.susFragments?.forEach(n=>n.dispose()),this.susFragments=[],this.corridorFragments=null,this.angle=null,this.furnitureBlocks.forEach(n=>n.dispose()),this.furnitureBlocks=[]}buildDragDropInfo(n){const l=new r;return this.baseBuildDragDropInfo(l),l.floor=this.floor,l.coreRoom=this.coreRoom,l._susFragment=this._susFragment?this._susFragment.clone():void 0,l.supAreaInfo=this.supAreaInfo?this.supAreaInfo.clone():void 0,l.supFragments=this.supFragments.map(p=>p.clone()),l.susFragments=this.susFragments.map(p=>p.clone()),l.corridorFragments=this.corridorFragments,l.angle=this.angle,l.isUserLocked=n,l}isEquivalent(n){return this.isSupInfo===n.isSupInfo&&this.isSusInfo===n.isSusInfo&&this.isMultiInfo===n.isMultiInfo&&this.coreRoom==n.coreRoom&&(this.isMultiInfo?this.programModule===n.programModule&&this.floor===n.floor&&this.supFragments.length===n.supFragments.length&&this.susFragments.length===n.susFragments.length&&this.supFragments.every(l=>n.supFragments.some(p=>p.isEquivalent(l)))&&this.susFragments.every(l=>n.susFragments.some(p=>p.isEquivalent(l))):this.isSusInfo?this.programModule===n.programModule&&this.floor===n.floor&&this.indirectLightUid.equals(n.indirectLightUid)&&this.gridUid.equals(n.gridUid)&&this.bottomLeft[0]===n.bottomLeft[0]&&this.bottomLeft[1]===n.bottomLeft[1]&&this.topRight[0]===n.topRight[0]&&this.topRight[1]===n.topRight[1]:this.isSupInfo?this.programModule===n.programModule&&this.floor===n.floor&&this.supAreaInfo.isEquivalent(n.supAreaInfo):this.programModule===n.programModule&&this.floor===n.floor)}static fromJson(n,l){const p=new r;return v.R.fromJson(n,l,p),p.floor=l.getStringKeyRef(O.O.JKEY,O.O.createStringKey(n.floor)),p.coreRoom=n.coreRoomFromLotUid?p.floor.getElement(X.ph.fromJson(n.coreRoomFromLotUid)):void 0,p.indirectLightUid=n.indirectLightUid?X.ph.fromJson(n.indirectLightUid):void 0,p.gridUid=n.gridUid?X.ph.fromJson(n.gridUid):void 0,p.bottomLeft=n.bottomLeft?[n.bottomLeft[0],n.bottomLeft[1]]:void 0,p.topRight=n.topRight?[n.topRight[0],n.topRight[1]]:void 0,p.supAreaInfo=n.supAreaInfo?r.SupAreaInfo.fromJson(n.supAreaInfo):void 0,p.supFragments=n.supFragments?.map(y=>r.SupAreaInfo.fromJson(y))??[],p.susFragments=n.susFragments?.map(y=>r.SusAreaInfo.fromJson(y))??[],p.corridorFragments=n.corridorFragments?E.Kk.fromJson(n.corridorFragments):null,p.angle="number"==typeof n.angle?n.angle:null,p.isUserLocked=!!n.isLocked,n.microInfo&&(p.furnitureBlocks=n.microInfo.map(y=>h.j7.fromJson(y,l))),p}static toJson(n){let l={...super.toJson(n),floor:n.floor.createIFloorUid(),coreRoomFromLotUid:n.coreRoom?X.ph.toJson(n.coreRoom.fullUid.consumeUidParts()[0]):void 0,indirectLightUid:n.indirectLightUid?X.ph.toJson(n.indirectLightUid):void 0,gridUid:n.gridUid?X.ph.toJson(n.gridUid):void 0,bottomLeft:n.bottomLeft?[n.bottomLeft[0],n.bottomLeft[1]]:void 0,topRight:n.topRight?[n.topRight[0],n.topRight[1]]:void 0,supAreaInfo:n.supAreaInfo?r.SupAreaInfo.toJson(n.supAreaInfo):void 0,supFragments:n.supFragments?.length>0?n.supFragments.map(p=>r.SupAreaInfo.toJson(p)):void 0,susFragments:n.susFragments?.length>0?n.susFragments.map(p=>r.SusAreaInfo.toJson(p)):void 0,corridorFragments:n.corridorFragments&&!e.xb(n.corridorFragments)?E.Kk.toJson(n.corridorFragments):void 0,angle:"number"==typeof n.angle?n.angle:void 0,isLocked:n.isUserLocked||void 0};return n.furnitureBlocks.length>0&&(l.microInfo=n.furnitureBlocks.map(p=>h.j7.toJson(p))),l}}!function(a){class n{get uid(){return this._uid}constructor(y=!1){this.dynamicSectionItemIdxes={},this.tileInfos=[],y||(this._uid=g.Z.generateModuleSupAreaUid())}clone(){const y=new n(!0);return y._uid=this._uid,y.supAreaFullUid=new X.ph(this.supAreaFullUid),y.dynamicSectionItemIdxes={...this.dynamicSectionItemIdxes},y.tileInfos=this.tileInfos.map(D=>
1D instanceof X.ph?new X.ph(D):{tileUid:new X.ph(D.tileUid),startOffset:D.startOffset,endOffset:D.endOffset,sideIsStart:D.sideIsStart}),y.coveredSpace=this.coveredSpace,y}isEquivalent(y){return!(!this.supAreaFullUid.equals(y.supAreaFullUid)||this.tileInfos.length!==y.tileInfos.length)&&this.tileInfos.every(D=>{const Y=D instanceof X.ph;return y.tileInfos.some(H=>Y&&H instanceof X.ph?D.equals(H):!Y&&"object"==typeof H&&"tileUid"in H&&D.tileUid.equals(H.tileUid)&&D.startOffset===H.startOffset&&D.endOffset===H.endOffset&&(D.sideIsStart??null)===(H.sideIsStart??null))})}dispose(){this.supAreaFullUid=null,this.dynamicSectionItemIdxes=null,this.tileInfos=null,this.coveredSpace=null}static fromJson(y){const D=new n;return D.supAreaFullUid=X.ph.fromJson(y.supAreaFullUid),D.dynamicSectionItemIdxes="object"==typeof y.dynamicSectionItemIdxes?Object.entries(y.dynamicSectionItemIdxes).reduce((Y,[H,ne])=>(Y[Number(H)]=ne,Y),{}):{},D.tileInfos=(y.tileInfos??[]).map(Y=>Array.isArray(Y)?X.ph.fromJson(Y):{tileUid:X.ph.fromJson(Y.tileUid),startOffset:Y.startOffset,endOffset:Y.endOffset,sideIsStart:Y.sideIsStart}),D.coveredSpace=E.mg.fromJson(y.coveredSpace),D}static toJson(y){return{supAreaFullUid:X.ph.toJson(y.supAreaFullUid),dynamicSectionItemIdxes:y.dynamicSectionItemIdxes,tileInfos:y.tileInfos.map(D=>D instanceof X.ph?X.ph.toJson(D):{tileUid:X.ph.toJson(D.tileUid),startOffset:D.startOffset,endOffset:D.endOffset,sideIsStart:D.sideIsStart}),coveredSpace:E.mg.toJson(y.coveredSpace)}}}a.SupAreaInfo=n;class l{clone(){const y=new l;return y.indirectLightUid=this.indirectLightUid?new X.ph(this.indirectLightUid):this.indirectLightUid,y.gridUid=this.gridUid?new X.ph(this.gridUid):this.gridUid,y.bottomLeft=this.bottomLeft?[this.bottomLeft[0],this.bottomLeft[1]]:this.bottomLeft,y.topRight=this.topRight?[this.topRight[0],this.topRight[1]]:this.topRight,y.coveredSpace=this.coveredSpace,y}isEquivalent(y){return!!this.indirectLightUid?.equals(y.indirectLightUid)&&!!this.gridUid?.equals(y.gridUid)&&this.bottomLeft?.[0]===y.bottomLeft?.[0]&&this.bottomLeft?.[1]===y.bottomLeft?.[1]&&this.topRight?.[0]===y.topRight?.[0]&&this.topRight?.[1]===y.topRight?.[1]}dispose(){this.indirectLightUid=null,this.gridUid=null,this.bottomLeft=null,this.topRight=null,this.coveredSpace=null}static fromJson(y){const D=new l;return D.indirectLightUid=X.ph.fromJson(y.indirectLightUid),D.gridUid=X.ph.fromJson(y.gridUid),D.bottomLeft=[y.bottomLeft[0],y.bottomLeft[1]],D.topRight=[y.topRight[0],y.topRight[1]],D.coveredSpace=y.coveredSpace?E.mg.fromJson(y.coveredSpace):void 0,D}static toJson(y){return{indirectLightUid:X.ph.toJson(y.indirectLightUid),gridUid:X.ph.toJson(y.gridUid),bottomLeft:[y.bottomLeft[0],y.bottomLeft[1]],topRight:[y.topRight[0],y.topRight[1]],coveredSpace:y.coveredSpace?E.mg.toJson(y.coveredSpace):void 0}}}a.SusAreaInfo=l}(r||(r={}))},56786:(tt,me,P)=>{P.d(me,{BM:()=>g,j7:()=>a,t0:()=>r});var e=P(56095),E=P(47318),X=P(45250),O=P(5959),v=P(68003),h=P(71884);class g{get accessType(){return this.access.accessType}translateBy(l,p){this.coveredSpace&&(this.coveredSpace=E.Uf(this.coveredSpace,E.pJ(l,p)))}dispose(){this.access=null}static fromUnpacked(l,p){const y=new g;return y.access=l,y.coveredSpace=E.tf(p.position,2.5),y}static fromJson(l,p){const y=new g;return y.access=p.getStringKeyRef(v.C.JKEY,l.accessTypeId),y.coveredSpace=e.mg.fromJson(l.coveredSpace),y}static toJson(l){return{accessTypeId:l.access.id?.toString()||"",coveredSpace:e.mg.toJson(l.coveredSpace)}}}class r{translateBy(l,p){this.position&&(this.position=E.Pu(this.position.getX()+l,this.position.getY()+p)),this.coveredSpace&&(this.coveredSpace=E.Uf(this.coveredSpace,E.pJ(l,p)))}dispose(){this.furniture=null}static fromUnpacked(l,p){const y=new r;return y.furniture=l,y.coveredSpace=E.tf(E.Pu(0,0),2.5),y.position=p.position,y.rotation=E.$B(p.rotation),y}static fromJson(l,p){const y=new r;return y.furniture=p.getStringKeyRef(h.l.JKEY,l.furnitureId),y.coveredSpace=e.mg.fromJson(l.coveredSpace),y.position=e.E9.fromJson(l.position),y.rotation=E.$B(e.E9.fromJson(l.rotation)),y}static toJson(l){return{furnitureId:l.furniture?.id||0,typeId:l.furniture?.type?.id??void 0,shapeId:l.furniture?.shape?.id??void 0,sizeId:l.furniture?.size?.id??void 0,coveredSpace:e.mg.toJson(l.coveredSpace),position:e.E9.toJson(l.position),rotation:e.E9.toJson(E.Pu(Math.cos(l.rotation),Math.sin(l.rotation)))}}}class a{get uid(){return this._uid}get furnitureBlock(){return this._furnitureBlock}get coveredSpace(){return this._coveredSpace}get position(){return this._position}get rotation(){return this._rotation}get wsGroup(){return this._wsGroup}get furnitures(){return this._furnitures}
1get pureAccesses(){return this._pureAccesses}constructor(l=!1){this._wsGroup=null,this._furnitures=[],this._pureAccesses=[],l||(this._uid=X.Z.generateFurnitureBlockUid())}dispose(){this._furnitureBlock=null,this._coveredSpace=null,this._position=null,this._furnitures.forEach(l=>l.dispose()),this._furnitures=[],this._pureAccesses.forEach(l=>l.dispose()),this._pureAccesses=[]}translateBy(l,p){this._position&&(this._position=E.Pu(this._position.getX()+l,this._position.getY()+p)),this._coveredSpace&&(this._coveredSpace=E.Uf(this._coveredSpace,E.pJ(l,p))),this._furnitures.forEach(y=>y.translateBy(l,p)),this._pureAccesses.forEach(y=>y.translateBy(l,p))}clone(){const l=new a(!0);return l._uid=this._uid,l._coveredSpace=this._coveredSpace,l._position=this._position,l._rotation=this._rotation,l._wsGroup=this._wsGroup,l._furnitureBlock=this._furnitureBlock,l._furnitures=this._furnitures.map(p=>{const y=new r;return y.furniture=p.furniture,y.coveredSpace=p.coveredSpace,y.position=p.position,y.rotation=p.rotation,y}),l._pureAccesses=this._pureAccesses.map(p=>{const y=new g;return y.access=p.access,y.coveredSpace=p.coveredSpace,y}),l}static fromUnpacked(l){const p=new a;return p._furnitureBlock=l.block,p._position=l.position,p._rotation=E.$B(l.rotation),p._pureAccesses=l.pureAccesses.map(y=>{const D=l.block.accesses.find(Y=>Y.accessType===y.accessType);return D?g.fromUnpacked(D,y):null}).filter(y=>null!==y),p}rebuildCoveredSpace(){this._coveredSpace=E.b3(E.lE(E.lD([...this._furnitures.map(l=>l.coveredSpace),...this._pureAccesses.map(l=>l.coveredSpace)]),2.5))}static fromJson(l,p){const y=new a;return y._position=e.E9.fromJson(l.position),y._rotation=E.$B(e.E9.fromJson(l.rotation)),y._furnitureBlock=p.getStringKeyRef(O.z.JKEY,l.blockId),y._wsGroup="number"==typeof l.wsGroup?l.wsGroup:null,y._furnitures=l.furnitures.map(D=>r.fromJson(D,p)),y._pureAccesses=l.pureAccesses.map(D=>g.fromJson(D,p)),y.rebuildCoveredSpace(),y}static toJson(l){return{blockId:l._furnitureBlock?.id||0,wsGroup:l._wsGroup??void 0,position:e.E9.toJson(l._position),rotation:{x:Math.cos(l._rotation),y:Math.sin(l._rotation)},furnitures:l._furnitures.map(y=>r.toJson(y)),pureAccesses:l._pureAccesses.map(y=>g.toJson(y))}}}},60816:(tt,me,P)=>{P.d(me,{E:()=>e,d:()=>O});var e=function(v){return v[v.DESK=0]="DESK",v[v.MEETING=1]="MEETING",v[v.UTILITY=2]="UTILITY",v}(e||{});const E=new Map([[e.DESK,"desk"],[e.MEETING,"meeting"],[e.UTILITY,"utility"]]),X=new Map([[e.DESK,"red"],[e.MEETING,"green"],[e.UTILITY,"blue"]]);class O{static typeToStr(h){switch(h){case e.DESK:return"desk";case e.MEETING:return"meeting";default:return"utility"}}static strToType(h){switch(h){case"desk":return e.DESK;case"meeting":return e.MEETING;default:return e.UTILITY}}static typeToColor(h){return X.get(h)}get type(){return this._type}get translationKey(){return E.get(this._type)}get color(){return X.get(this._type)}constructor(h){this._type=h}dispose(){}}},44553:(tt,me,P)=>{P.d(me,{n:()=>v});var e=P(60816);class E{get departmentRequirement(){return this._departmentRequirement}get name(){return this._departmentRequirement.name}get color(){return this._departmentRequirement.color}get order(){return this._departmentRequirement.inputOrder}constructor(g){this._departmentRequirement=g}dispose(){this._departmentRequirement=null}}class X{get category(){return this._moduleDefinition.category.type.toLowerCase()}get subCategory(){return this._useTypeAndCategory?this._moduleDefinition.category.names:null}get moduleDefinition(){return this._moduleDefinition}get moduleCategory(){return this._moduleDefinition.category}get moduleRequirement(){return this._moduleRequirement}get furnitureSize(){return this._furnitureSize}get furnitureShape(){return this._furnitureShape}get customName(){return this._moduleRequirement?.customName||""}get customCapacity(){return this._moduleRequirement?.customCapacity||null}get customArea(){return this._moduleRequirement?.customArea||null}get isCustom(){return this._moduleDefinition.isCustom}get moduleName(){return this._moduleDefinition.names}get customOrModuleName(){return this.customName||this.moduleName}get customOrCapacity(){return this._moduleRequirement?.customOrCapacity||this._moduleDefinition.capacity}get svgId(){return(this.moduleRequirement||this._moduleDefinition).thumbnail}get color(){return this._customColor||this._moduleDefinition.color}constructor(g,r,a,n,l,p,y,D){this._moduleRequirement=null,this._useTypeAndCategory=!1,this._furnitureSize=null,this._furnitureShape=null,this._customColor=null,g&&(this._moduleDefinition=r,this._useTypeAndCategory=a||!1,this._furnitureSize=n||null,this._furnitureShape=l||null,this._moduleRequirement=g.program.findRegularRequirement
1(this._moduleDefinition.id,this._furnitureSize,this._furnitureShape,p,y,D))}dispose(){this._moduleDefinition=null,this._moduleRequirement=null,this._furnitureSize=null,this._furnitureShape=null}static create(g,r){let a=new X;return a._useTypeAndCategory=r,a._moduleDefinition=g.module,a._moduleRequirement=g,a._furnitureSize=g.furnitureSize,a._furnitureShape=g.furnitureShape,a}}var O=P(42400);class v{get areaOptions(){return this._areaOptions}get departmentOptions(){return this._departmentOptions}get meetingOptions(){return this._meetingOptions}get utilityOptions(){return this._utilityOptions}get customUtilityModule(){return this._customUtilityModule}get customFormalMeetingModule(){return this._customFormalMeetingModule}findOrCreateCustomUtilityOption(g){let r=this._utilityOptions.find(a=>g.areEquivalent(a.moduleRequirement));return r||(r=X.create(g,!0),this._utilityOptions.push(r),r)}findOrCreateCustomFormalMeetingOption(g){let r=this._meetingOptions.find(a=>g.areEquivalent(a.moduleRequirement));return r||(r=X.create(g,!0),this._meetingOptions.push(r),r)}createDepartmentOption(g){let r=this._departmentOptions.find(a=>a.name===g.name);return r&&(r.dispose(),this._departmentOptions.splice(this._departmentOptions.indexOf(r),1)),r=new E(g),this._departmentOptions.push(r),r}constructor(g){this._areaOptions=[],this._departmentOptions=[],this._meetingOptions=[],this._utilityOptions=[],this._customUtilityModule=null,this._customFormalMeetingModule=null,console.debug("[ModelizationOptionManager] Creating with program:",g.program),console.debug("[ModelizationOptionManager] Program departments:",g.program?.departments),console.debug("[ModelizationOptionManager] Program departments count:",g.program?.departments?.length),this._areaOptions=[new e.d(e.E.DESK),new e.d(e.E.MEETING),new e.d(e.E.UTILITY)],this._departmentOptions=(g.program?.departments||[]).map(r=>new E(r)),console.debug("[ModelizationOptionManager] Created departmentOptions:",this._departmentOptions.length),g.moduleManager.modules.filter(r=>r.isPicked&&!r.category.isComposition).forEach(r=>{switch(r.category.type){case O.G9.COLLABORATIVE:r.isCustom?this._customFormalMeetingModule=r:this._meetingOptions.push(new X(g,r,!0));break;case O.G9.UTILITY:r.isCustom?this._customUtilityModule=r:r.furniturePickers.forEach(a=>{this._utilityOptions.push(new X(g,r,!0,a.size,a.shape))})}}),g.program.customMeetings.forEach(r=>{this._meetingOptions.push(X.create(r,!0))}),g.program.customUtilities.forEach(r=>{this._utilityOptions.push(X.create(r,!0))}),g.program.reception&&this._utilityOptions.push(X.create(g.program.reception,!0))}dispose(){this._areaOptions.forEach(g=>g.dispose()),this._departmentOptions.forEach(g=>g.dispose()),this._meetingOptions.forEach(g=>g.dispose()),this._utilityOptions.forEach(g=>g.dispose()),this._areaOptions=[],this._departmentOptions=[],this._meetingOptions=[],this._utilityOptions=[]}}},161:(tt,me,P)=>{P.d(me,{Z:()=>e});class e{get optionState(){return this._optionState}get dirtyState(){return this._optionState.dirtyState}get name(){return this._optionState.name}get color(){return this._optionState.color}get order(){return this._optionState.order}get remainCount(){return this._optionState.remainCount}get requiredCount(){return this._optionState.requiredCount}get remainingSurface(){return this._optionState.remainingSurface}get requiredSurface(){return this._optionState.requiredSurface}constructor(X){this._optionState=X}handleDirty(X){}dispose(){this._optionState=null}}},48707:(tt,me,P)=>{P.d(me,{Z:()=>n});class e{get optionState(){return this._optionState}get type(){return this._optionState.type}get color(){return this._optionState.color}constructor(p){this._optionState=p}handleDirty(p){}dispose(){this._optionState=null}}var E=P(161),X=P(60431),O=P(91668),v=P(36511),h=P(67399),g=P(42400);class r{constructor(p){this.category=p,this.options=[],this.highestCapacity=0}get name(){const p=this.category?.names?.en||"";return p.toLowerCase().includes("facility")||p.toLowerCase().includes("facilites")?"support-facilities":p.toLowerCase().includes("social")?"social-spaces":p.toLowerCase().replace(/\s+/g,"_")}dispose(){this.options=null,this.category=null}}class a{constructor(p){this.categoryType=p,this.subCategories=[],this.highestCapacity=0}get name(){switch(this.categoryType){case g.G9.DESK:return"desks";case g.G9.COLLABORATIVE:return"collaborative";case g.G9.UTILITY:return"support";default:return this.categoryType.toString().toLowerCase()}}
1dispose(){this.subCategories.forEach(p=>p.dispose()),this.subCategories=null}add(p){let y=this.subCategories.find(Y=>Y.category===p.moduleCategory);y||(y=new r(p.moduleCategory),this.subCategories.push(y)),y.options.push(p);const D=p.customOrCapacity||0;D>y.highestCapacity&&(y.highestCapacity=D),D>this.highestCapacity&&(this.highestCapacity=D)}}class n{get optionsState(){return this._optionsState}get areaOptionUIs(){return this._areaOptionUIs}get departmentOptionUIs(){return this._departmentOptionUIs}get meetingOptionUIs(){return this._meetingOptionUIs}get utilityOptionUIs(){return this._utilityOptionUIs}get meetingCategories(){return this._meetingCategories}get utilityCategories(){return this._utilityCategories}get utilitySizes(){return this._utilitySizes}constructor(p){this._areaOptionUIs=[],this._departmentOptionUIs=[],this._meetingOptionUIs=[],this._utilityOptionUIs=[],this._meetingCategories=[],this._utilityCategories=[],this._utilitySizes=[],console.debug("[OptionUI] Creating with optionManagerState:",p),console.debug("[OptionUI] departmentOptionStates count:",p.departmentOptionStates?.length),this._optionsState=p;const y=new Set;this._areaOptionUIs=p.areaOptionStates.map(ne=>new e(ne)),this._departmentOptionUIs=p.departmentOptionStates.map(ne=>new E.Z(ne)),console.debug("[OptionUI] Created departmentOptionUIs:",this._departmentOptionUIs.length),this._meetingOptionUIs=p.meetingOptionStates.map(ne=>new X.Z(ne)),this._utilityOptionUIs=p.utilityOptionStates.map(ne=>(ne.furnitureSize&&y.add(ne.furnitureSize),new X.Z(ne))),this._utilitySizes=Array.from(y).sort((ne,K)=>ne.listOrder-K.listOrder);const D=ne=>K=>{let k=ne.find(x=>x.categoryType===K.moduleCategory.type);
1k||(k=new a(K.moduleCategory.type),ne.push(k)),k.add(K)},Y=D(this._meetingCategories),H=D(this._utilityCategories);this._meetingOptionUIs.forEach(Y),this._utilityOptionUIs.forEach(H)}handleDirty(p){this._areaOptionUIs.forEach(D=>D.handleDirty(p)),this._departmentOptionUIs.forEach(D=>D.handleDirty(p)),this._meetingOptionUIs.forEach(D=>D.handleDirty(p));const y=D=>D.map(Y=>Y.dirtyState===O.w.DELETE?(Y.dispose(),null):Y).filter(Y=>!!Y);this._departmentOptionUIs=y(this._departmentOptionUIs),this._utilityOptionUIs=y(this._utilityOptionUIs),this._departmentOptionUIs.forEach(D=>D.handleDirty(p)),this._utilityOptionUIs.forEach(D=>D.handleDirty(p)),this._optionsState.newDirtyables.forEach(D=>{D instanceof v.Z?this._utilityOptionUIs.push(new X.Z(D)):D instanceof h.Z&&this._departmentOptionUIs.push(new E.Z(D))})}dispose(){this._optionsState=null,this._areaOptionUIs.forEach(p=>p.dispose()),this._departmentOptionUIs.forEach(p=>p.dispose()),this._meetingOptionUIs.forEach(p=>p.dispose()),this._utilityOptionUIs.forEach(p=>p.dispose()),this._areaOptionUIs=null,this._departmentOptionUIs=null,this._meetingOptionUIs=null,this._utilityOptionUIs=null,this._meetingCategories.forEach(p=>p.dispose()),this._utilityCategories.forEach(p=>p.dispose()),this._meetingCategories=null,this._utilityCategories=null}}},60431:(tt,me,P)=>{P.d(me,{Z:()=>e});class e{get optionState(){return this._optionState}get dirtyState(){return this._optionState.dirtyState}get moduleCategory(){return this._optionState.staticOption.moduleCategory}get category(){return this._optionState.category}get subCategory(){return this._optionState.subCategory}get customName(){return this._optionState.customName}get isCustom(){return this._optionState.isCustom}get moduleName(){return this._optionState.moduleName}get customOrModuleName(){return this._optionState.customOrModuleName}get svgId(){return this._optionState.svgId}get customOrCapacity(){return this._optionState.staticOption.customOrCapacity}get customArea(){return this._optionState.staticOption.customArea}get placedCount(){return this._optionState.placedCount}get requiredCount(){return this._optionState.requiredCount}get remainCount(){return this._optionState.remainCount}get color(){return this._optionState.staticOption.color}get furnitureSize(){return this._optionState.furnitureSize}get furnitureShape(){return this._optionState.furnitureShape}constructor(X){this._optionState=X}handleDirty(X){}dispose(){this._optionState=null}}},67870:(tt,me,P)=>{P.d(me,{Z:()=>e});class e{get placedElementState(){return this._placedElementState}get dirtyState(){return this._placedElementState.dirtyState}get dirtyable(){return this._placedElementState}constructor(X){this._placedElementState=X}dispose(){this._placedElementState=null}}},26352:(tt,me,P)=>{P.d(me,{Z:()=>E});var e=P(67870);class E extends e.Z{constructor(O){super(O)}dispose(){super.dispose()}}},91137:(tt,me,P)=>{P.d(me,{Z:()=>E});class e{constructor(O,v){this._moduleInfos=[],this._departmentInfos=[],this._moduleInfos=O,this._departmentInfos=v}do(O){return this._moduleInfos.forEach(v=>O.removeModule(v)),this._departmentInfos.forEach(v=>O.removeDepartmentFloor(v)),!0}undo(O){return this._departmentInfos.forEach(v=>O.placeDepartmentFloor(v)),this._moduleInfos.forEach(v=>O.placeModule(v)),!0}dispose(){this._departmentInfos=[],this._moduleInfos=[]}}function E(X){const O=[],v=[];return X.floors.forEach(h=>{h.placedModules.forEach(g=>O.push(g.info)),h.placedDepartments.forEach(g=>{g.supCoveredSpaceGroups.forEach(r=>{v.push(r.build())})})}),O.length||v.length?new e(O,v):null}},72657:(tt,me,P)=>{P.d(me,{Z:()=>E});class e{constructor(O){this.lockAll=O}_pickTargets(O){const v={departments:[],modules:[]};return O.propertyState.floors.forEach(h=>{v.modules.push(...h.placedModules),v.departments.push(...h.placedDepartments)}),v}do(O){return O.propertyState.globalLocked=this.lockAll,!0}undo(O){return O.propertyState.globalLocked=!this.lockAll,!0}dispose(){}}function E(X){return new e(!X.globalLocked)}},45802:(tt,me,P)=>{P.d(me,{eT:()=>ke,ek:()=>ce,rs:()=>h,wY:()=>Xe});var e=P(47318),E=P(48097),X=P(35418),O=P(28395);const v={deskToWall:45,deskToBench:90,tertiary:45,windowOffset:20};function h(te){let ye=null;try{const q=te?.settingId;for(const oe of te?.dimensions??[]){const ee=oe?.picker?.getSettings?.(q);if(ee){ye=ee;break}}}catch{ye=null}if(!ye)return{...v};const Ae=ye.deskToWallDistance,Ee=ye.deskToDeskDistance;return{deskToWall:Ae,deskToBench:Ee,tertiary:Math.max(0,Math.min(90,Ee-Ae)),windowOffset:ye.windowOffset}}function g(te){return!!te&&te.getMaxX()>=te.getMinX()&&te.getMaxY()>=te.getMinY()}function p(te,ye){if(!te||!ye)return te;try{const Ae=e.m0(te,ye);return Ae&&!e.xb(Ae)?Ae:te}catch{return te}}function D(te,ye){return(te??[]).filter(Ae=>!(!Ae||Ae.isCloset||!Ae.programModule||!Ae.coveredSpace||null!=ye&&Ae.programModule.id!==ye))}const K=2;function k(te,ye){try{return te&&ye&&e.kK(te,ye)?e.SO(e.m0(te,ye)):0}catch{return 0}}function f(te,ye){if(!ye.length)return-1;const Ae=te?.coveredSpace;let Ee=-1,q=0;if(ye.forEach((ee,Z)=>{const Q=k(Ae,ee);Q>q&&(q=Q,Ee=Z)}),Ee>=0)return Ee;const oe=function x(te){try{if(te?.position)return te.position}catch{}try{if(te?.coveredSpace)return e.Sc(te.coveredSpace)}catch{}return null}(te);if(oe){let ee=1/0;ye.forEach((Z,Q)=>{try{const V=e.TE(Z,oe);V<ee&&(ee=V,Ee=Q)}catch{}})}return Ee>=0?Ee:0}const ce=!1;function ke(te){if(!te||!te.length)return!1;const ye=new Set;return te.forEach(Ae=>{Ae?.department&&ye.add(Ae.department)}),1===ye.size}function Xe(te,ye,Ae=[]){if(!ce)return{modules:0,widened:0,blocks:0,areas:0};const Ee=te?.department?.openspace??null,q=Ee?.id??null,oe=h(Ee);let ee=0,Z=0,Q=0,V=0;
1[...te?.supAreaInfos??[],...te?.susAreaInfos??[]].forEach(de=>{const he=D(de?.programModules??[],q);he.length&&(ee+=he.length,ye&&he.forEach(ve=>{V=Math.max(V,function n(te,ye){const Ae=function a(te,ye){if(!(te&&ye&&ye[0]&&ye[1]))return null;try{const Ae=(0,E.rU)((0,E.E$)(te),[ye[0],ye[1],[ye[2][0],ye[2][1],ye[2][2]||0]]),Ee=ye[2][0]/2,q=ye[2][1]/2,oe=e.p([{x:-Ee,y:-q},{x:Ee,y:-q},{x:Ee,y:q},{x:-Ee,y:q},{x:-Ee,y:-q}]),ee=e.AZ(oe);let Z=null;return Ae.rules.forEach(Q=>{(0,X.rA)(Q,oe,ee),Q.isDefault&&Q.blocks.forEach(V=>{V.furnitures.forEach(U=>{U.coveredSpace&&(Z=Z?e.Y7(U.coveredSpace,Z):e.lD([U.coveredSpace]))})})}),!Z||e.xb(Z)?null:function r(te){try{const ye=te?.getEnvelopeInternal?.();return g(ye)?{w:ye.getMaxX()-ye.getMinX(),h:ye.getMaxY()-ye.getMinY()}:null}catch{return null}}(Z)}catch{return null}}(te,ye);return Ae&&ye?Math.max(0,Math.max(Ae.w-(ye[2][0]||0),Ae.h-(ye[2][1]||0))/2):0}(ye,ve.pickedDimension))}),Z+=function Y(te,ye,Ae,Ee,q=[]){const oe=te?.coveredSpace,ee=te?.programModules;if(!oe||!ee||!ee.length)return 0;const Z=[...ee];q.forEach(Te=>{if(Te)try{e.kK(Te,oe)&&Z.push({coveredSpace:Te,__obstacle:!0})}catch{}});const Q=D(Z,ye);if(!Q.length)return 0;const V=Ae.tertiary/2,U=Ae.tertiary+2*Ae.deskToWall,ae=new Map;Z.forEach(Te=>{Te?.coveredSpace&&ae.set(Te,Te.coveredSpace)});const de=Te=>{try{const Je=Te?.getEnvelopeInternal?.();return g(Je)?{x0:Je.getMinX(),y0:Je.getMinY(),x1:Je.getMaxX(),y1:Je.getMaxY()}:null}catch{return null}},ve=Te=>e.p([{x:Te.x0,y:Te.y0},{x:Te.x1,y:Te.y0},{x:Te.x1,y:Te.y1},{x:Te.x0,y:Te.y1},{x:Te.x0,y:Te.y0}]),be=new Map;Z.forEach(Te=>{const Je=de(ae.get(Te));Je&&be.set(Te,Je)});const Le=(Te,Je,Qe,st)=>{const et="x"===Je?"x0":"y0",Et="x"===Je?"x1":"y1",lt="x"===Je?"y0":"x0",i="x"===Je?"y1":"x1",d=Qe>0?Te[Et]:Te[et];let I=1/0,w=!1;if(be.forEach((_,o)=>{if(o===st||Math.min(Te[i],_[i])-Math.max(Te[lt],_[lt])<10)return;const s=Qe>0?_[et]-d:d-_[Et];if(s<-1)return;const u=Math.max(0,s);u<I&&(I=u,w=Q.indexOf(o)>=0)}),isFinite(I))return w?I/2:Math.min(I,U);try{const _={...Te};Qe>0?_[Et]=d+U:_[et]=d-U,Qe>0?_[et]=d:_[Et]=d;const o=e.m0(ve(_),oe),s=de(o);return!s||e.xb(o)?0:Math.max(0,Math.min(U,Qe>0?s[Et]-d:d-s[et]))}catch{return 0}};let Ye=0;return Q.forEach(Te=>{const Je=ae.get(Te);if(Je)try{const Qe=be.get(Te);let st;if(Qe&&((Te,Je)=>{try{const Qe=e.SO(Te),st=(Je.x1-Je.x0)*(Je.y1-Je.y0);return st>0&&Math.abs(Qe-st)/st<.02}catch{return!1}})(Je,Qe)){const lt={x0:Qe.x0-Le(Qe,"x",-1,Te),x1:Qe.x1+Le(Qe,"x",1,Te),y0:Qe.y0-Le(Qe,"y",-1,Te),y1:Qe.y1+Le(Qe,"y",1,Te)};st=p(ve(lt),oe)}else{if(!(V>0))return;st=p(function l(te,ye){if(!te||ye<=0)return te;try{const Ae=e.hq(te,ye);return Ae&&!e.xb(Ae)?Ae:te}catch{return te}}(Je,V),oe)}Z.forEach(lt=>{if(lt===Te)return;const i=ae.get(lt);i&&(st=function y(te,ye){if(!te||!ye)return te;try{const Ae=e.oo(te,ye);return Ae&&!e.xb(Ae)?Ae:te}catch{return te}}(st,i))});const et=e.b3(e.rY(st));if(!et||e.xb(et)||e.SO(et)<=e.SO(Je))return;let Et=!1;if(Z.forEach(lt=>{if(lt===Te||Et)return;const i=ae.get(lt);i&&k(et,i)>.5&&(Et=!0)}),Et)return;Te.coveredSpace=et,Ye++}catch{}}),Ye+=function H(te,ye,Ae,Ee){const oe=Math.max(6,K);let ee=0;const Z=(Q,V)=>{if(!Q||e.xb(Q))return null;if(!V)return Q;try{const U=e.oo(Q,V);return U&&!e.xb(U)?U:null}catch{return Q}};try{let Q=te;if(Ae.forEach(ae=>{const de=ae?.coveredSpace??Ee.get(ae);de&&Q&&(Q=Z(Q,de))}),!Q||e.xb(Q))return 0;const V=e.hq(e.hq(Q,-4),4);if(!V||e.xb(V))return 0;const U=[],re="function"==typeof V.getNumGeometries?V.getNumGeometries():0;for(let ae=0;ae<re;ae++){const de=V.getGeometryN(ae);de&&!e.xb(de)&&e.SO(de)>=1e4&&U.push(de)}U.sort((ae,de)=>e.SO(de)-e.SO(ae)),U.forEach(ae=>{let de=null,he=0;const ve=e.hq(ae,oe);if(ye.forEach(Je=>{const Qe=Je?.coveredSpace;if(!Qe)return;const st=k(ve,Qe);st>he&&(he=st,de=Je)}),!de||he<=0)return;const be=de.coveredSpace;let Le=e.Y7(be,e.hq(ae,oe/2));if(Le=p(Le,te),Ae.forEach(Je=>{if(Je===de||!Le)return;const Qe=Je?.coveredSpace??Ee.get(Je);Qe&&(Le=Z(Le,Qe))}),!Le)return;const Ye=e.b3(e.rY(Le));if(!Ye||e.xb(Ye)||e.SO(Ye)<=e.SO(be)+1)return;let Te=!1;Ae.forEach(Je=>{if(Je===de||Te)return;const Qe=Je?.coveredSpace??Ee.get(Je);Qe&&k(Ye,Qe)>.5&&(Te=!0)}),!Te&&(de.coveredSpace=Ye,ee++)})}catch{}return ee}(oe,Q,Z,ae),Ye}(de,q,oe,0,Ae),Q+=function ne(te,ye){const Ae=te?.openspaceFurnitureBlocks??[],Ee=D(te?.programModules??[],ye);if(!Ae.length||!Ee.length)return 0;Ee.forEach(ee=>{ee.furnitureBlocks=[]});let q=0;const oe=Ee.map(ee=>ee.coveredSpace);return Ae.forEach(ee=>{const Z=f(ee,oe);Z<0||(Ee[Z].furnitureBlocks.push(ee.clone()),q++)}),q}(de,q))});const re=function J(te,ye){const Ae=te?.supAreaInfos;
1if(!Ae||!Ae.length)return 0;const Ee=[];let q=0;return Ae.forEach(oe=>{const ee=D(oe.programModules??[],ye);if(ee.length<2)return void Ee.push(oe);const Z=(oe.programModules??[]).filter(he=>ee.indexOf(he)<0),Q=oe.openspaceFurnitureBlocks??[],V=new Set,U=[];if(ee.forEach(he=>{const ve=he.coveredSpace;if(!ve)return;const be=new O.O.SupAreaInfo;be.supAreaFullUid=oe.supAreaFullUid,be.dynamicSectionItemIdxes={...oe.dynamicSectionItemIdxes??{}},be.isUserLocked=!!oe.isUserLocked,be.susExtras=[],be.tileInfos=[...he.tileInfos??[]];let Le=ve;try{const Ye=e.hq(ve,-K/2);Ye&&!e.xb(Ye)&&(Le=e.b3(e.rY(Ye)))}catch{}be.coveredSpace=Le,be.programModules=[he],Z.forEach(Ye=>{V.has(Ye)||!Ye?.coveredSpace||k(Ye.coveredSpace,Le)>0&&(be.programModules.push(Ye),V.add(Ye))}),be.openspaceFurnitureBlocks=[],U.push(be)}),U.length<2)return void Ee.push(oe);const re=U.map(he=>he.coveredSpace);Q.forEach(he=>{const ve=f(he,re);U[ve<0?0:ve].openspaceFurnitureBlocks.push(he)});const ae=U[0];Z.forEach(he=>{V.has(he)||ae.programModules.push(he)});const de=new Set(U.flatMap(he=>he.tileInfos));(oe.tileInfos??[]).forEach(he=>{de.has(he)||ae.tileInfos.push(he)}),oe.susExtras?.length&&(ae.susExtras=[...oe.susExtras]),Ee.push(...U),q+=U.length}),q&&(te.supAreaInfos=Ee),q}(te,q),ae=re?0:function L(te,ye){const Ae=(te?.supAreaInfos??[]).filter(Z=>!!Z?.coveredSpace&&1===D(Z.programModules??[],ye).length);if(Ae.length<2)return 0;const Ee=Ae.map(Z=>Z.coveredSpace),q=[];if(Ae.forEach((Z,Q)=>{(Z.openspaceFurnitureBlocks??[]).forEach(V=>q.push({fb:V,from:Q}))}),!q.length)return 0;const oe=Ae.map(()=>[]);let ee=0;return q.forEach(({fb:Z,from:Q})=>{let V=f(Z,Ee);V<0&&(V=Q),oe[V].push(Z),V!==Q&&ee++}),ee&&Ae.forEach((Z,Q)=>{Z.openspaceFurnitureBlocks=oe[Q]}),ee}(te,q);return ee&&console.warn("[TESTFIT] bench sets treated as independent modules",{department:te?.department?.name,modules:ee,tertiariesIntegrated:Z,blocksAttached:Q,supAreasAfterSplit:re||(te?.supAreaInfos??[]).length,blocksRehomed:ae,recoils:oe,maxRecoilDeficitCm:Math.round(V)}),{modules:ee,widened:Z,blocks:Q,areas:re}}},89584:(tt,me,P)=>{P.d(me,{os:()=>Ys,Xc:()=>zi,ni:()=>Bs,ZP:()=>_s});var e=P(47318),E=P(45250);class X{get commandType(){return"MoveDepartmentCommand"}constructor(b,C){this._placeInfo=b,this._removeInfo=C,!this._placeInfo.uid&&0!==this._placeInfo.uid&&(this._placeInfo._uid=E.Z.generateDepartmentFloorUid(),this._placeInfo.supAreaInfos.forEach(A=>A._uid=E.Z.generateDepartmentSupAreaUid())),!this._removeInfo.uid&&0!==this._removeInfo.uid&&(this._removeInfo._uid=E.Z.generateDepartmentFloorUid(),this._removeInfo.supAreaInfos.forEach(A=>A._uid=E.Z.generateDepartmentSupAreaUid()))}do(b){return console.debug("MoveModuleCommand do",this),b.removeDepartmentFloor(this._removeInfo),b.placeDepartmentFloor(this._placeInfo),!0}undo(b){return console.debug("MoveModuleCommand undo",this),b.removeDepartmentFloor(this._placeInfo),b.placeDepartmentFloor(this._removeInfo),!0}dispose(){this._placeInfo?.dispose(),this._placeInfo=null,this._removeInfo?.dispose(),this._removeInfo=null}}class O{get commandType(){return"PlaceDepartmentCommand"}constructor(b){this._info=b,!this._info.uid&&0!==this._info.uid&&(this._info._uid=E.Z.generateDepartmentFloorUid(),this._info.supAreaInfos.forEach(C=>C._uid=E.Z.generateDepartmentSupAreaUid()))}do(b){return console.debug("PlaceModuleCommand do",this),b.placeDepartmentFloor(this._info),!0}undo(b){return console.debug("PlaceModuleCommand undo",this),b.removeDepartmentFloor(this._info),!0}dispose(){this._info?.dispose(),this._info=null}}var v=P(57152),h=P(42081),g=P(33487),r=P(13084),a=P(47875),n=P(37446),l=P(46376),p=P(38355),y=P(45802),D=P(28395),Y=P(42893),H=P(4516);function ne(m,b){return b.tile.sus?.isAtTileRangeBegin?b.tile.width-m:m}function K(m,b,C=!1){if(b.tile.sus&&!C){const A=b.tile.sus,R=ne(m,b),B=e.Sc(A.heightP2l),W=e.QH(B,A.fwdDir,R);return[!0,A.targetParsedGridShape.linkedShapeInfo().getPointCoord(W,A.cellSize,!0,!1)]}return[!1,b.tile.targetFlowMapTile.xToOffset(m,b)]}function k(m){return m.tile.targetFlowMapTile.computeUsedTile(m,!0)}function x(m){const b=m.tile.sus;let C=ne(m.x||0,m),A=ne((m.x||0)+m.partialOrWidth,m);C>A&&([C,A]=[A,C]);const R=e.Sc(b.heightP2l),B=e.hX(b.heightP2l),W=e.QH(R,b.fwdDir,C),j=e.QH(R,b.fwdDir,A),se=m.tile.height/2,le=e.p([e.QH(W,B,-se),e.QH(W,B,se),e.QH(j,B,se),e.QH(j,B,-se)]),_e=new D.O.SupExtraSus,Se=b.targetParsedGridShape.linkedShapeInfo();
1[_e.bottomLeft,_e.topRight]=Se.getRectangleCoords(le,b.cellSize);let Oe=Se.createPolygon(_e.bottomLeft,_e.topRight,b.cellSize);Oe=e.b3(e.m0(Oe,b.targetParsedGridShape.asPolygon())),_e.gridUid=b.targetParsedGridShape.uidInPackage();const Me=Se.getPointCoord(R,b.cellSize),Be=Se.getPointCoord(e.Pu(b.heightP2l.getCoordinateN(b.heightP2l.getNumPoints()-1))),Ne=Be[1]-Me[1],xe=Be[0]-Me[0];return _e.corridorSide=Math.abs(Ne)>Math.abs(xe)?Ne>0?"t":"b":xe>0?"r":"l",[_e,Oe]}function f(m){const b=[],C=[];for(const A of m)A.tile.sus?C.push(x(A)):b.push(k(A));return[b,C]}class J{constructor(){this.departmentInfo=null,this.dynamicMap=null,this.consumedWidth=0}}function L(m,b,C,A,R){const B=f(R)[0],W=ke(B,b,C),j=new Y.l;j.programModule=m,j.pickedDimension=A;const se=new Y.l.SupAreaInfo;return j.supAreaInfo=se,se.supAreaFullUid=b.directLight.fullUid,se.coveredSpace=W,se.dynamicSectionItemIdxes={...C},se.tileInfos=B.map(le=>le.asDict()),j}function ke(m,b=null,C=null,A=!1){null==C&&(C={});let R=e.lD();for(const B of m)R=e.Y7(B.createCoveredSpace(),R);if(R=e.lE(R,5),b){const B={...b.dynamicSectionItemIdx};if(C)for(const[W,j]of Object.entries(C))B[Number(W)]=j;for(const[W,j]of Object.entries(B)){const se=b.dynamicSectionStates[Number(W)].itemStates[j],le=se.secondaryCorridors;if(!le||e.xb(le))continue;const _e=se.corridorExtremityTiles.find(Se=>Se[1])?.[0]??null;_e&&m.some(Se=>Se.tile===_e)&&(R=e.lE(e.Y7(le,R),5))}}if(R.getNumGeometries()>1&&b){let B=R.getNumGeometries();for(let W=0;W<m.length;W++){const j=m[W],se=R,le=B;if(null==j.selfOrCurrentBeginOffset&&null==j.selfOrCurrentEndOffset)continue;if("boolean"==typeof j.sideIsStart){const[Me,Be]=j.createCoveredSpace(!0);if(e.lE(e.Y7(Be,se),1.5).getNumGeometries()<le){const xe=e.lE(e.Y7(Be,R),1.5);B=xe.getNumGeometries(),R=xe;continue}}const _e=j.clone();_e.beginOffset=null,_e.endOffset=null,_e.currentBeginOffset=null,_e.currentEndOffset=null;const Se=_e.createCoveredSpace(),Oe=e.lE(e.Y7(Se,R),1.5);Oe.getNumGeometries()<B&&(B=Oe.getNumGeometries(),R=Oe,m[W]=_e)}}return A?e.lE(R):e.b3(e.lE(R))}var Xe=P(36871),te=P(55656);const ye=!0;function Ee(m){const b=[];for(const C of m.dimensions){const A=C.hasNonDefaultRules()&&ye;for(const R of C.dimensions)b.push([[R[0],R[1]],[C.picker,C.layout,[R[0],R[1],R[2]]]]),A&&R[0]!==R[1]&&b.push([[R[1],R[0]],[C.picker,C.layout,[R[1],R[0],R[2]]]])}return new Xe.II({tiles:[],corners:[],susAreas:[],susLinks:[],offices:b.length>0?[new Xe.lk({programModule:m,required:1,widthHeights:b.map(C=>C[0]),dimensionSignatures:b.map(C=>C[1]),isPartitioned:m.module.isPartitioned,needWindow:!1})]:[],benches:[],requiredSeats:0,closetRowWidth:0,benchesBeforeCloset:0,benchesBeforeFirstCloset:0,windowOffset:0,distToWall:0,distBenchToBench:0,tertiaryCorridorWidth:0,runLeftToRight:!0,isStandaloneModule:!0})}const q=new WeakMap;function oe(m){return q.has(m)}function Z(m){return q.get(m)?.cornerTile??null}function Q(m,b,C){const A=[];if(C){const R=m.width-b;for(const B of m.posts){const W=B.x-R;W+B.width<=0||A.push(W<0?{...B,x:0,width:W+B.width}:{...B,x:W})}}else for(const R of m.posts)R.x>=b||A.push(R.x+R.width>b?{...R,width:b-R.x}:{...R});return A}function V(m,b){for(const C of m)if(C!==b)for(const[,A,,R]of C.tileRangeExtraInfos)if(R&&R.length>0)return[R[0],A];return null}function U(m){for(const[,,,b]of m.tileRangeExtraInfos)if(b&&b.length>0)return b[0];return null}function re(m,b){return`${m}:${b?1:0}`}const de=1e4;function he(m){return Math.round(m*de)}function ve(m){return m/de}function be(m){return he(m.width)}class Le{constructor(b,C,A){this.tile=b,this.x0=C,this.x1=A}get widthFixed(){return this.x1-this.x0}get isWholeTile(){return 0===this.x0&&this.x1===be(this.tile)}toUsedTile(){return new Xe.OB(this.tile,ve(this.x0),ve(this.x1-this.x0),oe(this.tile))}}function Ye(m){const b=[];for(const C of m)b.push(C instanceof Le?C:new Le(C,0,be(C)));return b}class Te{constructor(){this._byTile=new Map}occupied(b){return this._byTile.get(b)??[]}isFree(b,C,A){if(C<0||A>be(b)||C>=A)return!1;const R=this._byTile.get(b);if(!R)return!0;for(const B of R)if(C<B.x1&&B.x0<A)return!1;return!0}isSliceFree(b){return this.isFree(b.tile,b.x0,b.x1)}freeSegments(b){const C=be(b),A=this._byTile.get(b);if(!A||0===A.length)return C>0?[[0,C]]:[];const R=[];let B=0;for(const W of A)W.x0>B&&R.push([B,W.x0]),B=Math.max(B,W.x1);return B<C&&R.push([B,C]),R}
1freeSlices(b){return this.freeSegments(b).map(([C,A])=>new Le(b,C,A))}occupiedExtent(b){const C=this._byTile.get(b);if(!C||0===C.length)return null;let A=C[0].x0,R=C[0].x1;for(const B of C)B.x0<A&&(A=B.x0),B.x1>R&&(R=B.x1);return[A,R]}claim(b,C,A,R){if(!this.isFree(b,C,A))throw new Error(`claim [${C},${A}) on tile idx=${b.idx} is out of bounds or overlaps`);const B=this._byTile.get(b);B?(B.push({x0:C,x1:A,owner:R}),B.sort((W,j)=>W.x0-j.x0||W.x1-j.x1)):this._byTile.set(b,[{x0:C,x1:A,owner:R}])}claimSlice(b,C){this.claim(b.tile,b.x0,b.x1,C)}tiles(){return[...this._byTile.keys()]}}var Je=function(m){return m.BENCH="bench",m.CLOSET="closet",m.OFFICE="office",m}(Je||{});class Qe{constructor(b,C,A,R,B=0,W=null,j=null,se=null){this.kind=b,this.slices=C,this.bodySlices=A,this.benchOrOffice=R,this.usedDimensionIdx=B,this.centroidSliceIdx=W,this.centroidX=j,this.centroidY=se}get seats(){return this.kind===Je.BENCH&&this.benchOrOffice?this.benchOrOffice.seats:0}}class st{constructor(b,C,A,R,B){this.flatTiles=b,this.rangeIds=C,this.tileStartX=A,this.cornerTiles=R,this.stripWidth=B,this.ledger=new Te,this.placed=null}globalX(b){return(this.tileStartX.get(b.tile)??0)+ve(b.x0)}globalXEnd(b){return(this.tileStartX.get(b.tile)??0)+ve(b.x1)}get lastTile(){return this.flatTiles.length>0?this.flatTiles[this.flatTiles.length-1]:null}}const et=1e-6,Et=10;function lt(m){const b=[];let C=0;for(const A of m)b.push(C),C+=A.width;return b}function i(m,b,C){let A=null,R=null;for(const B of m.slices){const W=b.get(B.tile);if(void 0===W)return null;const j=C[W]+ve(B.x0),se=C[W]+ve(B.x1);A=null===A?j:Math.min(A,j),R=null===R?se:Math.max(R,se)}return null===A||null===R?null:[A,R-A]}function d(m,b,C,A){const R=C+A,B=[];for(let W=0;W<m.length;W++)b[W]+m[W].width<=C+et||b[W]>=R-et||B.push([W,m[W]]);return B}function I(m,b,C,A){const R=C+A,B=[];for(const[W,j]of d(m,b,C,A))for(const se of j.posts){const le=b[W]+se.x;le+se.width>C+et&&le<R-et&&B.push(se)}return B}const w=1;function _(m,b,C){let A=null,R=0;for(const B of m){const W=b.get(B.tile);if(void 0===W)continue;const j=C[W]+ve(B.x0),se=C[W]+ve(B.x1);(null===A||j<A)&&(A=j),se>R&&(R=se)}return null===A?null:[A,R]}function o(m,b,C,A,R,B){const W=[];for(const[j,se]of C)if(!(Math.abs(se-m)>=w&&Math.abs(j-b)>=w))for(const le of I(A,R,j,se-j))W.push({x:le.x,y:le.y,width:le.width,height:le.height+B});return W}function s(m,b,C,A,R){const B=d(m,b,C,A).map(([,W])=>W.height);return(B.length>0?Math.min(...B):0)-R}function u(m,b){const C=[],A=m.map(W=>[W.y,W.y+W.height]).sort((W,j)=>W[0]-j[0]);for(const[W,j]of A){const se=C[C.length-1];se&&W<=se[1]+et?se[1]=Math.max(se[1],j):C.push([W,j])}const R=[];let B=0;for(const[W,j]of C)W-B>et&&R.push([B,Math.min(W,b)]),B=j;return b-B>et&&R.push([B,b]),R.filter(([W,j])=>j-W>et)}function T(m,b,C){const A=b.length>0?u(b,C):[[0,C]],R=[];for(const[B,W]of A){const j=Math.min(W,C);if(j-B<m.height-et)continue;let se=B,le=j-m.height;B>et&&(se=Math.min(B+Et,le)),j<C-et&&(le=Math.max(j-Et-m.height,se)),R.push([se+m.height/2,le+m.height/2])}return R}function F(m,b){const C=new Set([b]);for(const R of m)for(const[B,W]of R)C.add(B),C.add(W),C.add(Math.max(B,Math.min(b,W)));let A=null;for(const R of[...C].sort((B,W)=>B-W)){let B=0;for(const j of m)j.some(([se,le])=>se-et<=R&&R<=le+et)&&B++;if(0===B)continue;const W=[-B,Math.abs(R-b),R];(null===A||W[0]<A[0]||W[0]===A[0]&&W[1]<A[1]||W[0]===A[0]&&W[1]===A[1]&&W[2]<A[2])&&(A=W)}return null===A?null:A[2]}function $(m,b,C,A){const R=C.filter(([Se,Oe])=>Oe-Se>=m.height-et);if(0===R.length)return null;let B=R.find(([Se,Oe])=>Se-et<=b&&b+m.height<=Oe+et);B||(B=R.reduce((Se,Oe)=>Oe[1]-Oe[0]>Se[1]-Se[0]?Oe:Se));const[W,j]=B;let se=(W+j)/2-m.height/2;const le=W>et?W+Et:0,_e=j<A-et?Math.min(j-Et,A)-m.height:A-m.height;return le<=_e&&(se=Math.max(le,Math.min(se,_e))),Math.max(0,Math.min(se,A-m.height))}function ue(m,b,C,A,R){const B=Math.max(0,Math.min(C,R-b.height));B+b.height<=R+et&&function S(m,b,C){return C.every(A=>m+b<=A.y+et||m>=A.y+A.height-et)}(B,b.height,A)&&(m.centroidY=B+b.height/2)}const Pe=1e6;class Ce{constructor(b=Pe){this._max=b,this._ops=0}tick(b=1){this._ops+=b}get exhausted(){return this._ops>=this._max}get spent(){return this._ops}}const Ue=3,Re=8;function De(m,b){return"boolean"==typeof m?m?b:0:Math.max(0,b-m)}function He(m,b,C){const A=m[b];if(!A)return null;for(const R of A)if(R.dynamicItemIdx===C)return R;return null}function rt(m){return Object.keys(m).map(b=>Number(b)).filter(b=>Number.isFinite(b)&&(m[b]?.length??0)>0).sort((b,C)=>b-C)}function Ge(m,b){let C=0,A=0;const R=b?.get(m);for(const[B,W,,j]of m.tileRangeExtraInfos){for(const le of j)C+=le.width,A=Math.max(A,le.height);const se=R?.get(re(B,W));void 0!==se&&(C+=se.width,A=Math.max(A,se.height))}return[C,A]}function mt(m,b,C,A=null){const R=m.map(_e=>({tiles:[..._e.tiles],startOnWall:_e.startOnWall,endOnWall:_e.endOnWall,startIsPartial:_e.startIsPartial,endIsPartial:_e.endIsPartial})),B=new Set,W=new Set,j=new Map;let se=0;for(const[_e,Se]of C){const Oe=He(b,_e,Se);if(!Oe)continue;const Me=A?.get(Oe);let Be=0;for(const[,,Ne,xe]of Oe.tileRangeExtraInfos)(!xe||0===xe.length)&&"number"==typeof Ne&&(Be=Math.max(Be,Ne));for(const[Ne,xe,ze,Fe]of Oe.tileRangeExtraInfos){if(!(Ne>=0&&Ne<R.length))continue;const qe=R[Ne],Ke="number"==typeof ze?ze:0;se=Math.max(se,Ke);const it=Me?.get(re(Ne,xe))??null;let $e;if(Fe&&Fe.length>0){const gt=Math.max(Ke,Be);for(const ct of Fe)B.add(ct),W.add(ct.idx),j.set(ct.idx,Math.max(j.get(ct.idx)??0,gt));qe.tiles=xe?[...Fe,...qe.tiles]:[...qe.tiles,...Fe],$e=ze,!(xe?qe.startIsPartial:qe.endIsPartial)&&Fe.some(ct=>ct.cornerIsInterior)&&($e=!1)}else null!==it?(qe.tiles=xe?[it,...qe.tiles]:[...qe.tiles,it],$e=!0):$e=ze;xe?qe.startOnWall=$e:qe.endOnWall=$e}}return{ranges:R,cornerTiles:B,irrigation:W.size>0?{cornerTileIdxs:W,tileOverride:j,maxOverride:se}:null}}function ti(m,b){return[...m].sort((C,A)=>{const[R,B]=Ge(C,b),[W,j]=Ge(A,b);return W-R||j-B||C.dynamicItemIdx-A.dynamicItemIdx}).slice(0,Ue).map(C=>C.dynamicItemIdx)}var zt=function(m){return m.NOTHING_PLACED="nothing_placed",m.INFEASIBLE_GEOMETRY="infeasible_geometry",m.OVERLAP_CONFLICT="overlap_conflict",m.CONTINUITY_VIOLATION="continuity_violation",m.OUT_OF_SLICE="out_of_slice",m.START_TOO_FAR="start_too_far",m}(zt||{});const Pt=[zt.OVERLAP_CONFLICT,zt.CONTINUITY_VIOLATION,zt.OUT_OF_SLICE,zt.START_TOO_FAR,zt.NOTHING_PLACED];function xt(m){for(const b of Pt)if(m.has(b))return b;return zt.NOTHING_PLACED}function Jt(m){for(const b of m)if(b.x0<0||b.x1>be(b.tile)||b.x0>=b.x1)return!1;return!0}function $t(m,b){for(const C of b)if(!m.isSliceFree(C))return!1;return!0}function Wt(m,b){if(0===m.length)return!1;const C=[...m].sort((R,B)=>(b.get(R.tile)??0)-(b.get(B.tile)??0)),A=b.get(C[0].tile);if(void 0===A)return!1;for(let R=0;R<C.length;R++){const B=C[R];if(b.get(B.tile)!==A+R||B.x0>=B.x1)return!1;if(R>0){const W=C[R-1];if(W.x1!==be(W.tile)||0!==B.x0)return!1}}return!0}function Ft(m,b,C,A){for(const B of b)if(B.kind===Je.OFFICE)for(const W of B.slices)m.officed.add(W.tile.idx);const R=B=>{const W=Z(B.tile);null!==W&&m.reached.add(W.idx)};for(const B of C)R(B);for(const B of A)for(const W of B)R(W)}function Zt(m,b,C,A){if(0===m.length||0===A.size)return{spans:m,sw:b,ew:C};const R=B=>{const W=Z(B.tile);return null!==W&&A.has(W.idx)};return R(m[0])?{spans:m.slice(1),sw:!0,ew:C}:m.length>1&&R(m[m.length-1])?{spans:m.slice(0,-1),sw:b,ew:!0}:{spans:m,sw:b,ew:C}}function Bt(m,b){const C=[];for(const R of m.slices)R.tile===b&&C.push([R.x0,R.x1]);if(0===C.length)return!1;C.sort((R,B)=>R[0]-B[0]);let A=0;for(const[R,B]of C){if(R>A)return!1;B>A&&(A=B)}return A>=be(b)}function Mi(m){return m.reached}const ft=1e-6;function wi(m,b){const C=m.length,A=new Array(C),R=new Array(C),B=new Array(C),W=new Array(C);let j=0;for(let se=0;se<C;se++){const le=m[se];A[se]=le.tile,R[se]=ve(le.x0),B[se]=0===le.x0&&le.x1===be(le.tile)?le.tile.width:ve(le.x1-le.x0),W[se]=j,j+=B[se]}return{spans:m,tiles:A,origin:R,usable:B,tileCum:W,totalWidth:j,reversedInput:b}}function ni(m,b){const{tileCum:C,usable:A}=m;let R=0,B=C.length;for(;R<B;){const W=R+B>>1;C[W]+A[W]<=b+ft?R=W+1:B=W}return R}function ii(m,b,C,A){const{tiles:R,tileCum:B,usable:W}=m,j=C+A;let se=1/0;for(let le=ni(m,C);le<R.length;le++){const _e=B[le];if(_e>=j-ft)break;b.tick();const Se=Math.max(0,C-_e);Math.min(W[le],j-_e)-Se>ft&&R[le].height<se&&(se=R[le].height)}return se}function hi(m,b,C,A){const{tiles:R,tileCum:B,usable:W}=m,j=C+A,se=[];for(let le=ni(m,C);le<R.length;le++){const _e=B[le];if(_e>=j-ft)break;b.tick();const Se=Math.max(0,C-_e),Me=Math.min(W[le],j-_e)-Se;Me>ft&&se.push(le,Se,Me)}return se}function di(m,b,C,A,R,B){const{tiles:W,tileCum:j,usable:se,origin:le,reversedInput:_e}=m,Se=C+A;let Oe=0;for(let Me=ni(m,C);Me<W.length;Me++){const Be=j[Me];if(Be>=Se)break;b.tick();const Ne=W[Me];if(!(Be+se[Me]<=C))for(const xe of Ne.posts){const Fe=Be+((_e?Ne.width-xe.x-xe.width:xe.x)-le[Me]);Fe+xe.width>C+ft&&Fe<Se-ft&&(R[Oe]=xe,B&&(B[Oe]=Fe),Oe++)}}return Oe}function fi(m,b){const C=[];for(let A=0;A<b.length;A+=3){const R=m.spans[b[A]];C.push(new Le(R.tile,R.x0+he(b[A+1]),R.x0+he(b[A+1]+b[A+2])))}return C}function Ni(m,b,C=0){const A=[];for(let R=0;R<b.length;R++){if(b[R]<=ft)continue;const B=m.spans[R],W=Math.min(b[R],m.usable[R]),j=m.tileCum[R],se=Math.max(j,C);if(se>=j+W-ft)continue;const le=se-j,_e=le>ft?B.x0+he(le):B.x0,Se=W>=m.usable[R]-ft?B.x1:B.x0+he(W);Se>_e&&A.push(new Le(B.tile,_e,Se))}return A}const Ki=8,$i=2;function Gi(m,b){const C=Math.max(0,b-m.placedSeats);let A=0;for(const R of m.footprint)A+=ve(R.x1-R.x0)*R.tile.height;return[C,A]}class Vi{constructor(b,C,A,R,B,W,j,se,le){this.inp=b,this.dept=C,this.geom=A,this.startsOnWall=R,this.endsOnWall=B,this.requiredSeats=W,this.pickTertiaries=j,this.budget=se,this.decisions=le,this.cursor=0,this.tileIdx=0,this.tileConsumed=0,this.placedSeats=0,this.benchCountSinceCloset=0,this.built=[],this.tertiaries=[],this.snapCursor=0,this.snapTileIdx=0,this.snapTileConsumed=0,this.snapTertiaryCount=0,this.lastBench=null,this.contentLo=null,this.postScratch=[],this.laneScratch=[],this.trace=[],this.tileUsage=new Array(A.spans.length).fill(0),this.snapUsage=this.tileUsage.slice(),this.benchesBeforeNext=b.benchesBeforeFirstCloset,this.startTertiary=De(R,C.tertiary),this.endTertiary=De(B,C.tertiary),this.trailingGap=C.benchMargin+this.endTertiary}totalRemaining(){return this.geom.totalWidth-this.cursor}advance(b){const{usable:C}=this.geom;let A=b;for(;A>ft;){if(this.tileIdx>=C.length)return!1;const R=C[this.tileIdx]-this.tileConsumed;R<=ft?(this.tileConsumed=0,this.tileIdx++):R<=A+ft?(A-=R,this.cursor+=R,this.tileUsage[this.tileIdx]+=R,this.tileConsumed=0,this.tileIdx++):(this.cursor+=A,this.tileConsumed+=A,this.tileUsage[this.tileIdx]+=A,A=0)}return!0}saveSnapshot(){this.snapCursor=this.cursor,this.snapTileIdx=this.tileIdx,this.snapTileConsumed=this.tileConsumed,this.snapUsage=this.tileUsage.slice(),this.snapTertiaryCount=this.tertiaries.length}restoreSnapshot(){this.cursor=this.snapCursor,this.tileIdx=this.snapTileIdx,this.tileConsumed=this.snapTileConsumed;for(let b=0;b<this.tileUsage.length;b++)this.tileUsage[b]=this.snapUsage[b];this.tertiaries.length=this.snapTertiaryCount}advanceGap(b){const{tertiary:C}=this.dept,A=Math.max(0,(b-C)/2);if(!this.advance(A))return!1;const R=this.cursor;return!!this.advance(C)&&(this.recordTertiary(R,C),this.advance(A))}
1recordTertiary(b,C){if(C<=ft)return;const A=hi(this.geom,this.budget,b,C);A.length>0&&this.tertiaries.push(fi(this.geom,A))}computeBenchY(b,C,A,R=null,B=0){const W=this.postScratch,j=di(this.geom,this.budget,C,A,W,null),le=ii(this.geom,this.budget,C,A)-this.inp.windowOffset,_e=[];for(let xe=0;xe<j;xe++)_e.push([W[xe].y,W[xe].y+W[xe].height]);if(null!==R){const xe=[];for(let ze=0;ze+1<B;ze+=2){const Fe=di(this.geom,this.budget,R[ze],R[ze+1],xe,null);for(let qe=0;qe<Fe;qe++)_e.push([xe[qe].y,xe[qe].y+xe[qe].height+this.dept.tertiary])}}if(0===_e.length)return b.height<=le+ft?0:null;_e.sort((xe,ze)=>xe[0]-ze[0]);const Se=[];for(const[xe,ze]of _e){const Fe=Se[Se.length-1];Fe&&xe<=Fe[1]+ft?Fe[1]=Math.max(Fe[1],ze):Se.push([xe,ze])}let Oe=null,Me=-1;const Be=(xe,ze)=>{const Fe=Math.min(ze,le)-xe;Fe>=b.height-ft&&Fe>Me&&(Oe=xe<ft?0:xe+Math.min(10,Fe-b.height),Me=Fe)};let Ne=0;for(const[xe,ze]of Se)xe-Ne>ft&&Be(Ne,xe),Ne=ze;return le-Ne>ft&&Be(Ne,le),Oe}computeRightMargin(b){const{inp:C,dept:A}=this;return this.placedSeats+b>=this.requiredSeats?A.benchMargin:this.benchCountSinceCloset+1>=this.benchesBeforeNext?Math.max(0,(C.distToWall-A.tertiary)/2):Math.max(0,(C.distBenchToBench-A.tertiary)/2)}tertiaryRanges(b,C,A,R,B){const{tertiary:W}=this.dept;let j=0;const le=b+A.width+R;if(this.built.length>0||this.startsOnWall){const Se=this.built.length>0?W:this.startTertiary;Se>ft&&(B[j++]=b-C-Se,B[j++]=Se)}return this.placedSeats+A.seats>=this.requiredSeats&&!this.endsOnWall||(B[j++]=le,B[j++]=W),j}scanBenches(b,C){let A=null,R=0;for(const B of this.dept.benchesSorted){const W=this.computeRightMargin(B.seats),j=b-C,se=C+B.width+W,le=ii(this.geom,this.budget,j,se);if(le===1/0)continue;const _e=le-this.inp.windowOffset;if(!(B.height>_e+ft)){if(0===R&&(R=B.seats),null===A){const Se=this.tertiaryRanges(b,C,B,W,this.laneScratch),Oe=this.computeBenchY(
1B,j,se,this.laneScratch,Se);null!==Oe&&Oe+B.height<=_e+ft&&(A={bench:B,benchY:Oe})}if(null!==A&&0!==R)break}}return{here:A,idealSeats:R}}benchAt(b,C){for(const A of this.dept.benchesSorted){const R=this.computeRightMargin(A.seats),B=b-C,W=C+A.width+R,j=ii(this.geom,this.budget,B,W);if(j===1/0)continue;const se=j-this.inp.windowOffset;if(A.height>se+ft)continue;const le=this.tertiaryRanges(b,C,A,R,this.laneScratch),_e=this.computeBenchY(A,B,W,this.laneScratch,le);if(null!==_e&&_e+A.height<=se+ft)return{bench:A,benchY:_e}}return null}postAvoidance(b,C){const A=C?C.bench.seats:-1,B=[],W=[],j=di(this.geom,this.budget,this.cursor,this.dept.maxBenchW+2*this.dept.tertiary,B,W),se=new Set;for(let Se=0;Se<j;Se++){const Oe=Math.round(1e3*(W[Se]+B[Se].width+this.dept.tertiary-this.cursor))/1e3;Oe>ft&&se.add(Oe)}const le=[...se].sort((Se,Oe)=>Se-Oe).slice(0,2);let _e=null;for(const Se of le){const Oe=this.cursor+Se;if(this.geom.totalWidth-Oe<this.dept.minBenchW+this.trailingGap-ft)continue;const Me=this.benchAt(Oe,b);Me&&Me.bench.seats>A&&(null===_e||Me.bench.seats>_e.bench.seats)&&(_e={skip:Se,bench:Me.bench,benchY:Me.benchY})}return _e}make(b,C,A,R,B,W,j,se){const le=hi(this.geom,this.budget,A-j,j+R+se);if(0===le.length)return null;const _e=hi(this.geom,this.budget,A,R),{origin:Se,tileCum:Oe,usable:Me}=this.geom,Be=A+R/2,Ne=B+W/2;let xe=0;const ze=le[0];let Fe=Se[ze]+(Be-Oe[ze]);for(let qe=0;qe<le.length;qe+=3){const Ke=le[qe],it=Oe[Ke];if(it<=Be+ft&&Be+ft<it+Me[Ke]){xe=qe/3,Fe=Se[Ke]+(Be-it);break}}return new Qe(b,fi(this.geom,le),fi(this.geom,_e),C,0,xe,Fe,Ne)}emit(b,C,A,R,B,W,j,se){const le=this.make(b,C,A,R,B,W,j,se);null!==le&&this.built.push(le)}run(){const{inp:b,dept:C,geom:A}=this,R=4*A.tiles.length+8*this.requiredSeats+16;let B=0;for(;this.placedSeats<this.requiredSeats&&this.tileIdx<A.tiles.length&&!(++B>R||this.budget.exhausted);){const j=this.cursor;let se=this.benchCountSinceCloset>=this.benchesBeforeNext;if(se){const Fe=b.distToWall+b.closetRowWidth+b.distToWall+C.minBenchW+this.trailingGap;this.totalRemaining()<Fe-ft&&(se=!1)}if(se){if(!this.advanceGap(b.distToWall))break;const Fe=this.cursor;if(this.totalRemaining()<b.closetRowWidth+this.trailingGap-ft)break;const qe=ii(this.geom,this.budget,Fe,b.closetRowWidth),Ke=(qe===1/0?0:qe)-b.windowOffset;if(!this.advance(b.closetRowWidth))break;const it=Math.max(0,(b.distToWall-C.tertiary)/2);this.emit(Je.CLOSET,null,Fe,b.closetRowWidth,0,Ke,it,it),null===this.contentLo&&(this.contentLo=j),this.benchCountSinceCloset=0,this.benchesBeforeNext=b.benchesBeforeCloset,this.saveSnapshot();continue}const _e=this.built.length>0&&this.built[this.built.length-1].kind===Je.CLOSET;let Se;if(0===this.built.length){if(this.startsOnWall){const Fe=this.cursor;if(!this.advance(this.startTertiary))break;this.recordTertiary(Fe,this.startTertiary)}if(!this.advance(C.benchMargin))break;Se=C.benchMargin}else{const Fe=_e?b.distToWall:b.distBenchToBench;if(!this.advanceGap(Fe))break;Se=Math.max(0,(Fe-C.tertiary)/2)}if(this.totalRemaining()<C.minBenchW+this.trailingGap-ft)break;const{here:Oe,idealSeats:Me}=this.scanBenches(this.cursor,Se);let Ne,xe,Be=0;if(null!==Oe&&Oe.bench.seats>=Me)Ne=Oe.bench,xe=Oe.benchY;else{const Fe=this.postAvoidance(Se,Oe);if(null!==Fe&&null!==Oe){const qe=this.trace.length,Ke=qe<this.decisions.length?this.decisions[qe]:1;this.trace.push(Ke),Ke?(Be=Fe.skip,Ne=Fe.bench,xe=Fe.benchY):(Ne=Oe.bench,xe=Oe.benchY)}else if(null!==Fe)Be=Fe.skip,Ne=Fe.bench,xe=Fe.benchY;else{if(null===Oe){if(!this.advance(Math.min(30,C.minBenchW)))break;continue}Ne=Oe.bench,xe=Oe.benchY}}if(Be>0&&!this.advance(Be)||this.totalRemaining()<Ne.width+this.trailingGap-ft)break;const ze=this.cursor;if(!this.advance(Ne.width))break;this.emit(Je.BENCH,Ne,ze,Ne.width,xe,Ne.height,Se,this.computeRightMargin(Ne.seats)),null===this.contentLo&&(this.contentLo=j),this.lastBench={idx:this.built.length-1,startX:ze,leftMargin:Se,bench:Ne,benchY:xe},this.placedSeats+=Ne.seats,this.benchCountSinceCloset++,this.saveSnapshot()}if(this.built.length>0&&null!==this.lastBench){const j=this.lastBench,se=this.make(Je.BENCH,j.bench,j.startX,j.bench.width,j.benchY,j.bench.height,j.leftMargin,this.dept.benchMargin);null!==se&&(this.built[j.idx]=se)}if(this.built.length>0&&(this.restoreSnapshot(),this.advance(C.benchMargin)&&this.endsOnWall)){let j=this.endTertiary;if(j>ft&&j<C.tertiary-ft&&this.totalRemaining()>C.minBenchW+C.tertiary+ft&&(j=C.tertiary),j>ft){const se=this.cursor;this.advance(j)&&this.recordTertiary(se,j)}}return 0===this.built.length?null:{furniture:this.built,footprint:Ni(this.geom,this.tileUsage,this.dept.trimExtremities&&null!==this.contentLo?this.contentLo:0),tertiaries:this.tertiaries,placedSeats:this.placedSeats}}}function Ss(m,b,C){return m>1.5*Math.min(b,C)+1e-6&&C+Math.max(200,C/1.5)<m-1e-6}class As{constructor(b,C,A,R,B=new Set,W=!1){this.inp=b,this.geom=C,this.irrigation=A,this.budget=R,this.blockedTiles=B,this.checkDepthWaste=W,this.cursor=0,this.tileIdx=0,this.tileConsumed=0,this.built=[],this.snapCursor=0,this.snapTileIdx=0,this.snapTileConsumed=0,this.isModule=b.isStandaloneModule,this.tileUsage=new Array(C.spans.length).fill(0),this.snapUsage=this.tileUsage.slice()}saveSnapshot(){this.snapCursor=this.cursor,this.snapTileIdx=this.tileIdx,this.snapTileConsumed=this.tileConsumed,this.snapUsage=this.tileUsage.slice()}restoreSnapshot(){this.cursor=this.snapCursor,this.tileIdx=this.snapTileIdx,this.tileConsumed=this.snapTileConsumed;for(let b=0;b<this.tileUsage.length;b++)this.tileUsage[b]=this.snapUsage[b]}advance(b){const{usable:C}=this.geom;let A=b;for(;A>ft;){if(this.tileIdx>=C.length)return!1;const R=C[this.tileIdx]-this.tileConsumed;R<=ft?(this.tileConsumed=0,this.tileIdx++):R<=A+ft?(A-=R,this.cursor+=R,this.tileUsage[this.tileIdx]+=R,this.tileConsumed=0,this.tileIdx++):(this.cursor+=A,this.tileConsumed+=A,this.tileUsage[this.tileIdx]+=A,A=0)}return!0}buildSpan(b,C,A,R){const{tiles:B,tileCum:W,usable:j}=this.geom,se=[];let le=0,_e=!1,Se=1/0,Oe=!1;for(let ze=this.tileIdx;ze<B.length;ze++){const Fe=B[ze],qe=W[ze];
1if(qe+j[ze]<=this.cursor+ft)continue;if(this.budget.tick(),this.blockedTiles.has(Fe.idx)||this.isModule&&Fe.sus||this.isModule&&this.checkDepthWaste&&Ss(Fe.height,b,C)||A&&this.isModule&&oe(Fe))return null;let Ke,it;if(Fe.hasWindow&&A){if(this.cursor>qe+ft)return null;Ke=0,it=j[ze],_e=!0}else Ke=Math.max(0,this.cursor-qe),it=j[ze]-Ke,Fe.hasWindow&&(_e=!0);if(se.push(ze,Ke,it),le+=it,Fe.height<Se&&(Se=Fe.height),(_e||!R)&&le>=b-ft){Oe=!0;break}}if(!Oe||R&&!_e||C>Se+ft)return null;let Me=b;const Be=le-b;if(Be>ft){const ze=se.length-3,qe=se[ze+2];B[se[ze]].hasWindow&&A||!(qe-Be>=-ft)?Me=le:se[ze+2]=qe-Be}let Ne=1/0,xe=!1;for(let ze=0;ze<se.length;ze+=3){if(se[ze+2]<=ft)continue;const Fe=B[se[ze]];Fe.height<Ne&&(Ne=Fe.height),Fe.hasWindow&&(xe=!0)}return Ne===1/0||C>Ne+ft||R&&!xe||!this.irrigated(se)?null:{infos:se,advanceDist:Me,minH:Ne}}irrigated(b){const C=this.irrigation;if(null===C)return!0;const{tiles:A}=this.geom;let R=!1,B=0,W=0;for(let j=0;j<b.length;j+=3){const se=b[j+2];if(se<=ft)continue;const le=A[b[j]].idx;C.cornerTileIdxs.has(le)?(R=!0,W=Math.max(W,C.tileOverride.get(le)??0)):B+=se}return!R||C.maxOverride>=100-ft||B+W>=100-ft}emit(b,C,A,R,B){const W=[];for(let le=0;le<b.length;le+=3){if(b[le+2]<=ft)continue;const _e=this.geom.spans[b[le]];W.push(new Le(_e.tile,_e.x0+he(b[le+1]),_e.x0+he(b[le+1]+b[le+2])))}if(0===W.length)return;const j=hi(this.geom,this.budget,R,B),se=[];for(let le=0;le<j.length;le+=3){const _e=this.geom.spans[j[le]];se.push(new Le(_e.tile,_e.x0+he(j[le+1]),_e.x0+he(j[le+1]+j[le+2])))}this.built.push(new Qe(Je.OFFICE,W,se.length>0?se:W,C,A,null,null,null))}run(b){const C=new Map(b),{tiles:A,usable:R,totalWidth:B}=this.geom;let W=0;for(const le of C.values())W+=Math.max(0,le);const j=2*A.length+2*W+8;let se=0;for(;this.tileIdx<A.length;){let le=!1;for(const Me of C.values())if(Me>0){le=!0;break}if(!le||++se>j||this.budget.exhausted)break;let _e=null;for(const[Me,Be]of C){if(Be<=0)continue;const Ne=this.inp.offices[Me];if(Ne)for(let xe=0;xe<Ne.widthHeights.length;xe++){const[ze,Fe]=Ne.widthHeights[xe];if(this.cursor+ze>B+ft)continue;const qe=this.buildSpan(ze,Fe,Ne.isPartitioned,Ne.needWindow);if(null===qe)continue;const Ke=qe.minH-Fe;(null===_e||Ke<_e.score-ft)&&(_e={score:Ke,ridx:Me,whIdx:xe,fit:qe})}}if(null===_e){if(A[this.tileIdx].hasWindow&&this.tileConsumed>ft&&this.advance(R[this.tileIdx]-this.tileConsumed))continue;break}const Se=this.cursor,Oe=this.inp.offices[_e.ridx].widthHeights[_e.whIdx][0];if(!this.advance(_e.fit.advanceDist))break;this.emit(_e.fit.infos,this.inp.offices[_e.ridx],_e.whIdx,Se,Oe),C.set(_e.ridx,(C.get(_e.ridx)??0)-1),this.saveSnapshot()}return 0===this.built.length?null:(this.restoreSnapshot(),{furniture:this.built,footprint:Ni(this.geom,this.tileUsage),remaining:C})}}const ks=[{osFirst:!0,reversed:!1,order:0},{osFirst:!1,reversed:!1,order:1}],xs=[{osFirst:!0,reversed:!1,order:0}],Rs=[{osFirst:!0,reversed:!0,order:0},{osFirst:!1,reversed:!0,order:1}],Ds=[{osFirst:!0,reversed:!0,order:0}],ls=405;function Fi(m){const b=be(m.tile);return new Le(m.tile,b-m.x1,b-m.x0)}function cs(m){const b=[...m.slices].reverse().map(Fi),C=[...m.bodySlices].reverse().map(Fi);let A=null,R=null;return null!==m.centroidSliceIdx&&(A=m.slices.length-1-m.centroidSliceIdx,R=m.slices[m.centroidSliceIdx].tile.width-(m.centroidX??0)),new Qe(m.kind,b,C,m.benchOrOffice,m.usedDimensionIdx,A,R,m.centroidY)}function vi(m){for(const b of m.values())if(b>0)return!0;return!1}function bi(m){let b=0;for(const C of m.values())C>0&&(b+=C);return b}function us(m,b){for(let C=0;C<m.length;C++){if(m[C]<b[C]-ft)return!0;if(m[C]>b[C]+ft)return!1}return!1}function bs(m,b,C,A,R,B,W,j,se,le,_e,Se,Oe,Me){const Be=j.reversed?function Fs(m){const b=[];for(let C=m.length-1;C>=0;C--)b.push(Fi(m[C]));return b}(C):C,ze=function es(m,b,C,A,R,B,W,j,se,le,_e,Se,Oe,Me){const Be=[],Ne=[];let xe=0,ze=new Map(W);const Fe=new Map,qe=new Map;for(let at=0;at<C.length;at++)Fe.set(C[at].tile,at),qe.set(C[at].tile,C[at]);const Ke=(at,Ze,Ve)=>{if(B<=0||null===b||0===at.length)return[];const pt=wi(at,se),Ct=function qi(m,b,C,A,R,B,W,j){if(0===C.spans.length||B<=0)return null;let se=null,le=null;const _e=[[]],Se=new Set([""]);let Oe=0,Me=0;for(;_e.length>0&&Oe<Ki&&!j.exhausted;){const Be=_e.shift(),Ne=new Vi(m,b,C,A,R,B,W,j,Be),xe=Ne.run();if(Oe++,null!==xe){const ze=Gi(xe,B);(null===le||ze[0]<le[0]||ze[0]===le[0]&&ze[1]<le[1]-ft)&&(se=xe,le=ze)}if(null!==le&&0===le[0]&&(Me++,Me>$i))break;for(let ze=Be.length;ze<Ne.trace.length;ze++){const Fe=Ne.trace.slice(0,ze);Fe.push(1-Ne.trace[ze]);const qe=Fe.join("");Se.has(qe)||(Se.add(qe),_e.push(Fe))}}return se}(m,b,pt,Ze,Ve,B,_e,Se);return null===Ct?[]:(Be.push(...Ct.furniture),Ne.push(...Ct.tert
1iaries),xe=Ct.placedSeats,[...Ct.footprint])},it=at=>{if(!vi(W)||0===at.length)return[];const Ze=wi(at,se),Ve=function vs(m,b,C,A,R,B=new Set,W=!1){if(0===b.spans.length)return null;let j=!1;for(const se of C.values())if(se>0){j=!0;break}return j?new As(m,b,A,R,B,W).run(C):null}(m,Ze,ze,le,Se,Oe,Me);return null===Ve?[]:(Be.push(...Ve.furniture),ze=Ve.remaining,[...Ve.footprint])},$e=at=>{if(0===at.length)return C;const Ze=Fe.get(at[at.length-1].tile);return void 0===Ze?[]:C.slice(Ze+1)};let ot,ct;return j?(ot=Ke(C,A,R),ct=vi(W)?it($e(ot)):[]):(ot=it(C),ct=B>0&&null!==b?Ke($e(ot),!0,R):[]),ct.length>0&&(at=>{if(0===at.length)return;const Ze=at[at.length-1],Ve=qe.get(Ze.tile);void 0!==Ve&&(at[at.length-1]=new Le(Ze.tile,Ve.x0,Ve.x1))})(ot),{furniture:Be,footprint:[...ot,...ct],tertiaries:Ne,placedSeats:xe,remainingOffices:ze}}(m,b,Be,j.reversed?R:A,j.reversed?A:R,B,W,j.osFirst,j.reversed,le,_e,Se,Oe,Me);return j.reversed?{furniture:[...ze.furniture].reverse().map(cs),footprint:ze.footprint.map(Fi).sort((Fe,qe)=>(se.get(Fe.tile)??0)-(se.get(qe.tile)??0)),tertiaries:[...ze.tertiaries].reverse().map(Fe=>[...Fe].reverse().map(Fi)),placedSeats:ze.placedSeats,remainingOffices:ze.remainingOffices}:ze}function Ui(m,b,C,A){return null===C||("head"===C?function Es(m,b){let C=1/0;for(const A of b)for(const R of A.bodySlices){const B=m.globalX(R);B<C&&(C=B)}return C}(m,b)-A<=ls+ft:A-function Ps(m,b){let C=-1/0;for(const A of b)for(const R of A.bodySlices){const B=m.globalXEnd(R);B>C&&(C=B)}return C}(m,b)<=ls+ft)}function Ts(m,b){if(0===m.length)return b;const C=m.map(B=>[Math.max(0,B.y),Math.min(b,B.y+B.height)]).filter(([B,W])=>W>B).sort((B,W)=>B[0]-W[0]);let A=0,R=0;for(const[B,W]of C)B-R>A&&(A=B-R),W>R&&(R=W);return Math.max(A,b-R)}function hs(m,b,C,A){const R=m.height-A;if(R<C-ft||m.width<b-ft)return!1;if(0===m.posts.length)return!0;const B=[0];for(const j of m.posts)B.push(j.x+j.width),B.push(j.x-b);const W=[];for(const j of B)if(!(j<-ft||j+b>m.width+ft)){W.length=0;for(const se of m.posts)se.x<j+b-ft&&se.x+se.width>j+ft&&W.push(se);if(Ts(W,R)>=C-ft)return!0}return!1}function pi(m,b,C,A,R,B,W,j,se,le,_e,Se,Oe,Me,Be,Ne,xe,ze){const Fe=W>0&&null!==C&&vi(j),qe=new Map;for(let it=0;it<A.length;it++)qe.set(A[it].tile,it);let Ke=null;for(const it of function Ns(m,b){return b?m?Rs:Ds:m?ks:xs}(Fe,Se)){if(_e.exhausted)break;if(null!==ze&&it.osFirst!==ze)continue;const $e=bs(b,C,A,R,B,W,j,it,qe,se,le,_e,Be,xe);if(0===$e.footprint.length){Me.add(zt.NOTHING_PLACED);continue}if(!Jt($e.footprint)){Me.add(zt.OUT_OF_SLICE);continue}if(!$t(m.ledger,$e.footprint)){Me.add(zt.OVERLAP_CONFLICT);continue}if(!Wt($e.footprint,qe)){Me.add(zt.CONTINUITY_VIOLATION);continue}if(!Ui(m,$e.furniture,Oe,Ne)){Me.add(zt.START_TOO_FAR);continue}let gt=0;for(const ct of $e.footprint)gt+=ve(ct.x1-ct.x0)*ct.tile.height;const ot=[Math.max(0,W-$e.placedSeats),bi($e.remainingOffices),gt,it.order];
1(null===Ke||us(ot,Ke.rankKey))&&(Ke={furniture:$e.furniture,footprint:$e.footprint,tertiaries:$e.tertiaries,placedSeats:$e.placedSeats,remainingOffices:$e.remainingOffices,rankKey:ot,reversed:it.reversed})}return Ke}function ds(m,b){return null!==m&&m.placedSeats>=b&&!vi(m.remainingOffices)}function Cs(m,b){return!(null===m||m.placedSeats<b.placedSeats)&&bi(m.remainingOffices)<=bi(b.remainingOffices)}function Bi(m,b,C){if(0===b.length||0===C.length)return b;const A=new Map;for(let se=0;se<C.length;se++)A.set(C[se].tile,se);const R=A.get(b[b.length-1].tile);if(void 0===R)return b;const B=[...b],W=B[B.length-1],j=C[R].x1;W.x1<j&&m.ledger.isFree(W.tile,W.x1,j)&&(B[B.length-1]=new Le(W.tile,W.x0,j));for(let se=R+1;se<C.length;se++){const le=C[se];m.ledger.isFree(le.tile,le.x0,le.x1)&&B.push(new Le(le.tile,le.x0,le.x1))}return B}function fs(m,b,C){if(0===b.length||0===C.length)return b;const A=new Map;for(let le=0;le<C.length;le++)A.set(C[le].tile,le);const R=A.get(b[0].tile);if(void 0===R)return b;const B=[...b],W=B[0],j=C[R].x0;W.x0>j&&m.ledger.isFree(W.tile,j,W.x0)&&(B[0]=new Le(W.tile,j,W.x1));const se=[];for(let le=0;le<R;le++){const _e=C[le];m.ledger.isFree(_e.tile,_e.x0,_e.x1)&&se.push(new Le(_e.tile,_e.x0,_e.x1))}return[...se,...B]}function nt(m,b){return m[0]-b[0]||m[1]-b[1]}function t(m,b,C,A){const R=[];for(const B of m){const W=b.get(B.tile)??-1;if(null!==C){const[j,se]=C;if(W<j)continue;if(W===j){const le=Math.max(B.x0,se);le<B.x1&&R.push(new Le(B.tile,le,B.x1));continue}}if(null!==A){const[j,se]=A;if(W>j)continue;if(W===j){const le=Math.min(B.x1,se);B.x0<le&&R.push(new Le(B.tile,B.x0,le));continue}}R.push(B)}return R}function c(m,b,C,A,R){const B=m.flatTiles;let W=b,j=C,se=A;if(R){for(;W>=0&&W<B.length;){const le=be(B[W]);if(j+se<=le)return[W,j+se];se-=le-j,W++,j=0}return B.length>0?[B.length-1,be(B[B.length-1])]:[b,C]}for(;W>=0;){if(j-se>=0)return[W,j-se];se-=j,W--,W>=0&&(j=be(B[W]))}return[0,0]}function pe(m,b,C){return b?m.placedSeats>=C:!vi(m.remainingOffices)}function we(m,b,C,A,R,B,W,j,se,le,_e,Se,Oe,Me,Be){let Ne=new Map(le);const xe=[];let ze=0;const Fe=function Vt(){return{officed:new Set,reached:new Set}}(),qe="officesFirst"!==_e;let Ke=null!==_e;for(let it=0;it<A.length;it++){const $e=A[it];if(0===$e.spans.length||W.exhausted)break;const gt=Zt($e.spans,$e.sw,$e.ew,Fe.officed);if(0===gt.spans.length)break;const ot=gt.spans,ct=gt.sw,at=gt.ew,Ze=Math.max(0,se-ze);let Ve,pt,Ct=null;if(null===_e?(Ve=Ze,pt=Ne):Ke===qe?(Ve=Ze,pt=new Map):(Ve=0,pt=Ne),it>0&&Ve<=0&&!vi(pt))break;const ht=it+1<A.length&&A[it+1].spans.length>0,Nt=Ne,Ht=0===it?j?"tail":"head":null,ei=Mi(Fe);let Xt=pi(m,b,C,ot,ct,at,Ve,pt,R,B,W,j,Ht,Oe,ei,Me,Be,Ct),vt=!1;if(Ke&&null!==Xt&&pe(Xt,qe,Ze)){const Ot=qe,bt=pi(m,b,C,ot,ct,at,Ze,Ne,R,B,W,j,Ht,Oe,ei,Me,Be,Ot);null!==bt&&(Xt=bt,Ve=Ze,pt=Ne,Ct=Ot),vt=!0}if(null===_e&&ht&&null!==Xt&&!ds(Xt,Ve)){const Ot=pi(m,b,C,ot,ct,at,Ve,pt,R,B,W,!j,Ht,Oe,ei,Me,Be,Ct);Cs(Ot,Xt)&&(Xt=Ot)}if(null===Xt||it>0&&0===Xt.placedSeats&&bi(Xt.remainingOffices)===bi(Nt))break;xe.push({seg:{spans:ot,sw:ct,ew:at},cand:Xt}),Ft(Fe,Xt.furniture,Xt.footprint,Xt.tertiaries),ze+=Xt.placedSeats,pt===Ne&&(Ne=Xt.remainingOffices),vt&&(Ke=!1)}return function z(m,b,C,A,R,B,W,j,se){if(0===C.length)return null;const le=b.loops&&C.length>=2&&j>=2&&C.length===j,_e=W?Bi:fs,Se=W?fs:Bi,Oe=[],Me=[],Be=[],Ne=C.length-1;for(let Ve=0;Ve<C.length;Ve++){const{seg:pt,cand:Ct}=C[Ve];let Dt=Ct.footprint;(Ve>0||le)&&(Dt=_e(m,Dt,pt.spans)),(Ve<Ne||le)&&(Dt=Se(m,Dt,pt.spans)),Oe.push(Ct.furniture),Me.push(Ct.tertiaries),Be.push(Dt)}W&&(Oe.reverse(),Me.reverse(),Be.reverse());const xe=Oe.flat(),ze=Me.flat(),Fe=Be.flat();if(0===Fe.length)return null;const qe=new Map;for(let Ve=0;Ve<m.flatTiles.length;Ve++)qe.set(m.flatTiles[Ve],Ve);let Ke=!0,it=!0,$e=1/0,gt=-1/0;for(const{seg:Ve}of C){let pt=1/0,Ct=-1/0;for(const Dt of Ve.spans){const ht=qe.get(Dt.tile)??0;ht<pt&&(pt=ht),ht>Ct&&(Ct=ht)}pt<$e&&($e=pt,Ke=Ve.sw),Ct>gt&&(gt=Ct,it=Ve.ew)}let ot=!1;if(b.loops&&j>=2){const Ve=new Map;for(let Dt=0;Dt<m.flatTiles.length;Dt++)Ve.set(m.flatTiles[Dt],m.rangeIds[Dt]);let pt=!1,Ct=!1;for(const Dt of Fe){const ht=Ve.get(Dt.tile);0===ht&&(pt=!0),ht===j-1&&(Ct=!0)}ot=pt&&Ct}const ct=ot?{furniture:xe,footprint:Fe,tertiaries:ze,placedSeats:A}:function N(m,b,C,A,R,B,W,j,se,le,_e){let Se=[...C],Oe=[...A],Me=[...R],Be=B;if(Se.length<2)return{furniture:Se,footprint:Oe,tertiaries:Me,placedSeats:Be};const Ne=Math.max(0,he(b.distToWall)-he(b.tertiaryCorridorWidth)),xe=Ne+he(De(j,b.tertiaryCorridorWidth)),ze=Ne+he(De(se,b.tertiaryCorridorWidth)),Fe=Se.some($e=>$e.kind===Je.OFFICE),qe=new Map;for(let $e=0;$e<m.flatTiles.length;$e++)qe.set(m.flatTiles[$e],$e);const Ke=$e=>{let gt=null;for(const ot of $e.slices){const ct=[qe.get(ot.tile)??-1,ot.x0];(null===gt||nt(ct,gt)<0)&&(gt=ct)}return gt??[-1,0]},it=$e=>{let gt=null;for(const ot of $e.slices){const ct=[qe.get(ot.tile)??-1,ot.x1];(null===gt||nt(ct,gt)>0)&&(gt=ct)}return gt??[-1,0]};for(;Se.length>=2;){const $e=[...Se].sort((ct,at)=>nt(Ke(ct),Ke(at))),gt=Be-W;let ot=!1;for(const ct of[!0,!1]){const at=ct?$e[0]:$e[$e.length-1];if(!(at.kind===Je.CLOSET||!Fe&&at.seats>0&&at.seats<=gt))continue;const Ve=Se.filter(ht=>ht!==at);if(Ve.length>0&&!Ui(m,Ve,le,_e))continue;const pt=ct?$e[1]:$e[$e.length-2],Ct=ct?c(m,...Ke(pt),xe,!1):c(m,...it(pt),ze,!0);Oe=ct?t(Oe,qe,Ct,null):t(Oe,qe,null,Ct),Me=Me.map(ht=>ct?t(ht,qe,Ct,null):t(ht,qe,null,Ct)).filter(ht=>ht.length>0);const Dt=Se.indexOf(at);Dt>
1=0&&Se.splice(Dt,1),Be-=at.seats,ot=!0;break}if(!ot)break}return{furniture:Se,footprint:Oe,tertiaries:Me,placedSeats:Be}}(m,b,xe,Fe,ze,A,R,Ke,it,W?"tail":"head",se);if(0===ct.footprint.length||0===ct.furniture.length)return null;const at=function li(m,b,C){let A=null;for(const j of m.flatTiles){const se=Z(j);if(null===se)continue;null===A&&(A=new Map);const le=A.get(se);le?le.push(j):A.set(se,[j])}if(null===A)return{furniture:[...b],footprint:[...C]};const R=[...b],B=[...C],W=new Set(B.map(j=>j.tile));for(let j=0;j<R.length;j++){const se=R[j];if(se.kind!==Je.OFFICE)continue;const le=new Set(se.slices.map(Oe=>Oe.tile)),_e=[];for(const Oe of le){if(!Bt(se,Oe))continue;const Me=Z(Oe);if(null!==Me)_e.push(Me);else{const Be=A.get(Oe);Be&&_e.push(...Be)}}const Se=[];for(const Oe of _e){if(le.has(Oe)||Se.some(Be=>Be.tile===Oe))continue;if(R.some(Be=>Be.slices.some(Ne=>Ne.tile===Oe)))return null;const Me=new Le(Oe,0,be(Oe));if(!$t(m.ledger,[Me]))return null;Se.push(Me)}if(0!==Se.length){R[j]=new Qe(se.kind,[...se.slices,...Se],se.bodySlices,se.benchOrOffice,se.usedDimensionIdx,se.centroidSliceIdx,se.centroidX,se.centroidY);for(const Oe of Se)W.has(Oe.tile)||(B.push(Oe),W.add(Oe.tile))}}return{furniture:R,footprint:B}}(m,ct.furniture,ct.footprint);if(null===at)return null;let Ze=0;for(const Ve of at.footprint)Ze+=ve(Ve.x1-Ve.x0)*Ve.tile.height;return{furniture:at.furniture,footprint:at.footprint,tertiaries:ct.tertiaries,placedSeats:ct.placedSeats,officeDemand:B,rankKey:[Math.max(0,R-ct.placedSeats),bi(B),Ze],flippedFirstRange:W||C[0].cand.reversed}}(m,b,xe,ze,se,Ne,j,Se,Me)}function We(m){const b=m.slices.map(A=>A.toUsedTile()),C=null!==m.centroidSliceIdx&&m.centroidSliceIdx<b.length?b[m.centroidSliceIdx]:null;return new Xe.SP({tiles:b,benchOrOffice:m.benchOrOffice,usedDimensionIdx:m.usedDimensionIdx,centroidTile:C,centroidTileX:null!==C?m.centroidX:null,centroidTileY:null!==C?m.centroidY:null})}function yt(m,b,C){const A=new Map;for(let W=0;W<m.flatTiles.length;W++)A.set(m.flatTiles[W],m.rangeIds[W]);let R=-1;for(const W of b.furniture)for(const j of W.slices){const se=A.get(j.tile);void 0!==se&&se>R&&(R=se)}if(R<0)return[];const B=[];for(let W=0;W<m.flatTiles.length;W++){if(m.rangeIds[W]!==R)continue;const j=m.flatTiles[W];if(C.has(j))continue;const se=oe(j),le=m.ledger.occupiedExtent(j);if(null===le){B.push(new Xe.OB(j,0,j.width,se));continue}const _e=be(j)-le[1];_e>0&&B.push(new Xe.OB(j,ve(le[1]),ve(_e),se))}return B}function St(m){return m.filter(b=>b.length>0).map(b=>b.map(C=>C.toUsedTile()))}function ut(m,b){if(m.unmetSeats>(b?.seats??0))return!1;for(const[A,R]of m.unmetOffices)if(R>(b?.officeCounts.get(A)??0))return!1;return!0}function Rt(m,b){const C=m.susAreas[b.susAreaIdx];if(!C)return null;const A=C.configurations?.[b.configIdx];return A?A.rects?.[b.rectIdx]??null:null}const Tt=1e-9;function Lt(m,b){return m/b}function jt(m,b,C,A,R){const B=m.filter(j=>Lt(j.width,R)<=C+Tt&&Lt(j.height,R)<=A+Tt);if(0===B.length)return null;B.sort((j,se)=>j.seats-se.seats);const W=B.filter(j=>j.seats<=b);return W.length>0?W[W.length-1]:B[0]}function _i(m,b,C,A){let R=null,B=-1;for(let W=0;W<m.widthHeights.length;W++){const[j,se]=m.widthHeights[W],le=Lt(j,A),_e=Lt(se,A);le>b+Tt||_e>C+Tt||le*_e>B&&(B=le*_e,R=[W,le,_e])}return R}function gi(m,b,C,A,R,B=0,W=null,j=null){if(A.width<=0||A.height<=0)return null;let se=!1;for(const bt of C.values())if(bt>0){se=!0;break}if(b<=0&&!se)return null;const le=null===W?A.startOnWall:W,_e=null===j?A.endOnWall:j,Se=Lt(m.tertiaryCorridorWidth,R),Oe=Math.max(0,Lt(m.distToWall,R)-Se),Me=Lt(m.distToWall,R),Be=Lt(m.distBenchToBench,R),Ne=Lt(m.closetRowWidth,R),xe=A.width,ze=A.consumeHeightFully?A.height:A.height-A.minRemainHeight,Fe=A.height,qe=Oe+(_e?Se:0),Ke=[],it=[];let $e=B,gt=0,ot=0;const ct=(bt,Mt)=>{const Yt=Math.max(0,(Mt-Se)/2);let Gt=bt+Yt;return Se>Tt&&(it.push([Gt,Gt+Se]),Gt+=Se),Gt+Yt};le&&($e+=Se);const at=new Map,Ze=[...C.keys()].sort((bt,Mt)=>bt-Mt);for(const bt of Ze){const Mt=C.get(bt)??0,Yt=m.offices[bt];if(Yt)for(let Gt=0;Gt<Mt;Gt++){const Kt=0===Ke.length?$e+Oe:ct($e,Be),si=_i(Yt,xe-Kt-qe,Fe,R);if(null===si)break;const[Di,ai,Si]=si;if(Kt+ai+qe>xe+Tt)break;Ke.push(new Xe.OM({bottomLeft:[Kt,0],topRight:[Kt+ai,Si],benchOrOffice:Yt,usedDimensionIdx:Di,furnitureCentroid:null})),$e=Kt+ai,gt=Math.max(gt,Si),ot=Math.max(ot,Si),at.set(bt,(at.get(bt)??0)+1)}}let Ve=b,pt=!1,Ct=0,Dt=m.benchesBeforeFirstCloset,ht=!1,Nt=0;const Ht=8*A.width+16;for(;Ve>0&&Nt<Ht;){if(Nt++,pt&&Ct>=Dt&&Ne>Tt){const Kt=ct($e,Me);if(Kt+Ne+qe>xe+Tt)break;const si=Math.max(gt,1e-6);Ke.push(new Xe.OM({bottomLeft:[Kt,0],topRight:[Kt+Ne,si],benchOrOffice:null,usedDimensionIdx:0,furnitureCentroid:[Ne/2,si/2]})),$e=Kt+Ne,Ct=0,Dt=m.benchesBeforeCloset,ht=!0;continue}const bt=0===Ke.length?$e+Oe:ct($e,ht?Me:Be),Mt=jt(m.benches,Ve,xe-bt-qe,ze,R);if(null===Mt)break;const Yt=Lt(Mt.width,R),Gt=Lt(Mt.height,R);if(bt+Yt+qe>xe+Tt)break;Ke.push(new Xe.OM({bottomLeft:[bt,0],topRight:[bt+Yt,Gt],benchOrOffice:Mt,usedDimensionIdx:0,furnitureCentroid:[Yt/2,Gt/2]})),$e=bt+Yt,gt=Math.max(gt,Gt),Ve-=Mt.seats,Ct++,pt=!0,ht=!1}if(0===Ke.length)return null;$e+=Oe,_e&&($e+=Se);const ei=function ci(m,b,C){if(m<=Tt)return null;if(b.consumeHeightFully)return b.height;const A=Math.max(1,Math.ceil(m-Tt));if(A>b.height)return null;const R=b.height-A;return(C>Tt&&C>=m-Tt?0:b.minRemainHeight)<=R&&R<=b.maxRemainHeight?A:null}(gt,A,ot);if(null===ei)return null;const Xt=Math.floor(B+Tt),vt=Math.max(Xt+1,Math.ceil($e-Tt));if(vt>A.width)return null;for(let bt=0;bt<Ke.length;bt++){const Mt=Ke[bt];null===Mt.benchOrOffice&&(Ke[bt]=new Xe.OM({bottomLeft:Mt.bottomLeft,topRight:[Mt.topRight[0],gt],benchOrOffice:null,usedDimensionIdx:0,furnitureCentroid:[(Mt.bottomLeft[0]+Mt.topRight[0])/2,gt/2]}))}let Ot=0;for(const bt of Ke)null!==bt.benchOrOffice&&!(bt.benchOrOffice instanceof Xe.lk)&&(Ot+=bt.benchOrOffice.seats);
1return{builtRect:new Xe.EG({targetRect:A,bottomLeft:[Xt,0],topRight:[vt,ei],items:Ke}),tertiaries:it.map(([bt,Mt])=>[bt,0,Mt,gt]),seats:Ot,officeCounts:at}}function Pi(m,b,C,A){const R=()=>{for(let le=0;le<b.ranges.length;le++)if(b.ranges[le].tiles.length>0)return{rangeIdx:le,tileIdx:0};return{rangeIdx:0,tileIdx:0}},B=m.cursorTile;if(!B)return R();const[W,j,se]=B;if(null!=se){const le=A.get(se);if(void 0===le)return R();const Se=C[se]?.find(Oe=>Oe.dynamicItemIdx===le);if(!Se)return R();for(const[,,,Oe]of Se.tileRangeExtraInfos)if(Oe&&0!==Oe.length)for(let Me=0;Me<b.ranges.length;Me++){const Be=b.ranges[Me].tiles.indexOf(Oe[0]);if(Be>=0)return{rangeIdx:Me,tileIdx:Be}}return R()}return W>=0&&W<b.ranges.length&&j>=0&&j<b.ranges[W].tiles.length?{rangeIdx:W,tileIdx:j}:R()}function Ti(m,b,C,A){const R=m.ranges.length,B=[],W=(le,_e)=>{if(0===_e.length)return;const Se=m.ranges[le];B.push({spans:Ye(_e),sw:Se.startOnWall,ew:Se.endOnWall})},j=m.ranges[b.rangeIdx];j&&W(b.rangeIdx,C?j.tiles.slice(b.tileIdx):j.tiles.slice(0,b.tileIdx));const se=C?1:-1;for(let le=1;le<R;le++){let _e=b.rangeIdx+se*le;if((_e<0||_e>=R)&&(!A||(_e=(_e%R+R)%R,_e===b.rangeIdx)))break;W(_e,[...m.ranges[_e].tiles])}return B}function is(m,b,C){const[A,R]=function Ut(m,b){let C=0,A=0;for(const R of m.furniture)R.kind===Je.BENCH&&R.benchOrOffice?C+=R.benchOrOffice.seats:R.kind===Je.OFFICE&&R.benchOrOffice instanceof Xe.lk&&A++;return[Math.min(C,b.requiredSeats),A]}(b,C);let B=0;for(const se of C.offices)B+=Math.max(0,se.required);let W=0;for(const se of b.usedSlices)W+=(se.x1-se.x0)/1e4*se.tile.height;let j=0;for(const se of b.furniture)for(const le of se.bodySlices)j+=(le.x1-le.x0)/1e4*le.tile.height;return[Math.max(0,C.requiredSeats-A),Math.max(0,B-R),-j,W]}function Ci(m,b){for(let C=0;C<m.length;C++){if(m[C]<b[C]-1e-6)return!0;if(m[C]>b[C]+1e-6)return!1}return!1}function Oi(m,b,C,A,R,B,W,j,se,le,_e,Se){const Me=mt(b,C,A,j),Be=function Ei(m){const b=[],C=[],A=new Map;let R=0;for(let B=0;B<m.ranges.length;B++)for(const W of m.ranges[B].tiles)b.push(W),C.push(B),A.set(W,R),R+=W.width;return new st(b,C,A,m.cornerTiles,R)}(Me);if(0===Be.flatTiles.length)return{attempt:null,hasCursorFloor:!1,cursorTile:null};const Ne=Pi(m,Me,C,A),xe=Me.ranges[Ne.rangeIdx]?.tiles[Ne.tileIdx],ze=W?function ts(m,b){const[C,A]=function Us(m){let b=1/0,C=1/0;for(const A of m.benches??[])A.width<b&&(b=A.width),A.height<C&&(C=A.height);return m.offices.forEach(A=>{if(!(A.required<=0))for(const[R,B]of A.widthHeights)R<b&&(b=R),B<C&&(C=B)}),[b,C]}(b);if(!Number.isFinite(C)||!Number.isFinite(A))return m.stripWidth;for(let R=m.flatTiles.length-1;R>=0;R--){const B=m.flatTiles[R];if(hs(B,C,A,b.windowOffset))return(m.tileStartX.get(B)??0)+B.width}return 0}(Be,m):void 0!==xe?Be.tileStartX.get(xe)??0:0,qe=Ti(Me,W?{rangeIdx:Me.ranges.length-1,tileIdx:Math.max(0,Me.ranges[Me.ranges.length-1]?.tiles.length??1)}:Ne,!W,m.loops),Ke=!W&&Ti(Me,Ne,!1,m.loops).length>0,it=xe??null;if(0===qe.length)return{attempt:null,hasCursorFloor:Ke,cursorTile:it};const $e=function Xi(m,b=!0){if(!m.benches||0===m.benches.length)return null;const C=[...m.benches].sort((W,j)=>j.seats-W.seats||j.height-W.height);let A=1/0,R=0;for(const W of m.benches)W.width<A&&(A=W.width),W.width>R&&(R=W.width);const B=m.tertiaryCorridorWidth;return{benchesSorted:C,minBenchW:A,maxBenchW:R,tertiary:B,benchMargin:Math.max(0,m.distToWall-B),trimExtremities:b}}(m,se),ot=function fe(m,b,C,A,R,B,W,j=!1,se=!0,le=0,_e=!1){if(0===A.length||0===A[0].spans.length)return{placed:null,failure:zt.INFEASIBLE_GEOMETRY};const Se=b.requiredSeats,Oe=new Map;if(b.offices.forEach((qe,Ke)=>{qe.required>0&&Oe.set(Ke,qe.required)}),Se<=0&&0===Oe.size)return{placed:null,failure:zt.NOTHING_PLACED};let Me=0;for(const qe of m.rangeIds)qe+1>Me&&(Me=qe+1);const Be=new Set,Ne=function ie(m,b,C,A,R,B){if(!B||!(C>0&&null!==b&&vi(A)))return null;let W=0;for(const j of R)j.spans.length>0&&W++;return W>=2?["benchesFirst","officesFirst"]:null}(0,C,Se,Oe,A,se);let xe=null;if(null===Ne)xe=we(m,b,C,A,R,B,W,j,Se,Oe,null,Me,Be,le,_e);else for(const qe of Ne){const Ke=we(m,b,C,A,R,B,W,j,Se,Oe,qe,Me,Be,le,_e);
1null!==Ke&&(null===xe||us(Ke.rankKey,xe.rankKey))&&(xe=Ke)}if(null===xe)return{placed:null,failure:xt(Be)};if(!Ui(m,xe.furniture,j?"tail":"head",le))return{placed:null,failure:zt.START_TOO_FAR};const ze=new Map;for(const[qe,Ke]of xe.officeDemand)Ke>0&&ze.set(qe,Ke);for(const qe of xe.footprint)m.ledger.isSliceFree(qe)&&m.ledger.claimSlice(qe,"dept");const Fe={furniture:xe.furniture,tertiaries:xe.tertiaries,usedSlices:xe.footprint,placedSeats:xe.placedSeats,unmetSeats:Math.max(0,Se-xe.placedSeats),unmetOffices:ze,flippedFirstRange:xe.flippedFirstRange};return m.placed=Fe,{placed:Fe,failure:null}}(Be,m,$e,qe,Se?null:Me.irrigation,R,B,W,le,ze,_e);if(null===ot.placed)return{attempt:null,hasCursorFloor:Ke,cursorTile:it};const ct=new Map;for(let Ze=0;Ze<Be.flatTiles.length;Ze++)ct.set(Be.flatTiles[Ze],Be.rangeIds[Ze]);const at=new Set;for(const Ze of ot.placed.usedSlices){const Ve=ct.get(Ze.tile);void 0!==Ve&&at.add(Ve)}return{attempt:{state:Be,placed:ot.placed,rankKey:is(0,ot.placed,m),reachedRanges:at,fromEnd:W,cursorPos:Ne},hasCursorFloor:Ke,cursorTile:it}}function yi(m,b,C,A,R,B,W,j,se,le,_e,Se,Oe,Me){const Be=Oi(m,b,C,A,R,B,!1,j,se,le,Se,Me),Ne=Be.attempt,xe=null===Ne||Ne.placed.unmetSeats>0||Ne.placed.unmetOffices.size>0,ze=Ne?.state.lastTile??null,Fe=null!==Ne&&null!==ze&&null!==Ne.state.ledger.occupiedExtent(ze),qe=W&&Fe,Ke=_e&&Be.hasCursorFloor&&xe;if(!Oe||!qe&&!Ke||B.exhausted)return Ne;const it=Oi(m,b,C,A,R,B,!0,j,se,le,Se,Me),$e=it.attempt;return null===$e||Ke&&!qe&&!function Ii(m,b){if(null===b)return!0;for(const B of m.placed.usedSlices)if(B.tile===b)return!0;const C=m.state,A=C.tileStartX.get(b);if(void 0===A)return!0;const R=A+b.width;for(const B of m.placed.furniture)for(const W of B.bodySlices){const j=C.globalX(W),se=C.globalXEnd(W);if((j>=R?j-R:se<=A?A-se:0)<=ls+1e-6)return!0}return!1}($e,it.cursorTile??Be.cursorTile)?Ne:null===Ne?$e:Ci(Ne.rankKey,$e.rankKey)?Ne:$e}function ss(m,b){const C=m.cursorTile;if(!C)return null;const A=C[2];if(null==A)return null;const R=b[A];return R&&R.length>0?A:null}function ns(m){const b=[];for(const C of m)C.tileRangeExtraInfos.some(([,,,A])=>A&&A.length>0)&&b.push(C.dynamicItemIdx);return b}function ps(m,b){for(const[C,A]of m)if(b.get(C)!==A)return!1;return!0}function gs(m){return m.placed.unmetSeats<=0&&0===m.placed.unmetOffices.size}function ms(m,b,C,A){const R=se=>Math.abs(se.cursorPos.rangeIdx-C),B=se=>Math.abs(se.cursorPos.tileIdx-A),W=R(m),j=R(b);return W!==j?W<j:B(m)<B(b)}function oi(m,b,C,A,R,B,W,j,se,le,_e,Se,Oe,Me,Be){let Ne=yi(m,b,C,A,R,B,W,j,se,le,_e,Se,Oe,Be),xe=A;if(null!==Ne){const ze=function kt(m,b){const C=[];for(const A of rt(m))m[A].some(B=>B.tileRangeExtraInfos.some(W=>b.has(W[0])))&&C.push(A);return C}(C,Ne.reachedRanges).filter(Fe=>Fe!==Me);if(ze.length>0)for(const Fe of function qt(m,b,C,A=null){const R=[];for(const W of b){const j=m[W];j&&j.length>1&&R.push([W,ti(j,A)])}if(0===R.length)return[new Map(C)];let B=[new Map(C)];for(const[W,j]of R){const se=[];for(const le of B){for(const _e of j){if(se.length>=Re)break;const Se=new Map(le);Se.set(W,_e),se.push(Se)}if(se.length>=Re)break}if(B=se,B.length>=Re)break}return B.slice(0,Re)}(C,ze,A,j)){if(B.exhausted)break;if(ps(Fe,A))continue;const qe=yi(m,b,C,Fe,R,B,W,j,se,le,_e,Se,Oe,Be);null!==qe&&Ci(qe.rankKey,Ne.rankKey)&&(Ne=qe,xe=Fe)}}return null===Ne?null:{attempt:Ne,picks:xe}}function Ai(m,b={}){if(!m.tiles||0===m.tiles.length)return null;const C=b.pickTertiaries??!1,A=b.pickRemain??!1,R=b.canReverseFromLastTile??!1,B=b.trimDepartmentExtremities??!0,W=b.contiguousDepartmentFurniture??!0,j=b.continueFromCursorBackwards??!0,se=b.checkDepthWaste??!1,le=b.cornerCursorReverseAll??!0,_e=b.moduleSkipIrrigation??!1,Se=new Ce(b.opBudget??Pe),Oe=function ri(m){return m.runLeftToRight?[...m.tiles]:[...m.tiles].reverse().map(b=>({tiles:[...b.tiles].reverse(),startOnWall:b.endOnWall,endOnWall:b.startOnWall,startIsPartial:b.endIsPartial,endIsPartial:b.startIsPartial}))}(m),Me=m.corners??{},Be=function ae(m){const b=new Map,C=m.corners??{},A=m.tertiaryCorridorWidth;for(const R of Object.keys(C)){const B=C[Number(R)];if(B&&0!==B.length)for(const W of B){let j=null;for(const[se,le,_e,Se]of W.tileRangeExtraInfos){if(Se&&Se.length>0||"number"!=typeof _e||_e<=A)continue;const Oe=V(B,W);if(null===Oe)continue;const[Me,Be]=Oe,Ne={...Me,width:_e,hasWindow:!0,posts:Q(Me,_e,Be)};q.set(Ne,{sibling:Me,wallAtStart:le,cornerTile:U(W)}),null===j&&(j=new Map),j.set(re(se,le),Ne)}null!==j&&b.set(W,j)}}return b}(m),Ne=function dt(m,b=null){const C=new Map;for(const A of rt(m)){const R=m[A];let B=R[0],W=Ge(B,b);for(const j of R.slice(1)){const se=Ge(j,b);(se[0]>W[0]||se[0]===W[0]&&se[1]>W[1]||se[0]===W[0]&&se[1]===W[1]&&j.dynamicItemIdx<B.dynamicItemIdx)&&(B=j,W=se)}C.set(A,B.dynamicItemIdx)}return C}(Me,Be);b.debug&&function Li(m,b,C,A,R){const B=(...Se)=>console.log("[CLAUDE-PLACEALL]",...Se),W=Se=>`${Math.round(Se.width)}x${Math.round(Se.height)}${Se.isInCorner?"@corner":""}`;B("=== corners ===");for(const Se of Object.keys(C)){const Oe=Number(Se),Me=C[Oe];if(Me){B(`group ${Oe}: ${Me.length} variant(s), picked = v${R.get(Oe)}`);for(const Be of Me){const Ne=A.get(Be);let xe=0;const ze=[];for(const[Fe,qe,Ke,it]of Be.tileRangeExtraInfos){const $e=Ne?.get(re(Fe,qe));if(it&&it.length>0){for(const gt of it)xe+=gt.width;ze.push(`[r${Fe}${qe?"@begin":"@end"} MAIN ${it.map(W).join("+")}]`)}else void 0!==$e?(xe+=$e.width,ze.push(`[r${Fe}${qe?"@begin":"@end"} REACH ${W($e)} (ovr=${Ke})]`)):ze.push(`[r${Fe}${qe?"@begin":"@end"} onWall=${String(Ke)} \u2014 no reach]`)}B(` v${Be.dynamicItemIdx}: exposes ${Math.round(xe)}cm ${ze.join(" ")}`)}for(const Be of Me){const Ne=mt(b,C,new Map([[Oe,Be.dynamicItemIdx]]),A);B(` v${Be.dynamicItemIdx}
1 resolves to:`),Ne.ranges.forEach((xe,ze)=>B(` r${ze} sw=${String(xe.startOnWall)} ew=${String(xe.endOnWall)} [${xe.tiles.map(Fe=>oe(Fe)?`W${Math.round(Fe.width)}`:W(Fe)).join(", ")}]`))}}}const j=ss(m,C);null!==j&&B(` cursorTile targets corner group ${j}; anchorable variants = [${ns(C[j]).map(Se=>"v"+Se).join(", ")}] \u2014 each is tried as its own forward candidate (SPEC2 \xa79.7)`);const se=mt(b,C,R,A),le=Pi(m,se,C,R),_e=se.ranges[le.rangeIdx]?.tiles[le.tileIdx];B("=== cursor ==="),B(` Input.cursorTile = ${JSON.stringify(m.cursorTile)} -> resolved r${le.rangeIdx}/t${le.tileIdx}${_e?" = "+W(_e):" = <none>"}`),B(" NOTE: the emitter indexes tiles BEFORE corner tiles are spliced in; a prepended"),B(" corner shifts every real tile by +1, so a cursor with tileIdx>0 can slice"),B(" the corner away from the forward pass."),B("=== segments (forward from cursor) ==="),Ti(se,le,!0,m.loops).forEach((Se,Oe)=>B(` seg${Oe} sw=${String(Se.sw)} ew=${String(Se.ew)} [${Se.spans.map(Me=>oe(Me.tile)?`W${Math.round(Me.tile.width)}`:W(Me.tile)).join(", ")}]`)),B("=== department ==="),B(` requiredSeats=${m.requiredSeats} offices=${m.offices.map(Se=>Se.required).join("/")||"none"}`),B(` benches=${m.benches.map(Se=>`${Math.round(Se.width)}x${Math.round(Se.height)}/${Se.seats}s`).join(" ")||"none"}`),B(` distToWall=${m.distToWall} distBenchToBench=${m.distBenchToBench} tertiary=${m.tertiaryCorridorWidth} windowOffset=${m.windowOffset}`),B(` a bench needs tile depth >= minBenchHeight + windowOffset = ${Math.min(...m.benches.map(Se=>Se.height))+m.windowOffset}`)}(m,Oe,Me,Be,Ne);const xe=ss(m,Me),ze=_e&&m.isStandaloneModule&&null!==xe;let Fe=null;if(null===xe)Fe=oi(m,Oe,Me,Ne,C,Se,R,Be,B,W,j,se,!0,null,ze)?.attempt??null;else{const it=m.cursorTile?.[0]??0,$e=m.cursorTile?.[1]??0;let gt=null;for(const ot of ns(Me[xe])){if(Se.exhausted)break;const ct=new Map(Ne);ct.set(xe,ot);const at=oi(m,Oe,Me,ct,C,Se,R,Be,B,W,j,se,le,xe,ze);if(null!==at&&((null===Fe||Ci(at.attempt.rankKey,Fe.rankKey)||!Ci(Fe.rankKey,at.attempt.rankKey)&&ms(at.attempt,Fe,it,$e))&&(Fe=at.attempt,gt=at.picks),null!==Fe&&gs(Fe)))break}if(!le&&null!==Fe&&null!==gt&&!Se.exhausted){const ot=yi(m,Oe,Me,gt,C,Se,R,Be,B,W,j,se,!0,ze);null!==ot&&Ci(ot.rankKey,Fe.rankKey)&&(Fe=ot)}}if(null===Fe)return null;let qe=null;const Ke=function wt(m){const b=[];if(!m.susAreas||0===m.susAreas.length||!m.susLinks)return b;for(const C of m.susLinks){const A=C.targetSusAreaIdx;if(!(A>=0&&A<m.susAreas.length))continue;const R=C.perConfigurationAdjacentRects??[];for(let B=0;B<R.length;B++)for(const W of R[B]??[]){const[j,se]=W.rectMinMaxXs;b.push({susAreaIdx:A,configIdx:B,rectIdx:W.rectIdx,rectXMin:0|Math.min(j,se),rectXMax:0|Math.max(j,se),anchorTileIdxs:new Set(W.tileIdxes)})}}return b}(m);if(Ke.length>0&&(Fe.placed.unmetSeats>0||Fe.placed.unmetOffices.size>0)){const it=new Set;for(const $e of Fe.placed.usedSlices)it.add($e.tile.idx);qe=function ui(m,b,C,A,R){if(0===b.length)return null;let B=!1;for(const Ke of R.values())if(Ke>0){B=!0;break}if(A<=0&&!B)return null;const W=function It(m,b){return m.filter(C=>{for(const A of C.anchorTileIdxs)if(b.has(A))return!0;return!1})}(b,C);if(0===W.length)return null;const j=[...W].sort((Ke,it)=>Ke.susAreaIdx-it.susAreaIdx||Ke.configIdx-it.configIdx||Ke.rectIdx-it.rectIdx),se=new Map,le=new Set,_e=[],Se=new Map;for(const[Ke,it]of R)it>0&&Se.set(Ke,it);let Oe=A,Me=0;const Be=new Map;for(const Ke of j){if(Oe<=0&&0===Se.size)break;const it=se.get(Ke.susAreaIdx);if(void 0!==it&&it!==Ke.configIdx)continue;const $e=Rt(m,Ke);if(null===$e)continue;const gt=`${Ke.susAreaIdx}#${Ke.configIdx}#${Ke.rectIdx}`;if(le.has(gt))continue;const ot=gi(m,Math.max(0,Oe),Se,$e,m.cellSize,0,$e.startOnWall);if(null===ot)continue;let ct=0;for(const at of ot.officeCounts.values())ct+=at;if(!(ot.seats<=0&&ct<=0)){_e.push({susAreaIdx:Ke.susAreaIdx,configIdx:Ke.configIdx,builtRect:ot.builtRect}),se.set(Ke.susAreaIdx,Ke.configIdx),le.add(gt),Oe-=ot.seats,Me+=ot.seats;for(const[at,Ze]of ot.officeCounts){if(Ze<=0)continue;const Ve=(Se.get(at)??0)-Ze;Ve>0?Se.set(at,Ve):Se.delete(at),Be.set(at,(Be.get(at)??0)+Ze)}}}if(0===_e.length)return null;let Ne=1/0;for(const Ke of m.benches)Ne=Math.min(Ne,Ke.seats);let xe=0;for(const Ke of Be.values())xe+=Ke;if(!(Me>=Ne||xe>=1))return null;const ze=m.cellSize*m.cellSize,Fe=new Map;for(const Ke of _e){const it=Fe.get(Ke.susAreaIdx);it?it.push(Ke):Fe.set(Ke.susAreaIdx,[Ke])}const qe=[];for(const Ke of[...Fe.keys()].sort((it,$e)=>it-$e)){const it=Fe.get(Ke),$e=it.map(ot=>ot.builtRect);let gt=0;for(const ot of $e)gt+=(ot.topRight[0]-ot.bottomLeft[0])*(ot.topRight[1]-ot.bottomLeft[1])*ze;qe.push({targetSusArea:m.susAreas[Ke],configurationIdx:it[0].configIdx,consumedArea:gt,builtRects:$e})}return{outputs:qe,seats:Me,officeCounts:Be}}(m,Ke,it,Fe.placed.unmetSeats,Fe.placed.unmetOffices)}return function Ie(m,b,C){const A=new Set;for(const W of C.usedSlices)A.add(W.tile);if(0===A.size)return;const R=C.furniture.filter(W=>W.kind===Je.BENCH&&null!==W.benchOrOffice&&W.slices.length>0);if(0===R.length)return;const B=new Map;for(let W=0;W<m.flatTiles.length;W++){const j=m.flatTiles[W];if(!A.has(j))continue;const se=m.rangeIds[W],le=B.get(se);le?le.push(j):B.set(se,[j])}for(const W of B.values()){if(0===W.length)continue;const j=lt(W),se=new Map;for(let Me=0;Me<W.length;Me++)se.set(W[Me],Me);const le=[],_e=[];for(const Me of C.tertiaries){const Be=_(Me,se,j);null!==Be&&_e.push(Be)}for(const Me of R){if(!Me.slices.every(Ke=>se.has(Ke.tile)))continue;const Be=i(Me,se,j);if(null===Be)continue;const[Ne,xe]=Be,ze=Me.benchOrOffice;let Fe=I(W,j,Ne,xe);_e.length>0&&(Fe=Fe.concat(o(Ne,Ne+xe,_e,W,j,b.tertiaryCorridorWidth)));const qe=s(W,j,Ne,xe,b.windowOffset);le.push({item:Me,bench:ze,posts:Fe,maxY:qe,feasible:T(ze,Fe,qe)})}if(0===le.length)continue;const Se=Math.min(...le.map(Me=>Me.maxY))/2,Oe=F(le.map(Me=>Me.feasible),Se);for(const Me of le){if(null!==Oe&&Me.feasible.some(([xe,ze])=>xe-et<=Oe&&Oe<=ze+et)){ue(Me.item,Me.bench,Oe-Me.bench.height/2,Me.posts,Me.maxY);continue}const Ne=$(Me.bench,(Me.item.centroidY??0)-Me.bench.height/2,u(Me.posts,Me.maxY),Me.maxY);null!==Ne&&ue(Me.item,Me.bench,Ne,Me.posts,Me.maxY)}}}(Fe.state,m,Fe.placed),function At(m,b,C,A,R,B,W){const j=function je(m){const b=[];for(const C of m.flatTiles){const A=m.ledger.occupiedExtent(C);if(null===A)continue;const[R,B]=A;b.push(new Xe.OB(C,ve(R),ve(B-R),oe(C)))}return b}(m);if(0===j.length)return null;let se=0;
1for(const Oe of j)se+=Oe.partialOrWidth*Oe.tile.height;const le=A?.outputs??[],_e=function _t(m,b){if(0===b.length)return[];const C=b[0].tile,A=[];for(const B of m.flatTiles){if(B===C)break;A.push(new Xe.OB(B,0,B.width,oe(B)))}const R=m.ledger.occupiedExtent(C);return null!==R&&R[0]>0&&A.push(new Xe.OB(C,0,ve(R[0]),oe(C))),A}(m,j),Se=new Set;for(const Oe of _e)(Oe.x??0)<=0&&Math.abs(Oe.partialOrWidth-Oe.tile.width)<=.001&&Se.add(Oe.tile);return{usedTiles:j,builtBenchesOfficesAndClosets:C.furniture.map(We),susAreas:le,tertiariesTiles:B?St(C.tertiaries):[],firstUsedTile:j[0],lastUsedTile:j[j.length-1],consumedArea:se,isFulfilled:ut(C,A),tilesUntilFirstPicked:_e,remainRangeTiles:R?yt(m,C,Se):[],hasFlippedFirstRange:C.flippedFirstRange,pickedReversed:W}}(Fe.state,0,Fe.placed,qe,A,C,Fe.fromEnd)}const Ji=m=>Math.max(15,.05*m);function Hi(m,b){const C={side:"top",rotation:0};try{if(!m)return C;const A=m.getEnvelopeInternal(),R=A.getMaxX()-A.getMinX(),B=A.getMaxY()-A.getMinY();let W=null;try{W=b?._targetFloorInput?.targetFloor?.corridorSpaces?.()}catch{W=null}if(W&&!e.xb(W)){const Oe=[["bottom",e.uM({x:A.getMinX(),y:A.getMinY()},{x:A.getMaxX(),y:A.getMinY()})],["top",e.uM({x:A.getMinX(),y:A.getMaxY()},{x:A.getMaxX(),y:A.getMaxY()})],["left",e.uM({x:A.getMinX(),y:A.getMinY()},{x:A.getMinX(),y:A.getMaxY()})],["right",e.uM({x:A.getMaxX(),y:A.getMinY()},{x:A.getMaxX(),y:A.getMaxY()})]];let Me=null,Be=1/0;if(Oe.forEach(([Ne,xe])=>{let ze=1/0;try{ze=e.TE(xe,W)}catch{ze=1/0}ze<Be&&(Be=ze,Me=Ne)}),Me)return{side:Me,rotation:"top"===Me||"bottom"===Me?0:Math.PI/2}}let j=0,se=0,le=0;if((b?.directLightAreaStates||[]).forEach(Oe=>{try{const Me=Oe.coveredSpace?.getEnvelopeInternal?.();if(!(Me&&Me.getMaxX()>=Me.getMinX()))return;j+=(Me.getMinX()+Me.getMaxX())/2,se+=(Me.getMinY()+Me.getMaxY())/2,le++}catch{}}),!le)return C;j/=le,se/=le;const _e=(A.getMinX()+A.getMaxX())/2,Se=(A.getMinY()+A.getMaxY())/2;return R>=B?{side:se>=Se?"top":"bottom",rotation:0}:{side:j>=_e?"right":"left",rotation:Math.PI/2}}catch{return C}}function Ri(m,b,C,A,R,B){let W=(0,n._e)(m,b,C,!0,!0,R,B);if(W?.manager)return{cres:W,tile:C,supArea:b};try{W?.dispose?.()}catch{}const se=[];m.directLightAreaStates.forEach(le=>{le.tileStates.forEach(_e=>{if(!_e.isActive||!_e.isFree||_e===C)return;let Se=1/0;try{Se=e.TE(A,_e.coveredSpace)}catch{}Se<=300&&se.push({t:_e,a:le,d:Se+(le===b?0:300)})})}),se.sort((le,_e)=>le.d-_e.d);for(const le of se.slice(0,6)){if(W=(0,n._e)(m,le.a,le.t,!0,!0,R,B),W?.manager)return console.warn("[TILEDBG] started from the nearest free tile instead of the drop tile",{distance:Math.round(le.d)}),{cres:W,tile:le.t,supArea:le.a};try{W?.dispose?.()}catch{}}return{cres:null,tile:C,supArea:b}}function zi(m,b,C,A=!0){let R=null,B=null,W=150,j=null,se=null;if(m.floor.directLightAreaStates.forEach(vt=>{R||vt.tileStates.forEach(Ot=>{if(!R&&Ot.isActive)if(e.kK(Ot.coveredSpace,m.floorPosition))B=Ot,R=vt;else{const bt=e.TE(m.floorPosition,Ot.coveredSpace);bt<W&&(W=bt,j=Ot,se=vt)}})}),!B&&j&&(B=j,R=se),!R)return console.warn("createPlaceDepartmentInfo: returning false because no supArea found (1)"),!1;let le=null;if(m.droppedOption&&m.droppedOption.department){const vt=m.droppedOption.department;le=m.floor.parentPropertyState.programState.departmentStates.find(Ot=>Ot.targetRequirement===vt||Ot.targetRequirement?.id&&Ot.targetRequirement?.id===vt?.id||Ot.targetRequirement?.name&&Ot.targetRequirement?.name===vt?.name)}else m.droppedOption&&m.droppedOption.optionState?.state&&(le=m.droppedOption.optionState.state);if(!le)return console.warn("createPlaceDepartmentInfo: returning false because no departmentState found. Dropped option:",m.droppedOption,"departmentStates:",m.floor.parentPropertyState.programState.departmentStates),!1;const Se=(vt=m.droppedOption)&&Array.isArray(vt.supAreaInfos)?m.droppedOption:null,Oe=Ri(m.floor,R,B,m.floorPosition,m.directionFlowIsPositive??null,Se);var vt;let Me=Oe.cres;B=Oe.tile,R=Oe.supArea;let Be=Me?.manager,Ne=Me?.flowDirectionIsPositive,xe=Me?.currentFloorNavigator,ze=Me?.dispose;if(!Be){try{const vt=R?.tileStates||[],Ot=vt.filter(Yt=>Yt?.isActive).length,bt=vt.filter(Yt=>Yt?.isFree).length,Mt=vt.filter(Yt=>Yt?.isFreeAndActive).length;console.warn("[TILEDBG] no flowManager",{dropTile:B?{isActive:B.isActive,isFree:B.isFree,isFreeAndActive:B.isFreeAndActive}:"NO TILE AT DROP POINT",supAreaTiles:vt.length,active:Ot,free:bt,freeAndActive:Mt,department:le?.targetRequirement?.name,isMove:!!Se})}catch(vt){console.warn("[TILEDBG] failed",vt)}return console.warn("createPlaceDepartmentInfo: returning false because no flowManager found (2)"),ze?.(),!1}const Fe=[],qe=new H.bI;let Ke=new Map,it=0;const $e=new Set,gt=()=>{try{return Be.pickFlowMap(B.partitionableShapeInfo.uidInPackage())?.sections??[]}catch{return[]}},ot=(vt,Ot)=>`${String(vt?.directLight?.fullUid)}#${Ot}`,ct=vt=>gt().some((Ot,bt)=>!$e.has(ot(vt,bt))),at=[];let Ze=B;const Ve=()=>{const vt=gt();let Ot=-1;for(let Kt=0;Kt<vt.length;Kt++)if(!$e.has(ot(R,Kt))){Ot=Kt;break}if(Ot<0)return console.warn("[LOOPDBG] no unused section left in this area",{sections:vt.length}),[!1,null];$e.add(ot(R,Ot));const bt=vt[Ot],Mt=function Ae(m,b,C,A,R,B){let W=new Map,j=0;const se=b.openspaceState.targetRequirement;C?(j=C.usedOpenSpaces,W=new Map(C.usedOffices)):(b.officeStates.forEac
1h(Be=>{W.set(Be.targetRequirement,Be.remainingCount)}),j=b.openspaceState.remainingCount,A&&A.supAreaInfos.forEach(Be=>{Be.programModules.forEach(Ne=>{if(Ne.programModule&&!(Ne.placedCount<=0))if(Ne.programModule===se)j+=Ne.placedCount;else{const xe=W.get(Ne.programModule)??0;W.set(Ne.programModule,xe+Ne.placedCount)}})})),R&&R.forEach((Be,Ne)=>{if(Ne===se)j=Math.max(0,j-Be);else{const xe=W.get(Ne)??0;W.set(Ne,Math.max(0,xe-Be))}}),B&&(j=Math.max(0,j-B));const le=[];for(const[Be,Ne]of W.entries())if(Ne>0){const xe=[];for(const ze of Be.dimensions)for(const Fe of ze.dimensions)xe.push([[Fe[0],Fe[1]],[ze.picker,ze.layout,[Fe[0],Fe[1],Fe[2]]]]);xe.length>0&&le.push(new Xe.lk({programModule:Be,required:Ne,widthHeights:xe.map(ze=>ze[0]),dimensionSignatures:xe.map(ze=>ze[1])}))}const _e=[];let Se=null;const Oe=se.settingId;for(const Be of se.dimensions){const Ne=Be.picker.getSettings(Oe);Se=Ne;for(const xe of Be.dimensions)xe[2]>Ne.maxDeskPerBench||_e.push([xe[0]+2*Ne.setback,xe[1],xe[2],Be.picker,Be.layout,Ne])}return null===Se&&(Se=te.t.createDefault()),new Xe.II({tiles:[],corners:[],susAreas:[],susLinks:[],offices:le,benches:_e.map(Be=>({width:Be[0],height:Be[1],seats:Be[2],dimensionSignature:[Be[3],Be[4],[Be[0],Be[1],Be[2]]]})),requiredSeats:j,closetRowWidth:m,benchesBeforeCloset:Se.benchCountBeforeScreening,benchesBeforeFirstCloset:Se.benchCountBeforeScreening,windowOffset:Se.windowOffset,distToWall:Se.deskToWallDistance,distBenchToBench:Se.deskToDeskDistance,tertiaryCorridorWidth:90,runLeftToRight:!0})}(m.floor.parentPropertyState.inputData.moduleManager.getClosetWidth(),le,b,Se,Ke,it),Yt=bt.buildForClaude(Ze);Mt.tiles=Yt.tileRanges,Mt.corners=Yt.corners,Mt.cursorTile=Yt.cursorTile,Mt.loops=Yt.isLoop,console.warn("[LOOPDBG] candidate",{section:Ot,ofSections:vt.length,tiles:Mt.tiles?.length??0,placedOsWorkstations:it});try{const si=(Mt.tiles??[]).map(ai=>(Array.isArray(ai)?ai:ai?.tiles??[]).map(Si=>{const rs=Si?.tile??Si;return`${Math.round(rs?.width??0)}x${Math.round(rs?.height??0)}${rs?.isInCorner?"@c":""}`}).join("+")).join(" | "),Di=(Mt.benches??[]).map(ai=>`${Math.round(ai.width)}x${Math.round(ai.height)}/${ai.seats}s`).join(" ");at.push(`section ${Ot}/${vt.length}: tiles [${si}] need=${Mt.requiredSeats} benches=${Di} distToWall=${Mt.distToWall} benchToBench=${Mt.distBenchToBench} tertiary=${Mt.tertiaryCorridorWidth} windowOffset=${Mt.windowOffset}`)}catch(Kt){at.push("trace failed: "+Kt)}const Gt=Ai(Mt,{pickRemain:!0});if(Gt&&Gt.usedTiles.length>0){const Kt=R,si=qe.has(R.directLight.fullUid);return R=xe?.currentAreaNavigator?.directLightInfoState,qe.add(Kt.directLight.fullUid),Kt===R&&si&&Fe.length>0&&!ct(Kt)?[!1,[Mt,Gt,Kt,Gt.builtBenchesOfficesAndClosets.length>0]]:[!0,[Mt,Gt,Kt,Gt.builtBenchesOfficesAndClosets.length>0]]}return console.warn("[LOOPDBG] section produced no placement",{section:Ot,ofSections:vt.length}),[!1,null]};let pt=200,Ct=!1,Dt=0;const ht=vt=>{console.warn("[LOOPDBG] stop:",vt,{iterations:Dt,iterationsLeft:pt,outputs:Fe.length,placedOsWorkstations:it,hasElement:Ct})};for(;pt-- >0;){Dt++;const[vt,Ot]=Ve();if(!Ot){if(ct(R)){console.warn("[LOOPDBG] section barren \u2014 trying the next one");continue}ht("no result and no untried section left in this area");break}Fe.push(Ot);const bt=Ot[1];if(Ct=Ct||Ot[3],bt.builtBenchesOfficesAndClosets.forEach(Gt=>{Gt.benchOrOffice&&(Gt.benchOrOffice?.programModule?Ke.set(Gt.benchOrOffice.programModule,(Ke.get(Gt.benchOrOffice.programModule)??0)+1):it+=Gt.benchOrOffice.seats)}),(bt.susAreas||[]).forEach(Gt=>{Gt.builtRects.forEach(Kt=>{Kt.items.forEach(si=>{si.benchOrOffice&&(si.benchOrOffice?.programModule?Ke.set(si.benchOrOffice.programModule,(Ke.get(si.benchOrOffice.programModule)??0)+1):it+=si.benchOrOffice.seats)})})}),console.warn("[LOOPDBG] iteration",Dt,{keepOn:vt,builtThisPass:bt.builtBenchesOfficesAndClosets.length,usedTiles:bt.usedTiles?.length??0,placedOsWorkstations:it}),bt.isFulfilled){ht("engine reports isFulfilled (need met)");break}if(!vt){if(ct(R)){console.warn("[LOOPDBG] area pass finished \u2014 trying the next section");continue}
1ht("keepOn=false and no untried section left");break}B=bt.pickedReversed?bt.firstUsedTile.tile.targetTile.tile:bt.lastUsedTile.tile.targetTile.tile;let Yt=(0,n._e)(m.floor,R,B,!0,!0,Ne,Se,xe,bt.pickedReversed?bt.lastUsedTile.tile.targetTile.tile:bt.firstUsedTile.tile.targetTile.tile);if(Yt?.shouldStop){if(ct(R)){console.warn("[LOOPDBG] shouldStop here \u2014 trying the next section");continue}ht("createFlowMappingManager: shouldStop, no untried section left");break}if(!Yt){if(ct(R)){console.warn("[LOOPDBG] no next flow manager here \u2014 trying the next section");continue}ht("createFlowMappingManager returned null (stuck between placed elements)");break}if(Be=Yt.manager,xe=Yt.currentFloorNavigator,bt.expandedFromLastTile=Yt.choseReverseCursorTile||!1,Ze=null,!Be)return console.warn("createPlaceDepartmentInfo: returning false because no flowManager after loop"),ze?.(),!1;pt<=0&&ht("ran out of iterations (noEternity cap reached)")}if(ze?.(),Fe.length<=0||!Ct)return console.warn("createPlaceDepartmentInfo: returning false because outputs empty or !hasElement\n "+at.join("\n ")),!1;const Nt=Fe.filter(vt=>vt[1].usedTiles.length>0),Ht=function ce(m,b,C){const A=new J,R=new D.O;R.department=m,A.departmentInfo=R;const j=b.length-1;return b.forEach(([se,le],_e)=>{((se,le,_e,Se)=>{let Oe={...le.dynamicSectionItemIdx};const Me=[],Be=[];let Ne=null;const xe=[];let ze=!1,Fe=!1;_e||(xe.push(se.pickedReversed?se.remainRangeTiles:se.tilesUntilFirstPicked),ze=se.pickedReversed,Fe=!se.pickedReversed),xe.push(se.usedTiles),Se||xe.push((se.expandedFromLastTile?se.pickedReversed:!se.pickedReversed)||ze?Fe?[]:se.remainRangeTiles:se.tilesUntilFirstPicked);const qe=xe.flat();for(const Ze of qe){if(Ze.tile.sus){const[Ve,pt]=x(Ze);Be.push([Ve,pt]),Ne=Ne?e.Y7(pt,Ne):e.rY(pt)}else Me.push(k(Ze));Ze.tile.targetTile.tile.dynamicSectionIdx>=0&&Ze.tile.targetTile.tile.dynamicItemIdx>0&&(Oe[Ze.tile.targetTile.tile.dynamicSectionIdx]=Ze.tile.targetTile.tile.dynamicItemIdx),A.consumedWidth+=Ze.partialOrWidth}A.dynamicMap=Oe;let Ke=ke(Me,le,Oe,!0);Ne&&(Ke=e.lE(e.Y7(Ke,Ne),5));const it=[],$e=new Map,gt=Ke.getNumGeometries();for(let Ze=0;Ze<gt;Ze++)$e.set(Ze,[]);const ot=new H.me,ct={};for(let Ze=0;Ze<Ke.getNumGeometries();Ze++)ct[Ze]=[];const at=Ze=>{let Ve=e.lD();for(const pt of Ze)Ve=e.Y7(pt.createCoveredSpace(),Ve);return e.b3(e.lE(Ve,5))};for(const Ze of Me){const Ve=Ze.createCoveredSpace();ot.set(Ze.tile.partitionableShapeInfo.uidInPackage(),Ve);for(let pt=0;pt<Ke.getNumGeometries();pt++)if(e.kK(Ve,Ke.getGeometryN(pt))){$e.get(pt).push(Ze);break}}for(const[Ze,Ve]of Be)for(let pt=0;pt<Ke.getNumGeometries();pt++)if(e.kK(Ve,Ke.getGeometryN(pt))){ct[pt].push([Ze,Ve]);break}for(let Ze=0;Ze<Ke.getNumGeometries();Ze++){const Ve=Ke.getGeometryN(Ze),pt=new D.O.SupAreaInfo;pt.supAreaFullUid=le.directLight.fullUid,R.supAreaInfos.push(pt),it.push([Ve,pt]);const Ct=$e.get(Ze)||[];pt.tileInfos=Ct.map(ht=>ht.asDict()),pt.susExtras=ct[Ze].map(([ht,Nt])=>ht),pt.coveredSpace=Ve;const Dt={};for(const ht of Ct)ht.tile.dynamicSectionIdx>=0&&ht.tile.dynamicItemIdx>0&&(Dt[ht.tile.dynamicSectionIdx]=ht.tile.dynamicItemIdx);if(pt.dynamicSectionItemIdxes=Dt,C&&C.supAreaInfos&&C.supAreaInfos[Ze]){const ht=C.supAreaInfos[Ze];if(ht.openspaceFurnitureBlocks&&(pt.openspaceFurnitureBlocks=ht.openspaceFurnitureBlocks.map(Nt=>Nt.clone()),ht.coveredSpace&&pt.coveredSpace)){const Nt=e.Sc(ht.coveredSpace),Ht=e.Sc(pt.coveredSpace),ei=Ht.getX()-Nt.getX(),Xt=Ht.getY()-Nt.getY();pt.openspaceFurnitureBlocks.forEach(vt=>vt.translateBy(ei,Xt))}}}for(const Ze of se.builtBenchesOfficesAndClosets){const Ve=new D.O.SupProgramModuleInfo,pt=null==Ze.benchOrOffice,Ct=!pt&&!Ze.benchOrOffice?.programModule;pt||(Ve.placedCount=Ct?Ze.benchOrOffice.seats:1,Ve.pickedDimension=Ze.dimensionSignature,Ve.programModule=Ct?m.openspace:Ze.benchOrOffice.programModule);const[Dt,ht]=f(Ze.tiles);Ve.tileInfos=Dt.map(Ht=>Ht.asDict()),Ve.isCloset=pt;let Nt=at(Dt);if(ht&&(Ve.extraSus=ht[0],Nt=e.b3(e.lE(e.Y7(Nt,ht[1])))),Ve.coveredSpace=Nt,pt||Ct){const[Ht,ei]=K(Ze.centroidTileX,Ze.centroidTile);if(Ht&&null!=Ve.extraSus)Ve.extraSus.furnitureCentroid=ei;else{let Xt=ei;Array.isArray(Xt)&&(Xt=K(Ze.centroidTileX,Ze.centroidTile,!0)[1]),Ve.furnitureCentroidTile=Ze.centroidTile.tile.targetTile.tile.partitionableShapeInfo.uidInPackage(),Ve.furnitureCentroidOffsetX=Xt,Ve.furnitureCentroidDepth=Ze.centroidTileY}}for(let Ht=0;Ht<it.length;Ht++){const[ei,Xt]=it[Ht];if(e.kK(Nt,ei)){if(C&&C.supAreaInfos&&C.supAreaInfos[Se?b.length-1:Ht]){const vt=C.supAreaInfos[Se?b.length-1:Ht];if(vt&&vt.programModules){const Ot=Xt.programModules.length;if(vt.programModules[Ot]&&vt.programModules[Ot].furnitureBlocks&&(Ve.furnitureBlocks=vt.programModules[Ot].furnitureBlocks.map(bt=>bt.clone()),vt.programModules[Ot].coveredSpace&&Ve.coveredSpace)){const bt=e.Sc(vt.programModules[Ot].coveredSpace),Mt=e.Sc(Ve.coveredSpace),Yt=Mt.getX()-bt.getX(),Gt=Mt.getY()-bt.getY();Ve.furnitureBlocks.forEach(Kt=>Kt.translateBy(Yt,Gt))}}}Xt.programModules.push(Ve);break}}}})(se,le,0===_e,_e===j),((se,le)=>
1{(se.susAreas||[]).forEach(_e=>{_e.builtRects.length&&_e.builtRects.forEach(Se=>{})})})(se)}),A}(le.targetRequirement,Nt.map(vt=>[vt[1],vt[2]]),Se);if(!Ht)return console.warn("createPlaceDepartmentInfo: returning false because buildDepartment failed"),C&&(C.nextTile=null),!1;const ei=m.floor.parentPropertyState?.inputData?.furnitureManager;if(ei&&Ht.departmentInfo){const vt=le.targetRequirement.openspace?.id;let Ot=null;try{Ot=m.floor._targetFloorInput?.targetFloor?.postSpaces?.()??null}catch{Ot=null}const bt=function Wi(m){let b=null;try{(m?.directLightAreaStates||[]).forEach(C=>{Object.entries(C?.dynamicSectionItemIdx||{}).forEach(([R,B])=>{const j=C?.dynamicSectionStates?.[Number(R)]?.itemStates?.[B]?.secondaryCorridors;!j||e.xb(j)||(b=e.Y7(b??e.lD(),j))})})}catch{return null}return b&&!e.xb(b)?b:null}(m.floor);Ht.departmentInfo.supAreaInfos.forEach(Mt=>{const Yt=!(!Mt.openspaceFurnitureBlocks||!Mt.openspaceFurnitureBlocks.length),Gt=le.targetRequirement?.openspace?.requiredWorkstations??le.targetRequirement?.openspace?.count??0;let Kt=Mt.coveredSpace;if(bt&&Mt.coveredSpace)try{const Qt=e.oo(Mt.coveredSpace,bt);Qt&&!e.xb(Qt)&&(Kt=Qt)}catch{}let si=null,Di=0;Mt.programModules.forEach(Qt=>{if(Qt?.isCloset&&Qt.coveredSpace)try{si=e.Y7(si??e.lD(),Qt.coveredSpace),Di++}catch{}}),Di&&console.warn("[FURNDBG] reserved closets/storage before desks",Di);const ai=Mt.programModules.filter(Qt=>!Qt?.isCloset&&Qt?.programModule&&Qt.programModule.id===vt),Si=function Os(m,b){const C=Hi(m,b),A=[C];try{if(!m)return A;const R=m.getEnvelopeInternal();if(!(R.getMaxX()>=R.getMinX()))return A;let B=null;try{B=b?._targetFloorInput?.targetFloor?.corridorSpaces?.()}catch{B=null}if(!B||e.xb(B))return A;const W=[["bottom",e.uM({x:R.getMinX(),y:R.getMinY()},{x:R.getMaxX(),y:R.getMinY()})],["top",e.uM({x:R.getMinX(),y:R.getMaxY()},{x:R.getMaxX(),y:R.getMaxY()})],["left",e.uM({x:R.getMinX(),y:R.getMinY()},{x:R.getMinX(),y:R.getMaxY()})],["right",e.uM({x:R.getMaxX(),y:R.getMinY()},{x:R.getMaxX(),y:R.getMaxY()})]],j=Oe=>{const Me=W.find(([Be])=>Be===Oe);if(!Me)return 1/0;try{return e.TE(Me[1],B)}catch{return 1/0}},se=j(C.side);if(!isFinite(se))return A;const le=300,_e=Oe=>"top"===Oe||"bottom"===Oe,Se=["bottom","top","left","right"].filter(Oe=>_e(Oe)!==_e(C.side)).map(Oe=>({side:Oe,d:j(Oe)})).filter(Oe=>isFinite(Oe.d)&&Oe.d<=se+le).sort((Oe,Me)=>Oe.d-Me.d)[0];Se&&A.push({side:Se.side,rotation:_e(Se.side)?0:Math.PI/2})}catch{}return A}(Mt.coveredSpace,m.floor);let ki=null;!Yt&&ai.length&&(Si.forEach((Qt,xi)=>{const Is=((Qt,xi)=>{const Is={geom:si},Hs=[];let ws=0,Ls=0;return ai.forEach(ys=>{try{Ls++;const os={programModule:ys.programModule,pickedDimension:ys.pickedDimension,coveredSpace:ys.coveredSpace??Mt.coveredSpace,furnitureBlocks:[]};(0,p.G)(os,ei,Qt.rotation,{room:Kt,posts:Ot,occupied:Is,align:{room:Kt,side:Qt.side},label:`dir${xi}(${Qt.side}):bench${Ls}`}),os.furnitureBlocks.length&&(ws+=ys.placedCount||0),Hs.push(...os.furnitureBlocks)}catch(os){console.warn("autoplace furniture failed for a bench",os)}}),{cs:Qt,blocks:Hs,seats:ws,benches:Ls,score:100*ws+(0===xi?50:0)}})(Qt,xi);(!ki||Is.score>ki.score)&&(ki=Is)}),Si.length>1&&console.warn("[FURNDBG] corner \u2014 compared corridor directions",{directions:Si.map(Qt=>Qt.side),chosen:ki?.cs?.side,seats:ki?.seats}));const Ms=ki?.blocks??[],Js=ki?.seats??0,Ws=ki?.benches??0;Mt.programModules.forEach(Qt=>{try{if(Qt.isCloset||!Qt.programModule||Qt.programModule.id===vt)return;if(!Qt.furnitureBlocks||0===Qt.furnitureBlocks.length){const xi=Hi(Qt.coveredSpace,m.floor);(0,p.G)(Qt,ei,xi.rotation,{room:Qt.coveredSpace,posts:Ot,clearances:{furniture:60,wall:20},label:`office:${Qt.programModule?.name??"?"}`})}}catch(xi){console.warn("autoplace furniture failed for a department module",xi)}}),Ms.length&&(Mt.openspaceFurnitureBlocks=Ms),Ws>0&&console.warn("[FURNDBG] sup-area capacity",{corridorDirection:ki?.cs?.side,directionsCompared:Si.length,benchCandidatesFromEngine:Ws,blocksAccepted:Ms.length,acceptedSeats:Js,needSeats:Gt,remainingNeed:Math.max(0,Gt-Js)})})}if(Ht.departmentInfo&&A)try{const vt=new Set;
1if((m.floor?.placedDepartments??[]).forEach(Ot=>{Ot?.departmentRequirement&&vt.add(Ot.departmentRequirement)}),vt.add(Ht.departmentInfo.department),1===vt.size){const Ot=(m.floor?._placedModules??m.floor?.placedModules??[]).map(bt=>bt?.coveredSpaces??bt?.coveredSpace).filter(Boolean);(0,y.wY)(Ht.departmentInfo,ei,Ot)}}catch(vt){console.warn("[TESTFIT] could not subdivide the department into bench modules",vt)}const Xt=Fe[Fe.length-1][1];return C&&Xt.lastUsedTile&&(C.nextTile=Xt.lastUsedTile.tile.targetTile.tile,C.nextTileSupArea=R),"boolean"!=typeof m.directionFlowIsPositive&&(m.directionFlowIsPositive=Ne),Ht.departmentInfo.floor=m.floor.targetFloor,Ht.departmentInfo}function _s(m,b,C,A=!0){const R=[],B=W=>W&&Array.isArray(W.supAreaInfos);if(!m.highlightInfo&&B(m.droppedOption)){const W=m.droppedOption.supAreaInfos.map(j=>j.coveredSpace).filter(Boolean);if(W.length>0&&m.floor.directLightAreaStates.forEach(j=>{j.tileStates.forEach(se=>{se.isActive||W.some(_e=>{try{return e.kK(se.coveredSpace,_e)}catch{return!1}})&&(se.setIsActive(!0),R.push(se))})}),0===R.length){const j=new Set(m.droppedOption.supAreaInfos.map(se=>se.supAreaFullUid?.toString?.()).filter(Boolean));j.size>0&&m.floor.directLightAreaStates.forEach(se=>{const le=se.directLight?.fullUid?.toString?.();!le||!j.has(le)||se.tileStates.forEach(_e=>{_e.isActive||(_e.setIsActive(!0),R.push(_e))})}),0===R.length&&m.floor.directLightAreaStates.forEach(se=>{se.tileStates.forEach(le=>{le.isActive||(le.setIsActive(!0),R.push(le))})})}}try{if(!m.highlightInfo&&B(m.droppedOption)&&m.floorPosition){const j=m.droppedOption,se=m.floor.placedDepartments.find(le=>{if(le.departmentRequirement===j.department)return!1;try{return e.kK(le.coveredSpaces,m.floorPosition)}catch{return!1}});if(se){const le=se.buildDragDropInfo(),_e=le.clone();_e.department=j.department;const Se=j.clone();return Se.department=le.department,new v.Z(j,_e,le,Se)}}const W=m.highlightInfo||zi(m,b,C,A);return!0===W&&B(m.droppedOption)?new h.Z(m.droppedOption):"boolean"==typeof W?null:B(m.droppedOption)?new X(W,m.droppedOption):new O(W)}finally{R.forEach(W=>W.setIsActive(!1))}}function Bs(m,b){let C=null,A=null,R=150,B=null,W=null;if(m.floor.directLightAreaStates.forEach($e=>{C||$e.tileStates.forEach(gt=>{if(!C&>.isActive)if(e.kK(gt.coveredSpace,m.floorPosition))A=gt,C=$e;else{const ot=e.TE(m.floorPosition,gt.coveredSpace);ot<R&&(R=ot,B=gt,W=$e)}})}),!A&&B&&(A=B,C=W),!C){const $e=m.floor.directLightAreaStates.reduce((ot,ct)=>ot+ct.tileStates.length,0),gt=m.floor.directLightAreaStates.reduce((ot,ct)=>ot+ct.tileStates.filter(at=>at.isActive).length,0);return console.warn("[MODDBG] createRegularModuleToSupPlaceInfo: no supArea. directLightAreas:",m.floor.directLightAreaStates.length,"totalTiles:",$e,"activeTiles:",gt),!1}const j=$e=>$e&&(void 0!==$e.programModule||void 0!==$e.coveredSpace)&&!$e.supAreaInfos,se=j(m.droppedOption)?m.droppedOption.programModule:m.droppedOption.optionState.state.targetRequirement,le=j(m.droppedOption)?m.droppedOption:null,_e=Ri(m.floor,C,A,m.floorPosition,m.directionFlowIsPositive??null,le);let Se=_e.cres;A=_e.tile,C=_e.supArea;let Oe=Se?.manager,Me=Se?.flowDirectionIsPositive,Be=Se?.dispose;if(!Oe){const $e=C.tileStates.filter(ot=>ot.isFree).length,gt=C.tileStates.filter(ot=>ot.isActive).length;return console.warn("[MODDBG] createRegularModuleToSupPlaceInfo: no flowManager. module:",se?.name||se?.module?.name,"tile isFree:",A?.isFree,"tile isActive:",A?.isActive,"supArea freeTiles:",$e,"activeTiles:",gt),Be?.(),!1}const Ne=Oe.pickFlowMap(A.partitionableShapeInfo.uidInPackage()).sections[0],xe=Ee(se);if(xe.offices.length<=0)return console.warn("[MODDBG] createRegularModuleToSupPlaceInfo: no offices (module has no dimensions). module:",se?.name||se?.module?.name),Be?.(),!1;const ze=Ne.buildForClaude(A);xe.tiles=ze.tileRanges,xe.corners=ze.corners,xe.cursorTile=ze.cursorTile,xe.loops=ze.isLoop;let Fe=Ai(xe,{pickRemain:!0,moduleSkipIrrigation:!0}),qe=null;if((!Fe||Fe.usedTiles.length<=0)&&xe.offices[0])try{const $e=xe.offices[0],gt=(ze.tileRanges??[]).map(Ze=>(Ze.tiles??[]).reduce((Ve,pt)=>Ve+(pt.width||0),0)),ot=Math.max(0,...gt),ct=Math.min(1/0,...(ze.tileRanges??[]).flatMap(Ze=>(Ze.tiles??[]).map(Ve=>Ve.height))),at=($e.widthHeights??[]).map((Ze,Ve)=>({w:Ze[0],h:Ze[1],i:Ve})).filter(Ze=>Ze.h<=ct+1e-6&&Ze.w>ot&&Ze.w-ot<=Ji(Ze.w)).sort((Ze,Ve)=>Ze.w-Ve.w);if(at.length&&ot>0){const Ze=at[0],Ve=xe.clone?xe.clone():xe,pt=Ve.offices[0];pt.widthHeights=[[ot,Ze.h]],pt.dimensionSignatures=[$e.dimensionSignatures[Ze.i]];const Ct=Ai(Ve,{pickRemain:!0,moduleSkipIrrigation:!0});Ct&&Ct.usedTiles.length>0&&(Fe=Ct,qe=ot,console.info(`[MODDBG] manual drop: module narrowed from ${Math.round(Ze.w)} to ${Math.round(ot)} cm to fit the free run`))}}catch($e){console.warn("[MODDBG] manual-drop tolerance failed",$e)}if(!Fe||Fe.usedTiles.length<=0){Be?.(),Be=void 0;let $e=null;const gt=m.floorPosition?350:1/0;e:for(const ot of m.floor.directLightAreaStates)for(const ct of ot.tileStates){if(!ct.isActive||!ct.isFree||ct===A&&ot===C||m.floorPosition&&ct.coveredSpace&&e.TE(m.floorPosition,ct.coveredSpace)>gt)continue;const at=(0,n._e)(m.floor,ot,ct,!0,!0,m.directionFlowIsPositive??null,le);if(!at?.manager){at?.dispose?.();continue}const Ze=at.manager.pickFlowMap(ct.partitionableShapeInfo.uidInPackage()).sections[0],Ve=Ee(se),pt=Ze.buildForClaude(ct);Ve.tiles=pt.tileRanges,Ve.corners=pt.corners,Ve.cursorTile=pt.cursorTile,Ve.loops=pt.isLoop;const Ct=Ai(Ve,{pickRemain:!0});if(Ct&&Ct.usedTiles.length>0){const Dt=Ct.builtBenchesOfficesAndClosets[0];if(Dt?.benchOrOffice){const ht=L(se,ot,{},Dt.dimensionSignature,Dt.tiles);if(ht){ht.floor=m.floor.targetFloor,"boolean"!=typeof m.directionFlowIsPositive&&(m.directionFlowIsPositive=at.flowDirectionIsPositive),at.dispose?.(),b&&Ct.lastUsedTile&&(b.nextTile=Ct.lastUsedTile.tile.targetTile.tile,b.nextTileSupArea=ot),$e=ht;break e}}}at.dispose?.()}if(!$e){try{const ot=(xe.offices[0]?.widthHeights??[]).map(ht=>`${Math.round(ht[0])}x${Math.round(ht[1])}`),ct=(ze.tileRanges??[]).flatMap(ht=>(ht.tiles??[]).map(Nt=>{const Ht=Nt.targetTile?.tile;return{w:Math.round(Nt.width),h:Math.round(Nt.height),fullW:Math.round(Ht?.partitionableShapeInfo?.width??-1),fullH:Math.round(Ht?.partitionableShapeInfo?.he
1ight??-1),beginOffset:Ht?.beginOffset,endOffset:Ht?.endOffset,isPartial:Nt.targetTile?.isPartial,corner:Nt.isInCorner,window:Nt.hasWindow,posts:(Nt.posts??[]).map(ei=>`x${Math.round(ei.x)} y${Math.round(ei.y)} ${Math.round(ei.width)}x${Math.round(ei.height)}`),tilePosts:(Ht?.postInfos??[]).map(ei=>`offsetH${Math.round(ei.offsetH)} len${Math.round(ei.length)} y${Math.round(ei.y)} h${Math.round(ei.height)}`)}}));console.warn("[MODDBG] createRegularModuleToSupPlaceInfo: claudePlaceAll failed on all tiles.","module:",se?.module?.name??se?.module?.label??se?.name,"dims(WxD):",ot.join(" "),"windowOffset:",xe.windowOffset,"distToWall:",xe.distToWall,"primary tiles:",JSON.stringify(ct));const at=ht=>{const Nt=ht?.getEnvelopeInternal?.();return Nt?[Math.round(Nt.getMinX()),Math.round(Nt.getMinY()),Math.round(Nt.getMaxX()),Math.round(Nt.getMaxY())]:null},Ze=ht=>{const Nt=String(ht??"");return Nt.slice(Nt.lastIndexOf("|")+1)},Ve=ht=>"number"==typeof ht?.startOffset||"number"==typeof ht?.endOffset?`${Ze(ht.tileUid)}[${ht.startOffset??"-"}..${ht.endOffset??"-"}]`:`${Ze(ht?.tileUid??ht)} full`,pt=(C?.tileStates??[]).map(ht=>({id:Ze(ht.partitionableShapeInfo?.uidInPackage?.()),env:at(ht.coveredSpace),free:ht.isFree,active:ht.isActive,w:Math.round(ht.width),bo:ht.beginOffset,eo:ht.endOffset})),Ct=(m.floor.placedDepartments??[]).flatMap(ht=>(ht.supCoveredSpaceGroups??[]).map(Nt=>({dep:ht.departmentRequirement?.name,env:at(Nt.coveredSpace),tiles:(Nt.supAreaInfos??[]).flatMap(Ht=>(Ht.tileInfos??[]).map(Ve))}))),Dt=(m.floor.placedModules??[]).filter(ht=>2!==ht.dirtyState).map(ht=>({uid:ht.uid,name:ht.moduleRequirement?.module?.name,env:at(ht.coveredSpace),tiles:(ht.info?.getAllSupFragments?.()??[]).flatMap(Nt=>(Nt.tileInfos??[]).map(Ve))}));console.warn("[MODDBG] sup-area tiles:",JSON.stringify(pt),"department groups:",JSON.stringify(Ct),"standalone modules:",JSON.stringify(Dt))}catch(ot){console.warn("[MODDBG] createRegularModuleToSupPlaceInfo: claudePlaceAll failed on all tiles (dump failed)",ot)}return!1}return $e}const Ke=Fe.builtBenchesOfficesAndClosets[0];if(!Ke||!Ke.benchOrOffice)return Be?.(),!1;Be?.();const it=L(se,C,{},Ke.dimensionSignature,Ke.tiles);if(!it)return console.warn("createPlaceDepartmentInfo: returning false because buildModule failed"),b&&(b.nextTile=null),!1;b&&Fe.lastUsedTile&&(b.nextTile=Fe.lastUsedTile.tile.targetTile.tile,b.nextTileSupArea=C),"boolean"!=typeof m.directionFlowIsPositive&&(m.directionFlowIsPositive=Me),it.floor=m.floor.targetFloor;try{const $e=m.droppedOption?.furnitureBlocks;if(Array.isArray($e)&&$e.length){const gt=m.droppedOption?.coveredSpace,ot=it.coveredSpace;if(it.furnitureBlocks=$e.map(ct=>ct.clone()),gt&&ot){const ct=e.Sc(gt),at=e.Sc(ot),Ze=at.getX()-ct.getX(),Ve=at.getY()-ct.getY();it.furnitureBlocks.forEach(pt=>pt.translateBy(Ze,Ve))}}else{const gt=m.floor.parentPropertyState?.inputData?.furnitureManager;gt?(0,p.G)(it,gt):console.warn("[FURNDBG] module placed on a sup area with no furniture manager available")}}catch($e){console.warn("[FURNDBG] sup-area module furnishing failed",$e)}if(null!==qe){const $e=it.furnitureBlocks??[],gt=it.coveredSpace,ot=$e.map(at=>{try{const Ze=at.coveredSpace;if(!Ze)return 0;const Ve=e.oo(Ze,gt);return(Ve&&!e.xb(Ve)?e.SO(Ve):0)/Math.max(1,e.SO(Ze))}catch{return 1}}),ct=$e.length>0&&ot.every(at=>at<=.25);if(ct||console.warn("[MODDBG] manual drop: furniture spill ratios per block:",ot.map(at=>Math.round(100*at)+"%").join(" ")),!ct)return console.warn(`[MODDBG] manual drop: ${Math.round(qe)} cm is too narrow for the module's furniture, refusing`),!1}return it}function Ys(m,b){const C=m.highlightInfo&&m.highlightInfo.isSupInfo?m.highlightInfo:function zs(m,b){const C=Bs(m,b);if(C&&"boolean"!=typeof C){const R=!(W=m.droppedOption)||void 0===W.programModule&&void 0===W.coveredSpace||W.supAreaInfos?null:m.droppedOption,B=(0,l.p)(m.floor,(0,l.W)(C),R);if(B)return console.warn("[MODDBG] SUP placement refused: footprint overlaps a placed piece",{overlap:Math.round(100*B.ratio)+"%",piece:B.piece?.departmentRequirement?.name??B.piece?.moduleRequirement?.module?.name??B.piece?.uid}),b&&(b.nextTile=null),!1}var W;return C}(m,b),A=R=>
1R&&(void 0!==R.programModule||void 0!==R.coveredSpace)&&!R.supAreaInfos;return!0===C&&A(m.droppedOption)?new g.Z(m.droppedOption):"boolean"==typeof C?null:A(m.droppedOption)?new r.Z(C,m.droppedOption):new a.Z(C)}},58057:(tt,me,P)=>{P.d(me,{Jc:()=>L,BZ:()=>Xe,ZP:()=>ke});var e=P(47318),E=P(13084),X=P(47875),O=P(33487),v=P(42893),h=P(4516),g=P(89584),r=P(46376),a=P(45250),n=P(38355),l=P(91250),p=P(85094),y=P(24861),D=P(73329),Y=P(87372),H=P(65681);const ne=te=>te&&(void 0!==te.programModule||void 0!==te.coveredSpace)&&!te.supAreaInfos;let k=null;function J(te,ye,Ae){const Ee=new Set;if(Ee.add(ye),!Ee.size)return null;const oe=new h.me;Ae.dimensions.forEach(V=>{V.dimensions.forEach(U=>{oe.set([Math.ceil(U[0]/te.cellSize),Math.ceil(U[1]/te.cellSize)],[V.picker,V.layout,U]),oe.set([Math.ceil(U[1]/te.cellSize),Math.ceil(U[0]/te.cellSize)],[V.picker,V.layout,[U[1],U[0],U[2]]])})});const ee=oe.mapArray((V,U)=>[V[0],V[1],U,V[2]]);ee.sort((V,U)=>V[2][0]*V[2][1]-U[2][0]*U[2][1]);const Z=(V,U,re)=>{const ae=T=>{const F=(T.fl||0)+(T.fr||0)+1,$=(T.ft||0)+(T.fb||0)+1;let ue=F>=U[0],Ie=$>=U[1];if(!ue||!Ie)return!1;if(F===U[0]){let Pe=F*te.cellSize;const Ce=te.cells.get([T.coords[0]-(T.fl||0),T.coords[1]]);Ce&&void 0!==Ce.hl&&(Pe-=te.cellSize-Ce.hl);const Ue=te.cells.get([T.coords[0]+(T.fr||0),T.coords[1]]);Ue&&void 0!==Ue.hl&&(Pe-=te.cellSize-Ue.hl),ue=Pe>=re[0]}if($===U[1]){let Pe=$*te.cellSize;const Ce=te.cells.get([T.coords[0],T.coords[1]-(T.fb||0)]);Ce&&void 0!==Ce.vl&&(Pe-=te.cellSize-Ce.vl);const Ue=te.cells.get([T.coords[0],T.coords[1]+(T.ft||0)]);Ue&&void 0!==Ue.vl&&(Pe-=te.cellSize-Ue.vl),Ie=Pe>=re[1]}return ue&&Ie};if(!ae(V))return null;const de=[];let he=!1,ve=-1;for(let T=V.coords[0]-(V.fl||0),F=V.coords[0]+(V.fr||0);T<=F;T++){const $=te.cells.get([T,V.coords[1]]);if($&&ae($))$===V&&(he=!0,ve=de.length),de.push($);else{if(he)break;de.splice(0)}}if(de.length<U[0])return null;let be=Math.max(0,Math.min(de.length-U[0],ve)),Le=be+U[0]-1,Ye=de[be],Te=Ye.coords[0],Je=Ye.coords[0]+U[0]-1,Qe=(Je-Te+1)*te.cellSize;if(void 0!==Ye.hl&&(Qe-=te.cellSize-Ye.hl,Qe<re[0])){if(!(Le+1<de.length))return null;Je++,Le++}if(void 0!==de[Le].hl&&(Qe-=te.cellSize-de[Le].hl,Qe<re[0])){if(!(be-1>=0))return null;if(Te--,be--,Ye=de[be],Qe+=Ye.hl||te.cellSize,Qe<re[0])return null}let st=-1/0,et=1/0;for(let T=be,F=be+U[0]-1;T<=F;T++){const $=de[T],ue=$.coords[1]-($.fb||0),Ie=$.coords[1]+($.ft||0);ue>st&&(st=ue),Ie<et&&(et=Ie)}let Et=Math.min(Math.max(st,et-U[1]+1),Math.max(st,V.coords[1]-U[1]+1));const lt=st,i=et;st=Et,et=Et+U[1]-1;let d=(et-st+1)*te.cellSize;const I=T=>{let F=te.cellSize;for(let $=be,ue=Le;$<=ue;$++){const Ie=te.cells.get([de[$].coords[0],T]);Ie?void 0!==Ie.vl&&Ie.vl<F&&(F=Ie.vl):d=0}return F};{const T=I(st);if(d-=te.cellSize-T,d<re[1]){if(!(et+1<=i))return null;et++,d+=te.cellSize}}{const T=I(et);if(d-=te.cellSize-T,d<re[1]){if(!(st-1>=lt))return null;{st--,d+=te.cellSize;const F=I(st);if(d-=te.cellSize-F,d<re[1])return null}}}const[o,s]=(()=>{const T=be>0,F=Le+1<de.length;let $=!1,ue=!1;for(let Ie=st,Pe=et;Ie<=Pe;Ie++){if(T){const Ce=te.cells.get([Te-1,Ie]);Ce&&void 0!==Ce.hl&&($=!0)}if(F){const Ce=te.cells.get([Je+1,Ie]);Ce&&void 0!==Ce.hl&&(ue=!0)}}return[$,ue]})(),[u,S]=(()=>{const T=st>lt,F=et<i;let $=!1,ue=!1;for(let Ie=Te,Pe=Je;Ie<=Pe;Ie++){if(T){const Ce=te.cells.get([Ie,st-1]);Ce&&void 0!==Ce.hl&&($=!0)}if(F){const Ce=te.cells.get([Ie,et+1]);Ce&&void 0!==Ce.hl&&(ue=!0)}}return[$,ue]})();return o&&Te--,s&&Je++,u&&st--,S&&et++,{bottomLeft:[Te,st],topRight:[Je,et]}};let Q=null;for(const V of ee){for(const U of Ee){const re=Z(U,V[2],V[3]);if(re){Q={...re,pickedDim:[V[0],V[1],V[3]]};break}}if(Q)break}return Q}function L(te){const ye=function ce(te){const ye=Q=>Q&&(void 0!==Q.programModule||void 0!==Q.coveredSpace)&&!Q.supAreaInfos,Ae=ye(te.droppedOption)?te.droppedOption.programModule:te.droppedOption?.optionState?.state?.targetRequirement;if((0,y.nu)(Ae?.module,te.floor)){const Q=function x(te){const ye=(0,H.SA)();let Ae=null;try{Ae=function f(te,ye){if(!te?.floor||!te.floorPosition)return(0,H.JP)(ye,"no floor or cursor position on the drop context"),null;const Ae=ne(te.droppedOption)?te.droppedOption:null,Ee=Ae?Ae.programModule:te.droppedOption?.optionState?.state?.targetRequirement;if(!Ee)return(0,H.JP)(ye,"could not resolve the program module from the dropped option"),null;const q=(0,Y.qt)(Ee);if((0,H.JP)(ye,`module "${Ee.module?.names?.en??Ee.name??"?"}", ${q.length} candidate dimension(s)`+(q.length?`: ${q.slice(0,6).map(V=>`${Math.round(V.dimension[0])}x${Math.round(V.dimension[1])}`).join(", ")}`:"")),!q.length)return null;const oe=function K(te){return{directLightAreaStates:te.directLightAreaStates,indirectLightAreaStates:te.indirectLightAreaStates,coreRoomStates:te.coreRoomStates??[]}}(te.floor),ee=Ae?(0,l.w1)(Ae,oe):null;if(ee&&(0,l.M$)(ee),Ae){const V=Ae.isMultiInfo?"multi-span":Ae.isSupInfo?"SUP":Ae.isSusInfo?"SUS":Ae.isCoreRoom?"core room":"UNKNOWN KIND";let U=0;try{Ae.corridorFragments&&!e.xb(Ae.corridorFragments)&&(U=Math.round(e.SO(Ae.corridorFragments)/100)/100)}catch{}(0,H.JP)(ye,`MOVE of an existing ${V} module (uid ${Ae.uid})`),(0,H.JP)(ye,` self-exclusion released: ${ee?.supFragments.length??0}
1 SUP + ${ee?.susFragments.length??0} SUS fragment(s), corridor ${U} m\xb2 (of ${Ae.getAllSupFragments().length} SUP + ${Ae.getAllSusFragments().length} SUS on the info)`)}const Z=(0,y.d7)(Ee.module,te.floor);Z&&(0,H.JP)(ye,"partitioned here: windowed tiles are all-or-nothing, shape grows out to them");let Q=null;try{const V=(0,Y._T)(te.floor,te.floorPosition,q,Ae??void 0,ye,Z);if(!V)return null;Q=new p.o(te.floor,te.floorPosition,Ae,te.directionFlowIsPositive??null);const U=(0,D.fB)(V,q,Q,ye);if(!U)return null;if(globalThis.MULTISPAN_VERBOSE){const ae=Te=>{try{return Math.round(e.SO(Te)/100)/100}catch{return NaN}},de=Te=>Math.round(Te),[he,ve]=U.dimension.dimension,be=U.quality,Le=(0,D.FO)(U.coveredSpace,U.angle),Ye=Te=>{const Je=(0,D.FO)(Te,U.angle);return Je&&Le?` | x ${de(Je.minX-Le.minX)}..${de(Je.maxX-Le.minX)}, y ${de(Je.minY-Le.minY)}..${de(Je.maxY-Le.minY)}`:""};(0,H.JP)(ye,`WON: ${de(he)}x${de(ve)} at ${de(180*U.angle/Math.PI)}\xb0`),(0,H.JP)(ye,` score ${Math.round(1e3*be.score)/1e3} = fill ${Math.round(1e3*be.fill)/1e3} x bloat ${Math.round(1e3*be.bloat)/1e3} x ragged ${Math.round(1e3*be.ragged)/1e3}`),(0,H.JP)(ye,` box ${de(be.boxWidth)}x${de(be.boxHeight)} vs nominal ${de(he)}x${de(ve)} (overshoot ${de(be.boxWidth-he)}x${de(be.boxHeight-ve)})`);for(const Te of U.supFragments){const Je=Te.tileInfos.filter(Qe=>Qe&&"object"==typeof Qe&&"tileUid"in Qe).length;(0,H.JP)(ye,` SUP fragment: ${Te.tileInfos.length} tile(s) (${Je} partial), ${ae(Te.coveredSpace)} m\xb2${Ye(Te.coveredSpace)}`)}for(const Te of U.susFragments)(0,H.JP)(ye,` SUS fragment: cells [${Te.bottomLeft}]..[${Te.topRight}] = ${Te.topRight[0]-Te.bottomLeft[0]+1}x${Te.topRight[1]-Te.bottomLeft[1]+1}, ${ae(Te.coveredSpace)} m\xb2${Ye(Te.coveredSpace)}`);(0,H.JP)(ye,` corridor: ${ae(U.corridor)} m\xb2${Ye(U.corridor)}`),(0,H.JP)(ye,` total covered ${ae(U.coveredSpace)} m\xb2, nominal ${Math.round(he*ve/100)/100} m\xb2`)}const re=new v.l;return re.floor=te.floor.targetFloor,re.programModule=Ee,re.pickedDimension=[U.dimension.picker,U.dimension.layout,U.dimension.dimension],re.supFragments=U.supFragments,re.susFragments=U.susFragments,re.corridorFragments=U.corridor,re._coveredSpace=U.coveredSpace,re.angle=U.angle,"boolean"!=typeof te.directionFlowIsPositive&&"boolean"==typeof Q.flowDirectionIsPositive&&(te.directionFlowIsPositive=Q.flowDirectionIsPositive),re}finally{Q?.dispose(),ee&&(0,l.Ie)(ee)}}(te,ye)}catch(Ee){console.error("[MULTISPAN] threw; falling back to single-substrate placement",Ee),Ae=null}if(!globalThis.MULTISPAN_SILENT)if(Ae)k=null,globalThis.MULTISPAN_VERBOSE&&console.warn("[MULTISPAN] placed:\n"+(0,H._0)(ye));else{const Ee=(0,H.lJ)(ye),q=(0,H._0)(ye)+(Ee?"\n => "+Ee:"");q!==k&&(k=q,console.warn("[MULTISPAN] no placement:\n"+q))}return Ae}(te);if(Q)return Q}if(te.floor.coreRoomStates.length){const Q=ye(te.droppedOption)?te.droppedOption.programModule:te.droppedOption.optionState.state.targetRequirement,V=te.floor.stackingPlanInfo?.cellSize||60,U=new h.me;Q.dimensions.forEach(ae=>{ae.dimensions.forEach(de=>{U.set([Math.ceil(de[0]/V),Math.ceil(de[1]/V)],[ae.picker,ae.layout,de]),U.set([Math.ceil(de[1]/V),Math.ceil(de[0]/V)],[ae.picker,ae.layout,[de[1],de[0],de[2]]])})});const re=U.mapArray((ae,de)=>[ae[0],ae[1],de,ae[2]]);re.sort((ae,de)=>ae[2][0]*ae[2][1]-de[2][0]*de[2][1]);for(const ae of te.floor.coreRoomStates)if(ae.isAvailable&&e.kK(ae.targetCoreRoom.coveredSpace(),te.floorPosition)){let de=null;const he=ae.width,ve=ae.height;for(const be of re)if(be[3][0]<=he&&be[3][1]<=ve){de=[be[0],be[1],be[3]];break}if(de){const be=new v.l;return be.floor=te.floor.targetFloor,be.coreRoom=ae.targetCoreRoom,be.programModule=Q,be.pickedDimension=de,be._coveredSpace=be.coreRoom.coveredSpace(),be}}}let Ee=null,q=null,oe=null;for(const Q of te.floor.indirectLightAreaStates){const V=Q.tryPickCell(te.floorPosition);if(V){Ee=Q,q=V[0],oe=V[1];break}}if(!oe)return(0,g.ni)(te);let ee=null;if(ye(te.droppedOption)){if(te.droppedOption.isSusInfo&&q.unblit(te.droppedOption.bottomLeft,te.droppedOption.topRight),!oe.isFree)return te.droppedOption.isSusInfo&&q.blit(te.droppedOption.bottomLeft,te.droppedOption.topRight),!0;if(ee=J(q,oe,te.droppedOption.programModule),te.droppedOption.isSusInfo&&q.blit(te.droppedOption.bottomLeft,te.droppedOption.topRight),!ee)return!0}else{const Q=te.droppedOption.optionState.state.targetRequirement;if(ee=oe.isFree?J(q,oe,Q):null,!ee){let V=6;try{for(const ve of Q?.dimensions??[])for(const be of ve?.dimensions??[])V=Math.max(V,Math.ceil(Math.max(be[0],be[1])/q.cellSize))}catch{}
1const U=Math.min(20,Math.max(6,V)),[re,ae]=oe.coords,de=[];for(const ve of q.cells?.values()??[]){if(!ve?.isFree)continue;const[be,Le]=ve.coords,Ye=Math.max(Math.abs(be-re),Math.abs(Le-ae));0===Ye||Ye>U||de.push({cell:ve,d:Ye})}de.sort((ve,be)=>ve.d-be.d);const he=400;for(let ve=0;ve<de.length&&ve<he;ve++){const be=J(q,de[ve].cell,Q);if(be){ee=be,oe=de[ve].cell;break}}}if(!ee)return!1}const Z=new v.l;if(Z.floor=te.floor.targetFloor,Z.indirectLightUid=Ee.lightShapeUid,Z.gridUid=q.gridInfo.uidInPackage(),Z.programModule=ye(te.droppedOption)?te.droppedOption.programModule:te.droppedOption.optionState.state.targetRequirement,Z.bottomLeft=ee.bottomLeft,Z.topRight=ee.topRight,Z.pickedDimension=ee.pickedDim,Z._coveredSpace=q.createPolygon(Z.bottomLeft,Z.topRight),!te.skipFurniture&&ye(te.droppedOption)&&te.droppedOption.furnitureBlocks){Z.furnitureBlocks=te.droppedOption.furnitureBlocks.map(U=>U.clone());const Q=te.droppedOption.coveredSpace,V=Z.coveredSpace;if(Q&&V){const U=e.Sc(Q),re=e.Sc(V),ae=re.getX()-U.getX(),de=re.getY()-U.getY();Z.furnitureBlocks.forEach(he=>he.translateBy(ae,de))}}else if(!te.skipFurniture){const Q=te.floor.parentPropertyState?.inputData?.furnitureManager;Q&&(0,n.G)(Z,Q)}return Z}(te);if(ye&&"boolean"!=typeof ye){const Ee=!(oe=te.droppedOption)||void 0===oe.programModule&&void 0===oe.coveredSpace||oe.supAreaInfos?null:te.droppedOption,q=(0,r.p)(te.floor,(0,r.W)(ye),Ee);if(q)return console.warn("[MODDBG] placement refused: footprint overlaps a placed piece",{overlap:Math.round(100*q.ratio)+"%",piece:q.piece?.departmentRequirement?.name??q.piece?.moduleRequirement?.module?.name??q.piece?.uid}),!!Ee}var oe;return ye}function ke(te){const ye=q=>q&&(void 0!==q.programModule||void 0!==q.coveredSpace)&&!q.supAreaInfos;if(te.highlightInfo&&!1===te.highlightInfo.isSusInfo&&te.highlightInfo.isSupInfo)return(0,g.os)(te);const Ae=te.highlightInfo,Ee=Ae&&(Ae.isSusInfo||Ae.isMultiInfo)?Ae:L(te);return!1===Ee&&ye(te.droppedOption)?new O.Z(te.droppedOption):"boolean"==typeof Ee?null:ye(te.droppedOption)?new E.Z(Ee,te.droppedOption):new X.Z(Ee)}function Xe(te,ye,Ae){const Ee=ye.module.isReception;for(const q of Ae.indirectLightAreaStates)for(const oe of q.gridStates.values()){if(Ee&&!oe.gridInfo.receptionFriendlyCells.length)continue;let ee=oe.contourCells;Ee&&(ee=new Set(oe.gridInfo.receptionFriendlyCells.map(Z=>oe.cells.get([Z[0],Z[1]])).filter(Z=>!!Z)));for(const Z of ee){if(!Z.isFree)continue;const Q=J(oe,Z,ye);if(!Q)continue;const V=new v.l;return V.floor=Ae.targetFloor,V.indirectLightUid=q.lightShapeUid,V.gridUid=oe.gridInfo.uidInPackage(),V.programModule=ye,V.bottomLeft=Q.bottomLeft,V.topRight=Q.topRight,V.pickedDimension=Q.pickedDim,V._coveredSpace=oe.createPolygon(V.bottomLeft,V.topRight),V._uid=a.Z.generateRegularUid(),V}}return null}},38355:(tt,me,P)=>{P.d(me,{G:()=>g});var e=P(47318),E=P(48097),X=P(35418),O=P(56786);function v(r){return!!r&&r.getMaxX()>=r.getMinX()&&r.getMaxY()>=r.getMinY()}function h(r,a,n,l){const p=[0,0];if(!r||!a)return p;let y,D;try{y=a.getEnvelopeInternal(),D=r.getEnvelopeInternal()}catch{return p}if(!v(y)||!v(D))return p;const Y=1e3,ne="top"===n||"bottom"===n?[[D.getMinX(),y.getMinY()-Y],[D.getMaxX(),y.getMinY()-Y],[D.getMaxX(),y.getMaxY()+Y],[D.getMinX(),y.getMaxY()+Y]]:[[y.getMinX()-Y,D.getMinY()],[y.getMaxX()+Y,D.getMinY()],[y.getMaxX()+Y,D.getMaxY()],[y.getMinX()-Y,D.getMaxY()]];let K=null;try{const k=e.p([...ne,ne[0]].map(f=>({x:f[0],y:f[1]}))),x=e.m0(k,a);x&&!e.xb(x)&&(K=x.getEnvelopeInternal())}catch{K=null}return v(K)||(K=y),"bottom"===n?[0,K.getMinY()+l-D.getMinY()]:"top"===n?[0,K.getMaxY()-l-D.getMaxY()]:"left"===n?[K.getMinX()+l-D.getMinX(),0]:[K.getMaxX()-l-D.getMaxX(),0]}function g(r,a,n=0,l){if(r.programModule&&r.pickedDimension&&r.coveredSpace&&a)try{const p=r.pickedDimension,y=e.Sc(r.coveredSpace),D=l?.room??r.coveredSpace;let Y=null;try{Y=D?e.hq(D,5):null}catch{Y=null}Y&&e.xb(Y)&&(Y=null);let H=null;try{const d=D?.getEnvelopeInternal?.();v(d)&&(H={x0:d.getMinX()-5,y0:d.getMinY()-5,x1:d.getMaxX()+5,y1:d.getMaxY()+5})}catch{H=null}const ne=l?.label??"unit",K=l?.occupied,k=l?.align,x=!!l?.enclosed,f=l?.clearances?.furniture??90,J=l?.clearances?.wall??45,L=l?.clearances?.post??15;let ce=null;
1const ke=[];try{const d=l?.posts;if(d&&!e.xb(d)){ce=L>0?e.lE(d,L):d,ce&&e.xb(ce)&&(ce=d);const I=d.getNumGeometries?.()??0;for(let w=0;w<I;w++){const _=d.getGeometryN(w);_&&!e.xb(_)&&ke.push(_)}ke.length||ke.push(d)}}catch{ce=null}const Xe=`${ne}@(${Math.round(y.getX())},${Math.round(y.getY())})`,te="\n ",ye=d=>{console.warn("[FURNDBG] REJECT",Xe,d)},Ae=(d,I)=>{if(!I||e.xb(I))return d;if(d)return e.Y7(d,I);if("function"==typeof I.getExteriorRing||"function"!=typeof I.getNumGeometries)return e.lD([I]);const _=[];for(let o=0;o<I.getNumGeometries();o++){const s=I.getGeometryN(o);s&&!e.xb(s)&&"function"==typeof s.getExteriorRing&&_.push(s)}return _.length?e.lD(_):d},Ee=new Set(["storage","closet","locker","shelf","cabinet","joinery","server_rack","reception"]),q=(d,I)=>{try{const w=d?.furniture?.type?.type??d?.furniture?.type?.typeString;if(w&&Ee.has(String(w).toLowerCase()))return!0;const _=I?.getEnvelopeInternal?.();if(!v(_))return!1;const o=_.getMaxX()-_.getMinX(),s=_.getMaxY()-_.getMinY(),u=Math.min(o,s),S=Math.max(o,s);return u<=25&&S>=80}catch{return!1}},oe=d=>{const I=(0,E.rU)((0,E.E$)(a),[p[0],p[1],[p[2][0],p[2][1],p[2][2]||0]]),w=p[2][0]/2,_=p[2][1]/2,o=e.p([{x:-w,y:-_},{x:w,y:-_},{x:w,y:_},{x:-w,y:_},{x:-w,y:-_}]),s=e.AZ(o);
1I.rules.forEach(Pe=>{(0,X.rA)(Pe,o,s),d&&Pe.rotate(d)});const u=e.pJ(y.getX(),y.getY()),S=[];let T=null,F=0,$=0,ue=0;if(I.rules.forEach(Pe=>{Pe.isDefault&&Pe.blocks.forEach(Ce=>{let Ue=null;try{Ce.furnitures.forEach(Re=>{if(!Re.coveredSpace)return;const ge=e.Uf(Re.coveredSpace,u);if(Ue=Ae(Ue,ge),q(Re,ge))try{const De=ge.getEnvelopeInternal();F+=(De.getMinX()+De.getMaxX())/2,$+=(De.getMinY()+De.getMaxY())/2,ue++}catch{}})}catch{Ue=null}!Ue||e.xb(Ue)||(S.push({block:Ce,rule:Pe}),T=Ae(T,Ue))})}),!S.length||!T||e.xb(T))return null;let Ie=null;if(ue)try{const Pe=T.getEnvelopeInternal();v(Pe)&&(Ie={x:F/ue-(Pe.getMinX()+Pe.getMaxX())/2,y:$/ue-(Pe.getMinY()+Pe.getMaxY())/2})}catch{Ie=null}return{blocks:S,footprint:T,wallFocus:Ie}},ee=(d,I,w,_)=>w>d&&_>I?e.p([{x:d,y:I},{x:w,y:I},{x:w,y:_},{x:d,y:_},{x:d,y:I}]):null,Z=d=>{const I=[];if(K?.geom&&!e.xb(K.geom)&&I.push(K.geom),ce&&I.push(ce),!k||!I.length)return!0;let w,_;try{w=k.room.getEnvelopeInternal(),_=d.getEnvelopeInternal()}catch{return!0}if(!v(w)||!v(_))return!0;const o=[];if("bottom"===k.side||"top"===k.side){const s="bottom"===k.side?w.getMinY():_.getMaxY(),u="bottom"===k.side?_.getMinY():w.getMaxY();o.push(ee(_.getMinX(),Math.min(s,u),_.getMaxX(),Math.max(s,u))),o.push(ee(_.getMinX()-f,w.getMinY(),_.getMinX(),w.getMaxY())),o.push(ee(_.getMaxX(),w.getMinY(),_.getMaxX()+f,w.getMaxY()))}else{const s="left"===k.side?w.getMinX():_.getMaxX(),u="left"===k.side?_.getMinX():w.getMaxX();o.push(ee(Math.min(s,u),_.getMinY(),Math.max(s,u),_.getMaxY())),o.push(ee(w.getMinX(),_.getMinY()-f,w.getMaxX(),_.getMinY())),o.push(ee(w.getMinX(),_.getMaxY(),w.getMaxX(),_.getMaxY()+f))}return o.some(s=>{if(!s||e.xb(s))return!0;try{return!I.some(u=>e.kK(s,u))}catch{return!0}})},Q=d=>{if(ce){try{if(e.kK(d,ce))return`post/column exclusion zone (${L}cm)`}catch{}try{const I=d.getEnvelopeInternal();if(v(I)){const w=ee(I.getMinX(),I.getMinY(),I.getMaxX(),I.getMaxY());if(w&&ke.some(_=>{try{return e.uh(_,w)}catch{return!1}}))return"would enclose a post/column"}}catch{}}if(H)try{const I=d.getEnvelopeInternal();if(v(I)&&(I.getMinX()<H.x0||I.getMaxX()>H.x1||I.getMinY()<H.y0||I.getMaxY()>H.y1))return`sticks out of the room BOX (unit x ${Math.round(I.getMinX())}..${Math.round(I.getMaxX())} y ${Math.round(I.getMinY())}..${Math.round(I.getMaxY())} vs room x ${Math.round(H.x0)}..${Math.round(H.x1)} y ${Math.round(H.y0)}..${Math.round(H.y1)})`}catch{}if(Y){let I=!1;try{I=e.fK(d,Y)}catch{I=!1}if(!I){let w="?";if(globalThis.__sfDebug)try{const _=e.oo(d,Y),o=_?.getEnvelopeInternal?.();_&&!e.xb(_)&&v(o)&&(w=`${Math.round(e.SO(_))}cm\xb2 at x ${Math.round(o.getMinX())}..${Math.round(o.getMaxX())} y ${Math.round(o.getMinY())}..${Math.round(o.getMaxY())}`)}catch{}return`sticks out of the room OUTLINE (outside part: ${w}; room is ${D?.getGeometryType?.()??"?"} with ${D?.getNumInteriorRing?.()??"?"} holes)`}}if(K?.geom&&!e.xb(K.geom))try{const I=f>0?e.lE(d,f):d,w=I&&!e.xb(I)?I:d;if(e.kK(w,K.geom))return`needs ${f}cm to other furniture`}catch{}return Z(d)?null:"no continuous walking path from the circulation"},V=(d,I)=>{let w=0,_=null;try{_=d.getEnvelopeInternal()}catch{return 0}if(!v(_))return 0;const o=!k||"top"===k.side||"bottom"===k.side;if(x){const S=k?.room??D;try{const T=S?.getEnvelopeInternal?.();if(v(T)){const F=Math.max(1,(T.getMaxX()-T.getMinX())/2),$=Math.max(1,(T.getMaxY()-T.getMinY())/2),ue=Math.abs((_.getMinX()+_.getMaxX())/2-(T.getMinX()+T.getMaxX())/2)/F,Ie=Math.abs((_.getMinY()+_.getMaxY())/2-(T.getMinY()+T.getMaxY())/2)/$;w+=300*(1-Math.min(1,(ue+Ie)/2))}}catch{}if(k&&I?.wallFocus){const T=I.wallFocus,F="bottom"===k.side?T.y:"top"===k.side?-T.y:"left"===k.side?T.x:-T.x,$=Math.max(1,Math.hypot(T.x,T.y));w+=400*Math.max(0,F/$)}return w}const s=_.getMaxX()-_.getMinX(),u=_.getMaxY()-_.getMinY();if((o?u>=s:s>=u)&&(w+=300),k)try{const S=k.room.getEnvelopeInternal();if(v(S)){const T=Math.max(1,o?S.getMaxY()-S.getMinY():S.getMaxX()-S.getMinX());let F=0;F="bottom"===k.side?_.getMinY()-S.getMinY():"top"===k.side?S.getMaxY()-_.getMaxY():"left"===k.side?_.getMinX()-S.getMinX():S.getMaxX()-_.getMaxX(),w+=200*(1-Math.min(1,Math.max(0,F)/T))}}catch{}if(K?.geom&&!e.xb(K.geom))try{const S=e.TE(d,K.geom);w+=150*(1-Math.min(1,Math.max(0,S-f)/600))}catch{}return w}
1,U=240,re={top:"bottom",bottom:"top",left:"right",right:"left"},ae=d=>{const I=[];if(x){try{const o=(k?.room??D)?.getEnvelopeInternal?.(),s=d.getEnvelopeInternal();v(o)&&v(s)&&I.push([(o.getMinX()+o.getMaxX())/2-(s.getMinX()+s.getMaxX())/2,(o.getMinY()+o.getMaxY())/2-(s.getMinY()+s.getMaxY())/2,"centred in the room"])}catch{}if(k){const o=h(d,k.room,re[k.side],k.clearance??J);(o[0]||o[1])&&I.push([o[0],o[1],"against the wall facing the door"])}}let w=null;if(k){const _=h(d,k.room,k.side,k.clearance??J);w=_,(_[0]||_[1])&&I.push([_[0],_[1],"aligned"])}if(I.push([0,0,"engine position"]),!x)try{const o=(k?.room??D)?.getEnvelopeInternal?.(),s=d.getEnvelopeInternal();if(v(o)&&v(s)){const u=(o.getMinX()+o.getMaxX())/2-(s.getMinX()+s.getMaxX())/2,S=(o.getMinY()+o.getMaxY())/2-(s.getMinY()+s.getMaxY())/2;if(I.push([u,S,"centred in the room"]),k){const T=h(d,k.room,k.side,k.clearance??J);I.push("top"===k.side||"bottom"===k.side?[u,T[1],"centred, aligned to the corridor"]:[T[0],S,"centred, aligned to the corridor"])}}}catch{}if(w){const _="top"===k.side||"bottom"===k.side;let o=0,s=0;try{const T=d.getEnvelopeInternal();v(T)&&(o=T.getMaxX()-T.getMinX(),s=T.getMaxY()-T.getMinY())}catch{}const u=_?o:s,S=[L+20,-(L+20),f,-f];u>0&&S.push(u/2,-u/2,u+f,-(u+f)),S.forEach(T=>{I.push(_?[w[0]+T,w[1],`slid ${Math.round(T)}cm along corridor`]:[w[0],w[1]+T,`slid ${Math.round(T)}cm along corridor`])})}try{const o=(k?.room??D)?.getEnvelopeInternal?.(),s=d.getEnvelopeInternal();if(v(o)&&v(s)){const u=s.getMaxX()-s.getMinX(),S=s.getMaxY()-s.getMinY(),T=u+f,F=S+f,$=k?.side??"bottom",ue=o.getMinX()+J,Ie=o.getMaxX()-J,Pe=o.getMinY()+J,Ce=o.getMaxY()-J,Ue=Math.max(1,Math.floor((Ie-ue-u)/T)+1),Re=Math.max(1,Math.floor((Ce-Pe-S)/F)+1);for(let ge=0;ge<Re&&I.length<U;ge++)for(let De=0;De<Ue&&I.length<U;De++){const rt="top"===$?Ce-S-ge*F:Pe+ge*F;I.push([ue+De*T-s.getMinX(),rt-s.getMinY(),`sweep r${ge}c${De}`])}}}catch{}return I};r.furnitureBlocks=[];const de=12;let he=null,ve=-1/0,be="no measurable geometry",Le=0,Ye=0;const Te=!!l?.lockRotation,Je=[n,n+Math.PI/2],Qe=x?10:de,st=[],et=[];for(const d of Je){if(Te&&d!==n&&null!==he)break;const I=`${Math.round(180*(d-n)/Math.PI)}\xb0`,w=[],_=oe(d);if(!_)continue;try{const s=_.footprint.getEnvelopeInternal();v(s)&&st.push(`${Math.round(180*(d-n)/Math.PI)}\xb0:${Math.round(s.getMaxX()-s.getMinX())}x${Math.round(s.getMaxY()-s.getMinY())}`)}catch{}let o=0;for(const[s,u,S]of ae(_.footprint)){if(o>=Qe)break;let T=_.footprint;if(s||u)try{T=e.Uf(_.footprint,e.pJ(s,u))}catch{continue}if(!T||e.xb(T))continue;Le++;const F=Q(T);if(F){be=`${S}: ${F}`,w.length<3&&w.push(`${S}: ${F}`);continue}Ye++,o++;const $=V(T,_);$>ve&&(ve=$,he={built:_,dx:s,dy:u,footprint:T,label:S,rot:d})}if(et.push(`[${I}] ${o} valid; `+(w.length?w.join(" / "):"no candidate tried")),!x&&Ye>=de)break}if(!he){let d="?";try{const I=D?.getEnvelopeInternal?.();v(I)&&(d=`${Math.round(I.getMaxX()-I.getMinX())}x${Math.round(I.getMaxY()-I.getMinY())}`)}catch{}return void ye(`no valid placement in ${Le} candidates (last ${be}) | room ${d} | unit ${st.join(" ")||"?"}`+te+et.join(te))}if(K)try{K.geom=K.geom?e.Y7(K.geom,he.footprint):he.footprint}catch{}console.warn("[FURNDBG] ACCEPT",Xe,{blocks:he.built.blocks.length,via:he.label,score:Math.round(ve),candidatesTried:Le,validCandidates:Ye,orientation:`${Math.round(180*(he.rot-n)/Math.PI%360)}deg`,enclosed:x});const Et=y.getX()+he.dx,lt=y.getY()+he.dy,i=e.pJ(Et,lt);he.built.blocks.forEach(({block:d,rule:I})=>{const w=new O.j7;w._furnitureBlock=I.rule.block,w._position=e.Pu(d.center.getX()+Et,d.center.getY()+lt),w._rotation=e.$B(d.orientation),w._furnitures=d.furnitures.map(_=>{const o=new O.t0;return o.furniture=_.furniture,o.position=e.Pu(_.center.getX()+Et,_.center.getY()+lt),o.rotation=e.$B(_.orientation),o.coveredSpace=_.coveredSpace?e.Uf(_.coveredSpace,i):null,o}),w.rebuildCoveredSpace(),r.furnitureBlocks.push(w)})}catch(p){console.error("Error in autoplaceFurnitureForModule:",p)}}},36871:(tt,me,P)=>{P.d(me,{EG:()=>r,II:()=>O,OB:()=>v,OM:()=>g,SP:()=>h,lk:()=>e});class e{constructor(n){this.widthHeights=n.widthHeights,this.required=n.required,this.isPartitioned=n.isPartitioned??!0,this.needWindow=n.needWindow??!0,this.dimensionSignatures=n.dimensionSignatures,this.programModule=n.programModule}
1clone(){return new e({widthHeights:this.widthHeights,required:this.required,isPartitioned:this.isPartitioned,needWindow:this.needWindow,dimensionSignatures:this.dimensionSignatures,programModule:this.programModule})}}class O{constructor(n){this.corners={},this.susAreas=[],this.susLinks=[],this.maxTravelDistance=1e6,this.cellSize=60,this.cursorTile=[0,0],this.loops=!1,this.isStandaloneModule=!1,this.tiles=n.tiles,this.corners=n.corners,this.susAreas=n.susAreas,this.susLinks=n.susLinks,this.benches=n.benches,this.offices=n.offices,this.requiredSeats=n.requiredSeats,this.closetRowWidth=n.closetRowWidth,this.benchesBeforeCloset=n.benchesBeforeCloset,this.benchesBeforeFirstCloset=n.benchesBeforeFirstCloset,this.windowOffset=n.windowOffset,this.distToWall=n.distToWall,this.distBenchToBench=n.distBenchToBench,this.tertiaryCorridorWidth=n.tertiaryCorridorWidth,this.runLeftToRight=n.runLeftToRight,this.cursorTile=n.cursorTile??[0,0],this.loops=n.loops??!1,this.isStandaloneModule=n.isStandaloneModule??!1}clone(){return new O({tiles:this.tiles,corners:this.corners,susAreas:this.susAreas,susLinks:this.susLinks,benches:this.benches,offices:this.offices.map(n=>n.clone()),requiredSeats:this.requiredSeats,closetRowWidth:this.closetRowWidth,benchesBeforeCloset:this.benchesBeforeCloset,benchesBeforeFirstCloset:this.benchesBeforeFirstCloset,windowOffset:this.windowOffset,distToWall:this.distToWall,distBenchToBench:this.distBenchToBench,tertiaryCorridorWidth:this.tertiaryCorridorWidth,runLeftToRight:this.runLeftToRight,cursorTile:this.cursorTile,loops:this.loops,isStandaloneModule:this.isStandaloneModule})}}class v{constructor(n,l=null,p=null,y=!1){this.tile=n,this.x=l,this.width=p,this.fromOtherSide=y}get isPartial(){return"boolean"==typeof this.tile.sideIsStart||(this.x??0)>0||Math.abs(this.partialOrWidth-this.tile.width)>.001}get partialOrWidth(){return this.width??this.tile.width}}class h{constructor(n){this.tiles=n.tiles,this.benchOrOffice=n.benchOrOffice,this.usedDimensionIdx=n.usedDimensionIdx??null,this.centroidTile=n.centroidTile??null,this.centroidTileX=n.centroidTileX??null,this.centroidTileY=n.centroidTileY??null}get dimensionSignature(){return this.benchOrOffice?this.benchOrOffice instanceof e?this.benchOrOffice.dimensionSignatures[this.usedDimensionIdx]:this.benchOrOffice.dimensionSignature:null}}class g{constructor(n){this.bottomLeft=n.bottomLeft,this.topRight=n.topRight,this.benchOrOffice=n.benchOrOffice,this.usedDimensionIdx=n.usedDimensionIdx,this.furnitureCentroid=n.furnitureCentroid??null}get dimensionSignature(){return this.benchOrOffice?this.benchOrOffice instanceof e?this.benchOrOffice.dimensionSignatures[this.usedDimensionIdx]:this.benchOrOffice.dimensionSignature:null}}class r{constructor(n){this.targetRect=n.targetRect,this.bottomLeft=n.bottomLeft,this.topRight=n.topRight,this.items=n.items}}},37446:(tt,me,P)=>{P.d(me,{_e:()=>st});var e=P(47318);class E{constructor(){this._currentNavigator=null,this._currentSubNavigator=null,this._willReviseClbk=null,this._mayReviseAtEnd=!1}get currentSubNavigator(){return this._currentSubNavigator}get currentNavigator(){return this._currentNavigator}get mayReviseAtEnd(){return this._mayReviseAtEnd}setNavigator(i){this._currentNavigator=i;const d=this._currentNavigator.createFirstResult();return this._currentSubNavigator=d.currentAreaNavigator,this._processNavigationResult(d)}finalRevise(){return this._mayReviseAtEnd=!1,[this]}step(i){return i?{type:"drop"}:this._willReviseClbk?this._willReviseClbk():this._processNavigationResult(this._currentNavigator.tryPickNextAvailableTile())}_clone(i){i._currentNavigator=this._currentNavigator.clone(),i._currentSubNavigator=i._currentNavigator.currentSelection.currentAreaNavigator,i._willReviseClbk=this._willReviseClbk,i._mayReviseAtEnd=this._mayReviseAtEnd}dispose(){this._currentNavigator?.dispose(),this._currentNavigator=null,this._currentSubNavigator=null,this._willReviseClbk=null}_processNavigationResult(i){return{type:"keep"}}_createCoveredSpace(i,d,I={},w=!1){let _=e.lD();if(i.forEach(o=>{_=e.Y7(o.createCoveredSpace(),_)}),_=e.lE(_,5),d){let o={...d.dynamicSectionItemIdx,...I};
1Object.entries(o).forEach(([s,u])=>{const S=d.dynamicSectionStates[+s].itemStates[u],T=S.secondaryCorridors;if(e.xb(T))return;const F=S.corridorExtremityTiles.find($=>$[1])?.[0];F&&i.some($=>$.tile===F)&&(_=e.lE(e.Y7(T,_),5))})}if(_.getNumGeometries()>1&&d){let o=_.getNumGeometries();const s=_,u=o;i.forEach((S,T)=>{if("number"!=typeof S.selfOrCurrentBeginOffset&&"number"!=typeof S.selfOrCurrentEndOffset)return;if("boolean"==typeof S.sideIsStart){const[Ie,Pe]=S.createCoveredSpace(!0);if(e.lE(e.Y7(Pe,s),1.5).getNumGeometries()<u){const Ue=e.lE(e.Y7(Pe,_),1.5);return o=Ue.getNumGeometries(),void(_=Ue)}}const F=S.clone();F.beginOffset=void 0,F.endOffset=void 0,F.currentBeginOffset=void 0,F.currentEndOffset=void 0;const $=F.createCoveredSpace(),ue=e.lE(e.Y7($,_),1.5);ue.getNumGeometries()<o&&(o=ue.getNumGeometries(),_=ue,i[T]=F)})}return w?e.lE(_):e.b3(e.lE(_))}}class X{get canHaveBeginNeighbours(){return"number"!=typeof this.beginOffset}get canHaveEndNeighbours(){return"number"!=typeof this.endOffset}get isWidthFree(){return this.width>=.01&&(this.canHaveBeginNeighbours||this.canHaveEndNeighbours)}constructor(i){i&&(this.tile=i.tile,this.isPartial=i.isPartial,this.isWindow=i.isWindow,this.width=i.width,this.height=i.height,this.beginOffset=i.beginOffset,this.endOffset=i.endOffset,this.sideIsStart=i.sideIsStart)}static create(i,d,I,w,_,o,s,u){const S=new X;return S.tile=i,S.isPartial=d,S.isWindow=I,S.width=w,S.height=_,S.beginOffset=o,S.endOffset=s,S.sideIsStart=u,S}}class v extends X{constructor(i,d,I,w,_=!1){super(i),this.origin={isDynamic:d,sectionIdx:I},this.isConsecutiveToPrevious=w,this.isOnCorridor=_}}class h{constructor(){this._selectedTileInfos=[],this._lastPickedTileInfo=null,this._hasChangedFlow=!1,this._dynamicItemOptions=null,this._cornerTileOptions=[]}get isSuccess(){return!!this._lastPickedTileInfo||!!this._dynamicItemOptions||this._cornerTileOptions.length>0}get selectedTileInfos(){return this._selectedTileInfos}get lastPickedTileInfo(){return this._lastPickedTileInfo}get hasChangedFlow(){return this._hasChangedFlow}get dynamicItemOptions(){return this._dynamicItemOptions}get cornerTileOptions(){return this._cornerTileOptions}_clone(i){return i._selectedTileInfos=[...this._selectedTileInfos],i._lastPickedTileInfo=this._lastPickedTileInfo,i._dynamicItemOptions=this._dynamicItemOptions,i._hasChangedFlow=this._hasChangedFlow,i._cornerTileOptions=[...this._cornerTileOptions],i}_absorb(i){this._selectedTileInfos=[...i._selectedTileInfos],this._lastPickedTileInfo=i._lastPickedTileInfo,this._dynamicItemOptions=i._dynamicItemOptions,this._hasChangedFlow=i._hasChangedFlow,this._cornerTileOptions=[...i._cornerTileOptions]}}class g extends h{get directLightState(){return this._directLightState}get directionIsPositive(){return this._directionIsPositive}get cursor(){return this._cursor}get pushInCorner(){return this._pushInCorner}get hasRevised(){return this._hasRevised}constructor(i,d=null){super(),this._directionIsPositive=null,this._cursor=null,this._pushInCorner=!1,this._hasRevised=!1,this._directLightState=i,this._directionIsPositive=d}clone(){const i=new g(this._directLightState,this._directionIsPositive);return i._cursor=this._cursor,this._clone(i),i._pushInCorner=this._pushInCorner,i._hasRevised=this._hasRevised,i}reset(i=!0){this._selectedTileInfos=[],this._lastPickedTileInfo=null,this._cursor=null,this._dynamicItemOptions=null,i||(this._directionIsPositive=null),this._hasChangedFlow=!1,this._hasRevised=!1}get needToPickDirection(){return null==this._directionIsPositive}tileIsFree(i){return!this._selectedTileInfos.find(d=>d.tile===i)&&!this._cornerTileOptions.find(d=>d.tile===i)}reverse(){const i=this._selectedTileInfos.length-1;this._selectedTileInfos.forEach((d,I,w)=>{d.isConsecutiveToPrevious=!(I<i)||w[I+1].isConsecutiveToPrevious}),this._selectedTileInfos.reverse(),this._lastPickedTileInfo=this._selectedTileInfos.length?this._selectedTileInfos[i]:null,this._cursor=this._lastPickedTileInfo?this._lastPickedTileInfo.tile:null,this._dynamicItemOptions=null,this._cornerTileOptions=[],this._pushInCorner=!1,this.markAsChangedFlow()}markAsChangedFlow(){this._hasChangedFlow=!0}suggestDynamicItems(i,d){if(this._lastPickedTileInfo=null,this._dynamicItemOptions={dynSectionIdx:i,itemOptions:d},this._hasChangedFlow=!1,!this._cursor&&d&&Object.keys(d).length>0){const I=d[Object.keys(d)[0]];this._cursor=I.tile}}pushNextTile(i){if(this._pushInCorner)this._cornerTileOptions.push(i);else{if(i.tile.isInCorner)return this.initializePushInCorner(),void this.pushNextTile(i);this._selectedTileInfos.push(i),this._lastPickedTileInfo=i,this._cursor=i.tile,this._dynamicItemOptions=null,this._hasChangedFlow=!1}}initializePushInCorner(){this._pushInCorner||(this._pushInCorner=!0,this._cornerTileOptions=[],this._dynamicItemOptions=null,this._hasChangedFlow=!1,this._lastPickedTileInfo=null)}concludePushInCorner(i){if(this._pushInCorner){this._pushInCorner=!1;for(let d=i;d>0;d--)this._cornerTileOptions.pop()}}flushCorner(){this._selectedTileInfos.push(...this._cornerTileOptions),this._lastPickedTileInfo=this._cornerTileOptions.length?this._cornerTileOptions[this._cornerTileOptions.length-1]:this._lastPickedTileInfo,this._cursor=this._lastPickedTileInfo?.tile||null,this._cornerTileOptions=[],this._pushInCorner=!1}abort(){this._lastPickedTileInfo=null,this._dynamicItemOptions=null,this._cornerTileOptions=[],this._pushInCorner=!1}
1restoreSelectionPartial(i,d){i.forEach((I,w,_)=>{"number"!=typeof I.beginOffset&&"number"!=typeof I.endOffset||(_[w]=d.createSelectionTileInfo(I.tile,I.isConsecutiveToPrevious))})}}class r{get tileSelectionInfo(){return this._tileSelectionInfo}get beginOffset(){return this._beginOffset}set beginOffset(i){this._beginOffset=i,this._recomputeWidth()}get endOffset(){return this._endOffset}set endOffset(i){this._endOffset=i,this._recomputeWidth()}get currentBeginOffset(){return this._currentBeginOffset}set currentBeginOffset(i){this._currentBeginOffset=i,this._recomputeWidth()}get currentEndOffset(){return this._currentEndOffset}set currentEndOffset(i){this._currentEndOffset=i,this._recomputeWidth()}get selfOrCurrentBeginOffset(){return"number"==typeof this._beginOffset?this._beginOffset:this._currentBeginOffset}get selfOrCurrentEndOffset(){return"number"==typeof this._endOffset?this._endOffset:this._currentEndOffset}get width(){return this._width}get height(){return this._tileSelectionInfo.tile.partitionableShapeInfo.height}get isWindow(){return this._tileSelectionInfo.isWindow}get isPartial(){return this._tileSelectionInfo.isPartial}get tile(){return this._tileSelectionInfo.tile}get sideIsStart(){return this._sideIsStart}set sideIsStart(i){this._sideIsStart=i,this._recomputeWidth()}get beginNeighbours(){return"number"==typeof this._beginOffset||"number"==typeof this._currentBeginOffset?[]:this._tileSelectionInfo.tile._beginNeighbours}get endNeighbours(){return"number"==typeof this._endOffset||"number"==typeof this._currentEndOffset?[]:this._tileSelectionInfo.tile._endNeighbours}clone(){const i=new r(this._tileSelectionInfo);return i._beginOffset=this._beginOffset,i._endOffset=this._endOffset,i._currentBeginOffset=this._currentBeginOffset,i._currentEndOffset=this._currentEndOffset,i._width=this._width,i._sideIsStart=this._sideIsStart,i}_recomputeWidth(){if(!this.autoUpdate)return;const d="number"==typeof this.endOffset?this.endOffset:this._currentEndOffset;let I;I=null==this._sideIsStart?this._tileSelectionInfo.tile.partitionableShapeInfo.width:this._sideIsStart?this._tileSelectionInfo.tile.startWidth:this._tileSelectionInfo.tile.endWidth,I-=("number"==typeof this.beginOffset?this.beginOffset:this._currentBeginOffset)||0,"number"==typeof d&&(I-=I-d),this._width=I}constructor(i){this._width=0,this._sideIsStart=null,this.autoUpdate=!0,this._tileSelectionInfo=i,this.currentBeginOffset=i.beginOffset,this.currentEndOffset=i.endOffset,this._sideIsStart=i.sideIsStart,this._recomputeWidth()}getClosestFittingOffset(i,d,I,w){const _=("boolean"!=typeof w?this.tile.partitionableShapeInfo.width:w?this.tile.startWidth:this.tile.endWidth)-(w==this.sideIsStart?this.width:"boolean"!=typeof w?this.tile.partitionableShapeInfo.width:w?this.tile.startWidth:this.tile.endWidth);return this.tile.getClosestFittingOffset(i+(d&&"number"==typeof this.selfOrCurrentBeginOffset?_:0)+(d||"number"!=typeof this.selfOrCurrentEndOffset?0:_),d,I,w)}getPostsInRange(i,d,I,w){if(I){const _=this.selfOrCurrentBeginOffset||0;return this.tile.getPostsInRange(_+i,_+d,!0,w)}{const _=this.selfOrCurrentEndOffset||0;return this.tile.getPostsInRange(i+_,d+_,!1,w)}}asDict(){return"number"==typeof this.selfOrCurrentBeginOffset||"number"==typeof this.selfOrCurrentEndOffset?{tileUid:this.tile.partitionableShapeInfo.uidInPackage(),startOffset:"number"==typeof this._beginOffset?this._beginOffset:this._currentEndOffset,endOffset:"number"==typeof this._endOffset?this._endOffset:this._currentBeginOffset,sideIsStart:this._sideIsStart}:this.tile.partitionableShapeInfo.uidInPackage()}asConsumedTileInfo(){return"number"==typeof this.selfOrCurrentBeginOffset||"number"==typeof this.selfOrCurrentEndOffset?X.create(this.tile,!0,this.isWindow,"number"==typeof this.beginOffset&&"number"==typeof this.endOffset?0:Math.max(0,this.tile.width-this.width),this.height,this.beginOffset,this.endOffset,this.sideIsStart):X.create(this.tile,!1,this.isWindow,0,this.height,null,null,this.sideIsStart)}asConsumedSelectionTileInfo(){const i="number"==typeof this.selfOrCurrentBeginOffset||"number"==typeof this.selfOrCurrentEndOffset?X.create(this.tile,!0,this.isWindow,"number"==typeof this.beginOffset&&"number"==typeof this.endOffset?0:Math.max(0,this.tile.width-this.width),this.height,this.beginOffset,this.endOffset,this.sideIsStart):X.create(this.tile,!1,this.isWindow,0,this.height,null,null,this.sideIsStart);return new v(i,this.tileSelectionInfo.origin.isDynamic,this.tileSelectionInfo.origin.sectionIdx,this.tileSelectionInfo.isConsecutiveToPrevious,this.tileSelectionInfo.isOnCorridor)}asConsumed(){return new r(this.asConsumedSelectionTileInfo())}isFreeAfterBlit(){return("number"==typeof this.selfOrCurrentBeginOffset||"number"==typeof this.selfOrCurrentEndOffset)&&!!("number"!=typeof this._currentBeginOffset&&"number"!=typeof this._currentEndOffset||"number"!=typeof this._beginOffset&&"number"!=typeof this._endOffset)}createCoveredSpace(i=!1){if("number"==typeof this.selfOrCurrentBeginOffset||"number"==typeof this.selfOrCurrentEndOffset){const d="number"==typeof this._currentBeginOffset||"number"==typeof this._currentEndOffset,I="number"==typeof this._beginOffset||"number"==typeof this._endOffset;let w=e.lD(),_=w;
1if(d&&I){const[o,s]=this.tile.computePartialCoveredSpace(!1,0===this.currentBeginOffset?this.currentBeginOffset:this.currentBeginOffset||void 0,0===this.currentEndOffset?this.currentEndOffset:this.currentEndOffset||void 0,this._sideIsStart,!0);let[u,S]=this.tile.computePartialCoveredSpace(!0,0===this._beginOffset?this._beginOffset:this._beginOffset||void 0,0===this.endOffset?this.endOffset:this.endOffset||void 0,this._sideIsStart,!0);u=e.oo(u,o),w=e.Y7(u,w),i&&(S=e.oo(S,s),_=e.Y7(S,_))}else if(I){const[o,s]=this.tile.computePartialCoveredSpace(!0,0===this._beginOffset?this._beginOffset:this._beginOffset||void 0,0===this.endOffset?this.endOffset:this.endOffset||void 0,this._sideIsStart,!0);w=e.Y7(o,w),i&&(_=e.Y7(s,_))}else{const[o,s]=this.tile.computePartialCoveredSpace(!1,0===this.currentBeginOffset?this.currentBeginOffset:this.currentBeginOffset||void 0,0===this.currentEndOffset?this.currentEndOffset:this.currentEndOffset||void 0,this._sideIsStart,!0);w=e.Y7(o,w),i&&(_=e.Y7(s,_))}return i?[e.b3(w),e.b3(_)]:e.b3(w)}return i?[this.tile.coveredSpace,this.tile.coveredSpace]:this.tile.coveredSpace}}class a{constructor(){this._tilesInfo=[],this._targetProgramModule=null,this._pickedDimension=null,this._count=0,this._isCloset=!1,this._furnitureCentroidTile=null,this._furnitureCentroidOffsetX=null,this._furnitureCentroidDepth=null}get tileInfos(){return this._tilesInfo}get targetProgramModule(){return this._targetProgramModule}get pickedDimension(){return this._pickedDimension}get count(){return this._count}get isCloset(){return this._isCloset}get furnitureCentroidTile(){return this._furnitureCentroidTile}get furnitureCentroidOffsetX(){return this._furnitureCentroidOffsetX}get furnitureCentroidDepth(){return this._furnitureCentroidDepth}get hasValidProgramModule(){return this._count>0&&this._targetProgramModule&&this._pickedDimension}get firstTileInfo(){return this._tilesInfo.length?this._tilesInfo[0]:null}get lastTileInfo(){return this._tilesInfo.length?this._tilesInfo[this._tilesInfo.length-1]:null}static create(i,d=null,I=0,w=null,_,o,s,u=!1){const S=new a;return S._tilesInfo=i,S._pickedDimension=d,S._count=I,S._targetProgramModule=w,_&&(S._furnitureCentroidTile=_,S._furnitureCentroidOffsetX=o,S._furnitureCentroidDepth=s),S._isCloset=u,S}clone(){const i=new a;return i._tilesInfo=this._tilesInfo.map(d=>d.clone()),i._targetProgramModule=this._targetProgramModule,i._pickedDimension=this._pickedDimension,i._count=this._count,i._furnitureCentroidTile=this._furnitureCentroidTile,i._furnitureCentroidOffsetX=this._furnitureCentroidOffsetX,i._furnitureCentroidDepth=this._furnitureCentroidDepth,i._isCloset=this._isCloset,i}}class n{_createRequirementCheckerTileInfo(i,d,I,w,_){return n.createRequirementCheckerTileInfo(i,d,I,w,_)}static createRequirementCheckerTileInfo(i,d,I,w,_){const o=new r(i);return o.autoUpdate=!1,typeof d<"u"&&(o.currentBeginOffset=d),typeof I<"u"&&(o.currentEndOffset=I),o.beginOffset=w,o.endOffset=_,o.autoUpdate=!0,o._recomputeWidth(),o}getBuiltUnitsPerDirectLight(){return new Map}}class l extends n{constructor(){super(...arguments),this._dimensions=[],this._beginSkippedTiles=0,this._currentConsecutiveTileInfos=[],this._pickedDimension=null,this._firstTileInfo=null,this._currentTotalWidth=0,this._builtInfo=[]}get beginSkippedTiles(){return this._beginSkippedTiles}get pickedDimension(){return this._pickedDimension}get builtInfo(){return this._builtInfo}get isFullfilled(){return this._builtInfo.length&&this._pickedDimension&&this._pickedDimension[2][0]<=this._currentTotalWidth}get isEmpty(){return!this.isFullfilled}static create(i){const d=new l;return d._programModule=i,d._dimensions=d._programModule.dimensions.flatMap(I=>I.dimensions.map(w=>[I.picker,I.layout,[w[0],w[1],w[2]||0]])),d}_updateModuleInfo(i,d=!1){const I=(w,_,o)=>{let s=!0;s="number"==typeof w.beginOffset||"number"==typeof w.endOffset?"number"!=typeof w.beginOffset:1===this._currentConsecutiveTileInfos.length?w.beginNeighbours.length<=w.endNeighbours.length:w.tileSelectionInfo.tile.isOtherCloseToBegin(_);const u=w.tileSelectionInfo.tile.getClosestFittingOffset(w.width-o,s,!this._programModule.module.isPartitioned);return this._createRequirementCheckerTileInfo(w.tileSelectionInfo,w.tileSelectionInfo.beginOffset,w.tileSelectionInfo.endOffset,s?u:void 0,s?void 0:u)};if(!d&&!i.tile.isInCorner&&this.pickedDimension&&this._currentTotalWidth+i.width>this._pickedDimension[2][0]){this._currentTotalWidth+=i.width;let w=this._currentTotalWidth-this._pickedDimension[2][0];if(this._currentConsecutiveTileInfos.length>1&&i.isWindow&&this._firstTileInfo&&!this._firstTileInfo.isWindow&&!this._firstTileInfo?.isPartial){let _=w;_>this._firstTileInfo.width&&(_=this._firstTileInfo.width),w-=_;const o=I(this._firstTileInfo,this._currentConsecutiveTileInfos[1].tileSelectionInfo.tile,_);if(this._builtInfo[0]=o,w>.01){let u=I(i,this._currentConsecutiveTileInfos.length>=2?this._currentConsecutiveTileInfos[this._currentConsecutiveTileInfos.length-2].tileSelectionInfo.tile:null,w);return this._builtInfo.push(u),!0}return this._builtInfo.push(this._createRequirementCheckerTileInfo(i.tileSelectionInfo,i.tileSelectionInfo.beginOffset,i.tileSelectionInfo.endOffset)),!1}{let o=I(i,this._currentConsecutiveTileInfos.length>=2?this._currentConsecutiveTileInfos[this._currentConsecutiveTileInfos.length-2].tileSelectionInfo.tile:null,w);return this._builtInfo.push(o),!0}}return this._currentTotalWidth+=i.width,this._builtInfo.push(this._createRequirementCheckerTileInfo(i.tileSelectionInfo,i.selfOrCurrentBeginOffset,i.selfOrCurrentEndOffset)),!1}_tryPlace(i,d,I=!1){const w=this._currentConsecutiveTileInfos.reduce((s,u)=>Math.min(u.height,s),Number.MAX_VALUE);let _=this._dimensions.map(([s,u,[S,T,F]])=>[w-T,S,T,[s,u,[S,T,F]]]).filter(s=>s[0]>=-1);return _.length?(_=_.filter(s=>s[1]<=i),_.sort((s,u)=>s[0]-u[0]||s[1]-u[1]),this._pickedDimension=_.length?_[0][3]:null,this._updateModuleInfo(d,I)?"partial":"keep"):(this._currentConsecutiveTileInfos.pop(),"drop")}step(i){if(!i.lastPickedTileInfo)return"reverse";if(this.isFullfilled)return"untouched";if(i.lastPickedTileInfo.isPartial&&i.lastPickedTileInfo.isWindow&&this._programModule.module.isPartitioned)return 0===this._currentConsecutiveTileInfos.length?(this._beginSkippedTiles++,"keep"):"drop";
1const d=this._createRequirementCheckerTileInfo(i.lastPickedTileInfo);return 0===this._currentConsecutiveTileInfos.length&&(this._firstTileInfo=d),this._currentConsecutiveTileInfos.push(d),this._tryPlace(this._currentTotalWidth+d.width,d)}forceBlit(i){if(!i.lastPickedTileInfo)return;const d=this._createRequirementCheckerTileInfo(i.lastPickedTileInfo),I=this._builtInfo.length?this._builtInfo[this._builtInfo.length-1]:null;I&&I.tileSelectionInfo.tile===d.tileSelectionInfo.tile?this._builtInfo[this._builtInfo.length-1]=d:(0===this._currentConsecutiveTileInfos.length&&(this._firstTileInfo=d),this._currentConsecutiveTileInfos.push(d),this._tryPlace(this._currentTotalWidth+d.width,d,!0))}reset(i){this._currentConsecutiveTileInfos=[],this._pickedDimension=null,this._beginSkippedTiles=0,this._firstTileInfo=null,this._currentTotalWidth=0,this._builtInfo=[]}dispose(){this._currentConsecutiveTileInfos=null,this._pickedDimension=null,this._programModule=null,this._firstTileInfo=null,this._dimensions=null,this._builtInfo=null}clone(){const i=new l;return i._programModule=this._programModule,i._dimensions=this._dimensions,i._beginSkippedTiles=this._beginSkippedTiles,i._firstTileInfo=this._firstTileInfo,i._currentTotalWidth=this._currentTotalWidth,i._builtInfo=[...this._builtInfo],i._pickedDimension=this._pickedDimension,i._currentConsecutiveTileInfos=[...this._currentConsecutiveTileInfos],i}}var p=P(42893),y=P(28395);class D extends E{constructor(){super(...arguments),this._hasReversed=!1,this._hasDroppedBeforeReversing=!1}static create(i){const d=new D;return d._module=i,d._subChecker=l.create(i),d}buildInfo(){const i=new p.l;i.floor=this._currentNavigator.floorState.targetFloor,i.programModule=this._module,i.pickedDimension=this._subChecker.pickedDimension;let d=this._currentSubNavigator.currentSelection.selectedTileInfos.length?this._currentSubNavigator.currentSelection.selectedTileInfos[this._currentSubNavigator.currentSelection.selectedTileInfos.length-1]:null,I=null,w=null;const _=new y.O.SupAreaInfo;_.supAreaFullUid=this._currentSubNavigator.directLightInfoState.directLight.fullUid;const o=this._currentSubNavigator.collectActivatedDynamicItems();Object.entries(o).forEach(([u,S])=>{_.dynamicSectionItemIdxes[u]=S}),_.tileInfos=this._subChecker.builtInfo.map(u=>(u.tileSelectionInfo===d&&(I=u,w=this._currentSubNavigator.directLightInfoState),u.asDict()));const s=this._module.module.attributes.isFreeForm;return _.coveredSpace=this._createCoveredSpace(this._subChecker.builtInfo,s?this._currentSubNavigator.directLightInfoState:null,s?_.dynamicSectionItemIdxes:null),_.programModules=[],i.supAreaInfo=_,[i,(this._subChecker.isFullfilled?1e6:0)+e.SO(_.coveredSpace)/1e3,I,w]}clone(){const i=new D;return i._module=this._module,i._subChecker=this._subChecker.clone(),i._hasReversed=this._hasReversed,i._hasDroppedBeforeReversing=this._hasDroppedBeforeReversing,this._clone(i),i}dispose(){super.dispose(),this._subChecker?.dispose(),this._subChecker=null,this._module=null}_processNavigationResult(i){if(i.reachedDeadEnd||i.shouldFlushCurrentArea||i.shouldStartOverFormerArea||i.shouldStartOverCurrentArea&&this._hasReversed||i.shouldStartOverCurrentModulePlacement&&!this._module.module.attributes.isFreeForm)return this._subChecker.isEmpty?{type:"drop"}:{type:"flush",flushIsFullfilled:this._subChecker.isFullfilled};if(i.shouldProcessCorner)return this._subChecker.isEmpty||i.cornerTileOptions[0].isConsecutiveToPrevious||this._module.module.attributes.isFreeForm?(i.cornerTileOptions.forEach(I=>{i.pushSelectedTileInfo(I);const w=this._subChecker.step(i);("partial"===w||"untouched"===w)&&this._subChecker.forceBlit(i)}),this._subChecker.isFullfilled?{type:"flush",flushIsFullfilled:!0}:{type:"keep"}):this._subChecker.isEmpty?{type:"drop"}:{type:"flush",flushIsFullfilled:this._subChecker.isFullfilled};if(this._currentSubNavigator=i.currentAreaNavigator,i.shouldStartOverCurrentArea){const I=this._subChecker.beginSkippedTiles+(this._hasDroppedBeforeReversing?1:0);this._subChecker.reset(i.currentAreaNavigator.directLightInfoState.directLight),this._hasReversed=!0;const w=i.clone();
1w.clearSelection(),i.selectedTileInfos.slice(I).forEach(_=>{w.pushSelectedTileInfo(_),this._subChecker.step(w)})}if(i.shouldBranch){const I=i.dynamicItemOptions.dynSectionIdx;return{type:"branch",branchClbk:()=>{const w=Object.entries(i.dynamicItemOptions.itemOptions).filter(_=>0!=+_[0]).map(_=>{const o=this.clone();return o._currentNavigator.selectDynamicItem(I,+_[0],_[1].tile,_[1].isConsecutiveToPrevious||!1,_[1].isOnCorridor||!1),o});return this.dispose(),w}}}const d=this._subChecker.step(i);return this._subChecker.isFullfilled?{type:"flush",flushIsFullfilled:!0}:!this._hasReversed||"drop"!==d&&"reverse"!==d?["keep","partial","untouched"].includes(d)?{type:"keep"}:(this._hasReversed=!0,this._hasDroppedBeforeReversing="drop"===d,{type:this._currentSubNavigator.trySetwillReverse()?"keep":"drop"}):{type:"drop"}}}var Y=P(76314);class H extends n{constructor(){super(...arguments),this._requiredOffices=new Map,this._remainingOffices=new Map,this._currentConsecutiveTileInfos=[],this._selectionHasWindow=!1,this._currentSupAreaIsStuck=!1,this._builtInfos=new Map,this._shiftedTilesMap=new Map}get isFullfilled(){return Array.from(this._remainingOffices.values()).every(i=>i<=0)}get isEmpty(){return Array.from(this._remainingOffices.entries()).every(([i,d])=>d>=(this._requiredOffices.get(i)||0))}static create(i){const d=new H;if(i.userSp?d._requiredOffices=new Map(i.userSp.usedOffices):(d._requiredOffices=new Map,i.department.officeStates.forEach(I=>{d._requiredOffices.set(I.targetRequirement,I.remainingCount)})),d._remainingOffices=new Map(d._requiredOffices),i.movingInfo){const I=i.department.openspaceState.targetRequirement;i.movingInfo.supAreaInfos.forEach(w=>{w.programModules.forEach(_=>{_.programModule!==I&&d._remainingOffices.set(_.programModule,(d._remainingOffices.get(_.programModule)||0)+_.placedCount)})})}return d}step(i,d){if(!i.lastPickedTileInfo||this.isFullfilled||this._currentSupAreaIsStuck)return!1;if(i.shouldStartOverCurrentModulePlacement){if(d||this._currentConsecutiveTileInfos.length&&this._builtInfos.has(i.currentAreaNavigator.directLightInfoState.directLight)){const u=this._builtInfos.get(i.currentAreaNavigator.directLightInfoState.directLight)||[];u.push(a.create(this._currentConsecutiveTileInfos)),this._builtInfos.set(i.currentAreaNavigator.directLightInfoState.directLight,u)}this._currentConsecutiveTileInfos=[],this._selectionHasWindow=!1}if(this._currentConsecutiveTileInfos.push(this._createRequirementCheckerTileInfo(i.lastPickedTileInfo)),this._selectionHasWindow=this._selectionHasWindow||i.lastPickedTileInfo.isWindow,i.lastPickedTileInfo.isPartial&&i.lastPickedTileInfo.isWindow){const u=this._builtInfos.get(i.currentAreaNavigator.directLightInfoState.directLight)||[];return!u.length&&(u.push(a.create(this._currentConsecutiveTileInfos)),this._builtInfos.set(i.currentAreaNavigator.directLightInfoState.directLight,u),this._currentConsecutiveTileInfos=[],this._selectionHasWindow=!1,!0)}let I=!1,w=[];const _=()=>{const[u,S]=this._currentConsecutiveTileInfos.reduce((Re,ge)=>(Re[0]+=ge.width,Re[1]=Math.min(ge.height,Re[1]),Re),[0,Number.MAX_VALUE]);let T=Array.from(this._remainingOffices.entries()).flatMap(([Re,ge])=>ge<=0?[]:Re.dimensions.flatMap(De=>De.dimensions.map(He=>[S-He[1],He[0],He[1],Re,De])).filter(De=>De[0]>=-1));if(!T.length)return!1;if(T=T.filter(Re=>Re[1]<=u),T.sort((Re,ge)=>Re[0]-ge[0]||Re[1]-ge[1]),!T.length||!this._selectionHasWindow)return!0;const F=T[0][3],$=T[0][4];this._remainingOffices.set(F,(this._remainingOffices.get(F)||0)-1);const ue=this._builtInfos.get(i.currentAreaNavigator.directLightInfoState.directLight)||[];if(d||ue.length){const Re=this._shiftedTilesMap.get(i.currentAreaNavigator.directLightInfoState.directLight)||[];Re.push(...w),ue.push(a.create(Re)),this._shiftedTilesMap.delete(i.currentAreaNavigator.directLightInfoState.directLight),w=[]}const Ie=a.create(this._currentConsecutiveTileInfos,$.asTuple([T[0][1],T[0][2],0]),1,F);ue.push(Ie),this._builtInfos.set(i.currentAreaNavigator.directLightInfoState.directLight,ue),this._currentConsecutiveTileInfos=[],this._selectionHasWindow=!1;const Pe=(Re,ge,De)=>{let He=!0;He="number"==typeof Re.beginOffset||"number"==typeof Re.endOffset?"number"!=typeof Re.beginOffset:1===this._currentConsecutiveTileInfos.length?Re.beginNeighbours.length<=Re.endNeighbours.length:Re.tileSelectionInfo.tile.isOtherCloseToBegin(ge);const rt=Re.tileSelectionInfo.tile.getClosestFittingOffset(Re.width-De,He,!1);return[this._createRequirementCheckerTileInfo(Re.tileSelectionInfo,Re.tileSelectionInfo.beginOffset,Re.tileSelectionInfo.endOffset,He?rt:void 0,He?void 0:rt),He]};let Ue=u-T[0][1];if(Ue>.01){const Re=(Re=>{if(1===ue.length&&!Ie.firstTileInfo.isWindow&&Ie.tileInfos.length>1){let ge=Re;const De=Ie.firstTileInfo;ge>De.width&&(ge=De.width),Re-=ge;const[He,rt]=Pe(De,Ie.tileInfos[1].tileSelectionInfo.tile,ge);if(Ie.tileInfos[0]=He,Re>.01&&!Ie.lastTileInfo.isWindow){let Ge=Ie.tileInfos.length>=2?Ie.tileInfos[Ie.tileInfos.length-2].tileSelectionInfo.tile:null,[mt,dt]=Pe(Ie.lastTileInfo,Ge,Re);return Ie.tileInfos[Ie.tileInfos.length-1]=mt,dt}return null}if(Ie.lastTileInfo.isWindow)return null;{let ge=Ie.tileInfos.length>=2?Ie.tileInfos[Ie.tileInfos.length-2].tileSelectionInfo.tile:null,[De,He]=Pe(Ie.lastTileInfo,ge,Re);return Ie.tileInfos[Ie.tileInfos.length-1]=De,He}})(Ue);if(null!==Re){const ge=Ie.lastTileInfo;return Re?(i.lastPickedTileInfo.beginOffset=ge.beginOffset,i.lastPickedTileInfo.isPartial=!0,i.lastPickedTileInfo.width=Y.vC.width(ge.tile,ge.beginOffset,ge.currentEndOffset)):(i.lastPickedTileInfo.endOffset=ge.endOffset,i.lastPickedTileInfo.isPartial=!0,i.lastPickedTileInfo.width=Y.vC.width(ge.tile,ge.currentBeginOffset,ge.endOffset)),I=!0,null}i.abort()}return!0};let o=10,s=!1;for(;o-- >0&&this._currentConsecutiveTileInfos.length;){const u=_();if(!1!==u){s=null===u;break}this._currentConsecutiveTileInfos.length&&w.push(this._currentConsecutiveTileInfos.shift()),this._selectionHasWindow=this._currentConsecutiveTileInfos.some(S=>S.isWindow)}if(w.length){const u=this._shiftedTilesMap.get(i.currentAreaNavigator.directLightInfoState.directLight)||[];u.push(...w),this._shiftedTilesMap.set(i.currentAreaNavigator.directLightInfoState.directLight,u)}return s?this.step(i,d):!I}forceBlit(i){if(!i.lastPickedTileInfo)return;const d=this._createRequirementCheckerTileInfo(i.lastPickedTileInfo),w=this._builtInfos.get(i.currentAreaNavigator.directLightInfoState.directLight)||[];if(w.length){const _=w[w.length-1].tileInfos.length?w[w.length-1].tileInfos[w[w.length-1].tileInfos.length-1]:null;if(_&&_.tile===d.tile){if(_.width==d.width)return;return void(w[w.length-1].tileInfos[w[w.length-1].tileInfos.length-1]=d)}}if(this._currentConsecutiveTileInfos.push(d),this.isFullfilled){this._builtInfos.has(i.currentAreaNavigator.directLightInfoState.directLight)||this._builtInfos.set(i.currentAreaNavigator.directLightInfoState.directLight,[]);const _=this._builtInfos.get(i.currentAreaNavigator.directLightInfoState.directLight),o=a.create(this._currentConsecutiveTileInfos);this._currentConsecutiveTileInfos=[],_.push(o)}}reset(i,d=!1,I){this._currentConsecutiveTileInfos=[],this._selectionHasWindow=!1,this._currentSupAreaIsStuck=!1;const w=this._builtInfos.get(i);w&&(d||(w.forEach(_=>{if(!_.hasValidProgramModule)return;const o=this._remainingOffices.get(_.targetProgramModule)||0;this._remainingOffices.set(_.targetProgramModule,o+_.count)}
1),I&&I.length?(I.forEach(_=>{if(!_.hasValidProgramModule)return;const o=this._remainingOffices.get(_.targetProgramModule)||0;this._remainingOffices.set(_.targetProgramModule,o-_.count)}),this._builtInfos.set(i,I)):this._builtInfos.delete(i)),this._shiftedTilesMap.delete(i))}flushCurrentArea(i,d){if(d){const I=this._builtInfos.get(i)||[];I.push(a.create(this._currentConsecutiveTileInfos)),this._builtInfos.set(i,I);const w=this._shiftedTilesMap.get(i);w&&(I.push(a.create(w)),this._shiftedTilesMap.delete(i))}this._currentConsecutiveTileInfos=[],this._selectionHasWindow=!1,this._currentSupAreaIsStuck=!1}getBuiltUnitsForDirectLight(i){return this._builtInfos.get(i)||[]}setBuiltUnitsForDirectLight(i,d){this._builtInfos.set(i,d)}getBuiltUnitsPerDirectLight(){const i=new Map;return this._builtInfos.forEach((d,I)=>{d.every(w=>!w.hasValidProgramModule)||i.set(I,d)}),i}dispose(){this._requiredOffices.clear(),this._requiredOffices=null,this._remainingOffices.clear(),this._remainingOffices=null,this._currentConsecutiveTileInfos=null,this._builtInfos.clear(),this._builtInfos=null}clone(){const i=new H;return i._requiredOffices=new Map(this._requiredOffices),i._remainingOffices=new Map(this._remainingOffices),i._currentConsecutiveTileInfos=[...this._currentConsecutiveTileInfos],i._selectionHasWindow=this._selectionHasWindow,i._currentSupAreaIsStuck=this._currentSupAreaIsStuck,this._builtInfos.forEach((d,I)=>{i._builtInfos.set(I,d.map(w=>w.clone()))}),this._shiftedTilesMap.forEach((d,I)=>{i._shiftedTilesMap.set(I,d.map(w=>w.clone()))}),i}}var ne=P(55656);class K{constructor(i,d,I,w,_,o){this._osProgramModule=i,this._osDimensions=d,this._mainOsSettings=I,this._tertiaryWidth=w,this._closetWidth=_,this._checker=o,this._maxNeedHeight=0,this._maxNeedHeight=this._osDimensions.map(s=>s[1]).sort((s,u)=>u-s)[0]||0}get currentMinHeight(){return this._checker._currentMinHeight}set currentMinHeight(i){this._checker._currentMinHeight=i}get currentConsecutiveTileInfos(){return this._checker._currentConsecutiveTileInfos}set currentConsecutiveTileInfos(i){this._checker._currentConsecutiveTileInfos=i}get remainingWorkstations(){return this._checker._remainingWorkstations}set remainingWorkstations(i){this._checker._remainingWorkstations=i}get builtInfos(){return this._checker._builtInfos}get shiftedTilesMap(){return this._checker._shiftedTilesMap}get pickedWidth(){return this._checker._pickedWidth}set pickedWidth(i){this._checker._pickedWidth=i}get extraTertiaryNeed(){return this._checker._extraTertiaryNeed}set extraTertiaryNeed(i){this._checker._extraTertiaryNeed=i}get buildingOsCount(){return this._checker._buildingOsCount}set buildingOsCount(i){this._checker._buildingOsCount=i}blitWidth(i,d,I,w,_,o,s=!1){const u=this.currentConsecutiveTileInfos.some(Ce=>Ce.tile.postInfos.length>0),S=I.currentAreaNavigator.currentSelection.directionIsPositive,T=this.builtInfos.get(I.currentAreaNavigator.directLightInfoState.directLight)||[],F=[];let $=0,ue=0;if(u){let Ce=[],Ue=this.extraTertiaryNeed,Re=90,ge=_-Ue-Re;this.currentConsecutiveTileInfos.forEach((Ge,mt)=>{let dt=Ge.width,kt=0;const ti=this._isFromBegin(Ge,mt,T,S);if(Ue>0){const qt=Math.min(Ue,dt);Ue-=qt,dt-=qt,kt+=qt}if(Ue<=0&&ge>0){const qt=Math.min(ge,dt),zt=Ge.getPostsInRange(kt,qt,ti);zt.length&&F.push([Ge.tile,zt]),ge-=qt,dt-=qt,kt+=qt}if(ge<=0){const qt=Math.min(Re,dt);Ce.push(...Ge.getPostsInRange(kt,qt,ti)),dt-=qt,kt+=qt}});const De=o?o[1]:this._maxNeedHeight;Ce=Ce.filter(Ge=>Ge.y<De);const rt=Ce.map(Ge=>Ge.bl>Ge.el?Ge.bl:Ge.el).reduce((Ge,mt)=>Math.min(Ge,mt),90)+30-90;rt<0&&($=-rt)}if(u&&o&&F.length){const Ce=F.map(([De,He])=>Y.vC.postHeight(De.partitionableShapeInfo.height,He)),Ue=Math.min(...Ce,this.currentMinHeight),Re=this._osDimensions.map(De=>[Ue-De[1],De[0],De[1],De[2]||0,De[3],De[4]]).filter(De=>De[0]>=-1);Re.sort((De,He)=>De[0]-He[0]);const ge=o[2];if(!(o=Re.length>0?[Re[0][1],Re[0][2],Re[0][3]||1,Re[0][4],Re[0][5]]:null))return!1;if(ue=F.flatMap(([De,He])=>He.filter(rt=>rt.y<=o[1])).reduce((De,He)=>Math.max(De,He.y+He.height),0),o[2]<ge&&this.remainingWorkstations-o[2]>0&&this.remainingWorkstations-ge<=0){const De=this.currentConsecutiveTileInfos.length?this.currentConsecutiveTileInfos[this.currentConsecutiveTileInfos.length-1]:null;
1_=this.extraTertiaryNeed+o[0]+(De?.tileSelectionInfo?.isOnCorridor&&this.currentConsecutiveTileInfos.length>1&&s?this._tertiaryWidth:1===this.buildingOsCount?this._mainOsSettings.deskToWallDistance:this._mainOsSettings.deskToDeskDistance)}}if(this.pickedWidth<(_+=$))return!1;if(this.pickedWidth-=_,$=this.extraTertiaryNeed,this.extraTertiaryNeed=0,this.currentMinHeight=this.pickedWidth<=0||!i?Number.MAX_SAFE_INTEGER:i.height,d||T.length){const Ce=this.shiftedTilesMap.get(I.currentAreaNavigator.directLightInfoState.directLight)||[];Ce.push(...w),Ce.length&&T.push(a.create(Ce)),this.shiftedTilesMap.delete(I.currentAreaNavigator.directLightInfoState.directLight),w.splice(0)}const Ie=this._pickAndBlitTiles(_,$,T,S,i,o,ue),Pe=a.create(Ie.tiles,o?[o[3],o[4],[o[0],o[1],o[2]]]:null,o?o[2]:0,o?this._osProgramModule:null,Ie.centroidTile,Ie.centroidOffsetX,Ie.centroidDepth,!o);return o&&(this.remainingWorkstations-=o[2]),T.push(Pe),this.builtInfos.set(I.currentAreaNavigator.directLightInfoState.directLight,T),!0}_isFromBegin(i,d,I,w){let _=!0;return _="number"==typeof i.beginOffset||"number"==typeof i.endOffset?"number"!=typeof i.beginOffset:0===d?this.currentConsecutiveTileInfos.length>1?i.tile.isOtherCloseToBegin(this.currentConsecutiveTileInfos[1].tile):I.length>0&&i.tileSelectionInfo.isConsecutiveToPrevious?i.tile.isOtherCloseToBegin(I[I.length-1].lastTileInfo.tile):i.beginNeighbours.length<=i.endNeighbours.length:i.tile.isOtherCloseToBegin(this.currentConsecutiveTileInfos[d-1].tile),_}_pickAndBlitTiles(i,d,I,w,_,o,s=0){const u=[],S=[];let T=i/2,F=s+(o?o[1]/2:0)||0,$=null,ue=d,Ie=o?o[0]/2:this._closetWidth/2;this.currentConsecutiveTileInfos.forEach((Ue,Re)=>{let ge=Ue.width,De=0;if(ue>0){const He=Math.min(ue,ge);ue-=He,ge-=He,De+=He}if(ue<=0&&Ie>0){const He=Math.min(Ie,ge);if(Ie-=He,De+=He,ge-=He,Ie<=0){const rt=this._isFromBegin(Ue,Re,I,w);T=Ue.getClosestFittingOffset(De,rt,!0),$=Ue.tile.partitionableShapeInfo.uidInPackage()}}});let Pe=-1,Ce=i;for(const Ue of this.currentConsecutiveTileInfos)if(Pe++,Ce<=0)S.push(Ue);else if(Ce-Ue.width<0&&"number"!=typeof Ue.selfOrCurrentBeginOffset&&"number"!=typeof Ue.selfOrCurrentEndOffset){const Re=this._isFromBegin(Ue,Pe,I,w),ge=Ue.getClosestFittingOffset(Ce,Re,!0),De=this._checker._createRequirementCheckerTileInfo(Ue.tileSelectionInfo,Ue.tileSelectionInfo.beginOffset,Ue.tileSelectionInfo.endOffset,Re?ge:void 0,Re?void 0:ge),He=this._checker._createRequirementCheckerTileInfo(Ue.tileSelectionInfo,Re?ge:Ue.tileSelectionInfo.beginOffset,Re?Ue.tileSelectionInfo.endOffset:ge);u.push(De),S.push(He),_.tile===Ue.tile&&(_.autoUpdate=!1,_.currentBeginOffset=He.currentBeginOffset,_.currentEndOffset=He.currentEndOffset,_.beginOffset=He.beginOffset,_.autoUpdate=!0,_.endOffset=He.endOffset)}else Ce-=Ue.width,u.push(Ue);return this.currentConsecutiveTileInfos=S,{tiles:u,centroidOffsetX:T,centroidDepth:F,centroidTile:$||void 0}}tryBlitOs(i,d,I,w,_=!1){const o=this._osDimensions.map(F=>[this.currentMinHeight-F[1],F[0],F[1],F[2]||0,F[3],F[4]]).filter(F=>F[0]>=-1);o.sort((F,$)=>F[0]-$[0]);const s=o.length>0?[o[0][1],o[0][2],o[0][3]||1,o[0][4],o[0][5]]:null;if(!s){if(_)return!1;if(this.currentConsecutiveTileInfos.length){const F=this.currentConsecutiveTileInfos.shift();this.pickedWidth-=F.width,this.currentMinHeight=this.currentConsecutiveTileInfos.reduce(($,ue)=>Math.min($,ue.height),Number.MAX_SAFE_INTEGER),w.push(F)}return!0}const u=this.remainingWorkstations-s[2],S=this.currentConsecutiveTileInfos.length?this.currentConsecutiveTileInfos[this.currentConsecutiveTileInfos.length-1]:null,T=this.extraTertiaryNeed+s[0]+(S?.tileSelectionInfo?.isOnCorridor&&this.currentConsecutiveTileInfos.length>1&&(u<=0||_)?this._tertiaryWidth:u<=0||1===this.buildingOsCount?this._mainOsSettings.deskToWallDistance:this._mainOsSettings.deskToDeskDistance);return this.pickedWidth>=T&&(this.blitWidth(i,d,I,w,T,s,_)&&(this.buildingOsCount-=1),!0)}tryBlitCloset(i,d,I,w){const _=this._closetWidth+this._mainOsSettings.deskToWallDistance+this.extraTertiaryNeed;return this.pickedWidth>=_&&(this.blitWidth(i,d,I,w,_)&&(this.buildingOsCount=this._mainOsSettings.benchCountBeforeScreening||2),!0)}clone(i){return new K(this._osProgramModule,this._osDimensions,this._mainOsSettings,this._tertiaryWidth,this._closetWidth,i)}dispose(){this._checker=null}}class k extends n{constructor(){super(...arguments),this._requiredWorkstations=0,this._remainingWorkstations=0,this._osDimensions=[],this._tertiaryWidth=0,this._buildingOsCount=2,this._currentConsecutiveTileInfos=[],this._pickedWidth=0,this._currentMinHeight=Number.MAX_SAFE_INTEGER,this._extraTert
1iaryNeed=0,this._builtInfos=new Map,this._shiftedTilesMap=new Map}get builtInfosMap(){return this._builtInfos}get isFullfilled(){return this._remainingWorkstations<=0}get isEmpty(){return this._remainingWorkstations>=this._requiredWorkstations}static create(i){const d=new k;if(d._requiredWorkstations=i.userSp?i.userSp.usedOpenSpaces:i.department.openspaceState.remainingCount,d._osProgramModule=i.department.openspaceState.targetRequirement,d._parameters=i.parameters,d._remainingWorkstations=d._requiredWorkstations,d._osDimensions=i.department.openspaceState.targetRequirement.dimensions.flatMap(I=>{const w=I.picker.getSettings(d._osProgramModule.settingId);return d._mainOsSettings=w,I.dimensions.map(_=>[_[0]+2*w.setback,_[1]+w.windowOffset,_[2],I.picker,I.layout,w])}).filter(I=>I[2]<=I[5].maxDeskPerBench),d._mainOsSettings||(d._mainOsSettings=ne.t.createDefault()),d._buildingOsCount=d._mainOsSettings.benchCountBeforeScreening||2,d._pickedWidth=0,d._extraTertiaryNeed=d._mainOsSettings.deskToWallDistance,d._tertiaryWidth=Math.min(60,d._mainOsSettings.deskToDeskDistance-d._mainOsSettings.deskToWallDistance),i.movingInfo){const I=i.department.openspaceState.requiredCount;i.movingInfo.supAreaInfos.forEach(w=>{w.programModules.forEach(_=>{_.programModule===i.department.openspaceState.targetRequirement&&(d._remainingWorkstations=Math.min(I,d._remainingWorkstations+_.placedCount))})})}return d._blitter=new K(d._osProgramModule,d._osDimensions,d._mainOsSettings,d._tertiaryWidth,d._parameters.closetWidth,d),d}step(i,d){if(!i.lastPickedTileInfo||this.isFullfilled)return!1;let I=!0,w=10,_=[],o=null;const u=(S=!1)=>{I=this._blitter.tryBlitOs(o,d,i,_,S)||I};if(i.shouldStartOverCurrentModulePlacement&&!i.shouldFlushCurrentArea){if(u(!0),d||this._currentConsecutiveTileInfos.length&&this._builtInfos.has(i.currentAreaNavigator.directLightInfoState.directLight)){const S=this._builtInfos.get(i.currentAreaNavigator.directLightInfoState.directLight)||[],T=a.create(this._currentConsecutiveTileInfos,null,0);S.push(T),this._builtInfos.set(i.currentAreaNavigator.directLightInfoState.directLight,S)}this._currentConsecutiveTileInfos=[],this._pickedWidth=0,this._extraTertiaryNeed=i.lastPickedTileInfo.isOnCorridor?this._tertiaryWidth:this._mainOsSettings.deskToWallDistance,this._buildingOsCount=this._mainOsSettings.benchCountBeforeScreening||2,this._currentMinHeight=Number.MAX_SAFE_INTEGER}for(i.lastPickedTileInfo.isOnCorridor&&0===this._currentConsecutiveTileInfos.length&&0===this._builtInfos.size&&0===this._pickedWidth&&(this._extraTertiaryNeed=this._tertiaryWidth),o=this._createRequirementCheckerTileInfo(i.lastPickedTileInfo),this._currentConsecutiveTileInfos.push(o),this._pickedWidth+=o.width,this._currentMinHeight=Math.min(this._currentMinHeight,o.height);I&&w>0&&this._remainingWorkstations>0;)w--,I=!1,this._buildingOsCount<=0?I=this._blitter.tryBlitCloset(o,d,i,_)||I:u();if(_.length){const S=this._shiftedTilesMap.get(i.currentAreaNavigator.directLightInfoState.directLight)||[];S.push(..._),this._shiftedTilesMap.set(i.currentAreaNavigator.directLightInfoState.directLight,S)}if(this._remainingWorkstations<=0){const S=this._builtInfos.get(i.currentAreaNavigator.directLightInfoState.directLight);if(!S||!S.length)return!0;const T=()=>{for(let Pe=S.length-1;Pe>=0;Pe--){const Ce=S[Pe];if(Ce.tileInfos.length)return[Ce.tileInfos[Ce.tileInfos.length-1],Ce.tileInfos[Ce.tileInfos.length-2]]}return[null,null]},[F,$]=T();if(!F)return!0;const ue=F.tile.isOtherCloseToBegin($?.tile),Ie=ue?F.selfOrCurrentBeginOffset:F.selfOrCurrentEndOffset;"number"!=typeof Ie?i.abort():ue?(F.beginOffset=Ie,i.lastPickedTileInfo.beginOffset=F.beginOffset,i.lastPickedTileInfo.isPartial=!0,i.lastPickedTileInfo.width=Y.vC.width(F.tile,F.beginOffset,F.currentEndOffset)):(F.endOffset=Ie,i.lastPickedTileInfo.endOffset=F.endOffset,i.lastPickedTileInfo.isPartial=!0,i.lastPickedTileInfo.width=Y.vC.width(F.tile,F.currentBeginOffset,F.endOffset))}return!this.isFullfilled}forceBlit(i){if(!i.lastPickedTileInfo)return;const d=this._createRequirementCheckerTileInfo(i.lastPickedTileInfo);if(this._currentConsecutiveTileInfos.length&&this._currentConsecutiveTileInfos[this._currentConsecutiveTileInfos.length-1].tile===d.tile)return;const w=this._builtInfos.get(i.currentAreaNavigator.directLightInfoState.directLight)||[];if(w.length){const _=w[w.length-1].tileInfos.length?w[w.length-1].tileInfos[w[w.length-1].tileInfos.length-1]:null;if(_&&_.tile===d.tile){if(_.width==d.width)return;return this._pickedWidth+=d.width-_.width,this._currentMinHeight=Math.min(this._currentMinHeight,d.height),void(w[w.length-1].tileInfos[w[w.length-1].tileInfos.length-1]=d)}}if(this._currentConsecutiveTileInfos.push(d),this._pickedWidth+=d.width,this._currentMinHeight=Math.min(this._currentMinHeight,d.height),this.isFullfilled){this._builtInfos.has(i.currentAreaNavigator.directLightInfoState.directLight)||this._builtInfos.set(i.currentAreaNavigator.directLightInfoState.directLight,[]);const _=this._builtInfos.get(i.currentAreaNavigator.directLightInfoState.directLight),o=a.create(this._currentConsecutiveTileInfos);o.tileInfos.length&&_.push(o),this._currentConsecutiveTileInfos=[]}}reset(i,d=!1,I){this._currentConsecutiveTileInfos=[],this._pickedWidth=0,this._extraTert
1iaryNeed=this._mainOsSettings.deskToWallDistance,this._currentMinHeight=Number.MAX_SAFE_INTEGER,this._buildingOsCount=this._mainOsSettings.benchCountBeforeScreening||2;const w=this._builtInfos.get(i);if(w){if(d){if(w.length){const _=w[w.length-1];(!_.hasValidProgramModule||!_.count)&&w.pop()}}else this._remainingWorkstations+=w.reduce((_,o)=>_+o.count,0),I?(this._remainingWorkstations-=I.reduce((_,o)=>_+o.count,0),this._builtInfos.set(i,I)):this._builtInfos.delete(i);this._shiftedTilesMap.delete(i)}}flushCurrentArea(i,d){if(d){this._builtInfos.has(i)||this._builtInfos.set(i,[]);const I=this._builtInfos.get(i);this._currentConsecutiveTileInfos.length&&I.push(a.create(this._currentConsecutiveTileInfos,null,0));const w=this._shiftedTilesMap.get(i);w&&w.length&&(I.push(a.create(w)),this._shiftedTilesMap.delete(i))}this._currentConsecutiveTileInfos=[],this._pickedWidth=0,this._extraTertiaryNeed=this._mainOsSettings.deskToWallDistance,this._currentMinHeight=Number.MAX_SAFE_INTEGER,this._buildingOsCount=this._mainOsSettings.benchCountBeforeScreening||2}getBuiltUnitsForDirectLight(i){return this._builtInfos.get(i)||[]}setBuiltUnitsForDirectLight(i,d){this._builtInfos.set(i,d)}getBuiltUnitsPerDirectLight(){const i=new Map;return this._builtInfos.forEach((d,I)=>{d.every(w=>!w.hasValidProgramModule)||i.set(I,d)}),i}dispose(){this._parameters=null,this._osProgramModule=null,this._mainOsSettings=null,this._blitter.dispose()}clone(){const i=new k;return i._parameters=this._parameters,i._osDimensions=this._osDimensions,i._requiredWorkstations=this._requiredWorkstations,i._remainingWorkstations=this._remainingWorkstations,i._buildingOsCount=this._buildingOsCount,i._osProgramModule=this._osProgramModule,i._mainOsSettings=this._mainOsSettings,i._tertiaryWidth=this._tertiaryWidth,i._currentConsecutiveTileInfos=[...this._currentConsecutiveTileInfos],i._pickedWidth=this._pickedWidth,i._extraTertiaryNeed=this._extraTertiaryNeed,i._currentMinHeight=this._currentMinHeight,i._blitter=this._blitter.clone(i),this.builtInfosMap.forEach((d,I)=>{i._builtInfos.set(I,d.map(w=>w.clone()))}),this._shiftedTilesMap.forEach((d,I)=>{i._shiftedTilesMap.set(I,d.map(w=>w.clone()))}),i}}var Xe,x=P(4516);class f{constructor(){this.dynamicSectionItemIdxes={},this.builtUnits=[]}get isEmpty(){return 0===this.builtUnits.length}getTileInfos(){return this.builtUnits.flatMap(i=>i.tileInfos)}explode(i,d){if(i.getNumGeometries()<=1)return[this];const I=_=>{const o={};for(const s of _.tileInfos)void 0!==s.tile.dynamicSectionIdx&&s.tile.dynamicSectionIdx>=0&&void 0!==s.tile.dynamicItemIdx&&s.tile.dynamicItemIdx>0&&(o[s.tile.dynamicSectionIdx]=s.tile.dynamicItemIdx);return o},w=[];for(let _=i.getNumGeometries()-1;_>=0;_--)w.push(new f);for(const _ of this.builtUnits){const o=d(_.tileInfos);for(let s=i.getNumGeometries()-1;s>=0;s--){const u=i.getGeometryN(s);if(e.kK(u,o)){w[s].builtUnits.push(_),Object.assign(w[s].dynamicSectionItemIdxes,I(_));break}}}return w}}class J extends E{constructor(){super(...arguments),this._isOsFirst=!0}static create(i,d){const I=new J;return I._department=d.department.targetRequirement,I._isOsFirst=i,I._officeChecker=H.create(d),I._openspaceChecker=k.create(d),I}buildInfo(){const i=new y.O;i.department=this._department;const d=new Map;let I=this._currentSubNavigator.currentSelection.selectedTileInfos.length?this._currentSubNavigator.currentSelection.selectedTileInfos[this._currentSubNavigator.currentSelection.selectedTileInfos.length-1]:null,w=null,_=null;this._currentNavigator.collectDynamicActivations().forEach((S,T)=>{let F=d.get(T);F||(F=new f,d.set(T,F),F.dynamicSectionItemIdxes=S),F.dynamicSectionItemIdxes={...F.dynamicSectionItemIdxes,...S}});const s=S=>{S.getBuiltUnitsPerDirectLight().forEach((T,F)=>{let $=d.get(F);$||($=new f,d.set(F,$)),$.builtUnits.push(...T)})};this._isOsFirst?(s(this._openspaceChecker),s(this._officeChecker)):(s(this._officeChecker),s(this._openspaceChecker));let u=1e10*((this._officeChecker.isFullfilled?1:0)+(this._openspaceChecker.isFullfilled?1:0));return d.forEach((S,T)=>{if(S.isEmpty)return;const F=this._currentNavigator.floorState.directLightAreaStates.find(Ce=>Ce.directLight===T);if(!F)return;const $=Ce=>{const Ue=new y.O.SupAreaInfo;Ue.supAreaFullUid=T.fullUid,Ue.dynamicSectionItemIdxes=Ce.dynamicSectionItemIdxes;const Re=Ce.getTileInfos();Ue.coveredSpace=this._createCoveredSpace(Re,F,Ue.dynamicSectionItemIdxes),Ue.tileInfos=Re.map(ge=>
1(ge.tileSelectionInfo===I&&(w=ge,_=F),ge.asDict())),Ce.builtUnits.forEach(ge=>{if(!ge.hasValidProgramModule&&!ge.isCloset)return;const De=new y.O.SupProgramModuleInfo;De.programModule=ge.targetProgramModule,De.placedCount=ge.count,De.pickedDimension=ge.pickedDimension,De.tileInfos=ge.tileInfos.map(He=>He.asDict()),De.coveredSpace=this._createCoveredSpace(ge.tileInfos),De.furnitureCentroidTile=ge.furnitureCentroidTile,De.furnitureCentroidOffsetX=ge.furnitureCentroidOffsetX,De.furnitureCentroidDepth=ge.furnitureCentroidDepth,De.isCloset=ge.isCloset,Ue.programModules.push(De),u+=1e4*ge.count*(ge.targetProgramModule?.customOrCapacity||1)}),i.supAreaInfos.push(Ue),u-=e.SO(Ue.coveredSpace)/1e4},ue=S.getTileInfos(),Ie=this._createCoveredSpace(ue,F,S.dynamicSectionItemIdxes,!0);S.explode(Ie,this._createCoveredSpace.bind(this)).forEach(Ce=>{$(Ce)})}),[i,u,w,_]}clone(){const i=new J;return i._department=this._department,i._isOsFirst=this._isOsFirst,i._officeChecker=this._officeChecker.clone(),i._openspaceChecker=this._openspaceChecker.clone(),this._clone(i),i}dispose(){super.dispose(),this._department=null,this._officeChecker?.dispose(),this._officeChecker=null,this._openspaceChecker?.dispose(),this._openspaceChecker=null}_processNavigationResult(i){if(i.reachedDeadEnd)return this._officeChecker.isEmpty&&this._openspaceChecker.isEmpty?{type:"drop"}:{type:"flush",flushIsFullfilled:this._officeChecker.isFullfilled&&this._openspaceChecker.isFullfilled};if(i.shouldProcessCorner){this._mayReviseAtEnd=!i.currentAreaNavigator.currentSelection.hasRevised;let d=i.cornerTileOptions[i.cornerTileOptions.length-1];return i.cornerTileOptions.forEach(I=>{i.pushSelectedTileInfo(I);let w=!1;this._isOsFirst?this._openspaceChecker.step(i,!1)||this._officeChecker.step(i,!this._openspaceChecker.isEmpty)||(w=!0,this._officeChecker.isFullfilled?this._openspaceChecker.forceBlit(i):this._officeChecker.forceBlit(i)):this._officeChecker.step(i,!1)||this._openspaceChecker.step(i,!this._officeChecker.isEmpty)||(w=!0,this._openspaceChecker.isFullfilled?this._officeChecker.forceBlit(i):this._openspaceChecker.forceBlit(i)),I===d&&!w&&(this._isOsFirst?this._openspaceChecker.isEmpty||this._openspaceChecker.isFullfilled?!this._officeChecker.isEmpty&&!this._officeChecker.isFullfilled&&this._officeChecker.forceBlit(i):this._openspaceChecker.forceBlit(i):this._officeChecker.isEmpty||this._officeChecker.isFullfilled?!this._openspaceChecker.isEmpty&&!this._openspaceChecker.isFullfilled&&this._openspaceChecker.forceBlit(i):this._officeChecker.forceBlit(i))}),this._openspaceChecker.isFullfilled&&this._officeChecker.isFullfilled?{type:"flush",flushIsFullfilled:!0}:{type:"keep"}}if(i.shouldFlushCurrentArea){if(this._mayReviseAtEnd||!i.currentAreaNavigator.currentSelection.hasRevised)return{type:"branch",branchClbk:()=>{this._willReviseClbk=()=>{this._willReviseClbk=null,this._mayReviseAtEnd=!1;const w=!this._openspaceChecker.isEmpty||!this._officeChecker.isEmpty;return this._officeChecker.flushCurrentArea(this._currentSubNavigator.directLightInfoState.directLight,w),this._openspaceChecker.flushCurrentArea(this._currentSubNavigator.directLightInfoState.directLight,w),this._processNormal(i)};const d=i.clone();if(!d.tryRestorePreviousAreaSelection())return[this];const I=this.clone();return I._willReviseClbk=()=>{I._willReviseClbk=null;const w=I._processRevised(d);if("drop"===w.type)return w;I._mayReviseAtEnd=!1;const _=!I._openspaceChecker.isEmpty||!I._officeChecker.isEmpty;return I._officeChecker.flushCurrentArea(I._currentSubNavigator.directLightInfoState.directLight,_),I._openspaceChecker.flushCurrentArea(I._currentSubNavigator.directLightInfoState.directLight,_),I._processNormal(d)},[I,this]}};{const d=!this._openspaceChecker.isEmpty||!this._officeChecker.isEmpty;return this._officeChecker.flushCurrentArea(this._currentSubNavigator.directLightInfoState.directLight,d),this._openspaceChecker.flushCurrentArea(this._currentSubNavigator.directLightInfoState.directLight,d),this._processNormal(i)}}return i.shouldRevise?(this._mayReviseAtEnd=!1,{type:"branch",branchClbk:()=>{const d=this.clone(),I=i.clone();return d._willReviseClbk=()=>(d._willReviseClbk=null,d._processRevised(I)),this._willReviseClbk=()=>(this._willReviseClbk=null,this._processNormal(i)),[d,this]}}):this._processNormal(i)}
1_processNormal(i){if(this._currentSubNavigator=i.currentAreaNavigator,i.shouldStartOverFormerArea||i.shouldStartOverCurrentArea){this._mayReviseAtEnd=!1,this._openspaceChecker.reset(i.currentAreaNavigator.directLightInfoState.directLight),this._officeChecker.reset(i.currentAreaNavigator.directLightInfoState.directLight);const d=i.clone();return d.clearSelection(),i.selectedTileInfos.forEach(I=>{d.pushSelectedTileInfo(I),this._isOsFirst?this._openspaceChecker.step(d,!1)||this._officeChecker.step(d,!this._openspaceChecker.isEmpty):this._officeChecker.step(d,!1)||this._openspaceChecker.step(d,!this._officeChecker.isEmpty)}),this._openspaceChecker.isFullfilled&&this._officeChecker.isFullfilled?{type:"flush",flushIsFullfilled:!0}:{type:"keep"}}if(i.shouldBranch){const d=i.dynamicItemOptions.dynSectionIdx;return{type:"branch",branchClbk:()=>{const I=Object.entries(i.dynamicItemOptions.itemOptions).filter(w=>0!=+w[0]).map(w=>{const _=this.clone();return _._currentNavigator.selectDynamicItem(d,+w[0],w[1].tile,w[1].isConsecutiveToPrevious||!1,w[1].isOnCorridor||!1),_});return this.dispose(),I}}}return this._isOsFirst?this._openspaceChecker.step(i,!1)||this._officeChecker.step(i,!this._openspaceChecker.isEmpty):this._officeChecker.step(i,!1)||this._openspaceChecker.step(i,!this._officeChecker.isEmpty),this._openspaceChecker.isFullfilled&&this._officeChecker.isFullfilled?{type:"flush",flushIsFullfilled:!0}:{type:"keep"}}_processRevised(i){const d=i.collectReversedTileUntilNonConsecutive(),I=i.currentAreaNavigator.directLightInfoState.directLight,w=this._officeChecker.getBuiltUnitsForDirectLight(I),_=this._openspaceChecker.getBuiltUnitsForDirectLight(I),o=new x.bI(d.map(Pe=>Pe.tile.partitionableShapeInfo.uidInPackage())),s=Pe=>Pe.some(Ce=>o.has(Ce.tile.partitionableShapeInfo.uidInPackage())),u=[],S=[];let T=0,F=0;w.forEach(Pe=>{Pe.tileInfos.length&&!s(Pe.tileInfos)&&u.push(Pe),T+=Pe.count*(Pe.targetProgramModule?.customOrCapacity||1)}),_.forEach(Pe=>{Pe.tileInfos.length&&!s(Pe.tileInfos)&&S.push(Pe),F+=Pe.count*(Pe.targetProgramModule?.customOrCapacity||1)}),this._openspaceChecker.reset(I,!1,S),this._officeChecker.reset(I,!1,u);const $=i.clone();$.clearSelection(),d.forEach(Pe=>{$.pushSelectedTileInfo(Pe),this._isOsFirst?this._openspaceChecker.step($,!1)||this._officeChecker.step($,!this._openspaceChecker.isEmpty):this._officeChecker.step($,!1)||this._openspaceChecker.step($,!this._officeChecker.isEmpty)}),this._openspaceChecker.reset(I,!0),this._officeChecker.reset(I,!0);let ue=0,Ie=0;return this._officeChecker.getBuiltUnitsForDirectLight(I).forEach(Pe=>Ie+=Pe.count*(Pe.targetProgramModule?.customOrCapacity||1)),this._openspaceChecker.getBuiltUnitsForDirectLight(I).forEach(Pe=>ue+=Pe.count*(Pe.targetProgramModule?.customOrCapacity||1)),Ie<T||ue<F?{type:"drop"}:this._openspaceChecker.isFullfilled&&this._officeChecker.isFullfilled?{type:"flush",flushIsFullfilled:!0}:this._processNormal(i)}finalRevise(){this._mayReviseAtEnd=!1;const i=this._currentNavigator.currentSelection,d=this.clone(),I=i.clone();return d._willReviseClbk=()=>(d._willReviseClbk=null,d._processRevised(I)),[d,this]}}class L{constructor(){this._checkers=[],this._isFulfilled=!1,this._builtInfo=null,this._builtScore=0,this._builtNextTile=null}get builtNextTile(){return this._builtNextTile}run(i,d){let I=[];const w=(o,s)=>{switch(o.type){case"keep":I.push(s);break;case"drop":s.dispose();break;case"flush":if(s.mayReviseAtEnd){I.push(...s.finalRevise());break}const[u,S,T,F]=s.buildInfo();if((!this._builtInfo||S>this._builtScore)&&(this._builtInfo=u,this._builtScore=S,d))if(T?.isFreeAfterBlit())this._builtNextTile=[!1,T.tile,F];else{const $=s.currentNavigator.tryPickNextAvailableTile();if($.dynamicItemOptions){const ue=Object.values($.dynamicItemOptions.itemOptions)[0].tile;ue&&$.pushSelectedTileInfo(s.currentSubNavigator.createSelectionTileInfo(ue))}this._builtNextTile=$.lastPickedTileInfo?[$.areaNavigatorHasChanged,$.lastPickedTileInfo.tile,$.directLightState]:null}s.dispose();break;case"branch":o.branchClbk&&I.push(...o.branchClbk())}};if(this._executeFirstCheckers(i,w),this._isFulfilled)return this._builtInfo;let _=250;for(this._checkers=I;_>0&&I.length&&!this._isFulfilled;
1)_--,I=[],this._checkers.forEach(o=>w(o.step(this._isFulfilled),o)),this._checkers=I;return this._builtInfo}dispose(){this._checkers.forEach(i=>i.dispose()),this._checkers=[],this._builtInfo=null}}class ce extends L{constructor(i){super(),this._checkers.push(D.create(i.module))}_executeFirstCheckers(i,d){d(this._checkers[0].setNavigator(i.firstNavigator),this._checkers[0])}}class ke extends L{constructor(i){super(),this._checkers.push(J.create(!0,i),J.create(!1,i))}_executeFirstCheckers(i,d){const I=i.firstNavigator,w=I.clone();d(this._checkers[0].setNavigator(I),this._checkers[0]),d(this._checkers[1].setNavigator(w),this._checkers[1])}}!function(lt){class i{static create(o){const s=new i;return s.module=o,s}}lt.RegularCreateArg=i;class d{static create(o,s,u,S){const T=new d;return T.department=o,T.parameters=s,T.userSp=u,T.movingInfo=S,T}}lt.DepartmentCreateArg=d,lt.createRegularCheckerManager=function I(_){return new ce(_)},lt.createDepartmentCheckerManager=function w(_){return new ke(_)}}(Xe||(Xe={}));var te=P(21449);class ye{constructor(){this._restoredTileStates=[],this._restoredTileInfos=new Map,this._previouslyPickedTileInfos=new Map,this._skippedTiles=new Set}get sectionIdx(){return this._sectionIdx}_clone(i){return i._sectionIdx=this._sectionIdx,i._restoredTileStates=this._restoredTileStates,i._restoredTileInfos=this._restoredTileInfos,i._previouslyPickedTileInfos=new Map(this._previouslyPickedTileInfos),i._skippedTiles=new Set(this._skippedTiles),i}restoreTile(i){if(i instanceof te.ph){const d=this._getTileState(i);d&&(this._restoredTileStates.push(d),this._restoredTileInfos.set(d,this._createRestoredInfo(d,d.partitionableShapeInfo.width)))}else{const d=this._getTileState(i.tileUid);if(d&&(this._restoredTileStates.push(d),"number"==typeof d.beginOffset||"number"==typeof d.endOffset)){const I="number"==typeof i.startOffset?void 0:d.beginOffset,w="number"==typeof i.endOffset?void 0:d.endOffset;this._restoredTileInfos.set(d,this._createRestoredInfo(d,d.partitionableShapeInfo.width-(I||0)-("number"==typeof w?d.partitionableShapeInfo.width-w:0),I,w))}}}flushTileAsPreviously(i){i.isWidthFree?this._previouslyPickedTileInfos.set(i.tile,i):this._skippedTiles.add(i.tile)}tileIsFree(i){return(i.isFree||this._restoredTileStates.includes(i))&&!this._skippedTiles.has(i)}tileIsActive(i){return i.isActive}tileBeginNeighbours(i){return this.createRestoredTileInfo(i).canHaveBeginNeighbours?i._beginNeighbours:[]}tileEndNeighbours(i){return this.createRestoredTileInfo(i).canHaveEndNeighbours?i._endNeighbours:[]}createRestoredTileInfo(i){return this._createRestoredInfo(i)}_createRestoredInfo(i,d,I,w){const _=this._restoredTileInfos.get(i)||this._previouslyPickedTileInfos.get(i);if(_&&void 0===d)return _;if(_&&void 0!==d){const o="number"!=typeof I||"number"!=typeof _.beginOffset?void 0:i.beginOffset,s="number"!=typeof w||"number"!=typeof _.endOffset?void 0:i.endOffset;return _.width=i.partitionableShapeInfo.width-(o||0)-("number"==typeof s?i.partitionableShapeInfo.width-s:0),_.beginOffset=o,_.endOffset=s,_.isPartial="number"==typeof o||"number"==typeof s,_}return X.create(i,"number"==typeof i.beginOffset||"number"==typeof i.endOffset,i.partitionableShapeInfo.partitionableSpans.some(o=>o.isWindow),d||i.width,i.partitionableShapeInfo.height,"number"!=typeof I?i.beginOffset:I,"number"!=typeof w?i.endOffset:w)}createSelectionTileInfo(i,d,I=!1){return new v(this.createRestoredTileInfo(i),this.isDynamic,this._sectionIdx,d,I)}}(ye||(ye={})).TryPickNextResult=class i{};class Ae extends ye{constructor(){super(...arguments),this._tileStates=[]}get isDynamic(){return!1}clone(){const i=new Ae;return this._clone(i),i._sectionInfo=this._sectionInfo,i._tileStates=this._tileStates,i}_getTileState(i){return this._tileStates.find(d=>d.partitionableShapeInfo.uidInPackage().equals(i))||null}static create(i,d,I){const w=new Ae;return w._sectionInfo=d,w._sectionIdx=I,d.shapeUids.forEach(_=>{const o=i.tileStates.find(s=>s.partitionableShapeInfo.uidInPackage().equals(_));o&&w._tileStates.push(o)}),w}setupSelection(i,d,I,w,_,o){return i.pushNextTile(this.createSelectionTileInfo(d,!0)),!0}tryPickTile(i,d,I,w,_,o){return!(!this.tileIsFree(d)||!w.tileIsFree(d)||(o="boolean"==typeof o?o:this.tileBeginNeighbours(d).includes(i)||this.tileEndNeighbours(d).includes(i),w.pushNextTile(this.createSelectionTileInfo(d,o)),0))}}var Ee=P(14960);class q extends ye{constructor(){super(...arguments),this._itemStates=[],this._currentActiveItem=null,this._positiveStaticNeighbour=null,this._negativeStaticNeighbour=null,this._onlyOne
1Suggestion=!1,this._inheritDynamicItemIdx=null,this._activatedDynamicItemIdx=null,this._allowedDynamicItem0ByOtherItem={}}get isDynamic(){return!0}get maySuggestItems(){return"number"!=typeof this._activatedDynamicItemIdx}get activatedNotInheritedItemIdx(){return this._activatedDynamicItemIdx!==this._inheritDynamicItemIdx?this._activatedDynamicItemIdx:null}clone(){const i=new q;return this._clone(i),i._sectionInfo=this._sectionInfo,i._itemStates=this._itemStates,i._currentActiveItem=this._currentActiveItem,i._inheritDynamicItemIdx=this._inheritDynamicItemIdx,i._activatedDynamicItemIdx=this._activatedDynamicItemIdx,i._allowedDynamicItem0ByOtherItem=this._allowedDynamicItem0ByOtherItem,i._onlyOneSuggestion=this._onlyOneSuggestion,i._positiveStaticNeighbour=this._positiveStaticNeighbour,i._negativeStaticNeighbour=this._negativeStaticNeighbour,i}flush(){null!=this._activatedDynamicItemIdx&&(this._inheritDynamicItemIdx=this._activatedDynamicItemIdx)}_getTileState(i){let d=this._currentActiveItem.tryGetTileState(i);if(d)return d;for(const I of this._itemStates)if(I!==this._currentActiveItem&&(d=I.tryGetTileState(i),d))return d;return null}static create(i,d,I,w){const _=new q;_._sectionIdx=I,_._sectionInfo=d,_._onlyOneSuggestion=w,d.items.forEach((s,u)=>{const S=q.ItemNavigator.create(i,s,u);_._itemStates.push(S)}),_._allowedDynamicItem0ByOtherItem=i.allowedDynamicItem0ByOtherItem[I]||{},_._inheritDynamicItemIdx=i.dynamicSectionItemIdx[I],_._inheritDynamicItemIdx>=_._itemStates.length&&(_._inheritDynamicItemIdx=null),_._activatedDynamicItemIdx=_._inheritDynamicItemIdx;const o=_._itemStates[0];if(o.extremitiesOnCorridor.length){const s=o.extremitiesOnCorridor[0][0],[u,S]=s.flowingFromBeginToEndIsPositiveDirection?[s.beginNeighbours,s.endNeighbours]:[s.endNeighbours,s.beginNeighbours];_._positiveStaticNeighbour=S.find(T=>T.dynamicItemIdx<=0),_._negativeStaticNeighbour=u.find(T=>T.dynamicItemIdx<=0)}return _._currentActiveItem="number"==typeof _._inheritDynamicItemIdx?_._itemStates[_._inheritDynamicItemIdx]:_._itemStates[0],_}resetTo0(i){this._currentActiveItem=this._itemStates[0],i&&(this._inheritDynamicItemIdx=null),this._activatedDynamicItemIdx=null}selectItem(i){const d=this._itemStates[i];d&&(this._currentActiveItem=d,this._activatedDynamicItemIdx=i)}tileIsActive(i){const d=this._currentActiveItem.itemIdx;return d===i.dynamicItemIdx||0==i.dynamicItemIdx&&this._allowedDynamicItem0ByOtherItem[d]?.has(i)}setupSelection(i,d,I,w,_,o){if(this.maySuggestItems){if(_&&!o){let s={},u=[];if("boolean"!=typeof i.directionIsPositive)this._itemStates.forEach(S=>{if(0===S.itemIdx)return;const[T,F,$]=S.pickClosestFree(_,i,this);T&&u.push({tile:T,dist:F,isOnCorridor:$,itemIdx:S.itemIdx})}
1),this._onlyOneSuggestion&&u.length>0&&(u.sort((S,T)=>T.dist-S.dist),u=[u[0]]);else{let S=i.directionIsPositive?this._positiveStaticNeighbour:this._negativeStaticNeighbour;if(!S){const T=i.directionIsPositive===d.flowingFromBeginToEndIsPositiveDirection?[w.tileEndNeighbours(d),w.tileBeginNeighbours(d)]:[w.tileBeginNeighbours(d),w.tileEndNeighbours(d)],F=$=>$.find(ue=>w.tileIsActive(ue));S=F(T[0])||F(T[1])}this._itemStates.forEach(T=>{const F=T.peakCirculationNodePosition&&!e.xb(T.peakCirculationNodePosition)?e.TE(S?.coveredSpace,T.peakCirculationNodePosition):0;if(0===T.itemIdx)return;const[$,ue,Ie]=T.pickClosestFree(_,i,this);$&&u.push({tile:$,dist:F,isOnCorridor:Ie,itemIdx:T.itemIdx})}),this._onlyOneSuggestion&&u.length>0&&(u.sort((T,F)=>F.dist-T.dist),u=[u[0]])}return u.forEach(S=>{s[S.itemIdx]={tile:S.tile,isOnCorridor:S.isOnCorridor}}),i.suggestDynamicItems(this._sectionIdx,s),!0}{let s={},u=[];if("boolean"!=typeof i.directionIsPositive)this._itemStates.forEach(S=>{if(0===S.itemIdx)return;const T=S.extremitiesOnCorridor.filter($=>i.tileIsFree($[0])&&this.tileIsFree($[0]));if(0===T.length)return;const F=T.map($=>({dist:e.TE(d.coveredSpace,$[0].coveredSpace),tile:$}));F.sort(($,ue)=>$.dist-ue.dist),u.push({tile:F[0].tile[0],dist:F[0].dist,isOnCorridor:F[0].tile[1],itemIdx:S.itemIdx})}
1),this._onlyOneSuggestion&&u.length>0&&(u.sort((S,T)=>T.dist-S.dist),u=[u[0]]);else{let S=i.directionIsPositive?this._positiveStaticNeighbour:this._negativeStaticNeighbour;if(!S){const F=i.directionIsPositive===d.flowingFromBeginToEndIsPositiveDirection?[w.tileEndNeighbours(d),w.tileBeginNeighbours(d)]:[w.tileBeginNeighbours(d),w.tileEndNeighbours(d)],$=ue=>ue.find(Ie=>w.tileIsActive(Ie));S=$(F[0])||$(F[1])}let T=null;this._itemStates.forEach(F=>{const $=F.peakCirculationNodePosition&&!e.xb(F.peakCirculationNodePosition)?e.TE(S?.coveredSpace,F.peakCirculationNodePosition):0,ue=F.extremitiesOnCorridor.find(Ie=>!Ie[1])?.[0];ue&&i.tileIsFree(ue)&&(0===F.itemIdx?T={tile:ue,dist:$,isOnCorridor:!1,itemIdx:F.itemIdx}:u.push({tile:ue,dist:$,isOnCorridor:!1,itemIdx:F.itemIdx}))}),this._onlyOneSuggestion&&u.length>0&&(u.sort((F,$)=>$.dist-F.dist),u=[u[0]]),T&&(u=[T,...u])}return u.forEach(S=>{s[S.itemIdx]={tile:S.tile,isOnCorridor:S.isOnCorridor}}),i.suggestDynamicItems(this._sectionIdx,s),!0}}{let s=d,u=!1;if(_&&!this._currentActiveItem){const[S,T,F]=this._currentActiveItem.pickClosestFree(_,i,this);if(u=F,S)s=S;else{const $=this._currentActiveItem.tryGetTileState(s.partitionableShapeInfo.uidInPackage());if(!$)return!1;s=$}}else{const S=this._currentActiveItem.tryGetTileState(s.partitionableShapeInfo.uidInPackage());if(!S)return!1;s=S,u=this._currentActiveItem.extremitiesOnCorridor.find(T=>T[0]===s)?.[1]||!1}return i.pushNextTile(this.createSelectionTileInfo(s,!0,u)),!0}}tryPickTile(i,d,I,w,_,o){if(this.maySuggestItems){let s=this._itemStates.map((S,T)=>0===T?[null,0,T]:[...S.trySuggestTile(this,i,I,w,_),T]);s=s.filter(S=>
1null!==S[0]),this._onlyOneSuggestion&&s.length>0&&(s.sort((S,T)=>T[1]-S[1]),s=[s[0]]);let u={};return s.forEach(S=>{u[S[4]]={tile:S[0],isConsecutiveToPrevious:S[2],isOnCorridor:S[3]}}),w.suggestDynamicItems(this._sectionIdx,u),!0}return this._currentActiveItem.tryPickTile(this,i,d,I,w,_,o)}}!function(lt){class i{constructor(){this._tileStates=[],this._extremityTileStates=[],this._extremitiesOnCorridor=[]}get itemIdx(){return this._itemIdx}get extremitiesOnCorridor(){return this._extremitiesOnCorridor}get peakCirculationNodePosition(){return this._itemInfo.peakCirculationNodePosition}static create(I,w,_){const o=new i;return o._itemInfo=w,o._itemIdx=_,w.shapeUids.forEach(s=>{const u=I.tileStates.find(S=>S.partitionableShapeInfo.uidInPackage().equals(s));u&&o._tileStates.push(u)}),w.extremityShapeUids.forEach(s=>{const u=I.tileStates.find(S=>S.partitionableShapeInfo.uidInPackage().equals(s));u&&o._extremityTileStates.push(u)}),_>0?o._buildExtremitesOnCorridor():o._tileStates.forEach(s=>{s.partitionableShapeInfo.type===Ee.W5.CORNER&&o._extremitiesOnCorridor.push([s,!1])}),o}_buildExtremitesOnCorridor(){const I=this._itemInfo.peakCirculationNodePosition,w=this._itemInfo.corridorSpace;if(!I||e.xb(I)||!w||e.xb(w))return;const _=this._extremityTileStates.map(F=>({dist:e.TE(I,F.coveredSpace),tile:F}));if(_.sort((F,$)=>F.dist-$.dist),0===_.length)return;const o=_[0].tile,s=[o],u=e.Sc(o.coveredSpace);for(let F=1;F<_.length;F++){const $=_[F].tile,ue=e.uM(e.Sc($.coveredSpace),u);if(e.kK(w,ue)){s.push($);break}}const S=e.hq(w,5),T=s.map(F=>{const $=e.m0(F.coveredSpace,S);return{area:$?e.SO($):0,tile:F}});T.sort((F,$)=>$.area-F.area),T.forEach((F,$)=>{this._extremitiesOnCorridor.push([F.tile,0===$])})}tryGetTileState(I){return this._tileStates.find(w=>w.partitionableShapeInfo.uidInPackage().equals(I))||null}pickClosestFree(I,w,_){const s=this._tileStates.filter(u=>w.tileIsFree(u)&&_.tileIsFree(u)).map(u=>({dist:e.TE(I,u.coveredSpace),tile:u}));return s.sort((u,S)=>u.dist-S.dist),s.length>0?[s[0].tile,this._itemInfo.peakCirculationNodePosition&&!e.xb(this._itemInfo.peakCirculationNodePosition)?e.TE(I,this._itemInfo.peakCirculationNodePosition):0,this._extremitiesOnCorridor.find(u=>u[0]===s[0].tile)?.[1]||!1]:[null,1/0,!1]}trySuggestTile(I,w,_,o,s){const u=_.find(F=>this.tryGetTileState(F.partitionableShapeInfo.uidInPackage()));if(u)return I.tileIsFree(u)&&o.tileIsFree(u)?[u,this._itemInfo.peakCirculationNodePosition&&!e.xb(this._itemInfo.peakCirculationNodePosition)?e.TE(w.coveredSpace,this._itemInfo.peakCirculationNodePosition):0,!0,this._extremitiesOnCorridor.find(F=>F[0]===u)?.[1]||!1]:[null,0,!1,!1];const S=this._extremitiesOnCorridor.map(F=>({dist:e.TE(w.coveredSpace,F[0].coveredSpace),extTile:F}));S.sort((F,$)=>F.dist-$.dist);const T=S.length>0?S[0].extTile:null;return T&&I.tileIsFree(T[0])&&o.tileIsFree(T[0])?[T[0],this._itemInfo.peakCirculationNodePosition&&!e.xb(this._itemInfo.peakCirculationNodePosition)?e.TE(w.coveredSpace,this._itemInfo.peakCirculationNodePosition):0,!1,T[1]]:[null,0,!1,!1]}tryPickTile(I,w,_,o,s,u,S){if(_&&this.tryGetTileState(_.partitionableShapeInfo.uidInPackage()))return!(!I.tileIsFree(_)||!s.tileIsFree(_)||(S="boolean"==typeof S?S:I.tileBeginNeighbours(_).includes(w)||I.tileEndNeighbours(_).includes(w),s.pushNextTile(I.createSelectionTileInfo(_,S)),0));const T=o.find(ue=>this.tryGetTileState(ue.partitionableShapeInfo.uidInPackage()));if(T)return!(!I.tileIsFree(T)||!s.tileIsFree(T)||(S="boolean"==typeof S?S:I.tileBeginNeighbours(T).includes(w)||I.tileEndNeighbours(T).includes(w),s.pushNextTile(I.createSelectionTileInfo(T,S)),0));if(!this._extremitiesOnCorridor.some(ue=>ue[0]===w))return!1;const F=this._extremitiesOnCorridor.map(ue=>({dist:e.TE(w.coveredSpace,ue[0].coveredSpace),tile:ue}));F.sort((ue,Ie)=>Ie.dist-ue.dist);const $=F.length>0?F[0].tile:null;return!(!$||!I.tileIsFree($[0])||!s.tileIsFree($[0])||(s.pushNextTile(I.createSelectionTileInfo($[0],!1,$[1])),0))}}lt.ItemNavigator=i}(q||(q={}));class oe{constructor(){this._staticSubNavigators=[],this._dynamicSubNavigators=[],this._tileTargets=new x.me,this._hasSelectedDynamicItem=!1,this._canSelfReverse=!0,this._hasReversed=!1,this._willReverse=!1}get directLightInfoState(){return this._directLightInfoState}get currentSelection(){return this._selection}get hasReversed(){return this._hasReversed}clone(){const i=new oe;return i._directLightInfoState=this._directLightInfoState,i._staticSubNavigators=this._staticSubNavigators.map(d=>d.clone()),i._dynamicSubNavigators=this._dynamicSubNavigators.map(d=>
1d.clone()),i._tileTargets=new x.me,this._tileTargets.forEach((d,I)=>{i._tileTargets.set(I,(d.isDynamic?i._dynamicSubNavigators:i._staticSubNavigators)[d.sectionIdx])}),i._selection=this._selection.clone(),i._hasSelectedDynamicItem=this._hasSelectedDynamicItem,i._canSelfReverse=this._canSelfReverse,i._hasReversed=this._hasReversed,i._willReverse=this._willReverse,i}cloneFlushed(){const i=new oe;return i._directLightInfoState=this._directLightInfoState,i._staticSubNavigators=this._staticSubNavigators.map(d=>d.clone()),i._dynamicSubNavigators=this._dynamicSubNavigators.map(d=>d.clone()),i._tileTargets=new x.me,this._tileTargets.forEach((d,I)=>{i._tileTargets.set(I,(d.isDynamic?i._dynamicSubNavigators:i._staticSubNavigators)[d.sectionIdx])}),i._selection=this._selection.clone(),i._hasSelectedDynamicItem=this._hasSelectedDynamicItem,i._canSelfReverse=this._canSelfReverse,i._hasReversed=!1,i._willReverse=!1,this._selection.selectedTileInfos.forEach(d=>{i._tileTargets.get(d.tile.partitionableShapeInfo.uidInPackage())?.flushTileAsPreviously(d)}),i._selection.reset(),i._dynamicSubNavigators.forEach(d=>d.flush()),i}dispose(){}static create(i,d){const I=new oe;if(I._directLightInfoState=i,I._selection=new g(i,d.directionIsPositive),I._staticSubNavigators=i.directLight.staticSections.map((w,_)=>{const o=Ae.create(i,w,_);return w.shapeUids.forEach(s=>I._tileTargets.set(s,o)),o}),I._dynamicSubNavigators=i.directLight.dynamicSections.map((w,_)=>{const o=q.create(i,w,_,d.dynamicsOnlyOneSuggestion);return w.items.forEach(s=>{s.shapeUids.forEach(u=>I._tileTargets.set(u,o))}),o.resetTo0(!0),o.selectItem(0),o}),I._canSelfReverse=d.canAreaSelfReverse,d.movingInfo){const w=o=>{o.forEach(s=>{const S=I._tileTargets.get(s instanceof te.ph?s:s.tileUid);S&&S.restoreTile(s)})},_=o=>{Object.keys(o).forEach(s=>{const u=Number(s);(i.dynamicSectionLockers[u]||0)<=1&&I._dynamicSubNavigators[u].resetTo0(!0)})};if(d.movingInfo&&Array.isArray(d.movingInfo.supAreaInfos))d.movingInfo.supAreaInfos.forEach(o=>{o.supAreaFullUid.equals(i.directLight.fullUid)&&(_(o.dynamicSectionItemIdxes),w(o.tileInfos))});else{if(!d.movingInfo.supAreaFullUid.equals(i.directLight.fullUid))return I;_(d.movingInfo.dynamicSectionItemIdxes),w(d.movingInfo.tileInfos)}}return I}setStartingTile(i,d,I,w=!0){const _=this._tileTargets.get(i.partitionableShapeInfo.uidInPackage());return _&&_.tileIsFree(i)?(this._selection.needToPickDirection&&(this._selection._directionIsPositive=this.computeFlowDirection(this._selection.cursor||i)),_.setupSelection(this._selection,i,d,this,I,w),this._selection):this._selection}computeFlowDirection(i){const d=(S,T,F)=>{const $=e.lZ(S,F);let ue=0;ue=$&&!e.xb($)?e.$B(e.hX(e.$$(T,$))):e.$B(e.hX(e.$$(T,F)));const Ie=180*ue/Math.PI;return Ie>=45&&Ie<135?3:Ie>=135||Ie<-135?2:Ie>=-135&&Ie<-45?1:4},I=e.Sc(i.coveredSpace),w=i.coveredSpace,_=this.tileEndNeighbours(i).filter(S=>this.tileIsFree(S)),o=this.tileBeginNeighbours(i).filter(S=>this.tileIsFree(S));return(_.length?d(w,I,_[0].coveredSpace):-1)>=(o.length?d(w,I,o[0].coveredSpace):-1)?i.flowingFromBeginToEndIsPositiveDirection:!i.flowingFromBeginToEndIsPositiveDirection}tryPickNextAvailableTile(i){const d=I=>this._tryPickNextAvailableTile(I,i);return this._hasSelectedDynamicItem?(this._hasSelectedDynamicItem=!1,this._selection):(!this._willReverse&&d(this._selection.cursor)||(this._hasReversed||!this._willReverse&&!this._canSelfReverse?this._selection.abort():(this._hasReversed=!0,this._willReverse=!1,this._selection.reverse(),d(this._selection.cursor)?this._selection.markAsChangedFlow():this._selection.abort())),this._selection)}pickCorner(i){const d=I=>this._tryPickNextAvailableTile(I,i);if(this._selection.pushInCorner){this._hasSelectedDynamicItem=!1;let I=this._tileTargets.size+1,w=this._selection.cornerTileOptions[0];const _=w.tile.dynamicSectionIdx;for(;d(w.tile)&&I>0;)if(I--,w=this._selection.cornerTileOptions[this._selection.cornerTileOptions.length-1],!w||!w.isConsecutiveToPrevious||w.tile.dynamicSectionIdx!==_||!w.tile.isInCorner){this._selection.concludePushInCorner(1);break}this._selection.concludePushInCorner(0)}return this._selection}_tryPickNextAvailableTile(i,d){const I=this._selection.directionIsPositive!==i.flowingFromBeginToEndIsPositiveDirection||this._hasReversed?[this.tileBeginNeighbours(i),this.tileEndNeighbours(i)]:[this.tileEndNeighbours(i),this.tileBeginNeighbours(i)];if(1===this._selection.selectedTileInfos.length&&i.dynamicItemIdx>0){const o=I[0].some(u=>u.dynamicItemIdx===i.dynamicItemIdx);I[1].some(u=>u.dynamicItemIdx===i.dynamicItemIdx)&&!o&&I.reverse()}const w=()=>{const o=this._tileTargets.get(i.partitionableShapeInfo.uidInPackage());return!(!o||!o.isDynamic)&&o.tryPickTile(i,null,[],this._selection,d,!1)},_=o=>{const s=u=>{const S=this._tileTargets.get(u.partitionableShapeInfo.uidInPackage());return!!S&&S.tryPickTile(i,u,o,this._selection,d,!0)};if(!o.length)return w();for(const u of o)if(s(u))return!0;return!1};return _(I[0])||_(I[1])||w()}trySetwillReverse(){return!this._hasReversed&&(this._willReverse=!0,!0)}tryReverse(){return!this._hasReversed&&(this._hasReversed=!0,this._willReverse=!1,this._selection.reverse(),!0)}createTileInfo(i){const d=this._tileTargets.get(i.partitionableShapeInfo.uidInPackage());return d?d.createRestoredTileInfo(i):null}createSelectionTileInfo(i,d=!0){const I=this._tileTargets.get(i.partitionableShapeInfo.uidInPackage());return I?I.createSelectionTileInfo(i,d):null}selectDynamicItem(i,d,I,w,_){const o=this._dynamicSubNavigators[i];o&&(o.selectItem(d),this._selection.pushNextTile(o.createSelectionTileInfo(I,w||!1,_||!1)),this._hasSelectedDynamicItem=!0)}tileIsFree(i){const d=this._tileTargets.get(i.partitionableShapeInfo.uidInPackage());return d?d.tileIsFree(i)&&this._selection.tileIsFree(i):i.isFree&&this._selection.tileIsFree(i)}tileIsActive(i){const d=this._tileTargets.get(i.partitionableShapeInfo.uidInPackage());return d?d.tileIsActive(i):i.isActive}tileBeginNeighbours(i){const d=this._tileTargets.get(i.partitionableShapeInfo.uidInPackage());return d?d.tileBeginNeighbours(i):[]}tileEndNeighbours(i){const d=this._tileTargets.get(i.partitionableShapeInfo.uidInPackage());return d?d.tileEndNeighbours(i):[]}collectActivatedDynamicItems(){const i={};
1return this._dynamicSubNavigators.forEach(d=>{const I=d.activatedNotInheritedItemIdx;"number"==typeof I&&(i[d.sectionIdx]=I)}),i}}!function(lt){class i{constructor(){this.canAreaSelfReverse=!0,this.dynamicsOnlyOneSuggestion=!0,this.directionIsPositive=null,this.dynamicSetupPickFarest=!0}static createRegularDefault(I,w,_){const o=_||new i;return o.canAreaSelfReverse=!0,o.dynamicsOnlyOneSuggestion=!0,o.directionIsPositive=I,o.movingInfo=w,o}static createDepartmentDefault(I,w,_,o=!0){const s=_||new i;return s.canAreaSelfReverse=!1,s.dynamicsOnlyOneSuggestion=!0,s.directionIsPositive=I,s.movingInfo=w,s.dynamicSetupPickFarest=o,s}}lt.CreateOptions=i}(oe||(oe={}));class ee extends h{constructor(){super(...arguments),this._areaNavigatorHasChanged=!1,this._isAreaFormer=!1,this._shouldRevise=!1,this._previousAreaAndSelection=null}get directLightState(){return this._currentAreaNavigator.directLightInfoState}get currentAreaNavigator(){return this._currentAreaNavigator}get areaNavigatorHasChanged(){return this._areaNavigatorHasChanged}get previousAreaAndSelection(){return this._previousAreaAndSelection}get reachedDeadEnd(){return!this.isSuccess}get shouldProcessCorner(){return this._cornerTileOptions.length>0}get shouldRevise(){return this._shouldRevise}get shouldFlushCurrentArea(){return this._areaNavigatorHasChanged}get shouldStartOverFormerArea(){return this._areaNavigatorHasChanged&&this._isAreaFormer}get shouldStartOverCurrentArea(){return this.hasChangedFlow}get shouldBranch(){return!!this.dynamicItemOptions}get shouldStartOverCurrentModulePlacement(){return this._lastPickedTileInfo&&!this._lastPickedTileInfo.isConsecutiveToPrevious&&this._selectedTileInfos.length>1}clone(){const i=new ee;return this._clone(i),i._currentAreaNavigator=this._currentAreaNavigator,i._areaNavigatorHasChanged=this._areaNavigatorHasChanged,i._isAreaFormer=this._isAreaFormer,i._shouldRevise=this._shouldRevise,i._previousAreaAndSelection=this._previousAreaAndSelection,i}absorbAreaResult(i){this._previousAreaAndSelection={areaNavigator:this._currentAreaNavigator,selectedTileInfos:this._selectedTileInfos},this._absorb(i),this._areaNavigatorHasChanged=!1,this._isAreaFormer=!1,!i.hasRevised&&i.lastPickedTileInfo&&!i.lastPickedTileInfo.isConsecutiveToPrevious||this.shouldFlushCurrentArea?(this._shouldRevise=!0,i._hasRevised=!0):this._shouldRevise=!1,i.flushCorner()}setAreaNavigator(i,d=!1){this._areaNavigatorHasChanged=this._currentAreaNavigator&&this._currentAreaNavigator!==i,this._currentAreaNavigator=i,this._isAreaFormer=d}abort(){this._lastPickedTileInfo=null,this._dynamicItemOptions=null,this._cornerTileOptions=[],this._previousAreaAndSelection=null}markAsFlushedSupArea(){this._areaNavigatorHasChanged=!1}clearSelection(i=!1,d=!1){i?(this._lastPickedTileInfo=this._selectedTileInfos.length?this._selectedTileInfos[this._selectedTileInfos.length-1]:null,d&&null!==this._lastPickedTileInfo?this._selectedTileInfos=[this._lastPickedTileInfo]:d||(this._selectedTileInfos=[])):(this._selectedTileInfos=[],this._lastPickedTileInfo=null),this._dynamicItemOptions=null,this._cornerTileOptions=[],this._shouldRevise=!1}pushSelectedTileInfo(i){this._selectedTileInfos.push(i),this._lastPickedTileInfo=i,this._dynamicItemOptions=null,this._hasChangedFlow=!1}tryRestorePreviousAreaSelection(){return!!this._previousAreaAndSelection&&(this._currentAreaNavigator=this._previousAreaAndSelection.areaNavigator,this._selectedTileInfos=this._previousAreaAndSelection.selectedTileInfos,this._previousAreaAndSelection=null,!0)}collectReversedTileUntilNonConsecutive(){const i=this._selectedTileInfos.slice().reverse();let d=!0;const I=[];for(const w of i){if((!d||w.isConsecutiveToPrevious)&&I.push(w),!d&&!w.isConsecutiveToPrevious)break;d=!1}return this._currentAreaNavigator.currentSelection.restoreSelectionPartial(I,this._currentAreaNavigator),I}}class V{constructor(){this._areaNavigators=[],this._remainAreaLinks=[],this._triedExtremities=[],this._canCrossSupAreas=!0,this._hasReversed=!1}get currentSelection(){return this._currentSelection}get floorState(){return this._floorState}get currentAreaNavigator(){return this._currentAreaNavigator}static create(i,d){const I=new V;if(I._floorState=i,I._areaCreateOptions=d,I._currentSelection=new ee,I._canCrossSupAreas=d.canCrossSupAreas,I._hasReversed=!d.canFloorReverse,d.canCrossSupAreas){const w=new x.me;
1i.directLightAreaStates.forEach(_=>w.set(_.directLight.fullUid,_)),i.stackingPlanInfo.directLightAreaLinks.forEach(_=>{const o=w.get(_.directAreaA),s=w.get(_.directAreaB);if(o&&s){const u=o.tileStates.find(T=>T.partitionableShapeInfo.uidInPackage().equals(_.partitionableShapeA)),S=s.tileStates.find(T=>T.partitionableShapeInfo.uidInPackage().equals(_.partitionableShapeB));u&&S&&_.distance<=700&&I._remainAreaLinks.push([o,u,s,S,_.distance])}}),I._remainAreaLinks.sort((_,o)=>_[4]-o[4])}return I}setStartingTile(i,d,I,w){const _=oe.create(d,this._areaCreateOptions),o=_.setStartingTile(i,I,w,this._areaCreateOptions.dynamicSetupPickFarest);return this._areaNavigators.push(_),this._currentAreaNavigator=_,o.isSuccess&&(this._currentSelection.setAreaNavigator(_),this._currentSelection.absorbAreaResult(o)),o.isSuccess}selectDynamicItem(i,d,I,w,_){this._currentAreaNavigator.selectDynamicItem(i,d,I,w,_)}clone(){const i=new V;return i._floorState=this._floorState,i._areaCreateOptions=this._areaCreateOptions,i._remainAreaLinks=[...this._remainAreaLinks],i._triedExtremities=[...this._triedExtremities],i._canCrossSupAreas=this._canCrossSupAreas,i._areaNavigators=this._areaNavigators.map(d=>d.clone()),i._currentAreaNavigator=i._areaNavigators[this._areaNavigators.indexOf(this._currentAreaNavigator)],i._hasReversed=this._hasReversed,i._currentSelection=this._currentSelection.clone(),i._currentSelection._currentAreaNavigator=i._currentAreaNavigator,i}dispose(){}createFirstResult(){return this._currentSelection}tryPickNextAvailableTile(){const i=this._currentSelection;let d=this._currentAreaNavigator.tryPickNextAvailableTile(this._floorState.targetFloor);if(d.isSuccess)return d.cornerTileOptions.length>0&&(d=this._currentAreaNavigator.pickCorner(this._floorState.targetFloor)),i.absorbAreaResult(d),i;const I=(w,_=!0)=>{if(!w||!w.currentSelection.selectedTileInfos.length)return!1;const o=w.currentSelection.selectedTileInfos,s=this._tryPickNextDirectLightArea(w.directLightInfoState.directLight.fullUid,_?o[o.length-1].tile.partitionableShapeInfo.uidInPackage():o[0].tile.partitionableShapeInfo.uidInPackage(),_?o[0].tile.partitionableShapeInfo.uidInPackage():o[o.length-1].tile.partitionableShapeInfo.uidInPackage());if(s){const[u,S]=s;return i.absorbAreaResult(S),i.setAreaNavigator(u),!0}return!1};return this._canCrossSupAreas&&I(this._currentAreaNavigator)?i:!this._hasReversed&&this._areaNavigators[0].tryReverse()?(this._currentAreaNavigator=this._areaNavigators[0],i.absorbAreaResult(this._areaNavigators[0].currentSelection),i.setAreaNavigator(this._currentAreaNavigator,!0),this._hasReversed=!0,i):(!this._hasReversed&&(this._hasReversed=!0,this._canCrossSupAreas&&I(this._areaNavigators[0],!1))||i.abort(),i)}checkTileIsCloseEnoughToCursor(i){return!!this._currentAreaNavigator?.currentSelection?.cursor&&e.TE(this._currentAreaNavigator.currentSelection.cursor.coveredSpace,i.coveredSpace)<=700}_tryPickNextDirectLightArea(i,d,I){const w=(Ue,Re)=>{const ge=De=>{if(!(De[0].directLight.fullUid.equals(Ue)&&De[1].partitionableShapeInfo.uidInPackage().equals(Re)||De[2].directLight.fullUid.equals(Ue)&&De[3].partitionableShapeInfo.uidInPackage().equals(Re)))return!1;const rt=De[0].directLight.fullUid.equals(Ue)?De[2]:De[0],Ge=De[0].directLight.fullUid.equals(Ue)?De[3]:De[1],mt=this._areaNavigators.some(kt=>kt.directLightInfoState===rt&&kt.tileIsFree(Ge)),dt=mt||this._areaNavigators.some(kt=>kt.directLightInfoState===rt);return!(dt&&!mt||!dt&&!Ge.isFree)};return this._remainAreaLinks.find(De=>ge(De))};let _=w(i,d);if(_||(_=w(i,I)),!_)for(const[Ue,Re]of this._triedExtremities)if(_=w(Ue,Re),_){i=Ue,d=Re;break}if(this._triedExtremities.push([i,d]),!_)return null;this._remainAreaLinks.splice(this._remainAreaLinks.indexOf(_),1);const[o,s,u,S,T]=_;let F,$;o.directLight.fullUid.equals(i)?(F=u,$=S):(F=o,$=s),this._triedExtremities.push([F.directLight.fullUid,$.partitionableShapeInfo.uidInPackage()]);const Ie=this._areaNavigators.slice().reverse().find(Ue=>Ue.directLightInfoState===F);let Pe=null;Pe=Ie?Ie.cloneFlushed():oe.create(F,this._areaCreateOptions),Pe._hasReversed=!0;const Ce=Pe.setStartingTile($,null,void 0,this._areaCreateOptions.dynamicSetupPickFarest);return Ce.isSuccess?(this._areaNavigators.push(Pe),this._currentAreaNavigator=Pe,[Pe,Ce]):(Pe.dispose(),null)}collectDynamicActivations(i=!0){const d=new Map;
1return this._areaNavigators.forEach(I=>{const w=I.collectActivatedDynamicItems();if(!i&&0===Object.keys(w).length)return;let _=d.get(I.directLightInfoState.directLight)||{};Object.keys(w).forEach(o=>{const s=parseInt(o);_[s]=_[s]||w[s]}),d.set(I.directLightInfoState.directLight,_)}),d}}!function(lt){class i extends oe.CreateOptions{constructor(){super(...arguments),this.canCrossSupAreas=!0,this.canFloorReverse=!0}static createRegularDefault(I,w){const _=new i;return oe.CreateOptions.createRegularDefault(I,w,_),_.canCrossSupAreas=!1,_.canFloorReverse=!1,_}static createDepartmentDefault(I,w,_,o=!0){const s=new i;return oe.CreateOptions.createDepartmentDefault(I,w,s,o),s.canCrossSupAreas=!0,s.canFloorReverse=!1,s}static createDepartmentDefaultFromStacking(I,w){return i.createDepartmentDefault(I,w)}}lt.CreateOptions=i}(V||(V={}));class U{get firstNavigator(){return this._floorNavigators[0]}static create(i,d){return new U(i,d)}constructor(i,d){this._floorState=i,this._options=d,this._floorNavigators=[]}trySetStartingTile(i,d,I,w){const _=V.create(this._floorState,this._options),o=_.setStartingTile(i,d,I,w);return this._floorNavigators.push(_),o}dispose(){this._floorNavigators.forEach(i=>i.dispose()),this._floorNavigators=[]}}class re{constructor(){this._extremityUidFlowMapMap=new Map}get extremityUidFlowMapMap(){return this._extremityUidFlowMapMap}get isEmpty(){return 0===this._extremityUidFlowMapMap.size}pickFlowMap(i){return this._extremityUidFlowMapMap.get(i)??null}clone(){const i=new re;return i._extremityUidFlowMapMap=new Map(Array.from(this._extremityUidFlowMapMap.entries()).map(([d,I])=>[d,I.clone()])),i}blit(i,d,I,w){const _=new Map;for(const[o,s]of this._extremityUidFlowMapMap)s.blit(d,I,s===i,w)&&_.set(o,s);this._extremityUidFlowMapMap=_}blitAndMaySplitSections(i,d,I,w,_){const o=new Map;for(const[s,u]of this._extremityUidFlowMapMap)u.blitAndMaySplitSections(d,I,w,u===i,_)&&o.set(s,u);this._extremityUidFlowMapMap=o}}var ae=P(96038);class ve{constructor(){this._reqTile=null,this._isBeginToEnd=!0}get reqTile(){return this._reqTile}get isBeginToEnd(){return this._isBeginToEnd}set reqTile(i){this._reqTile=i}set isBeginToEnd(i){this._isBeginToEnd=i}get isCorner(){return this._reqTile.tile.partitionableShapeInfo.type==ae.W.CORNER}clone(){const i=new ve;return i._reqTile=this._reqTile.clone(),i._isBeginToEnd=this._isBeginToEnd,i}build(i){const d={width:this._reqTile.width,height:this._reqTile.height,posts:[],hasWindow:this._reqTile.isWindow,isInCorner:this._reqTile.tile.isInCorner,idx:i.currIdx++,cornerIsInterior:this._reqTile.tile.cornerIsInterior,targetTile:this._reqTile,isBeginToEnd:this._isBeginToEnd,targetFlowMapTile:this,sideIsStart:this._reqTile.tile.sideIsStart,distanceToEntrance:0};if(this._reqTile.isPartial){const I=this._reqTile.tile.partitionableShapeInfo.width,w=this._reqTile.getPostsInRange(0,this._reqTile.width,this._isBeginToEnd);for(const _ of w)d.posts.push({x:(this._isBeginToEnd?_.bl:I-_.el)-1.75,y:_.y-.75,width:_.length+3.5,height:_.height+1.5})}else for(const I of this._reqTile.tile.postInfos)d.posts.push({x:(this._isBeginToEnd?I.x:this._reqTile.width-I.x-I.length)-1.75,y:I.y-.75,width:I.length+3.5,height:I.height+1.5});return d}buildForClaude(i,d){const I=d?!this._isBeginToEnd:this._isBeginToEnd,w={idx:i.tileGidx,posts:[],width:this._reqTile.width,height:this._reqTile.height,isInCorner:this._reqTile.tile.isInCorner,cornerIsInterior:this._reqTile.tile.cornerIsInterior,targetTile:this._reqTile,isBeginToEnd:I,hasWindow:this._reqTile.isWindow,targetFlowMapTile:this,isReceptionFriendly:this._reqTile.tile.partitionableShapeInfo.isReceptionFriendly,centroid:e.Sc(this._reqTile.tile.coveredSpace),distanceToEntrance:0,sideIsStart:null};if(this._reqTile.isPartial){const _=this._reqTile.tile.partitionableShapeInfo.width,o=this._reqTile.getPostsInRange(0,this._reqTile.width,I);for(const s of o)w.posts.push({x:(I?s.bl:_-s.el)-1.75,y:s.y-.75,width:s.length+3.5,height:s.height+1.5})}else for(const _ of this._reqTile.tile.postInfos)w.posts.push({x:(I?_.x:this._reqTile.width-_.x-_.length)-1.75,y:_.y-.75,width:_.length+3.5,height:_.height+1.5});return i.tileGidx++,w}trySplitForClaude(i,d){if(!this.isCorner)return null;const I=this._isBeginToEnd,w=d?!I:I,_="boolean"==typeof this._reqTile.tile.sideIsStart&&this._reqTile.tile.sideIsStart!==w?null:{idx:i.tileGidx,posts:[],width:w?this._reqTile.tile.startWidth:this._reqTile.tile.endWidth,height:w?this._reqTile.tile.startHeight:this._reqTile.tile.endHeight,sideIsStart:w,isInCorner:!0,cornerIsInterior:this._reqTile.tile.cornerIsInterior,targetTile:this._reqTile,isBeginToEnd:I,hasWindow:!0,targetFlowMapTile:this,isReceptionFriendly:this._reqTile.tile.partitionableShapeInfo.isReceptionFriendly,centroid:e.Sc(this._reqTile.tile.coveredSpace),distanceToEntrance:0};if(_){const o=w?this._reqTile.tile.startWidth:this._reqTile.tile.endWidth;
1if(this._reqTile.isPartial){const s=this._reqTile.getPostsInRange(0,this._reqTile.width,I,w);for(const u of s)_.posts.push({x:(d?o-u.el:u.bl)-1.75,y:u.y-.75,width:u.length+3.5,height:u.height+1.5})}else{const s=w?this._reqTile.tile.postInfos:this._reqTile.tile.endPostInfos;for(const u of s)_.posts.push({x:(d?o-u.x-u.length:u.x)-1.75,y:u.y-.75,width:u.length+3.5,height:u.height+1.5})}i.tileGidx++}return[_,w?this._reqTile.tile.startSideWidth:this._reqTile.tile.endSideWidth]}blit(i,d){if(!i.isPartial)return!1;const w=this.computeUsedTile(i,d).asConsumed();return this._reqTile=w,w.width>0}_convertXToOffsetFromOtherSide(i,d){if(d.fromOtherSide&&"boolean"==typeof d.tile.sideIsStart){const I=d.tile.targetTile.tile,[w,_]=d.tile.sideIsStart?[I.startWidth,I.endSideWidth]:[I.endWidth,I.startSideWidth],o=w-_;return console.debug("convertXToOffsetFromOtherSide",{x:i,ut:d,ori_width:w,delta:o,oth_side:_}),[w,o,_]}return[0,0,0]}xToOffset(i,d){const I=d.tile.sideIsStart;let[w,_,o]=this._convertXToOffsetFromOtherSide(i,d),s=d.tile.isBeginToEnd;if(console.debug("xToOffset",{x:i,ut:d,ori_width:w,oth_delta:_,oth_side:o,bte:s,sideIsStart:I}),"boolean"==typeof I&&(w=w||d.tile.width,I?(!0===d.tile.inTilerangePosition||!s)&&(i+=_):((!0===d.tile.inTilerangePosition||s)&&(i+=_),s=!s,i=w-i)),s){let u=this._reqTile.getClosestFittingOffset(i,!0,!0,I);return null==u&&(console.debug("xToOffset fallback to 0"),u=this._reqTile.getClosestFittingOffset(0,!0,!1,I),null==u)?(console.debug("xToOffset second fallback to 0"),0):(console.debug("xToOffset final result from front (B -> E fwd)",{x:i,res:u}),u)}{let u=this._reqTile.getClosestFittingOffset(i,!1,!0,I);return null==u&&(console.debug("xToOffset fallback to 0 (reverse)"),u=this._reqTile.getClosestFittingOffset(0,!1,!1,I),null==u)?(console.debug("xToOffset second fallback to 0 (reverse)"),0):(console.debug("xToOffset final result from front (E -> B rev)",{x:i,res:u}),u)}}computeUsedTile(i,d=!0){if(!i.isPartial||i.tile.sus)return this._reqTile;const I=i.tile.targetTile.clone();let w=i.x??0,_=w+(i.width??i.partialOrWidth),[o,s,u]=this._convertXToOffsetFromOtherSide(w,i);const S=i.tile.sideIsStart;I.sideIsStart=S;let T=i.tile.isBeginToEnd;console.debug("computeUsedTile",{id:I.tile.elementId,ut:i,owns:d,ori_width:o,oth_delta:s,oth_side:u,bte:T,sideIsStart:S}),d||(T=!T);let F=w>1,$=_<i.tile.width-1;if(console.debug("computeUsedTile before side_is_start check",{id:I.tile.elementId,b1:w,b2:_,needs_b1:F,needs_b2:$}),"boolean"==typeof S&&(o=o||i.tile.width,S?!0!==i.tile.inTilerangePosition&&T?$=!0:(w+=s,_+=s,F=!0,console.debug("side_is_start True and in_tilerange_position True, adjusted b1 and b2",{id:I.tile.elementId,b1:w,b2:_})):(console.debug("side_is_start False and not in_tilerange_position, bte",{id:I.tile.elementId,bte:T}),!0===i.tile.inTilerangePosition||T?(F=!0,w+=s,_+=s,console.debug("side_is_start False and in_tilerange_position True, adjusted b1 and b2",{id:I.tile.elementId,b1:w,b2:_})):$=!0,T=!T,w=o-w,_=o-_)),console.debug("computeUsedTile after side_is_start check",{id:I.tile.elementId,b1:w,b2:_,needs_b1:F,needs_b2:$}),F&&$)T?(I.endOffset=I.getClosestFittingOffset(w,!0,!0,S),I.beginOffset=I.getClosestFittingOffset(_,!0,!0,S),console.debug("computeUsedTile Set beginOffset and endOffset (B -> E fwd) to",{id:I.tile.elementId,beginOffset:I.beginOffset,endOffset:I.endOffset})):(I.beginOffset=I.getClosestFittingOffset(w,!1,!0,S),I.endOffset=I.getClosestFittingOffset(_,!1,!0,S),console.debug("computeUsedTile Set beginOffset and endOffset (E -> B rev) to",{beginOffset:I.beginOffset,endOffset:I.endOffset}));else if(F)if(T){const ue=I.getClosestFittingOffset(w,!0,!0,S);I.endOffset=ue,console.debug("computeUsedTile Set b1 to endOffset (B -> E fwd) to",{id:I.tile.elementId,offset:ue})}else{const ue=I.getClosestFittingOffset(w,!1,!0,S);I.beginOffset=ue,console.debug("computeUsedTile Set b2 to beginOffset (E -> B rev) to",{id:I.tile.elementId,offset:ue})}else if(T){const ue=I.getClosestFittingOffset(_,!0,!0,S);I.beginOffset=ue,console.debug("computeUsedTile Set b2 to beginOffset (B -> E fwd) to",{id:I.tile.elementId,offset:ue})}else{const ue=I.getClosestFittingOffset(_,!1,!0,S);I.endOffset=ue,console.debug("computeUsedTile Set b2 to endOffset (E -> B rev) to",{id:I.tile.elementId,offset:ue})}return console.debug("computeUsedTile Final beginOffset and endOffset",{id:I.tile.elementId,res:I,beginOffset:I.beginOffset,endOffset:I.endOffset}),I}
1OLDcomputeUsedTile(i,d=!0){if(!i.isPartial)return this._reqTile;const I=i.tile.targetTile.clone();let w=i.x||0,_=(w||0)+i.partialOrWidth;if(!d&&(w||_)&&(w=i.tile.width-w,_=i.tile.width-_,[w,_]=[_,w]),i.tile.isBeginToEnd)if(null==i.x||i.x<=0){const o=I.getClosestFittingOffset(_,!0,!0);I.beginOffset=o}else{const o=I.getClosestFittingOffset(w,!0,!0);I.endOffset=o}else if(null==i.x||i.x<=0){const o=I.getClosestFittingOffset(_,!1,!0);I.endOffset=o}else{const o=I.getClosestFittingOffset(w,!1,!0);I.beginOffset=o}return I}}class be{constructor(){this._tiles=[],this._tileUids=new x.bI,this._usedDynamics=new Map,this._receptionFriendlyIdx=-1}get tiles(){return this._tiles}set tiles(i){this._tiles=i}get usedDynamics(){return this._usedDynamics}set usedDynamics(i){this._usedDynamics=i}get isReceptionFriendly(){return this._receptionFriendlyIdx>=0}get receptionFriendlyTile(){return this._receptionFriendlyIdx>=0&&this._receptionFriendlyIdx<this._tiles.length?this._tiles[this._receptionFriendlyIdx]:null}get receptionFriendlyTileIdx(){return this._receptionFriendlyIdx}set receptionFriendlyIdx(i){this._receptionFriendlyIdx=i}clone(){const i=new be;return i._tiles=this._tiles.map(d=>d.clone()),i._tileUids=this._tileUids,i._usedDynamics=new Map(this._usedDynamics),i._receptionFriendlyIdx=this._receptionFriendlyIdx,i}build(i){if(!this._tiles.length)return null;const d=this._tiles[0],I=this._tiles[this._tiles.length-1];return{startIsPartial:d.reqTile.isPartial,endIsPartial:I.reqTile.isPartial,tiles:this._tiles.map(w=>w.build(i)),startOnWall:!d.reqTile.tileSelectionInfo.isOnCorridor,endOnWall:!I.reqTile.tileSelectionInfo.isOnCorridor}}buildForClaude(i,d,I=null){if(I=I??this._tiles,d&&(I=I.reverse()),!I.length)return{startIsPartial:!1,endIsPartial:!1,tiles:[],startOnWall:!0,endOnWall:!0};const w=I[0],_=I[I.length-1],o=new Set(I.map(u=>u?.reqTile?.tile).filter(Boolean)),s=u=>{try{const S=u?.reqTile?.tile;return!!S&&[...S.beginNeighbours??[],...S.endNeighbours??[]].filter(F=>F&&!o.has(F)).some(F=>F.isActive&&!F.isFree)}catch{return!1}};return{startIsPartial:w.reqTile.isPartial,endIsPartial:_.reqTile.isPartial,tiles:I.map(u=>u.buildForClaude(i,d)),startOnWall:!w.reqTile.tileSelectionInfo.isOnCorridor&&!s(w),endOnWall:!_.reqTile.tileSelectionInfo.isOnCorridor&&!s(_)}}pickUsedTiles(i){const d=[];for(const I of i)this._tileUids.has(I.tile.targetTile.tile.partitionableShapeInfo.uidInPackage())&&d.push(I);return d}blit(i,d,I){if(!d&&!this.removeDynamics(I,!1))return!1;const w=new Map;for(const o of i)w.set(o.tile.targetTile.tile.partitionableShapeInfo.uidInPackage(),o);const _=[];for(const o of this._tiles){const s=w.get(o.reqTile.tile.partitionableShapeInfo.uidInPackage())??null;if(null!==s){const u=o.blit(s,d);_.push(u?o:null)}else _.push(o)}return this._tiles=this._cleanNewTiles(_),this._updateUids(),this._tiles.length>0}blitAndMaySplit(i,d,I){const w=new Map;for(const u of i)w.set(u.tile.targetTile.tile.partitionableShapeInfo.uidInPackage(),u);let _=this._tiles.length,o=-1;const s=[];for(let u=0;u<this._tiles.length;u++){const S=this._tiles[u],T=w.get(S.reqTile.tile.partitionableShapeInfo.uidInPackage())??null;null!==T?(u<_&&(_=u),u>o&&(o=u),S.blit(T,d)?s.push(S):s.push(null)):s.push(S)}if(_<=o){const u=this._cleanNewTiles(s.slice(0,_)),S=this._cleanNewTiles(s.slice(o+1)),T=ue=>{const Ie=new Map;for(const Pe of ue)Pe.reqTile.tile.dynamicSectionIdx>=0&&Ie.set(Pe.reqTile.tile.dynamicSectionIdx,Pe.reqTile.tile.dynamicItemIdx);return Ie};let F=new be;F._tiles=u,F._usedDynamics=T(u);let $=new be;return $._tiles=S,$._usedDynamics=T(S),F._tiles.length&&(d||F.removeDynamics(I,!1))?F._updateUids():F=null,$._tiles.length&&(d||$.removeDynamics(I,!1))?$._updateUids():$=null,[F,$]}{const u=this._cleanNewTiles(s);return u.length?(this._tiles=u,d||this.removeDynamics(I)?(this._updateUids(),[this]):[]):[]}}_cleanNewTiles(i){const d=i.length-1;for(let I=0;I<i.length;I++)null!==i[I]&&(0===I||null===i[I-1])&&(I===d||null===i[I+1])&&(i[I]=null);return i.filter(I=>null!==I)}removeDynamics(i,d=!0){const I=new Set;for(const[w,_]of i){const o=this._usedDynamics.get(w);void 0!==o&&o!==_&&I.add(w)}return!I.size||(this._tiles=this._tiles.filter(w=>!I.has(w.reqTile.tile.dynamicSectionIdx)),d&&this._updateUids(),this._tiles.length>0)}_updateUids(){this._tileUids=new x.bI(this._tiles.map(i=>i.reqTile.tile.partitionableShapeInfo.uidInPackage()))}}class Le{constructor(){this._tileRanges=[],this._isAtMapExtremity=!1,this._initialFirstTileUid=null,this._initialLastTileUid=null,this._receptionFriendly
1RangeIdxes=[],this._isLoop=!1}get tileRanges(){return this._tileRanges}set tileRanges(i){this._tileRanges=i}get isAtMapExtremity(){return this._isAtMapExtremity}set isAtMapExtremity(i){this._isAtMapExtremity=i}get isReceptionFriendly(){return this._receptionFriendlyRangeIdxes.length>0}get initialFirstTileUid(){return this._initialFirstTileUid}set initialFirstTileUid(i){this._initialFirstTileUid=i}get initialLastTileUid(){return this._initialLastTileUid}set initialLastTileUid(i){this._initialLastTileUid=i}set receptionFriendlyRangeIdxes(i){this._receptionFriendlyRangeIdxes=i}get isLoop(){return this._isLoop}set isLoop(i){this._isLoop=i}isEquivalent(i){return this._initialFirstTileUid.equals(i._initialFirstTileUid)||this._initialLastTileUid.equals(i._initialLastTileUid)||this._initialFirstTileUid.equals(i._initialLastTileUid)||this._initialLastTileUid.equals(i._initialFirstTileUid)}clone(){const i=new Le;return i._tileRanges=this._tileRanges.map(d=>d.clone()),i._isAtMapExtremity=this._isAtMapExtremity,i._initialFirstTileUid=this._initialFirstTileUid,i._initialLastTileUid=this._initialLastTileUid,i._receptionFriendlyRangeIdxes=this._receptionFriendlyRangeIdxes,i._isLoop=this._isLoop,i}getReceptionFriendlyTileRanges(){return this._receptionFriendlyRangeIdxes.map(i=>this._tileRanges[i])}has(i){return this._tileRanges.some(d=>d._tileUids.has(i))}build(){let i={currIdx:0};return this._tileRanges.map(d=>d.build(i))}buildForClaude(i){const d=[],I={};let w={tileGidx:0},_=[0,0],o=!1;const s=[];let u=0,S=!1,T=!1;for(let ue=0;ue<this._tileRanges.length;ue++){const Ie=this._tileRanges[ue];let Pe=!1,Ce=!1;T&&Ie.tiles[0].isCorner&&(d.push({startIsPartial:!1,endIsPartial:!1,tiles:[],startOnWall:!0,endOnWall:!0}),u++),Ie.tiles[0].isCorner&&(s.push({trangeIdx:ue+u,trange:Ie,isBegin:!0,cornerTile:Ie.tiles[0]}),Pe=!0,0===ue&&(S=!0)),Ie.tiles[Ie.tiles.length-1].isCorner&&Ie.tiles.length>1&&(s.push({trangeIdx:ue+u,trange:Ie,isBegin:!1,cornerTile:Ie.tiles[Ie.tiles.length-1]}),Ce=!0),T=Ie.tiles[Ie.tiles.length-1].isCorner;const ge=Ie.tiles.slice(Pe?1:0,Ie.tiles.length-(Ce?1:0));d.push(Ie.buildForClaude(w,!1,ge))}const F=this._isLoop;F&&S&&T&&(d.push({startIsPartial:!1,endIsPartial:!1,tiles:[],startOnWall:!0,endOnWall:!0}),u++);const $=d.length;for(let ue=0;ue<s.length;ue++){const Ie=s[ue],Pe=Ie.trangeIdx,Ue=Ie.isBegin,Re=Ie.cornerTile,ge=Re.trySplitForClaude(w,!1);if(null===ge)continue;ge[0]&&(ge[0].inTilerangePosition=Ue);const De=Ue?[Pe>0?[Pe-1,!1,!0,ge[0]?[ge[0]]:[]]:F?[$-1,!1,!0,ge[0]?[ge[0]]:[]]:null,[Pe,!0,ge[1],[]]]:[[Pe,!1,!0,ge[0]?[ge[0]]:[]],Pe<$-1?[Pe+1,!0,ge[1],[]]:F?[0,!0,ge[1],[]]:null];I[ue]||(I[ue]=[]),I[ue].push({dynamicSectionIdx:ue,dynamicItemIdx:0,tileRangeExtraInfos:De.filter(Ge=>null!==Ge)});const He=Re.trySplitForClaude(w,!0);if(null===He)continue;He[0]&&(He[0].inTilerangePosition=!Ue);const rt=Ue?[[Pe,!0,!0,He[0]?[He[0]]:[]],Pe>0?[Pe-1,!1,He[1],[]]:F?[$-1,!1,He[1],[]]:null]:[Pe<$-1?[Pe+1,!0,!0,He[0]?[He[0]]:[]]:F?[0,!0,!0,He[0]?[He[0]]:[]]:null,[Pe,!1,He[1],[]]];I[ue]||(I[ue]=[]),I[ue].push({dynamicSectionIdx:ue,dynamicItemIdx:1,tileRangeExtraInfos:rt.filter(Ge=>null!==Ge)}),Re.reqTile.tile===i&&(_=[0,0,ue],o=!0)}if(!o&&i)e:for(let ue=0,Ie=d.length;ue<Ie;ue++){const Pe=d[ue];for(let Ce=0,Ue=Pe.tiles.length;Ce<Ue;Ce++)if(Pe.tiles[Ce].targetTile?.tile===i){_=[ue,Ce],o=!0;break e}}return{tileRanges:d,corners:I,cursorTile:_,isLoop:F}}blit(i,d,I){const w=[];for(const _ of this._tileRanges){const o=_.pickUsedTiles(i);o.length?_.blit(o,d,I)&&w.push(_):(d||_.removeDynamics(I))&&w.push(_)}return this._tileRanges=w,this._tileRanges.length>0}blitAndMaySplit(i,d,I,w){const _=(s,u)=>{const S=[];if(s.length){const T=new Le;T._tileRanges=s,T._isAtMapExtremity=this._isAtMapExtremity,T._initialFirstTileUid=s[0].tiles[0].reqTile.tile.partitionableShapeInfo.uidInPackage(),T._initialLastTileUid=s[s.length-1].tiles[s[s.length-1].tiles.length-1].reqTile.tile.partitionableShapeInfo.uidInPackage(),S.push(T)}if(u.length){const T=new Le;T._tileRanges=u,T._isAtMapExtremity=this._isAtMapExtremity&&!s.length,T._initialFirstTileUid=u[0].tiles[0].reqTile.tile.partitionableShapeInfo.uidInPackage(),T._initialLastTileUid=u[u.length-1].tiles[u[u.length-1].tiles.length-1].reqTile.tile.partitionableShapeInfo.uidInPackage(),S.push(T)}return S},o=s=>{const u=this._tileRanges.indexOf(s),S=s.blitAndMaySplit(i,!0,w);let T,F;Array.isArray(S)&&2===S.length&&(null===S[0]||S[0]instanceof be)&&(null===S[1]||S[1]instanceof be)?[T,F]=S:(T=S.length>0?S[0]:null,F=null);const $=this._tileRanges.slice(0,u),ue=this._tileRanges.slice(u+1);return null!==T&&$.push(T),null!==F&&ue.unshift(F),_($,ue)};if(I)return o(d);{const s=this._tileRanges.find(u=>u.pickUsedTiles(i).length>0)??null;return null!==s?o(s):[this]}}}class Ye{constructor(){this._sections=[],this._isReceptionFriendly=!1}get sections(){return this._sections}set sections(i){this._sections=i}get isReceptionFriendly(){return this._isReceptionFriendly}set isReceptionFriendly(i){this._isReceptionFriendly=i}clone(){const i=new Ye;return i._sections=this._sections.map(d=>d.clone()),i._isReceptionFriendly=this._isReceptionFriendly,i}blit(i,d,I,w){if(I){if(!d.blit(i,!0,w)){const _=this._sections.indexOf(d);_>=0&&this._sections.splice(_,1)}}else{const _=this._sections.find(o=>o.isEquivalent(d))??null;if(null!==_&&!_.blit(i,!1,w)){const o=this._sections.indexOf(_);o>=0&&this._sections.splice(o,1)}}return this._sections.length>0}blitAndMaySplitSections(i,d,I,w,_){if(w){const o=this._sections.indexOf(d),s=d.blitAndMaySplit(i,I,!0,_);this._sections.splice(o,1,...s)}else{const o=this._sections.find(s=>s.isEquivalent(d))??null;if(null!==o){const s=this._sections.indexOf(o),u=o.blitAndMaySplit(i,I,!1,_);this._sections.splice(s,1,...u)}}return this._sections.length>0}}const Te=!0;
1class Je extends E{constructor(i,d=!1,I={fnav:null}){super(),this._hasStarted=!1,this._pickedTileRanges=[],this._canCrossCorridors=!1,this._rangeCurrentIdx=0,this._resHolder=i,this._canCrossCorridors=d,this._lastFloorNavHolder=I}buildInfo(){return[null,0,null,null]}clone(){const i=new Je(this._resHolder);return i._hasStarted=this._hasStarted,i._pickedTileRanges=this._pickedTileRanges.map(d=>[...d]),i._rangeCurrentIdx=this._rangeCurrentIdx,i._canCrossCorridors=this._canCrossCorridors,i._lastFloorNavHolder=this._lastFloorNavHolder,this._clone(i),i}dispose(){super.dispose()}step(i){if(i||this._resHolder.tiles.length)return{type:"drop"};{let d=this._hasStarted?this._currentNavigator.tryPickNextAvailableTile():this._currentNavigator.createFirstResult();this._hasStarted=!0;let I=500;const w=s=>{if(s.hasChangedFlow&&(this._resHolder.hasChandedFlow=!0),s.reachedDeadEnd||s.shouldFlushCurrentArea||s.shouldStartOverCurrentModulePlacement){let u,S;if(s.shouldFlushCurrentArea?(u=s.previousAreaAndSelection.selectedTileInfos,S=s.previousAreaAndSelection.areaNavigator):(u=s.selectedTileInfos,S=s.currentAreaNavigator),s.shouldStartOverCurrentModulePlacement){const T=u.slice(this._rangeCurrentIdx,-1);T.length&&(this._pickedTileRanges.push(T),this._rangeCurrentIdx=u.length-1,s.clearSelection(!0,!0))}else{const T=u.slice(this._rangeCurrentIdx);T.length&&(this._pickedTileRanges.push(T),this._rangeCurrentIdx=u.length,s.clearSelection(!0))}if(s.reachedDeadEnd||s.shouldFlushCurrentArea||s.shouldStartOverCurrentModulePlacement&&!this._canCrossCorridors){const T=s.shouldFlushCurrentArea;return T&&s.markAsFlushedSupArea(),[!1,this._flushRange(T)]}return[!0,{type:"keep"}]}if(s.shouldBranch){const u=s.dynamicItemOptions.dynSectionIdx;return[!1,{type:"branch",branchClbk:()=>{const T=[];for(const[F,$]of Object.entries(s.dynamicItemOptions.itemOptions)){const ue="string"==typeof F?parseInt(F,10):F;if(0===ue)continue;const Ie=this.clone();Ie._currentNavigator.selectDynamicItem(u,ue,$.tile,$.isConsecutiveToPrevious||!1,$.isOnCorridor||!1),T.push(Ie)}return this.dispose(),T}}]}return s=this._currentNavigator.tryPickNextAvailableTile(),[!0,{type:"keep"}]};let _,o;for([_,o]=w(d);I>0&&_;)I-=1,[_,o]=w(d);return o}}_flushRange(i){if(!this._pickedTileRanges.length||this._resHolder.tiles.length)return{type:"drop"};{const I=[];let w=[];for(const _ of this._pickedTileRanges[this._pickedTileRanges.length-1])w.push(_),_.tile.isCorner&&(I.push(w),w=[]);w.length&&I.push(w),this._pickedTileRanges=I}i&&(this._lastFloorNavHolder.fnav=this._currentNavigator);const d=[];for(const I of this._pickedTileRanges)I.length&&d.push(I.map(w=>n.createRequirementCheckerTileInfo(w)));return this._resHolder.tiles.push(...d),this._pickedTileRanges=[],{type:"drop"}}}class Qe extends L{constructor(i,d=!1,I={fnav:null}){super(),this.finalFloorNavigatorHolder=I,this._checkers.push(new Je(i,d,I))}_executeFirstCheckers(i,d){d(this._checkers[0].setNavigator(i.firstNavigator??i),this._checkers[0])}}function st(lt,i,d,I=!0,w=!1,_,o,s,u){const S=new re,T=function et(lt,i,d,I=!0,w=!1,_,o,s,u){let T,S=s,F=!1,$=!1;if(S)S.checkTileIsCloseEnoughToCursor(d)||(Te&&u&&S.checkTileIsCloseEnoughToCursor(u)?$=!0:F=!0);else{const Ce=I?V.CreateOptions.createDepartmentDefault(_,o,void 0,!1):V.CreateOptions.createRegularDefault(_,o);Ce.canAreaSelfReverse=Te;const Ue=U.create(lt,Ce);if(!Ue.trySetStartingTile(d,i,null,e.Sc(d.coveredSpace)))return Ue.dispose(),null;T=()=>Ue.dispose(),S=Ue.firstNavigator}const ue=new Ye,Ie=S.currentAreaNavigator.currentSelection.directionIsPositive,Pe=function Et(lt,i=!1){let d={hasChandedFlow:!1,tiles:[]},I={fnav:lt};const w=new Qe(d,i,I);w.run(lt);let _=d.tiles;if(d.hasChandedFlow&&(_=_.reverse().map(S=>S.reverse())),w.dispose(),!_.length)return null;if(_.length>1&&(1===_[0].length&&_[0][0].tile.isCorner&&!_[1][0].tile.isCorner&&(_[1]=_[0].concat(_[1]),_=_.slice(1)),1===_[_.length-1].length&&_[_.length-1][0].tile.isCorner&&!_[_.length-2][_[_.length-2].length-1].tile.isCorner&&(_[_.length-2]=_[_.length-2].concat(_[_.length-1]),_=_.slice(0,-1))),_.length>1){for(let S=0;S<_.length;S++)1===_[S].length&&_[S][0].tile.isCorner&&(S>0&&!_[S-1][_[S-1].length-1].tile.isCorner?_[S-1].push(..._[S]):S<_.length-1&&!_[S+1][0].tile.isCorner&&(_[S+1]=[..._[S],..._[S+1]]),_[S]=[]);_=_.filter(S=>S.length>0)}const o=new Le;for(const S of _)if(S.length){const T=new be;let F=-1;for(const $ of S){$.tile.dynamicSectionIdx>=0&&$.tile.dynamicItemIdx>0&&T.usedDynamics.set($.tile.dynamicSectionIdx,$.tile.dynamicItemIdx);const ue=new ve;ue.reqTile=$,T.tiles.push(ue),T._tileUids.add($.tile.partitionableShapeInfo.uidInPackage()),F<0&&$.tile.partitionableShapeInfo.isReceptionFriendly&&(F=T.tiles.length-1)}if(F>
1=0&&(o._receptionFriendlyRangeIdxes.push(o.tileRanges.length),T.receptionFriendlyIdx=F),o.tileRanges.push(T),1===S.length)T.tiles[0].isBeginToEnd=!0;else{const $=T.tiles[0];$.isBeginToEnd=!$.reqTile.tile.isOtherCloseToBegin(T.tiles[1].reqTile.tile);for(let ue=1;ue<T.tiles.length;ue++){const Pe=T.tiles[ue];Pe.isBeginToEnd=Pe.reqTile.tile.isOtherCloseToBegin(T.tiles[ue-1].reqTile.tile)}}}if(!o.tileRanges.length)return null;const s=o.tileRanges[0].tiles[0].reqTile.tile,u=o.tileRanges[o.tileRanges.length-1].tiles[o.tileRanges[o.tileRanges.length-1].tiles.length-1].reqTile.tile;return o.initialFirstTileUid=s.partitionableShapeInfo.uidInPackage(),o.initialLastTileUid=u.partitionableShapeInfo.uidInPackage(),o.isLoop=!!s.beginNeighbours.find(S=>S===u)||!!s.endNeighbours.find(S=>S===u),{section:o,nextFloorNavigator:I.fnav}}(S,I||w);return Pe?(Pe.section.isAtMapExtremity=!0,ue.sections.push(Pe.section),ue.isReceptionFriendly=Pe.section.isReceptionFriendly,{map:ue,flowDirectionIsPositive:Ie,currentFloorNavigator:Pe.nextFloorNavigator,shouldStop:F,choseReverseCursorTile:$,dispose:T}):(T&&T(),null)}(lt,i,d,I,w,_,o,s,u);return T?(S.extremityUidFlowMapMap.set(d.partitionableShapeInfo.uidInPackage(),T.map),{manager:S,flowDirectionIsPositive:T.flowDirectionIsPositive,currentFloorNavigator:T.currentFloorNavigator,shouldStop:T.shouldStop,dispose:T.dispose}):null}},73329:(tt,me,P)=>{P.d(me,{FO:()=>x,Fw:()=>g,Od:()=>y,UB:()=>ne,Ud:()=>Ee,Xg:()=>K,fB:()=>ee});var e=P(47318),E=P(21449),X=P(42893),O=P(36871),v=P(48636),h=P(65681);function g(Z,Q,V,U){const re=Q/2,ae=V/2,de=e.p([{x:-re,y:-ae},{x:-re,y:ae},{x:re,y:ae},{x:re,y:-ae}]);return e.Uf(de,e.FY(U,[Z.getX(),Z.getY()]))}function r(Z,Q,V,U,re="free"){const ae=Q.grid;let de,he,ve;try{de=e.m0(Z,ae.coveredSpace)}catch{return null}if(!de||e.xb(de))return null;try{[he,ve]=ae.gridInfo.getRectangleCoords(de,ae.cellSize)}catch{return(0,h.d1)(V,"candidate","SUS getRectangleCoords threw")}if(U&&"free"!==re){const Te="contain"===re,Je=Te?(lt,i)=>function J(Z,Q,V,U){const re=Z.cellSize,ae=Math.cos(-U.angle),de=Math.sin(-U.angle),he=[[Q*re,V*re],[Q*re,(V+1)*re],[(Q+1)*re,(V+1)*re],[(Q+1)*re,V*re]];for(const[ve,be]of he){let Le;try{Le=e.Uf(e.Pu({x:ve,y:be}),Z.ltwMtx)}catch{return!1}const Ye=Le.getX(),Te=Le.getY(),Je=Ye*ae-Te*de,Qe=Ye*de+Te*ae;if(Je<U.minX-v.N5||Je>U.maxX+v.N5||Qe<U.minY-v.N5||Qe>U.maxY+v.N5)return!1}return!0}(ae,lt,i,U):(lt,i)=>function L(Z,Q,V,U){const re=Z.cellSize,ae=Math.cos(-U.angle),de=Math.sin(-U.angle);let he;try{he=e.Uf(e.Pu({x:(Q+.5)*re,y:(V+.5)*re}),Z.ltwMtx)}catch{return!1}const ve=he.getX(),be=he.getY(),Le=ve*ae-be*de,Ye=ve*de+be*ae;return Le>=U.minX&&Le<=U.maxX&&Ye>=U.minY&&Ye<=U.maxY}(ae,lt,i,U),Qe=lt=>{for(const[i,d]of lt){const I=Je(i,d);if(Te&&!I)return!0;if(!Te&&I)return!1}return!Te},st=lt=>{const i=[];for(let d=he[1];d<=ve[1];d++)i.push([lt,d]);return Qe(i)},et=lt=>{const i=[];for(let d=he[0];d<=ve[0];d++)i.push([d,lt]);return Qe(i)};let Et=0;for(;he[0]<=ve[0]&&st(he[0])&&Et++<64;)he[0]++;for(;he[0]<=ve[0]&&st(ve[0])&&Et++<64;)ve[0]--;for(;he[1]<=ve[1]&&et(he[1])&&Et++<64;)he[1]++;for(;he[1]<=ve[1]&&et(ve[1])&&Et++<64;)ve[1]--;if(he[0]>ve[0]||he[1]>ve[1])return(0,h.d1)(V,"candidate",`SUS fragment emptied by the ${re} pass`)}let be=0;for(let Te=he[0];Te<=ve[0];Te++)for(let Je=he[1];Je<=ve[1];Je++){const Qe=ae.cells.get([Te,Je]);if(Qe&&(be++,!Qe.isFree))return(0,h.d1)(V,"candidate","SUS cell already occupied")}if(!be)return(0,h.d1)(V,"candidate","SUS rect covers no free cells (outside the grid shape)");const Le=ae.createPolygon(he,ve);if(!Le||e.xb(Le))return(0,h.d1)(V,"candidate","SUS createPolygon returned nothing");const Ye=new X.l.SusAreaInfo;return Ye.indirectLightUid=Q.area.lightShapeUid,Ye.gridUid=ae.gridInfo.uidInPackage(),Ye.bottomLeft=he,Ye.topRight=ve,Ye.coveredSpace=Le,Ye}function a(Z,Q){try{const V=e.SO(Q);if(!(V>0))return 0;const U=e.m0(Z,Q);return!U||e.xb(U)?0:e.SO(U)/V}catch{return 0}}function p(Z,Q,V,U,re=!1){const{flowTile:ae,ts:de,uid:he}=Z[Q],ve={uid:he,coveredSpace:de.coveredSpace};try{if(re&&ae.reqTile?.isWindow)return U&&U.supTilesForcedWhole++,ve;const be=de.partitionableShapeInfo,Le=be?.width;if(!(Le>0))return ve;const Ye=e.m0(de.coveredSpace,V);if(!Ye||e.xb(Ye))return null;const Te=e.b3(Ye);if(!Te||e.xb(Te))return null;if(ae.isCorner)return ve;const Je=K(de.coveredSpace);if(!Je)return ve;const Qe=be.width>=be.height?Je:{x:-Je.y,y:Je.x},st=k(de.coveredSpace,Qe),et=k(Te,Qe);if(!st||!et)return ve;const Et=et.min-st.min,lt=st.max-et.max;if(Et<=v.N5&<<=v.N5||Et>v.N5&<>v.N5)return ve;const i=function l(Z,Q,V,U){const re=Z[Q-1],de=re??Z[Q+1];if(!de?.ts?.coveredSpace)return null;const he=k(de.ts.coveredSpace,V);if(!he)return null;const ve=(U.min+U.max)/2,be=(he.min+he.max)/2;return re?be<ve:be>ve}(Z,Q,Qe,st);if(null===i)return ve;const d=i?Et:lt,I=Math.max(0,st.max-st.min-Et-lt);if(!(I>v.N5))return null;const w={targetTile:ae.reqTile,width:Le,height:be.height,sideIsStart:null,isBeginToEnd:ae.isBeginToEnd,inTilerangePosition:null,posts:[],hasWindow:!1,isInCorner:!1,idx:Q,distanceToEntrance:0,cornerIsInterior:!1},o=ae.computeUsedTile(new O.OB(w,d,I),!0)?.asDict?.();return!o||o instanceof E.ph||!("tileUid"in o)?((0,h.d1)(U,"candidate","SUP tile claimed whole: computeUsedTile produced no offsets"),ve):{uid:he,coveredSpace:Te,startOffset:"number"==typeof o.startOffset?o.startOffset:void 0,endOffset:"number"==typeof o.endOffset?o.endOffset:void 0,sideIsStart:
1o.sideIsStart}}catch{return ve}}function y(Z,Q,V,U,re,ae=!1){const de=V.sectionFor(Q);if(!de)return(0,h.d1)(U,"candidate","SUP band has no navigable flow-map section from the cursor");const he=[];for(const et of de.tileRanges??[])for(const Et of et.tiles??[]){const lt=Et?.reqTile?.tile;if(!lt||!lt.coveredSpace)continue;const i=lt.partitionableShapeInfo.uidInPackage();he.some(d=>d.uid.equals(i))||he.push({flowTile:Et,ts:lt,uid:i})}const ve=[];let be=0;for(let et=0;et<he.length;et++){const{ts:Et,uid:lt}=he[et],i=a(Z,Et.coveredSpace);U&&(U.supTilesSeen++,i>U.bestSupOverlap&&(U.bestSupOverlap=i)),!(i<=0)&&(i>be&&(be=i),ve.push({idx:et,ts:Et,ratio:i,uid:lt}))}if(!(be>0))return null;const Le=Math.max(v.lG,be*v.G4),Ye=Math.max(v.tJ,be*v.UH),Te=[];for(const et of ve){const Et=he[et.idx].flowTile;if(et.ratio<(ae&&(Et.reqTile?.isWindow||Et.isCorner)?Ye:Le))continue;if(!et.ts.isActive){(0,h.d1)(U,"candidate","SUP tile skipped: inactive");continue}if(!et.ts.isFullyFree){(0,h.d1)(U,"candidate",et.ts.isFree?"SUP tile skipped: partly claimed already (isFree true but offsets set)":"SUP tile skipped: already occupied");continue}const i=p(he,et.idx,Z,U,ae);if(i){if((!re||ce(i,re))&&re){(0,h.d1)(U,"candidate","SUP tile skipped: whole-tile claim would exceed the edge box");continue}U&&("number"==typeof i.startOffset||"number"==typeof i.endOffset)&&U.supTilesPartial++,Te.push(i)}}if(!Te.length)return(0,h.d1)(U,"candidate","no claimable tiles in the band section under the footprint");let Je=e.lD();for(const et of Te)Je=e.Y7(Je,et.coveredSpace);const Qe=e.b3(e.lE(Je,v.MA));if(!Qe||e.xb(Qe))return(0,h.d1)(U,"candidate","SUP fragment union came out empty");const st=new X.l.SupAreaInfo;return st.supAreaFullUid=Q.area.directLight.fullUid,st.tileInfos=Te.map(et=>"number"==typeof et.startOffset||"number"==typeof et.endOffset?{tileUid:et.uid,startOffset:et.startOffset,endOffset:et.endOffset,sideIsStart:et.sideIsStart}:et.uid),st.coveredSpace=Qe,st}function Y(Z,Q){try{const U=e.Uf(Z,e.FY(-Q)).getEnvelopeInternal();if(!(U.getMaxX()>U.getMinX()&&U.getMaxY()>U.getMinY()))return null;const re=e.p([{x:U.getMinX(),y:U.getMinY()},{x:U.getMinX(),y:U.getMaxY()},{x:U.getMaxX(),y:U.getMaxY()},{x:U.getMaxX(),y:U.getMinY()}]);return e.Uf(re,e.FY(Q))}catch{return null}}function H(Z,Q,V,U){let ae,re=e.lD();for(const he of Z)re=e.Y7(re,he.coveredSpace);for(const he of Q)re=e.Y7(re,he.coveredSpace);re=e.Y7(re,V);try{ae=e.lE(re,v.MA)}catch{return(0,h.d1)(U,"candidate","weld threw")}if(!ae||e.xb(ae))return(0,h.d1)(U,"candidate","weld came out empty");if(1!==ae.getNumGeometries())return(0,h.d1)(U,"candidate",`union is disjoint after welding (${ae.getNumGeometries()} pieces, WELD_DILATE=${v.MA})`);const de=e.b3(ae);return!de||e.xb(de)?(0,h.d1)(U,"candidate","welded shape empty after pickBiggest"):de}function ne(Z,Q,V,U,re){const ae=Q.wholeTilesOnly?f(Z,V):null,de=ae?"nearest":"free",he=[];for(const Te of Q.susHits){const Je=r(Z,Te,re,ae??void 0,de);Je&&he.push(Je)}const ve=[];for(const Te of Q.supHits){const Je=y(Z,Te,U,re,void 0,Q.wholeTilesOnly);Je&&ve.push(Je)}const be=ve.length+he.length;if(re&&be>re.bestFragmentCount&&(re.bestFragmentCount=be),be<2)return(0,h.d1)(re,"candidate",`fewer than 2 fragments (got ${ve.length} SUP + ${he.length} SUS)`);let Le;try{Le=e.m0(Z,Q.freeCorridor)}catch{return(0,h.d1)(re,"candidate","corridor intersection threw")}if(!Le||e.xb(Le))return(0,h.d1)(re,"candidate","footprint does not overlap any free corridor");const Ye=H(ve,he,Le,re);return Ye?{supFragments:ve,susFragments:he,corridor:Le,coveredSpace:Ye}:null}function K(Z){try{const Q=e.b3(Z);if(!Q||e.xb(Q))return null;const V=Q.getExteriorRing();let U=-1,re=0,ae=0;for(let he=0,ve=V.getNumPoints();he<ve-1;he++){const be=V.getCoordinateN(he),Le=V.getCoordinateN(he+1),Ye=Le.x-be.x,Te=Le.y-be.y,Je=Ye*Ye+Te*Te;Je>U&&(U=Je,re=Ye,ae=Te)}if(!(U>0))return null;const de=Math.sqrt(U);return{x:re/de,y:ae/de}}catch{return null}}function k(Z,Q){try{const V=e.b3(Z);if(!V||e.xb(V))return null;const U=V.getExteriorRing();let re=1/0,ae=-1/0;for(let de=0,he=U.getNumPoints();de<he;de++){const ve=U.getCoordinateN(de),be=ve.x*Q.x+ve.y*Q.y;be<re&&(re=be),be>ae&&(ae=be)}return isFinite(re)&&isFinite(ae)?{min:re,max:ae}:null}catch{return null}}
1function x(Z,Q){try{if(!Z||e.xb(Z))return null;const U=e.Uf(Z,e.FY(-Q)).getEnvelopeInternal();return{minX:U.getMinX(),minY:U.getMinY(),maxX:U.getMaxX(),maxY:U.getMaxY()}}catch{return null}}function f(Z,Q){const V=Y(Z,Q),U=V?x(V,Q):null;return V&&U?{polygon:V,...U,angle:Q}:null}function ce(Z,Q){if("number"==typeof Z.startOffset||"number"==typeof Z.endOffset)return!1;const U=x(Z.coveredSpace,Q.angle);return!U||U.minX<Q.minX-v.N5||U.maxX>Q.maxX+v.N5||U.minY<Q.minY-v.N5||U.maxY>Q.maxY+v.N5}const ke={fill:1/0,bloat:1/0,ragged:1/0,score:1/0,boxWidth:0,boxHeight:0};function te(Z,Q,V){if(!Z||e.xb(Z))return ke;const U=x(Z,Q);if(!U)return ke;const re=U.maxX-U.minX,ae=U.maxY-U.minY,de=re*ae;if(!(de>0))return ke;let he=0;try{he=e.SO(Z)}catch{return ke}if(!(he>0))return ke;const ve=de/he,be=V>0?Math.max(1,de/V):1,Le=1+function Xe(Z,Q){try{const V=Y(Z,Q);if(!V)return 0;const U=e.oo(V,Z);if(!U||e.xb(U))return 0;let re=0;for(let ae=0,de=U.getNumGeometries();ae<de;ae++){const he=x(U.getGeometryN(ae),Q);if(!he)continue;const ve=Math.min(he.maxX-he.minX,he.maxY-he.minY);ve>re&&(re=ve)}return re}catch{return 0}}(Z,Q)/Math.max(1,Math.min(re,ae));return{fill:ve,bloat:be,ragged:Le,score:ve*be*Le,boxWidth:re,boxHeight:ae}}function Ee(Z,Q,V,U){const re=f(Z.coveredSpace,V);if(!re)return(0,h.u7)(U,"grow: no box"),null;const ae=[];for(const ve of Q.susHits){const be=r(re.polygon,ve,void 0,re,"nearest");be&&ae.push(be)}if(ae.length<Z.susFragments.length)return(0,h.u7)(U,"grow: blocked, a SUS fragment could not extend"),null;let de;try{de=e.m0(re.polygon,Q.freeCorridor)}catch{return(0,h.u7)(U,"grow: corridor threw"),null}if(!de||e.xb(de))return(0,h.u7)(U,"grow: no corridor in the box"),null;const he=H(Z.supFragments,ae,de);return he?{supFragments:Z.supFragments,susFragments:ae,corridor:de,coveredSpace:he}:((0,h.u7)(U,"grow: weld failed"),null)}function q(Z,Q,V,U,re,ae){ae&&ae.candidatesTried++;let ve=ne(g(e.Pu({x:Z.cursor.getX()+U[0],y:Z.cursor.getY()+U[1]}),Q.dimension[0],Q.dimension[1],V),Z,V,re,ae);if(!ve)return null;const be=Q.dimension[0]*Q.dimension[1];let Le=te(ve.coveredSpace,V,be);if(Z.wholeTilesOnly){const st=Ee(ve,Z,V,ae);if(st){const et=te(st.coveredSpace,V,be);(0,h.u7)(ae,et.score<=Le.score?"grow: applied (score improved)":`grow: applied (score worsened ${Math.round(100*Le.score)/100} -> ${Math.round(100*et.score)/100}, shape is the correct one)`),ve=st,Le=et}}else{const st=function Ae(Z,Q,V,U,re){const ae=f(Z.coveredSpace,V);if(!ae)return(0,h.u7)(re,"no box"),null;const de=[];for(const Le of Q.susHits){const Ye=r(ae.polygon,Le,void 0,ae,"contain");Ye&&de.push(Ye)}if(de.length<Z.susFragments.length)return(0,h.u7)(re,"lost a SUS fragment"),null;const he=[];for(const Le of Q.supHits){const Ye=y(ae.polygon,Le,U,void 0,ae,Q.wholeTilesOnly);Ye&&he.push(Ye)}if(he.length<Z.supFragments.length)return(0,h.u7)(re,"lost a SUP fragment"),null;let ve;try{ve=e.m0(ae.polygon,Q.freeCorridor)}catch{return(0,h.u7)(re,"corridor threw"),null}if(!ve||e.xb(ve))return(0,h.u7)(re,"no corridor in box"),null;const be=H(he,de,ve);return be?{supFragments:he,susFragments:de,corridor:ve,coveredSpace:be}:((0,h.u7)(re,"weld failed"),null)}(ve,Z,V,re,ae);if(st){const et=te(st.coveredSpace,V,be);et.score<Le.score?(ve=st,Le=et,(0,h.u7)(ae,"applied")):(0,h.u7)(ae,`discarded, not better (${Math.round(100*et.score)/100} vs ${Math.round(100*Le.score)/100})`)}}const Ye=Le.score;ae&&Ye<ae.bestScore&&(ae.bestScore=Ye,ae.bestFill=Le.fill,ae.bestBloat=Le.bloat,ae.bestRagged=Le.ragged);const[Te,Je]=Q.dimension,Qe=function ye(Z,Q,V,U,re){const ae={ok:!1,gotWidth:0,gotHeight:0,usableArea:0};if(!Z||e.xb(Z))return ae;const de=x(Z,re);if(!de)return ae;const he=de.maxX-de.minX,ve=de.maxY-de.minY;let be=0;try{be=e.SO(Z),Q&&!e.xb(Q)&&(be-=e.SO(Q))}catch{return ae}const Le=Math.min(he,ve),Ye=Math.min(V,U);return{ok:be>=V*U*v.ZB-1e-6&&Le>=Ye*v.UL-1e-6,gotWidth:he,gotHeight:ve,usableArea:be}}(ve.coveredSpace,ve.corridor,Te,Je,V);return ae&&Qe.usableArea>ae.bestUsableArea&&(ae.bestUsableArea=Qe.usableArea),Qe.ok?Z.wholeTilesOnly&&Le.bloat>v.I5?(0,h.d1)(ae,"candidate",`box ${Math.round(100*Le.bloat)/100}x nominal area, above MAX_BLOAT_WHOLE_TILES (${v.I5})`):Ye<=v.QH?{angle:V,dimension:Q,supFragments:ve.supFragments,susFragments:ve.susFragments,corridor:ve.corridor,coveredSpace:ve.coveredSpace,score:Ye,quality:Le}:(0,h.d1)(ae,"candidate",`rectangularity above MAX_DIVERGENCE (${v.QH})`):(0,h.d1)(ae,"candidate",Qe.gotWidth<Te*v.ZB-1e-6||Qe.gotHeight<Je*v.ZB-1e-6?`extent below nominal (got ${Math.round(Qe.gotWidth)}x${Math.round(Qe.gotHeight)}, needs ${Math.round(Te)}x${Math.round(Je)})`:"usable area below nominal (excludes absorbed corridor)")}
1function oe(Z,Q){const V=Q/2,U=[[0,0],[V,0],[-V,0],[0,V],[0,-V],[Q,0],[-Q,0],[0,Q],[0,-Q]],re=Math.cos(Z),ae=Math.sin(Z);return U.map(([de,he])=>[de*re-he*ae,de*ae+he*re])}function ee(Z,Q,V,U){let re=null,ae=1/0,de=0;for(const he of Q)for(const ve of Z.angles)for(const be of oe(ve,Z.slideBudget)){if(de++>=v.An)return(0,h.d1)(U,"candidate",`hit MAX_CANDIDATES (${v.An}) before finishing the sweep`),re;const Le=q(Z,he,ve,be,V,U);if(!Le)continue;let Ye=1/0;try{Ye=e.TE(e.Sc(Le.coveredSpace),Z.cursor)}catch{}(!re||Le.score<re.score||Le.score===re.score&&Ye<ae)&&(re=Le,ae=Ye)}return re}},48636:(tt,me,P)=>{P.d(me,{An:()=>a,G4:()=>O,HI:()=>e,I5:()=>y,MA:()=>E,N5:()=>g,QH:()=>X,UH:()=>n,UL:()=>p,ZB:()=>h,iN:()=>r,lG:()=>v,tJ:()=>l});const e=Math.PI/180,E=5,X=5,O=.1,v=.05,h=1,g=5,r=60,a=200,n=.5,l=.35,p=.85,y=2},85094:(tt,me,P)=>{P.d(me,{o:()=>X});var e=P(47318),E=P(37446);class X{constructor(v,h,g=null,r=null){this._bands=new Map,this._disposed=!1,this._floor=v,this._cursor=h,this._movingInfo=g,this._flowDirectionIsPositive=r}get flowDirectionIsPositive(){return this._flowDirectionIsPositive}sectionFor(v){if(this._disposed)return null;const h=v.area.directLight.fullUid.toString(),g=this._bands.get(h);if(g)return g.section;const r={section:null};this._bands.set(h,r);const a=this._nearestTile(v);if(!a)return null;let n=null;try{n=(0,E._e)(this._floor,v.area,a,!0,!0,this._flowDirectionIsPositive??null,void 0)}catch(p){return console.warn("[MULTISPAN] flow map build threw for a SUP band",p),null}if(!n?.manager)return n?.dispose?.(),null;r.dispose=n.dispose,"boolean"!=typeof this._flowDirectionIsPositive&&(this._flowDirectionIsPositive=n.flowDirectionIsPositive);const l=n.manager.pickFlowMap(a.partitionableShapeInfo.uidInPackage());return r.section=l?.sections?.[0]??null,r.section}_nearestTile(v){let h=null,g=1/0;for(const r of v.area.tileStates??[]){if(!r.isActive||!r.coveredSpace)continue;let a=1/0;try{a=e.TE(this._cursor,r.coveredSpace)}catch{continue}a<g&&(g=a,h=r)}return h}dispose(){this._disposed||(this._disposed=!0,this._bands.forEach(v=>{try{v.dispose?.()}catch{}}),this._bands.clear())}}},24861:(tt,me,P)=>{P.d(me,{d7:()=>O,nu:()=>X});let e=!1;function E(v){const h=v?.parentPropertyState?.inputData?.extra??null;return!h&&!e&&(e=!0,console.warn("[MULTISPAN] no ModelizationContext.extra reachable from the floor state; every scenario-driven permission reads as OFF.")),h}function X(v,h){return!!v?.isReception&&!!E(h)?.isReceptionHub}function O(v,h){return!!(v&&(v.isPartitioned||v.isReception&&E(h)?.isReceptionFilterVisitors))}},87372:(tt,me,P)=>{P.d(me,{LW:()=>n,_T:()=>p,qt:()=>h});var e=P(47318),E=P(4516),X=P(91668),O=P(48636),v=P(65681);function h(y){const D=new E.me;y?.dimensions?.forEach(H=>{H.dimensions.forEach(ne=>{D.set([ne[0],ne[1]],{picker:H.picker,layout:H.layout,dimension:[ne[0],ne[1],ne[2]]}),D.set([ne[1],ne[0]],{picker:H.picker,layout:H.layout,dimension:[ne[1],ne[0],ne[2]]})})});const Y=D.mapArray(H=>H);return Y.sort((H,ne)=>H.dimension[0]*H.dimension[1]-ne.dimension[0]*ne.dimension[1]),Y}function r(y){try{const D=e.b3(y);if(!D||e.xb(D))return null;const Y=D.getExteriorRing(),H=Y.getNumPoints();let ne=-1,K=null;for(let k=0;k<H-1;k++){const x=Y.getCoordinateN(k),f=Y.getCoordinateN(k+1),J=f.x-x.x,L=f.y-x.y,ce=J*J+L*L;ce>ne&&(ne=ce,K=Math.atan2(L,J))}return null===K?null:n(K)}catch{return null}}function a(y){try{const D=e.Uf(e.Pu({x:0,y:0}),y.ltwMtx),Y=e.Uf(e.Pu({x:1,y:0}),y.ltwMtx);return n(Math.atan2(Y.getY()-D.getY(),Y.getX()-D.getX()))}catch{return null}}function n(y){let D=y%Math.PI;return D<0&&(D+=Math.PI),D}function l(y,D){if(null===D||!isFinite(D))return;const Y=n(D);y.some(H=>Math.abs(H-Y)<O.HI||Math.abs(Math.abs(H-Y)-Math.PI)<O.HI)||y.push(Y)}function p(y,D,Y,H,ne,K=!1){if(!y||!D||!Y?.length)return(0,v.d1)(ne,"probe","no floor, cursor or dimensions");let k=0;for(const Ee of Y){const q=Math.sqrt(Ee.dimension[0]*Ee.dimension[0]+Ee.dimension[1]*Ee.dimension[1]);q>k&&(k=q)}if(k<=0)return(0,v.d1)(ne,"probe","every candidate dimension is degenerate");const x=[];for(const Ee of y.indirectLightAreaStates??[])for(const q of Ee.gridStates.values()){const oe=q.coveredSpace;!oe||e.xb(oe)||e.TE(D,oe)<=k&&x.push({area:Ee,grid:q})}const f=x.length?Math.max(...x.map(Ee=>Ee.grid.cellSize||O.iN)):O.iN,J=k/2+f,L=[];let ce=1/0;for(const Ee of y.directLightAreaStates??[]){const q=Ee.coveredSpace;if(!q||e.xb(q))continue;let oe=1/0;try{oe=e.TE(D,q)}catch{continue}oe<ce&&(ce=oe),oe<=J&&L.push({area:Ee})}if((0,v.JP)(ne,`reach: maxDiagonal=${Math.round(k)} slide=${Math.round(f)}
1 radius=${Math.round(J)}`),(0,v.JP)(ne,`in reach: ${L.length} SUP band(s) of ${y.directLightAreaStates?.length??0} (nearest ${isFinite(ce)?Math.round(ce):"n/a"}), ${x.length} SUS grid(s)`),L.length+x.length<2)return(0,v.d1)(ne,"probe","too few substrates in reach (need 2)");let ke=null;try{ke=y.targetFloor?.corridorSpaces?.()}catch{ke=null}if(!ke||e.xb(ke))return(0,v.d1)(ne,"probe","no corridor geometry on this floor");const Xe=function g(y,D){let Y=e.lD();for(const H of y.placedModules??[]){if(H?.dirtyState===X.w.DELETE)continue;const ne=H?.info;if(!ne||ne===D)continue;const K=ne.corridorFragments;!K||e.xb(K)||(Y=e.Y7(Y,K))}return Y}(y,H),te=e.xb(Xe)?e.Y7(e.lD(),ke):e.oo(ke,Xe);if(!te||e.xb(te))return(0,v.d1)(ne,"probe","all corridor already claimed by other multi-span modules");let ye=1/0;try{ye=e.TE(D,te)}catch{}if((0,v.JP)(ne,`free corridor: nearest ${isFinite(ye)?Math.round(ye):"n/a"} vs radius ${Math.round(J)}`),ye>J)return(0,v.d1)(ne,"probe","corridor out of reach of the candidate rectangle");const Ae=[];for(const Ee of x)l(Ae,a(Ee.grid));for(const Ee of L)l(Ae,r(Ee.area.coveredSpace));return l(Ae,r(te)),l(Ae,0),(0,v.JP)(ne,`angles: ${Ae.map(Ee=>Math.round(180*Ee/Math.PI)+"\xb0").join(", ")}`),{cursor:D,radius:J,supHits:L,susHits:x,freeCorridor:te,angles:Ae,slideBudget:f,wholeTilesOnly:K}}},65681:(tt,me,P)=>{function e(){return{reasons:new Map,notes:[],candidatesTried:0,bestScore:1/0,bestFill:1/0,bestBloat:1/0,bestRagged:1/0,bestFragmentCount:0,bestSupOverlap:0,supTilesSeen:0,supTilesPartial:0,supTilesForcedWhole:0,tileSamples:[],squareUp:new Map,bestUsableArea:0}}function E(r,a,n){if(r){const l=`${a}: ${n}`;r.reasons.set(l,(r.reasons.get(l)??0)+1)}return null}function X(r,a){r&&r.squareUp.set(a,(r.squareUp.get(a)??0)+1)}function O(r,a){r?.notes.push(a)}function v(r,a=1){const n=Math.pow(10,a);return Math.round(r*n)/n}function h(r){const a=[];for(const l of r.notes)a.push(" "+l);if(r.candidatesTried>0&&(a.push(` candidates tried: ${r.candidatesTried}, best fragments assembled: ${r.bestFragmentCount}`),isFinite(r.bestScore)&&a.push(` best score ${v(r.bestScore,3)} = fill ${v(r.bestFill,3)} x bloat ${v(r.bestBloat,3)} x ragged ${v(r.bestRagged,3)} (1.0 = a perfect nominal rectangle; the largest term is what is hurting)`)),r.supTilesSeen>0&&a.push(` SUP tiles examined: ${r.supTilesSeen}, best single-tile overlap: ${v(100*r.bestSupOverlap,1)}%, partial claims: ${r.supTilesPartial}`+(r.supTilesForcedWhole?`, forced whole (window): ${r.supTilesForcedWhole}`:"")),r.squareUp.size&&a.push(" shape pass: "+[...r.squareUp.entries()].sort((l,p)=>p[1]-l[1]).map(([l,p])=>`${p}x ${l}`).join(", ")),r.tileSamples.length){a.push(" tiles the footprint wanted to cut:");for(const l of r.tileSamples)a.push(" "+l)}r.bestUsableArea>0&&a.push(` best usable area reached: ${v(r.bestUsableArea/1e4,2)} m\xb2 (corridor excluded)`);const n=[...r.reasons.entries()].sort((l,p)=>p[1]-l[1]);if(n.length){a.push(" rejections, most frequent first:");for(const[l,p]of n)a.push(` ${p.toString().padStart(5)} x ${l}`)}return a.join("\n")}function g(r){const a=l=>[...r.reasons.keys()].some(p=>p.includes(l)),n=[...r.reasons.keys()].find(l=>l.includes("threw"));if(n)return`Something threw: "${n}". That is a defect, not a tuning problem \u2014 every other rejection below is downstream of it.`;if(a("too few substrates in reach"))return"The probe disc reaches fewer than 2 substrates. The module may be too small to span, or the drop point is too far from the boundary between them.";if(a("corridor out of reach"))return"Substrates are in reach but no free corridor is. The rectangle is not big enough to bridge from the cursor to the corridor, or the corridor there is already claimed.";if(a("no corridor geometry"))return"floor.targetFloor.corridorSpaces() is empty on this floor \u2014 multi-span needs a PRIMARY corridor and there is none to cross.";if(a("no navigable flow-map section"))return"The SUP band could not be navigated from the cursor, so none of its tiles are reachable. createFlowMappingManager failed for that band \u2014 usually because the tile nearest the cursor is not a valid starting tile.";if(a("tile frame (construction lines) unavailable"))return"Partial tile claiming is inert: ModelizationPartitionableShapeState never assigns its construction lines, so every claim falls back to a whole tile. Shape qual
1ity is capped at whole-tile granularity until a tile frame comes from somewhere populated.";if(a("SUP tile skipped"))return"Some SUP tiles the footprint wanted were unavailable and were skipped, so the room is narrower than asked. That alone is not fatal; check whether the extent or area gate then rejected the result.";if(a("no claimable tiles in the band"))return"Every SUP tile the footprint wanted is unavailable. The band is occupied where the room needs it.";if(a("union is disjoint"))return"Fragments were found but do not weld into one polygon: the gap between the grid/band covered spaces and the corridor is wider than WELD_DILATE.";if(a("fewer than 2 fragments"))return"The rectangle reaches the corridor but only ever lands substantially in ONE substrate. It likely needs to be longer across the corridor axis.";if(a("usable area below nominal"))return'Shapes were assembled but none delivers the module\'s programme area once the absorbed corridor is excluded \u2014 compare "best usable area reached" against the nominal. The floor simply may not have room; lower NOMINAL_TOLERANCE to accept placements that fall short.';if(a("extent below nominal"))return"Shapes were assembled with enough area but not enough SPAN: the bounding box is shorter than the module in one direction. Lower NOMINAL_TOLERANCE to accept it.";if(a("rectangularity above")){const l=Math.max(r.bestFill,r.bestBloat,r.bestRagged),p=l===r.bestBloat?"bloat \u2014 the shape is much bigger than the module asked for, usually whole-tile SUP claiming":l===r.bestRagged?"ragged \u2014 the outline steps in deeply somewhere, usually one substrate reaching less far than its neighbour":"fill \u2014 the shape has notches bitten out of its bounding box";return`Candidates were assembled but all scored worse than MAX_DIVERGENCE (best was ${v(r.bestScore,3)}). Dominant term: ${p}.`}return a("no free cells")||a("no claimable tiles")?"Substrates are in reach but everything the rectangle covers is already occupied.":null}P.d(me,{JP:()=>O,SA:()=>e,_0:()=>h,d1:()=>E,lJ:()=>g,u7:()=>X})},46376:(tt,me,P)=>{P.d(me,{W:()=>r,p:()=>g});var e=P(47318),E=P(91668);const X=5,O=.05;function v(a,n){if(null==a||null==n)return!1;if(a===n)return!0;try{if("function"==typeof a.equals)return!!a.equals(n)}catch{}return!1}function h(a){try{if(!a||a.dirtyState===E.w.DELETE)return null;const n=a.coveredSpaces??a.coveredSpace??null;return n&&!e.xb(n)?n:null}catch{return null}}function g(a,n,l){if(!a||!n)return null;try{if(e.xb(n))return null;const p=e.SO(n);if(!(p>0))return null;const y=e.hq(n,-X);if(!y||e.xb(y))return null;const D=y.getEnvelopeInternal(),Y=[...a.placedDepartments??[],...a.placedModules??[]];for(const H of Y){if(l&&(H?.info===l||v(H?.uid,l?.uid)))continue;const ne=h(H);if(ne){try{if(!D.intersects(ne.getEnvelopeInternal()))continue}catch{}try{const K=e.m0(y,ne);if(!K||e.xb(K))continue;const k=e.SO(K)/p;if(k>O)return{piece:H,ratio:k}}catch{}}}return null}catch{return null}}function r(a){try{return a?.coveredSpace??a?._coveredSpace??null}catch{return null}}},32531:(tt,me,P)=>{P.d(me,{t:()=>X});var e=P(68385),E=P(91955);class X{get programModule(){return this._programModule}set programModule(v){this._programModule=v}static baseFromJson(v,h,g){const r=v||new X;if(h.programModuleId)r._programModule=g.getStringKeyRef("program"===(h.programModuleType||"program")?E.P.JKEY:e.p.JKEY,h.programModuleId);else{const a=g.getRefs("program"===(h.programModuleType||"program")?E.P.JKEY:e.p.JKEY);r._programModule=Object.values(a).find(n=>n.module.id===h.moduleId&&n.furnitureSize?.id==h.sizeId&&n.furnitureShape?.id==h.shapeId)}return r}static baseToJson(v){return v._programModule.id?{programModuleId:v._programModule.id,programModuleType:v._programModule instanceof E.P?"program":"feasability"}:{programModuleType:v._programModule instanceof E.P?"program":"feasability",moduleId:v._programModule.module.id,sizeId:v._programModule.furnitureSize?.id||void 0,shapeId:v._programModule.furnitureShape?.id||void 0}}dispose(){this._programModule=null}}},67193:(tt,me,P)=>{P.d(me,{G:()=>O});var e=P(78376),E=P(91955),X=P(21449);class O{constructor(){this._usedOffices=new Map,this._usedOpenSpaces=0,this._supAreaSpreading=[]}get department(){return this._department}set department(h){this._department=h}get workforce(){return this._workforce}set workforce(h){this._workforce=h}get usedTiles(){return this._usedTiles}set usedTiles(h){this._usedTiles=h}get sqMeters(){return this._sqMeters}set sqMeters(h){this._sqMeters=h}get htmlWidth(){return this._htmlWidth}set htmlWidth(h){this._htmlWidth=h}get usedOffices(){return this._usedOffices}get usedOpenSpaces(){return this._usedOpenSpaces}set usedOpenSpaces(h){this._usedOpenSpaces=h}get supAreaSpreading(){return this._supAreaSpreading}static fromJson(h,g){const r=new O;return h&&(r._department=g.getStringKeyRef(e.v.JKEY,h.departmentName),r._workforce=h.workforce,r._usedTiles=h.usedTiles,r._sqMeters=h.sqMeters,r._htmlWidth=h.htmlWidth,Object.entries(h.usedOffices||{}
1).forEach(([a,n])=>{const l=g.getStringKeyRef(E.P.JKEY,parseInt(a));r._usedOffices.set(l,n)}),r._usedOpenSpaces=h.usedOpenSpaces||0,r._supAreaSpreading=(h.supAreaSpreading||[]).map(a=>[X.ph.fromJson(a[0]),a[1],a[2],a[3]||0])),r}static toJson(h){return{departmentName:h._department.name,workforce:h._workforce,usedTiles:h._usedTiles,sqMeters:h._sqMeters,htmlWidth:h._htmlWidth,usedOffices:Array.from(h._usedOffices.entries()).reduce((g,[r,a])=>(g[r.id]=a,g),{}),usedOpenSpaces:h._usedOpenSpaces,supAreaSpreading:h._supAreaSpreading?h._supAreaSpreading.map(g=>[X.ph.toJson(g[0]),g[1],g[2],g[3]||0]):null}}clone(){const h=new O;return h._department=this._department,h._workforce=this._workforce,h._usedTiles=this._usedTiles,h._sqMeters=this._sqMeters,h._htmlWidth=this._htmlWidth,h._usedOffices=new Map(this._usedOffices),h._usedOpenSpaces=this._usedOpenSpaces,h._supAreaSpreading=this._supAreaSpreading.map(g=>[g[0],g[1],g[2],g[3]]),h}dispose(){this._department=null,this._usedOffices.clear()}}},41118:(tt,me,P)=>{P.d(me,{X:()=>v});var e=P(34376),E=P(67193),X=P(8950),O=P(89237);class v{constructor(g){this._departments=[],this._modules=[],this._floor=g}get shouldSerialize(){return this._departments.length>0||this._modules.length>0||!!this._supReception}get floor(){return this._floor}set floor(g){this._floor=g}get departments(){return this._departments}get modules(){return this._modules}get supReception(){return this._supReception}set supReception(g){this._supReception=g}static fromJson(g,r){const a=new v;if(!g)return a;a._floor=r.getStringKeyRef(e._.JKEY,g.floorId),a._departments=(g.departments||[]).map(p=>E.G.fromJson(p,r)),a._modules=(g.modules||[]).map(p=>X.E.fromJson(p,r)),a._supReception=g.supReception?O.z.fromJson(g.supReception,r):void 0;const n=[],l=a._modules.flatMap(p=>{const y=[];if(p.count>1){for(let D=0;D<p.count;D++){const Y=new X.E;Y.count=1,Y.programModule=p.programModule,Y.unitSqMeters=p.unitSqMeters,y.push(Y)}n.push(p)}else y.push(p);return y});return n.forEach(p=>p.dispose()),a._modules=l,a}static toJson(g){let r=new Map;g.modules.forEach(l=>{r.has(l.programModule)||r.set(l.programModule,[]),r.get(l.programModule)?.push(l)});const a=Array.from(r.entries()).map(([l,p])=>{const y=p[0],D=new X.E;return D.programModule=y.programModule,D.count=p.length,D.unitSqMeters=y.unitSqMeters,D}),n={floorId:g._floor.id,floorIndex:g.floor.floorIndex,buildingIndexes:g.floor.rawJson.buildingIndexes,departments:g.departments.map(l=>E.G.toJson(l)),modules:a.map(l=>X.E.toJson(l)),supReception:g.supReception?O.z.toJson(g.supReception):null};return a.forEach(l=>l.dispose()),n}dispose(){this._departments.forEach(g=>g.dispose()),this._departments=[],this._modules.forEach(g=>g.dispose()),this._modules=[],this._supReception?.dispose(),this._supReception=void 0,this._floor=null}}},8950:(tt,me,P)=>{P.d(me,{E:()=>E});var e=P(32531);class E extends e.t{get count(){return this._count}set count(O){this._count=O}get unitSqMeters(){return this._unitSqMeters}set unitSqMeters(O){this._unitSqMeters=O}static fromJson(O,v){const h=new E;return e.t.baseFromJson(h,O,v),h.count=O.count,h.unitSqMeters=O.unitSqMeters,h}static toJson(O){return{...e.t.baseToJson(O),count:O.count,unitSqMeters:O.unitSqMeters}}dispose(){super.dispose()}}},89237:(tt,me,P)=>{P.d(me,{z:()=>X});var e=P(32531),E=P(21449);class X extends e.t{get usedTiles(){return this._usedTiles}set usedTiles(v){this._usedTiles=v}get sqMeters(){return this._sqMeters}set sqMeters(v){this._sqMeters=v}get htmlWidth(){return this._htmlWidth}set htmlWidth(v){this._htmlWidth=v}get supAreaSpreading(){return this._supAreaSpreading}set supAreaSpreading(v){this._supAreaSpreading=v}static fromJson(v,h){const g=new X;return e.t.baseFromJson(g,v,h),g.usedTiles=v.usedTiles,g.sqMeters=v.sqMeters,g.htmlWidth=v.htmlWidth,g.supAreaSpreading=v.supAreaSpreading?[E.ph.fromJson(v.supAreaSpreading[0]),v.supAreaSpreading[1]]:null,g}static toJson(v){return{...e.t.baseToJson(v),usedTiles:v.usedTiles,sqMeters:v.sqMeters,htmlWidth:v.htmlWidth,supAreaSpreading:v.supAreaSpreading?[E.ph.toJson(v.supAreaSpreading[0]),v.supAreaSpreading[1]]:null}}clone(){const v=new X;return v._programModule=this._programModule,v._usedTiles=this._usedTiles,v._sqMeters=this._sqMeters,v._htmlWidth=this._htmlWidth,v._supAreaSpreading=[...this._supAreaSpreading],v}dispose(){super.dispose()}}},70285:(tt,me,P)=>{P.d(me,{o:()=>E});var e=P(42400);
1class E{constructor(O){this.parameters=O,this.openspaceClearance=0,this.collaborativeClearance=0,this.utilityClearance=0}get tertiaryCorridorWidth(){return this.parameters?.tertiaryCorridorWidth||1}getModuleClearance(){return this.module.isOpenspace?this.openspaceClearance:this.module.category.type===e.G9.COLLABORATIVE?this.collaborativeClearance:this.module.category.type===e.G9.UTILITY?this.utilityClearance:0}}},92818:(tt,me,P)=>{P.d(me,{B:()=>v});var e=P(8239);const E=40,X=200,O=(()=>{if(typeof MessageChannel>"u")return()=>new Promise(a=>setTimeout(a,0));const g=new MessageChannel,r=[];return g.port1.onmessage=()=>r.shift()?.(),()=>new Promise(a=>{r.push(a),g.port2.postMessage(null)})})();function v(g){return h.apply(this,arguments)}function h(){return(h=(0,e.Z)(function*(g){const r=performance.now(),a=new Map,n=[{items:g,idx:0}];let l=performance.now();for(;n.length>0;){const y=n[n.length-1];if(y.idx>=y.items.length){n.pop();continue}const D=y.items[y.idx++],Y=performance.now(),H=D.clbk(),ne=performance.now()-Y,K=D.label??"unnamed",k=a.get(K)??{count:0,total:0};if(k.count++,k.total+=ne,a.set(K,k),ne>X&&console.debug(`Preparation "${K}" executed in ${Math.round(ne)}ms (since start: ${Math.round(performance.now()-r)}ms)`),Array.isArray(H)&&H.length>0)n.push({items:H,idx:0});else if(D.afterTimeout&&D.afterTimeout>0){yield new Promise(x=>setTimeout(x,D.afterTimeout)),l=performance.now();continue}performance.now()-l>E&&(yield O(),l=performance.now())}const p=[...a.entries()].sort((y,D)=>D[1].total-y[1].total).slice(0,10).map(([y,D])=>`${y}: ${Math.round(D.total)}ms (x${D.count})`).join(" | ");console.debug(`Preparations done in ${Math.round(performance.now()-r)}ms. Top: ${p}`)})).apply(this,arguments)}},60565:(tt,me,P)=>{P.d(me,{w:()=>e});var e=function(E){return E[E.IDLE=0]="IDLE",E[E.DIRTY=1]="DIRTY",E[E.DELETE=2]="DELETE",E}(e||{})},52785:(tt,me,P)=>{var e=P(10347);const E=O=>(O.changedTouches&&(O=O.changedTouches[0]),{x:O.clientX,y:O.clientY});class X{constructor(v){v.remember("_draggable",this),this.el=v,this.drag=this.drag.bind(this),this.startDrag=this.startDrag.bind(this),this.endDrag=this.endDrag.bind(this)}init(v){v?(this.el.on("mousedown.drag",this.startDrag),this.el.on("touchstart.drag",this.startDrag,{passive:!1})):(this.el.off("mousedown.drag"),this.el.off("touchstart.drag"))}startDrag(v){const h=!v.type.indexOf("mouse");if(h&&1!==v.which&&0!==v.buttons||this.el.dispatch("beforedrag",{event:v,handler:this}).defaultPrevented)return;v.preventDefault(),v.stopPropagation(),this.init(!1),this.box=this.el.bbox(),this.lastClick=this.el.point(E(v));const r=(h?"mouseup":"touchend")+".drag";(0,e.on)(window,(h?"mousemove":"touchmove")+".drag",this.drag,this,{passive:!1}),(0,e.on)(window,r,this.endDrag,this,{passive:!1}),this.el.fire("dragstart",{event:v,handler:this,box:this.box})}drag(v){const{box:h,lastClick:g}=this,r=this.el.point(E(v)),a=r.x-g.x,n=r.y-g.y;if(!a&&!n)return h;const l=h.x+a,p=h.y+n;this.box=new e.xu(l,p,h.w,h.h),this.lastClick=r,!this.el.dispatch("dragmove",{event:v,handler:this,box:this.box,dx:a,dy:n}).defaultPrevented&&this.move(l,p)}move(v,h){"svg"===this.el.type?e.G.prototype.move.call(this.el,v,h):this.el.move(v,h)}endDrag(v){this.drag(v),this.el.fire("dragend",{event:v,handler:this,box:this.box}),(0,e.S1)(window,"mousemove.drag"),(0,e.S1)(window,"touchmove.drag"),(0,e.S1)(window,"mouseup.drag"),(0,e.S1)(window,"touchend.drag"),this.init(!0)}}(0,e.l7)(e.W_,{draggable(O=!0){return(this.remember("_draggable")||new X(this)).init(O),this}})}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.