@ray-js/robot-map-sdk 0.0.3-beta-9 → 0.0.3-beta-11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/application/Interaction.js +1 -1
- package/dist/application/MapApplication.js +1 -1
- package/dist/assets/floorType1.png.js +1 -0
- package/dist/assets/floorType2.png.js +1 -0
- package/dist/components/Map/Free.js +1 -1
- package/dist/components/Map/Obstacle.js +1 -1
- package/dist/components/Path/index.js +1 -1
- package/dist/components/RoomFloorType/index.js +1 -1
- package/dist/components/RoomInfo/RoomProperty.js +1 -1
- package/dist/components/RoomInfo/RoomSelectionIndicator.js +1 -1
- package/dist/components/RoomInfo/index.js +1 -1
- package/dist/constant/config.js +1 -1
- package/dist/constant/methods.js +1 -1
- package/dist/index.d.ts +43 -1
- package/dist/index.rjs.js +1 -1
- package/dist/managers/MapManager.js +1 -1
- package/dist/managers/RoomManager.js +1 -1
- package/dist/utils/algorithm.js +1 -1
- package/dist-app/assets/{index-C3rjigWj.js → index-BZrSlwsu.js} +1 -1
- package/dist-app/index.html +1 -1
- package/dist-docs/404.html +2 -2
- package/dist-docs/assets/{app.BGQfBD4o.js → app.DQX-KXAE.js} +1 -1
- package/dist-docs/assets/chunks/@localSearchIndexroot.DFhlA73m.js +1 -0
- package/dist-docs/assets/chunks/{VPLocalSearchBox.YvMlJA6m.js → VPLocalSearchBox.DMOz5xxA.js} +1 -1
- package/dist-docs/assets/chunks/{theme.1StzhkaW.js → theme.BNIQfRMl.js} +2 -2
- package/dist-docs/assets/{guide_advanced-usage.md.ChUH15VJ.js → guide_advanced-usage.md.DUawnQ9c.js} +6 -6
- package/dist-docs/assets/{guide_advanced-usage.md.ChUH15VJ.lean.js → guide_advanced-usage.md.DUawnQ9c.lean.js} +1 -1
- package/dist-docs/assets/{guide_getting-started.md.D0sqgiqb.js → guide_getting-started.md.pCYbkwjy.js} +1 -1
- package/dist-docs/assets/{reference_methods.md.BkU-PXMt.js → reference_methods.md.B71e_LYO.js} +6 -3
- package/dist-docs/assets/{reference_methods.md.BkU-PXMt.lean.js → reference_methods.md.B71e_LYO.lean.js} +1 -1
- package/dist-docs/guide/advanced-usage.html +9 -9
- package/dist-docs/guide/concepts.html +3 -3
- package/dist-docs/guide/getting-started.html +5 -5
- package/dist-docs/hashmap.json +1 -1
- package/dist-docs/index.html +3 -3
- package/dist-docs/reference/callbacks.html +3 -3
- package/dist-docs/reference/config.html +3 -3
- package/dist-docs/reference/data.html +3 -3
- package/dist-docs/reference/methods.html +9 -6
- package/dist-docs/reference/runtime.html +3 -3
- package/dist-docs/reference/types.html +3 -3
- package/dist-docs/reference/utils.html +3 -3
- package/package.json +1 -1
- package/dist-docs/assets/chunks/@localSearchIndexroot.CSdgg9Q0.js +0 -1
- /package/dist/assets/{floorType.png.js → floorType3.png.js} +0 -0
- /package/dist-docs/assets/{guide_getting-started.md.D0sqgiqb.lean.js → guide_getting-started.md.pCYbkwjy.lean.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isEqual as t}from"lodash-es";import{Logger as o}from"../utils/logger.js";import{Rectangle as e}from"pixi.js";import{calculateRasterMapBounds as s,generateOutlineData as a,calculateRoomCenterPoint as r,mergeBounds as i,calculateRasterRoomCenter as n}from"../utils/algorithm.js";import{Obstacle as m}from"../components/Map/Obstacle.js";import{Free as h}from"../components/Map/Free.js";import{RoomFill as c}from"../components/Map/RoomFill.js";import{Carpet as p}from"../components/Map/Carpet.js";import{ChargingStation as l}from"../components/ChargingStation/index.js";import{subscribeKey as d}from"valtio/vanilla/utils";import{SPECIAL_ROOM_IDS as u}from"@ray-js/robot-protocol";import{useAppService as g}from"../application/AppService.js";class
|
|
1
|
+
import{isEqual as t}from"lodash-es";import{Logger as o}from"../utils/logger.js";import{Rectangle as e}from"pixi.js";import{calculateRasterMapBounds as s,generateOutlineData as a,calculateRoomCenterPoint as r,mergeBounds as i,calculateRasterRoomCenter as n}from"../utils/algorithm.js";import{Obstacle as m}from"../components/Map/Obstacle.js";import{Free as h}from"../components/Map/Free.js";import{RoomFill as c}from"../components/Map/RoomFill.js";import{Carpet as p}from"../components/Map/Carpet.js";import{ChargingStation as l}from"../components/ChargingStation/index.js";import{subscribeKey as d}from"valtio/vanilla/utils";import{SPECIAL_ROOM_IDS as u}from"@ray-js/robot-protocol";import{useAppService as g}from"../application/AppService.js";class M{obstacle=new m;free=new h;roomFill=new c;carpet=new p;chargingStation=new l;mapBounds={minX:0,minY:0,maxX:0,maxY:0};lastMapId=null;roomGeometryMap=new Map;rasterRoomPixelsMap=new Map;carpetData=null;unsubscribeFns=[];constructor(){const t=g(),e=d(t.runtime,"enableRoomSelection",e=>{if(o.log(`[runtime] enableRoomSelection: ${e}`),e){this.roomFill.setAllRoomsState(!1);const o=t.runtimeSnapshot.selectRoomIds;this.roomFill.setRoomStateBySelectIds(o)}else this.roomFill.setAllRoomsState(!0)}),s=d(t.runtime,"selectRoomIds",t=>{o.log(`[runtime] selectRoomIds: ${t}`),this.roomFill.setRoomStateBySelectIds(t)}),a=d(t.runtime,"showChargingStation",t=>{o.log(`[runtime] showChargingStation: ${t}`),this.chargingStation.visible=t}),r=d(t.runtime,"showCarpet",t=>{o.log(`[runtime] showCarpet: ${t}`),t?this.createCarpet():this.carpet.clearCarpet()});this.unsubscribeFns.push(e,s,a,r)}async drawMap(e){const s=g(),{id:a,obstacles:r,free:i,rooms:n,charger:m,carpet:h}=e;this.clearComponents(),this.resetGeometryData();const c=this.processRoomsGeometry(n);this.roomFill.draw(c),this.free.draw(i),this.obstacle.draw(r),this.carpetData={type:"structured",carpetData:h},this.createCarpet();const p=this.mergeLayerBounds();t(p,this.mapBounds)||(o.debug("[Map] Map bounds updated:",p),this.mapBounds=p,this.lastMapId!==a&&(s.getApp().fitMapToView(this.mapBounds),this.lastMapId=a));const l=((e.charger.angle??0)+s.chargingStationConfig.rotationCorrection)*Math.PI/180;return await this.chargingStation.draw({x:m.coordinate[0],y:m.coordinate[1],rotation:l}),s.roomsManager.refresh(),!0}async drawRasterMap(e,a){const r=g();this.clearComponents();const{id:i,width:n,height:m,charger:h,chargerDirection:c}=a;o.debug("[Map] Parsed Raster Map Data",e),this.obstacle.drawRaster(e.obstacles,n),this.carpetData={type:"raster",carpetPixels:e.carpet,mapWidth:n},this.createCarpet();const p=this.processRasterData(e);this.roomFill.drawRaster(p);const l=s(e,n,m);t(l,this.mapBounds)||(o.debug("[Map] Raster map bounds updated:",l),this.mapBounds=l,this.lastMapId!==i&&(r.getApp().fitMapToView(this.mapBounds),this.lastMapId=i));const d=(c+r.chargingStationConfig.rotationCorrection)*Math.PI/180;return await this.chargingStation.draw({x:h.x,y:h.y,rotation:d}),this.generateRoomGeometryFromRaster(e),r.roomsManager.refresh(),!0}resetGeometryData(){this.roomGeometryMap.clear(),this.rasterRoomPixelsMap.clear(),this.mapBounds={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}async createCarpet(){if(g().runtimeSnapshot.showCarpet&&this.carpetData)if("raster"===this.carpetData.type){const{carpetPixels:t,mapWidth:o}=this.carpetData;await this.carpet.createCarpetFromRasterData(t,o)}else if("structured"===this.carpetData.type){const{carpetData:t}=this.carpetData;await this.carpet.createCarpetFromStructuredData(t)}}processRoomsGeometry(t){if(!t)return[];const o=g(),{active:s}=o.roomConfig.colors,i=o.roomConfig.colors[u.UNKNOWN_ROOM];if(0===Object.keys(t).length)return this.mapBounds={minX:0,minY:0,maxX:0,maxY:0},[];const n=Object.keys(t).sort((t,o)=>Number(t)-Number(o)),m=n.filter(t=>Number(t)<255),h=n.filter(t=>Number(t)>=255),c=[];return m.forEach((o,i)=>{const{coordinates:n}=t[o];if(n.length<4)return;const m=Number(o),h=i%s.length,p=s[h];let l=1/0,d=1/0,u=-1/0,g=-1/0;const M=[];for(let t=0;t<n.length;t+=2){const o=n[t],e=n[t+1];l=Math.min(l,o),d=Math.min(d,e),u=Math.max(u,o),g=Math.max(g,e),M.push({x:o,y:e})}const f=new e(l,d,u-l+1,g-d+1),x=a(M),y=x.flatMap(t=>[t.x+.5,t.y+.5]),b={id:m,color:p,boundingBox:f,points:M,outlinePoints:x,polyPoints:y,centerPoint:r(x,l,d,u,g)};this.roomGeometryMap.set(m,b),c.push(b),this.mapBounds.minX=Math.min(this.mapBounds.minX,l),this.mapBounds.minY=Math.min(this.mapBounds.minY,d),this.mapBounds.maxX=Math.max(this.mapBounds.maxX,u),this.mapBounds.maxY=Math.max(this.mapBounds.maxY,g)}),h.forEach(o=>{const{coordinates:s}=t[o];if(s.length<4)return;const n=Number(o);let m=1/0,h=1/0,p=-1/0,l=-1/0;const d=[];for(let t=0;t<s.length;t+=2){const o=s[t],e=s[t+1];m=Math.min(m,o),h=Math.min(h,e),p=Math.max(p,o),l=Math.max(l,e),d.push({x:o,y:e})}const u=new e(m,h,p-m+1,l-h+1),g=a(d),M=g.flatMap(t=>[t.x+.5,t.y+.5]),f=r(g,m,h,p,l),x={id:n,color:i,boundingBox:u,points:d,outlinePoints:g,polyPoints:M,centerPoint:f};c.push(x),this.mapBounds.minX=Math.min(this.mapBounds.minX,m),this.mapBounds.minY=Math.min(this.mapBounds.minY,h),this.mapBounds.maxX=Math.max(this.mapBounds.maxX,p),this.mapBounds.maxY=Math.max(this.mapBounds.maxY,l)}),c}mergeLayerBounds(){let t={...this.mapBounds};if(this.obstacle.bounds&&(t=i(t,this.obstacle.bounds)),this.roomFill.children.length>0){const o=this.roomFill.getLocalBounds();o.width>0&&o.height>0&&(t=i(t,{minX:o.x,minY:o.y,maxX:o.x+o.width,maxY:o.y+o.height}))}return t}getRoomById(t){return this.roomGeometryMap.get(t)}clearComponents(){this.obstacle.clear(),this.obstacle.destroy(),this.obstacle=new m,this.free.clear(),this.free.destroy(),this.free=new h,this.carpet.clearCarpet(),this.carpetData=null,this.roomFill.removeChildren(),this.roomFill.destroy(),this.roomFill=new c}processRasterData(t){const o=g().roomConfig,e=[],s=[];t.rooms.forEach((t,o)=>{"number"==typeof o?e.push([o,t]):s.push([o,t])}),e.sort(([t],[o])=>t-o);const a=[...e.map(([t,e],s)=>{const a=s%o.colors.active.length,r=s%o.colors.inactive.length;return{roomId:t,pixelIndices:e,activeColor:o.colors.active[a],inactiveColor:o.colors.inactive[r]}}),...s.map(([t,e])=>{const s=o.colors[t]||"#ebebeb";return{roomId:t,pixelIndices:e,activeColor:s,inactiveColor:s}})];return{obstacles:t.obstacles,carpet:t.carpet,sortedRooms:a,width:t.width,height:t.height,totalPixels:t.totalPixels}}generateRoomGeometryFromRaster(t){const o=g();this.roomGeometryMap.clear(),this.rasterRoomPixelsMap.clear();const{active:s}=o.roomConfig.colors,a=[];t.rooms.forEach((t,o)=>{"number"==typeof o&&a.push(o)}),a.sort((t,o)=>t-o),a.forEach((o,a)=>{const r=t.rooms.get(o);this.rasterRoomPixelsMap.set(o,r);let i=1/0,m=1/0,h=-1/0,c=-1/0;for(let o=0;o<r.length;o++){const e=r[o],s=e%t.width,a=Math.floor(e/t.width);i=Math.min(i,s),m=Math.min(m,a),h=Math.max(h,s),c=Math.max(c,a)}const p=n(r,t.width,i,m,h,c),l=a%s.length,d={id:o,color:s[l],boundingBox:new e(i,m,h-i+1,c-m+1),points:[],outlinePoints:[],polyPoints:[],centerPoint:p};this.roomGeometryMap.set(o,d)})}getRasterRoomPixels(t){return this.rasterRoomPixelsMap.get(t)}destroy(){this.obstacle.destroy(),this.free.destroy(),this.roomFill.destroy(),this.carpet.destroy(),this.chargingStation.destroy(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[]}}export{M as MapManager};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Container as o}from"pixi.js";import{LAYER_ROOM_INFO as t}from"../application/AppContainer.js";import{RoomInfo as i}from"../components/RoomInfo/index.js";import{RoomFloorType as e}from"../components/RoomFloorType/index.js";import{subscribeKey as r}from"valtio/vanilla/utils";import{Logger as s}from"../utils/logger.js";import{useAppService as n}from"../application/AppService.js";class a{unsubscribeFns=[];roomInfoContainer=new o;roomInfoMap=new Map;roomDisplayMap=new Map;roomFloorType=new e;constructor(){const o=n();o.appContainer.addToLayer(t,this.roomInfoContainer);const i=r(o.runtime,"showRoomFloorType",o=>{s.log(`[runtime] showRoomFloorType: ${o}`),o?this.updateFloorTypes():this.roomFloorType.clearFloorTypes()}),e=r(o.runtime,"showRoomProperty",o=>{s.log(`[runtime] showRoomProperty: ${o}`),this.updateAllRoomPropertyVisibility()}),a=r(o.runtime,"showRoomOrder",o=>{s.log(`[runtime] showRoomOrder: ${o}`),this.updateAllRoomPropertyVisibility()}),m=r(o.runtime,"roomPropertyFoldIds",o=>{s.log(`[runtime] roomPropertyFoldIds: ${o}`),this.updateAllRoomPropertyVisibility()}),l=r(o.runtime,"showRoomName",o=>{s.log(`[runtime] showRoomName: ${o}`),this.updateAllRoomNameVisibility(o)}),p=r(o.runtime,"enableRoomSelection",o=>{s.log(`[runtime] enableRoomSelection: ${o}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility()}),c=r(o.runtime,"selectRoomIds",o=>{s.log(`[runtime] selectRoomIds: ${o}`),this.updateAllRoomSelectionIndicatorVisibility()}),h=r(o.runtime,"roomSelectionMode",o=>{s.log(`[runtime] roomSelectionMode: ${o}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility()});this.unsubscribeFns.push(i,e,a,m,l,p,c,h)}drawRoomProperty(o){const t=n();return this.roomDisplayMap.clear(),o.forEach((o,i)=>{const e=t.mapManager.getRoomById(o.id),r={...o,centerPoint:e?.centerPoint||null,index:i};this.roomDisplayMap.set(o.id,r)}),this.updateRoomInfoDisplay(),this.updateFloorTypes(),!0}updateRoomInfoDisplay(){if(0===this.roomDisplayMap.size)return;const o=Array.from(this.roomDisplayMap.values()).filter(o=>null!==o.centerPoint);this.clearRoomInfos(),o.forEach(o=>{this.createRoomInfo(o)})}createRoomInfo(o){const t=new i(o);this.roomInfoContainer.addChild(t),this.roomInfoMap.set(o.id,t)}updateRoomName(o,t){const i=this.roomInfoMap.get(o);i&&i.updateName(t)}updateRoomPosition(o,t){const i=this.roomDisplayMap.get(o);i&&(i.centerPoint=t);const e=this.roomInfoMap.get(o);e&&e.updatePosition(t)}clearRoomInfos(){this.roomInfoMap.forEach(o=>{o.destroy()}),this.roomInfoMap.clear(),this.roomInfoContainer.removeChildren()}getRoomPropertyById(o){return this.roomDisplayMap.get(o)}refresh(){const o=n();this.roomFloorType.clearFloorTypes(),this.roomDisplayMap.forEach((t,i)=>{const e=o.mapManager.getRoomById(i),r=e?.centerPoint||null;if(t.centerPoint!==r){t.centerPoint=r;const o=this.roomInfoMap.get(i);o&&r&&o.updatePosition(r)}}),this.updateRoomInfoDisplay(),this.updateFloorTypes()}updateAllRoomPropertyVisibility(){this.roomInfoMap.forEach(o=>{o.updateRoomPropertyVisibility()})}updateAllRoomNameVisibility(o){this.roomInfoMap.forEach(t=>{t.updateRoomNameVisibility(o)})}updateAllRoomSelectionIndicatorVisibility(){this.roomInfoMap.forEach(o=>{o.updateRoomSelectionIndicatorVisibility()})}async updateFloorTypes(){const o=n(),t=o.mapManager.roomFill.getRoomGraphicsMap();t.size>0&&(await this.roomFloorType.createFloorTypes(t),o.getApp().renderOnceNextFrame())}destroy(){this.clearRoomInfos(),this.roomInfoContainer.destroy(),this.roomFloorType.destroy(),this.unsubscribeFns.forEach(o=>o()),this.unsubscribeFns=[]}}export{a as RoomManager};
|
|
1
|
+
import{Container as o}from"pixi.js";import{LAYER_ROOM_INFO as t}from"../application/AppContainer.js";import{RoomInfo as i}from"../components/RoomInfo/index.js";import{RoomFloorType as e}from"../components/RoomFloorType/index.js";import{subscribeKey as r}from"valtio/vanilla/utils";import{Logger as s}from"../utils/logger.js";import{useAppService as n}from"../application/AppService.js";class a{unsubscribeFns=[];roomInfoContainer=new o;roomInfoMap=new Map;roomDisplayMap=new Map;roomFloorType=new e;constructor(){const o=n();o.appContainer.addToLayer(t,this.roomInfoContainer);const i=r(o.runtime,"showRoomFloorType",o=>{s.log(`[runtime] showRoomFloorType: ${o}`),o?this.updateFloorTypes():this.roomFloorType.clearFloorTypes()}),e=r(o.runtime,"showRoomProperty",o=>{s.log(`[runtime] showRoomProperty: ${o}`),this.updateAllRoomPropertyVisibility()}),a=r(o.runtime,"showRoomOrder",o=>{s.log(`[runtime] showRoomOrder: ${o}`),this.updateAllRoomPropertyVisibility()}),m=r(o.runtime,"roomPropertyFoldIds",o=>{s.log(`[runtime] roomPropertyFoldIds: ${o}`),this.updateAllRoomPropertyVisibility()}),l=r(o.runtime,"showRoomName",o=>{s.log(`[runtime] showRoomName: ${o}`),this.updateAllRoomNameVisibility(o)}),p=r(o.runtime,"enableRoomSelection",o=>{s.log(`[runtime] enableRoomSelection: ${o}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility()}),c=r(o.runtime,"selectRoomIds",o=>{s.log(`[runtime] selectRoomIds: ${o}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility()}),h=r(o.runtime,"roomSelectionMode",o=>{s.log(`[runtime] roomSelectionMode: ${o}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility()});this.unsubscribeFns.push(i,e,a,m,l,p,c,h)}drawRoomProperty(o){const t=n();return this.roomDisplayMap.clear(),o.forEach((o,i)=>{const e=t.mapManager.getRoomById(o.id),r={...o,centerPoint:e?.centerPoint||null,index:i};this.roomDisplayMap.set(o.id,r)}),this.updateRoomInfoDisplay(),this.updateFloorTypes(),!0}updateRoomInfoDisplay(){if(0===this.roomDisplayMap.size)return;const o=Array.from(this.roomDisplayMap.values()).filter(o=>null!==o.centerPoint);this.clearRoomInfos(),o.forEach(o=>{this.createRoomInfo(o)})}createRoomInfo(o){const t=new i(o);this.roomInfoContainer.addChild(t),this.roomInfoMap.set(o.id,t)}updateRoomName(o,t){const i=this.roomInfoMap.get(o);i&&i.updateName(t)}updateRoomPosition(o,t){const i=this.roomDisplayMap.get(o);i&&(i.centerPoint=t);const e=this.roomInfoMap.get(o);e&&e.updatePosition(t)}clearRoomInfos(){this.roomInfoMap.forEach(o=>{o.destroy()}),this.roomInfoMap.clear(),this.roomInfoContainer.removeChildren()}getRoomPropertyById(o){return this.roomDisplayMap.get(o)}refresh(){const o=n();this.roomFloorType.clearFloorTypes(),this.roomDisplayMap.forEach((t,i)=>{const e=o.mapManager.getRoomById(i),r=e?.centerPoint||null;if(t.centerPoint!==r){t.centerPoint=r;const o=this.roomInfoMap.get(i);o&&r&&o.updatePosition(r)}}),this.updateRoomInfoDisplay(),this.updateFloorTypes()}updateAllRoomPropertyVisibility(){this.roomInfoMap.forEach(o=>{o.updateRoomPropertyVisibility()})}updateAllRoomNameVisibility(o){this.roomInfoMap.forEach(t=>{t.updateRoomNameVisibility(o)})}updateAllRoomSelectionIndicatorVisibility(){this.roomInfoMap.forEach(o=>{o.updateRoomSelectionIndicatorVisibility()})}async updateFloorTypes(){const o=n(),t=o.mapManager.roomFill.getRoomGraphicsMap();t.size>0&&(await this.roomFloorType.createFloorTypes(t),o.getApp().renderOnceNextFrame())}destroy(){this.clearRoomInfos(),this.roomInfoContainer.destroy(),this.roomFloorType.destroy(),this.unsubscribeFns.forEach(o=>o()),this.unsubscribeFns=[]}}export{a as RoomManager};
|
package/dist/utils/algorithm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const t=t=>{if(t.length<=1)return[...t];const r=n(t),
|
|
1
|
+
const t=t=>{if(t.length<=1)return[...t];const r=n(t),e=r.slice(1).map((t,n)=>({prev:r[n],current:t})),y=new Map;return e.forEach(({prev:t,current:n})=>{x(t,n).forEach(t=>{const n=`${t.x},${t.y}`;y.has(n)||y.set(n,t)})}),Array.from(y.values())},n=t=>{if(t.length<=1)return[...t];const n=t[0],x=t[t.length-1];return n.x===x.x&&n.y===x.y?[...t]:[...t,n]},x=(t,n)=>{const x=[],r=Math.abs(n.x-t.x),e=Math.abs(n.y-t.y),y=t.x<n.x?1:-1,a=t.y<n.y?1:-1;let o=r-e,h=t.x,s=t.y;for(;x.push({x:h,y:s}),h!==n.x||s!==n.y;){const t=2*o;t>-e&&(o-=e,h+=y),t<r&&(o+=r,s+=a)}return x},r=(t,n,x=1,r=2e3)=>{const e=[],y=n.x-t.x,a=n.y-t.y,o=Math.sqrt(y*y+a*a);if(0===o)return[t];const h=Math.min(Math.max(Math.ceil(o/x),2),r);for(let n=0;n<=h;n++){const x=n/h,r={x:t.x+x*y,y:t.y+x*a};e.push(r)}return e},e=(t,n,x,r,e,o=8)=>{const s={x:(n+r)/2,y:(x+e)/2},i=r-n,m=e-x,c=Math.min(o,.2*Math.min(i,m));return h(s,t)&&a(s,t)>=c?s:y(t,s,c)},y=(t,n,x)=>{const{minX:r,minY:e,maxX:y,maxY:o}=m(t),s=y-r,i=o-e,c=n.x,l=n.y,u=Math.min(.5,.05*Math.min(s,i)),f=[];if(h({x:c,y:l},t)){const n=a({x:c,y:l},t);f.push({point:{x:c,y:l},distance:n,centerDistance:0})}const g=.6*Math.max(s,i),p=Math.PI/16;for(let n=u;n<=g;n+=u){const s=p*(1+n/g);for(let i=0;i<2*Math.PI;i+=s){const s=c+n*Math.cos(i),m=l+n*Math.sin(i);if(s>=r&&s<=y&&m>=e&&m<=o){const n={x:s,y:m};if(h(n,t)){const r=a(n,t),e=M({x:s,y:m},{x:c,y:l});r>=x&&f.push({point:n,distance:r,centerDistance:e})}}}if(f.length>=15)break}if(f.length>0){const t=f.map(t=>({...t,score:1.5*t.distance-.5*t.centerDistance}));return t.sort((t,n)=>n.score-t.score),t[0].point}if(0===f.length){let n={x:c,y:l},x=0;const s=2*u;for(let i=r;i<=y;i+=s)for(let r=e;r<=o;r+=s){const e={x:i,y:r};if(h(e,t)){const r=a(e,t);r>x&&(x=r,n=e)}}return n}return{x:c,y:l}},a=(t,n)=>{let x=1/0;for(let r=0,e=n.length-1;r<n.length;e=r++){const y=n[e],a=n[r],h=o(t,y,a);x=Math.min(x,h)}return x},o=(t,n,x)=>{const r=(n.x-x.x)**2+(n.y-x.y)**2;if(0===r)return M(t,n);const e=Math.max(0,Math.min(1,((t.x-n.x)*(x.x-n.x)+(t.y-n.y)*(x.y-n.y))/r)),y=n.x+e*(x.x-n.x),a=n.y+e*(x.y-n.y);return M(t,{x:y,y:a})},h=(t,n,x=!1)=>{if(n.length<3)return!1;if(x&&s(t,n))return!0;let r=!1;for(let x=0,e=n.length-1;x<n.length;e=x++){const y=n[x].x,a=n[x].y,o=n[e].x,h=n[e].y;a>t.y!=h>t.y&&t.x<(o-y)*(t.y-a)/(h-a)+y&&(r=!r)}return r},s=(t,n)=>{if(n.length<2)return!1;for(let x=0;x<n.length;x++){const r=(x+1)%n.length;if(i(t,n[x],n[r]))return!0}return!1},i=(t,n,x,r=.5)=>{if(o(t,n,x)>r)return!1;const e=Math.min(n.x,x.x)-r,y=Math.max(n.x,x.x)+r,a=Math.min(n.y,x.y)-r,h=Math.max(n.y,x.y)+r;return t.x>=e&&t.x<=y&&t.y>=a&&t.y<=h},m=t=>{if(0===t.length)return{minX:0,minY:0,maxX:0,maxY:0};let n=1/0,x=1/0,r=-1/0,e=-1/0;for(const y of t)n=Math.min(n,y.x),x=Math.min(x,y.y),r=Math.max(r,y.x),e=Math.max(e,y.y);return{minX:n,minY:x,maxX:r,maxY:e}},c=t=>{const n=t.reduce((t,n)=>({x:t.x+n.x,y:t.y+n.y}),{x:0,y:0});return{x:n.x/t.length,y:n.y/t.length}},l=t=>{if(4!==t.length)return t;const n=c(t),x=M(t[0],t[1]),r=M(t[1],t[2]),e=Math.atan2(t[1].y-t[0].y,t[1].x-t[0].x),y=[{x:-x/2,y:-r/2},{x:x/2,y:-r/2},{x:x/2,y:r/2},{x:-x/2,y:r/2}],a=Math.cos(e),o=Math.sin(e);return y.map(t=>({x:t.x*a-t.y*o+n.x,y:t.x*o+t.y*a+n.y}))},u=(t,n,x,r=10)=>{if(0===x)return 1;const e=(t.x*n.x+t.y*n.y)/x/x,y=r/x;return e<=0?y:Math.max(e,y)},M=(t,n)=>{const x=t.x-n.x,r=t.y-n.y;return Math.sqrt(x*x+r*r)},f=t=>Math.sqrt(t.x*t.x+t.y*t.y),g=(t,n)=>({x:n.x-t.x,y:n.y-t.y}),p=t=>{const n=f(t);return 0===n?{x:0,y:0}:{x:t.x/n,y:t.y/n}},X=(t,n)=>{const x=g(t,n);return p(x)},Y=t=>({x:-t.y,y:t.x}),d=(t,n)=>{const x=X(t,n);return Y(x)},w=(t,n)=>{const x=p(t),r=p(n),e={x:(x.x+r.x)/2,y:(x.y+r.y)/2};return p(e)},$=(t,n)=>{const x=g(t,n);let r=Math.atan2(x.y,x.x);return(r>Math.PI/2||r<-Math.PI/2)&&(r+=Math.PI),r},b=(t,n,x)=>{const r=c([t,n]),e=d(t,n);return{x:r.x+e.x*x,y:r.y+e.y*x}},q=(t,n,x)=>{const r=Math.cos(x),e=Math.sin(x),y=t.x-n.x,a=t.y-n.y;return{x:y*r-a*e+n.x,y:y*e+a*r+n.y}},I=(t,n,x)=>t.map(t=>q(t,n,x)),P=(t,n,x)=>{if(0===M(t,n))return[t,t,t,t];const r=X(t,n),e=Y(r),y=t.x-r.x*x,a=t.y-r.y*x,o=n.x+r.x*x,h=n.y+r.y*x;return[{x:y+e.x*x,y:a+e.y*x},{x:o+e.x*x,y:h+e.y*x},{x:o-e.x*x,y:h-e.y*x},{x:y-e.x*x,y:a-e.y*x}]},E=(t,n)=>{if(t.length<3)return t;const x=[];for(let r=0;r<t.length;r++){const e=t[r],y=t[(r+1)%t.length],a=t[(r-1+t.length)%t.length],o=g(e,y);if(0===f(o)){x.push(e);continue}const h=p(o),s={x:h.y,y:-h.x},i=g(a,e);let m={x:0,y:0};if(f(i)>0){const t=p(i);m={x:t.y,y:-t.x}}const c=w(m,s),l=m.x*s.x+m.y*s.y,u=1/Math.max(.1,Math.sqrt((1+l)/2)),M={x:e.x+c.x*n*u,y:e.y+c.y*n*u};x.push(M)}return x},v=(t,n,x)=>{if(0===M(t,n))return[];const r=d(t,n),e=x/2;return[t.x+r.x*e,t.y+r.y*e,n.x+r.x*e,n.y+r.y*e,n.x-r.x*e,n.y-r.y*e,t.x-r.x*e,t.y-r.y*e]},A=(t,n,x,r)=>{const e=g(t,n),y=g(t,x),a=w(e,y),o=-a.x,h=-a.y;return{x:t.x+o*r,y:t.y+h*r}},D=(t,n,x,r,e,y)=>{const a=new Set(t),o=S(t,n);return k(o,a,n,x,r,e,y)||o},S=(t,n)=>{let x=0,r=0;for(let e=0;e<t.length;e++){const y=t[e];x+=y%n,r+=Math.floor(y/n)}return{x:x/t.length,y:r/t.length}},k=(t,n,x,r,e,y,a)=>{const o={x:r-10,y:t.y},h={x:y+10,y:t.y},s={x:y,y:e},i={x:y,y:a},m=z(o,h,{x:r,y:e},{x:r,y:a}),c=z(o,h,s,i);if(!m||!c)return null;const l=[],u=Math.max(r,Math.min(m.x,c.x)),M=Math.min(y,Math.max(m.x,c.x)),f=Math.round(t.y);for(let t=Math.round(u);t<=Math.round(M);t++){const r=f*x+t;n.has(r)&&l.push({x:t,y:f})}if(l.length>=2){const t=j(l),r={x:(t.min.x+t.max.x)/2,y:(t.min.y+t.max.y)/2},e=Math.round(r.y)*x+Math.round(r.x);if(n.has(e))return r}return null},z=(t,n,x,r)=>{const e=(t.x-x.x)*(n.y-x.y)-(t.y-x.y)*(n.x-x.x),y=(t.x-r.x)*(n.y-r.y)-(t.y-r.y)*(n.x-r.x);if(e*y>=0)return null;const a=(x.x-t.x)*(r.y-t.y)-(x.y-t.y)*(r.x-t.x);if(a*(a+e-y)>=0)return null;const o=a/(y-e),h=o*(n.x-t.x),s=o*(n.y-t.y);return{x:t.x+h,y:t.y+s}},j=t=>{if(!t||0===t.length)return{min:{x:0,y:0},max:{x:0,y:0}};let n=t[0],x=t[0];const r=t=>t.x-t.y;for(let e=1;e<t.length;e++){const y=t[e];r(y)<r(n)&&(n=y),r(y)>r(x)&&(x=y)}return{min:n,max:x}},B=(t,n)=>({minX:Math.min(t.minX,n.minX),minY:Math.min(t.minY,n.minY),maxX:Math.max(t.maxX,n.maxX),maxY:Math.max(t.maxY,n.maxY)}),C=t=>{if(0===t.length)return{x:0,y:0,width:0,height:0};let n=t[0].x,x=t[0].y,r=t[0].x+t[0].width,e=t[0].y+t[0].height;return t.forEach(t=>{n=Math.min(n,t.x),x=Math.min(x,t.y),r=Math.max(r,t.x+t.width),e=Math.max(e,t.y+t.height)}),{x:n,y:x,width:r-n,height:e-x}},F=(t,n,x)=>{let r=1/0,e=1/0,y=-1/0,a=-1/0;for(let x=0;x<t.obstacles.length;x++){const o=t.obstacles[x],h=o%n,s=Math.floor(o/n);r=Math.min(r,h),e=Math.min(e,s),y=Math.max(y,h),a=Math.max(a,s)}return t.rooms.forEach(t=>{for(let x=0;x<t.length;x++){const o=t[x],h=o%n,s=Math.floor(o/n);r=Math.min(r,h),e=Math.min(e,s),y=Math.max(y,h),a=Math.max(a,s)}}),r===1/0?{minX:0,minY:0,maxX:n,maxY:x}:{minX:Math.max(0,r),minY:Math.max(0,e),maxX:Math.min(n,y),maxY:Math.min(x,a)}},G=(t,n,x,r,e,y)=>{const a=x+e,o=r+y,h=Math.min(t.x,n.x),s=Math.max(t.x,n.x),i=Math.min(t.y,n.y),m=Math.max(t.y,n.y);if(s<x||h>a||m<r||i>o)return!1;if(H(t,x,r,e,y)||H(n,x,r,e,y))return!0;const c=[{x:x,y:r},{x:a,y:r},{x:a,y:o},{x:x,y:o}];for(let x=0;x<4;x++)if(z(t,n,c[x],c[(x+1)%4]))return!0;return!1},H=(t,n,x,r,e)=>t.x>=n&&t.x<=n+r&&t.y>=x&&t.y<=x+e,J=(t,n,x,r)=>{const e=x/2;return"horizontal"===r?[{x:t-e,y:n},{x:t+e,y:n}]:[{x:t,y:n-e},{x:t,y:n+e}]},K=(t,n,x)=>{const r=n.x-t.x,e=n.y-t.y,y=Math.sqrt(r*r+e*e);if(0===y)return[t,n];const a=r/y,o=e/y;return[{x:t.x-a*x,y:t.y-o*x},{x:n.x+a*x,y:n.y+o*x}]},L=(t,n,x)=>{const r=m(t),e=m(n),y=Math.max(0,Math.max(r.minX,e.minX)-Math.min(r.maxX,e.maxX)),a=Math.max(0,Math.max(r.minY,e.minY)-Math.min(r.maxY,e.maxY));if(y>x||a>x)return!1;let[o,h]=[t,n];n.length>t.length&&([o,h]=[n,t]);const s=Math.max(1,Math.floor(x)),i=new Map;for(const t of o){const n=`${Math.floor(t.x/s)},${Math.floor(t.y/s)}`;i.has(n)||i.set(n,[]),i.get(n).push(t)}const c=x*x;for(const t of h){const n=Math.floor(t.x/s),x=Math.floor(t.y/s);for(let r=-1;r<=1;r++)for(let e=-1;e<=1;e++){const y=`${n+r},${x+e}`,a=i.get(y);if(a)for(const n of a){const x=t.x-n.x,r=t.y-n.y;if(x*x+r*r<=c)return!0}}}return!1},N=(t,n,x,r)=>{let[e,y]=[t,n];n.length>t.length&&([e,y]=[n,t]);const a=new Set(e),o=r*r;for(let t=0;t<y.length;t++){const n=y[t],e=n%x,h=Math.floor(n/x);for(let t=-r;t<=r;t++)for(let n=-r;n<=r;n++){const r=(h+n)*x+(e+t);if(a.has(r)&&t*t+n*n<=o)return!0}}return!1},O=(t,n)=>{if(t<=1)return!0;if(0===n.length)return!1;const x=Array.from({length:t},(t,n)=>n),r=Array(t).fill(0),e=t=>(x[t]!==t&&(x[t]=e(x[t])),x[t]),y=(t,n)=>{const y=e(t),a=e(n);y!==a&&(r[y]<r[a]?x[y]=a:r[y]>r[a]?x[a]=y:(x[a]=y,r[y]++))};for(const[t,x]of n)y(t,x);const a=e(0);for(let n=1;n<t;n++)if(e(n)!==a)return!1;return!0};export{O as areMultipleRoomsConnected,N as areRasterRoomsAdjacent,L as areStructuredRoomsAdjacent,m as calculateBoundingBox,c as calculateCenter,x as calculateCoordinatesBetweenPoints,A as calculateCornerExtension,J as calculateLineEndpoints,b as calculateLineMidpointOffset,v as calculateLineSegmentHitArea,P as calculateLineSegmentOutline,C as calculateMergedBounds,a as calculateMinDistanceToBoundary,S as calculatePixelWeightedCenter,E as calculatePolygonOutline,F as calculateRasterMapBounds,D as calculateRasterRoomCenter,e as calculateRoomCenterPoint,u as calculateScaleRatio,$ as calculateUprightLineAngle,g as createVector,n as ensureClosedPath,K as extendLineSegment,y as findBestInnerPoint,j as findExtremePoints,t as generateOutlineData,w as getBisectorDirection,M as getDistance,d as getPerpendicularUnitVector,Y as getPerpendicularVector,X as getUnitVector,f as getVectorLength,H as isPointInBox,h as isPointInPolygon,i as isPointOnLineSegment,s as isPointOnPolygonBoundary,G as lineIntersectsBox,z as lineSegmentsIntersection,B as mergeBounds,l as normalizeToRectangle,p as normalizeVector,k as optimizeRasterCenterWithLineIntersection,o as pointToSegmentDistance,q as rotatePointAroundCenter,I as rotatePointsAroundCenter,r as sampleLinePoints};
|