/*!
 * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
 */
import{p as t,e as i}from"./p-DfdVaPrt.js";import{r as s,E as n,c as e}from"./p-BuOEMGyM.js";class r{constructor(t,i="view",s="pin-icon",n=undefined){this.model=t;this.mode=i;this.type=s;this.styleAttributes=n}addPin(t){this.model.addPin(t)}clearPins(){this.model.clearPins()}removePin(t){this.model.removePin(t)}setPins(t){this.model.setPins(t)}setPin(t){this.model.setPin(t)}updatePin(t){this.model.updatePin(t)}setSelectedPinId(t){this.model.setSelectedPin(t)}getToolMode(){return this.mode}getToolType(){return this.type}setToolMode(t){this.mode=t}setToolType(t){this.type=t}getDraggable(){return this.draggable}setDraggable(t){this.draggable=t}setPrimaryColor(t){this.styleAttributes={...this.styleAttributes,primaryColor:t}}setAccentColor(t){this.styleAttributes={...this.styleAttributes,accentColor:t}}getStyleAttributes(){return this.styleAttributes}updateDraggable(t,i,s){if(this.draggable!=null){this.draggable=t}const n=this.model.getPinById(t.id);if(n!=null){this.updatePin({...n,worldPosition:i,partId:s})}}}function o(i,s){const n=Math.max(s.start,Math.min(s.end,i.x));const e=Math.max(s.start,Math.min(s.end,i.y));return t.create(n,e)}function h(s,n){return t.add(t.scale(s,n.width,n.height),i.center(n))}function l(n,e,r,h,l){const u=1/e.height;const d=1/e.width;const a=i.center(e);const c=t.scale(t.subtract(n,a),d,u);if(r){const i=t.scale(t.create(h,l),d,u);const e=a.x>n.x;const r=e?i.x:-3*i.x;const v=a.y>n.y;const f=v?i.y:-3*i.y;const P=t.add(c,t.create(r,f));return o(P,s.create(-.5,.5))}else{return o(c,s.create(-.5,.5))}}function u(t){return(t===null||t===void 0?void 0:t.type)==="text"}function d(t){return(t===null||t===void 0?void 0:t.type)==="icon"}function a(t){return typeof t==="string"?t:e.toHexString(t)}function c(t){var i,s,n,e,r,o,h,l;return{primaryColor:((s=(i=t===null||t===void 0?void 0:t.attributes)===null||i===void 0?void 0:i.style)===null||s===void 0?void 0:s.primaryColor)==null?undefined:a((e=(n=t===null||t===void 0?void 0:t.attributes)===null||n===void 0?void 0:n.style)===null||e===void 0?void 0:e.primaryColor),accentColor:((o=(r=t===null||t===void 0?void 0:t.attributes)===null||r===void 0?void 0:r.style)===null||o===void 0?void 0:o.accentColor)==null?undefined:a((l=(h=t===null||t===void 0?void 0:t.attributes)===null||h===void 0?void 0:h.style)===null||l===void 0?void 0:l.accentColor)}}class v{constructor(){this.entities={};this.entityAdded=new n;this.entityUpdated=new n;this.entitiesChanged=new n;this.selectionChanged=new n}addPin(t,i=false){if(this.entities[t.id]==null){this.entities={...this.entities,[t.id]:t};if(!i){this.entitiesChanged.emit(this.getPins());this.entityAdded.emit(t)}return true}else{return false}}clearPins(){this.getPins().forEach((t=>this.removePin(t)))}getPins(){return Object.keys(this.entities).map((t=>this.entities[t]))}getPinById(t){return this.entities[t]}getSelectedPinId(){return this.selectedPinId}removePin(t){if(this.entities[t.id]!=null){delete this.entities[t.id];this.entitiesChanged.emit(this.getPins());return true}else{return false}}setPins(t){this.clearPins();t.forEach((t=>this.addPin(t,true)));this.entitiesChanged.emit(this.getPins());return true}setPin(t){const i=this.entities[t.id]==null;this.entities={...this.entities,[t.id]:t};this.entitiesChanged.emit(this.getPins());if(i){this.entityAdded.emit(t)}return true}updatePin(t){const i=this.getPinById(t.id);if(i!=null){this.entities={...this.entities,[t.id]:t};this.entitiesChanged.emit(this.getPins());this.entityUpdated.emit(t);return true}return false}onEntitiesChanged(t){return this.entitiesChanged.on(t)}onEntityAdded(t){return this.entityAdded.on(t)}onEntityUpdated(t){return this.entityUpdated.on(t)}onSelectionChange(t){return this.selectionChanged.on(t)}setSelectedPin(t){this.selectedPinId=t;this.selectionChanged.emit(this.selectedPinId)}}export{v as P,r as a,u as b,h as c,c as g,d as i,l as t};
//# sourceMappingURL=p-ND6l6nAr.js.map